@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.
@@ -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(_ref) {
69
- var registry = _ref.registry,
70
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
71
- var translateString = registry.translateString;
72
- return jsxRuntime.jsx(IconButton__default["default"], _extends({
73
- title: translateString(utils.TranslatableString.AddItemButton)
74
- }, props, {
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
- var children = props.children,
86
- disabled = props.disabled,
87
- hasToolbar = props.hasToolbar,
88
- hasCopy = props.hasCopy,
89
- hasMoveDown = props.hasMoveDown,
90
- hasMoveUp = props.hasMoveUp,
91
- hasRemove = props.hasRemove,
92
- index = props.index,
93
- onCopyIndexClick = props.onCopyIndexClick,
94
- onDropIndexClick = props.onDropIndexClick,
95
- onReorderClick = props.onReorderClick,
96
- readonly = props.readonly,
97
- uiSchema = props.uiSchema,
98
- registry = props.registry;
99
- var _registry$templates$B = registry.templates.ButtonTemplates,
100
- CopyButton = _registry$templates$B.CopyButton,
101
- MoveDownButton = _registry$templates$B.MoveDownButton,
102
- MoveUpButton = _registry$templates$B.MoveUpButton,
103
- RemoveButton = _registry$templates$B.RemoveButton;
104
- var btnStyle = {
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
- var canAdd = props.canAdd,
168
- disabled = props.disabled,
169
- idSchema = props.idSchema,
170
- uiSchema = props.uiSchema,
171
- items = props.items,
172
- onAddClick = props.onAddClick,
173
- readonly = props.readonly,
174
- registry = props.registry,
175
- required = props.required,
176
- schema = props.schema,
177
- title = props.title;
178
- var uiOptions = utils.getUiOptions(uiSchema);
179
- var ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
180
- var ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
181
- var ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
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
- var AddButton = registry.templates.ButtonTemplates.AddButton;
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(function (_ref) {
204
- var key = _ref.key,
205
- itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$3);
206
- return jsxRuntime.jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
207
- }), canAdd && jsxRuntime.jsx(Grid__default["default"], {
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
- }, "array-item-list-" + idSchema.$id)]
209
+ }, `array-item-list-${idSchema.$id}`)]
225
210
  })
226
211
  });
227
212
  }
228
213
 
229
- var _excluded$2 = ["id", "name", "placeholder", "required", "readonly", "disabled", "type", "label", "hideLabel", "value", "onChange", "onChangeOverride", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry", "InputLabelProps"],
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
- var id = props.id,
240
- placeholder = props.placeholder,
241
- required = props.required,
242
- readonly = props.readonly,
243
- disabled = props.disabled,
244
- type = props.type,
245
- label = props.label,
246
- hideLabel = props.hideLabel,
247
- value = props.value,
248
- onChange = props.onChange,
249
- onChangeOverride = props.onChangeOverride,
250
- onBlur = props.onBlur,
251
- onFocus = props.onFocus,
252
- autofocus = props.autofocus,
253
- options = props.options,
254
- schema = props.schema,
255
- _props$rawErrors = props.rawErrors,
256
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
257
- InputLabelProps = props.InputLabelProps,
258
- textFieldProps = _objectWithoutPropertiesLoose(props, _excluded$2);
259
- var inputProps = utils.getInputProps(schema, type, options);
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
- var step = inputProps.step,
262
- min = inputProps.min,
263
- max = inputProps.max,
264
- rest = _objectWithoutPropertiesLoose(inputProps, _excluded2$1);
265
- var otherProps = _extends({
266
- inputProps: _extends({
267
- step: step,
268
- min: min,
269
- max: max
270
- }, schema.examples ? {
271
- list: utils.examplesId(id)
272
- } : undefined)
273
- }, rest);
274
- var _onChange = function _onChange(_ref) {
275
- var value = _ref.target.value;
276
- return onChange(value === '' ? options.emptyValue : value);
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
- var DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? _extends({}, InputLabelProps, {
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
- }) : InputLabelProps;
285
+ } : InputLabelProps;
289
286
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
290
- children: [jsxRuntime.jsx(TextField__default["default"], _extends({
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
- }, otherProps, {
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
- }, textFieldProps, {
301
+ InputLabelProps: DisplayInputLabelProps,
302
+ ...textFieldProps,
306
303
  "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
307
- })), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
304
+ }), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
308
305
  id: utils.examplesId(id),
309
- children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
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
- var id = props.id,
324
- description = props.description;
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(_ref) {
343
- var errors = _ref.errors,
344
- registry = _ref.registry;
345
- var translateString = registry.translateString;
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(function (error, i) {
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
- var icon = props.icon,
376
- color = props.color,
377
- otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
378
- return jsxRuntime.jsx(IconButton__default["default"], _extends({}, otherProps, {
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
- var translateString = props.registry.translateString;
386
- return jsxRuntime.jsx(MuiIconButton, _extends({
387
- title: translateString(utils.TranslatableString.CopyButton)
388
- }, props, {
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
- var translateString = props.registry.translateString;
396
- return jsxRuntime.jsx(MuiIconButton, _extends({
397
- title: translateString(utils.TranslatableString.MoveDownButton)
398
- }, props, {
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
- var translateString = props.registry.translateString;
406
- return jsxRuntime.jsx(MuiIconButton, _extends({
407
- title: translateString(utils.TranslatableString.MoveUpButton)
408
- }, props, {
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
- var iconType = props.iconType,
416
- otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
417
- var translateString = otherProps.registry.translateString;
418
- return jsxRuntime.jsx(MuiIconButton, _extends({
419
- title: translateString(utils.TranslatableString.RemoveButton)
420
- }, otherProps, {
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
- var _props$errors = props.errors,
434
- errors = _props$errors === void 0 ? [] : _props$errors,
435
- idSchema = props.idSchema;
456
+ const {
457
+ errors = [],
458
+ idSchema
459
+ } = props;
436
460
  if (errors.length === 0) {
437
461
  return null;
438
462
  }
439
- var id = utils.errorId(idSchema);
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(function (error, i) {
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
- var idSchema = props.idSchema,
461
- help = props.help;
484
+ const {
485
+ idSchema,
486
+ help
487
+ } = props;
462
488
  if (!help) {
463
489
  return null;
464
490
  }
465
- var id = utils.helpId(idSchema);
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
- var id = props.id,
479
- children = props.children,
480
- classNames = props.classNames,
481
- style = props.style,
482
- disabled = props.disabled,
483
- displayLabel = props.displayLabel,
484
- hidden = props.hidden,
485
- label = props.label,
486
- onDropPropertyClick = props.onDropPropertyClick,
487
- onKeyChange = props.onKeyChange,
488
- readonly = props.readonly,
489
- required = props.required,
490
- _props$rawErrors = props.rawErrors,
491
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
492
- errors = props.errors,
493
- help = props.help,
494
- description = props.description,
495
- rawDescription = props.rawDescription,
496
- schema = props.schema,
497
- uiSchema = props.uiSchema,
498
- registry = props.registry;
499
- var uiOptions = utils.getUiOptions(uiSchema);
500
- var WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
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
- var description = props.description,
543
- title = props.title,
544
- properties = props.properties,
545
- required = props.required,
546
- disabled = props.disabled,
547
- readonly = props.readonly,
548
- uiSchema = props.uiSchema,
549
- idSchema = props.idSchema,
550
- schema = props.schema,
551
- formData = props.formData,
552
- onAddClick = props.onAddClick,
553
- registry = props.registry;
554
- var uiOptions = utils.getUiOptions(uiSchema);
555
- var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, uiOptions);
556
- var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
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
- var AddButton = registry.templates.ButtonTemplates.AddButton;
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(function (element, index) {
580
- return (
581
- // Remove the <Grid> if the inner element is hidden as the <Grid>
582
- // itself would otherwise still take up space.
583
- element.hidden ? element.content : jsxRuntime.jsx(Grid__default["default"], {
584
- item: true,
585
- xs: 12,
586
- style: {
587
- marginBottom: '10px'
588
- },
589
- children: element.content
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(_ref) {
613
- var uiSchema = _ref.uiSchema;
614
- var _getSubmitButtonOptio = utils.getSubmitButtonOptions(uiSchema),
615
- submitText = _getSubmitButtonOptio.submitText,
616
- norender = _getSubmitButtonOptio.norender,
617
- _getSubmitButtonOptio2 = _getSubmitButtonOptio.props,
618
- submitButtonProps = _getSubmitButtonOptio2 === void 0 ? {} : _getSubmitButtonOptio2;
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"], _extends({
655
+ children: jsxRuntime.jsx(Button__default["default"], {
625
656
  type: 'submit',
626
657
  variant: 'contained',
627
- color: 'primary'
628
- }, submitButtonProps, {
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(_ref) {
639
- var id = _ref.id,
640
- title = _ref.title;
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
- var children = props.children,
659
- classNames = props.classNames,
660
- style = props.style,
661
- disabled = props.disabled,
662
- id = props.id,
663
- label = props.label,
664
- onDropPropertyClick = props.onDropPropertyClick,
665
- onKeyChange = props.onKeyChange,
666
- readonly = props.readonly,
667
- required = props.required,
668
- schema = props.schema,
669
- uiSchema = props.uiSchema,
670
- registry = props.registry;
671
- var templates = registry.templates,
672
- translateString = registry.translateString;
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
- var RemoveButton = templates.ButtonTemplates.RemoveButton;
675
- var keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
676
- var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
677
- var btnStyle = {
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
- var handleBlur = function handleBlur(_ref) {
691
- var target = _ref.target;
692
- return onKeyChange(target.value);
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 + "-key",
710
- name: id + "-key",
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 + "-key");
766
+ }, `${id}-key`);
730
767
  }
731
768
 
732
769
  function generateTemplates() {
733
770
  return {
734
- ArrayFieldItemTemplate: ArrayFieldItemTemplate,
735
- ArrayFieldTemplate: ArrayFieldTemplate,
736
- BaseInputTemplate: BaseInputTemplate,
771
+ ArrayFieldItemTemplate,
772
+ ArrayFieldTemplate,
773
+ BaseInputTemplate,
737
774
  ButtonTemplates: {
738
- AddButton: AddButton,
739
- CopyButton: CopyButton,
740
- MoveDownButton: MoveDownButton,
741
- MoveUpButton: MoveUpButton,
742
- RemoveButton: RemoveButton,
743
- SubmitButton: 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: FieldErrorTemplate,
748
- FieldHelpTemplate: FieldHelpTemplate,
749
- FieldTemplate: FieldTemplate,
750
- ObjectFieldTemplate: ObjectFieldTemplate,
784
+ FieldErrorTemplate,
785
+ FieldHelpTemplate,
786
+ FieldTemplate,
787
+ ObjectFieldTemplate,
751
788
  TitleFieldTemplate: TitleField,
752
- WrapIfAdditionalTemplate: 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
- var _options$description;
764
- var schema = props.schema,
765
- id = props.id,
766
- value = props.value,
767
- disabled = props.disabled,
768
- readonly = props.readonly,
769
- _props$label = props.label,
770
- label = _props$label === void 0 ? '' : _props$label,
771
- hideLabel = props.hideLabel,
772
- autofocus = props.autofocus,
773
- onChange = props.onChange,
774
- onBlur = props.onBlur,
775
- onFocus = props.onFocus,
776
- registry = props.registry,
777
- options = props.options,
778
- uiSchema = props.uiSchema;
779
- var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, options);
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
- var required = utils.schemaRequiresTrueValue(schema);
784
- var _onChange = function _onChange(_, checked) {
785
- return onChange(checked);
786
- };
787
- var _onBlur = function _onBlur(_ref) {
788
- var value = _ref.target.value;
789
- return onBlur(id, value);
790
- };
791
- var _onFocus = function _onFocus(_ref2) {
792
- var value = _ref2.target.value;
793
- return onFocus(id, value);
794
- };
795
- var description = (_options$description = options.description) != null ? _options$description : schema.description;
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(_ref) {
827
- var label = _ref.label,
828
- hideLabel = _ref.hideLabel,
829
- id = _ref.id,
830
- disabled = _ref.disabled,
831
- options = _ref.options,
832
- value = _ref.value,
833
- autofocus = _ref.autofocus,
834
- readonly = _ref.readonly,
835
- required = _ref.required,
836
- onChange = _ref.onChange,
837
- onBlur = _ref.onBlur,
838
- onFocus = _ref.onFocus;
839
- var enumOptions = options.enumOptions,
840
- enumDisabled = options.enumDisabled,
841
- inline = options.inline,
842
- emptyValue = options.emptyValue;
843
- var checkboxesValues = Array.isArray(value) ? value : [value];
844
- var _onChange = function _onChange(index) {
845
- return function (_ref2) {
846
- var checked = _ref2.target.checked;
847
- if (checked) {
848
- onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
849
- } else {
850
- onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
851
- }
852
- };
853
- };
854
- var _onBlur = function _onBlur(_ref3) {
855
- var value = _ref3.target.value;
856
- return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
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(function (option, index) {
871
- var checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
872
- var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
873
- var checkbox = jsxRuntime.jsx(Checkbox__default["default"], {
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(_ref) {
899
- var _enumOptionsIndexForV;
900
- var id = _ref.id,
901
- options = _ref.options,
902
- value = _ref.value,
903
- required = _ref.required,
904
- disabled = _ref.disabled,
905
- readonly = _ref.readonly,
906
- label = _ref.label,
907
- hideLabel = _ref.hideLabel,
908
- onChange = _ref.onChange,
909
- onBlur = _ref.onBlur,
910
- onFocus = _ref.onFocus;
911
- var enumOptions = options.enumOptions,
912
- enumDisabled = options.enumDisabled,
913
- emptyValue = options.emptyValue;
914
- var _onChange = function _onChange(_, value) {
915
- return onChange(utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
916
- };
917
- var _onBlur = function _onBlur(_ref2) {
918
- var value = _ref2.target.value;
919
- return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
920
- };
921
- var _onFocus = function _onFocus(_ref3) {
922
- var value = _ref3.target.value;
923
- return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
924
- };
925
- var row = options ? options.inline : false;
926
- var selectedIndex = (_enumOptionsIndexForV = utils.enumOptionsIndexForValue(value, enumOptions)) != null ? _enumOptionsIndexForV : null;
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(function (option, index) {
942
- var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
943
- var radio = jsxRuntime.jsx(FormControlLabel__default["default"], {
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
- var value = props.value,
966
- readonly = props.readonly,
967
- disabled = props.disabled,
968
- onBlur = props.onBlur,
969
- onFocus = props.onFocus,
970
- options = props.options,
971
- schema = props.schema,
972
- onChange = props.onChange,
973
- required = props.required,
974
- label = props.label,
975
- hideLabel = props.hideLabel,
976
- id = props.id;
977
- var sliderProps = _extends({
978
- value: value,
979
- label: label,
980
- id: id,
981
- name: id
982
- }, utils.rangeSpec(schema));
983
- var _onChange = function _onChange(_, value) {
984
- onChange(value != null ? value : options.emptyValue);
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
- var _onFocus = function _onFocus(_ref2) {
991
- var value = _ref2.target.value;
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"], _extends({
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
- }, sliderProps, {
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(_ref) {
1018
- var id = _ref.id,
1019
- options = _ref.options,
1020
- label = _ref.label,
1021
- hideLabel = _ref.hideLabel,
1022
- required = _ref.required,
1023
- disabled = _ref.disabled,
1024
- placeholder = _ref.placeholder,
1025
- readonly = _ref.readonly,
1026
- value = _ref.value,
1027
- multiple = _ref.multiple,
1028
- autofocus = _ref.autofocus,
1029
- onChange = _ref.onChange,
1030
- onBlur = _ref.onBlur,
1031
- onFocus = _ref.onFocus,
1032
- _ref$rawErrors = _ref.rawErrors,
1033
- rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors,
1034
- textFieldProps = _objectWithoutPropertiesLoose(_ref, _excluded);
1035
- var enumOptions = options.enumOptions,
1036
- enumDisabled = options.enumDisabled,
1037
- optEmptyVal = options.emptyValue;
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
- var emptyValue = multiple ? [] : '';
1040
- var isEmpty = typeof value === 'undefined' || multiple && value.length < 1 || !multiple && value === emptyValue;
1041
- var _onChange = function _onChange(_ref2) {
1042
- var value = _ref2.target.value;
1043
- return onChange(utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1044
- };
1045
- var _onBlur = function _onBlur(_ref3) {
1046
- var value = _ref3.target.value;
1047
- return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1048
- };
1049
- var _onFocus = function _onFocus(_ref4) {
1050
- var value = _ref4.target.value;
1051
- return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1052
- };
1053
- var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
1054
- return jsxRuntime.jsx(TextField__default["default"], _extends({
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
- }, textFieldProps, {
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: _extends({}, textFieldProps.InputLabelProps, {
1131
+ InputLabelProps: {
1132
+ ...textFieldProps.InputLabelProps,
1071
1133
  shrink: !isEmpty
1072
- }),
1073
- SelectProps: _extends({}, textFieldProps.SelectProps, {
1074
- multiple: multiple
1075
- }),
1134
+ },
1135
+ SelectProps: {
1136
+ ...textFieldProps.SelectProps,
1137
+ multiple
1138
+ },
1076
1139
  "aria-describedby": utils.ariaDescribedByIds(id),
1077
- children: Array.isArray(enumOptions) && enumOptions.map(function (_ref5, i) {
1078
- var value = _ref5.value,
1079
- label = _ref5.label;
1080
- var disabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1;
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
- var options = props.options,
1096
- registry = props.registry;
1097
- var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
1098
- var rows = 5;
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, _extends({}, props, {
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: CheckboxWidget,
1111
- CheckboxesWidget: CheckboxesWidget,
1112
- RadioWidget: RadioWidget,
1113
- RangeWidget: RangeWidget,
1114
- SelectWidget: SelectWidget,
1115
- TextareaWidget: TextareaWidget
1177
+ CheckboxWidget,
1178
+ CheckboxesWidget,
1179
+ RadioWidget,
1180
+ RangeWidget,
1181
+ SelectWidget,
1182
+ TextareaWidget
1116
1183
  };
1117
1184
  }
1118
1185
  var Widgets = /*#__PURE__*/generateWidgets();