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