amis 1.8.0-beta.5 → 1.8.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Schema.d.ts +9 -2
- package/lib/Schema.js.map +1 -1
- package/lib/actions/PageAction.d.ts +32 -0
- package/lib/actions/PageAction.js +72 -0
- package/lib/actions/PageAction.js.map +13 -0
- package/lib/actions/index.d.ts +1 -0
- package/lib/actions/index.js +1 -0
- package/lib/actions/index.js.map +2 -2
- package/lib/components/CalendarMobile.d.ts +84 -84
- package/lib/components/Cascader.d.ts +2 -0
- package/lib/components/Cascader.js +28 -12
- package/lib/components/Cascader.js.map +2 -2
- package/lib/components/Checkbox.js +2 -2
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/Collapse.d.ts +20 -20
- package/lib/components/DatePicker.d.ts +84 -84
- package/lib/components/DatePicker.js +5 -5
- package/lib/components/DatePicker.js.map +2 -2
- package/lib/components/Drawer.js +1 -1
- package/lib/components/Drawer.js.map +2 -2
- package/lib/components/ListGroup.d.ts +21 -21
- package/lib/components/Modal.js +1 -1
- package/lib/components/Modal.js.map +2 -2
- package/lib/components/Overlay.d.ts +1 -0
- package/lib/components/Overlay.js +4 -3
- package/lib/components/Overlay.js.map +2 -2
- package/lib/components/PullRefresh.d.ts +86 -0
- package/lib/components/PullRefresh.js +135 -0
- package/lib/components/PullRefresh.js.map +13 -0
- package/lib/components/Spinner.d.ts +200 -107
- package/lib/components/Spinner.js +30 -26
- package/lib/components/Spinner.js.map +2 -2
- package/lib/components/Tooltip.d.ts +4 -0
- package/lib/components/Tooltip.js +6 -4
- package/lib/components/Tooltip.js.map +2 -2
- package/lib/components/TooltipWrapper.d.ts +60 -4
- package/lib/components/TooltipWrapper.js +27 -8
- package/lib/components/TooltipWrapper.js.map +2 -2
- package/lib/components/Transfer.d.ts +84 -84
- package/lib/components/TransferDropDown.d.ts +84 -84
- package/lib/components/Tree.d.ts +87 -85
- package/lib/components/Tree.js +13 -5
- package/lib/components/Tree.js.map +2 -2
- package/lib/components/TreeSelection.d.ts +84 -84
- package/lib/components/calendar/TimeView.d.ts +1 -0
- package/lib/components/calendar/TimeView.js +7 -0
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/condition-builder/Expression.d.ts +1 -0
- package/lib/components/condition-builder/Expression.js +4 -4
- package/lib/components/condition-builder/Expression.js.map +2 -2
- package/lib/components/condition-builder/Field.d.ts +1 -0
- package/lib/components/condition-builder/Field.js +3 -2
- package/lib/components/condition-builder/Field.js.map +2 -2
- package/lib/components/condition-builder/Group.d.ts +1 -0
- package/lib/components/condition-builder/Group.js +2 -2
- package/lib/components/condition-builder/Group.js.map +2 -2
- package/lib/components/condition-builder/GroupOrItem.d.ts +1 -0
- package/lib/components/condition-builder/GroupOrItem.js +2 -2
- package/lib/components/condition-builder/GroupOrItem.js.map +2 -2
- package/lib/components/condition-builder/InputSwitch.d.ts +2 -1
- package/lib/components/condition-builder/InputSwitch.js +2 -2
- package/lib/components/condition-builder/InputSwitch.js.map +2 -2
- package/lib/components/condition-builder/Item.d.ts +1 -0
- package/lib/components/condition-builder/Item.js +9 -8
- package/lib/components/condition-builder/Item.js.map +2 -2
- package/lib/components/condition-builder/Value.d.ts +1 -0
- package/lib/components/condition-builder/Value.js +5 -5
- package/lib/components/condition-builder/Value.js.map +2 -2
- package/lib/components/condition-builder/index.d.ts +1 -0
- package/lib/components/condition-builder/index.js +2 -2
- package/lib/components/condition-builder/index.js.map +2 -2
- package/lib/components/formula/Editor.d.ts +87 -85
- package/lib/components/formula/Editor.js +10 -6
- package/lib/components/formula/Editor.js.map +2 -2
- package/lib/components/formula/Picker.js +3 -1
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/index.js +1 -1
- package/lib/locale/de-DE.js +5 -1
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +5 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +5 -1
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/CRUD.js +1 -1
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Form/Combo.d.ts +2 -1
- package/lib/renderers/Form/Combo.js +51 -14
- package/lib/renderers/Form/Combo.js.map +2 -2
- package/lib/renderers/Form/DiffEditor.d.ts +1 -0
- package/lib/renderers/Form/InputCity.d.ts +84 -84
- package/lib/renderers/Form/InputDate.js +10 -3
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputDateRange.js +12 -3
- package/lib/renderers/Form/InputDateRange.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +13 -5
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputImage.js +12 -4
- package/lib/renderers/Form/InputImage.js.map +2 -2
- package/lib/renderers/Form/InputMonthRange.js +5 -1
- package/lib/renderers/Form/InputMonthRange.js.map +2 -2
- package/lib/renderers/Form/InputText.js +8 -4
- package/lib/renderers/Form/InputText.js.map +2 -2
- package/lib/renderers/Form/InputTree.d.ts +5 -0
- package/lib/renderers/Form/InputTree.js +51 -2
- package/lib/renderers/Form/InputTree.js.map +2 -2
- package/lib/renderers/Form/Item.d.ts +68 -70
- package/lib/renderers/Form/Item.js.map +2 -2
- package/lib/renderers/Form/NestedSelect.d.ts +4 -0
- package/lib/renderers/Form/NestedSelect.js +14 -5
- package/lib/renderers/Form/NestedSelect.js.map +2 -2
- package/lib/renderers/Form/Options.js +61 -27
- package/lib/renderers/Form/Options.js.map +2 -2
- package/lib/renderers/Form/Select.js +4 -2
- package/lib/renderers/Form/Select.js.map +2 -2
- package/lib/renderers/Form/TreeSelect.d.ts +11 -2
- package/lib/renderers/Form/TreeSelect.js +56 -10
- package/lib/renderers/Form/TreeSelect.js.map +2 -2
- package/lib/renderers/Form/wrapControl.js +3 -3
- package/lib/renderers/Form/wrapControl.js.map +2 -2
- package/lib/renderers/Nav.d.ts +82 -67
- package/lib/renderers/Nav.js +47 -11
- package/lib/renderers/Nav.js.map +2 -2
- package/lib/renderers/Page.d.ts +20 -0
- package/lib/renderers/Page.js +51 -14
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.d.ts +2 -0
- package/lib/renderers/Service.js +52 -20
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Spinner.d.ts +58 -2
- package/lib/renderers/Spinner.js +8 -1
- package/lib/renderers/Spinner.js.map +2 -2
- package/lib/renderers/Table/ColumnToggler.d.ts +4 -0
- package/lib/renderers/Table/ColumnToggler.js +11 -6
- package/lib/renderers/Table/ColumnToggler.js.map +2 -2
- package/lib/renderers/Table/TableCell.js +27 -1
- package/lib/renderers/Table/TableCell.js.map +2 -2
- package/lib/renderers/Table/index.d.ts +1 -0
- package/lib/renderers/Table/index.js +19 -11
- package/lib/renderers/Table/index.js.map +2 -2
- package/lib/renderers/TooltipWrapper.d.ts +31 -6
- package/lib/renderers/TooltipWrapper.js +18 -8
- package/lib/renderers/TooltipWrapper.js.map +2 -2
- package/lib/renderers/Wizard.js +23 -14
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/crud.js +23 -13
- package/lib/store/crud.js.map +2 -2
- package/lib/themes/ang-ie11.css +313 -100
- package/lib/themes/ang.css +322 -103
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +429 -216
- package/lib/themes/antd.css +323 -104
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +424 -211
- package/lib/themes/cxd.css +324 -105
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +313 -100
- package/lib/themes/dark.css +322 -103
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +424 -211
- package/lib/themes/default.css +324 -105
- package/lib/themes/default.css.map +1 -1
- package/lib/types.d.ts +3 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/ColorScale.d.ts +19 -0
- package/lib/utils/ColorScale.js +104 -0
- package/lib/utils/ColorScale.js.map +13 -0
- package/lib/utils/api.js +20 -4
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/dom.d.ts +1 -1
- package/lib/utils/dom.js +7 -5
- package/lib/utils/dom.js.map +2 -2
- package/package.json +3 -2
- package/schema.json +29645 -29137
- package/scss/_properties.scss +33 -15
- package/scss/components/_column-toggler.scss +21 -11
- package/scss/components/_formula.scss +1 -1
- package/scss/components/_nav.scss +51 -6
- package/scss/components/_pull-refresh.scss +25 -0
- package/scss/components/_spinner.scss +134 -56
- package/scss/components/_tooltip.scss +4 -9
- package/scss/components/form/_checks.scss +1 -0
- package/scss/components/form/_combo.scss +13 -1
- package/scss/components/form/_date-range.scss +11 -2
- package/scss/components/form/_date.scss +11 -0
- package/scss/components/form/_file.scss +4 -0
- package/scss/components/form/_form.scss +15 -8
- package/scss/components/form/_transfer.scss +3 -2
- package/scss/themes/_antd-variables.scss +1 -1
- package/scss/themes/_common.scss +1 -0
- package/scss/themes/_cxd-variables.scss +2 -2
- package/sdk/ang-ie11.css +286 -80
- package/sdk/ang.css +294 -82
- package/sdk/antd-ie11.css +402 -196
- package/sdk/antd.css +295 -83
- 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 +397 -191
- package/sdk/cxd.css +296 -84
- package/sdk/dark-ie11.css +286 -80
- package/sdk/dark.css +294 -82
- package/sdk/exceljs.js +1 -1
- package/sdk/locale/de-DE.js +5 -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 +17 -17
- package/sdk/rich-text.js +62 -62
- package/sdk/sdk-ie11.css +397 -191
- package/sdk/sdk.css +296 -84
- package/sdk/sdk.js +1300 -1260
- 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/Schema.ts +10 -0
- package/src/actions/PageAction.ts +62 -0
- package/src/actions/index.ts +1 -0
- package/src/components/Cascader.tsx +37 -11
- package/src/components/Checkbox.tsx +1 -1
- package/src/components/DatePicker.tsx +7 -5
- package/src/components/Drawer.tsx +1 -0
- package/src/components/Modal.tsx +1 -0
- package/src/components/Overlay.tsx +6 -3
- package/src/components/PullRefresh.tsx +197 -0
- package/src/components/Spinner.tsx +77 -42
- package/src/components/Tooltip.tsx +12 -3
- package/src/components/TooltipWrapper.tsx +120 -33
- package/src/components/Tree.tsx +19 -5
- package/src/components/calendar/TimeView.tsx +12 -0
- package/src/components/condition-builder/Expression.tsx +6 -1
- package/src/components/condition-builder/Field.tsx +5 -1
- package/src/components/condition-builder/Group.tsx +4 -1
- package/src/components/condition-builder/GroupOrItem.tsx +4 -1
- package/src/components/condition-builder/InputSwitch.tsx +4 -1
- package/src/components/condition-builder/Item.tsx +28 -4
- package/src/components/condition-builder/Value.tsx +7 -1
- package/src/components/condition-builder/index.tsx +4 -2
- package/src/components/formula/Editor.tsx +20 -15
- package/src/components/formula/Picker.tsx +9 -5
- package/src/locale/de-DE.ts +5 -1
- package/src/locale/en-US.ts +5 -1
- package/src/locale/zh-CN.ts +5 -1
- package/src/renderers/CRUD.tsx +1 -1
- package/src/renderers/Form/Combo.tsx +102 -46
- package/src/renderers/Form/InputDate.tsx +18 -4
- package/src/renderers/Form/InputDateRange.tsx +19 -2
- package/src/renderers/Form/InputFile.tsx +16 -4
- package/src/renderers/Form/InputImage.tsx +15 -3
- package/src/renderers/Form/InputMonthRange.tsx +7 -1
- package/src/renderers/Form/InputText.tsx +14 -2
- package/src/renderers/Form/InputTree.tsx +40 -2
- package/src/renderers/Form/Item.tsx +6 -0
- package/src/renderers/Form/NestedSelect.tsx +23 -4
- package/src/renderers/Form/Options.tsx +26 -7
- package/src/renderers/Form/Select.tsx +5 -3
- package/src/renderers/Form/TreeSelect.tsx +47 -9
- package/src/renderers/Form/wrapControl.tsx +2 -2
- package/src/renderers/Nav.tsx +230 -32
- package/src/renderers/Page.tsx +89 -33
- package/src/renderers/Service.tsx +62 -27
- package/src/renderers/Spinner.tsx +85 -3
- package/src/renderers/Table/ColumnToggler.tsx +36 -11
- package/src/renderers/Table/TableCell.tsx +39 -1
- package/src/renderers/Table/index.tsx +34 -21
- package/src/renderers/TooltipWrapper.tsx +64 -28
- package/src/renderers/Wizard.tsx +36 -25
- package/src/store/crud.ts +10 -0
- package/src/types.ts +4 -0
- package/src/utils/ColorScale.ts +138 -0
- package/src/utils/api.ts +26 -4
- package/src/utils/dom.tsx +7 -6
@@ -8,6 +8,8 @@ import {
|
|
8
8
|
} from './Options';
|
9
9
|
import {Spinner} from '../../components';
|
10
10
|
import {SchemaApi} from '../../Schema';
|
11
|
+
import {autobind, createObject} from '../../utils/helper';
|
12
|
+
import {Action} from '../../types';
|
11
13
|
|
12
14
|
/**
|
13
15
|
* Tree 下拉选择框。
|
@@ -98,12 +100,48 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
98
100
|
enableNodePath: false,
|
99
101
|
pathSeparator: '/'
|
100
102
|
};
|
103
|
+
treeRef: any
|
101
104
|
|
102
105
|
reload() {
|
103
106
|
const reload = this.props.reloadOptions;
|
104
107
|
reload && reload();
|
105
108
|
}
|
106
109
|
|
110
|
+
doAction(action: Action, data: any, throwErrors: boolean) {
|
111
|
+
const {resetValue, onChange, options} = this.props;
|
112
|
+
if (action.actionType && ['clear', 'reset'].includes(action.actionType)) {
|
113
|
+
onChange && onChange(resetValue ?? '');
|
114
|
+
}
|
115
|
+
if (action.actionType === 'expand') {
|
116
|
+
this.treeRef.syncUnFolded(this.props, action.openLevel);
|
117
|
+
}
|
118
|
+
if (action.actionType === 'collapse') {
|
119
|
+
this.treeRef.syncUnFolded(this.props, 0);
|
120
|
+
}
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
@autobind
|
126
|
+
async handleChange(value: any) {
|
127
|
+
const {onChange, dispatchEvent, data} = this.props;
|
128
|
+
|
129
|
+
const rendererEvent = await dispatchEvent('change', createObject(data, {
|
130
|
+
value
|
131
|
+
}));
|
132
|
+
|
133
|
+
if (rendererEvent?.prevented) {
|
134
|
+
return;
|
135
|
+
}
|
136
|
+
|
137
|
+
onChange && onChange(value);
|
138
|
+
}
|
139
|
+
|
140
|
+
@autobind
|
141
|
+
domRef(ref: any) {
|
142
|
+
this.treeRef = ref;
|
143
|
+
}
|
144
|
+
|
107
145
|
render() {
|
108
146
|
const {
|
109
147
|
className,
|
@@ -112,7 +150,6 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
112
150
|
value,
|
113
151
|
enableNodePath,
|
114
152
|
pathSeparator = '/',
|
115
|
-
onChange,
|
116
153
|
disabled,
|
117
154
|
joinValues,
|
118
155
|
extractValue,
|
@@ -162,11 +199,12 @@ export default class TreeControl extends React.Component<TreeProps> {
|
|
162
199
|
{loading ? null : (
|
163
200
|
<TreeSelector
|
164
201
|
classPrefix={ns}
|
202
|
+
onRef={this.domRef}
|
165
203
|
labelField={labelField}
|
166
204
|
valueField={valueField}
|
167
205
|
iconField={iconField}
|
168
206
|
disabled={disabled}
|
169
|
-
onChange={
|
207
|
+
onChange={this.handleChange}
|
170
208
|
joinValues={joinValues}
|
171
209
|
extractValue={extractValue}
|
172
210
|
delimiter={delimiter}
|
@@ -25,6 +25,7 @@ import {
|
|
25
25
|
BaseSchema,
|
26
26
|
SchemaApi,
|
27
27
|
SchemaClassName,
|
28
|
+
SchemaExpression,
|
28
29
|
SchemaObject,
|
29
30
|
SchemaType
|
30
31
|
} from '../../Schema';
|
@@ -87,6 +88,11 @@ export interface FormBaseControl
|
|
87
88
|
*/
|
88
89
|
readOnly?: boolean;
|
89
90
|
|
91
|
+
/**
|
92
|
+
* 只读条件
|
93
|
+
*/
|
94
|
+
readOnlyOn?: SchemaExpression;
|
95
|
+
|
90
96
|
/**
|
91
97
|
* 不设置时,当表单提交过后表单项每次修改都会触发重新验证,
|
92
98
|
* 如果设置了,则由此配置项来决定要不要每次修改都触发验证。
|
@@ -61,6 +61,11 @@ export interface NestedSelectControlSchema extends FormOptionsControl {
|
|
61
61
|
*/
|
62
62
|
onlyChildren?: boolean;
|
63
63
|
|
64
|
+
/**
|
65
|
+
* 单选时只允许选择叶子节点
|
66
|
+
*/
|
67
|
+
onlyLeaf?: boolean;
|
68
|
+
|
64
69
|
/**
|
65
70
|
* 是否隐藏选择框中已选中节点的祖先节点的文本信息
|
66
71
|
*/
|
@@ -91,6 +96,7 @@ export default class NestedSelectControl extends React.Component<
|
|
91
96
|
cascade: false,
|
92
97
|
withChildren: false,
|
93
98
|
onlyChildren: false,
|
99
|
+
onlyLeaf: false,
|
94
100
|
searchPromptText: 'Select.searchPromptText',
|
95
101
|
noResultsText: 'noResult',
|
96
102
|
checkAll: true,
|
@@ -241,7 +247,7 @@ export default class NestedSelectControl extends React.Component<
|
|
241
247
|
);
|
242
248
|
})
|
243
249
|
: label}
|
244
|
-
{!isEnd && '>'}
|
250
|
+
{!isEnd && ' > '}
|
245
251
|
</span>
|
246
252
|
);
|
247
253
|
})
|
@@ -252,7 +258,7 @@ export default class NestedSelectControl extends React.Component<
|
|
252
258
|
|
253
259
|
@autobind
|
254
260
|
async handleOptionClick(option: Option) {
|
255
|
-
const {multiple, onChange, joinValues, extractValue, valueField} =
|
261
|
+
const {multiple, onChange, joinValues, extractValue, valueField, onlyLeaf} =
|
256
262
|
this.props;
|
257
263
|
|
258
264
|
if (multiple) {
|
@@ -265,10 +271,21 @@ export default class NestedSelectControl extends React.Component<
|
|
265
271
|
? option[valueField || 'value']
|
266
272
|
: option;
|
267
273
|
|
274
|
+
if (value === undefined) {
|
275
|
+
return;
|
276
|
+
}
|
277
|
+
|
278
|
+
if (onlyLeaf && option.children) {
|
279
|
+
return;
|
280
|
+
}
|
281
|
+
|
268
282
|
const isPrevented = await this.dispatchEvent('change', {
|
269
283
|
value
|
270
284
|
});
|
271
285
|
isPrevented || onChange(value);
|
286
|
+
|
287
|
+
isPrevented || this.handleResultClear();
|
288
|
+
|
272
289
|
!multiple && this.close();
|
273
290
|
}
|
274
291
|
|
@@ -383,6 +400,8 @@ export default class NestedSelectControl extends React.Component<
|
|
383
400
|
value: newValue
|
384
401
|
});
|
385
402
|
isPrevented || onChange(newValue);
|
403
|
+
|
404
|
+
isPrevented || this.handleResultClear();
|
386
405
|
}
|
387
406
|
|
388
407
|
allChecked(options: Options): boolean {
|
@@ -421,7 +440,7 @@ export default class NestedSelectControl extends React.Component<
|
|
421
440
|
});
|
422
441
|
|
423
442
|
const isPrevented = await this.dispatchEvent('focus', e);
|
424
|
-
isPrevented || onFocus && onFocus(e);
|
443
|
+
isPrevented || (onFocus && onFocus(e));
|
425
444
|
}
|
426
445
|
}
|
427
446
|
|
@@ -434,7 +453,7 @@ export default class NestedSelectControl extends React.Component<
|
|
434
453
|
});
|
435
454
|
|
436
455
|
const isPrevented = await this.dispatchEvent('blur', e);
|
437
|
-
isPrevented || onBlur && onBlur(e);
|
456
|
+
isPrevented || (onBlur && onBlur(e));
|
438
457
|
}
|
439
458
|
|
440
459
|
@autobind
|
@@ -454,10 +454,10 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
454
454
|
this.toDispose = [];
|
455
455
|
}
|
456
456
|
|
457
|
-
async
|
457
|
+
async dispatchOptionEvent(eventName: string, eventData: any = '') {
|
458
458
|
const {dispatchEvent, options, data} = this.props;
|
459
459
|
const rendererEvent = await dispatchEvent(
|
460
|
-
|
460
|
+
eventName,
|
461
461
|
createObject(data, {
|
462
462
|
value: eventData,
|
463
463
|
options,
|
@@ -599,7 +599,7 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
599
599
|
value
|
600
600
|
);
|
601
601
|
|
602
|
-
const isPrevented = await this.
|
602
|
+
const isPrevented = await this.dispatchOptionEvent('change', newValue);
|
603
603
|
isPrevented || (onChange && onChange(newValue, submitOnChange, changeImmediately));
|
604
604
|
}
|
605
605
|
|
@@ -667,7 +667,7 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
667
667
|
? []
|
668
668
|
: formItem.filteredOptions.concat();
|
669
669
|
const newValue = this.formatValueArray(valueArray);
|
670
|
-
const isPrevented = await this.
|
670
|
+
const isPrevented = await this.dispatchOptionEvent('change', newValue);
|
671
671
|
isPrevented || (onChange && onChange(newValue));
|
672
672
|
}
|
673
673
|
|
@@ -767,7 +767,7 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
767
767
|
}
|
768
768
|
|
769
769
|
@autobind
|
770
|
-
deferLoad(option: Option) {
|
770
|
+
async deferLoad(option: Option) {
|
771
771
|
const {deferApi, source, env, formItem, data} = this.props;
|
772
772
|
const api = option.deferApi || deferApi || source;
|
773
773
|
|
@@ -779,7 +779,9 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
779
779
|
return;
|
780
780
|
}
|
781
781
|
|
782
|
-
formItem?.deferLoadOptions(option, api, createObject(data, option));
|
782
|
+
const json = await formItem?.deferLoadOptions(option, api, createObject(data, option));
|
783
|
+
// 触发事件通知,加载完成
|
784
|
+
this.dispatchOptionEvent('loadFinished',json);
|
783
785
|
}
|
784
786
|
|
785
787
|
@autobind
|
@@ -992,10 +994,15 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
992
994
|
[valueField || 'value']: result[labelField || 'label']
|
993
995
|
};
|
994
996
|
}
|
997
|
+
// 触发事件通知
|
998
|
+
const isPrevented = await this.dispatchOptionEvent('add', {...result, idx});
|
999
|
+
if (isPrevented) {
|
1000
|
+
return;
|
1001
|
+
}
|
995
1002
|
|
996
1003
|
// 如果是懒加载的,只懒加载当前节点。
|
997
1004
|
if (parent?.defer) {
|
998
|
-
this.deferLoad(parent);
|
1005
|
+
await this.deferLoad(parent);
|
999
1006
|
} else if (source && addApi) {
|
1000
1007
|
// 如果配置了 source 且配置了 addApi 直接重新拉取接口就够了
|
1001
1008
|
// 不能不判断 addApi 就刷新,因为有些场景就是临时添加的。
|
@@ -1095,6 +1102,12 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
1095
1102
|
return;
|
1096
1103
|
}
|
1097
1104
|
|
1105
|
+
// 触发事件通知
|
1106
|
+
const isPrevented = await this.dispatchOptionEvent('edit', result);
|
1107
|
+
if (isPrevented) {
|
1108
|
+
return;
|
1109
|
+
}
|
1110
|
+
|
1098
1111
|
if (source && editApi) {
|
1099
1112
|
this.reload();
|
1100
1113
|
} else {
|
@@ -1141,6 +1154,12 @@ export function registerOptionsControl(config: OptionsConfig) {
|
|
1141
1154
|
return;
|
1142
1155
|
}
|
1143
1156
|
|
1157
|
+
// 触发事件通知
|
1158
|
+
const isPrevented = await this.dispatchOptionEvent('delete', ctx);
|
1159
|
+
if (isPrevented) {
|
1160
|
+
return;
|
1161
|
+
}
|
1162
|
+
|
1144
1163
|
// 通过 deleteApi 删除。
|
1145
1164
|
try {
|
1146
1165
|
if (!deleteApi) {
|
@@ -228,7 +228,7 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|
228
228
|
'change',
|
229
229
|
createObject(data, {
|
230
230
|
value: newValue,
|
231
|
-
options
|
231
|
+
options
|
232
232
|
})
|
233
233
|
);
|
234
234
|
if (rendererEvent?.prevented) {
|
@@ -409,8 +409,10 @@ export default class SelectControl extends React.Component<SelectProps, any> {
|
|
409
409
|
onBlur={(e: any) => this.dispatchEvent('blur', e)}
|
410
410
|
onFocus={(e: any) => this.dispatchEvent('focus', e)}
|
411
411
|
onAdd={() => this.dispatchEvent('add')}
|
412
|
-
onEdit={(item: any) => this.dispatchEvent('edit', item)}
|
413
|
-
onDelete={(item: any) =>
|
412
|
+
onEdit={(item: any) => this.dispatchEvent('edit', {value: item})}
|
413
|
+
onDelete={(item: any) =>
|
414
|
+
this.dispatchEvent('delete', {value: item})
|
415
|
+
}
|
414
416
|
loading={loading}
|
415
417
|
noResultsText={noResultsText}
|
416
418
|
renderMenu={menuTpl ? this.renderMenu : undefined}
|
@@ -18,9 +18,10 @@ import {Api} from '../../types';
|
|
18
18
|
import {isEffectiveApi} from '../../utils/api';
|
19
19
|
import Spinner from '../../components/Spinner';
|
20
20
|
import ResultBox from '../../components/ResultBox';
|
21
|
-
import {autobind, getTreeAncestors, isMobile} from '../../utils/helper';
|
21
|
+
import {autobind, getTreeAncestors, isMobile, createObject} from '../../utils/helper';
|
22
22
|
import {findDOMNode} from 'react-dom';
|
23
23
|
import {normalizeOptions} from '../../components/Select';
|
24
|
+
import {Action} from '../../types';
|
24
25
|
|
25
26
|
/**
|
26
27
|
* Tree 下拉选择框。
|
@@ -64,6 +65,11 @@ export interface TreeSelectControlSchema extends FormOptionsControl {
|
|
64
65
|
*/
|
65
66
|
onlyChildren?: boolean;
|
66
67
|
|
68
|
+
/**
|
69
|
+
* 单选时,只运行选择叶子节点
|
70
|
+
*/
|
71
|
+
onlyLeaf?: boolean;
|
72
|
+
|
67
73
|
/**
|
68
74
|
* 顶级节点是否可以创建子节点
|
69
75
|
*/
|
@@ -121,6 +127,8 @@ export default class TreeSelectControl extends React.Component<
|
|
121
127
|
pathSeparator: '/'
|
122
128
|
};
|
123
129
|
|
130
|
+
treeRef: any
|
131
|
+
|
124
132
|
container: React.RefObject<HTMLDivElement> = React.createRef();
|
125
133
|
|
126
134
|
input: React.RefObject<any> = React.createRef();
|
@@ -185,16 +193,20 @@ export default class TreeSelectControl extends React.Component<
|
|
185
193
|
);
|
186
194
|
}
|
187
195
|
|
188
|
-
handleFocus() {
|
196
|
+
handleFocus(e: any) {
|
197
|
+
const {dispatchEvent} = this.props;
|
189
198
|
this.setState({
|
190
199
|
isFocused: true
|
191
200
|
});
|
201
|
+
dispatchEvent('focus', e);
|
192
202
|
}
|
193
203
|
|
194
|
-
handleBlur() {
|
204
|
+
handleBlur(e: any) {
|
205
|
+
const {dispatchEvent} = this.props;
|
195
206
|
this.setState({
|
196
207
|
isFocused: false
|
197
208
|
});
|
209
|
+
dispatchEvent('blur', e);
|
198
210
|
}
|
199
211
|
|
200
212
|
handleKeyPress(e: React.KeyboardEvent) {
|
@@ -257,19 +269,19 @@ export default class TreeSelectControl extends React.Component<
|
|
257
269
|
}
|
258
270
|
|
259
271
|
handleChange(value: any) {
|
260
|
-
const {
|
272
|
+
const {multiple} = this.props;
|
261
273
|
|
262
274
|
if (!multiple) {
|
263
275
|
this.close();
|
264
276
|
}
|
265
277
|
|
266
278
|
multiple || !this.state.inputValue
|
267
|
-
?
|
279
|
+
? this.resultChangeEvent(value)
|
268
280
|
: this.setState(
|
269
281
|
{
|
270
282
|
inputValue: ''
|
271
283
|
},
|
272
|
-
() =>
|
284
|
+
() => this.resultChangeEvent(value)
|
273
285
|
);
|
274
286
|
}
|
275
287
|
|
@@ -410,14 +422,13 @@ export default class TreeSelectControl extends React.Component<
|
|
410
422
|
extractValue,
|
411
423
|
delimiter,
|
412
424
|
valueField,
|
413
|
-
onChange,
|
414
425
|
multiple
|
415
426
|
} = this.props;
|
416
427
|
|
417
428
|
let newValue: any = Array.isArray(value) ? value.concat() : [];
|
418
429
|
|
419
430
|
if (!multiple && !newValue.length) {
|
420
|
-
|
431
|
+
this.resultChangeEvent('');
|
421
432
|
return;
|
422
433
|
}
|
423
434
|
|
@@ -428,8 +439,27 @@ export default class TreeSelectControl extends React.Component<
|
|
428
439
|
if (joinValues) {
|
429
440
|
newValue = newValue.join(delimiter || ',');
|
430
441
|
}
|
442
|
+
this.resultChangeEvent(newValue);
|
443
|
+
}
|
431
444
|
|
432
|
-
|
445
|
+
doAction(action: Action, data: any, throwErrors: boolean) {
|
446
|
+
if (action.actionType && ['clear', 'reset'].includes(action.actionType)) {
|
447
|
+
this.clearValue();
|
448
|
+
}
|
449
|
+
}
|
450
|
+
|
451
|
+
@autobind
|
452
|
+
async resultChangeEvent(value: any) {
|
453
|
+
const {onChange, dispatchEvent, data} = this.props;
|
454
|
+
|
455
|
+
const rendererEvent = await dispatchEvent('change', createObject(data, {
|
456
|
+
value
|
457
|
+
}));
|
458
|
+
|
459
|
+
if (rendererEvent?.prevented) {
|
460
|
+
return;
|
461
|
+
}
|
462
|
+
onChange && onChange(value);
|
433
463
|
}
|
434
464
|
|
435
465
|
@autobind
|
@@ -449,6 +479,11 @@ export default class TreeSelectControl extends React.Component<
|
|
449
479
|
}`;
|
450
480
|
}
|
451
481
|
|
482
|
+
@autobind
|
483
|
+
domRef(ref: any) {
|
484
|
+
this.treeRef = ref;
|
485
|
+
}
|
486
|
+
|
452
487
|
renderOuter() {
|
453
488
|
const {
|
454
489
|
value,
|
@@ -472,6 +507,7 @@ export default class TreeSelectControl extends React.Component<
|
|
472
507
|
showRadio,
|
473
508
|
popOverContainer,
|
474
509
|
onlyChildren,
|
510
|
+
onlyLeaf,
|
475
511
|
classPrefix: ns,
|
476
512
|
optionsPlaceholder,
|
477
513
|
searchable,
|
@@ -506,7 +542,9 @@ export default class TreeSelectControl extends React.Component<
|
|
506
542
|
return (
|
507
543
|
<TreeSelector
|
508
544
|
classPrefix={ns}
|
545
|
+
onRef={this.domRef}
|
509
546
|
onlyChildren={onlyChildren}
|
547
|
+
onlyLeaf={onlyLeaf}
|
510
548
|
labelField={labelField}
|
511
549
|
valueField={valueField}
|
512
550
|
disabled={disabled}
|
@@ -539,8 +539,8 @@ export function wrapControl<
|
|
539
539
|
|
540
540
|
if (
|
541
541
|
// 如果配置了 minLength 或者 maxLength 就切成及时验证
|
542
|
-
this.model.rules.minLength ||
|
543
|
-
this.model.rules.maxLength ||
|
542
|
+
// this.model.rules.minLength ||
|
543
|
+
// this.model.rules.maxLength ||
|
544
544
|
validateOnChange === true ||
|
545
545
|
(validateOnChange !== false && (formSubmited || validated))
|
546
546
|
) {
|