@douyinfe/semi-ui 2.1.0-beta.0 → 2.1.0-beta.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/dist/umd/semi-ui.js +61 -28
- 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/es/cascader/index.js +15 -3
- package/lib/es/select/index.js +16 -9
- package/lib/es/select/option.js +2 -2
- package/lib/es/select/utils.d.ts +1 -1
- package/lib/es/select/utils.js +10 -4
- package/lib/es/tree/interface.d.ts +2 -2
- package/package.json +8 -8
package/lib/es/cascader/index.js
CHANGED
|
@@ -272,15 +272,27 @@ class Cascader extends BaseComponent {
|
|
|
272
272
|
this.renderCustomTrigger = () => {
|
|
273
273
|
const {
|
|
274
274
|
disabled,
|
|
275
|
-
triggerRender
|
|
275
|
+
triggerRender,
|
|
276
|
+
multiple,
|
|
277
|
+
autoMergeValue
|
|
276
278
|
} = this.props;
|
|
277
279
|
const {
|
|
278
280
|
selectedKeys,
|
|
279
281
|
inputValue,
|
|
280
|
-
inputPlaceHolder
|
|
282
|
+
inputPlaceHolder,
|
|
283
|
+
mergedCheckedKeys,
|
|
284
|
+
checkedKeys
|
|
281
285
|
} = this.state;
|
|
286
|
+
let realValue;
|
|
287
|
+
|
|
288
|
+
if (multiple) {
|
|
289
|
+
realValue = autoMergeValue ? mergedCheckedKeys : checkedKeys;
|
|
290
|
+
} else {
|
|
291
|
+
realValue = [...selectedKeys][0];
|
|
292
|
+
}
|
|
293
|
+
|
|
282
294
|
return /*#__PURE__*/React.createElement(Trigger, {
|
|
283
|
-
value:
|
|
295
|
+
value: realValue,
|
|
284
296
|
inputValue: inputValue,
|
|
285
297
|
onChange: this.handleInputChange,
|
|
286
298
|
onClear: this.handleClear,
|
package/lib/es/select/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import ConfigContext from '../configProvider/context';
|
|
|
22
22
|
import SelectFoundation from '@douyinfe/semi-foundation/lib/es/select/foundation';
|
|
23
23
|
import { cssClasses, strings, numbers } from '@douyinfe/semi-foundation/lib/es/select/constants';
|
|
24
24
|
import BaseComponent from '../_base/baseComponent';
|
|
25
|
-
import { isEqual, isString, noop } from 'lodash-es';
|
|
25
|
+
import { isEqual, isString, noop, get, isNumber } from 'lodash-es';
|
|
26
26
|
import Tag from '../tag/index';
|
|
27
27
|
import TagGroup from '../tag/group';
|
|
28
28
|
import LocaleCosumer from '../locale/localeConsumer';
|
|
@@ -177,9 +177,10 @@ class Select extends BaseComponent {
|
|
|
177
177
|
} = _this.props;
|
|
178
178
|
|
|
179
179
|
if (optionList && optionList.length) {
|
|
180
|
-
options = _mapInstanceProperty(optionList).call(optionList, itemOpt => _Object$assign({
|
|
180
|
+
options = _mapInstanceProperty(optionList).call(optionList, (itemOpt, index) => _Object$assign({
|
|
181
181
|
_show: true,
|
|
182
|
-
_selected: false
|
|
182
|
+
_selected: false,
|
|
183
|
+
_scrollIndex: index
|
|
183
184
|
}, itemOpt));
|
|
184
185
|
optionGroups[0] = {
|
|
185
186
|
children: options,
|
|
@@ -754,15 +755,21 @@ class Select extends BaseComponent {
|
|
|
754
755
|
}
|
|
755
756
|
|
|
756
757
|
if (virtualize) {
|
|
757
|
-
let
|
|
758
|
+
let minItemIndex = -1;
|
|
758
759
|
|
|
759
|
-
_forEachInstanceProperty(selections).call(selections,
|
|
760
|
-
const
|
|
761
|
-
|
|
760
|
+
_forEachInstanceProperty(selections).call(selections, item => {
|
|
761
|
+
const itemIndex = get(item, '_scrollIndex');
|
|
762
|
+
/* When the itemIndex is legal */
|
|
763
|
+
|
|
764
|
+
if (isNumber(itemIndex) && itemIndex >= 0) {
|
|
765
|
+
minItemIndex = minItemIndex !== -1 && minItemIndex < itemIndex ? minItemIndex : itemIndex;
|
|
766
|
+
}
|
|
762
767
|
});
|
|
763
768
|
|
|
764
|
-
if (
|
|
765
|
-
|
|
769
|
+
if (minItemIndex !== -1) {
|
|
770
|
+
try {
|
|
771
|
+
this.virtualizeListRef.current.scrollToItem(minItemIndex, 'center');
|
|
772
|
+
} catch (error) {}
|
|
766
773
|
}
|
|
767
774
|
} else {
|
|
768
775
|
this.foundation.updateScrollTop();
|
package/lib/es/select/option.js
CHANGED
|
@@ -144,14 +144,14 @@ class Option extends PureComponent {
|
|
|
144
144
|
style: style
|
|
145
145
|
}, showTick ? /*#__PURE__*/React.createElement("div", {
|
|
146
146
|
className: selectedIconClassName
|
|
147
|
-
}, /*#__PURE__*/React.createElement(IconTick, null)) : null, /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
}, /*#__PURE__*/React.createElement(IconTick, null)) : null, isString(children) ? /*#__PURE__*/React.createElement("div", {
|
|
148
148
|
className: "".concat(prefixCls, "-text")
|
|
149
149
|
}, this.renderOptionContent({
|
|
150
150
|
children,
|
|
151
151
|
config,
|
|
152
152
|
inputValue,
|
|
153
153
|
prefixCls
|
|
154
|
-
})));
|
|
154
|
+
})) : children);
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
}
|
package/lib/es/select/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { OptionProps } from './option';
|
|
3
3
|
import { OptionGroupProps } from './optionGroup';
|
|
4
|
-
declare const generateOption: (child: React.ReactElement, parent
|
|
4
|
+
declare const generateOption: (child: React.ReactElement, parent: any, index: number) => OptionProps;
|
|
5
5
|
declare const getOptionsFromGroup: (selectChildren: React.ReactNode) => {
|
|
6
6
|
optionGroups: OptionGroupProps[];
|
|
7
7
|
options: OptionProps[];
|
package/lib/es/select/utils.js
CHANGED
|
@@ -20,7 +20,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
20
20
|
import React from 'react';
|
|
21
21
|
import warning from '@douyinfe/semi-foundation/lib/es/utils/warning';
|
|
22
22
|
|
|
23
|
-
const generateOption = (child, parent) => {
|
|
23
|
+
const generateOption = (child, parent, index) => {
|
|
24
24
|
const childProps = child.props;
|
|
25
25
|
|
|
26
26
|
if (!child || !childProps) {
|
|
@@ -32,7 +32,8 @@ const generateOption = (child, parent) => {
|
|
|
32
32
|
// Drop-down menu rendering priority label value, children, value in turn downgrade
|
|
33
33
|
label: childProps.label || childProps.children || childProps.value,
|
|
34
34
|
_show: true,
|
|
35
|
-
_selected: false
|
|
35
|
+
_selected: false,
|
|
36
|
+
_scrollIndex: index
|
|
36
37
|
}, childProps), {
|
|
37
38
|
_parentGroup: parent
|
|
38
39
|
});
|
|
@@ -55,11 +56,13 @@ const getOptionsFromGroup = selectChildren => {
|
|
|
55
56
|
const childNodes = _filterInstanceProperty(_context = React.Children.toArray(selectChildren)).call(_context, childNode => childNode && childNode.props);
|
|
56
57
|
|
|
57
58
|
let type = '';
|
|
59
|
+
let optionIndex = -1;
|
|
58
60
|
|
|
59
61
|
_forEachInstanceProperty(childNodes).call(childNodes, child => {
|
|
60
62
|
if (child.type.isSelectOption) {
|
|
61
63
|
type = 'option';
|
|
62
|
-
|
|
64
|
+
optionIndex++;
|
|
65
|
+
const option = generateOption(child, undefined, optionIndex);
|
|
63
66
|
emptyGroup.children.push(option);
|
|
64
67
|
options.push(option);
|
|
65
68
|
} else if (child.type.isSelectOptionGroup) {
|
|
@@ -74,7 +77,10 @@ const getOptionsFromGroup = selectChildren => {
|
|
|
74
77
|
|
|
75
78
|
children = React.Children.toArray(children);
|
|
76
79
|
|
|
77
|
-
const childrenOption = _mapInstanceProperty(children).call(children, option =>
|
|
80
|
+
const childrenOption = _mapInstanceProperty(children).call(children, option => {
|
|
81
|
+
optionIndex++;
|
|
82
|
+
return generateOption(option, restGroupProps, optionIndex);
|
|
83
|
+
});
|
|
78
84
|
|
|
79
85
|
const group = _Object$assign(_Object$assign({}, child.props), {
|
|
80
86
|
children: childrenOption,
|
|
@@ -22,7 +22,7 @@ export interface OnDragProps extends BasicOnDragProps {
|
|
|
22
22
|
export interface DragEnterProps extends DragProps {
|
|
23
23
|
expandedKeys?: string[];
|
|
24
24
|
}
|
|
25
|
-
export interface
|
|
25
|
+
export interface ExpandedOtherProps extends BasicExpandedOtherProps {
|
|
26
26
|
node: TreeNodeData;
|
|
27
27
|
}
|
|
28
28
|
export interface RenderFullLabelProps extends BasicRenderFullLabelProps {
|
|
@@ -57,7 +57,7 @@ export interface TreeProps extends BasicTreeProps {
|
|
|
57
57
|
onDragStart?: (dragProps: DragProps) => void;
|
|
58
58
|
onDragEnter?: (dragEnterProps: DragEnterProps) => void;
|
|
59
59
|
onDrop?: (onDragProps: OnDragProps) => void;
|
|
60
|
-
onExpand?: (expandedKeys: string[],
|
|
60
|
+
onExpand?: (expandedKeys: string[], expandedOtherProps: ExpandedOtherProps) => void;
|
|
61
61
|
onLoad?: (loadedKeys?: Set<string>, treeNode?: TreeNodeData) => void;
|
|
62
62
|
onContextMenu?: (e: MouseEvent, node: TreeNodeData) => void;
|
|
63
63
|
onSelect?: (selectedKeys: string, selected: boolean, selectedNode: TreeNodeData) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@douyinfe/semi-ui",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/es/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@babel/runtime-corejs3": "^7.15.4",
|
|
22
|
-
"@douyinfe/semi-animation-react": "2.1.0-beta.
|
|
23
|
-
"@douyinfe/semi-foundation": "2.1.0-beta.
|
|
24
|
-
"@douyinfe/semi-icons": "2.1.0-beta.
|
|
25
|
-
"@douyinfe/semi-illustrations": "2.1.0-beta.
|
|
26
|
-
"@douyinfe/semi-theme-default": "2.1.0-beta.
|
|
22
|
+
"@douyinfe/semi-animation-react": "2.1.0-beta.1",
|
|
23
|
+
"@douyinfe/semi-foundation": "2.1.0-beta.1",
|
|
24
|
+
"@douyinfe/semi-icons": "2.1.0-beta.1",
|
|
25
|
+
"@douyinfe/semi-illustrations": "2.1.0-beta.1",
|
|
26
|
+
"@douyinfe/semi-theme-default": "2.1.0-beta.1",
|
|
27
27
|
"async-validator": "^3.5.0",
|
|
28
28
|
"classnames": "^2.2.6",
|
|
29
29
|
"copy-text-to-clipboard": "^2.1.1",
|
|
@@ -64,13 +64,13 @@
|
|
|
64
64
|
],
|
|
65
65
|
"author": "",
|
|
66
66
|
"license": "MIT",
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "112ef9a681542c2057f98e2e708648b4fdd5618c",
|
|
68
68
|
"devDependencies": {
|
|
69
69
|
"@babel/plugin-proposal-decorators": "^7.15.8",
|
|
70
70
|
"@babel/plugin-transform-runtime": "^7.15.8",
|
|
71
71
|
"@babel/preset-env": "^7.15.8",
|
|
72
72
|
"@babel/preset-react": "^7.14.5",
|
|
73
|
-
"@douyinfe/semi-scss-compile": "2.1.0-beta.
|
|
73
|
+
"@douyinfe/semi-scss-compile": "2.1.0-beta.1",
|
|
74
74
|
"@storybook/addon-knobs": "^6.3.1",
|
|
75
75
|
"babel-loader": "^8.2.2",
|
|
76
76
|
"case-sensitive-paths-webpack-plugin": "^2.4.0",
|