@rjsf/semantic-ui 5.0.0-beta.8 → 5.0.0

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