@rjsf/semantic-ui 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
1
  import { withTheme } from '@rjsf/core';
2
2
  import { Button, Icon, Segment, Grid, Form, Message, Label, List, Header, Radio, Input } from 'semantic-ui-react';
3
- import React from 'react';
4
- import { getUiOptions, getTemplate, isFixedItems, UI_OPTIONS_KEY, getInputProps, examplesId, ariaDescribedByIds, descriptionId, titleId, canExpand, getSubmitButtonOptions, ADDITIONAL_PROPERTY_FLAG, schemaRequiresTrueValue, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, enumOptionsValueForIndex, rangeSpec, enumOptionsIndexForValue } from '@rjsf/utils';
3
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
+ import { TranslatableString, getUiOptions, getTemplate, isFixedItems, UI_OPTIONS_KEY, getInputProps, examplesId, ariaDescribedByIds, errorId, helpId, descriptionId, titleId, canExpand, getSubmitButtonOptions, ADDITIONAL_PROPERTY_FLAG, schemaRequiresTrueValue, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, enumOptionsValueForIndex, rangeSpec, enumOptionsIndexForValue } from '@rjsf/utils';
5
5
  import { nanoid } from 'nanoid';
6
+ import { createElement } from 'react';
6
7
  import map from 'lodash-es/map';
7
8
 
8
9
  function _extends() {
@@ -36,16 +37,19 @@ var _excluded$4 = ["uiSchema", "registry", "color"];
36
37
  /** The `AddButton` renders a button that represent the `Add` action on a form
37
38
  */
38
39
  function AddButton(_ref) {
39
- var color = _ref.color,
40
+ var registry = _ref.registry,
41
+ color = _ref.color,
40
42
  props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
41
- return /*#__PURE__*/React.createElement(Button, _extends({
42
- title: "Add Item",
43
+ var translateString = registry.translateString;
44
+ return jsx(Button, _extends({
45
+ title: translateString(TranslatableString.AddItemButton),
43
46
  color: color
44
47
  }, props, {
45
48
  icon: true,
46
- size: "tiny"
47
- }), /*#__PURE__*/React.createElement(Icon, {
48
- name: "plus"
49
+ size: 'tiny',
50
+ children: jsx(Icon, {
51
+ name: 'plus'
52
+ })
49
53
  }));
50
54
  }
51
55
 
@@ -99,8 +103,8 @@ function getSemanticErrorProps(_ref2) {
99
103
  options = _ref2$options === void 0 ? {} : _ref2$options,
100
104
  _ref2$defaultProps = _ref2.defaultProps,
101
105
  defaultProps = _ref2$defaultProps === void 0 ? {
102
- size: "small",
103
- pointing: "above"
106
+ size: 'small',
107
+ pointing: 'above'
104
108
  } : _ref2$defaultProps;
105
109
  var formContextProps = formContext.semantic && formContext.semantic.errorOptions;
106
110
  var semanticOptions = getUiOptions(uiSchema).semantic;
@@ -130,7 +134,7 @@ function cleanClassNames(classNameArr, omit) {
130
134
  // returning them as a string
131
135
  return [].concat(new Set(classList.filter(function (cn) {
132
136
  return !omit.includes(cn);
133
- }))).join(" ");
137
+ }))).join(' ');
134
138
  }
135
139
  /**
136
140
  *
@@ -143,14 +147,14 @@ function cleanClassNames(classNameArr, omit) {
143
147
  function MaybeWrap(_ref3) {
144
148
  var wrap = _ref3.wrap,
145
149
  _ref3$component = _ref3.component,
146
- Component = _ref3$component === void 0 ? "div" : _ref3$component,
150
+ Component = _ref3$component === void 0 ? 'div' : _ref3$component,
147
151
  props = _objectWithoutPropertiesLoose(_ref3, _excluded$3);
148
- return wrap ? /*#__PURE__*/React.createElement(Component, _extends({}, props)) : props.children;
152
+ return wrap ? jsx(Component, _extends({}, props)) : props.children;
149
153
  }
150
154
 
151
155
  var gridStyle = function gridStyle(vertical) {
152
156
  return {
153
- display: "grid",
157
+ display: 'grid',
154
158
  gridTemplateColumns: "1fr " + (vertical ? 65 : 110) + "px"
155
159
  };
156
160
  };
@@ -182,40 +186,47 @@ function ArrayFieldItemTemplate(props) {
182
186
  horizontalButtons = _uiOptions$semantic$h === void 0 ? false : _uiOptions$semantic$h,
183
187
  _uiOptions$semantic$w = _uiOptions$semantic.wrapItem,
184
188
  wrapItem = _uiOptions$semantic$w === void 0 ? false : _uiOptions$semantic$w;
185
- return /*#__PURE__*/React.createElement("div", {
186
- className: "array-item"
187
- }, /*#__PURE__*/React.createElement(MaybeWrap, {
188
- wrap: wrapItem,
189
- component: Segment
190
- }, /*#__PURE__*/React.createElement(Grid, {
191
- style: index !== 0 ? _extends({}, gridStyle(!horizontalButtons), {
192
- alignItems: "center"
193
- }) : gridStyle(!horizontalButtons)
194
- }, /*#__PURE__*/React.createElement(Grid.Column, {
195
- width: 16,
196
- verticalAlign: "middle"
197
- }, children), hasToolbar && /*#__PURE__*/React.createElement(Grid.Column, null, (hasMoveUp || hasMoveDown || hasRemove) && /*#__PURE__*/React.createElement(Button.Group, {
198
- size: "mini",
199
- vertical: !horizontalButtons
200
- }, (hasMoveUp || hasMoveDown) && /*#__PURE__*/React.createElement(MoveUpButton, {
201
- className: "array-item-move-up",
202
- disabled: disabled || readonly || !hasMoveUp,
203
- onClick: onReorderClick(index, index - 1),
204
- uiSchema: uiSchema,
205
- registry: registry
206
- }), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React.createElement(MoveDownButton, {
207
- className: "array-item-move-down",
208
- disabled: disabled || readonly || !hasMoveDown,
209
- onClick: onReorderClick(index, index + 1),
210
- uiSchema: uiSchema,
211
- registry: registry
212
- }), hasRemove && /*#__PURE__*/React.createElement(RemoveButton, {
213
- className: "array-item-remove",
214
- disabled: disabled || readonly,
215
- onClick: onDropIndexClick(index),
216
- uiSchema: uiSchema,
217
- registry: registry
218
- }))))));
189
+ return jsx("div", {
190
+ className: 'array-item',
191
+ children: jsx(MaybeWrap, {
192
+ wrap: wrapItem,
193
+ component: Segment,
194
+ children: jsxs(Grid, {
195
+ style: index !== 0 ? _extends({}, gridStyle(!horizontalButtons), {
196
+ alignItems: 'center'
197
+ }) : gridStyle(!horizontalButtons),
198
+ children: [jsx(Grid.Column, {
199
+ width: 16,
200
+ verticalAlign: 'middle',
201
+ children: children
202
+ }), hasToolbar && jsx(Grid.Column, {
203
+ children: (hasMoveUp || hasMoveDown || hasRemove) && jsxs(Button.Group, {
204
+ size: 'mini',
205
+ vertical: !horizontalButtons,
206
+ children: [(hasMoveUp || hasMoveDown) && jsx(MoveUpButton, {
207
+ className: 'array-item-move-up',
208
+ disabled: disabled || readonly || !hasMoveUp,
209
+ onClick: onReorderClick(index, index - 1),
210
+ uiSchema: uiSchema,
211
+ registry: registry
212
+ }), (hasMoveUp || hasMoveDown) && jsx(MoveDownButton, {
213
+ className: 'array-item-move-down',
214
+ disabled: disabled || readonly || !hasMoveDown,
215
+ onClick: onReorderClick(index, index + 1),
216
+ uiSchema: uiSchema,
217
+ registry: registry
218
+ }), hasRemove && jsx(RemoveButton, {
219
+ className: 'array-item-remove',
220
+ disabled: disabled || readonly,
221
+ onClick: onDropIndexClick(index),
222
+ uiSchema: uiSchema,
223
+ registry: registry
224
+ })]
225
+ })
226
+ })]
227
+ })
228
+ })
229
+ });
219
230
  }
220
231
 
221
232
  var _excluded$2 = ["key", "uiSchema"];
@@ -252,57 +263,58 @@ function ArrayFieldTemplate(props) {
252
263
  wrapItem: wrapItem
253
264
  };
254
265
  var uiOptions = getUiOptions(uiSchema);
255
- var ArrayFieldDescriptionTemplate = getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
256
- var ArrayFieldItemTemplate = getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
257
- var ArrayFieldTitleTemplate = getTemplate("ArrayFieldTitleTemplate", registry, uiOptions);
266
+ var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
267
+ var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
268
+ var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
258
269
  // Button templates are not overridden in the uiSchema
259
270
  var AddButton = registry.templates.ButtonTemplates.AddButton;
260
- return /*#__PURE__*/React.createElement("div", {
261
- className: cleanClassNames([className, isFixedItems(schema) ? "" : "sortable-form-fields"])
262
- }, /*#__PURE__*/React.createElement(ArrayFieldTitleTemplate, {
263
- idSchema: idSchema,
264
- title: uiOptions.title || title,
265
- schema: schema,
266
- uiSchema: uiSchema,
267
- required: required,
268
- registry: registry
269
- }), /*#__PURE__*/React.createElement(ArrayFieldDescriptionTemplate, {
270
- idSchema: idSchema,
271
- description: uiOptions.description || schema.description,
272
- schema: schema,
273
- uiSchema: uiSchema,
274
- registry: registry
275
- }), /*#__PURE__*/React.createElement("div", {
276
- key: "array-item-list-" + idSchema.$id
277
- }, /*#__PURE__*/React.createElement("div", {
278
- className: "row array-item-list"
279
- }, items && items.map(function (_ref) {
280
- var _extends2;
281
- var key = _ref.key,
282
- _ref$uiSchema = _ref.uiSchema,
283
- itemUiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
284
- props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
285
- // Merge in the semantic props from the ArrayFieldTemplate into each of the items
286
- var mergedUiSchema = _extends({}, itemUiSchema, (_extends2 = {}, _extends2[UI_OPTIONS_KEY] = _extends({}, itemUiSchema[UI_OPTIONS_KEY], {
287
- semantic: semantic
288
- }), _extends2));
289
- return /*#__PURE__*/React.createElement(ArrayFieldItemTemplate, _extends({
290
- key: key
291
- }, props, {
292
- uiSchema: mergedUiSchema
293
- }));
294
- })), canAdd && /*#__PURE__*/React.createElement("div", {
295
- style: {
296
- marginTop: "1rem",
297
- position: "relative",
298
- textAlign: "right"
299
- }
300
- }, /*#__PURE__*/React.createElement(AddButton, {
301
- onClick: onAddClick,
302
- disabled: disabled || readonly,
303
- uiSchema: uiSchema,
304
- registry: registry
305
- }))));
271
+ return jsxs("div", {
272
+ className: cleanClassNames([className, isFixedItems(schema) ? '' : 'sortable-form-fields']),
273
+ children: [jsx(ArrayFieldTitleTemplate, {
274
+ idSchema: idSchema,
275
+ title: uiOptions.title || title,
276
+ schema: schema,
277
+ uiSchema: uiSchema,
278
+ required: required,
279
+ registry: registry
280
+ }), jsx(ArrayFieldDescriptionTemplate, {
281
+ idSchema: idSchema,
282
+ description: uiOptions.description || schema.description,
283
+ schema: schema,
284
+ uiSchema: uiSchema,
285
+ registry: registry
286
+ }), jsxs("div", {
287
+ children: [jsx("div", {
288
+ className: 'row array-item-list',
289
+ children: items && items.map(function (_ref) {
290
+ var _extends2;
291
+ var key = _ref.key,
292
+ _ref$uiSchema = _ref.uiSchema,
293
+ itemUiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
294
+ props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
295
+ // Merge in the semantic props from the ArrayFieldTemplate into each of the items
296
+ var mergedUiSchema = _extends({}, itemUiSchema, (_extends2 = {}, _extends2[UI_OPTIONS_KEY] = _extends({}, itemUiSchema[UI_OPTIONS_KEY], {
297
+ semantic: semantic
298
+ }), _extends2));
299
+ return jsx(ArrayFieldItemTemplate, _extends({}, props, {
300
+ uiSchema: mergedUiSchema
301
+ }), key);
302
+ })
303
+ }), canAdd && jsx("div", {
304
+ style: {
305
+ marginTop: '1rem',
306
+ position: 'relative',
307
+ textAlign: 'right'
308
+ },
309
+ children: jsx(AddButton, {
310
+ onClick: onAddClick,
311
+ disabled: disabled || readonly,
312
+ uiSchema: uiSchema,
313
+ registry: registry
314
+ })
315
+ })]
316
+ }, "array-item-list-" + idSchema.$id)]
317
+ });
306
318
  }
307
319
 
308
320
  /** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
@@ -320,6 +332,7 @@ function BaseInputTemplate(props) {
320
332
  readonly = props.readonly,
321
333
  disabled = props.disabled,
322
334
  onChange = props.onChange,
335
+ onChangeOverride = props.onChangeOverride,
323
336
  onBlur = props.onBlur,
324
337
  onFocus = props.onFocus,
325
338
  autofocus = props.autofocus,
@@ -340,7 +353,7 @@ function BaseInputTemplate(props) {
340
353
  var schemaUtils = registry.schemaUtils;
341
354
  var _onChange = function _onChange(_ref) {
342
355
  var value = _ref.target.value;
343
- return onChange(value === "" ? options.emptyValue : value);
356
+ return onChange(value === '' ? options.emptyValue : value);
344
357
  };
345
358
  var _onBlur = function _onBlur() {
346
359
  return onBlur && onBlur(id, value);
@@ -349,32 +362,33 @@ function BaseInputTemplate(props) {
349
362
  return onFocus && onFocus(id, value);
350
363
  };
351
364
  var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
352
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Form.Input, _extends({
353
- key: id,
354
- id: id,
355
- name: id,
356
- placeholder: placeholder
357
- }, inputProps, {
358
- label: displayLabel ? label || schema.title : false,
359
- required: required,
360
- autoFocus: autofocus,
361
- disabled: disabled || readonly,
362
- list: schema.examples ? examplesId(id) : undefined
363
- }, semanticProps, {
364
- value: value || value === 0 ? value : "",
365
- error: rawErrors.length > 0,
366
- onChange: _onChange,
367
- onBlur: _onBlur,
368
- onFocus: _onFocus,
369
- "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
370
- })), Array.isArray(schema.examples) && /*#__PURE__*/React.createElement("datalist", {
371
- id: examplesId(id)
372
- }, schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
373
- return /*#__PURE__*/React.createElement("option", {
374
- key: example,
375
- value: example
376
- });
377
- })));
365
+ return jsxs(Fragment, {
366
+ children: [jsx(Form.Input, _extends({
367
+ id: id,
368
+ name: id,
369
+ placeholder: placeholder
370
+ }, inputProps, {
371
+ label: displayLabel ? label || schema.title : false,
372
+ required: required,
373
+ autoFocus: autofocus,
374
+ disabled: disabled || readonly,
375
+ list: schema.examples ? examplesId(id) : undefined
376
+ }, semanticProps, {
377
+ value: value || value === 0 ? value : '',
378
+ error: rawErrors.length > 0,
379
+ onChange: onChangeOverride || _onChange,
380
+ onBlur: _onBlur,
381
+ onFocus: _onFocus,
382
+ "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
383
+ }), id), Array.isArray(schema.examples) && jsx("datalist", {
384
+ id: examplesId(id),
385
+ children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
386
+ return jsx("option", {
387
+ value: example
388
+ }, example);
389
+ })
390
+ })]
391
+ });
378
392
  }
379
393
 
380
394
  /** The `DescriptionField` is the template to use to render the description of a field
@@ -387,10 +401,11 @@ function DescriptionField(props) {
387
401
  if (!description) {
388
402
  return null;
389
403
  }
390
- return /*#__PURE__*/React.createElement("p", {
404
+ return jsx("p", {
391
405
  id: id,
392
- className: "sui-description"
393
- }, description);
406
+ className: 'sui-description',
407
+ children: description
408
+ });
394
409
  }
395
410
 
396
411
  /** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
@@ -398,14 +413,21 @@ function DescriptionField(props) {
398
413
  * @param props - The `ErrorListProps` for this component
399
414
  */
400
415
  function ErrorList(_ref) {
401
- var errors = _ref.errors;
402
- return /*#__PURE__*/React.createElement(Message, {
403
- negative: true
404
- }, /*#__PURE__*/React.createElement(Message.Header, null, "Errors"), /*#__PURE__*/React.createElement(Message.List, null, errors.map(function (error, index) {
405
- return /*#__PURE__*/React.createElement(Message.Item, {
406
- key: "error-" + index
407
- }, error.stack);
408
- })));
416
+ var errors = _ref.errors,
417
+ registry = _ref.registry;
418
+ var translateString = registry.translateString;
419
+ return jsxs(Message, {
420
+ negative: true,
421
+ children: [jsx(Message.Header, {
422
+ children: translateString(TranslatableString.ErrorsLabel)
423
+ }), jsx(Message.List, {
424
+ children: errors.map(function (error, index) {
425
+ return jsx(Message.Item, {
426
+ children: error.stack
427
+ }, "error-" + index);
428
+ })
429
+ })]
430
+ });
409
431
  }
410
432
 
411
433
  var _excluded$1 = ["icon", "iconType", "color", "className", "uiSchema", "registry"];
@@ -415,7 +437,7 @@ function IconButton(props) {
415
437
  color = props.color,
416
438
  className = props.className,
417
439
  otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
418
- return /*#__PURE__*/React.createElement(Button, _extends({
440
+ return jsx(Button, _extends({
419
441
  icon: icon,
420
442
  size: iconType,
421
443
  color: color,
@@ -423,31 +445,34 @@ function IconButton(props) {
423
445
  }, otherProps));
424
446
  }
425
447
  function MoveDownButton(props) {
426
- return /*#__PURE__*/React.createElement(IconButton, _extends({
427
- title: "Move down"
448
+ var translateString = props.registry.translateString;
449
+ return jsx(IconButton, _extends({
450
+ title: translateString(TranslatableString.MoveDownButton)
428
451
  }, props, {
429
- icon: "angle down"
452
+ icon: 'angle down'
430
453
  }));
431
454
  }
432
455
  function MoveUpButton(props) {
433
- return /*#__PURE__*/React.createElement(IconButton, _extends({
434
- title: "Move up"
456
+ var translateString = props.registry.translateString;
457
+ return jsx(IconButton, _extends({
458
+ title: translateString(TranslatableString.MoveUpButton)
435
459
  }, props, {
436
- icon: "angle up"
460
+ icon: 'angle up'
437
461
  }));
438
462
  }
439
463
  function RemoveButton(props) {
440
- return /*#__PURE__*/React.createElement(IconButton, _extends({
441
- title: "Remove"
464
+ var translateString = props.registry.translateString;
465
+ return jsx(IconButton, _extends({
466
+ title: translateString(TranslatableString.RemoveButton)
442
467
  }, props, {
443
- icon: "trash"
468
+ icon: 'trash'
444
469
  }));
445
470
  }
446
471
 
447
472
  var DEFAULT_OPTIONS$1 = {
448
473
  options: {
449
- pointing: "above",
450
- size: "small"
474
+ pointing: 'above',
475
+ size: 'small'
451
476
  }
452
477
  };
453
478
  /** The `FieldErrorTemplate` component renders the errors local to the particular field
@@ -468,20 +493,22 @@ function FieldErrorTemplate(_ref) {
468
493
  var pointing = options.pointing,
469
494
  size = options.size;
470
495
  if (errors && errors.length > 0) {
471
- var id = idSchema.$id + "__error";
472
- return /*#__PURE__*/React.createElement(Label, {
496
+ var id = errorId(idSchema);
497
+ return jsx(Label, {
473
498
  id: id,
474
- color: "red",
475
- pointing: pointing || "above",
476
- size: size || "small",
477
- basic: true
478
- }, /*#__PURE__*/React.createElement(List, {
479
- bulleted: true
480
- }, errors.map(function (error) {
481
- return /*#__PURE__*/React.createElement(List.Item, {
482
- key: nanoid()
483
- }, error);
484
- })));
499
+ color: 'red',
500
+ pointing: pointing || 'above',
501
+ size: size || 'small',
502
+ basic: true,
503
+ children: jsx(List, {
504
+ bulleted: true,
505
+ children: errors.map(function (error) {
506
+ return jsx(List.Item, {
507
+ children: error
508
+ }, nanoid());
509
+ })
510
+ })
511
+ });
485
512
  }
486
513
  return null;
487
514
  }
@@ -494,9 +521,9 @@ function FieldHelpTemplate(props) {
494
521
  var idSchema = props.idSchema,
495
522
  help = props.help;
496
523
  if (help) {
497
- var id = idSchema.$id + "__help";
498
- return /*#__PURE__*/React.createElement(Message, {
499
- size: "mini",
524
+ var id = helpId(idSchema);
525
+ return jsx(Message, {
526
+ size: 'mini',
500
527
  info: true,
501
528
  id: id,
502
529
  content: help
@@ -530,16 +557,17 @@ function FieldTemplate(props) {
530
557
  var wrapLabel = semanticProps.wrapLabel,
531
558
  wrapContent = semanticProps.wrapContent;
532
559
  var uiOptions = getUiOptions(uiSchema);
533
- var WrapIfAdditionalTemplate = getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
534
- var DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, uiOptions);
560
+ var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
561
+ var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
535
562
  if (hidden) {
536
- return /*#__PURE__*/React.createElement("div", {
563
+ return jsx("div", {
537
564
  style: {
538
- display: "none"
539
- }
540
- }, children);
565
+ display: 'none'
566
+ },
567
+ children: children
568
+ });
541
569
  }
542
- return /*#__PURE__*/React.createElement(WrapIfAdditionalTemplate, _extends({
570
+ return jsx(WrapIfAdditionalTemplate, _extends({
543
571
  classNames: classNames,
544
572
  style: style,
545
573
  id: id,
@@ -547,23 +575,27 @@ function FieldTemplate(props) {
547
575
  registry: registry,
548
576
  schema: schema,
549
577
  uiSchema: uiSchema
550
- }, otherProps), /*#__PURE__*/React.createElement(Form.Group, {
551
- key: id,
552
- widths: "equal",
553
- grouped: true
554
- }, /*#__PURE__*/React.createElement(MaybeWrap, {
555
- wrap: wrapContent,
556
- className: "sui-field-content"
557
- }, children, displayLabel && rawDescription && /*#__PURE__*/React.createElement(MaybeWrap, {
558
- wrap: wrapLabel,
559
- className: "sui-field-label"
560
- }, rawDescription && /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
561
- id: descriptionId(id),
562
- description: rawDescription,
563
- schema: schema,
564
- uiSchema: uiSchema,
565
- registry: registry
566
- })), help, errors)));
578
+ }, otherProps, {
579
+ children: jsx(Form.Group, {
580
+ widths: 'equal',
581
+ grouped: true,
582
+ children: jsxs(MaybeWrap, {
583
+ wrap: wrapContent,
584
+ className: 'sui-field-content',
585
+ children: [children, displayLabel && rawDescription && jsx(MaybeWrap, {
586
+ wrap: wrapLabel,
587
+ className: 'sui-field-label',
588
+ children: rawDescription && jsx(DescriptionFieldTemplate, {
589
+ id: descriptionId(id),
590
+ description: rawDescription,
591
+ schema: schema,
592
+ uiSchema: uiSchema,
593
+ registry: registry
594
+ })
595
+ }), help, errors]
596
+ })
597
+ }, id)
598
+ }));
567
599
  }
568
600
 
569
601
  /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
@@ -586,42 +618,48 @@ function ObjectFieldTemplate(props) {
586
618
  idSchema = props.idSchema,
587
619
  registry = props.registry;
588
620
  var uiOptions = getUiOptions(uiSchema);
589
- var TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, uiOptions);
590
- var DescriptionFieldTemplate = getTemplate("DescriptionFieldTemplate", registry, uiOptions);
621
+ var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
622
+ var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
591
623
  // Button templates are not overridden in the uiSchema
592
624
  var AddButton = registry.templates.ButtonTemplates.AddButton;
593
625
  var fieldTitle = uiOptions.title || title;
594
626
  var fieldDescription = uiOptions.description || description;
595
- return /*#__PURE__*/React.createElement(React.Fragment, null, fieldTitle && /*#__PURE__*/React.createElement(TitleFieldTemplate, {
596
- id: titleId(idSchema),
597
- title: fieldTitle,
598
- required: required,
599
- schema: schema,
600
- uiSchema: uiSchema,
601
- registry: registry
602
- }), fieldDescription && /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
603
- id: descriptionId(idSchema),
604
- description: fieldDescription,
605
- schema: schema,
606
- uiSchema: uiSchema,
607
- registry: registry
608
- }), properties.map(function (prop) {
609
- return prop.content;
610
- }), canExpand(schema, uiSchema, formData) && /*#__PURE__*/React.createElement(Grid.Column, {
611
- width: 16,
612
- verticalAlign: "middle"
613
- }, /*#__PURE__*/React.createElement(Grid.Row, null, /*#__PURE__*/React.createElement("div", {
614
- style: {
615
- marginTop: "1rem",
616
- position: "relative",
617
- textAlign: "right"
618
- }
619
- }, /*#__PURE__*/React.createElement(AddButton, {
620
- onClick: onAddClick(schema),
621
- disabled: disabled || readonly,
622
- uiSchema: uiSchema,
623
- registry: registry
624
- })))));
627
+ return jsxs(Fragment, {
628
+ children: [fieldTitle && jsx(TitleFieldTemplate, {
629
+ id: titleId(idSchema),
630
+ title: fieldTitle,
631
+ required: required,
632
+ schema: schema,
633
+ uiSchema: uiSchema,
634
+ registry: registry
635
+ }), fieldDescription && jsx(DescriptionFieldTemplate, {
636
+ id: descriptionId(idSchema),
637
+ description: fieldDescription,
638
+ schema: schema,
639
+ uiSchema: uiSchema,
640
+ registry: registry
641
+ }), properties.map(function (prop) {
642
+ return prop.content;
643
+ }), canExpand(schema, uiSchema, formData) && jsx(Grid.Column, {
644
+ width: 16,
645
+ verticalAlign: 'middle',
646
+ children: jsx(Grid.Row, {
647
+ children: jsx("div", {
648
+ style: {
649
+ marginTop: '1rem',
650
+ position: 'relative',
651
+ textAlign: 'right'
652
+ },
653
+ children: jsx(AddButton, {
654
+ onClick: onAddClick(schema),
655
+ disabled: disabled || readonly,
656
+ uiSchema: uiSchema,
657
+ registry: registry
658
+ })
659
+ })
660
+ })
661
+ })]
662
+ });
625
663
  }
626
664
 
627
665
  /** The `SubmitButton` renders a button that represent the `Submit` action on a form
@@ -636,10 +674,12 @@ function SubmitButton(_ref) {
636
674
  if (norender) {
637
675
  return null;
638
676
  }
639
- return /*#__PURE__*/React.createElement(Button, _extends({
640
- type: "submit",
677
+ return jsx(Button, _extends({
678
+ type: 'submit',
641
679
  primary: true
642
- }, submitButtonProps), submitText);
680
+ }, submitButtonProps, {
681
+ children: submitText
682
+ }));
643
683
  }
644
684
 
645
685
  var DEFAULT_OPTIONS = {
@@ -661,11 +701,12 @@ function TitleField(_ref) {
661
701
  if (!title) {
662
702
  return null;
663
703
  }
664
- return /*#__PURE__*/React.createElement(Header, _extends({
704
+ return jsx(Header, _extends({
665
705
  id: id
666
706
  }, semanticProps, {
667
- as: "h5"
668
- }), title);
707
+ as: 'h5',
708
+ children: title
709
+ }));
669
710
  }
670
711
 
671
712
  /** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
@@ -687,60 +728,71 @@ function WrapIfAdditionalTemplate(props) {
687
728
  schema = props.schema,
688
729
  uiSchema = props.uiSchema,
689
730
  registry = props.registry;
731
+ var templates = registry.templates,
732
+ translateString = registry.translateString;
690
733
  // Button templates are not overridden in the uiSchema
691
- var RemoveButton = registry.templates.ButtonTemplates.RemoveButton;
734
+ var RemoveButton = templates.ButtonTemplates.RemoveButton;
735
+ var keyLabel = translateString(TranslatableString.KeyLabel, [label]);
692
736
  var _registry$formContext = registry.formContext,
693
737
  _registry$formContext2 = _registry$formContext.readonlyAsDisabled,
694
738
  readonlyAsDisabled = _registry$formContext2 === void 0 ? true : _registry$formContext2,
695
739
  wrapperStyle = _registry$formContext.wrapperStyle;
696
- var keyLabel = label + " Key"; // i18n ?
697
740
  var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
698
741
  if (!additional) {
699
- return /*#__PURE__*/React.createElement("div", {
742
+ return jsx("div", {
700
743
  className: classNames,
701
- style: style
702
- }, children);
744
+ style: style,
745
+ children: children
746
+ });
703
747
  }
704
748
  var handleBlur = function handleBlur(_ref) {
705
749
  var target = _ref.target;
706
750
  return onKeyChange(target.value);
707
751
  };
708
- return /*#__PURE__*/React.createElement("div", {
752
+ return jsx("div", {
709
753
  className: classNames,
710
754
  style: style,
711
- key: id + "-key"
712
- }, /*#__PURE__*/React.createElement(Grid, {
713
- columns: "equal"
714
- }, /*#__PURE__*/React.createElement(Grid.Row, null, /*#__PURE__*/React.createElement(Grid.Column, {
715
- className: "form-additional"
716
- }, /*#__PURE__*/React.createElement(Form.Group, {
717
- widths: "equal",
718
- grouped: true
719
- }, /*#__PURE__*/React.createElement(Form.Input, {
720
- className: "form-group",
721
- hasFeedback: true,
722
- fluid: true,
723
- htmlFor: "" + id,
724
- label: keyLabel,
725
- required: required,
726
- defaultValue: label,
727
- disabled: disabled || readonlyAsDisabled && readonly,
728
- id: "" + id,
729
- name: "" + id,
730
- onBlur: !readonly ? handleBlur : undefined,
731
- style: wrapperStyle,
732
- type: "text"
733
- }))), /*#__PURE__*/React.createElement(Grid.Column, {
734
- className: "form-additional",
735
- verticalAlign: "middle"
736
- }, children), /*#__PURE__*/React.createElement(Grid.Column, null, /*#__PURE__*/React.createElement(RemoveButton, {
737
- iconType: "mini",
738
- className: "array-item-remove",
739
- disabled: disabled || readonly,
740
- onClick: onDropPropertyClick(label),
741
- uiSchema: uiSchema,
742
- registry: registry
743
- })))));
755
+ children: jsx(Grid, {
756
+ columns: 'equal',
757
+ children: jsxs(Grid.Row, {
758
+ children: [jsx(Grid.Column, {
759
+ className: 'form-additional',
760
+ children: jsx(Form.Group, {
761
+ widths: 'equal',
762
+ grouped: true,
763
+ children: jsx(Form.Input, {
764
+ className: 'form-group',
765
+ hasFeedback: true,
766
+ fluid: true,
767
+ htmlFor: "" + id,
768
+ label: keyLabel,
769
+ required: required,
770
+ defaultValue: label,
771
+ disabled: disabled || readonlyAsDisabled && readonly,
772
+ id: "" + id,
773
+ name: "" + id,
774
+ onBlur: !readonly ? handleBlur : undefined,
775
+ style: wrapperStyle,
776
+ type: 'text'
777
+ })
778
+ })
779
+ }), jsx(Grid.Column, {
780
+ className: 'form-additional',
781
+ verticalAlign: 'middle',
782
+ children: children
783
+ }), jsx(Grid.Column, {
784
+ children: jsx(RemoveButton, {
785
+ iconType: 'mini',
786
+ className: 'array-item-remove',
787
+ disabled: disabled || readonly,
788
+ onClick: onDropPropertyClick(label),
789
+ uiSchema: uiSchema,
790
+ registry: registry
791
+ })
792
+ })]
793
+ })
794
+ })
795
+ }, id + "-key");
744
796
  }
745
797
 
746
798
  function generateTemplates() {
@@ -809,20 +861,20 @@ function CheckboxWidget(props) {
809
861
  var _onFocus = function _onFocus() {
810
862
  return onFocus && onFocus(id, value);
811
863
  };
812
- var checked = value == "true" || value == true;
813
- return /*#__PURE__*/React.createElement(Form.Checkbox, _extends({
864
+ var checked = value == 'true' || value == true;
865
+ return jsx(Form.Checkbox, _extends({
814
866
  id: id,
815
867
  name: id,
816
868
  disabled: disabled || readonly,
817
869
  autoFocus: autofocus
818
870
  }, semanticProps, {
819
- checked: typeof value === "undefined" ? false : checked,
871
+ checked: typeof value === 'undefined' ? false : checked,
820
872
  error: rawErrors.length > 0,
821
873
  onChange: _onChange,
822
874
  onBlur: _onBlur,
823
875
  onFocus: _onFocus,
824
876
  required: required,
825
- label: label || "",
877
+ label: label || '',
826
878
  "aria-describedby": ariaDescribedByIds(id)
827
879
  }));
828
880
  }
@@ -848,7 +900,7 @@ function CheckboxesWidget(props) {
848
900
  _props$rawErrors = props.rawErrors,
849
901
  rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
850
902
  registry = props.registry;
851
- var TitleFieldTemplate = getTemplate("TitleFieldTemplate", registry, options);
903
+ var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
852
904
  var enumOptions = options.enumOptions,
853
905
  enumDisabled = options.enumDisabled,
854
906
  inline = options.inline;
@@ -884,34 +936,37 @@ function CheckboxesWidget(props) {
884
936
  } : {
885
937
  grouped: true
886
938
  };
887
- return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement(TitleFieldTemplate, {
888
- id: titleId(id),
889
- title: title,
890
- schema: schema,
891
- uiSchema: uiSchema,
892
- registry: registry
893
- }), /*#__PURE__*/React.createElement(Form.Group, _extends({
894
- id: id,
895
- name: id
896
- }, inlineOption), Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
897
- var checked = enumOptionsIsSelected(option.value, checkboxesValues);
898
- var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
899
- return /*#__PURE__*/React.createElement(Form.Checkbox, _extends({
900
- id: optionId(id, index),
901
- name: id,
902
- key: index,
903
- label: option.label
904
- }, semanticProps, {
905
- checked: checked,
906
- error: rawErrors.length > 0,
907
- disabled: disabled || itemDisabled || readonly,
908
- autoFocus: autofocus && index === 0,
909
- onChange: _onChange(index),
910
- onBlur: _onBlur,
911
- onFocus: _onFocus,
912
- "aria-describedby": ariaDescribedByIds(id)
913
- }));
914
- })));
939
+ return jsxs(Fragment, {
940
+ children: [title && jsx(TitleFieldTemplate, {
941
+ id: titleId(id),
942
+ title: title,
943
+ schema: schema,
944
+ uiSchema: uiSchema,
945
+ registry: registry
946
+ }), jsx(Form.Group, _extends({
947
+ id: id,
948
+ name: id
949
+ }, inlineOption, {
950
+ children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
951
+ var checked = enumOptionsIsSelected(option.value, checkboxesValues);
952
+ var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
953
+ return jsx(Form.Checkbox, _extends({
954
+ id: optionId(id, index),
955
+ name: id,
956
+ label: option.label
957
+ }, semanticProps, {
958
+ checked: checked,
959
+ error: rawErrors.length > 0,
960
+ disabled: disabled || itemDisabled || readonly,
961
+ autoFocus: autofocus && index === 0,
962
+ onChange: _onChange(index),
963
+ onBlur: _onBlur,
964
+ onFocus: _onFocus,
965
+ "aria-describedby": ariaDescribedByIds(id)
966
+ }), index);
967
+ })
968
+ }))]
969
+ });
915
970
  }
916
971
 
917
972
  /** The `RadioWidget` is a widget for rendering a radio group.
@@ -956,26 +1011,28 @@ function RadioWidget(props) {
956
1011
  } : {
957
1012
  grouped: true
958
1013
  };
959
- return /*#__PURE__*/React.createElement(Form.Group, _extends({}, inlineOption), Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
960
- var checked = enumOptionsIsSelected(option.value, value);
961
- var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
962
- return /*#__PURE__*/React.createElement(Form.Field, _extends({
963
- required: required,
964
- control: Radio,
965
- id: optionId(id, index),
966
- name: id
967
- }, semanticProps, {
968
- onFocus: _onFocus,
969
- onBlur: _onBlur,
970
- onChange: _onChange,
971
- label: option.label,
972
- value: String(index),
973
- error: rawErrors.length > 0,
974
- key: index,
975
- checked: checked,
976
- disabled: disabled || itemDisabled || readonly,
977
- "aria-describedby": ariaDescribedByIds(id)
978
- }));
1014
+ return jsx(Form.Group, _extends({}, inlineOption, {
1015
+ children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
1016
+ var checked = enumOptionsIsSelected(option.value, value);
1017
+ var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
1018
+ return /*#__PURE__*/createElement(Form.Field, _extends({
1019
+ required: required,
1020
+ control: Radio,
1021
+ id: optionId(id, index),
1022
+ name: id
1023
+ }, semanticProps, {
1024
+ onFocus: _onFocus,
1025
+ onBlur: _onBlur,
1026
+ onChange: _onChange,
1027
+ label: option.label,
1028
+ value: String(index),
1029
+ error: rawErrors.length > 0,
1030
+ key: index,
1031
+ checked: checked,
1032
+ disabled: disabled || itemDisabled || readonly,
1033
+ "aria-describedby": ariaDescribedByIds(id)
1034
+ }));
1035
+ })
979
1036
  }));
980
1037
  }
981
1038
 
@@ -1010,7 +1067,7 @@ function RangeWidget(props) {
1010
1067
  // eslint-disable-next-line no-shadow
1011
1068
  var _onChange = function _onChange(_ref) {
1012
1069
  var value = _ref.target.value;
1013
- return onChange && onChange(value === "" ? options.emptyValue : value);
1070
+ return onChange && onChange(value === '' ? options.emptyValue : value);
1014
1071
  };
1015
1072
  var _onBlur = function _onBlur() {
1016
1073
  return onBlur && onBlur(id, value);
@@ -1018,21 +1075,24 @@ function RangeWidget(props) {
1018
1075
  var _onFocus = function _onFocus() {
1019
1076
  return onFocus && onFocus(id, value);
1020
1077
  };
1021
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Input, _extends({
1022
- id: id,
1023
- key: id,
1024
- name: id,
1025
- type: "range",
1026
- required: required,
1027
- disabled: disabled || readonly
1028
- }, rangeSpec(schema), semanticProps, {
1029
- value: value || "",
1030
- error: rawErrors.length > 0,
1031
- onChange: _onChange,
1032
- onBlur: _onBlur,
1033
- onFocus: _onFocus,
1034
- "aria-describedby": ariaDescribedByIds(id)
1035
- })), /*#__PURE__*/React.createElement("span", null, value));
1078
+ return jsxs(Fragment, {
1079
+ children: [jsx(Input, _extends({
1080
+ id: id,
1081
+ name: id,
1082
+ type: 'range',
1083
+ required: required,
1084
+ disabled: disabled || readonly
1085
+ }, rangeSpec(schema), semanticProps, {
1086
+ value: value || '',
1087
+ error: rawErrors.length > 0,
1088
+ onChange: _onChange,
1089
+ onBlur: _onBlur,
1090
+ onFocus: _onFocus,
1091
+ "aria-describedby": ariaDescribedByIds(id)
1092
+ }), id), jsx("span", {
1093
+ children: value
1094
+ })]
1095
+ });
1036
1096
  }
1037
1097
 
1038
1098
  /**
@@ -1084,7 +1144,7 @@ function SelectWidget(props) {
1084
1144
  formContext: formContext,
1085
1145
  options: options,
1086
1146
  defaultSchemaProps: {
1087
- inverted: "false",
1147
+ inverted: 'false',
1088
1148
  selection: true,
1089
1149
  fluid: true,
1090
1150
  scrolling: true,
@@ -1094,7 +1154,7 @@ function SelectWidget(props) {
1094
1154
  var enumDisabled = options.enumDisabled,
1095
1155
  enumOptions = options.enumOptions,
1096
1156
  optEmptyVal = options.emptyValue;
1097
- var emptyValue = multiple ? [] : "";
1157
+ var emptyValue = multiple ? [] : '';
1098
1158
  var dropdownOptions = createDefaultValueOptionsForDropDown(enumOptions, enumDisabled);
1099
1159
  var _onChange = function _onChange(_, _ref2) {
1100
1160
  var value = _ref2.value;
@@ -1110,13 +1170,12 @@ function SelectWidget(props) {
1110
1170
  return onFocus(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
1111
1171
  };
1112
1172
  var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
1113
- return /*#__PURE__*/React.createElement(Form.Dropdown, _extends({
1114
- key: id,
1173
+ return jsx(Form.Dropdown, _extends({
1115
1174
  id: id,
1116
1175
  name: id,
1117
1176
  label: label || schema.title,
1118
- multiple: typeof multiple === "undefined" ? false : multiple,
1119
- value: typeof value === "undefined" ? emptyValue : selectedIndexes,
1177
+ multiple: typeof multiple === 'undefined' ? false : multiple,
1178
+ value: typeof value === 'undefined' ? emptyValue : selectedIndexes,
1120
1179
  error: rawErrors.length > 0,
1121
1180
  disabled: disabled,
1122
1181
  placeholder: placeholder
@@ -1129,7 +1188,7 @@ function SelectWidget(props) {
1129
1188
  onBlur: _onBlur,
1130
1189
  onFocus: _onFocus,
1131
1190
  "aria-describedby": ariaDescribedByIds(id)
1132
- }));
1191
+ }), id);
1133
1192
  }
1134
1193
 
1135
1194
  /** The `TextareaWidget` is a widget for rendering input fields as textarea.
@@ -1166,7 +1225,7 @@ function TextareaWidget(props) {
1166
1225
  // eslint-disable-next-line no-shadow
1167
1226
  var _onChange = function _onChange(_ref) {
1168
1227
  var value = _ref.target.value;
1169
- return onChange && onChange(value === "" ? options.emptyValue : value);
1228
+ return onChange && onChange(value === '' ? options.emptyValue : value);
1170
1229
  };
1171
1230
  var _onBlur = function _onBlur() {
1172
1231
  return onBlur && onBlur(id, value);
@@ -1175,9 +1234,8 @@ function TextareaWidget(props) {
1175
1234
  return onFocus && onFocus(id, value);
1176
1235
  };
1177
1236
  var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
1178
- return /*#__PURE__*/React.createElement(Form.TextArea, _extends({
1237
+ return jsx(Form.TextArea, _extends({
1179
1238
  id: id,
1180
- key: id,
1181
1239
  name: id,
1182
1240
  label: displayLabel ? label || schema.title : false,
1183
1241
  placeholder: placeholder,
@@ -1185,14 +1243,14 @@ function TextareaWidget(props) {
1185
1243
  required: required,
1186
1244
  disabled: disabled || readonly
1187
1245
  }, semanticProps, {
1188
- value: value || "",
1246
+ value: value || '',
1189
1247
  error: rawErrors.length > 0,
1190
1248
  rows: options.rows || 5,
1191
1249
  onChange: _onChange,
1192
1250
  onBlur: _onBlur,
1193
1251
  onFocus: _onFocus,
1194
1252
  "aria-describedby": ariaDescribedByIds(id)
1195
- }));
1253
+ }), id);
1196
1254
  }
1197
1255
 
1198
1256
  function generateWidgets() {