@rjsf/antd 5.10.0 → 5.11.2
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/dist/antd.cjs.development.js +777 -780
- 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 +778 -781
- package/dist/antd.esm.js.map +1 -1
- package/dist/antd.umd.development.js +777 -780
- 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 +11 -10
package/dist/antd.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ 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';
|
|
6
|
-
import { getUiOptions, getTemplate, getInputProps,
|
|
6
|
+
import { getUiOptions, getTemplate, getInputProps, examplesId, ariaDescribedByIds, TranslatableString, errorId, titleId, descriptionId, canExpand, getSubmitButtonOptions, ADDITIONAL_PROPERTY_FLAG, UI_OPTIONS_KEY, parseDateString, toDateString, pad, enumOptionsIndexForValue, optionId, enumOptionsValueForIndex, labelValue, rangeSpec } from '@rjsf/utils';
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import { ConfigConsumer } from 'antd/es/config-provider/context';
|
|
9
9
|
import Input from 'antd/es/input';
|
|
@@ -30,10 +30,10 @@ import Radio from 'antd/es/radio';
|
|
|
30
30
|
import Slider from 'antd/es/slider';
|
|
31
31
|
import Select from 'antd/es/select';
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
const BTN_GRP_STYLE = {
|
|
34
34
|
width: '100%'
|
|
35
35
|
};
|
|
36
|
-
|
|
36
|
+
const BTN_STYLE = {
|
|
37
37
|
width: 'calc(100% / 4)'
|
|
38
38
|
};
|
|
39
39
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
@@ -41,30 +41,32 @@ var BTN_STYLE = {
|
|
|
41
41
|
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
42
42
|
*/
|
|
43
43
|
function ArrayFieldItemTemplate(props) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
44
|
+
const {
|
|
45
|
+
children,
|
|
46
|
+
disabled,
|
|
47
|
+
hasCopy,
|
|
48
|
+
hasMoveDown,
|
|
49
|
+
hasMoveUp,
|
|
50
|
+
hasRemove,
|
|
51
|
+
hasToolbar,
|
|
52
|
+
index,
|
|
53
|
+
onCopyIndexClick,
|
|
54
|
+
onDropIndexClick,
|
|
55
|
+
onReorderClick,
|
|
56
|
+
readonly,
|
|
57
|
+
registry,
|
|
58
|
+
uiSchema
|
|
59
|
+
} = props;
|
|
60
|
+
const {
|
|
61
|
+
CopyButton,
|
|
62
|
+
MoveDownButton,
|
|
63
|
+
MoveUpButton,
|
|
64
|
+
RemoveButton
|
|
65
|
+
} = registry.templates.ButtonTemplates;
|
|
66
|
+
const {
|
|
67
|
+
rowGutter = 24,
|
|
68
|
+
toolbarAlign = 'top'
|
|
69
|
+
} = registry.formContext;
|
|
68
70
|
return jsxs(Row, {
|
|
69
71
|
align: toolbarAlign,
|
|
70
72
|
gutter: rowGutter,
|
|
@@ -102,38 +104,10 @@ function ArrayFieldItemTemplate(props) {
|
|
|
102
104
|
})]
|
|
103
105
|
})
|
|
104
106
|
})]
|
|
105
|
-
},
|
|
107
|
+
}, `array-item-${index}`);
|
|
106
108
|
}
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
110
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
111
|
-
var source = arguments[i];
|
|
112
|
-
for (var key in source) {
|
|
113
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
114
|
-
target[key] = source[key];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return target;
|
|
119
|
-
};
|
|
120
|
-
return _extends.apply(this, arguments);
|
|
121
|
-
}
|
|
122
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
123
|
-
if (source == null) return {};
|
|
124
|
-
var target = {};
|
|
125
|
-
var sourceKeys = Object.keys(source);
|
|
126
|
-
var key, i;
|
|
127
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
128
|
-
key = sourceKeys[i];
|
|
129
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
130
|
-
target[key] = source[key];
|
|
131
|
-
}
|
|
132
|
-
return target;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
var _excluded$1 = ["key"];
|
|
136
|
-
var DESCRIPTION_COL_STYLE$1 = {
|
|
110
|
+
const DESCRIPTION_COL_STYLE$1 = {
|
|
137
111
|
paddingBottom: '8px'
|
|
138
112
|
};
|
|
139
113
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
@@ -141,35 +115,43 @@ var DESCRIPTION_COL_STYLE$1 = {
|
|
|
141
115
|
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
142
116
|
*/
|
|
143
117
|
function ArrayFieldTemplate(props) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
118
|
+
const {
|
|
119
|
+
canAdd,
|
|
120
|
+
className,
|
|
121
|
+
disabled,
|
|
122
|
+
formContext,
|
|
123
|
+
idSchema,
|
|
124
|
+
items,
|
|
125
|
+
onAddClick,
|
|
126
|
+
readonly,
|
|
127
|
+
registry,
|
|
128
|
+
required,
|
|
129
|
+
schema,
|
|
130
|
+
title,
|
|
131
|
+
uiSchema
|
|
132
|
+
} = props;
|
|
133
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
134
|
+
const ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
135
|
+
const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
136
|
+
const ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
161
137
|
// Button templates are not overridden in the uiSchema
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
138
|
+
const {
|
|
139
|
+
ButtonTemplates: {
|
|
140
|
+
AddButton
|
|
141
|
+
}
|
|
142
|
+
} = registry.templates;
|
|
143
|
+
const {
|
|
144
|
+
labelAlign = 'right',
|
|
145
|
+
rowGutter = 24
|
|
146
|
+
} = formContext;
|
|
167
147
|
return jsx(ConfigConsumer, {
|
|
168
|
-
children:
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
148
|
+
children: configProps => {
|
|
149
|
+
const {
|
|
150
|
+
getPrefixCls
|
|
151
|
+
} = configProps;
|
|
152
|
+
const prefixCls = getPrefixCls('form');
|
|
153
|
+
const labelClsBasic = `${prefixCls}-item-label`;
|
|
154
|
+
const labelColClassName = classNames(labelClsBasic, labelAlign === 'left' && `${labelClsBasic}-left`
|
|
173
155
|
// labelCol.className,
|
|
174
156
|
);
|
|
175
157
|
|
|
@@ -202,11 +184,12 @@ function ArrayFieldTemplate(props) {
|
|
|
202
184
|
}), jsx(Col, {
|
|
203
185
|
className: 'row array-item-list',
|
|
204
186
|
span: 24,
|
|
205
|
-
children: items && items.map(
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
187
|
+
children: items && items.map(({
|
|
188
|
+
key,
|
|
189
|
+
...itemProps
|
|
190
|
+
}) => jsx(ArrayFieldItemTemplate, {
|
|
191
|
+
...itemProps
|
|
192
|
+
}, key))
|
|
210
193
|
}), canAdd && jsx(Col, {
|
|
211
194
|
span: 24,
|
|
212
195
|
children: jsx(Row, {
|
|
@@ -230,7 +213,7 @@ function ArrayFieldTemplate(props) {
|
|
|
230
213
|
});
|
|
231
214
|
}
|
|
232
215
|
|
|
233
|
-
|
|
216
|
+
const INPUT_STYLE$2 = {
|
|
234
217
|
width: '100%'
|
|
235
218
|
};
|
|
236
219
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
@@ -240,38 +223,36 @@ var INPUT_STYLE$2 = {
|
|
|
240
223
|
* @param props - The `WidgetProps` for this template
|
|
241
224
|
*/
|
|
242
225
|
function BaseInputTemplate(props) {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
};
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
};
|
|
274
|
-
var input = inputProps.type === 'number' || inputProps.type === 'integer' ? jsx(InputNumber, _extends({
|
|
226
|
+
const {
|
|
227
|
+
disabled,
|
|
228
|
+
formContext,
|
|
229
|
+
id,
|
|
230
|
+
onBlur,
|
|
231
|
+
onChange,
|
|
232
|
+
onChangeOverride,
|
|
233
|
+
onFocus,
|
|
234
|
+
options,
|
|
235
|
+
placeholder,
|
|
236
|
+
readonly,
|
|
237
|
+
schema,
|
|
238
|
+
value,
|
|
239
|
+
type
|
|
240
|
+
} = props;
|
|
241
|
+
const inputProps = getInputProps(schema, type, options, false);
|
|
242
|
+
const {
|
|
243
|
+
readonlyAsDisabled = true
|
|
244
|
+
} = formContext;
|
|
245
|
+
const handleNumberChange = nextValue => onChange(nextValue);
|
|
246
|
+
const handleTextChange = onChangeOverride ? onChangeOverride : ({
|
|
247
|
+
target
|
|
248
|
+
}) => onChange(target.value === '' ? options.emptyValue : target.value);
|
|
249
|
+
const handleBlur = ({
|
|
250
|
+
target
|
|
251
|
+
}) => onBlur(id, target.value);
|
|
252
|
+
const handleFocus = ({
|
|
253
|
+
target
|
|
254
|
+
}) => onFocus(id, target.value);
|
|
255
|
+
const input = inputProps.type === 'number' || inputProps.type === 'integer' ? jsx(InputNumber, {
|
|
275
256
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
276
257
|
id: id,
|
|
277
258
|
name: id,
|
|
@@ -280,11 +261,11 @@ function BaseInputTemplate(props) {
|
|
|
280
261
|
onFocus: !readonly ? handleFocus : undefined,
|
|
281
262
|
placeholder: placeholder,
|
|
282
263
|
style: INPUT_STYLE$2,
|
|
283
|
-
list: schema.examples ? examplesId(id) : undefined
|
|
284
|
-
|
|
264
|
+
list: schema.examples ? examplesId(id) : undefined,
|
|
265
|
+
...inputProps,
|
|
285
266
|
value: value,
|
|
286
267
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
287
|
-
})
|
|
268
|
+
}) : jsx(Input, {
|
|
288
269
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
289
270
|
id: id,
|
|
290
271
|
name: id,
|
|
@@ -293,15 +274,15 @@ function BaseInputTemplate(props) {
|
|
|
293
274
|
onFocus: !readonly ? handleFocus : undefined,
|
|
294
275
|
placeholder: placeholder,
|
|
295
276
|
style: INPUT_STYLE$2,
|
|
296
|
-
list: schema.examples ? examplesId(id) : undefined
|
|
297
|
-
|
|
277
|
+
list: schema.examples ? examplesId(id) : undefined,
|
|
278
|
+
...inputProps,
|
|
298
279
|
value: value,
|
|
299
280
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
300
|
-
})
|
|
281
|
+
});
|
|
301
282
|
return jsxs(Fragment, {
|
|
302
283
|
children: [input, Array.isArray(schema.examples) && jsx("datalist", {
|
|
303
284
|
id: examplesId(id),
|
|
304
|
-
children: schema.examples.concat(schema
|
|
285
|
+
children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map(example => {
|
|
305
286
|
return jsx("option", {
|
|
306
287
|
value: example
|
|
307
288
|
}, example);
|
|
@@ -315,8 +296,10 @@ function BaseInputTemplate(props) {
|
|
|
315
296
|
* @param props - The `DescriptionFieldProps` for this component
|
|
316
297
|
*/
|
|
317
298
|
function DescriptionField(props) {
|
|
318
|
-
|
|
319
|
-
|
|
299
|
+
const {
|
|
300
|
+
id,
|
|
301
|
+
description
|
|
302
|
+
} = props;
|
|
320
303
|
if (!description) {
|
|
321
304
|
return null;
|
|
322
305
|
}
|
|
@@ -330,23 +313,22 @@ function DescriptionField(props) {
|
|
|
330
313
|
*
|
|
331
314
|
* @param props - The `ErrorListProps` for this component
|
|
332
315
|
*/
|
|
333
|
-
function ErrorList(
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}, index);
|
|
316
|
+
function ErrorList({
|
|
317
|
+
errors,
|
|
318
|
+
registry
|
|
319
|
+
}) {
|
|
320
|
+
const {
|
|
321
|
+
translateString
|
|
322
|
+
} = registry;
|
|
323
|
+
const renderErrors = () => jsx(List, {
|
|
324
|
+
className: 'list-group',
|
|
325
|
+
size: 'small',
|
|
326
|
+
children: errors.map((error, index) => jsx(List.Item, {
|
|
327
|
+
children: jsxs(Space, {
|
|
328
|
+
children: [jsx(ExclamationCircleOutlined, {}), error.stack]
|
|
347
329
|
})
|
|
348
|
-
})
|
|
349
|
-
};
|
|
330
|
+
}, index))
|
|
331
|
+
});
|
|
350
332
|
return jsx(Alert, {
|
|
351
333
|
className: 'panel panel-danger errors',
|
|
352
334
|
description: renderErrors(),
|
|
@@ -355,63 +337,86 @@ function ErrorList(_ref) {
|
|
|
355
337
|
});
|
|
356
338
|
}
|
|
357
339
|
|
|
358
|
-
var _excluded = ["iconType", "icon", "uiSchema", "registry"];
|
|
359
340
|
function IconButton(props) {
|
|
360
|
-
|
|
361
|
-
iconType =
|
|
362
|
-
icon
|
|
363
|
-
|
|
364
|
-
|
|
341
|
+
const {
|
|
342
|
+
iconType = 'default',
|
|
343
|
+
icon,
|
|
344
|
+
uiSchema,
|
|
345
|
+
registry,
|
|
346
|
+
...otherProps
|
|
347
|
+
} = props;
|
|
348
|
+
return jsx(Button, {
|
|
365
349
|
type: iconType,
|
|
366
|
-
icon: icon
|
|
367
|
-
|
|
350
|
+
icon: icon,
|
|
351
|
+
...otherProps
|
|
352
|
+
});
|
|
368
353
|
}
|
|
369
354
|
function AddButton(props) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
355
|
+
const {
|
|
356
|
+
registry: {
|
|
357
|
+
translateString
|
|
358
|
+
}
|
|
359
|
+
} = props;
|
|
360
|
+
return jsx(IconButton, {
|
|
361
|
+
title: translateString(TranslatableString.AddItemButton),
|
|
362
|
+
...props,
|
|
374
363
|
block: true,
|
|
375
364
|
iconType: 'primary',
|
|
376
365
|
icon: jsx(PlusCircleOutlined, {})
|
|
377
|
-
})
|
|
366
|
+
});
|
|
378
367
|
}
|
|
379
368
|
function CopyButton(props) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
369
|
+
const {
|
|
370
|
+
registry: {
|
|
371
|
+
translateString
|
|
372
|
+
}
|
|
373
|
+
} = props;
|
|
374
|
+
return jsx(IconButton, {
|
|
375
|
+
title: translateString(TranslatableString.CopyButton),
|
|
376
|
+
...props,
|
|
384
377
|
icon: jsx(CopyOutlined, {})
|
|
385
|
-
})
|
|
378
|
+
});
|
|
386
379
|
}
|
|
387
380
|
function MoveDownButton(props) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
381
|
+
const {
|
|
382
|
+
registry: {
|
|
383
|
+
translateString
|
|
384
|
+
}
|
|
385
|
+
} = props;
|
|
386
|
+
return jsx(IconButton, {
|
|
387
|
+
title: translateString(TranslatableString.MoveDownButton),
|
|
388
|
+
...props,
|
|
392
389
|
icon: jsx(ArrowDownOutlined, {})
|
|
393
|
-
})
|
|
390
|
+
});
|
|
394
391
|
}
|
|
395
392
|
function MoveUpButton(props) {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
393
|
+
const {
|
|
394
|
+
registry: {
|
|
395
|
+
translateString
|
|
396
|
+
}
|
|
397
|
+
} = props;
|
|
398
|
+
return jsx(IconButton, {
|
|
399
|
+
title: translateString(TranslatableString.MoveUpButton),
|
|
400
|
+
...props,
|
|
400
401
|
icon: jsx(ArrowUpOutlined, {})
|
|
401
|
-
})
|
|
402
|
+
});
|
|
402
403
|
}
|
|
403
404
|
function RemoveButton(props) {
|
|
404
405
|
// The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
406
|
+
const options = getUiOptions(props.uiSchema);
|
|
407
|
+
const {
|
|
408
|
+
registry: {
|
|
409
|
+
translateString
|
|
410
|
+
}
|
|
411
|
+
} = props;
|
|
412
|
+
return jsx(IconButton, {
|
|
413
|
+
title: translateString(TranslatableString.RemoveButton),
|
|
414
|
+
...props,
|
|
410
415
|
danger: true,
|
|
411
416
|
block: !!options.block,
|
|
412
417
|
iconType: 'primary',
|
|
413
418
|
icon: jsx(DeleteOutlined, {})
|
|
414
|
-
})
|
|
419
|
+
});
|
|
415
420
|
}
|
|
416
421
|
|
|
417
422
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -419,27 +424,26 @@ function RemoveButton(props) {
|
|
|
419
424
|
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
420
425
|
*/
|
|
421
426
|
function FieldErrorTemplate(props) {
|
|
422
|
-
|
|
423
|
-
errors =
|
|
424
|
-
idSchema
|
|
427
|
+
const {
|
|
428
|
+
errors = [],
|
|
429
|
+
idSchema
|
|
430
|
+
} = props;
|
|
425
431
|
if (errors.length === 0) {
|
|
426
432
|
return null;
|
|
427
433
|
}
|
|
428
|
-
|
|
434
|
+
const id = errorId(idSchema);
|
|
429
435
|
return jsx("div", {
|
|
430
436
|
id: id,
|
|
431
|
-
children: errors.map(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
}, "field-" + id + "-error-" + error);
|
|
435
|
-
})
|
|
437
|
+
children: errors.map(error => jsx("div", {
|
|
438
|
+
children: error
|
|
439
|
+
}, `field-${id}-error-${error}`))
|
|
436
440
|
});
|
|
437
441
|
}
|
|
438
442
|
|
|
439
|
-
|
|
443
|
+
const VERTICAL_LABEL_COL$1 = {
|
|
440
444
|
span: 24
|
|
441
445
|
};
|
|
442
|
-
|
|
446
|
+
const VERTICAL_WRAPPER_COL$1 = {
|
|
443
447
|
span: 24
|
|
444
448
|
};
|
|
445
449
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -448,38 +452,39 @@ var VERTICAL_WRAPPER_COL$1 = {
|
|
|
448
452
|
* @param props - The `FieldTemplateProps` for this component
|
|
449
453
|
*/
|
|
450
454
|
function FieldTemplate(props) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
descriptionLocation =
|
|
481
|
-
|
|
482
|
-
|
|
455
|
+
const {
|
|
456
|
+
children,
|
|
457
|
+
classNames,
|
|
458
|
+
style,
|
|
459
|
+
description,
|
|
460
|
+
disabled,
|
|
461
|
+
displayLabel,
|
|
462
|
+
errors,
|
|
463
|
+
formContext,
|
|
464
|
+
help,
|
|
465
|
+
hidden,
|
|
466
|
+
id,
|
|
467
|
+
label,
|
|
468
|
+
onDropPropertyClick,
|
|
469
|
+
onKeyChange,
|
|
470
|
+
rawErrors,
|
|
471
|
+
rawDescription,
|
|
472
|
+
rawHelp,
|
|
473
|
+
readonly,
|
|
474
|
+
registry,
|
|
475
|
+
required,
|
|
476
|
+
schema,
|
|
477
|
+
uiSchema
|
|
478
|
+
} = props;
|
|
479
|
+
const {
|
|
480
|
+
colon,
|
|
481
|
+
labelCol = VERTICAL_LABEL_COL$1,
|
|
482
|
+
wrapperCol = VERTICAL_WRAPPER_COL$1,
|
|
483
|
+
wrapperStyle,
|
|
484
|
+
descriptionLocation = 'below'
|
|
485
|
+
} = formContext;
|
|
486
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
487
|
+
const WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
483
488
|
if (hidden) {
|
|
484
489
|
return jsx("div", {
|
|
485
490
|
className: 'field-hidden',
|
|
@@ -488,8 +493,8 @@ function FieldTemplate(props) {
|
|
|
488
493
|
}
|
|
489
494
|
// check to see if there is rawDescription(string) before using description(ReactNode)
|
|
490
495
|
// to prevent showing a blank description area
|
|
491
|
-
|
|
492
|
-
|
|
496
|
+
const descriptionNode = rawDescription ? description : undefined;
|
|
497
|
+
const descriptionProps = {};
|
|
493
498
|
switch (descriptionLocation) {
|
|
494
499
|
case 'tooltip':
|
|
495
500
|
descriptionProps.tooltip = descriptionNode;
|
|
@@ -512,7 +517,7 @@ function FieldTemplate(props) {
|
|
|
512
517
|
schema: schema,
|
|
513
518
|
uiSchema: uiSchema,
|
|
514
519
|
registry: registry,
|
|
515
|
-
children: jsx(Form$1.Item,
|
|
520
|
+
children: jsx(Form$1.Item, {
|
|
516
521
|
colon: colon,
|
|
517
522
|
hasFeedback: schema.type !== 'array' && schema.type !== 'object',
|
|
518
523
|
help: !!rawHelp && help || (rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? errors : undefined),
|
|
@@ -522,14 +527,14 @@ function FieldTemplate(props) {
|
|
|
522
527
|
required: required,
|
|
523
528
|
style: wrapperStyle,
|
|
524
529
|
validateStatus: rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? 'error' : undefined,
|
|
525
|
-
wrapperCol: wrapperCol
|
|
526
|
-
|
|
530
|
+
wrapperCol: wrapperCol,
|
|
531
|
+
...descriptionProps,
|
|
527
532
|
children: children
|
|
528
|
-
})
|
|
533
|
+
})
|
|
529
534
|
});
|
|
530
535
|
}
|
|
531
536
|
|
|
532
|
-
|
|
537
|
+
const DESCRIPTION_COL_STYLE = {
|
|
533
538
|
paddingBottom: '8px'
|
|
534
539
|
};
|
|
535
540
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -539,54 +544,49 @@ var DESCRIPTION_COL_STYLE = {
|
|
|
539
544
|
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
540
545
|
*/
|
|
541
546
|
function ObjectFieldTemplate(props) {
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
547
|
+
const {
|
|
548
|
+
description,
|
|
549
|
+
disabled,
|
|
550
|
+
formContext,
|
|
551
|
+
formData,
|
|
552
|
+
idSchema,
|
|
553
|
+
onAddClick,
|
|
554
|
+
properties,
|
|
555
|
+
readonly,
|
|
556
|
+
required,
|
|
557
|
+
registry,
|
|
558
|
+
schema,
|
|
559
|
+
title,
|
|
560
|
+
uiSchema
|
|
561
|
+
} = props;
|
|
562
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
563
|
+
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
564
|
+
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
558
565
|
// Button templates are not overridden in the uiSchema
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
};
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
return getUiOptions(findUiSchema(element)).widget;
|
|
580
|
-
};
|
|
581
|
-
var calculateColSpan = function calculateColSpan(element) {
|
|
582
|
-
var type = findSchemaType(element);
|
|
583
|
-
var field = findUiSchemaField(element);
|
|
584
|
-
var widget = findUiSchemaWidget(element);
|
|
585
|
-
var defaultColSpan = properties.length < 2 ||
|
|
566
|
+
const {
|
|
567
|
+
ButtonTemplates: {
|
|
568
|
+
AddButton
|
|
569
|
+
}
|
|
570
|
+
} = registry.templates;
|
|
571
|
+
const {
|
|
572
|
+
colSpan = 24,
|
|
573
|
+
labelAlign = 'right',
|
|
574
|
+
rowGutter = 24
|
|
575
|
+
} = formContext;
|
|
576
|
+
const findSchema = element => element.content.props.schema;
|
|
577
|
+
const findSchemaType = element => findSchema(element).type;
|
|
578
|
+
const findUiSchema = element => element.content.props.uiSchema;
|
|
579
|
+
const findUiSchemaField = element => getUiOptions(findUiSchema(element)).field;
|
|
580
|
+
const findUiSchemaWidget = element => getUiOptions(findUiSchema(element)).widget;
|
|
581
|
+
const calculateColSpan = element => {
|
|
582
|
+
const type = findSchemaType(element);
|
|
583
|
+
const field = findUiSchemaField(element);
|
|
584
|
+
const widget = findUiSchemaWidget(element);
|
|
585
|
+
const defaultColSpan = properties.length < 2 ||
|
|
586
586
|
// Single or no field in object.
|
|
587
587
|
type === 'object' || type === 'array' || widget === 'textarea' ? 24 : 12;
|
|
588
588
|
if (isObject(colSpan)) {
|
|
589
|
-
|
|
589
|
+
const colSpanObj = colSpan;
|
|
590
590
|
if (isString(widget)) {
|
|
591
591
|
return colSpanObj[widget];
|
|
592
592
|
}
|
|
@@ -603,11 +603,13 @@ function ObjectFieldTemplate(props) {
|
|
|
603
603
|
return defaultColSpan;
|
|
604
604
|
};
|
|
605
605
|
return jsx(ConfigConsumer, {
|
|
606
|
-
children:
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
606
|
+
children: configProps => {
|
|
607
|
+
const {
|
|
608
|
+
getPrefixCls
|
|
609
|
+
} = configProps;
|
|
610
|
+
const prefixCls = getPrefixCls('form');
|
|
611
|
+
const labelClsBasic = `${prefixCls}-item-label`;
|
|
612
|
+
const labelColClassName = classNames(labelClsBasic, labelAlign === 'left' && `${labelClsBasic}-left`
|
|
611
613
|
// labelCol.className,
|
|
612
614
|
);
|
|
613
615
|
|
|
@@ -636,14 +638,10 @@ function ObjectFieldTemplate(props) {
|
|
|
636
638
|
uiSchema: uiSchema,
|
|
637
639
|
registry: registry
|
|
638
640
|
})
|
|
639
|
-
}), properties.filter(
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
span: calculateColSpan(element),
|
|
644
|
-
children: element.content
|
|
645
|
-
}, element.name);
|
|
646
|
-
})]
|
|
641
|
+
}), properties.filter(e => !e.hidden).map(element => jsx(Col, {
|
|
642
|
+
span: calculateColSpan(element),
|
|
643
|
+
children: element.content
|
|
644
|
+
}, element.name))]
|
|
647
645
|
}), canExpand(schema, uiSchema, formData) && jsx(Col, {
|
|
648
646
|
span: 24,
|
|
649
647
|
children: jsx(Row, {
|
|
@@ -668,54 +666,64 @@ function ObjectFieldTemplate(props) {
|
|
|
668
666
|
|
|
669
667
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
670
668
|
*/
|
|
671
|
-
function SubmitButton(
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
669
|
+
function SubmitButton({
|
|
670
|
+
uiSchema
|
|
671
|
+
}) {
|
|
672
|
+
const {
|
|
673
|
+
submitText,
|
|
674
|
+
norender,
|
|
675
|
+
props: submitButtonProps
|
|
676
|
+
} = getSubmitButtonOptions(uiSchema);
|
|
677
677
|
if (norender) {
|
|
678
678
|
return null;
|
|
679
679
|
}
|
|
680
|
-
return jsx(Button,
|
|
681
|
-
type: 'submit'
|
|
682
|
-
|
|
680
|
+
return jsx(Button, {
|
|
681
|
+
type: 'submit',
|
|
682
|
+
...submitButtonProps,
|
|
683
683
|
htmlType: 'submit',
|
|
684
684
|
children: submitText
|
|
685
|
-
})
|
|
685
|
+
});
|
|
686
686
|
}
|
|
687
687
|
|
|
688
688
|
/** The `TitleField` is the template to use to render the title of a field
|
|
689
689
|
*
|
|
690
690
|
* @param props - The `TitleFieldProps` for this component
|
|
691
691
|
*/
|
|
692
|
-
function TitleField(
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
692
|
+
function TitleField({
|
|
693
|
+
id,
|
|
694
|
+
required,
|
|
695
|
+
registry,
|
|
696
|
+
title
|
|
697
|
+
}) {
|
|
698
|
+
const {
|
|
699
|
+
formContext
|
|
700
|
+
} = registry;
|
|
701
|
+
const {
|
|
702
|
+
colon = true
|
|
703
|
+
} = formContext;
|
|
704
|
+
let labelChildren = title;
|
|
701
705
|
if (colon && typeof title === 'string' && title.trim() !== '') {
|
|
702
706
|
labelChildren = title.replace(/[::]\s*$/, '');
|
|
703
707
|
}
|
|
704
|
-
|
|
708
|
+
const handleLabelClick = () => {
|
|
705
709
|
if (!id) {
|
|
706
710
|
return;
|
|
707
711
|
}
|
|
708
|
-
|
|
712
|
+
const control = document.querySelector(`[id="${id}"]`);
|
|
709
713
|
if (control && control.focus) {
|
|
710
714
|
control.focus();
|
|
711
715
|
}
|
|
712
716
|
};
|
|
713
717
|
return title ? jsx(ConfigConsumer, {
|
|
714
|
-
children:
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
718
|
+
children: configProps => {
|
|
719
|
+
const {
|
|
720
|
+
getPrefixCls
|
|
721
|
+
} = configProps;
|
|
722
|
+
const prefixCls = getPrefixCls('form');
|
|
723
|
+
const labelClassName = classNames({
|
|
724
|
+
[`${prefixCls}-item-required`]: required,
|
|
725
|
+
[`${prefixCls}-item-no-colon`]: !colon
|
|
726
|
+
});
|
|
719
727
|
return jsx("label", {
|
|
720
728
|
className: labelClassName,
|
|
721
729
|
htmlFor: id,
|
|
@@ -727,13 +735,13 @@ function TitleField(_ref) {
|
|
|
727
735
|
}) : null;
|
|
728
736
|
}
|
|
729
737
|
|
|
730
|
-
|
|
738
|
+
const VERTICAL_LABEL_COL = {
|
|
731
739
|
span: 24
|
|
732
740
|
};
|
|
733
|
-
|
|
741
|
+
const VERTICAL_WRAPPER_COL = {
|
|
734
742
|
span: 24
|
|
735
743
|
};
|
|
736
|
-
|
|
744
|
+
const INPUT_STYLE$1 = {
|
|
737
745
|
width: '100%'
|
|
738
746
|
};
|
|
739
747
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -742,39 +750,40 @@ var INPUT_STYLE$1 = {
|
|
|
742
750
|
* @param props - The `WrapIfAdditionalProps` for this component
|
|
743
751
|
*/
|
|
744
752
|
function WrapIfAdditionalTemplate(props) {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
classNames
|
|
748
|
-
style
|
|
749
|
-
disabled
|
|
750
|
-
id
|
|
751
|
-
label
|
|
752
|
-
onDropPropertyClick
|
|
753
|
-
onKeyChange
|
|
754
|
-
readonly
|
|
755
|
-
required
|
|
756
|
-
registry
|
|
757
|
-
schema
|
|
758
|
-
uiSchema
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
labelCol =
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
translateString = registry.translateString;
|
|
753
|
+
const {
|
|
754
|
+
children,
|
|
755
|
+
classNames,
|
|
756
|
+
style,
|
|
757
|
+
disabled,
|
|
758
|
+
id,
|
|
759
|
+
label,
|
|
760
|
+
onDropPropertyClick,
|
|
761
|
+
onKeyChange,
|
|
762
|
+
readonly,
|
|
763
|
+
required,
|
|
764
|
+
registry,
|
|
765
|
+
schema,
|
|
766
|
+
uiSchema
|
|
767
|
+
} = props;
|
|
768
|
+
const {
|
|
769
|
+
colon,
|
|
770
|
+
labelCol = VERTICAL_LABEL_COL,
|
|
771
|
+
readonlyAsDisabled = true,
|
|
772
|
+
rowGutter = 24,
|
|
773
|
+
toolbarAlign = 'top',
|
|
774
|
+
wrapperCol = VERTICAL_WRAPPER_COL,
|
|
775
|
+
wrapperStyle
|
|
776
|
+
} = registry.formContext;
|
|
777
|
+
const {
|
|
778
|
+
templates,
|
|
779
|
+
translateString
|
|
780
|
+
} = registry;
|
|
774
781
|
// Button templates are not overridden in the uiSchema
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
782
|
+
const {
|
|
783
|
+
RemoveButton
|
|
784
|
+
} = templates.ButtonTemplates;
|
|
785
|
+
const keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
786
|
+
const additional = (ADDITIONAL_PROPERTY_FLAG in schema);
|
|
778
787
|
if (!additional) {
|
|
779
788
|
return jsx("div", {
|
|
780
789
|
className: classNames,
|
|
@@ -782,15 +791,18 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
782
791
|
children: children
|
|
783
792
|
});
|
|
784
793
|
}
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
};
|
|
794
|
+
const handleBlur = ({
|
|
795
|
+
target
|
|
796
|
+
}) => onKeyChange(target.value);
|
|
789
797
|
// The `block` prop is not part of the `IconButtonProps` defined in the template, so put it into the uiSchema instead
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
798
|
+
const uiOptions = uiSchema ? uiSchema[UI_OPTIONS_KEY] : {};
|
|
799
|
+
const buttonUiOptions = {
|
|
800
|
+
...uiSchema,
|
|
801
|
+
[UI_OPTIONS_KEY]: {
|
|
802
|
+
...uiOptions,
|
|
803
|
+
block: true
|
|
804
|
+
}
|
|
805
|
+
};
|
|
794
806
|
return jsx("div", {
|
|
795
807
|
className: classNames,
|
|
796
808
|
style: style,
|
|
@@ -806,7 +818,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
806
818
|
colon: colon,
|
|
807
819
|
className: 'form-group',
|
|
808
820
|
hasFeedback: true,
|
|
809
|
-
htmlFor: id
|
|
821
|
+
htmlFor: `${id}-key`,
|
|
810
822
|
label: keyLabel,
|
|
811
823
|
labelCol: labelCol,
|
|
812
824
|
required: required,
|
|
@@ -816,8 +828,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
816
828
|
className: 'form-control',
|
|
817
829
|
defaultValue: label,
|
|
818
830
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
819
|
-
id: id
|
|
820
|
-
name: id
|
|
831
|
+
id: `${id}-key`,
|
|
832
|
+
name: `${id}-key`,
|
|
821
833
|
onBlur: !readonly ? handleBlur : undefined,
|
|
822
834
|
style: INPUT_STYLE$1,
|
|
823
835
|
type: 'text'
|
|
@@ -844,31 +856,31 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
844
856
|
|
|
845
857
|
function generateTemplates() {
|
|
846
858
|
return {
|
|
847
|
-
ArrayFieldItemTemplate
|
|
848
|
-
ArrayFieldTemplate
|
|
849
|
-
BaseInputTemplate
|
|
859
|
+
ArrayFieldItemTemplate,
|
|
860
|
+
ArrayFieldTemplate,
|
|
861
|
+
BaseInputTemplate,
|
|
850
862
|
ButtonTemplates: {
|
|
851
|
-
AddButton
|
|
852
|
-
CopyButton
|
|
853
|
-
MoveDownButton
|
|
854
|
-
MoveUpButton
|
|
855
|
-
RemoveButton
|
|
856
|
-
SubmitButton
|
|
863
|
+
AddButton,
|
|
864
|
+
CopyButton,
|
|
865
|
+
MoveDownButton,
|
|
866
|
+
MoveUpButton,
|
|
867
|
+
RemoveButton,
|
|
868
|
+
SubmitButton
|
|
857
869
|
},
|
|
858
870
|
DescriptionFieldTemplate: DescriptionField,
|
|
859
871
|
ErrorListTemplate: ErrorList,
|
|
860
|
-
FieldErrorTemplate
|
|
861
|
-
FieldTemplate
|
|
862
|
-
ObjectFieldTemplate
|
|
872
|
+
FieldErrorTemplate,
|
|
873
|
+
FieldTemplate,
|
|
874
|
+
ObjectFieldTemplate,
|
|
863
875
|
TitleFieldTemplate: TitleField,
|
|
864
|
-
WrapIfAdditionalTemplate
|
|
876
|
+
WrapIfAdditionalTemplate
|
|
865
877
|
};
|
|
866
878
|
}
|
|
867
879
|
var index$1 = /*#__PURE__*/generateTemplates();
|
|
868
880
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
for (
|
|
881
|
+
const rangeOptions = (start, stop) => {
|
|
882
|
+
const options = [];
|
|
883
|
+
for (let i = start; i <= stop; i++) {
|
|
872
884
|
options.push({
|
|
873
885
|
value: i,
|
|
874
886
|
label: pad(i, 2)
|
|
@@ -876,22 +888,19 @@ var rangeOptions = function rangeOptions(start, stop) {
|
|
|
876
888
|
}
|
|
877
889
|
return options;
|
|
878
890
|
};
|
|
879
|
-
|
|
880
|
-
return Object.values(state).every(
|
|
881
|
-
return value !== -1;
|
|
882
|
-
});
|
|
891
|
+
const readyForChange = state => {
|
|
892
|
+
return Object.values(state).every(value => value !== -1);
|
|
883
893
|
};
|
|
884
|
-
function dateElementProps(state, time, yearsRange) {
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
var data = [{
|
|
894
|
+
function dateElementProps(state, time, yearsRange = [1900, new Date().getFullYear() + 2]) {
|
|
895
|
+
const {
|
|
896
|
+
year,
|
|
897
|
+
month,
|
|
898
|
+
day,
|
|
899
|
+
hour,
|
|
900
|
+
minute,
|
|
901
|
+
second
|
|
902
|
+
} = state;
|
|
903
|
+
const data = [{
|
|
895
904
|
type: 'year',
|
|
896
905
|
range: yearsRange,
|
|
897
906
|
value: year
|
|
@@ -922,99 +931,103 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
922
931
|
return data;
|
|
923
932
|
}
|
|
924
933
|
function AltDateWidget(props) {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
934
|
+
const {
|
|
935
|
+
autofocus,
|
|
936
|
+
disabled,
|
|
937
|
+
formContext,
|
|
938
|
+
id,
|
|
939
|
+
onBlur,
|
|
940
|
+
onChange,
|
|
941
|
+
onFocus,
|
|
942
|
+
options,
|
|
943
|
+
readonly,
|
|
944
|
+
registry,
|
|
945
|
+
showTime,
|
|
946
|
+
value
|
|
947
|
+
} = props;
|
|
948
|
+
const {
|
|
949
|
+
translateString,
|
|
950
|
+
widgets
|
|
951
|
+
} = registry;
|
|
952
|
+
const {
|
|
953
|
+
SelectWidget
|
|
954
|
+
} = widgets;
|
|
955
|
+
const {
|
|
956
|
+
rowGutter = 24
|
|
957
|
+
} = formContext;
|
|
958
|
+
const [state, setState] = useState(parseDateString(value, showTime));
|
|
959
|
+
useEffect(() => {
|
|
946
960
|
setState(parseDateString(value, showTime));
|
|
947
961
|
}, [showTime, value]);
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
962
|
+
const handleChange = (property, nextValue) => {
|
|
963
|
+
const nextState = {
|
|
964
|
+
...state,
|
|
965
|
+
[property]: typeof nextValue === 'undefined' ? -1 : nextValue
|
|
966
|
+
};
|
|
951
967
|
if (readyForChange(nextState)) {
|
|
952
968
|
onChange(toDateString(nextState, showTime));
|
|
953
969
|
} else {
|
|
954
970
|
setState(nextState);
|
|
955
971
|
}
|
|
956
972
|
};
|
|
957
|
-
|
|
973
|
+
const handleNow = event => {
|
|
958
974
|
event.preventDefault();
|
|
959
975
|
if (disabled || readonly) {
|
|
960
976
|
return;
|
|
961
977
|
}
|
|
962
|
-
|
|
978
|
+
const nextState = parseDateString(new Date().toJSON(), showTime);
|
|
963
979
|
onChange(toDateString(nextState, showTime));
|
|
964
980
|
};
|
|
965
|
-
|
|
981
|
+
const handleClear = event => {
|
|
966
982
|
event.preventDefault();
|
|
967
983
|
if (disabled || readonly) {
|
|
968
984
|
return;
|
|
969
985
|
}
|
|
970
986
|
onChange(undefined);
|
|
971
987
|
};
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
label: '',
|
|
995
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
996
|
-
});
|
|
997
|
-
};
|
|
988
|
+
const renderDateElement = elemProps => jsx(SelectWidget, {
|
|
989
|
+
autofocus: elemProps.autofocus,
|
|
990
|
+
className: 'form-control',
|
|
991
|
+
disabled: elemProps.disabled,
|
|
992
|
+
id: elemProps.id,
|
|
993
|
+
name: elemProps.name,
|
|
994
|
+
onBlur: elemProps.onBlur,
|
|
995
|
+
onChange: elemValue => elemProps.select(elemProps.type, elemValue),
|
|
996
|
+
onFocus: elemProps.onFocus,
|
|
997
|
+
options: {
|
|
998
|
+
enumOptions: rangeOptions(elemProps.range[0], elemProps.range[1])
|
|
999
|
+
},
|
|
1000
|
+
placeholder: elemProps.type,
|
|
1001
|
+
readonly: elemProps.readonly,
|
|
1002
|
+
schema: {
|
|
1003
|
+
type: 'integer'
|
|
1004
|
+
},
|
|
1005
|
+
value: elemProps.value,
|
|
1006
|
+
registry: registry,
|
|
1007
|
+
label: '',
|
|
1008
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
1009
|
+
});
|
|
998
1010
|
return jsxs(Row, {
|
|
999
1011
|
gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)],
|
|
1000
|
-
children: [dateElementProps(state, showTime, options.yearsRange).map(
|
|
1001
|
-
|
|
1012
|
+
children: [dateElementProps(state, showTime, options.yearsRange).map((elemProps, i) => {
|
|
1013
|
+
const elemId = id + '_' + elemProps.type;
|
|
1002
1014
|
return jsx(Col, {
|
|
1003
1015
|
flex: '88px',
|
|
1004
|
-
children: renderDateElement(
|
|
1016
|
+
children: renderDateElement({
|
|
1017
|
+
...elemProps,
|
|
1005
1018
|
autofocus: autofocus && i === 0,
|
|
1006
|
-
disabled
|
|
1019
|
+
disabled,
|
|
1007
1020
|
id: elemId,
|
|
1008
1021
|
name: id,
|
|
1009
|
-
onBlur
|
|
1010
|
-
onFocus
|
|
1011
|
-
readonly
|
|
1012
|
-
registry
|
|
1022
|
+
onBlur,
|
|
1023
|
+
onFocus,
|
|
1024
|
+
readonly,
|
|
1025
|
+
registry,
|
|
1013
1026
|
select: handleChange,
|
|
1014
1027
|
// NOTE: antd components accept -1 rather than issue a warning
|
|
1015
1028
|
// like material-ui, so we need to convert -1 to undefined here.
|
|
1016
1029
|
value: elemProps.value < 0 ? undefined : elemProps.value
|
|
1017
|
-
})
|
|
1030
|
+
})
|
|
1018
1031
|
}, elemId);
|
|
1019
1032
|
}), !options.hideNowButton && jsx(Col, {
|
|
1020
1033
|
flex: '88px',
|
|
@@ -1049,62 +1062,66 @@ AltDateWidget.defaultProps = {
|
|
|
1049
1062
|
};
|
|
1050
1063
|
|
|
1051
1064
|
function AltDateTimeWidget(props) {
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1065
|
+
const {
|
|
1066
|
+
AltDateWidget
|
|
1067
|
+
} = props.registry.widgets;
|
|
1068
|
+
return jsx(AltDateWidget, {
|
|
1069
|
+
showTime: true,
|
|
1070
|
+
...props
|
|
1071
|
+
});
|
|
1056
1072
|
}
|
|
1057
|
-
AltDateTimeWidget.defaultProps =
|
|
1073
|
+
AltDateTimeWidget.defaultProps = {
|
|
1074
|
+
...AltDateWidget.defaultProps,
|
|
1058
1075
|
showTime: true
|
|
1059
|
-
}
|
|
1076
|
+
};
|
|
1060
1077
|
|
|
1061
1078
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
1062
1079
|
* It is typically used to represent an array of enums.
|
|
1063
1080
|
*
|
|
1064
1081
|
* @param props - The `WidgetProps` for this component
|
|
1065
1082
|
*/
|
|
1066
|
-
function CheckboxesWidget(
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
};
|
|
1083
|
+
function CheckboxesWidget({
|
|
1084
|
+
autofocus,
|
|
1085
|
+
disabled,
|
|
1086
|
+
formContext,
|
|
1087
|
+
id,
|
|
1088
|
+
label,
|
|
1089
|
+
hideLabel,
|
|
1090
|
+
onBlur,
|
|
1091
|
+
onChange,
|
|
1092
|
+
onFocus,
|
|
1093
|
+
options,
|
|
1094
|
+
readonly,
|
|
1095
|
+
registry,
|
|
1096
|
+
schema,
|
|
1097
|
+
uiSchema,
|
|
1098
|
+
value
|
|
1099
|
+
}) {
|
|
1100
|
+
const {
|
|
1101
|
+
readonlyAsDisabled = true
|
|
1102
|
+
} = formContext;
|
|
1103
|
+
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
1104
|
+
const {
|
|
1105
|
+
enumOptions,
|
|
1106
|
+
enumDisabled,
|
|
1107
|
+
inline,
|
|
1108
|
+
emptyValue
|
|
1109
|
+
} = options;
|
|
1110
|
+
const handleChange = nextValue => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1111
|
+
const handleBlur = ({
|
|
1112
|
+
target
|
|
1113
|
+
}) => onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1114
|
+
const handleFocus = ({
|
|
1115
|
+
target
|
|
1116
|
+
}) => onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1100
1117
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1101
1118
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1102
|
-
|
|
1103
|
-
id
|
|
1119
|
+
const extraProps = {
|
|
1120
|
+
id,
|
|
1104
1121
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1105
1122
|
onFocus: !readonly ? handleFocus : undefined
|
|
1106
1123
|
};
|
|
1107
|
-
|
|
1124
|
+
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, true);
|
|
1108
1125
|
return Array.isArray(enumOptions) && enumOptions.length > 0 ? jsxs(Fragment, {
|
|
1109
1126
|
children: [!hideLabel && !!label && jsx("div", {
|
|
1110
1127
|
children: jsx(TitleFieldTemplate, {
|
|
@@ -1114,26 +1131,24 @@ function CheckboxesWidget(_ref) {
|
|
|
1114
1131
|
uiSchema: uiSchema,
|
|
1115
1132
|
registry: registry
|
|
1116
1133
|
})
|
|
1117
|
-
}), jsx(Checkbox.Group,
|
|
1134
|
+
}), jsx(Checkbox.Group, {
|
|
1118
1135
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1119
1136
|
name: id,
|
|
1120
1137
|
onChange: !readonly ? handleChange : undefined,
|
|
1121
|
-
value: selectedIndexes
|
|
1122
|
-
|
|
1138
|
+
value: selectedIndexes,
|
|
1139
|
+
...extraProps,
|
|
1123
1140
|
"aria-describedby": ariaDescribedByIds(id),
|
|
1124
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
})
|
|
1136
|
-
}))]
|
|
1141
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, i) => jsxs("span", {
|
|
1142
|
+
children: [jsx(Checkbox, {
|
|
1143
|
+
id: optionId(id, i),
|
|
1144
|
+
name: id,
|
|
1145
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1146
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1147
|
+
value: String(i),
|
|
1148
|
+
children: option.label
|
|
1149
|
+
}), !inline && jsx("br", {})]
|
|
1150
|
+
}, i))
|
|
1151
|
+
})]
|
|
1137
1152
|
}) : null;
|
|
1138
1153
|
}
|
|
1139
1154
|
|
|
@@ -1143,53 +1158,53 @@ function CheckboxesWidget(_ref) {
|
|
|
1143
1158
|
* @param props - The `WidgetProps` for this component
|
|
1144
1159
|
*/
|
|
1145
1160
|
function CheckboxWidget(props) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
};
|
|
1161
|
+
const {
|
|
1162
|
+
autofocus,
|
|
1163
|
+
disabled,
|
|
1164
|
+
formContext,
|
|
1165
|
+
id,
|
|
1166
|
+
label,
|
|
1167
|
+
hideLabel,
|
|
1168
|
+
onBlur,
|
|
1169
|
+
onChange,
|
|
1170
|
+
onFocus,
|
|
1171
|
+
readonly,
|
|
1172
|
+
value
|
|
1173
|
+
} = props;
|
|
1174
|
+
const {
|
|
1175
|
+
readonlyAsDisabled = true
|
|
1176
|
+
} = formContext;
|
|
1177
|
+
const handleChange = ({
|
|
1178
|
+
target
|
|
1179
|
+
}) => onChange(target.checked);
|
|
1180
|
+
const handleBlur = ({
|
|
1181
|
+
target
|
|
1182
|
+
}) => onBlur(id, target.checked);
|
|
1183
|
+
const handleFocus = ({
|
|
1184
|
+
target
|
|
1185
|
+
}) => onFocus(id, target.checked);
|
|
1171
1186
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1172
1187
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1173
|
-
|
|
1188
|
+
const extraProps = {
|
|
1174
1189
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1175
1190
|
onFocus: !readonly ? handleFocus : undefined
|
|
1176
1191
|
};
|
|
1177
|
-
return jsx(Checkbox,
|
|
1192
|
+
return jsx(Checkbox, {
|
|
1178
1193
|
autoFocus: autofocus,
|
|
1179
1194
|
checked: typeof value === 'undefined' ? false : value,
|
|
1180
1195
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1181
1196
|
id: id,
|
|
1182
1197
|
name: id,
|
|
1183
|
-
onChange: !readonly ? handleChange : undefined
|
|
1184
|
-
|
|
1198
|
+
onChange: !readonly ? handleChange : undefined,
|
|
1199
|
+
...extraProps,
|
|
1185
1200
|
"aria-describedby": ariaDescribedByIds(id),
|
|
1186
1201
|
children: labelValue(label, hideLabel, '')
|
|
1187
|
-
})
|
|
1202
|
+
});
|
|
1188
1203
|
}
|
|
1189
1204
|
|
|
1190
|
-
|
|
1205
|
+
const DatePicker = /*#__PURE__*/generatePicker(dayjsGenerateConfig);
|
|
1191
1206
|
|
|
1192
|
-
|
|
1207
|
+
const DATE_PICKER_STYLE$1 = {
|
|
1193
1208
|
width: '100%'
|
|
1194
1209
|
};
|
|
1195
1210
|
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
@@ -1198,29 +1213,24 @@ var DATE_PICKER_STYLE$1 = {
|
|
|
1198
1213
|
* @param props - The `WidgetProps` for this component
|
|
1199
1214
|
*/
|
|
1200
1215
|
function DateTimeWidget(props) {
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
return onFocus(id, value);
|
|
1220
|
-
};
|
|
1221
|
-
var getPopupContainer = function getPopupContainer(node) {
|
|
1222
|
-
return node.parentNode;
|
|
1223
|
-
};
|
|
1216
|
+
const {
|
|
1217
|
+
disabled,
|
|
1218
|
+
formContext,
|
|
1219
|
+
id,
|
|
1220
|
+
onBlur,
|
|
1221
|
+
onChange,
|
|
1222
|
+
onFocus,
|
|
1223
|
+
placeholder,
|
|
1224
|
+
readonly,
|
|
1225
|
+
value
|
|
1226
|
+
} = props;
|
|
1227
|
+
const {
|
|
1228
|
+
readonlyAsDisabled = true
|
|
1229
|
+
} = formContext;
|
|
1230
|
+
const handleChange = nextValue => onChange(nextValue && nextValue.toISOString());
|
|
1231
|
+
const handleBlur = () => onBlur(id, value);
|
|
1232
|
+
const handleFocus = () => onFocus(id, value);
|
|
1233
|
+
const getPopupContainer = node => node.parentNode;
|
|
1224
1234
|
return jsx(DatePicker, {
|
|
1225
1235
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1226
1236
|
getPopupContainer: getPopupContainer,
|
|
@@ -1237,7 +1247,7 @@ function DateTimeWidget(props) {
|
|
|
1237
1247
|
});
|
|
1238
1248
|
}
|
|
1239
1249
|
|
|
1240
|
-
|
|
1250
|
+
const DATE_PICKER_STYLE = {
|
|
1241
1251
|
width: '100%'
|
|
1242
1252
|
};
|
|
1243
1253
|
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
@@ -1246,29 +1256,24 @@ var DATE_PICKER_STYLE = {
|
|
|
1246
1256
|
* @param props - The `WidgetProps` for this component
|
|
1247
1257
|
*/
|
|
1248
1258
|
function DateWidget(props) {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
};
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
return onFocus(id, value);
|
|
1268
|
-
};
|
|
1269
|
-
var getPopupContainer = function getPopupContainer(node) {
|
|
1270
|
-
return node.parentNode;
|
|
1271
|
-
};
|
|
1259
|
+
const {
|
|
1260
|
+
disabled,
|
|
1261
|
+
formContext,
|
|
1262
|
+
id,
|
|
1263
|
+
onBlur,
|
|
1264
|
+
onChange,
|
|
1265
|
+
onFocus,
|
|
1266
|
+
placeholder,
|
|
1267
|
+
readonly,
|
|
1268
|
+
value
|
|
1269
|
+
} = props;
|
|
1270
|
+
const {
|
|
1271
|
+
readonlyAsDisabled = true
|
|
1272
|
+
} = formContext;
|
|
1273
|
+
const handleChange = nextValue => onChange(nextValue && nextValue.format('YYYY-MM-DD'));
|
|
1274
|
+
const handleBlur = () => onBlur(id, value);
|
|
1275
|
+
const handleFocus = () => onFocus(id, value);
|
|
1276
|
+
const getPopupContainer = node => node.parentNode;
|
|
1272
1277
|
return jsx(DatePicker, {
|
|
1273
1278
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1274
1279
|
getPopupContainer: getPopupContainer,
|
|
@@ -1290,31 +1295,31 @@ function DateWidget(props) {
|
|
|
1290
1295
|
* @param props - The `WidgetProps` for this component
|
|
1291
1296
|
*/
|
|
1292
1297
|
function PasswordWidget(props) {
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
};
|
|
1298
|
+
const {
|
|
1299
|
+
disabled,
|
|
1300
|
+
formContext,
|
|
1301
|
+
id,
|
|
1302
|
+
onBlur,
|
|
1303
|
+
onChange,
|
|
1304
|
+
onFocus,
|
|
1305
|
+
options,
|
|
1306
|
+
placeholder,
|
|
1307
|
+
readonly,
|
|
1308
|
+
value
|
|
1309
|
+
} = props;
|
|
1310
|
+
const {
|
|
1311
|
+
readonlyAsDisabled = true
|
|
1312
|
+
} = formContext;
|
|
1313
|
+
const emptyValue = options.emptyValue || '';
|
|
1314
|
+
const handleChange = ({
|
|
1315
|
+
target
|
|
1316
|
+
}) => onChange(target.value === '' ? emptyValue : target.value);
|
|
1317
|
+
const handleBlur = ({
|
|
1318
|
+
target
|
|
1319
|
+
}) => onBlur(id, target.value);
|
|
1320
|
+
const handleFocus = ({
|
|
1321
|
+
target
|
|
1322
|
+
}) => onFocus(id, target.value);
|
|
1318
1323
|
return jsx(Input.Password, {
|
|
1319
1324
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1320
1325
|
id: id,
|
|
@@ -1333,35 +1338,38 @@ function PasswordWidget(props) {
|
|
|
1333
1338
|
*
|
|
1334
1339
|
* @param props - The `WidgetProps` for this component
|
|
1335
1340
|
*/
|
|
1336
|
-
function RadioWidget(
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
};
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
};
|
|
1364
|
-
|
|
1341
|
+
function RadioWidget({
|
|
1342
|
+
autofocus,
|
|
1343
|
+
disabled,
|
|
1344
|
+
formContext,
|
|
1345
|
+
id,
|
|
1346
|
+
onBlur,
|
|
1347
|
+
onChange,
|
|
1348
|
+
onFocus,
|
|
1349
|
+
options,
|
|
1350
|
+
readonly,
|
|
1351
|
+
value
|
|
1352
|
+
}) {
|
|
1353
|
+
const {
|
|
1354
|
+
readonlyAsDisabled = true
|
|
1355
|
+
} = formContext;
|
|
1356
|
+
const {
|
|
1357
|
+
enumOptions,
|
|
1358
|
+
enumDisabled,
|
|
1359
|
+
emptyValue
|
|
1360
|
+
} = options;
|
|
1361
|
+
const handleChange = ({
|
|
1362
|
+
target: {
|
|
1363
|
+
value: nextValue
|
|
1364
|
+
}
|
|
1365
|
+
}) => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1366
|
+
const handleBlur = ({
|
|
1367
|
+
target
|
|
1368
|
+
}) => onBlur(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1369
|
+
const handleFocus = ({
|
|
1370
|
+
target
|
|
1371
|
+
}) => onFocus(id, enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1372
|
+
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions);
|
|
1365
1373
|
return jsx(Radio.Group, {
|
|
1366
1374
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1367
1375
|
id: id,
|
|
@@ -1371,16 +1379,14 @@ function RadioWidget(_ref) {
|
|
|
1371
1379
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1372
1380
|
value: selectedIndexes,
|
|
1373
1381
|
"aria-describedby": ariaDescribedByIds(id),
|
|
1374
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
}, i);
|
|
1383
|
-
})
|
|
1382
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, i) => jsx(Radio, {
|
|
1383
|
+
id: optionId(id, i),
|
|
1384
|
+
name: id,
|
|
1385
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1386
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1387
|
+
value: String(i),
|
|
1388
|
+
children: option.label
|
|
1389
|
+
}, i))
|
|
1384
1390
|
});
|
|
1385
1391
|
}
|
|
1386
1392
|
|
|
@@ -1390,42 +1396,40 @@ function RadioWidget(_ref) {
|
|
|
1390
1396
|
* @param props - The `WidgetProps` for this component
|
|
1391
1397
|
*/
|
|
1392
1398
|
function RangeWidget(props) {
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
};
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
return onFocus(id, value);
|
|
1420
|
-
};
|
|
1399
|
+
const {
|
|
1400
|
+
autofocus,
|
|
1401
|
+
disabled,
|
|
1402
|
+
formContext,
|
|
1403
|
+
id,
|
|
1404
|
+
onBlur,
|
|
1405
|
+
onChange,
|
|
1406
|
+
onFocus,
|
|
1407
|
+
options,
|
|
1408
|
+
placeholder,
|
|
1409
|
+
readonly,
|
|
1410
|
+
schema,
|
|
1411
|
+
value
|
|
1412
|
+
} = props;
|
|
1413
|
+
const {
|
|
1414
|
+
readonlyAsDisabled = true
|
|
1415
|
+
} = formContext;
|
|
1416
|
+
const {
|
|
1417
|
+
min,
|
|
1418
|
+
max,
|
|
1419
|
+
step
|
|
1420
|
+
} = rangeSpec(schema);
|
|
1421
|
+
const emptyValue = options.emptyValue || '';
|
|
1422
|
+
const handleChange = nextValue => onChange(nextValue === '' ? emptyValue : nextValue);
|
|
1423
|
+
const handleBlur = () => onBlur(id, value);
|
|
1424
|
+
const handleFocus = () => onFocus(id, value);
|
|
1421
1425
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1422
1426
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1423
|
-
|
|
1424
|
-
placeholder
|
|
1427
|
+
const extraProps = {
|
|
1428
|
+
placeholder,
|
|
1425
1429
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1426
1430
|
onFocus: !readonly ? handleFocus : undefined
|
|
1427
1431
|
};
|
|
1428
|
-
return jsx(Slider,
|
|
1432
|
+
return jsx(Slider, {
|
|
1429
1433
|
autoFocus: autofocus,
|
|
1430
1434
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1431
1435
|
id: id,
|
|
@@ -1434,13 +1438,13 @@ function RangeWidget(props) {
|
|
|
1434
1438
|
onChange: !readonly ? handleChange : undefined,
|
|
1435
1439
|
range: false,
|
|
1436
1440
|
step: step,
|
|
1437
|
-
value: value
|
|
1438
|
-
|
|
1441
|
+
value: value,
|
|
1442
|
+
...extraProps,
|
|
1439
1443
|
"aria-describedby": ariaDescribedByIds(id)
|
|
1440
|
-
})
|
|
1444
|
+
});
|
|
1441
1445
|
}
|
|
1442
1446
|
|
|
1443
|
-
|
|
1447
|
+
const SELECT_STYLE = {
|
|
1444
1448
|
width: '100%'
|
|
1445
1449
|
};
|
|
1446
1450
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
@@ -1448,51 +1452,46 @@ var SELECT_STYLE = {
|
|
|
1448
1452
|
*
|
|
1449
1453
|
* @param props - The `WidgetProps` for this component
|
|
1450
1454
|
*/
|
|
1451
|
-
function SelectWidget(
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
readonlyAsDisabled =
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
};
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1478
|
-
};
|
|
1479
|
-
var filterOption = function filterOption(input, option) {
|
|
1455
|
+
function SelectWidget({
|
|
1456
|
+
autofocus,
|
|
1457
|
+
disabled,
|
|
1458
|
+
formContext = {},
|
|
1459
|
+
id,
|
|
1460
|
+
multiple,
|
|
1461
|
+
onBlur,
|
|
1462
|
+
onChange,
|
|
1463
|
+
onFocus,
|
|
1464
|
+
options,
|
|
1465
|
+
placeholder,
|
|
1466
|
+
readonly,
|
|
1467
|
+
value
|
|
1468
|
+
}) {
|
|
1469
|
+
const {
|
|
1470
|
+
readonlyAsDisabled = true
|
|
1471
|
+
} = formContext;
|
|
1472
|
+
const {
|
|
1473
|
+
enumOptions,
|
|
1474
|
+
enumDisabled,
|
|
1475
|
+
emptyValue
|
|
1476
|
+
} = options;
|
|
1477
|
+
const handleChange = nextValue => onChange(enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1478
|
+
const handleBlur = () => onBlur(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1479
|
+
const handleFocus = () => onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1480
|
+
const filterOption = (input, option) => {
|
|
1480
1481
|
if (option && isString(option.label)) {
|
|
1481
1482
|
// labels are strings in this context
|
|
1482
1483
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
1483
1484
|
}
|
|
1484
1485
|
return false;
|
|
1485
1486
|
};
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
};
|
|
1489
|
-
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1487
|
+
const getPopupContainer = node => node.parentNode;
|
|
1488
|
+
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1490
1489
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1491
1490
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1492
|
-
|
|
1491
|
+
const extraProps = {
|
|
1493
1492
|
name: id
|
|
1494
1493
|
};
|
|
1495
|
-
return jsx(Select,
|
|
1494
|
+
return jsx(Select, {
|
|
1496
1495
|
autoFocus: autofocus,
|
|
1497
1496
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1498
1497
|
getPopupContainer: getPopupContainer,
|
|
@@ -1503,60 +1502,58 @@ function SelectWidget(_ref) {
|
|
|
1503
1502
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1504
1503
|
placeholder: placeholder,
|
|
1505
1504
|
style: SELECT_STYLE,
|
|
1506
|
-
value: selectedIndexes
|
|
1507
|
-
|
|
1505
|
+
value: selectedIndexes,
|
|
1506
|
+
...extraProps,
|
|
1508
1507
|
filterOption: filterOption,
|
|
1509
1508
|
"aria-describedby": ariaDescribedByIds(id),
|
|
1510
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
}));
|
|
1509
|
+
children: Array.isArray(enumOptions) && enumOptions.map(({
|
|
1510
|
+
value: optionValue,
|
|
1511
|
+
label: optionLabel
|
|
1512
|
+
}, index) => jsx(Select.Option, {
|
|
1513
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
|
|
1514
|
+
value: String(index),
|
|
1515
|
+
children: optionLabel
|
|
1516
|
+
}, String(index)))
|
|
1517
|
+
});
|
|
1520
1518
|
}
|
|
1521
1519
|
|
|
1522
|
-
|
|
1520
|
+
const INPUT_STYLE = {
|
|
1523
1521
|
width: '100%'
|
|
1524
1522
|
};
|
|
1525
1523
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1526
1524
|
*
|
|
1527
1525
|
* @param props - The `WidgetProps` for this component
|
|
1528
1526
|
*/
|
|
1529
|
-
function TextareaWidget(
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
};
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
};
|
|
1527
|
+
function TextareaWidget({
|
|
1528
|
+
disabled,
|
|
1529
|
+
formContext,
|
|
1530
|
+
id,
|
|
1531
|
+
onBlur,
|
|
1532
|
+
onChange,
|
|
1533
|
+
onFocus,
|
|
1534
|
+
options,
|
|
1535
|
+
placeholder,
|
|
1536
|
+
readonly,
|
|
1537
|
+
value
|
|
1538
|
+
}) {
|
|
1539
|
+
const {
|
|
1540
|
+
readonlyAsDisabled = true
|
|
1541
|
+
} = formContext;
|
|
1542
|
+
const handleChange = ({
|
|
1543
|
+
target
|
|
1544
|
+
}) => onChange(target.value === '' ? options.emptyValue : target.value);
|
|
1545
|
+
const handleBlur = ({
|
|
1546
|
+
target
|
|
1547
|
+
}) => onBlur(id, target.value);
|
|
1548
|
+
const handleFocus = ({
|
|
1549
|
+
target
|
|
1550
|
+
}) => onFocus(id, target.value);
|
|
1554
1551
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1555
1552
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1556
|
-
|
|
1553
|
+
const extraProps = {
|
|
1557
1554
|
type: 'textarea'
|
|
1558
1555
|
};
|
|
1559
|
-
return jsx(Input.TextArea,
|
|
1556
|
+
return jsx(Input.TextArea, {
|
|
1560
1557
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1561
1558
|
id: id,
|
|
1562
1559
|
name: id,
|
|
@@ -1566,25 +1563,25 @@ function TextareaWidget(_ref) {
|
|
|
1566
1563
|
placeholder: placeholder,
|
|
1567
1564
|
rows: options.rows || 4,
|
|
1568
1565
|
style: INPUT_STYLE,
|
|
1569
|
-
value: value
|
|
1570
|
-
|
|
1566
|
+
value: value,
|
|
1567
|
+
...extraProps,
|
|
1571
1568
|
"aria-describedby": ariaDescribedByIds(id)
|
|
1572
|
-
})
|
|
1569
|
+
});
|
|
1573
1570
|
}
|
|
1574
1571
|
|
|
1575
1572
|
function generateWidgets() {
|
|
1576
1573
|
return {
|
|
1577
|
-
AltDateTimeWidget
|
|
1578
|
-
AltDateWidget
|
|
1579
|
-
CheckboxesWidget
|
|
1580
|
-
CheckboxWidget
|
|
1581
|
-
DateTimeWidget
|
|
1582
|
-
DateWidget
|
|
1583
|
-
PasswordWidget
|
|
1584
|
-
RadioWidget
|
|
1585
|
-
RangeWidget
|
|
1586
|
-
SelectWidget
|
|
1587
|
-
TextareaWidget
|
|
1574
|
+
AltDateTimeWidget,
|
|
1575
|
+
AltDateWidget,
|
|
1576
|
+
CheckboxesWidget,
|
|
1577
|
+
CheckboxWidget,
|
|
1578
|
+
DateTimeWidget,
|
|
1579
|
+
DateWidget,
|
|
1580
|
+
PasswordWidget,
|
|
1581
|
+
RadioWidget,
|
|
1582
|
+
RangeWidget,
|
|
1583
|
+
SelectWidget,
|
|
1584
|
+
TextareaWidget
|
|
1588
1585
|
};
|
|
1589
1586
|
}
|
|
1590
1587
|
var index = /*#__PURE__*/generateWidgets();
|
|
@@ -1595,11 +1592,11 @@ function generateTheme() {
|
|
|
1595
1592
|
widgets: generateWidgets()
|
|
1596
1593
|
};
|
|
1597
1594
|
}
|
|
1598
|
-
|
|
1595
|
+
const Theme = /*#__PURE__*/generateTheme();
|
|
1599
1596
|
function generateForm() {
|
|
1600
1597
|
return withTheme(generateTheme());
|
|
1601
1598
|
}
|
|
1602
|
-
|
|
1599
|
+
const Form = /*#__PURE__*/generateForm();
|
|
1603
1600
|
|
|
1604
1601
|
export { Form, index$1 as Templates, Theme, index as Widgets, Form as default, generateForm, generateTemplates, generateTheme, generateWidgets };
|
|
1605
1602
|
//# sourceMappingURL=antd.esm.js.map
|