@douyinfe/semi-ui 2.11.2 → 2.12.0-beta.1
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/Button.tsx +1 -1
- package/dist/css/semi.css +33 -0
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +2338 -323
- 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/_story/FormSubmit/index.tsx +45 -0
- package/form/_story/form.stories.js +2 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/modal/Modal.js +3 -2
- package/lib/cjs/modal/ModalContent.d.ts +2 -0
- package/lib/cjs/modal/ModalContent.js +17 -9
- package/lib/cjs/progress/index.js +1 -1
- package/lib/cjs/select/index.js +1 -1
- package/lib/cjs/slider/index.js +9 -5
- package/lib/cjs/tabs/TabBar.d.ts +1 -0
- package/lib/cjs/tabs/TabBar.js +8 -1
- package/lib/cjs/tabs/TabPane.js +2 -1
- package/lib/cjs/tabs/index.js +2 -1
- package/lib/cjs/tabs/interface.d.ts +1 -0
- package/lib/cjs/tag/index.d.ts +2 -0
- package/lib/cjs/tag/index.js +60 -11
- package/lib/cjs/tag/interface.d.ts +1 -0
- package/lib/cjs/tagInput/index.js +3 -2
- package/lib/cjs/tooltip/TooltipStyledTransition.js +5 -2
- package/lib/cjs/treeSelect/index.js +3 -3
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/modal/Modal.js +3 -2
- package/lib/es/modal/ModalContent.d.ts +2 -0
- package/lib/es/modal/ModalContent.js +16 -9
- package/lib/es/progress/index.js +1 -1
- package/lib/es/select/index.js +1 -1
- package/lib/es/slider/index.js +9 -5
- package/lib/es/tabs/TabBar.d.ts +1 -0
- package/lib/es/tabs/TabBar.js +8 -1
- package/lib/es/tabs/TabPane.js +2 -1
- package/lib/es/tabs/index.js +2 -1
- package/lib/es/tabs/interface.d.ts +1 -0
- package/lib/es/tag/index.d.ts +2 -0
- package/lib/es/tag/index.js +56 -9
- package/lib/es/tag/interface.d.ts +1 -0
- package/lib/es/tagInput/index.js +3 -2
- package/lib/es/tooltip/TooltipStyledTransition.js +5 -2
- package/lib/es/treeSelect/index.js +2 -2
- package/modal/Modal.tsx +2 -1
- package/modal/ModalContent.tsx +14 -8
- package/package.json +9 -9
- package/progress/index.tsx +1 -1
- package/select/index.tsx +1 -2
- package/slider/index.tsx +5 -3
- package/table/_story/v2/index.js +2 -1
- package/table/_story/v2/radioRowSelection.tsx +107 -0
- package/tabs/TabBar.tsx +7 -0
- package/tabs/TabPane.tsx +1 -0
- package/tabs/index.tsx +2 -1
- package/tabs/interface.ts +1 -0
- package/tag/index.tsx +32 -2
- package/tag/interface.ts +1 -0
- package/tagInput/index.tsx +1 -0
- package/tooltip/TooltipStyledTransition.tsx +2 -1
- package/tooltip/_story/tooltip.stories.js +90 -0
- package/treeSelect/index.tsx +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import _get from "lodash/get";
|
|
2
|
-
import _isFunction from "lodash/isFunction";
|
|
3
1
|
import _noop from "lodash/noop";
|
|
2
|
+
import _isFunction from "lodash/isFunction";
|
|
3
|
+
import _get from "lodash/get";
|
|
4
4
|
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
5
5
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
6
6
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
@@ -32,7 +32,7 @@ import BaseComponent from '../_base/baseComponent'; // eslint-disable-next-line
|
|
|
32
32
|
|
|
33
33
|
import ModalContentFoundation from '@douyinfe/semi-foundation/lib/es/modal/modalContentFoundation';
|
|
34
34
|
import { IconClose } from '@douyinfe/semi-icons';
|
|
35
|
-
import
|
|
35
|
+
import FocusTrapHandle from '@douyinfe/semi-foundation/lib/es/utils/FocusHandle';
|
|
36
36
|
let uuid = 0;
|
|
37
37
|
export default class ModalContent extends BaseComponent {
|
|
38
38
|
constructor(props) {
|
|
@@ -200,6 +200,7 @@ export default class ModalContent extends BaseComponent {
|
|
|
200
200
|
}, /*#__PURE__*/React.createElement("div", {
|
|
201
201
|
role: "dialog",
|
|
202
202
|
ref: this.modalDialogRef,
|
|
203
|
+
tabIndex: -1,
|
|
203
204
|
"aria-modal": "true",
|
|
204
205
|
"aria-labelledby": "".concat(cssClasses.DIALOG, "-title"),
|
|
205
206
|
"aria-describedby": "".concat(cssClasses.DIALOG, "-body"),
|
|
@@ -214,7 +215,7 @@ export default class ModalContent extends BaseComponent {
|
|
|
214
215
|
|
|
215
216
|
this.state = {
|
|
216
217
|
dialogMouseDown: false,
|
|
217
|
-
prevFocusElement: getActiveElement()
|
|
218
|
+
prevFocusElement: FocusTrapHandle.getActiveElement()
|
|
218
219
|
};
|
|
219
220
|
this.foundation = new ModalContentFoundation(this.adapter);
|
|
220
221
|
this.dialogId = "dialog-".concat(uuid++);
|
|
@@ -257,19 +258,26 @@ export default class ModalContent extends BaseComponent {
|
|
|
257
258
|
},
|
|
258
259
|
getMouseState: () => this.state.dialogMouseDown,
|
|
259
260
|
modalDialogFocus: () => {
|
|
261
|
+
var _a, _b, _c;
|
|
262
|
+
|
|
260
263
|
let activeElementInDialog;
|
|
261
264
|
|
|
262
265
|
if (this.modalDialogRef) {
|
|
263
|
-
const activeElement = getActiveElement();
|
|
266
|
+
const activeElement = FocusTrapHandle.getActiveElement();
|
|
264
267
|
activeElementInDialog = this.modalDialogRef.current.contains(activeElement);
|
|
268
|
+
(_a = this.focusTrapHandle) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
269
|
+
this.focusTrapHandle = new FocusTrapHandle(this.modalDialogRef.current);
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
if (!activeElementInDialog) {
|
|
268
|
-
this.modalDialogRef
|
|
273
|
+
(_c = (_b = this.modalDialogRef) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c.focus();
|
|
269
274
|
}
|
|
270
275
|
},
|
|
271
276
|
modalDialogBlur: () => {
|
|
272
|
-
|
|
277
|
+
var _a, _b;
|
|
278
|
+
|
|
279
|
+
(_a = this.modalDialogRef) === null || _a === void 0 ? void 0 : _a.current.blur();
|
|
280
|
+
(_b = this.focusTrapHandle) === null || _b === void 0 ? void 0 : _b.destroy();
|
|
273
281
|
},
|
|
274
282
|
prevFocusElementReFocus: () => {
|
|
275
283
|
const {
|
|
@@ -318,8 +326,7 @@ export default class ModalContent extends BaseComponent {
|
|
|
318
326
|
className: "".concat(cssClasses.DIALOG, "-wrap"),
|
|
319
327
|
onClick: maskClosable ? this.onMaskClick : null,
|
|
320
328
|
onMouseUp: maskClosable ? this.onMaskMouseUp : null
|
|
321
|
-
}, this.getDialogElement())); //
|
|
322
|
-
// eslint-disable-next-line max-len
|
|
329
|
+
}, this.getDialogElement())); // eslint-disable-next-line max-len
|
|
323
330
|
|
|
324
331
|
return containerContext && containerContext.Provider ? /*#__PURE__*/React.createElement(containerContext.Provider, {
|
|
325
332
|
value: containerContext.value
|
package/lib/es/progress/index.js
CHANGED
|
@@ -220,7 +220,7 @@ class Progress extends Component {
|
|
|
220
220
|
const perc = this.calcPercent(percent);
|
|
221
221
|
const percNumber = this.calcPercent(percentNumber);
|
|
222
222
|
const innerStyle = {
|
|
223
|
-
|
|
223
|
+
background: stroke
|
|
224
224
|
};
|
|
225
225
|
|
|
226
226
|
if (direction === strings.DEFAULT_DIRECTION) {
|
package/lib/es/select/index.js
CHANGED
|
@@ -626,7 +626,7 @@ class Select extends BaseComponent {
|
|
|
626
626
|
role: "listbox",
|
|
627
627
|
"aria-multiselectable": multiple,
|
|
628
628
|
onScroll: e => this.foundation.handleListScroll(e)
|
|
629
|
-
}, innerTopSlot,
|
|
629
|
+
}, innerTopSlot, loading ? this.renderLoading() : isEmpty ? this.renderEmpty() : listContent, innerBottomSlot), outerBottomSlot);
|
|
630
630
|
}
|
|
631
631
|
|
|
632
632
|
renderSingleSelection(selections, filterable) {
|
package/lib/es/slider/index.js
CHANGED
|
@@ -243,7 +243,7 @@ export default class Slider extends BaseComponent {
|
|
|
243
243
|
React.createElement("div", {
|
|
244
244
|
className: cssClasses.TRACK,
|
|
245
245
|
style: trackStyle,
|
|
246
|
-
onClick:
|
|
246
|
+
onClick: this.foundation.handleWrapClick
|
|
247
247
|
})
|
|
248
248
|
);
|
|
249
249
|
};
|
|
@@ -271,7 +271,7 @@ export default class Slider extends BaseComponent {
|
|
|
271
271
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
272
272
|
React.createElement("span", {
|
|
273
273
|
key: mark,
|
|
274
|
-
onClick:
|
|
274
|
+
onClick: this.foundation.handleWrapClick,
|
|
275
275
|
className: markClass,
|
|
276
276
|
style: {
|
|
277
277
|
[stylePos]: "calc(".concat(markPercent * 100, "% - 2px)")
|
|
@@ -299,12 +299,16 @@ export default class Slider extends BaseComponent {
|
|
|
299
299
|
|
|
300
300
|
const activeResult = this.foundation.isMarkActive(Number(mark));
|
|
301
301
|
const markPercent = (Number(mark) - min) / (max - min);
|
|
302
|
-
return activeResult ?
|
|
302
|
+
return activeResult ?
|
|
303
|
+
/*#__PURE__*/
|
|
304
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
305
|
+
React.createElement("span", {
|
|
303
306
|
key: mark,
|
|
304
307
|
className: cls(_concatInstanceProperty(_context3 = "".concat(prefixCls, "-mark")).call(_context3, vertical && verticalReverse ? '-reverse' : '')),
|
|
305
308
|
style: {
|
|
306
309
|
[stylePos]: "".concat(markPercent * 100, "%")
|
|
307
|
-
}
|
|
310
|
+
},
|
|
311
|
+
onClick: this.foundation.handleWrapClick
|
|
308
312
|
}, marks[mark]) : null;
|
|
309
313
|
})) : null;
|
|
310
314
|
return labelContent;
|
|
@@ -584,7 +588,7 @@ export default class Slider extends BaseComponent {
|
|
|
584
588
|
onMouseLeave: () => this.foundation.handleWrapperLeave()
|
|
585
589
|
}, /*#__PURE__*/React.createElement("div", {
|
|
586
590
|
className: "".concat(prefixCls, "-rail"),
|
|
587
|
-
onClick:
|
|
591
|
+
onClick: this.foundation.handleWrapClick,
|
|
588
592
|
style: this.props.railStyle
|
|
589
593
|
}), this.renderTrack(), this.renderStepDot(), /*#__PURE__*/React.createElement("div", null, this.renderHandle()), this.renderLabel(), /*#__PURE__*/React.createElement("div", {
|
|
590
594
|
className: boundaryClass
|
package/lib/es/tabs/TabBar.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ declare class TabBar extends React.Component<TabBarProps, TabBarState> {
|
|
|
30
30
|
renderIcon(icon: ReactNode): ReactNode;
|
|
31
31
|
renderExtra(): ReactNode;
|
|
32
32
|
handleItemClick: (itemKey: string, e: MouseEvent<Element>) => void;
|
|
33
|
+
handleKeyDown: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
|
|
33
34
|
renderTabItem: (panel: PlainTab) => ReactNode;
|
|
34
35
|
renderTabComponents: (list: Array<PlainTab>) => Array<ReactNode>;
|
|
35
36
|
handleArrowClick: (items: Array<OverflowItem>, pos: 'start' | 'end') => void;
|
package/lib/es/tabs/TabBar.js
CHANGED
|
@@ -49,6 +49,10 @@ class TabBar extends React.Component {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
+
this.handleKeyDown = (event, itemKey, closable) => {
|
|
53
|
+
this.props.handleKeyDown(event, itemKey, closable);
|
|
54
|
+
};
|
|
55
|
+
|
|
52
56
|
this.renderTabItem = panel => {
|
|
53
57
|
const {
|
|
54
58
|
size,
|
|
@@ -82,9 +86,12 @@ class TabBar extends React.Component {
|
|
|
82
86
|
return /*#__PURE__*/React.createElement("div", _Object$assign({
|
|
83
87
|
role: "tab",
|
|
84
88
|
id: "semiTab".concat(key),
|
|
89
|
+
"data-tabkey": "semiTab".concat(key),
|
|
85
90
|
"aria-controls": "semiTabPanel".concat(key),
|
|
86
91
|
"aria-disabled": panel.disabled ? 'true' : 'false',
|
|
87
|
-
"aria-selected": isSelected ? 'true' : 'false'
|
|
92
|
+
"aria-selected": isSelected ? 'true' : 'false',
|
|
93
|
+
tabIndex: isSelected ? 0 : -1,
|
|
94
|
+
onKeyDown: e => this.handleKeyDown(e, key, panel.closable)
|
|
88
95
|
}, events, {
|
|
89
96
|
className: className,
|
|
90
97
|
key: this._getItemKey(key)
|
package/lib/es/tabs/TabPane.js
CHANGED
|
@@ -114,7 +114,8 @@ class TabPane extends PureComponent {
|
|
|
114
114
|
"aria-labelledby": "semiTab".concat(itemKey),
|
|
115
115
|
className: classNames,
|
|
116
116
|
style: style,
|
|
117
|
-
"aria-hidden": active ? 'false' : 'true'
|
|
117
|
+
"aria-hidden": active ? 'false' : 'true',
|
|
118
|
+
tabIndex: 0
|
|
118
119
|
}, getDataAttr(restProps)), motion ? /*#__PURE__*/React.createElement(TabPaneTransition, {
|
|
119
120
|
direction: this.getDirection(this.context.activeKey, itemKey, this.context.panes),
|
|
120
121
|
motion: motion,
|
package/lib/es/tabs/index.js
CHANGED
|
@@ -313,7 +313,8 @@ class Tabs extends BaseComponent {
|
|
|
313
313
|
tabBarExtraContent,
|
|
314
314
|
tabPosition,
|
|
315
315
|
type,
|
|
316
|
-
deleteTabItem: this.deleteTabItem
|
|
316
|
+
deleteTabItem: this.deleteTabItem,
|
|
317
|
+
handleKeyDown: this.foundation.handleKeyDown
|
|
317
318
|
};
|
|
318
319
|
const tabBar = renderTabBar ? renderTabBar(tabBarProps, TabBar) : /*#__PURE__*/React.createElement(TabBar, _Object$assign({}, tabBarProps));
|
|
319
320
|
const content = keepDOM ? children : this.getActiveItem();
|
|
@@ -48,6 +48,7 @@ export interface TabBarProps {
|
|
|
48
48
|
dropdownStyle?: CSSProperties;
|
|
49
49
|
closable?: boolean;
|
|
50
50
|
deleteTabItem?: (tabKey: string, event: MouseEvent<Element>) => void;
|
|
51
|
+
handleKeyDown?: (event: React.KeyboardEvent, itemKey: string, closable: boolean) => void;
|
|
51
52
|
}
|
|
52
53
|
export interface TabPaneProps {
|
|
53
54
|
className?: string;
|
package/lib/es/tag/index.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export default class Tag extends Component<TagProps, TagState> {
|
|
|
21
21
|
className: PropTypes.Requireable<string>;
|
|
22
22
|
avatarSrc: PropTypes.Requireable<string>;
|
|
23
23
|
avatarShape: PropTypes.Requireable<string>;
|
|
24
|
+
'aria-label': PropTypes.Requireable<string>;
|
|
24
25
|
};
|
|
25
26
|
constructor(props: TagProps);
|
|
26
27
|
static getDerivedStateFromProps(nextProps: TagProps): {
|
|
@@ -28,6 +29,7 @@ export default class Tag extends Component<TagProps, TagState> {
|
|
|
28
29
|
};
|
|
29
30
|
setVisible(visible: boolean): void;
|
|
30
31
|
close(e: React.MouseEvent<HTMLElement>, value: React.ReactNode): void;
|
|
32
|
+
handleKeyDown(event: any): void;
|
|
31
33
|
renderAvatar(): JSX.Element;
|
|
32
34
|
render(): JSX.Element;
|
|
33
35
|
}
|
package/lib/es/tag/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _isString from "lodash/isString";
|
|
1
2
|
import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
|
|
2
3
|
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
|
3
4
|
import _bindInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/bind";
|
|
@@ -14,6 +15,8 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
14
15
|
}
|
|
15
16
|
return t;
|
|
16
17
|
};
|
|
18
|
+
/* eslint-disable jsx-a11y/no-static-element-interactions */
|
|
19
|
+
|
|
17
20
|
/* eslint-disable no-unused-vars */
|
|
18
21
|
|
|
19
22
|
/* eslint-disable max-len */
|
|
@@ -25,6 +28,7 @@ import PropTypes from 'prop-types';
|
|
|
25
28
|
import { cssClasses, strings } from '@douyinfe/semi-foundation/lib/es/tag/constants';
|
|
26
29
|
import Avatar from '../avatar/index';
|
|
27
30
|
import { IconClose } from '@douyinfe/semi-icons';
|
|
31
|
+
import { handlePrevent } from '@douyinfe/semi-foundation/lib/es/utils/a11y';
|
|
28
32
|
import '@douyinfe/semi-foundation/lib/es/tag/tag.css';
|
|
29
33
|
export * from './interface';
|
|
30
34
|
const prefixCls = cssClasses.PREFIX;
|
|
@@ -34,13 +38,14 @@ const tagType = strings.TAG_TYPE;
|
|
|
34
38
|
const avatarShapeSet = strings.AVATAR_SHAPE;
|
|
35
39
|
export default class Tag extends Component {
|
|
36
40
|
constructor(props) {
|
|
37
|
-
var _context;
|
|
41
|
+
var _context, _context2;
|
|
38
42
|
|
|
39
43
|
super(props);
|
|
40
44
|
this.state = {
|
|
41
45
|
visible: true
|
|
42
46
|
};
|
|
43
47
|
this.close = _bindInstanceProperty(_context = this.close).call(_context, this);
|
|
48
|
+
this.handleKeyDown = _bindInstanceProperty(_context2 = this.handleKeyDown).call(_context2, this);
|
|
44
49
|
} // any other way to achieve this?
|
|
45
50
|
|
|
46
51
|
|
|
@@ -77,6 +82,33 @@ export default class Tag extends Component {
|
|
|
77
82
|
this.setVisible(false);
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
handleKeyDown(event) {
|
|
86
|
+
const {
|
|
87
|
+
closable,
|
|
88
|
+
onClick
|
|
89
|
+
} = this.props;
|
|
90
|
+
|
|
91
|
+
switch (event.key) {
|
|
92
|
+
case "Backspace":
|
|
93
|
+
case "Delete":
|
|
94
|
+
closable && this.close(event, this.props.children);
|
|
95
|
+
handlePrevent(event);
|
|
96
|
+
break;
|
|
97
|
+
|
|
98
|
+
case "Enter":
|
|
99
|
+
onClick(event);
|
|
100
|
+
handlePrevent(event);
|
|
101
|
+
break;
|
|
102
|
+
|
|
103
|
+
case 'Escape':
|
|
104
|
+
event.target.blur();
|
|
105
|
+
break;
|
|
106
|
+
|
|
107
|
+
default:
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
80
112
|
renderAvatar() {
|
|
81
113
|
const {
|
|
82
114
|
avatarShape,
|
|
@@ -90,7 +122,7 @@ export default class Tag extends Component {
|
|
|
90
122
|
}
|
|
91
123
|
|
|
92
124
|
render() {
|
|
93
|
-
var
|
|
125
|
+
var _context3, _context4, _context5, _context6, _context7;
|
|
94
126
|
|
|
95
127
|
const _a = this.props,
|
|
96
128
|
{
|
|
@@ -100,37 +132,51 @@ export default class Tag extends Component {
|
|
|
100
132
|
closable,
|
|
101
133
|
visible,
|
|
102
134
|
onClose,
|
|
135
|
+
onClick,
|
|
103
136
|
className,
|
|
104
137
|
type,
|
|
105
138
|
avatarSrc,
|
|
106
139
|
avatarShape
|
|
107
140
|
} = _a,
|
|
108
|
-
attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "className", "type", "avatarSrc", "avatarShape"]);
|
|
141
|
+
attr = __rest(_a, ["children", "size", "color", "closable", "visible", "onClose", "onClick", "className", "type", "avatarSrc", "avatarShape"]);
|
|
109
142
|
|
|
110
143
|
const {
|
|
111
144
|
visible: isVisible
|
|
112
145
|
} = this.state;
|
|
146
|
+
const clickable = onClick !== Tag.defaultProps.onClick || closable;
|
|
147
|
+
const a11yProps = {
|
|
148
|
+
role: 'button',
|
|
149
|
+
tabIndex: 0,
|
|
150
|
+
onKeyDown: this.handleKeyDown
|
|
151
|
+
};
|
|
113
152
|
|
|
114
153
|
const baseProps = _Object$assign(_Object$assign({}, attr), {
|
|
154
|
+
onClick,
|
|
115
155
|
className: classNames(prefixCls, {
|
|
116
156
|
["".concat(prefixCls, "-default")]: size === 'default',
|
|
117
157
|
["".concat(prefixCls, "-small")]: size === 'small',
|
|
118
158
|
["".concat(prefixCls, "-large")]: size === 'large',
|
|
119
|
-
[_concatInstanceProperty(
|
|
120
|
-
[_concatInstanceProperty(
|
|
159
|
+
[_concatInstanceProperty(_context3 = "".concat(prefixCls, "-")).call(_context3, type)]: type,
|
|
160
|
+
[_concatInstanceProperty(_context4 = _concatInstanceProperty(_context5 = "".concat(prefixCls, "-")).call(_context5, color, "-")).call(_context4, type)]: color && type,
|
|
121
161
|
["".concat(prefixCls, "-closable")]: closable,
|
|
122
162
|
["".concat(prefixCls, "-invisible")]: !isVisible,
|
|
123
|
-
[_concatInstanceProperty(
|
|
163
|
+
[_concatInstanceProperty(_context6 = "".concat(prefixCls, "-avatar-")).call(_context6, avatarShape)]: avatarSrc
|
|
124
164
|
}, className)
|
|
125
165
|
});
|
|
126
166
|
|
|
127
|
-
const
|
|
167
|
+
const wrapProps = clickable ? _Object$assign(_Object$assign({}, baseProps), a11yProps) : baseProps;
|
|
168
|
+
const closeIcon = closable ?
|
|
169
|
+
/*#__PURE__*/
|
|
170
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events
|
|
171
|
+
React.createElement("div", {
|
|
128
172
|
className: "".concat(prefixCls, "-close"),
|
|
129
173
|
onClick: e => this.close(e, children)
|
|
130
174
|
}, /*#__PURE__*/React.createElement(IconClose, {
|
|
131
175
|
size: "small"
|
|
132
176
|
})) : null;
|
|
133
|
-
return /*#__PURE__*/React.createElement("div", _Object$assign({
|
|
177
|
+
return /*#__PURE__*/React.createElement("div", _Object$assign({
|
|
178
|
+
"aria-label": this.props['aria-label'] || _isString(children) ? _concatInstanceProperty(_context7 = "".concat(closable ? 'Closable ' : '', "Tag: ")).call(_context7, children) : ''
|
|
179
|
+
}, wrapProps), /*#__PURE__*/React.createElement("div", {
|
|
134
180
|
className: "".concat(prefixCls, "-content")
|
|
135
181
|
}, avatarSrc ? this.renderAvatar() : null, children, closeIcon));
|
|
136
182
|
}
|
|
@@ -160,5 +206,6 @@ Tag.propTypes = {
|
|
|
160
206
|
style: PropTypes.object,
|
|
161
207
|
className: PropTypes.string,
|
|
162
208
|
avatarSrc: PropTypes.string,
|
|
163
|
-
avatarShape: PropTypes.oneOf(avatarShapeSet)
|
|
209
|
+
avatarShape: PropTypes.oneOf(avatarShapeSet),
|
|
210
|
+
'aria-label': PropTypes.string
|
|
164
211
|
};
|
package/lib/es/tagInput/index.js
CHANGED
|
@@ -251,7 +251,7 @@ class TagInput extends BaseComponent {
|
|
|
251
251
|
if (_isFunction(renderTagItem)) {
|
|
252
252
|
item = renderTagItem(value, index);
|
|
253
253
|
} else {
|
|
254
|
-
var _context2;
|
|
254
|
+
var _context2, _context3;
|
|
255
255
|
|
|
256
256
|
item = /*#__PURE__*/React.createElement(Tag, {
|
|
257
257
|
className: tagCls,
|
|
@@ -263,7 +263,8 @@ class TagInput extends BaseComponent {
|
|
|
263
263
|
},
|
|
264
264
|
closable: !disabled,
|
|
265
265
|
key: _concatInstanceProperty(_context2 = "".concat(index)).call(_context2, value),
|
|
266
|
-
visible: true
|
|
266
|
+
visible: true,
|
|
267
|
+
"aria-label": _concatInstanceProperty(_context3 = "".concat(!disabled ? 'Closable ' : '', "Tag: ")).call(_context3, value)
|
|
267
268
|
}, /*#__PURE__*/React.createElement(Paragraph, {
|
|
268
269
|
className: typoCls,
|
|
269
270
|
ellipsis: {
|
|
@@ -15,12 +15,15 @@ const TooltipTransition = function () {
|
|
|
15
15
|
const {
|
|
16
16
|
children
|
|
17
17
|
} = props;
|
|
18
|
-
const motion = getMotionObjFromProps(props);
|
|
18
|
+
const motion = getMotionObjFromProps(props); // add fillMode forward to fix issue 715, tooltip close will flashing under react 18
|
|
19
|
+
|
|
19
20
|
return /*#__PURE__*/React.createElement(StyledTransition, _Object$assign({}, props, {
|
|
20
21
|
enter: enterCls,
|
|
21
22
|
leave: leaveCls,
|
|
22
23
|
duration: '100ms'
|
|
23
|
-
}, motion
|
|
24
|
+
}, motion, {
|
|
25
|
+
fillMode: 'forward'
|
|
26
|
+
}), typeof children === 'function' ? _ref => {
|
|
24
27
|
let {
|
|
25
28
|
animateCls,
|
|
26
29
|
animateEvents,
|
|
@@ -5,13 +5,13 @@ import _isEmpty from "lodash/isEmpty";
|
|
|
5
5
|
import _isString from "lodash/isString";
|
|
6
6
|
import _isEqual from "lodash/isEqual";
|
|
7
7
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
8
|
+
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
8
9
|
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
|
9
10
|
import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
|
|
10
11
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
11
12
|
import _Promise from "@babel/runtime-corejs3/core-js-stable/promise";
|
|
12
13
|
import _Set from "@babel/runtime-corejs3/core-js-stable/set";
|
|
13
14
|
import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
|
|
14
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
|
15
15
|
import React, { Fragment } from 'react';
|
|
16
16
|
import ReactDOM from 'react-dom';
|
|
17
17
|
import cls from 'classnames';
|
|
@@ -179,7 +179,7 @@ class TreeSelect extends BaseComponent {
|
|
|
179
179
|
|
|
180
180
|
if (checkRelation === 'related') {
|
|
181
181
|
renderKeys = normalizeKeyList([...checkedKeys], keyEntities, leafOnly);
|
|
182
|
-
} else if (checkRelation === 'unRelated') {
|
|
182
|
+
} else if (checkRelation === 'unRelated' && _Object$keys(keyEntities).length > 0) {
|
|
183
183
|
renderKeys = [...realCheckedKeys];
|
|
184
184
|
}
|
|
185
185
|
|
package/modal/Modal.tsx
CHANGED
|
@@ -103,7 +103,7 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
103
103
|
onOk: noop,
|
|
104
104
|
afterClose: noop,
|
|
105
105
|
maskFixed: false,
|
|
106
|
-
closeOnEsc:
|
|
106
|
+
closeOnEsc: true,
|
|
107
107
|
size: 'small',
|
|
108
108
|
keepDOM: false,
|
|
109
109
|
lazyRender: true,
|
|
@@ -290,6 +290,7 @@ class Modal extends BaseComponent<ModalReactProps, ModalState> {
|
|
|
290
290
|
onClick={this.handleCancel}
|
|
291
291
|
loading={cancelLoading}
|
|
292
292
|
type="tertiary"
|
|
293
|
+
autoFocus={true}
|
|
293
294
|
{...this.props.cancelButtonProps}
|
|
294
295
|
>
|
|
295
296
|
{cancelText || locale.cancel}
|
package/modal/ModalContent.tsx
CHANGED
|
@@ -13,9 +13,9 @@ import ModalContentFoundation, {
|
|
|
13
13
|
ModalContentProps,
|
|
14
14
|
ModalContentState
|
|
15
15
|
} from '@douyinfe/semi-foundation/modal/modalContentFoundation';
|
|
16
|
-
import {
|
|
16
|
+
import { get, isFunction, noop } from 'lodash';
|
|
17
17
|
import { IconClose } from '@douyinfe/semi-icons';
|
|
18
|
-
import
|
|
18
|
+
import FocusTrapHandle from "@douyinfe/semi-foundation/utils/FocusHandle";
|
|
19
19
|
|
|
20
20
|
let uuid = 0;
|
|
21
21
|
|
|
@@ -23,6 +23,7 @@ let uuid = 0;
|
|
|
23
23
|
export interface ModalContentReactProps extends ModalContentProps {
|
|
24
24
|
children?: React.ReactNode;
|
|
25
25
|
}
|
|
26
|
+
|
|
26
27
|
export default class ModalContent extends BaseComponent<ModalContentReactProps, ModalContentState> {
|
|
27
28
|
static contextType = ConfigContext;
|
|
28
29
|
static propTypes = {
|
|
@@ -45,12 +46,13 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
|
|
|
45
46
|
modalDialogRef: React.MutableRefObject<HTMLDivElement>;
|
|
46
47
|
foundation: ModalContentFoundation;
|
|
47
48
|
context: ContextValue;
|
|
49
|
+
focusTrapHandle: FocusTrapHandle;
|
|
48
50
|
|
|
49
51
|
constructor(props: ModalContentProps) {
|
|
50
52
|
super(props);
|
|
51
53
|
this.state = {
|
|
52
54
|
dialogMouseDown: false,
|
|
53
|
-
prevFocusElement: getActiveElement(),
|
|
55
|
+
prevFocusElement: FocusTrapHandle.getActiveElement(),
|
|
54
56
|
};
|
|
55
57
|
this.foundation = new ModalContentFoundation(this.adapter);
|
|
56
58
|
this.dialogId = `dialog-${uuid++}`;
|
|
@@ -88,15 +90,18 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
|
|
|
88
90
|
modalDialogFocus: () => {
|
|
89
91
|
let activeElementInDialog;
|
|
90
92
|
if (this.modalDialogRef) {
|
|
91
|
-
const activeElement = getActiveElement();
|
|
93
|
+
const activeElement = FocusTrapHandle.getActiveElement();
|
|
92
94
|
activeElementInDialog = this.modalDialogRef.current.contains(activeElement);
|
|
95
|
+
this.focusTrapHandle?.destroy();
|
|
96
|
+
this.focusTrapHandle = new FocusTrapHandle(this.modalDialogRef.current);
|
|
93
97
|
}
|
|
94
98
|
if (!activeElementInDialog) {
|
|
95
|
-
this.modalDialogRef
|
|
99
|
+
this.modalDialogRef?.current?.focus();
|
|
96
100
|
}
|
|
97
101
|
},
|
|
98
102
|
modalDialogBlur: () => {
|
|
99
|
-
this.modalDialogRef
|
|
103
|
+
this.modalDialogRef?.current.blur();
|
|
104
|
+
this.focusTrapHandle?.destroy();
|
|
100
105
|
},
|
|
101
106
|
prevFocusElementReFocus: () => {
|
|
102
107
|
const { prevFocusElement } = this.state;
|
|
@@ -192,7 +197,8 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
|
|
|
192
197
|
(
|
|
193
198
|
<div className={`${cssClasses.DIALOG}-header`}>
|
|
194
199
|
{icon}
|
|
195
|
-
<Typography.Title heading={5} className={`${cssClasses.DIALOG}-title`}
|
|
200
|
+
<Typography.Title heading={5} className={`${cssClasses.DIALOG}-title`}
|
|
201
|
+
id={`${cssClasses.DIALOG}-title`}>{title}</Typography.Title>
|
|
196
202
|
{closer}
|
|
197
203
|
</div>
|
|
198
204
|
);
|
|
@@ -255,6 +261,7 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
|
|
|
255
261
|
<div
|
|
256
262
|
role="dialog"
|
|
257
263
|
ref={this.modalDialogRef}
|
|
264
|
+
tabIndex={-1}
|
|
258
265
|
aria-modal="true"
|
|
259
266
|
aria-labelledby={`${cssClasses.DIALOG}-title`}
|
|
260
267
|
aria-describedby={`${cssClasses.DIALOG}-body`}
|
|
@@ -304,7 +311,6 @@ export default class ModalContent extends BaseComponent<ModalContentReactProps,
|
|
|
304
311
|
</div>
|
|
305
312
|
);
|
|
306
313
|
|
|
307
|
-
// @ts-ignore Unreachable branch
|
|
308
314
|
// eslint-disable-next-line max-len
|
|
309
315
|
return containerContext && containerContext.Provider ?
|
|
310
316
|
<containerContext.Provider value={containerContext.value}>{elem}</containerContext.Provider> : elem;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0-beta.1",
|
|
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.12.0-beta.1",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.12.0-beta.1",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.12.0-beta.1",
|
|
20
|
+
"@douyinfe/semi-icons": "2.12.0-beta.1",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.12.0-beta.1",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.12.0-beta.1",
|
|
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": "65e57208ade0892136b2d31ea8983d47a9029f22",
|
|
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.12.0-beta.1",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
package/progress/index.tsx
CHANGED
|
@@ -239,7 +239,7 @@ class Progress extends Component<ProgressProps, ProgressState> {
|
|
|
239
239
|
const percNumber = this.calcPercent(percentNumber);
|
|
240
240
|
|
|
241
241
|
const innerStyle: Record<string, any> = {
|
|
242
|
-
|
|
242
|
+
background: stroke
|
|
243
243
|
};
|
|
244
244
|
if (direction === strings.DEFAULT_DIRECTION) {
|
|
245
245
|
innerStyle.width = `${perc}%`;
|
package/select/index.tsx
CHANGED
|
@@ -842,8 +842,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
842
842
|
onScroll={e => this.foundation.handleListScroll(e)}
|
|
843
843
|
>
|
|
844
844
|
{innerTopSlot}
|
|
845
|
-
{
|
|
846
|
-
{isEmpty && !loading ? this.renderEmpty() : null}
|
|
845
|
+
{loading ? this.renderLoading() : isEmpty ? this.renderEmpty() : listContent}
|
|
847
846
|
{innerBottomSlot}
|
|
848
847
|
</div>
|
|
849
848
|
{outerBottomSlot}
|
package/slider/index.tsx
CHANGED
|
@@ -479,7 +479,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
|
|
|
479
479
|
};
|
|
480
480
|
trackStyle = included ? trackStyle : {};
|
|
481
481
|
return (// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
482
|
-
<div className={cssClasses.TRACK} style={trackStyle} onClick={
|
|
482
|
+
<div className={cssClasses.TRACK} style={trackStyle} onClick={this.foundation.handleWrapClick}>
|
|
483
483
|
{/* {this.renderTrack} */}
|
|
484
484
|
</div>
|
|
485
485
|
);
|
|
@@ -501,7 +501,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
|
|
|
501
501
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
502
502
|
<span
|
|
503
503
|
key={mark}
|
|
504
|
-
onClick={
|
|
504
|
+
onClick={this.foundation.handleWrapClick}
|
|
505
505
|
className={markClass}
|
|
506
506
|
style={{ [stylePos]: `calc(${markPercent * 100}% - 2px)` }}
|
|
507
507
|
/>
|
|
@@ -522,10 +522,12 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
|
|
|
522
522
|
const activeResult = this.foundation.isMarkActive(Number(mark));
|
|
523
523
|
const markPercent = (Number(mark) - min) / (max - min);
|
|
524
524
|
return activeResult ? (
|
|
525
|
+
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
525
526
|
<span
|
|
526
527
|
key={mark}
|
|
527
528
|
className={cls(`${prefixCls}-mark${(vertical && verticalReverse) ? '-reverse' : ''}`)}
|
|
528
529
|
style={{ [stylePos]: `${markPercent * 100}%` }}
|
|
530
|
+
onClick={this.foundation.handleWrapClick}
|
|
529
531
|
>
|
|
530
532
|
{marks[mark]}
|
|
531
533
|
</span>
|
|
@@ -565,7 +567,7 @@ export default class Slider extends BaseComponent<SliderProps, SliderState> {
|
|
|
565
567
|
{// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
|
566
568
|
<div
|
|
567
569
|
className={`${prefixCls}-rail`}
|
|
568
|
-
onClick={
|
|
570
|
+
onClick={this.foundation.handleWrapClick}
|
|
569
571
|
style={this.props.railStyle}
|
|
570
572
|
/>
|
|
571
573
|
}
|