@douyinfe/semi-ui 2.5.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/index.tsx +1 -1
- package/calendar/monthCalendar.tsx +14 -13
- package/cascader/index.tsx +21 -3
- package/cascader/item.tsx +25 -5
- package/datePicker/dateInput.tsx +8 -5
- package/datePicker/datePicker.tsx +6 -1
- package/datePicker/month.tsx +14 -7
- package/datePicker/monthsGrid.tsx +17 -5
- package/datePicker/navigation.tsx +8 -4
- package/datePicker/quickControl.tsx +1 -0
- package/datePicker/yearAndMonth.tsx +1 -1
- package/dist/css/semi.css +22 -8
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +259 -104
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/form/__test__/formApi.test.js +182 -0
- package/form/_story/FormApi/arrayDemo.jsx +4 -7
- package/form/_story/Layout/slotDemo.jsx +2 -2
- package/form/_story/demo.jsx +18 -1
- package/form/_story/form.stories.js +6 -6
- package/form/baseForm.tsx +2 -2
- package/form/hoc/withField.tsx +1 -1
- package/lib/cjs/_base/base.css +5 -5
- package/lib/cjs/button/Button.d.ts +4 -4
- package/lib/cjs/button/buttonGroup.d.ts +2 -2
- package/lib/cjs/button/index.d.ts +5 -6
- package/lib/cjs/calendar/monthCalendar.js +21 -5
- package/lib/cjs/cascader/index.d.ts +9 -2
- package/lib/cjs/cascader/index.js +14 -1
- package/lib/cjs/cascader/item.d.ts +6 -2
- package/lib/cjs/cascader/item.js +33 -4
- package/lib/cjs/datePicker/dateInput.d.ts +0 -2
- package/lib/cjs/datePicker/dateInput.js +17 -6
- package/lib/cjs/datePicker/datePicker.js +15 -12
- package/lib/cjs/datePicker/month.d.ts +1 -0
- package/lib/cjs/datePicker/month.js +18 -2
- package/lib/cjs/datePicker/monthsGrid.js +16 -4
- package/lib/cjs/datePicker/navigation.js +8 -0
- package/lib/cjs/datePicker/quickControl.js +1 -0
- package/lib/cjs/datePicker/yearAndMonth.js +1 -0
- package/lib/cjs/form/baseForm.js +2 -2
- package/lib/cjs/form/hoc/withField.js +1 -1
- package/lib/cjs/iconButton/index.d.ts +2 -2
- package/lib/cjs/navigation/Item.d.ts +2 -2
- package/lib/cjs/navigation/Item.js +8 -6
- package/lib/cjs/navigation/SubNav.js +2 -2
- package/lib/cjs/scrollList/scrollItem.d.ts +2 -1
- package/lib/cjs/scrollList/scrollItem.js +13 -3
- package/lib/cjs/table/Body/index.d.ts +2 -0
- package/lib/cjs/table/Body/index.js +13 -4
- package/lib/cjs/tooltip/index.js +6 -2
- package/lib/es/_base/base.css +5 -5
- package/lib/es/button/Button.d.ts +4 -4
- package/lib/es/button/buttonGroup.d.ts +2 -2
- package/lib/es/button/index.d.ts +5 -6
- package/lib/es/calendar/monthCalendar.js +22 -5
- package/lib/es/cascader/index.d.ts +9 -2
- package/lib/es/cascader/index.js +14 -1
- package/lib/es/cascader/item.d.ts +6 -2
- package/lib/es/cascader/item.js +31 -4
- package/lib/es/datePicker/dateInput.d.ts +0 -2
- package/lib/es/datePicker/dateInput.js +17 -6
- package/lib/es/datePicker/datePicker.js +15 -12
- package/lib/es/datePicker/month.d.ts +1 -0
- package/lib/es/datePicker/month.js +18 -2
- package/lib/es/datePicker/monthsGrid.js +16 -4
- package/lib/es/datePicker/navigation.js +8 -0
- package/lib/es/datePicker/quickControl.js +2 -0
- package/lib/es/datePicker/yearAndMonth.js +1 -0
- package/lib/es/form/baseForm.js +2 -2
- package/lib/es/form/hoc/withField.js +1 -1
- package/lib/es/iconButton/index.d.ts +2 -2
- package/lib/es/navigation/Item.d.ts +2 -2
- package/lib/es/navigation/Item.js +8 -6
- package/lib/es/navigation/SubNav.js +2 -2
- package/lib/es/scrollList/scrollItem.d.ts +2 -1
- package/lib/es/scrollList/scrollItem.js +13 -3
- package/lib/es/table/Body/index.d.ts +2 -0
- package/lib/es/table/Body/index.js +13 -4
- package/lib/es/tooltip/index.js +6 -2
- package/navigation/Item.tsx +15 -12
- package/navigation/SubNav.tsx +4 -4
- package/package.json +9 -9
- package/scrollList/_story/ScrollList/index.js +3 -0
- package/scrollList/_story/WheelList/index.js +3 -0
- package/scrollList/scrollItem.tsx +30 -9
- package/table/Body/index.tsx +15 -4
- package/table/__test__/table.test.js +18 -0
- package/table/_story/Perf/Virtualized/index.jsx +6 -0
- package/table/_story/v2/FixedExpandedRow/index.jsx +95 -0
- package/table/_story/v2/FixedHeaderMerge/index.jsx +1 -1
- package/table/_story/v2/defaultFilteredValue.tsx +0 -9
- package/table/_story/v2/index.js +2 -1
- package/tooltip/_story/tooltip.stories.js +702 -625
- package/tooltip/index.tsx +2 -2
|
@@ -6,6 +6,8 @@ import _trimInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instanc
|
|
|
6
6
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
7
7
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
8
8
|
|
|
9
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-noninteractive-element-interactions */
|
|
10
|
+
|
|
9
11
|
/* eslint-disable max-len */
|
|
10
12
|
import React from 'react';
|
|
11
13
|
import classNames from 'classnames';
|
|
@@ -328,8 +330,10 @@ export default class Month extends BaseComponent {
|
|
|
328
330
|
const weekdaysText = _mapInstanceProperty(weekdays).call(weekdays, key => locale.weeks[key]);
|
|
329
331
|
|
|
330
332
|
return /*#__PURE__*/React.createElement("div", {
|
|
333
|
+
role: "row",
|
|
331
334
|
className: weekdayCls
|
|
332
335
|
}, _mapInstanceProperty(weekdaysText).call(weekdaysText, (E, i) => /*#__PURE__*/React.createElement("div", {
|
|
336
|
+
role: "columnheader",
|
|
333
337
|
key: E + i,
|
|
334
338
|
className: weekdayItemCls
|
|
335
339
|
}, E)));
|
|
@@ -364,6 +368,7 @@ export default class Month extends BaseComponent {
|
|
|
364
368
|
renderWeek(week, weekIndex) {
|
|
365
369
|
const weekCls = cssClasses.WEEK;
|
|
366
370
|
return /*#__PURE__*/React.createElement("div", {
|
|
371
|
+
role: "row",
|
|
367
372
|
className: weekCls,
|
|
368
373
|
key: weekIndex
|
|
369
374
|
}, _mapInstanceProperty(week).call(week, (day, dayIndex) => this.renderDay(day, dayIndex)));
|
|
@@ -384,6 +389,8 @@ export default class Month extends BaseComponent {
|
|
|
384
389
|
|
|
385
390
|
if (!fullDate) {
|
|
386
391
|
return /*#__PURE__*/React.createElement("div", {
|
|
392
|
+
role: "gridcell",
|
|
393
|
+
tabIndex: -1,
|
|
387
394
|
key: dayNumber + dayIndex,
|
|
388
395
|
className: cssClasses.DAY
|
|
389
396
|
}, /*#__PURE__*/React.createElement("span", null));
|
|
@@ -421,6 +428,11 @@ export default class Month extends BaseComponent {
|
|
|
421
428
|
const customRender = _isFunction(renderFullDate);
|
|
422
429
|
|
|
423
430
|
return /*#__PURE__*/React.createElement("div", {
|
|
431
|
+
role: "gridcell",
|
|
432
|
+
tabIndex: dayStatus.isDisabled ? -1 : 0,
|
|
433
|
+
"aria-disabled": dayStatus.isDisabled,
|
|
434
|
+
"aria-selected": dayStatus.isSelected,
|
|
435
|
+
"aria-label": fullDate,
|
|
424
436
|
className: !customRender ? dayCls : cssClasses.DAY,
|
|
425
437
|
title: fullDate,
|
|
426
438
|
key: dayNumber + dayIndex,
|
|
@@ -434,13 +446,16 @@ export default class Month extends BaseComponent {
|
|
|
434
446
|
|
|
435
447
|
render() {
|
|
436
448
|
const {
|
|
437
|
-
forwardRef
|
|
449
|
+
forwardRef,
|
|
450
|
+
multiple
|
|
438
451
|
} = this.props;
|
|
439
452
|
const weekday = this.renderDayOfWeek();
|
|
440
453
|
const weeks = this.renderWeeks();
|
|
441
454
|
const monthCls = classNames(cssClasses.MONTH);
|
|
442
455
|
const ref = forwardRef || this.monthRef;
|
|
443
456
|
return /*#__PURE__*/React.createElement("div", {
|
|
457
|
+
role: "grid",
|
|
458
|
+
"aria-multiselectable": multiple,
|
|
444
459
|
ref: ref,
|
|
445
460
|
className: monthCls
|
|
446
461
|
}, weekday, weeks);
|
|
@@ -466,7 +481,8 @@ Month.propTypes = {
|
|
|
466
481
|
startDateOffset: PropTypes.func,
|
|
467
482
|
endDateOffset: PropTypes.func,
|
|
468
483
|
rangeInputFocus: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]),
|
|
469
|
-
focusRecordsRef: PropTypes.object
|
|
484
|
+
focusRecordsRef: PropTypes.object,
|
|
485
|
+
multiple: PropTypes.bool
|
|
470
486
|
};
|
|
471
487
|
Month.defaultProps = {
|
|
472
488
|
month: new Date(),
|
|
@@ -7,6 +7,8 @@ import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign"
|
|
|
7
7
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
8
8
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
9
9
|
|
|
10
|
+
/* eslint-disable jsx-a11y/interactive-supports-focus,jsx-a11y/click-events-have-key-events */
|
|
11
|
+
|
|
10
12
|
/* eslint-disable react/no-did-update-set-state */
|
|
11
13
|
|
|
12
14
|
/* eslint-disable max-len */
|
|
@@ -362,7 +364,8 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
362
364
|
endDateOffset,
|
|
363
365
|
density,
|
|
364
366
|
rangeInputFocus,
|
|
365
|
-
syncSwitchMonth
|
|
367
|
+
syncSwitchMonth,
|
|
368
|
+
multiple
|
|
366
369
|
} = this.props;
|
|
367
370
|
let monthText = ''; // i18n monthText
|
|
368
371
|
|
|
@@ -428,7 +431,8 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
428
431
|
onWeeksRowNumChange: weeksRowNum => this.handleWeeksRowNumChange(weeksRowNum, panelType),
|
|
429
432
|
startDateOffset: startDateOffset,
|
|
430
433
|
endDateOffset: endDateOffset,
|
|
431
|
-
focusRecordsRef: this.props.focusRecordsRef
|
|
434
|
+
focusRecordsRef: this.props.focusRecordsRef,
|
|
435
|
+
multiple: multiple
|
|
432
436
|
}));
|
|
433
437
|
}
|
|
434
438
|
|
|
@@ -584,14 +588,22 @@ export default class MonthsGrid extends BaseComponent {
|
|
|
584
588
|
className: switchCls,
|
|
585
589
|
ref: current => this.adapter.setCache("switch-".concat(panelType), current)
|
|
586
590
|
}, /*#__PURE__*/React.createElement("div", {
|
|
591
|
+
role: "button",
|
|
592
|
+
"aria-label": "Switch to date panel",
|
|
587
593
|
className: dateCls,
|
|
588
594
|
onClick: e => this.foundation.showDatePanel(panelType)
|
|
589
|
-
}, showSwithIcon && /*#__PURE__*/React.createElement(IconCalendar,
|
|
595
|
+
}, showSwithIcon && /*#__PURE__*/React.createElement(IconCalendar, {
|
|
596
|
+
"aria-hidden": true
|
|
597
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
590
598
|
className: textCls
|
|
591
599
|
}, dateText || monthText)), /*#__PURE__*/React.createElement("div", {
|
|
600
|
+
role: "button",
|
|
601
|
+
"aria-label": "Switch to time panel",
|
|
592
602
|
className: timeCls,
|
|
593
603
|
onClick: e => this.foundation.showTimePicker(panelType, true)
|
|
594
|
-
}, showSwithIcon && /*#__PURE__*/React.createElement(IconClock,
|
|
604
|
+
}, showSwithIcon && /*#__PURE__*/React.createElement(IconClock, {
|
|
605
|
+
"aria-hidden": true
|
|
606
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
595
607
|
className: textCls
|
|
596
608
|
}, timeText)));
|
|
597
609
|
}
|
|
@@ -54,7 +54,9 @@ export default class Navigation extends PureComponent {
|
|
|
54
54
|
ref: ref
|
|
55
55
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
56
56
|
key: "double-chevron-left",
|
|
57
|
+
"aria-label": "Previous year",
|
|
57
58
|
icon: /*#__PURE__*/React.createElement(IconDoubleChevronLeft, {
|
|
59
|
+
"aria-hidden": true,
|
|
58
60
|
size: iconBtnSize
|
|
59
61
|
}),
|
|
60
62
|
size: buttonSize,
|
|
@@ -64,7 +66,9 @@ export default class Navigation extends PureComponent {
|
|
|
64
66
|
style: leftButtonStyle
|
|
65
67
|
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
66
68
|
key: "chevron-left",
|
|
69
|
+
"aria-label": "Previous month",
|
|
67
70
|
icon: /*#__PURE__*/React.createElement(IconChevronLeft, {
|
|
71
|
+
"aria-hidden": true,
|
|
68
72
|
size: iconBtnSize
|
|
69
73
|
}),
|
|
70
74
|
size: buttonSize,
|
|
@@ -80,7 +84,9 @@ export default class Navigation extends PureComponent {
|
|
|
80
84
|
size: buttonSize
|
|
81
85
|
}, /*#__PURE__*/React.createElement("span", null, monthText))), /*#__PURE__*/React.createElement(IconButton, {
|
|
82
86
|
key: "chevron-right",
|
|
87
|
+
"aria-label": "Next month",
|
|
83
88
|
icon: /*#__PURE__*/React.createElement(IconChevronRight, {
|
|
89
|
+
"aria-hidden": true,
|
|
84
90
|
size: iconBtnSize
|
|
85
91
|
}),
|
|
86
92
|
size: buttonSize,
|
|
@@ -90,7 +96,9 @@ export default class Navigation extends PureComponent {
|
|
|
90
96
|
style: rightButtonStyle
|
|
91
97
|
}), /*#__PURE__*/React.createElement(IconButton, {
|
|
92
98
|
key: "double-chevron-right",
|
|
99
|
+
"aria-label": "Next year",
|
|
93
100
|
icon: /*#__PURE__*/React.createElement(IconDoubleChevronRight, {
|
|
101
|
+
"aria-hidden": true,
|
|
94
102
|
size: iconBtnSize
|
|
95
103
|
}),
|
|
96
104
|
size: buttonSize,
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
2
2
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
3
|
+
|
|
4
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions,jsx-a11y/click-events-have-key-events */
|
|
3
5
|
import React, { PureComponent } from 'react';
|
|
4
6
|
import classNames from 'classnames';
|
|
5
7
|
import PropTypes from 'prop-types';
|
|
@@ -222,6 +222,7 @@ class YearAndMonth extends BaseComponent {
|
|
|
222
222
|
}, /*#__PURE__*/React.createElement(IconButton, {
|
|
223
223
|
noHorizontalPadding: false,
|
|
224
224
|
icon: /*#__PURE__*/React.createElement(IconChevronLeft, {
|
|
225
|
+
"aria-hidden": true,
|
|
225
226
|
size: iconSize
|
|
226
227
|
}),
|
|
227
228
|
size: buttonSize,
|
package/lib/es/form/baseForm.js
CHANGED
|
@@ -77,8 +77,8 @@ class Form extends BaseComponent {
|
|
|
77
77
|
notifySubmitFail: (errors, values) => {
|
|
78
78
|
this.props.onSubmitFail(errors, values);
|
|
79
79
|
},
|
|
80
|
-
forceUpdate:
|
|
81
|
-
this.forceUpdate();
|
|
80
|
+
forceUpdate: callback => {
|
|
81
|
+
this.forceUpdate(callback);
|
|
82
82
|
},
|
|
83
83
|
notifyChange: formState => {
|
|
84
84
|
this.props.onChange(formState);
|
|
@@ -19,7 +19,7 @@ export interface IconButtonProps extends ButtonProps {
|
|
|
19
19
|
}
|
|
20
20
|
declare class IconButton extends PureComponent<IconButtonProps> {
|
|
21
21
|
static defaultProps: {
|
|
22
|
-
iconPosition:
|
|
22
|
+
iconPosition: "left";
|
|
23
23
|
prefixCls: string;
|
|
24
24
|
loading: boolean;
|
|
25
25
|
noHorizontalPadding: boolean;
|
|
@@ -36,7 +36,7 @@ declare class IconButton extends PureComponent<IconButtonProps> {
|
|
|
36
36
|
noHorizontalPadding: PropTypes.Requireable<string | boolean | any[]>;
|
|
37
37
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
38
38
|
theme: PropTypes.Requireable<string>;
|
|
39
|
-
iconPosition: PropTypes.Requireable<
|
|
39
|
+
iconPosition: PropTypes.Requireable<"left" | "right">;
|
|
40
40
|
className: PropTypes.Requireable<string>;
|
|
41
41
|
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
42
42
|
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import ItemFoundation, { ItemProps, SelectedItemProps
|
|
4
|
+
import ItemFoundation, { ItemAdapter, ItemProps, SelectedItemProps } from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
|
|
5
5
|
export interface NavItemProps extends ItemProps, BaseProps {
|
|
6
6
|
children?: React.ReactNode;
|
|
7
7
|
disabled?: boolean;
|
|
@@ -63,7 +63,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
63
63
|
constructor(props: NavItemProps);
|
|
64
64
|
_invokeContextFunc(funcName: string, ...args: any[]): any;
|
|
65
65
|
get adapter(): ItemAdapter<NavItemProps, NavItemState>;
|
|
66
|
-
renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean): JSX.Element;
|
|
66
|
+
renderIcon(icon: React.ReactNode, pos: string, isToggleIcon?: boolean, key?: number | string): JSX.Element;
|
|
67
67
|
setItemRef: (ref: HTMLLIElement) => void;
|
|
68
68
|
wrapTooltip: (node: React.ReactNode) => JSX.Element;
|
|
69
69
|
handleClick: (e: React.MouseEvent) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _noop from "lodash/noop";
|
|
2
1
|
import _times from "lodash/times";
|
|
2
|
+
import _noop from "lodash/noop";
|
|
3
3
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
4
4
|
import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
|
|
5
5
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
@@ -14,7 +14,7 @@ import cls from 'classnames';
|
|
|
14
14
|
import isNullOrUndefined from '@douyinfe/semi-foundation/lib/es/utils/isNullOrUndefined';
|
|
15
15
|
import { cloneDeep, isSemiIcon } from '../_utils';
|
|
16
16
|
import ItemFoundation from '@douyinfe/semi-foundation/lib/es/navigation/itemFoundation';
|
|
17
|
-
import {
|
|
17
|
+
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/navigation/constants';
|
|
18
18
|
import Tooltip from '../tooltip';
|
|
19
19
|
import NavContext from './nav-context';
|
|
20
20
|
import Dropdown from '../dropdown';
|
|
@@ -118,6 +118,7 @@ export default class NavItem extends BaseComponent {
|
|
|
118
118
|
var _context3;
|
|
119
119
|
|
|
120
120
|
let isToggleIcon = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
121
|
+
let key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
121
122
|
|
|
122
123
|
if (this.props.isSubNav) {
|
|
123
124
|
return null;
|
|
@@ -138,7 +139,8 @@ export default class NavItem extends BaseComponent {
|
|
|
138
139
|
["".concat(clsPrefix, "-icon-info")]: !isToggleIcon
|
|
139
140
|
});
|
|
140
141
|
return /*#__PURE__*/React.createElement("i", {
|
|
141
|
-
className: className
|
|
142
|
+
className: className,
|
|
143
|
+
key: key
|
|
142
144
|
}, isSemiIcon(icon) ? /*#__PURE__*/React.cloneElement(icon, {
|
|
143
145
|
size: icon.props.size || iconSize
|
|
144
146
|
}) : icon);
|
|
@@ -178,12 +180,12 @@ export default class NavItem extends BaseComponent {
|
|
|
178
180
|
|
|
179
181
|
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
180
182
|
const iconAmount = icon && !indent ? level : level - 1;
|
|
181
|
-
placeholderIcons = _times(iconAmount,
|
|
183
|
+
placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, index));
|
|
182
184
|
}
|
|
183
185
|
|
|
184
|
-
itemChildren = /*#__PURE__*/React.createElement(React.Fragment, null, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true), icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT) : null, !isNullOrUndefined(text) ? /*#__PURE__*/React.createElement("span", {
|
|
186
|
+
itemChildren = /*#__PURE__*/React.createElement(React.Fragment, null, placeholderIcons, this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'), icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, 'key-position-left') : null, !isNullOrUndefined(text) ? /*#__PURE__*/React.createElement("span", {
|
|
185
187
|
className: "".concat(cssClasses.PREFIX, "-item-text")
|
|
186
|
-
}, text) : '', this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true));
|
|
188
|
+
}, text) : '', this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right'));
|
|
187
189
|
}
|
|
188
190
|
|
|
189
191
|
if (typeof link === 'string') {
|
|
@@ -203,7 +203,7 @@ export default class SubNav extends BaseComponent {
|
|
|
203
203
|
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
204
204
|
/* Different icons' amount means different indents.*/
|
|
205
205
|
const iconAmount = icon && !indent ? level : level - 1;
|
|
206
|
-
placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false,
|
|
206
|
+
placeholderIcons = _times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, false, index));
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
const titleDiv = /*#__PURE__*/React.createElement("div", {
|
|
@@ -215,7 +215,7 @@ export default class SubNav extends BaseComponent {
|
|
|
215
215
|
onKeyPress: this.handleKeyPress
|
|
216
216
|
}, /*#__PURE__*/React.createElement("div", {
|
|
217
217
|
className: "".concat(prefixCls, "-item-inner")
|
|
218
|
-
}, 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,
|
|
218
|
+
}, 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", {
|
|
219
219
|
className: "".concat(prefixCls, "-item-text")
|
|
220
220
|
}, text), this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')));
|
|
221
221
|
return titleDiv;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { AriaAttributes } from 'react';
|
|
2
2
|
import BaseComponent from '../_base/baseComponent';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { Item, ScrollItemAdapter } from '@douyinfe/semi-foundation/lib/es/scrollList/itemFoundation';
|
|
@@ -18,6 +18,7 @@ export interface ScrollItemProps<T extends Item> {
|
|
|
18
18
|
motion?: Motion;
|
|
19
19
|
style?: React.CSSProperties;
|
|
20
20
|
type?: string | number;
|
|
21
|
+
'aria-label'?: AriaAttributes['aria-label'];
|
|
21
22
|
}
|
|
22
23
|
export interface ScrollItemState {
|
|
23
24
|
prependCount: number;
|
|
@@ -274,13 +274,14 @@ export default class ScrollItem extends BaseComponent {
|
|
|
274
274
|
transform: itemTrans
|
|
275
275
|
} = item;
|
|
276
276
|
const transform = typeof itemTrans === 'function' ? itemTrans : commonTrans;
|
|
277
|
+
const selected = selectedIndex === index;
|
|
277
278
|
const cls = classnames({
|
|
278
|
-
["".concat(cssClasses.PREFIX, "-item-sel")]:
|
|
279
|
+
["".concat(cssClasses.PREFIX, "-item-sel")]: selected && mode !== wheelMode,
|
|
279
280
|
["".concat(cssClasses.PREFIX, "-item-disabled")]: Boolean(item.disabled)
|
|
280
281
|
});
|
|
281
282
|
let text = '';
|
|
282
283
|
|
|
283
|
-
if (
|
|
284
|
+
if (selected) {
|
|
284
285
|
if (typeof transform === 'function') {
|
|
285
286
|
text = transform(item.value, item.text);
|
|
286
287
|
} else {
|
|
@@ -304,7 +305,10 @@ export default class ScrollItem extends BaseComponent {
|
|
|
304
305
|
React.createElement("li", _Object$assign({
|
|
305
306
|
key: prefixKey + index
|
|
306
307
|
}, events, {
|
|
307
|
-
className: cls
|
|
308
|
+
className: cls,
|
|
309
|
+
role: "option",
|
|
310
|
+
"aria-selected": selected,
|
|
311
|
+
"aria-disabled": item.disabled
|
|
308
312
|
}), text)
|
|
309
313
|
);
|
|
310
314
|
});
|
|
@@ -323,6 +327,9 @@ export default class ScrollItem extends BaseComponent {
|
|
|
323
327
|
className: wrapperCls,
|
|
324
328
|
ref: this._cacheWrapperNode
|
|
325
329
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
330
|
+
role: "listbox",
|
|
331
|
+
"aria-multiselectable": false,
|
|
332
|
+
"aria-label": this.props['aria-label'],
|
|
326
333
|
ref: this._cacheListNode
|
|
327
334
|
}, inner));
|
|
328
335
|
};
|
|
@@ -380,6 +387,9 @@ export default class ScrollItem extends BaseComponent {
|
|
|
380
387
|
ref: this._cacheWrapperNode,
|
|
381
388
|
onScroll: this.scrollToSelectItem
|
|
382
389
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
390
|
+
role: "listbox",
|
|
391
|
+
"aria-label": this.props['aria-label'],
|
|
392
|
+
"aria-multiselectable": false,
|
|
383
393
|
ref: this._cacheListNode,
|
|
384
394
|
onClick: this.clickToSelectItem
|
|
385
395
|
}, prependList, inner, appendList)));
|
|
@@ -43,6 +43,8 @@ export interface BodyState {
|
|
|
43
43
|
}
|
|
44
44
|
export interface BodyContext {
|
|
45
45
|
getVirtualizedListRef: GetVirtualizedListRef;
|
|
46
|
+
flattenedColumns: ColumnProps[];
|
|
47
|
+
getCellWidths: (flattenedColumns: ColumnProps[]) => number[];
|
|
46
48
|
}
|
|
47
49
|
declare const _default: React.ForwardRefExoticComponent<Omit<BodyProps, "forwardedRef"> & React.RefAttributes<HTMLDivElement>>;
|
|
48
50
|
export default _default;
|
|
@@ -389,8 +389,13 @@ class Body extends BaseComponent {
|
|
|
389
389
|
const {
|
|
390
390
|
flattenedColumns,
|
|
391
391
|
getCellWidths
|
|
392
|
-
} = _this.context;
|
|
393
|
-
|
|
392
|
+
} = _this.context; // we use memoized cellWidths to avoid re-render expanded row (fix #686)
|
|
393
|
+
|
|
394
|
+
if (flattenedColumns !== _this.flattenedColumns) {
|
|
395
|
+
_this.flattenedColumns = flattenedColumns;
|
|
396
|
+
_this.cellWidths = getCellWidths(flattenedColumns);
|
|
397
|
+
}
|
|
398
|
+
|
|
394
399
|
return /*#__PURE__*/React.createElement(ExpandedRow, {
|
|
395
400
|
style: style,
|
|
396
401
|
components: components,
|
|
@@ -402,7 +407,7 @@ class Body extends BaseComponent {
|
|
|
402
407
|
index: index,
|
|
403
408
|
virtualized: virtualized,
|
|
404
409
|
key: genExpandedRowKey(key),
|
|
405
|
-
cellWidths: cellWidths
|
|
410
|
+
cellWidths: _this.cellWidths
|
|
406
411
|
});
|
|
407
412
|
};
|
|
408
413
|
/**
|
|
@@ -580,7 +585,9 @@ class Body extends BaseComponent {
|
|
|
580
585
|
};
|
|
581
586
|
this.listRef = /*#__PURE__*/React.createRef();
|
|
582
587
|
const {
|
|
583
|
-
getVirtualizedListRef
|
|
588
|
+
getVirtualizedListRef,
|
|
589
|
+
flattenedColumns,
|
|
590
|
+
getCellWidths
|
|
584
591
|
} = context;
|
|
585
592
|
|
|
586
593
|
if (getVirtualizedListRef) {
|
|
@@ -592,6 +599,8 @@ class Body extends BaseComponent {
|
|
|
592
599
|
}
|
|
593
600
|
|
|
594
601
|
this.foundation = new BodyFoundation(this.adapter);
|
|
602
|
+
this.flattenedColumns = flattenedColumns;
|
|
603
|
+
this.cellWidths = getCellWidths(flattenedColumns);
|
|
595
604
|
this.observer = null;
|
|
596
605
|
}
|
|
597
606
|
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -184,7 +184,9 @@ export default class Tooltip extends BaseComponent {
|
|
|
184
184
|
} = _ref;
|
|
185
185
|
return /*#__PURE__*/React.createElement("div", _Object$assign({
|
|
186
186
|
className: classNames(className, animateCls),
|
|
187
|
-
style: _Object$assign(_Object$assign(_Object$assign({
|
|
187
|
+
style: _Object$assign(_Object$assign(_Object$assign({
|
|
188
|
+
visibility: 'visible'
|
|
189
|
+
}, animateStyle), {
|
|
188
190
|
transformOrigin
|
|
189
191
|
}), style)
|
|
190
192
|
}, portalEventSet, animateEvents, {
|
|
@@ -196,7 +198,9 @@ export default class Tooltip extends BaseComponent {
|
|
|
196
198
|
className: className
|
|
197
199
|
}, portalEventSet, {
|
|
198
200
|
"x-placement": placement,
|
|
199
|
-
style:
|
|
201
|
+
style: _Object$assign({
|
|
202
|
+
visibility: motion ? undefined : 'visible'
|
|
203
|
+
}, style)
|
|
200
204
|
}), content, icon);
|
|
201
205
|
return /*#__PURE__*/React.createElement(Portal, {
|
|
202
206
|
getPopupContainer: this.props.getPopupContainer,
|
package/navigation/Item.tsx
CHANGED
|
@@ -4,12 +4,16 @@ import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import cls from 'classnames';
|
|
7
|
-
import {
|
|
7
|
+
import { noop, times } from 'lodash';
|
|
8
8
|
|
|
9
9
|
import isNullOrUndefined from '@douyinfe/semi-foundation/utils/isNullOrUndefined';
|
|
10
10
|
import { cloneDeep, isSemiIcon } from '../_utils';
|
|
11
|
-
import ItemFoundation, {
|
|
12
|
-
|
|
11
|
+
import ItemFoundation, {
|
|
12
|
+
ItemAdapter,
|
|
13
|
+
ItemProps,
|
|
14
|
+
SelectedItemProps
|
|
15
|
+
} from '@douyinfe/semi-foundation/navigation/itemFoundation';
|
|
16
|
+
import { cssClasses, strings } from '@douyinfe/semi-foundation/navigation/constants';
|
|
13
17
|
|
|
14
18
|
import Tooltip from '../tooltip';
|
|
15
19
|
import NavContext from './nav-context';
|
|
@@ -114,7 +118,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
114
118
|
};
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
renderIcon(icon: React.ReactNode, pos: string, isToggleIcon = false) {
|
|
121
|
+
renderIcon(icon: React.ReactNode, pos: string, isToggleIcon = false, key: number | string = 0) {
|
|
118
122
|
if (this.props.isSubNav) {
|
|
119
123
|
return null;
|
|
120
124
|
}
|
|
@@ -134,8 +138,8 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
134
138
|
});
|
|
135
139
|
|
|
136
140
|
return (
|
|
137
|
-
<i className={className}>
|
|
138
|
-
{isSemiIcon(icon) ? React.cloneElement((icon as React.ReactElement), {size: (icon as React.ReactElement).props.size || iconSize}) : icon}
|
|
141
|
+
<i className={className} key={key}>
|
|
142
|
+
{isSemiIcon(icon) ? React.cloneElement((icon as React.ReactElement), { size: (icon as React.ReactElement).props.size || iconSize }) : icon}
|
|
139
143
|
</i>
|
|
140
144
|
);
|
|
141
145
|
}
|
|
@@ -189,7 +193,6 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
189
193
|
const selected = this.adapter.getSelected();
|
|
190
194
|
|
|
191
195
|
|
|
192
|
-
|
|
193
196
|
let itemChildren = null;
|
|
194
197
|
if (!isNullOrUndefined(children)) {
|
|
195
198
|
itemChildren = children;
|
|
@@ -197,15 +200,15 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
197
200
|
let placeholderIcons = null;
|
|
198
201
|
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
199
202
|
const iconAmount = (icon && !indent) ? level : level - 1;
|
|
200
|
-
placeholderIcons = times(iconAmount, () => this.renderIcon(null, strings.ICON_POS_RIGHT, false));
|
|
203
|
+
placeholderIcons = times(iconAmount, (index) => this.renderIcon(null, strings.ICON_POS_RIGHT, false, index));
|
|
201
204
|
}
|
|
202
205
|
itemChildren = (
|
|
203
206
|
<>
|
|
204
207
|
{placeholderIcons}
|
|
205
|
-
{this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true)}
|
|
206
|
-
{icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT) : null}
|
|
208
|
+
{this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right')}
|
|
209
|
+
{icon || indent || isInSubNav ? this.renderIcon(icon, strings.ICON_POS_LEFT, false, 'key-position-left') : null}
|
|
207
210
|
{!isNullOrUndefined(text) ? <span className={`${cssClasses.PREFIX}-item-text`}>{text}</span> : ''}
|
|
208
|
-
{this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true)}
|
|
211
|
+
{this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIcon, strings.ICON_POS_RIGHT, true, 'key-toggle-pos-right')}
|
|
209
212
|
</>
|
|
210
213
|
);
|
|
211
214
|
}
|
|
@@ -246,7 +249,7 @@ export default class NavItem extends BaseComponent<NavItemProps, NavItemState> {
|
|
|
246
249
|
);
|
|
247
250
|
} else {
|
|
248
251
|
// Items are divided into normal and sub-wrap
|
|
249
|
-
const popoverItemCls = cls(`${className || `${clsPrefix
|
|
252
|
+
const popoverItemCls = cls(`${className || `${clsPrefix}-normal`}`, {
|
|
250
253
|
[clsPrefix]: true,
|
|
251
254
|
[`${clsPrefix}-sub`]: isSubNav,
|
|
252
255
|
[`${clsPrefix}-selected`]: selected && !isSubNav,
|
package/navigation/SubNav.tsx
CHANGED
|
@@ -240,15 +240,15 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
|
240
240
|
if (mode === strings.MODE_VERTICAL && !limitIndent && !isCollapsed) {
|
|
241
241
|
/* Different icons' amount means different indents.*/
|
|
242
242
|
const iconAmount = (icon && !indent) ? level : level - 1;
|
|
243
|
-
placeholderIcons = times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false,
|
|
243
|
+
placeholderIcons = times(iconAmount, index => this.renderIcon(null, strings.ICON_POS_RIGHT, false, false, index));
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
const titleDiv = (
|
|
247
247
|
<div
|
|
248
248
|
role="menuitem"
|
|
249
249
|
tabIndex={-1}
|
|
250
|
-
ref={this.setTitleRef as any}
|
|
251
|
-
className={titleCls}
|
|
250
|
+
ref={this.setTitleRef as any}
|
|
251
|
+
className={titleCls}
|
|
252
252
|
onClick={this.handleClick}
|
|
253
253
|
onKeyPress={this.handleKeyPress}
|
|
254
254
|
>
|
|
@@ -256,7 +256,7 @@ export default class SubNav extends BaseComponent<SubNavProps, SubNavState> {
|
|
|
256
256
|
{placeholderIcons}
|
|
257
257
|
{this.context.toggleIconPosition === strings.TOGGLE_ICON_LEFT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-left')}
|
|
258
258
|
{icon || indent || (isInSubNav && mode !== strings.MODE_HORIZONTAL)
|
|
259
|
-
? this.renderIcon(icon, strings.ICON_POS_LEFT,
|
|
259
|
+
? this.renderIcon(icon, strings.ICON_POS_LEFT, false, false, 'key-inSubNav-position-left')
|
|
260
260
|
: null}
|
|
261
261
|
<span className={`${prefixCls}-item-text`}>{text}</span>
|
|
262
262
|
{this.context.toggleIconPosition === strings.TOGGLE_ICON_RIGHT && this.renderIcon(toggleIconType, strings.ICON_POS_RIGHT, withTransition, true, 'key-toggle-position-right')}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation": "2.
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.
|
|
20
|
-
"@douyinfe/semi-icons": "2.
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.
|
|
17
|
+
"@douyinfe/semi-animation": "2.6.0",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.6.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.6.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.6.0",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.6.0",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.6.0",
|
|
23
23
|
"@types/react-window": "^1.8.2",
|
|
24
24
|
"async-validator": "^3.5.0",
|
|
25
25
|
"classnames": "^2.2.6",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "d3a844137fb02b81a93320eb5c183636b05a4a68",
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
75
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
76
76
|
"@babel/preset-env": "^7.15.8",
|
|
77
77
|
"@babel/preset-react": "^7.14.5",
|
|
78
|
-
"@douyinfe/semi-scss-compile": "2.
|
|
78
|
+
"@douyinfe/semi-scss-compile": "2.6.0",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
|
@@ -43,6 +43,7 @@ class ScrollListDemo extends React.Component {
|
|
|
43
43
|
type={1}
|
|
44
44
|
selectedIndex={this.state.selectIndex1}
|
|
45
45
|
onSelect={this.onSelect}
|
|
46
|
+
aria-label="1"
|
|
46
47
|
/>
|
|
47
48
|
<ScrollItem
|
|
48
49
|
mode="normal"
|
|
@@ -50,6 +51,7 @@ class ScrollListDemo extends React.Component {
|
|
|
50
51
|
type={2}
|
|
51
52
|
selectedIndex={this.state.selectIndex2}
|
|
52
53
|
onSelect={this.onSelect}
|
|
54
|
+
aria-label="2"
|
|
53
55
|
/>
|
|
54
56
|
<ScrollItem
|
|
55
57
|
mode="normal"
|
|
@@ -57,6 +59,7 @@ class ScrollListDemo extends React.Component {
|
|
|
57
59
|
type={3}
|
|
58
60
|
selectedIndex={this.state.selectIndex3}
|
|
59
61
|
onSelect={this.onSelect}
|
|
62
|
+
aria-label="3"
|
|
60
63
|
/>
|
|
61
64
|
</ScrollList>
|
|
62
65
|
);
|