amis 1.9.1-beta.18 → 1.9.1-beta.22

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. package/lib/components/Radios.d.ts +10 -10
  2. package/lib/components/ResultBox.d.ts +44 -40
  3. package/lib/components/ResultBox.js +43 -7
  4. package/lib/components/ResultBox.js.map +2 -2
  5. package/lib/components/ResultTableList.js +16 -17
  6. package/lib/components/ResultTableList.js.map +2 -2
  7. package/lib/components/Select.d.ts +498 -294
  8. package/lib/components/Select.js +64 -12
  9. package/lib/components/Select.js.map +2 -2
  10. package/lib/components/TableSelection.d.ts +42 -40
  11. package/lib/components/TableSelection.js +7 -2
  12. package/lib/components/TableSelection.js.map +2 -2
  13. package/lib/components/TooltipWrapper.d.ts +1 -1
  14. package/lib/components/TooltipWrapper.js.map +2 -2
  15. package/lib/components/TransferDropDown.d.ts +43 -40
  16. package/lib/components/TransferDropDown.js +2 -2
  17. package/lib/components/TransferDropDown.js.map +2 -2
  18. package/lib/index.js +1 -1
  19. package/lib/locale/de-DE.js +1 -1
  20. package/lib/locale/de-DE.js.map +2 -2
  21. package/lib/locale/en-US.js +1 -1
  22. package/lib/locale/en-US.js.map +2 -2
  23. package/lib/renderers/Form/DiffEditor.d.ts +66 -20
  24. package/lib/renderers/Form/Editor.d.ts +66 -20
  25. package/lib/renderers/Form/Group.js +1 -1
  26. package/lib/renderers/Form/Group.js.map +2 -2
  27. package/lib/renderers/Form/InputImage.js.map +2 -2
  28. package/lib/renderers/Form/InputTag.d.ts +8 -0
  29. package/lib/renderers/Form/InputTag.js +2 -2
  30. package/lib/renderers/Form/InputTag.js.map +2 -2
  31. package/lib/renderers/Form/Options.js +7 -7
  32. package/lib/renderers/Form/Options.js.map +2 -2
  33. package/lib/renderers/Form/Select.d.ts +24 -0
  34. package/lib/renderers/Form/Select.js +5 -3
  35. package/lib/renderers/Form/Select.js.map +2 -2
  36. package/lib/renderers/Form/Transfer.d.ts +1 -0
  37. package/lib/renderers/Form/Transfer.js +4 -0
  38. package/lib/renderers/Form/Transfer.js.map +2 -2
  39. package/lib/renderers/Form/TreeSelect.d.ts +0 -1
  40. package/lib/renderers/Form/TreeSelect.js +1 -9
  41. package/lib/renderers/Form/TreeSelect.js.map +2 -2
  42. package/lib/renderers/Form/index.js +8 -4
  43. package/lib/renderers/Form/index.js.map +2 -2
  44. package/lib/renderers/QRCode.d.ts +16 -0
  45. package/lib/renderers/QRCode.js +25 -1
  46. package/lib/renderers/QRCode.js.map +2 -2
  47. package/lib/renderers/Table/exportExcel.js +50 -36
  48. package/lib/renderers/Table/exportExcel.js.map +2 -2
  49. package/lib/renderers/Table/index.d.ts +2 -0
  50. package/lib/renderers/Table/index.js +37 -5
  51. package/lib/renderers/Table/index.js.map +2 -2
  52. package/lib/renderers/Tpl.d.ts +4 -0
  53. package/lib/renderers/Tpl.js +6 -3
  54. package/lib/renderers/Tpl.js.map +2 -2
  55. package/lib/store/combo.d.ts +72 -22
  56. package/lib/store/form.d.ts +30 -9
  57. package/lib/store/form.js +28 -10
  58. package/lib/store/form.js.map +2 -2
  59. package/lib/store/formItem.d.ts +3 -1
  60. package/lib/store/formItem.js +3 -5
  61. package/lib/store/formItem.js.map +2 -2
  62. package/lib/store/table.d.ts +60 -18
  63. package/lib/themes/ang-ie11.css +87 -6
  64. package/lib/themes/ang.css +92 -6
  65. package/lib/themes/ang.css.map +1 -1
  66. package/lib/themes/antd-ie11.css +87 -6
  67. package/lib/themes/antd.css +92 -6
  68. package/lib/themes/antd.css.map +1 -1
  69. package/lib/themes/cxd-ie11.css +87 -6
  70. package/lib/themes/cxd.css +94 -6
  71. package/lib/themes/cxd.css.map +1 -1
  72. package/lib/themes/dark-ie11.css +87 -6
  73. package/lib/themes/dark.css +92 -6
  74. package/lib/themes/dark.css.map +1 -1
  75. package/lib/themes/default-ie11.css +87 -6
  76. package/lib/themes/default.css +94 -6
  77. package/lib/themes/default.css.map +1 -1
  78. package/lib/utils/helper.d.ts +1 -0
  79. package/lib/utils/helper.js +11 -1
  80. package/lib/utils/helper.js.map +2 -2
  81. package/package.json +1 -1
  82. package/schema.json +94 -28
  83. package/scss/_properties.scss +11 -6
  84. package/scss/components/_result-box.scss +34 -2
  85. package/scss/components/form/_select.scss +88 -32
  86. package/scss/components/form/_selection.scss +9 -6
  87. package/scss/themes/_cxd-variables.scss +2 -0
  88. package/scss/themes/cxd.scss +0 -2
  89. package/sdk/ang-ie11.css +101 -6
  90. package/sdk/ang.css +106 -6
  91. package/sdk/antd-ie11.css +101 -6
  92. package/sdk/antd.css +106 -6
  93. package/sdk/barcode.js +51 -51
  94. package/sdk/charts.js +14 -14
  95. package/sdk/codemirror.js +7 -7
  96. package/sdk/color-picker.js +65 -65
  97. package/sdk/cropperjs.js +2 -2
  98. package/sdk/cxd-ie11.css +101 -6
  99. package/sdk/cxd.css +108 -6
  100. package/sdk/dark-ie11.css +101 -6
  101. package/sdk/dark.css +106 -6
  102. package/sdk/exceljs.js +1 -1
  103. package/sdk/locale/de-DE.js +2 -2
  104. package/sdk/markdown.js +69 -69
  105. package/sdk/papaparse.js +1 -1
  106. package/sdk/renderers/Form/CityDB.js +1 -1
  107. package/sdk/rest.js +16 -16
  108. package/sdk/rich-text.js +62 -62
  109. package/sdk/sdk-ie11.css +101 -6
  110. package/sdk/sdk.css +108 -6
  111. package/sdk/sdk.js +1648 -1647
  112. package/sdk/thirds/hls.js/hls.js +1 -1
  113. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  114. package/sdk/tinymce.js +57 -57
  115. package/src/components/ResultBox.tsx +98 -12
  116. package/src/components/ResultTableList.tsx +32 -33
  117. package/src/components/Select.tsx +149 -17
  118. package/src/components/TableSelection.tsx +15 -8
  119. package/src/components/TooltipWrapper.tsx +20 -14
  120. package/src/components/TransferDropDown.tsx +9 -1
  121. package/src/locale/de-DE.ts +2 -2
  122. package/src/locale/en-US.ts +2 -2
  123. package/src/renderers/Form/Group.tsx +1 -1
  124. package/src/renderers/Form/InputImage.tsx +4 -2
  125. package/src/renderers/Form/InputTag.tsx +14 -0
  126. package/src/renderers/Form/Options.tsx +7 -9
  127. package/src/renderers/Form/Select.tsx +41 -2
  128. package/src/renderers/Form/Transfer.tsx +6 -0
  129. package/src/renderers/Form/TreeSelect.tsx +14 -16
  130. package/src/renderers/Form/index.tsx +11 -2
  131. package/src/renderers/QRCode.tsx +50 -1
  132. package/src/renderers/Table/exportExcel.ts +29 -12
  133. package/src/renderers/Table/index.tsx +42 -6
  134. package/src/renderers/Tpl.tsx +11 -1
  135. package/src/store/form.ts +31 -24
  136. package/src/store/formItem.ts +65 -52
  137. package/src/utils/helper.ts +11 -1
@@ -1,11 +1,14 @@
1
1
  import {ThemeProps, themeable} from '../theme';
2
2
  import React from 'react';
3
+ import omit from 'lodash/omit';
4
+ import isInteger from 'lodash/isInteger';
3
5
  import {InputBoxProps} from './InputBox';
4
6
  import {uncontrollable} from 'uncontrollable';
5
7
  import {Icon} from './icons';
6
8
  import Input from './Input';
7
9
  import {autobind, isMobile, ucFirst} from '../utils/helper';
8
10
  import {LocaleProps, localeable} from '../locale';
11
+ import TooltipWrapper, {TooltipObject} from './TooltipWrapper';
9
12
  import isPlainObject = require('lodash/isPlainObject');
10
13
 
11
14
  export interface ResultBoxProps
@@ -22,6 +25,8 @@ export interface ResultBoxProps
22
25
  inputPlaceholder: string;
23
26
  useMobileUI?: boolean;
24
27
  hasDropDownArrow?: boolean;
28
+ maxTagCount?: number;
29
+ overflowTagPopover?: TooltipObject;
25
30
  }
26
31
 
27
32
  export class ResultBox extends React.Component<ResultBoxProps> {
@@ -94,6 +99,91 @@ export class ResultBox extends React.Component<ResultBoxProps> {
94
99
  onChange?.(e.currentTarget.value);
95
100
  }
96
101
 
102
+ renderMultipeTags(tags: any[]) {
103
+ const {
104
+ maxTagCount,
105
+ overflowTagPopover,
106
+ itemRender,
107
+ classnames: cx
108
+ } = this.props;
109
+
110
+ if (
111
+ maxTagCount != null &&
112
+ isInteger(Math.floor(maxTagCount)) &&
113
+ Math.floor(maxTagCount) >= 0 &&
114
+ Math.floor(maxTagCount) < tags.length
115
+ ) {
116
+ const maxVisibleCount = Math.floor(maxTagCount);
117
+ const tooltipProps: TooltipObject = {
118
+ placement: 'top',
119
+ trigger: 'hover',
120
+ showArrow: false,
121
+ offset: [0, -10],
122
+ tooltipClassName: cx(
123
+ 'ResultBox-overflow',
124
+ overflowTagPopover?.tooltipClassName
125
+ ),
126
+ ...omit(overflowTagPopover, ['children', 'content', 'tooltipClassName'])
127
+ };
128
+
129
+ return [
130
+ ...tags.slice(0, maxVisibleCount),
131
+ {label: `+ ${tags.length - maxVisibleCount} ...`}
132
+ ].map((item, index) => {
133
+ return index === maxVisibleCount ? (
134
+ <TooltipWrapper
135
+ key={tags.length}
136
+ tooltip={{
137
+ ...tooltipProps,
138
+ children: () => (
139
+ <div className={cx('ResultBox-overflow-wrapper')}>
140
+ {tags
141
+ .slice(maxVisibleCount, tags.length)
142
+ .map((item, index) => {
143
+ const itemIndex = index + maxVisibleCount;
144
+
145
+ return (
146
+ <div className={cx('ResultBox-value')} key={itemIndex}>
147
+ <span className={cx('ResultBox-valueLabel')}>
148
+ {itemRender(item)}
149
+ </span>
150
+ <a data-index={itemIndex} onClick={this.removeItem}>
151
+ <Icon icon="close" className="icon" />
152
+ </a>
153
+ </div>
154
+ );
155
+ })}
156
+ </div>
157
+ )
158
+ }}
159
+ >
160
+ <div className={cx('ResultBox-value')} key={index}>
161
+ <span className={cx('ResultBox-valueLabel')}>{item.label}</span>
162
+ </div>
163
+ </TooltipWrapper>
164
+ ) : (
165
+ <div className={cx('ResultBox-value')} key={index}>
166
+ <span className={cx('ResultBox-valueLabel')}>
167
+ {itemRender(item)}
168
+ </span>
169
+ <a data-index={index} onClick={this.removeItem}>
170
+ <Icon icon="close" className="icon" />
171
+ </a>
172
+ </div>
173
+ );
174
+ });
175
+ }
176
+
177
+ return tags.map((item, index) => (
178
+ <div className={cx('ResultBox-value')} key={index}>
179
+ <span className={cx('ResultBox-valueLabel')}>{itemRender(item)}</span>
180
+ <a data-index={index} onClick={this.removeItem}>
181
+ <Icon icon="close" className="icon" />
182
+ </a>
183
+ </div>
184
+ ));
185
+ }
186
+
97
187
  render() {
98
188
  const {
99
189
  className,
@@ -125,6 +215,9 @@ export class ResultBox extends React.Component<ResultBoxProps> {
125
215
  } = this.props;
126
216
  const isFocused = this.state.isFocused;
127
217
  const mobileUI = useMobileUI && isMobile();
218
+ /** 不需要透传给Input的属性 */
219
+ const omitPropsList = ['maxTagCount', 'overflowTagPopover'];
220
+
128
221
  return (
129
222
  <div
130
223
  className={cx('ResultBox', className, {
@@ -144,16 +237,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
144
237
  onBlur={allowInput ? undefined : onBlur}
145
238
  >
146
239
  {Array.isArray(result) && result.length ? (
147
- result.map((item, index) => (
148
- <div className={cx('ResultBox-value')} key={index}>
149
- <span className={cx('ResultBox-valueLabel')}>
150
- {itemRender(item)}
151
- </span>
152
- <a data-index={index} onClick={this.removeItem}>
153
- <Icon icon="close" className="icon" />
154
- </a>
155
- </div>
156
- ))
240
+ this.renderMultipeTags(result)
157
241
  ) : result && !Array.isArray(result) ? (
158
242
  <span className={cx('ResultBox-singleValue')}>
159
243
  {isPlainObject(result) ? itemRender(result) : result}
@@ -166,7 +250,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
166
250
 
167
251
  {allowInput && !disabled ? (
168
252
  <Input
169
- {...rest}
253
+ {...omit(rest, omitPropsList)}
170
254
  onKeyPress={onKeyPress}
171
255
  ref={this.inputRef}
172
256
  value={value || ''}
@@ -174,7 +258,9 @@ export class ResultBox extends React.Component<ResultBoxProps> {
174
258
  placeholder={__(
175
259
  Array.isArray(result) && result.length
176
260
  ? inputPlaceholder
177
- : (result ? '' : placeholder)
261
+ : result
262
+ ? ''
263
+ : placeholder
178
264
  )}
179
265
  onFocus={this.handleFocus}
180
266
  onBlur={this.handleBlur}
@@ -43,7 +43,10 @@ export interface ResultTableSelectionState {
43
43
  searchTableOptions: Options;
44
44
  }
45
45
 
46
- export class BaseResultTableSelection extends BaseSelection<ResultTableSelectionProps, ResultTableSelectionState> {
46
+ export class BaseResultTableSelection extends BaseSelection<
47
+ ResultTableSelectionProps,
48
+ ResultTableSelectionState
49
+ > {
47
50
  static defaultProps = {
48
51
  ...BaseSelection.defaultProps,
49
52
  cellRender: (
@@ -55,25 +58,21 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
55
58
  option: Option,
56
59
  colIndex: number,
57
60
  rowIndex: number
58
- ) => <span>{resolveVariable(column.name, option)}</span>,
61
+ ) => <span>{resolveVariable(column.name, option)}</span>
59
62
  };
60
63
 
61
64
  state: ResultTableSelectionState = {
62
65
  tableOptions: [],
63
66
  searching: false,
64
67
  searchTableOptions: []
65
- }
68
+ };
66
69
 
67
70
  static getDerivedStateFromProps(props: ResultTableSelectionProps) {
68
- const {
69
- options,
70
- value,
71
- option2value,
72
- } = props;
71
+ const {options, value, option2value} = props;
73
72
  const valueArray = BaseSelection.value2array(value, options, option2value);
74
73
  return {
75
74
  tableOptions: valueArray
76
- }
75
+ };
77
76
  }
78
77
 
79
78
  @autobind
@@ -117,15 +116,16 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
117
116
  }
118
117
 
119
118
  const {value, onSearch} = this.props;
120
- const searchOptions = ((value || []) as Options)
121
- .filter(item => onSearch?.(inputValue, item));
119
+ const searchOptions = ((value || []) as Options).filter(item =>
120
+ onSearch?.(inputValue, item)
121
+ );
122
122
 
123
123
  this.setState({
124
124
  searching: true,
125
125
  searchTableOptions: searchOptions
126
126
  });
127
127
  }
128
-
128
+
129
129
  @autobind
130
130
  clearSearch() {
131
131
  this.setState({
@@ -152,9 +152,7 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
152
152
 
153
153
  return (
154
154
  <div className={cx('ResultTableList', className)}>
155
- {
156
- Array.isArray(value) && value.length ?
157
- (
155
+ {Array.isArray(value) && value.length ? (
158
156
  <TableSelection
159
157
  columns={columns}
160
158
  options={!searching ? tableOptions : searchTableOptions}
@@ -163,6 +161,7 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
163
161
  option2value={option2value}
164
162
  onChange={onChange}
165
163
  multiple={false}
164
+ resultMode={true}
166
165
  cellRender={(
167
166
  column: {
168
167
  name: string;
@@ -176,27 +175,28 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
176
175
  const raw = cellRender(column, option, colIndex, rowIndex);
177
176
  if (colIndex === columns.length - 1) {
178
177
  return (
179
- <>
180
- {raw}
181
- {
182
- <span
183
- className={cx('ResultTableList-close-btn')}
184
- onClick={(e: React.SyntheticEvent<HTMLElement>) => {
185
- e.stopPropagation();
186
- this.handleCloseItem(option);
187
- }}
188
- >
189
- <CloseIcon />
190
- </span>
191
- }
192
- </>)
178
+ <>
179
+ {raw}
180
+ {
181
+ <span
182
+ className={cx('ResultTableList-close-btn')}
183
+ onClick={(e: React.SyntheticEvent<HTMLElement>) => {
184
+ e.stopPropagation();
185
+ this.handleCloseItem(option);
186
+ }}
187
+ >
188
+ <CloseIcon />
189
+ </span>
190
+ }
191
+ </>
192
+ );
193
193
  }
194
194
  return raw;
195
195
  }}
196
196
  />
197
- )
198
- : (<div className={cx('Selections-placeholder')}>{__(placeholder)}</div>)
199
- }
197
+ ) : (
198
+ <div className={cx('Selections-placeholder')}>{__(placeholder)}</div>
199
+ )}
200
200
  </div>
201
201
  );
202
202
  }
@@ -211,7 +211,6 @@ export class BaseResultTableSelection extends BaseSelection<ResultTableSelection
211
211
  placeholder = __('Transfer.searchKeyword')
212
212
  } = this.props;
213
213
 
214
-
215
214
  return (
216
215
  <div className={cx('Selections', className)}>
217
216
  {title ? <div className={cx('Selections-title')}>{title}</div> : null}
@@ -7,6 +7,9 @@
7
7
 
8
8
  import {uncontrollable} from 'uncontrollable';
9
9
  import React from 'react';
10
+ import merge from 'lodash/merge';
11
+ import isInteger from 'lodash/isInteger';
12
+ import omit from 'lodash/omit';
10
13
  import VirtualList from './virtual-list';
11
14
  import Overlay from './Overlay';
12
15
  import PopOver from './PopOver';
@@ -24,15 +27,12 @@ import {
24
27
  normalizeNodePath,
25
28
  isMobile
26
29
  } from '../utils/helper';
27
- import find from 'lodash/find';
28
30
  import isPlainObject from 'lodash/isPlainObject';
29
- import union from 'lodash/union';
30
31
  import {highlight} from '../renderers/Form/Options';
31
32
  import {findDOMNode} from 'react-dom';
32
33
  import {ClassNamesFn, themeable, ThemeProps} from '../theme';
33
34
  import Checkbox from './Checkbox';
34
35
  import Input from './Input';
35
- import {Api} from '../types';
36
36
  import {LocaleProps, localeable} from '../locale';
37
37
  import Spinner from './Spinner';
38
38
  import {Option, Options} from '../Schema';
@@ -40,6 +40,8 @@ import {RemoteOptionsProps, withRemoteConfig} from './WithRemoteConfig';
40
40
  import Picker from './Picker';
41
41
  import PopUp from './PopUp';
42
42
 
43
+ import type {TooltipObject} from '../components/TooltipWrapper';
44
+
43
45
  export {Option, Options};
44
46
 
45
47
  export interface OptionProps {
@@ -60,6 +62,8 @@ export interface OptionProps {
60
62
  disabled?: boolean;
61
63
  creatable?: boolean;
62
64
  pathSeparator?: string;
65
+ itemHeight?: number; // 每个选项的高度,主要用于虚拟渲染
66
+ virtualThreshold?: number; // 数据量多大的时候开启虚拟渲染
63
67
  hasError?: boolean;
64
68
  block?: boolean;
65
69
  onAdd?: (
@@ -350,6 +354,16 @@ interface SelectProps extends OptionProps, ThemeProps, LocaleProps {
350
354
  * 移动端样式类名
351
355
  */
352
356
  mobileClassName?: string;
357
+
358
+ /**
359
+ * 标签的最大展示数量,超出数量后以收纳浮层的方式展示,仅在多选模式开启后生效
360
+ */
361
+ maxTagCount?: number;
362
+
363
+ /**
364
+ * 收纳标签的Popover配置
365
+ */
366
+ overflowTagPopover?: TooltipObject;
353
367
  }
354
368
 
355
369
  interface SelectState {
@@ -382,7 +396,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
382
396
  checkAll: false,
383
397
  checkAllLabel: 'Select.checkAll',
384
398
  defaultCheckAll: false,
385
- overlayPlacement: 'auto'
399
+ overlayPlacement: 'auto',
400
+ virtualThreshold: 100
386
401
  };
387
402
 
388
403
  input: HTMLInputElement;
@@ -397,7 +412,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
397
412
  inputValue: '',
398
413
  highlightedIndex: -1,
399
414
  selection: value2array(props.value, props),
400
- itemHeight: 35,
415
+ itemHeight: 32 /** Select选项高度保持一致 */,
401
416
  pickerSelectItem: ''
402
417
  };
403
418
  }
@@ -712,7 +727,9 @@ export class Select extends React.Component<SelectProps, SelectState> {
712
727
 
713
728
  @autobind
714
729
  menuItemRef(ref: any) {
715
- ref && this.setState({itemHeight: ref.offsetHeight});
730
+ if (ref && typeof ref.offsetHeight === 'number' && ref > 0) {
731
+ this.setState({itemHeight: ref.offsetHeight});
732
+ }
716
733
  }
717
734
 
718
735
  renderValue({inputValue, isOpen}: ControllerStateAndHelpers<any>) {
@@ -723,11 +740,11 @@ export class Select extends React.Component<SelectProps, SelectState> {
723
740
  placeholder,
724
741
  labelField,
725
742
  disabled,
743
+ maxTagCount,
744
+ overflowTagPopover,
726
745
  translate: __
727
746
  } = this.props;
728
-
729
747
  const selection = this.state.selection;
730
- // console.log('selection', selection);
731
748
 
732
749
  if (!selection.length) {
733
750
  return (
@@ -737,6 +754,114 @@ export class Select extends React.Component<SelectProps, SelectState> {
737
754
  );
738
755
  }
739
756
 
757
+ if (
758
+ multiple &&
759
+ maxTagCount != null &&
760
+ isInteger(Math.floor(maxTagCount)) &&
761
+ Math.floor(maxTagCount) >= 0 &&
762
+ Math.floor(maxTagCount) < selection.length
763
+ ) {
764
+ const maxVisibleCount = Math.floor(maxTagCount);
765
+ const tooltipProps: TooltipObject = {
766
+ placement: 'top',
767
+ trigger: 'hover',
768
+ showArrow: false,
769
+ offset: [0, -10],
770
+ tooltipClassName: cx(
771
+ 'Select-overflow',
772
+ overflowTagPopover?.tooltipClassName
773
+ ),
774
+ ...omit(overflowTagPopover, ['children', 'content', 'tooltipClassName'])
775
+ };
776
+ return [
777
+ ...selection.slice(0, maxVisibleCount),
778
+ {label: `+ ${selection.length - maxVisibleCount} ...`}
779
+ ].map((item, index) => {
780
+ if (index === maxVisibleCount) {
781
+ return (
782
+ <TooltipWrapper
783
+ key={selection.length}
784
+ tooltip={{
785
+ ...tooltipProps,
786
+ children: () => (
787
+ <div className={cx('Select-overflow-wrapper')}>
788
+ {selection
789
+ .slice(maxVisibleCount, selection.length)
790
+ .map((item, index) => {
791
+ const itemIndex = index + maxVisibleCount;
792
+ return (
793
+ <div
794
+ key={itemIndex}
795
+ className={cx('Select-value', {
796
+ 'is-disabled': disabled,
797
+ 'is-invalid': item.__unmatched
798
+ })}
799
+ >
800
+ <span className={cx('Select-valueLabel')}>
801
+ {item[labelField || 'label']}
802
+ </span>
803
+ <span
804
+ className={cx('Select-valueIcon', {
805
+ 'is-disabled': disabled || item.disabled
806
+ })}
807
+ onClick={this.removeItem.bind(this, itemIndex)}
808
+ >
809
+ <Icon icon="close" className="icon" />
810
+ </span>
811
+ </div>
812
+ );
813
+ })}
814
+ </div>
815
+ )
816
+ }}
817
+ >
818
+ <div
819
+ className={cx('Select-value', {
820
+ 'is-disabled': disabled,
821
+ 'is-invalid': item.__unmatched
822
+ })}
823
+ onClick={(e: React.MouseEvent) =>
824
+ e.stopPropagation()
825
+ } /** 避免点击查看浮窗时呼出下拉菜单 */
826
+ >
827
+ <span className={cx('Select-valueLabel')}>
828
+ {item[labelField || 'label']}
829
+ </span>
830
+ </div>
831
+ </TooltipWrapper>
832
+ );
833
+ }
834
+
835
+ return (
836
+ <TooltipWrapper
837
+ placement={'top'}
838
+ tooltip={item[labelField || 'label']}
839
+ trigger={'hover'}
840
+ key={index}
841
+ >
842
+ <div
843
+ className={cx('Select-value', {
844
+ 'is-disabled': disabled,
845
+ 'is-invalid': item.__unmatched
846
+ })}
847
+ >
848
+ <span className={cx('Select-valueLabel')}>
849
+ {item[labelField || 'label']}
850
+ </span>
851
+ <span
852
+ className={cx('Select-valueIcon', {
853
+ 'is-disabled': disabled || item.disabled
854
+ })}
855
+ onClick={this.removeItem.bind(this, index)}
856
+ >
857
+ <Icon icon="close" className="icon" />
858
+ </span>
859
+ </div>
860
+ </TooltipWrapper>
861
+ );
862
+ });
863
+ }
864
+
740
865
  return selection.map((item, index) => {
741
866
  if (!multiple) {
742
867
  return (
@@ -822,6 +947,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
822
947
  hideSelected,
823
948
  renderMenu,
824
949
  mobileClassName,
950
+ virtualThreshold = 100,
825
951
  useMobileUI = false
826
952
  } = this.props;
827
953
  const {selection} = this.state;
@@ -835,7 +961,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
835
961
  })
836
962
  : options.concat()
837
963
  ).filter((option: Option) => !option.hidden && option.visible !== false);
838
-
964
+ const enableVirtualRender =
965
+ filtedOptions.length && filtedOptions.length > virtualThreshold;
839
966
  const selectionValues = selection.map(select => select[valueField]);
840
967
  if (multiple && checkAll) {
841
968
  const optionsValues = (checkAllBySearch ? filtedOptions : options).map(
@@ -850,7 +977,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
850
977
  );
851
978
  }
852
979
 
853
- const itemHeight = this.state.itemHeight;
980
+ // 用于虚拟渲染的每项高度
981
+ const virtualItemHeight = this.props.itemHeight || this.state.itemHeight;
854
982
 
855
983
  // 渲染单个选项
856
984
  const renderItem = ({index, style}: {index: number; style?: object}) => {
@@ -874,7 +1002,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
874
1002
  item,
875
1003
  disabled: item.disabled
876
1004
  })}
877
- style={style}
1005
+ style={merge(style, enableVirtualRender ? {width: '100%'} : {})}
878
1006
  className={cx(`Select-option`, {
879
1007
  'is-disabled': item.disabled,
880
1008
  'is-highlight': highlightedIndex === index,
@@ -952,7 +1080,12 @@ export class Select extends React.Component<SelectProps, SelectState> {
952
1080
  {item.tip}
953
1081
  </Checkbox>
954
1082
  ) : (
955
- <span>
1083
+ <span
1084
+ className={cx('Select-option-content')}
1085
+ title={
1086
+ typeof item[labelField] === 'string' ? item[labelField] : ''
1087
+ }
1088
+ >
956
1089
  {item.disabled
957
1090
  ? item[labelField]
958
1091
  : highlight(
@@ -976,8 +1109,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
976
1109
  <div
977
1110
  ref={this.menu}
978
1111
  className={cx('Select-menu', {
979
- 'Select--longlist':
980
- filtedOptions.length && filtedOptions.length > 100,
1112
+ 'Select--longlist': enableVirtualRender,
981
1113
  'is-mobile': mobileUI
982
1114
  })}
983
1115
  >
@@ -1039,15 +1171,15 @@ export class Select extends React.Component<SelectProps, SelectState> {
1039
1171
  ) : null}
1040
1172
 
1041
1173
  {filtedOptions.length ? (
1042
- filtedOptions.length > 100 ? ( // 超过 100 行数据才启用 virtuallist 避免滚动条问题
1174
+ filtedOptions.length > virtualThreshold ? ( // 较多数据时才启用 virtuallist,避免滚动条问题
1043
1175
  <VirtualList
1044
1176
  height={
1045
1177
  filtedOptions.length > 8
1046
1178
  ? 266
1047
- : filtedOptions.length * itemHeight
1179
+ : filtedOptions.length * virtualItemHeight
1048
1180
  }
1049
1181
  itemCount={filtedOptions.length}
1050
- itemSize={itemHeight}
1182
+ itemSize={virtualItemHeight}
1051
1183
  renderItem={renderItem}
1052
1184
  />
1053
1185
  ) : (
@@ -5,9 +5,12 @@ import {uncontrollable} from 'uncontrollable';
5
5
  import Checkbox from './Checkbox';
6
6
  import {Option} from './Select';
7
7
  import {resolveVariable} from '../utils/tpl-builtin';
8
+ import {noop} from '../utils/helper';
8
9
  import {localeable} from '../locale';
9
10
 
10
11
  export interface TableSelectionProps extends BaseSelectionProps {
12
+ /** 是否为结果渲染列表 */
13
+ resultMode?: boolean;
11
14
  columns: Array<{
12
15
  name: string;
13
16
  label: string;
@@ -108,7 +111,8 @@ export class TableSelection extends BaseSelection<TableSelectionProps> {
108
111
  multiple,
109
112
  option2value,
110
113
  translate: __,
111
- itemClassName
114
+ itemClassName,
115
+ resultMode
112
116
  } = this.props;
113
117
  const columns = this.getColumns();
114
118
  let valueArray = BaseSelection.value2array(value, options, option2value);
@@ -122,6 +126,12 @@ export class TableSelection extends BaseSelection<TableSelectionProps> {
122
126
  return (
123
127
  <tr
124
128
  key={rowIndex}
129
+ /** 被ResultTableList引用,如果设置click事件,会导致错误删除结果列表的内容,先加一个开关判断 */
130
+ onClick={
131
+ resultMode
132
+ ? noop
133
+ : e => e.defaultPrevented || this.toggleOption(option)
134
+ }
125
135
  className={cx(
126
136
  itemClassName,
127
137
  option.className,
@@ -130,18 +140,15 @@ export class TableSelection extends BaseSelection<TableSelectionProps> {
130
140
  )}
131
141
  >
132
142
  {multiple ? (
133
- <td className={cx('Table-checkCell')}
143
+ <td
144
+ className={cx('Table-checkCell')}
134
145
  key="checkbox"
135
146
  onClick={e => {
136
147
  e.stopPropagation();
137
148
  this.toggleOption(option);
138
149
  }}
139
150
  >
140
- <Checkbox
141
- size="sm"
142
- checked={checked}
143
- disabled={disabled}
144
- />
151
+ <Checkbox size="sm" checked={checked} disabled={disabled} />
145
152
  </td>
146
153
  ) : null}
147
154
  {columns.map((column, colIndex) => (
@@ -183,4 +190,4 @@ export default themeable(
183
190
  value: 'onChange'
184
191
  })
185
192
  )
186
- );
193
+ );