@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.
@@ -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: [...selectedKeys][0],
295
+ value: realValue,
284
296
  inputValue: inputValue,
285
297
  onChange: this.handleInputChange,
286
298
  onClear: this.handleClear,
@@ -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 minKey;
758
+ let minItemIndex = -1;
758
759
 
759
- _forEachInstanceProperty(selections).call(selections, (v, k) => {
760
- const tempKey = Number(String(k).match(/option-(.*)/)[1]);
761
- minKey = typeof minKey === 'number' && minKey < tempKey ? minKey : tempKey;
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 (minKey) {
765
- this.virtualizeListRef.current.scrollToItem(minKey, 'center');
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();
@@ -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
  }
@@ -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?: any) => OptionProps;
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[];
@@ -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
- const option = generateOption(child);
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 => generateOption(option, restGroupProps));
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 ExpanedOtherProps extends BasicExpandedOtherProps {
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[], expanedOtherProps: ExpanedOtherProps) => void;
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.0",
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.0",
23
- "@douyinfe/semi-foundation": "2.1.0-beta.0",
24
- "@douyinfe/semi-icons": "2.1.0-beta.0",
25
- "@douyinfe/semi-illustrations": "2.1.0-beta.0",
26
- "@douyinfe/semi-theme-default": "2.1.0-beta.0",
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": "1fa6463d0c9875d62ea2c76f02c253ad40dffa0a",
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.0",
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",