@douyinfe/semi-ui 2.17.1 → 2.19.0-alpha.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/anchor/index.tsx +1 -1
- package/anchor/link.tsx +3 -4
- package/autoComplete/__test__/autoComplete.test.js +6 -6
- package/autoComplete/index.tsx +1 -1
- package/autoComplete/option.tsx +164 -0
- package/calendar/__test__/calendar.test.js +21 -2
- package/calendar/_story/calendar.stories.js +31 -0
- package/calendar/index.tsx +3 -1
- package/calendar/interface.ts +2 -1
- package/carousel/index.tsx +5 -5
- package/checkbox/checkbox.tsx +10 -2
- package/checkbox/checkboxGroup.tsx +2 -0
- package/dist/css/semi.css +160 -22
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +15144 -16407
- 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/FieldProps/labelOptional.jsx +30 -0
- package/form/_story/form.stories.js +7 -0
- package/form/hoc/withField.tsx +1 -0
- package/form/label.tsx +21 -7
- package/gulpfile.js +3 -1
- package/lib/cjs/_base/base.css +35 -0
- package/lib/cjs/anchor/index.js +2 -1
- package/lib/cjs/anchor/link.d.ts +1 -1
- package/lib/cjs/anchor/link.js +9 -5
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.js +1 -1
- package/lib/cjs/autoComplete/option.d.ts +50 -0
- package/lib/cjs/autoComplete/option.js +218 -0
- package/lib/cjs/calendar/index.d.ts +2 -0
- package/lib/cjs/calendar/index.js +3 -1
- package/lib/cjs/calendar/interface.d.ts +2 -1
- package/lib/cjs/carousel/index.js +2 -2
- package/lib/cjs/checkbox/checkbox.d.ts +4 -0
- package/lib/cjs/checkbox/checkbox.js +9 -3
- package/lib/cjs/checkbox/checkboxGroup.js +4 -2
- package/lib/cjs/form/baseForm.d.ts +1 -1
- package/lib/cjs/form/field.d.ts +1 -1
- package/lib/cjs/form/hoc/withField.js +2 -1
- package/lib/cjs/form/label.d.ts +8 -5
- package/lib/cjs/form/label.js +15 -4
- package/lib/cjs/locale/interface.d.ts +3 -0
- package/lib/cjs/locale/source/ar.js +3 -0
- package/lib/cjs/locale/source/de.js +3 -0
- package/lib/cjs/locale/source/en_GB.js +3 -0
- package/lib/cjs/locale/source/en_US.js +3 -0
- package/lib/cjs/locale/source/es.js +3 -0
- package/lib/cjs/locale/source/fr.js +3 -0
- package/lib/cjs/locale/source/id_ID.js +3 -0
- package/lib/cjs/locale/source/it.js +3 -0
- package/lib/cjs/locale/source/ja_JP.js +3 -0
- package/lib/cjs/locale/source/ko_KR.js +3 -0
- package/lib/cjs/locale/source/ms_MY.js +3 -0
- package/lib/cjs/locale/source/pt_BR.js +3 -0
- package/lib/cjs/locale/source/ru_RU.js +3 -0
- package/lib/cjs/locale/source/th_TH.js +3 -0
- package/lib/cjs/locale/source/tr_TR.js +3 -0
- package/lib/cjs/locale/source/vi_VN.js +3 -0
- package/lib/cjs/locale/source/zh_CN.js +3 -0
- package/lib/cjs/locale/source/zh_TW.js +3 -0
- package/lib/cjs/modal/Modal.js +0 -8
- package/lib/cjs/modal/ModalContent.js +4 -1
- package/lib/cjs/radio/radio.d.ts +2 -0
- package/lib/cjs/radio/radio.js +33 -8
- package/lib/cjs/radio/radioGroup.js +4 -2
- package/lib/cjs/tag/group.d.ts +3 -0
- package/lib/cjs/tag/group.js +24 -6
- package/lib/cjs/tag/index.d.ts +2 -1
- package/lib/cjs/tag/index.js +7 -5
- package/lib/cjs/tag/interface.d.ts +2 -1
- package/lib/cjs/tree/index.d.ts +3 -1
- package/lib/cjs/tree/index.js +23 -0
- package/lib/cjs/tree/interface.d.ts +4 -0
- package/lib/cjs/typography/title.d.ts +1 -1
- package/lib/es/_base/base.css +35 -0
- package/lib/es/anchor/index.js +2 -1
- package/lib/es/anchor/link.d.ts +1 -1
- package/lib/es/anchor/link.js +9 -5
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/autoComplete/index.js +1 -1
- package/lib/es/autoComplete/option.d.ts +50 -0
- package/lib/es/autoComplete/option.js +188 -0
- package/lib/es/calendar/index.d.ts +2 -0
- package/lib/es/calendar/index.js +3 -1
- package/lib/es/calendar/interface.d.ts +2 -1
- package/lib/es/carousel/index.js +2 -2
- package/lib/es/checkbox/checkbox.d.ts +4 -0
- package/lib/es/checkbox/checkbox.js +10 -4
- package/lib/es/checkbox/checkboxGroup.js +4 -2
- package/lib/es/form/baseForm.d.ts +1 -1
- package/lib/es/form/field.d.ts +1 -1
- package/lib/es/form/hoc/withField.js +2 -1
- package/lib/es/form/label.d.ts +8 -5
- package/lib/es/form/label.js +13 -4
- package/lib/es/locale/interface.d.ts +3 -0
- package/lib/es/locale/source/ar.js +3 -0
- package/lib/es/locale/source/de.js +3 -0
- package/lib/es/locale/source/en_GB.js +3 -0
- package/lib/es/locale/source/en_US.js +3 -0
- package/lib/es/locale/source/es.js +3 -0
- package/lib/es/locale/source/fr.js +3 -0
- package/lib/es/locale/source/id_ID.js +3 -0
- package/lib/es/locale/source/it.js +3 -0
- package/lib/es/locale/source/ja_JP.js +3 -0
- package/lib/es/locale/source/ko_KR.js +3 -0
- package/lib/es/locale/source/ms_MY.js +3 -0
- package/lib/es/locale/source/pt_BR.js +3 -0
- package/lib/es/locale/source/ru_RU.js +3 -0
- package/lib/es/locale/source/th_TH.js +3 -0
- package/lib/es/locale/source/tr_TR.js +3 -0
- package/lib/es/locale/source/vi_VN.js +3 -0
- package/lib/es/locale/source/zh_CN.js +3 -0
- package/lib/es/locale/source/zh_TW.js +3 -0
- package/lib/es/modal/Modal.js +0 -8
- package/lib/es/modal/ModalContent.js +4 -1
- package/lib/es/radio/radio.d.ts +2 -0
- package/lib/es/radio/radio.js +31 -8
- package/lib/es/radio/radioGroup.js +4 -2
- package/lib/es/tag/group.d.ts +3 -0
- package/lib/es/tag/group.js +24 -6
- package/lib/es/tag/index.d.ts +2 -1
- package/lib/es/tag/index.js +7 -5
- package/lib/es/tag/interface.d.ts +2 -1
- package/lib/es/tree/index.d.ts +3 -1
- package/lib/es/tree/index.js +22 -0
- package/lib/es/tree/interface.d.ts +4 -0
- package/lib/es/typography/title.d.ts +1 -1
- package/locale/interface.ts +3 -0
- package/locale/source/ar.ts +3 -0
- package/locale/source/de.ts +3 -0
- package/locale/source/en_GB.ts +3 -0
- package/locale/source/en_US.ts +3 -0
- package/locale/source/es.ts +3 -0
- package/locale/source/fr.ts +3 -0
- package/locale/source/id_ID.ts +3 -0
- package/locale/source/it.ts +3 -0
- package/locale/source/ja_JP.ts +3 -0
- package/locale/source/ko_KR.ts +3 -0
- package/locale/source/ms_MY.ts +3 -0
- package/locale/source/pt_BR.ts +3 -0
- package/locale/source/ru_RU.ts +3 -0
- package/locale/source/th_TH.ts +3 -0
- package/locale/source/tr_TR.ts +4 -1
- package/locale/source/vi_VN.ts +3 -0
- package/locale/source/zh_CN.ts +3 -0
- package/locale/source/zh_TW.ts +3 -0
- package/modal/Modal.tsx +0 -6
- package/modal/ModalContent.tsx +4 -1
- package/modal/__test__/modal.test.js +1 -1
- package/modal/_story/__snapshots__/modal.stories.tsx.snap +203 -0
- package/package.json +7 -7
- package/radio/_story/radio.stories.js +2 -2
- package/radio/radio.tsx +27 -5
- package/radio/radioGroup.tsx +2 -0
- package/rating/__test__/rating.test.js +1 -1
- package/select/__test__/select.test.js +11 -17
- package/select/_story/select.stories.js +6 -6
- package/steps/_story/steps.stories.js +3 -3
- package/switch/_story/switch.stories.js +4 -4
- package/switch/_story/switch.stories.tsx +4 -4
- package/tag/_story/tag.stories.js +57 -1
- package/tag/group.tsx +20 -3
- package/tag/index.tsx +6 -5
- package/tag/interface.ts +2 -1
- package/transfer/_story/transfer.stories.js +2 -2
- package/tree/_story/tree.stories.js +152 -3
- package/tree/index.tsx +16 -1
- package/tree/interface.ts +6 -0
- package/upload/_story/upload.stories.js +2 -2
- package/webpack.config.js +10 -2
|
@@ -8,7 +8,7 @@ import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/ins
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import classnames from 'classnames';
|
|
11
|
-
import { checkboxClasses as css } from '@douyinfe/semi-foundation/lib/es/checkbox/constants';
|
|
11
|
+
import { checkboxClasses as css, strings } from '@douyinfe/semi-foundation/lib/es/checkbox/constants';
|
|
12
12
|
import CheckboxFoundation from '@douyinfe/semi-foundation/lib/es/checkbox/checkboxFoundation';
|
|
13
13
|
import CheckboxInner from './checkboxInner';
|
|
14
14
|
import BaseComponent from '../_base/baseComponent';
|
|
@@ -126,7 +126,8 @@ class Checkbox extends BaseComponent {
|
|
|
126
126
|
value,
|
|
127
127
|
role,
|
|
128
128
|
tabIndex,
|
|
129
|
-
id
|
|
129
|
+
id,
|
|
130
|
+
type
|
|
130
131
|
} = this.props;
|
|
131
132
|
const {
|
|
132
133
|
checked,
|
|
@@ -160,6 +161,9 @@ class Checkbox extends BaseComponent {
|
|
|
160
161
|
props.isCardType = isCardType;
|
|
161
162
|
props.isPureCardType = isPureCardType;
|
|
162
163
|
props['name'] = this.context.checkboxGroup.name;
|
|
164
|
+
} else {
|
|
165
|
+
props.isPureCardType = type === strings.TYPE_PURECARD;
|
|
166
|
+
props.isCardType = type === strings.TYPE_CARD || props.isPureCardType;
|
|
163
167
|
}
|
|
164
168
|
|
|
165
169
|
const prefix = prefixCls || css.PREFIX;
|
|
@@ -250,13 +254,15 @@ Checkbox.propTypes = {
|
|
|
250
254
|
index: PropTypes.number,
|
|
251
255
|
'aria-label': PropTypes.string,
|
|
252
256
|
tabIndex: PropTypes.number,
|
|
253
|
-
preventScroll: PropTypes.bool
|
|
257
|
+
preventScroll: PropTypes.bool,
|
|
258
|
+
type: PropTypes.string
|
|
254
259
|
};
|
|
255
260
|
Checkbox.defaultProps = {
|
|
256
261
|
defaultChecked: false,
|
|
257
262
|
indeterminate: false,
|
|
258
263
|
onChange: _noop,
|
|
259
264
|
onMouseEnter: _noop,
|
|
260
|
-
onMouseLeave: _noop
|
|
265
|
+
onMouseLeave: _noop,
|
|
266
|
+
type: 'default'
|
|
261
267
|
};
|
|
262
268
|
export default Checkbox;
|
|
@@ -96,7 +96,8 @@ class CheckboxGroup extends BaseComponent {
|
|
|
96
96
|
key: index,
|
|
97
97
|
disabled: this.props.disabled,
|
|
98
98
|
value: option,
|
|
99
|
-
prefixCls: prefixCls
|
|
99
|
+
prefixCls: prefixCls,
|
|
100
|
+
type: type
|
|
100
101
|
}, option);
|
|
101
102
|
} else {
|
|
102
103
|
return /*#__PURE__*/React.createElement(Checkbox, {
|
|
@@ -108,7 +109,8 @@ class CheckboxGroup extends BaseComponent {
|
|
|
108
109
|
extra: option.extra,
|
|
109
110
|
className: option.className,
|
|
110
111
|
style: option.style,
|
|
111
|
-
onChange: option.onChange
|
|
112
|
+
onChange: option.onChange,
|
|
113
|
+
type: type
|
|
112
114
|
}, option.label);
|
|
113
115
|
}
|
|
114
116
|
});
|
|
@@ -126,7 +126,7 @@ declare class Form extends BaseComponent<BaseFormProps, BaseFormState> {
|
|
|
126
126
|
onListScroll?: (e: React.UIEvent<HTMLDivElement, UIEvent>) => void;
|
|
127
127
|
children?: React.ReactNode;
|
|
128
128
|
preventScroll?: boolean;
|
|
129
|
-
} & Pick<import("../tooltip").TooltipProps, "
|
|
129
|
+
} & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & React.RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
|
|
130
130
|
static Checkbox: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox").CheckboxProps & import("./interface").RCIncludeType>;
|
|
131
131
|
static CheckboxGroup: React.ComponentType<import("utility-types").Subtract<import("../checkbox").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & React.RefAttributes<any>>;
|
|
132
132
|
static Radio: React.ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../radio").RadioProps & import("./interface").RCIncludeType>;
|
package/lib/es/form/field.d.ts
CHANGED
|
@@ -74,7 +74,7 @@ declare const FormSelect: import("react").ComponentType<import("utility-types").
|
|
|
74
74
|
onListScroll?: (e: import("react").UIEvent<HTMLDivElement, UIEvent>) => void;
|
|
75
75
|
children?: import("react").ReactNode;
|
|
76
76
|
preventScroll?: boolean;
|
|
77
|
-
} & Pick<import("../tooltip").TooltipProps, "
|
|
77
|
+
} & Pick<import("../tooltip").TooltipProps, "getPopupContainer" | "stopPropagation" | "spacing" | "mouseEnterDelay" | "autoAdjustOverflow" | "mouseLeaveDelay" | "motion"> & import("react").RefAttributes<any> & import("./interface").CommonFieldProps, import("./interface").CommonexcludeType>> & import("./interface").SelectStatic;
|
|
78
78
|
declare const FormCheckboxGroup: import("react").ComponentType<import("utility-types").Subtract<import("../checkbox/checkboxGroup").CheckboxGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
|
|
79
79
|
declare const FormCheckbox: import("react").ComponentType<import("utility-types").Subtract<import("./interface").CommonFieldProps, import("./interface").RadioCheckboxExcludeProps> & import("../checkbox/checkbox").CheckboxProps & import("./interface").RCIncludeType>;
|
|
80
80
|
declare const FormRadioGroup: import("react").ComponentType<import("utility-types").Subtract<import("../radio/radioGroup").RadioGroupProps, import("./interface").CommonexcludeType> & import("./interface").CommonFieldProps & import("react").RefAttributes<any>>;
|
|
@@ -99,7 +99,8 @@ function withField(Component, opts) {
|
|
|
99
99
|
if (arrayFieldState) {
|
|
100
100
|
initVal = arrayFieldState.shouldUseInitValue && typeof initValue !== 'undefined' ? initValue : initValueInFormOpts;
|
|
101
101
|
}
|
|
102
|
-
} catch (err) {}
|
|
102
|
+
} catch (err) {} // FIXME typeof initVal
|
|
103
|
+
|
|
103
104
|
|
|
104
105
|
const [value, setValue, getVal] = useStateWithGetter(typeof initVal !== undefined ? initVal : null);
|
|
105
106
|
|
package/lib/es/form/label.d.ts
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import React, { PureComponent } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
export interface LabelProps {
|
|
4
|
+
/** text-align of label */
|
|
5
|
+
align?: string;
|
|
6
|
+
className?: string;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
4
9
|
id?: string;
|
|
5
10
|
/** Whether to display the required * symbol */
|
|
6
11
|
required?: boolean;
|
|
7
12
|
/** Content of label */
|
|
8
13
|
text?: React.ReactNode;
|
|
9
|
-
disabled?: boolean;
|
|
10
14
|
/** Used to configure the htmlFor attribute of the label tag */
|
|
11
15
|
name?: string;
|
|
12
|
-
/** text-align of label */
|
|
13
|
-
align?: string;
|
|
14
16
|
/** width of label */
|
|
15
17
|
width?: number | string;
|
|
16
18
|
style?: React.CSSProperties;
|
|
17
|
-
className?: string;
|
|
18
|
-
children?: React.ReactNode;
|
|
19
19
|
extra?: React.ReactNode;
|
|
20
|
+
optional?: boolean;
|
|
20
21
|
}
|
|
21
22
|
export default class Label extends PureComponent<LabelProps> {
|
|
22
23
|
static defaultProps: {
|
|
@@ -24,6 +25,7 @@ export default class Label extends PureComponent<LabelProps> {
|
|
|
24
25
|
name: string;
|
|
25
26
|
align: string;
|
|
26
27
|
className: string;
|
|
28
|
+
optional: boolean;
|
|
27
29
|
};
|
|
28
30
|
static propTypes: {
|
|
29
31
|
id: PropTypes.Requireable<string>;
|
|
@@ -37,6 +39,7 @@ export default class Label extends PureComponent<LabelProps> {
|
|
|
37
39
|
style: PropTypes.Requireable<object>;
|
|
38
40
|
className: PropTypes.Requireable<string>;
|
|
39
41
|
extra: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
42
|
+
optional: PropTypes.Requireable<boolean>;
|
|
40
43
|
};
|
|
41
44
|
render(): JSX.Element;
|
|
42
45
|
}
|
package/lib/es/form/label.js
CHANGED
|
@@ -2,6 +2,7 @@ import React, { PureComponent } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { cssClasses } from '@douyinfe/semi-foundation/lib/es/form/constants';
|
|
5
|
+
import LocaleConsumer from '../locale/localeConsumer';
|
|
5
6
|
const prefixCls = cssClasses.PREFIX;
|
|
6
7
|
export default class Label extends PureComponent {
|
|
7
8
|
render() {
|
|
@@ -16,7 +17,8 @@ export default class Label extends PureComponent {
|
|
|
16
17
|
style,
|
|
17
18
|
className,
|
|
18
19
|
extra,
|
|
19
|
-
id
|
|
20
|
+
id,
|
|
21
|
+
optional
|
|
20
22
|
} = this.props;
|
|
21
23
|
const labelCls = classNames(className, {
|
|
22
24
|
["".concat(prefixCls, "-field-label")]: true,
|
|
@@ -28,10 +30,15 @@ export default class Label extends PureComponent {
|
|
|
28
30
|
});
|
|
29
31
|
const labelStyle = style ? style : {};
|
|
30
32
|
width ? labelStyle.width = width : null;
|
|
33
|
+
const optionalText = /*#__PURE__*/React.createElement(LocaleConsumer, {
|
|
34
|
+
componentName: "Form"
|
|
35
|
+
}, locale => /*#__PURE__*/React.createElement("span", {
|
|
36
|
+
className: "".concat(prefixCls, "-field-label-optional-text")
|
|
37
|
+
}, locale.optional));
|
|
31
38
|
const textContent = /*#__PURE__*/React.createElement("div", {
|
|
32
39
|
className: "".concat(prefixCls, "-field-label-text"),
|
|
33
40
|
"x-semi-prop": "label"
|
|
34
|
-
}, typeof text !== 'undefined' ? text : children);
|
|
41
|
+
}, typeof text !== 'undefined' ? text : children, optional ? optionalText : null);
|
|
35
42
|
const contentWithExtra = /*#__PURE__*/React.createElement(React.Fragment, null, textContent, /*#__PURE__*/React.createElement("div", {
|
|
36
43
|
className: "".concat(prefixCls, "-field-label-extra")
|
|
37
44
|
}, extra));
|
|
@@ -48,7 +55,8 @@ Label.defaultProps = {
|
|
|
48
55
|
required: false,
|
|
49
56
|
name: '',
|
|
50
57
|
align: 'left',
|
|
51
|
-
className: ''
|
|
58
|
+
className: '',
|
|
59
|
+
optional: false
|
|
52
60
|
};
|
|
53
61
|
Label.propTypes = {
|
|
54
62
|
id: PropTypes.string,
|
|
@@ -61,5 +69,6 @@ Label.propTypes = {
|
|
|
61
69
|
width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
62
70
|
style: PropTypes.object,
|
|
63
71
|
className: PropTypes.string,
|
|
64
|
-
extra: PropTypes.node
|
|
72
|
+
extra: PropTypes.node,
|
|
73
|
+
optional: PropTypes.bool
|
|
65
74
|
};
|
package/lib/es/modal/Modal.js
CHANGED
|
@@ -125,14 +125,6 @@ class Modal extends BaseComponent {
|
|
|
125
125
|
let style = styleFromProps;
|
|
126
126
|
const maskStyle = maskStyleFromProps;
|
|
127
127
|
const renderFooter = 'footer' in this.props ? footer : this.renderFooter();
|
|
128
|
-
|
|
129
|
-
if (this.props.centered) {
|
|
130
|
-
style = _Object$assign({
|
|
131
|
-
transform: 'translateY(-50%)',
|
|
132
|
-
top: '50%'
|
|
133
|
-
}, style);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
128
|
let wrapperStyle = {
|
|
137
129
|
zIndex
|
|
138
130
|
};
|
|
@@ -342,7 +342,10 @@ export default class ModalContent extends BaseComponent {
|
|
|
342
342
|
}, this.getMaskElement(), /*#__PURE__*/React.createElement("div", {
|
|
343
343
|
role: "none",
|
|
344
344
|
tabIndex: -1,
|
|
345
|
-
className:
|
|
345
|
+
className: cls({
|
|
346
|
+
["".concat(cssClasses.DIALOG, "-wrap")]: true,
|
|
347
|
+
["".concat(cssClasses.DIALOG, "-wrap-center")]: this.props.centered
|
|
348
|
+
}),
|
|
346
349
|
onClick: maskClosable ? this.onMaskClick : null,
|
|
347
350
|
onMouseUp: maskClosable ? this.onMaskMouseUp : null
|
|
348
351
|
}, this.getDialogElement())); // eslint-disable-next-line max-len
|
package/lib/es/radio/radio.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export interface RadioState {
|
|
|
39
39
|
addonId?: string;
|
|
40
40
|
extraId?: string;
|
|
41
41
|
focusVisible?: boolean;
|
|
42
|
+
checked?: boolean;
|
|
42
43
|
}
|
|
43
44
|
export { RadioChangeEvent };
|
|
44
45
|
declare class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
@@ -71,6 +72,7 @@ declare class Radio extends BaseComponent<RadioProps, RadioState> {
|
|
|
71
72
|
addonId: string;
|
|
72
73
|
extraId: string;
|
|
73
74
|
constructor(props: RadioProps);
|
|
75
|
+
componentDidUpdate(prevProps: RadioProps): void;
|
|
74
76
|
get adapter(): RadioAdapter;
|
|
75
77
|
isInGroup(): {
|
|
76
78
|
value?: string | number;
|
package/lib/es/radio/radio.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import _isBoolean from "lodash/isBoolean";
|
|
2
|
+
import _isUndefined from "lodash/isUndefined";
|
|
1
3
|
import _noop from "lodash/noop";
|
|
2
4
|
import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
|
|
3
5
|
import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
|
|
@@ -30,6 +32,7 @@ class Radio extends BaseComponent {
|
|
|
30
32
|
radioGroup.onChange && radioGroup.onChange(e);
|
|
31
33
|
}
|
|
32
34
|
|
|
35
|
+
!('checked' in this.props) && this.foundation.setChecked(e.target.checked);
|
|
33
36
|
onChange && onChange(e);
|
|
34
37
|
};
|
|
35
38
|
|
|
@@ -54,12 +57,23 @@ class Radio extends BaseComponent {
|
|
|
54
57
|
this.state = {
|
|
55
58
|
hover: false,
|
|
56
59
|
addonId: props.addonId,
|
|
57
|
-
extraId: props.extraId
|
|
60
|
+
extraId: props.extraId,
|
|
61
|
+
checked: props.checked || props.defaultChecked || false
|
|
58
62
|
};
|
|
59
63
|
this.foundation = new RadioFoundation(this.adapter);
|
|
60
64
|
this.radioEntity = null;
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
componentDidUpdate(prevProps) {
|
|
68
|
+
if (this.props.checked !== prevProps.checked) {
|
|
69
|
+
if (_isUndefined(this.props.checked)) {
|
|
70
|
+
this.foundation.setChecked(false);
|
|
71
|
+
} else if (_isBoolean(this.props.checked)) {
|
|
72
|
+
this.foundation.setChecked(this.props.checked);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
63
77
|
get adapter() {
|
|
64
78
|
return _Object$assign(_Object$assign({}, super.adapter), {
|
|
65
79
|
setHover: hover => {
|
|
@@ -74,6 +88,11 @@ class Radio extends BaseComponent {
|
|
|
74
88
|
})
|
|
75
89
|
});
|
|
76
90
|
},
|
|
91
|
+
setChecked: checked => {
|
|
92
|
+
this.setState({
|
|
93
|
+
checked
|
|
94
|
+
});
|
|
95
|
+
},
|
|
77
96
|
setExtraId: () => {
|
|
78
97
|
this.setState({
|
|
79
98
|
extraId: getUuidShort({
|
|
@@ -108,7 +127,6 @@ class Radio extends BaseComponent {
|
|
|
108
127
|
const {
|
|
109
128
|
addonClassName,
|
|
110
129
|
addonStyle,
|
|
111
|
-
checked,
|
|
112
130
|
disabled,
|
|
113
131
|
style,
|
|
114
132
|
className,
|
|
@@ -126,9 +144,13 @@ class Radio extends BaseComponent {
|
|
|
126
144
|
hover: isHover,
|
|
127
145
|
addonId,
|
|
128
146
|
extraId,
|
|
129
|
-
focusVisible
|
|
147
|
+
focusVisible,
|
|
148
|
+
checked
|
|
130
149
|
} = this.state;
|
|
131
|
-
|
|
150
|
+
const props = {
|
|
151
|
+
checked,
|
|
152
|
+
disabled
|
|
153
|
+
};
|
|
132
154
|
|
|
133
155
|
if (this.isInGroup()) {
|
|
134
156
|
realChecked = this.context.radioGroup.value === propValue;
|
|
@@ -139,16 +161,17 @@ class Radio extends BaseComponent {
|
|
|
139
161
|
isPureCardRadioGroup = this.context.radioGroup.isPureCardRadio;
|
|
140
162
|
buttonSize = this.context.radioGroup.buttonSize;
|
|
141
163
|
realPrefixCls = prefixCls || this.context.radioGroup.prefixCls;
|
|
142
|
-
props =
|
|
143
|
-
|
|
144
|
-
disabled: isDisabled
|
|
145
|
-
};
|
|
164
|
+
props.checked = realChecked;
|
|
165
|
+
props.disabled = isDisabled;
|
|
146
166
|
} else {
|
|
147
167
|
realChecked = checked;
|
|
148
168
|
isDisabled = disabled;
|
|
149
169
|
realMode = mode;
|
|
150
170
|
isButtonRadioComponent = type === 'button';
|
|
151
171
|
realPrefixCls = prefixCls;
|
|
172
|
+
isButtonRadioGroup = type === strings.TYPE_BUTTON;
|
|
173
|
+
isPureCardRadioGroup = type === strings.TYPE_PURECARD;
|
|
174
|
+
isCardRadioGroup = type === strings.TYPE_CARD || isPureCardRadioGroup;
|
|
152
175
|
}
|
|
153
176
|
|
|
154
177
|
const isButtonRadio = typeof isButtonRadioGroup === 'undefined' ? isButtonRadioComponent : isButtonRadioGroup;
|
|
@@ -101,7 +101,8 @@ class RadioGroup extends BaseComponent {
|
|
|
101
101
|
return /*#__PURE__*/React.createElement(Radio, {
|
|
102
102
|
key: index,
|
|
103
103
|
disabled: this.props.disabled,
|
|
104
|
-
value: option
|
|
104
|
+
value: option,
|
|
105
|
+
type: type
|
|
105
106
|
}, option);
|
|
106
107
|
} else {
|
|
107
108
|
return /*#__PURE__*/React.createElement(Radio, {
|
|
@@ -110,7 +111,8 @@ class RadioGroup extends BaseComponent {
|
|
|
110
111
|
value: option.value,
|
|
111
112
|
extra: option.extra,
|
|
112
113
|
className: option.className,
|
|
113
|
-
style: option.style
|
|
114
|
+
style: option.style,
|
|
115
|
+
type: type
|
|
114
116
|
}, option.label);
|
|
115
117
|
}
|
|
116
118
|
});
|
package/lib/es/tag/group.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface TagGroupProps<T> {
|
|
|
14
14
|
popoverProps?: PopoverProps;
|
|
15
15
|
avatarShape?: AvatarShape;
|
|
16
16
|
mode?: string;
|
|
17
|
+
onTagClose: (tagChildren: React.ReactNode, event: React.MouseEvent<HTMLElement>, tagKey: string | number) => void;
|
|
17
18
|
}
|
|
18
19
|
export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
19
20
|
static defaultProps: {
|
|
@@ -21,6 +22,7 @@ export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
|
21
22
|
className: string;
|
|
22
23
|
size: string;
|
|
23
24
|
avatarShape: string;
|
|
25
|
+
onTagClose: () => any;
|
|
24
26
|
};
|
|
25
27
|
static propTypes: {
|
|
26
28
|
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
@@ -31,6 +33,7 @@ export default class TagGroup<T> extends PureComponent<TagGroupProps<T>> {
|
|
|
31
33
|
tagList: PropTypes.Requireable<any[]>;
|
|
32
34
|
size: PropTypes.Requireable<string>;
|
|
33
35
|
mode: PropTypes.Requireable<string>;
|
|
36
|
+
onTagClose: PropTypes.Requireable<(...args: any[]) => any>;
|
|
34
37
|
showPopover: PropTypes.Requireable<boolean>;
|
|
35
38
|
popoverProps: PropTypes.Requireable<object>;
|
|
36
39
|
avatarShape: PropTypes.Requireable<string>;
|
package/lib/es/tag/group.js
CHANGED
|
@@ -72,10 +72,11 @@ export default class TagGroup extends PureComponent {
|
|
|
72
72
|
tagList,
|
|
73
73
|
size,
|
|
74
74
|
mode,
|
|
75
|
-
avatarShape
|
|
75
|
+
avatarShape,
|
|
76
|
+
onTagClose
|
|
76
77
|
} = this.props;
|
|
77
78
|
|
|
78
|
-
const renderTags = _mapInstanceProperty(tagList).call(tagList,
|
|
79
|
+
const renderTags = _mapInstanceProperty(tagList).call(tagList, tag => {
|
|
79
80
|
if (mode === 'custom') {
|
|
80
81
|
return tag;
|
|
81
82
|
}
|
|
@@ -88,9 +89,24 @@ export default class TagGroup extends PureComponent {
|
|
|
88
89
|
tag.avatarShape = avatarShape;
|
|
89
90
|
}
|
|
90
91
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
if (!tag.tagKey) {
|
|
93
|
+
if (typeof tag.children === 'string' || typeof tag.children === 'number') {
|
|
94
|
+
tag.tagKey = tag.children;
|
|
95
|
+
} else {
|
|
96
|
+
tag.tagKey = Math.random();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return /*#__PURE__*/React.createElement(Tag, _Object$assign({}, tag, {
|
|
101
|
+
key: tag.tagKey,
|
|
102
|
+
onClose: (tagChildren, e, tagKey) => {
|
|
103
|
+
if (tag.onClose) {
|
|
104
|
+
tag.onClose(tagChildren, e, tagKey);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onTagClose && onTagClose(tagChildren, e, tagKey);
|
|
108
|
+
}
|
|
109
|
+
}));
|
|
94
110
|
});
|
|
95
111
|
|
|
96
112
|
return renderTags;
|
|
@@ -122,7 +138,8 @@ TagGroup.defaultProps = {
|
|
|
122
138
|
style: {},
|
|
123
139
|
className: '',
|
|
124
140
|
size: tagSize[0],
|
|
125
|
-
avatarShape: 'square'
|
|
141
|
+
avatarShape: 'square',
|
|
142
|
+
onTagClose: () => undefined
|
|
126
143
|
};
|
|
127
144
|
TagGroup.propTypes = {
|
|
128
145
|
children: PropTypes.node,
|
|
@@ -133,6 +150,7 @@ TagGroup.propTypes = {
|
|
|
133
150
|
tagList: PropTypes.array,
|
|
134
151
|
size: PropTypes.oneOf(tagSize),
|
|
135
152
|
mode: PropTypes.string,
|
|
153
|
+
onTagClose: PropTypes.func,
|
|
136
154
|
showPopover: PropTypes.bool,
|
|
137
155
|
popoverProps: PropTypes.object,
|
|
138
156
|
avatarShape: PropTypes.oneOf(avatarShapeSet)
|