@rjsf/antd 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +183 -183
- package/dist/antd.cjs.development.js +456 -383
- package/dist/antd.cjs.development.js.map +1 -1
- package/dist/antd.cjs.production.min.js +1 -1
- package/dist/antd.cjs.production.min.js.map +1 -1
- package/dist/antd.esm.js +453 -380
- package/dist/antd.esm.js.map +1 -1
- package/dist/antd.umd.development.js +457 -386
- package/dist/antd.umd.development.js.map +1 -1
- package/dist/antd.umd.production.min.js +1 -1
- package/dist/antd.umd.production.min.js.map +1 -1
- package/package.json +18 -14
package/dist/antd.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { withTheme } from '@rjsf/core';
|
|
2
|
-
import
|
|
2
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import Button from 'antd/es/button';
|
|
4
4
|
import Col from 'antd/es/col';
|
|
5
5
|
import Row from 'antd/es/row';
|
|
@@ -14,12 +14,14 @@ import Space from 'antd/es/space';
|
|
|
14
14
|
import ExclamationCircleOutlined from '@ant-design/icons/ExclamationCircleOutlined';
|
|
15
15
|
import ArrowDownOutlined from '@ant-design/icons/ArrowDownOutlined';
|
|
16
16
|
import ArrowUpOutlined from '@ant-design/icons/ArrowUpOutlined';
|
|
17
|
+
import CopyOutlined from '@ant-design/icons/CopyOutlined';
|
|
17
18
|
import DeleteOutlined from '@ant-design/icons/DeleteOutlined';
|
|
18
19
|
import PlusCircleOutlined from '@ant-design/icons/PlusCircleOutlined';
|
|
19
20
|
import Form$1 from 'antd/es/form';
|
|
20
21
|
import isObject from 'lodash-es/isObject';
|
|
21
22
|
import isNumber from 'lodash-es/isNumber';
|
|
22
23
|
import isString from 'lodash-es/isString';
|
|
24
|
+
import { useState, useEffect } from 'react';
|
|
23
25
|
import Checkbox from 'antd/es/checkbox';
|
|
24
26
|
import dayjs from 'dayjs';
|
|
25
27
|
import dayjsGenerateConfig from 'rc-picker/es/generate/dayjs';
|
|
@@ -29,10 +31,10 @@ import Slider from 'antd/es/slider';
|
|
|
29
31
|
import Select from 'antd/es/select';
|
|
30
32
|
|
|
31
33
|
var BTN_GRP_STYLE = {
|
|
32
|
-
width:
|
|
34
|
+
width: '100%'
|
|
33
35
|
};
|
|
34
36
|
var BTN_STYLE = {
|
|
35
|
-
width:
|
|
37
|
+
width: 'calc(100% / 4)'
|
|
36
38
|
};
|
|
37
39
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
38
40
|
*
|
|
@@ -41,17 +43,20 @@ var BTN_STYLE = {
|
|
|
41
43
|
function ArrayFieldItemTemplate(props) {
|
|
42
44
|
var children = props.children,
|
|
43
45
|
disabled = props.disabled,
|
|
46
|
+
hasCopy = props.hasCopy,
|
|
44
47
|
hasMoveDown = props.hasMoveDown,
|
|
45
48
|
hasMoveUp = props.hasMoveUp,
|
|
46
49
|
hasRemove = props.hasRemove,
|
|
47
50
|
hasToolbar = props.hasToolbar,
|
|
48
51
|
index = props.index,
|
|
52
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
49
53
|
onDropIndexClick = props.onDropIndexClick,
|
|
50
54
|
onReorderClick = props.onReorderClick,
|
|
51
55
|
readonly = props.readonly,
|
|
52
56
|
registry = props.registry,
|
|
53
57
|
uiSchema = props.uiSchema;
|
|
54
58
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
59
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
55
60
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
56
61
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
57
62
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -59,36 +64,45 @@ function ArrayFieldItemTemplate(props) {
|
|
|
59
64
|
_registry$formContext2 = _registry$formContext.rowGutter,
|
|
60
65
|
rowGutter = _registry$formContext2 === void 0 ? 24 : _registry$formContext2,
|
|
61
66
|
_registry$formContext3 = _registry$formContext.toolbarAlign,
|
|
62
|
-
toolbarAlign = _registry$formContext3 === void 0 ?
|
|
63
|
-
return
|
|
67
|
+
toolbarAlign = _registry$formContext3 === void 0 ? 'top' : _registry$formContext3;
|
|
68
|
+
return jsxs(Row, {
|
|
64
69
|
align: toolbarAlign,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
70
|
+
gutter: rowGutter,
|
|
71
|
+
children: [jsx(Col, {
|
|
72
|
+
flex: '1',
|
|
73
|
+
children: children
|
|
74
|
+
}), hasToolbar && jsx(Col, {
|
|
75
|
+
flex: '192px',
|
|
76
|
+
children: jsxs(Button.Group, {
|
|
77
|
+
style: BTN_GRP_STYLE,
|
|
78
|
+
children: [(hasMoveUp || hasMoveDown) && jsx(MoveUpButton, {
|
|
79
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
80
|
+
onClick: onReorderClick(index, index - 1),
|
|
81
|
+
style: BTN_STYLE,
|
|
82
|
+
uiSchema: uiSchema,
|
|
83
|
+
registry: registry
|
|
84
|
+
}), (hasMoveUp || hasMoveDown) && jsx(MoveDownButton, {
|
|
85
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
86
|
+
onClick: onReorderClick(index, index + 1),
|
|
87
|
+
style: BTN_STYLE,
|
|
88
|
+
uiSchema: uiSchema,
|
|
89
|
+
registry: registry
|
|
90
|
+
}), hasCopy && jsx(CopyButton, {
|
|
91
|
+
disabled: disabled || readonly,
|
|
92
|
+
onClick: onCopyIndexClick(index),
|
|
93
|
+
style: BTN_STYLE,
|
|
94
|
+
uiSchema: uiSchema,
|
|
95
|
+
registry: registry
|
|
96
|
+
}), hasRemove && jsx(RemoveButton, {
|
|
97
|
+
disabled: disabled || readonly,
|
|
98
|
+
onClick: onDropIndexClick(index),
|
|
99
|
+
style: BTN_STYLE,
|
|
100
|
+
uiSchema: uiSchema,
|
|
101
|
+
registry: registry
|
|
102
|
+
})]
|
|
103
|
+
})
|
|
104
|
+
})]
|
|
105
|
+
}, "array-item-" + index);
|
|
92
106
|
}
|
|
93
107
|
|
|
94
108
|
function _extends() {
|
|
@@ -120,7 +134,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
120
134
|
|
|
121
135
|
var _excluded$1 = ["key"];
|
|
122
136
|
var DESCRIPTION_COL_STYLE$1 = {
|
|
123
|
-
paddingBottom:
|
|
137
|
+
paddingBottom: '8px'
|
|
124
138
|
};
|
|
125
139
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
126
140
|
*
|
|
@@ -141,75 +155,83 @@ function ArrayFieldTemplate(props) {
|
|
|
141
155
|
title = props.title,
|
|
142
156
|
uiSchema = props.uiSchema;
|
|
143
157
|
var uiOptions = getUiOptions(uiSchema);
|
|
144
|
-
var ArrayFieldDescriptionTemplate = getTemplate(
|
|
145
|
-
var ArrayFieldItemTemplate = getTemplate(
|
|
146
|
-
var ArrayFieldTitleTemplate = getTemplate(
|
|
158
|
+
var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
159
|
+
var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
160
|
+
var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
147
161
|
// Button templates are not overridden in the uiSchema
|
|
148
162
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
149
163
|
var _formContext$labelAli = formContext.labelAlign,
|
|
150
|
-
labelAlign = _formContext$labelAli === void 0 ?
|
|
164
|
+
labelAlign = _formContext$labelAli === void 0 ? 'right' : _formContext$labelAli,
|
|
151
165
|
_formContext$rowGutte = formContext.rowGutter,
|
|
152
166
|
rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
167
|
+
return jsx(ConfigConsumer, {
|
|
168
|
+
children: function children(configProps) {
|
|
169
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
170
|
+
var prefixCls = getPrefixCls('form');
|
|
171
|
+
var labelClsBasic = prefixCls + "-item-label";
|
|
172
|
+
var labelColClassName = classNames(labelClsBasic, labelAlign === 'left' && labelClsBasic + "-left"
|
|
173
|
+
// labelCol.className,
|
|
174
|
+
);
|
|
160
175
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
176
|
+
return jsx("fieldset", {
|
|
177
|
+
className: className,
|
|
178
|
+
id: idSchema.$id,
|
|
179
|
+
children: jsxs(Row, {
|
|
180
|
+
gutter: rowGutter,
|
|
181
|
+
children: [(uiOptions.title || title) && jsx(Col, {
|
|
182
|
+
className: labelColClassName,
|
|
183
|
+
span: 24,
|
|
184
|
+
children: jsx(ArrayFieldTitleTemplate, {
|
|
185
|
+
idSchema: idSchema,
|
|
186
|
+
required: required,
|
|
187
|
+
title: uiOptions.title || title,
|
|
188
|
+
schema: schema,
|
|
189
|
+
uiSchema: uiSchema,
|
|
190
|
+
registry: registry
|
|
191
|
+
})
|
|
192
|
+
}), (uiOptions.description || schema.description) && jsx(Col, {
|
|
193
|
+
span: 24,
|
|
194
|
+
style: DESCRIPTION_COL_STYLE$1,
|
|
195
|
+
children: jsx(ArrayFieldDescriptionTemplate, {
|
|
196
|
+
description: uiOptions.description || schema.description || '',
|
|
197
|
+
idSchema: idSchema,
|
|
198
|
+
schema: schema,
|
|
199
|
+
uiSchema: uiSchema,
|
|
200
|
+
registry: registry
|
|
201
|
+
})
|
|
202
|
+
}), jsx(Col, {
|
|
203
|
+
className: 'row array-item-list',
|
|
204
|
+
span: 24,
|
|
205
|
+
children: items && items.map(function (_ref) {
|
|
206
|
+
var key = _ref.key,
|
|
207
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
208
|
+
return jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
209
|
+
})
|
|
210
|
+
}), canAdd && jsx(Col, {
|
|
211
|
+
span: 24,
|
|
212
|
+
children: jsx(Row, {
|
|
213
|
+
gutter: rowGutter,
|
|
214
|
+
justify: 'end',
|
|
215
|
+
children: jsx(Col, {
|
|
216
|
+
flex: '192px',
|
|
217
|
+
children: jsx(AddButton, {
|
|
218
|
+
className: 'array-item-add',
|
|
219
|
+
disabled: disabled || readonly,
|
|
220
|
+
onClick: onAddClick,
|
|
221
|
+
uiSchema: uiSchema,
|
|
222
|
+
registry: registry
|
|
223
|
+
})
|
|
224
|
+
})
|
|
225
|
+
})
|
|
226
|
+
})]
|
|
227
|
+
})
|
|
228
|
+
});
|
|
229
|
+
}
|
|
208
230
|
});
|
|
209
231
|
}
|
|
210
232
|
|
|
211
233
|
var INPUT_STYLE$2 = {
|
|
212
|
-
width:
|
|
234
|
+
width: '100%'
|
|
213
235
|
};
|
|
214
236
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
215
237
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
@@ -223,6 +245,7 @@ function BaseInputTemplate(props) {
|
|
|
223
245
|
id = props.id,
|
|
224
246
|
onBlur = props.onBlur,
|
|
225
247
|
onChange = props.onChange,
|
|
248
|
+
onChangeOverride = props.onChangeOverride,
|
|
226
249
|
onFocus = props.onFocus,
|
|
227
250
|
options = props.options,
|
|
228
251
|
placeholder = props.placeholder,
|
|
@@ -236,9 +259,9 @@ function BaseInputTemplate(props) {
|
|
|
236
259
|
var handleNumberChange = function handleNumberChange(nextValue) {
|
|
237
260
|
return onChange(nextValue);
|
|
238
261
|
};
|
|
239
|
-
var handleTextChange = function
|
|
262
|
+
var handleTextChange = onChangeOverride ? onChangeOverride : function (_ref) {
|
|
240
263
|
var target = _ref.target;
|
|
241
|
-
return onChange(target.value ===
|
|
264
|
+
return onChange(target.value === '' ? options.emptyValue : target.value);
|
|
242
265
|
};
|
|
243
266
|
var handleBlur = function handleBlur(_ref2) {
|
|
244
267
|
var target = _ref2.target;
|
|
@@ -248,7 +271,7 @@ function BaseInputTemplate(props) {
|
|
|
248
271
|
var target = _ref3.target;
|
|
249
272
|
return onFocus(id, target.value);
|
|
250
273
|
};
|
|
251
|
-
var input = inputProps.type ===
|
|
274
|
+
var input = inputProps.type === 'number' || inputProps.type === 'integer' ? jsx(InputNumber, _extends({
|
|
252
275
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
253
276
|
id: id,
|
|
254
277
|
name: id,
|
|
@@ -261,7 +284,7 @@ function BaseInputTemplate(props) {
|
|
|
261
284
|
}, inputProps, {
|
|
262
285
|
value: value,
|
|
263
286
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
264
|
-
})) :
|
|
287
|
+
})) : jsx(Input, _extends({
|
|
265
288
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
266
289
|
id: id,
|
|
267
290
|
name: id,
|
|
@@ -275,14 +298,16 @@ function BaseInputTemplate(props) {
|
|
|
275
298
|
value: value,
|
|
276
299
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
277
300
|
}));
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
301
|
+
return jsxs(Fragment, {
|
|
302
|
+
children: [input, Array.isArray(schema.examples) && jsx("datalist", {
|
|
303
|
+
id: examplesId(id),
|
|
304
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
305
|
+
return jsx("option", {
|
|
306
|
+
value: example
|
|
307
|
+
}, example);
|
|
308
|
+
})
|
|
309
|
+
})]
|
|
310
|
+
});
|
|
286
311
|
}
|
|
287
312
|
|
|
288
313
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
@@ -295,9 +320,10 @@ function DescriptionField(props) {
|
|
|
295
320
|
if (!description) {
|
|
296
321
|
return null;
|
|
297
322
|
}
|
|
298
|
-
return
|
|
299
|
-
id: id
|
|
300
|
-
|
|
323
|
+
return jsx("span", {
|
|
324
|
+
id: id,
|
|
325
|
+
children: description
|
|
326
|
+
});
|
|
301
327
|
}
|
|
302
328
|
|
|
303
329
|
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
@@ -309,71 +335,82 @@ function ErrorList(_ref) {
|
|
|
309
335
|
registry = _ref.registry;
|
|
310
336
|
var translateString = registry.translateString;
|
|
311
337
|
var renderErrors = function renderErrors() {
|
|
312
|
-
return
|
|
313
|
-
className:
|
|
314
|
-
size:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
338
|
+
return jsx(List, {
|
|
339
|
+
className: 'list-group',
|
|
340
|
+
size: 'small',
|
|
341
|
+
children: errors.map(function (error, index) {
|
|
342
|
+
return jsx(List.Item, {
|
|
343
|
+
children: jsxs(Space, {
|
|
344
|
+
children: [jsx(ExclamationCircleOutlined, {}), error.stack]
|
|
345
|
+
})
|
|
346
|
+
}, index);
|
|
347
|
+
})
|
|
348
|
+
});
|
|
320
349
|
};
|
|
321
|
-
return
|
|
322
|
-
className:
|
|
350
|
+
return jsx(Alert, {
|
|
351
|
+
className: 'panel panel-danger errors',
|
|
323
352
|
description: renderErrors(),
|
|
324
353
|
message: translateString(TranslatableString.ErrorsLabel),
|
|
325
|
-
type:
|
|
354
|
+
type: 'error'
|
|
326
355
|
});
|
|
327
356
|
}
|
|
328
357
|
|
|
329
358
|
var _excluded = ["iconType", "icon", "uiSchema", "registry"];
|
|
330
359
|
function IconButton(props) {
|
|
331
360
|
var _props$iconType = props.iconType,
|
|
332
|
-
iconType = _props$iconType === void 0 ?
|
|
361
|
+
iconType = _props$iconType === void 0 ? 'default' : _props$iconType,
|
|
333
362
|
icon = props.icon,
|
|
334
363
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
335
|
-
return
|
|
364
|
+
return jsx(Button, _extends({
|
|
336
365
|
type: iconType,
|
|
337
366
|
icon: icon
|
|
338
367
|
}, otherProps));
|
|
339
368
|
}
|
|
340
369
|
function AddButton(props) {
|
|
341
370
|
var translateString = props.registry.translateString;
|
|
342
|
-
return
|
|
371
|
+
return jsx(IconButton, _extends({
|
|
343
372
|
title: translateString(TranslatableString.AddItemButton)
|
|
344
373
|
}, props, {
|
|
345
374
|
block: true,
|
|
346
|
-
iconType:
|
|
347
|
-
icon:
|
|
375
|
+
iconType: 'primary',
|
|
376
|
+
icon: jsx(PlusCircleOutlined, {})
|
|
377
|
+
}));
|
|
378
|
+
}
|
|
379
|
+
function CopyButton(props) {
|
|
380
|
+
var translateString = props.registry.translateString;
|
|
381
|
+
return jsx(IconButton, _extends({
|
|
382
|
+
title: translateString(TranslatableString.CopyButton)
|
|
383
|
+
}, props, {
|
|
384
|
+
icon: jsx(CopyOutlined, {})
|
|
348
385
|
}));
|
|
349
386
|
}
|
|
350
387
|
function MoveDownButton(props) {
|
|
351
388
|
var translateString = props.registry.translateString;
|
|
352
|
-
return
|
|
389
|
+
return jsx(IconButton, _extends({
|
|
353
390
|
title: translateString(TranslatableString.MoveDownButton)
|
|
354
391
|
}, props, {
|
|
355
|
-
icon:
|
|
392
|
+
icon: jsx(ArrowDownOutlined, {})
|
|
356
393
|
}));
|
|
357
394
|
}
|
|
358
395
|
function MoveUpButton(props) {
|
|
359
396
|
var translateString = props.registry.translateString;
|
|
360
|
-
return
|
|
397
|
+
return jsx(IconButton, _extends({
|
|
361
398
|
title: translateString(TranslatableString.MoveUpButton)
|
|
362
399
|
}, props, {
|
|
363
|
-
icon:
|
|
400
|
+
icon: jsx(ArrowUpOutlined, {})
|
|
364
401
|
}));
|
|
365
402
|
}
|
|
366
403
|
function RemoveButton(props) {
|
|
367
404
|
// The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead
|
|
368
405
|
var options = getUiOptions(props.uiSchema);
|
|
369
406
|
var translateString = props.registry.translateString;
|
|
370
|
-
return
|
|
407
|
+
return jsx(IconButton, _extends({
|
|
371
408
|
title: translateString(TranslatableString.RemoveButton)
|
|
372
409
|
}, props, {
|
|
373
410
|
danger: true,
|
|
374
411
|
block: !!options.block,
|
|
375
|
-
iconType:
|
|
376
|
-
icon:
|
|
412
|
+
iconType: 'primary',
|
|
413
|
+
icon: jsx(DeleteOutlined, {})
|
|
377
414
|
}));
|
|
378
415
|
}
|
|
379
416
|
|
|
@@ -389,13 +426,14 @@ function FieldErrorTemplate(props) {
|
|
|
389
426
|
return null;
|
|
390
427
|
}
|
|
391
428
|
var id = errorId(idSchema);
|
|
392
|
-
return
|
|
393
|
-
id: id
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
429
|
+
return jsx("div", {
|
|
430
|
+
id: id,
|
|
431
|
+
children: errors.map(function (error) {
|
|
432
|
+
return jsx("div", {
|
|
433
|
+
children: error
|
|
434
|
+
}, "field-" + id + "-error-" + error);
|
|
435
|
+
})
|
|
436
|
+
});
|
|
399
437
|
}
|
|
400
438
|
|
|
401
439
|
var VERTICAL_LABEL_COL$1 = {
|
|
@@ -439,13 +477,14 @@ function FieldTemplate(props) {
|
|
|
439
477
|
wrapperCol = _formContext$wrapperC === void 0 ? VERTICAL_WRAPPER_COL$1 : _formContext$wrapperC,
|
|
440
478
|
wrapperStyle = formContext.wrapperStyle;
|
|
441
479
|
var uiOptions = getUiOptions(uiSchema);
|
|
442
|
-
var WrapIfAdditionalTemplate = getTemplate(
|
|
480
|
+
var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
443
481
|
if (hidden) {
|
|
444
|
-
return
|
|
445
|
-
className:
|
|
446
|
-
|
|
482
|
+
return jsx("div", {
|
|
483
|
+
className: 'field-hidden',
|
|
484
|
+
children: children
|
|
485
|
+
});
|
|
447
486
|
}
|
|
448
|
-
return
|
|
487
|
+
return jsx(WrapIfAdditionalTemplate, {
|
|
449
488
|
classNames: classNames,
|
|
450
489
|
style: style,
|
|
451
490
|
disabled: disabled,
|
|
@@ -457,24 +496,26 @@ function FieldTemplate(props) {
|
|
|
457
496
|
required: required,
|
|
458
497
|
schema: schema,
|
|
459
498
|
uiSchema: uiSchema,
|
|
460
|
-
registry: registry
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
499
|
+
registry: registry,
|
|
500
|
+
children: id === 'root' ? children : jsx(Form$1.Item, {
|
|
501
|
+
colon: colon,
|
|
502
|
+
extra: rawDescription && description,
|
|
503
|
+
hasFeedback: schema.type !== 'array' && schema.type !== 'object',
|
|
504
|
+
help: !!rawHelp && help || (rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? errors : undefined),
|
|
505
|
+
htmlFor: id,
|
|
506
|
+
label: displayLabel && label,
|
|
507
|
+
labelCol: labelCol,
|
|
508
|
+
required: required,
|
|
509
|
+
style: wrapperStyle,
|
|
510
|
+
validateStatus: rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? 'error' : undefined,
|
|
511
|
+
wrapperCol: wrapperCol,
|
|
512
|
+
children: children
|
|
513
|
+
})
|
|
514
|
+
});
|
|
474
515
|
}
|
|
475
516
|
|
|
476
517
|
var DESCRIPTION_COL_STYLE = {
|
|
477
|
-
paddingBottom:
|
|
518
|
+
paddingBottom: '8px'
|
|
478
519
|
};
|
|
479
520
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
480
521
|
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
@@ -497,14 +538,14 @@ function ObjectFieldTemplate(props) {
|
|
|
497
538
|
title = props.title,
|
|
498
539
|
uiSchema = props.uiSchema;
|
|
499
540
|
var uiOptions = getUiOptions(uiSchema);
|
|
500
|
-
var TitleFieldTemplate = getTemplate(
|
|
501
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
541
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
542
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
502
543
|
// Button templates are not overridden in the uiSchema
|
|
503
544
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
504
545
|
var _formContext$colSpan = formContext.colSpan,
|
|
505
546
|
colSpan = _formContext$colSpan === void 0 ? 24 : _formContext$colSpan,
|
|
506
547
|
_formContext$labelAli = formContext.labelAlign,
|
|
507
|
-
labelAlign = _formContext$labelAli === void 0 ?
|
|
548
|
+
labelAlign = _formContext$labelAli === void 0 ? 'right' : _formContext$labelAli,
|
|
508
549
|
_formContext$rowGutte = formContext.rowGutter,
|
|
509
550
|
rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
|
|
510
551
|
var findSchema = function findSchema(element) {
|
|
@@ -528,7 +569,7 @@ function ObjectFieldTemplate(props) {
|
|
|
528
569
|
var widget = findUiSchemaWidget(element);
|
|
529
570
|
var defaultColSpan = properties.length < 2 ||
|
|
530
571
|
// Single or no field in object.
|
|
531
|
-
type ===
|
|
572
|
+
type === 'object' || type === 'array' || widget === 'textarea' ? 24 : 12;
|
|
532
573
|
if (isObject(colSpan)) {
|
|
533
574
|
var colSpanObj = colSpan;
|
|
534
575
|
if (isString(widget)) {
|
|
@@ -546,58 +587,67 @@ function ObjectFieldTemplate(props) {
|
|
|
546
587
|
}
|
|
547
588
|
return defaultColSpan;
|
|
548
589
|
};
|
|
549
|
-
return
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
590
|
+
return jsx(ConfigConsumer, {
|
|
591
|
+
children: function children(configProps) {
|
|
592
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
593
|
+
var prefixCls = getPrefixCls('form');
|
|
594
|
+
var labelClsBasic = prefixCls + "-item-label";
|
|
595
|
+
var labelColClassName = classNames(labelClsBasic, labelAlign === 'left' && labelClsBasic + "-left"
|
|
596
|
+
// labelCol.className,
|
|
597
|
+
);
|
|
556
598
|
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
599
|
+
return jsxs("fieldset", {
|
|
600
|
+
id: idSchema.$id,
|
|
601
|
+
children: [jsxs(Row, {
|
|
602
|
+
gutter: rowGutter,
|
|
603
|
+
children: [(uiOptions.title || title) && jsx(Col, {
|
|
604
|
+
className: labelColClassName,
|
|
605
|
+
span: 24,
|
|
606
|
+
children: jsx(TitleFieldTemplate, {
|
|
607
|
+
id: titleId(idSchema),
|
|
608
|
+
title: uiOptions.title || title,
|
|
609
|
+
required: required,
|
|
610
|
+
schema: schema,
|
|
611
|
+
uiSchema: uiSchema,
|
|
612
|
+
registry: registry
|
|
613
|
+
})
|
|
614
|
+
}), (uiOptions.description || description) && jsx(Col, {
|
|
615
|
+
span: 24,
|
|
616
|
+
style: DESCRIPTION_COL_STYLE,
|
|
617
|
+
children: jsx(DescriptionFieldTemplate, {
|
|
618
|
+
id: descriptionId(idSchema),
|
|
619
|
+
description: uiOptions.description || description,
|
|
620
|
+
schema: schema,
|
|
621
|
+
uiSchema: uiSchema,
|
|
622
|
+
registry: registry
|
|
623
|
+
})
|
|
624
|
+
}), properties.filter(function (e) {
|
|
625
|
+
return !e.hidden;
|
|
626
|
+
}).map(function (element) {
|
|
627
|
+
return jsx(Col, {
|
|
628
|
+
span: calculateColSpan(element),
|
|
629
|
+
children: element.content
|
|
630
|
+
}, element.name);
|
|
631
|
+
})]
|
|
632
|
+
}), canExpand(schema, uiSchema, formData) && jsx(Col, {
|
|
633
|
+
span: 24,
|
|
634
|
+
children: jsx(Row, {
|
|
635
|
+
gutter: rowGutter,
|
|
636
|
+
justify: 'end',
|
|
637
|
+
children: jsx(Col, {
|
|
638
|
+
flex: '192px',
|
|
639
|
+
children: jsx(AddButton, {
|
|
640
|
+
className: 'object-property-expand',
|
|
641
|
+
disabled: disabled || readonly,
|
|
642
|
+
onClick: onAddClick(schema),
|
|
643
|
+
uiSchema: uiSchema,
|
|
644
|
+
registry: registry
|
|
645
|
+
})
|
|
646
|
+
})
|
|
647
|
+
})
|
|
648
|
+
})]
|
|
649
|
+
});
|
|
650
|
+
}
|
|
601
651
|
});
|
|
602
652
|
}
|
|
603
653
|
|
|
@@ -612,11 +662,12 @@ function SubmitButton(_ref) {
|
|
|
612
662
|
if (norender) {
|
|
613
663
|
return null;
|
|
614
664
|
}
|
|
615
|
-
return
|
|
616
|
-
type:
|
|
665
|
+
return jsx(Button, _extends({
|
|
666
|
+
type: 'submit'
|
|
617
667
|
}, submitButtonProps, {
|
|
618
|
-
htmlType:
|
|
619
|
-
|
|
668
|
+
htmlType: 'submit',
|
|
669
|
+
children: submitText
|
|
670
|
+
}));
|
|
620
671
|
}
|
|
621
672
|
|
|
622
673
|
/** The `TitleField` is the template to use to render the title of a field
|
|
@@ -632,8 +683,8 @@ function TitleField(_ref) {
|
|
|
632
683
|
var _formContext$colon = formContext.colon,
|
|
633
684
|
colon = _formContext$colon === void 0 ? true : _formContext$colon;
|
|
634
685
|
var labelChildren = title;
|
|
635
|
-
if (colon && typeof title ===
|
|
636
|
-
labelChildren = title.replace(/[::]\s*$/,
|
|
686
|
+
if (colon && typeof title === 'string' && title.trim() !== '') {
|
|
687
|
+
labelChildren = title.replace(/[::]\s*$/, '');
|
|
637
688
|
}
|
|
638
689
|
var handleLabelClick = function handleLabelClick() {
|
|
639
690
|
if (!id) {
|
|
@@ -644,17 +695,20 @@ function TitleField(_ref) {
|
|
|
644
695
|
control.focus();
|
|
645
696
|
}
|
|
646
697
|
};
|
|
647
|
-
return title ?
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
698
|
+
return title ? jsx(ConfigConsumer, {
|
|
699
|
+
children: function children(configProps) {
|
|
700
|
+
var _classNames;
|
|
701
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
702
|
+
var prefixCls = getPrefixCls('form');
|
|
703
|
+
var labelClassName = classNames((_classNames = {}, _classNames[prefixCls + "-item-required"] = required, _classNames[prefixCls + "-item-no-colon"] = !colon, _classNames));
|
|
704
|
+
return jsx("label", {
|
|
705
|
+
className: labelClassName,
|
|
706
|
+
htmlFor: id,
|
|
707
|
+
onClick: handleLabelClick,
|
|
708
|
+
title: typeof title === 'string' ? title : '',
|
|
709
|
+
children: labelChildren
|
|
710
|
+
});
|
|
711
|
+
}
|
|
658
712
|
}) : null;
|
|
659
713
|
}
|
|
660
714
|
|
|
@@ -665,7 +719,7 @@ var VERTICAL_WRAPPER_COL = {
|
|
|
665
719
|
span: 24
|
|
666
720
|
};
|
|
667
721
|
var INPUT_STYLE$1 = {
|
|
668
|
-
width:
|
|
722
|
+
width: '100%'
|
|
669
723
|
};
|
|
670
724
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
671
725
|
* part of an `additionalProperties` part of a schema.
|
|
@@ -696,7 +750,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
696
750
|
_registry$formContext4 = _registry$formContext.rowGutter,
|
|
697
751
|
rowGutter = _registry$formContext4 === void 0 ? 24 : _registry$formContext4,
|
|
698
752
|
_registry$formContext5 = _registry$formContext.toolbarAlign,
|
|
699
|
-
toolbarAlign = _registry$formContext5 === void 0 ?
|
|
753
|
+
toolbarAlign = _registry$formContext5 === void 0 ? 'top' : _registry$formContext5,
|
|
700
754
|
_registry$formContext6 = _registry$formContext.wrapperCol,
|
|
701
755
|
wrapperCol = _registry$formContext6 === void 0 ? VERTICAL_WRAPPER_COL : _registry$formContext6,
|
|
702
756
|
wrapperStyle = _registry$formContext.wrapperStyle;
|
|
@@ -707,10 +761,11 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
707
761
|
var keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
708
762
|
var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
|
|
709
763
|
if (!additional) {
|
|
710
|
-
return
|
|
764
|
+
return jsx("div", {
|
|
711
765
|
className: classNames,
|
|
712
|
-
style: style
|
|
713
|
-
|
|
766
|
+
style: style,
|
|
767
|
+
children: children
|
|
768
|
+
});
|
|
714
769
|
}
|
|
715
770
|
var handleBlur = function handleBlur(_ref) {
|
|
716
771
|
var target = _ref.target;
|
|
@@ -721,48 +776,55 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
721
776
|
var buttonUiOptions = _extends({}, uiSchema, (_extends2 = {}, _extends2[UI_OPTIONS_KEY] = _extends({}, uiOptions, {
|
|
722
777
|
block: true
|
|
723
778
|
}), _extends2));
|
|
724
|
-
return
|
|
779
|
+
return jsx("div", {
|
|
725
780
|
className: classNames,
|
|
726
|
-
style: style
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
781
|
+
style: style,
|
|
782
|
+
children: jsxs(Row, {
|
|
783
|
+
align: toolbarAlign,
|
|
784
|
+
gutter: rowGutter,
|
|
785
|
+
children: [jsx(Col, {
|
|
786
|
+
className: 'form-additional',
|
|
787
|
+
flex: '1',
|
|
788
|
+
children: jsx("div", {
|
|
789
|
+
className: 'form-group',
|
|
790
|
+
children: jsx(Form$1.Item, {
|
|
791
|
+
colon: colon,
|
|
792
|
+
className: 'form-group',
|
|
793
|
+
hasFeedback: true,
|
|
794
|
+
htmlFor: id + "-key",
|
|
795
|
+
label: keyLabel,
|
|
796
|
+
labelCol: labelCol,
|
|
797
|
+
required: required,
|
|
798
|
+
style: wrapperStyle,
|
|
799
|
+
wrapperCol: wrapperCol,
|
|
800
|
+
children: jsx(Input, {
|
|
801
|
+
className: 'form-control',
|
|
802
|
+
defaultValue: label,
|
|
803
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
804
|
+
id: id + "-key",
|
|
805
|
+
name: id + "-key",
|
|
806
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
807
|
+
style: INPUT_STYLE$1,
|
|
808
|
+
type: 'text'
|
|
809
|
+
})
|
|
810
|
+
})
|
|
811
|
+
})
|
|
812
|
+
}), jsx(Col, {
|
|
813
|
+
className: 'form-additional',
|
|
814
|
+
flex: '1',
|
|
815
|
+
children: children
|
|
816
|
+
}), jsx(Col, {
|
|
817
|
+
flex: '192px',
|
|
818
|
+
children: jsx(RemoveButton, {
|
|
819
|
+
className: 'array-item-remove',
|
|
820
|
+
disabled: disabled || readonly,
|
|
821
|
+
onClick: onDropPropertyClick(label),
|
|
822
|
+
uiSchema: buttonUiOptions,
|
|
823
|
+
registry: registry
|
|
824
|
+
})
|
|
825
|
+
})]
|
|
826
|
+
})
|
|
827
|
+
});
|
|
766
828
|
}
|
|
767
829
|
|
|
768
830
|
function generateTemplates() {
|
|
@@ -772,6 +834,7 @@ function generateTemplates() {
|
|
|
772
834
|
BaseInputTemplate: BaseInputTemplate,
|
|
773
835
|
ButtonTemplates: {
|
|
774
836
|
AddButton: AddButton,
|
|
837
|
+
CopyButton: CopyButton,
|
|
775
838
|
MoveDownButton: MoveDownButton,
|
|
776
839
|
MoveUpButton: MoveUpButton,
|
|
777
840
|
RemoveButton: RemoveButton,
|
|
@@ -814,29 +877,29 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
814
877
|
minute = state.minute,
|
|
815
878
|
second = state.second;
|
|
816
879
|
var data = [{
|
|
817
|
-
type:
|
|
880
|
+
type: 'year',
|
|
818
881
|
range: yearsRange,
|
|
819
882
|
value: year
|
|
820
883
|
}, {
|
|
821
|
-
type:
|
|
884
|
+
type: 'month',
|
|
822
885
|
range: [1, 12],
|
|
823
886
|
value: month
|
|
824
887
|
}, {
|
|
825
|
-
type:
|
|
888
|
+
type: 'day',
|
|
826
889
|
range: [1, 31],
|
|
827
890
|
value: day
|
|
828
891
|
}];
|
|
829
892
|
if (time) {
|
|
830
893
|
data.push({
|
|
831
|
-
type:
|
|
894
|
+
type: 'hour',
|
|
832
895
|
range: [0, 23],
|
|
833
896
|
value: hour || -1
|
|
834
897
|
}, {
|
|
835
|
-
type:
|
|
898
|
+
type: 'minute',
|
|
836
899
|
range: [0, 59],
|
|
837
900
|
value: minute || -1
|
|
838
901
|
}, {
|
|
839
|
-
type:
|
|
902
|
+
type: 'second',
|
|
840
903
|
range: [0, 59],
|
|
841
904
|
value: second || -1
|
|
842
905
|
});
|
|
@@ -869,7 +932,7 @@ function AltDateWidget(props) {
|
|
|
869
932
|
}, [showTime, value]);
|
|
870
933
|
var handleChange = function handleChange(property, nextValue) {
|
|
871
934
|
var _extends2;
|
|
872
|
-
var nextState = _extends({}, state, (_extends2 = {}, _extends2[property] = typeof nextValue ===
|
|
935
|
+
var nextState = _extends({}, state, (_extends2 = {}, _extends2[property] = typeof nextValue === 'undefined' ? -1 : nextValue, _extends2));
|
|
873
936
|
if (readyForChange(nextState)) {
|
|
874
937
|
onChange(toDateString(nextState, showTime));
|
|
875
938
|
} else {
|
|
@@ -892,9 +955,9 @@ function AltDateWidget(props) {
|
|
|
892
955
|
onChange(undefined);
|
|
893
956
|
};
|
|
894
957
|
var renderDateElement = function renderDateElement(elemProps) {
|
|
895
|
-
return
|
|
958
|
+
return jsx(SelectWidget, {
|
|
896
959
|
autofocus: elemProps.autofocus,
|
|
897
|
-
className:
|
|
960
|
+
className: 'form-control',
|
|
898
961
|
disabled: elemProps.disabled,
|
|
899
962
|
id: elemProps.id,
|
|
900
963
|
name: elemProps.name,
|
|
@@ -909,51 +972,56 @@ function AltDateWidget(props) {
|
|
|
909
972
|
placeholder: elemProps.type,
|
|
910
973
|
readonly: elemProps.readonly,
|
|
911
974
|
schema: {
|
|
912
|
-
type:
|
|
975
|
+
type: 'integer'
|
|
913
976
|
},
|
|
914
977
|
value: elemProps.value,
|
|
915
978
|
registry: registry,
|
|
916
|
-
label:
|
|
979
|
+
label: '',
|
|
917
980
|
"aria-describedby": ariaDescribedByIds(id)
|
|
918
981
|
});
|
|
919
982
|
};
|
|
920
|
-
return
|
|
921
|
-
gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)]
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
983
|
+
return jsxs(Row, {
|
|
984
|
+
gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)],
|
|
985
|
+
children: [dateElementProps(state, showTime, options.yearsRange).map(function (elemProps, i) {
|
|
986
|
+
var elemId = id + '_' + elemProps.type;
|
|
987
|
+
return jsx(Col, {
|
|
988
|
+
flex: '88px',
|
|
989
|
+
children: renderDateElement(_extends({}, elemProps, {
|
|
990
|
+
autofocus: autofocus && i === 0,
|
|
991
|
+
disabled: disabled,
|
|
992
|
+
id: elemId,
|
|
993
|
+
name: id,
|
|
994
|
+
onBlur: onBlur,
|
|
995
|
+
onFocus: onFocus,
|
|
996
|
+
readonly: readonly,
|
|
997
|
+
registry: registry,
|
|
998
|
+
select: handleChange,
|
|
999
|
+
// NOTE: antd components accept -1 rather than issue a warning
|
|
1000
|
+
// like material-ui, so we need to convert -1 to undefined here.
|
|
1001
|
+
value: elemProps.value < 0 ? undefined : elemProps.value
|
|
1002
|
+
}))
|
|
1003
|
+
}, elemId);
|
|
1004
|
+
}), !options.hideNowButton && jsx(Col, {
|
|
1005
|
+
flex: '88px',
|
|
1006
|
+
children: jsx(Button, {
|
|
1007
|
+
block: true,
|
|
1008
|
+
className: 'btn-now',
|
|
1009
|
+
onClick: handleNow,
|
|
1010
|
+
type: 'primary',
|
|
1011
|
+
children: translateString(TranslatableString.NowLabel)
|
|
1012
|
+
})
|
|
1013
|
+
}), !options.hideClearButton && jsx(Col, {
|
|
1014
|
+
flex: '88px',
|
|
1015
|
+
children: jsx(Button, {
|
|
1016
|
+
block: true,
|
|
1017
|
+
className: 'btn-clear',
|
|
1018
|
+
danger: true,
|
|
1019
|
+
onClick: handleClear,
|
|
1020
|
+
type: 'primary',
|
|
1021
|
+
children: translateString(TranslatableString.ClearLabel)
|
|
1022
|
+
})
|
|
1023
|
+
})]
|
|
1024
|
+
});
|
|
957
1025
|
}
|
|
958
1026
|
AltDateWidget.defaultProps = {
|
|
959
1027
|
autofocus: false,
|
|
@@ -967,7 +1035,7 @@ AltDateWidget.defaultProps = {
|
|
|
967
1035
|
|
|
968
1036
|
function AltDateTimeWidget(props) {
|
|
969
1037
|
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
970
|
-
return
|
|
1038
|
+
return jsx(AltDateWidget, _extends({
|
|
971
1039
|
showTime: true
|
|
972
1040
|
}, props));
|
|
973
1041
|
}
|
|
@@ -1016,23 +1084,25 @@ function CheckboxesWidget(_ref) {
|
|
|
1016
1084
|
onFocus: !readonly ? handleFocus : undefined
|
|
1017
1085
|
};
|
|
1018
1086
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
|
|
1019
|
-
return Array.isArray(enumOptions) && enumOptions.length > 0 ?
|
|
1087
|
+
return Array.isArray(enumOptions) && enumOptions.length > 0 ? jsx(Checkbox.Group, _extends({
|
|
1020
1088
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1021
1089
|
name: id,
|
|
1022
1090
|
onChange: !readonly ? handleChange : undefined,
|
|
1023
1091
|
value: selectedIndexes
|
|
1024
1092
|
}, extraProps, {
|
|
1025
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1093
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1094
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
1095
|
+
return jsxs("span", {
|
|
1096
|
+
children: [jsx(Checkbox, {
|
|
1097
|
+
id: optionId(id, i),
|
|
1098
|
+
name: id,
|
|
1099
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1100
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1101
|
+
value: String(i),
|
|
1102
|
+
children: option.label
|
|
1103
|
+
}), !inline && jsx("br", {})]
|
|
1104
|
+
}, i);
|
|
1105
|
+
})
|
|
1036
1106
|
})) : null;
|
|
1037
1107
|
}
|
|
1038
1108
|
|
|
@@ -1072,22 +1142,23 @@ function CheckboxWidget(props) {
|
|
|
1072
1142
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1073
1143
|
onFocus: !readonly ? handleFocus : undefined
|
|
1074
1144
|
};
|
|
1075
|
-
return
|
|
1145
|
+
return jsx(Checkbox, _extends({
|
|
1076
1146
|
autoFocus: autofocus,
|
|
1077
|
-
checked: typeof value ===
|
|
1147
|
+
checked: typeof value === 'undefined' ? false : value,
|
|
1078
1148
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1079
1149
|
id: id,
|
|
1080
1150
|
name: id,
|
|
1081
1151
|
onChange: !readonly ? handleChange : undefined
|
|
1082
1152
|
}, extraProps, {
|
|
1083
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1084
|
-
|
|
1153
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1154
|
+
children: label
|
|
1155
|
+
}));
|
|
1085
1156
|
}
|
|
1086
1157
|
|
|
1087
1158
|
var DatePicker = /*#__PURE__*/generatePicker(dayjsGenerateConfig);
|
|
1088
1159
|
|
|
1089
1160
|
var DATE_PICKER_STYLE$1 = {
|
|
1090
|
-
width:
|
|
1161
|
+
width: '100%'
|
|
1091
1162
|
};
|
|
1092
1163
|
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
1093
1164
|
* the value to/from utc using the appropriate utility functions.
|
|
@@ -1118,7 +1189,7 @@ function DateTimeWidget(props) {
|
|
|
1118
1189
|
var getPopupContainer = function getPopupContainer(node) {
|
|
1119
1190
|
return node.parentNode;
|
|
1120
1191
|
};
|
|
1121
|
-
return
|
|
1192
|
+
return jsx(DatePicker, {
|
|
1122
1193
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1123
1194
|
getPopupContainer: getPopupContainer,
|
|
1124
1195
|
id: id,
|
|
@@ -1135,7 +1206,7 @@ function DateTimeWidget(props) {
|
|
|
1135
1206
|
}
|
|
1136
1207
|
|
|
1137
1208
|
var DATE_PICKER_STYLE = {
|
|
1138
|
-
width:
|
|
1209
|
+
width: '100%'
|
|
1139
1210
|
};
|
|
1140
1211
|
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
1141
1212
|
* the value to undefined when it is falsy during the `onChange` handling.
|
|
@@ -1155,7 +1226,7 @@ function DateWidget(props) {
|
|
|
1155
1226
|
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1156
1227
|
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1157
1228
|
var handleChange = function handleChange(nextValue) {
|
|
1158
|
-
return onChange(nextValue && nextValue.format(
|
|
1229
|
+
return onChange(nextValue && nextValue.format('YYYY-MM-DD'));
|
|
1159
1230
|
};
|
|
1160
1231
|
var handleBlur = function handleBlur() {
|
|
1161
1232
|
return onBlur(id, value);
|
|
@@ -1166,7 +1237,7 @@ function DateWidget(props) {
|
|
|
1166
1237
|
var getPopupContainer = function getPopupContainer(node) {
|
|
1167
1238
|
return node.parentNode;
|
|
1168
1239
|
};
|
|
1169
|
-
return
|
|
1240
|
+
return jsx(DatePicker, {
|
|
1170
1241
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1171
1242
|
getPopupContainer: getPopupContainer,
|
|
1172
1243
|
id: id,
|
|
@@ -1199,10 +1270,10 @@ function PasswordWidget(props) {
|
|
|
1199
1270
|
value = props.value;
|
|
1200
1271
|
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1201
1272
|
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1202
|
-
var emptyValue = options.emptyValue ||
|
|
1273
|
+
var emptyValue = options.emptyValue || '';
|
|
1203
1274
|
var handleChange = function handleChange(_ref) {
|
|
1204
1275
|
var target = _ref.target;
|
|
1205
|
-
return onChange(target.value ===
|
|
1276
|
+
return onChange(target.value === '' ? emptyValue : target.value);
|
|
1206
1277
|
};
|
|
1207
1278
|
var handleBlur = function handleBlur(_ref2) {
|
|
1208
1279
|
var target = _ref2.target;
|
|
@@ -1212,7 +1283,7 @@ function PasswordWidget(props) {
|
|
|
1212
1283
|
var target = _ref3.target;
|
|
1213
1284
|
return onFocus(id, target.value);
|
|
1214
1285
|
};
|
|
1215
|
-
return
|
|
1286
|
+
return jsx(Input.Password, {
|
|
1216
1287
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1217
1288
|
id: id,
|
|
1218
1289
|
name: id,
|
|
@@ -1220,7 +1291,7 @@ function PasswordWidget(props) {
|
|
|
1220
1291
|
onChange: !readonly ? handleChange : undefined,
|
|
1221
1292
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1222
1293
|
placeholder: placeholder,
|
|
1223
|
-
value: value ||
|
|
1294
|
+
value: value || '',
|
|
1224
1295
|
"aria-describedby": ariaDescribedByIds(id)
|
|
1225
1296
|
});
|
|
1226
1297
|
}
|
|
@@ -1259,7 +1330,7 @@ function RadioWidget(_ref) {
|
|
|
1259
1330
|
return onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1260
1331
|
};
|
|
1261
1332
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions);
|
|
1262
|
-
return
|
|
1333
|
+
return jsx(Radio.Group, {
|
|
1263
1334
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1264
1335
|
id: id,
|
|
1265
1336
|
name: id,
|
|
@@ -1267,17 +1338,18 @@ function RadioWidget(_ref) {
|
|
|
1267
1338
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1268
1339
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1269
1340
|
value: selectedIndexes,
|
|
1270
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1341
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1342
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
1343
|
+
return jsx(Radio, {
|
|
1344
|
+
id: optionId(id, i),
|
|
1345
|
+
name: id,
|
|
1346
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1347
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1348
|
+
value: String(i),
|
|
1349
|
+
children: option.label
|
|
1350
|
+
}, i);
|
|
1351
|
+
})
|
|
1352
|
+
});
|
|
1281
1353
|
}
|
|
1282
1354
|
|
|
1283
1355
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -1304,9 +1376,9 @@ function RangeWidget(props) {
|
|
|
1304
1376
|
min = _rangeSpec.min,
|
|
1305
1377
|
max = _rangeSpec.max,
|
|
1306
1378
|
step = _rangeSpec.step;
|
|
1307
|
-
var emptyValue = options.emptyValue ||
|
|
1379
|
+
var emptyValue = options.emptyValue || '';
|
|
1308
1380
|
var handleChange = function handleChange(nextValue) {
|
|
1309
|
-
return onChange(nextValue ===
|
|
1381
|
+
return onChange(nextValue === '' ? emptyValue : nextValue);
|
|
1310
1382
|
};
|
|
1311
1383
|
var handleBlur = function handleBlur() {
|
|
1312
1384
|
return onBlur(id, value);
|
|
@@ -1321,7 +1393,7 @@ function RangeWidget(props) {
|
|
|
1321
1393
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1322
1394
|
onFocus: !readonly ? handleFocus : undefined
|
|
1323
1395
|
};
|
|
1324
|
-
return
|
|
1396
|
+
return jsx(Slider, _extends({
|
|
1325
1397
|
autoFocus: autofocus,
|
|
1326
1398
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1327
1399
|
id: id,
|
|
@@ -1337,7 +1409,7 @@ function RangeWidget(props) {
|
|
|
1337
1409
|
}
|
|
1338
1410
|
|
|
1339
1411
|
var SELECT_STYLE = {
|
|
1340
|
-
width:
|
|
1412
|
+
width: '100%'
|
|
1341
1413
|
};
|
|
1342
1414
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
1343
1415
|
* It is typically used with string properties constrained with enum options.
|
|
@@ -1388,12 +1460,12 @@ function SelectWidget(_ref) {
|
|
|
1388
1460
|
var extraProps = {
|
|
1389
1461
|
name: id
|
|
1390
1462
|
};
|
|
1391
|
-
return
|
|
1463
|
+
return jsx(Select, _extends({
|
|
1392
1464
|
autoFocus: autofocus,
|
|
1393
1465
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1394
1466
|
getPopupContainer: getPopupContainer,
|
|
1395
1467
|
id: id,
|
|
1396
|
-
mode: typeof multiple !==
|
|
1468
|
+
mode: typeof multiple !== 'undefined' ? 'multiple' : undefined,
|
|
1397
1469
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1398
1470
|
onChange: !readonly ? handleChange : undefined,
|
|
1399
1471
|
onFocus: !readonly ? handleFocus : undefined,
|
|
@@ -1402,20 +1474,21 @@ function SelectWidget(_ref) {
|
|
|
1402
1474
|
value: selectedIndexes
|
|
1403
1475
|
}, extraProps, {
|
|
1404
1476
|
filterOption: filterOption,
|
|
1405
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1477
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1478
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (_ref2, index) {
|
|
1479
|
+
var optionValue = _ref2.value,
|
|
1480
|
+
optionLabel = _ref2.label;
|
|
1481
|
+
return jsx(Select.Option, {
|
|
1482
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
|
|
1483
|
+
value: String(index),
|
|
1484
|
+
children: optionLabel
|
|
1485
|
+
}, String(index));
|
|
1486
|
+
})
|
|
1414
1487
|
}));
|
|
1415
1488
|
}
|
|
1416
1489
|
|
|
1417
1490
|
var INPUT_STYLE = {
|
|
1418
|
-
width:
|
|
1491
|
+
width: '100%'
|
|
1419
1492
|
};
|
|
1420
1493
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1421
1494
|
*
|
|
@@ -1436,7 +1509,7 @@ function TextareaWidget(_ref) {
|
|
|
1436
1509
|
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1437
1510
|
var handleChange = function handleChange(_ref2) {
|
|
1438
1511
|
var target = _ref2.target;
|
|
1439
|
-
return onChange(target.value ===
|
|
1512
|
+
return onChange(target.value === '' ? options.emptyValue : target.value);
|
|
1440
1513
|
};
|
|
1441
1514
|
var handleBlur = function handleBlur(_ref3) {
|
|
1442
1515
|
var target = _ref3.target;
|
|
@@ -1449,9 +1522,9 @@ function TextareaWidget(_ref) {
|
|
|
1449
1522
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1450
1523
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1451
1524
|
var extraProps = {
|
|
1452
|
-
type:
|
|
1525
|
+
type: 'textarea'
|
|
1453
1526
|
};
|
|
1454
|
-
return
|
|
1527
|
+
return jsx(Input.TextArea, _extends({
|
|
1455
1528
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1456
1529
|
id: id,
|
|
1457
1530
|
name: id,
|