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

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 (49) hide show
  1. package/README.md +3 -3
  2. package/dist/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +2 -0
  3. package/dist/ArrayFieldItemTemplate/index.d.ts +2 -0
  4. package/dist/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +17 -1
  5. package/dist/BaseInputTemplate/BaseInputTemplate.d.ts +2 -0
  6. package/dist/BaseInputTemplate/index.d.ts +2 -0
  7. package/dist/DescriptionField/DescriptionField.d.ts +2 -1
  8. package/dist/ErrorList/ErrorList.d.ts +1 -2
  9. package/dist/FieldTemplate/FieldTemplate.d.ts +4 -2
  10. package/dist/FieldTemplate/WrapIfAdditional.d.ts +2 -1
  11. package/dist/HelpField/HelpField.d.ts +2 -3
  12. package/dist/IconButton/IconButton.d.ts +5 -3
  13. package/dist/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +2 -3
  14. package/dist/RawErrors/RawErrors.d.ts +2 -3
  15. package/dist/SemanticUIForm/SemanticUIForm.d.ts +1 -2
  16. package/dist/Templates/Templates.d.ts +31 -0
  17. package/dist/Templates/index.d.ts +2 -0
  18. package/dist/Theme/Theme.d.ts +4 -30
  19. package/dist/TitleField/TitleField.d.ts +3 -17
  20. package/dist/Widgets/Widgets.d.ts +0 -16
  21. package/dist/index.d.ts +2 -5
  22. package/dist/semantic-ui.cjs.development.js +754 -1126
  23. package/dist/semantic-ui.cjs.development.js.map +1 -1
  24. package/dist/semantic-ui.cjs.production.min.js +1 -1
  25. package/dist/semantic-ui.cjs.production.min.js.map +1 -1
  26. package/dist/semantic-ui.esm.js +754 -1123
  27. package/dist/semantic-ui.esm.js.map +1 -1
  28. package/dist/semantic-ui.umd.development.js +757 -1130
  29. package/dist/semantic-ui.umd.development.js.map +1 -1
  30. package/dist/semantic-ui.umd.production.min.js +1 -1
  31. package/dist/semantic-ui.umd.production.min.js.map +1 -1
  32. package/dist/util.d.ts +2 -2
  33. package/package.json +35 -68
  34. package/dist/DateTimeWidget/DateTimeWidget.d.ts +0 -2
  35. package/dist/DateTimeWidget/index.d.ts +0 -2
  36. package/dist/DateWidget/DateWidget.d.ts +0 -2
  37. package/dist/DateWidget/index.d.ts +0 -2
  38. package/dist/EmailWidget/EmailWidget.d.ts +0 -2
  39. package/dist/EmailWidget/index.d.ts +0 -2
  40. package/dist/Fields/Fields.d.ts +0 -7
  41. package/dist/Fields/index.d.ts +0 -2
  42. package/dist/PasswordWidget/PasswordWidget.d.ts +0 -2
  43. package/dist/PasswordWidget/index.d.ts +0 -2
  44. package/dist/TextWidget/TextWidget.d.ts +0 -2
  45. package/dist/TextWidget/index.d.ts +0 -2
  46. package/dist/URLWidget/URLWidget.d.ts +0 -2
  47. package/dist/URLWidget/index.d.ts +0 -2
  48. package/dist/UpDownWidget/UpDownWidget.d.ts +0 -2
  49. package/dist/UpDownWidget/index.d.ts +0 -2
@@ -7,12 +7,13 @@ function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'defau
7
7
  var core = require('@rjsf/core');
8
8
  var semanticUiReact = require('semantic-ui-react');
9
9
  var React = _interopDefault(require('react'));
10
+ var utils = require('@rjsf/utils');
10
11
  var PropTypes = _interopDefault(require('prop-types'));
11
12
  var nanoid = require('nanoid');
12
13
  var _ = _interopDefault(require('lodash'));
13
14
 
14
15
  function _extends() {
15
- _extends = Object.assign || function (target) {
16
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
16
17
  for (var i = 1; i < arguments.length; i++) {
17
18
  var source = arguments[i];
18
19
 
@@ -25,33 +26,19 @@ function _extends() {
25
26
 
26
27
  return target;
27
28
  };
28
-
29
29
  return _extends.apply(this, arguments);
30
30
  }
31
31
 
32
- function _objectWithoutPropertiesLoose(source, excluded) {
33
- if (source == null) return {};
34
- var target = {};
35
- var sourceKeys = Object.keys(source);
36
- var key, i;
37
-
38
- for (i = 0; i < sourceKeys.length; i++) {
39
- key = sourceKeys[i];
40
- if (excluded.indexOf(key) >= 0) continue;
41
- target[key] = source[key];
42
- }
43
-
44
- return target;
45
- }
46
-
47
32
  function AddButton(props) {
48
- return React.createElement(semanticUiReact.Button, _extends({}, props, {
33
+ return /*#__PURE__*/React.createElement(semanticUiReact.Button, _extends({
34
+ title: "Add Item"
35
+ }, props, {
49
36
  icon: true,
50
37
  size: "tiny",
51
38
  labelPosition: "left"
52
- }), React.createElement(semanticUiReact.Icon, {
39
+ }), /*#__PURE__*/React.createElement(semanticUiReact.Icon, {
53
40
  name: "plus"
54
- }), "Add Item");
41
+ }));
55
42
  }
56
43
 
57
44
  /**
@@ -67,24 +54,23 @@ function AddButton(props) {
67
54
  */
68
55
 
69
56
  function getSemanticProps(_ref) {
70
- var _ref$formContext = _ref.formContext,
71
- formContext = _ref$formContext === void 0 ? {} : _ref$formContext,
72
- _ref$uiSchema = _ref.uiSchema,
73
- uiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
74
- _ref$options = _ref.options,
75
- options = _ref$options === void 0 ? {} : _ref$options,
76
- _ref$defaultSchemaPro = _ref.defaultSchemaProps,
77
- defaultSchemaProps = _ref$defaultSchemaPro === void 0 ? {
78
- fluid: true,
79
- inverted: false
80
- } : _ref$defaultSchemaPro,
81
- _ref$defaultContextPr = _ref.defaultContextProps,
82
- defaultContextProps = _ref$defaultContextPr === void 0 ? {} : _ref$defaultContextPr;
83
- var formContextProps = formContext.semantic;
84
- var schemaProps = uiSchema["ui:options"] && uiSchema["ui:options"].semantic;
85
- var optionProps = options.semantic; // formContext props should overide other props
86
-
87
- return Object.assign({}, _extends({}, defaultSchemaProps && defaultSchemaProps), _extends({}, defaultContextProps && defaultContextProps), schemaProps, optionProps, formContextProps);
57
+ let {
58
+ formContext = {},
59
+ uiSchema = {},
60
+ options = {},
61
+ defaultSchemaProps = {
62
+ fluid: true,
63
+ 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);
88
74
  }
89
75
  /**
90
76
  * Extract error props meant for semantic UI components from props that are
@@ -97,21 +83,20 @@ function getSemanticProps(_ref) {
97
83
  */
98
84
 
99
85
  function getSemanticErrorProps(_ref2) {
100
- var _ref2$formContext = _ref2.formContext,
101
- formContext = _ref2$formContext === void 0 ? {} : _ref2$formContext,
102
- _ref2$uiSchema = _ref2.uiSchema,
103
- uiSchema = _ref2$uiSchema === void 0 ? {} : _ref2$uiSchema,
104
- _ref2$options = _ref2.options,
105
- options = _ref2$options === void 0 ? {} : _ref2$options,
106
- _ref2$defaultProps = _ref2.defaultProps,
107
- defaultProps = _ref2$defaultProps === void 0 ? {
108
- size: 'small',
109
- pointing: 'above'
110
- } : _ref2$defaultProps;
111
- var formContextProps = formContext.semantic && formContext.semantic.errorOptions;
112
- var schemaProps = uiSchema["ui:options"] && uiSchema["ui:options"].semantic && uiSchema["ui:options"].semantic.errorOptions;
113
- var optionProps = options.semantic && options.semantic.errorOptions;
114
- return Object.assign({}, _extends({}, defaultProps && defaultProps), schemaProps, optionProps, formContextProps);
86
+ let {
87
+ formContext = {},
88
+ uiSchema = {},
89
+ options = {},
90
+ defaultProps = {
91
+ size: "small",
92
+ 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);
115
100
  }
116
101
  /**
117
102
  * Combine multiple strings containing class names into a single string,
@@ -130,14 +115,10 @@ function cleanClassNames(classNameArr, omit) {
130
115
 
131
116
  // Split each arg on whitespace, and add it to an array. Skip false-y args
132
117
  // like "" and undefined.
133
- var classList = classNameArr.filter(Boolean).reduce(function (previous, current) {
134
- return previous.concat(current.trim().split(/\s+/));
135
- }, []); // Remove any class names from omit, and make the rest unique before
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
136
119
  // returning them as a string
137
120
 
138
- return [].concat(new Set(classList.filter(function (cn) {
139
- return !omit.includes(cn);
140
- }))).join(" ");
121
+ return [...new Set(classList.filter(cn => !omit.includes(cn)))].join(" ");
141
122
  }
142
123
  /**
143
124
  *
@@ -149,235 +130,237 @@ function cleanClassNames(classNameArr, omit) {
149
130
  */
150
131
 
151
132
  function MaybeWrap(_ref3) {
152
- var wrap = _ref3.wrap,
153
- _ref3$component = _ref3.component,
154
- Component = _ref3$component === void 0 ? "div" : _ref3$component,
155
- props = _objectWithoutPropertiesLoose(_ref3, ["wrap", "component"]);
156
-
157
- return wrap ? React.createElement(Component, props) : props.children;
133
+ let {
134
+ wrap,
135
+ component: Component = "div",
136
+ ...props
137
+ } = _ref3;
138
+ return wrap ? /*#__PURE__*/React.createElement(Component, props) : props.children;
158
139
  }
159
140
 
160
- var isFixedItems = core.utils.isFixedItems;
161
-
162
- var ArrayFieldTitle = function ArrayFieldTitle(_ref) {
163
- var TitleField = _ref.TitleField,
164
- idSchema = _ref.idSchema,
165
- uiSchema = _ref.uiSchema,
166
- title = _ref.title;
167
-
168
- if (!title) {
169
- return null;
170
- }
171
-
172
- var id = idSchema.$id + "__title";
173
- return React.createElement(TitleField, {
174
- id: id,
175
- title: title,
176
- options: uiSchema["ui:options"]
177
- });
178
- };
179
-
180
- function ArrayFieldDescription(_ref2) {
181
- var DescriptionField = _ref2.DescriptionField,
182
- idSchema = _ref2.idSchema,
183
- description = _ref2.description;
184
-
185
- if (!description) {
186
- // See #312: Ensure compatibility with old versions of React.
187
- return null;
188
- }
189
-
190
- var id = idSchema.$id + "__description";
191
- return React.createElement(DescriptionField, {
192
- id: id,
193
- description: description
194
- });
195
- }
196
-
197
- var gridStyle = function gridStyle(vertical) {
198
- return {
199
- display: "grid",
200
- gridTemplateColumns: "1fr " + (vertical ? 65 : 110) + "px"
201
- };
202
- }; // checks if its the first array item
141
+ const gridStyle = vertical => ({
142
+ display: "grid",
143
+ gridTemplateColumns: "1fr " + (vertical ? 65 : 110) + "px"
144
+ }); // checks if it's the first array item
203
145
 
204
146
 
205
147
  function isInitialArrayItem(props) {
206
148
  // no underscore because im not sure if we want to import a library here
207
- var idSchema = props.children.props.idSchema;
149
+ const {
150
+ idSchema
151
+ } = props.children.props;
208
152
  return idSchema.target && idSchema.conditions;
209
- } // Used in the two templates
210
-
153
+ }
211
154
 
212
- function DefaultArrayItem(props) {
213
- return React.createElement("div", {
214
- className: "array-item",
215
- key: props.key
216
- }, React.createElement(MaybeWrap, {
217
- wrap: props.wrapItem,
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", {
177
+ className: "array-item"
178
+ }, /*#__PURE__*/React.createElement(MaybeWrap, {
179
+ wrap: wrapItem,
218
180
  component: semanticUiReact.Segment
219
- }, React.createElement(semanticUiReact.Grid, {
220
- style: !isInitialArrayItem(props) ? _extends({}, gridStyle(!props.horizontalButtons), {
181
+ }, /*#__PURE__*/React.createElement(semanticUiReact.Grid, {
182
+ style: !isInitialArrayItem(props) ? { ...gridStyle(!horizontalButtons),
221
183
  alignItems: "center"
222
- }) : gridStyle(!props.horizontalButtons)
223
- }, React.createElement(semanticUiReact.Grid.Column, {
184
+ } : gridStyle(!horizontalButtons)
185
+ }, /*#__PURE__*/React.createElement(semanticUiReact.Grid.Column, {
224
186
  width: 16,
225
187
  verticalAlign: "middle"
226
- }, props.children), props.hasToolbar && React.createElement(semanticUiReact.Grid.Column, null, (props.hasMoveUp || props.hasMoveDown || props.hasRemove) && React.createElement(semanticUiReact.Button.Group, {
188
+ }, children), hasToolbar && /*#__PURE__*/React.createElement(semanticUiReact.Grid.Column, null, (hasMoveUp || hasMoveDown || hasRemove) && /*#__PURE__*/React.createElement(semanticUiReact.Button.Group, {
227
189
  size: "mini",
228
- vertical: !props.horizontalButtons
229
- }, (props.hasMoveUp || props.hasMoveDown) && React.createElement(semanticUiReact.Button, {
230
- icon: "angle up",
190
+ vertical: !horizontalButtons
191
+ }, (hasMoveUp || hasMoveDown) && /*#__PURE__*/React.createElement(MoveUpButton, {
231
192
  className: "array-item-move-up",
232
- tabIndex: "-1",
233
- disabled: props.disabled || props.readOnly || !props.hasMoveUp,
234
- onClick: props.onReorderClick(props.index, props.index - 1)
235
- }), (props.hasMoveUp || props.hasMoveDown) && React.createElement(semanticUiReact.Button, {
236
- icon: "angle down",
193
+ disabled: disabled || readonly || !hasMoveUp,
194
+ onClick: onReorderClick(index, index - 1)
195
+ }), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React.createElement(MoveDownButton, {
237
196
  className: "array-item-move-down",
238
- tabIndex: "-1",
239
- disabled: props.disabled || props.readOnly || !props.hasMoveDown,
240
- onClick: props.onReorderClick(props.index, props.index + 1)
241
- }), props.hasRemove && React.createElement(semanticUiReact.Button, {
242
- icon: "trash",
197
+ disabled: disabled || readonly || !hasMoveDown,
198
+ onClick: onReorderClick(index, index + 1)
199
+ }), hasRemove && /*#__PURE__*/React.createElement(RemoveButton, {
243
200
  className: "array-item-remove",
244
- tabIndex: "-1",
245
- disabled: props.disabled || props.readOnly,
246
- onClick: props.onDropIndexClick(props.index)
201
+ disabled: disabled || readonly,
202
+ onClick: onDropIndexClick(index)
247
203
  }))))));
248
- } // Used for arrays that are represented as multiple selection fields
249
- // (displayed as a multi select or checkboxes)
250
-
251
-
252
- function DefaultFixedArrayFieldTemplate(_ref3) {
253
- var uiSchema = _ref3.uiSchema,
254
- idSchema = _ref3.idSchema,
255
- canAdd = _ref3.canAdd,
256
- className = _ref3.className,
257
- classNames = _ref3.classNames,
258
- disabled = _ref3.disabled,
259
- items = _ref3.items,
260
- onAddClick = _ref3.onAddClick,
261
- readOnly = _ref3.readOnly,
262
- required = _ref3.required,
263
- schema = _ref3.schema,
264
- title = _ref3.title,
265
- TitleField = _ref3.TitleField,
266
- itemProps = _ref3.itemProps;
267
- var fieldTitle = uiSchema["ui:title"] || title;
268
- var fieldDescription = uiSchema["ui:description"] || schema.description;
269
- return React.createElement("div", {
270
- className: cleanClassNames([className, classNames])
271
- }, React.createElement(ArrayFieldTitle, {
272
- key: "array-field-title-" + idSchema.$id,
273
- TitleField: TitleField,
274
- idSchema: idSchema,
275
- uiSchema: uiSchema,
276
- title: fieldTitle,
277
- required: required
278
- }), fieldDescription && React.createElement("div", {
279
- className: "field-description",
280
- key: "field-description-" + idSchema.$id
281
- }, fieldDescription), React.createElement("div", {
282
- key: "array-item-list-" + idSchema.$id
283
- }, React.createElement("div", {
284
- className: "row array-item-list"
285
- }, items && items.map(function (p) {
286
- return DefaultArrayItem(_extends({}, p, itemProps));
287
- })), canAdd && React.createElement("div", {
288
- style: {
289
- marginTop: "1rem",
290
- position: "relative",
291
- textAlign: "right"
292
- }
293
- }, React.createElement(AddButton, {
294
- onClick: onAddClick,
295
- disabled: disabled || readOnly
296
- }))));
297
- }
204
+ };
298
205
 
299
- function DefaultNormalArrayFieldTemplate(_ref4) {
300
- var uiSchema = _ref4.uiSchema,
301
- idSchema = _ref4.idSchema,
302
- canAdd = _ref4.canAdd,
303
- className = _ref4.className,
304
- classNames = _ref4.classNames,
305
- disabled = _ref4.disabled,
306
- DescriptionField = _ref4.DescriptionField,
307
- items = _ref4.items,
308
- onAddClick = _ref4.onAddClick,
309
- readOnly = _ref4.readOnly,
310
- required = _ref4.required,
311
- schema = _ref4.schema,
312
- title = _ref4.title,
313
- TitleField = _ref4.TitleField,
314
- itemProps = _ref4.itemProps;
315
- var fieldTitle = uiSchema["ui:title"] || title;
316
- var fieldDescription = uiSchema["ui:description"] || schema.description;
317
- return React.createElement("div", {
318
- className: cleanClassNames([className, classNames, "sortable-form-fields"])
319
- }, React.createElement(ArrayFieldTitle, {
320
- key: "array-field-title-" + idSchema.$id,
321
- TitleField: TitleField,
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,
228
+ defaultSchemaProps: {
229
+ horizontalButtons: false,
230
+ wrapItem: false
231
+ }
232
+ });
233
+ const {
234
+ horizontalButtons,
235
+ wrapItem
236
+ } = semanticProps;
237
+ const itemProps = {
238
+ horizontalButtons,
239
+ wrapItem
240
+ };
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, {
322
256
  idSchema: idSchema,
323
- uiSchema: uiSchema,
324
257
  title: fieldTitle,
325
- required: required
326
- }), fieldDescription && React.createElement(ArrayFieldDescription, {
327
- key: "array-field-description-" + idSchema.$id,
328
- DescriptionField: DescriptionField,
258
+ uiSchema: uiSchema,
259
+ required: required,
260
+ registry: registry
261
+ }), fieldDescription && /*#__PURE__*/React.createElement(ArrayFieldDescriptionTemplate, {
329
262
  idSchema: idSchema,
330
- description: fieldDescription
331
- }), React.createElement("div", {
263
+ description: fieldDescription,
264
+ uiSchema: uiSchema,
265
+ registry: registry
266
+ }), /*#__PURE__*/React.createElement("div", {
332
267
  key: "array-item-list-" + idSchema.$id
333
- }, React.createElement("div", {
268
+ }, /*#__PURE__*/React.createElement("div", {
334
269
  className: "row array-item-list"
335
- }, items && items.map(function (p) {
336
- return DefaultArrayItem(_extends({}, p, itemProps));
337
- })), canAdd && React.createElement("div", {
270
+ }, items && items.map(props => /*#__PURE__*/React.createElement(ArrayFieldItemTemplate, _extends({}, props, itemProps)))), canAdd && /*#__PURE__*/React.createElement("div", {
338
271
  style: {
339
272
  marginTop: "1rem",
340
273
  position: "relative",
341
274
  textAlign: "right"
342
275
  }
343
- }, React.createElement(AddButton, {
276
+ }, /*#__PURE__*/React.createElement(AddButton, {
344
277
  onClick: onAddClick,
345
278
  disabled: disabled || readOnly
346
279
  }))));
347
280
  }
348
281
 
349
- function ArrayFieldTemplate(props) {
350
- var options = props.options,
351
- schema = props.schema,
352
- uiSchema = props.uiSchema,
353
- formContext = props.formContext;
354
- var semanticProps = getSemanticProps({
355
- options: options,
356
- uiSchema: uiSchema,
357
- formContext: formContext,
358
- defaultSchemaProps: {
359
- horizontalButtons: false,
360
- wrapItem: false
361
- }
282
+ 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
362
309
  });
363
- var horizontalButtons = semanticProps.horizontalButtons,
364
- wrapItem = semanticProps.wrapItem;
365
- var itemProps = {
366
- horizontalButtons: horizontalButtons,
367
- wrapItem: wrapItem
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;
320
+ return onChange(value === "" ? options.emptyValue : value);
368
321
  };
369
322
 
370
- if (isFixedItems(schema)) {
371
- return React.createElement(DefaultFixedArrayFieldTemplate, _extends({}, props, {
372
- itemProps: itemProps
373
- }));
374
- }
323
+ const _onBlur = () => onBlur && onBlur(id, value);
324
+
325
+ const _onFocus = () => onFocus && onFocus(id, value);
375
326
 
376
- return React.createElement(DefaultNormalArrayFieldTemplate, _extends({}, props, {
377
- itemProps: itemProps
327
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
328
+ return /*#__PURE__*/React.createElement(semanticUiReact.Form.Input, _extends({
329
+ key: id,
330
+ id: id,
331
+ placeholder: placeholder
332
+ }, inputProps, {
333
+ label: displayLabel ? label || schema.title : false,
334
+ required: required,
335
+ autoFocus: autofocus,
336
+ disabled: disabled || readonly,
337
+ name: name
338
+ }, semanticProps, {
339
+ value: value || value === 0 ? value : "",
340
+ error: rawErrors.length > 0,
341
+ onChange: _onChange,
342
+ onBlur: _onBlur,
343
+ onFocus: _onFocus
378
344
  }));
379
345
  }
380
346
 
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);
361
+ }
362
+ }
363
+
381
364
  /* eslint-disable react/no-array-index-key */
382
365
  /**
383
366
  *
@@ -387,61 +370,59 @@ function ArrayFieldTemplate(props) {
387
370
  */
388
371
 
389
372
  function ErrorList(_ref) {
390
- var errors = _ref.errors;
391
- return React.createElement(semanticUiReact.Message, {
373
+ let {
374
+ errors
375
+ } = _ref;
376
+ return /*#__PURE__*/React.createElement(semanticUiReact.Message, {
392
377
  negative: true
393
- }, React.createElement(semanticUiReact.Message.Header, null, "Errors"), React.createElement(semanticUiReact.Message.List, null, errors.map(function (error, index) {
394
- return React.createElement(semanticUiReact.Message.Item, {
395
- key: "error-" + index
396
- }, error.stack);
397
- })));
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))));
398
381
  }
399
382
 
400
383
  ErrorList.propTypes = {
401
384
  errors: PropTypes.array
402
385
  };
403
386
 
404
- /* eslint-disable react/prop-types */
405
-
406
- function DescriptionField(_ref) {
407
- var className = _ref.className,
408
- description = _ref.description;
409
-
410
- if (description) {
411
- return React.createElement("p", {
412
- className: className || "sui-description"
413
- }, description);
414
- }
415
- }
416
-
417
- function TitleField(_ref) {
418
- var title = _ref.title,
419
- options = _ref.options;
420
- var semantic = options.semantic;
421
-
422
- if (title) {
423
- return React.createElement(semanticUiReact.Header, _extends({}, semantic, {
424
- as: "h5"
425
- }), title);
426
- }
387
+ function IconButton(props) {
388
+ const {
389
+ icon,
390
+ iconType,
391
+ className,
392
+ ...otherProps
393
+ } = props;
394
+ return /*#__PURE__*/React.createElement(semanticUiReact.Button, _extends({
395
+ icon: icon,
396
+ size: iconType,
397
+ className: className
398
+ }, otherProps));
427
399
  }
428
400
 
429
- TitleField.defaultProps = {
430
- options: {
431
- semantic: {
432
- inverted: false,
433
- dividing: true
434
- }
435
- }
436
- };
437
- TitleField.propTypes = {
438
- options: PropTypes.object
439
- };
440
-
441
- var Fields = {
442
- DescriptionField: DescriptionField,
443
- TitleField: TitleField
401
+ IconButton.propTypes = {
402
+ icon: PropTypes.string.isRequired,
403
+ className: PropTypes.string
444
404
  };
405
+ function MoveDownButton(props) {
406
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
407
+ title: "Move down"
408
+ }, props, {
409
+ icon: "angle down"
410
+ }));
411
+ }
412
+ function MoveUpButton(props) {
413
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
414
+ title: "Move up"
415
+ }, props, {
416
+ icon: "angle up"
417
+ }));
418
+ }
419
+ function RemoveButton(props) {
420
+ return /*#__PURE__*/React.createElement(IconButton, _extends({
421
+ title: "Remove"
422
+ }, props, {
423
+ icon: "trash"
424
+ }));
425
+ }
445
426
 
446
427
  /* eslint-disable react/prop-types */
447
428
  /**
@@ -449,11 +430,13 @@ var Fields = {
449
430
  */
450
431
 
451
432
  function HelpField(_ref) {
452
- var helpText = _ref.helpText,
453
- id = _ref.id;
433
+ let {
434
+ helpText,
435
+ id
436
+ } = _ref;
454
437
 
455
438
  if (helpText) {
456
- return React.createElement(semanticUiReact.Message, {
439
+ return /*#__PURE__*/React.createElement(semanticUiReact.Message, {
457
440
  size: "mini",
458
441
  info: true,
459
442
  id: id,
@@ -480,25 +463,27 @@ HelpField.propTypes = {
480
463
  */
481
464
 
482
465
  function RawErrors(_ref) {
483
- var errors = _ref.errors,
484
- options = _ref.options;
485
- var pointing = options.pointing,
486
- size = options.size;
466
+ let {
467
+ errors,
468
+ options
469
+ } = _ref;
470
+ const {
471
+ pointing,
472
+ size
473
+ } = options;
487
474
 
488
475
  if (errors && errors.length > 0) {
489
- return React.createElement(semanticUiReact.Label, {
476
+ return /*#__PURE__*/React.createElement(semanticUiReact.Label, {
490
477
  color: "red",
491
478
  pointing: pointing || "above",
492
479
  size: size || "small",
493
480
  basic: true
494
- }, React.createElement(semanticUiReact.List, {
481
+ }, /*#__PURE__*/React.createElement(semanticUiReact.List, {
495
482
  bulleted: true
496
- }, errors.map(function (error) {
497
- return React.createElement(semanticUiReact.List.Item, {
498
- key: nanoid.nanoid(),
499
- content: error
500
- });
501
- })));
483
+ }, errors.map(error => /*#__PURE__*/React.createElement(semanticUiReact.List.Item, {
484
+ key: nanoid.nanoid(),
485
+ content: error
486
+ }))));
502
487
  }
503
488
 
504
489
  return null;
@@ -515,47 +500,56 @@ RawErrors.propTypes = {
515
500
  errors: PropTypes.array
516
501
  };
517
502
 
518
- var ADDITIONAL_PROPERTY_FLAG = core.utils.ADDITIONAL_PROPERTY_FLAG;
519
-
520
- var WrapIfAdditional = function WrapIfAdditional(_ref) {
521
- var children = _ref.children,
522
- classNames = _ref.classNames,
523
- disabled = _ref.disabled,
524
- formContext = _ref.formContext,
525
- id = _ref.id,
526
- label = _ref.label,
527
- onDropPropertyClick = _ref.onDropPropertyClick,
528
- onKeyChange = _ref.onKeyChange,
529
- readonly = _ref.readonly,
530
- required = _ref.required,
531
- schema = _ref.schema;
532
- var _formContext$readonly = formContext.readonlyAsDisabled,
533
- readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly,
534
- wrapperStyle = formContext.wrapperStyle;
535
- var keyLabel = label + " Key"; // i18n ?
536
-
537
- var additional = schema.hasOwnProperty(ADDITIONAL_PROPERTY_FLAG);
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);
538
528
 
539
529
  if (!additional) {
540
- return React.createElement(React.Fragment, null, children);
530
+ return /*#__PURE__*/React.createElement("div", {
531
+ className: classNames
532
+ }, children);
541
533
  }
542
534
 
543
- var handleBlur = function handleBlur(_ref2) {
544
- var target = _ref2.target;
535
+ const handleBlur = _ref2 => {
536
+ let {
537
+ target
538
+ } = _ref2;
545
539
  return onKeyChange(target.value);
546
540
  };
547
541
 
548
- return React.createElement("div", {
542
+ return /*#__PURE__*/React.createElement("div", {
549
543
  className: classNames,
550
544
  key: id + "-key"
551
- }, React.createElement(semanticUiReact.Grid, {
545
+ }, /*#__PURE__*/React.createElement(semanticUiReact.Grid, {
552
546
  columns: "equal"
553
- }, React.createElement(semanticUiReact.Grid.Row, null, React.createElement(semanticUiReact.Grid.Column, {
547
+ }, /*#__PURE__*/React.createElement(semanticUiReact.Grid.Row, null, /*#__PURE__*/React.createElement(semanticUiReact.Grid.Column, {
554
548
  className: "form-additional"
555
- }, React.createElement(semanticUiReact.Form.Group, {
549
+ }, /*#__PURE__*/React.createElement(semanticUiReact.Form.Group, {
556
550
  widths: "equal",
557
551
  grouped: true
558
- }, React.createElement(semanticUiReact.Form.Input, {
552
+ }, /*#__PURE__*/React.createElement(semanticUiReact.Form.Input, {
559
553
  className: "form-group",
560
554
  hasFeedback: true,
561
555
  fluid: true,
@@ -569,159 +563,243 @@ var WrapIfAdditional = function WrapIfAdditional(_ref) {
569
563
  onBlur: !readonly ? handleBlur : undefined,
570
564
  style: wrapperStyle,
571
565
  type: "text"
572
- }))), React.createElement(semanticUiReact.Grid.Column, {
566
+ }))), /*#__PURE__*/React.createElement(semanticUiReact.Grid.Column, {
573
567
  className: "form-additional",
574
568
  verticalAlign: "middle"
575
- }, children), React.createElement(semanticUiReact.Grid.Column, null, React.createElement(semanticUiReact.Button, {
576
- size: "mini",
577
- icon: "trash",
569
+ }, children), /*#__PURE__*/React.createElement(semanticUiReact.Grid.Column, null, /*#__PURE__*/React.createElement(RemoveButton, {
570
+ iconType: "mini",
578
571
  className: "array-item-remove",
579
- tabIndex: "-1",
580
572
  disabled: disabled || readonly,
581
573
  onClick: onDropPropertyClick(label)
582
574
  })))));
583
575
  };
584
576
 
585
577
  function FieldTemplate(_ref) {
586
- var id = _ref.id,
587
- children = _ref.children,
588
- classNames = _ref.classNames,
589
- displayLabel = _ref.displayLabel,
590
- label = _ref.label,
591
- _ref$rawErrors = _ref.rawErrors,
592
- rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors,
593
- rawHelp = _ref.rawHelp,
594
- hidden = _ref.hidden,
595
- rawDescription = _ref.rawDescription,
596
- props = _objectWithoutPropertiesLoose(_ref, ["id", "children", "className", "classNames", "displayLabel", "label", "rawErrors", "rawHelp", "hidden", "rawDescription"]);
597
-
598
- var semanticProps = getSemanticProps(props);
599
- var wrapLabel = semanticProps.wrapLabel,
600
- wrapContent = semanticProps.wrapContent;
601
- var errorOptions = getSemanticErrorProps(props);
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
602
 
603
603
  if (hidden) {
604
- return children;
604
+ return /*#__PURE__*/React.createElement("div", {
605
+ style: {
606
+ display: "none"
607
+ }
608
+ }, children);
605
609
  }
606
610
 
607
- return React.createElement(WrapIfAdditional, _extends({
611
+ return /*#__PURE__*/React.createElement(WrapIfAdditional, _extends({
608
612
  classNames: classNames,
609
613
  id: id,
610
- label: label
611
- }, props), React.createElement(semanticUiReact.Form.Group, {
614
+ label: label,
615
+ registry: registry
616
+ }, props), /*#__PURE__*/React.createElement(semanticUiReact.Form.Group, {
612
617
  key: id,
613
618
  widths: "equal",
614
619
  grouped: true
615
- }, React.createElement(MaybeWrap, {
620
+ }, /*#__PURE__*/React.createElement(MaybeWrap, {
616
621
  wrap: wrapContent,
617
622
  className: "sui-field-content"
618
- }, children, displayLabel && rawDescription && React.createElement(MaybeWrap, {
623
+ }, children, displayLabel && rawDescription && /*#__PURE__*/React.createElement(MaybeWrap, {
619
624
  wrap: wrapLabel,
620
625
  className: "sui-field-label"
621
- }, rawDescription && React.createElement(DescriptionField, {
626
+ }, rawDescription && /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
627
+ id: id + "-description",
622
628
  description: rawDescription
623
- })), React.createElement(HelpField, {
629
+ })), /*#__PURE__*/React.createElement(HelpField, {
624
630
  helpText: rawHelp,
625
631
  id: id + "__help"
626
- }), React.createElement(RawErrors, {
632
+ }), /*#__PURE__*/React.createElement(RawErrors, {
627
633
  errors: rawErrors,
628
634
  options: errorOptions
629
635
  }))));
630
636
  }
631
637
 
632
638
  /* eslint-disable react/prop-types */
633
- var canExpand = core.utils.canExpand;
634
639
 
635
640
  function ObjectFieldTemplate(_ref) {
636
- var DescriptionField = _ref.DescriptionField,
637
- description = _ref.description,
638
- TitleField = _ref.TitleField,
639
- onAddClick = _ref.onAddClick,
640
- title = _ref.title,
641
- properties = _ref.properties,
642
- disabled = _ref.disabled,
643
- readOnly = _ref.readOnly,
644
- required = _ref.required,
645
- uiSchema = _ref.uiSchema,
646
- schema = _ref.schema,
647
- formData = _ref.formData,
648
- idSchema = _ref.idSchema;
649
- var fieldTitle = uiSchema["ui:title"] || title;
650
- var fieldDescription = uiSchema["ui:description"] || description;
651
- return React.createElement(React.Fragment, null, fieldTitle && React.createElement(TitleField, {
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, {
652
667
  id: idSchema.$id + "-title",
653
668
  title: fieldTitle,
654
- options: uiSchema["ui:options"],
655
- required: required
656
- }), fieldDescription && React.createElement(DescriptionField, {
669
+ required: required,
670
+ uiSchema: uiSchema,
671
+ registry: registry
672
+ }), fieldDescription && /*#__PURE__*/React.createElement(DescriptionFieldTemplate, {
657
673
  id: idSchema.$id + "-description",
658
- description: fieldDescription
659
- }), properties.map(function (prop) {
660
- return prop.content;
661
- }), canExpand(schema, uiSchema, formData) && React.createElement(semanticUiReact.Grid.Column, {
674
+ description: fieldDescription,
675
+ registry: registry
676
+ }), properties.map(prop => prop.content), utils.canExpand(schema, uiSchema, formData) && /*#__PURE__*/React.createElement(semanticUiReact.Grid.Column, {
662
677
  width: 16,
663
678
  verticalAlign: "middle"
664
- }, React.createElement(semanticUiReact.Grid.Row, null, React.createElement("div", {
679
+ }, /*#__PURE__*/React.createElement(semanticUiReact.Grid.Row, null, /*#__PURE__*/React.createElement("div", {
665
680
  style: {
666
681
  marginTop: "1rem",
667
682
  position: "relative",
668
683
  textAlign: "right"
669
684
  }
670
- }, React.createElement(AddButton, {
685
+ }, /*#__PURE__*/React.createElement(AddButton, {
671
686
  onClick: onAddClick(schema),
672
687
  disabled: disabled || readOnly
673
688
  })))));
674
689
  }
675
690
 
676
- var getDisplayLabel = core.utils.getDisplayLabel;
691
+ var SubmitButton = (_ref => {
692
+ let {
693
+ uiSchema
694
+ } = _ref;
695
+ const {
696
+ submitText,
697
+ norender,
698
+ props: submitButtonProps
699
+ } = utils.getSubmitButtonOptions(uiSchema);
700
+
701
+ if (norender) {
702
+ return null;
703
+ }
704
+
705
+ return /*#__PURE__*/React.createElement(semanticUiReact.Button, _extends({
706
+ type: "submit",
707
+ primary: true
708
+ }, submitButtonProps), submitText);
709
+ });
710
+
711
+ const DEFAULT_OPTIONS = {
712
+ semantic: {
713
+ inverted: false,
714
+ dividing: true
715
+ }
716
+ };
717
+
718
+ 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;
728
+
729
+ if (title) {
730
+ return /*#__PURE__*/React.createElement(semanticUiReact.Header, _extends({
731
+ id: id
732
+ }, semantic, {
733
+ as: "h5"
734
+ }), title);
735
+ }
736
+ }
737
+
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
+ };
677
755
 
678
756
  function CheckboxWidget(props) {
679
- var id = props.id,
680
- value = props.value,
681
- required = props.required,
682
- disabled = props.disabled,
683
- readonly = props.readonly,
684
- label = props.label,
685
- autofocus = props.autofocus,
686
- onChange = props.onChange,
687
- onBlur = props.onBlur,
688
- options = props.options,
689
- onFocus = props.onFocus,
690
- formContext = props.formContext,
691
- schema = props.schema,
692
- uiSchema = props.uiSchema;
693
- var semanticProps = getSemanticProps({
694
- options: options,
695
- formContext: formContext,
696
- schema: schema,
697
- uiSchema: uiSchema,
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,
698
780
  defaultSchemaProps: {
699
781
  inverted: false
700
782
  }
701
783
  });
702
- var displayLabel = getDisplayLabel(schema, uiSchema
703
- /* TODO: , rootSchema */
704
- );
784
+ const {
785
+ schemaUtils
786
+ } = registry;
787
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
705
788
 
706
- var _onChange = function _onChange(event, data) {
707
- return onChange && onChange(data.checked);
708
- };
789
+ const _onChange = (event, data) => onChange && onChange(data.checked);
709
790
 
710
- var _onBlur = function _onBlur() {
711
- return onBlur && onBlur(id, value);
712
- };
791
+ const _onBlur = () => onBlur && onBlur(id, value);
713
792
 
714
- var _onFocus = function _onFocus() {
715
- return onFocus && onFocus(id, value);
716
- };
793
+ const _onFocus = () => onFocus && onFocus(id, value);
717
794
 
718
- var checked = value == "true" || value == true;
719
- return React.createElement(semanticUiReact.Form.Checkbox, _extends({
795
+ const checked = value == "true" || value == true;
796
+ return /*#__PURE__*/React.createElement(semanticUiReact.Form.Checkbox, _extends({
720
797
  id: id,
721
798
  disabled: disabled || readonly,
722
799
  autoFocus: autofocus
723
800
  }, semanticProps, {
724
801
  checked: typeof value === "undefined" ? false : checked,
802
+ error: rawErrors.length > 0,
725
803
  onChange: _onChange,
726
804
  onBlur: _onBlur,
727
805
  onFocus: _onFocus,
@@ -731,89 +809,100 @@ function CheckboxWidget(props) {
731
809
  }
732
810
 
733
811
  function selectValue(value, selected, all) {
734
- var at = all.indexOf(value);
735
- var updated = selected.slice(0, at).concat(value, selected.slice(at)); // As inserting values at predefined index positions doesn't work with empty
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
736
814
  // arrays, we need to reorder the updated selection to match the initial order
737
815
 
738
- return updated.sort(function (a, b) {
739
- return all.indexOf(a) > all.indexOf(b);
740
- });
816
+ return updated.sort((a, b) => all.indexOf(a) > all.indexOf(b));
741
817
  }
742
818
 
743
819
  function deselectValue(value, selected) {
744
- return selected.filter(function (v) {
745
- return v !== value;
746
- });
820
+ return selected.filter(v => v !== value);
747
821
  }
748
822
 
749
823
  function CheckboxesWidget(props) {
750
- var id = props.id,
751
- disabled = props.disabled,
752
- options = props.options,
753
- value = props.value,
754
- autofocus = props.autofocus,
755
- readonly = props.readonly,
756
- onChange = props.onChange,
757
- onBlur = props.onBlur,
758
- onFocus = props.onFocus,
759
- formContext = props.formContext,
760
- schema = props.schema,
761
- uiSchema = props.uiSchema;
762
- var enumOptions = options.enumOptions,
763
- enumDisabled = options.enumDisabled,
764
- inline = options.inline;
765
- var title = schema.title;
766
- var semanticProps = getSemanticProps({
767
- options: options,
768
- formContext: formContext,
769
- schema: schema,
770
- uiSchema: uiSchema,
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,
771
854
  defaultSchemaProps: {
772
855
  inverted: false
773
856
  }
774
857
  });
775
858
 
776
- var _onChange = function _onChange(option) {
777
- return function (_ref) {
778
- var checked = _ref.target.checked;
779
- // eslint-disable-next-line no-shadow
780
- var all = enumOptions.map(function (_ref2) {
781
- var value = _ref2.value;
782
- return value;
783
- });
784
-
785
- if (checked) {
786
- onChange(selectValue(option.value, value, all));
787
- } else {
788
- onChange(deselectValue(option.value, value));
859
+ const _onChange = option => _ref => {
860
+ let {
861
+ target: {
862
+ checked
789
863
  }
790
- };
791
- };
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
+ });
792
872
 
793
- var _onBlur = function _onBlur() {
794
- return onBlur && onBlur(id, value);
873
+ if (checked) {
874
+ onChange(selectValue(option.value, value, all));
875
+ } else {
876
+ onChange(deselectValue(option.value, value));
877
+ }
795
878
  };
796
879
 
797
- var _onFocus = function _onFocus() {
798
- return onFocus && onFocus(id, value);
799
- };
880
+ const _onBlur = () => onBlur && onBlur(id, value);
881
+
882
+ const _onFocus = () => onFocus && onFocus(id, value);
800
883
 
801
- var inlineOption = inline ? {
884
+ const inlineOption = inline ? {
802
885
  inline: true
803
886
  } : {
804
887
  grouped: true
805
888
  };
806
- return React.createElement(React.Fragment, null, title && React.createElement(TitleField, {
807
- title: title
808
- }), React.createElement(semanticUiReact.Form.Group, inlineOption, enumOptions.map(function (option, index) {
809
- var checked = value.indexOf(option.value) !== -1;
810
- var itemDisabled = enumDisabled && enumDisabled.indexOf(option.value) !== -1;
811
- return React.createElement(semanticUiReact.Form.Checkbox, _extends({
889
+ return /*#__PURE__*/React.createElement(React.Fragment, null, title && /*#__PURE__*/React.createElement(TitleFieldTemplate, {
890
+ id: id + "-title",
891
+ title: title,
892
+ uiSchema: uiSchema,
893
+ 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({
812
900
  id: id + "_" + index,
813
901
  key: id + "_" + index,
814
902
  label: option.label
815
903
  }, semanticProps, {
816
904
  checked: checked,
905
+ error: rawErrors.length > 0,
817
906
  disabled: disabled || itemDisabled || readonly,
818
907
  autoFocus: autofocus && index === 0,
819
908
  onChange: _onChange(option),
@@ -823,116 +912,60 @@ function CheckboxesWidget(props) {
823
912
  })));
824
913
  }
825
914
 
826
- var getDisplayLabel$1 = core.utils.getDisplayLabel;
827
-
828
- function PasswordWidget(props) {
829
- var id = props.id,
830
- required = props.required,
831
- readonly = props.readonly,
832
- disabled = props.disabled,
833
- label = props.label,
834
- name = props.name,
835
- value = props.value,
836
- onChange = props.onChange,
837
- onBlur = props.onBlur,
838
- onFocus = props.onFocus,
839
- autofocus = props.autofocus,
840
- options = props.options,
841
- schema = props.schema,
842
- uiSchema = props.uiSchema,
843
- formContext = props.formContext;
844
- var semanticProps = getSemanticProps({
845
- schema: schema,
846
- uiSchema: uiSchema,
847
- formContext: formContext,
848
- options: options
849
- }); // eslint-disable-next-line no-shadow
850
-
851
- var _onChange = function _onChange(_ref) {
852
- var value = _ref.target.value;
853
- return onChange && onChange(value === "" ? options.emptyValue : value);
854
- };
855
-
856
- var _onBlur = function _onBlur() {
857
- return onBlur && onBlur(id, value);
858
- };
859
-
860
- var _onFocus = function _onFocus() {
861
- return onFocus && onFocus(id, value);
862
- };
863
-
864
- var displayLabel = getDisplayLabel$1(schema, uiSchema
865
- /* TODO: , rootSchema */
866
- );
867
- return React.createElement(semanticUiReact.Form.Input, _extends({
868
- id: id,
869
- key: id,
870
- label: displayLabel ? label || schema.title : false,
871
- autoFocus: autofocus,
872
- required: required,
873
- disabled: disabled || readonly,
874
- name: name
875
- }, semanticProps, {
876
- type: "password",
877
- value: value || "",
878
- onChange: _onChange,
879
- onBlur: _onBlur,
880
- onFocus: _onFocus
881
- }));
882
- }
883
-
884
915
  function RadioWidget(props) {
885
- var id = props.id,
886
- value = props.value,
887
- required = props.required,
888
- disabled = props.disabled,
889
- readonly = props.readonly,
890
- onChange = props.onChange,
891
- onBlur = props.onBlur,
892
- onFocus = props.onFocus,
893
- schema = props.schema,
894
- options = props.options,
895
- formContext = props.formContext,
896
- uiSchema = props.uiSchema; // Generating a unique field name to identify this set of radio buttons
897
-
898
- var name = Math.random().toString();
899
- var enumOptions = options.enumOptions,
900
- enumDisabled = options.enumDisabled;
901
- var semanticProps = getSemanticProps({
902
- formContext: formContext,
903
- options: options,
904
- uiSchema: uiSchema
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
905
939
  }); // eslint-disable-next-line no-shadow
906
940
 
907
- var _onChange = function _onChange(event, _ref) {
908
- var eventValue = _ref.value;
941
+ const _onChange = (event, _ref) => {
942
+ let {
943
+ value: eventValue
944
+ } = _ref;
909
945
  return onChange && onChange(schema.type === "boolean" ? eventValue !== "false" : eventValue);
910
946
  };
911
947
 
912
- var _onBlur = function _onBlur() {
913
- return onBlur && onBlur(id, value);
914
- };
948
+ const _onBlur = () => onBlur && onBlur(id, value);
915
949
 
916
- var _onFocus = function _onFocus() {
917
- return onFocus && onFocus(id, value);
918
- };
950
+ const _onFocus = () => onFocus && onFocus(id, value);
919
951
 
920
- var inlineOption = options.inline ? {
952
+ const inlineOption = options.inline ? {
921
953
  inline: true
922
954
  } : {
923
955
  grouped: true
924
956
  };
925
- return React.createElement(semanticUiReact.Form.Group, inlineOption, enumOptions.map(function (option, i) {
926
- var itemDisabled = enumDisabled && enumDisabled.indexOf(option.value) !== -1;
927
- return React.createElement(semanticUiReact.Form.Field, _extends({
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({
928
960
  required: required,
929
961
  control: semanticUiReact.Radio,
930
- name: name
962
+ name: id + "-radio-" + option.value
931
963
  }, semanticProps, {
932
964
  onFocus: _onFocus,
933
965
  onBlur: _onBlur,
934
966
  label: "" + option.label,
935
967
  value: "" + option.value,
968
+ error: rawErrors.length > 0,
936
969
  key: option.value + "-" + i,
937
970
  checked: value == option.value,
938
971
  onChange: _onChange,
@@ -941,62 +974,61 @@ function RadioWidget(props) {
941
974
  }));
942
975
  }
943
976
 
944
- var rangeSpec = core.utils.rangeSpec;
945
-
946
977
  function RangeWidget(props) {
947
- var id = props.id,
948
- name = props.name,
949
- value = props.value,
950
- required = props.required,
951
- readonly = props.readonly,
952
- disabled = props.disabled,
953
- onChange = props.onChange,
954
- onBlur = props.onBlur,
955
- onFocus = props.onFocus,
956
- options = props.options,
957
- schema = props.schema,
958
- uiSchema = props.uiSchema,
959
- formContext = props.formContext;
960
- var semanticProps = getSemanticProps({
961
- formContext: formContext,
962
- options: options,
963
- uiSchema: uiSchema,
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,
964
998
  defaultSchemaProps: {
965
999
  fluid: true
966
1000
  }
967
1001
  }); // eslint-disable-next-line no-shadow
968
1002
 
969
- var _onChange = function _onChange(_ref) {
970
- var value = _ref.target.value;
1003
+ const _onChange = _ref => {
1004
+ let {
1005
+ target: {
1006
+ value
1007
+ }
1008
+ } = _ref;
971
1009
  return onChange && onChange(value === "" ? options.emptyValue : value);
972
1010
  };
973
1011
 
974
- var _onBlur = function _onBlur() {
975
- return onBlur && onBlur(id, value);
976
- };
1012
+ const _onBlur = () => onBlur && onBlur(id, value);
977
1013
 
978
- var _onFocus = function _onFocus() {
979
- return onFocus && onFocus(id, value);
980
- };
1014
+ const _onFocus = () => onFocus && onFocus(id, value);
981
1015
 
982
- return React.createElement(React.Fragment, null, React.createElement(semanticUiReact.Input, _extends({
1016
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(semanticUiReact.Input, _extends({
983
1017
  id: id,
984
1018
  key: id,
985
1019
  name: name,
986
1020
  type: "range",
987
1021
  required: required,
988
1022
  disabled: disabled || readonly
989
- }, rangeSpec(schema), semanticProps, {
1023
+ }, utils.rangeSpec(schema), semanticProps, {
990
1024
  value: value || "",
1025
+ error: rawErrors.length > 0,
991
1026
  onChange: _onChange,
992
1027
  onBlur: _onBlur,
993
1028
  onFocus: _onFocus
994
- })), React.createElement("span", null, value));
1029
+ })), /*#__PURE__*/React.createElement("span", null, value));
995
1030
  }
996
1031
 
997
- var asNumber = core.utils.asNumber,
998
- guessType = core.utils.guessType;
999
- var nums = /*#__PURE__*/new Set(["number", "integer"]);
1000
1032
  /**
1001
1033
  * * Returns and creates an array format required for semantic drop down
1002
1034
  * @param {array} enumOptions- array of items for the dropdown
@@ -1005,82 +1037,50 @@ var nums = /*#__PURE__*/new Set(["number", "integer"]);
1005
1037
  */
1006
1038
 
1007
1039
  function createDefaultValueOptionsForDropDown(enumOptions, enumDisabled) {
1008
- var disabledOptions = enumDisabled || [];
1009
- var options = []; // eslint-disable-next-line no-shadow
1010
-
1011
- options = _.map(enumOptions, function (_ref) {
1012
- var label = _ref.label,
1013
- value = _ref.value;
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;
1014
1048
  return {
1015
1049
  disabled: disabledOptions.indexOf(value) !== -1,
1016
1050
  key: label,
1017
1051
  text: label,
1018
- value: value
1052
+ value
1019
1053
  };
1020
1054
  });
1021
1055
  return options;
1022
1056
  }
1023
- /**
1024
- * This is a silly limitation in the DOM where option change event values are
1025
- * always retrieved as strings.
1026
- */
1027
-
1028
-
1029
- var processValue = function processValue(schema, value) {
1030
- // "enum" is a reserved word, so only "type" and "items" can be destructured
1031
- var type = schema.type,
1032
- items = schema.items;
1033
-
1034
- if (value === "") {
1035
- return undefined;
1036
- } else if (type === "array" && items && nums.has(items.type)) {
1037
- return value.map(asNumber);
1038
- } else if (type === "boolean") {
1039
- return value === "true" || value === true;
1040
- } else if (type === "number") {
1041
- return asNumber(value);
1042
- } // If type is undefined, but an enum is present, try and infer the type from
1043
- // the enum values
1044
-
1045
-
1046
- if (schema.enum) {
1047
- if (schema.enum.every(function (x) {
1048
- return guessType(x) === "number";
1049
- })) {
1050
- return asNumber(value);
1051
- } else if (schema.enum.every(function (x) {
1052
- return guessType(x) === "boolean";
1053
- })) {
1054
- return value === "true";
1055
- }
1056
- }
1057
-
1058
- return value;
1059
- };
1060
1057
 
1061
1058
  function SelectWidget(props) {
1062
- var schema = props.schema,
1063
- uiSchema = props.uiSchema,
1064
- formContext = props.formContext,
1065
- id = props.id,
1066
- options = props.options,
1067
- name = props.name,
1068
- label = props.label,
1069
- required = props.required,
1070
- disabled = props.disabled,
1071
- readonly = props.readonly,
1072
- value = props.value,
1073
- multiple = props.multiple,
1074
- placeholder = props.placeholder,
1075
- autofocus = props.autofocus,
1076
- onChange = props.onChange,
1077
- onBlur = props.onBlur,
1078
- onFocus = props.onFocus;
1079
- var semanticProps = getSemanticProps({
1080
- schema: schema,
1081
- uiSchema: uiSchema,
1082
- formContext: formContext,
1083
- options: options,
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,
1084
1084
  defaultSchemaProps: {
1085
1085
  inverted: "false",
1086
1086
  selection: true,
@@ -1089,34 +1089,48 @@ function SelectWidget(props) {
1089
1089
  upward: false
1090
1090
  }
1091
1091
  });
1092
- var enumDisabled = options.enumDisabled,
1093
- enumOptions = options.enumOptions;
1094
- var emptyValue = multiple ? [] : "";
1095
- var dropdownOptions = createDefaultValueOptionsForDropDown(enumOptions, enumDisabled);
1096
-
1097
- var _onChange = function _onChange(event, // eslint-disable-next-line no-shadow
1098
- _ref2) {
1099
- var value = _ref2.value;
1100
- return onChange && onChange(processValue(schema, value));
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;
1104
+ return onChange && onChange(utils.processSelectValue(schema, value, options));
1101
1105
  }; // eslint-disable-next-line no-shadow
1102
1106
 
1103
1107
 
1104
- var _onBlur = function _onBlur(_ref3) {
1105
- var value = _ref3.target.value;
1106
- return onBlur && onBlur(id, processValue(schema, value));
1108
+ const _onBlur = _ref3 => {
1109
+ let {
1110
+ target: {
1111
+ value
1112
+ }
1113
+ } = _ref3;
1114
+ return onBlur && onBlur(id, utils.processSelectValue(schema, value, options));
1107
1115
  };
1108
1116
 
1109
- var _onFocus = function _onFocus(_ref4) {
1110
- var value = _ref4.target.value;
1111
- return onFocus && onFocus(id, processValue(schema, value));
1117
+ const _onFocus = _ref4 => {
1118
+ let {
1119
+ // eslint-disable-next-line no-shadow
1120
+ target: {
1121
+ value
1122
+ }
1123
+ } = _ref4;
1124
+ return onFocus && onFocus(id, utils.processSelectValue(schema, value, options));
1112
1125
  };
1113
1126
 
1114
- return React.createElement(semanticUiReact.Form.Dropdown, _extends({
1127
+ return /*#__PURE__*/React.createElement(semanticUiReact.Form.Dropdown, _extends({
1115
1128
  key: id,
1116
1129
  name: name,
1117
1130
  label: label || schema.title,
1118
1131
  multiple: typeof multiple === "undefined" ? false : multiple,
1119
1132
  value: typeof value === "undefined" ? emptyValue : value,
1133
+ error: rawErrors.length > 0,
1120
1134
  disabled: disabled,
1121
1135
  placeholder: placeholder
1122
1136
  }, semanticProps, {
@@ -1130,50 +1144,53 @@ function SelectWidget(props) {
1130
1144
  }));
1131
1145
  }
1132
1146
 
1133
- var getDisplayLabel$2 = core.utils.getDisplayLabel;
1134
-
1135
1147
  function TextareaWidget(props) {
1136
- var id = props.id,
1137
- placeholder = props.placeholder,
1138
- value = props.value,
1139
- required = props.required,
1140
- disabled = props.disabled,
1141
- autofocus = props.autofocus,
1142
- label = props.label,
1143
- name = props.name,
1144
- readonly = props.readonly,
1145
- onBlur = props.onBlur,
1146
- onFocus = props.onFocus,
1147
- onChange = props.onChange,
1148
- options = props.options,
1149
- schema = props.schema,
1150
- uiSchema = props.uiSchema,
1151
- formContext = props.formContext;
1152
- var semanticProps = getSemanticProps({
1153
- formContext: formContext,
1154
- options: options,
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,
1155
1171
  defaultSchemaProps: {
1156
1172
  inverted: false
1157
1173
  }
1158
- }); // eslint-disable-next-line no-shadow
1159
-
1160
- var _onChange = function _onChange(_ref) {
1161
- var value = _ref.target.value;
1174
+ });
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;
1162
1185
  return onChange && onChange(value === "" ? options.emptyValue : value);
1163
1186
  };
1164
1187
 
1165
- var _onBlur = function _onBlur() {
1166
- return onBlur && onBlur(id, value);
1167
- };
1188
+ const _onBlur = () => onBlur && onBlur(id, value);
1168
1189
 
1169
- var _onFocus = function _onFocus() {
1170
- return onFocus && onFocus(id, value);
1171
- };
1190
+ const _onFocus = () => onFocus && onFocus(id, value);
1172
1191
 
1173
- var displayLabel = getDisplayLabel$2(schema, uiSchema
1174
- /* TODO: , rootSchema */
1175
- );
1176
- return React.createElement(semanticUiReact.Form.TextArea, _extends({
1192
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
1193
+ return /*#__PURE__*/React.createElement(semanticUiReact.Form.TextArea, _extends({
1177
1194
  id: id,
1178
1195
  key: id,
1179
1196
  label: displayLabel ? label || schema.title : false,
@@ -1184,6 +1201,7 @@ function TextareaWidget(props) {
1184
1201
  name: name
1185
1202
  }, semanticProps, {
1186
1203
  value: value || "",
1204
+ error: rawErrors.length > 0,
1187
1205
  rows: options.rows || 5,
1188
1206
  onChange: _onChange,
1189
1207
  onBlur: _onBlur,
@@ -1191,415 +1209,25 @@ function TextareaWidget(props) {
1191
1209
  }));
1192
1210
  }
1193
1211
 
1194
- var getDisplayLabel$3 = core.utils.getDisplayLabel;
1195
-
1196
- function TextWidget(props) {
1197
- var id = props.id,
1198
- placeholder = props.placeholder,
1199
- name = props.name,
1200
- label = props.label,
1201
- value = props.value,
1202
- required = props.required,
1203
- readonly = props.readonly,
1204
- disabled = props.disabled,
1205
- onChange = props.onChange,
1206
- onBlur = props.onBlur,
1207
- onFocus = props.onFocus,
1208
- autofocus = props.autofocus,
1209
- options = props.options,
1210
- schema = props.schema,
1211
- uiSchema = props.uiSchema,
1212
- formContext = props.formContext;
1213
- var semanticProps = getSemanticProps({
1214
- formContext: formContext,
1215
- options: options,
1216
- uiSchema: uiSchema
1217
- }); // eslint-disable-next-line no-shadow
1218
-
1219
- var _onChange = function _onChange(_ref) {
1220
- var value = _ref.target.value;
1221
- return onChange(value === "" ? options.emptyValue : value);
1222
- };
1223
-
1224
- var _onBlur = function _onBlur() {
1225
- return onBlur && onBlur(id, value);
1226
- };
1227
-
1228
- var _onFocus = function _onFocus() {
1229
- return onFocus && onFocus(id, value);
1230
- };
1231
-
1232
- var displayLabel = getDisplayLabel$3(schema, uiSchema
1233
- /* TODO: , rootSchema */
1234
- );
1235
- return React.createElement(semanticUiReact.Form.Input, _extends({
1236
- key: id,
1237
- id: id,
1238
- placeholder: placeholder,
1239
- type: schema.type === 'string' ? 'text' : "" + schema.type,
1240
- label: displayLabel ? label || schema.title : false,
1241
- required: required,
1242
- autoFocus: autofocus,
1243
- disabled: disabled || readonly,
1244
- name: name
1245
- }, semanticProps, {
1246
- value: value || value === 0 ? value : "",
1247
- onChange: _onChange,
1248
- onBlur: _onBlur,
1249
- onFocus: _onFocus
1250
- }));
1251
- }
1252
-
1253
- var getDisplayLabel$4 = core.utils.getDisplayLabel;
1254
-
1255
- function UpDownWidget(props) {
1256
- var id = props.id,
1257
- name = props.name,
1258
- label = props.label,
1259
- value = props.value,
1260
- required = props.required,
1261
- readonly = props.readonly,
1262
- disabled = props.disabled,
1263
- onChange = props.onChange,
1264
- onBlur = props.onBlur,
1265
- onFocus = props.onFocus,
1266
- autofocus = props.autofocus,
1267
- options = props.options,
1268
- schema = props.schema,
1269
- uiSchema = props.uiSchema,
1270
- formContext = props.formContext;
1271
- var semanticProps = getSemanticProps({
1272
- formContext: formContext,
1273
- options: options,
1274
- uiSchema: uiSchema
1275
- }); // eslint-disable-next-line no-shadow
1276
-
1277
- var _onChange = function _onChange(_ref) {
1278
- var value = _ref.target.value;
1279
- return onChange && onChange(value);
1280
- };
1281
-
1282
- var _onBlur = function _onBlur() {
1283
- return onBlur && onBlur(id, value);
1284
- };
1285
-
1286
- var _onFocus = function _onFocus() {
1287
- return onFocus && onFocus(id, value);
1288
- };
1289
-
1290
- var displayLabel = getDisplayLabel$4(schema, uiSchema
1291
- /* TODO: , rootSchema */
1292
- );
1293
- return React.createElement(React.Fragment, null, React.createElement(semanticUiReact.Form.Input, _extends({
1294
- id: id,
1295
- key: id,
1296
- autoFocus: autofocus,
1297
- required: required,
1298
- type: "number",
1299
- label: displayLabel ? label || schema.title : false,
1300
- disabled: disabled || readonly,
1301
- name: name
1302
- }, semanticProps, {
1303
- value: value || value === 0 ? value : "",
1304
- onChange: _onChange,
1305
- onBlur: _onBlur,
1306
- onFocus: _onFocus
1307
- })));
1308
- }
1309
-
1310
- var getDisplayLabel$5 = core.utils.getDisplayLabel;
1311
-
1312
- function DateWidget(props) {
1313
- var id = props.id,
1314
- required = props.required,
1315
- readonly = props.readonly,
1316
- disabled = props.disabled,
1317
- name = props.name,
1318
- label = props.label,
1319
- value = props.value,
1320
- onChange = props.onChange,
1321
- onBlur = props.onBlur,
1322
- onFocus = props.onFocus,
1323
- autofocus = props.autofocus,
1324
- options = props.options,
1325
- formContext = props.formContext,
1326
- schema = props.schema,
1327
- uiSchema = props.uiSchema;
1328
- var semanticProps = getSemanticProps({
1329
- uiSchema: uiSchema,
1330
- schema: schema,
1331
- formContext: formContext,
1332
- options: options
1333
- });
1334
-
1335
- var _onChange = function _onChange(_ref) {
1336
- var value = _ref.target.value;
1337
- return onChange && onChange(value);
1338
- };
1339
-
1340
- var _onBlur = function _onBlur() {
1341
- return onBlur && onBlur(id, value);
1342
- };
1343
-
1344
- var _onFocus = function _onFocus() {
1345
- return onFocus && onFocus(id, value);
1346
- };
1347
-
1348
- var displayLabel = getDisplayLabel$5(schema, uiSchema
1349
- /* TODO: , rootSchema */
1350
- );
1351
- return React.createElement(semanticUiReact.Form.Input, _extends({
1352
- key: id,
1353
- id: id,
1354
- type: "date",
1355
- label: displayLabel ? label || schema.title : false,
1356
- required: required,
1357
- autoFocus: autofocus,
1358
- disabled: disabled || readonly,
1359
- name: name
1360
- }, semanticProps, {
1361
- value: value || value === 0 ? value : "",
1362
- onChange: _onChange,
1363
- onBlur: _onBlur,
1364
- onFocus: _onFocus
1365
- }));
1366
- }
1367
-
1368
- var localToUTC = core.utils.localToUTC,
1369
- utcToLocal = core.utils.utcToLocal,
1370
- getDisplayLabel$6 = core.utils.getDisplayLabel;
1371
-
1372
- function DateTimeWidget(props) {
1373
- var id = props.id,
1374
- required = props.required,
1375
- readonly = props.readonly,
1376
- disabled = props.disabled,
1377
- name = props.name,
1378
- label = props.label,
1379
- schema = props.schema,
1380
- uiSchema = props.uiSchema,
1381
- value = props.value,
1382
- onChange = props.onChange,
1383
- onBlur = props.onBlur,
1384
- onFocus = props.onFocus,
1385
- autofocus = props.autofocus,
1386
- options = props.options,
1387
- formContext = props.formContext;
1388
- var semanticProps = getSemanticProps({
1389
- uiSchema: uiSchema,
1390
- schema: schema,
1391
- formContext: formContext,
1392
- options: options
1393
- });
1394
-
1395
- var _onChange = function _onChange(_ref) {
1396
- var value = _ref.target.value;
1397
- return onChange && onChange(localToUTC(value));
1398
- };
1399
-
1400
- var _onBlur = function _onBlur() {
1401
- return onBlur && onBlur(id, value);
1402
- };
1403
-
1404
- var _onFocus = function _onFocus() {
1405
- return onFocus && onFocus(id, value);
1406
- };
1407
-
1408
- var dateValue = utcToLocal(value);
1409
- var displayLabel = getDisplayLabel$6(schema, uiSchema
1410
- /* TODO: , rootSchema */
1411
- );
1412
- return React.createElement(semanticUiReact.Form.Input, _extends({
1413
- key: id,
1414
- id: id,
1415
- type: "datetime-local",
1416
- label: displayLabel ? label || schema.title : false,
1417
- required: required,
1418
- autoFocus: autofocus,
1419
- disabled: disabled || readonly,
1420
- name: name
1421
- }, semanticProps, {
1422
- value: dateValue,
1423
- onChange: _onChange,
1424
- onBlur: _onBlur,
1425
- onFocus: _onFocus
1426
- }));
1427
- }
1428
-
1429
- var getDisplayLabel$7 = core.utils.getDisplayLabel;
1430
-
1431
- function EmailWidget(props) {
1432
- var id = props.id,
1433
- required = props.required,
1434
- readonly = props.readonly,
1435
- disabled = props.disabled,
1436
- name = props.name,
1437
- label = props.label,
1438
- schema = props.schema,
1439
- uiSchema = props.uiSchema,
1440
- value = props.value,
1441
- onChange = props.onChange,
1442
- onBlur = props.onBlur,
1443
- onFocus = props.onFocus,
1444
- autofocus = props.autofocus,
1445
- options = props.options,
1446
- formContext = props.formContext;
1447
- var semanticProps = getSemanticProps({
1448
- schema: schema,
1449
- uiSchema: uiSchema,
1450
- formContext: formContext,
1451
- options: options
1452
- }); // eslint-disable-next-line no-shadow
1453
-
1454
- var _onChange = function _onChange(_ref) {
1455
- var value = _ref.target.value;
1456
- return onChange(value === "" ? options.emptyValue : value);
1457
- };
1458
-
1459
- var _onBlur = function _onBlur() {
1460
- return onBlur && onBlur(id, value);
1461
- };
1462
-
1463
- var _onFocus = function _onFocus() {
1464
- return onFocus && onFocus(id, value);
1465
- };
1466
-
1467
- var displayLabel = getDisplayLabel$7(schema, uiSchema
1468
- /* TODO: , rootSchema */
1469
- );
1470
- return React.createElement(semanticUiReact.Form.Input, _extends({
1471
- key: id,
1472
- id: id,
1473
- type: "email",
1474
- label: displayLabel ? label || schema.title : false,
1475
- required: required,
1476
- autoFocus: autofocus,
1477
- disabled: disabled || readonly,
1478
- name: name
1479
- }, semanticProps, {
1480
- value: value || value === 0 ? value : "",
1481
- onChange: _onChange,
1482
- onBlur: _onBlur,
1483
- onFocus: _onFocus
1484
- }));
1485
- }
1486
-
1487
- var getDisplayLabel$8 = core.utils.getDisplayLabel;
1488
-
1489
- function URLWidget(props) {
1490
- var id = props.id,
1491
- name = props.name,
1492
- label = props.label,
1493
- value = props.value,
1494
- required = props.required,
1495
- readonly = props.readonly,
1496
- disabled = props.disabled,
1497
- onChange = props.onChange,
1498
- onBlur = props.onBlur,
1499
- onFocus = props.onFocus,
1500
- autofocus = props.autofocus,
1501
- options = props.options,
1502
- schema = props.schema,
1503
- uiSchema = props.uiSchema,
1504
- formContext = props.formContext;
1505
- var semanticProps = getSemanticProps({
1506
- formContext: formContext,
1507
- options: options,
1508
- uiSchema: uiSchema
1509
- }); // eslint-disable-next-line no-shadow
1510
-
1511
- var _onChange = function _onChange(_ref) {
1512
- var value = _ref.target.value;
1513
- return onChange(value === "" ? options.emptyValue : value);
1514
- };
1515
-
1516
- var _onBlur = function _onBlur() {
1517
- return onBlur && onBlur(id, value);
1518
- };
1519
-
1520
- var _onFocus = function _onFocus() {
1521
- return onFocus && onFocus(id, value);
1522
- };
1523
-
1524
- var displayLabel = getDisplayLabel$8(schema, uiSchema
1525
- /* TODO: , rootSchema */
1526
- );
1527
- return React.createElement(semanticUiReact.Form.Input, _extends({
1528
- key: id,
1529
- id: id,
1530
- type: "url",
1531
- label: displayLabel ? label || schema.title : false,
1532
- required: required,
1533
- autoFocus: autofocus,
1534
- disabled: disabled || readonly,
1535
- name: name
1536
- }, semanticProps, {
1537
- value: value || value === 0 ? value : "",
1538
- onChange: _onChange,
1539
- onBlur: _onBlur,
1540
- onFocus: _onFocus
1541
- }));
1542
- }
1543
-
1544
- var getSubmitButtonOptions = core.utils.getSubmitButtonOptions;
1545
- var SubmitButton = (function (_ref) {
1546
- var uiSchema = _ref.uiSchema;
1547
-
1548
- var _getSubmitButtonOptio = getSubmitButtonOptions(uiSchema),
1549
- submitText = _getSubmitButtonOptio.submitText,
1550
- norender = _getSubmitButtonOptio.norender,
1551
- submitButtonProps = _getSubmitButtonOptio.props;
1552
-
1553
- if (norender) {
1554
- return null;
1555
- }
1556
-
1557
- return React.createElement(semanticUiReact.Button, _extends({
1558
- type: "submit",
1559
- primary: true
1560
- }, submitButtonProps), submitText);
1561
- });
1562
-
1563
1212
  var Widgets = {
1564
- CheckboxWidget: CheckboxWidget,
1565
- CheckboxesWidget: CheckboxesWidget,
1566
- DateWidget: DateWidget,
1567
- DateTimeWidget: DateTimeWidget,
1568
- PasswordWidget: PasswordWidget,
1569
- EmailWidget: EmailWidget,
1570
- URLWidget: URLWidget,
1571
- RadioWidget: RadioWidget,
1572
- RangeWidget: RangeWidget,
1573
- SelectWidget: SelectWidget,
1574
- TextareaWidget: TextareaWidget,
1575
- TextWidget: TextWidget,
1576
- UpDownWidget: UpDownWidget,
1577
- SubmitButton: SubmitButton
1213
+ CheckboxWidget,
1214
+ CheckboxesWidget,
1215
+ RadioWidget,
1216
+ RangeWidget,
1217
+ SelectWidget,
1218
+ TextareaWidget
1578
1219
  };
1579
1220
 
1580
- var getDefaultRegistry = core.utils.getDefaultRegistry;
1581
-
1582
- var _getDefaultRegistry = /*#__PURE__*/getDefaultRegistry(),
1583
- fields = _getDefaultRegistry.fields,
1584
- widgets = _getDefaultRegistry.widgets;
1585
-
1586
- var Theme = {
1587
- ArrayFieldTemplate: ArrayFieldTemplate,
1588
- ErrorList: ErrorList,
1589
- fields: /*#__PURE__*/_extends({}, fields, Fields),
1590
- FieldTemplate: FieldTemplate,
1591
- ObjectFieldTemplate: ObjectFieldTemplate,
1592
- _internalFormWrapper: semanticUiReact.Form,
1593
- widgets: /*#__PURE__*/_extends({}, widgets, Widgets)
1221
+ const Theme = {
1222
+ templates: Templates,
1223
+ widgets: Widgets,
1224
+ _internalFormWrapper: semanticUiReact.Form
1594
1225
  };
1595
1226
 
1596
- var SemanticUIForm = /*#__PURE__*/core.withTheme(Theme);
1227
+ const SemanticUIForm = /*#__PURE__*/core.withTheme(Theme);
1597
1228
 
1598
- exports.ArrayFieldTemplate = ArrayFieldTemplate;
1599
- exports.FieldTemplate = FieldTemplate;
1600
- exports.Fields = Fields;
1601
- exports.ObjectFieldTemplate = ObjectFieldTemplate;
1602
- exports.SemanticUIForm = SemanticUIForm;
1229
+ exports.Form = SemanticUIForm;
1230
+ exports.Templates = Templates;
1603
1231
  exports.Theme = Theme;
1604
1232
  exports.Widgets = Widgets;
1605
1233
  exports.default = SemanticUIForm;