amis 1.9.1-beta.21 → 1.9.1-beta.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (171) hide show
  1. package/lib/components/AssociatedSelection.d.ts +40 -40
  2. package/lib/components/Badge.d.ts +1 -1
  3. package/lib/components/Badge.js.map +1 -1
  4. package/lib/components/ChainedSelection.d.ts +40 -40
  5. package/lib/components/GroupedSelection.d.ts +40 -40
  6. package/lib/components/GroupedSelection.js +2 -3
  7. package/lib/components/GroupedSelection.js.map +2 -2
  8. package/lib/components/PickerContainer.d.ts +0 -1
  9. package/lib/components/PickerContainer.js +4 -4
  10. package/lib/components/PickerContainer.js.map +2 -2
  11. package/lib/components/ResultBox.js +3 -1
  12. package/lib/components/ResultBox.js.map +2 -2
  13. package/lib/components/ResultList.d.ts +53 -43
  14. package/lib/components/ResultList.js +22 -34
  15. package/lib/components/ResultList.js.map +2 -2
  16. package/lib/components/ResultTableList.d.ts +40 -40
  17. package/lib/components/ResultTreeList.d.ts +40 -40
  18. package/lib/components/Select.js +10 -6
  19. package/lib/components/Select.js.map +2 -2
  20. package/lib/components/Selection.d.ts +40 -41
  21. package/lib/components/Selection.js.map +2 -2
  22. package/lib/components/TableSelection.d.ts +40 -40
  23. package/lib/components/TabsTransfer.d.ts +2 -2
  24. package/lib/components/TabsTransfer.js.map +1 -1
  25. package/lib/components/Transfer.d.ts +40 -40
  26. package/lib/components/Transfer.js +1 -1
  27. package/lib/components/Transfer.js.map +2 -2
  28. package/lib/components/TransferDropDown.d.ts +40 -40
  29. package/lib/components/TreeSelection.d.ts +40 -40
  30. package/lib/components/TreeSelection.js +2 -3
  31. package/lib/components/TreeSelection.js.map +2 -2
  32. package/lib/components/formula/Editor.d.ts +45 -45
  33. package/lib/components/formula/Editor.js +16 -11
  34. package/lib/components/formula/Editor.js.map +2 -2
  35. package/lib/components/formula/Picker.d.ts +85 -40
  36. package/lib/components/formula/Picker.js +12 -6
  37. package/lib/components/formula/Picker.js.map +2 -2
  38. package/lib/components/formula/VariableList.d.ts +0 -2
  39. package/lib/components/formula/VariableList.js +5 -15
  40. package/lib/components/formula/VariableList.js.map +2 -2
  41. package/lib/components/index.d.ts +1 -3
  42. package/lib/components/index.js +1 -5
  43. package/lib/components/index.js.map +2 -2
  44. package/lib/components/schema-editor/SchemaVariableList.d.ts +0 -1
  45. package/lib/components/schema-editor/SchemaVariableList.js +2 -2
  46. package/lib/components/schema-editor/SchemaVariableList.js.map +2 -2
  47. package/lib/components/schema-editor/SchemaVariableListPicker.d.ts +0 -1
  48. package/lib/components/schema-editor/SchemaVariableListPicker.js +2 -2
  49. package/lib/components/schema-editor/SchemaVariableListPicker.js.map +2 -2
  50. package/lib/helper.css.map +1 -1
  51. package/lib/index.js +1 -1
  52. package/lib/renderers/CRUD.js +3 -3
  53. package/lib/renderers/CRUD.js.map +2 -2
  54. package/lib/renderers/Form/DiffEditor.d.ts +66 -20
  55. package/lib/renderers/Form/Editor.d.ts +66 -20
  56. package/lib/renderers/Form/Group.js +1 -1
  57. package/lib/renderers/Form/Group.js.map +2 -2
  58. package/lib/renderers/Form/InputFormula.d.ts +5 -5
  59. package/lib/renderers/Form/InputFormula.js +4 -3
  60. package/lib/renderers/Form/InputFormula.js.map +2 -2
  61. package/lib/renderers/Form/InputTag.d.ts +1 -1
  62. package/lib/renderers/Form/InputTag.js.map +1 -1
  63. package/lib/renderers/Form/Options.js +7 -7
  64. package/lib/renderers/Form/Options.js.map +2 -2
  65. package/lib/renderers/Form/Select.d.ts +6 -1
  66. package/lib/renderers/Form/Select.js +3 -1
  67. package/lib/renderers/Form/Select.js.map +2 -2
  68. package/lib/renderers/Form/TreeSelect.d.ts +0 -1
  69. package/lib/renderers/Form/TreeSelect.js +1 -9
  70. package/lib/renderers/Form/TreeSelect.js.map +2 -2
  71. package/lib/renderers/Form/index.js +9 -4
  72. package/lib/renderers/Form/index.js.map +2 -2
  73. package/lib/renderers/Table/exportExcel.js +1 -1
  74. package/lib/renderers/Table/exportExcel.js.map +2 -2
  75. package/lib/renderers/Table/index.d.ts +2 -0
  76. package/lib/renderers/Table/index.js +37 -5
  77. package/lib/renderers/Table/index.js.map +2 -2
  78. package/lib/renderers/Tpl.d.ts +4 -0
  79. package/lib/renderers/Tpl.js +6 -3
  80. package/lib/renderers/Tpl.js.map +2 -2
  81. package/lib/store/combo.d.ts +72 -22
  82. package/lib/store/form.d.ts +30 -9
  83. package/lib/store/form.js +28 -10
  84. package/lib/store/form.js.map +2 -2
  85. package/lib/store/formItem.d.ts +3 -1
  86. package/lib/store/formItem.js +3 -5
  87. package/lib/store/formItem.js.map +2 -2
  88. package/lib/store/table.d.ts +60 -18
  89. package/lib/themes/ang-ie11.css +33 -9
  90. package/lib/themes/ang.css +27 -9
  91. package/lib/themes/ang.css.map +1 -1
  92. package/lib/themes/antd-ie11.css +33 -9
  93. package/lib/themes/antd.css +27 -9
  94. package/lib/themes/antd.css.map +1 -1
  95. package/lib/themes/cxd-ie11.css +35 -15
  96. package/lib/themes/cxd.css +31 -17
  97. package/lib/themes/cxd.css.map +1 -1
  98. package/lib/themes/dark-ie11.css +33 -9
  99. package/lib/themes/dark.css +27 -9
  100. package/lib/themes/dark.css.map +1 -1
  101. package/lib/themes/default-ie11.css +35 -15
  102. package/lib/themes/default.css +31 -17
  103. package/lib/themes/default.css.map +1 -1
  104. package/lib/utils/formula.js +2 -3
  105. package/lib/utils/formula.js.map +2 -2
  106. package/lib/utils/helper.js +1 -1
  107. package/lib/utils/helper.js.map +2 -2
  108. package/package.json +1 -1
  109. package/schema.json +22 -16
  110. package/scss/_mixins.scss +1 -1
  111. package/scss/components/form/_date.scss +9 -10
  112. package/scss/components/form/_select.scss +14 -0
  113. package/scss/components/form/_transfer.scss +1 -2
  114. package/scss/themes/cxd.scss +4 -9
  115. package/sdk/ang-ie11.css +36 -9
  116. package/sdk/ang.css +30 -9
  117. package/sdk/antd-ie11.css +36 -9
  118. package/sdk/antd.css +30 -9
  119. package/sdk/barcode.js +51 -51
  120. package/sdk/charts.js +14 -14
  121. package/sdk/codemirror.js +7 -7
  122. package/sdk/color-picker.js +65 -65
  123. package/sdk/cropperjs.js +2 -2
  124. package/sdk/cxd-ie11.css +38 -16
  125. package/sdk/cxd.css +34 -18
  126. package/sdk/dark-ie11.css +36 -9
  127. package/sdk/dark.css +30 -9
  128. package/sdk/exceljs.js +1 -1
  129. package/sdk/helper.css.map +1 -1
  130. package/sdk/markdown.js +69 -69
  131. package/sdk/papaparse.js +1 -1
  132. package/sdk/renderers/Form/CityDB.js +1 -1
  133. package/sdk/rest.js +16 -16
  134. package/sdk/rich-text.js +62 -62
  135. package/sdk/sdk-ie11.css +38 -16
  136. package/sdk/sdk.css +34 -18
  137. package/sdk/sdk.js +1356 -1354
  138. package/sdk/thirds/hls.js/hls.js +1 -1
  139. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  140. package/sdk/tinymce.js +57 -57
  141. package/src/components/Badge.tsx +1 -1
  142. package/src/components/GroupedSelection.tsx +2 -3
  143. package/src/components/PickerContainer.tsx +8 -13
  144. package/src/components/ResultBox.tsx +3 -1
  145. package/src/components/ResultList.tsx +51 -48
  146. package/src/components/Select.tsx +16 -8
  147. package/src/components/Selection.tsx +0 -1
  148. package/src/components/TabsTransfer.tsx +2 -2
  149. package/src/components/Transfer.tsx +4 -0
  150. package/src/components/TreeSelection.tsx +1 -2
  151. package/src/components/formula/Editor.tsx +51 -38
  152. package/src/components/formula/Picker.tsx +26 -7
  153. package/src/components/formula/VariableList.tsx +2 -36
  154. package/src/components/index.tsx +0 -4
  155. package/src/components/schema-editor/SchemaVariableList.tsx +2 -4
  156. package/src/components/schema-editor/SchemaVariableListPicker.tsx +1 -4
  157. package/src/renderers/CRUD.tsx +3 -3
  158. package/src/renderers/Form/Group.tsx +1 -1
  159. package/src/renderers/Form/InputFormula.tsx +11 -10
  160. package/src/renderers/Form/InputTag.tsx +1 -1
  161. package/src/renderers/Form/Options.tsx +7 -9
  162. package/src/renderers/Form/Select.tsx +10 -2
  163. package/src/renderers/Form/TreeSelect.tsx +14 -16
  164. package/src/renderers/Form/index.tsx +13 -2
  165. package/src/renderers/Table/exportExcel.ts +1 -1
  166. package/src/renderers/Table/index.tsx +42 -6
  167. package/src/renderers/Tpl.tsx +11 -1
  168. package/src/store/form.ts +31 -24
  169. package/src/store/formItem.ts +65 -52
  170. package/src/utils/formula.ts +2 -2
  171. package/src/utils/helper.ts +2 -2
@@ -71,7 +71,7 @@ export interface BadgeSchema extends Omit<BaseSchema, 'type'> {
71
71
  export interface BadgeProps {
72
72
  badge?: BadgeSchema;
73
73
  classnames: ClassNamesFn;
74
- data?: any;
74
+ data: any;
75
75
  }
76
76
 
77
77
  export class Badge extends React.Component<BadgeProps, object> {
@@ -89,8 +89,7 @@ export class GroupedSelection extends BaseSelection<BaseSelectionProps> {
89
89
  placeholder,
90
90
  classnames: cx,
91
91
  option2value,
92
- onClick,
93
- placeholderRender
92
+ onClick
94
93
  } = this.props;
95
94
  const __ = this.props.translate;
96
95
 
@@ -107,7 +106,7 @@ export class GroupedSelection extends BaseSelection<BaseSelectionProps> {
107
106
  body
108
107
  ) : (
109
108
  <div className={cx('GroupedSelection-placeholder')}>
110
- {placeholderRender?.(this.props) ?? __(placeholder)}
109
+ {__(placeholder)}
111
110
  </div>
112
111
  )}
113
112
  </div>
@@ -11,7 +11,6 @@ import Button from './Button';
11
11
  export interface PickerContainerProps extends ThemeProps, LocaleProps {
12
12
  title?: string;
13
13
  showTitle?: boolean;
14
- showFooter?: boolean;
15
14
  headerClassName?: string;
16
15
  children: (props: {
17
16
  onClick: (e: React.MouseEvent) => void;
@@ -132,8 +131,7 @@ export class PickerContainer extends React.Component<
132
131
  showTitle,
133
132
  headerClassName,
134
133
  translate: __,
135
- size,
136
- showFooter
134
+ size
137
135
  } = this.props;
138
136
  return (
139
137
  <>
@@ -160,18 +158,15 @@ export class PickerContainer extends React.Component<
160
158
  ref: this.bodyRef,
161
159
  setState: this.updateState,
162
160
  onClose: this.close,
163
- onChange: this.handleChange,
164
- onConfirm: this.confirm
161
+ onChange: this.handleChange
165
162
  })}
166
163
  </Modal.Body>
167
- {showFooter ?? true ? (
168
- <Modal.Footer>
169
- <Button onClick={this.close}>{__('cancel')}</Button>
170
- <Button onClick={this.confirm} level="primary">
171
- {__('confirm')}
172
- </Button>
173
- </Modal.Footer>
174
- ) : null}
164
+ <Modal.Footer>
165
+ <Button onClick={this.close}>{__('cancel')}</Button>
166
+ <Button onClick={this.confirm} level="primary">
167
+ {__('confirm')}
168
+ </Button>
169
+ </Modal.Footer>
175
170
  </Modal>
176
171
  </>
177
172
  );
@@ -215,6 +215,8 @@ export class ResultBox extends React.Component<ResultBoxProps> {
215
215
  } = this.props;
216
216
  const isFocused = this.state.isFocused;
217
217
  const mobileUI = useMobileUI && isMobile();
218
+ /** 不需要透传给Input的属性 */
219
+ const omitPropsList = ['maxTagCount', 'overflowTagPopover'];
218
220
 
219
221
  return (
220
222
  <div
@@ -248,7 +250,7 @@ export class ResultBox extends React.Component<ResultBoxProps> {
248
250
 
249
251
  {allowInput && !disabled ? (
250
252
  <Input
251
- {...rest}
253
+ {...omit(rest, omitPropsList)}
252
254
  onKeyPress={onKeyPress}
253
255
  ref={this.inputRef}
254
256
  value={value || ''}
@@ -4,16 +4,19 @@
4
4
  import React from 'react';
5
5
  import Sortable from 'sortablejs';
6
6
  import {findDOMNode} from 'react-dom';
7
- import {cloneDeep} from 'lodash';
8
7
 
9
8
  import {Option, Options} from './Select';
10
9
  import {ThemeProps, themeable} from '../theme';
11
10
  import {Icon} from './icons';
12
11
  import {autobind, guid} from '../utils/helper';
13
12
  import {LocaleProps, localeable} from '../locale';
13
+ import {BaseSelection, BaseSelectionProps} from './Selection';
14
14
  import TransferSearch from './TransferSearch';
15
15
 
16
- export interface ResultListProps extends ThemeProps, LocaleProps {
16
+ export interface ResultListProps
17
+ extends ThemeProps,
18
+ LocaleProps,
19
+ BaseSelectionProps {
17
20
  className?: string;
18
21
  value?: Array<Option>;
19
22
  onChange?: (value: Array<Option>, optionModified?: boolean) => void;
@@ -23,9 +26,23 @@ export interface ResultListProps extends ThemeProps, LocaleProps {
23
26
  placeholder: string;
24
27
  itemRender: (option: Option, states: ItemRenderStates) => JSX.Element;
25
28
  itemClassName?: string;
29
+ columns: Array<{
30
+ name: string;
31
+ label: string;
32
+ [propName: string]: any;
33
+ }>;
34
+ cellRender?: (
35
+ column: {
36
+ name: string;
37
+ label: string;
38
+ [propName: string]: any;
39
+ },
40
+ option: Option,
41
+ colIndex: number,
42
+ rowIndex: number
43
+ ) => JSX.Element;
26
44
  searchable?: boolean;
27
45
  onSearch?: Function;
28
- valueField?: string;
29
46
  }
30
47
 
31
48
  export interface ItemRenderStates {
@@ -42,11 +59,15 @@ export class ResultList extends React.Component<
42
59
  ResultListProps,
43
60
  ResultListState
44
61
  > {
62
+
45
63
  static itemRender(option: any) {
46
64
  return <span>{`${option.scopeLabel || ''}${option.label}`}</span>;
47
65
  }
48
66
 
49
- static defaultProps: Pick<ResultListProps, 'placeholder' | 'itemRender'> = {
67
+ static defaultProps: Pick<
68
+ ResultListProps,
69
+ 'placeholder' | 'itemRender'
70
+ > = {
50
71
  placeholder: 'placeholder.selectData',
51
72
  itemRender: ResultList.itemRender
52
73
  };
@@ -151,60 +172,43 @@ export class ResultList extends React.Component<
151
172
  const searchResult = (value || []).filter(
152
173
  item => onSearch && onSearch(inputValue, item)
153
174
  );
154
- this.setState({searchResult});
175
+ this.setState({searchResult})
155
176
  }
156
177
 
157
178
  @autobind
158
179
  clearSearch() {
159
- this.setState({searchResult: null});
180
+ this.setState({searchResult: null})
160
181
  }
161
182
 
162
- // 删除项
183
+ // 关闭表格最后一项
163
184
  @autobind
164
- handleCloseItem(e: React.MouseEvent<HTMLElement>, option: Option) {
165
- const {
166
- value,
167
- onChange,
168
- disabled,
169
- searchable,
170
- valueField = 'value'
171
- } = this.props;
185
+ handleCloseItem(option: Option) {
186
+ const {value, onChange, option2value, options, disabled} = this.props;
172
187
 
173
188
  if (disabled || option.disabled) {
174
189
  return;
175
190
  }
176
191
 
177
- const {searchResult} = this.state;
178
- // 结果搜索
179
- if (searchable && searchResult) {
180
- // 删除普通值
181
- const valueArray = cloneDeep(value) || [];
182
- const idx = valueArray.findIndex(
183
- (item: Option) => item[valueField] === option[valueField]
184
- );
185
- if (idx > -1) {
186
- valueArray.splice(idx, 1);
187
- onChange && onChange(valueArray);
188
- }
189
- // 删除搜索结果
190
- const searchIdx = parseInt(e.currentTarget.getAttribute('data-index')!, 10);
191
- if (searchIdx > -1) {
192
- searchResult.splice(searchIdx, 1);
193
- this.setState({searchResult});
194
- }
195
- }
196
- // 没有搜索,走旧的删除方式
197
- else {
198
- const index = parseInt(e.currentTarget.getAttribute('data-index')!, 10);
199
- const {value, onChange} = this.props;
192
+ // 删除普通值
193
+ let valueArray = BaseSelection.value2array(value, options, option2value);
200
194
 
201
- if (!Array.isArray(value)) {
202
- return;
203
- }
195
+ let idx = valueArray.indexOf(option);
196
+ valueArray.splice(idx, 1);
197
+ let newValue: string | Array<Option> = option2value
198
+ ? valueArray.map(item => option2value(item))
199
+ : valueArray;
200
+ onChange && onChange(newValue);
204
201
 
205
- const newValue = value.concat();
206
- newValue.splice(index, 1);
207
- onChange?.(newValue);
202
+ const {searchResult} = this.state;
203
+ if (searchResult) {
204
+ const searchArray = BaseSelection.value2array(
205
+ searchResult,
206
+ options,
207
+ option2value
208
+ );
209
+ const searchIdx = searchArray.indexOf(option);
210
+ searchResult.splice(searchIdx, 1);
211
+ this.setState({searchResult});
208
212
  }
209
213
  }
210
214
 
@@ -252,7 +256,7 @@ export class ResultList extends React.Component<
252
256
  className={cx('Selections-delBtn')}
253
257
  data-index={index}
254
258
  onClick={(e: React.MouseEvent<HTMLElement>) =>
255
- this.handleCloseItem(e, option)
259
+ this.handleCloseItem(option)
256
260
  }
257
261
  >
258
262
  <Icon icon="close" className="icon" />
@@ -261,9 +265,8 @@ export class ResultList extends React.Component<
261
265
  </div>
262
266
  ))}
263
267
  </div>
264
- ) : (
265
- <div className={cx('Selections-placeholder')}>{__(placeholder)}</div>
266
- )}
268
+ ) :
269
+ (<div className={cx('Selections-placeholder')}>{__(placeholder)}</div>)}
267
270
  </>
268
271
  );
269
272
  }
@@ -7,6 +7,7 @@
7
7
 
8
8
  import {uncontrollable} from 'uncontrollable';
9
9
  import React from 'react';
10
+ import merge from 'lodash/merge';
10
11
  import isInteger from 'lodash/isInteger';
11
12
  import omit from 'lodash/omit';
12
13
  import VirtualList from './virtual-list';
@@ -411,7 +412,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
411
412
  inputValue: '',
412
413
  highlightedIndex: -1,
413
414
  selection: value2array(props.value, props),
414
- itemHeight: 35,
415
+ itemHeight: 32 /** Select选项高度保持一致 */,
415
416
  pickerSelectItem: ''
416
417
  };
417
418
  }
@@ -726,7 +727,9 @@ export class Select extends React.Component<SelectProps, SelectState> {
726
727
 
727
728
  @autobind
728
729
  menuItemRef(ref: any) {
729
- ref && this.setState({itemHeight: ref.offsetHeight});
730
+ if (ref && typeof ref.offsetHeight === 'number' && ref > 0) {
731
+ this.setState({itemHeight: ref.offsetHeight});
732
+ }
730
733
  }
731
734
 
732
735
  renderValue({inputValue, isOpen}: ControllerStateAndHelpers<any>) {
@@ -944,7 +947,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
944
947
  hideSelected,
945
948
  renderMenu,
946
949
  mobileClassName,
947
- virtualThreshold = 200,
950
+ virtualThreshold = 100,
948
951
  useMobileUI = false
949
952
  } = this.props;
950
953
  const {selection} = this.state;
@@ -958,7 +961,8 @@ export class Select extends React.Component<SelectProps, SelectState> {
958
961
  })
959
962
  : options.concat()
960
963
  ).filter((option: Option) => !option.hidden && option.visible !== false);
961
-
964
+ const enableVirtualRender =
965
+ filtedOptions.length && filtedOptions.length > virtualThreshold;
962
966
  const selectionValues = selection.map(select => select[valueField]);
963
967
  if (multiple && checkAll) {
964
968
  const optionsValues = (checkAllBySearch ? filtedOptions : options).map(
@@ -998,7 +1002,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
998
1002
  item,
999
1003
  disabled: item.disabled
1000
1004
  })}
1001
- style={style}
1005
+ style={merge(style, enableVirtualRender ? {width: '100%'} : {})}
1002
1006
  className={cx(`Select-option`, {
1003
1007
  'is-disabled': item.disabled,
1004
1008
  'is-highlight': highlightedIndex === index,
@@ -1076,7 +1080,12 @@ export class Select extends React.Component<SelectProps, SelectState> {
1076
1080
  {item.tip}
1077
1081
  </Checkbox>
1078
1082
  ) : (
1079
- <span>
1083
+ <span
1084
+ className={cx('Select-option-content')}
1085
+ title={
1086
+ typeof item[labelField] === 'string' ? item[labelField] : ''
1087
+ }
1088
+ >
1080
1089
  {item.disabled
1081
1090
  ? item[labelField]
1082
1091
  : highlight(
@@ -1100,8 +1109,7 @@ export class Select extends React.Component<SelectProps, SelectState> {
1100
1109
  <div
1101
1110
  ref={this.menu}
1102
1111
  className={cx('Select-menu', {
1103
- 'Select--longlist':
1104
- filtedOptions.length && filtedOptions.length > virtualThreshold,
1112
+ 'Select--longlist': enableVirtualRender,
1105
1113
  'is-mobile': mobileUI
1106
1114
  })}
1107
1115
  >
@@ -33,7 +33,6 @@ export interface BaseSelectionProps extends ThemeProps, LocaleProps {
33
33
  itemRender: (option: Option, states: ItemRenderStates) => JSX.Element;
34
34
  disabled?: boolean;
35
35
  onClick?: (e: React.MouseEvent) => void;
36
- placeholderRender?: (props: any) => JSX.Element | null;
37
36
  }
38
37
 
39
38
  export interface ItemRenderStates {
@@ -45,8 +45,8 @@ export interface TabsTransferProps
45
45
  colIndex: number,
46
46
  rowIndex: number
47
47
  ) => JSX.Element;
48
- onTabChange?: (key: number) => void;
49
- activeKey?: number
48
+ onTabChange: (key: number) => void;
49
+ activeKey: number
50
50
  }
51
51
 
52
52
  export interface TabsTransferState {
@@ -664,6 +664,10 @@ export class Transfer<
664
664
  onChange={onChange}
665
665
  placeholder={placeholder}
666
666
  itemRender={resultItemRender}
667
+ columns={columns!}
668
+ options={options || []}
669
+ option2value={option2value}
670
+ cellRender={cellRender}
667
671
  searchable={searchable}
668
672
  onSearch={onResultSearch}
669
673
  />
@@ -282,7 +282,6 @@ export class TreeSelection extends BaseSelection<
282
282
  placeholder,
283
283
  classnames: cx,
284
284
  option2value,
285
- placeholderRender,
286
285
  translate: __
287
286
  } = this.props;
288
287
 
@@ -299,7 +298,7 @@ export class TreeSelection extends BaseSelection<
299
298
  body
300
299
  ) : (
301
300
  <div className={cx('TreeSelection-placeholder')}>
302
- {placeholderRender?.(this.props) ?? __(placeholder)}
301
+ {__(placeholder)}
303
302
  </div>
304
303
  )}
305
304
  </div>
@@ -13,13 +13,12 @@ import CodeMirrorEditor from '../CodeMirror';
13
13
  import {autobind, eachTree} from '../../utils/helper';
14
14
  import {themeable, ThemeProps} from '../../theme';
15
15
  import {localeable, LocaleProps} from '../../locale';
16
- import {toast} from '../Toast';
17
16
 
18
17
  export interface VariableItem {
19
18
  label: string;
20
19
  value?: string;
21
20
  children?: Array<VariableItem>;
22
- type?: string;
21
+ type: '';
23
22
  tag?: string;
24
23
  selectMode?: 'tree' | 'tabs';
25
24
  }
@@ -56,6 +55,11 @@ export interface FormulaEditorProps extends ThemeProps, LocaleProps {
56
55
  */
57
56
  variableMode?: 'tabs' | 'tree';
58
57
 
58
+ /**
59
+ * 只展示变量,不需要其他面板
60
+ */
61
+ onlyVariable?: boolean;
62
+
59
63
  /**
60
64
  * 函数集合,默认不需要传,即 amis-formula 里面那个函数
61
65
  * 如果有扩充,则需要传。
@@ -70,11 +74,6 @@ export interface FormulaEditorProps extends ThemeProps, LocaleProps {
70
74
  variableClassName?: string;
71
75
 
72
76
  functionClassName?: string;
73
-
74
- /**
75
- * 当前输入项字段 name: 用于避免循环绑定自身导致无限渲染
76
- */
77
- selfVariableName?: string;
78
77
  }
79
78
 
80
79
  export interface FunctionsProps {
@@ -227,11 +226,17 @@ export class FormulaEditor extends React.Component<
227
226
 
228
227
  @autobind
229
228
  handleVariableSelect(item: VariableItem) {
230
- const {evalMode, selfVariableName} = this.props;
231
-
232
- if (item && item.label && selfVariableName === item.label) {
233
- toast.warning('不能使用当前变量[self],避免循环引用。');
234
- return;
229
+ const {onlyVariable, evalMode} = this.props;
230
+
231
+ // 只展示变量时,选择即提交
232
+ if (onlyVariable) {
233
+ const onChange = this.props.onChange;
234
+ const value = item.value
235
+ ? evalMode
236
+ ? item.value
237
+ : '${' + item.value + '}'
238
+ : '';
239
+ return onChange?.(value);
235
240
  }
236
241
 
237
242
  this.editorPlugin?.insertContent(
@@ -261,12 +266,12 @@ export class FormulaEditor extends React.Component<
261
266
  value,
262
267
  functions,
263
268
  variableMode,
269
+ onlyVariable,
264
270
  translate: __,
265
271
  classnames: cx,
266
272
  variableClassName,
267
273
  functionClassName,
268
- classPrefix,
269
- selfVariableName
274
+ classPrefix
270
275
  } = this.props;
271
276
  const {focused} = this.state;
272
277
  const customFunctions = Array.isArray(functions) ? functions : [];
@@ -281,23 +286,30 @@ export class FormulaEditor extends React.Component<
281
286
  'is-focused': focused
282
287
  })}
283
288
  >
284
- <section className={cx(`FormulaEditor-content`)}>
285
- <header className={cx(`FormulaEditor-header`)}>
286
- {__(header || 'FormulaEditor.title')}
287
- </header>
288
-
289
- <CodeMirrorEditor
290
- className={cx('FormulaEditor-editor')}
291
- value={value}
292
- onChange={this.handleOnChange}
293
- editorFactory={this.editorFactory}
294
- editorDidMount={this.handleEditorMounted}
295
- onFocus={this.handleFocus}
296
- onBlur={this.handleBlur}
297
- />
298
- </section>
299
-
300
- <section className={cx('FormulaEditor-settings')}>
289
+ {onlyVariable ? null : (
290
+ <section className={cx(`FormulaEditor-content`)}>
291
+ <header className={cx(`FormulaEditor-header`)}>
292
+ {__(header || 'FormulaEditor.title')}
293
+ </header>
294
+
295
+ <CodeMirrorEditor
296
+ className={cx('FormulaEditor-editor')}
297
+ value={value}
298
+ onChange={this.handleOnChange}
299
+ editorFactory={this.editorFactory}
300
+ editorDidMount={this.handleEditorMounted}
301
+ onFocus={this.handleFocus}
302
+ onBlur={this.handleBlur}
303
+ />
304
+ </section>
305
+ )}
306
+
307
+ <section
308
+ className={cx(
309
+ 'FormulaEditor-settings',
310
+ onlyVariable ? 'only-variable' : ''
311
+ )}
312
+ >
301
313
  <div className={cx('FormulaEditor-panel')}>
302
314
  {variableMode !== 'tabs' ? (
303
315
  <div className={cx('FormulaEditor-panel-header')}>
@@ -320,17 +332,18 @@ export class FormulaEditor extends React.Component<
320
332
  selectMode={variableMode}
321
333
  data={variables!}
322
334
  onSelect={this.handleVariableSelect}
323
- selfVariableName={selfVariableName}
324
335
  />
325
336
  </div>
326
337
  </div>
327
338
 
328
- <FuncList
329
- className={functionClassName}
330
- title={__('FormulaEditor.function')}
331
- data={functionList}
332
- onSelect={this.handleFunctionSelect}
333
- />
339
+ {onlyVariable ? null : (
340
+ <FuncList
341
+ className={functionClassName}
342
+ title={__('FormulaEditor.function')}
343
+ data={functionList}
344
+ onSelect={this.handleFunctionSelect}
345
+ />
346
+ )}
334
347
  </section>
335
348
  </div>
336
349
  );
@@ -43,6 +43,11 @@ export interface FormulaPickerProps extends FormulaEditorProps {
43
43
  */
44
44
  borderMode?: 'full' | 'half' | 'none';
45
45
 
46
+ /**
47
+ * 只展示变量,不需要其他面板
48
+ */
49
+ onlyVariable?: boolean;
50
+
46
51
  /**
47
52
  * 按钮Label,inputMode为button时生效
48
53
  */
@@ -133,7 +138,8 @@ export class FormulaPicker extends React.Component<
133
138
  }
134
139
 
135
140
  static defaultProps = {
136
- evalMode: true
141
+ evalMode: true,
142
+ onlyVariable: false
137
143
  };
138
144
 
139
145
  state: FormulaPickerState = {
@@ -182,6 +188,11 @@ export class FormulaPicker extends React.Component<
182
188
 
183
189
  @autobind
184
190
  handleEditorChange(value: string) {
191
+ const {onlyVariable} = this.props;
192
+ if (onlyVariable) {
193
+ return this.confirm(value);
194
+ }
195
+
185
196
  this.setState({
186
197
  editorValue: value,
187
198
  isError: false
@@ -285,6 +296,7 @@ export class FormulaPicker extends React.Component<
285
296
  functions,
286
297
  children,
287
298
  variableMode,
299
+ onlyVariable,
288
300
  ...rest
289
301
  } = this.props;
290
302
  const {isOpened, value, editorValue, isError} = this.state;
@@ -394,7 +406,10 @@ export class FormulaPicker extends React.Component<
394
406
  className={cx(`FormulaPicker-toggler`)}
395
407
  onClick={this.handleClick}
396
408
  >
397
- <Icon icon="function" className="icon" />
409
+ <Icon
410
+ icon={onlyVariable ? 'ellipsis-v' : 'function'}
411
+ className="icon"
412
+ />
398
413
  </a>
399
414
  </>
400
415
  )}
@@ -415,9 +430,9 @@ export class FormulaPicker extends React.Component<
415
430
  variables={this.state.variables ?? variables}
416
431
  functions={this.state.functions ?? functions}
417
432
  variableMode={this.state.variableMode ?? variableMode}
433
+ onlyVariable={onlyVariable}
418
434
  value={editorValue}
419
435
  onChange={this.handleEditorChange}
420
- selfVariableName={this.props.selfVariableName}
421
436
  />
422
437
  </Modal.Body>
423
438
  <Modal.Footer>
@@ -428,10 +443,14 @@ export class FormulaPicker extends React.Component<
428
443
  </span>
429
444
  </div>
430
445
  ) : null}
431
- <Button onClick={this.close}>{__('cancel')}</Button>
432
- <Button onClick={this.handleEditorConfirm} level="primary">
433
- {__('confirm')}
434
- </Button>
446
+ {onlyVariable ? null : (
447
+ <>
448
+ <Button onClick={this.close}>{__('cancel')}</Button>
449
+ <Button onClick={this.handleEditorConfirm} level="primary">
450
+ {__('confirm')}
451
+ </Button>
452
+ </>
453
+ )}
435
454
  </Modal.Footer>
436
455
  </Modal>
437
456
  </>