@rjsf/mui 5.0.0-beta.13 → 5.0.0-beta.15

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.esm.js CHANGED
@@ -31,39 +31,68 @@ import RadioGroup from '@mui/material/RadioGroup';
31
31
  import Slider from '@mui/material/Slider';
32
32
  import MenuItem from '@mui/material/MenuItem';
33
33
 
34
- const AddButton = _ref => {
35
- let {
36
- uiSchema,
37
- ...props
38
- } = _ref;
39
- return /*#__PURE__*/React.createElement(IconButton, {
40
- title: "Add Item",
41
- ...props,
34
+ function _extends() {
35
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
36
+ for (var i = 1; i < arguments.length; i++) {
37
+ var source = arguments[i];
38
+
39
+ for (var key in source) {
40
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
41
+ target[key] = source[key];
42
+ }
43
+ }
44
+ }
45
+
46
+ return target;
47
+ };
48
+ return _extends.apply(this, arguments);
49
+ }
50
+
51
+ function _objectWithoutPropertiesLoose(source, excluded) {
52
+ if (source == null) return {};
53
+ var target = {};
54
+ var sourceKeys = Object.keys(source);
55
+ var key, i;
56
+
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
+
63
+ return target;
64
+ }
65
+
66
+ var _excluded$3 = ["uiSchema"];
67
+
68
+ var AddButton = function AddButton(_ref) {
69
+ var props = _objectWithoutPropertiesLoose(_ref, _excluded$3);
70
+
71
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
72
+ title: "Add Item"
73
+ }, props, {
42
74
  color: "primary"
43
- }, /*#__PURE__*/React.createElement(AddIcon, null));
75
+ }), /*#__PURE__*/React.createElement(AddIcon, null));
44
76
  };
45
77
 
46
- const ArrayFieldItemTemplate = props => {
47
- const {
48
- children,
49
- disabled,
50
- hasToolbar,
51
- hasMoveDown,
52
- hasMoveUp,
53
- hasRemove,
54
- index,
55
- onDropIndexClick,
56
- onReorderClick,
57
- readonly,
58
- uiSchema,
59
- registry
60
- } = props;
61
- const {
62
- MoveDownButton,
63
- MoveUpButton,
64
- RemoveButton
65
- } = registry.templates.ButtonTemplates;
66
- const btnStyle = {
78
+ var ArrayFieldItemTemplate = function ArrayFieldItemTemplate(props) {
79
+ var children = props.children,
80
+ disabled = props.disabled,
81
+ hasToolbar = props.hasToolbar,
82
+ hasMoveDown = props.hasMoveDown,
83
+ hasMoveUp = props.hasMoveUp,
84
+ hasRemove = props.hasRemove,
85
+ index = props.index,
86
+ onDropIndexClick = props.onDropIndexClick,
87
+ onReorderClick = props.onReorderClick,
88
+ readonly = props.readonly,
89
+ uiSchema = props.uiSchema,
90
+ registry = props.registry;
91
+ var _registry$templates$B = registry.templates.ButtonTemplates,
92
+ MoveDownButton = _registry$templates$B.MoveDownButton,
93
+ MoveUpButton = _registry$templates$B.MoveUpButton,
94
+ RemoveButton = _registry$templates$B.RemoveButton;
95
+ var btnStyle = {
67
96
  flex: 1,
68
97
  paddingLeft: 6,
69
98
  paddingRight: 6,
@@ -105,30 +134,26 @@ const ArrayFieldItemTemplate = props => {
105
134
  })));
106
135
  };
107
136
 
108
- const ArrayFieldTemplate = props => {
109
- const {
110
- canAdd,
111
- disabled,
112
- idSchema,
113
- uiSchema,
114
- items,
115
- onAddClick,
116
- readonly,
117
- registry,
118
- required,
119
- schema,
120
- title
121
- } = props;
122
- const uiOptions = getUiOptions(uiSchema);
123
- const ArrayFieldDescriptionTemplate = getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
124
- const ArrayFieldItemTemplate = getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
125
- const ArrayFieldTitleTemplate = getTemplate("ArrayFieldTitleTemplate", registry, uiOptions); // Button templates are not overridden in the uiSchema
126
-
127
- const {
128
- ButtonTemplates: {
129
- AddButton
130
- }
131
- } = registry.templates;
137
+ var _excluded$2 = ["key"];
138
+
139
+ var ArrayFieldTemplate = function ArrayFieldTemplate(props) {
140
+ var canAdd = props.canAdd,
141
+ disabled = props.disabled,
142
+ idSchema = props.idSchema,
143
+ uiSchema = props.uiSchema,
144
+ items = props.items,
145
+ onAddClick = props.onAddClick,
146
+ readonly = props.readonly,
147
+ registry = props.registry,
148
+ required = props.required,
149
+ schema = props.schema,
150
+ title = props.title;
151
+ var uiOptions = getUiOptions(uiSchema);
152
+ var ArrayFieldDescriptionTemplate = getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
153
+ var ArrayFieldItemTemplate = getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
154
+ var ArrayFieldTitleTemplate = getTemplate("ArrayFieldTitleTemplate", registry, uiOptions); // Button templates are not overridden in the uiSchema
155
+
156
+ var AddButton = registry.templates.ButtonTemplates.AddButton;
132
157
  return /*#__PURE__*/React.createElement(Paper, {
133
158
  elevation: 2
134
159
  }, /*#__PURE__*/React.createElement(Box, {
@@ -149,15 +174,13 @@ const ArrayFieldTemplate = props => {
149
174
  }), /*#__PURE__*/React.createElement(Grid, {
150
175
  container: true,
151
176
  key: "array-item-list-" + idSchema.$id
152
- }, items && items.map(_ref => {
153
- let {
154
- key,
155
- ...itemProps
156
- } = _ref;
157
- return /*#__PURE__*/React.createElement(ArrayFieldItemTemplate, {
158
- key: key,
159
- ...itemProps
160
- });
177
+ }, items && items.map(function (_ref) {
178
+ var key = _ref.key,
179
+ itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$2);
180
+
181
+ return /*#__PURE__*/React.createElement(ArrayFieldItemTemplate, _extends({
182
+ key: key
183
+ }, itemProps));
161
184
  }), canAdd && /*#__PURE__*/React.createElement(Grid, {
162
185
  container: true,
163
186
  justifyContent: "flex-end"
@@ -173,97 +196,81 @@ const ArrayFieldTemplate = props => {
173
196
  })))))));
174
197
  };
175
198
 
176
- const BaseInputTemplate = _ref => {
177
- let {
178
- id,
179
- placeholder,
180
- required,
181
- readonly,
182
- disabled,
183
- type,
184
- label,
185
- value,
186
- onChange,
187
- onBlur,
188
- onFocus,
189
- autofocus,
190
- options,
191
- schema,
192
- uiSchema,
193
- rawErrors = [],
194
- formContext,
195
- registry,
196
- ...textFieldProps
197
- } = _ref;
198
- const inputProps = getInputProps(schema, type, options); // Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
199
-
200
- const {
201
- step,
202
- min,
203
- max,
204
- ...rest
205
- } = inputProps;
206
- const otherProps = {
207
- inputProps: {
208
- step,
209
- min,
210
- max,
211
- ...(schema.examples ? {
212
- list: "examples_" + id
213
- } : undefined)
214
- },
215
- ...rest
216
- };
217
-
218
- const _onChange = _ref2 => {
219
- let {
220
- target: {
221
- value
222
- }
223
- } = _ref2;
199
+ var _excluded$1 = ["id", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry"],
200
+ _excluded2$1 = ["step", "min", "max"];
201
+
202
+ var BaseInputTemplate = function BaseInputTemplate(_ref) {
203
+ var id = _ref.id,
204
+ placeholder = _ref.placeholder,
205
+ required = _ref.required,
206
+ readonly = _ref.readonly,
207
+ disabled = _ref.disabled,
208
+ type = _ref.type,
209
+ label = _ref.label,
210
+ value = _ref.value,
211
+ onChange = _ref.onChange,
212
+ onBlur = _ref.onBlur,
213
+ onFocus = _ref.onFocus,
214
+ autofocus = _ref.autofocus,
215
+ options = _ref.options,
216
+ schema = _ref.schema,
217
+ uiSchema = _ref.uiSchema,
218
+ _ref$rawErrors = _ref.rawErrors,
219
+ rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors,
220
+ registry = _ref.registry,
221
+ textFieldProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
222
+
223
+ var inputProps = getInputProps(schema, type, options); // Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
224
+
225
+ var step = inputProps.step,
226
+ min = inputProps.min,
227
+ max = inputProps.max,
228
+ rest = _objectWithoutPropertiesLoose(inputProps, _excluded2$1);
229
+
230
+ var otherProps = _extends({
231
+ inputProps: _extends({
232
+ step: step,
233
+ min: min,
234
+ max: max
235
+ }, schema.examples ? {
236
+ list: "examples_" + id
237
+ } : undefined)
238
+ }, rest);
239
+
240
+ var _onChange = function _onChange(_ref2) {
241
+ var value = _ref2.target.value;
224
242
  return onChange(value === "" ? options.emptyValue : value);
225
243
  };
226
244
 
227
- const _onBlur = _ref3 => {
228
- let {
229
- target: {
230
- value
231
- }
232
- } = _ref3;
245
+ var _onBlur = function _onBlur(_ref3) {
246
+ var value = _ref3.target.value;
233
247
  return onBlur(id, value);
234
248
  };
235
249
 
236
- const _onFocus = _ref4 => {
237
- let {
238
- target: {
239
- value
240
- }
241
- } = _ref4;
250
+ var _onFocus = function _onFocus(_ref4) {
251
+ var value = _ref4.target.value;
242
252
  return onFocus(id, value);
243
253
  };
244
254
 
245
- const {
246
- schemaUtils
247
- } = registry;
248
- const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
249
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, {
255
+ var schemaUtils = registry.schemaUtils;
256
+ var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
257
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TextField, _extends({
250
258
  id: id,
251
259
  name: id,
252
260
  placeholder: placeholder,
253
261
  label: displayLabel ? label || schema.title : false,
254
262
  autoFocus: autofocus,
255
263
  required: required,
256
- disabled: disabled || readonly,
257
- ...otherProps,
264
+ disabled: disabled || readonly
265
+ }, otherProps, {
258
266
  value: value || value === 0 ? value : "",
259
267
  error: rawErrors.length > 0,
260
268
  onChange: _onChange,
261
269
  onBlur: _onBlur,
262
- onFocus: _onFocus,
263
- ...textFieldProps
264
- }), schema.examples && /*#__PURE__*/React.createElement("datalist", {
270
+ onFocus: _onFocus
271
+ }, textFieldProps)), schema.examples && /*#__PURE__*/React.createElement("datalist", {
265
272
  id: "examples_" + id
266
- }, schema.examples.concat(schema.default ? [schema.default] : []).map(example => {
273
+ }, schema.examples.concat(schema["default"] ? [schema["default"]] : []).map(function (example) {
267
274
  return /*#__PURE__*/React.createElement("option", {
268
275
  key: example,
269
276
  value: example
@@ -271,11 +278,9 @@ const BaseInputTemplate = _ref => {
271
278
  })));
272
279
  };
273
280
 
274
- const DescriptionField = _ref => {
275
- let {
276
- description,
277
- id
278
- } = _ref;
281
+ var DescriptionField = function DescriptionField(_ref) {
282
+ var description = _ref.description,
283
+ id = _ref.id;
279
284
 
280
285
  if (description) {
281
286
  return /*#__PURE__*/React.createElement(Typography, {
@@ -290,10 +295,8 @@ const DescriptionField = _ref => {
290
295
  return null;
291
296
  };
292
297
 
293
- const ErrorList = _ref => {
294
- let {
295
- errors
296
- } = _ref;
298
+ var ErrorList = function ErrorList(_ref) {
299
+ var errors = _ref.errors;
297
300
  return /*#__PURE__*/React.createElement(Paper, {
298
301
  elevation: 2
299
302
  }, /*#__PURE__*/React.createElement(Box, {
@@ -303,7 +306,7 @@ const ErrorList = _ref => {
303
306
  variant: "h6"
304
307
  }, "Errors"), /*#__PURE__*/React.createElement(List, {
305
308
  dense: true
306
- }, errors.map((error, i) => {
309
+ }, errors.map(function (error, i) {
307
310
  return /*#__PURE__*/React.createElement(ListItem, {
308
311
  key: i
309
312
  }, /*#__PURE__*/React.createElement(ListItemIcon, null, /*#__PURE__*/React.createElement(ErrorIcon, {
@@ -314,49 +317,48 @@ const ErrorList = _ref => {
314
317
  }))));
315
318
  };
316
319
 
320
+ var _excluded = ["icon", "color", "uiSchema"],
321
+ _excluded2 = ["iconType"];
317
322
  function MuiIconButton(props) {
318
- const {
319
- icon,
320
- color,
321
- uiSchema,
322
- ...otherProps
323
- } = props;
324
- return /*#__PURE__*/React.createElement(IconButton, { ...otherProps,
323
+ var icon = props.icon,
324
+ color = props.color,
325
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded);
326
+
327
+ return /*#__PURE__*/React.createElement(IconButton, _extends({}, otherProps, {
325
328
  size: "small",
326
329
  color: color
327
- }, icon);
330
+ }), icon);
328
331
  }
329
332
  function MoveDownButton(props) {
330
- return /*#__PURE__*/React.createElement(MuiIconButton, {
331
- title: "Move down",
332
- ...props,
333
+ return /*#__PURE__*/React.createElement(MuiIconButton, _extends({
334
+ title: "Move down"
335
+ }, props, {
333
336
  icon: /*#__PURE__*/React.createElement(ArrowDownwardIcon, {
334
337
  fontSize: "small"
335
338
  })
336
- });
339
+ }));
337
340
  }
338
341
  function MoveUpButton(props) {
339
- return /*#__PURE__*/React.createElement(MuiIconButton, {
340
- title: "Move up",
341
- ...props,
342
+ return /*#__PURE__*/React.createElement(MuiIconButton, _extends({
343
+ title: "Move up"
344
+ }, props, {
342
345
  icon: /*#__PURE__*/React.createElement(ArrowUpwardIcon, {
343
346
  fontSize: "small"
344
347
  })
345
- });
348
+ }));
346
349
  }
347
350
  function RemoveButton(props) {
348
- const {
349
- iconType,
350
- ...otherProps
351
- } = props;
352
- return /*#__PURE__*/React.createElement(MuiIconButton, {
353
- title: "Remove",
354
- ...otherProps,
351
+ var iconType = props.iconType,
352
+ otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
353
+
354
+ return /*#__PURE__*/React.createElement(MuiIconButton, _extends({
355
+ title: "Remove"
356
+ }, otherProps, {
355
357
  color: "error",
356
358
  icon: /*#__PURE__*/React.createElement(RemoveIcon, {
357
359
  fontSize: iconType === "default" ? undefined : "small"
358
360
  })
359
- });
361
+ }));
360
362
  }
361
363
 
362
364
  /** The `FieldErrorTemplate` component renders the errors local to the particular field
@@ -365,20 +367,19 @@ function RemoveButton(props) {
365
367
  */
366
368
 
367
369
  function FieldErrorTemplate(props) {
368
- const {
369
- errors = [],
370
- idSchema
371
- } = props;
370
+ var _props$errors = props.errors,
371
+ errors = _props$errors === void 0 ? [] : _props$errors,
372
+ idSchema = props.idSchema;
372
373
 
373
374
  if (errors.length === 0) {
374
375
  return null;
375
376
  }
376
377
 
377
- const id = idSchema.$id + "__error";
378
+ var id = idSchema.$id + "__error";
378
379
  return /*#__PURE__*/React.createElement(List, {
379
380
  dense: true,
380
381
  disablePadding: true
381
- }, errors.map((error, i) => {
382
+ }, errors.map(function (error, i) {
382
383
  return /*#__PURE__*/React.createElement(ListItem, {
383
384
  key: i,
384
385
  disableGutters: true
@@ -394,44 +395,41 @@ function FieldErrorTemplate(props) {
394
395
  */
395
396
 
396
397
  function FieldHelpTemplate(props) {
397
- const {
398
- idSchema,
399
- help
400
- } = props;
398
+ var idSchema = props.idSchema,
399
+ help = props.help;
401
400
 
402
401
  if (!help) {
403
402
  return null;
404
403
  }
405
404
 
406
- const id = idSchema.$id + "__help";
405
+ var id = idSchema.$id + "__help";
407
406
  return /*#__PURE__*/React.createElement(FormHelperText, {
408
407
  id: id
409
408
  }, help);
410
409
  }
411
410
 
412
- const FieldTemplate = _ref => {
413
- let {
414
- id,
415
- children,
416
- classNames,
417
- disabled,
418
- displayLabel,
419
- hidden,
420
- label,
421
- onDropPropertyClick,
422
- onKeyChange,
423
- readonly,
424
- required,
425
- rawErrors = [],
426
- errors,
427
- help,
428
- rawDescription,
429
- schema,
430
- uiSchema,
431
- registry
432
- } = _ref;
433
- const uiOptions = getUiOptions(uiSchema);
434
- const WrapIfAdditionalTemplate = getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
411
+ var FieldTemplate = function FieldTemplate(_ref) {
412
+ var id = _ref.id,
413
+ children = _ref.children,
414
+ classNames = _ref.classNames,
415
+ disabled = _ref.disabled,
416
+ displayLabel = _ref.displayLabel,
417
+ hidden = _ref.hidden,
418
+ label = _ref.label,
419
+ onDropPropertyClick = _ref.onDropPropertyClick,
420
+ onKeyChange = _ref.onKeyChange,
421
+ readonly = _ref.readonly,
422
+ required = _ref.required,
423
+ _ref$rawErrors = _ref.rawErrors,
424
+ rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors,
425
+ errors = _ref.errors,
426
+ help = _ref.help,
427
+ rawDescription = _ref.rawDescription,
428
+ schema = _ref.schema,
429
+ uiSchema = _ref.uiSchema,
430
+ registry = _ref.registry;
431
+ var uiOptions = getUiOptions(uiSchema);
432
+ var WrapIfAdditionalTemplate = getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
435
433
 
436
434
  if (hidden) {
437
435
  return /*#__PURE__*/React.createElement("div", {
@@ -463,30 +461,24 @@ const FieldTemplate = _ref => {
463
461
  }, rawDescription) : null, errors, help));
464
462
  };
465
463
 
466
- const ObjectFieldTemplate = _ref => {
467
- let {
468
- description,
469
- title,
470
- properties,
471
- required,
472
- disabled,
473
- readonly,
474
- uiSchema,
475
- idSchema,
476
- schema,
477
- formData,
478
- onAddClick,
479
- registry
480
- } = _ref;
481
- const uiOptions = getUiOptions(uiSchema);
482
- const TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, uiOptions);
483
- const DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, uiOptions); // Button templates are not overridden in the uiSchema
484
-
485
- const {
486
- ButtonTemplates: {
487
- AddButton
488
- }
489
- } = registry.templates;
464
+ var ObjectFieldTemplate = function ObjectFieldTemplate(_ref) {
465
+ var description = _ref.description,
466
+ title = _ref.title,
467
+ properties = _ref.properties,
468
+ required = _ref.required,
469
+ disabled = _ref.disabled,
470
+ readonly = _ref.readonly,
471
+ uiSchema = _ref.uiSchema,
472
+ idSchema = _ref.idSchema,
473
+ schema = _ref.schema,
474
+ formData = _ref.formData,
475
+ onAddClick = _ref.onAddClick,
476
+ registry = _ref.registry;
477
+ var uiOptions = getUiOptions(uiSchema);
478
+ var TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, uiOptions);
479
+ var DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, uiOptions); // Button templates are not overridden in the uiSchema
480
+
481
+ var AddButton = registry.templates.ButtonTemplates.AddButton;
490
482
  return /*#__PURE__*/React.createElement(React.Fragment, null, (uiOptions.title || title) && /*#__PURE__*/React.createElement(TitleFieldTemplate, {
491
483
  id: idSchema.$id + "-title",
492
484
  title: title,
@@ -506,16 +498,19 @@ const ObjectFieldTemplate = _ref => {
506
498
  style: {
507
499
  marginTop: "10px"
508
500
  }
509
- }, properties.map((element, index) => // Remove the <Grid> if the inner element is hidden as the <Grid>
510
- // itself would otherwise still take up space.
511
- element.hidden ? element.content : /*#__PURE__*/React.createElement(Grid, {
512
- item: true,
513
- xs: 12,
514
- key: index,
515
- style: {
516
- marginBottom: "10px"
517
- }
518
- }, element.content)), canExpand(schema, uiSchema, formData) && /*#__PURE__*/React.createElement(Grid, {
501
+ }, properties.map(function (element, index) {
502
+ return (// Remove the <Grid> if the inner element is hidden as the <Grid>
503
+ // itself would otherwise still take up space.
504
+ element.hidden ? element.content : /*#__PURE__*/React.createElement(Grid, {
505
+ item: true,
506
+ xs: 12,
507
+ key: index,
508
+ style: {
509
+ marginBottom: "10px"
510
+ }
511
+ }, element.content)
512
+ );
513
+ }), canExpand(schema, uiSchema, formData) && /*#__PURE__*/React.createElement(Grid, {
519
514
  container: true,
520
515
  justifyContent: "flex-end"
521
516
  }, /*#__PURE__*/React.createElement(Grid, {
@@ -528,12 +523,11 @@ const ObjectFieldTemplate = _ref => {
528
523
  })))));
529
524
  };
530
525
 
531
- const SubmitButton = props => {
532
- const {
533
- submitText,
534
- norender,
535
- props: submitButtonProps
536
- } = getSubmitButtonOptions(props.uiSchema);
526
+ var SubmitButton = function SubmitButton(props) {
527
+ var _getSubmitButtonOptio = getSubmitButtonOptions(props.uiSchema),
528
+ submitText = _getSubmitButtonOptio.submitText,
529
+ norender = _getSubmitButtonOptio.norender,
530
+ submitButtonProps = _getSubmitButtonOptio.props;
537
531
 
538
532
  if (norender) {
539
533
  return null;
@@ -541,19 +535,16 @@ const SubmitButton = props => {
541
535
 
542
536
  return /*#__PURE__*/React.createElement(Box, {
543
537
  marginTop: 3
544
- }, /*#__PURE__*/React.createElement(Button, {
538
+ }, /*#__PURE__*/React.createElement(Button, _extends({
545
539
  type: "submit",
546
540
  variant: "contained",
547
- color: "primary",
548
- ...submitButtonProps
549
- }, submitText));
541
+ color: "primary"
542
+ }, submitButtonProps), submitText));
550
543
  };
551
544
 
552
- const TitleField = _ref => {
553
- let {
554
- id,
555
- title
556
- } = _ref;
545
+ var TitleField = function TitleField(_ref) {
546
+ var id = _ref.id,
547
+ title = _ref.title;
557
548
  return /*#__PURE__*/React.createElement(Box, {
558
549
  id: id,
559
550
  mb: 1,
@@ -563,29 +554,25 @@ const TitleField = _ref => {
563
554
  }, title), /*#__PURE__*/React.createElement(Divider, null));
564
555
  };
565
556
 
566
- const WrapIfAdditionalTemplate = _ref => {
567
- let {
568
- children,
569
- classNames,
570
- disabled,
571
- id,
572
- label,
573
- onDropPropertyClick,
574
- onKeyChange,
575
- readonly,
576
- required,
577
- schema,
578
- uiSchema,
579
- registry
580
- } = _ref;
557
+ var WrapIfAdditionalTemplate = function WrapIfAdditionalTemplate(_ref) {
558
+ var children = _ref.children,
559
+ classNames = _ref.classNames,
560
+ disabled = _ref.disabled,
561
+ id = _ref.id,
562
+ label = _ref.label,
563
+ onDropPropertyClick = _ref.onDropPropertyClick,
564
+ onKeyChange = _ref.onKeyChange,
565
+ readonly = _ref.readonly,
566
+ required = _ref.required,
567
+ schema = _ref.schema,
568
+ uiSchema = _ref.uiSchema,
569
+ registry = _ref.registry;
581
570
  // Button templates are not overridden in the uiSchema
582
- const {
583
- RemoveButton
584
- } = registry.templates.ButtonTemplates;
585
- const keyLabel = label + " Key"; // i18n ?
571
+ var RemoveButton = registry.templates.ButtonTemplates.RemoveButton;
572
+ var keyLabel = label + " Key"; // i18n ?
586
573
 
587
- const additional = (ADDITIONAL_PROPERTY_FLAG in schema);
588
- const btnStyle = {
574
+ var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
575
+ var btnStyle = {
589
576
  flex: 1,
590
577
  paddingLeft: 6,
591
578
  paddingRight: 6,
@@ -598,10 +585,8 @@ const WrapIfAdditionalTemplate = _ref => {
598
585
  }, children);
599
586
  }
600
587
 
601
- const handleBlur = _ref2 => {
602
- let {
603
- target
604
- } = _ref2;
588
+ var handleBlur = function handleBlur(_ref2) {
589
+ var target = _ref2.target;
605
590
  return onKeyChange(target.value);
606
591
  };
607
592
 
@@ -639,61 +624,53 @@ const WrapIfAdditionalTemplate = _ref => {
639
624
  };
640
625
 
641
626
  var Templates = {
642
- ArrayFieldItemTemplate,
643
- ArrayFieldTemplate,
644
- BaseInputTemplate,
627
+ ArrayFieldItemTemplate: ArrayFieldItemTemplate,
628
+ ArrayFieldTemplate: ArrayFieldTemplate,
629
+ BaseInputTemplate: BaseInputTemplate,
645
630
  ButtonTemplates: {
646
- AddButton,
647
- MoveDownButton,
648
- MoveUpButton,
649
- RemoveButton,
650
- SubmitButton
631
+ AddButton: AddButton,
632
+ MoveDownButton: MoveDownButton,
633
+ MoveUpButton: MoveUpButton,
634
+ RemoveButton: RemoveButton,
635
+ SubmitButton: SubmitButton
651
636
  },
652
637
  DescriptionFieldTemplate: DescriptionField,
653
638
  ErrorListTemplate: ErrorList,
654
- FieldErrorTemplate,
655
- FieldHelpTemplate,
656
- FieldTemplate,
657
- ObjectFieldTemplate,
639
+ FieldErrorTemplate: FieldErrorTemplate,
640
+ FieldHelpTemplate: FieldHelpTemplate,
641
+ FieldTemplate: FieldTemplate,
642
+ ObjectFieldTemplate: ObjectFieldTemplate,
658
643
  TitleFieldTemplate: TitleField,
659
- WrapIfAdditionalTemplate
644
+ WrapIfAdditionalTemplate: WrapIfAdditionalTemplate
660
645
  };
661
646
 
662
- const CheckboxWidget = props => {
663
- const {
664
- schema,
665
- id,
666
- value,
667
- disabled,
668
- readonly,
669
- label,
670
- autofocus,
671
- onChange,
672
- onBlur,
673
- onFocus
674
- } = props; // Because an unchecked checkbox will cause html5 validation to fail, only add
647
+ var CheckboxWidget = function CheckboxWidget(props) {
648
+ var schema = props.schema,
649
+ id = props.id,
650
+ value = props.value,
651
+ disabled = props.disabled,
652
+ readonly = props.readonly,
653
+ label = props.label,
654
+ autofocus = props.autofocus,
655
+ onChange = props.onChange,
656
+ onBlur = props.onBlur,
657
+ onFocus = props.onFocus; // Because an unchecked checkbox will cause html5 validation to fail, only add
675
658
  // the "required" attribute if the field value must be "true", due to the
676
659
  // "const" or "enum" keywords
677
660
 
678
- const required = schemaRequiresTrueValue(schema);
661
+ var required = schemaRequiresTrueValue(schema);
679
662
 
680
- const _onChange = (_, checked) => onChange(checked);
663
+ var _onChange = function _onChange(_, checked) {
664
+ return onChange(checked);
665
+ };
681
666
 
682
- const _onBlur = _ref => {
683
- let {
684
- target: {
685
- value
686
- }
687
- } = _ref;
667
+ var _onBlur = function _onBlur(_ref) {
668
+ var value = _ref.target.value;
688
669
  return onBlur(id, value);
689
670
  };
690
671
 
691
- const _onFocus = _ref2 => {
692
- let {
693
- target: {
694
- value
695
- }
696
- } = _ref2;
672
+ var _onFocus = function _onFocus(_ref2) {
673
+ var value = _ref2.target.value;
697
674
  return onFocus(id, value);
698
675
  };
699
676
 
@@ -713,74 +690,62 @@ const CheckboxWidget = props => {
713
690
  });
714
691
  };
715
692
 
716
- const selectValue = (value, selected, all) => {
717
- const at = all.indexOf(value);
718
- const updated = selected.slice(0, at).concat(value, selected.slice(at)); // As inserting values at predefined index positions doesn't work with empty
693
+ var selectValue = function selectValue(value, selected, all) {
694
+ var at = all.indexOf(value);
695
+ var updated = selected.slice(0, at).concat(value, selected.slice(at)); // As inserting values at predefined index positions doesn't work with empty
719
696
  // arrays, we need to reorder the updated selection to match the initial order
720
697
 
721
- return updated.sort((a, b) => all.indexOf(a) > all.indexOf(b));
698
+ return updated.sort(function (a, b) {
699
+ return all.indexOf(a) > all.indexOf(b);
700
+ });
722
701
  };
723
702
 
724
- const deselectValue = (value, selected) => {
725
- return selected.filter(v => v !== value);
703
+ var deselectValue = function deselectValue(value, selected) {
704
+ return selected.filter(function (v) {
705
+ return v !== value;
706
+ });
726
707
  };
727
708
 
728
- const CheckboxesWidget = _ref => {
729
- let {
730
- schema,
731
- label,
732
- id,
733
- disabled,
734
- options,
735
- value,
736
- autofocus,
737
- readonly,
738
- required,
739
- onChange,
740
- onBlur,
741
- onFocus
742
- } = _ref;
743
- const {
744
- enumOptions,
745
- enumDisabled,
746
- inline
747
- } = options;
748
-
749
- const _onChange = option => _ref2 => {
750
- let {
751
- target: {
752
- checked
709
+ var CheckboxesWidget = function CheckboxesWidget(_ref) {
710
+ var schema = _ref.schema,
711
+ label = _ref.label,
712
+ id = _ref.id,
713
+ disabled = _ref.disabled,
714
+ options = _ref.options,
715
+ value = _ref.value,
716
+ autofocus = _ref.autofocus,
717
+ readonly = _ref.readonly,
718
+ required = _ref.required,
719
+ onChange = _ref.onChange,
720
+ onBlur = _ref.onBlur,
721
+ onFocus = _ref.onFocus;
722
+ var enumOptions = options.enumOptions,
723
+ enumDisabled = options.enumDisabled,
724
+ inline = options.inline;
725
+
726
+ var _onChange = function _onChange(option) {
727
+ return function (_ref2) {
728
+ var checked = _ref2.target.checked;
729
+ var all = enumOptions.map(function (_ref3) {
730
+ var value = _ref3.value;
731
+ return value;
732
+ });
733
+
734
+ if (checked) {
735
+ onChange(selectValue(option.value, value, all));
736
+ } else {
737
+ onChange(deselectValue(option.value, value));
753
738
  }
754
- } = _ref2;
755
- const all = enumOptions.map(_ref3 => {
756
- let {
757
- value
758
- } = _ref3;
759
- return value;
760
- });
761
-
762
- if (checked) {
763
- onChange(selectValue(option.value, value, all));
764
- } else {
765
- onChange(deselectValue(option.value, value));
766
- }
739
+ };
767
740
  };
768
741
 
769
- const _onBlur = _ref4 => {
770
- let {
771
- target: {
772
- value
773
- }
774
- } = _ref4;
742
+ var _onBlur = function _onBlur(_ref4) {
743
+ var value = _ref4.target.value;
775
744
  return onBlur(id, value);
776
745
  };
777
746
 
778
- const _onFocus = _ref5 => {
779
- let {
780
- target: {
781
- value
782
- }
783
- } = _ref5;
747
+ var _onFocus = function _onFocus(_ref5) {
748
+ var value = _ref5.target.value;
784
749
  return onFocus(id, value);
785
750
  };
786
751
 
@@ -790,10 +755,10 @@ const CheckboxesWidget = _ref => {
790
755
  }, label || schema.title), /*#__PURE__*/React.createElement(FormGroup, {
791
756
  id: id,
792
757
  row: !!inline
793
- }, Array.isArray(enumOptions) && enumOptions.map((option, index) => {
794
- const checked = value.indexOf(option.value) !== -1;
795
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
796
- const checkbox = /*#__PURE__*/React.createElement(Checkbox, {
758
+ }, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
759
+ var checked = value.indexOf(option.value) !== -1;
760
+ var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
761
+ var checkbox = /*#__PURE__*/React.createElement(Checkbox, {
797
762
  id: id + "-" + option.value,
798
763
  name: id,
799
764
  checked: checked,
@@ -811,84 +776,69 @@ const CheckboxesWidget = _ref => {
811
776
  })));
812
777
  };
813
778
 
814
- const DateWidget = props => {
815
- const {
816
- options,
817
- registry
818
- } = props;
819
- const BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
820
- return /*#__PURE__*/React.createElement(BaseInputTemplate, {
779
+ var DateWidget = function DateWidget(props) {
780
+ var options = props.options,
781
+ registry = props.registry;
782
+ var BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
783
+ return /*#__PURE__*/React.createElement(BaseInputTemplate, _extends({
821
784
  type: "date",
822
785
  InputLabelProps: {
823
786
  shrink: true
824
- },
825
- ...props
826
- });
787
+ }
788
+ }, props));
827
789
  };
828
790
 
829
- const DateTimeWidget = props => {
830
- const {
831
- options,
832
- registry
833
- } = props;
834
- const BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
835
- const value = utcToLocal(props.value);
791
+ var DateTimeWidget = function DateTimeWidget(props) {
792
+ var options = props.options,
793
+ registry = props.registry;
794
+ var BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
795
+ var value = utcToLocal(props.value);
836
796
 
837
- const onChange = value => {
797
+ var onChange = function onChange(value) {
838
798
  props.onChange(localToUTC(value));
839
799
  };
840
800
 
841
- return /*#__PURE__*/React.createElement(BaseInputTemplate, {
801
+ return /*#__PURE__*/React.createElement(BaseInputTemplate, _extends({
842
802
  type: "datetime-local",
843
803
  InputLabelProps: {
844
804
  shrink: true
845
- },
846
- ...props,
805
+ }
806
+ }, props, {
847
807
  value: value,
848
808
  onChange: onChange
849
- });
809
+ }));
850
810
  };
851
811
 
852
- const RadioWidget = _ref => {
853
- let {
854
- id,
855
- schema,
856
- options,
857
- value,
858
- required,
859
- disabled,
860
- readonly,
861
- label,
862
- onChange,
863
- onBlur,
864
- onFocus
865
- } = _ref;
866
- const {
867
- enumOptions,
868
- enumDisabled
869
- } = options;
870
-
871
- const _onChange = (_, value) => onChange(schema.type == "boolean" ? value !== "false" : value);
872
-
873
- const _onBlur = _ref2 => {
874
- let {
875
- target: {
876
- value
877
- }
878
- } = _ref2;
812
+ var RadioWidget = function RadioWidget(_ref) {
813
+ var id = _ref.id,
814
+ schema = _ref.schema,
815
+ options = _ref.options,
816
+ value = _ref.value,
817
+ required = _ref.required,
818
+ disabled = _ref.disabled,
819
+ readonly = _ref.readonly,
820
+ label = _ref.label,
821
+ onChange = _ref.onChange,
822
+ onBlur = _ref.onBlur,
823
+ onFocus = _ref.onFocus;
824
+ var enumOptions = options.enumOptions,
825
+ enumDisabled = options.enumDisabled;
826
+
827
+ var _onChange = function _onChange(_, value) {
828
+ return onChange(schema.type == "boolean" ? value !== "false" : value);
829
+ };
830
+
831
+ var _onBlur = function _onBlur(_ref2) {
832
+ var value = _ref2.target.value;
879
833
  return onBlur(id, value);
880
834
  };
881
835
 
882
- const _onFocus = _ref3 => {
883
- let {
884
- target: {
885
- value
886
- }
887
- } = _ref3;
836
+ var _onFocus = function _onFocus(_ref3) {
837
+ var value = _ref3.target.value;
888
838
  return onFocus(id, value);
889
839
  };
890
840
 
891
- const row = options ? options.inline : false;
841
+ var row = options ? options.inline : false;
892
842
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormLabel, {
893
843
  required: required,
894
844
  htmlFor: id
@@ -900,9 +850,9 @@ const RadioWidget = _ref => {
900
850
  onChange: _onChange,
901
851
  onBlur: _onBlur,
902
852
  onFocus: _onFocus
903
- }, Array.isArray(enumOptions) && enumOptions.map(option => {
904
- const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
905
- const radio = /*#__PURE__*/React.createElement(FormControlLabel, {
853
+ }, Array.isArray(enumOptions) && enumOptions.map(function (option) {
854
+ var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
855
+ var radio = /*#__PURE__*/React.createElement(FormControlLabel, {
906
856
  control: /*#__PURE__*/React.createElement(Radio, {
907
857
  name: id,
908
858
  id: id + "-" + option.value,
@@ -917,110 +867,84 @@ const RadioWidget = _ref => {
917
867
  })));
918
868
  };
919
869
 
920
- const RangeWidget = _ref => {
921
- let {
922
- value,
923
- readonly,
924
- disabled,
925
- onBlur,
926
- onFocus,
927
- options,
928
- schema,
929
- onChange,
930
- required,
931
- label,
932
- id
933
- } = _ref;
934
- const sliderProps = {
935
- value,
936
- label,
937
- id,
938
- name: id,
939
- ...rangeSpec(schema)
940
- };
870
+ var RangeWidget = function RangeWidget(_ref) {
871
+ var value = _ref.value,
872
+ readonly = _ref.readonly,
873
+ disabled = _ref.disabled,
874
+ onBlur = _ref.onBlur,
875
+ onFocus = _ref.onFocus,
876
+ options = _ref.options,
877
+ schema = _ref.schema,
878
+ onChange = _ref.onChange,
879
+ required = _ref.required,
880
+ label = _ref.label,
881
+ id = _ref.id;
882
+
883
+ var sliderProps = _extends({
884
+ value: value,
885
+ label: label,
886
+ id: id,
887
+ name: id
888
+ }, rangeSpec(schema));
941
889
 
942
- const _onChange = (_, value) => {
943
- onChange(value ? options.emptyValue : value);
890
+ var _onChange = function _onChange(_, value) {
891
+ onChange(value ? value : options.emptyValue);
944
892
  };
945
893
 
946
- const _onBlur = _ref2 => {
947
- let {
948
- target: {
949
- value
950
- }
951
- } = _ref2;
894
+ var _onBlur = function _onBlur(_ref2) {
895
+ var value = _ref2.target.value;
952
896
  return onBlur(id, value);
953
897
  };
954
898
 
955
- const _onFocus = _ref3 => {
956
- let {
957
- target: {
958
- value
959
- }
960
- } = _ref3;
899
+ var _onFocus = function _onFocus(_ref3) {
900
+ var value = _ref3.target.value;
961
901
  return onFocus(id, value);
962
902
  };
963
903
 
964
904
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormLabel, {
965
905
  required: required,
966
- id: id
967
- }, label), /*#__PURE__*/React.createElement(Slider, {
906
+ htmlFor: id
907
+ }, label || schema.title), /*#__PURE__*/React.createElement(Slider, _extends({
968
908
  disabled: disabled || readonly,
969
909
  onChange: _onChange,
970
910
  onBlur: _onBlur,
971
911
  onFocus: _onFocus,
972
- valueLabelDisplay: "auto",
973
- ...sliderProps
974
- }));
912
+ valueLabelDisplay: "auto"
913
+ }, sliderProps)));
975
914
  };
976
915
 
977
- const SelectWidget = _ref => {
978
- let {
979
- schema,
980
- id,
981
- options,
982
- label,
983
- required,
984
- disabled,
985
- readonly,
986
- value,
987
- multiple,
988
- autofocus,
989
- onChange,
990
- onBlur,
991
- onFocus,
992
- rawErrors = []
993
- } = _ref;
994
- const {
995
- enumOptions,
996
- enumDisabled
997
- } = options;
998
- const emptyValue = multiple ? [] : "";
999
-
1000
- const _onChange = _ref2 => {
1001
- let {
1002
- target: {
1003
- value
1004
- }
1005
- } = _ref2;
916
+ var SelectWidget = function SelectWidget(_ref) {
917
+ var schema = _ref.schema,
918
+ id = _ref.id,
919
+ options = _ref.options,
920
+ label = _ref.label,
921
+ required = _ref.required,
922
+ disabled = _ref.disabled,
923
+ readonly = _ref.readonly,
924
+ value = _ref.value,
925
+ multiple = _ref.multiple,
926
+ autofocus = _ref.autofocus,
927
+ onChange = _ref.onChange,
928
+ onBlur = _ref.onBlur,
929
+ onFocus = _ref.onFocus,
930
+ _ref$rawErrors = _ref.rawErrors,
931
+ rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors;
932
+ var enumOptions = options.enumOptions,
933
+ enumDisabled = options.enumDisabled;
934
+ var emptyValue = multiple ? [] : "";
935
+
936
+ var _onChange = function _onChange(_ref2) {
937
+ var value = _ref2.target.value;
1006
938
  return onChange(processSelectValue(schema, value, options));
1007
939
  };
1008
940
 
1009
- const _onBlur = _ref3 => {
1010
- let {
1011
- target: {
1012
- value
1013
- }
1014
- } = _ref3;
941
+ var _onBlur = function _onBlur(_ref3) {
942
+ var value = _ref3.target.value;
1015
943
  return onBlur(id, processSelectValue(schema, value, options));
1016
944
  };
1017
945
 
1018
- const _onFocus = _ref4 => {
1019
- let {
1020
- target: {
1021
- value
1022
- }
1023
- } = _ref4;
946
+ var _onFocus = function _onFocus(_ref4) {
947
+ var value = _ref4.target.value;
1024
948
  return onFocus(id, processSelectValue(schema, value, options));
1025
949
  };
1026
950
 
@@ -1043,12 +967,10 @@ const SelectWidget = _ref => {
1043
967
  SelectProps: {
1044
968
  multiple: typeof multiple === "undefined" ? false : multiple
1045
969
  }
1046
- }, enumOptions.map((_ref5, i) => {
1047
- let {
1048
- value,
1049
- label
1050
- } = _ref5;
1051
- const disabled = enumDisabled && enumDisabled.indexOf(value) != -1;
970
+ }, enumOptions.map(function (_ref5, i) {
971
+ var value = _ref5.value,
972
+ label = _ref5.label;
973
+ var disabled = enumDisabled && enumDisabled.indexOf(value) != -1;
1052
974
  return /*#__PURE__*/React.createElement(MenuItem, {
1053
975
  key: i,
1054
976
  value: value,
@@ -1057,41 +979,39 @@ const SelectWidget = _ref => {
1057
979
  }));
1058
980
  };
1059
981
 
1060
- const TextareaWidget = props => {
1061
- const {
1062
- options,
1063
- registry
1064
- } = props;
1065
- const BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
1066
- let rows = 5;
982
+ var TextareaWidget = function TextareaWidget(props) {
983
+ var options = props.options,
984
+ registry = props.registry;
985
+ var BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
986
+ var rows = 5;
1067
987
 
1068
988
  if (typeof options.rows === "string" || typeof options.rows === "number") {
1069
989
  rows = options.rows;
1070
990
  }
1071
991
 
1072
- return /*#__PURE__*/React.createElement(BaseInputTemplate, { ...props,
992
+ return /*#__PURE__*/React.createElement(BaseInputTemplate, _extends({}, props, {
1073
993
  multiline: true,
1074
994
  rows: rows
1075
- });
995
+ }));
1076
996
  };
1077
997
 
1078
998
  var Widgets = {
1079
- CheckboxWidget,
1080
- CheckboxesWidget,
1081
- DateWidget,
1082
- DateTimeWidget,
1083
- RadioWidget,
1084
- RangeWidget,
1085
- SelectWidget,
1086
- TextareaWidget
999
+ CheckboxWidget: CheckboxWidget,
1000
+ CheckboxesWidget: CheckboxesWidget,
1001
+ DateWidget: DateWidget,
1002
+ DateTimeWidget: DateTimeWidget,
1003
+ RadioWidget: RadioWidget,
1004
+ RangeWidget: RangeWidget,
1005
+ SelectWidget: SelectWidget,
1006
+ TextareaWidget: TextareaWidget
1087
1007
  };
1088
1008
 
1089
- const Theme = {
1009
+ var Theme = {
1090
1010
  templates: Templates,
1091
1011
  widgets: Widgets
1092
1012
  };
1093
1013
 
1094
- const MuiForm = /*#__PURE__*/withTheme(Theme);
1014
+ var MuiForm = /*#__PURE__*/withTheme(Theme);
1095
1015
 
1096
1016
  export { MuiForm as Form, Templates, Theme, Widgets, MuiForm as default };
1097
1017
  //# sourceMappingURL=mui.esm.js.map