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