amis 1.9.0 → 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/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
@@ -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;
|
@@ -31,7 +34,12 @@ interface CustomDaysViewProps extends LocaleProps {
|
|
31
34
|
setDateTimeState: (state: any) => void;
|
32
35
|
showTime: () => void;
|
33
36
|
setTime: (type: string, amount: number) => void;
|
34
|
-
scrollToTop: (
|
37
|
+
scrollToTop: (
|
38
|
+
type: string,
|
39
|
+
amount: number,
|
40
|
+
i: number,
|
41
|
+
lable?: string
|
42
|
+
) => void;
|
35
43
|
subtractTime: (
|
36
44
|
amount: number,
|
37
45
|
type: string,
|
@@ -61,9 +69,33 @@ interface CustomDaysViewProps extends LocaleProps {
|
|
61
69
|
hideHeader?: boolean;
|
62
70
|
getColumns: (types: DateType[], dateBoundary: void) => any;
|
63
71
|
getDateBoundary: (currentDate: moment.Moment) => any;
|
72
|
+
timeConstraints?: any;
|
64
73
|
}
|
65
74
|
|
66
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
|
+
|
67
99
|
state: {
|
68
100
|
columns: {options: PickerOption[]}[];
|
69
101
|
types: DateType[];
|
@@ -177,21 +209,20 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
177
209
|
columns,
|
178
210
|
types,
|
179
211
|
pickerValue: currentDate.toArray(),
|
180
|
-
uniqueTag: 0
|
212
|
+
uniqueTag: 0
|
213
|
+
};
|
214
|
+
|
215
|
+
if (this.props.timeConstraints) {
|
216
|
+
this.timeConstraints = merge(this.timeConstraints, props.timeConstraints);
|
181
217
|
}
|
182
218
|
}
|
183
219
|
|
184
220
|
componentWillMount() {
|
185
|
-
this.setState({uniqueTag:
|
221
|
+
this.setState({uniqueTag: new Date().valueOf()});
|
186
222
|
}
|
187
223
|
|
188
224
|
componentDidMount() {
|
189
|
-
const {
|
190
|
-
timeFormat,
|
191
|
-
selectedDate,
|
192
|
-
viewDate,
|
193
|
-
isEndDate,
|
194
|
-
} = this.props;
|
225
|
+
const {timeFormat, selectedDate, viewDate, isEndDate} = this.props;
|
195
226
|
const formatMap = {
|
196
227
|
hours: 'HH',
|
197
228
|
minutes: 'mm',
|
@@ -207,9 +238,14 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
207
238
|
? 'seconds'
|
208
239
|
: '';
|
209
240
|
if (type) {
|
210
|
-
this.scrollToTop(
|
241
|
+
this.scrollToTop(
|
242
|
+
type,
|
243
|
+
parseInt(date.format(formatMap[type]), 10),
|
244
|
+
i,
|
245
|
+
'init'
|
246
|
+
);
|
211
247
|
}
|
212
|
-
})
|
248
|
+
});
|
213
249
|
}
|
214
250
|
|
215
251
|
updateSelectedDate = (event: React.MouseEvent<any>) => {
|
@@ -246,17 +282,14 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
246
282
|
this.props.updateSelectedDate(event, true);
|
247
283
|
};
|
248
284
|
|
249
|
-
showTime = () =>{
|
250
|
-
const {selectedDate, viewDate, timeFormat} = this.props
|
285
|
+
showTime = () => {
|
286
|
+
const {selectedDate, viewDate, timeFormat} = this.props;
|
251
287
|
return (
|
252
|
-
<div
|
253
|
-
key="stb"
|
254
|
-
className="rdtShowTime"
|
255
|
-
>
|
288
|
+
<div key="stb" className="rdtShowTime">
|
256
289
|
{(selectedDate || viewDate || moment()).format(timeFormat)}
|
257
290
|
</div>
|
258
|
-
)
|
259
|
-
}
|
291
|
+
);
|
292
|
+
};
|
260
293
|
|
261
294
|
setTime = (
|
262
295
|
type: 'hours' | 'minutes' | 'seconds' | 'milliseconds',
|
@@ -279,13 +312,19 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
279
312
|
type: 'hours' | 'minutes' | 'seconds' | 'milliseconds',
|
280
313
|
value: number,
|
281
314
|
i: number,
|
282
|
-
label?: string
|
315
|
+
label?: string
|
283
316
|
) => {
|
284
|
-
|
285
|
-
|
286
|
-
|
317
|
+
const elf: any = document.getElementById(
|
318
|
+
`${this.state.uniqueTag}-${i}-input`
|
319
|
+
);
|
320
|
+
const {min, step} = this.timeConstraints[type];
|
321
|
+
const offset = (value - min) / step;
|
322
|
+
const height = 28; /** 单个选项的高度 */
|
323
|
+
|
324
|
+
elf?.parentNode?.scrollTo({
|
325
|
+
top: offset * height,
|
287
326
|
behavior: label === 'init' ? 'auto' : 'smooth'
|
288
|
-
})
|
327
|
+
});
|
289
328
|
};
|
290
329
|
|
291
330
|
confirm = () => {
|
@@ -456,15 +495,17 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
456
495
|
return <td {...props}>{currentDate.date()}</td>;
|
457
496
|
};
|
458
497
|
|
459
|
-
|
460
|
-
|
498
|
+
/** 时间选择器数据源 */
|
499
|
+
computedTimeOptions(timeScale: TimeScale) {
|
500
|
+
const {min, max, step} = this.timeConstraints?.[timeScale];
|
461
501
|
|
462
|
-
|
463
|
-
const
|
464
|
-
|
465
|
-
|
502
|
+
return Array.from({length: max - min + 1}, (item, index) => {
|
503
|
+
const value = (index + min)
|
504
|
+
.toString()
|
505
|
+
.padStart(timeScale !== 'milliseconds' ? 2 : 3, '0');
|
466
506
|
|
467
|
-
|
507
|
+
return index % step === 0 ? {label: value, value} : undefined;
|
508
|
+
}).filter((item): item is {label: string; value: string} => !!item);
|
468
509
|
}
|
469
510
|
|
470
511
|
renderTimes = () => {
|
@@ -478,8 +519,9 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
478
519
|
|
479
520
|
const date = selectedDate || (isEndDate ? viewDate.endOf('day') : viewDate);
|
480
521
|
const inputs: Array<React.ReactNode> = [];
|
522
|
+
const timeConstraints = this.timeConstraints;
|
481
523
|
|
482
|
-
inputs.push(this.showTime())
|
524
|
+
inputs.push(this.showTime());
|
483
525
|
|
484
526
|
timeFormat.split(':').forEach((format, i) => {
|
485
527
|
const type = /h/i.test(format)
|
@@ -490,11 +532,9 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
490
532
|
? 'seconds'
|
491
533
|
: '';
|
492
534
|
if (type) {
|
493
|
-
const min =
|
494
|
-
const max = type
|
495
|
-
const
|
496
|
-
const times = this.computedTimeOptions(60);
|
497
|
-
const options = type === 'hours' ? hours : times;
|
535
|
+
const min = timeConstraints[type].min;
|
536
|
+
const max = timeConstraints[type].max;
|
537
|
+
const options = this.computedTimeOptions(type);
|
498
538
|
const formatMap = {
|
499
539
|
hours: 'HH',
|
500
540
|
minutes: 'mm',
|
@@ -525,7 +565,12 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
525
565
|
)
|
526
566
|
});
|
527
567
|
return (
|
528
|
-
<div
|
568
|
+
<div
|
569
|
+
className={cx(
|
570
|
+
'CalendarInputWrapper',
|
571
|
+
'CalendarInputWrapperMT'
|
572
|
+
)}
|
573
|
+
>
|
529
574
|
{/* <input
|
530
575
|
type="text"
|
531
576
|
value={date.format(formatMap[type])}
|
@@ -534,24 +579,31 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
534
579
|
max={max}
|
535
580
|
{...inputProps}
|
536
581
|
/> */}
|
537
|
-
<div
|
582
|
+
<div
|
538
583
|
className={cx(
|
539
584
|
'CalendarInput-sugs',
|
540
|
-
type === 'hours'
|
541
|
-
|
585
|
+
type === 'hours'
|
586
|
+
? 'CalendarInput-sugsHours'
|
587
|
+
: 'CalendarInput-sugsTimes'
|
588
|
+
)}
|
542
589
|
id={`${this.state.uniqueTag}-${i}-input`}
|
543
590
|
>
|
544
591
|
{options.map(option => {
|
545
592
|
return (
|
546
593
|
<div
|
547
594
|
key={option.value}
|
548
|
-
className={cx(
|
549
|
-
'
|
550
|
-
|
551
|
-
|
595
|
+
className={cx('CalendarInput-sugsItem', {
|
596
|
+
'is-highlight': selectedDate
|
597
|
+
? option.value === date.format(formatMap[type])
|
598
|
+
: option.value === options?.[0]?.value
|
599
|
+
})}
|
552
600
|
onClick={() => {
|
553
601
|
this.setTime(type, parseInt(option.value, 10));
|
554
|
-
this.scrollToTop(
|
602
|
+
this.scrollToTop(
|
603
|
+
type,
|
604
|
+
parseInt(option.value, 10),
|
605
|
+
i
|
606
|
+
);
|
555
607
|
closeMenu();
|
556
608
|
}}
|
557
609
|
>
|
@@ -649,7 +701,13 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
649
701
|
};
|
650
702
|
|
651
703
|
render() {
|
652
|
-
const {
|
704
|
+
const {
|
705
|
+
viewDate: date,
|
706
|
+
useMobileUI,
|
707
|
+
embed,
|
708
|
+
timeFormat,
|
709
|
+
classnames: cx
|
710
|
+
} = this.props;
|
653
711
|
const locale = date.localeData();
|
654
712
|
const __ = this.props.translate;
|
655
713
|
if (isMobile() && useMobileUI && !embed) {
|
@@ -718,9 +776,19 @@ export class CustomDaysView extends React.Component<CustomDaysViewProps> {
|
|
718
776
|
return (
|
719
777
|
<>
|
720
778
|
<div className={timeFormat ? 'rdtDays' : ''}>
|
721
|
-
<table className={timeFormat ? 'rdtDaysPart' : ''}>
|
779
|
+
<table className={timeFormat ? 'rdtDaysPart' : ''}>
|
780
|
+
{tableChildren}
|
781
|
+
</table>
|
722
782
|
{timeFormat ? (
|
723
|
-
<div
|
783
|
+
<div
|
784
|
+
className={
|
785
|
+
timeFormat.toLowerCase().indexOf('s') > 0
|
786
|
+
? 'rdtTimePartWithS'
|
787
|
+
: 'rdtTimePart'
|
788
|
+
}
|
789
|
+
>
|
790
|
+
{this.renderTimes()}
|
791
|
+
</div>
|
724
792
|
) : null}
|
725
793
|
</div>
|
726
794
|
<table>{this.renderFooter()}</table>
|
@@ -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
|
-
|
554
|
-
|
553
|
+
const {min, step} = this.timeConstraints[type];
|
554
|
+
const offset = (value - min) / step;
|
555
|
+
const height = 28; /** 单个选项的高度 */
|
556
|
+
|
557
|
+
elf?.parentNode?.scrollTo({
|
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));
|