@rjsf/semantic-ui 5.0.0-beta.2 → 5.0.0-beta.20

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