amis 1.9.0 → 1.9.1-beta.3
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/RootRenderer.js +10 -2
- package/lib/RootRenderer.js.map +2 -2
- package/lib/Schema.d.ts +3 -2
- package/lib/Schema.js.map +1 -1
- package/lib/actions/Action.d.ts +1 -0
- package/lib/actions/Action.js +7 -6
- package/lib/actions/Action.js.map +2 -2
- package/lib/components/Button.d.ts +11 -10
- package/lib/components/Button.js +2 -2
- package/lib/components/Button.js.map +2 -2
- package/lib/components/CalendarMobile.d.ts +40 -40
- package/lib/components/Checkbox.js +1 -1
- package/lib/components/Checkbox.js.map +2 -2
- package/lib/components/ContextMenu.d.ts +4 -0
- package/lib/components/ContextMenu.js +23 -7
- package/lib/components/ContextMenu.js.map +2 -2
- package/lib/components/DatePicker.d.ts +40 -40
- package/lib/components/DateRangePicker.d.ts +40 -40
- package/lib/components/Form.d.ts +22 -0
- package/lib/components/Form.js +44 -0
- package/lib/components/Form.js.map +13 -0
- package/lib/components/FormField.d.ts +65 -0
- package/lib/components/FormField.js +48 -0
- package/lib/components/FormField.js.map +13 -0
- package/lib/components/InputBox.d.ts +10 -10
- package/lib/components/InputBox.js +4 -3
- package/lib/components/InputBox.js.map +2 -2
- package/lib/components/InputBoxWithSuggestion.d.ts +280 -0
- package/lib/components/InputBoxWithSuggestion.js +65 -0
- package/lib/components/InputBoxWithSuggestion.js.map +13 -0
- package/lib/components/ListGroup.d.ts +10 -10
- package/lib/components/PickerContainer.d.ts +4 -2
- package/lib/components/PickerContainer.js +28 -5
- package/lib/components/PickerContainer.js.map +2 -2
- package/lib/components/Radios.d.ts +10 -10
- package/lib/components/ResultBox.d.ts +40 -40
- package/lib/components/Select.d.ts +195 -202
- package/lib/components/Select.js +7 -3
- package/lib/components/Select.js.map +2 -2
- package/lib/components/Textarea.d.ts +568 -2
- package/lib/components/Textarea.js +129 -1
- package/lib/components/Textarea.js.map +2 -2
- package/lib/components/Toast.js +11 -9
- package/lib/components/Toast.js.map +2 -2
- package/lib/components/UserSelect.d.ts +500 -0
- package/lib/components/UserSelect.js +559 -0
- package/lib/components/UserSelect.js.map +13 -0
- package/lib/components/UserTabSelect.d.ts +320 -0
- package/lib/components/UserTabSelect.js +163 -0
- package/lib/components/UserTabSelect.js.map +13 -0
- package/lib/components/WithRemoteConfig.d.ts +7 -0
- package/lib/components/WithRemoteConfig.js +17 -11
- package/lib/components/WithRemoteConfig.js.map +2 -2
- package/lib/components/calendar/DaysView.d.ts +26 -1
- package/lib/components/calendar/DaysView.js +60 -19
- package/lib/components/calendar/DaysView.js.map +2 -2
- package/lib/components/calendar/TimeView.d.ts +1 -1
- package/lib/components/calendar/TimeView.js +10 -3
- package/lib/components/calendar/TimeView.js.map +2 -2
- package/lib/components/formula/Picker.js +4 -4
- package/lib/components/formula/Picker.js.map +2 -2
- package/lib/components/icons.d.ts +7 -1
- package/lib/components/icons.js +17 -1
- package/lib/components/icons.js.map +2 -2
- package/lib/components/index.d.ts +2 -1
- package/lib/components/index.js +3 -1
- package/lib/components/index.js.map +2 -2
- package/lib/components/json-schema/Array.d.ts +3 -0
- package/lib/components/json-schema/Array.js +125 -0
- package/lib/components/json-schema/Array.js.map +13 -0
- package/lib/components/json-schema/Item.d.ts +3 -0
- package/lib/components/json-schema/Item.js +34 -0
- package/lib/components/json-schema/Item.js.map +13 -0
- package/lib/components/json-schema/Object.d.ts +3 -0
- package/lib/components/json-schema/Object.js +178 -0
- package/lib/components/json-schema/Object.js.map +13 -0
- package/lib/components/json-schema/index.d.ts +279 -0
- package/lib/components/json-schema/index.js +16 -0
- package/lib/components/json-schema/index.js.map +13 -0
- package/lib/components/schema-editor/Array.js +2 -2
- package/lib/components/schema-editor/Array.js.map +2 -2
- package/lib/components/schema-editor/Common.d.ts +2 -0
- package/lib/components/schema-editor/Common.js +39 -3
- package/lib/components/schema-editor/Common.js.map +2 -2
- package/lib/components/schema-editor/Object.js +2 -2
- package/lib/components/schema-editor/Object.js.map +2 -2
- package/lib/components/schema-editor/index.d.ts +45 -41
- package/lib/components/schema-editor/index.js +5 -5
- package/lib/components/schema-editor/index.js.map +2 -2
- package/lib/helper.css +125 -124
- package/lib/helper.css.map +1 -1
- package/lib/hooks/use-validation-resolver.d.ts +1 -0
- package/lib/hooks/use-validation-resolver.js +49 -0
- package/lib/hooks/use-validation-resolver.js.map +13 -0
- package/lib/icons/department.js +17 -0
- package/lib/icons/menu.js +9 -0
- package/lib/icons/post.js +15 -0
- package/lib/icons/role.js +14 -0
- package/lib/icons/user-remove.js +12 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -1
- package/lib/index.js.map +2 -2
- package/lib/locale/de-DE.js +11 -1
- package/lib/locale/de-DE.js.map +2 -2
- package/lib/locale/en-US.js +12 -1
- package/lib/locale/en-US.js.map +2 -2
- package/lib/locale/zh-CN.js +14 -3
- package/lib/locale/zh-CN.js.map +2 -2
- package/lib/renderers/Action.js +25 -11
- package/lib/renderers/Action.js.map +2 -2
- package/lib/renderers/CRUD.js +5 -1
- package/lib/renderers/CRUD.js.map +2 -2
- package/lib/renderers/Dialog.js +9 -3
- package/lib/renderers/Dialog.js.map +2 -2
- package/lib/renderers/Drawer.js +5 -1
- package/lib/renderers/Drawer.js.map +2 -2
- package/lib/renderers/Form/InputDate.d.ts +2 -2
- package/lib/renderers/Form/InputDate.js.map +2 -2
- package/lib/renderers/Form/InputFile.js +5 -12
- package/lib/renderers/Form/InputFile.js.map +2 -2
- package/lib/renderers/Form/InputText.d.ts +1 -1
- package/lib/renderers/Form/InputText.js.map +1 -1
- package/lib/renderers/Form/JSONSchema.d.ts +23 -0
- package/lib/renderers/Form/JSONSchema.js +44 -0
- package/lib/renderers/Form/JSONSchema.js.map +13 -0
- package/lib/renderers/Form/JSONSchemaEditor.d.ts +2 -3
- package/lib/renderers/Form/JSONSchemaEditor.js +9 -24
- package/lib/renderers/Form/JSONSchemaEditor.js.map +2 -2
- package/lib/renderers/Form/Textarea.d.ts +1 -8
- package/lib/renderers/Form/Textarea.js +11 -75
- package/lib/renderers/Form/Textarea.js.map +2 -2
- package/lib/renderers/Form/UserSelect.d.ts +54 -0
- package/lib/renderers/Form/UserSelect.js +197 -0
- package/lib/renderers/Form/UserSelect.js.map +13 -0
- package/lib/renderers/Form/index.d.ts +1 -1
- package/lib/renderers/Form/index.js +88 -42
- package/lib/renderers/Form/index.js.map +2 -2
- package/lib/renderers/Link.d.ts +1 -1
- package/lib/renderers/Link.js +15 -29
- package/lib/renderers/Link.js.map +2 -2
- package/lib/renderers/Log.d.ts +28 -0
- package/lib/renderers/Log.js +110 -20
- package/lib/renderers/Log.js.map +2 -2
- package/lib/renderers/Page.js +5 -1
- package/lib/renderers/Page.js.map +2 -2
- package/lib/renderers/Service.js +5 -1
- package/lib/renderers/Service.js.map +2 -2
- package/lib/renderers/Wizard.js +37 -14
- package/lib/renderers/Wizard.js.map +2 -2
- package/lib/store/form.js +65 -45
- package/lib/store/form.js.map +2 -2
- package/lib/themes/ang-ie11.css +576 -24
- package/lib/themes/ang.css +553 -12
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +576 -24
- package/lib/themes/antd.css +553 -12
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +576 -24
- package/lib/themes/cxd.css +553 -12
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +576 -24
- package/lib/themes/dark.css +553 -12
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +576 -24
- package/lib/themes/default.css +553 -12
- package/lib/themes/default.css.map +1 -1
- package/lib/utils/api.js +1 -1
- package/lib/utils/api.js.map +2 -2
- package/lib/utils/renderer-event.js.map +2 -2
- package/package.json +2 -1
- package/schema.json +542 -4
- package/scss/_properties.scss +20 -8
- package/scss/components/_input-box.scss +22 -1
- package/scss/components/_json-schema.scss +124 -0
- package/scss/components/_log.scss +37 -5
- package/scss/components/form/_date-range.scss +1 -0
- package/scss/components/form/_select.scss +9 -0
- package/scss/components/form/_transfer.scss +19 -3
- package/scss/components/form/_user-select.scss +422 -0
- package/scss/helper/background/_background-color.scss +125 -124
- package/scss/themes/_common.scss +2 -0
- package/sdk/ang-ie11.css +670 -24
- package/sdk/ang.css +647 -12
- package/sdk/antd-ie11.css +670 -24
- package/sdk/antd.css +647 -12
- 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 +670 -24
- package/sdk/cxd.css +647 -12
- package/sdk/dark-ie11.css +670 -24
- package/sdk/dark.css +647 -12
- package/sdk/exceljs.js +1 -1
- package/sdk/helper.css +125 -124
- package/sdk/helper.css.map +1 -1
- package/sdk/locale/de-DE.js +11 -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 +670 -24
- package/sdk/sdk.css +647 -12
- package/sdk/sdk.js +1651 -1637
- 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/RootRenderer.tsx +27 -15
- package/src/Schema.ts +5 -1
- package/src/actions/Action.ts +5 -4
- package/src/components/Button.tsx +3 -0
- package/src/components/Checkbox.tsx +2 -1
- package/src/components/ContextMenu.tsx +25 -7
- package/src/components/Form.tsx +70 -0
- package/src/components/FormField.tsx +127 -0
- package/src/components/InputBox.tsx +4 -1
- package/src/components/InputBoxWithSuggestion.tsx +113 -0
- package/src/components/PickerContainer.tsx +20 -5
- package/src/components/Select.tsx +18 -10
- package/src/components/Textarea.tsx +234 -2
- package/src/components/Toast.tsx +19 -18
- package/src/components/UserSelect.tsx +850 -0
- package/src/components/UserTabSelect.tsx +261 -0
- package/src/components/WithRemoteConfig.tsx +22 -7
- package/src/components/calendar/DaysView.tsx +117 -49
- package/src/components/calendar/TimeView.tsx +11 -6
- package/src/components/formula/Picker.tsx +2 -1
- package/src/components/icons.tsx +17 -1
- package/src/components/index.tsx +3 -1
- package/src/components/json-schema/Array.tsx +216 -0
- package/src/components/json-schema/Item.tsx +47 -0
- package/src/components/json-schema/Object.tsx +339 -0
- package/src/components/json-schema/index.tsx +44 -0
- package/src/components/schema-editor/Array.tsx +3 -1
- package/src/components/schema-editor/Common.tsx +61 -4
- package/src/components/schema-editor/Object.tsx +3 -1
- package/src/components/schema-editor/index.tsx +12 -5
- package/src/hooks/use-validation-resolver.ts +45 -0
- package/src/icons/department.svg +17 -0
- package/src/icons/menu.svg +2 -0
- package/src/icons/post.svg +15 -0
- package/src/icons/role.svg +14 -0
- package/src/icons/user-remove.svg +12 -0
- package/src/index.tsx +2 -0
- package/src/locale/de-DE.ts +11 -1
- package/src/locale/en-US.ts +12 -1
- package/src/locale/zh-CN.ts +14 -3
- package/src/renderers/Action.tsx +10 -9
- package/src/renderers/CRUD.tsx +5 -1
- package/src/renderers/Dialog.tsx +9 -3
- package/src/renderers/Drawer.tsx +5 -1
- package/src/renderers/Form/InputDate.tsx +9 -4
- package/src/renderers/Form/InputFile.tsx +5 -15
- package/src/renderers/Form/InputText.tsx +1 -1
- package/src/renderers/Form/JSONSchema.tsx +56 -0
- package/src/renderers/Form/JSONSchemaEditor.tsx +8 -27
- package/src/renderers/Form/Textarea.tsx +7 -117
- package/src/renderers/Form/UserSelect.tsx +263 -0
- package/src/renderers/Form/index.tsx +28 -18
- package/src/renderers/Link.tsx +5 -17
- package/src/renderers/Log.tsx +213 -19
- package/src/renderers/Page.tsx +6 -1
- package/src/renderers/Service.tsx +5 -1
- package/src/renderers/Wizard.tsx +24 -10
- package/src/store/form.ts +24 -17
- package/src/utils/api.ts +1 -1
- package/src/utils/renderer-event.ts +0 -2
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
} from '../../utils/tpl-builtin';
|
|
9
9
|
import moment from 'moment';
|
|
10
10
|
import 'moment/locale/zh-cn';
|
|
11
|
-
import DatePicker, {
|
|
11
|
+
import DatePicker, {
|
|
12
|
+
DatePicker as BaseDatePicker
|
|
13
|
+
} from '../../components/DatePicker';
|
|
12
14
|
import {SchemaObject} from '../../Schema';
|
|
13
15
|
import {createObject, anyChanged, isMobile, autobind} from '../../utils/helper';
|
|
14
16
|
import {Action} from '../../types';
|
|
@@ -134,7 +136,7 @@ export interface DateTimeControlSchema extends InputDateBaseControlSchema {
|
|
|
134
136
|
maxDate?: string;
|
|
135
137
|
|
|
136
138
|
/**
|
|
137
|
-
*
|
|
139
|
+
* 时间输入范围限制
|
|
138
140
|
*/
|
|
139
141
|
timeConstraints?: any;
|
|
140
142
|
}
|
|
@@ -169,7 +171,7 @@ export interface TimeControlSchema extends InputDateBaseControlSchema {
|
|
|
169
171
|
timeFormat?: string;
|
|
170
172
|
|
|
171
173
|
/**
|
|
172
|
-
*
|
|
174
|
+
* 时间输入范围限制
|
|
173
175
|
*/
|
|
174
176
|
timeConstraints?: any;
|
|
175
177
|
}
|
|
@@ -445,7 +447,10 @@ export default class DateControl extends React.PureComponent<
|
|
|
445
447
|
@autobind
|
|
446
448
|
async handleChange(nextValue: any) {
|
|
447
449
|
const {dispatchEvent, data} = this.props;
|
|
448
|
-
const dispatcher = dispatchEvent(
|
|
450
|
+
const dispatcher = dispatchEvent(
|
|
451
|
+
'change',
|
|
452
|
+
createObject(data, {value: nextValue})
|
|
453
|
+
);
|
|
449
454
|
if (dispatcher?.prevented) {
|
|
450
455
|
return;
|
|
451
456
|
}
|
|
@@ -1045,16 +1045,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
|
1045
1045
|
while (tasks.length) {
|
|
1046
1046
|
const res = await Promise.all(
|
|
1047
1047
|
tasks.splice(0, concurrency).map(async task => {
|
|
1048
|
-
return await uploadPartFile(state, config)(
|
|
1049
|
-
task,
|
|
1050
|
-
(err: any, value: any) => {
|
|
1051
|
-
if (err) {
|
|
1052
|
-
reject(err);
|
|
1053
|
-
throw new Error(err);
|
|
1054
|
-
}
|
|
1055
|
-
return value;
|
|
1056
|
-
}
|
|
1057
|
-
);
|
|
1048
|
+
return await uploadPartFile(state, config)(task);
|
|
1058
1049
|
})
|
|
1059
1050
|
);
|
|
1060
1051
|
results = results.concat(res);
|
|
@@ -1104,7 +1095,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
|
1104
1095
|
}
|
|
1105
1096
|
|
|
1106
1097
|
function uploadPartFile(state: ObjectState, conf: Partial<FileProps>) {
|
|
1107
|
-
return (task: Task
|
|
1098
|
+
return (task: Task) => {
|
|
1108
1099
|
const api = buildApi(
|
|
1109
1100
|
conf.chunkApi!,
|
|
1110
1101
|
createObject(config.data, params),
|
|
@@ -1137,12 +1128,11 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|
|
1137
1128
|
)
|
|
1138
1129
|
.then(ret => {
|
|
1139
1130
|
state.loaded++;
|
|
1140
|
-
|
|
1131
|
+
return {
|
|
1141
1132
|
partNumber: task.partNumber,
|
|
1142
1133
|
eTag: (ret.data as any).eTag
|
|
1143
|
-
}
|
|
1144
|
-
})
|
|
1145
|
-
.catch(callback);
|
|
1134
|
+
};
|
|
1135
|
+
});
|
|
1146
1136
|
};
|
|
1147
1137
|
}
|
|
1148
1138
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {FormItem, FormControlProps, FormBaseControl} from './Item';
|
|
3
|
+
import {autobind, isObjectShallowModified} from '../../utils/helper';
|
|
4
|
+
import InputJSONSchema from '../../components/json-schema/index';
|
|
5
|
+
import {
|
|
6
|
+
isPureVariable,
|
|
7
|
+
resolveVariableAndFilter
|
|
8
|
+
} from '../../utils/tpl-builtin';
|
|
9
|
+
import {isApiOutdated, isEffectiveApi} from '../../utils/api';
|
|
10
|
+
import {withRemoteConfig} from '../../components/WithRemoteConfig';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* JSON Schema
|
|
14
|
+
* 文档:https://baidu.gitee.io/amis/docs/components/form/json-schema
|
|
15
|
+
*/
|
|
16
|
+
export interface JSONSchemaControlSchema extends FormBaseControl {
|
|
17
|
+
/**
|
|
18
|
+
* 指定为 JSON Schema
|
|
19
|
+
*/
|
|
20
|
+
type: 'json-schema';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* json-schema 详情,支持关联上下文数据
|
|
24
|
+
*/
|
|
25
|
+
schema?: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface JSONSchemaProps
|
|
29
|
+
extends FormControlProps,
|
|
30
|
+
Omit<
|
|
31
|
+
JSONSchemaControlSchema,
|
|
32
|
+
'type' | 'className' | 'descriptionClassName' | 'inputClassName'
|
|
33
|
+
> {}
|
|
34
|
+
|
|
35
|
+
const EnhancedInputJSONSchema = withRemoteConfig({
|
|
36
|
+
sourceField: 'schema',
|
|
37
|
+
injectedPropsFilter: props => {
|
|
38
|
+
return {
|
|
39
|
+
schema: props.config,
|
|
40
|
+
loading: props.loading
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
})(InputJSONSchema as any);
|
|
44
|
+
export default class JSONSchemaControl extends React.PureComponent<JSONSchemaProps> {
|
|
45
|
+
render() {
|
|
46
|
+
const {...rest} = this.props;
|
|
47
|
+
|
|
48
|
+
return <EnhancedInputJSONSchema {...rest} />;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@FormItem({
|
|
53
|
+
type: 'json-schema',
|
|
54
|
+
strictMode: false
|
|
55
|
+
})
|
|
56
|
+
export class JSONSchemaRenderer extends JSONSchemaControl {}
|
|
@@ -22,7 +22,7 @@ export interface JSONSchemaEditorControlSchema extends FormBaseControl {
|
|
|
22
22
|
type:
|
|
23
23
|
| 'string'
|
|
24
24
|
| 'number'
|
|
25
|
-
| '
|
|
25
|
+
| 'integer'
|
|
26
26
|
| 'object'
|
|
27
27
|
| 'array'
|
|
28
28
|
| 'boolean'
|
|
@@ -79,39 +79,21 @@ export default class JSONSchemaEditorControl extends React.PureComponent<JSONSch
|
|
|
79
79
|
enableAdvancedSetting: false
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
-
// todo 完善这块配置
|
|
83
|
-
settings: any = {
|
|
84
|
-
common: [
|
|
85
|
-
{
|
|
86
|
-
type: 'input-text',
|
|
87
|
-
name: 'title',
|
|
88
|
-
label: this.props.translate('JSONSchema.title')
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
type: 'textarea',
|
|
93
|
-
name: 'description',
|
|
94
|
-
label: this.props.translate('JSONSchema.description')
|
|
95
|
-
}
|
|
96
|
-
]
|
|
97
|
-
};
|
|
98
|
-
|
|
99
82
|
@autobind
|
|
100
|
-
renderModalProps(
|
|
83
|
+
renderModalProps(value: any, onChange: (value: any) => void) {
|
|
101
84
|
const {render, advancedSettings} = this.props;
|
|
85
|
+
const fields = advancedSettings?.[value?.type] || [];
|
|
102
86
|
return render(
|
|
103
87
|
`modal`,
|
|
104
88
|
{
|
|
105
89
|
type: 'form',
|
|
106
90
|
wrapWithPanel: false,
|
|
107
|
-
body:
|
|
108
|
-
|
|
109
|
-
...(advancedSettings?.[value?.type] || [])
|
|
110
|
-
]
|
|
91
|
+
body: fields,
|
|
92
|
+
submitOnChange: true
|
|
111
93
|
},
|
|
112
94
|
{
|
|
113
95
|
data: value,
|
|
114
|
-
|
|
96
|
+
onSubmit: (value: any) => onChange(value)
|
|
115
97
|
}
|
|
116
98
|
);
|
|
117
99
|
}
|
|
@@ -122,9 +104,8 @@ export default class JSONSchemaEditorControl extends React.PureComponent<JSONSch
|
|
|
122
104
|
return (
|
|
123
105
|
<JSONSchemaEditor
|
|
124
106
|
{...rest}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
107
|
+
enableAdvancedSetting={enableAdvancedSetting}
|
|
108
|
+
renderModalProps={this.renderModalProps}
|
|
128
109
|
/>
|
|
129
110
|
);
|
|
130
111
|
}
|
|
@@ -86,60 +86,22 @@ export default class TextAreaControl extends React.Component<
|
|
|
86
86
|
clearable: false
|
|
87
87
|
};
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
focused: false
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
input?: HTMLInputElement;
|
|
94
|
-
inputRef = (ref: any) => (this.input = findDOMNode(ref) as HTMLInputElement);
|
|
89
|
+
inputRef = React.createRef<any>();
|
|
95
90
|
|
|
96
91
|
doAction(action: ListenerAction, args: any) {
|
|
97
92
|
const actionType = action?.actionType as string;
|
|
93
|
+
const onChange = this.props.onChange;
|
|
98
94
|
|
|
99
95
|
if (!!~['clear', 'reset'].indexOf(actionType)) {
|
|
100
|
-
this.
|
|
96
|
+
onChange?.(this.props.resetValue);
|
|
97
|
+
this.focus();
|
|
101
98
|
} else if (actionType === 'focus') {
|
|
102
99
|
this.focus();
|
|
103
100
|
}
|
|
104
101
|
}
|
|
105
102
|
|
|
106
|
-
valueToString(value: any) {
|
|
107
|
-
return typeof value === 'undefined' || value === null
|
|
108
|
-
? ''
|
|
109
|
-
: typeof value === 'string'
|
|
110
|
-
? value
|
|
111
|
-
: JSON.stringify(value);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
103
|
focus() {
|
|
115
|
-
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
this.setState(
|
|
120
|
-
{
|
|
121
|
-
focused: true
|
|
122
|
-
},
|
|
123
|
-
() => {
|
|
124
|
-
if (!this.input) {
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
this.input.focus();
|
|
129
|
-
|
|
130
|
-
// 光标放到最后
|
|
131
|
-
const len = this.input.value.length;
|
|
132
|
-
len && this.input.setSelectionRange(len, len);
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
@autobind
|
|
138
|
-
handleChange(e: React.ChangeEvent<HTMLTextAreaElement>) {
|
|
139
|
-
const {onChange} = this.props;
|
|
140
|
-
let value = e.currentTarget.value;
|
|
141
|
-
|
|
142
|
-
onChange?.(value);
|
|
104
|
+
this.inputRef.current?.focus();
|
|
143
105
|
}
|
|
144
106
|
|
|
145
107
|
@autobind
|
|
@@ -176,83 +138,11 @@ export default class TextAreaControl extends React.Component<
|
|
|
176
138
|
);
|
|
177
139
|
}
|
|
178
140
|
|
|
179
|
-
@autobind
|
|
180
|
-
async handleClear() {
|
|
181
|
-
const {onChange, resetValue} = this.props;
|
|
182
|
-
|
|
183
|
-
onChange?.(resetValue);
|
|
184
|
-
this.focus();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
141
|
render() {
|
|
188
|
-
const {
|
|
189
|
-
className,
|
|
190
|
-
classPrefix: ns,
|
|
191
|
-
value,
|
|
192
|
-
type,
|
|
193
|
-
placeholder,
|
|
194
|
-
disabled,
|
|
195
|
-
minRows,
|
|
196
|
-
maxRows,
|
|
197
|
-
readOnly,
|
|
198
|
-
name,
|
|
199
|
-
borderMode,
|
|
200
|
-
classnames: cx,
|
|
201
|
-
maxLength,
|
|
202
|
-
showCounter,
|
|
203
|
-
clearable
|
|
204
|
-
} = this.props;
|
|
205
|
-
const counter = showCounter ? this.valueToString(value).length : 0;
|
|
142
|
+
const {...rest} = this.props;
|
|
206
143
|
|
|
207
144
|
return (
|
|
208
|
-
<
|
|
209
|
-
className={cx(
|
|
210
|
-
`TextareaControl`,
|
|
211
|
-
{
|
|
212
|
-
[`TextareaControl--border${ucFirst(borderMode)}`]: borderMode,
|
|
213
|
-
'is-focused': this.state.focused,
|
|
214
|
-
'is-disabled': disabled
|
|
215
|
-
},
|
|
216
|
-
className
|
|
217
|
-
)}
|
|
218
|
-
>
|
|
219
|
-
<Textarea
|
|
220
|
-
className={cx(`TextareaControl-input`)}
|
|
221
|
-
autoComplete="off"
|
|
222
|
-
ref={this.inputRef}
|
|
223
|
-
name={name}
|
|
224
|
-
disabled={disabled}
|
|
225
|
-
value={this.valueToString(value)}
|
|
226
|
-
placeholder={placeholder}
|
|
227
|
-
autoCorrect="off"
|
|
228
|
-
spellCheck="false"
|
|
229
|
-
readOnly={readOnly}
|
|
230
|
-
minRows={minRows || undefined}
|
|
231
|
-
maxRows={maxRows || undefined}
|
|
232
|
-
onChange={this.handleChange}
|
|
233
|
-
onFocus={this.handleFocus}
|
|
234
|
-
onBlur={this.handleBlur}
|
|
235
|
-
/>
|
|
236
|
-
|
|
237
|
-
{clearable && !disabled && value ? (
|
|
238
|
-
<a onClick={this.handleClear} className={cx('TextareaControl-clear')}>
|
|
239
|
-
<Icon icon="input-clear" className="icon" />
|
|
240
|
-
</a>
|
|
241
|
-
) : null}
|
|
242
|
-
|
|
243
|
-
{showCounter ? (
|
|
244
|
-
<span
|
|
245
|
-
className={cx('TextareaControl-counter', {
|
|
246
|
-
'is-empty': counter === 0,
|
|
247
|
-
'is-clearable': clearable && !disabled && value
|
|
248
|
-
})}
|
|
249
|
-
>
|
|
250
|
-
{`${counter}${
|
|
251
|
-
typeof maxLength === 'number' && maxLength ? `/${maxLength}` : ''
|
|
252
|
-
}`}
|
|
253
|
-
</span>
|
|
254
|
-
) : null}
|
|
255
|
-
</div>
|
|
145
|
+
<Textarea {...rest} onFocus={this.handleFocus} onBlur={this.handleBlur} />
|
|
256
146
|
);
|
|
257
147
|
}
|
|
258
148
|
}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cx from 'classnames';
|
|
3
|
+
import {
|
|
4
|
+
OptionsControl,
|
|
5
|
+
OptionsControlProps,
|
|
6
|
+
Option,
|
|
7
|
+
FormOptionsControl
|
|
8
|
+
} from './Options';
|
|
9
|
+
import UserSelect from '../../components/UserSelect';
|
|
10
|
+
import UserTabSelect from '../../components/UserTabSelect';
|
|
11
|
+
import {isEffectiveApi} from '../../utils/api';
|
|
12
|
+
import find from 'lodash/find';
|
|
13
|
+
import {createObject, autobind} from '../../utils/helper';
|
|
14
|
+
import {PlainObject} from '../../types';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* UserSelect 移动端人员选择。
|
|
18
|
+
*/
|
|
19
|
+
export interface UserSelectControlSchema extends FormOptionsControl {
|
|
20
|
+
type: 'users-select';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface UserSelectProps extends OptionsControlProps {
|
|
24
|
+
/**
|
|
25
|
+
* 部门可选
|
|
26
|
+
*/
|
|
27
|
+
isDep?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 人员可选
|
|
30
|
+
*/
|
|
31
|
+
isRef?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
showNav?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* 导航头标题
|
|
38
|
+
*/
|
|
39
|
+
navTitle?: string;
|
|
40
|
+
/**
|
|
41
|
+
* 选项卡模式
|
|
42
|
+
*/
|
|
43
|
+
tabMode?: boolean;
|
|
44
|
+
tabOptions?: Array<any>;
|
|
45
|
+
/**
|
|
46
|
+
* 搜索字段
|
|
47
|
+
*/
|
|
48
|
+
searchTerm?: string;
|
|
49
|
+
/**
|
|
50
|
+
* 搜索携带的额外参数
|
|
51
|
+
*/
|
|
52
|
+
searchParam?: PlainObject;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export default class UserSelectControl extends React.Component<
|
|
56
|
+
UserSelectProps,
|
|
57
|
+
any
|
|
58
|
+
> {
|
|
59
|
+
static defaultProps: Partial<UserSelectProps> = {
|
|
60
|
+
showNav: true
|
|
61
|
+
};
|
|
62
|
+
input?: HTMLInputElement;
|
|
63
|
+
unHook: Function;
|
|
64
|
+
lazyloadRemote: Function;
|
|
65
|
+
|
|
66
|
+
constructor(props: UserSelectProps) {
|
|
67
|
+
super(props);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
componentWillUnmount() {
|
|
71
|
+
this.unHook && this.unHook();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@autobind
|
|
75
|
+
async onSearch(input: string, cancelExecutor: Function, param?: PlainObject) {
|
|
76
|
+
let {searchApi, setLoading, env} = this.props;
|
|
77
|
+
searchApi = param?.searchApi || searchApi;
|
|
78
|
+
let searchTerm = param?.searchTerm || this.props.searchTerm || 'term';
|
|
79
|
+
let searchObj = param?.searchParam || this.props.searchParam || {};
|
|
80
|
+
|
|
81
|
+
const ctx = {
|
|
82
|
+
[searchTerm]: input,
|
|
83
|
+
...searchObj
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (!isEffectiveApi(searchApi, ctx)) {
|
|
87
|
+
return Promise.resolve([]);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
setLoading(true);
|
|
91
|
+
try {
|
|
92
|
+
const ret = await env.fetcher(searchApi, ctx, {
|
|
93
|
+
cancelExecutor,
|
|
94
|
+
autoAppend: true
|
|
95
|
+
});
|
|
96
|
+
let options = (ret.data && (ret.data as any).options) || ret.data || [];
|
|
97
|
+
|
|
98
|
+
return options;
|
|
99
|
+
} finally {
|
|
100
|
+
setLoading(false);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@autobind
|
|
105
|
+
async deferLoad(data?: Object, isRef?: boolean, param?: PlainObject) {
|
|
106
|
+
let {env, deferApi, setLoading, formInited, addHook} = this.props;
|
|
107
|
+
|
|
108
|
+
deferApi = param?.deferApi || deferApi;
|
|
109
|
+
|
|
110
|
+
if (!env || !env.fetcher) {
|
|
111
|
+
throw new Error('fetcher is required');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const ctx = createObject(data, {});
|
|
115
|
+
|
|
116
|
+
if (!isEffectiveApi(deferApi, ctx)) {
|
|
117
|
+
return Promise.resolve([]);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
const ret = await env.fetcher(deferApi, ctx);
|
|
122
|
+
|
|
123
|
+
let options = (ret.data && (ret.data as any).options) || ret.data || [];
|
|
124
|
+
|
|
125
|
+
if (isRef) {
|
|
126
|
+
options.forEach((option: Option) => {
|
|
127
|
+
option.isRef = true;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
return options;
|
|
131
|
+
} finally {
|
|
132
|
+
setLoading(false);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
@autobind
|
|
137
|
+
async changeValue(value: Option | Array<Option> | string | void) {
|
|
138
|
+
const {
|
|
139
|
+
joinValues,
|
|
140
|
+
extractValue,
|
|
141
|
+
delimiter,
|
|
142
|
+
multiple,
|
|
143
|
+
valueField,
|
|
144
|
+
onChange,
|
|
145
|
+
options,
|
|
146
|
+
setOptions,
|
|
147
|
+
data,
|
|
148
|
+
dispatchEvent
|
|
149
|
+
} = this.props;
|
|
150
|
+
let newValue: string | Option | Array<Option> | void = value;
|
|
151
|
+
let additonalOptions: Array<any> = [];
|
|
152
|
+
(Array.isArray(value) ? value : value ? [value] : []).forEach(
|
|
153
|
+
(option: any) => {
|
|
154
|
+
let resolved = find(
|
|
155
|
+
options,
|
|
156
|
+
(item: any) =>
|
|
157
|
+
item[valueField || 'value'] == option[valueField || 'value']
|
|
158
|
+
);
|
|
159
|
+
resolved || additonalOptions.push(option);
|
|
160
|
+
}
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
if (joinValues) {
|
|
164
|
+
if (multiple) {
|
|
165
|
+
newValue = Array.isArray(value)
|
|
166
|
+
? (value
|
|
167
|
+
.map(item => item[valueField || 'value'])
|
|
168
|
+
.join(delimiter) as string)
|
|
169
|
+
: value
|
|
170
|
+
? (value as Option)[valueField || 'value']
|
|
171
|
+
: '';
|
|
172
|
+
} else {
|
|
173
|
+
newValue = newValue ? (newValue as Option)[valueField || 'value'] : '';
|
|
174
|
+
}
|
|
175
|
+
} else if (extractValue) {
|
|
176
|
+
if (multiple) {
|
|
177
|
+
newValue = Array.isArray(value)
|
|
178
|
+
? value.map(item => item[valueField || 'value'])
|
|
179
|
+
: value
|
|
180
|
+
? [(value as Option)[valueField || 'value']]
|
|
181
|
+
: [];
|
|
182
|
+
} else {
|
|
183
|
+
newValue = newValue ? (newValue as Option)[valueField || 'value'] : '';
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const rendererEvent = await dispatchEvent(
|
|
188
|
+
'change',
|
|
189
|
+
createObject(data, {
|
|
190
|
+
value: newValue,
|
|
191
|
+
options
|
|
192
|
+
})
|
|
193
|
+
);
|
|
194
|
+
if (rendererEvent?.prevented) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
onChange(newValue);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
render() {
|
|
202
|
+
let {
|
|
203
|
+
showNav,
|
|
204
|
+
navTitle,
|
|
205
|
+
searchable,
|
|
206
|
+
options,
|
|
207
|
+
className,
|
|
208
|
+
selectedOptions,
|
|
209
|
+
tabOptions,
|
|
210
|
+
multi,
|
|
211
|
+
multiple,
|
|
212
|
+
isDep,
|
|
213
|
+
isRef,
|
|
214
|
+
placeholder,
|
|
215
|
+
searchPlaceholder,
|
|
216
|
+
tabMode,
|
|
217
|
+
data
|
|
218
|
+
} = this.props;
|
|
219
|
+
tabOptions?.forEach((item: any) => {
|
|
220
|
+
item.deferLoad = this.deferLoad;
|
|
221
|
+
item.onChange = this.changeValue;
|
|
222
|
+
item.onSearch = this.onSearch;
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div className={cx(`UserSelectControl`, className)}>
|
|
227
|
+
{tabMode ? (
|
|
228
|
+
<UserTabSelect
|
|
229
|
+
selection={selectedOptions}
|
|
230
|
+
tabOptions={tabOptions}
|
|
231
|
+
multiple={multiple}
|
|
232
|
+
onChange={this.changeValue}
|
|
233
|
+
onSearch={this.onSearch}
|
|
234
|
+
deferLoad={this.deferLoad}
|
|
235
|
+
data={data}
|
|
236
|
+
/>
|
|
237
|
+
) : (
|
|
238
|
+
<UserSelect
|
|
239
|
+
showNav={showNav}
|
|
240
|
+
navTitle={navTitle}
|
|
241
|
+
selection={selectedOptions}
|
|
242
|
+
options={options}
|
|
243
|
+
multi={multi}
|
|
244
|
+
multiple={multiple}
|
|
245
|
+
searchable={searchable}
|
|
246
|
+
placeholder={placeholder}
|
|
247
|
+
searchPlaceholder={searchPlaceholder}
|
|
248
|
+
deferLoad={this.deferLoad}
|
|
249
|
+
onChange={this.changeValue}
|
|
250
|
+
onSearch={this.onSearch}
|
|
251
|
+
isDep={isDep}
|
|
252
|
+
isRef={isRef}
|
|
253
|
+
/>
|
|
254
|
+
)}
|
|
255
|
+
</div>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
@OptionsControl({
|
|
261
|
+
type: 'users-select'
|
|
262
|
+
})
|
|
263
|
+
export class UserSelectControlRenderer extends UserSelectControl {}
|