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.
Files changed (248) hide show
  1. package/lib/RootRenderer.js +10 -2
  2. package/lib/RootRenderer.js.map +2 -2
  3. package/lib/Schema.d.ts +3 -2
  4. package/lib/Schema.js.map +1 -1
  5. package/lib/components/Alert2.d.ts +10 -10
  6. package/lib/components/Button.d.ts +11 -10
  7. package/lib/components/Button.js +2 -2
  8. package/lib/components/Button.js.map +2 -2
  9. package/lib/components/CalendarMobile.d.ts +40 -40
  10. package/lib/components/Checkbox.js +1 -1
  11. package/lib/components/Checkbox.js.map +2 -2
  12. package/lib/components/ContextMenu.d.ts +4 -0
  13. package/lib/components/ContextMenu.js +23 -7
  14. package/lib/components/ContextMenu.js.map +2 -2
  15. package/lib/components/DatePicker.d.ts +40 -40
  16. package/lib/components/DateRangePicker.d.ts +40 -40
  17. package/lib/components/Form.d.ts +22 -0
  18. package/lib/components/Form.js +44 -0
  19. package/lib/components/Form.js.map +13 -0
  20. package/lib/components/FormField.d.ts +65 -0
  21. package/lib/components/FormField.js +48 -0
  22. package/lib/components/FormField.js.map +13 -0
  23. package/lib/components/InputBox.d.ts +10 -10
  24. package/lib/components/InputBox.js +4 -3
  25. package/lib/components/InputBox.js.map +2 -2
  26. package/lib/components/InputBoxWithSuggestion.d.ts +280 -0
  27. package/lib/components/InputBoxWithSuggestion.js +65 -0
  28. package/lib/components/InputBoxWithSuggestion.js.map +13 -0
  29. package/lib/components/ListGroup.d.ts +10 -10
  30. package/lib/components/PickerContainer.d.ts +4 -2
  31. package/lib/components/PickerContainer.js +28 -5
  32. package/lib/components/PickerContainer.js.map +2 -2
  33. package/lib/components/Radios.d.ts +10 -10
  34. package/lib/components/ResultBox.d.ts +40 -40
  35. package/lib/components/SearchBox.d.ts +40 -40
  36. package/lib/components/Select.d.ts +195 -202
  37. package/lib/components/Select.js +7 -3
  38. package/lib/components/Select.js.map +2 -2
  39. package/lib/components/Textarea.d.ts +568 -2
  40. package/lib/components/Textarea.js +129 -1
  41. package/lib/components/Textarea.js.map +2 -2
  42. package/lib/components/Toast.js +11 -9
  43. package/lib/components/Toast.js.map +2 -2
  44. package/lib/components/UserSelect.d.ts +500 -0
  45. package/lib/components/UserSelect.js +559 -0
  46. package/lib/components/UserSelect.js.map +13 -0
  47. package/lib/components/UserTabSelect.d.ts +320 -0
  48. package/lib/components/UserTabSelect.js +163 -0
  49. package/lib/components/UserTabSelect.js.map +13 -0
  50. package/lib/components/WithRemoteConfig.d.ts +7 -0
  51. package/lib/components/WithRemoteConfig.js +17 -11
  52. package/lib/components/WithRemoteConfig.js.map +2 -2
  53. package/lib/components/calendar/DaysView.d.ts +26 -1
  54. package/lib/components/calendar/DaysView.js +48 -14
  55. package/lib/components/calendar/DaysView.js.map +2 -2
  56. package/lib/components/calendar/TimeView.d.ts +1 -1
  57. package/lib/components/calendar/TimeView.js +8 -2
  58. package/lib/components/calendar/TimeView.js.map +2 -2
  59. package/lib/components/icons.d.ts +7 -1
  60. package/lib/components/icons.js +17 -1
  61. package/lib/components/icons.js.map +2 -2
  62. package/lib/components/index.d.ts +2 -1
  63. package/lib/components/index.js +3 -1
  64. package/lib/components/index.js.map +2 -2
  65. package/lib/components/json-schema/Array.d.ts +3 -0
  66. package/lib/components/json-schema/Array.js +125 -0
  67. package/lib/components/json-schema/Array.js.map +13 -0
  68. package/lib/components/json-schema/Item.d.ts +3 -0
  69. package/lib/components/json-schema/Item.js +34 -0
  70. package/lib/components/json-schema/Item.js.map +13 -0
  71. package/lib/components/json-schema/Object.d.ts +3 -0
  72. package/lib/components/json-schema/Object.js +178 -0
  73. package/lib/components/json-schema/Object.js.map +13 -0
  74. package/lib/components/json-schema/index.d.ts +279 -0
  75. package/lib/components/json-schema/index.js +16 -0
  76. package/lib/components/json-schema/index.js.map +13 -0
  77. package/lib/components/schema-editor/Array.js +2 -2
  78. package/lib/components/schema-editor/Array.js.map +2 -2
  79. package/lib/components/schema-editor/Common.d.ts +2 -0
  80. package/lib/components/schema-editor/Common.js +39 -3
  81. package/lib/components/schema-editor/Common.js.map +2 -2
  82. package/lib/components/schema-editor/Object.js +2 -2
  83. package/lib/components/schema-editor/Object.js.map +2 -2
  84. package/lib/components/schema-editor/index.d.ts +45 -41
  85. package/lib/components/schema-editor/index.js +5 -5
  86. package/lib/components/schema-editor/index.js.map +2 -2
  87. package/lib/hooks/use-validation-resolver.d.ts +1 -0
  88. package/lib/hooks/use-validation-resolver.js +49 -0
  89. package/lib/hooks/use-validation-resolver.js.map +13 -0
  90. package/lib/icons/department.js +17 -0
  91. package/lib/icons/menu.js +9 -0
  92. package/lib/icons/post.js +15 -0
  93. package/lib/icons/role.js +14 -0
  94. package/lib/icons/user-remove.js +12 -0
  95. package/lib/index.d.ts +2 -0
  96. package/lib/index.js +3 -1
  97. package/lib/index.js.map +2 -2
  98. package/lib/locale/de-DE.js +11 -1
  99. package/lib/locale/de-DE.js.map +2 -2
  100. package/lib/locale/en-US.js +12 -1
  101. package/lib/locale/en-US.js.map +2 -2
  102. package/lib/locale/zh-CN.js +14 -3
  103. package/lib/locale/zh-CN.js.map +2 -2
  104. package/lib/renderers/Action.js +25 -11
  105. package/lib/renderers/Action.js.map +2 -2
  106. package/lib/renderers/CRUD.js +5 -1
  107. package/lib/renderers/CRUD.js.map +2 -2
  108. package/lib/renderers/Dialog.js +9 -3
  109. package/lib/renderers/Dialog.js.map +2 -2
  110. package/lib/renderers/Drawer.js +5 -1
  111. package/lib/renderers/Drawer.js.map +2 -2
  112. package/lib/renderers/Form/InputDate.d.ts +2 -2
  113. package/lib/renderers/Form/InputDate.js.map +2 -2
  114. package/lib/renderers/Form/JSONSchema.d.ts +23 -0
  115. package/lib/renderers/Form/JSONSchema.js +44 -0
  116. package/lib/renderers/Form/JSONSchema.js.map +13 -0
  117. package/lib/renderers/Form/JSONSchemaEditor.d.ts +2 -3
  118. package/lib/renderers/Form/JSONSchemaEditor.js +9 -24
  119. package/lib/renderers/Form/JSONSchemaEditor.js.map +2 -2
  120. package/lib/renderers/Form/Textarea.d.ts +1 -8
  121. package/lib/renderers/Form/Textarea.js +11 -75
  122. package/lib/renderers/Form/Textarea.js.map +2 -2
  123. package/lib/renderers/Form/UserSelect.d.ts +54 -0
  124. package/lib/renderers/Form/UserSelect.js +197 -0
  125. package/lib/renderers/Form/UserSelect.js.map +13 -0
  126. package/lib/renderers/Form/index.d.ts +1 -1
  127. package/lib/renderers/Form/index.js +88 -42
  128. package/lib/renderers/Form/index.js.map +2 -2
  129. package/lib/renderers/Log.d.ts +13 -1
  130. package/lib/renderers/Log.js +82 -16
  131. package/lib/renderers/Log.js.map +2 -2
  132. package/lib/renderers/Page.js +5 -1
  133. package/lib/renderers/Page.js.map +2 -2
  134. package/lib/renderers/Service.js +5 -1
  135. package/lib/renderers/Service.js.map +2 -2
  136. package/lib/renderers/Wizard.js +37 -14
  137. package/lib/renderers/Wizard.js.map +2 -2
  138. package/lib/store/form.js +65 -45
  139. package/lib/store/form.js.map +2 -2
  140. package/lib/themes/ang-ie11.css +561 -21
  141. package/lib/themes/ang.css +538 -9
  142. package/lib/themes/ang.css.map +1 -1
  143. package/lib/themes/antd-ie11.css +561 -21
  144. package/lib/themes/antd.css +538 -9
  145. package/lib/themes/antd.css.map +1 -1
  146. package/lib/themes/cxd-ie11.css +561 -21
  147. package/lib/themes/cxd.css +538 -9
  148. package/lib/themes/cxd.css.map +1 -1
  149. package/lib/themes/dark-ie11.css +561 -21
  150. package/lib/themes/dark.css +538 -9
  151. package/lib/themes/dark.css.map +1 -1
  152. package/lib/themes/default-ie11.css +561 -21
  153. package/lib/themes/default.css +538 -9
  154. package/lib/themes/default.css.map +1 -1
  155. package/lib/utils/api.js +1 -1
  156. package/lib/utils/api.js.map +2 -2
  157. package/lib/utils/renderer-event.js.map +2 -2
  158. package/package.json +2 -1
  159. package/schema.json +539 -3
  160. package/scss/_properties.scss +20 -8
  161. package/scss/components/_input-box.scss +22 -1
  162. package/scss/components/_json-schema.scss +124 -0
  163. package/scss/components/_log.scss +37 -5
  164. package/scss/components/form/_date-range.scss +1 -0
  165. package/scss/components/form/_select.scss +9 -0
  166. package/scss/components/form/_user-select.scss +422 -0
  167. package/scss/themes/_common.scss +2 -0
  168. package/sdk/ang-ie11.css +651 -21
  169. package/sdk/ang.css +628 -9
  170. package/sdk/antd-ie11.css +651 -21
  171. package/sdk/antd.css +628 -9
  172. package/sdk/barcode.js +51 -51
  173. package/sdk/charts.js +14 -14
  174. package/sdk/codemirror.js +7 -7
  175. package/sdk/color-picker.js +65 -65
  176. package/sdk/cropperjs.js +2 -2
  177. package/sdk/cxd-ie11.css +651 -21
  178. package/sdk/cxd.css +628 -9
  179. package/sdk/dark-ie11.css +651 -21
  180. package/sdk/dark.css +628 -9
  181. package/sdk/exceljs.js +1 -1
  182. package/sdk/locale/de-DE.js +11 -1
  183. package/sdk/markdown.js +69 -69
  184. package/sdk/papaparse.js +1 -1
  185. package/sdk/renderers/Form/CityDB.js +1 -1
  186. package/sdk/rest.js +16 -16
  187. package/sdk/rich-text.js +62 -62
  188. package/sdk/sdk-ie11.css +651 -21
  189. package/sdk/sdk.css +628 -9
  190. package/sdk/sdk.js +1655 -1643
  191. package/sdk/thirds/hls.js/hls.js +1 -1
  192. package/sdk/thirds/mpegts.js/mpegts.js +1 -1
  193. package/sdk/tinymce.js +57 -57
  194. package/src/RootRenderer.tsx +27 -15
  195. package/src/Schema.ts +5 -1
  196. package/src/components/Button.tsx +3 -0
  197. package/src/components/Checkbox.tsx +2 -1
  198. package/src/components/ContextMenu.tsx +25 -7
  199. package/src/components/Form.tsx +70 -0
  200. package/src/components/FormField.tsx +127 -0
  201. package/src/components/InputBox.tsx +4 -1
  202. package/src/components/InputBoxWithSuggestion.tsx +113 -0
  203. package/src/components/PickerContainer.tsx +20 -5
  204. package/src/components/Select.tsx +18 -10
  205. package/src/components/Textarea.tsx +234 -2
  206. package/src/components/Toast.tsx +19 -18
  207. package/src/components/UserSelect.tsx +850 -0
  208. package/src/components/UserTabSelect.tsx +261 -0
  209. package/src/components/WithRemoteConfig.tsx +22 -7
  210. package/src/components/calendar/DaysView.tsx +53 -16
  211. package/src/components/calendar/TimeView.tsx +10 -5
  212. package/src/components/icons.tsx +17 -1
  213. package/src/components/index.tsx +3 -1
  214. package/src/components/json-schema/Array.tsx +216 -0
  215. package/src/components/json-schema/Item.tsx +47 -0
  216. package/src/components/json-schema/Object.tsx +339 -0
  217. package/src/components/json-schema/index.tsx +44 -0
  218. package/src/components/schema-editor/Array.tsx +3 -1
  219. package/src/components/schema-editor/Common.tsx +61 -4
  220. package/src/components/schema-editor/Object.tsx +3 -1
  221. package/src/components/schema-editor/index.tsx +12 -5
  222. package/src/hooks/use-validation-resolver.ts +45 -0
  223. package/src/icons/department.svg +17 -0
  224. package/src/icons/menu.svg +2 -0
  225. package/src/icons/post.svg +15 -0
  226. package/src/icons/role.svg +14 -0
  227. package/src/icons/user-remove.svg +12 -0
  228. package/src/index.tsx +2 -0
  229. package/src/locale/de-DE.ts +11 -1
  230. package/src/locale/en-US.ts +12 -1
  231. package/src/locale/zh-CN.ts +14 -3
  232. package/src/renderers/Action.tsx +10 -9
  233. package/src/renderers/CRUD.tsx +5 -1
  234. package/src/renderers/Dialog.tsx +9 -3
  235. package/src/renderers/Drawer.tsx +5 -1
  236. package/src/renderers/Form/InputDate.tsx +9 -4
  237. package/src/renderers/Form/JSONSchema.tsx +56 -0
  238. package/src/renderers/Form/JSONSchemaEditor.tsx +8 -27
  239. package/src/renderers/Form/Textarea.tsx +7 -117
  240. package/src/renderers/Form/UserSelect.tsx +263 -0
  241. package/src/renderers/Form/index.tsx +28 -18
  242. package/src/renderers/Log.tsx +148 -13
  243. package/src/renderers/Page.tsx +6 -1
  244. package/src/renderers/Service.tsx +5 -1
  245. package/src/renderers/Wizard.tsx +24 -10
  246. package/src/store/form.ts +24 -17
  247. package/src/utils/api.ts +1 -1
  248. 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, source, data} = this.props;
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, source} = this.props;
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, source, data} = this.props;
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, source, data, deferApi} = this.props;
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
- {...injectedProps}
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
- let elf: any = document.getElementById(
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: value * 28,
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
- computedTimeOptions(total: number) {
464
- const times: {label: string; value: string}[] = [];
498
+ /** 时间选择器数据源 */
499
+ computedTimeOptions(timeScale: TimeScale) {
500
+ const {min, max, step} = this.timeConstraints?.[timeScale];
465
501
 
466
- for (let t = 0; t < total; t++) {
467
- const label = t < 10 ? `0${t}` : `${t}`;
468
- times.push({label, value: label});
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
- return times;
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 = 0;
498
- const max = type === 'hours' ? 23 : 59;
499
- const hours = this.computedTimeOptions(24);
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
- let elf: any = document.getElementById(
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: value * 28,
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));
@@ -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
  };
@@ -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
  };