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