@rjsf/semantic-ui 5.0.0-beta.9 → 5.0.1

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