@rjsf/mui 5.9.0 → 5.11.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/dist/mui.cjs.development.js +548 -481
- package/dist/mui.cjs.development.js.map +1 -1
- package/dist/mui.cjs.production.min.js +1 -1
- package/dist/mui.cjs.production.min.js.map +1 -1
- package/dist/mui.esm.js +548 -481
- package/dist/mui.esm.js.map +1 -1
- package/dist/mui.umd.development.js +548 -481
- package/dist/mui.umd.development.js.map +1 -1
- package/dist/mui.umd.production.min.js +1 -1
- package/dist/mui.umd.production.min.js.map +1 -1
- package/package.json +16 -15
package/dist/mui.esm.js
CHANGED
|
@@ -30,46 +30,22 @@ import RadioGroup from '@mui/material/RadioGroup';
|
|
|
30
30
|
import Slider from '@mui/material/Slider';
|
|
31
31
|
import MenuItem from '@mui/material/MenuItem';
|
|
32
32
|
|
|
33
|
-
function _extends() {
|
|
34
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
35
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
36
|
-
var source = arguments[i];
|
|
37
|
-
for (var key in source) {
|
|
38
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
39
|
-
target[key] = source[key];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return target;
|
|
44
|
-
};
|
|
45
|
-
return _extends.apply(this, arguments);
|
|
46
|
-
}
|
|
47
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
48
|
-
if (source == null) return {};
|
|
49
|
-
var target = {};
|
|
50
|
-
var sourceKeys = Object.keys(source);
|
|
51
|
-
var key, i;
|
|
52
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
53
|
-
key = sourceKeys[i];
|
|
54
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
55
|
-
target[key] = source[key];
|
|
56
|
-
}
|
|
57
|
-
return target;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
var _excluded$4 = ["uiSchema", "registry"];
|
|
61
33
|
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
62
34
|
*/
|
|
63
|
-
function AddButton(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
35
|
+
function AddButton({
|
|
36
|
+
uiSchema,
|
|
37
|
+
registry,
|
|
38
|
+
...props
|
|
39
|
+
}) {
|
|
40
|
+
const {
|
|
41
|
+
translateString
|
|
42
|
+
} = registry;
|
|
43
|
+
return jsx(IconButton, {
|
|
44
|
+
title: translateString(TranslatableString.AddItemButton),
|
|
45
|
+
...props,
|
|
70
46
|
color: 'primary',
|
|
71
47
|
children: jsx(AddIcon, {})
|
|
72
|
-
})
|
|
48
|
+
});
|
|
73
49
|
}
|
|
74
50
|
|
|
75
51
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
@@ -77,26 +53,29 @@ function AddButton(_ref) {
|
|
|
77
53
|
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
78
54
|
*/
|
|
79
55
|
function ArrayFieldItemTemplate(props) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
56
|
+
const {
|
|
57
|
+
children,
|
|
58
|
+
disabled,
|
|
59
|
+
hasToolbar,
|
|
60
|
+
hasCopy,
|
|
61
|
+
hasMoveDown,
|
|
62
|
+
hasMoveUp,
|
|
63
|
+
hasRemove,
|
|
64
|
+
index,
|
|
65
|
+
onCopyIndexClick,
|
|
66
|
+
onDropIndexClick,
|
|
67
|
+
onReorderClick,
|
|
68
|
+
readonly,
|
|
69
|
+
uiSchema,
|
|
70
|
+
registry
|
|
71
|
+
} = props;
|
|
72
|
+
const {
|
|
73
|
+
CopyButton,
|
|
74
|
+
MoveDownButton,
|
|
75
|
+
MoveUpButton,
|
|
76
|
+
RemoveButton
|
|
77
|
+
} = registry.templates.ButtonTemplates;
|
|
78
|
+
const btnStyle = {
|
|
100
79
|
flex: 1,
|
|
101
80
|
paddingLeft: 6,
|
|
102
81
|
paddingRight: 6,
|
|
@@ -153,29 +132,34 @@ function ArrayFieldItemTemplate(props) {
|
|
|
153
132
|
});
|
|
154
133
|
}
|
|
155
134
|
|
|
156
|
-
var _excluded$3 = ["key"];
|
|
157
135
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
158
136
|
*
|
|
159
137
|
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
160
138
|
*/
|
|
161
139
|
function ArrayFieldTemplate(props) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
140
|
+
const {
|
|
141
|
+
canAdd,
|
|
142
|
+
disabled,
|
|
143
|
+
idSchema,
|
|
144
|
+
uiSchema,
|
|
145
|
+
items,
|
|
146
|
+
onAddClick,
|
|
147
|
+
readonly,
|
|
148
|
+
registry,
|
|
149
|
+
required,
|
|
150
|
+
schema,
|
|
151
|
+
title
|
|
152
|
+
} = props;
|
|
153
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
154
|
+
const ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
155
|
+
const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
156
|
+
const ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
177
157
|
// Button templates are not overridden in the uiSchema
|
|
178
|
-
|
|
158
|
+
const {
|
|
159
|
+
ButtonTemplates: {
|
|
160
|
+
AddButton
|
|
161
|
+
}
|
|
162
|
+
} = registry.templates;
|
|
179
163
|
return jsx(Paper, {
|
|
180
164
|
elevation: 2,
|
|
181
165
|
children: jsxs(Box, {
|
|
@@ -195,11 +179,12 @@ function ArrayFieldTemplate(props) {
|
|
|
195
179
|
registry: registry
|
|
196
180
|
}), jsxs(Grid, {
|
|
197
181
|
container: true,
|
|
198
|
-
children: [items && items.map(
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
182
|
+
children: [items && items.map(({
|
|
183
|
+
key,
|
|
184
|
+
...itemProps
|
|
185
|
+
}) => jsx(ArrayFieldItemTemplate, {
|
|
186
|
+
...itemProps
|
|
187
|
+
}, key)), canAdd && jsx(Grid, {
|
|
203
188
|
container: true,
|
|
204
189
|
justifyContent: 'flex-end',
|
|
205
190
|
children: jsx(Grid, {
|
|
@@ -216,14 +201,12 @@ function ArrayFieldTemplate(props) {
|
|
|
216
201
|
})
|
|
217
202
|
})
|
|
218
203
|
})]
|
|
219
|
-
},
|
|
204
|
+
}, `array-item-list-${idSchema.$id}`)]
|
|
220
205
|
})
|
|
221
206
|
});
|
|
222
207
|
}
|
|
223
208
|
|
|
224
|
-
|
|
225
|
-
_excluded2$1 = ["step", "min", "max"];
|
|
226
|
-
var TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
|
|
209
|
+
const TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
|
|
227
210
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
228
211
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
229
212
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -231,77 +214,91 @@ var TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
|
|
|
231
214
|
* @param props - The `WidgetProps` for this template
|
|
232
215
|
*/
|
|
233
216
|
function BaseInputTemplate(props) {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
217
|
+
const {
|
|
218
|
+
id,
|
|
219
|
+
name,
|
|
220
|
+
// remove this from textFieldProps
|
|
221
|
+
placeholder,
|
|
222
|
+
required,
|
|
223
|
+
readonly,
|
|
224
|
+
disabled,
|
|
225
|
+
type,
|
|
226
|
+
label,
|
|
227
|
+
hideLabel,
|
|
228
|
+
value,
|
|
229
|
+
onChange,
|
|
230
|
+
onChangeOverride,
|
|
231
|
+
onBlur,
|
|
232
|
+
onFocus,
|
|
233
|
+
autofocus,
|
|
234
|
+
options,
|
|
235
|
+
schema,
|
|
236
|
+
uiSchema,
|
|
237
|
+
rawErrors = [],
|
|
238
|
+
formContext,
|
|
239
|
+
registry,
|
|
240
|
+
InputLabelProps,
|
|
241
|
+
...textFieldProps
|
|
242
|
+
} = props;
|
|
243
|
+
const inputProps = getInputProps(schema, type, options);
|
|
255
244
|
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
};
|
|
273
|
-
var _onBlur = function _onBlur(_ref2) {
|
|
274
|
-
var value = _ref2.target.value;
|
|
275
|
-
return onBlur(id, value);
|
|
276
|
-
};
|
|
277
|
-
var _onFocus = function _onFocus(_ref3) {
|
|
278
|
-
var value = _ref3.target.value;
|
|
279
|
-
return onFocus(id, value);
|
|
245
|
+
const {
|
|
246
|
+
step,
|
|
247
|
+
min,
|
|
248
|
+
max,
|
|
249
|
+
...rest
|
|
250
|
+
} = inputProps;
|
|
251
|
+
const otherProps = {
|
|
252
|
+
inputProps: {
|
|
253
|
+
step,
|
|
254
|
+
min,
|
|
255
|
+
max,
|
|
256
|
+
...(schema.examples ? {
|
|
257
|
+
list: examplesId(id)
|
|
258
|
+
} : undefined)
|
|
259
|
+
},
|
|
260
|
+
...rest
|
|
280
261
|
};
|
|
281
|
-
|
|
262
|
+
const _onChange = ({
|
|
263
|
+
target: {
|
|
264
|
+
value
|
|
265
|
+
}
|
|
266
|
+
}) => onChange(value === '' ? options.emptyValue : value);
|
|
267
|
+
const _onBlur = ({
|
|
268
|
+
target: {
|
|
269
|
+
value
|
|
270
|
+
}
|
|
271
|
+
}) => onBlur(id, value);
|
|
272
|
+
const _onFocus = ({
|
|
273
|
+
target: {
|
|
274
|
+
value
|
|
275
|
+
}
|
|
276
|
+
}) => onFocus(id, value);
|
|
277
|
+
const DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? {
|
|
278
|
+
...InputLabelProps,
|
|
282
279
|
shrink: true
|
|
283
|
-
}
|
|
280
|
+
} : InputLabelProps;
|
|
284
281
|
return jsxs(Fragment, {
|
|
285
|
-
children: [jsx(TextField,
|
|
282
|
+
children: [jsx(TextField, {
|
|
286
283
|
id: id,
|
|
287
284
|
name: id,
|
|
288
285
|
placeholder: placeholder,
|
|
289
286
|
label: labelValue(label || undefined, hideLabel, false),
|
|
290
287
|
autoFocus: autofocus,
|
|
291
288
|
required: required,
|
|
292
|
-
disabled: disabled || readonly
|
|
293
|
-
|
|
289
|
+
disabled: disabled || readonly,
|
|
290
|
+
...otherProps,
|
|
294
291
|
value: value || value === 0 ? value : '',
|
|
295
292
|
error: rawErrors.length > 0,
|
|
296
293
|
onChange: onChangeOverride || _onChange,
|
|
297
294
|
onBlur: _onBlur,
|
|
298
295
|
onFocus: _onFocus,
|
|
299
|
-
InputLabelProps: DisplayInputLabelProps
|
|
300
|
-
|
|
296
|
+
InputLabelProps: DisplayInputLabelProps,
|
|
297
|
+
...textFieldProps,
|
|
301
298
|
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
302
|
-
})
|
|
299
|
+
}), Array.isArray(schema.examples) && jsx("datalist", {
|
|
303
300
|
id: examplesId(id),
|
|
304
|
-
children: schema.examples.concat(schema
|
|
301
|
+
children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map(example => {
|
|
305
302
|
return jsx("option", {
|
|
306
303
|
value: example
|
|
307
304
|
}, example);
|
|
@@ -315,8 +312,10 @@ function BaseInputTemplate(props) {
|
|
|
315
312
|
* @param props - The `DescriptionFieldProps` for this component
|
|
316
313
|
*/
|
|
317
314
|
function DescriptionField(props) {
|
|
318
|
-
|
|
319
|
-
|
|
315
|
+
const {
|
|
316
|
+
id,
|
|
317
|
+
description
|
|
318
|
+
} = props;
|
|
320
319
|
if (description) {
|
|
321
320
|
return jsx(Typography, {
|
|
322
321
|
id: id,
|
|
@@ -334,10 +333,13 @@ function DescriptionField(props) {
|
|
|
334
333
|
*
|
|
335
334
|
* @param props - The `ErrorListProps` for this component
|
|
336
335
|
*/
|
|
337
|
-
function ErrorList(
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
336
|
+
function ErrorList({
|
|
337
|
+
errors,
|
|
338
|
+
registry
|
|
339
|
+
}) {
|
|
340
|
+
const {
|
|
341
|
+
translateString
|
|
342
|
+
} = registry;
|
|
341
343
|
return jsx(Paper, {
|
|
342
344
|
elevation: 2,
|
|
343
345
|
children: jsxs(Box, {
|
|
@@ -348,7 +350,7 @@ function ErrorList(_ref) {
|
|
|
348
350
|
children: translateString(TranslatableString.ErrorsLabel)
|
|
349
351
|
}), jsx(List, {
|
|
350
352
|
dense: true,
|
|
351
|
-
children: errors.map(
|
|
353
|
+
children: errors.map((error, i) => {
|
|
352
354
|
return jsxs(ListItem, {
|
|
353
355
|
children: [jsx(ListItemIcon, {
|
|
354
356
|
children: jsx(ErrorIcon, {
|
|
@@ -364,60 +366,81 @@ function ErrorList(_ref) {
|
|
|
364
366
|
});
|
|
365
367
|
}
|
|
366
368
|
|
|
367
|
-
var _excluded$1 = ["icon", "color", "uiSchema", "registry"],
|
|
368
|
-
_excluded2 = ["iconType"];
|
|
369
369
|
function MuiIconButton(props) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
370
|
+
const {
|
|
371
|
+
icon,
|
|
372
|
+
color,
|
|
373
|
+
uiSchema,
|
|
374
|
+
registry,
|
|
375
|
+
...otherProps
|
|
376
|
+
} = props;
|
|
377
|
+
return jsx(IconButton, {
|
|
378
|
+
...otherProps,
|
|
374
379
|
size: 'small',
|
|
375
380
|
color: color,
|
|
376
381
|
children: icon
|
|
377
|
-
})
|
|
382
|
+
});
|
|
378
383
|
}
|
|
379
384
|
function CopyButton(props) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
385
|
+
const {
|
|
386
|
+
registry: {
|
|
387
|
+
translateString
|
|
388
|
+
}
|
|
389
|
+
} = props;
|
|
390
|
+
return jsx(MuiIconButton, {
|
|
391
|
+
title: translateString(TranslatableString.CopyButton),
|
|
392
|
+
...props,
|
|
384
393
|
icon: jsx(CopyIcon, {
|
|
385
394
|
fontSize: 'small'
|
|
386
395
|
})
|
|
387
|
-
})
|
|
396
|
+
});
|
|
388
397
|
}
|
|
389
398
|
function MoveDownButton(props) {
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
399
|
+
const {
|
|
400
|
+
registry: {
|
|
401
|
+
translateString
|
|
402
|
+
}
|
|
403
|
+
} = props;
|
|
404
|
+
return jsx(MuiIconButton, {
|
|
405
|
+
title: translateString(TranslatableString.MoveDownButton),
|
|
406
|
+
...props,
|
|
394
407
|
icon: jsx(ArrowDownwardIcon, {
|
|
395
408
|
fontSize: 'small'
|
|
396
409
|
})
|
|
397
|
-
})
|
|
410
|
+
});
|
|
398
411
|
}
|
|
399
412
|
function MoveUpButton(props) {
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
413
|
+
const {
|
|
414
|
+
registry: {
|
|
415
|
+
translateString
|
|
416
|
+
}
|
|
417
|
+
} = props;
|
|
418
|
+
return jsx(MuiIconButton, {
|
|
419
|
+
title: translateString(TranslatableString.MoveUpButton),
|
|
420
|
+
...props,
|
|
404
421
|
icon: jsx(ArrowUpwardIcon, {
|
|
405
422
|
fontSize: 'small'
|
|
406
423
|
})
|
|
407
|
-
})
|
|
424
|
+
});
|
|
408
425
|
}
|
|
409
426
|
function RemoveButton(props) {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
427
|
+
const {
|
|
428
|
+
iconType,
|
|
429
|
+
...otherProps
|
|
430
|
+
} = props;
|
|
431
|
+
const {
|
|
432
|
+
registry: {
|
|
433
|
+
translateString
|
|
434
|
+
}
|
|
435
|
+
} = otherProps;
|
|
436
|
+
return jsx(MuiIconButton, {
|
|
437
|
+
title: translateString(TranslatableString.RemoveButton),
|
|
438
|
+
...otherProps,
|
|
416
439
|
color: 'error',
|
|
417
440
|
icon: jsx(RemoveIcon, {
|
|
418
441
|
fontSize: iconType === 'default' ? undefined : 'small'
|
|
419
442
|
})
|
|
420
|
-
})
|
|
443
|
+
});
|
|
421
444
|
}
|
|
422
445
|
|
|
423
446
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -425,17 +448,18 @@ function RemoveButton(props) {
|
|
|
425
448
|
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
426
449
|
*/
|
|
427
450
|
function FieldErrorTemplate(props) {
|
|
428
|
-
|
|
429
|
-
errors =
|
|
430
|
-
idSchema
|
|
451
|
+
const {
|
|
452
|
+
errors = [],
|
|
453
|
+
idSchema
|
|
454
|
+
} = props;
|
|
431
455
|
if (errors.length === 0) {
|
|
432
456
|
return null;
|
|
433
457
|
}
|
|
434
|
-
|
|
458
|
+
const id = errorId(idSchema);
|
|
435
459
|
return jsx(List, {
|
|
436
460
|
dense: true,
|
|
437
461
|
disablePadding: true,
|
|
438
|
-
children: errors.map(
|
|
462
|
+
children: errors.map((error, i) => {
|
|
439
463
|
return jsx(ListItem, {
|
|
440
464
|
disableGutters: true,
|
|
441
465
|
children: jsx(FormHelperText, {
|
|
@@ -452,12 +476,14 @@ function FieldErrorTemplate(props) {
|
|
|
452
476
|
* @param props - The `FieldHelpProps` to be rendered
|
|
453
477
|
*/
|
|
454
478
|
function FieldHelpTemplate(props) {
|
|
455
|
-
|
|
456
|
-
|
|
479
|
+
const {
|
|
480
|
+
idSchema,
|
|
481
|
+
help
|
|
482
|
+
} = props;
|
|
457
483
|
if (!help) {
|
|
458
484
|
return null;
|
|
459
485
|
}
|
|
460
|
-
|
|
486
|
+
const id = helpId(idSchema);
|
|
461
487
|
return jsx(FormHelperText, {
|
|
462
488
|
id: id,
|
|
463
489
|
children: help
|
|
@@ -470,29 +496,30 @@ function FieldHelpTemplate(props) {
|
|
|
470
496
|
* @param props - The `FieldTemplateProps` for this component
|
|
471
497
|
*/
|
|
472
498
|
function FieldTemplate(props) {
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
rawErrors =
|
|
487
|
-
errors
|
|
488
|
-
help
|
|
489
|
-
description
|
|
490
|
-
rawDescription
|
|
491
|
-
schema
|
|
492
|
-
uiSchema
|
|
493
|
-
registry
|
|
494
|
-
|
|
495
|
-
|
|
499
|
+
const {
|
|
500
|
+
id,
|
|
501
|
+
children,
|
|
502
|
+
classNames,
|
|
503
|
+
style,
|
|
504
|
+
disabled,
|
|
505
|
+
displayLabel,
|
|
506
|
+
hidden,
|
|
507
|
+
label,
|
|
508
|
+
onDropPropertyClick,
|
|
509
|
+
onKeyChange,
|
|
510
|
+
readonly,
|
|
511
|
+
required,
|
|
512
|
+
rawErrors = [],
|
|
513
|
+
errors,
|
|
514
|
+
help,
|
|
515
|
+
description,
|
|
516
|
+
rawDescription,
|
|
517
|
+
schema,
|
|
518
|
+
uiSchema,
|
|
519
|
+
registry
|
|
520
|
+
} = props;
|
|
521
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
522
|
+
const WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
496
523
|
if (hidden) {
|
|
497
524
|
return jsx("div", {
|
|
498
525
|
style: {
|
|
@@ -534,23 +561,29 @@ function FieldTemplate(props) {
|
|
|
534
561
|
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
535
562
|
*/
|
|
536
563
|
function ObjectFieldTemplate(props) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
564
|
+
const {
|
|
565
|
+
description,
|
|
566
|
+
title,
|
|
567
|
+
properties,
|
|
568
|
+
required,
|
|
569
|
+
disabled,
|
|
570
|
+
readonly,
|
|
571
|
+
uiSchema,
|
|
572
|
+
idSchema,
|
|
573
|
+
schema,
|
|
574
|
+
formData,
|
|
575
|
+
onAddClick,
|
|
576
|
+
registry
|
|
577
|
+
} = props;
|
|
578
|
+
const uiOptions = getUiOptions(uiSchema);
|
|
579
|
+
const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
580
|
+
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
552
581
|
// Button templates are not overridden in the uiSchema
|
|
553
|
-
|
|
582
|
+
const {
|
|
583
|
+
ButtonTemplates: {
|
|
584
|
+
AddButton
|
|
585
|
+
}
|
|
586
|
+
} = registry.templates;
|
|
554
587
|
return jsxs(Fragment, {
|
|
555
588
|
children: [title && jsx(TitleFieldTemplate, {
|
|
556
589
|
id: titleId(idSchema),
|
|
@@ -571,20 +604,17 @@ function ObjectFieldTemplate(props) {
|
|
|
571
604
|
style: {
|
|
572
605
|
marginTop: '10px'
|
|
573
606
|
},
|
|
574
|
-
children: [properties.map(
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
}, index)
|
|
586
|
-
);
|
|
587
|
-
}), canExpand(schema, uiSchema, formData) && jsx(Grid, {
|
|
607
|
+
children: [properties.map((element, index) =>
|
|
608
|
+
// Remove the <Grid> if the inner element is hidden as the <Grid>
|
|
609
|
+
// itself would otherwise still take up space.
|
|
610
|
+
element.hidden ? element.content : jsx(Grid, {
|
|
611
|
+
item: true,
|
|
612
|
+
xs: 12,
|
|
613
|
+
style: {
|
|
614
|
+
marginBottom: '10px'
|
|
615
|
+
},
|
|
616
|
+
children: element.content
|
|
617
|
+
}, index)), canExpand(schema, uiSchema, formData) && jsx(Grid, {
|
|
588
618
|
container: true,
|
|
589
619
|
justifyContent: 'flex-end',
|
|
590
620
|
children: jsx(Grid, {
|
|
@@ -604,25 +634,26 @@ function ObjectFieldTemplate(props) {
|
|
|
604
634
|
|
|
605
635
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
606
636
|
*/
|
|
607
|
-
function SubmitButton(
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
submitButtonProps =
|
|
637
|
+
function SubmitButton({
|
|
638
|
+
uiSchema
|
|
639
|
+
}) {
|
|
640
|
+
const {
|
|
641
|
+
submitText,
|
|
642
|
+
norender,
|
|
643
|
+
props: submitButtonProps = {}
|
|
644
|
+
} = getSubmitButtonOptions(uiSchema);
|
|
614
645
|
if (norender) {
|
|
615
646
|
return null;
|
|
616
647
|
}
|
|
617
648
|
return jsx(Box, {
|
|
618
649
|
marginTop: 3,
|
|
619
|
-
children: jsx(Button,
|
|
650
|
+
children: jsx(Button, {
|
|
620
651
|
type: 'submit',
|
|
621
652
|
variant: 'contained',
|
|
622
|
-
color: 'primary'
|
|
623
|
-
|
|
653
|
+
color: 'primary',
|
|
654
|
+
...submitButtonProps,
|
|
624
655
|
children: submitText
|
|
625
|
-
})
|
|
656
|
+
})
|
|
626
657
|
});
|
|
627
658
|
}
|
|
628
659
|
|
|
@@ -630,9 +661,10 @@ function SubmitButton(_ref) {
|
|
|
630
661
|
*
|
|
631
662
|
* @param props - The `TitleFieldProps` for this component
|
|
632
663
|
*/
|
|
633
|
-
function TitleField(
|
|
634
|
-
|
|
635
|
-
|
|
664
|
+
function TitleField({
|
|
665
|
+
id,
|
|
666
|
+
title
|
|
667
|
+
}) {
|
|
636
668
|
return jsxs(Box, {
|
|
637
669
|
id: id,
|
|
638
670
|
mb: 1,
|
|
@@ -650,26 +682,32 @@ function TitleField(_ref) {
|
|
|
650
682
|
* @param props - The `WrapIfAdditionalProps` for this component
|
|
651
683
|
*/
|
|
652
684
|
function WrapIfAdditionalTemplate(props) {
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
685
|
+
const {
|
|
686
|
+
children,
|
|
687
|
+
classNames,
|
|
688
|
+
style,
|
|
689
|
+
disabled,
|
|
690
|
+
id,
|
|
691
|
+
label,
|
|
692
|
+
onDropPropertyClick,
|
|
693
|
+
onKeyChange,
|
|
694
|
+
readonly,
|
|
695
|
+
required,
|
|
696
|
+
schema,
|
|
697
|
+
uiSchema,
|
|
698
|
+
registry
|
|
699
|
+
} = props;
|
|
700
|
+
const {
|
|
701
|
+
templates,
|
|
702
|
+
translateString
|
|
703
|
+
} = registry;
|
|
668
704
|
// Button templates are not overridden in the uiSchema
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
705
|
+
const {
|
|
706
|
+
RemoveButton
|
|
707
|
+
} = templates.ButtonTemplates;
|
|
708
|
+
const keyLabel = translateString(TranslatableString.KeyLabel, [label]);
|
|
709
|
+
const additional = (ADDITIONAL_PROPERTY_FLAG in schema);
|
|
710
|
+
const btnStyle = {
|
|
673
711
|
flex: 1,
|
|
674
712
|
paddingLeft: 6,
|
|
675
713
|
paddingRight: 6,
|
|
@@ -682,10 +720,9 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
682
720
|
children: children
|
|
683
721
|
});
|
|
684
722
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
};
|
|
723
|
+
const handleBlur = ({
|
|
724
|
+
target
|
|
725
|
+
}) => onKeyChange(target.value);
|
|
689
726
|
return jsxs(Grid, {
|
|
690
727
|
container: true,
|
|
691
728
|
alignItems: 'center',
|
|
@@ -701,8 +738,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
701
738
|
label: keyLabel,
|
|
702
739
|
defaultValue: label,
|
|
703
740
|
disabled: disabled || readonly,
|
|
704
|
-
id: id
|
|
705
|
-
name: id
|
|
741
|
+
id: `${id}-key`,
|
|
742
|
+
name: `${id}-key`,
|
|
706
743
|
onBlur: !readonly ? handleBlur : undefined,
|
|
707
744
|
type: 'text'
|
|
708
745
|
})
|
|
@@ -721,30 +758,30 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
721
758
|
registry: registry
|
|
722
759
|
})
|
|
723
760
|
})]
|
|
724
|
-
}, id
|
|
761
|
+
}, `${id}-key`);
|
|
725
762
|
}
|
|
726
763
|
|
|
727
764
|
function generateTemplates() {
|
|
728
765
|
return {
|
|
729
|
-
ArrayFieldItemTemplate
|
|
730
|
-
ArrayFieldTemplate
|
|
731
|
-
BaseInputTemplate
|
|
766
|
+
ArrayFieldItemTemplate,
|
|
767
|
+
ArrayFieldTemplate,
|
|
768
|
+
BaseInputTemplate,
|
|
732
769
|
ButtonTemplates: {
|
|
733
|
-
AddButton
|
|
734
|
-
CopyButton
|
|
735
|
-
MoveDownButton
|
|
736
|
-
MoveUpButton
|
|
737
|
-
RemoveButton
|
|
738
|
-
SubmitButton
|
|
770
|
+
AddButton,
|
|
771
|
+
CopyButton,
|
|
772
|
+
MoveDownButton,
|
|
773
|
+
MoveUpButton,
|
|
774
|
+
RemoveButton,
|
|
775
|
+
SubmitButton
|
|
739
776
|
},
|
|
740
777
|
DescriptionFieldTemplate: DescriptionField,
|
|
741
778
|
ErrorListTemplate: ErrorList,
|
|
742
|
-
FieldErrorTemplate
|
|
743
|
-
FieldHelpTemplate
|
|
744
|
-
FieldTemplate
|
|
745
|
-
ObjectFieldTemplate
|
|
779
|
+
FieldErrorTemplate,
|
|
780
|
+
FieldHelpTemplate,
|
|
781
|
+
FieldTemplate,
|
|
782
|
+
ObjectFieldTemplate,
|
|
746
783
|
TitleFieldTemplate: TitleField,
|
|
747
|
-
WrapIfAdditionalTemplate
|
|
784
|
+
WrapIfAdditionalTemplate
|
|
748
785
|
};
|
|
749
786
|
}
|
|
750
787
|
var Templates = /*#__PURE__*/generateTemplates();
|
|
@@ -755,39 +792,39 @@ var Templates = /*#__PURE__*/generateTemplates();
|
|
|
755
792
|
* @param props - The `WidgetProps` for this component
|
|
756
793
|
*/
|
|
757
794
|
function CheckboxWidget(props) {
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
id
|
|
761
|
-
value
|
|
762
|
-
disabled
|
|
763
|
-
readonly
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
795
|
+
const {
|
|
796
|
+
schema,
|
|
797
|
+
id,
|
|
798
|
+
value,
|
|
799
|
+
disabled,
|
|
800
|
+
readonly,
|
|
801
|
+
label = '',
|
|
802
|
+
hideLabel,
|
|
803
|
+
autofocus,
|
|
804
|
+
onChange,
|
|
805
|
+
onBlur,
|
|
806
|
+
onFocus,
|
|
807
|
+
registry,
|
|
808
|
+
options,
|
|
809
|
+
uiSchema
|
|
810
|
+
} = props;
|
|
811
|
+
const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
|
|
775
812
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
776
813
|
// the "required" attribute if the field value must be "true", due to the
|
|
777
814
|
// "const" or "enum" keywords
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
};
|
|
790
|
-
|
|
815
|
+
const required = schemaRequiresTrueValue(schema);
|
|
816
|
+
const _onChange = (_, checked) => onChange(checked);
|
|
817
|
+
const _onBlur = ({
|
|
818
|
+
target: {
|
|
819
|
+
value
|
|
820
|
+
}
|
|
821
|
+
}) => onBlur(id, value);
|
|
822
|
+
const _onFocus = ({
|
|
823
|
+
target: {
|
|
824
|
+
value
|
|
825
|
+
}
|
|
826
|
+
}) => onFocus(id, value);
|
|
827
|
+
const description = options.description ?? schema.description;
|
|
791
828
|
return jsxs(Fragment, {
|
|
792
829
|
children: [!hideLabel && !!description && jsx(DescriptionFieldTemplate, {
|
|
793
830
|
id: descriptionId(id),
|
|
@@ -818,42 +855,48 @@ function CheckboxWidget(props) {
|
|
|
818
855
|
*
|
|
819
856
|
* @param props - The `WidgetProps` for this component
|
|
820
857
|
*/
|
|
821
|
-
function CheckboxesWidget(
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
};
|
|
853
|
-
var _onFocus = function _onFocus(_ref4) {
|
|
854
|
-
var value = _ref4.target.value;
|
|
855
|
-
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
858
|
+
function CheckboxesWidget({
|
|
859
|
+
label,
|
|
860
|
+
hideLabel,
|
|
861
|
+
id,
|
|
862
|
+
disabled,
|
|
863
|
+
options,
|
|
864
|
+
value,
|
|
865
|
+
autofocus,
|
|
866
|
+
readonly,
|
|
867
|
+
required,
|
|
868
|
+
onChange,
|
|
869
|
+
onBlur,
|
|
870
|
+
onFocus
|
|
871
|
+
}) {
|
|
872
|
+
const {
|
|
873
|
+
enumOptions,
|
|
874
|
+
enumDisabled,
|
|
875
|
+
inline,
|
|
876
|
+
emptyValue
|
|
877
|
+
} = options;
|
|
878
|
+
const checkboxesValues = Array.isArray(value) ? value : [value];
|
|
879
|
+
const _onChange = index => ({
|
|
880
|
+
target: {
|
|
881
|
+
checked
|
|
882
|
+
}
|
|
883
|
+
}) => {
|
|
884
|
+
if (checked) {
|
|
885
|
+
onChange(enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
886
|
+
} else {
|
|
887
|
+
onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
888
|
+
}
|
|
856
889
|
};
|
|
890
|
+
const _onBlur = ({
|
|
891
|
+
target: {
|
|
892
|
+
value
|
|
893
|
+
}
|
|
894
|
+
}) => onBlur(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
895
|
+
const _onFocus = ({
|
|
896
|
+
target: {
|
|
897
|
+
value
|
|
898
|
+
}
|
|
899
|
+
}) => onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
857
900
|
return jsxs(Fragment, {
|
|
858
901
|
children: [labelValue(jsx(FormLabel, {
|
|
859
902
|
required: required,
|
|
@@ -862,10 +905,10 @@ function CheckboxesWidget(_ref) {
|
|
|
862
905
|
}), hideLabel), jsx(FormGroup, {
|
|
863
906
|
id: id,
|
|
864
907
|
row: !!inline,
|
|
865
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
908
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
909
|
+
const checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
910
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
911
|
+
const checkbox = jsx(Checkbox, {
|
|
869
912
|
id: optionId(id, index),
|
|
870
913
|
name: id,
|
|
871
914
|
checked: checked,
|
|
@@ -890,35 +933,37 @@ function CheckboxesWidget(_ref) {
|
|
|
890
933
|
*
|
|
891
934
|
* @param props - The `WidgetProps` for this component
|
|
892
935
|
*/
|
|
893
|
-
function RadioWidget(
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
936
|
+
function RadioWidget({
|
|
937
|
+
id,
|
|
938
|
+
options,
|
|
939
|
+
value,
|
|
940
|
+
required,
|
|
941
|
+
disabled,
|
|
942
|
+
readonly,
|
|
943
|
+
label,
|
|
944
|
+
hideLabel,
|
|
945
|
+
onChange,
|
|
946
|
+
onBlur,
|
|
947
|
+
onFocus
|
|
948
|
+
}) {
|
|
949
|
+
const {
|
|
950
|
+
enumOptions,
|
|
951
|
+
enumDisabled,
|
|
952
|
+
emptyValue
|
|
953
|
+
} = options;
|
|
954
|
+
const _onChange = (_, value) => onChange(enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
955
|
+
const _onBlur = ({
|
|
956
|
+
target: {
|
|
957
|
+
value
|
|
958
|
+
}
|
|
959
|
+
}) => onBlur(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
960
|
+
const _onFocus = ({
|
|
961
|
+
target: {
|
|
962
|
+
value
|
|
963
|
+
}
|
|
964
|
+
}) => onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
965
|
+
const row = options ? options.inline : false;
|
|
966
|
+
const selectedIndex = enumOptionsIndexForValue(value, enumOptions) ?? null;
|
|
922
967
|
return jsxs(Fragment, {
|
|
923
968
|
children: [labelValue(jsx(FormLabel, {
|
|
924
969
|
required: required,
|
|
@@ -933,9 +978,9 @@ function RadioWidget(_ref) {
|
|
|
933
978
|
onBlur: _onBlur,
|
|
934
979
|
onFocus: _onFocus,
|
|
935
980
|
"aria-describedby": ariaDescribedByIds(id),
|
|
936
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
937
|
-
|
|
938
|
-
|
|
981
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
|
|
982
|
+
const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
983
|
+
const radio = jsx(FormControlLabel, {
|
|
939
984
|
control: jsx(Radio, {
|
|
940
985
|
name: id,
|
|
941
986
|
id: optionId(id, index),
|
|
@@ -957,96 +1002,112 @@ function RadioWidget(_ref) {
|
|
|
957
1002
|
* @param props - The `WidgetProps` for this component
|
|
958
1003
|
*/
|
|
959
1004
|
function RangeWidget(props) {
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
};
|
|
981
|
-
var _onBlur = function _onBlur(_ref) {
|
|
982
|
-
var value = _ref.target.value;
|
|
983
|
-
return onBlur(id, value);
|
|
1005
|
+
const {
|
|
1006
|
+
value,
|
|
1007
|
+
readonly,
|
|
1008
|
+
disabled,
|
|
1009
|
+
onBlur,
|
|
1010
|
+
onFocus,
|
|
1011
|
+
options,
|
|
1012
|
+
schema,
|
|
1013
|
+
onChange,
|
|
1014
|
+
required,
|
|
1015
|
+
label,
|
|
1016
|
+
hideLabel,
|
|
1017
|
+
id
|
|
1018
|
+
} = props;
|
|
1019
|
+
const sliderProps = {
|
|
1020
|
+
value,
|
|
1021
|
+
label,
|
|
1022
|
+
id,
|
|
1023
|
+
name: id,
|
|
1024
|
+
...rangeSpec(schema)
|
|
984
1025
|
};
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
return onFocus(id, value);
|
|
1026
|
+
const _onChange = (_, value) => {
|
|
1027
|
+
onChange(value ?? options.emptyValue);
|
|
988
1028
|
};
|
|
1029
|
+
const _onBlur = ({
|
|
1030
|
+
target: {
|
|
1031
|
+
value
|
|
1032
|
+
}
|
|
1033
|
+
}) => onBlur(id, value);
|
|
1034
|
+
const _onFocus = ({
|
|
1035
|
+
target: {
|
|
1036
|
+
value
|
|
1037
|
+
}
|
|
1038
|
+
}) => onFocus(id, value);
|
|
989
1039
|
return jsxs(Fragment, {
|
|
990
1040
|
children: [labelValue(jsx(FormLabel, {
|
|
991
1041
|
required: required,
|
|
992
1042
|
htmlFor: id,
|
|
993
1043
|
children: label || undefined
|
|
994
|
-
}), hideLabel), jsx(Slider,
|
|
1044
|
+
}), hideLabel), jsx(Slider, {
|
|
995
1045
|
disabled: disabled || readonly,
|
|
996
1046
|
onChange: _onChange,
|
|
997
1047
|
onBlur: _onBlur,
|
|
998
1048
|
onFocus: _onFocus,
|
|
999
|
-
valueLabelDisplay: 'auto'
|
|
1000
|
-
|
|
1049
|
+
valueLabelDisplay: 'auto',
|
|
1050
|
+
...sliderProps,
|
|
1001
1051
|
"aria-describedby": ariaDescribedByIds(id)
|
|
1002
|
-
})
|
|
1052
|
+
})]
|
|
1003
1053
|
});
|
|
1004
1054
|
}
|
|
1005
1055
|
|
|
1006
|
-
var _excluded = ["schema", "id", "name", "options", "label", "hideLabel", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
|
|
1007
1056
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
1008
1057
|
* It is typically used with string properties constrained with enum options.
|
|
1009
1058
|
*
|
|
1010
1059
|
* @param props - The `WidgetProps` for this component
|
|
1011
1060
|
*/
|
|
1012
|
-
function SelectWidget(
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1061
|
+
function SelectWidget({
|
|
1062
|
+
schema,
|
|
1063
|
+
id,
|
|
1064
|
+
name,
|
|
1065
|
+
// remove this from textFieldProps
|
|
1066
|
+
options,
|
|
1067
|
+
label,
|
|
1068
|
+
hideLabel,
|
|
1069
|
+
required,
|
|
1070
|
+
disabled,
|
|
1071
|
+
placeholder,
|
|
1072
|
+
readonly,
|
|
1073
|
+
value,
|
|
1074
|
+
multiple,
|
|
1075
|
+
autofocus,
|
|
1076
|
+
onChange,
|
|
1077
|
+
onBlur,
|
|
1078
|
+
onFocus,
|
|
1079
|
+
rawErrors = [],
|
|
1080
|
+
registry,
|
|
1081
|
+
uiSchema,
|
|
1082
|
+
hideError,
|
|
1083
|
+
formContext,
|
|
1084
|
+
...textFieldProps
|
|
1085
|
+
}) {
|
|
1086
|
+
const {
|
|
1087
|
+
enumOptions,
|
|
1088
|
+
enumDisabled,
|
|
1089
|
+
emptyValue: optEmptyVal
|
|
1090
|
+
} = options;
|
|
1033
1091
|
multiple = typeof multiple === 'undefined' ? false : !!multiple;
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1092
|
+
const emptyValue = multiple ? [] : '';
|
|
1093
|
+
const isEmpty = typeof value === 'undefined' || multiple && value.length < 1 || !multiple && value === emptyValue;
|
|
1094
|
+
const _onChange = ({
|
|
1095
|
+
target: {
|
|
1096
|
+
value
|
|
1097
|
+
}
|
|
1098
|
+
}) => onChange(enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1099
|
+
const _onBlur = ({
|
|
1100
|
+
target: {
|
|
1101
|
+
value
|
|
1102
|
+
}
|
|
1103
|
+
}) => onBlur(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1104
|
+
const _onFocus = ({
|
|
1105
|
+
target: {
|
|
1106
|
+
value
|
|
1107
|
+
}
|
|
1108
|
+
}) => onFocus(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1109
|
+
const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1110
|
+
return jsx(TextField, {
|
|
1050
1111
|
id: id,
|
|
1051
1112
|
name: id,
|
|
1052
1113
|
label: labelValue(label || undefined, hideLabel, false),
|
|
@@ -1058,28 +1119,31 @@ function SelectWidget(_ref) {
|
|
|
1058
1119
|
error: rawErrors.length > 0,
|
|
1059
1120
|
onChange: _onChange,
|
|
1060
1121
|
onBlur: _onBlur,
|
|
1061
|
-
onFocus: _onFocus
|
|
1062
|
-
|
|
1122
|
+
onFocus: _onFocus,
|
|
1123
|
+
...textFieldProps,
|
|
1063
1124
|
select // Apply this and the following props after the potential overrides defined in textFieldProps
|
|
1064
1125
|
: true,
|
|
1065
|
-
InputLabelProps:
|
|
1126
|
+
InputLabelProps: {
|
|
1127
|
+
...textFieldProps.InputLabelProps,
|
|
1066
1128
|
shrink: !isEmpty
|
|
1067
|
-
}
|
|
1068
|
-
SelectProps:
|
|
1069
|
-
|
|
1070
|
-
|
|
1129
|
+
},
|
|
1130
|
+
SelectProps: {
|
|
1131
|
+
...textFieldProps.SelectProps,
|
|
1132
|
+
multiple
|
|
1133
|
+
},
|
|
1071
1134
|
"aria-describedby": ariaDescribedByIds(id),
|
|
1072
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1135
|
+
children: Array.isArray(enumOptions) && enumOptions.map(({
|
|
1136
|
+
value,
|
|
1137
|
+
label
|
|
1138
|
+
}, i) => {
|
|
1139
|
+
const disabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1;
|
|
1076
1140
|
return jsx(MenuItem, {
|
|
1077
1141
|
value: String(i),
|
|
1078
1142
|
disabled: disabled,
|
|
1079
1143
|
children: label
|
|
1080
1144
|
}, i);
|
|
1081
1145
|
})
|
|
1082
|
-
})
|
|
1146
|
+
});
|
|
1083
1147
|
}
|
|
1084
1148
|
|
|
1085
1149
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
@@ -1087,27 +1151,30 @@ function SelectWidget(_ref) {
|
|
|
1087
1151
|
* @param props - The `WidgetProps` for this component
|
|
1088
1152
|
*/
|
|
1089
1153
|
function TextareaWidget(props) {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1154
|
+
const {
|
|
1155
|
+
options,
|
|
1156
|
+
registry
|
|
1157
|
+
} = props;
|
|
1158
|
+
const BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
1159
|
+
let rows = 5;
|
|
1094
1160
|
if (typeof options.rows === 'string' || typeof options.rows === 'number') {
|
|
1095
1161
|
rows = options.rows;
|
|
1096
1162
|
}
|
|
1097
|
-
return jsx(BaseInputTemplate,
|
|
1163
|
+
return jsx(BaseInputTemplate, {
|
|
1164
|
+
...props,
|
|
1098
1165
|
multiline: true,
|
|
1099
1166
|
rows: rows
|
|
1100
|
-
})
|
|
1167
|
+
});
|
|
1101
1168
|
}
|
|
1102
1169
|
|
|
1103
1170
|
function generateWidgets() {
|
|
1104
1171
|
return {
|
|
1105
|
-
CheckboxWidget
|
|
1106
|
-
CheckboxesWidget
|
|
1107
|
-
RadioWidget
|
|
1108
|
-
RangeWidget
|
|
1109
|
-
SelectWidget
|
|
1110
|
-
TextareaWidget
|
|
1172
|
+
CheckboxWidget,
|
|
1173
|
+
CheckboxesWidget,
|
|
1174
|
+
RadioWidget,
|
|
1175
|
+
RangeWidget,
|
|
1176
|
+
SelectWidget,
|
|
1177
|
+
TextareaWidget
|
|
1111
1178
|
};
|
|
1112
1179
|
}
|
|
1113
1180
|
var Widgets = /*#__PURE__*/generateWidgets();
|