@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
|
@@ -151,7 +151,8 @@ class Checkbox extends _baseComponent.default {
|
|
|
151
151
|
value,
|
|
152
152
|
role,
|
|
153
153
|
tabIndex,
|
|
154
|
-
id
|
|
154
|
+
id,
|
|
155
|
+
type
|
|
155
156
|
} = this.props;
|
|
156
157
|
const {
|
|
157
158
|
checked,
|
|
@@ -184,6 +185,9 @@ class Checkbox extends _baseComponent.default {
|
|
|
184
185
|
props.isCardType = isCardType;
|
|
185
186
|
props.isPureCardType = isPureCardType;
|
|
186
187
|
props['name'] = this.context.checkboxGroup.name;
|
|
188
|
+
} else {
|
|
189
|
+
props.isPureCardType = type === _constants.strings.TYPE_PURECARD;
|
|
190
|
+
props.isCardType = type === _constants.strings.TYPE_CARD || props.isPureCardType;
|
|
187
191
|
}
|
|
188
192
|
|
|
189
193
|
const prefix = prefixCls || _constants.checkboxClasses.PREFIX;
|
|
@@ -274,14 +278,16 @@ Checkbox.propTypes = {
|
|
|
274
278
|
index: _propTypes.default.number,
|
|
275
279
|
'aria-label': _propTypes.default.string,
|
|
276
280
|
tabIndex: _propTypes.default.number,
|
|
277
|
-
preventScroll: _propTypes.default.bool
|
|
281
|
+
preventScroll: _propTypes.default.bool,
|
|
282
|
+
type: _propTypes.default.string
|
|
278
283
|
};
|
|
279
284
|
Checkbox.defaultProps = {
|
|
280
285
|
defaultChecked: false,
|
|
281
286
|
indeterminate: false,
|
|
282
287
|
onChange: _noop2.default,
|
|
283
288
|
onMouseEnter: _noop2.default,
|
|
284
|
-
onMouseLeave: _noop2.default
|
|
289
|
+
onMouseLeave: _noop2.default,
|
|
290
|
+
type: 'default'
|
|
285
291
|
};
|
|
286
292
|
var _default = Checkbox;
|
|
287
293
|
exports.default = _default;
|
|
@@ -118,7 +118,8 @@ class CheckboxGroup extends _baseComponent.default {
|
|
|
118
118
|
key: index,
|
|
119
119
|
disabled: this.props.disabled,
|
|
120
120
|
value: option,
|
|
121
|
-
prefixCls: prefixCls
|
|
121
|
+
prefixCls: prefixCls,
|
|
122
|
+
type: type
|
|
122
123
|
}, option);
|
|
123
124
|
} else {
|
|
124
125
|
return /*#__PURE__*/_react.default.createElement(_checkbox.default, {
|
|
@@ -130,7 +131,8 @@ class CheckboxGroup extends _baseComponent.default {
|
|
|
130
131
|
extra: option.extra,
|
|
131
132
|
className: option.className,
|
|
132
133
|
style: option.style,
|
|
133
|
-
onChange: option.onChange
|
|
134
|
+
onChange: option.onChange,
|
|
135
|
+
type: type
|
|
134
136
|
}, option.label);
|
|
135
137
|
}
|
|
136
138
|
});
|
|
@@ -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/cjs/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>>;
|
|
@@ -136,7 +136,8 @@ function withField(Component, opts) {
|
|
|
136
136
|
if (arrayFieldState) {
|
|
137
137
|
initVal = arrayFieldState.shouldUseInitValue && typeof initValue !== 'undefined' ? initValue : initValueInFormOpts;
|
|
138
138
|
}
|
|
139
|
-
} catch (err) {}
|
|
139
|
+
} catch (err) {} // FIXME typeof initVal
|
|
140
|
+
|
|
140
141
|
|
|
141
142
|
const [value, setValue, getVal] = (0, _index.useStateWithGetter)(typeof initVal !== undefined ? initVal : null);
|
|
142
143
|
const validateOnMount = (0, _includes.default)(trigger).call(trigger, 'mount');
|
package/lib/cjs/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/cjs/form/label.js
CHANGED
|
@@ -22,6 +22,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
22
22
|
|
|
23
23
|
var _constants = require("@douyinfe/semi-foundation/lib/cjs/form/constants");
|
|
24
24
|
|
|
25
|
+
var _localeConsumer = _interopRequireDefault(require("../locale/localeConsumer"));
|
|
26
|
+
|
|
25
27
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
26
28
|
|
|
27
29
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -41,7 +43,8 @@ class Label extends _react.PureComponent {
|
|
|
41
43
|
style,
|
|
42
44
|
className,
|
|
43
45
|
extra,
|
|
44
|
-
id
|
|
46
|
+
id,
|
|
47
|
+
optional
|
|
45
48
|
} = this.props;
|
|
46
49
|
const labelCls = (0, _classnames.default)(className, {
|
|
47
50
|
["".concat(prefixCls, "-field-label")]: true,
|
|
@@ -54,10 +57,16 @@ class Label extends _react.PureComponent {
|
|
|
54
57
|
const labelStyle = style ? style : {};
|
|
55
58
|
width ? labelStyle.width = width : null;
|
|
56
59
|
|
|
60
|
+
const optionalText = /*#__PURE__*/_react.default.createElement(_localeConsumer.default, {
|
|
61
|
+
componentName: "Form"
|
|
62
|
+
}, locale => /*#__PURE__*/_react.default.createElement("span", {
|
|
63
|
+
className: "".concat(prefixCls, "-field-label-optional-text")
|
|
64
|
+
}, locale.optional));
|
|
65
|
+
|
|
57
66
|
const textContent = /*#__PURE__*/_react.default.createElement("div", {
|
|
58
67
|
className: "".concat(prefixCls, "-field-label-text"),
|
|
59
68
|
"x-semi-prop": "label"
|
|
60
|
-
}, typeof text !== 'undefined' ? text : children);
|
|
69
|
+
}, typeof text !== 'undefined' ? text : children, optional ? optionalText : null);
|
|
61
70
|
|
|
62
71
|
const contentWithExtra = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, textContent, /*#__PURE__*/_react.default.createElement("div", {
|
|
63
72
|
className: "".concat(prefixCls, "-field-label-extra")
|
|
@@ -78,7 +87,8 @@ Label.defaultProps = {
|
|
|
78
87
|
required: false,
|
|
79
88
|
name: '',
|
|
80
89
|
align: 'left',
|
|
81
|
-
className: ''
|
|
90
|
+
className: '',
|
|
91
|
+
optional: false
|
|
82
92
|
};
|
|
83
93
|
Label.propTypes = {
|
|
84
94
|
id: _propTypes.default.string,
|
|
@@ -91,5 +101,6 @@ Label.propTypes = {
|
|
|
91
101
|
width: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
92
102
|
style: _propTypes.default.object,
|
|
93
103
|
className: _propTypes.default.string,
|
|
94
|
-
extra: _propTypes.default.node
|
|
104
|
+
extra: _propTypes.default.node,
|
|
105
|
+
optional: _propTypes.default.bool
|
|
95
106
|
};
|
package/lib/cjs/modal/Modal.js
CHANGED
|
@@ -164,14 +164,6 @@ class Modal extends _baseComponent.default {
|
|
|
164
164
|
let style = styleFromProps;
|
|
165
165
|
const maskStyle = maskStyleFromProps;
|
|
166
166
|
const renderFooter = 'footer' in this.props ? footer : this.renderFooter();
|
|
167
|
-
|
|
168
|
-
if (this.props.centered) {
|
|
169
|
-
style = (0, _assign.default)({
|
|
170
|
-
transform: 'translateY(-50%)',
|
|
171
|
-
top: '50%'
|
|
172
|
-
}, style);
|
|
173
|
-
}
|
|
174
|
-
|
|
175
167
|
let wrapperStyle = {
|
|
176
168
|
zIndex
|
|
177
169
|
};
|
|
@@ -376,7 +376,10 @@ class ModalContent extends _baseComponent.default {
|
|
|
376
376
|
}, this.getMaskElement(), /*#__PURE__*/_react.default.createElement("div", {
|
|
377
377
|
role: "none",
|
|
378
378
|
tabIndex: -1,
|
|
379
|
-
className:
|
|
379
|
+
className: (0, _classnames.default)({
|
|
380
|
+
["".concat(_constants.cssClasses.DIALOG, "-wrap")]: true,
|
|
381
|
+
["".concat(_constants.cssClasses.DIALOG, "-wrap-center")]: this.props.centered
|
|
382
|
+
}),
|
|
380
383
|
onClick: maskClosable ? this.onMaskClick : null,
|
|
381
384
|
onMouseUp: maskClosable ? this.onMaskMouseUp : null
|
|
382
385
|
}, this.getDialogElement())); // eslint-disable-next-line max-len
|
package/lib/cjs/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/cjs/radio/radio.js
CHANGED
|
@@ -14,6 +14,10 @@ var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-sta
|
|
|
14
14
|
|
|
15
15
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
16
16
|
|
|
17
|
+
var _isBoolean2 = _interopRequireDefault(require("lodash/isBoolean"));
|
|
18
|
+
|
|
19
|
+
var _isUndefined2 = _interopRequireDefault(require("lodash/isUndefined"));
|
|
20
|
+
|
|
17
21
|
var _noop2 = _interopRequireDefault(require("lodash/noop"));
|
|
18
22
|
|
|
19
23
|
var _react = _interopRequireDefault(require("react"));
|
|
@@ -53,6 +57,7 @@ class Radio extends _baseComponent.default {
|
|
|
53
57
|
radioGroup.onChange && radioGroup.onChange(e);
|
|
54
58
|
}
|
|
55
59
|
|
|
60
|
+
!('checked' in this.props) && this.foundation.setChecked(e.target.checked);
|
|
56
61
|
onChange && onChange(e);
|
|
57
62
|
};
|
|
58
63
|
|
|
@@ -77,12 +82,23 @@ class Radio extends _baseComponent.default {
|
|
|
77
82
|
this.state = {
|
|
78
83
|
hover: false,
|
|
79
84
|
addonId: props.addonId,
|
|
80
|
-
extraId: props.extraId
|
|
85
|
+
extraId: props.extraId,
|
|
86
|
+
checked: props.checked || props.defaultChecked || false
|
|
81
87
|
};
|
|
82
88
|
this.foundation = new _radioFoundation.default(this.adapter);
|
|
83
89
|
this.radioEntity = null;
|
|
84
90
|
}
|
|
85
91
|
|
|
92
|
+
componentDidUpdate(prevProps) {
|
|
93
|
+
if (this.props.checked !== prevProps.checked) {
|
|
94
|
+
if ((0, _isUndefined2.default)(this.props.checked)) {
|
|
95
|
+
this.foundation.setChecked(false);
|
|
96
|
+
} else if ((0, _isBoolean2.default)(this.props.checked)) {
|
|
97
|
+
this.foundation.setChecked(this.props.checked);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
86
102
|
get adapter() {
|
|
87
103
|
return (0, _assign.default)((0, _assign.default)({}, super.adapter), {
|
|
88
104
|
setHover: hover => {
|
|
@@ -97,6 +113,11 @@ class Radio extends _baseComponent.default {
|
|
|
97
113
|
})
|
|
98
114
|
});
|
|
99
115
|
},
|
|
116
|
+
setChecked: checked => {
|
|
117
|
+
this.setState({
|
|
118
|
+
checked
|
|
119
|
+
});
|
|
120
|
+
},
|
|
100
121
|
setExtraId: () => {
|
|
101
122
|
this.setState({
|
|
102
123
|
extraId: (0, _uuid.getUuidShort)({
|
|
@@ -131,7 +152,6 @@ class Radio extends _baseComponent.default {
|
|
|
131
152
|
const {
|
|
132
153
|
addonClassName,
|
|
133
154
|
addonStyle,
|
|
134
|
-
checked,
|
|
135
155
|
disabled,
|
|
136
156
|
style,
|
|
137
157
|
className,
|
|
@@ -149,9 +169,13 @@ class Radio extends _baseComponent.default {
|
|
|
149
169
|
hover: isHover,
|
|
150
170
|
addonId,
|
|
151
171
|
extraId,
|
|
152
|
-
focusVisible
|
|
172
|
+
focusVisible,
|
|
173
|
+
checked
|
|
153
174
|
} = this.state;
|
|
154
|
-
|
|
175
|
+
const props = {
|
|
176
|
+
checked,
|
|
177
|
+
disabled
|
|
178
|
+
};
|
|
155
179
|
|
|
156
180
|
if (this.isInGroup()) {
|
|
157
181
|
realChecked = this.context.radioGroup.value === propValue;
|
|
@@ -162,16 +186,17 @@ class Radio extends _baseComponent.default {
|
|
|
162
186
|
isPureCardRadioGroup = this.context.radioGroup.isPureCardRadio;
|
|
163
187
|
buttonSize = this.context.radioGroup.buttonSize;
|
|
164
188
|
realPrefixCls = prefixCls || this.context.radioGroup.prefixCls;
|
|
165
|
-
props =
|
|
166
|
-
|
|
167
|
-
disabled: isDisabled
|
|
168
|
-
};
|
|
189
|
+
props.checked = realChecked;
|
|
190
|
+
props.disabled = isDisabled;
|
|
169
191
|
} else {
|
|
170
192
|
realChecked = checked;
|
|
171
193
|
isDisabled = disabled;
|
|
172
194
|
realMode = mode;
|
|
173
195
|
isButtonRadioComponent = type === 'button';
|
|
174
196
|
realPrefixCls = prefixCls;
|
|
197
|
+
isButtonRadioGroup = type === _constants.strings.TYPE_BUTTON;
|
|
198
|
+
isPureCardRadioGroup = type === _constants.strings.TYPE_PURECARD;
|
|
199
|
+
isCardRadioGroup = type === _constants.strings.TYPE_CARD || isPureCardRadioGroup;
|
|
175
200
|
}
|
|
176
201
|
|
|
177
202
|
const isButtonRadio = typeof isButtonRadioGroup === 'undefined' ? isButtonRadioComponent : isButtonRadioGroup;
|
|
@@ -124,7 +124,8 @@ class RadioGroup extends _baseComponent.default {
|
|
|
124
124
|
return /*#__PURE__*/_react.default.createElement(_radio.default, {
|
|
125
125
|
key: index,
|
|
126
126
|
disabled: this.props.disabled,
|
|
127
|
-
value: option
|
|
127
|
+
value: option,
|
|
128
|
+
type: type
|
|
128
129
|
}, option);
|
|
129
130
|
} else {
|
|
130
131
|
return /*#__PURE__*/_react.default.createElement(_radio.default, {
|
|
@@ -133,7 +134,8 @@ class RadioGroup extends _baseComponent.default {
|
|
|
133
134
|
value: option.value,
|
|
134
135
|
extra: option.extra,
|
|
135
136
|
className: option.className,
|
|
136
|
-
style: option.style
|
|
137
|
+
style: option.style,
|
|
138
|
+
type: type
|
|
137
139
|
}, option.label);
|
|
138
140
|
}
|
|
139
141
|
});
|
package/lib/cjs/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/cjs/tag/group.js
CHANGED
|
@@ -100,9 +100,10 @@ class TagGroup extends _react.PureComponent {
|
|
|
100
100
|
tagList,
|
|
101
101
|
size,
|
|
102
102
|
mode,
|
|
103
|
-
avatarShape
|
|
103
|
+
avatarShape,
|
|
104
|
+
onTagClose
|
|
104
105
|
} = this.props;
|
|
105
|
-
const renderTags = (0, _map.default)(tagList).call(tagList,
|
|
106
|
+
const renderTags = (0, _map.default)(tagList).call(tagList, tag => {
|
|
106
107
|
if (mode === 'custom') {
|
|
107
108
|
return tag;
|
|
108
109
|
}
|
|
@@ -115,9 +116,24 @@ class TagGroup extends _react.PureComponent {
|
|
|
115
116
|
tag.avatarShape = avatarShape;
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
if (!tag.tagKey) {
|
|
120
|
+
if (typeof tag.children === 'string' || typeof tag.children === 'number') {
|
|
121
|
+
tag.tagKey = tag.children;
|
|
122
|
+
} else {
|
|
123
|
+
tag.tagKey = Math.random();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return /*#__PURE__*/_react.default.createElement(_index.default, (0, _assign.default)({}, tag, {
|
|
128
|
+
key: tag.tagKey,
|
|
129
|
+
onClose: (tagChildren, e, tagKey) => {
|
|
130
|
+
if (tag.onClose) {
|
|
131
|
+
tag.onClose(tagChildren, e, tagKey);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
onTagClose && onTagClose(tagChildren, e, tagKey);
|
|
135
|
+
}
|
|
136
|
+
}));
|
|
121
137
|
});
|
|
122
138
|
return renderTags;
|
|
123
139
|
}
|
|
@@ -150,7 +166,8 @@ TagGroup.defaultProps = {
|
|
|
150
166
|
style: {},
|
|
151
167
|
className: '',
|
|
152
168
|
size: tagSize[0],
|
|
153
|
-
avatarShape: 'square'
|
|
169
|
+
avatarShape: 'square',
|
|
170
|
+
onTagClose: () => undefined
|
|
154
171
|
};
|
|
155
172
|
TagGroup.propTypes = {
|
|
156
173
|
children: _propTypes.default.node,
|
|
@@ -161,6 +178,7 @@ TagGroup.propTypes = {
|
|
|
161
178
|
tagList: _propTypes.default.array,
|
|
162
179
|
size: _propTypes.default.oneOf(tagSize),
|
|
163
180
|
mode: _propTypes.default.string,
|
|
181
|
+
onTagClose: _propTypes.default.func,
|
|
164
182
|
showPopover: _propTypes.default.bool,
|
|
165
183
|
popoverProps: _propTypes.default.object,
|
|
166
184
|
avatarShape: _propTypes.default.oneOf(avatarShapeSet)
|