@rjsf/semantic-ui 5.10.0 → 5.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,54 +6,29 @@ import { nanoid } from 'nanoid';
6
6
  import { createElement } from 'react';
7
7
  import map from 'lodash-es/map';
8
8
 
9
- function _extends() {
10
- _extends = Object.assign ? Object.assign.bind() : function (target) {
11
- for (var i = 1; i < arguments.length; i++) {
12
- var source = arguments[i];
13
- for (var key in source) {
14
- if (Object.prototype.hasOwnProperty.call(source, key)) {
15
- target[key] = source[key];
16
- }
17
- }
18
- }
19
- return target;
20
- };
21
- return _extends.apply(this, arguments);
22
- }
23
- function _objectWithoutPropertiesLoose(source, excluded) {
24
- if (source == null) return {};
25
- var target = {};
26
- var sourceKeys = Object.keys(source);
27
- var key, i;
28
- for (i = 0; i < sourceKeys.length; i++) {
29
- key = sourceKeys[i];
30
- if (excluded.indexOf(key) >= 0) continue;
31
- target[key] = source[key];
32
- }
33
- return target;
34
- }
35
-
36
- var _excluded$4 = ["uiSchema", "registry", "color"];
37
9
  /** The `AddButton` renders a button that represent the `Add` action on a form
38
10
  */
39
- function AddButton(_ref) {
40
- var registry = _ref.registry,
41
- color = _ref.color,
42
- props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
43
- var translateString = registry.translateString;
44
- return jsx(Button, _extends({
11
+ function AddButton({
12
+ uiSchema,
13
+ registry,
14
+ color,
15
+ ...props
16
+ }) {
17
+ const {
18
+ translateString
19
+ } = registry;
20
+ return jsx(Button, {
45
21
  title: translateString(TranslatableString.AddItemButton),
46
- color: color
47
- }, props, {
22
+ color: color,
23
+ ...props,
48
24
  icon: true,
49
25
  size: 'tiny',
50
26
  children: jsx(Icon, {
51
27
  name: 'plus'
52
28
  })
53
- }));
29
+ });
54
30
  }
55
31
 
56
- var _excluded$3 = ["wrap", "component"];
57
32
  /**
58
33
  * Extract props meant for semantic UI components from props that are
59
34
  * passed to Widgets, Templates and Fields.
@@ -65,25 +40,25 @@ var _excluded$3 = ["wrap", "component"];
65
40
  * @param {Object?} params.defaultContextProps
66
41
  * @returns {any}
67
42
  */
68
- function getSemanticProps(_ref) {
69
- var _ref$formContext = _ref.formContext,
70
- formContext = _ref$formContext === void 0 ? {} : _ref$formContext,
71
- _ref$uiSchema = _ref.uiSchema,
72
- uiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
73
- _ref$options = _ref.options,
74
- options = _ref$options === void 0 ? {} : _ref$options,
75
- _ref$defaultSchemaPro = _ref.defaultSchemaProps,
76
- defaultSchemaProps = _ref$defaultSchemaPro === void 0 ? {
77
- fluid: true,
78
- inverted: false
79
- } : _ref$defaultSchemaPro,
80
- _ref$defaultContextPr = _ref.defaultContextProps,
81
- defaultContextProps = _ref$defaultContextPr === void 0 ? {} : _ref$defaultContextPr;
82
- var formContextProps = formContext.semantic;
83
- var schemaProps = getUiOptions(uiSchema).semantic;
84
- var optionProps = options.semantic;
43
+ function getSemanticProps({
44
+ formContext = {},
45
+ uiSchema = {},
46
+ options = {},
47
+ defaultSchemaProps = {
48
+ fluid: true,
49
+ inverted: false
50
+ },
51
+ defaultContextProps = {}
52
+ }) {
53
+ const formContextProps = formContext.semantic;
54
+ const schemaProps = getUiOptions(uiSchema).semantic;
55
+ const optionProps = options.semantic;
85
56
  // formContext props should overide other props
86
- return Object.assign({}, _extends({}, defaultSchemaProps), _extends({}, defaultContextProps), schemaProps, optionProps, formContextProps);
57
+ return Object.assign({}, {
58
+ ...defaultSchemaProps
59
+ }, {
60
+ ...defaultContextProps
61
+ }, schemaProps, optionProps, formContextProps);
87
62
  }
88
63
  /**
89
64
  * Extract error props meant for semantic UI components from props that are
@@ -94,23 +69,22 @@ function getSemanticProps(_ref) {
94
69
  * @param {Object?} params.defaultProps
95
70
  * @returns {any}
96
71
  */
97
- function getSemanticErrorProps(_ref2) {
98
- var _ref2$formContext = _ref2.formContext,
99
- formContext = _ref2$formContext === void 0 ? {} : _ref2$formContext,
100
- _ref2$uiSchema = _ref2.uiSchema,
101
- uiSchema = _ref2$uiSchema === void 0 ? {} : _ref2$uiSchema,
102
- _ref2$options = _ref2.options,
103
- options = _ref2$options === void 0 ? {} : _ref2$options,
104
- _ref2$defaultProps = _ref2.defaultProps,
105
- defaultProps = _ref2$defaultProps === void 0 ? {
106
- size: 'small',
107
- pointing: 'above'
108
- } : _ref2$defaultProps;
109
- var formContextProps = formContext.semantic && formContext.semantic.errorOptions;
110
- var semanticOptions = getUiOptions(uiSchema).semantic;
111
- var schemaProps = semanticOptions && semanticOptions.errorOptions;
112
- var optionProps = options.semantic && options.semantic.errorOptions;
113
- return Object.assign({}, _extends({}, defaultProps), schemaProps, optionProps, formContextProps);
72
+ function getSemanticErrorProps({
73
+ formContext = {},
74
+ uiSchema = {},
75
+ options = {},
76
+ defaultProps = {
77
+ size: 'small',
78
+ pointing: 'above'
79
+ }
80
+ }) {
81
+ const formContextProps = formContext.semantic && formContext.semantic.errorOptions;
82
+ const semanticOptions = getUiOptions(uiSchema).semantic;
83
+ const schemaProps = semanticOptions && semanticOptions.errorOptions;
84
+ const optionProps = options.semantic && options.semantic.errorOptions;
85
+ return Object.assign({}, {
86
+ ...defaultProps
87
+ }, schemaProps, optionProps, formContextProps);
114
88
  }
115
89
  /**
116
90
  * Combine multiple strings containing class names into a single string,
@@ -121,20 +95,13 @@ function getSemanticErrorProps(_ref2) {
121
95
  * @param {Array} omit
122
96
  * @returns {string}
123
97
  */
124
- function cleanClassNames(classNameArr, omit) {
125
- if (omit === void 0) {
126
- omit = [];
127
- }
98
+ function cleanClassNames(classNameArr, omit = []) {
128
99
  // Split each arg on whitespace, and add it to an array. Skip false-y args
129
100
  // like "" and undefined.
130
- var classList = classNameArr.filter(Boolean).reduce(function (previous, current) {
131
- return previous.concat(current.trim().split(/\s+/));
132
- }, []);
101
+ const classList = classNameArr.filter(Boolean).reduce((previous, current) => previous.concat(current.trim().split(/\s+/)), []);
133
102
  // Remove any class names from omit, and make the rest unique before
134
103
  // returning them as a string
135
- return [].concat(new Set(classList.filter(function (cn) {
136
- return !omit.includes(cn);
137
- }))).join(' ');
104
+ return [...new Set(classList.filter(cn => !omit.includes(cn)))].join(' ');
138
105
  }
139
106
  /**
140
107
  *
@@ -144,60 +111,63 @@ function cleanClassNames(classNameArr, omit) {
144
111
  * @returns {*}
145
112
  * @constructor
146
113
  */
147
- function MaybeWrap(_ref3) {
148
- var wrap = _ref3.wrap,
149
- _ref3$component = _ref3.component,
150
- Component = _ref3$component === void 0 ? 'div' : _ref3$component,
151
- props = _objectWithoutPropertiesLoose(_ref3, _excluded$3);
152
- return wrap ? jsx(Component, _extends({}, props)) : props.children;
114
+ function MaybeWrap({
115
+ wrap,
116
+ component: Component = 'div',
117
+ ...props
118
+ }) {
119
+ return wrap ? jsx(Component, {
120
+ ...props
121
+ }) : props.children;
153
122
  }
154
123
 
155
- var gridStyle = function gridStyle(vertical) {
156
- return {
157
- display: 'grid',
158
- gridTemplateColumns: "1fr " + (vertical ? 65 : 150) + "px"
159
- };
160
- };
124
+ const gridStyle = vertical => ({
125
+ display: 'grid',
126
+ gridTemplateColumns: `1fr ${vertical ? 65 : 150}px`
127
+ });
161
128
  /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
162
129
  *
163
130
  * @param props - The `ArrayFieldTemplateItemType` props for the component
164
131
  */
165
132
  function ArrayFieldItemTemplate(props) {
166
- var children = props.children,
167
- disabled = props.disabled,
168
- hasToolbar = props.hasToolbar,
169
- hasCopy = props.hasCopy,
170
- hasMoveDown = props.hasMoveDown,
171
- hasMoveUp = props.hasMoveUp,
172
- hasRemove = props.hasRemove,
173
- index = props.index,
174
- onCopyIndexClick = props.onCopyIndexClick,
175
- onDropIndexClick = props.onDropIndexClick,
176
- onReorderClick = props.onReorderClick,
177
- readonly = props.readonly,
178
- uiSchema = props.uiSchema,
179
- registry = props.registry;
180
- var _registry$templates$B = registry.templates.ButtonTemplates,
181
- CopyButton = _registry$templates$B.CopyButton,
182
- MoveDownButton = _registry$templates$B.MoveDownButton,
183
- MoveUpButton = _registry$templates$B.MoveUpButton,
184
- RemoveButton = _registry$templates$B.RemoveButton;
185
- var uiOptions = getUiOptions(uiSchema);
133
+ const {
134
+ children,
135
+ disabled,
136
+ hasToolbar,
137
+ hasCopy,
138
+ hasMoveDown,
139
+ hasMoveUp,
140
+ hasRemove,
141
+ index,
142
+ onCopyIndexClick,
143
+ onDropIndexClick,
144
+ onReorderClick,
145
+ readonly,
146
+ uiSchema,
147
+ registry
148
+ } = props;
149
+ const {
150
+ CopyButton,
151
+ MoveDownButton,
152
+ MoveUpButton,
153
+ RemoveButton
154
+ } = registry.templates.ButtonTemplates;
155
+ const uiOptions = getUiOptions(uiSchema);
186
156
  // Pull the semantic props out of the uiOptions that were put in via the ArrayFieldTemplate
187
- var _uiOptions$semantic = uiOptions.semantic,
188
- _uiOptions$semantic$h = _uiOptions$semantic.horizontalButtons,
189
- horizontalButtons = _uiOptions$semantic$h === void 0 ? true : _uiOptions$semantic$h,
190
- _uiOptions$semantic$w = _uiOptions$semantic.wrapItem,
191
- wrapItem = _uiOptions$semantic$w === void 0 ? false : _uiOptions$semantic$w;
157
+ const {
158
+ horizontalButtons = true,
159
+ wrapItem = false
160
+ } = uiOptions.semantic;
192
161
  return jsx("div", {
193
162
  className: 'array-item',
194
163
  children: jsx(MaybeWrap, {
195
164
  wrap: wrapItem,
196
165
  component: Segment,
197
166
  children: jsxs(Grid, {
198
- style: _extends({}, gridStyle(!horizontalButtons), {
167
+ style: {
168
+ ...gridStyle(!horizontalButtons),
199
169
  alignItems: 'center'
200
- }),
170
+ },
201
171
  children: [jsx(Grid.Column, {
202
172
  width: 16,
203
173
  verticalAlign: 'middle',
@@ -238,45 +208,54 @@ function ArrayFieldItemTemplate(props) {
238
208
  });
239
209
  }
240
210
 
241
- var _excluded$2 = ["key", "uiSchema"];
242
211
  /** The `ArrayFieldTemplate` component is the template used to render all items in an array.
243
212
  *
244
213
  * @param props - The `ArrayFieldTemplateItemType` props for the component
245
214
  */
246
215
  function ArrayFieldTemplate(props) {
247
- var uiSchema = props.uiSchema,
248
- idSchema = props.idSchema,
249
- canAdd = props.canAdd,
250
- className = props.className,
251
- disabled = props.disabled,
252
- formContext = props.formContext,
253
- items = props.items,
254
- onAddClick = props.onAddClick,
255
- readonly = props.readonly,
256
- required = props.required,
257
- schema = props.schema,
258
- title = props.title,
259
- registry = props.registry;
260
- var semanticProps = getSemanticProps({
261
- uiSchema: uiSchema,
262
- formContext: formContext,
216
+ const {
217
+ uiSchema,
218
+ idSchema,
219
+ canAdd,
220
+ className,
221
+ // classNames, This is not part of the type, so it is likely never passed in
222
+ disabled,
223
+ formContext,
224
+ items,
225
+ onAddClick,
226
+ // options, This is not part of the type, so it is likely never passed in
227
+ readonly,
228
+ required,
229
+ schema,
230
+ title,
231
+ registry
232
+ } = props;
233
+ const semanticProps = getSemanticProps({
234
+ uiSchema,
235
+ formContext,
263
236
  defaultSchemaProps: {
264
237
  horizontalButtons: true,
265
238
  wrapItem: false
266
239
  }
267
240
  });
268
- var horizontalButtons = semanticProps.horizontalButtons,
269
- wrapItem = semanticProps.wrapItem;
270
- var semantic = {
271
- horizontalButtons: horizontalButtons,
272
- wrapItem: wrapItem
241
+ const {
242
+ horizontalButtons,
243
+ wrapItem
244
+ } = semanticProps;
245
+ const semantic = {
246
+ horizontalButtons,
247
+ wrapItem
273
248
  };
274
- var uiOptions = getUiOptions(uiSchema);
275
- var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
276
- var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
277
- var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
249
+ const uiOptions = getUiOptions(uiSchema);
250
+ const ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
251
+ const ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
252
+ const ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
278
253
  // Button templates are not overridden in the uiSchema
279
- var AddButton = registry.templates.ButtonTemplates.AddButton;
254
+ const {
255
+ ButtonTemplates: {
256
+ AddButton
257
+ }
258
+ } = registry.templates;
280
259
  return jsxs("div", {
281
260
  className: cleanClassNames([className, isFixedItems(schema) ? '' : 'sortable-form-fields']),
282
261
  children: [jsx(ArrayFieldTitleTemplate, {
@@ -295,19 +274,23 @@ function ArrayFieldTemplate(props) {
295
274
  }), jsxs("div", {
296
275
  children: [jsx("div", {
297
276
  className: 'row array-item-list',
298
- children: items && items.map(function (_ref) {
299
- var _extends2;
300
- var key = _ref.key,
301
- _ref$uiSchema = _ref.uiSchema,
302
- itemUiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
303
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
277
+ children: items && items.map(({
278
+ key,
279
+ uiSchema: itemUiSchema = {},
280
+ ...props
281
+ }) => {
304
282
  // Merge in the semantic props from the ArrayFieldTemplate into each of the items
305
- var mergedUiSchema = _extends({}, itemUiSchema, (_extends2 = {}, _extends2[UI_OPTIONS_KEY] = _extends({}, itemUiSchema[UI_OPTIONS_KEY], {
306
- semantic: semantic
307
- }), _extends2));
308
- return jsx(ArrayFieldItemTemplate, _extends({}, props, {
283
+ const mergedUiSchema = {
284
+ ...itemUiSchema,
285
+ [UI_OPTIONS_KEY]: {
286
+ ...itemUiSchema[UI_OPTIONS_KEY],
287
+ semantic
288
+ }
289
+ };
290
+ return jsx(ArrayFieldItemTemplate, {
291
+ ...props,
309
292
  uiSchema: mergedUiSchema
310
- }), key);
293
+ }, key);
311
294
  })
312
295
  }), canAdd && jsx("div", {
313
296
  style: {
@@ -322,7 +305,7 @@ function ArrayFieldTemplate(props) {
322
305
  registry: registry
323
306
  })
324
307
  })]
325
- }, "array-item-list-" + idSchema.$id)]
308
+ }, `array-item-list-${idSchema.$id}`)]
326
309
  });
327
310
  }
328
311
 
@@ -333,63 +316,61 @@ function ArrayFieldTemplate(props) {
333
316
  * @param props - The `WidgetProps` for this template
334
317
  */
335
318
  function BaseInputTemplate(props) {
336
- var id = props.id,
337
- placeholder = props.placeholder,
338
- label = props.label,
339
- hideLabel = props.hideLabel,
340
- value = props.value,
341
- required = props.required,
342
- readonly = props.readonly,
343
- disabled = props.disabled,
344
- onChange = props.onChange,
345
- onChangeOverride = props.onChangeOverride,
346
- onBlur = props.onBlur,
347
- onFocus = props.onFocus,
348
- autofocus = props.autofocus,
349
- options = props.options,
350
- schema = props.schema,
351
- uiSchema = props.uiSchema,
352
- formContext = props.formContext,
353
- type = props.type,
354
- _props$rawErrors = props.rawErrors,
355
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
356
- var inputProps = getInputProps(schema, type, options);
357
- var semanticProps = getSemanticProps({
358
- uiSchema: uiSchema,
359
- formContext: formContext,
360
- options: options
319
+ const {
320
+ id,
321
+ placeholder,
322
+ label,
323
+ hideLabel,
324
+ value,
325
+ required,
326
+ readonly,
327
+ disabled,
328
+ onChange,
329
+ onChangeOverride,
330
+ onBlur,
331
+ onFocus,
332
+ autofocus,
333
+ options,
334
+ schema,
335
+ uiSchema,
336
+ formContext,
337
+ type,
338
+ rawErrors = []
339
+ } = props;
340
+ const inputProps = getInputProps(schema, type, options);
341
+ const semanticProps = getSemanticProps({
342
+ uiSchema,
343
+ formContext,
344
+ options
361
345
  });
362
- var _onChange = function _onChange(_ref) {
363
- var value = _ref.target.value;
364
- return onChange(value === '' ? options.emptyValue : value);
365
- };
366
- var _onBlur = function _onBlur() {
367
- return onBlur && onBlur(id, value);
368
- };
369
- var _onFocus = function _onFocus() {
370
- return onFocus && onFocus(id, value);
371
- };
346
+ const _onChange = ({
347
+ target: {
348
+ value
349
+ }
350
+ }) => onChange(value === '' ? options.emptyValue : value);
351
+ const _onBlur = () => onBlur && onBlur(id, value);
352
+ const _onFocus = () => onFocus && onFocus(id, value);
372
353
  return jsxs(Fragment, {
373
- children: [jsx(Form.Input, _extends({
354
+ children: [jsx(Form.Input, {
374
355
  id: id,
375
356
  name: id,
376
- placeholder: placeholder
377
- }, inputProps, {
357
+ placeholder: placeholder,
358
+ ...inputProps,
378
359
  label: labelValue(label || undefined, hideLabel, false),
379
360
  required: required,
380
361
  autoFocus: autofocus,
381
362
  disabled: disabled || readonly,
382
- list: schema.examples ? examplesId(id) : undefined
383
- }, semanticProps, {
363
+ list: schema.examples ? examplesId(id) : undefined,
364
+ ...semanticProps,
384
365
  value: value || value === 0 ? value : '',
385
366
  error: rawErrors.length > 0,
386
367
  onChange: onChangeOverride || _onChange,
387
368
  onBlur: _onBlur,
388
369
  onFocus: _onFocus,
389
370
  "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
390
- }), id), Array.isArray(schema.examples) && jsx("datalist", {
371
+ }, id), Array.isArray(schema.examples) && jsx("datalist", {
391
372
  id: examplesId(id),
392
- children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
373
+ children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map(example => {
393
374
  return jsx("option", {
394
375
  value: example
395
376
  }, example);
@@ -403,8 +384,10 @@ function BaseInputTemplate(props) {
403
384
  * @param props - The `DescriptionFieldProps` for this component
404
385
  */
405
386
  function DescriptionField(props) {
406
- var id = props.id,
407
- description = props.description;
387
+ const {
388
+ id,
389
+ description
390
+ } = props;
408
391
  if (!description) {
409
392
  return null;
410
393
  }
@@ -419,72 +402,93 @@ function DescriptionField(props) {
419
402
  *
420
403
  * @param props - The `ErrorListProps` for this component
421
404
  */
422
- function ErrorList(_ref) {
423
- var errors = _ref.errors,
424
- registry = _ref.registry;
425
- var translateString = registry.translateString;
405
+ function ErrorList({
406
+ errors,
407
+ registry
408
+ }) {
409
+ const {
410
+ translateString
411
+ } = registry;
426
412
  return jsxs(Message, {
427
413
  negative: true,
428
414
  children: [jsx(Message.Header, {
429
415
  children: translateString(TranslatableString.ErrorsLabel)
430
416
  }), jsx(Message.List, {
431
- children: errors.map(function (error, index) {
432
- return jsx(Message.Item, {
433
- children: error.stack
434
- }, "error-" + index);
435
- })
417
+ children: errors.map((error, index) => jsx(Message.Item, {
418
+ children: error.stack
419
+ }, `error-${index}`))
436
420
  })]
437
421
  });
438
422
  }
439
423
 
440
- var _excluded$1 = ["icon", "iconType", "color", "className", "uiSchema", "registry"];
441
424
  function IconButton(props) {
442
- var icon = props.icon,
443
- iconType = props.iconType,
444
- color = props.color,
445
- className = props.className,
446
- otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
447
- return jsx(Button, _extends({
425
+ const {
426
+ icon,
427
+ iconType,
428
+ color,
429
+ className,
430
+ uiSchema,
431
+ registry,
432
+ ...otherProps
433
+ } = props;
434
+ return jsx(Button, {
448
435
  icon: icon,
449
436
  size: iconType,
450
437
  color: color,
451
- className: className
452
- }, otherProps));
438
+ className: className,
439
+ ...otherProps
440
+ });
453
441
  }
454
442
  function CopyButton(props) {
455
- var translateString = props.registry.translateString;
456
- return jsx(IconButton, _extends({
457
- title: translateString(TranslatableString.CopyButton)
458
- }, props, {
443
+ const {
444
+ registry: {
445
+ translateString
446
+ }
447
+ } = props;
448
+ return jsx(IconButton, {
449
+ title: translateString(TranslatableString.CopyButton),
450
+ ...props,
459
451
  icon: 'copy'
460
- }));
452
+ });
461
453
  }
462
454
  function MoveDownButton(props) {
463
- var translateString = props.registry.translateString;
464
- return jsx(IconButton, _extends({
465
- title: translateString(TranslatableString.MoveDownButton)
466
- }, props, {
455
+ const {
456
+ registry: {
457
+ translateString
458
+ }
459
+ } = props;
460
+ return jsx(IconButton, {
461
+ title: translateString(TranslatableString.MoveDownButton),
462
+ ...props,
467
463
  icon: 'angle down'
468
- }));
464
+ });
469
465
  }
470
466
  function MoveUpButton(props) {
471
- var translateString = props.registry.translateString;
472
- return jsx(IconButton, _extends({
473
- title: translateString(TranslatableString.MoveUpButton)
474
- }, props, {
467
+ const {
468
+ registry: {
469
+ translateString
470
+ }
471
+ } = props;
472
+ return jsx(IconButton, {
473
+ title: translateString(TranslatableString.MoveUpButton),
474
+ ...props,
475
475
  icon: 'angle up'
476
- }));
476
+ });
477
477
  }
478
478
  function RemoveButton(props) {
479
- var translateString = props.registry.translateString;
480
- return jsx(IconButton, _extends({
481
- title: translateString(TranslatableString.RemoveButton)
482
- }, props, {
479
+ const {
480
+ registry: {
481
+ translateString
482
+ }
483
+ } = props;
484
+ return jsx(IconButton, {
485
+ title: translateString(TranslatableString.RemoveButton),
486
+ ...props,
483
487
  icon: 'trash'
484
- }));
488
+ });
485
489
  }
486
490
 
487
- var DEFAULT_OPTIONS$1 = {
491
+ const DEFAULT_OPTIONS$1 = {
488
492
  options: {
489
493
  pointing: 'above',
490
494
  size: 'small'
@@ -494,21 +498,26 @@ var DEFAULT_OPTIONS$1 = {
494
498
  *
495
499
  * @param props - The `FieldErrorProps` for the errors being rendered
496
500
  */
497
- function FieldErrorTemplate(_ref) {
498
- var errors = _ref.errors,
499
- idSchema = _ref.idSchema,
500
- uiSchema = _ref.uiSchema,
501
- registry = _ref.registry;
502
- var formContext = registry.formContext;
503
- var options = getSemanticErrorProps({
504
- formContext: formContext,
505
- uiSchema: uiSchema,
501
+ function FieldErrorTemplate({
502
+ errors,
503
+ idSchema,
504
+ uiSchema,
505
+ registry
506
+ }) {
507
+ const {
508
+ formContext
509
+ } = registry;
510
+ const options = getSemanticErrorProps({
511
+ formContext,
512
+ uiSchema,
506
513
  defaultProps: DEFAULT_OPTIONS$1
507
514
  });
508
- var pointing = options.pointing,
509
- size = options.size;
515
+ const {
516
+ pointing,
517
+ size
518
+ } = options;
510
519
  if (errors && errors.length > 0) {
511
- var id = errorId(idSchema);
520
+ const id = errorId(idSchema);
512
521
  return jsx(Label, {
513
522
  id: id,
514
523
  color: 'red',
@@ -517,11 +526,9 @@ function FieldErrorTemplate(_ref) {
517
526
  basic: true,
518
527
  children: jsx(List, {
519
528
  bulleted: true,
520
- children: errors.map(function (error) {
521
- return jsx(List.Item, {
522
- children: error
523
- }, nanoid());
524
- })
529
+ children: errors.map(error => jsx(List.Item, {
530
+ children: error
531
+ }, nanoid()))
525
532
  })
526
533
  });
527
534
  }
@@ -533,10 +540,12 @@ function FieldErrorTemplate(_ref) {
533
540
  * @param props - The `FieldHelpProps` to be rendered
534
541
  */
535
542
  function FieldHelpTemplate(props) {
536
- var idSchema = props.idSchema,
537
- help = props.help;
543
+ const {
544
+ idSchema,
545
+ help
546
+ } = props;
538
547
  if (help) {
539
- var id = helpId(idSchema);
548
+ const id = helpId(idSchema);
540
549
  return jsx(Message, {
541
550
  size: 'mini',
542
551
  info: true,
@@ -547,33 +556,36 @@ function FieldHelpTemplate(props) {
547
556
  return null;
548
557
  }
549
558
 
550
- var _excluded = ["id", "children", "classNames", "style", "displayLabel", "label", "errors", "help", "hidden", "description", "rawDescription", "registry", "schema", "uiSchema"];
551
559
  /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
552
560
  * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
553
561
  *
554
562
  * @param props - The `FieldTemplateProps` for this component
555
563
  */
556
564
  function FieldTemplate(props) {
557
- var id = props.id,
558
- children = props.children,
559
- classNames = props.classNames,
560
- style = props.style,
561
- displayLabel = props.displayLabel,
562
- label = props.label,
563
- errors = props.errors,
564
- help = props.help,
565
- hidden = props.hidden,
566
- description = props.description,
567
- rawDescription = props.rawDescription,
568
- registry = props.registry,
569
- schema = props.schema,
570
- uiSchema = props.uiSchema,
571
- otherProps = _objectWithoutPropertiesLoose(props, _excluded);
572
- var semanticProps = getSemanticProps(otherProps);
573
- var wrapLabel = semanticProps.wrapLabel,
574
- wrapContent = semanticProps.wrapContent;
575
- var uiOptions = getUiOptions(uiSchema);
576
- var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
565
+ const {
566
+ id,
567
+ children,
568
+ classNames,
569
+ style,
570
+ displayLabel,
571
+ label,
572
+ errors,
573
+ help,
574
+ hidden,
575
+ description,
576
+ rawDescription,
577
+ registry,
578
+ schema,
579
+ uiSchema,
580
+ ...otherProps
581
+ } = props;
582
+ const semanticProps = getSemanticProps(otherProps);
583
+ const {
584
+ wrapLabel,
585
+ wrapContent
586
+ } = semanticProps;
587
+ const uiOptions = getUiOptions(uiSchema);
588
+ const WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
577
589
  if (hidden) {
578
590
  return jsx("div", {
579
591
  style: {
@@ -582,15 +594,15 @@ function FieldTemplate(props) {
582
594
  children: children
583
595
  });
584
596
  }
585
- return jsx(WrapIfAdditionalTemplate, _extends({
597
+ return jsx(WrapIfAdditionalTemplate, {
586
598
  classNames: classNames,
587
599
  style: style,
588
600
  id: id,
589
601
  label: label,
590
602
  registry: registry,
591
603
  schema: schema,
592
- uiSchema: uiSchema
593
- }, otherProps, {
604
+ uiSchema: uiSchema,
605
+ ...otherProps,
594
606
  children: jsx(Form.Group, {
595
607
  widths: 'equal',
596
608
  grouped: true,
@@ -604,7 +616,7 @@ function FieldTemplate(props) {
604
616
  }), help, errors]
605
617
  })
606
618
  }, id)
607
- }));
619
+ });
608
620
  }
609
621
 
610
622
  /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
@@ -614,23 +626,29 @@ function FieldTemplate(props) {
614
626
  * @param props - The `ObjectFieldTemplateProps` for this component
615
627
  */
616
628
  function ObjectFieldTemplate(props) {
617
- var description = props.description,
618
- onAddClick = props.onAddClick,
619
- title = props.title,
620
- properties = props.properties,
621
- disabled = props.disabled,
622
- readonly = props.readonly,
623
- required = props.required,
624
- uiSchema = props.uiSchema,
625
- schema = props.schema,
626
- formData = props.formData,
627
- idSchema = props.idSchema,
628
- registry = props.registry;
629
- var uiOptions = getUiOptions(uiSchema);
630
- var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
631
- var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
629
+ const {
630
+ description,
631
+ onAddClick,
632
+ title,
633
+ properties,
634
+ disabled,
635
+ readonly,
636
+ required,
637
+ uiSchema,
638
+ schema,
639
+ formData,
640
+ idSchema,
641
+ registry
642
+ } = props;
643
+ const uiOptions = getUiOptions(uiSchema);
644
+ const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
645
+ const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
632
646
  // Button templates are not overridden in the uiSchema
633
- var AddButton = registry.templates.ButtonTemplates.AddButton;
647
+ const {
648
+ ButtonTemplates: {
649
+ AddButton
650
+ }
651
+ } = registry.templates;
634
652
  return jsxs(Fragment, {
635
653
  children: [title && jsx(TitleFieldTemplate, {
636
654
  id: titleId(idSchema),
@@ -645,9 +663,7 @@ function ObjectFieldTemplate(props) {
645
663
  schema: schema,
646
664
  uiSchema: uiSchema,
647
665
  registry: registry
648
- }), properties.map(function (prop) {
649
- return prop.content;
650
- }), canExpand(schema, uiSchema, formData) && jsx(Grid.Column, {
666
+ }), properties.map(prop => prop.content), canExpand(schema, uiSchema, formData) && jsx(Grid.Column, {
651
667
  width: 16,
652
668
  verticalAlign: 'middle',
653
669
  children: jsx(Grid.Row, {
@@ -671,25 +687,26 @@ function ObjectFieldTemplate(props) {
671
687
 
672
688
  /** The `SubmitButton` renders a button that represent the `Submit` action on a form
673
689
  */
674
- function SubmitButton(_ref) {
675
- var uiSchema = _ref.uiSchema;
676
- var _getSubmitButtonOptio = getSubmitButtonOptions(uiSchema),
677
- submitText = _getSubmitButtonOptio.submitText,
678
- norender = _getSubmitButtonOptio.norender,
679
- _getSubmitButtonOptio2 = _getSubmitButtonOptio.props,
680
- submitButtonProps = _getSubmitButtonOptio2 === void 0 ? {} : _getSubmitButtonOptio2;
690
+ function SubmitButton({
691
+ uiSchema
692
+ }) {
693
+ const {
694
+ submitText,
695
+ norender,
696
+ props: submitButtonProps = {}
697
+ } = getSubmitButtonOptions(uiSchema);
681
698
  if (norender) {
682
699
  return null;
683
700
  }
684
- return jsx(Button, _extends({
701
+ return jsx(Button, {
685
702
  type: 'submit',
686
- primary: true
687
- }, submitButtonProps, {
703
+ primary: true,
704
+ ...submitButtonProps,
688
705
  children: submitText
689
- }));
706
+ });
690
707
  }
691
708
 
692
- var DEFAULT_OPTIONS = {
709
+ const DEFAULT_OPTIONS = {
693
710
  inverted: false,
694
711
  dividing: true
695
712
  };
@@ -697,23 +714,24 @@ var DEFAULT_OPTIONS = {
697
714
  *
698
715
  * @param props - The `TitleFieldProps` for this component
699
716
  */
700
- function TitleField(_ref) {
701
- var id = _ref.id,
702
- title = _ref.title,
703
- uiSchema = _ref.uiSchema;
704
- var semanticProps = getSemanticProps({
705
- uiSchema: uiSchema,
717
+ function TitleField({
718
+ id,
719
+ title,
720
+ uiSchema
721
+ }) {
722
+ const semanticProps = getSemanticProps({
723
+ uiSchema,
706
724
  defaultSchemaProps: DEFAULT_OPTIONS
707
725
  });
708
726
  if (!title) {
709
727
  return null;
710
728
  }
711
- return jsx(Header, _extends({
712
- id: id
713
- }, semanticProps, {
729
+ return jsx(Header, {
730
+ id: id,
731
+ ...semanticProps,
714
732
  as: 'h5',
715
733
  children: title
716
- }));
734
+ });
717
735
  }
718
736
 
719
737
  /** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
@@ -722,29 +740,35 @@ function TitleField(_ref) {
722
740
  * @param props - The `WrapIfAdditionalProps` for this component
723
741
  */
724
742
  function WrapIfAdditionalTemplate(props) {
725
- var children = props.children,
726
- classNames = props.classNames,
727
- style = props.style,
728
- disabled = props.disabled,
729
- id = props.id,
730
- label = props.label,
731
- onDropPropertyClick = props.onDropPropertyClick,
732
- onKeyChange = props.onKeyChange,
733
- readonly = props.readonly,
734
- required = props.required,
735
- schema = props.schema,
736
- uiSchema = props.uiSchema,
737
- registry = props.registry;
738
- var templates = registry.templates,
739
- translateString = registry.translateString;
743
+ const {
744
+ children,
745
+ classNames,
746
+ style,
747
+ disabled,
748
+ id,
749
+ label,
750
+ onDropPropertyClick,
751
+ onKeyChange,
752
+ readonly,
753
+ required,
754
+ schema,
755
+ uiSchema,
756
+ registry
757
+ } = props;
758
+ const {
759
+ templates,
760
+ translateString
761
+ } = registry;
740
762
  // Button templates are not overridden in the uiSchema
741
- var RemoveButton = templates.ButtonTemplates.RemoveButton;
742
- var keyLabel = translateString(TranslatableString.KeyLabel, [label]);
743
- var _registry$formContext = registry.formContext,
744
- _registry$formContext2 = _registry$formContext.readonlyAsDisabled,
745
- readonlyAsDisabled = _registry$formContext2 === void 0 ? true : _registry$formContext2,
746
- wrapperStyle = _registry$formContext.wrapperStyle;
747
- var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
763
+ const {
764
+ RemoveButton
765
+ } = templates.ButtonTemplates;
766
+ const keyLabel = translateString(TranslatableString.KeyLabel, [label]);
767
+ const {
768
+ readonlyAsDisabled = true,
769
+ wrapperStyle
770
+ } = registry.formContext;
771
+ const additional = (ADDITIONAL_PROPERTY_FLAG in schema);
748
772
  if (!additional) {
749
773
  return jsx("div", {
750
774
  className: classNames,
@@ -752,10 +776,9 @@ function WrapIfAdditionalTemplate(props) {
752
776
  children: children
753
777
  });
754
778
  }
755
- var handleBlur = function handleBlur(_ref) {
756
- var target = _ref.target;
757
- return onKeyChange(target.value);
758
- };
779
+ const handleBlur = ({
780
+ target
781
+ }) => onKeyChange(target.value);
759
782
  return jsx("div", {
760
783
  className: classNames,
761
784
  style: style,
@@ -771,13 +794,13 @@ function WrapIfAdditionalTemplate(props) {
771
794
  className: 'form-group',
772
795
  hasFeedback: true,
773
796
  fluid: true,
774
- htmlFor: "" + id,
797
+ htmlFor: `${id}`,
775
798
  label: keyLabel,
776
799
  required: required,
777
800
  defaultValue: label,
778
801
  disabled: disabled || readonlyAsDisabled && readonly,
779
- id: "" + id,
780
- name: "" + id,
802
+ id: `${id}`,
803
+ name: `${id}`,
781
804
  onBlur: !readonly ? handleBlur : undefined,
782
805
  style: wrapperStyle,
783
806
  type: 'text'
@@ -799,30 +822,30 @@ function WrapIfAdditionalTemplate(props) {
799
822
  })]
800
823
  })
801
824
  })
802
- }, id + "-key");
825
+ }, `${id}-key`);
803
826
  }
804
827
 
805
828
  function generateTemplates() {
806
829
  return {
807
- ArrayFieldItemTemplate: ArrayFieldItemTemplate,
808
- ArrayFieldTemplate: ArrayFieldTemplate,
809
- BaseInputTemplate: BaseInputTemplate,
830
+ ArrayFieldItemTemplate,
831
+ ArrayFieldTemplate,
832
+ BaseInputTemplate,
810
833
  ButtonTemplates: {
811
- AddButton: AddButton,
812
- CopyButton: CopyButton,
813
- MoveDownButton: MoveDownButton,
814
- MoveUpButton: MoveUpButton,
815
- RemoveButton: RemoveButton,
816
- SubmitButton: SubmitButton
834
+ AddButton,
835
+ CopyButton,
836
+ MoveDownButton,
837
+ MoveUpButton,
838
+ RemoveButton,
839
+ SubmitButton
817
840
  },
818
841
  DescriptionFieldTemplate: DescriptionField,
819
842
  ErrorListTemplate: ErrorList,
820
- FieldErrorTemplate: FieldErrorTemplate,
821
- FieldHelpTemplate: FieldHelpTemplate,
822
- FieldTemplate: FieldTemplate,
823
- ObjectFieldTemplate: ObjectFieldTemplate,
843
+ FieldErrorTemplate,
844
+ FieldHelpTemplate,
845
+ FieldTemplate,
846
+ ObjectFieldTemplate,
824
847
  TitleFieldTemplate: TitleField,
825
- WrapIfAdditionalTemplate: WrapIfAdditionalTemplate
848
+ WrapIfAdditionalTemplate
826
849
  };
827
850
  }
828
851
  var Templates = /*#__PURE__*/generateTemplates();
@@ -833,49 +856,42 @@ var Templates = /*#__PURE__*/generateTemplates();
833
856
  * @param props - The `WidgetProps` for this component
834
857
  */
835
858
  function CheckboxWidget(props) {
836
- var _options$description;
837
- var id = props.id,
838
- value = props.value,
839
- disabled = props.disabled,
840
- readonly = props.readonly,
841
- _props$label = props.label,
842
- label = _props$label === void 0 ? '' : _props$label,
843
- hideLabel = props.hideLabel,
844
- autofocus = props.autofocus,
845
- onChange = props.onChange,
846
- onBlur = props.onBlur,
847
- options = props.options,
848
- onFocus = props.onFocus,
849
- formContext = props.formContext,
850
- schema = props.schema,
851
- uiSchema = props.uiSchema,
852
- _props$rawErrors = props.rawErrors,
853
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
854
- registry = props.registry;
855
- var semanticProps = getSemanticProps({
856
- options: options,
857
- formContext: formContext,
858
- uiSchema: uiSchema,
859
+ const {
860
+ id,
861
+ value,
862
+ disabled,
863
+ readonly,
864
+ label = '',
865
+ hideLabel,
866
+ autofocus,
867
+ onChange,
868
+ onBlur,
869
+ options,
870
+ onFocus,
871
+ formContext,
872
+ schema,
873
+ uiSchema,
874
+ rawErrors = [],
875
+ registry
876
+ } = props;
877
+ const semanticProps = getSemanticProps({
878
+ options,
879
+ formContext,
880
+ uiSchema,
859
881
  defaultSchemaProps: {
860
882
  inverted: 'false'
861
883
  }
862
884
  });
863
- var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
885
+ const DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, options);
864
886
  // Because an unchecked checkbox will cause html5 validation to fail, only add
865
887
  // the "required" attribute if the field value must be "true", due to the
866
888
  // "const" or "enum" keywords
867
- var required = schemaRequiresTrueValue(schema);
868
- var _onChange = function _onChange(_, data) {
869
- return onChange && onChange(data.checked);
870
- };
871
- var _onBlur = function _onBlur() {
872
- return onBlur && onBlur(id, value);
873
- };
874
- var _onFocus = function _onFocus() {
875
- return onFocus && onFocus(id, value);
876
- };
877
- var checked = value == 'true' || value == true;
878
- var description = (_options$description = options.description) != null ? _options$description : schema.description;
889
+ const required = schemaRequiresTrueValue(schema);
890
+ const _onChange = (_, data) => onChange && onChange(data.checked);
891
+ const _onBlur = () => onBlur && onBlur(id, value);
892
+ const _onFocus = () => onFocus && onFocus(id, value);
893
+ const checked = value == 'true' || value == true;
894
+ const description = options.description ?? schema.description;
879
895
  return jsxs(Fragment, {
880
896
  children: [!hideLabel && !!description && jsx(DescriptionFieldTemplate, {
881
897
  id: descriptionId(id),
@@ -883,12 +899,12 @@ function CheckboxWidget(props) {
883
899
  schema: schema,
884
900
  uiSchema: uiSchema,
885
901
  registry: registry
886
- }), jsx(Form.Checkbox, _extends({
902
+ }), jsx(Form.Checkbox, {
887
903
  id: id,
888
904
  name: id,
889
905
  disabled: disabled || readonly,
890
- autoFocus: autofocus
891
- }, semanticProps, {
906
+ autoFocus: autofocus,
907
+ ...semanticProps,
892
908
  checked: typeof value === 'undefined' ? false : checked,
893
909
  error: rawErrors.length > 0,
894
910
  onChange: _onChange,
@@ -897,7 +913,7 @@ function CheckboxWidget(props) {
897
913
  required: required,
898
914
  label: labelValue(label, hideLabel, false),
899
915
  "aria-describedby": ariaDescribedByIds(id)
900
- }))]
916
+ })]
901
917
  });
902
918
  }
903
919
 
@@ -907,54 +923,54 @@ function CheckboxWidget(props) {
907
923
  * @param props - The `WidgetProps` for this component
908
924
  */
909
925
  function CheckboxesWidget(props) {
910
- var id = props.id,
911
- disabled = props.disabled,
912
- options = props.options,
913
- value = props.value,
914
- autofocus = props.autofocus,
915
- readonly = props.readonly,
916
- label = props.label,
917
- hideLabel = props.hideLabel,
918
- onChange = props.onChange,
919
- onBlur = props.onBlur,
920
- onFocus = props.onFocus,
921
- formContext = props.formContext,
922
- schema = props.schema,
923
- uiSchema = props.uiSchema,
924
- _props$rawErrors = props.rawErrors,
925
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
926
- registry = props.registry;
927
- var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
928
- var enumOptions = options.enumOptions,
929
- enumDisabled = options.enumDisabled,
930
- inline = options.inline;
931
- var checkboxesValues = Array.isArray(value) ? value : [value];
932
- var semanticProps = getSemanticProps({
933
- options: options,
934
- formContext: formContext,
935
- uiSchema: uiSchema,
926
+ const {
927
+ id,
928
+ disabled,
929
+ options,
930
+ value,
931
+ autofocus,
932
+ readonly,
933
+ label,
934
+ hideLabel,
935
+ onChange,
936
+ onBlur,
937
+ onFocus,
938
+ formContext,
939
+ schema,
940
+ uiSchema,
941
+ rawErrors = [],
942
+ registry
943
+ } = props;
944
+ const TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
945
+ const {
946
+ enumOptions,
947
+ enumDisabled,
948
+ inline
949
+ } = options;
950
+ const checkboxesValues = Array.isArray(value) ? value : [value];
951
+ const semanticProps = getSemanticProps({
952
+ options,
953
+ formContext,
954
+ uiSchema,
936
955
  defaultSchemaProps: {
937
956
  inverted: 'false'
938
957
  }
939
958
  });
940
- var _onChange = function _onChange(index) {
941
- return function (_ref) {
942
- var checked = _ref.target.checked;
943
- // eslint-disable-next-line no-shadow
944
- if (checked) {
945
- onChange(enumOptionsSelectValue(index, checkboxesValues, enumOptions));
946
- } else {
947
- onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
948
- }
949
- };
950
- };
951
- var _onBlur = function _onBlur() {
952
- return onBlur(id, value);
953
- };
954
- var _onFocus = function _onFocus() {
955
- return onFocus(id, value);
959
+ const _onChange = index => ({
960
+ target: {
961
+ checked
962
+ }
963
+ }) => {
964
+ // eslint-disable-next-line no-shadow
965
+ if (checked) {
966
+ onChange(enumOptionsSelectValue(index, checkboxesValues, enumOptions));
967
+ } else {
968
+ onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
969
+ }
956
970
  };
957
- var inlineOption = inline ? {
971
+ const _onBlur = () => onBlur(id, value);
972
+ const _onFocus = () => onFocus(id, value);
973
+ const inlineOption = inline ? {
958
974
  inline: true
959
975
  } : {
960
976
  grouped: true
@@ -966,18 +982,18 @@ function CheckboxesWidget(props) {
966
982
  schema: schema,
967
983
  uiSchema: uiSchema,
968
984
  registry: registry
969
- }), jsx(Form.Group, _extends({
985
+ }), jsx(Form.Group, {
970
986
  id: id,
971
- name: id
972
- }, inlineOption, {
973
- children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
974
- var checked = enumOptionsIsSelected(option.value, checkboxesValues);
975
- var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
976
- return jsx(Form.Checkbox, _extends({
987
+ name: id,
988
+ ...inlineOption,
989
+ children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
990
+ const checked = enumOptionsIsSelected(option.value, checkboxesValues);
991
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
992
+ return jsx(Form.Checkbox, {
977
993
  id: optionId(id, index),
978
994
  name: id,
979
- label: option.label
980
- }, semanticProps, {
995
+ label: option.label,
996
+ ...semanticProps,
981
997
  checked: checked,
982
998
  error: rawErrors.length > 0,
983
999
  disabled: disabled || itemDisabled || readonly,
@@ -986,9 +1002,9 @@ function CheckboxesWidget(props) {
986
1002
  onBlur: _onBlur,
987
1003
  onFocus: _onFocus,
988
1004
  "aria-describedby": ariaDescribedByIds(id)
989
- }), index);
1005
+ }, index);
990
1006
  })
991
- }))]
1007
+ })]
992
1008
  });
993
1009
  }
994
1010
 
@@ -998,52 +1014,53 @@ function CheckboxesWidget(props) {
998
1014
  * @param props - The `WidgetProps` for this component
999
1015
  */
1000
1016
  function RadioWidget(props) {
1001
- var id = props.id,
1002
- value = props.value,
1003
- required = props.required,
1004
- disabled = props.disabled,
1005
- readonly = props.readonly,
1006
- onChange = props.onChange,
1007
- onBlur = props.onBlur,
1008
- onFocus = props.onFocus,
1009
- options = props.options,
1010
- formContext = props.formContext,
1011
- uiSchema = props.uiSchema,
1012
- _props$rawErrors = props.rawErrors,
1013
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
1014
- var enumOptions = options.enumOptions,
1015
- enumDisabled = options.enumDisabled,
1016
- emptyValue = options.emptyValue;
1017
- var semanticProps = getSemanticProps({
1018
- formContext: formContext,
1019
- options: options,
1020
- uiSchema: uiSchema
1017
+ const {
1018
+ id,
1019
+ value,
1020
+ required,
1021
+ disabled,
1022
+ readonly,
1023
+ onChange,
1024
+ onBlur,
1025
+ onFocus,
1026
+ options,
1027
+ formContext,
1028
+ uiSchema,
1029
+ rawErrors = []
1030
+ } = props;
1031
+ const {
1032
+ enumOptions,
1033
+ enumDisabled,
1034
+ emptyValue
1035
+ } = options;
1036
+ const semanticProps = getSemanticProps({
1037
+ formContext,
1038
+ options,
1039
+ uiSchema
1021
1040
  });
1022
- var _onChange = function _onChange(_, _ref) {
1023
- var eventValue = _ref.value;
1041
+ const _onChange = (_, {
1042
+ value: eventValue
1043
+ }) => {
1024
1044
  return onChange(enumOptionsValueForIndex(eventValue, enumOptions, emptyValue));
1025
1045
  };
1026
- var _onBlur = function _onBlur() {
1027
- return onBlur(id, value);
1028
- };
1029
- var _onFocus = function _onFocus() {
1030
- return onFocus(id, value);
1031
- };
1032
- var inlineOption = options.inline ? {
1046
+ const _onBlur = () => onBlur(id, value);
1047
+ const _onFocus = () => onFocus(id, value);
1048
+ const inlineOption = options.inline ? {
1033
1049
  inline: true
1034
1050
  } : {
1035
1051
  grouped: true
1036
1052
  };
1037
- return jsx(Form.Group, _extends({}, inlineOption, {
1038
- children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
1039
- var checked = enumOptionsIsSelected(option.value, value);
1040
- var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
1041
- return /*#__PURE__*/createElement(Form.Field, _extends({
1053
+ return jsx(Form.Group, {
1054
+ ...inlineOption,
1055
+ children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
1056
+ const checked = enumOptionsIsSelected(option.value, value);
1057
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
1058
+ return /*#__PURE__*/createElement(Form.Field, {
1042
1059
  required: required,
1043
1060
  control: Radio,
1044
1061
  id: optionId(id, index),
1045
- name: id
1046
- }, semanticProps, {
1062
+ name: id,
1063
+ ...semanticProps,
1047
1064
  onFocus: _onFocus,
1048
1065
  onBlur: _onBlur,
1049
1066
  onChange: _onChange,
@@ -1054,9 +1071,9 @@ function RadioWidget(props) {
1054
1071
  checked: checked,
1055
1072
  disabled: disabled || itemDisabled || readonly,
1056
1073
  "aria-describedby": ariaDescribedByIds(id)
1057
- }));
1074
+ });
1058
1075
  })
1059
- }));
1076
+ });
1060
1077
  }
1061
1078
 
1062
1079
  /** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
@@ -1065,54 +1082,53 @@ function RadioWidget(props) {
1065
1082
  * @param props - The `WidgetProps` for this component
1066
1083
  */
1067
1084
  function RangeWidget(props) {
1068
- var id = props.id,
1069
- value = props.value,
1070
- required = props.required,
1071
- readonly = props.readonly,
1072
- disabled = props.disabled,
1073
- onChange = props.onChange,
1074
- onBlur = props.onBlur,
1075
- onFocus = props.onFocus,
1076
- options = props.options,
1077
- schema = props.schema,
1078
- uiSchema = props.uiSchema,
1079
- formContext = props.formContext,
1080
- _props$rawErrors = props.rawErrors,
1081
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
1082
- var semanticProps = getSemanticProps({
1083
- formContext: formContext,
1084
- options: options,
1085
- uiSchema: uiSchema,
1085
+ const {
1086
+ id,
1087
+ value,
1088
+ required,
1089
+ readonly,
1090
+ disabled,
1091
+ onChange,
1092
+ onBlur,
1093
+ onFocus,
1094
+ options,
1095
+ schema,
1096
+ uiSchema,
1097
+ formContext,
1098
+ rawErrors = []
1099
+ } = props;
1100
+ const semanticProps = getSemanticProps({
1101
+ formContext,
1102
+ options,
1103
+ uiSchema,
1086
1104
  defaultSchemaProps: {
1087
1105
  fluid: true
1088
1106
  }
1089
1107
  });
1090
1108
  // eslint-disable-next-line no-shadow
1091
- var _onChange = function _onChange(_ref) {
1092
- var value = _ref.target.value;
1093
- return onChange && onChange(value === '' ? options.emptyValue : value);
1094
- };
1095
- var _onBlur = function _onBlur() {
1096
- return onBlur && onBlur(id, value);
1097
- };
1098
- var _onFocus = function _onFocus() {
1099
- return onFocus && onFocus(id, value);
1100
- };
1109
+ const _onChange = ({
1110
+ target: {
1111
+ value
1112
+ }
1113
+ }) => onChange && onChange(value === '' ? options.emptyValue : value);
1114
+ const _onBlur = () => onBlur && onBlur(id, value);
1115
+ const _onFocus = () => onFocus && onFocus(id, value);
1101
1116
  return jsxs(Fragment, {
1102
- children: [jsx(Input, _extends({
1117
+ children: [jsx(Input, {
1103
1118
  id: id,
1104
1119
  name: id,
1105
1120
  type: 'range',
1106
1121
  required: required,
1107
- disabled: disabled || readonly
1108
- }, rangeSpec(schema), semanticProps, {
1122
+ disabled: disabled || readonly,
1123
+ ...rangeSpec(schema),
1124
+ ...semanticProps,
1109
1125
  value: value || '',
1110
1126
  error: rawErrors.length > 0,
1111
1127
  onChange: _onChange,
1112
1128
  onBlur: _onBlur,
1113
1129
  onFocus: _onFocus,
1114
1130
  "aria-describedby": ariaDescribedByIds(id)
1115
- }), id), jsx("span", {
1131
+ }, id), jsx("span", {
1116
1132
  children: value
1117
1133
  })]
1118
1134
  });
@@ -1125,17 +1141,16 @@ function RangeWidget(props) {
1125
1141
  * @returns {*}
1126
1142
  */
1127
1143
  function createDefaultValueOptionsForDropDown(enumOptions, enumDisabled) {
1128
- var disabledOptions = enumDisabled || [];
1129
- var options = map(enumOptions, function (_ref, index) {
1130
- var label = _ref.label,
1131
- value = _ref.value;
1132
- return {
1133
- disabled: disabledOptions.indexOf(value) !== -1,
1134
- key: label,
1135
- text: label,
1136
- value: String(index)
1137
- };
1138
- });
1144
+ const disabledOptions = enumDisabled || [];
1145
+ const options = map(enumOptions, ({
1146
+ label,
1147
+ value
1148
+ }, index) => ({
1149
+ disabled: disabledOptions.indexOf(value) !== -1,
1150
+ key: label,
1151
+ text: label,
1152
+ value: String(index)
1153
+ }));
1139
1154
  return options;
1140
1155
  }
1141
1156
  /** The `SelectWidget` is a widget for rendering dropdowns.
@@ -1144,28 +1159,29 @@ function createDefaultValueOptionsForDropDown(enumOptions, enumDisabled) {
1144
1159
  * @param props - The `WidgetProps` for this component
1145
1160
  */
1146
1161
  function SelectWidget(props) {
1147
- var uiSchema = props.uiSchema,
1148
- formContext = props.formContext,
1149
- id = props.id,
1150
- options = props.options,
1151
- label = props.label,
1152
- hideLabel = props.hideLabel,
1153
- required = props.required,
1154
- disabled = props.disabled,
1155
- readonly = props.readonly,
1156
- value = props.value,
1157
- multiple = props.multiple,
1158
- placeholder = props.placeholder,
1159
- autofocus = props.autofocus,
1160
- onChange = props.onChange,
1161
- onBlur = props.onBlur,
1162
- onFocus = props.onFocus,
1163
- _props$rawErrors = props.rawErrors,
1164
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
1165
- var semanticProps = getSemanticProps({
1166
- uiSchema: uiSchema,
1167
- formContext: formContext,
1168
- options: options,
1162
+ const {
1163
+ uiSchema,
1164
+ formContext,
1165
+ id,
1166
+ options,
1167
+ label,
1168
+ hideLabel,
1169
+ required,
1170
+ disabled,
1171
+ readonly,
1172
+ value,
1173
+ multiple,
1174
+ placeholder,
1175
+ autofocus,
1176
+ onChange,
1177
+ onBlur,
1178
+ onFocus,
1179
+ rawErrors = []
1180
+ } = props;
1181
+ const semanticProps = getSemanticProps({
1182
+ uiSchema,
1183
+ formContext,
1184
+ options,
1169
1185
  defaultSchemaProps: {
1170
1186
  inverted: 'false',
1171
1187
  selection: true,
@@ -1174,26 +1190,29 @@ function SelectWidget(props) {
1174
1190
  upward: false
1175
1191
  }
1176
1192
  });
1177
- var enumDisabled = options.enumDisabled,
1178
- enumOptions = options.enumOptions,
1179
- optEmptyVal = options.emptyValue;
1180
- var emptyValue = multiple ? [] : '';
1181
- var dropdownOptions = createDefaultValueOptionsForDropDown(enumOptions, enumDisabled);
1182
- var _onChange = function _onChange(_, _ref2) {
1183
- var value = _ref2.value;
1184
- return onChange(enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1185
- };
1193
+ const {
1194
+ enumDisabled,
1195
+ enumOptions,
1196
+ emptyValue: optEmptyVal
1197
+ } = options;
1198
+ const emptyValue = multiple ? [] : '';
1199
+ const dropdownOptions = createDefaultValueOptionsForDropDown(enumOptions, enumDisabled);
1200
+ const _onChange = (_, {
1201
+ value
1202
+ }) => onChange(enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1186
1203
  // eslint-disable-next-line no-shadow
1187
- var _onBlur = function _onBlur(_, _ref3) {
1188
- var value = _ref3.target.value;
1189
- return onBlur(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1190
- };
1191
- var _onFocus = function _onFocus(_, _ref4) {
1192
- var value = _ref4.target.value;
1193
- return onFocus(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1194
- };
1195
- var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
1196
- return jsx(Form.Dropdown, _extends({
1204
+ const _onBlur = (_, {
1205
+ target: {
1206
+ value
1207
+ }
1208
+ }) => onBlur(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1209
+ const _onFocus = (_, {
1210
+ target: {
1211
+ value
1212
+ }
1213
+ }) => onFocus(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1214
+ const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
1215
+ return jsx(Form.Dropdown, {
1197
1216
  id: id,
1198
1217
  name: id,
1199
1218
  label: labelValue(label || undefined, hideLabel, false),
@@ -1201,8 +1220,8 @@ function SelectWidget(props) {
1201
1220
  value: typeof value === 'undefined' ? emptyValue : selectedIndexes,
1202
1221
  error: rawErrors.length > 0,
1203
1222
  disabled: disabled,
1204
- placeholder: placeholder
1205
- }, semanticProps, {
1223
+ placeholder: placeholder,
1224
+ ...semanticProps,
1206
1225
  required: required,
1207
1226
  autoFocus: autofocus,
1208
1227
  readOnly: readonly,
@@ -1211,7 +1230,7 @@ function SelectWidget(props) {
1211
1230
  onBlur: _onBlur,
1212
1231
  onFocus: _onFocus,
1213
1232
  "aria-describedby": ariaDescribedByIds(id)
1214
- }), id);
1233
+ }, id);
1215
1234
  }
1216
1235
 
1217
1236
  /** The `TextareaWidget` is a widget for rendering input fields as textarea.
@@ -1219,49 +1238,47 @@ function SelectWidget(props) {
1219
1238
  * @param props - The `WidgetProps` for this component
1220
1239
  */
1221
1240
  function TextareaWidget(props) {
1222
- var id = props.id,
1223
- placeholder = props.placeholder,
1224
- value = props.value,
1225
- required = props.required,
1226
- disabled = props.disabled,
1227
- autofocus = props.autofocus,
1228
- label = props.label,
1229
- hideLabel = props.hideLabel,
1230
- readonly = props.readonly,
1231
- onBlur = props.onBlur,
1232
- onFocus = props.onFocus,
1233
- onChange = props.onChange,
1234
- options = props.options,
1235
- formContext = props.formContext,
1236
- _props$rawErrors = props.rawErrors,
1237
- rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
1238
- var semanticProps = getSemanticProps({
1239
- formContext: formContext,
1240
- options: options,
1241
+ const {
1242
+ id,
1243
+ placeholder,
1244
+ value,
1245
+ required,
1246
+ disabled,
1247
+ autofocus,
1248
+ label,
1249
+ hideLabel,
1250
+ readonly,
1251
+ onBlur,
1252
+ onFocus,
1253
+ onChange,
1254
+ options,
1255
+ formContext,
1256
+ rawErrors = []
1257
+ } = props;
1258
+ const semanticProps = getSemanticProps({
1259
+ formContext,
1260
+ options,
1241
1261
  defaultSchemaProps: {
1242
1262
  inverted: 'false'
1243
1263
  }
1244
1264
  });
1245
1265
  // eslint-disable-next-line no-shadow
1246
- var _onChange = function _onChange(_ref) {
1247
- var value = _ref.target.value;
1248
- return onChange && onChange(value === '' ? options.emptyValue : value);
1249
- };
1250
- var _onBlur = function _onBlur() {
1251
- return onBlur && onBlur(id, value);
1252
- };
1253
- var _onFocus = function _onFocus() {
1254
- return onFocus && onFocus(id, value);
1255
- };
1256
- return jsx(Form.TextArea, _extends({
1266
+ const _onChange = ({
1267
+ target: {
1268
+ value
1269
+ }
1270
+ }) => onChange && onChange(value === '' ? options.emptyValue : value);
1271
+ const _onBlur = () => onBlur && onBlur(id, value);
1272
+ const _onFocus = () => onFocus && onFocus(id, value);
1273
+ return jsx(Form.TextArea, {
1257
1274
  id: id,
1258
1275
  name: id,
1259
1276
  label: labelValue(label || undefined, hideLabel, false),
1260
1277
  placeholder: placeholder,
1261
1278
  autoFocus: autofocus,
1262
1279
  required: required,
1263
- disabled: disabled || readonly
1264
- }, semanticProps, {
1280
+ disabled: disabled || readonly,
1281
+ ...semanticProps,
1265
1282
  value: value || '',
1266
1283
  error: rawErrors.length > 0,
1267
1284
  rows: options.rows || 5,
@@ -1269,17 +1286,17 @@ function TextareaWidget(props) {
1269
1286
  onBlur: _onBlur,
1270
1287
  onFocus: _onFocus,
1271
1288
  "aria-describedby": ariaDescribedByIds(id)
1272
- }), id);
1289
+ }, id);
1273
1290
  }
1274
1291
 
1275
1292
  function generateWidgets() {
1276
1293
  return {
1277
- CheckboxWidget: CheckboxWidget,
1278
- CheckboxesWidget: CheckboxesWidget,
1279
- RadioWidget: RadioWidget,
1280
- RangeWidget: RangeWidget,
1281
- SelectWidget: SelectWidget,
1282
- TextareaWidget: TextareaWidget
1294
+ CheckboxWidget,
1295
+ CheckboxesWidget,
1296
+ RadioWidget,
1297
+ RangeWidget,
1298
+ SelectWidget,
1299
+ TextareaWidget
1283
1300
  };
1284
1301
  }
1285
1302
  var Widgets = /*#__PURE__*/generateWidgets();