@douyinfe/semi-ui 2.40.0-beta.0 → 2.41.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/css/semi.css +26 -4
- package/dist/css/semi.min.css +1 -1
- package/dist/umd/semi-ui.js +5235 -1752
- package/dist/umd/semi-ui.js.map +1 -1
- package/dist/umd/semi-ui.min.js +1 -1
- package/dist/umd/semi-ui.min.js.map +1 -1
- package/lib/cjs/_portal/index.js +10 -10
- package/lib/cjs/_sortable/index.d.ts +41 -0
- package/lib/cjs/_sortable/index.js +177 -0
- package/lib/cjs/anchor/index.d.ts +1 -1
- package/lib/cjs/autoComplete/index.d.ts +1 -1
- package/lib/cjs/button/Button.d.ts +1 -1
- package/lib/cjs/button/index.d.ts +1 -1
- package/lib/cjs/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/cjs/carousel/index.d.ts +1 -1
- package/lib/cjs/datePicker/dateInput.d.ts +1 -1
- package/lib/cjs/datePicker/datePicker.d.ts +3 -3
- package/lib/cjs/datePicker/monthsGrid.d.ts +2 -2
- package/lib/cjs/datePicker/quickControl.d.ts +1 -1
- package/lib/cjs/datePicker/yearAndMonth.d.ts +2 -2
- package/lib/cjs/dropdown/index.d.ts +1 -1
- package/lib/cjs/form/baseForm.d.ts +3 -3
- package/lib/cjs/form/field.d.ts +3 -3
- package/lib/cjs/image/interface.d.ts +1 -1
- package/lib/cjs/image/preview.d.ts +1 -1
- package/lib/cjs/image/preview.js +1 -1
- package/lib/cjs/image/previewInner.d.ts +1 -1
- package/lib/cjs/image/previewInner.js +1 -1
- package/lib/cjs/modal/confirm.d.ts +104 -104
- package/lib/cjs/popover/index.d.ts +1 -1
- package/lib/cjs/radio/radio.d.ts +1 -1
- package/lib/cjs/radio/radioGroup.d.ts +1 -1
- package/lib/cjs/select/index.d.ts +1 -1
- package/lib/cjs/table/Column.d.ts +1 -1
- package/lib/cjs/table/ColumnShape.d.ts +1 -1
- package/lib/cjs/table/Table.d.ts +2 -2
- package/lib/cjs/table/index.d.ts +1 -1
- package/lib/cjs/tagInput/index.d.ts +4 -1
- package/lib/cjs/tagInput/index.js +58 -55
- package/lib/cjs/tooltip/index.d.ts +1 -1
- package/lib/cjs/transfer/index.d.ts +4 -3
- package/lib/cjs/transfer/index.js +65 -77
- package/lib/es/_portal/index.js +10 -10
- package/lib/es/_sortable/index.d.ts +41 -0
- package/lib/es/_sortable/index.js +167 -0
- package/lib/es/anchor/index.d.ts +1 -1
- package/lib/es/autoComplete/index.d.ts +1 -1
- package/lib/es/button/Button.d.ts +1 -1
- package/lib/es/button/index.d.ts +1 -1
- package/lib/es/carousel/CarouselIndicator.d.ts +1 -1
- package/lib/es/carousel/index.d.ts +1 -1
- package/lib/es/datePicker/dateInput.d.ts +1 -1
- package/lib/es/datePicker/datePicker.d.ts +3 -3
- package/lib/es/datePicker/monthsGrid.d.ts +2 -2
- package/lib/es/datePicker/quickControl.d.ts +1 -1
- package/lib/es/datePicker/yearAndMonth.d.ts +2 -2
- package/lib/es/dropdown/index.d.ts +1 -1
- package/lib/es/form/baseForm.d.ts +3 -3
- package/lib/es/form/field.d.ts +3 -3
- package/lib/es/image/interface.d.ts +1 -1
- package/lib/es/image/preview.d.ts +1 -1
- package/lib/es/image/preview.js +1 -1
- package/lib/es/image/previewInner.d.ts +1 -1
- package/lib/es/image/previewInner.js +1 -1
- package/lib/es/modal/confirm.d.ts +104 -104
- package/lib/es/popover/index.d.ts +1 -1
- package/lib/es/radio/radio.d.ts +1 -1
- package/lib/es/radio/radioGroup.d.ts +1 -1
- package/lib/es/select/index.d.ts +1 -1
- package/lib/es/table/Column.d.ts +1 -1
- package/lib/es/table/ColumnShape.d.ts +1 -1
- package/lib/es/table/Table.d.ts +2 -2
- package/lib/es/table/index.d.ts +1 -1
- package/lib/es/tagInput/index.d.ts +4 -1
- package/lib/es/tagInput/index.js +58 -55
- package/lib/es/tooltip/index.d.ts +1 -1
- package/lib/es/transfer/index.d.ts +4 -3
- package/lib/es/transfer/index.js +65 -77
- package/package.json +5 -3
package/lib/es/transfer/index.js
CHANGED
|
@@ -13,7 +13,6 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
13
13
|
};
|
|
14
14
|
import React from 'react';
|
|
15
15
|
import cls from 'classnames';
|
|
16
|
-
import { SortableContainer, SortableElement, SortableHandle } from 'react-sortable-hoc';
|
|
17
16
|
import PropTypes from 'prop-types';
|
|
18
17
|
import TransferFoundation from '@douyinfe/semi-foundation/lib/es/transfer/foundation';
|
|
19
18
|
import { _generateDataByType, _generateSelectedItems } from '@douyinfe/semi-foundation/lib/es/transfer/transferUtils';
|
|
@@ -27,34 +26,69 @@ import Spin from '../spin';
|
|
|
27
26
|
import Button from '../button';
|
|
28
27
|
import Tree from '../tree';
|
|
29
28
|
import { IconClose, IconSearch, IconHandle } from '@douyinfe/semi-icons';
|
|
29
|
+
import { Sortable } from '../_sortable';
|
|
30
|
+
import { verticalListSortingStrategy } from '@dnd-kit/sortable';
|
|
30
31
|
const prefixCls = cssClasses.PREFIX;
|
|
31
|
-
// SortableItem & SortableList should not be assigned inside of the render function
|
|
32
|
-
const SortableItem = SortableElement(props => props.item.node);
|
|
33
|
-
const SortableList = SortableContainer(_ref => {
|
|
34
|
-
let {
|
|
35
|
-
items
|
|
36
|
-
} = _ref;
|
|
37
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
-
className: `${prefixCls}-right-list`,
|
|
39
|
-
role: "list",
|
|
40
|
-
"aria-label": "Selected list"
|
|
41
|
-
}, items.map((item, index) =>
|
|
42
|
-
/*#__PURE__*/
|
|
43
|
-
// @ts-ignore skip SortableItem type check
|
|
44
|
-
React.createElement(SortableItem, {
|
|
45
|
-
key: item.key,
|
|
46
|
-
index: index,
|
|
47
|
-
item: item
|
|
48
|
-
})))
|
|
49
|
-
// @ts-ignore see reasons: https://github.com/clauderic/react-sortable-hoc/issues/206
|
|
50
|
-
;
|
|
51
|
-
}, {
|
|
52
|
-
distance: 10
|
|
53
|
-
});
|
|
54
32
|
class Transfer extends BaseComponent {
|
|
55
33
|
constructor(props) {
|
|
56
34
|
super(props);
|
|
57
35
|
this._treeRef = null;
|
|
36
|
+
this.renderRightItem = (item, sortableHandle) => {
|
|
37
|
+
const {
|
|
38
|
+
renderSelectedItem,
|
|
39
|
+
draggable,
|
|
40
|
+
type,
|
|
41
|
+
showPath
|
|
42
|
+
} = this.props;
|
|
43
|
+
const onRemove = () => this.foundation.handleSelectOrRemove(item);
|
|
44
|
+
const rightItemCls = cls({
|
|
45
|
+
[`${prefixCls}-item`]: true,
|
|
46
|
+
[`${prefixCls}-right-item`]: true,
|
|
47
|
+
[`${prefixCls}-right-item-draggable`]: draggable
|
|
48
|
+
});
|
|
49
|
+
const shouldShowPath = type === strings.TYPE_TREE_TO_LIST && showPath === true;
|
|
50
|
+
const label = shouldShowPath ? this.foundation._generatePath(item) : item.label;
|
|
51
|
+
if (renderSelectedItem) {
|
|
52
|
+
return renderSelectedItem(Object.assign(Object.assign({}, item), {
|
|
53
|
+
onRemove,
|
|
54
|
+
sortableHandle
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
const DragHandle = sortableHandle && sortableHandle(() => /*#__PURE__*/React.createElement(IconHandle, {
|
|
58
|
+
role: "button",
|
|
59
|
+
"aria-label": "Drag and sort",
|
|
60
|
+
className: `${prefixCls}-right-item-drag-handler`
|
|
61
|
+
}));
|
|
62
|
+
return (
|
|
63
|
+
/*#__PURE__*/
|
|
64
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
|
|
65
|
+
React.createElement("div", {
|
|
66
|
+
role: "listitem",
|
|
67
|
+
className: rightItemCls,
|
|
68
|
+
key: item.key
|
|
69
|
+
}, draggable && sortableHandle ? /*#__PURE__*/React.createElement(DragHandle, null) : null, /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: `${prefixCls}-right-item-text`
|
|
71
|
+
}, label), /*#__PURE__*/React.createElement(IconClose, {
|
|
72
|
+
onClick: onRemove,
|
|
73
|
+
"aria-disabled": item.disabled,
|
|
74
|
+
className: cls(`${prefixCls}-item-close-icon`, {
|
|
75
|
+
[`${prefixCls}-item-close-icon-disabled`]: item.disabled
|
|
76
|
+
})
|
|
77
|
+
}))
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
this.renderSortItem = props => {
|
|
81
|
+
const {
|
|
82
|
+
id,
|
|
83
|
+
sortableHandle
|
|
84
|
+
} = props;
|
|
85
|
+
const {
|
|
86
|
+
selectedItems
|
|
87
|
+
} = this.state;
|
|
88
|
+
const selectedData = [...selectedItems.values()];
|
|
89
|
+
const item = selectedData.find(item => item.key === id);
|
|
90
|
+
return this.renderRightItem(item, sortableHandle);
|
|
91
|
+
};
|
|
58
92
|
const {
|
|
59
93
|
defaultValue = [],
|
|
60
94
|
dataSource,
|
|
@@ -421,50 +455,6 @@ class Transfer extends BaseComponent {
|
|
|
421
455
|
"aria-label": "Option list"
|
|
422
456
|
}, content);
|
|
423
457
|
}
|
|
424
|
-
renderRightItem(item) {
|
|
425
|
-
const {
|
|
426
|
-
renderSelectedItem,
|
|
427
|
-
draggable,
|
|
428
|
-
type,
|
|
429
|
-
showPath
|
|
430
|
-
} = this.props;
|
|
431
|
-
const onRemove = () => this.foundation.handleSelectOrRemove(item);
|
|
432
|
-
const rightItemCls = cls({
|
|
433
|
-
[`${prefixCls}-item`]: true,
|
|
434
|
-
[`${prefixCls}-right-item`]: true,
|
|
435
|
-
[`${prefixCls}-right-item-draggable`]: draggable
|
|
436
|
-
});
|
|
437
|
-
const shouldShowPath = type === strings.TYPE_TREE_TO_LIST && showPath === true;
|
|
438
|
-
const label = shouldShowPath ? this.foundation._generatePath(item) : item.label;
|
|
439
|
-
if (renderSelectedItem) {
|
|
440
|
-
return renderSelectedItem(Object.assign(Object.assign({}, item), {
|
|
441
|
-
onRemove,
|
|
442
|
-
sortableHandle: SortableHandle
|
|
443
|
-
}));
|
|
444
|
-
}
|
|
445
|
-
const DragHandle = SortableHandle(() => /*#__PURE__*/React.createElement(IconHandle, {
|
|
446
|
-
role: "button",
|
|
447
|
-
"aria-label": "Drag and sort",
|
|
448
|
-
className: `${prefixCls}-right-item-drag-handler`
|
|
449
|
-
}));
|
|
450
|
-
return (
|
|
451
|
-
/*#__PURE__*/
|
|
452
|
-
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex
|
|
453
|
-
React.createElement("div", {
|
|
454
|
-
role: "listitem",
|
|
455
|
-
className: rightItemCls,
|
|
456
|
-
key: item.key
|
|
457
|
-
}, draggable ? /*#__PURE__*/React.createElement(DragHandle, null) : null, /*#__PURE__*/React.createElement("div", {
|
|
458
|
-
className: `${prefixCls}-right-item-text`
|
|
459
|
-
}, label), /*#__PURE__*/React.createElement(IconClose, {
|
|
460
|
-
onClick: onRemove,
|
|
461
|
-
"aria-disabled": item.disabled,
|
|
462
|
-
className: cls(`${prefixCls}-item-close-icon`, {
|
|
463
|
-
[`${prefixCls}-item-close-icon-disabled`]: item.disabled
|
|
464
|
-
})
|
|
465
|
-
}))
|
|
466
|
-
);
|
|
467
|
-
}
|
|
468
458
|
renderEmpty(type, emptyText) {
|
|
469
459
|
const emptyCls = cls({
|
|
470
460
|
[`${prefixCls}-empty`]: true,
|
|
@@ -477,16 +467,14 @@ class Transfer extends BaseComponent {
|
|
|
477
467
|
}, emptyText);
|
|
478
468
|
}
|
|
479
469
|
renderRightSortableList(selectedData) {
|
|
480
|
-
const
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// helperClass:add styles to the helper(item being dragged) https://github.com/clauderic/react-sortable-hoc/issues/87
|
|
484
|
-
// @ts-ignore skip SortableItem type check
|
|
485
|
-
const sortList = /*#__PURE__*/React.createElement(SortableList, {
|
|
486
|
-
useDragHandle: true,
|
|
487
|
-
helperClass: `${prefixCls}-right-item-drag-item-move`,
|
|
470
|
+
const sortItems = selectedData.map(item => item.key);
|
|
471
|
+
const sortList = /*#__PURE__*/React.createElement(Sortable, {
|
|
472
|
+
strategy: verticalListSortingStrategy,
|
|
488
473
|
onSortEnd: this.onSortEnd,
|
|
489
|
-
items:
|
|
474
|
+
items: sortItems,
|
|
475
|
+
renderItem: this.renderSortItem,
|
|
476
|
+
prefix: `${prefixCls}-right-item`,
|
|
477
|
+
dragOverlayCls: `${prefixCls}-right-item-drag-item-move`
|
|
490
478
|
});
|
|
491
479
|
return sortList;
|
|
492
480
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.41.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
"lib/*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@dnd-kit/core": "^6.0.8",
|
|
21
|
+
"@dnd-kit/sortable": "^7.0.2",
|
|
22
|
+
"@dnd-kit/utilities": "^3.2.1",
|
|
20
23
|
"@douyinfe/semi-animation": "2.40.0-beta.0",
|
|
21
24
|
"@douyinfe/semi-animation-react": "2.40.0-beta.0",
|
|
22
25
|
"@douyinfe/semi-foundation": "2.40.0-beta.0",
|
|
@@ -31,7 +34,6 @@
|
|
|
31
34
|
"lodash": "^4.17.21",
|
|
32
35
|
"prop-types": "^15.7.2",
|
|
33
36
|
"react-resizable": "^1.8.0",
|
|
34
|
-
"react-sortable-hoc": "^2.0.0",
|
|
35
37
|
"react-window": "^1.8.2",
|
|
36
38
|
"resize-observer-polyfill": "^1.5.1",
|
|
37
39
|
"scroll-into-view-if-needed": "^2.2.24",
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
],
|
|
70
72
|
"author": "",
|
|
71
73
|
"license": "MIT",
|
|
72
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "f83f6076d1c6f3b64c1d9359a335a7182d991fb6",
|
|
73
75
|
"devDependencies": {
|
|
74
76
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
75
77
|
"@babel/plugin-transform-runtime": "^7.15.8",
|