amis 1.9.1-beta.1 → 1.9.1-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- 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/components/Alert2.d.ts +10 -10
- 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/SearchBox.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 +48 -14
- package/lib/components/calendar/DaysView.js.map +2 -2
- package/lib/components/calendar/TimeView.d.ts +1 -1
- package/lib/components/calendar/TimeView.js +8 -2
- package/lib/components/calendar/TimeView.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/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/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/Log.d.ts +13 -1
- package/lib/renderers/Log.js +82 -16
- 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 +561 -21
- package/lib/themes/ang.css +538 -9
- package/lib/themes/ang.css.map +1 -1
- package/lib/themes/antd-ie11.css +561 -21
- package/lib/themes/antd.css +538 -9
- package/lib/themes/antd.css.map +1 -1
- package/lib/themes/cxd-ie11.css +561 -21
- package/lib/themes/cxd.css +538 -9
- package/lib/themes/cxd.css.map +1 -1
- package/lib/themes/dark-ie11.css +561 -21
- package/lib/themes/dark.css +538 -9
- package/lib/themes/dark.css.map +1 -1
- package/lib/themes/default-ie11.css +561 -21
- package/lib/themes/default.css +538 -9
- 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 +539 -3
- 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/_user-select.scss +422 -0
- package/scss/themes/_common.scss +2 -0
- package/sdk/ang-ie11.css +651 -21
- package/sdk/ang.css +628 -9
- package/sdk/antd-ie11.css +651 -21
- package/sdk/antd.css +628 -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 +651 -21
- package/sdk/cxd.css +628 -9
- package/sdk/dark-ie11.css +651 -21
- package/sdk/dark.css +628 -9
- package/sdk/exceljs.js +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 +651 -21
- package/sdk/sdk.css +628 -9
- package/sdk/sdk.js +1655 -1643
- 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/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 +53 -16
- package/src/components/calendar/TimeView.tsx +10 -5
- 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/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/Log.tsx +148 -13
- 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
@@ -0,0 +1,261 @@
|
|
1
|
+
/**
|
2
|
+
* @file 移动端人员、部门、角色、岗位选择
|
3
|
+
* @author fex
|
4
|
+
*/
|
5
|
+
|
6
|
+
import React from 'react';
|
7
|
+
import {themeable, ThemeProps} from '../theme';
|
8
|
+
import {LocaleProps, localeable} from '../locale';
|
9
|
+
import {ResultBox} from '../components';
|
10
|
+
import UserSelect from './UserSelect';
|
11
|
+
import {Option} from '../renderers/Form/Options';
|
12
|
+
import Sortable from 'sortablejs';
|
13
|
+
import PopUp from '../components/PopUp';
|
14
|
+
import {Icon} from '../components/icons';
|
15
|
+
import {autobind, findTree} from '../utils/helper';
|
16
|
+
import {default as Tabs, Tab} from './Tabs';
|
17
|
+
import {UserSelectProps} from './UserSelect';
|
18
|
+
import {PlainObject} from '../types';
|
19
|
+
import {resolveVariableAndFilter} from '../utils/tpl-builtin';
|
20
|
+
|
21
|
+
export interface UserSelectTop extends UserSelectProps {
|
22
|
+
title: string;
|
23
|
+
deferApi?: string;
|
24
|
+
searchApi?: string;
|
25
|
+
searchable?: boolean;
|
26
|
+
searchParam?: PlainObject;
|
27
|
+
searchTerm?: string;
|
28
|
+
}
|
29
|
+
export interface UserTabSelectProps extends ThemeProps, LocaleProps {
|
30
|
+
tabOptions?: Array<UserSelectTop>;
|
31
|
+
multiple?: boolean;
|
32
|
+
placeholder?: string;
|
33
|
+
valueField?: string;
|
34
|
+
labelField?: string;
|
35
|
+
selection?: Array<Option>;
|
36
|
+
data?: PlainObject;
|
37
|
+
onChange: (value: Array<Option> | Option) => void;
|
38
|
+
onSearch?: (
|
39
|
+
term: string,
|
40
|
+
cancelExecutor: Function,
|
41
|
+
paramObj?: PlainObject
|
42
|
+
) => Promise<any[]> | undefined;
|
43
|
+
deferLoad: (
|
44
|
+
data?: Object,
|
45
|
+
isRef?: boolean,
|
46
|
+
param?: PlainObject
|
47
|
+
) => Promise<Option[]>;
|
48
|
+
}
|
49
|
+
|
50
|
+
export interface UserTabSelectState {
|
51
|
+
isOpened: boolean;
|
52
|
+
isSearch: boolean;
|
53
|
+
isSelectOpened: boolean;
|
54
|
+
inputValue: string;
|
55
|
+
breadList: Array<any>;
|
56
|
+
options: Array<Option>;
|
57
|
+
tempSelection: Array<Option>;
|
58
|
+
selection: Array<Option>;
|
59
|
+
searchList: Array<Option>;
|
60
|
+
searchLoading: boolean;
|
61
|
+
isEdit: boolean;
|
62
|
+
activeKey: number;
|
63
|
+
}
|
64
|
+
|
65
|
+
export class UserTabSelect extends React.Component<
|
66
|
+
UserTabSelectProps,
|
67
|
+
UserTabSelectState
|
68
|
+
> {
|
69
|
+
cancelSearch?: Function;
|
70
|
+
sortable?: Sortable;
|
71
|
+
unmounted = false;
|
72
|
+
|
73
|
+
constructor(props: UserTabSelectProps) {
|
74
|
+
super(props);
|
75
|
+
this.state = {
|
76
|
+
isOpened: false,
|
77
|
+
isSelectOpened: false,
|
78
|
+
inputValue: '',
|
79
|
+
options: [],
|
80
|
+
breadList: [],
|
81
|
+
searchList: [],
|
82
|
+
tempSelection: [],
|
83
|
+
selection: props.selection ? props.selection : [],
|
84
|
+
isSearch: false,
|
85
|
+
searchLoading: false,
|
86
|
+
isEdit: false,
|
87
|
+
activeKey: 0
|
88
|
+
};
|
89
|
+
}
|
90
|
+
|
91
|
+
static defaultProps = {};
|
92
|
+
|
93
|
+
componentDidMount() {}
|
94
|
+
|
95
|
+
componentDidUpdate(prevProps: UserTabSelectProps) {}
|
96
|
+
|
97
|
+
componentWillUnmount() {
|
98
|
+
this.unmounted = true;
|
99
|
+
}
|
100
|
+
|
101
|
+
@autobind
|
102
|
+
onClose() {
|
103
|
+
this.setState({
|
104
|
+
isOpened: false,
|
105
|
+
isSearch: false,
|
106
|
+
inputValue: '',
|
107
|
+
searchList: [],
|
108
|
+
searchLoading: false,
|
109
|
+
activeKey: 0
|
110
|
+
});
|
111
|
+
}
|
112
|
+
|
113
|
+
@autobind
|
114
|
+
onOpen() {
|
115
|
+
const {selection} = this.state;
|
116
|
+
this.setState({
|
117
|
+
isOpened: true,
|
118
|
+
tempSelection: selection.slice()
|
119
|
+
});
|
120
|
+
}
|
121
|
+
|
122
|
+
@autobind
|
123
|
+
handleBack() {
|
124
|
+
this.onClose();
|
125
|
+
const {onChange} = this.props;
|
126
|
+
onChange(this.state.selection);
|
127
|
+
}
|
128
|
+
|
129
|
+
@autobind
|
130
|
+
handleSelectChange(option: Option | Array<Option>, isReplace?: boolean) {
|
131
|
+
const {multiple, valueField = 'value'} = this.props;
|
132
|
+
let selection = this.state.selection.slice();
|
133
|
+
let selectionVals = selection.map((option: Option) => option[valueField]);
|
134
|
+
if (isReplace && Array.isArray(option)) {
|
135
|
+
selection = option.slice();
|
136
|
+
} else if (!Array.isArray(option)) {
|
137
|
+
let pos = selectionVals.indexOf(option[valueField]);
|
138
|
+
if (pos !== -1) {
|
139
|
+
selection.splice(selection.indexOf(option), 1);
|
140
|
+
} else {
|
141
|
+
if (multiple) {
|
142
|
+
selection.push(option);
|
143
|
+
} else {
|
144
|
+
selection = [option];
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
this.setState({
|
150
|
+
selection: selection
|
151
|
+
});
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
|
155
|
+
@autobind
|
156
|
+
handleTabChange(key: number) {
|
157
|
+
this.setState({
|
158
|
+
activeKey: key
|
159
|
+
});
|
160
|
+
}
|
161
|
+
|
162
|
+
render() {
|
163
|
+
let {
|
164
|
+
classnames: cx,
|
165
|
+
translate: __,
|
166
|
+
onChange,
|
167
|
+
placeholder = '请选择',
|
168
|
+
tabOptions,
|
169
|
+
onSearch,
|
170
|
+
deferLoad,
|
171
|
+
data
|
172
|
+
} = this.props;
|
173
|
+
const {activeKey, isOpened, selection} = this.state;
|
174
|
+
|
175
|
+
return (
|
176
|
+
<div className={cx('UserTabSelect')}>
|
177
|
+
<ResultBox
|
178
|
+
className={cx('UserTabSelect-input', isOpened ? 'is-active' : '')}
|
179
|
+
allowInput={false}
|
180
|
+
result={selection}
|
181
|
+
onResultChange={value => this.handleSelectChange(value, true)}
|
182
|
+
onResultClick={this.onOpen}
|
183
|
+
placeholder={placeholder}
|
184
|
+
useMobileUI
|
185
|
+
/>
|
186
|
+
<PopUp
|
187
|
+
isShow={isOpened}
|
188
|
+
className={cx(`UserTabSelect-popup`)}
|
189
|
+
onHide={this.onClose}
|
190
|
+
showClose={false}
|
191
|
+
>
|
192
|
+
<div className={cx('UserTabSelect-wrap')}>
|
193
|
+
<div className={cx('UserSelect-navbar')}>
|
194
|
+
<span className="left-arrow-box" onClick={this.handleBack}>
|
195
|
+
<Icon icon="left-arrow" className="icon" />
|
196
|
+
</span>
|
197
|
+
<div className={cx('UserSelect-navbar-title')}>人员选择</div>
|
198
|
+
</div>
|
199
|
+
<Tabs
|
200
|
+
mode="tiled"
|
201
|
+
className={cx('UserTabSelect-tabs')}
|
202
|
+
onSelect={this.handleTabChange}
|
203
|
+
activeKey={activeKey}
|
204
|
+
>
|
205
|
+
{tabOptions?.map((item: UserSelectTop, index: number) => {
|
206
|
+
return (
|
207
|
+
<Tab
|
208
|
+
{...this.props}
|
209
|
+
eventKey={index}
|
210
|
+
key={index}
|
211
|
+
title={item.title}
|
212
|
+
className="TabsTransfer-tab"
|
213
|
+
>
|
214
|
+
<UserSelect
|
215
|
+
selection={selection}
|
216
|
+
showResultBox={false}
|
217
|
+
{...item}
|
218
|
+
options={
|
219
|
+
typeof item.options === 'string' && data
|
220
|
+
? resolveVariableAndFilter(
|
221
|
+
item.options,
|
222
|
+
data,
|
223
|
+
'| raw'
|
224
|
+
)
|
225
|
+
: item.options
|
226
|
+
}
|
227
|
+
multiple
|
228
|
+
controlled
|
229
|
+
onChange={this.handleSelectChange}
|
230
|
+
onSearch={(input: string, cancelExecutor: Function) =>
|
231
|
+
item.searchable && onSearch
|
232
|
+
? onSearch(input, cancelExecutor, {
|
233
|
+
searchApi: item.searchApi,
|
234
|
+
searchParam: item.searchParam,
|
235
|
+
searchTerm: item.searchTerm
|
236
|
+
})
|
237
|
+
: undefined
|
238
|
+
}
|
239
|
+
deferLoad={(
|
240
|
+
data?: PlainObject,
|
241
|
+
isRef?: boolean,
|
242
|
+
param?: PlainObject
|
243
|
+
) =>
|
244
|
+
deferLoad(data, isRef, {
|
245
|
+
deferApi: item.deferApi,
|
246
|
+
...(param || {})
|
247
|
+
})
|
248
|
+
}
|
249
|
+
/>
|
250
|
+
</Tab>
|
251
|
+
);
|
252
|
+
})}
|
253
|
+
</Tabs>
|
254
|
+
</div>
|
255
|
+
</PopUp>
|
256
|
+
</div>
|
257
|
+
);
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
export default themeable(localeable(UserTabSelect));
|
@@ -5,7 +5,7 @@
|
|
5
5
|
import React from 'react';
|
6
6
|
import hoistNonReactStatic from 'hoist-non-react-statics';
|
7
7
|
import debounce from 'lodash/debounce';
|
8
|
-
import {Api, Payload} from '../types';
|
8
|
+
import {Api, ApiObject, Payload} from '../types';
|
9
9
|
import {SchemaApi, SchemaTokenizeableString} from '../Schema';
|
10
10
|
import {withStore} from './WithStore';
|
11
11
|
|
@@ -123,6 +123,8 @@ export interface RemoteOptionsProps<T = any> {
|
|
123
123
|
}
|
124
124
|
|
125
125
|
export interface WithRemoteConfigSettings {
|
126
|
+
sourceField?: string;
|
127
|
+
|
126
128
|
/**
|
127
129
|
* 从接口返回数据适配到配置
|
128
130
|
*/
|
@@ -163,6 +165,13 @@ export interface WithRemoteConfigSettings {
|
|
163
165
|
config: any,
|
164
166
|
props: any
|
165
167
|
) => any;
|
168
|
+
|
169
|
+
injectedPropsFilter?: (props: {
|
170
|
+
config: any;
|
171
|
+
loading?: boolean;
|
172
|
+
deferLoad: (term: string) => any;
|
173
|
+
updateConfig: (config: any) => void;
|
174
|
+
}) => any;
|
166
175
|
}
|
167
176
|
|
168
177
|
export function withRemoteConfig<P = any>(
|
@@ -214,7 +223,8 @@ export function withRemoteConfig<P = any>(
|
|
214
223
|
|
215
224
|
componentDidMount() {
|
216
225
|
const env: RendererEnv = this.props.env || this.context;
|
217
|
-
const {store,
|
226
|
+
const {store, data} = this.props;
|
227
|
+
const source = (this.props as any)[config.sourceField || 'source'];
|
218
228
|
|
219
229
|
store.setData(data);
|
220
230
|
|
@@ -233,7 +243,7 @@ export function withRemoteConfig<P = any>(
|
|
233
243
|
);
|
234
244
|
} else if (env && isEffectiveApi(source, data)) {
|
235
245
|
this.loadConfig();
|
236
|
-
source.autoRefresh !== false &&
|
246
|
+
(source as ApiObject).autoRefresh !== false &&
|
237
247
|
this.toDispose.push(
|
238
248
|
reaction(
|
239
249
|
() => {
|
@@ -268,7 +278,8 @@ export function withRemoteConfig<P = any>(
|
|
268
278
|
|
269
279
|
async loadConfig(ctx = this.props.data) {
|
270
280
|
const env: RendererEnv = this.props.env || this.context;
|
271
|
-
const {store
|
281
|
+
const {store} = this.props;
|
282
|
+
const source = (this.props as any)[config.sourceField || 'source'];
|
272
283
|
|
273
284
|
if (env && isEffectiveApi(source, ctx)) {
|
274
285
|
await store.load(env, source, ctx, config);
|
@@ -303,7 +314,8 @@ export function withRemoteConfig<P = any>(
|
|
303
314
|
}
|
304
315
|
|
305
316
|
syncConfig() {
|
306
|
-
const {store,
|
317
|
+
const {store, data} = this.props;
|
318
|
+
const source = (this.props as any)[config.sourceField || 'source'];
|
307
319
|
|
308
320
|
if (isPureVariable(source)) {
|
309
321
|
store.setConfig(
|
@@ -315,7 +327,8 @@ export function withRemoteConfig<P = any>(
|
|
315
327
|
}
|
316
328
|
|
317
329
|
async deferLoadConfig(item: any) {
|
318
|
-
const {store,
|
330
|
+
const {store, data, deferApi} = this.props;
|
331
|
+
const source = (this.props as any)[config.sourceField || 'source'];
|
319
332
|
const env: RendererEnv = this.props.env || this.context;
|
320
333
|
const indexes = findTreeIndex(store.config, a => a === item)!;
|
321
334
|
|
@@ -375,7 +388,9 @@ export function withRemoteConfig<P = any>(
|
|
375
388
|
{...(env && isEffectiveApi(autoComplete) && this.loadOptions
|
376
389
|
? {loadOptions: this.loadOptions}
|
377
390
|
: {})}
|
378
|
-
{...
|
391
|
+
{...(config.injectedPropsFilter
|
392
|
+
? config.injectedPropsFilter(injectedProps)
|
393
|
+
: injectedProps)}
|
379
394
|
/>
|
380
395
|
);
|
381
396
|
}
|
@@ -4,6 +4,7 @@ import moment from 'moment';
|
|
4
4
|
import React from 'react';
|
5
5
|
import Downshift from 'downshift';
|
6
6
|
import findIndex from 'lodash/findIndex';
|
7
|
+
import merge from 'lodash/merge';
|
7
8
|
import {LocaleProps, localeable} from '../../locale';
|
8
9
|
import {ClassNamesFn} from '../../theme';
|
9
10
|
import {isMobile, convertArrayValueToMoment} from '../../utils/helper';
|
@@ -11,6 +12,8 @@ import Picker from '../Picker';
|
|
11
12
|
import {PickerOption} from '../PickerColumn';
|
12
13
|
import {DateType} from './Calendar';
|
13
14
|
|
15
|
+
import type {TimeScale} from './TimeView';
|
16
|
+
|
14
17
|
interface CustomDaysViewProps extends LocaleProps {
|
15
18
|
classPrefix?: string;
|
16
19
|
prevIcon?: string;
|
@@ -66,9 +69,33 @@ interface CustomDaysViewProps extends LocaleProps {
|
|
66
69
|
hideHeader?: boolean;
|
67
70
|
getColumns: (types: DateType[], dateBoundary: void) => any;
|
68
71
|
getDateBoundary: (currentDate: moment.Moment) => any;
|
72
|
+
timeConstraints?: any;
|
69
73
|
}
|
70
74
|
|
71
75
|
export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
76
|
+
timeConstraints = {
|
77
|
+
hours: {
|
78
|
+
min: 0,
|
79
|
+
max: 23,
|
80
|
+
step: 1
|
81
|
+
},
|
82
|
+
minutes: {
|
83
|
+
min: 0,
|
84
|
+
max: 59,
|
85
|
+
step: 1
|
86
|
+
},
|
87
|
+
seconds: {
|
88
|
+
min: 0,
|
89
|
+
max: 59,
|
90
|
+
step: 1
|
91
|
+
},
|
92
|
+
milliseconds: {
|
93
|
+
min: 0,
|
94
|
+
max: 999,
|
95
|
+
step: 1
|
96
|
+
}
|
97
|
+
};
|
98
|
+
|
72
99
|
state: {
|
73
100
|
columns: {options: PickerOption[]}[];
|
74
101
|
types: DateType[];
|
@@ -184,6 +211,10 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
184
211
|
pickerValue: currentDate.toArray(),
|
185
212
|
uniqueTag: 0
|
186
213
|
};
|
214
|
+
|
215
|
+
if (this.props.timeConstraints) {
|
216
|
+
this.timeConstraints = merge(this.timeConstraints, props.timeConstraints);
|
217
|
+
}
|
187
218
|
}
|
188
219
|
|
189
220
|
componentWillMount() {
|
@@ -283,11 +314,15 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
283
314
|
i: number,
|
284
315
|
label?: string
|
285
316
|
) => {
|
286
|
-
|
317
|
+
const elf: any = document.getElementById(
|
287
318
|
`${this.state.uniqueTag}-${i}-input`
|
288
319
|
);
|
320
|
+
const {min, step} = this.timeConstraints[type];
|
321
|
+
const offset = (value - min) / step;
|
322
|
+
const height = 28; /** 单个选项的高度 */
|
323
|
+
|
289
324
|
elf?.parentNode?.scrollTo({
|
290
|
-
top:
|
325
|
+
top: offset * height,
|
291
326
|
behavior: label === 'init' ? 'auto' : 'smooth'
|
292
327
|
});
|
293
328
|
};
|
@@ -460,15 +495,17 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
460
495
|
return <td {...props}>{currentDate.date()}</td>;
|
461
496
|
};
|
462
497
|
|
463
|
-
|
464
|
-
|
498
|
+
/** 时间选择器数据源 */
|
499
|
+
computedTimeOptions(timeScale: TimeScale) {
|
500
|
+
const {min, max, step} = this.timeConstraints?.[timeScale];
|
465
501
|
|
466
|
-
|
467
|
-
const
|
468
|
-
|
469
|
-
|
502
|
+
return Array.from({length: max - min + 1}, (item, index) => {
|
503
|
+
const value = (index + min)
|
504
|
+
.toString()
|
505
|
+
.padStart(timeScale !== 'milliseconds' ? 2 : 3, '0');
|
470
506
|
|
471
|
-
|
507
|
+
return index % step === 0 ? {label: value, value} : undefined;
|
508
|
+
}).filter((item): item is {label: string; value: string} => !!item);
|
472
509
|
}
|
473
510
|
|
474
511
|
renderTimes = () => {
|
@@ -482,6 +519,7 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
482
519
|
|
483
520
|
const date = selectedDate || (isEndDate ? viewDate.endOf('day') : viewDate);
|
484
521
|
const inputs: Array<React.ReactNode> = [];
|
522
|
+
const timeConstraints = this.timeConstraints;
|
485
523
|
|
486
524
|
inputs.push(this.showTime());
|
487
525
|
|
@@ -494,11 +532,9 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
494
532
|
? 'seconds'
|
495
533
|
: '';
|
496
534
|
if (type) {
|
497
|
-
const min =
|
498
|
-
const max = type
|
499
|
-
const
|
500
|
-
const times = this.computedTimeOptions(60);
|
501
|
-
const options = type === 'hours' ? hours : times;
|
535
|
+
const min = timeConstraints[type].min;
|
536
|
+
const max = timeConstraints[type].max;
|
537
|
+
const options = this.computedTimeOptions(type);
|
502
538
|
const formatMap = {
|
503
539
|
hours: 'HH',
|
504
540
|
minutes: 'mm',
|
@@ -557,8 +593,9 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
557
593
|
<div
|
558
594
|
key={option.value}
|
559
595
|
className={cx('CalendarInput-sugsItem', {
|
560
|
-
'is-highlight':
|
561
|
-
option.value === date.format(formatMap[type])
|
596
|
+
'is-highlight': selectedDate
|
597
|
+
? option.value === date.format(formatMap[type])
|
598
|
+
: option.value === options?.[0]?.value
|
562
599
|
})}
|
563
600
|
onClick={() => {
|
564
601
|
this.setTime(type, parseInt(option.value, 10));
|
@@ -55,7 +55,7 @@ interface CustomTimeViewState {
|
|
55
55
|
[propName: string]: any;
|
56
56
|
}
|
57
57
|
|
58
|
-
type TimeScale = 'hours' | 'minutes' | 'seconds' | 'milliseconds';
|
58
|
+
export type TimeScale = 'hours' | 'minutes' | 'seconds' | 'milliseconds';
|
59
59
|
|
60
60
|
export class CustomTimeView extends React.Component<
|
61
61
|
CustomTimeViewProps & LocaleProps,
|
@@ -547,11 +547,15 @@ export class CustomTimeView extends React.Component<
|
|
547
547
|
};
|
548
548
|
|
549
549
|
scrollToTop = (type: TimeScale, value: number, i: number, label?: string) => {
|
550
|
-
|
550
|
+
const elf: any = document.getElementById(
|
551
551
|
`${this.state.uniqueTag}-${i}-input`
|
552
552
|
);
|
553
|
+
const {min, step} = this.timeConstraints[type];
|
554
|
+
const offset = (value - min) / step;
|
555
|
+
const height = 28; /** 单个选项的高度 */
|
556
|
+
|
553
557
|
elf?.parentNode?.scrollTo({
|
554
|
-
top:
|
558
|
+
top: offset * height,
|
555
559
|
behavior: label === 'init' ? 'auto' : 'smooth'
|
556
560
|
});
|
557
561
|
};
|
@@ -664,8 +668,9 @@ export class CustomTimeView extends React.Component<
|
|
664
668
|
<div
|
665
669
|
key={option.value}
|
666
670
|
className={cx('CalendarInput-sugsItem', {
|
667
|
-
'is-highlight':
|
668
|
-
option.value === date.format(formatMap[type])
|
671
|
+
'is-highlight': selectedDate
|
672
|
+
? option.value === date.format(formatMap[type])
|
673
|
+
: option.value === options?.[0]?.value
|
669
674
|
})}
|
670
675
|
onClick={() => {
|
671
676
|
this.setTime(type, parseInt(option.value, 10));
|
package/src/components/icons.tsx
CHANGED
@@ -84,6 +84,11 @@ import FunctionIcon from '../icons/function.svg';
|
|
84
84
|
import InputClearIcon from '../icons/input-clear.svg';
|
85
85
|
import SliderHandleIcon from '../icons/slider-handle-icon.svg';
|
86
86
|
import TrashIcon from '../icons/trash.svg';
|
87
|
+
import MenuIcon from '../icons/menu.svg';
|
88
|
+
import UserRemove from '../icons/user-remove.svg';
|
89
|
+
import Role from '../icons/role.svg';
|
90
|
+
import Department from '../icons/department.svg';
|
91
|
+
import Post from '../icons/post.svg';
|
87
92
|
import DotIcon from '../icons/dot.svg';
|
88
93
|
|
89
94
|
// 兼容原来的用法,后续不直接试用。
|
@@ -195,6 +200,11 @@ registerIcon('cloud-upload', CloudUploadIcon);
|
|
195
200
|
registerIcon('image', ImageIcon);
|
196
201
|
registerIcon('refresh', RefreshIcon);
|
197
202
|
registerIcon('trash', TrashIcon);
|
203
|
+
registerIcon('menu', MenuIcon);
|
204
|
+
registerIcon('user-remove', UserRemove);
|
205
|
+
registerIcon('role', Role);
|
206
|
+
registerIcon('department', Department);
|
207
|
+
registerIcon('post', Post);
|
198
208
|
registerIcon('dot', DotIcon);
|
199
209
|
|
200
210
|
export function Icon({
|
@@ -227,11 +237,17 @@ export {
|
|
227
237
|
MuteIcon,
|
228
238
|
PlayIcon,
|
229
239
|
PauseIcon,
|
240
|
+
ReloadIcon,
|
230
241
|
LeftArrowIcon,
|
231
242
|
RightArrowIcon,
|
232
243
|
CheckIcon,
|
233
244
|
PlusIcon,
|
234
245
|
MinusIcon,
|
235
246
|
PencilIcon,
|
236
|
-
FunctionIcon
|
247
|
+
FunctionIcon,
|
248
|
+
MenuIcon,
|
249
|
+
UserRemove,
|
250
|
+
Role,
|
251
|
+
Department,
|
252
|
+
Post
|
237
253
|
};
|
package/src/components/index.tsx
CHANGED
@@ -62,6 +62,7 @@ import Table from './table';
|
|
62
62
|
import SchemaVariableListPicker from './schema-editor/SchemaVariableListPicker';
|
63
63
|
import SchemaVariableList from './schema-editor/SchemaVariableList';
|
64
64
|
import FormulaPicker from './formula/Picker';
|
65
|
+
import InputJSONSchema from './json-schema';
|
65
66
|
|
66
67
|
export {
|
67
68
|
NotFound,
|
@@ -127,5 +128,6 @@ export {
|
|
127
128
|
Table,
|
128
129
|
SchemaVariableListPicker,
|
129
130
|
SchemaVariableList,
|
130
|
-
FormulaPicker
|
131
|
+
FormulaPicker,
|
132
|
+
InputJSONSchema
|
131
133
|
};
|