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.
- package/lib/components/AssociatedSelection.d.ts +40 -40
- package/lib/components/Badge.d.ts +1 -1
- package/lib/components/Badge.js.map +1 -1
- package/lib/components/ChainedSelection.d.ts +40 -40
- package/lib/components/GroupedSelection.d.ts +40 -40
- package/lib/components/GroupedSelection.js +2 -3
- package/lib/components/GroupedSelection.js.map +2 -2
- package/lib/components/PickerContainer.d.ts +0 -1
- package/lib/components/PickerContainer.js +4 -4
- package/lib/components/PickerContainer.js.map +2 -2
- package/lib/components/ResultBox.js +3 -1
- package/lib/components/ResultBox.js.map +2 -2
- package/lib/components/ResultList.d.ts +53 -43
- package/lib/components/ResultList.js +22 -34
- package/lib/components/ResultList.js.map +2 -2
- package/lib/components/ResultTableList.d.ts +40 -40
- package/lib/components/ResultTreeList.d.ts +40 -40
- package/lib/components/Select.js +10 -6
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Selection.d.ts +40 -41
- package/lib/components/Selection.js.map +2 -2
- package/lib/components/TableSelection.d.ts +40 -40
- package/lib/components/TabsTransfer.d.ts +2 -2
- package/lib/components/TabsTransfer.js.map +1 -1
- package/lib/components/Transfer.d.ts +40 -40
- package/lib/components/Transfer.js +1 -1
- package/lib/components/Transfer.js.map +2 -2
- package/lib/components/TransferDropDown.d.ts +40 -40
- package/lib/components/TreeSelection.d.ts +40 -40
- package/lib/components/TreeSelection.js +2 -3
- package/lib/components/TreeSelection.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +45 -45
- package/lib/components/formula/Editor.js +16 -11
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.d.ts +85 -40
- package/lib/components/formula/Picker.js +12 -6
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/components/formula/VariableList.d.ts +0 -2
- package/lib/components/formula/VariableList.js +5 -15
- package/lib/components/formula/VariableList.js.map +2 -2
- package/lib/components/index.d.ts +1 -3
- package/lib/components/index.js +1 -5
- package/lib/components/index.js.map +2 -2
- package/lib/components/schema-editor/SchemaVariableList.d.ts +0 -1
- package/lib/components/schema-editor/SchemaVariableList.js +2 -2
- package/lib/components/schema-editor/SchemaVariableList.js.map +2 -2
- package/lib/components/schema-editor/SchemaVariableListPicker.d.ts +0 -1
- package/lib/components/schema-editor/SchemaVariableListPicker.js +2 -2
- package/lib/components/schema-editor/SchemaVariableListPicker.js.map +2 -2
- package/lib/helper.css.map +1 -1
- package/lib/index.js +1 -1
- package/lib/renderers/CRUD.js +3 -3
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +66 -20
- package/lib/renderers/Form/Editor.d.ts +66 -20
- package/lib/renderers/Form/Group.js +1 -1
- package/lib/renderers/Form/Group.js.map +2 -2
- package/lib/renderers/Form/InputFormula.d.ts +5 -5
- package/lib/renderers/Form/InputFormula.js +4 -3
- package/lib/renderers/Form/InputFormula.js.map +2 -2
- package/lib/renderers/Form/InputTag.d.ts +1 -1
- package/lib/renderers/Form/InputTag.js.map +1 -1
- package/lib/renderers/Form/Options.js +7 -7
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Select.d.ts +6 -1
- package/lib/renderers/Form/Select.js +3 -1
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +0 -1
- package/lib/renderers/Form/TreeSelect.js +1 -9
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/index.js +9 -4
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Table/exportExcel.js +1 -1
- package/lib/renderers/Table/exportExcel.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +2 -0
- package/lib/renderers/Table/index.js +37 -5
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/Tpl.d.ts +4 -0
- package/lib/renderers/Tpl.js +6 -3
- package/lib/renderers/Tpl.js.map +2 -2
- package/lib/store/combo.d.ts +72 -22
- package/lib/store/form.d.ts +30 -9
- package/lib/store/form.js +28 -10
- package/lib/store/form.js.map +2 -2
- package/lib/store/formItem.d.ts +3 -1
- package/lib/store/formItem.js +3 -5
- package/lib/store/formItem.js.map +2 -2
- package/lib/store/table.d.ts +60 -18
- package/lib/themes/ang-ie11.css +33 -9
- package/lib/themes/ang.css +27 -9
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +33 -9
- package/lib/themes/antd.css +27 -9
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +35 -15
- package/lib/themes/cxd.css +31 -17
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +33 -9
- package/lib/themes/dark.css +27 -9
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +35 -15
- package/lib/themes/default.css +31 -17
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/formula.js +2 -3
- package/lib/utils/formula.js.map +2 -2
- package/lib/utils/helper.js +1 -1
- package/lib/utils/helper.js.map +2 -2
- package/package.json +1 -1
- package/schema.json +22 -16
- package/scss/_mixins.scss +1 -1
- package/scss/components/form/_date.scss +9 -10
- package/scss/components/form/_select.scss +14 -0
- package/scss/components/form/_transfer.scss +1 -2
- package/scss/themes/cxd.scss +4 -9
- package/sdk/ang-ie11.css +36 -9
- package/sdk/ang.css +30 -9
- package/sdk/antd-ie11.css +36 -9
- package/sdk/antd.css +30 -9
- package/sdk/barcode.js +51 -51
- package/sdk/charts.js +14 -14
- package/sdk/codemirror.js +7 -7
- package/sdk/color-picker.js +65 -65
- package/sdk/cropperjs.js +2 -2
- package/sdk/cxd-ie11.css +38 -16
- package/sdk/cxd.css +34 -18
- package/sdk/dark-ie11.css +36 -9
- package/sdk/dark.css +30 -9
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css.map +1 -1
- package/sdk/markdown.js +69 -69
- package/sdk/papaparse.js +1 -1
- package/sdk/renderers/Form/CityDB.js +1 -1
- package/sdk/rest.js +16 -16
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +38 -16
- package/sdk/sdk.css +34 -18
- package/sdk/sdk.js +1356 -1354
- package/sdk/thirds/hls.js/hls.js +1 -1
- package/sdk/thirds/mpegts.js/mpegts.js +1 -1
- package/sdk/tinymce.js +57 -57
- package/src/components/Badge.tsx +1 -1
- package/src/components/GroupedSelection.tsx +2 -3
- package/src/components/PickerContainer.tsx +8 -13
- package/src/components/ResultBox.tsx +3 -1
- package/src/components/ResultList.tsx +51 -48
- package/src/components/Select.tsx +16 -8
- package/src/components/Selection.tsx +0 -1
- package/src/components/TabsTransfer.tsx +2 -2
- package/src/components/Transfer.tsx +4 -0
- package/src/components/TreeSelection.tsx +1 -2
- package/src/components/formula/Editor.tsx +51 -38
- package/src/components/formula/Picker.tsx +26 -7
- package/src/components/formula/VariableList.tsx +2 -36
- package/src/components/index.tsx +0 -4
- package/src/components/schema-editor/SchemaVariableList.tsx +2 -4
- package/src/components/schema-editor/SchemaVariableListPicker.tsx +1 -4
- package/src/renderers/CRUD.tsx +3 -3
- package/src/renderers/Form/Group.tsx +1 -1
- package/src/renderers/Form/InputFormula.tsx +11 -10
- package/src/renderers/Form/InputTag.tsx +1 -1
- package/src/renderers/Form/Options.tsx +7 -9
- package/src/renderers/Form/Select.tsx +10 -2
- package/src/renderers/Form/TreeSelect.tsx +14 -16
- package/src/renderers/Form/index.tsx +13 -2
- package/src/renderers/Table/exportExcel.ts +1 -1
- package/src/renderers/Table/index.tsx +42 -6
- package/src/renderers/Tpl.tsx +11 -1
- package/src/store/form.ts +31 -24
- package/src/store/formItem.ts +65 -52
- package/src/utils/formula.ts +2 -2
- package/src/utils/helper.ts +2 -2
package/src/components/Badge.tsx
CHANGED
@@ -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
|
-
{
|
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
|
-
|
168
|
-
<
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
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
|
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<
|
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(
|
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
|
-
|
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
|
-
|
202
|
-
|
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
|
-
|
206
|
-
|
207
|
-
|
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(
|
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
|
-
|
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:
|
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 &&
|
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 =
|
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
|
49
|
-
activeKey
|
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
|
-
{
|
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
|
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 {
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
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
|
-
|
285
|
-
<
|
286
|
-
{
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
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
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
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
|
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
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
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
|
</>
|