@douyinfe/semi-ui 2.23.0 → 2.23.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.
@@ -105,7 +105,7 @@ const local = {
105
105
  },
106
106
  Table: {
107
107
  emptyText: 'Không kết quả',
108
- pageText: 'Hiển thị $ {currentStart} đến $ {currentEnd} trong tổng số $ {total}}'
108
+ pageText: 'Hiển thị ${currentStart} đến ${currentEnd} trong tổng số ${total}}'
109
109
  },
110
110
  Select: {
111
111
  emptyText: 'Không kết quả',
@@ -74,8 +74,6 @@ class Modal extends _baseComponent.default {
74
74
  visible
75
75
  } = this.props;
76
76
  this.foundation.toggleDisplayNone(!visible);
77
- const shouldRender = this.props.visible || this.props.keepDOM && (!this.props.lazyRender || this._haveRendered);
78
- this.foundation.setShouldRender(shouldRender);
79
77
  };
80
78
 
81
79
  this.renderFooter = () => {
@@ -157,8 +155,11 @@ class Modal extends _baseComponent.default {
157
155
  const classList = (0, _classnames.default)(className, {
158
156
  ["".concat(_constants.cssClasses.DIALOG, "-displayNone")]: keepDOM && this.state.displayNone
159
157
  });
158
+ const shouldRender = this.props.visible || this.props.keepDOM && (!this.props.lazyRender || this._haveRendered) || this.props.motion && !this.state.displayNone
159
+ /* When there is animation, we use displayNone to judge whether animation is ended and judge whether to unmount content */
160
+ ;
160
161
 
161
- if (this.state.shouldRender) {
162
+ if (shouldRender) {
162
163
  this._haveRendered = true;
163
164
  }
164
165
 
@@ -189,7 +190,7 @@ class Modal extends _baseComponent.default {
189
190
  animationClassName: maskAnimationClassName,
190
191
  animationEventsNeedBind: maskAnimationEventsNeedBind
191
192
  } = _ref2;
192
- return this.state.shouldRender ? /*#__PURE__*/_react.default.createElement(_ModalContent.default, Object.assign({}, restProps, {
193
+ return shouldRender ? /*#__PURE__*/_react.default.createElement(_ModalContent.default, Object.assign({}, restProps, {
193
194
  contentExtraProps: animationEventsNeedBind,
194
195
  maskExtraProps: maskAnimationEventsNeedBind,
195
196
  isFullScreen: this.state.isFullScreen,
@@ -209,8 +210,7 @@ class Modal extends _baseComponent.default {
209
210
 
210
211
  this.state = {
211
212
  displayNone: !props.visible,
212
- isFullScreen: props.fullScreen,
213
- shouldRender: this.props.visible || this.props.keepDOM && !this.props.lazyRender
213
+ isFullScreen: props.fullScreen
214
214
  };
215
215
  this.foundation = new _modalFoundation.default(this.adapter);
216
216
  this.modalRef = /*#__PURE__*/_react.default.createRef();
@@ -265,13 +265,6 @@ class Modal extends _baseComponent.default {
265
265
  isFullScreen
266
266
  });
267
267
  }
268
- },
269
- setShouldRender: shouldRender => {
270
- if (shouldRender !== this.state.shouldRender) {
271
- this.setState({
272
- shouldRender
273
- });
274
- }
275
268
  }
276
269
  });
277
270
  }
@@ -317,12 +310,6 @@ class Modal extends _baseComponent.default {
317
310
  this.foundation.beforeShow();
318
311
  }
319
312
 
320
- const shouldRender = this.props.visible || this.props.keepDOM && (!this.props.lazyRender || this._haveRendered);
321
-
322
- if (shouldRender === true && this.state.shouldRender === false) {
323
- this.foundation.setShouldRender(true);
324
- }
325
-
326
313
  if (!prevState.displayNone && this.state.displayNone) {
327
314
  this.foundation.afterHide();
328
315
  }
@@ -61,14 +61,11 @@ class SideSheet extends _baseComponent.default {
61
61
  };
62
62
 
63
63
  this.updateState = () => {
64
- const shouldRender = this.props.visible || this.props.keepDOM;
65
- this.foundation.setShouldRender(shouldRender);
66
64
  this.foundation.toggleDisplayNone(!this.props.visible);
67
65
  };
68
66
 
69
67
  this.state = {
70
- displayNone: !this.props.visible,
71
- shouldRender: this.props.visible
68
+ displayNone: !this.props.visible
72
69
  };
73
70
  this.foundation = new _sideSheetFoundation.default(this.adapter);
74
71
  }
@@ -115,13 +112,6 @@ class SideSheet extends _baseComponent.default {
115
112
  displayNone: displayNone
116
113
  });
117
114
  }
118
- },
119
- setShouldRender: shouldRender => {
120
- if (shouldRender !== this.state.shouldRender) {
121
- this.setState({
122
- shouldRender
123
- });
124
- }
125
115
  }
126
116
  });
127
117
  }
@@ -157,12 +147,6 @@ class SideSheet extends _baseComponent.default {
157
147
  this.foundation.afterHide();
158
148
  }
159
149
 
160
- const shouldRender = this.props.visible || this.props.keepDOM;
161
-
162
- if (shouldRender === true && this.state.shouldRender === false) {
163
- this.foundation.setShouldRender(true);
164
- }
165
-
166
150
  if (prevState.displayNone !== this.state.displayNone) {
167
151
  this.foundation.onVisibleChange(!this.state.displayNone);
168
152
  }
@@ -214,7 +198,10 @@ class SideSheet extends _baseComponent.default {
214
198
  width: sheetWidth,
215
199
  height: sheetHeight,
216
200
  onClose: this.handleCancel
217
- }); // Since user could change animate duration , we don't know which animation end first. So we call updateState func twice.
201
+ });
202
+ const shouldRender = this.props.visible || this.props.keepDOM || this.props.motion && !this.state.displayNone
203
+ /* When there is animation, we use displayNone to judge whether animation is ended and judge whether to unmount content */
204
+ ; // Since user could change animate duration , we don't know which animation end first. So we call updateState func twice.
218
205
 
219
206
  return /*#__PURE__*/_react.default.createElement(_cssAnimation.default, {
220
207
  motion: this.props.motion,
@@ -239,7 +226,7 @@ class SideSheet extends _baseComponent.default {
239
226
  animationStyle,
240
227
  animationEventsNeedBind
241
228
  } = _ref2;
242
- return this.state.shouldRender ? /*#__PURE__*/_react.default.createElement(_SideSheetContent.default, Object.assign({}, contentProps, {
229
+ return shouldRender ? /*#__PURE__*/_react.default.createElement(_SideSheetContent.default, Object.assign({}, contentProps, {
243
230
  maskExtraProps: maskAnimationEventsNeedBind,
244
231
  wrapperExtraProps: animationEventsNeedBind,
245
232
  dialogClassName: animationClassName,
@@ -450,9 +450,11 @@ class TagInput extends _baseComponent.default {
450
450
  }));
451
451
 
452
452
  if (active && draggable && sortableListItems.length > 0) {
453
+ // helperClass:add styles to the helper(item being dragged) https://github.com/clauderic/react-sortable-hoc/issues/87
453
454
  // @ts-ignore skip SortableItem type check
454
455
  return /*#__PURE__*/_react.default.createElement(SortableList, {
455
456
  useDragHandle: true,
457
+ helperClass: "".concat(prefixCls, "-drag-item-move"),
456
458
  items: sortableListItems,
457
459
  onSortEnd: this.onSortEnd,
458
460
  axis: "xy"
@@ -49,7 +49,30 @@ var _semiIcons = require("@douyinfe/semi-icons");
49
49
 
50
50
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
51
51
 
52
- const prefixcls = _constants.cssClasses.PREFIX;
52
+ const prefixcls = _constants.cssClasses.PREFIX; // SortableItem & SortableList should not be assigned inside of the render function
53
+
54
+ const SortableItem = (0, _reactSortableHoc.SortableElement)(props => props.item.node);
55
+ const SortableList = (0, _reactSortableHoc.SortableContainer)(_ref => {
56
+ let {
57
+ items
58
+ } = _ref;
59
+ return /*#__PURE__*/_react.default.createElement("div", {
60
+ className: "".concat(prefixcls, "-right-list"),
61
+ role: "list",
62
+ "aria-label": "Selected list"
63
+ }, items.map((item, index) =>
64
+ /*#__PURE__*/
65
+ // @ts-ignore skip SortableItem type check
66
+ _react.default.createElement(SortableItem, {
67
+ key: item.label,
68
+ index: index,
69
+ item: item
70
+ }))) // eslint-disable-next-line @typescript-eslint/ban-ts-comment
71
+ // @ts-ignore see reasons: https://github.com/clauderic/react-sortable-hoc/issues/206
72
+ ;
73
+ }, {
74
+ distance: 10
75
+ });
53
76
 
54
77
  class Transfer extends _baseComponent.default {
55
78
  constructor(props) {
@@ -493,34 +516,16 @@ class Transfer extends _baseComponent.default {
493
516
  }
494
517
 
495
518
  renderRightSortableList(selectedData) {
496
- // when choose some items && draggable is true
497
- const SortableItem = (0, _reactSortableHoc.SortableElement)(props => this.renderRightItem(props.item));
498
- const SortableList = (0, _reactSortableHoc.SortableContainer)(_ref => {
499
- let {
500
- items
501
- } = _ref;
502
- return /*#__PURE__*/_react.default.createElement("div", {
503
- className: "".concat(prefixcls, "-right-list"),
504
- role: "list",
505
- "aria-label": "Selected list"
506
- }, items.map((item, index) =>
507
- /*#__PURE__*/
508
- // @ts-ignore skip SortableItem type check
509
- _react.default.createElement(SortableItem, {
510
- key: item.label,
511
- index: index,
512
- item: item
513
- }))) // eslint-disable-next-line @typescript-eslint/ban-ts-comment
514
- // @ts-ignore see reasons: https://github.com/clauderic/react-sortable-hoc/issues/206
515
- ;
516
- }, {
517
- distance: 10
518
- }); // @ts-ignore skip SortableItem type check
519
+ const sortableListItems = selectedData.map(item => Object.assign(Object.assign({}, item), {
520
+ node: this.renderRightItem(item)
521
+ })); // helperClass:add styles to the helper(item being dragged) https://github.com/clauderic/react-sortable-hoc/issues/87
522
+ // @ts-ignore skip SortableItem type check
519
523
 
520
524
  const sortList = /*#__PURE__*/_react.default.createElement(SortableList, {
521
525
  useDragHandle: true,
526
+ helperClass: "".concat(prefixcls, "-right-item-drag-item-move"),
522
527
  onSortEnd: this.onSortEnd,
523
- items: selectedData
528
+ items: sortableListItems
524
529
  });
525
530
 
526
531
  return sortList;
@@ -97,7 +97,7 @@ const local = {
97
97
  },
98
98
  Table: {
99
99
  emptyText: 'Không kết quả',
100
- pageText: 'Hiển thị $ {currentStart} đến $ {currentEnd} trong tổng số $ {total}}'
100
+ pageText: 'Hiển thị ${currentStart} đến ${currentEnd} trong tổng số ${total}}'
101
101
  },
102
102
  Select: {
103
103
  emptyText: 'Không kết quả',
@@ -46,8 +46,6 @@ class Modal extends BaseComponent {
46
46
  visible
47
47
  } = this.props;
48
48
  this.foundation.toggleDisplayNone(!visible);
49
- const shouldRender = this.props.visible || this.props.keepDOM && (!this.props.lazyRender || this._haveRendered);
50
- this.foundation.setShouldRender(shouldRender);
51
49
  };
52
50
 
53
51
  this.renderFooter = () => {
@@ -129,8 +127,11 @@ class Modal extends BaseComponent {
129
127
  const classList = cls(className, {
130
128
  ["".concat(cssClasses.DIALOG, "-displayNone")]: keepDOM && this.state.displayNone
131
129
  });
130
+ const shouldRender = this.props.visible || this.props.keepDOM && (!this.props.lazyRender || this._haveRendered) || this.props.motion && !this.state.displayNone
131
+ /* When there is animation, we use displayNone to judge whether animation is ended and judge whether to unmount content */
132
+ ;
132
133
 
133
- if (this.state.shouldRender) {
134
+ if (shouldRender) {
134
135
  this._haveRendered = true;
135
136
  }
136
137
 
@@ -161,7 +162,7 @@ class Modal extends BaseComponent {
161
162
  animationClassName: maskAnimationClassName,
162
163
  animationEventsNeedBind: maskAnimationEventsNeedBind
163
164
  } = _ref2;
164
- return this.state.shouldRender ? /*#__PURE__*/React.createElement(ModalContent, Object.assign({}, restProps, {
165
+ return shouldRender ? /*#__PURE__*/React.createElement(ModalContent, Object.assign({}, restProps, {
165
166
  contentExtraProps: animationEventsNeedBind,
166
167
  maskExtraProps: maskAnimationEventsNeedBind,
167
168
  isFullScreen: this.state.isFullScreen,
@@ -181,8 +182,7 @@ class Modal extends BaseComponent {
181
182
 
182
183
  this.state = {
183
184
  displayNone: !props.visible,
184
- isFullScreen: props.fullScreen,
185
- shouldRender: this.props.visible || this.props.keepDOM && !this.props.lazyRender
185
+ isFullScreen: props.fullScreen
186
186
  };
187
187
  this.foundation = new ModalFoundation(this.adapter);
188
188
  this.modalRef = /*#__PURE__*/React.createRef();
@@ -237,13 +237,6 @@ class Modal extends BaseComponent {
237
237
  isFullScreen
238
238
  });
239
239
  }
240
- },
241
- setShouldRender: shouldRender => {
242
- if (shouldRender !== this.state.shouldRender) {
243
- this.setState({
244
- shouldRender
245
- });
246
- }
247
240
  }
248
241
  });
249
242
  }
@@ -289,12 +282,6 @@ class Modal extends BaseComponent {
289
282
  this.foundation.beforeShow();
290
283
  }
291
284
 
292
- const shouldRender = this.props.visible || this.props.keepDOM && (!this.props.lazyRender || this._haveRendered);
293
-
294
- if (shouldRender === true && this.state.shouldRender === false) {
295
- this.foundation.setShouldRender(true);
296
- }
297
-
298
285
  if (!prevState.displayNone && this.state.displayNone) {
299
286
  this.foundation.afterHide();
300
287
  }
@@ -40,14 +40,11 @@ export default class SideSheet extends BaseComponent {
40
40
  };
41
41
 
42
42
  this.updateState = () => {
43
- const shouldRender = this.props.visible || this.props.keepDOM;
44
- this.foundation.setShouldRender(shouldRender);
45
43
  this.foundation.toggleDisplayNone(!this.props.visible);
46
44
  };
47
45
 
48
46
  this.state = {
49
- displayNone: !this.props.visible,
50
- shouldRender: this.props.visible
47
+ displayNone: !this.props.visible
51
48
  };
52
49
  this.foundation = new SideSheetFoundation(this.adapter);
53
50
  }
@@ -94,13 +91,6 @@ export default class SideSheet extends BaseComponent {
94
91
  displayNone: displayNone
95
92
  });
96
93
  }
97
- },
98
- setShouldRender: shouldRender => {
99
- if (shouldRender !== this.state.shouldRender) {
100
- this.setState({
101
- shouldRender
102
- });
103
- }
104
94
  }
105
95
  });
106
96
  }
@@ -136,12 +126,6 @@ export default class SideSheet extends BaseComponent {
136
126
  this.foundation.afterHide();
137
127
  }
138
128
 
139
- const shouldRender = this.props.visible || this.props.keepDOM;
140
-
141
- if (shouldRender === true && this.state.shouldRender === false) {
142
- this.foundation.setShouldRender(true);
143
- }
144
-
145
129
  if (prevState.displayNone !== this.state.displayNone) {
146
130
  this.foundation.onVisibleChange(!this.state.displayNone);
147
131
  }
@@ -193,7 +177,10 @@ export default class SideSheet extends BaseComponent {
193
177
  width: sheetWidth,
194
178
  height: sheetHeight,
195
179
  onClose: this.handleCancel
196
- }); // Since user could change animate duration , we don't know which animation end first. So we call updateState func twice.
180
+ });
181
+ const shouldRender = this.props.visible || this.props.keepDOM || this.props.motion && !this.state.displayNone
182
+ /* When there is animation, we use displayNone to judge whether animation is ended and judge whether to unmount content */
183
+ ; // Since user could change animate duration , we don't know which animation end first. So we call updateState func twice.
197
184
 
198
185
  return /*#__PURE__*/React.createElement(CSSAnimation, {
199
186
  motion: this.props.motion,
@@ -218,7 +205,7 @@ export default class SideSheet extends BaseComponent {
218
205
  animationStyle,
219
206
  animationEventsNeedBind
220
207
  } = _ref2;
221
- return this.state.shouldRender ? /*#__PURE__*/React.createElement(SideSheetContent, Object.assign({}, contentProps, {
208
+ return shouldRender ? /*#__PURE__*/React.createElement(SideSheetContent, Object.assign({}, contentProps, {
222
209
  maskExtraProps: maskAnimationEventsNeedBind,
223
210
  wrapperExtraProps: animationEventsNeedBind,
224
211
  dialogClassName: animationClassName,
@@ -420,9 +420,11 @@ class TagInput extends BaseComponent {
420
420
  }));
421
421
 
422
422
  if (active && draggable && sortableListItems.length > 0) {
423
+ // helperClass:add styles to the helper(item being dragged) https://github.com/clauderic/react-sortable-hoc/issues/87
423
424
  // @ts-ignore skip SortableItem type check
424
425
  return /*#__PURE__*/React.createElement(SortableList, {
425
426
  useDragHandle: true,
427
+ helperClass: "".concat(prefixCls, "-drag-item-move"),
426
428
  items: sortableListItems,
427
429
  onSortEnd: this.onSortEnd,
428
430
  axis: "xy"
@@ -19,7 +19,30 @@ import Spin from '../spin';
19
19
  import Button from '../button';
20
20
  import Tree from '../tree';
21
21
  import { IconClose, IconSearch, IconHandle } from '@douyinfe/semi-icons';
22
- const prefixcls = cssClasses.PREFIX;
22
+ const prefixcls = cssClasses.PREFIX; // SortableItem & SortableList should not be assigned inside of the render function
23
+
24
+ const SortableItem = SortableElement(props => props.item.node);
25
+ const SortableList = SortableContainer(_ref => {
26
+ let {
27
+ items
28
+ } = _ref;
29
+ return /*#__PURE__*/React.createElement("div", {
30
+ className: "".concat(prefixcls, "-right-list"),
31
+ role: "list",
32
+ "aria-label": "Selected list"
33
+ }, items.map((item, index) =>
34
+ /*#__PURE__*/
35
+ // @ts-ignore skip SortableItem type check
36
+ React.createElement(SortableItem, {
37
+ key: item.label,
38
+ index: index,
39
+ item: item
40
+ }))) // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
+ // @ts-ignore see reasons: https://github.com/clauderic/react-sortable-hoc/issues/206
42
+ ;
43
+ }, {
44
+ distance: 10
45
+ });
23
46
 
24
47
  class Transfer extends BaseComponent {
25
48
  constructor(props) {
@@ -462,34 +485,16 @@ class Transfer extends BaseComponent {
462
485
  }
463
486
 
464
487
  renderRightSortableList(selectedData) {
465
- // when choose some items && draggable is true
466
- const SortableItem = SortableElement(props => this.renderRightItem(props.item));
467
- const SortableList = SortableContainer(_ref => {
468
- let {
469
- items
470
- } = _ref;
471
- return /*#__PURE__*/React.createElement("div", {
472
- className: "".concat(prefixcls, "-right-list"),
473
- role: "list",
474
- "aria-label": "Selected list"
475
- }, items.map((item, index) =>
476
- /*#__PURE__*/
477
- // @ts-ignore skip SortableItem type check
478
- React.createElement(SortableItem, {
479
- key: item.label,
480
- index: index,
481
- item: item
482
- }))) // eslint-disable-next-line @typescript-eslint/ban-ts-comment
483
- // @ts-ignore see reasons: https://github.com/clauderic/react-sortable-hoc/issues/206
484
- ;
485
- }, {
486
- distance: 10
487
- }); // @ts-ignore skip SortableItem type check
488
+ const sortableListItems = selectedData.map(item => Object.assign(Object.assign({}, item), {
489
+ node: this.renderRightItem(item)
490
+ })); // helperClass:add styles to the helper(item being dragged) https://github.com/clauderic/react-sortable-hoc/issues/87
491
+ // @ts-ignore skip SortableItem type check
488
492
 
489
493
  const sortList = /*#__PURE__*/React.createElement(SortableList, {
490
494
  useDragHandle: true,
495
+ helperClass: "".concat(prefixcls, "-right-item-drag-item-move"),
491
496
  onSortEnd: this.onSortEnd,
492
- items: selectedData
497
+ items: sortableListItems
493
498
  });
494
499
  return sortList;
495
500
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@douyinfe/semi-ui",
3
- "version": "2.23.0",
3
+ "version": "2.23.1",
4
4
  "description": "",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es/index.js",
@@ -18,11 +18,11 @@
18
18
  ],
19
19
  "dependencies": {
20
20
  "@douyinfe/semi-animation": "2.12.0",
21
- "@douyinfe/semi-animation-react": "2.23.0",
22
- "@douyinfe/semi-foundation": "2.23.0",
23
- "@douyinfe/semi-icons": "2.23.0",
21
+ "@douyinfe/semi-animation-react": "2.23.1",
22
+ "@douyinfe/semi-foundation": "2.23.1",
23
+ "@douyinfe/semi-icons": "2.23.1",
24
24
  "@douyinfe/semi-illustrations": "2.15.0",
25
- "@douyinfe/semi-theme-default": "2.23.0",
25
+ "@douyinfe/semi-theme-default": "2.23.1",
26
26
  "async-validator": "^3.5.0",
27
27
  "classnames": "^2.2.6",
28
28
  "copy-text-to-clipboard": "^2.1.1",
@@ -69,13 +69,13 @@
69
69
  ],
70
70
  "author": "",
71
71
  "license": "MIT",
72
- "gitHead": "a5195872c7df1a97551c6c23357bdb941b8fa807",
72
+ "gitHead": "3960e35ea5c7244e5adbc9cb938330e9a6ee43e2",
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.23.0",
78
+ "@douyinfe/semi-scss-compile": "2.23.1",
79
79
  "@storybook/addon-knobs": "^6.3.1",
80
80
  "@types/lodash": "^4.14.176",
81
81
  "@types/react": ">=16.0.0",