@douyinfe/semi-ui 2.5.1 → 2.7.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/__test__/button.test.js +7 -0
- package/button/buttonGroup.tsx +5 -2
- package/calendar/monthCalendar.tsx +14 -13
- package/cascader/__test__/cascader.test.js +159 -81
- package/cascader/_story/cascader.stories.js +36 -23
- package/cascader/index.tsx +47 -8
- package/cascader/item.tsx +25 -5
- package/datePicker/_story/v2/InsetInput.jsx +104 -0
- package/datePicker/_story/v2/InsetInputE2E.jsx +69 -0
- package/datePicker/_story/v2/index.js +2 -0
- package/datePicker/dateInput.tsx +102 -13
- package/datePicker/datePicker.tsx +95 -16
- package/datePicker/index.tsx +15 -0
- package/datePicker/insetInput.tsx +76 -0
- package/datePicker/month.tsx +14 -7
- package/datePicker/monthsGrid.tsx +31 -12
- package/datePicker/navigation.tsx +8 -4
- package/datePicker/quickControl.tsx +1 -0
- package/datePicker/yearAndMonth.tsx +1 -1
- package/dist/css/semi.css +120 -8
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +1100 -193
- 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/hoc/withField.tsx +1 -1
- package/input/_story/input.stories.js +13 -0
- package/lib/cjs/_base/base.css +5 -5
- package/lib/cjs/button/buttonGroup.d.ts +1 -0
- package/lib/cjs/button/buttonGroup.js +6 -2
- package/lib/cjs/calendar/monthCalendar.js +21 -5
- package/lib/cjs/cascader/index.d.ts +10 -2
- package/lib/cjs/cascader/index.js +52 -10
- package/lib/cjs/cascader/item.d.ts +6 -2
- package/lib/cjs/cascader/item.js +33 -4
- package/lib/cjs/datePicker/dateInput.d.ts +9 -4
- package/lib/cjs/datePicker/dateInput.js +107 -13
- package/lib/cjs/datePicker/datePicker.d.ts +7 -2
- package/lib/cjs/datePicker/datePicker.js +138 -30
- package/lib/cjs/datePicker/index.js +24 -2
- package/lib/cjs/datePicker/insetInput.d.ts +21 -0
- package/lib/cjs/datePicker/insetInput.js +80 -0
- package/lib/cjs/datePicker/month.d.ts +1 -0
- package/lib/cjs/datePicker/month.js +18 -2
- package/lib/cjs/datePicker/monthsGrid.js +35 -11
- 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/hoc/withField.js +1 -1
- 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/tree/index.js +5 -3
- package/lib/cjs/tree/interface.d.ts +1 -0
- package/lib/cjs/tree/nodeList.js +2 -1
- package/lib/cjs/treeSelect/index.js +7 -3
- package/lib/es/_base/base.css +5 -5
- package/lib/es/button/buttonGroup.d.ts +1 -0
- package/lib/es/button/buttonGroup.js +5 -2
- package/lib/es/calendar/monthCalendar.js +22 -5
- package/lib/es/cascader/index.d.ts +10 -2
- package/lib/es/cascader/index.js +49 -7
- package/lib/es/cascader/item.d.ts +6 -2
- package/lib/es/cascader/item.js +31 -4
- package/lib/es/datePicker/dateInput.d.ts +9 -4
- package/lib/es/datePicker/dateInput.js +106 -13
- package/lib/es/datePicker/datePicker.d.ts +7 -2
- package/lib/es/datePicker/datePicker.js +139 -30
- package/lib/es/datePicker/index.js +20 -0
- package/lib/es/datePicker/insetInput.d.ts +21 -0
- package/lib/es/datePicker/insetInput.js +65 -0
- package/lib/es/datePicker/month.d.ts +1 -0
- package/lib/es/datePicker/month.js +18 -2
- package/lib/es/datePicker/monthsGrid.js +35 -11
- 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/hoc/withField.js +1 -1
- 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/tree/index.js +5 -3
- package/lib/es/tree/interface.d.ts +1 -0
- package/lib/es/tree/nodeList.js +2 -1
- package/lib/es/treeSelect/index.js +7 -3
- 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/v2/FixedExpandedRow/index.jsx +95 -0
- package/table/_story/v2/index.js +2 -1
- package/tree/__test__/tree.test.js +87 -2
- package/tree/_story/tree.stories.js +65 -5
- package/tree/index.tsx +4 -2
- package/tree/interface.ts +1 -0
- package/tree/nodeList.tsx +2 -2
- package/treeSelect/__test__/treeSelect.test.js +28 -0
- package/treeSelect/_story/treeSelect.stories.js +55 -2
- package/treeSelect/index.tsx +11 -3
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);
|
|
@@ -18,6 +18,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
18
18
|
import React, { isValidElement, cloneElement } from 'react';
|
|
19
19
|
import BaseComponent from '../_base/baseComponent';
|
|
20
20
|
import PropTypes from 'prop-types';
|
|
21
|
+
import classNames from 'classnames';
|
|
21
22
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/button/constants';
|
|
22
23
|
import '@douyinfe/semi-foundation/lib/es/button/button.css';
|
|
23
24
|
const prefixCls = cssClasses.PREFIX;
|
|
@@ -30,11 +31,13 @@ export default class ButtonGroup extends BaseComponent {
|
|
|
30
31
|
disabled,
|
|
31
32
|
size,
|
|
32
33
|
type,
|
|
34
|
+
className,
|
|
33
35
|
'aria-label': ariaLabel
|
|
34
36
|
} = _a,
|
|
35
|
-
rest = __rest(_a, ["children", "disabled", "size", "type", 'aria-label']);
|
|
37
|
+
rest = __rest(_a, ["children", "disabled", "size", "type", "className", 'aria-label']);
|
|
36
38
|
|
|
37
39
|
let inner;
|
|
40
|
+
const cls = classNames("".concat(prefixCls, "-group"), className);
|
|
38
41
|
|
|
39
42
|
if (children) {
|
|
40
43
|
var _context;
|
|
@@ -49,7 +52,7 @@ export default class ButtonGroup extends BaseComponent {
|
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
return /*#__PURE__*/React.createElement("div", {
|
|
52
|
-
className:
|
|
55
|
+
className: cls,
|
|
53
56
|
role: "group",
|
|
54
57
|
"aria-label": ariaLabel
|
|
55
58
|
}, inner);
|
|
@@ -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,13 +180,14 @@ 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;
|
|
184
187
|
renderContent: () => JSX.Element;
|
|
185
188
|
renderPlusN: (hiddenTag: Array<ReactNode>) => JSX.Element;
|
|
186
189
|
renderMultipleTags: () => JSX.Element;
|
|
190
|
+
renderDisplayText: () => ReactNode;
|
|
187
191
|
renderSelectContent: () => JSX.Element;
|
|
188
192
|
renderSuffix: () => JSX.Element;
|
|
189
193
|
renderPrefix: () => JSX.Element;
|
|
@@ -191,6 +195,10 @@ declare class Cascader extends BaseComponent<CascaderProps, CascaderState> {
|
|
|
191
195
|
handleMouseOver: () => void;
|
|
192
196
|
handleMouseLeave: () => void;
|
|
193
197
|
handleClear: (e: MouseEvent) => void;
|
|
198
|
+
/**
|
|
199
|
+
* A11y: simulate clear button click
|
|
200
|
+
*/
|
|
201
|
+
handleClearEnterPress: (e: KeyboardEvent) => void;
|
|
194
202
|
showClearBtn: () => boolean;
|
|
195
203
|
renderClearBtn: () => JSX.Element;
|
|
196
204
|
renderArrow: () => JSX.Element;
|
package/lib/es/cascader/index.js
CHANGED
|
@@ -9,10 +9,10 @@ import _isSet from "lodash/isSet";
|
|
|
9
9
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
10
10
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
11
11
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
12
|
+
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
12
13
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
13
14
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
14
15
|
import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
|
|
15
|
-
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
16
16
|
import React, { Fragment } from 'react';
|
|
17
17
|
import ReactDOM from 'react-dom';
|
|
18
18
|
import cls from 'classnames';
|
|
@@ -210,6 +210,36 @@ class Cascader extends BaseComponent {
|
|
|
210
210
|
return /*#__PURE__*/React.createElement(React.Fragment, null, displayTag, !_isEmpty(hiddenTag) && this.renderPlusN(hiddenTag));
|
|
211
211
|
};
|
|
212
212
|
|
|
213
|
+
this.renderDisplayText = () => {
|
|
214
|
+
const {
|
|
215
|
+
displayProp,
|
|
216
|
+
separator,
|
|
217
|
+
displayRender
|
|
218
|
+
} = this.props;
|
|
219
|
+
const {
|
|
220
|
+
selectedKeys
|
|
221
|
+
} = this.state;
|
|
222
|
+
let displayText = '';
|
|
223
|
+
|
|
224
|
+
if (selectedKeys.size) {
|
|
225
|
+
const displayPath = this.foundation.getItemPropPath([...selectedKeys][0], displayProp);
|
|
226
|
+
|
|
227
|
+
if (displayRender && typeof displayRender === 'function') {
|
|
228
|
+
displayText = displayRender(displayPath);
|
|
229
|
+
} else {
|
|
230
|
+
displayText = _mapInstanceProperty(displayPath).call(displayPath, (path, index) => {
|
|
231
|
+
var _context3;
|
|
232
|
+
|
|
233
|
+
return /*#__PURE__*/React.createElement(Fragment, {
|
|
234
|
+
key: _concatInstanceProperty(_context3 = "".concat(path, "-")).call(_context3, index)
|
|
235
|
+
}, index < displayPath.length - 1 ? /*#__PURE__*/React.createElement(React.Fragment, null, path, separator) : path);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
return displayText;
|
|
241
|
+
};
|
|
242
|
+
|
|
213
243
|
this.renderSelectContent = () => {
|
|
214
244
|
const {
|
|
215
245
|
placeholder,
|
|
@@ -217,7 +247,6 @@ class Cascader extends BaseComponent {
|
|
|
217
247
|
multiple
|
|
218
248
|
} = this.props;
|
|
219
249
|
const {
|
|
220
|
-
selectedKeys,
|
|
221
250
|
checkedKeys
|
|
222
251
|
} = this.state;
|
|
223
252
|
const searchable = Boolean(filterTreeNode);
|
|
@@ -232,9 +261,9 @@ class Cascader extends BaseComponent {
|
|
|
232
261
|
|
|
233
262
|
return this.renderMultipleTags();
|
|
234
263
|
} else {
|
|
235
|
-
const displayText =
|
|
264
|
+
const displayText = this.renderDisplayText();
|
|
236
265
|
const spanCls = cls({
|
|
237
|
-
["".concat(prefixcls, "-selection-placeholder")]: !displayText
|
|
266
|
+
["".concat(prefixcls, "-selection-placeholder")]: !displayText
|
|
238
267
|
});
|
|
239
268
|
return /*#__PURE__*/React.createElement("span", {
|
|
240
269
|
className: spanCls
|
|
@@ -330,6 +359,15 @@ class Cascader extends BaseComponent {
|
|
|
330
359
|
e && e.stopPropagation();
|
|
331
360
|
this.foundation.handleClear();
|
|
332
361
|
};
|
|
362
|
+
/**
|
|
363
|
+
* A11y: simulate clear button click
|
|
364
|
+
*/
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
this.handleClearEnterPress = e => {
|
|
368
|
+
e && e.stopPropagation();
|
|
369
|
+
this.foundation.handleClearEnterPress();
|
|
370
|
+
};
|
|
333
371
|
|
|
334
372
|
this.showClearBtn = () => {
|
|
335
373
|
const {
|
|
@@ -356,6 +394,7 @@ class Cascader extends BaseComponent {
|
|
|
356
394
|
return /*#__PURE__*/React.createElement("div", {
|
|
357
395
|
className: clearCls,
|
|
358
396
|
onClick: this.handleClear,
|
|
397
|
+
onKeyPress: this.handleClearEnterPress,
|
|
359
398
|
role: 'button',
|
|
360
399
|
tabIndex: 0
|
|
361
400
|
}, /*#__PURE__*/React.createElement(IconClear, null));
|
|
@@ -445,6 +484,7 @@ class Cascader extends BaseComponent {
|
|
|
445
484
|
style: style,
|
|
446
485
|
ref: this.triggerRef,
|
|
447
486
|
onClick: e => this.foundation.handleClick(e),
|
|
487
|
+
onKeyPress: e => this.foundation.handleSelectionEnterPress(e),
|
|
448
488
|
"aria-invalid": this.props['aria-invalid'],
|
|
449
489
|
"aria-errormessage": this.props['aria-errormessage'],
|
|
450
490
|
"aria-label": this.props['aria-label'],
|
|
@@ -768,7 +808,7 @@ class Cascader extends BaseComponent {
|
|
|
768
808
|
}
|
|
769
809
|
|
|
770
810
|
renderTagInput() {
|
|
771
|
-
var
|
|
811
|
+
var _context4;
|
|
772
812
|
|
|
773
813
|
const {
|
|
774
814
|
size,
|
|
@@ -788,7 +828,7 @@ class Cascader extends BaseComponent {
|
|
|
788
828
|
const tagValue = [];
|
|
789
829
|
const realKeys = this.mergeType === strings.NONE_MERGE_TYPE ? checkedKeys : resolvedCheckedKeys;
|
|
790
830
|
|
|
791
|
-
_forEachInstanceProperty(
|
|
831
|
+
_forEachInstanceProperty(_context4 = [...realKeys]).call(_context4, checkedKey => {
|
|
792
832
|
if (!_isEmpty(keyEntities[checkedKey])) {
|
|
793
833
|
tagValue.push(keyEntities[checkedKey].valuePath);
|
|
794
834
|
}
|
|
@@ -887,6 +927,7 @@ Cascader.propTypes = {
|
|
|
887
927
|
'aria-errormessage': PropTypes.string,
|
|
888
928
|
'aria-describedby': PropTypes.string,
|
|
889
929
|
'aria-required': PropTypes.bool,
|
|
930
|
+
'aria-label': PropTypes.string,
|
|
890
931
|
arrowIcon: PropTypes.node,
|
|
891
932
|
changeOnSelect: PropTypes.bool,
|
|
892
933
|
defaultValue: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
|
|
@@ -981,6 +1022,7 @@ Cascader.defaultProps = {
|
|
|
981
1022
|
onClear: _noop,
|
|
982
1023
|
onDropdownVisibleChange: _noop,
|
|
983
1024
|
onListScroll: _noop,
|
|
984
|
-
enableLeafClick: false
|
|
1025
|
+
enableLeafClick: false,
|
|
1026
|
+
'aria-label': 'Cascader'
|
|
985
1027
|
};
|
|
986
1028
|
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),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import DateInputFoundation, { DateInputAdapter, DateInputFoundationProps, RangeType } from '@douyinfe/semi-foundation/lib/es/datePicker/inputFoundation';
|
|
3
|
+
import DateInputFoundation, { DateInputAdapter, DateInputFoundationProps, RangeType, InsetInputChangeProps, InsetInputChangeFoundationProps } from '@douyinfe/semi-foundation/lib/es/datePicker/inputFoundation';
|
|
4
4
|
import { noop } from '@douyinfe/semi-foundation/lib/es/utils/function';
|
|
5
|
-
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
6
5
|
import { ValueType } from '@douyinfe/semi-foundation/lib/es/datePicker/foundation';
|
|
6
|
+
import BaseComponent, { BaseProps } from '../_base/baseComponent';
|
|
7
7
|
export interface DateInputProps extends DateInputFoundationProps, BaseProps {
|
|
8
8
|
insetLabel?: React.ReactNode;
|
|
9
9
|
prefix?: React.ReactNode;
|
|
@@ -13,6 +13,8 @@ export interface DateInputProps extends DateInputFoundationProps, BaseProps {
|
|
|
13
13
|
onBlur?: (e: React.MouseEvent<HTMLInputElement>) => void;
|
|
14
14
|
onFocus?: (e: React.MouseEvent<HTMLInputElement>, rangeType?: RangeType) => void;
|
|
15
15
|
onClear?: (e: React.MouseEvent<HTMLDivElement>) => void;
|
|
16
|
+
onInsetInputChange?: (options: InsetInputChangeProps) => void;
|
|
17
|
+
value?: Date[];
|
|
16
18
|
}
|
|
17
19
|
export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
18
20
|
static propTypes: {
|
|
@@ -25,7 +27,6 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
25
27
|
value: PropTypes.Requireable<any[]>;
|
|
26
28
|
disabled: PropTypes.Requireable<boolean>;
|
|
27
29
|
type: PropTypes.Requireable<"dateTime" | "date" | "month" | "dateRange" | "year" | "dateTimeRange">;
|
|
28
|
-
multiple: PropTypes.Requireable<boolean>;
|
|
29
30
|
showClear: PropTypes.Requireable<boolean>;
|
|
30
31
|
format: PropTypes.Requireable<string>;
|
|
31
32
|
inputStyle: PropTypes.Requireable<object>;
|
|
@@ -40,6 +41,8 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
40
41
|
rangeInputStartRef: PropTypes.Requireable<object>;
|
|
41
42
|
rangeInputEndRef: PropTypes.Requireable<object>;
|
|
42
43
|
rangeSeparator: PropTypes.Requireable<string>;
|
|
44
|
+
insetInput: PropTypes.Requireable<boolean>;
|
|
45
|
+
insetInputValue: PropTypes.Requireable<object>;
|
|
43
46
|
};
|
|
44
47
|
static defaultProps: {
|
|
45
48
|
showClear: boolean;
|
|
@@ -49,7 +52,6 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
49
52
|
onBlur: typeof noop;
|
|
50
53
|
onClear: typeof noop;
|
|
51
54
|
onFocus: typeof noop;
|
|
52
|
-
multiple: boolean;
|
|
53
55
|
type: string;
|
|
54
56
|
inputStyle: {};
|
|
55
57
|
inputReadOnly: boolean;
|
|
@@ -71,11 +73,14 @@ export default class DateInput extends BaseComponent<DateInputProps, {}> {
|
|
|
71
73
|
handleRangeInputEndKeyPress: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
72
74
|
handleRangeInputFocus: (e: React.MouseEvent<HTMLElement>, rangeType: RangeType) => void;
|
|
73
75
|
handleRangeStartFocus: React.MouseEventHandler<HTMLElement>;
|
|
76
|
+
handleInsetInputChange: (options: InsetInputChangeFoundationProps) => void;
|
|
74
77
|
getRangeInputValue: (rangeStart: string, rangeEnd: string) => string;
|
|
75
78
|
renderRangePrefix(): JSX.Element;
|
|
76
79
|
renderRangeSeparator(rangeStart: string, rangeEnd: string): JSX.Element;
|
|
77
80
|
renderRangeClearBtn(rangeStart: string, rangeEnd: string): JSX.Element;
|
|
78
81
|
renderRangeSuffix(suffix: React.ReactNode): JSX.Element;
|
|
79
82
|
renderRangeInput(rangeProps: DateInputProps): JSX.Element;
|
|
83
|
+
renderInputInset(): JSX.Element;
|
|
84
|
+
renderTriggerInput(): JSX.Element;
|
|
80
85
|
render(): JSX.Element;
|
|
81
86
|
}
|