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