@douyinfe/semi-ui 2.19.0-alpha.5 → 2.19.0-alpha.6

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.
@@ -25,6 +25,5 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
25
25
  static defaultProps: {
26
26
  size: string;
27
27
  };
28
- getInnerWithLine(inner: any): any;
29
28
  render(): JSX.Element;
30
29
  }
@@ -18,22 +18,12 @@ var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-st
18
18
 
19
19
  var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols"));
20
20
 
21
- var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
22
-
23
- var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
24
-
25
- var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
26
-
27
- var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
28
-
29
21
  var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
30
22
 
31
23
  var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array"));
32
24
 
33
25
  var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign"));
34
26
 
35
- var _get2 = _interopRequireDefault(require("lodash/get"));
36
-
37
27
  var _react = _interopRequireWildcard(require("react"));
38
28
 
39
29
  var _baseComponent = _interopRequireDefault(require("../_base/baseComponent"));
@@ -65,47 +55,6 @@ const prefixCls = _constants.cssClasses.PREFIX;
65
55
  const btnSizes = _constants.strings.sizes;
66
56
 
67
57
  class ButtonGroup extends _baseComponent.default {
68
- getInnerWithLine(inner) {
69
- const innerWithLine = [];
70
- let lineCls = "".concat(prefixCls, "-group-line");
71
-
72
- if (inner.length > 1) {
73
- var _context;
74
-
75
- (0, _forEach.default)(_context = (0, _slice.default)(inner).call(inner, 0, -1)).call(_context, item => {
76
- var _context2;
77
-
78
- const isButtonType = (0, _includes.default)(_context2 = [(0, _get2.default)(item, 'type.displayName'), (0, _get2.default)(item, 'type.name')]).call(_context2, 'Button');
79
- const buttonProps = (0, _get2.default)(item, 'props');
80
-
81
- if (buttonProps) {
82
- var _context3, _context4;
83
-
84
- const {
85
- type,
86
- theme,
87
- disabled
88
- } = buttonProps;
89
- lineCls = (0, _classnames.default)("".concat(prefixCls, "-group-line"), (0, _concat.default)(_context3 = "".concat(prefixCls, "-group-line-")).call(_context3, theme !== null && theme !== void 0 ? theme : 'light'), (0, _concat.default)(_context4 = "".concat(prefixCls, "-group-line-")).call(_context4, type !== null && type !== void 0 ? type : 'primary'), {
90
- ["".concat(prefixCls, "-group-line-disabled")]: disabled
91
- });
92
- }
93
-
94
- if (isButtonType) {
95
- innerWithLine.push(item, /*#__PURE__*/_react.default.createElement("span", {
96
- className: lineCls
97
- }));
98
- } else {
99
- innerWithLine.push(item);
100
- }
101
- });
102
- innerWithLine.push((0, _slice.default)(inner).call(inner, -1));
103
- return innerWithLine;
104
- } else {
105
- return inner;
106
- }
107
- }
108
-
109
58
  render() {
110
59
  const _a = this.props,
111
60
  {
@@ -119,27 +68,25 @@ class ButtonGroup extends _baseComponent.default {
119
68
  rest = __rest(_a, ["children", "disabled", "size", "type", "className", 'aria-label']);
120
69
 
121
70
  let inner;
122
- let innerWithLine = [];
123
71
  const cls = (0, _classnames.default)("".concat(prefixCls, "-group"), className);
124
72
 
125
73
  if (children) {
126
- var _context5;
74
+ var _context;
127
75
 
128
- inner = (0, _map.default)(_context5 = (0, _isArray.default)(children) ? children : [children]).call(_context5, (itm, index) => /*#__PURE__*/(0, _react.isValidElement)(itm) ? /*#__PURE__*/(0, _react.cloneElement)(itm, (0, _assign.default)((0, _assign.default)((0, _assign.default)({
76
+ inner = (0, _map.default)(_context = (0, _isArray.default)(children) ? children : [children]).call(_context, (itm, index) => /*#__PURE__*/(0, _react.isValidElement)(itm) ? /*#__PURE__*/(0, _react.cloneElement)(itm, (0, _assign.default)((0, _assign.default)((0, _assign.default)({
129
77
  disabled,
130
78
  size,
131
79
  type
132
80
  }, itm.props), rest), {
133
81
  key: index
134
82
  })) : itm);
135
- innerWithLine = this.getInnerWithLine(inner);
136
83
  }
137
84
 
138
85
  return /*#__PURE__*/_react.default.createElement("div", {
139
86
  className: cls,
140
87
  role: "group",
141
88
  "aria-label": ariaLabel
142
- }, innerWithLine);
89
+ }, inner);
143
90
  }
144
91
 
145
92
  }
@@ -228,16 +228,26 @@ class Radio extends _baseComponent.default {
228
228
  ["".concat(prefix, "-focus")]: focusVisible && isButtonRadio
229
229
  }, addonClassName);
230
230
 
231
- const renderContent = () => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children ? /*#__PURE__*/_react.default.createElement("span", {
232
- className: addonCls,
233
- style: addonStyle,
234
- id: addonId,
235
- "x-semi-prop": "children"
236
- }, children) : null, extra && !isButtonRadio ? /*#__PURE__*/_react.default.createElement("div", {
237
- className: "".concat(prefix, "-extra"),
238
- id: extraId,
239
- "x-semi-prop": "extra"
240
- }, extra) : null);
231
+ const renderContent = () => {
232
+ if (!children && !extra) {
233
+ return null;
234
+ }
235
+
236
+ return /*#__PURE__*/_react.default.createElement("div", {
237
+ className: (0, _classnames.default)(["".concat(prefix, "-content"), {
238
+ ["".concat(prefix, "-isCardRadioGroup_content")]: isCardRadioGroup
239
+ }])
240
+ }, children ? /*#__PURE__*/_react.default.createElement("span", {
241
+ className: addonCls,
242
+ style: addonStyle,
243
+ id: addonId,
244
+ "x-semi-prop": "children"
245
+ }, children) : null, extra && !isButtonRadio ? /*#__PURE__*/_react.default.createElement("div", {
246
+ className: "".concat(prefix, "-extra"),
247
+ id: extraId,
248
+ "x-semi-prop": "extra"
249
+ }, extra) : null);
250
+ };
241
251
 
242
252
  return /*#__PURE__*/_react.default.createElement("label", {
243
253
  style: style,
@@ -258,9 +268,7 @@ class Radio extends _baseComponent.default {
258
268
  focusInner: focusVisible && !focusOuter,
259
269
  onInputFocus: this.handleFocusVisible,
260
270
  onInputBlur: this.handleBlur
261
- })), isCardRadioGroup ? /*#__PURE__*/_react.default.createElement("div", {
262
- className: "".concat(prefix, "-isCardRadioGroup_content")
263
- }, renderContent()) : renderContent());
271
+ })), renderContent());
264
272
  }
265
273
 
266
274
  }
@@ -45,7 +45,7 @@ class RadioGroup extends _baseComponent.default {
45
45
  this.getFormatName = () => this.props.name || 'default';
46
46
 
47
47
  this.state = {
48
- value: undefined
48
+ value: props.value || props.defaultValue
49
49
  };
50
50
  this.foundation = new _radioGroupFoundation.default(this.adapter);
51
51
  }
@@ -25,6 +25,5 @@ export default class ButtonGroup extends BaseComponent<ButtonGroupProps> {
25
25
  static defaultProps: {
26
26
  size: string;
27
27
  };
28
- getInnerWithLine(inner: any): any;
29
28
  render(): JSX.Element;
30
29
  }
@@ -1,10 +1,5 @@
1
- import _get from "lodash/get";
2
1
  import _indexOfInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/index-of";
3
2
  import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
4
- import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
5
- import _sliceInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/slice";
6
- import _includesInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/includes";
7
- import _concatInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/concat";
8
3
  import _mapInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/map";
9
4
  import _Array$isArray from "@babel/runtime-corejs3/core-js-stable/array/is-array";
10
5
  import _Object$assign from "@babel/runtime-corejs3/core-js-stable/object/assign";
@@ -29,49 +24,6 @@ import '@douyinfe/semi-foundation/lib/es/button/button.css';
29
24
  const prefixCls = cssClasses.PREFIX;
30
25
  const btnSizes = strings.sizes;
31
26
  export default class ButtonGroup extends BaseComponent {
32
- getInnerWithLine(inner) {
33
- const innerWithLine = [];
34
- let lineCls = "".concat(prefixCls, "-group-line");
35
-
36
- if (inner.length > 1) {
37
- var _context;
38
-
39
- _forEachInstanceProperty(_context = _sliceInstanceProperty(inner).call(inner, 0, -1)).call(_context, item => {
40
- var _context2;
41
-
42
- const isButtonType = _includesInstanceProperty(_context2 = [_get(item, 'type.displayName'), _get(item, 'type.name')]).call(_context2, 'Button');
43
-
44
- const buttonProps = _get(item, 'props');
45
-
46
- if (buttonProps) {
47
- var _context3, _context4;
48
-
49
- const {
50
- type,
51
- theme,
52
- disabled
53
- } = buttonProps;
54
- lineCls = classNames("".concat(prefixCls, "-group-line"), _concatInstanceProperty(_context3 = "".concat(prefixCls, "-group-line-")).call(_context3, theme !== null && theme !== void 0 ? theme : 'light'), _concatInstanceProperty(_context4 = "".concat(prefixCls, "-group-line-")).call(_context4, type !== null && type !== void 0 ? type : 'primary'), {
55
- ["".concat(prefixCls, "-group-line-disabled")]: disabled
56
- });
57
- }
58
-
59
- if (isButtonType) {
60
- innerWithLine.push(item, /*#__PURE__*/React.createElement("span", {
61
- className: lineCls
62
- }));
63
- } else {
64
- innerWithLine.push(item);
65
- }
66
- });
67
-
68
- innerWithLine.push(_sliceInstanceProperty(inner).call(inner, -1));
69
- return innerWithLine;
70
- } else {
71
- return inner;
72
- }
73
- }
74
-
75
27
  render() {
76
28
  const _a = this.props,
77
29
  {
@@ -85,27 +37,25 @@ export default class ButtonGroup extends BaseComponent {
85
37
  rest = __rest(_a, ["children", "disabled", "size", "type", "className", 'aria-label']);
86
38
 
87
39
  let inner;
88
- let innerWithLine = [];
89
40
  const cls = classNames("".concat(prefixCls, "-group"), className);
90
41
 
91
42
  if (children) {
92
- var _context5;
43
+ var _context;
93
44
 
94
- inner = _mapInstanceProperty(_context5 = _Array$isArray(children) ? children : [children]).call(_context5, (itm, index) => /*#__PURE__*/isValidElement(itm) ? /*#__PURE__*/cloneElement(itm, _Object$assign(_Object$assign(_Object$assign({
45
+ inner = _mapInstanceProperty(_context = _Array$isArray(children) ? children : [children]).call(_context, (itm, index) => /*#__PURE__*/isValidElement(itm) ? /*#__PURE__*/cloneElement(itm, _Object$assign(_Object$assign(_Object$assign({
95
46
  disabled,
96
47
  size,
97
48
  type
98
49
  }, itm.props), rest), {
99
50
  key: index
100
51
  })) : itm);
101
- innerWithLine = this.getInnerWithLine(inner);
102
52
  }
103
53
 
104
54
  return /*#__PURE__*/React.createElement("div", {
105
55
  className: cls,
106
56
  role: "group",
107
57
  "aria-label": ariaLabel
108
- }, innerWithLine);
58
+ }, inner);
109
59
  }
110
60
 
111
61
  }
@@ -203,16 +203,26 @@ class Radio extends BaseComponent {
203
203
  ["".concat(prefix, "-focus")]: focusVisible && isButtonRadio
204
204
  }, addonClassName);
205
205
 
206
- const renderContent = () => /*#__PURE__*/React.createElement(React.Fragment, null, children ? /*#__PURE__*/React.createElement("span", {
207
- className: addonCls,
208
- style: addonStyle,
209
- id: addonId,
210
- "x-semi-prop": "children"
211
- }, children) : null, extra && !isButtonRadio ? /*#__PURE__*/React.createElement("div", {
212
- className: "".concat(prefix, "-extra"),
213
- id: extraId,
214
- "x-semi-prop": "extra"
215
- }, extra) : null);
206
+ const renderContent = () => {
207
+ if (!children && !extra) {
208
+ return null;
209
+ }
210
+
211
+ return /*#__PURE__*/React.createElement("div", {
212
+ className: cls(["".concat(prefix, "-content"), {
213
+ ["".concat(prefix, "-isCardRadioGroup_content")]: isCardRadioGroup
214
+ }])
215
+ }, children ? /*#__PURE__*/React.createElement("span", {
216
+ className: addonCls,
217
+ style: addonStyle,
218
+ id: addonId,
219
+ "x-semi-prop": "children"
220
+ }, children) : null, extra && !isButtonRadio ? /*#__PURE__*/React.createElement("div", {
221
+ className: "".concat(prefix, "-extra"),
222
+ id: extraId,
223
+ "x-semi-prop": "extra"
224
+ }, extra) : null);
225
+ };
216
226
 
217
227
  return /*#__PURE__*/React.createElement("label", {
218
228
  style: style,
@@ -233,9 +243,7 @@ class Radio extends BaseComponent {
233
243
  focusInner: focusVisible && !focusOuter,
234
244
  onInputFocus: this.handleFocusVisible,
235
245
  onInputBlur: this.handleBlur
236
- })), isCardRadioGroup ? /*#__PURE__*/React.createElement("div", {
237
- className: "".concat(prefix, "-isCardRadioGroup_content")
238
- }, renderContent()) : renderContent());
246
+ })), renderContent());
239
247
  }
240
248
 
241
249
  }
@@ -22,7 +22,7 @@ class RadioGroup extends BaseComponent {
22
22
  this.getFormatName = () => this.props.name || 'default';
23
23
 
24
24
  this.state = {
25
- value: undefined
25
+ value: props.value || props.defaultValue
26
26
  };
27
27
  this.foundation = new RadioGroupFoundation(this.adapter);
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.19.0-alpha.5",
3
+ "version": "2.19.0-alpha.6",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -15,11 +15,11 @@
15
15
  "dependencies": {
16
16
  "@babel/runtime-corejs3": "^7.15.4",
17
17
  "@douyinfe/semi-animation": "2.12.0",
18
- "@douyinfe/semi-animation-react": "2.19.0-alpha.5",
19
- "@douyinfe/semi-foundation": "2.19.0-alpha.5",
20
- "@douyinfe/semi-icons": "2.19.0-alpha.5",
18
+ "@douyinfe/semi-animation-react": "2.19.0-alpha.6",
19
+ "@douyinfe/semi-foundation": "2.19.0-alpha.6",
20
+ "@douyinfe/semi-icons": "2.19.0-alpha.6",
21
21
  "@douyinfe/semi-illustrations": "2.15.0",
22
- "@douyinfe/semi-theme-default": "2.19.0-alpha.5",
22
+ "@douyinfe/semi-theme-default": "2.19.0-alpha.6",
23
23
  "async-validator": "^3.5.0",
24
24
  "classnames": "^2.2.6",
25
25
  "copy-text-to-clipboard": "^2.1.1",
@@ -66,13 +66,13 @@
66
66
  ],
67
67
  "author": "",
68
68
  "license": "MIT",
69
- "gitHead": "f49d77763d9cf17af15945bddd04557e57858b4b",
69
+ "gitHead": "f131defbb2a909ebb7035eea975bf3466908ac15",
70
70
  "devDependencies": {
71
71
  "@babel/plugin-proposal-decorators": "^7.15.8",
72
72
  "@babel/plugin-transform-runtime": "^7.15.8",
73
73
  "@babel/preset-env": "^7.15.8",
74
74
  "@babel/preset-react": "^7.14.5",
75
- "@douyinfe/semi-scss-compile": "2.19.0-alpha.5",
75
+ "@douyinfe/semi-scss-compile": "2.19.0-alpha.6",
76
76
  "@storybook/addon-knobs": "^6.3.1",
77
77
  "@types/lodash": "^4.14.176",
78
78
  "@types/react": ">=16.0.0",
@@ -254,18 +254,18 @@ _RadioGroup.story = {
254
254
 
255
255
  export const RadioWithVertical = () => {
256
256
  return (
257
- <Radio.Group>
258
- <Radio value="A" displayMode="vertical">
257
+ <Radio.Group direction="vertical">
258
+ <Radio value="A">
259
259
  无限长的一串字The Storybook webapp UI can be customised with this addon. It can be used to
260
260
  change the header, show/hide various UI elements and to enable full-screen mode by default.
261
261
  </Radio>
262
- <Radio value="C" displayMode="vertical">
262
+ <Radio value="C">
263
263
  C
264
264
  </Radio>
265
- <Radio value="D" displayMode="vertical">
265
+ <Radio value="D">
266
266
  D
267
267
  </Radio>
268
- <Radio value="E" displayMode="vertical">
268
+ <Radio value="E">
269
269
  E
270
270
  </Radio>
271
271
  </Radio.Group>
package/radio/radio.tsx CHANGED
@@ -268,20 +268,25 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
268
268
  [`${prefix}-addon-buttonRadio-${buttonSize}`]: isButtonRadio && buttonSize,
269
269
  [`${prefix}-focus`]: focusVisible && isButtonRadio,
270
270
  }, addonClassName);
271
- const renderContent = () => (
272
- <>
273
- {children ? (
274
- <span className={addonCls} style={addonStyle} id={addonId} x-semi-prop="children">
275
- {children}
276
- </span>
277
- ) : null}
278
- {extra && !isButtonRadio ? (
279
- <div className={`${prefix}-extra`} id={extraId} x-semi-prop="extra">
280
- {extra}
281
- </div>
282
- ) : null}
283
- </>
284
- );
271
+ const renderContent = () => {
272
+ if (!children && !extra) {
273
+ return null;
274
+ }
275
+ return (
276
+ <div className={cls([`${prefix}-content`, { [`${prefix}-isCardRadioGroup_content`]: isCardRadioGroup }])}>
277
+ {children ? (
278
+ <span className={addonCls} style={addonStyle} id={addonId} x-semi-prop="children">
279
+ {children}
280
+ </span>
281
+ ) : null}
282
+ {extra && !isButtonRadio ? (
283
+ <div className={`${prefix}-extra`} id={extraId} x-semi-prop="extra">
284
+ {extra}
285
+ </div>
286
+ ) : null}
287
+ </div>
288
+ );
289
+ };
285
290
 
286
291
  return (
287
292
  <label
@@ -307,11 +312,7 @@ class Radio extends BaseComponent<RadioProps, RadioState> {
307
312
  onInputFocus={this.handleFocusVisible}
308
313
  onInputBlur={this.handleBlur}
309
314
  />
310
- {
311
- isCardRadioGroup ?
312
- <div className={`${prefix}-isCardRadioGroup_content`}>{renderContent()}</div> :
313
- renderContent()
314
- }
315
+ {renderContent()}
315
316
  </label>
316
317
  );
317
318
  }
@@ -88,7 +88,7 @@ class RadioGroup extends BaseComponent<RadioGroupProps, RadioGroupState> {
88
88
  constructor(props: RadioGroupProps) {
89
89
  super(props);
90
90
  this.state = {
91
- value: undefined,
91
+ value: props.value || props.defaultValue,
92
92
  };
93
93
  this.foundation = new RadioGroupFoundation(this.adapter);
94
94
  }