@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
|
@@ -418,8 +418,13 @@ class Body extends _baseComponent.default {
|
|
|
418
418
|
const {
|
|
419
419
|
flattenedColumns,
|
|
420
420
|
getCellWidths
|
|
421
|
-
} = _this.context;
|
|
422
|
-
|
|
421
|
+
} = _this.context; // we use memoized cellWidths to avoid re-render expanded row (fix #686)
|
|
422
|
+
|
|
423
|
+
if (flattenedColumns !== _this.flattenedColumns) {
|
|
424
|
+
_this.flattenedColumns = flattenedColumns;
|
|
425
|
+
_this.cellWidths = getCellWidths(flattenedColumns);
|
|
426
|
+
}
|
|
427
|
+
|
|
423
428
|
return /*#__PURE__*/_react.default.createElement(_ExpandedRow.default, {
|
|
424
429
|
style: style,
|
|
425
430
|
components: components,
|
|
@@ -431,7 +436,7 @@ class Body extends _baseComponent.default {
|
|
|
431
436
|
index: index,
|
|
432
437
|
virtualized: virtualized,
|
|
433
438
|
key: (0, _utils.genExpandedRowKey)(key),
|
|
434
|
-
cellWidths: cellWidths
|
|
439
|
+
cellWidths: _this.cellWidths
|
|
435
440
|
});
|
|
436
441
|
};
|
|
437
442
|
/**
|
|
@@ -601,7 +606,9 @@ class Body extends _baseComponent.default {
|
|
|
601
606
|
};
|
|
602
607
|
this.listRef = /*#__PURE__*/_react.default.createRef();
|
|
603
608
|
const {
|
|
604
|
-
getVirtualizedListRef
|
|
609
|
+
getVirtualizedListRef,
|
|
610
|
+
flattenedColumns,
|
|
611
|
+
getCellWidths
|
|
605
612
|
} = context;
|
|
606
613
|
|
|
607
614
|
if (getVirtualizedListRef) {
|
|
@@ -613,6 +620,8 @@ class Body extends _baseComponent.default {
|
|
|
613
620
|
}
|
|
614
621
|
|
|
615
622
|
this.foundation = new _bodyFoundation.default(this.adapter);
|
|
623
|
+
this.flattenedColumns = flattenedColumns;
|
|
624
|
+
this.cellWidths = getCellWidths(flattenedColumns);
|
|
616
625
|
this.observer = null;
|
|
617
626
|
}
|
|
618
627
|
|
package/lib/cjs/tooltip/index.js
CHANGED
|
@@ -229,7 +229,9 @@ class Tooltip extends _baseComponent.default {
|
|
|
229
229
|
} = _ref;
|
|
230
230
|
return /*#__PURE__*/_react.default.createElement("div", (0, _assign.default)({
|
|
231
231
|
className: (0, _classnames.default)(className, animateCls),
|
|
232
|
-
style: (0, _assign.default)((0, _assign.default)((0, _assign.default)({
|
|
232
|
+
style: (0, _assign.default)((0, _assign.default)((0, _assign.default)({
|
|
233
|
+
visibility: 'visible'
|
|
234
|
+
}, animateStyle), {
|
|
233
235
|
transformOrigin
|
|
234
236
|
}), style)
|
|
235
237
|
}, portalEventSet, animateEvents, {
|
|
@@ -241,7 +243,9 @@ class Tooltip extends _baseComponent.default {
|
|
|
241
243
|
className: className
|
|
242
244
|
}, portalEventSet, {
|
|
243
245
|
"x-placement": placement,
|
|
244
|
-
style:
|
|
246
|
+
style: (0, _assign.default)({
|
|
247
|
+
visibility: motion ? undefined : 'visible'
|
|
248
|
+
}, style)
|
|
245
249
|
}), content, icon);
|
|
246
250
|
return /*#__PURE__*/_react.default.createElement(_index.default, {
|
|
247
251
|
getPopupContainer: this.props.getPopupContainer,
|
package/lib/es/_base/base.css
CHANGED
|
@@ -19,7 +19,7 @@ body .semi-always-light {
|
|
|
19
19
|
--semi-blue-2: 152,205,253;
|
|
20
20
|
--semi-blue-3: 101,178,252;
|
|
21
21
|
--semi-blue-4: 50,149,251;
|
|
22
|
-
--semi-blue-5: 0,
|
|
22
|
+
--semi-blue-5: 0,100,250;
|
|
23
23
|
--semi-blue-6: 0,98,214;
|
|
24
24
|
--semi-blue-7: 0,79,179;
|
|
25
25
|
--semi-blue-8: 0,61,143;
|
|
@@ -410,7 +410,7 @@ body, body[theme-mode=dark] .semi-always-light {
|
|
|
410
410
|
--semi-color-bg-4: rgba(var(--semi-white), 1);
|
|
411
411
|
--semi-color-text-0: rgba(var(--semi-grey-9), 1);
|
|
412
412
|
--semi-color-text-1: rgba(var(--semi-grey-9), .8);
|
|
413
|
-
--semi-color-text-2: rgba(var(--semi-grey-9), .
|
|
413
|
+
--semi-color-text-2: rgba(var(--semi-grey-9), .62);
|
|
414
414
|
--semi-color-text-3: rgba(var(--semi-grey-9), .35);
|
|
415
415
|
--semi-shadow-elevated: 0 0 1px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .1);
|
|
416
416
|
--semi-border-radius-extra-small: 3px;
|
|
@@ -487,9 +487,9 @@ body[theme-mode=dark], body .semi-always-dark {
|
|
|
487
487
|
--semi-color-nav-bg: rgba(35, 36, 41, 1);
|
|
488
488
|
--semi-shadow-elevated: inset 0 0 0 1px rgba(255, 255, 255, .1), 0 4px 14px rgba(0, 0, 0, .25);
|
|
489
489
|
--semi-color-overlay-bg: rgba(22, 22, 26, .6);
|
|
490
|
-
--semi-color-fill-0: rgba(var(--semi-white), .
|
|
491
|
-
--semi-color-fill-1: rgba(var(--semi-white), .
|
|
492
|
-
--semi-color-fill-2: rgba(var(--semi-white), .
|
|
490
|
+
--semi-color-fill-0: rgba(var(--semi-white), .12);
|
|
491
|
+
--semi-color-fill-1: rgba(var(--semi-white), .16);
|
|
492
|
+
--semi-color-fill-2: rgba(var(--semi-white), .20);
|
|
493
493
|
--semi-color-border: rgba(var(--semi-white), .08);
|
|
494
494
|
--semi-color-shadow: rgba(var(--semi-black), .04);
|
|
495
495
|
--semi-color-bg-0: rgba(22, 22, 26, 1);
|
|
@@ -46,15 +46,15 @@ export default class Button extends PureComponent<ButtonProps> {
|
|
|
46
46
|
disabled: PropTypes.Requireable<boolean>;
|
|
47
47
|
prefixCls: PropTypes.Requireable<string>;
|
|
48
48
|
style: PropTypes.Requireable<object>;
|
|
49
|
-
size: PropTypes.Requireable<
|
|
50
|
-
type: PropTypes.Requireable<
|
|
49
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
50
|
+
type: PropTypes.Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
51
51
|
block: PropTypes.Requireable<boolean>;
|
|
52
52
|
onClick: PropTypes.Requireable<(...args: any[]) => any>;
|
|
53
53
|
onMouseDown: PropTypes.Requireable<(...args: any[]) => any>;
|
|
54
54
|
circle: PropTypes.Requireable<boolean>;
|
|
55
55
|
loading: PropTypes.Requireable<boolean>;
|
|
56
|
-
htmlType: PropTypes.Requireable<
|
|
57
|
-
theme: PropTypes.Requireable<
|
|
56
|
+
htmlType: PropTypes.Requireable<"button" | "reset" | "submit">;
|
|
57
|
+
theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
|
|
58
58
|
className: PropTypes.Requireable<string>;
|
|
59
59
|
onMouseEnter: PropTypes.Requireable<(...args: any[]) => any>;
|
|
60
60
|
onMouseLeave: PropTypes.Requireable<(...args: any[]) => any>;
|
|
@@ -16,8 +16,8 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
|
|
|
16
16
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
17
17
|
disabled: PropTypes.Requireable<boolean>;
|
|
18
18
|
type: PropTypes.Requireable<string>;
|
|
19
|
-
size: PropTypes.Requireable<
|
|
20
|
-
theme: PropTypes.Requireable<
|
|
19
|
+
size: PropTypes.Requireable<"default" | "small" | "large">;
|
|
20
|
+
theme: PropTypes.Requireable<"solid" | "light" | "borderless">;
|
|
21
21
|
'aria-label': PropTypes.Requireable<string>;
|
|
22
22
|
};
|
|
23
23
|
static defaultProps: {
|
package/lib/es/button/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ButtonProps as BaseButtonProps } from './Button';
|
|
3
2
|
import { IconButtonProps } from '../iconButton';
|
|
4
3
|
export { ButtonProps as BaseButtonProps, HtmlType, Size, Theme, Type } from './Button';
|
|
5
4
|
export { HorizontalPaddingType } from '../iconButton';
|
|
6
5
|
export { ButtonGroupProps } from './buttonGroup';
|
|
7
6
|
export { SplitButtonGroupProps } from './splitButtonGroup';
|
|
8
|
-
export interface ButtonProps extends IconButtonProps
|
|
7
|
+
export interface ButtonProps extends IconButtonProps {
|
|
9
8
|
}
|
|
10
9
|
declare class Button extends React.PureComponent<ButtonProps> {
|
|
11
10
|
static propTypes: {
|
|
@@ -18,18 +17,18 @@ declare class Button extends React.PureComponent<ButtonProps> {
|
|
|
18
17
|
noHorizontalPadding: import("prop-types").Requireable<string | boolean | any[]>;
|
|
19
18
|
children: import("prop-types").Requireable<import("prop-types").ReactNodeLike>;
|
|
20
19
|
theme: import("prop-types").Requireable<string>;
|
|
21
|
-
iconPosition: import("prop-types").Requireable<
|
|
20
|
+
iconPosition: import("prop-types").Requireable<"left" | "right">;
|
|
22
21
|
className: import("prop-types").Requireable<string>;
|
|
23
22
|
onMouseEnter: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
24
23
|
onMouseLeave: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
25
24
|
disabled: import("prop-types").Requireable<boolean>;
|
|
26
|
-
size: import("prop-types").Requireable<
|
|
27
|
-
type: import("prop-types").Requireable<
|
|
25
|
+
size: import("prop-types").Requireable<"default" | "small" | "large">;
|
|
26
|
+
type: import("prop-types").Requireable<"warning" | "primary" | "tertiary" | "secondary" | "danger">;
|
|
28
27
|
block: import("prop-types").Requireable<boolean>;
|
|
29
28
|
onClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
30
29
|
onMouseDown: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
31
30
|
circle: import("prop-types").Requireable<boolean>;
|
|
32
|
-
htmlType: import("prop-types").Requireable<
|
|
31
|
+
htmlType: import("prop-types").Requireable<"button" | "reset" | "submit">;
|
|
33
32
|
'aria-label': import("prop-types").Requireable<string>;
|
|
34
33
|
};
|
|
35
34
|
constructor(props?: {});
|
|
@@ -6,6 +6,8 @@ import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
|
6
6
|
import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
|
|
7
7
|
import _Map from "@babel/runtime-corejs3/core-js-stable/map";
|
|
8
8
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
9
|
+
|
|
10
|
+
/* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */
|
|
9
11
|
import React from 'react';
|
|
10
12
|
import ReactDOM from 'react-dom';
|
|
11
13
|
import cls from 'classnames';
|
|
@@ -62,11 +64,13 @@ export default class monthCalendar extends BaseComponent {
|
|
|
62
64
|
} = this.props;
|
|
63
65
|
this.monthlyData = this.foundation.getMonthlyData(displayValue, dateFnsLocale);
|
|
64
66
|
return /*#__PURE__*/React.createElement("div", {
|
|
65
|
-
className: "".concat(prefixCls, "-header")
|
|
67
|
+
className: "".concat(prefixCls, "-header"),
|
|
68
|
+
role: "presentation"
|
|
66
69
|
}, /*#__PURE__*/React.createElement("div", {
|
|
67
|
-
role: "
|
|
70
|
+
role: "presentation",
|
|
68
71
|
className: "".concat(prefixCls, "-grid")
|
|
69
72
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
73
|
+
role: "row",
|
|
70
74
|
className: "".concat(prefixCls, "-grid-row")
|
|
71
75
|
}, _mapInstanceProperty(_context = this.monthlyData[0]).call(_context, day => {
|
|
72
76
|
const {
|
|
@@ -76,6 +80,8 @@ export default class monthCalendar extends BaseComponent {
|
|
|
76
80
|
["".concat(cssClasses.PREFIX, "-weekend")]: markWeekend && day.isWeekend
|
|
77
81
|
});
|
|
78
82
|
return /*#__PURE__*/React.createElement("li", {
|
|
83
|
+
role: "columnheader",
|
|
84
|
+
"aria-label": weekday,
|
|
79
85
|
key: "".concat(weekday, "-monthheader"),
|
|
80
86
|
className: listCls
|
|
81
87
|
}, /*#__PURE__*/React.createElement("span", null, weekday));
|
|
@@ -158,7 +164,10 @@ export default class monthCalendar extends BaseComponent {
|
|
|
158
164
|
const pos = showCard && showCard[key] ? showCard[key][1] : 'leftTopOver';
|
|
159
165
|
const text = /*#__PURE__*/React.createElement(LocaleConsumer, {
|
|
160
166
|
componentName: "Calendar"
|
|
161
|
-
}, locale =>
|
|
167
|
+
}, locale =>
|
|
168
|
+
/*#__PURE__*/
|
|
169
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
170
|
+
React.createElement("div", {
|
|
162
171
|
className: "".concat(cardCls, "-wrapper"),
|
|
163
172
|
style: {
|
|
164
173
|
bottom: 0
|
|
@@ -226,11 +235,12 @@ export default class monthCalendar extends BaseComponent {
|
|
|
226
235
|
day
|
|
227
236
|
} = events;
|
|
228
237
|
return /*#__PURE__*/React.createElement("div", {
|
|
229
|
-
role: "
|
|
238
|
+
role: "presentation",
|
|
230
239
|
className: "".concat(prefixCls, "-weekrow"),
|
|
231
240
|
ref: _this.cellDom,
|
|
232
241
|
key: "".concat(index, "-weekrow")
|
|
233
242
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
243
|
+
role: "row",
|
|
234
244
|
className: "".concat(prefixCls, "-skeleton")
|
|
235
245
|
}, _mapInstanceProperty(weekDay).call(weekDay, each => {
|
|
236
246
|
const {
|
|
@@ -249,6 +259,9 @@ export default class monthCalendar extends BaseComponent {
|
|
|
249
259
|
});
|
|
250
260
|
const shouldRenderCollapsed = Boolean(day && day[ind] && day[ind].length > itemLimit);
|
|
251
261
|
const inner = /*#__PURE__*/React.createElement("li", {
|
|
262
|
+
role: "gridcell",
|
|
263
|
+
"aria-label": date.toLocaleDateString(),
|
|
264
|
+
"aria-current": isToday ? "date" : false,
|
|
252
265
|
key: "".concat(date, "-weeksk"),
|
|
253
266
|
className: listCls,
|
|
254
267
|
onClick: e => _this.handleClick(e, [date])
|
|
@@ -271,9 +284,10 @@ export default class monthCalendar extends BaseComponent {
|
|
|
271
284
|
parsedEvents
|
|
272
285
|
} = this.state;
|
|
273
286
|
return /*#__PURE__*/React.createElement("div", {
|
|
274
|
-
role: "
|
|
287
|
+
role: "presentation",
|
|
275
288
|
className: "".concat(prefixCls, "-week")
|
|
276
289
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
290
|
+
role: "presentation",
|
|
277
291
|
className: "".concat(prefixCls, "-grid-col")
|
|
278
292
|
}, _mapInstanceProperty(_context3 = _Object$keys(this.monthlyData)).call(_context3, weekInd => this.renderWeekRow(weekInd, this.monthlyData[weekInd], parsedEvents[weekInd]))));
|
|
279
293
|
};
|
|
@@ -404,12 +418,15 @@ export default class monthCalendar extends BaseComponent {
|
|
|
404
418
|
return /*#__PURE__*/React.createElement(LocaleConsumer, {
|
|
405
419
|
componentName: "Calendar"
|
|
406
420
|
}, (locale, localeCode, dateFnsLocale) => /*#__PURE__*/React.createElement("div", {
|
|
421
|
+
role: "grid",
|
|
407
422
|
className: monthCls,
|
|
408
423
|
key: this.state.itemLimit,
|
|
409
424
|
style: monthStyle
|
|
410
425
|
}, /*#__PURE__*/React.createElement("div", {
|
|
426
|
+
role: "presentation",
|
|
411
427
|
className: "".concat(prefixCls, "-sticky-top")
|
|
412
428
|
}, header, this.renderHeader(dateFnsLocale)), /*#__PURE__*/React.createElement("div", {
|
|
429
|
+
role: "presentation",
|
|
413
430
|
className: "".concat(prefixCls, "-grid-wrapper")
|
|
414
431
|
}, this.renderMonthGrid())));
|
|
415
432
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactNode, CSSProperties, MouseEvent } from 'react';
|
|
1
|
+
import React, { ReactNode, CSSProperties, MouseEvent, KeyboardEvent } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { BasicCascaderInnerData, BasicCascaderProps, BasicTriggerRenderProps, BasicScrollPanelProps, CascaderAdapter, CascaderType } from '@douyinfe/semi-foundation/lib/es/cascader/foundation';
|
|
4
4
|
import '@douyinfe/semi-foundation/lib/es/cascader/cascader.css';
|
|
@@ -24,6 +24,7 @@ export interface CascaderProps extends BasicCascaderProps {
|
|
|
24
24
|
'aria-invalid'?: React.AriaAttributes['aria-invalid'];
|
|
25
25
|
'aria-labelledby'?: React.AriaAttributes['aria-labelledby'];
|
|
26
26
|
'aria-required'?: React.AriaAttributes['aria-required'];
|
|
27
|
+
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
27
28
|
arrowIcon?: ReactNode;
|
|
28
29
|
defaultValue?: Value;
|
|
29
30
|
dropdownStyle?: CSSProperties;
|
|
@@ -65,6 +66,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
65
66
|
'aria-errormessage': PropTypes.Requireable<string>;
|
|
66
67
|
'aria-describedby': PropTypes.Requireable<string>;
|
|
67
68
|
'aria-required': PropTypes.Requireable<boolean>;
|
|
69
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
68
70
|
arrowIcon: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
69
71
|
changeOnSelect: PropTypes.Requireable<boolean>;
|
|
70
72
|
defaultValue: PropTypes.Requireable<string | any[]>;
|
|
@@ -158,6 +160,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
158
160
|
onDropdownVisibleChange: (...args: any[]) => void;
|
|
159
161
|
onListScroll: (...args: any[]) => void;
|
|
160
162
|
enableLeafClick: boolean;
|
|
163
|
+
'aria-label': string;
|
|
161
164
|
};
|
|
162
165
|
options: any;
|
|
163
166
|
isEmpty: boolean;
|
|
@@ -177,7 +180,7 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
177
180
|
renderTagItem: (value: string | Array<string>, idx: number, type: string) => React.ReactNode;
|
|
178
181
|
renderTagInput(): JSX.Element;
|
|
179
182
|
renderInput(): JSX.Element;
|
|
180
|
-
handleItemClick: (e: MouseEvent, item: Entity | Data) => void;
|
|
183
|
+
handleItemClick: (e: MouseEvent | KeyboardEvent, item: Entity | Data) => void;
|
|
181
184
|
handleItemHover: (e: MouseEvent, item: Entity) => void;
|
|
182
185
|
onItemCheckboxClick: (item: Entity | Data) => void;
|
|
183
186
|
handleListScroll: (e: React.UIEvent<HTMLUListElement, UIEvent>, ind: number) => void;
|
|
@@ -191,6 +194,10 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
191
194
|
handleMouseOver: () => void;
|
|
192
195
|
handleMouseLeave: () => void;
|
|
193
196
|
handleClear: (e: MouseEvent) => void;
|
|
197
|
+
/**
|
|
198
|
+
* A11y: simulate clear button click
|
|
199
|
+
*/
|
|
200
|
+
handleClearEnterPress: (e: KeyboardEvent) => void;
|
|
194
201
|
showClearBtn: () => boolean;
|
|
195
202
|
renderClearBtn: () => JSX.Element;
|
|
196
203
|
renderArrow: () => JSX.Element;
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -330,6 +330,15 @@ class Cascader extends BaseComponent {
|
|
|
330
330
|
e && e.stopPropagation();
|
|
331
331
|
this.foundation.handleClear();
|
|
332
332
|
};
|
|
333
|
+
/**
|
|
334
|
+
* A11y: simulate clear button click
|
|
335
|
+
*/
|
|
336
|
+
|
|
337
|
+
|
|
338
|
+
this.handleClearEnterPress = e => {
|
|
339
|
+
e && e.stopPropagation();
|
|
340
|
+
this.foundation.handleClearEnterPress();
|
|
341
|
+
};
|
|
333
342
|
|
|
334
343
|
this.showClearBtn = () => {
|
|
335
344
|
const {
|
|
@@ -356,6 +365,7 @@ class Cascader extends BaseComponent {
|
|
|
356
365
|
return /*#__PURE__*/React.createElement("div", {
|
|
357
366
|
className: clearCls,
|
|
358
367
|
onClick: this.handleClear,
|
|
368
|
+
onKeyPress: this.handleClearEnterPress,
|
|
359
369
|
role: 'button',
|
|
360
370
|
tabIndex: 0
|
|
361
371
|
}, /*#__PURE__*/React.createElement(IconClear, null));
|
|
@@ -445,6 +455,7 @@ class Cascader extends BaseComponent {
|
|
|
445
455
|
style: style,
|
|
446
456
|
ref: this.triggerRef,
|
|
447
457
|
onClick: e => this.foundation.handleClick(e),
|
|
458
|
+
onKeyPress: e => this.foundation.handleSelectionEnterPress(e),
|
|
448
459
|
"aria-invalid": this.props['aria-invalid'],
|
|
449
460
|
"aria-errormessage": this.props['aria-errormessage'],
|
|
450
461
|
"aria-label": this.props['aria-label'],
|
|
@@ -887,6 +898,7 @@ Cascader.propTypes = {
|
|
|
887
898
|
'aria-errormessage': PropTypes.string,
|
|
888
899
|
'aria-describedby': PropTypes.string,
|
|
889
900
|
'aria-required': PropTypes.bool,
|
|
901
|
+
'aria-label': PropTypes.string,
|
|
890
902
|
arrowIcon: PropTypes.node,
|
|
891
903
|
changeOnSelect: PropTypes.bool,
|
|
892
904
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
@@ -981,6 +993,7 @@ Cascader.defaultProps = {
|
|
|
981
993
|
onClear: _noop,
|
|
982
994
|
onDropdownVisibleChange: _noop,
|
|
983
995
|
onListScroll: _noop,
|
|
984
|
-
enableLeafClick: false
|
|
996
|
+
enableLeafClick: false,
|
|
997
|
+
'aria-label': 'Cascader'
|
|
985
998
|
};
|
|
986
999
|
export default Cascader;
|
|
@@ -22,7 +22,7 @@ export interface CascaderItemProps {
|
|
|
22
22
|
selectedKeys: Set<string>;
|
|
23
23
|
loadedKeys: Set<string>;
|
|
24
24
|
loadingKeys: Set<string>;
|
|
25
|
-
onItemClick: (e: React.MouseEvent, item: Entity | Data) => void;
|
|
25
|
+
onItemClick: (e: React.MouseEvent | React.KeyboardEvent, item: Entity | Data) => void;
|
|
26
26
|
onItemHover: (e: React.MouseEvent, item: Entity) => void;
|
|
27
27
|
showNext: ShowNextType;
|
|
28
28
|
onItemCheckboxClick: (item: Entity | Data) => void;
|
|
@@ -57,7 +57,11 @@ export default class Item extends PureComponent<CascaderItemProps> {
|
|
|
57
57
|
static defaultProps: {
|
|
58
58
|
empty: boolean;
|
|
59
59
|
};
|
|
60
|
-
onClick: (e: React.MouseEvent, item: Entity | Data) => void;
|
|
60
|
+
onClick: (e: React.MouseEvent | React.KeyboardEvent, item: Entity | Data) => void;
|
|
61
|
+
/**
|
|
62
|
+
* A11y: simulate item click
|
|
63
|
+
*/
|
|
64
|
+
handleItemEnterPress: (keyboardEvent: React.KeyboardEvent, item: Entity | Data) => void;
|
|
61
65
|
onHover: (e: React.MouseEvent, item: Entity) => void;
|
|
62
66
|
onCheckboxChange: (e: CheckboxEvent, item: Entity | Data) => void;
|
|
63
67
|
getItemStatus: (key: string) => {
|
package/lib/es/cascader/item.js
CHANGED
|
@@ -2,10 +2,12 @@ import _includes from "lodash/includes";
|
|
|
2
2
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
3
3
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
4
4
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
5
|
+
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
5
6
|
import React, { PureComponent } from 'react';
|
|
6
7
|
import cls from 'classnames';
|
|
7
8
|
import PropTypes from 'prop-types';
|
|
8
9
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/cascader/constants';
|
|
10
|
+
import isEnterPress from '@douyinfe/semi-foundation/lib/es/utils/isEnterPress';
|
|
9
11
|
import ConfigContext from '../configProvider/context';
|
|
10
12
|
import LocaleConsumer from '../locale/localeConsumer';
|
|
11
13
|
import { IconChevronRight, IconTick } from '@douyinfe/semi-icons';
|
|
@@ -27,6 +29,16 @@ export default class Item extends PureComponent {
|
|
|
27
29
|
|
|
28
30
|
onItemClick(e, item);
|
|
29
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* A11y: simulate item click
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
this.handleItemEnterPress = (keyboardEvent, item) => {
|
|
38
|
+
if (isEnterPress(keyboardEvent)) {
|
|
39
|
+
this.onClick(keyboardEvent, item);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
30
42
|
|
|
31
43
|
this.onHover = (e, item) => {
|
|
32
44
|
const {
|
|
@@ -106,6 +118,7 @@ export default class Item extends PureComponent {
|
|
|
106
118
|
|
|
107
119
|
case 'empty':
|
|
108
120
|
return /*#__PURE__*/React.createElement("span", {
|
|
121
|
+
"aria-hidden": true,
|
|
109
122
|
className: _concatInstanceProperty(_context3 = "".concat(prefixcls, "-icon ")).call(_context3, prefixcls, "-icon-empty")
|
|
110
123
|
});
|
|
111
124
|
|
|
@@ -169,11 +182,13 @@ export default class Item extends PureComponent {
|
|
|
169
182
|
["".concat(prefixcls, "-disabled")]: disabled
|
|
170
183
|
});
|
|
171
184
|
return /*#__PURE__*/React.createElement("li", {
|
|
185
|
+
role: 'menuitem',
|
|
172
186
|
className: className,
|
|
173
187
|
key: key,
|
|
174
188
|
onClick: e => {
|
|
175
189
|
this.onClick(e, item);
|
|
176
|
-
}
|
|
190
|
+
},
|
|
191
|
+
onKeyPress: e => this.handleItemEnterPress(e, item)
|
|
177
192
|
}, /*#__PURE__*/React.createElement("span", {
|
|
178
193
|
className: "".concat(prefixcls, "-label")
|
|
179
194
|
}, !multiple && this.renderIcon('empty'), multiple && /*#__PURE__*/React.createElement(Checkbox, {
|
|
@@ -198,13 +213,15 @@ export default class Item extends PureComponent {
|
|
|
198
213
|
let showChildItem;
|
|
199
214
|
const ind = content.length;
|
|
200
215
|
content.push( /*#__PURE__*/React.createElement("ul", {
|
|
216
|
+
role: 'menu',
|
|
201
217
|
className: "".concat(prefixcls, "-list"),
|
|
202
218
|
key: renderData[0].key,
|
|
203
219
|
onScroll: e => this.props.onListScroll(e, ind)
|
|
204
220
|
}, _mapInstanceProperty(renderData).call(renderData, item => {
|
|
205
221
|
const {
|
|
206
222
|
data,
|
|
207
|
-
key
|
|
223
|
+
key,
|
|
224
|
+
parentKey
|
|
208
225
|
} = item;
|
|
209
226
|
const {
|
|
210
227
|
children,
|
|
@@ -229,16 +246,26 @@ export default class Item extends PureComponent {
|
|
|
229
246
|
["".concat(prefixcls, "-select")]: selected && !multiple,
|
|
230
247
|
["".concat(prefixcls, "-disabled")]: disabled
|
|
231
248
|
});
|
|
232
|
-
|
|
249
|
+
const otherAriaProps = parentKey ? {
|
|
250
|
+
['aria-owns']: "cascaderItem-".concat(parentKey)
|
|
251
|
+
} : {};
|
|
252
|
+
return /*#__PURE__*/React.createElement("li", _Object$assign({
|
|
253
|
+
role: 'menuitem',
|
|
254
|
+
id: "cascaderItem-".concat(key),
|
|
255
|
+
"aria-expanded": active,
|
|
256
|
+
"aria-haspopup": Boolean(showExpand),
|
|
257
|
+
"aria-disabled": disabled
|
|
258
|
+
}, otherAriaProps, {
|
|
233
259
|
className: className,
|
|
234
260
|
key: key,
|
|
235
261
|
onClick: e => {
|
|
236
262
|
this.onClick(e, item);
|
|
237
263
|
},
|
|
264
|
+
onKeyPress: e => this.handleItemEnterPress(e, item),
|
|
238
265
|
onMouseEnter: e => {
|
|
239
266
|
this.onHover(e, item);
|
|
240
267
|
}
|
|
241
|
-
}, /*#__PURE__*/React.createElement("span", {
|
|
268
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
242
269
|
className: "".concat(prefixcls, "-label")
|
|
243
270
|
}, selected && !multiple && this.renderIcon('tick'), !selected && !multiple && this.renderIcon('empty'), multiple && /*#__PURE__*/React.createElement(Checkbox, {
|
|
244
271
|
onChange: e => this.onCheckboxChange(e, item),
|
|
@@ -25,7 +25,6 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
25
25
|
value: PropTypes.Requireable<any[]>;
|
|
26
26
|
disabled: PropTypes.Requireable<boolean>;
|
|
27
27
|
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
28
|
-
multiple: PropTypes.Requireable<boolean>;
|
|
29
28
|
showClear: PropTypes.Requireable<boolean>;
|
|
30
29
|
format: PropTypes.Requireable<string>;
|
|
31
30
|
inputStyle: PropTypes.Requireable<object>;
|
|
@@ -49,7 +48,6 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
49
48
|
onBlur: typeof noop;
|
|
50
49
|
onClear: typeof noop;
|
|
51
50
|
onFocus: typeof noop;
|
|
52
|
-
multiple: boolean;
|
|
53
51
|
type: string;
|
|
54
52
|
inputStyle: {};
|
|
55
53
|
inputReadOnly: boolean;
|
|
@@ -15,6 +15,8 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
15
15
|
}
|
|
16
16
|
return t;
|
|
17
17
|
};
|
|
18
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions,jsx-a11y/interactive-supports-focus */
|
|
19
|
+
|
|
18
20
|
/* eslint-disable max-lines-per-function */
|
|
19
21
|
|
|
20
22
|
/* eslint-disable no-unused-vars */
|
|
@@ -170,9 +172,14 @@ export default class DateInput extends BaseComponent {
|
|
|
170
172
|
} = this.props;
|
|
171
173
|
const allowClear = (rangeStart || rangeEnd) && showClear;
|
|
172
174
|
return allowClear && !disabled ? /*#__PURE__*/React.createElement("div", {
|
|
175
|
+
role: "button",
|
|
176
|
+
tabIndex: 0,
|
|
177
|
+
"aria-label": "Clear range input value",
|
|
173
178
|
className: "".concat(prefixCls, "-range-input-clearbtn"),
|
|
174
179
|
onMouseDown: e => !disabled && this.handleRangeInputClear(e)
|
|
175
|
-
}, /*#__PURE__*/React.createElement(IconClear,
|
|
180
|
+
}, /*#__PURE__*/React.createElement(IconClear, {
|
|
181
|
+
"aria-hidden": true
|
|
182
|
+
})) : null;
|
|
176
183
|
}
|
|
177
184
|
|
|
178
185
|
renderRangeSuffix(suffix) {
|
|
@@ -273,6 +280,8 @@ export default class DateInput extends BaseComponent {
|
|
|
273
280
|
validateStatus,
|
|
274
281
|
block,
|
|
275
282
|
prefixCls,
|
|
283
|
+
multiple,
|
|
284
|
+
// Whether to allow multiple values for email and file types
|
|
276
285
|
dateFnsLocale,
|
|
277
286
|
// No need to pass to input
|
|
278
287
|
onBlur,
|
|
@@ -290,10 +299,14 @@ export default class DateInput extends BaseComponent {
|
|
|
290
299
|
rangeInputFocus,
|
|
291
300
|
rangeSeparator
|
|
292
301
|
} = _a,
|
|
293
|
-
rest = __rest(_a, ["placeholder", "type", "value", "inputValue", "inputStyle", "disabled", "showClear", "inputReadOnly", "insetLabel", "validateStatus", "block", "prefixCls", "dateFnsLocale", "onBlur", "onClear", "onFocus", "prefix", "autofocus", "size", "rangeInputStartRef", "rangeInputEndRef", "onRangeClear", "onRangeBlur", "onRangeEndTabPress", "rangeInputFocus", "rangeSeparator"]);
|
|
302
|
+
rest = __rest(_a, ["placeholder", "type", "value", "inputValue", "inputStyle", "disabled", "showClear", "inputReadOnly", "insetLabel", "validateStatus", "block", "prefixCls", "multiple", "dateFnsLocale", "onBlur", "onClear", "onFocus", "prefix", "autofocus", "size", "rangeInputStartRef", "rangeInputEndRef", "onRangeClear", "onRangeBlur", "onRangeEndTabPress", "rangeInputFocus", "rangeSeparator"]);
|
|
294
303
|
|
|
295
|
-
const dateIcon = /*#__PURE__*/React.createElement(IconCalendar,
|
|
296
|
-
|
|
304
|
+
const dateIcon = /*#__PURE__*/React.createElement(IconCalendar, {
|
|
305
|
+
"aria-hidden": true
|
|
306
|
+
});
|
|
307
|
+
const dateTimeIcon = /*#__PURE__*/React.createElement(IconCalendarClock, {
|
|
308
|
+
"aria-hidden": true
|
|
309
|
+
});
|
|
297
310
|
const suffix = _includesInstanceProperty(type).call(type, 'Time') ? dateTimeIcon : dateIcon;
|
|
298
311
|
let text = '';
|
|
299
312
|
|
|
@@ -348,7 +361,6 @@ DateInput.propTypes = {
|
|
|
348
361
|
value: PropTypes.array,
|
|
349
362
|
disabled: PropTypes.bool,
|
|
350
363
|
type: PropTypes.oneOf(strings.TYPE_SET),
|
|
351
|
-
multiple: PropTypes.bool,
|
|
352
364
|
showClear: PropTypes.bool,
|
|
353
365
|
format: PropTypes.string,
|
|
354
366
|
inputStyle: PropTypes.object,
|
|
@@ -372,7 +384,6 @@ DateInput.defaultProps = {
|
|
|
372
384
|
onBlur: noop,
|
|
373
385
|
onClear: noop,
|
|
374
386
|
onFocus: noop,
|
|
375
|
-
multiple: false,
|
|
376
387
|
type: 'date',
|
|
377
388
|
inputStyle: {},
|
|
378
389
|
inputReadOnly: false,
|
|
@@ -9,6 +9,8 @@ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/ins
|
|
|
9
9
|
import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
10
10
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
11
11
|
|
|
12
|
+
/* eslint-disable jsx-a11y/click-events-have-key-events,jsx-a11y/interactive-supports-focus */
|
|
13
|
+
|
|
12
14
|
/* eslint-disable max-len */
|
|
13
15
|
import React from 'react';
|
|
14
16
|
import classnames from 'classnames';
|
|
@@ -576,18 +578,19 @@ export default class DatePicker extends BaseComponent {
|
|
|
576
578
|
onRangeEndTabPress: this.handleRangeEndTabPress
|
|
577
579
|
});
|
|
578
580
|
|
|
579
|
-
return (
|
|
580
|
-
|
|
581
|
-
// eslint-disable-next-line jsx-a11y/
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
581
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
582
|
+
// tooltip will mount a11y props to children
|
|
583
|
+
// eslint-disable-next-line jsx-a11y/role-has-required-aria-props
|
|
584
|
+
role: "combobox",
|
|
585
|
+
"aria-label": _Array$isArray(value) && value.length ? "Change date" : "Choose date",
|
|
586
|
+
"aria-disabled": disabled,
|
|
587
|
+
onClick: this.handleTriggerWrapperClick,
|
|
588
|
+
className: inputCls
|
|
589
|
+
}, typeof triggerRender === 'function' ? /*#__PURE__*/React.createElement(Trigger, _Object$assign({}, props, {
|
|
590
|
+
triggerRender: triggerRender,
|
|
591
|
+
componentName: "DatePicker",
|
|
592
|
+
componentProps: _Object$assign({}, this.props)
|
|
593
|
+
})) : /*#__PURE__*/React.createElement(DateInput, _Object$assign({}, props)));
|
|
591
594
|
}
|
|
592
595
|
|
|
593
596
|
render() {
|
|
@@ -33,6 +33,7 @@ export default class Month extends BaseComponent<MonthProps, MonthState> {
|
|
|
33
33
|
endDateOffset: PropTypes.Requireable<(...args: any[]) => any>;
|
|
34
34
|
rangeInputFocus: PropTypes.Requireable<string | boolean>;
|
|
35
35
|
focusRecordsRef: PropTypes.Requireable<object>;
|
|
36
|
+
multiple: PropTypes.Requireable<boolean>;
|
|
36
37
|
};
|
|
37
38
|
static defaultProps: {
|
|
38
39
|
month: Date;
|