@douyinfe/semi-ui 2.10.2-alpha.1 → 2.11.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/checkbox/checkbox.tsx +16 -6
- package/datePicker/_story/datePicker.stories.js +48 -1
- package/datePicker/_story/v2/AutoFillTime.jsx +37 -0
- package/datePicker/_story/v2/InputFormat.jsx +29 -0
- package/datePicker/_story/v2/InputFormatConfirm.jsx +44 -0
- package/datePicker/_story/v2/InputFormatDisabled.jsx +27 -0
- package/datePicker/_story/v2/index.js +4 -0
- package/datePicker/dateInput.tsx +7 -0
- package/datePicker/datePicker.tsx +7 -11
- package/datePicker/monthsGrid.tsx +2 -1
- package/dist/css/semi.css +0 -1
- package/dist/umd/semi-ui.js +843 -518
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/checkbox/checkbox.d.ts +4 -0
- package/lib/cjs/checkbox/checkbox.js +23 -11
- package/lib/cjs/datePicker/dateInput.d.ts +1 -0
- package/lib/cjs/datePicker/dateInput.js +5 -3
- package/lib/cjs/datePicker/datePicker.js +9 -12
- package/lib/cjs/datePicker/monthsGrid.js +2 -1
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/radio/radio.d.ts +4 -0
- package/lib/cjs/radio/radio.js +26 -12
- package/lib/cjs/tag/group.d.ts +3 -3
- package/lib/cjs/tooltip/index.d.ts +1 -0
- package/lib/cjs/tooltip/index.js +6 -1
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/es/checkbox/checkbox.d.ts +4 -0
- package/lib/es/checkbox/checkbox.js +23 -11
- package/lib/es/datePicker/dateInput.d.ts +1 -0
- package/lib/es/datePicker/dateInput.js +5 -3
- package/lib/es/datePicker/datePicker.js +9 -12
- package/lib/es/datePicker/monthsGrid.js +2 -1
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/radio/radio.d.ts +4 -0
- package/lib/es/radio/radio.js +26 -12
- package/lib/es/tag/group.d.ts +3 -3
- package/lib/es/tooltip/index.d.ts +1 -0
- package/lib/es/tooltip/index.js +6 -1
- package/lib/es/typography/title.d.ts +1 -1
- package/package.json +9 -9
- package/radio/radio.tsx +17 -7
- package/scrollList/_story/ScrollList/index.js +1 -1
- package/select/index.tsx +7 -7
- package/tag/group.tsx +4 -4
- package/tooltip/index.tsx +5 -1
- package/treeSelect/index.tsx +1 -1
- package/upload/_story/upload.stories.js +1 -0
package/lib/es/radio/radio.js
CHANGED
|
@@ -44,16 +44,12 @@ class Radio extends BaseComponent {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
this.state = {
|
|
47
|
-
hover: false
|
|
47
|
+
hover: false,
|
|
48
|
+
addonId: props.addonId,
|
|
49
|
+
extraId: props.extraId
|
|
48
50
|
};
|
|
49
51
|
this.foundation = new RadioFoundation(this.adapter);
|
|
50
52
|
this.radioEntity = null;
|
|
51
|
-
this.addonId = getUuidShort({
|
|
52
|
-
prefix: 'addon'
|
|
53
|
-
});
|
|
54
|
-
this.extraId = getUuidShort({
|
|
55
|
-
prefix: 'extra'
|
|
56
|
-
});
|
|
57
53
|
}
|
|
58
54
|
|
|
59
55
|
get adapter() {
|
|
@@ -62,6 +58,20 @@ class Radio extends BaseComponent {
|
|
|
62
58
|
this.setState({
|
|
63
59
|
hover
|
|
64
60
|
});
|
|
61
|
+
},
|
|
62
|
+
setAddonId: () => {
|
|
63
|
+
this.setState({
|
|
64
|
+
addonId: getUuidShort({
|
|
65
|
+
prefix: 'addon'
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
setExtraId: () => {
|
|
70
|
+
this.setState({
|
|
71
|
+
extraId: getUuidShort({
|
|
72
|
+
prefix: 'extra'
|
|
73
|
+
})
|
|
74
|
+
});
|
|
65
75
|
}
|
|
66
76
|
});
|
|
67
77
|
}
|
|
@@ -98,7 +108,11 @@ class Radio extends BaseComponent {
|
|
|
98
108
|
value: propValue
|
|
99
109
|
} = this.props;
|
|
100
110
|
let realChecked, isDisabled, realMode, isButtonRadioGroup, isCardRadioGroup, isPureCardRadioGroup, isButtonRadioComponent, buttonSize, realPrefixCls;
|
|
101
|
-
const
|
|
111
|
+
const {
|
|
112
|
+
hover: isHover,
|
|
113
|
+
addonId,
|
|
114
|
+
extraId
|
|
115
|
+
} = this.state;
|
|
102
116
|
let props = {};
|
|
103
117
|
|
|
104
118
|
if (this.isInGroup()) {
|
|
@@ -151,10 +165,10 @@ class Radio extends BaseComponent {
|
|
|
151
165
|
const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
|
|
152
166
|
className: addonCls,
|
|
153
167
|
style: addonStyle,
|
|
154
|
-
id:
|
|
168
|
+
id: addonId
|
|
155
169
|
}, children) : null, extra && !isButtonRadio ? /*#__PURE__*/React.createElement("div", {
|
|
156
170
|
className: "".concat(prefix, "-extra"),
|
|
157
|
-
id:
|
|
171
|
+
id: extraId
|
|
158
172
|
}, extra) : null);
|
|
159
173
|
|
|
160
174
|
return /*#__PURE__*/React.createElement("label", {
|
|
@@ -171,8 +185,8 @@ class Radio extends BaseComponent {
|
|
|
171
185
|
ref: ref => {
|
|
172
186
|
this.radioEntity = ref;
|
|
173
187
|
},
|
|
174
|
-
addonId: children &&
|
|
175
|
-
extraId: extra &&
|
|
188
|
+
addonId: children && addonId,
|
|
189
|
+
extraId: extra && extraId
|
|
176
190
|
})), isCardRadioGroup ? /*#__PURE__*/React.createElement("div", {
|
|
177
191
|
className: "".concat(prefix, "-isCardRadioGroup_content")
|
|
178
192
|
}, renderContent()) : renderContent());
|
package/lib/es/tag/group.d.ts
CHANGED
|
@@ -3,19 +3,19 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import Tag from './index';
|
|
4
4
|
import { PopoverProps } from '../popover/index';
|
|
5
5
|
import { AvatarShape, TagProps } from './interface';
|
|
6
|
-
export interface TagGroupProps {
|
|
6
|
+
export interface TagGroupProps<T> {
|
|
7
7
|
style?: React.CSSProperties;
|
|
8
8
|
className?: string;
|
|
9
9
|
maxTagCount?: number;
|
|
10
10
|
restCount?: number;
|
|
11
|
-
tagList?: (
|
|
11
|
+
tagList?: (T extends 'custom' ? React.ReactNode : TagProps)[];
|
|
12
12
|
size?: 'small' | 'large';
|
|
13
13
|
showPopover?: boolean;
|
|
14
14
|
popoverProps?: PopoverProps;
|
|
15
15
|
avatarShape?: AvatarShape;
|
|
16
16
|
mode?: string;
|
|
17
17
|
}
|
|
18
|
-
export default class TagGroup extends PureComponent<TagGroupProps
|
|
18
|
+
export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
19
19
|
static defaultProps: {
|
|
20
20
|
style: {};
|
|
21
21
|
className: string;
|
package/lib/es/tooltip/index.js
CHANGED
|
@@ -293,7 +293,7 @@ export default class Tooltip extends BaseComponent {
|
|
|
293
293
|
placement: props.position || 'top',
|
|
294
294
|
transitionStyle: {},
|
|
295
295
|
isPositionUpdated: false,
|
|
296
|
-
id:
|
|
296
|
+
id: props.wrapperId // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
|
|
297
297
|
|
|
298
298
|
};
|
|
299
299
|
this.foundation = new TooltipFoundation(this.adapter);
|
|
@@ -562,6 +562,11 @@ export default class Tooltip extends BaseComponent {
|
|
|
562
562
|
},
|
|
563
563
|
notifyEscKeydown: event => {
|
|
564
564
|
this.props.onEscKeyDown(event);
|
|
565
|
+
},
|
|
566
|
+
setId: () => {
|
|
567
|
+
this.setState({
|
|
568
|
+
id: getUuidShort()
|
|
569
|
+
});
|
|
565
570
|
}
|
|
566
571
|
});
|
|
567
572
|
}
|
|
@@ -37,7 +37,7 @@ export default class Title extends PureComponent<TitleProps> {
|
|
|
37
37
|
underline: PropTypes.Requireable<boolean>;
|
|
38
38
|
strong: PropTypes.Requireable<boolean>;
|
|
39
39
|
type: PropTypes.Requireable<"warning" | "success" | "primary" | "tertiary" | "secondary" | "danger" | "quaternary">;
|
|
40
|
-
heading: PropTypes.Requireable<
|
|
40
|
+
heading: PropTypes.Requireable<1 | 2 | 3 | 4 | 5 | 6>;
|
|
41
41
|
style: PropTypes.Requireable<object>;
|
|
42
42
|
className: PropTypes.Requireable<string>;
|
|
43
43
|
component: PropTypes.Requireable<string>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -14,12 +14,12 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
17
|
-
"@douyinfe/semi-animation": "2.
|
|
18
|
-
"@douyinfe/semi-animation-react": "2.
|
|
19
|
-
"@douyinfe/semi-foundation": "2.
|
|
20
|
-
"@douyinfe/semi-icons": "2.
|
|
21
|
-
"@douyinfe/semi-illustrations": "2.
|
|
22
|
-
"@douyinfe/semi-theme-default": "2.
|
|
17
|
+
"@douyinfe/semi-animation": "2.11.0-beta.0",
|
|
18
|
+
"@douyinfe/semi-animation-react": "2.11.0-beta.0",
|
|
19
|
+
"@douyinfe/semi-foundation": "2.11.0-beta.0",
|
|
20
|
+
"@douyinfe/semi-icons": "2.11.0-beta.0",
|
|
21
|
+
"@douyinfe/semi-illustrations": "2.11.0-beta.0",
|
|
22
|
+
"@douyinfe/semi-theme-default": "2.11.0-beta.0",
|
|
23
23
|
"@types/react-window": "^1.8.2",
|
|
24
24
|
"async-validator": "^3.5.0",
|
|
25
25
|
"classnames": "^2.2.6",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
],
|
|
70
70
|
"author": "",
|
|
71
71
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "252c53310656cdc47124d257b878c131d8a74ef2",
|
|
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.11.0-beta.0",
|
|
79
79
|
"@storybook/addon-knobs": "^6.3.1",
|
|
80
80
|
"@types/lodash": "^4.14.176",
|
|
81
81
|
"babel-loader": "^8.2.2",
|
package/radio/radio.tsx
CHANGED
|
@@ -41,10 +41,14 @@ export type RadioProps = {
|
|
|
41
41
|
addonClassName?: string;
|
|
42
42
|
type?: RadioType;
|
|
43
43
|
'aria-label'?: React.AriaAttributes['aria-label'];
|
|
44
|
+
addonId?: string;
|
|
45
|
+
extraId?: string;
|
|
44
46
|
};
|
|
45
47
|
|
|
46
48
|
export interface RadioState {
|
|
47
49
|
hover?: boolean;
|
|
50
|
+
addonId?: string;
|
|
51
|
+
extraId?: string;
|
|
48
52
|
}
|
|
49
53
|
|
|
50
54
|
export { RadioChangeEvent };
|
|
@@ -94,11 +98,11 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
94
98
|
super(props);
|
|
95
99
|
this.state = {
|
|
96
100
|
hover: false,
|
|
101
|
+
addonId: props.addonId,
|
|
102
|
+
extraId: props.extraId,
|
|
97
103
|
};
|
|
98
104
|
this.foundation = new RadioFoundation(this.adapter);
|
|
99
105
|
this.radioEntity = null;
|
|
100
|
-
this.addonId = getUuidShort({ prefix: 'addon' });
|
|
101
|
-
this.extraId = getUuidShort({ prefix: 'extra' });
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
get adapter(): RadioAdapter {
|
|
@@ -106,6 +110,12 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
106
110
|
...super.adapter,
|
|
107
111
|
setHover: (hover: boolean) => {
|
|
108
112
|
this.setState({ hover });
|
|
113
|
+
},
|
|
114
|
+
setAddonId: () => {
|
|
115
|
+
this.setState({ addonId: getUuidShort({ prefix: 'addon' }) });
|
|
116
|
+
},
|
|
117
|
+
setExtraId: () => {
|
|
118
|
+
this.setState({ extraId: getUuidShort({ prefix: 'extra' }) });
|
|
109
119
|
}
|
|
110
120
|
};
|
|
111
121
|
}
|
|
@@ -168,7 +178,7 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
168
178
|
isButtonRadioComponent,
|
|
169
179
|
buttonSize,
|
|
170
180
|
realPrefixCls;
|
|
171
|
-
const isHover = this.state
|
|
181
|
+
const { hover: isHover, addonId, extraId } = this.state;
|
|
172
182
|
let props = {};
|
|
173
183
|
|
|
174
184
|
if (this.isInGroup()) {
|
|
@@ -218,8 +228,8 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
218
228
|
}, addonClassName);
|
|
219
229
|
const renderContent = () => (
|
|
220
230
|
<>
|
|
221
|
-
{children ? <span className={addonCls} style={addonStyle} id={
|
|
222
|
-
{extra && !isButtonRadio ? <div className={`${prefix}-extra`} id={
|
|
231
|
+
{children ? <span className={addonCls} style={addonStyle} id={addonId}>{children}</span> : null}
|
|
232
|
+
{extra && !isButtonRadio ? <div className={`${prefix}-extra`} id={extraId}>{extra}</div> : null}
|
|
223
233
|
</>
|
|
224
234
|
);
|
|
225
235
|
return (
|
|
@@ -240,8 +250,8 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
240
250
|
ref={(ref: RadioInner) => {
|
|
241
251
|
this.radioEntity = ref;
|
|
242
252
|
}}
|
|
243
|
-
addonId={children &&
|
|
244
|
-
extraId={extra &&
|
|
253
|
+
addonId={children && addonId}
|
|
254
|
+
extraId={extra && extraId}
|
|
245
255
|
/>
|
|
246
256
|
{
|
|
247
257
|
isCardRadioGroup ?
|
package/select/index.tsx
CHANGED
|
@@ -446,11 +446,11 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
446
446
|
let options = [];
|
|
447
447
|
const { optionList } = this.props;
|
|
448
448
|
if (optionList && optionList.length) {
|
|
449
|
-
options = optionList.map((itemOpt, index) => ({
|
|
450
|
-
_show: true,
|
|
451
|
-
_selected: false,
|
|
449
|
+
options = optionList.map((itemOpt, index) => ({
|
|
450
|
+
_show: true,
|
|
451
|
+
_selected: false,
|
|
452
452
|
_scrollIndex: index,
|
|
453
|
-
...itemOpt
|
|
453
|
+
...itemOpt
|
|
454
454
|
}));
|
|
455
455
|
optionGroups[0] = { children: options, label: '' };
|
|
456
456
|
} else {
|
|
@@ -771,7 +771,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
771
771
|
const groupContent = <OptionGroup {...parentGroup} key={parentGroup.label} />;
|
|
772
772
|
groupStatus.set(parentGroup.label, true);
|
|
773
773
|
content.push(groupContent);
|
|
774
|
-
}
|
|
774
|
+
}
|
|
775
775
|
content.push(optionContent);
|
|
776
776
|
});
|
|
777
777
|
|
|
@@ -899,7 +899,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
899
899
|
content: optionNode.label,
|
|
900
900
|
});
|
|
901
901
|
}
|
|
902
|
-
|
|
902
|
+
|
|
903
903
|
const mapItems = maxTagCount ? selectedItems.slice(0, maxTagCount) : selectedItems; // no need to render rest tag when maxTagCount is setting
|
|
904
904
|
|
|
905
905
|
const tags = mapItems.map((item, i) => {
|
|
@@ -946,7 +946,7 @@ class Select extends BaseComponent<SelectProps, SelectState> {
|
|
|
946
946
|
|
|
947
947
|
const NotOneLine = !maxTagCount; // Multiple lines (that is, do not set maxTagCount), do not use TagGroup, directly traverse with Tag, otherwise Input cannot follow the correct position
|
|
948
948
|
|
|
949
|
-
const tagContent = NotOneLine ? tags : <TagGroup tagList={tags} maxTagCount={n} restCount={maxTagCount ? selectedItems.length - maxTagCount : undefined} size="large" mode="custom" />;
|
|
949
|
+
const tagContent = NotOneLine ? tags : <TagGroup<"custom"> tagList={tags} maxTagCount={n} restCount={maxTagCount ? selectedItems.length - maxTagCount : undefined} size="large" mode="custom" />;
|
|
950
950
|
|
|
951
951
|
return (
|
|
952
952
|
<>
|
package/tag/group.tsx
CHANGED
|
@@ -10,12 +10,12 @@ const prefixCls = cssClasses.PREFIX;
|
|
|
10
10
|
const tagSize = strings.TAG_SIZE;
|
|
11
11
|
const avatarShapeSet = strings.AVATAR_SHAPE;
|
|
12
12
|
|
|
13
|
-
export interface TagGroupProps {
|
|
13
|
+
export interface TagGroupProps<T> {
|
|
14
14
|
style?: React.CSSProperties;
|
|
15
15
|
className?: string;
|
|
16
16
|
maxTagCount?: number;
|
|
17
17
|
restCount?: number;
|
|
18
|
-
tagList?: (
|
|
18
|
+
tagList?: (T extends 'custom' ? React.ReactNode : TagProps)[];
|
|
19
19
|
size?: 'small' | 'large';
|
|
20
20
|
showPopover?: boolean;
|
|
21
21
|
popoverProps?: PopoverProps;
|
|
@@ -23,7 +23,7 @@ export interface TagGroupProps {
|
|
|
23
23
|
mode?: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export default class TagGroup extends PureComponent<TagGroupProps
|
|
26
|
+
export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
27
27
|
static defaultProps = {
|
|
28
28
|
style: {},
|
|
29
29
|
className: '',
|
|
@@ -84,7 +84,7 @@ export default class TagGroup extends PureComponent<TagGroupProps> {
|
|
|
84
84
|
let renderTags: (Tag | React.ReactNode)[] = tags;
|
|
85
85
|
|
|
86
86
|
const normalTags: (Tag | React.ReactNode)[] = tags.slice(0, maxTagCount);
|
|
87
|
-
const restTags = tags.slice(maxTagCount) as
|
|
87
|
+
const restTags = tags.slice(maxTagCount) as React.ReactNode;
|
|
88
88
|
let nTag = null;
|
|
89
89
|
if (n > 0) {
|
|
90
90
|
nTag = this.renderNTag(n, restTags);
|
package/tooltip/index.tsx
CHANGED
|
@@ -75,6 +75,7 @@ export interface TooltipProps extends BaseProps {
|
|
|
75
75
|
guardFocus?: boolean;
|
|
76
76
|
returnFocusOnClose?: boolean;
|
|
77
77
|
onEscKeyDown?: (e: React.KeyboardEvent) => void;
|
|
78
|
+
wrapperId?: string;
|
|
78
79
|
}
|
|
79
80
|
interface TooltipState {
|
|
80
81
|
visible: boolean;
|
|
@@ -193,7 +194,7 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
193
194
|
placement: props.position || 'top',
|
|
194
195
|
transitionStyle: {},
|
|
195
196
|
isPositionUpdated: false,
|
|
196
|
-
id:
|
|
197
|
+
id: props.wrapperId, // auto generate id, will be used by children.aria-describedby & content.id, improve a11y
|
|
197
198
|
};
|
|
198
199
|
this.foundation = new TooltipFoundation(this.adapter);
|
|
199
200
|
this.eventManager = new Event();
|
|
@@ -428,6 +429,9 @@ export default class Tooltip extends BaseComponent<TooltipProps, TooltipState> {
|
|
|
428
429
|
},
|
|
429
430
|
notifyEscKeydown: (event: React.KeyboardEvent) => {
|
|
430
431
|
this.props.onEscKeyDown(event);
|
|
432
|
+
},
|
|
433
|
+
setId: () => {
|
|
434
|
+
this.setState({ id: getUuidShort() });
|
|
431
435
|
}
|
|
432
436
|
};
|
|
433
437
|
}
|
package/treeSelect/index.tsx
CHANGED
|
@@ -826,7 +826,7 @@ class TreeSelect extends BaseComponent<TreeSelectProps, TreeSelectState> {
|
|
|
826
826
|
const tagList = this.renderTagList();
|
|
827
827
|
// mode=custom to return tagList directly
|
|
828
828
|
return (
|
|
829
|
-
<TagGroup
|
|
829
|
+
<TagGroup<'custom'>
|
|
830
830
|
maxTagCount={maxTagCount}
|
|
831
831
|
tagList={tagList}
|
|
832
832
|
size="large"
|