@rjsf/antd 5.2.0 → 5.2.1
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 +436 -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 +434 -380
- package/dist/antd.esm.js.map +1 -1
- package/dist/antd.umd.development.js +438 -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 +5 -5
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';
|
|
@@ -20,6 +20,7 @@ import Form$1 from 'antd/es/form';
|
|
|
20
20
|
import isObject from 'lodash-es/isObject';
|
|
21
21
|
import isNumber from 'lodash-es/isNumber';
|
|
22
22
|
import isString from 'lodash-es/isString';
|
|
23
|
+
import { useState, useEffect } from 'react';
|
|
23
24
|
import Checkbox from 'antd/es/checkbox';
|
|
24
25
|
import dayjs from 'dayjs';
|
|
25
26
|
import dayjsGenerateConfig from 'rc-picker/es/generate/dayjs';
|
|
@@ -29,10 +30,10 @@ import Slider from 'antd/es/slider';
|
|
|
29
30
|
import Select from 'antd/es/select';
|
|
30
31
|
|
|
31
32
|
var BTN_GRP_STYLE = {
|
|
32
|
-
width:
|
|
33
|
+
width: '100%'
|
|
33
34
|
};
|
|
34
35
|
var BTN_STYLE = {
|
|
35
|
-
width:
|
|
36
|
+
width: 'calc(100% / 3)'
|
|
36
37
|
};
|
|
37
38
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
38
39
|
*
|
|
@@ -59,36 +60,39 @@ function ArrayFieldItemTemplate(props) {
|
|
|
59
60
|
_registry$formContext2 = _registry$formContext.rowGutter,
|
|
60
61
|
rowGutter = _registry$formContext2 === void 0 ? 24 : _registry$formContext2,
|
|
61
62
|
_registry$formContext3 = _registry$formContext.toolbarAlign,
|
|
62
|
-
toolbarAlign = _registry$formContext3 === void 0 ?
|
|
63
|
-
return
|
|
63
|
+
toolbarAlign = _registry$formContext3 === void 0 ? 'top' : _registry$formContext3;
|
|
64
|
+
return jsxs(Row, {
|
|
64
65
|
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
|
-
|
|
66
|
+
gutter: rowGutter,
|
|
67
|
+
children: [jsx(Col, {
|
|
68
|
+
flex: '1',
|
|
69
|
+
children: children
|
|
70
|
+
}), hasToolbar && jsx(Col, {
|
|
71
|
+
flex: '192px',
|
|
72
|
+
children: jsxs(Button.Group, {
|
|
73
|
+
style: BTN_GRP_STYLE,
|
|
74
|
+
children: [(hasMoveUp || hasMoveDown) && jsx(MoveUpButton, {
|
|
75
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
76
|
+
onClick: onReorderClick(index, index - 1),
|
|
77
|
+
style: BTN_STYLE,
|
|
78
|
+
uiSchema: uiSchema,
|
|
79
|
+
registry: registry
|
|
80
|
+
}), (hasMoveUp || hasMoveDown) && jsx(MoveDownButton, {
|
|
81
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
82
|
+
onClick: onReorderClick(index, index + 1),
|
|
83
|
+
style: BTN_STYLE,
|
|
84
|
+
uiSchema: uiSchema,
|
|
85
|
+
registry: registry
|
|
86
|
+
}), hasRemove && jsx(RemoveButton, {
|
|
87
|
+
disabled: disabled || readonly,
|
|
88
|
+
onClick: onDropIndexClick(index),
|
|
89
|
+
style: BTN_STYLE,
|
|
90
|
+
uiSchema: uiSchema,
|
|
91
|
+
registry: registry
|
|
92
|
+
})]
|
|
93
|
+
})
|
|
94
|
+
})]
|
|
95
|
+
}, "array-item-" + index);
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
function _extends() {
|
|
@@ -120,7 +124,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
120
124
|
|
|
121
125
|
var _excluded$1 = ["key"];
|
|
122
126
|
var DESCRIPTION_COL_STYLE$1 = {
|
|
123
|
-
paddingBottom:
|
|
127
|
+
paddingBottom: '8px'
|
|
124
128
|
};
|
|
125
129
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
126
130
|
*
|
|
@@ -141,75 +145,83 @@ function ArrayFieldTemplate(props) {
|
|
|
141
145
|
title = props.title,
|
|
142
146
|
uiSchema = props.uiSchema;
|
|
143
147
|
var uiOptions = getUiOptions(uiSchema);
|
|
144
|
-
var ArrayFieldDescriptionTemplate = getTemplate(
|
|
145
|
-
var ArrayFieldItemTemplate = getTemplate(
|
|
146
|
-
var ArrayFieldTitleTemplate = getTemplate(
|
|
148
|
+
var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
149
|
+
var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
150
|
+
var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
147
151
|
// Button templates are not overridden in the uiSchema
|
|
148
152
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
149
153
|
var _formContext$labelAli = formContext.labelAlign,
|
|
150
|
-
labelAlign = _formContext$labelAli === void 0 ?
|
|
154
|
+
labelAlign = _formContext$labelAli === void 0 ? 'right' : _formContext$labelAli,
|
|
151
155
|
_formContext$rowGutte = formContext.rowGutter,
|
|
152
156
|
rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
|
|
153
|
-
return
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
return jsx(ConfigConsumer, {
|
|
158
|
+
children: function children(configProps) {
|
|
159
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
160
|
+
var prefixCls = getPrefixCls('form');
|
|
161
|
+
var labelClsBasic = prefixCls + "-item-label";
|
|
162
|
+
var labelColClassName = classNames(labelClsBasic, labelAlign === 'left' && labelClsBasic + "-left"
|
|
163
|
+
// labelCol.className,
|
|
164
|
+
);
|
|
160
165
|
|
|
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
|
-
|
|
166
|
+
return jsx("fieldset", {
|
|
167
|
+
className: className,
|
|
168
|
+
id: idSchema.$id,
|
|
169
|
+
children: jsxs(Row, {
|
|
170
|
+
gutter: rowGutter,
|
|
171
|
+
children: [(uiOptions.title || title) && jsx(Col, {
|
|
172
|
+
className: labelColClassName,
|
|
173
|
+
span: 24,
|
|
174
|
+
children: jsx(ArrayFieldTitleTemplate, {
|
|
175
|
+
idSchema: idSchema,
|
|
176
|
+
required: required,
|
|
177
|
+
title: uiOptions.title || title,
|
|
178
|
+
schema: schema,
|
|
179
|
+
uiSchema: uiSchema,
|
|
180
|
+
registry: registry
|
|
181
|
+
})
|
|
182
|
+
}), (uiOptions.description || schema.description) && jsx(Col, {
|
|
183
|
+
span: 24,
|
|
184
|
+
style: DESCRIPTION_COL_STYLE$1,
|
|
185
|
+
children: jsx(ArrayFieldDescriptionTemplate, {
|
|
186
|
+
description: uiOptions.description || schema.description || '',
|
|
187
|
+
idSchema: idSchema,
|
|
188
|
+
schema: schema,
|
|
189
|
+
uiSchema: uiSchema,
|
|
190
|
+
registry: registry
|
|
191
|
+
})
|
|
192
|
+
}), jsx(Col, {
|
|
193
|
+
className: 'row array-item-list',
|
|
194
|
+
span: 24,
|
|
195
|
+
children: items && items.map(function (_ref) {
|
|
196
|
+
var key = _ref.key,
|
|
197
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
198
|
+
return jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
199
|
+
})
|
|
200
|
+
}), canAdd && jsx(Col, {
|
|
201
|
+
span: 24,
|
|
202
|
+
children: jsx(Row, {
|
|
203
|
+
gutter: rowGutter,
|
|
204
|
+
justify: 'end',
|
|
205
|
+
children: jsx(Col, {
|
|
206
|
+
flex: '192px',
|
|
207
|
+
children: jsx(AddButton, {
|
|
208
|
+
className: 'array-item-add',
|
|
209
|
+
disabled: disabled || readonly,
|
|
210
|
+
onClick: onAddClick,
|
|
211
|
+
uiSchema: uiSchema,
|
|
212
|
+
registry: registry
|
|
213
|
+
})
|
|
214
|
+
})
|
|
215
|
+
})
|
|
216
|
+
})]
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
}
|
|
208
220
|
});
|
|
209
221
|
}
|
|
210
222
|
|
|
211
223
|
var INPUT_STYLE$2 = {
|
|
212
|
-
width:
|
|
224
|
+
width: '100%'
|
|
213
225
|
};
|
|
214
226
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
215
227
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
@@ -223,6 +235,7 @@ function BaseInputTemplate(props) {
|
|
|
223
235
|
id = props.id,
|
|
224
236
|
onBlur = props.onBlur,
|
|
225
237
|
onChange = props.onChange,
|
|
238
|
+
onChangeOverride = props.onChangeOverride,
|
|
226
239
|
onFocus = props.onFocus,
|
|
227
240
|
options = props.options,
|
|
228
241
|
placeholder = props.placeholder,
|
|
@@ -236,9 +249,9 @@ function BaseInputTemplate(props) {
|
|
|
236
249
|
var handleNumberChange = function handleNumberChange(nextValue) {
|
|
237
250
|
return onChange(nextValue);
|
|
238
251
|
};
|
|
239
|
-
var handleTextChange = function
|
|
252
|
+
var handleTextChange = onChangeOverride ? onChangeOverride : function (_ref) {
|
|
240
253
|
var target = _ref.target;
|
|
241
|
-
return onChange(target.value ===
|
|
254
|
+
return onChange(target.value === '' ? options.emptyValue : target.value);
|
|
242
255
|
};
|
|
243
256
|
var handleBlur = function handleBlur(_ref2) {
|
|
244
257
|
var target = _ref2.target;
|
|
@@ -248,7 +261,7 @@ function BaseInputTemplate(props) {
|
|
|
248
261
|
var target = _ref3.target;
|
|
249
262
|
return onFocus(id, target.value);
|
|
250
263
|
};
|
|
251
|
-
var input = inputProps.type ===
|
|
264
|
+
var input = inputProps.type === 'number' || inputProps.type === 'integer' ? jsx(InputNumber, _extends({
|
|
252
265
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
253
266
|
id: id,
|
|
254
267
|
name: id,
|
|
@@ -261,7 +274,7 @@ function BaseInputTemplate(props) {
|
|
|
261
274
|
}, inputProps, {
|
|
262
275
|
value: value,
|
|
263
276
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
264
|
-
})) :
|
|
277
|
+
})) : jsx(Input, _extends({
|
|
265
278
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
266
279
|
id: id,
|
|
267
280
|
name: id,
|
|
@@ -275,14 +288,16 @@ function BaseInputTemplate(props) {
|
|
|
275
288
|
value: value,
|
|
276
289
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
277
290
|
}));
|
|
278
|
-
return
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
291
|
+
return jsxs(Fragment, {
|
|
292
|
+
children: [input, Array.isArray(schema.examples) && jsx("datalist", {
|
|
293
|
+
id: examplesId(id),
|
|
294
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
295
|
+
return jsx("option", {
|
|
296
|
+
value: example
|
|
297
|
+
}, example);
|
|
298
|
+
})
|
|
299
|
+
})]
|
|
300
|
+
});
|
|
286
301
|
}
|
|
287
302
|
|
|
288
303
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
@@ -295,9 +310,10 @@ function DescriptionField(props) {
|
|
|
295
310
|
if (!description) {
|
|
296
311
|
return null;
|
|
297
312
|
}
|
|
298
|
-
return
|
|
299
|
-
id: id
|
|
300
|
-
|
|
313
|
+
return jsx("span", {
|
|
314
|
+
id: id,
|
|
315
|
+
children: description
|
|
316
|
+
});
|
|
301
317
|
}
|
|
302
318
|
|
|
303
319
|
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
@@ -309,71 +325,74 @@ function ErrorList(_ref) {
|
|
|
309
325
|
registry = _ref.registry;
|
|
310
326
|
var translateString = registry.translateString;
|
|
311
327
|
var renderErrors = function renderErrors() {
|
|
312
|
-
return
|
|
313
|
-
className:
|
|
314
|
-
size:
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
328
|
+
return jsx(List, {
|
|
329
|
+
className: 'list-group',
|
|
330
|
+
size: 'small',
|
|
331
|
+
children: errors.map(function (error, index) {
|
|
332
|
+
return jsx(List.Item, {
|
|
333
|
+
children: jsxs(Space, {
|
|
334
|
+
children: [jsx(ExclamationCircleOutlined, {}), error.stack]
|
|
335
|
+
})
|
|
336
|
+
}, index);
|
|
337
|
+
})
|
|
338
|
+
});
|
|
320
339
|
};
|
|
321
|
-
return
|
|
322
|
-
className:
|
|
340
|
+
return jsx(Alert, {
|
|
341
|
+
className: 'panel panel-danger errors',
|
|
323
342
|
description: renderErrors(),
|
|
324
343
|
message: translateString(TranslatableString.ErrorsLabel),
|
|
325
|
-
type:
|
|
344
|
+
type: 'error'
|
|
326
345
|
});
|
|
327
346
|
}
|
|
328
347
|
|
|
329
348
|
var _excluded = ["iconType", "icon", "uiSchema", "registry"];
|
|
330
349
|
function IconButton(props) {
|
|
331
350
|
var _props$iconType = props.iconType,
|
|
332
|
-
iconType = _props$iconType === void 0 ?
|
|
351
|
+
iconType = _props$iconType === void 0 ? 'default' : _props$iconType,
|
|
333
352
|
icon = props.icon,
|
|
334
353
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
335
|
-
return
|
|
354
|
+
return jsx(Button, _extends({
|
|
336
355
|
type: iconType,
|
|
337
356
|
icon: icon
|
|
338
357
|
}, otherProps));
|
|
339
358
|
}
|
|
340
359
|
function AddButton(props) {
|
|
341
360
|
var translateString = props.registry.translateString;
|
|
342
|
-
return
|
|
361
|
+
return jsx(IconButton, _extends({
|
|
343
362
|
title: translateString(TranslatableString.AddItemButton)
|
|
344
363
|
}, props, {
|
|
345
364
|
block: true,
|
|
346
|
-
iconType:
|
|
347
|
-
icon:
|
|
365
|
+
iconType: 'primary',
|
|
366
|
+
icon: jsx(PlusCircleOutlined, {})
|
|
348
367
|
}));
|
|
349
368
|
}
|
|
350
369
|
function MoveDownButton(props) {
|
|
351
370
|
var translateString = props.registry.translateString;
|
|
352
|
-
return
|
|
371
|
+
return jsx(IconButton, _extends({
|
|
353
372
|
title: translateString(TranslatableString.MoveDownButton)
|
|
354
373
|
}, props, {
|
|
355
|
-
icon:
|
|
374
|
+
icon: jsx(ArrowDownOutlined, {})
|
|
356
375
|
}));
|
|
357
376
|
}
|
|
358
377
|
function MoveUpButton(props) {
|
|
359
378
|
var translateString = props.registry.translateString;
|
|
360
|
-
return
|
|
379
|
+
return jsx(IconButton, _extends({
|
|
361
380
|
title: translateString(TranslatableString.MoveUpButton)
|
|
362
381
|
}, props, {
|
|
363
|
-
icon:
|
|
382
|
+
icon: jsx(ArrowUpOutlined, {})
|
|
364
383
|
}));
|
|
365
384
|
}
|
|
366
385
|
function RemoveButton(props) {
|
|
367
386
|
// The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead
|
|
368
387
|
var options = getUiOptions(props.uiSchema);
|
|
369
388
|
var translateString = props.registry.translateString;
|
|
370
|
-
return
|
|
389
|
+
return jsx(IconButton, _extends({
|
|
371
390
|
title: translateString(TranslatableString.RemoveButton)
|
|
372
391
|
}, props, {
|
|
373
392
|
danger: true,
|
|
374
393
|
block: !!options.block,
|
|
375
|
-
iconType:
|
|
376
|
-
icon:
|
|
394
|
+
iconType: 'primary',
|
|
395
|
+
icon: jsx(DeleteOutlined, {})
|
|
377
396
|
}));
|
|
378
397
|
}
|
|
379
398
|
|
|
@@ -389,13 +408,14 @@ function FieldErrorTemplate(props) {
|
|
|
389
408
|
return null;
|
|
390
409
|
}
|
|
391
410
|
var id = errorId(idSchema);
|
|
392
|
-
return
|
|
393
|
-
id: id
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
411
|
+
return jsx("div", {
|
|
412
|
+
id: id,
|
|
413
|
+
children: errors.map(function (error) {
|
|
414
|
+
return jsx("div", {
|
|
415
|
+
children: error
|
|
416
|
+
}, "field-" + id + "-error-" + error);
|
|
417
|
+
})
|
|
418
|
+
});
|
|
399
419
|
}
|
|
400
420
|
|
|
401
421
|
var VERTICAL_LABEL_COL$1 = {
|
|
@@ -439,13 +459,14 @@ function FieldTemplate(props) {
|
|
|
439
459
|
wrapperCol = _formContext$wrapperC === void 0 ? VERTICAL_WRAPPER_COL$1 : _formContext$wrapperC,
|
|
440
460
|
wrapperStyle = formContext.wrapperStyle;
|
|
441
461
|
var uiOptions = getUiOptions(uiSchema);
|
|
442
|
-
var WrapIfAdditionalTemplate = getTemplate(
|
|
462
|
+
var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
443
463
|
if (hidden) {
|
|
444
|
-
return
|
|
445
|
-
className:
|
|
446
|
-
|
|
464
|
+
return jsx("div", {
|
|
465
|
+
className: 'field-hidden',
|
|
466
|
+
children: children
|
|
467
|
+
});
|
|
447
468
|
}
|
|
448
|
-
return
|
|
469
|
+
return jsx(WrapIfAdditionalTemplate, {
|
|
449
470
|
classNames: classNames,
|
|
450
471
|
style: style,
|
|
451
472
|
disabled: disabled,
|
|
@@ -457,24 +478,26 @@ function FieldTemplate(props) {
|
|
|
457
478
|
required: required,
|
|
458
479
|
schema: schema,
|
|
459
480
|
uiSchema: uiSchema,
|
|
460
|
-
registry: registry
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
481
|
+
registry: registry,
|
|
482
|
+
children: id === 'root' ? children : jsx(Form$1.Item, {
|
|
483
|
+
colon: colon,
|
|
484
|
+
extra: rawDescription && description,
|
|
485
|
+
hasFeedback: schema.type !== 'array' && schema.type !== 'object',
|
|
486
|
+
help: !!rawHelp && help || (rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? errors : undefined),
|
|
487
|
+
htmlFor: id,
|
|
488
|
+
label: displayLabel && label,
|
|
489
|
+
labelCol: labelCol,
|
|
490
|
+
required: required,
|
|
491
|
+
style: wrapperStyle,
|
|
492
|
+
validateStatus: rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? 'error' : undefined,
|
|
493
|
+
wrapperCol: wrapperCol,
|
|
494
|
+
children: children
|
|
495
|
+
})
|
|
496
|
+
});
|
|
474
497
|
}
|
|
475
498
|
|
|
476
499
|
var DESCRIPTION_COL_STYLE = {
|
|
477
|
-
paddingBottom:
|
|
500
|
+
paddingBottom: '8px'
|
|
478
501
|
};
|
|
479
502
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
480
503
|
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
@@ -497,14 +520,14 @@ function ObjectFieldTemplate(props) {
|
|
|
497
520
|
title = props.title,
|
|
498
521
|
uiSchema = props.uiSchema;
|
|
499
522
|
var uiOptions = getUiOptions(uiSchema);
|
|
500
|
-
var TitleFieldTemplate = getTemplate(
|
|
501
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
523
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
524
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
502
525
|
// Button templates are not overridden in the uiSchema
|
|
503
526
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
504
527
|
var _formContext$colSpan = formContext.colSpan,
|
|
505
528
|
colSpan = _formContext$colSpan === void 0 ? 24 : _formContext$colSpan,
|
|
506
529
|
_formContext$labelAli = formContext.labelAlign,
|
|
507
|
-
labelAlign = _formContext$labelAli === void 0 ?
|
|
530
|
+
labelAlign = _formContext$labelAli === void 0 ? 'right' : _formContext$labelAli,
|
|
508
531
|
_formContext$rowGutte = formContext.rowGutter,
|
|
509
532
|
rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
|
|
510
533
|
var findSchema = function findSchema(element) {
|
|
@@ -528,7 +551,7 @@ function ObjectFieldTemplate(props) {
|
|
|
528
551
|
var widget = findUiSchemaWidget(element);
|
|
529
552
|
var defaultColSpan = properties.length < 2 ||
|
|
530
553
|
// Single or no field in object.
|
|
531
|
-
type ===
|
|
554
|
+
type === 'object' || type === 'array' || widget === 'textarea' ? 24 : 12;
|
|
532
555
|
if (isObject(colSpan)) {
|
|
533
556
|
var colSpanObj = colSpan;
|
|
534
557
|
if (isString(widget)) {
|
|
@@ -546,58 +569,67 @@ function ObjectFieldTemplate(props) {
|
|
|
546
569
|
}
|
|
547
570
|
return defaultColSpan;
|
|
548
571
|
};
|
|
549
|
-
return
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
572
|
+
return jsx(ConfigConsumer, {
|
|
573
|
+
children: function children(configProps) {
|
|
574
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
575
|
+
var prefixCls = getPrefixCls('form');
|
|
576
|
+
var labelClsBasic = prefixCls + "-item-label";
|
|
577
|
+
var labelColClassName = classNames(labelClsBasic, labelAlign === 'left' && labelClsBasic + "-left"
|
|
578
|
+
// labelCol.className,
|
|
579
|
+
);
|
|
556
580
|
|
|
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
|
-
|
|
581
|
+
return jsxs("fieldset", {
|
|
582
|
+
id: idSchema.$id,
|
|
583
|
+
children: [jsxs(Row, {
|
|
584
|
+
gutter: rowGutter,
|
|
585
|
+
children: [(uiOptions.title || title) && jsx(Col, {
|
|
586
|
+
className: labelColClassName,
|
|
587
|
+
span: 24,
|
|
588
|
+
children: jsx(TitleFieldTemplate, {
|
|
589
|
+
id: titleId(idSchema),
|
|
590
|
+
title: uiOptions.title || title,
|
|
591
|
+
required: required,
|
|
592
|
+
schema: schema,
|
|
593
|
+
uiSchema: uiSchema,
|
|
594
|
+
registry: registry
|
|
595
|
+
})
|
|
596
|
+
}), (uiOptions.description || description) && jsx(Col, {
|
|
597
|
+
span: 24,
|
|
598
|
+
style: DESCRIPTION_COL_STYLE,
|
|
599
|
+
children: jsx(DescriptionFieldTemplate, {
|
|
600
|
+
id: descriptionId(idSchema),
|
|
601
|
+
description: uiOptions.description || description,
|
|
602
|
+
schema: schema,
|
|
603
|
+
uiSchema: uiSchema,
|
|
604
|
+
registry: registry
|
|
605
|
+
})
|
|
606
|
+
}), properties.filter(function (e) {
|
|
607
|
+
return !e.hidden;
|
|
608
|
+
}).map(function (element) {
|
|
609
|
+
return jsx(Col, {
|
|
610
|
+
span: calculateColSpan(element),
|
|
611
|
+
children: element.content
|
|
612
|
+
}, element.name);
|
|
613
|
+
})]
|
|
614
|
+
}), canExpand(schema, uiSchema, formData) && jsx(Col, {
|
|
615
|
+
span: 24,
|
|
616
|
+
children: jsx(Row, {
|
|
617
|
+
gutter: rowGutter,
|
|
618
|
+
justify: 'end',
|
|
619
|
+
children: jsx(Col, {
|
|
620
|
+
flex: '192px',
|
|
621
|
+
children: jsx(AddButton, {
|
|
622
|
+
className: 'object-property-expand',
|
|
623
|
+
disabled: disabled || readonly,
|
|
624
|
+
onClick: onAddClick(schema),
|
|
625
|
+
uiSchema: uiSchema,
|
|
626
|
+
registry: registry
|
|
627
|
+
})
|
|
628
|
+
})
|
|
629
|
+
})
|
|
630
|
+
})]
|
|
631
|
+
});
|
|
632
|
+
}
|
|
601
633
|
});
|
|
602
634
|
}
|
|
603
635
|
|
|
@@ -612,11 +644,12 @@ function SubmitButton(_ref) {
|
|
|
612
644
|
if (norender) {
|
|
613
645
|
return null;
|
|
614
646
|
}
|
|
615
|
-
return
|
|
616
|
-
type:
|
|
647
|
+
return jsx(Button, _extends({
|
|
648
|
+
type: 'submit'
|
|
617
649
|
}, submitButtonProps, {
|
|
618
|
-
htmlType:
|
|
619
|
-
|
|
650
|
+
htmlType: 'submit',
|
|
651
|
+
children: submitText
|
|
652
|
+
}));
|
|
620
653
|
}
|
|
621
654
|
|
|
622
655
|
/** The `TitleField` is the template to use to render the title of a field
|
|
@@ -632,8 +665,8 @@ function TitleField(_ref) {
|
|
|
632
665
|
var _formContext$colon = formContext.colon,
|
|
633
666
|
colon = _formContext$colon === void 0 ? true : _formContext$colon;
|
|
634
667
|
var labelChildren = title;
|
|
635
|
-
if (colon && typeof title ===
|
|
636
|
-
labelChildren = title.replace(/[::]\s*$/,
|
|
668
|
+
if (colon && typeof title === 'string' && title.trim() !== '') {
|
|
669
|
+
labelChildren = title.replace(/[::]\s*$/, '');
|
|
637
670
|
}
|
|
638
671
|
var handleLabelClick = function handleLabelClick() {
|
|
639
672
|
if (!id) {
|
|
@@ -644,17 +677,20 @@ function TitleField(_ref) {
|
|
|
644
677
|
control.focus();
|
|
645
678
|
}
|
|
646
679
|
};
|
|
647
|
-
return title ?
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
680
|
+
return title ? jsx(ConfigConsumer, {
|
|
681
|
+
children: function children(configProps) {
|
|
682
|
+
var _classNames;
|
|
683
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
684
|
+
var prefixCls = getPrefixCls('form');
|
|
685
|
+
var labelClassName = classNames((_classNames = {}, _classNames[prefixCls + "-item-required"] = required, _classNames[prefixCls + "-item-no-colon"] = !colon, _classNames));
|
|
686
|
+
return jsx("label", {
|
|
687
|
+
className: labelClassName,
|
|
688
|
+
htmlFor: id,
|
|
689
|
+
onClick: handleLabelClick,
|
|
690
|
+
title: typeof title === 'string' ? title : '',
|
|
691
|
+
children: labelChildren
|
|
692
|
+
});
|
|
693
|
+
}
|
|
658
694
|
}) : null;
|
|
659
695
|
}
|
|
660
696
|
|
|
@@ -665,7 +701,7 @@ var VERTICAL_WRAPPER_COL = {
|
|
|
665
701
|
span: 24
|
|
666
702
|
};
|
|
667
703
|
var INPUT_STYLE$1 = {
|
|
668
|
-
width:
|
|
704
|
+
width: '100%'
|
|
669
705
|
};
|
|
670
706
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
671
707
|
* part of an `additionalProperties` part of a schema.
|
|
@@ -696,7 +732,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
696
732
|
_registry$formContext4 = _registry$formContext.rowGutter,
|
|
697
733
|
rowGutter = _registry$formContext4 === void 0 ? 24 : _registry$formContext4,
|
|
698
734
|
_registry$formContext5 = _registry$formContext.toolbarAlign,
|
|
699
|
-
toolbarAlign = _registry$formContext5 === void 0 ?
|
|
735
|
+
toolbarAlign = _registry$formContext5 === void 0 ? 'top' : _registry$formContext5,
|
|
700
736
|
_registry$formContext6 = _registry$formContext.wrapperCol,
|
|
701
737
|
wrapperCol = _registry$formContext6 === void 0 ? VERTICAL_WRAPPER_COL : _registry$formContext6,
|
|
702
738
|
wrapperStyle = _registry$formContext.wrapperStyle;
|
|
@@ -707,10 +743,11 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
707
743
|
var keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
708
744
|
var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
|
|
709
745
|
if (!additional) {
|
|
710
|
-
return
|
|
746
|
+
return jsx("div", {
|
|
711
747
|
className: classNames,
|
|
712
|
-
style: style
|
|
713
|
-
|
|
748
|
+
style: style,
|
|
749
|
+
children: children
|
|
750
|
+
});
|
|
714
751
|
}
|
|
715
752
|
var handleBlur = function handleBlur(_ref) {
|
|
716
753
|
var target = _ref.target;
|
|
@@ -721,48 +758,55 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
721
758
|
var buttonUiOptions = _extends({}, uiSchema, (_extends2 = {}, _extends2[UI_OPTIONS_KEY] = _extends({}, uiOptions, {
|
|
722
759
|
block: true
|
|
723
760
|
}), _extends2));
|
|
724
|
-
return
|
|
761
|
+
return jsx("div", {
|
|
725
762
|
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
|
-
|
|
763
|
+
style: style,
|
|
764
|
+
children: jsxs(Row, {
|
|
765
|
+
align: toolbarAlign,
|
|
766
|
+
gutter: rowGutter,
|
|
767
|
+
children: [jsx(Col, {
|
|
768
|
+
className: 'form-additional',
|
|
769
|
+
flex: '1',
|
|
770
|
+
children: jsx("div", {
|
|
771
|
+
className: 'form-group',
|
|
772
|
+
children: jsx(Form$1.Item, {
|
|
773
|
+
colon: colon,
|
|
774
|
+
className: 'form-group',
|
|
775
|
+
hasFeedback: true,
|
|
776
|
+
htmlFor: id + "-key",
|
|
777
|
+
label: keyLabel,
|
|
778
|
+
labelCol: labelCol,
|
|
779
|
+
required: required,
|
|
780
|
+
style: wrapperStyle,
|
|
781
|
+
wrapperCol: wrapperCol,
|
|
782
|
+
children: jsx(Input, {
|
|
783
|
+
className: 'form-control',
|
|
784
|
+
defaultValue: label,
|
|
785
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
786
|
+
id: id + "-key",
|
|
787
|
+
name: id + "-key",
|
|
788
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
789
|
+
style: INPUT_STYLE$1,
|
|
790
|
+
type: 'text'
|
|
791
|
+
})
|
|
792
|
+
})
|
|
793
|
+
})
|
|
794
|
+
}), jsx(Col, {
|
|
795
|
+
className: 'form-additional',
|
|
796
|
+
flex: '1',
|
|
797
|
+
children: children
|
|
798
|
+
}), jsx(Col, {
|
|
799
|
+
flex: '192px',
|
|
800
|
+
children: jsx(RemoveButton, {
|
|
801
|
+
className: 'array-item-remove',
|
|
802
|
+
disabled: disabled || readonly,
|
|
803
|
+
onClick: onDropPropertyClick(label),
|
|
804
|
+
uiSchema: buttonUiOptions,
|
|
805
|
+
registry: registry
|
|
806
|
+
})
|
|
807
|
+
})]
|
|
808
|
+
})
|
|
809
|
+
});
|
|
766
810
|
}
|
|
767
811
|
|
|
768
812
|
function generateTemplates() {
|
|
@@ -814,29 +858,29 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
814
858
|
minute = state.minute,
|
|
815
859
|
second = state.second;
|
|
816
860
|
var data = [{
|
|
817
|
-
type:
|
|
861
|
+
type: 'year',
|
|
818
862
|
range: yearsRange,
|
|
819
863
|
value: year
|
|
820
864
|
}, {
|
|
821
|
-
type:
|
|
865
|
+
type: 'month',
|
|
822
866
|
range: [1, 12],
|
|
823
867
|
value: month
|
|
824
868
|
}, {
|
|
825
|
-
type:
|
|
869
|
+
type: 'day',
|
|
826
870
|
range: [1, 31],
|
|
827
871
|
value: day
|
|
828
872
|
}];
|
|
829
873
|
if (time) {
|
|
830
874
|
data.push({
|
|
831
|
-
type:
|
|
875
|
+
type: 'hour',
|
|
832
876
|
range: [0, 23],
|
|
833
877
|
value: hour || -1
|
|
834
878
|
}, {
|
|
835
|
-
type:
|
|
879
|
+
type: 'minute',
|
|
836
880
|
range: [0, 59],
|
|
837
881
|
value: minute || -1
|
|
838
882
|
}, {
|
|
839
|
-
type:
|
|
883
|
+
type: 'second',
|
|
840
884
|
range: [0, 59],
|
|
841
885
|
value: second || -1
|
|
842
886
|
});
|
|
@@ -869,7 +913,7 @@ function AltDateWidget(props) {
|
|
|
869
913
|
}, [showTime, value]);
|
|
870
914
|
var handleChange = function handleChange(property, nextValue) {
|
|
871
915
|
var _extends2;
|
|
872
|
-
var nextState = _extends({}, state, (_extends2 = {}, _extends2[property] = typeof nextValue ===
|
|
916
|
+
var nextState = _extends({}, state, (_extends2 = {}, _extends2[property] = typeof nextValue === 'undefined' ? -1 : nextValue, _extends2));
|
|
873
917
|
if (readyForChange(nextState)) {
|
|
874
918
|
onChange(toDateString(nextState, showTime));
|
|
875
919
|
} else {
|
|
@@ -892,9 +936,9 @@ function AltDateWidget(props) {
|
|
|
892
936
|
onChange(undefined);
|
|
893
937
|
};
|
|
894
938
|
var renderDateElement = function renderDateElement(elemProps) {
|
|
895
|
-
return
|
|
939
|
+
return jsx(SelectWidget, {
|
|
896
940
|
autofocus: elemProps.autofocus,
|
|
897
|
-
className:
|
|
941
|
+
className: 'form-control',
|
|
898
942
|
disabled: elemProps.disabled,
|
|
899
943
|
id: elemProps.id,
|
|
900
944
|
name: elemProps.name,
|
|
@@ -909,51 +953,56 @@ function AltDateWidget(props) {
|
|
|
909
953
|
placeholder: elemProps.type,
|
|
910
954
|
readonly: elemProps.readonly,
|
|
911
955
|
schema: {
|
|
912
|
-
type:
|
|
956
|
+
type: 'integer'
|
|
913
957
|
},
|
|
914
958
|
value: elemProps.value,
|
|
915
959
|
registry: registry,
|
|
916
|
-
label:
|
|
960
|
+
label: '',
|
|
917
961
|
"aria-describedby": ariaDescribedByIds(id)
|
|
918
962
|
});
|
|
919
963
|
};
|
|
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
|
-
|
|
964
|
+
return jsxs(Row, {
|
|
965
|
+
gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)],
|
|
966
|
+
children: [dateElementProps(state, showTime, options.yearsRange).map(function (elemProps, i) {
|
|
967
|
+
var elemId = id + '_' + elemProps.type;
|
|
968
|
+
return jsx(Col, {
|
|
969
|
+
flex: '88px',
|
|
970
|
+
children: renderDateElement(_extends({}, elemProps, {
|
|
971
|
+
autofocus: autofocus && i === 0,
|
|
972
|
+
disabled: disabled,
|
|
973
|
+
id: elemId,
|
|
974
|
+
name: id,
|
|
975
|
+
onBlur: onBlur,
|
|
976
|
+
onFocus: onFocus,
|
|
977
|
+
readonly: readonly,
|
|
978
|
+
registry: registry,
|
|
979
|
+
select: handleChange,
|
|
980
|
+
// NOTE: antd components accept -1 rather than issue a warning
|
|
981
|
+
// like material-ui, so we need to convert -1 to undefined here.
|
|
982
|
+
value: elemProps.value < 0 ? undefined : elemProps.value
|
|
983
|
+
}))
|
|
984
|
+
}, elemId);
|
|
985
|
+
}), !options.hideNowButton && jsx(Col, {
|
|
986
|
+
flex: '88px',
|
|
987
|
+
children: jsx(Button, {
|
|
988
|
+
block: true,
|
|
989
|
+
className: 'btn-now',
|
|
990
|
+
onClick: handleNow,
|
|
991
|
+
type: 'primary',
|
|
992
|
+
children: translateString(TranslatableString.NowLabel)
|
|
993
|
+
})
|
|
994
|
+
}), !options.hideClearButton && jsx(Col, {
|
|
995
|
+
flex: '88px',
|
|
996
|
+
children: jsx(Button, {
|
|
997
|
+
block: true,
|
|
998
|
+
className: 'btn-clear',
|
|
999
|
+
danger: true,
|
|
1000
|
+
onClick: handleClear,
|
|
1001
|
+
type: 'primary',
|
|
1002
|
+
children: translateString(TranslatableString.ClearLabel)
|
|
1003
|
+
})
|
|
1004
|
+
})]
|
|
1005
|
+
});
|
|
957
1006
|
}
|
|
958
1007
|
AltDateWidget.defaultProps = {
|
|
959
1008
|
autofocus: false,
|
|
@@ -967,7 +1016,7 @@ AltDateWidget.defaultProps = {
|
|
|
967
1016
|
|
|
968
1017
|
function AltDateTimeWidget(props) {
|
|
969
1018
|
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
970
|
-
return
|
|
1019
|
+
return jsx(AltDateWidget, _extends({
|
|
971
1020
|
showTime: true
|
|
972
1021
|
}, props));
|
|
973
1022
|
}
|
|
@@ -1016,23 +1065,25 @@ function CheckboxesWidget(_ref) {
|
|
|
1016
1065
|
onFocus: !readonly ? handleFocus : undefined
|
|
1017
1066
|
};
|
|
1018
1067
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
|
|
1019
|
-
return Array.isArray(enumOptions) && enumOptions.length > 0 ?
|
|
1068
|
+
return Array.isArray(enumOptions) && enumOptions.length > 0 ? jsx(Checkbox.Group, _extends({
|
|
1020
1069
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1021
1070
|
name: id,
|
|
1022
1071
|
onChange: !readonly ? handleChange : undefined,
|
|
1023
1072
|
value: selectedIndexes
|
|
1024
1073
|
}, extraProps, {
|
|
1025
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1074
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1075
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
1076
|
+
return jsxs("span", {
|
|
1077
|
+
children: [jsx(Checkbox, {
|
|
1078
|
+
id: optionId(id, i),
|
|
1079
|
+
name: id,
|
|
1080
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1081
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1082
|
+
value: String(i),
|
|
1083
|
+
children: option.label
|
|
1084
|
+
}), !inline && jsx("br", {})]
|
|
1085
|
+
}, i);
|
|
1086
|
+
})
|
|
1036
1087
|
})) : null;
|
|
1037
1088
|
}
|
|
1038
1089
|
|
|
@@ -1072,22 +1123,23 @@ function CheckboxWidget(props) {
|
|
|
1072
1123
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1073
1124
|
onFocus: !readonly ? handleFocus : undefined
|
|
1074
1125
|
};
|
|
1075
|
-
return
|
|
1126
|
+
return jsx(Checkbox, _extends({
|
|
1076
1127
|
autoFocus: autofocus,
|
|
1077
|
-
checked: typeof value ===
|
|
1128
|
+
checked: typeof value === 'undefined' ? false : value,
|
|
1078
1129
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1079
1130
|
id: id,
|
|
1080
1131
|
name: id,
|
|
1081
1132
|
onChange: !readonly ? handleChange : undefined
|
|
1082
1133
|
}, extraProps, {
|
|
1083
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1084
|
-
|
|
1134
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1135
|
+
children: label
|
|
1136
|
+
}));
|
|
1085
1137
|
}
|
|
1086
1138
|
|
|
1087
1139
|
var DatePicker = /*#__PURE__*/generatePicker(dayjsGenerateConfig);
|
|
1088
1140
|
|
|
1089
1141
|
var DATE_PICKER_STYLE$1 = {
|
|
1090
|
-
width:
|
|
1142
|
+
width: '100%'
|
|
1091
1143
|
};
|
|
1092
1144
|
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
1093
1145
|
* the value to/from utc using the appropriate utility functions.
|
|
@@ -1118,7 +1170,7 @@ function DateTimeWidget(props) {
|
|
|
1118
1170
|
var getPopupContainer = function getPopupContainer(node) {
|
|
1119
1171
|
return node.parentNode;
|
|
1120
1172
|
};
|
|
1121
|
-
return
|
|
1173
|
+
return jsx(DatePicker, {
|
|
1122
1174
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1123
1175
|
getPopupContainer: getPopupContainer,
|
|
1124
1176
|
id: id,
|
|
@@ -1135,7 +1187,7 @@ function DateTimeWidget(props) {
|
|
|
1135
1187
|
}
|
|
1136
1188
|
|
|
1137
1189
|
var DATE_PICKER_STYLE = {
|
|
1138
|
-
width:
|
|
1190
|
+
width: '100%'
|
|
1139
1191
|
};
|
|
1140
1192
|
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
1141
1193
|
* the value to undefined when it is falsy during the `onChange` handling.
|
|
@@ -1155,7 +1207,7 @@ function DateWidget(props) {
|
|
|
1155
1207
|
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1156
1208
|
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1157
1209
|
var handleChange = function handleChange(nextValue) {
|
|
1158
|
-
return onChange(nextValue && nextValue.format(
|
|
1210
|
+
return onChange(nextValue && nextValue.format('YYYY-MM-DD'));
|
|
1159
1211
|
};
|
|
1160
1212
|
var handleBlur = function handleBlur() {
|
|
1161
1213
|
return onBlur(id, value);
|
|
@@ -1166,7 +1218,7 @@ function DateWidget(props) {
|
|
|
1166
1218
|
var getPopupContainer = function getPopupContainer(node) {
|
|
1167
1219
|
return node.parentNode;
|
|
1168
1220
|
};
|
|
1169
|
-
return
|
|
1221
|
+
return jsx(DatePicker, {
|
|
1170
1222
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1171
1223
|
getPopupContainer: getPopupContainer,
|
|
1172
1224
|
id: id,
|
|
@@ -1199,10 +1251,10 @@ function PasswordWidget(props) {
|
|
|
1199
1251
|
value = props.value;
|
|
1200
1252
|
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1201
1253
|
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1202
|
-
var emptyValue = options.emptyValue ||
|
|
1254
|
+
var emptyValue = options.emptyValue || '';
|
|
1203
1255
|
var handleChange = function handleChange(_ref) {
|
|
1204
1256
|
var target = _ref.target;
|
|
1205
|
-
return onChange(target.value ===
|
|
1257
|
+
return onChange(target.value === '' ? emptyValue : target.value);
|
|
1206
1258
|
};
|
|
1207
1259
|
var handleBlur = function handleBlur(_ref2) {
|
|
1208
1260
|
var target = _ref2.target;
|
|
@@ -1212,7 +1264,7 @@ function PasswordWidget(props) {
|
|
|
1212
1264
|
var target = _ref3.target;
|
|
1213
1265
|
return onFocus(id, target.value);
|
|
1214
1266
|
};
|
|
1215
|
-
return
|
|
1267
|
+
return jsx(Input.Password, {
|
|
1216
1268
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1217
1269
|
id: id,
|
|
1218
1270
|
name: id,
|
|
@@ -1220,7 +1272,7 @@ function PasswordWidget(props) {
|
|
|
1220
1272
|
onChange: !readonly ? handleChange : undefined,
|
|
1221
1273
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1222
1274
|
placeholder: placeholder,
|
|
1223
|
-
value: value ||
|
|
1275
|
+
value: value || '',
|
|
1224
1276
|
"aria-describedby": ariaDescribedByIds(id)
|
|
1225
1277
|
});
|
|
1226
1278
|
}
|
|
@@ -1259,7 +1311,7 @@ function RadioWidget(_ref) {
|
|
|
1259
1311
|
return onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1260
1312
|
};
|
|
1261
1313
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions);
|
|
1262
|
-
return
|
|
1314
|
+
return jsx(Radio.Group, {
|
|
1263
1315
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1264
1316
|
id: id,
|
|
1265
1317
|
name: id,
|
|
@@ -1267,17 +1319,18 @@ function RadioWidget(_ref) {
|
|
|
1267
1319
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1268
1320
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1269
1321
|
value: selectedIndexes,
|
|
1270
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1322
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1323
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
1324
|
+
return jsx(Radio, {
|
|
1325
|
+
id: optionId(id, i),
|
|
1326
|
+
name: id,
|
|
1327
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1328
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1329
|
+
value: String(i),
|
|
1330
|
+
children: option.label
|
|
1331
|
+
}, i);
|
|
1332
|
+
})
|
|
1333
|
+
});
|
|
1281
1334
|
}
|
|
1282
1335
|
|
|
1283
1336
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -1304,9 +1357,9 @@ function RangeWidget(props) {
|
|
|
1304
1357
|
min = _rangeSpec.min,
|
|
1305
1358
|
max = _rangeSpec.max,
|
|
1306
1359
|
step = _rangeSpec.step;
|
|
1307
|
-
var emptyValue = options.emptyValue ||
|
|
1360
|
+
var emptyValue = options.emptyValue || '';
|
|
1308
1361
|
var handleChange = function handleChange(nextValue) {
|
|
1309
|
-
return onChange(nextValue ===
|
|
1362
|
+
return onChange(nextValue === '' ? emptyValue : nextValue);
|
|
1310
1363
|
};
|
|
1311
1364
|
var handleBlur = function handleBlur() {
|
|
1312
1365
|
return onBlur(id, value);
|
|
@@ -1321,7 +1374,7 @@ function RangeWidget(props) {
|
|
|
1321
1374
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1322
1375
|
onFocus: !readonly ? handleFocus : undefined
|
|
1323
1376
|
};
|
|
1324
|
-
return
|
|
1377
|
+
return jsx(Slider, _extends({
|
|
1325
1378
|
autoFocus: autofocus,
|
|
1326
1379
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1327
1380
|
id: id,
|
|
@@ -1337,7 +1390,7 @@ function RangeWidget(props) {
|
|
|
1337
1390
|
}
|
|
1338
1391
|
|
|
1339
1392
|
var SELECT_STYLE = {
|
|
1340
|
-
width:
|
|
1393
|
+
width: '100%'
|
|
1341
1394
|
};
|
|
1342
1395
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
1343
1396
|
* It is typically used with string properties constrained with enum options.
|
|
@@ -1388,12 +1441,12 @@ function SelectWidget(_ref) {
|
|
|
1388
1441
|
var extraProps = {
|
|
1389
1442
|
name: id
|
|
1390
1443
|
};
|
|
1391
|
-
return
|
|
1444
|
+
return jsx(Select, _extends({
|
|
1392
1445
|
autoFocus: autofocus,
|
|
1393
1446
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1394
1447
|
getPopupContainer: getPopupContainer,
|
|
1395
1448
|
id: id,
|
|
1396
|
-
mode: typeof multiple !==
|
|
1449
|
+
mode: typeof multiple !== 'undefined' ? 'multiple' : undefined,
|
|
1397
1450
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1398
1451
|
onChange: !readonly ? handleChange : undefined,
|
|
1399
1452
|
onFocus: !readonly ? handleFocus : undefined,
|
|
@@ -1402,20 +1455,21 @@ function SelectWidget(_ref) {
|
|
|
1402
1455
|
value: selectedIndexes
|
|
1403
1456
|
}, extraProps, {
|
|
1404
1457
|
filterOption: filterOption,
|
|
1405
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1458
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1459
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (_ref2, index) {
|
|
1460
|
+
var optionValue = _ref2.value,
|
|
1461
|
+
optionLabel = _ref2.label;
|
|
1462
|
+
return jsx(Select.Option, {
|
|
1463
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
|
|
1464
|
+
value: String(index),
|
|
1465
|
+
children: optionLabel
|
|
1466
|
+
}, String(index));
|
|
1467
|
+
})
|
|
1414
1468
|
}));
|
|
1415
1469
|
}
|
|
1416
1470
|
|
|
1417
1471
|
var INPUT_STYLE = {
|
|
1418
|
-
width:
|
|
1472
|
+
width: '100%'
|
|
1419
1473
|
};
|
|
1420
1474
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1421
1475
|
*
|
|
@@ -1436,7 +1490,7 @@ function TextareaWidget(_ref) {
|
|
|
1436
1490
|
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1437
1491
|
var handleChange = function handleChange(_ref2) {
|
|
1438
1492
|
var target = _ref2.target;
|
|
1439
|
-
return onChange(target.value ===
|
|
1493
|
+
return onChange(target.value === '' ? options.emptyValue : target.value);
|
|
1440
1494
|
};
|
|
1441
1495
|
var handleBlur = function handleBlur(_ref3) {
|
|
1442
1496
|
var target = _ref3.target;
|
|
@@ -1449,9 +1503,9 @@ function TextareaWidget(_ref) {
|
|
|
1449
1503
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1450
1504
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1451
1505
|
var extraProps = {
|
|
1452
|
-
type:
|
|
1506
|
+
type: 'textarea'
|
|
1453
1507
|
};
|
|
1454
|
-
return
|
|
1508
|
+
return jsx(Input.TextArea, _extends({
|
|
1455
1509
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1456
1510
|
id: id,
|
|
1457
1511
|
name: id,
|