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