@rjsf/semantic-ui 4.2.0 → 4.2.3

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 (189) hide show
  1. package/dist/AddButton/AddButton.d.ts +2 -0
  2. package/dist/AddButton/index.d.ts +2 -0
  3. package/dist/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +2 -0
  4. package/dist/ArrayFieldTemplate/index.d.ts +2 -0
  5. package/dist/CheckboxWidget/CheckboxWidget.d.ts +2 -0
  6. package/dist/CheckboxWidget/index.d.ts +2 -0
  7. package/dist/CheckboxesWidget/CheckboxesWidget.d.ts +2 -0
  8. package/dist/CheckboxesWidget/index.d.ts +2 -0
  9. package/dist/DateTimeWidget/DateTimeWidget.d.ts +2 -0
  10. package/dist/DateTimeWidget/index.d.ts +2 -0
  11. package/dist/DateWidget/DateWidget.d.ts +2 -0
  12. package/dist/DateWidget/index.d.ts +2 -0
  13. package/dist/DescriptionField/DescriptionField.d.ts +5 -0
  14. package/dist/DescriptionField/index.d.ts +2 -0
  15. package/dist/EmailWidget/EmailWidget.d.ts +2 -0
  16. package/dist/EmailWidget/index.d.ts +2 -0
  17. package/dist/ErrorList/ErrorList.d.ts +27 -0
  18. package/dist/ErrorList/index.d.ts +2 -0
  19. package/dist/FieldTemplate/FieldTemplate.d.ts +14 -0
  20. package/dist/FieldTemplate/WrapIfAdditional.d.ts +14 -0
  21. package/dist/FieldTemplate/index.d.ts +2 -0
  22. package/dist/Fields/Fields.d.ts +7 -0
  23. package/dist/Fields/index.d.ts +2 -0
  24. package/dist/HelpField/HelpField.d.ts +15 -0
  25. package/dist/HelpField/index.d.ts +2 -0
  26. package/dist/IconButton/IconButton.d.ts +9 -0
  27. package/dist/IconButton/index.d.ts +2 -0
  28. package/dist/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +16 -0
  29. package/dist/ObjectFieldTemplate/index.d.ts +2 -0
  30. package/dist/PasswordWidget/PasswordWidget.d.ts +2 -0
  31. package/dist/PasswordWidget/index.d.ts +2 -0
  32. package/dist/RadioWidget/RadioWidget.d.ts +2 -0
  33. package/dist/RadioWidget/index.d.ts +2 -0
  34. package/dist/RangeWidget/RangeWidget.d.ts +2 -0
  35. package/dist/RangeWidget/index.d.ts +2 -0
  36. package/dist/RawErrors/RawErrors.d.ts +41 -0
  37. package/dist/RawErrors/index.d.ts +2 -0
  38. package/dist/SelectWidget/SelectWidget.d.ts +2 -0
  39. package/dist/SelectWidget/index.d.ts +2 -0
  40. package/dist/SemanticUIForm/SemanticUIForm.d.ts +3 -0
  41. package/dist/SemanticUIForm/index.d.ts +2 -0
  42. package/dist/SubmitButton/SubmitButton.d.ts +4 -0
  43. package/dist/SubmitButton/index.d.ts +2 -0
  44. package/dist/TextWidget/TextWidget.d.ts +2 -0
  45. package/dist/TextWidget/index.d.ts +2 -0
  46. package/dist/TextareaWidget/TextareaWidget.d.ts +2 -0
  47. package/dist/TextareaWidget/index.d.ts +2 -0
  48. package/dist/Theme/Theme.d.ts +35 -0
  49. package/dist/Theme/index.d.ts +2 -0
  50. package/dist/TitleField/TitleField.d.ts +20 -0
  51. package/dist/TitleField/index.d.ts +2 -0
  52. package/dist/URLWidget/URLWidget.d.ts +2 -0
  53. package/dist/URLWidget/index.d.ts +2 -0
  54. package/dist/UpDownWidget/UpDownWidget.d.ts +2 -0
  55. package/dist/UpDownWidget/index.d.ts +2 -0
  56. package/dist/Widgets/Widgets.d.ts +31 -0
  57. package/dist/Widgets/index.d.ts +2 -0
  58. package/dist/index.d.ts +9 -0
  59. package/dist/index.js +8 -0
  60. package/dist/semantic-ui.cjs.development.js +1606 -0
  61. package/dist/semantic-ui.cjs.development.js.map +1 -0
  62. package/dist/semantic-ui.cjs.production.min.js +2 -0
  63. package/dist/semantic-ui.cjs.production.min.js.map +1 -0
  64. package/dist/semantic-ui.esm.js +1594 -0
  65. package/dist/semantic-ui.esm.js.map +1 -0
  66. package/dist/semantic-ui.umd.development.js +1607 -0
  67. package/dist/semantic-ui.umd.development.js.map +1 -0
  68. package/dist/semantic-ui.umd.production.min.js +2 -0
  69. package/dist/semantic-ui.umd.production.min.js.map +1 -0
  70. package/dist/util.d.ts +62 -0
  71. package/package.json +8 -11
  72. package/dist/cjs/AddButton/AddButton.js +0 -28
  73. package/dist/cjs/AddButton/index.js +0 -32
  74. package/dist/cjs/ArrayFieldTemplate/ArrayFieldTemplate.js +0 -251
  75. package/dist/cjs/ArrayFieldTemplate/index.js +0 -32
  76. package/dist/cjs/CheckboxWidget/CheckboxWidget.js +0 -79
  77. package/dist/cjs/CheckboxWidget/index.js +0 -32
  78. package/dist/cjs/CheckboxesWidget/CheckboxesWidget.js +0 -115
  79. package/dist/cjs/CheckboxesWidget/index.js +0 -32
  80. package/dist/cjs/DateTimeWidget/DateTimeWidget.js +0 -83
  81. package/dist/cjs/DateTimeWidget/index.js +0 -32
  82. package/dist/cjs/DateWidget/DateWidget.js +0 -80
  83. package/dist/cjs/DateWidget/index.js +0 -32
  84. package/dist/cjs/DescriptionField/DescriptionField.js +0 -26
  85. package/dist/cjs/DescriptionField/index.js +0 -32
  86. package/dist/cjs/EmailWidget/EmailWidget.js +0 -80
  87. package/dist/cjs/EmailWidget/index.js +0 -32
  88. package/dist/cjs/ErrorList/ErrorList.js +0 -40
  89. package/dist/cjs/ErrorList/index.js +0 -32
  90. package/dist/cjs/FieldTemplate/FieldTemplate.js +0 -80
  91. package/dist/cjs/FieldTemplate/WrapIfAdditional.js +0 -85
  92. package/dist/cjs/FieldTemplate/index.js +0 -32
  93. package/dist/cjs/Fields/Fields.js +0 -19
  94. package/dist/cjs/Fields/index.js +0 -32
  95. package/dist/cjs/HelpField/HelpField.js +0 -43
  96. package/dist/cjs/HelpField/index.js +0 -32
  97. package/dist/cjs/IconButton/IconButton.js +0 -39
  98. package/dist/cjs/IconButton/index.js +0 -32
  99. package/dist/cjs/ObjectFieldTemplate/ObjectFieldTemplate.js +0 -64
  100. package/dist/cjs/ObjectFieldTemplate/index.js +0 -32
  101. package/dist/cjs/PasswordWidget/PasswordWidget.js +0 -80
  102. package/dist/cjs/PasswordWidget/index.js +0 -32
  103. package/dist/cjs/RadioWidget/RadioWidget.js +0 -80
  104. package/dist/cjs/RadioWidget/index.js +0 -32
  105. package/dist/cjs/RangeWidget/RangeWidget.js +0 -75
  106. package/dist/cjs/RangeWidget/index.js +0 -32
  107. package/dist/cjs/RawErrors/RawErrors.js +0 -65
  108. package/dist/cjs/RawErrors/index.js +0 -32
  109. package/dist/cjs/SelectWidget/SelectWidget.js +0 -160
  110. package/dist/cjs/SelectWidget/index.js +0 -32
  111. package/dist/cjs/SemanticUIForm/SemanticUIForm.js +0 -17
  112. package/dist/cjs/SemanticUIForm/index.js +0 -32
  113. package/dist/cjs/SubmitButton/SubmitButton.js +0 -39
  114. package/dist/cjs/SubmitButton/index.js +0 -32
  115. package/dist/cjs/TextWidget/TextWidget.js +0 -81
  116. package/dist/cjs/TextWidget/index.js +0 -32
  117. package/dist/cjs/TextareaWidget/TextareaWidget.js +0 -83
  118. package/dist/cjs/TextareaWidget/index.js +0 -32
  119. package/dist/cjs/Theme/Theme.js +0 -49
  120. package/dist/cjs/Theme/index.js +0 -32
  121. package/dist/cjs/TitleField/TitleField.js +0 -43
  122. package/dist/cjs/TitleField/index.js +0 -32
  123. package/dist/cjs/URLWidget/URLWidget.js +0 -79
  124. package/dist/cjs/URLWidget/index.js +0 -32
  125. package/dist/cjs/UpDownWidget/UpDownWidget.js +0 -79
  126. package/dist/cjs/UpDownWidget/index.js +0 -32
  127. package/dist/cjs/Widgets/Widgets.js +0 -55
  128. package/dist/cjs/Widgets/index.js +0 -32
  129. package/dist/cjs/index.js +0 -70
  130. package/dist/cjs/util.js +0 -134
  131. package/dist/es/AddButton/AddButton.js +0 -17
  132. package/dist/es/AddButton/index.js +0 -4
  133. package/dist/es/ArrayFieldTemplate/ArrayFieldTemplate.js +0 -237
  134. package/dist/es/ArrayFieldTemplate/index.js +0 -4
  135. package/dist/es/CheckboxWidget/CheckboxWidget.js +0 -66
  136. package/dist/es/CheckboxWidget/index.js +0 -4
  137. package/dist/es/CheckboxesWidget/CheckboxesWidget.js +0 -103
  138. package/dist/es/CheckboxesWidget/index.js +0 -4
  139. package/dist/es/DateTimeWidget/DateTimeWidget.js +0 -70
  140. package/dist/es/DateTimeWidget/index.js +0 -3
  141. package/dist/es/DateWidget/DateWidget.js +0 -67
  142. package/dist/es/DateWidget/index.js +0 -3
  143. package/dist/es/DescriptionField/DescriptionField.js +0 -16
  144. package/dist/es/DescriptionField/index.js +0 -4
  145. package/dist/es/EmailWidget/EmailWidget.js +0 -66
  146. package/dist/es/EmailWidget/index.js +0 -3
  147. package/dist/es/ErrorList/ErrorList.js +0 -27
  148. package/dist/es/ErrorList/index.js +0 -4
  149. package/dist/es/FieldTemplate/FieldTemplate.js +0 -65
  150. package/dist/es/FieldTemplate/WrapIfAdditional.js +0 -72
  151. package/dist/es/FieldTemplate/index.js +0 -4
  152. package/dist/es/Fields/Fields.js +0 -7
  153. package/dist/es/Fields/index.js +0 -4
  154. package/dist/es/HelpField/HelpField.js +0 -30
  155. package/dist/es/HelpField/index.js +0 -4
  156. package/dist/es/IconButton/IconButton.js +0 -27
  157. package/dist/es/IconButton/index.js +0 -4
  158. package/dist/es/ObjectFieldTemplate/ObjectFieldTemplate.js +0 -50
  159. package/dist/es/ObjectFieldTemplate/index.js +0 -4
  160. package/dist/es/PasswordWidget/PasswordWidget.js +0 -67
  161. package/dist/es/PasswordWidget/index.js +0 -4
  162. package/dist/es/RadioWidget/RadioWidget.js +0 -69
  163. package/dist/es/RadioWidget/index.js +0 -4
  164. package/dist/es/RangeWidget/RangeWidget.js +0 -62
  165. package/dist/es/RangeWidget/index.js +0 -4
  166. package/dist/es/RawErrors/RawErrors.js +0 -51
  167. package/dist/es/RawErrors/index.js +0 -4
  168. package/dist/es/SelectWidget/SelectWidget.js +0 -146
  169. package/dist/es/SelectWidget/index.js +0 -4
  170. package/dist/es/SemanticUIForm/SemanticUIForm.js +0 -5
  171. package/dist/es/SemanticUIForm/index.js +0 -4
  172. package/dist/es/SubmitButton/SubmitButton.js +0 -24
  173. package/dist/es/SubmitButton/index.js +0 -3
  174. package/dist/es/TextWidget/TextWidget.js +0 -68
  175. package/dist/es/TextWidget/index.js +0 -4
  176. package/dist/es/TextareaWidget/TextareaWidget.js +0 -70
  177. package/dist/es/TextareaWidget/index.js +0 -4
  178. package/dist/es/Theme/Theme.js +0 -31
  179. package/dist/es/Theme/index.js +0 -4
  180. package/dist/es/TitleField/TitleField.js +0 -31
  181. package/dist/es/TitleField/index.js +0 -4
  182. package/dist/es/URLWidget/URLWidget.js +0 -65
  183. package/dist/es/URLWidget/index.js +0 -3
  184. package/dist/es/UpDownWidget/UpDownWidget.js +0 -66
  185. package/dist/es/UpDownWidget/index.js +0 -4
  186. package/dist/es/Widgets/Widgets.js +0 -31
  187. package/dist/es/Widgets/index.js +0 -4
  188. package/dist/es/index.js +0 -10
  189. package/dist/es/util.js +0 -119
@@ -0,0 +1,1594 @@
1
+ import { utils, withTheme } from '@rjsf/core';
2
+ import { Button, Icon, Segment, Grid, Message, Header, Label, List, Form, Radio, Input } from 'semantic-ui-react';
3
+ import React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { nanoid } from 'nanoid';
6
+ import _ from 'lodash-es';
7
+
8
+ function _extends() {
9
+ _extends = Object.assign || function (target) {
10
+ for (var i = 1; i < arguments.length; i++) {
11
+ var source = arguments[i];
12
+
13
+ for (var key in source) {
14
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
15
+ target[key] = source[key];
16
+ }
17
+ }
18
+ }
19
+
20
+ return target;
21
+ };
22
+
23
+ return _extends.apply(this, arguments);
24
+ }
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
+ function AddButton(props) {
42
+ return React.createElement(Button, _extends({}, props, {
43
+ icon: true,
44
+ size: "tiny",
45
+ labelPosition: "left"
46
+ }), React.createElement(Icon, {
47
+ name: "plus"
48
+ }), "Add Item");
49
+ }
50
+
51
+ /**
52
+ * Extract props meant for semantic UI components from props that are
53
+ * passed to Widgets, Templates and Fields.
54
+ * @param {Object} params
55
+ * @param {Object?} params.formContext
56
+ * @param {Object?} params.uiSchema
57
+ * @param {Object?} params.options
58
+ * @param {Object?} params.defaultSchemaProps
59
+ * @param {Object?} params.defaultContextProps
60
+ * @returns {any}
61
+ */
62
+
63
+ 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);
82
+ }
83
+ /**
84
+ * Extract error props meant for semantic UI components from props that are
85
+ * passed to Widgets, Templates and Fields.
86
+ * @param {Object} params
87
+ * @param {Object?} params.formContext
88
+ * @param {Object?} params.uiSchema
89
+ * @param {Object?} params.defaultProps
90
+ * @returns {any}
91
+ */
92
+
93
+ 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);
109
+ }
110
+ /**
111
+ * Combine multiple strings containing class names into a single string,
112
+ * removing duplicates. E.g.
113
+ * cleanClassNames('bar', 'baz bar', 'x y ', undefined)
114
+ * // 'bar baz x y'
115
+ * @param {Array} classNameArr
116
+ * @param {Array} omit
117
+ * @returns {string}
118
+ */
119
+
120
+ function cleanClassNames(classNameArr, omit) {
121
+ if (omit === void 0) {
122
+ omit = [];
123
+ }
124
+
125
+ // Split each arg on whitespace, and add it to an array. Skip false-y args
126
+ // 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
130
+ // returning them as a string
131
+
132
+ return [].concat(new Set(classList.filter(function (cn) {
133
+ return !omit.includes(cn);
134
+ }))).join(" ");
135
+ }
136
+ /**
137
+ *
138
+ * @param {boolean} wrap
139
+ * @param Component
140
+ * @param {Object} props
141
+ * @returns {*}
142
+ * @constructor
143
+ */
144
+
145
+ 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;
152
+ }
153
+
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
197
+
198
+
199
+ function isInitialArrayItem(props) {
200
+ // no underscore because im not sure if we want to import a library here
201
+ var idSchema = props.children.props.idSchema;
202
+ return idSchema.target && idSchema.conditions;
203
+ } // Used in the two templates
204
+
205
+
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,
212
+ component: Segment
213
+ }, React.createElement(Grid, {
214
+ style: !isInitialArrayItem(props) ? _extends({}, gridStyle(!props.horizontalButtons), {
215
+ alignItems: "center"
216
+ }) : gridStyle(!props.horizontalButtons)
217
+ }, React.createElement(Grid.Column, {
218
+ width: 16,
219
+ verticalAlign: "middle"
220
+ }, props.children), props.hasToolbar && React.createElement(Grid.Column, null, (props.hasMoveUp || props.hasMoveDown || props.hasRemove) && React.createElement(Button.Group, {
221
+ size: "mini",
222
+ vertical: !props.horizontalButtons
223
+ }, (props.hasMoveUp || props.hasMoveDown) && React.createElement(Button, {
224
+ icon: "angle up",
225
+ 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",
231
+ 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",
237
+ className: "array-item-remove",
238
+ tabIndex: "-1",
239
+ disabled: props.disabled || props.readOnly,
240
+ onClick: props.onDropIndexClick(props.index)
241
+ }))))));
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
+ }
292
+
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,
316
+ idSchema: idSchema,
317
+ uiSchema: uiSchema,
318
+ title: fieldTitle,
319
+ required: required
320
+ }), fieldDescription && React.createElement(ArrayFieldDescription, {
321
+ key: "array-field-description-" + idSchema.$id,
322
+ DescriptionField: DescriptionField,
323
+ idSchema: idSchema,
324
+ description: fieldDescription
325
+ }), React.createElement("div", {
326
+ key: "array-item-list-" + idSchema.$id
327
+ }, React.createElement("div", {
328
+ className: "row array-item-list"
329
+ }, items && items.map(function (p) {
330
+ return DefaultArrayItem(_extends({}, p, itemProps));
331
+ })), canAdd && React.createElement("div", {
332
+ style: {
333
+ marginTop: "1rem",
334
+ position: "relative",
335
+ textAlign: "right"
336
+ }
337
+ }, React.createElement(AddButton, {
338
+ onClick: onAddClick,
339
+ disabled: disabled || readOnly
340
+ }))));
341
+ }
342
+
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
+ }
356
+ });
357
+ var horizontalButtons = semanticProps.horizontalButtons,
358
+ wrapItem = semanticProps.wrapItem;
359
+ var itemProps = {
360
+ horizontalButtons: horizontalButtons,
361
+ wrapItem: wrapItem
362
+ };
363
+
364
+ if (isFixedItems(schema)) {
365
+ return React.createElement(DefaultFixedArrayFieldTemplate, _extends({}, props, {
366
+ itemProps: itemProps
367
+ }));
368
+ }
369
+
370
+ return React.createElement(DefaultNormalArrayFieldTemplate, _extends({}, props, {
371
+ itemProps: itemProps
372
+ }));
373
+ }
374
+
375
+ /* eslint-disable react/no-array-index-key */
376
+ /**
377
+ *
378
+ * @param errors
379
+ * @returns {*}
380
+ * @constructor
381
+ */
382
+
383
+ function ErrorList(_ref) {
384
+ var errors = _ref.errors;
385
+ return React.createElement(Message, {
386
+ 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
+ })));
392
+ }
393
+
394
+ ErrorList.propTypes = {
395
+ errors: PropTypes.array
396
+ };
397
+
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
+ }
421
+ }
422
+
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
438
+ };
439
+
440
+ /* eslint-disable react/prop-types */
441
+ /**
442
+ * @return {null}
443
+ */
444
+
445
+ function HelpField(_ref) {
446
+ var helpText = _ref.helpText,
447
+ id = _ref.id;
448
+
449
+ if (helpText) {
450
+ return React.createElement(Message, {
451
+ size: "mini",
452
+ info: true,
453
+ id: id,
454
+ content: helpText
455
+ });
456
+ }
457
+
458
+ return null;
459
+ }
460
+
461
+ HelpField.propTypes = {
462
+ helpText: PropTypes.string,
463
+ id: PropTypes.string
464
+ };
465
+
466
+ /* eslint-disable react/no-array-index-key */
467
+ /**
468
+ *
469
+ * @param errors
470
+ * @param displayError
471
+ * @returns {*}
472
+ * @constructor
473
+ * @return {null}
474
+ */
475
+
476
+ function RawErrors(_ref) {
477
+ var errors = _ref.errors,
478
+ options = _ref.options;
479
+ var pointing = options.pointing,
480
+ size = options.size;
481
+
482
+ if (errors && errors.length > 0) {
483
+ return React.createElement(Label, {
484
+ color: "red",
485
+ pointing: pointing || "above",
486
+ size: size || "small",
487
+ basic: true
488
+ }, React.createElement(List, {
489
+ bulleted: true
490
+ }, errors.map(function (error) {
491
+ return React.createElement(List.Item, {
492
+ key: nanoid(),
493
+ content: error
494
+ });
495
+ })));
496
+ }
497
+
498
+ return null;
499
+ }
500
+
501
+ RawErrors.defaultProps = {
502
+ options: {
503
+ pointing: "above",
504
+ size: "small"
505
+ }
506
+ };
507
+ RawErrors.propTypes = {
508
+ options: PropTypes.object,
509
+ errors: PropTypes.array
510
+ };
511
+
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);
532
+
533
+ if (!additional) {
534
+ return React.createElement(React.Fragment, null, children);
535
+ }
536
+
537
+ var handleBlur = function handleBlur(_ref2) {
538
+ var target = _ref2.target;
539
+ return onKeyChange(target.value);
540
+ };
541
+
542
+ return React.createElement("div", {
543
+ className: classNames,
544
+ key: id + "-key"
545
+ }, React.createElement(Grid, {
546
+ columns: "equal"
547
+ }, React.createElement(Grid.Row, null, React.createElement(Grid.Column, {
548
+ className: "form-additional"
549
+ }, React.createElement(Form.Group, {
550
+ widths: "equal",
551
+ grouped: true
552
+ }, React.createElement(Form.Input, {
553
+ className: "form-group",
554
+ hasFeedback: true,
555
+ fluid: true,
556
+ htmlFor: "" + id,
557
+ label: keyLabel,
558
+ required: required,
559
+ defaultValue: label,
560
+ disabled: disabled || readonlyAsDisabled && readonly,
561
+ id: "" + id,
562
+ name: "" + id,
563
+ onBlur: !readonly ? handleBlur : undefined,
564
+ style: wrapperStyle,
565
+ type: "text"
566
+ }))), React.createElement(Grid.Column, {
567
+ className: "form-additional",
568
+ verticalAlign: "middle"
569
+ }, children), React.createElement(Grid.Column, null, React.createElement(Button, {
570
+ size: "mini",
571
+ icon: "trash",
572
+ className: "array-item-remove",
573
+ tabIndex: "-1",
574
+ disabled: disabled || readonly,
575
+ onClick: onDropPropertyClick(label)
576
+ })))));
577
+ };
578
+
579
+ 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);
596
+
597
+ if (hidden) {
598
+ return children;
599
+ }
600
+
601
+ return React.createElement(WrapIfAdditional, _extends({
602
+ classNames: classNames,
603
+ id: id,
604
+ label: label
605
+ }, props), React.createElement(Form.Group, {
606
+ key: id,
607
+ widths: "equal",
608
+ grouped: true
609
+ }, React.createElement(MaybeWrap, {
610
+ wrap: wrapContent,
611
+ className: "sui-field-content"
612
+ }, children, displayLabel && rawDescription && React.createElement(MaybeWrap, {
613
+ wrap: wrapLabel,
614
+ className: "sui-field-label"
615
+ }, rawDescription && React.createElement(DescriptionField, {
616
+ description: rawDescription
617
+ })), React.createElement(HelpField, {
618
+ helpText: rawHelp,
619
+ id: id + "__help"
620
+ }), React.createElement(RawErrors, {
621
+ errors: rawErrors,
622
+ options: errorOptions
623
+ }))));
624
+ }
625
+
626
+ /* eslint-disable react/prop-types */
627
+ var canExpand = utils.canExpand;
628
+
629
+ 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, {
646
+ id: idSchema.$id + "-title",
647
+ title: fieldTitle,
648
+ options: uiSchema["ui:options"],
649
+ required: required
650
+ }), fieldDescription && React.createElement(DescriptionField, {
651
+ 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, {
656
+ width: 16,
657
+ verticalAlign: "middle"
658
+ }, React.createElement(Grid.Row, null, React.createElement("div", {
659
+ style: {
660
+ marginTop: "1rem",
661
+ position: "relative",
662
+ textAlign: "right"
663
+ }
664
+ }, React.createElement(AddButton, {
665
+ onClick: onAddClick(schema),
666
+ disabled: disabled || readOnly
667
+ })))));
668
+ }
669
+
670
+ var getDisplayLabel = utils.getDisplayLabel;
671
+
672
+ 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,
692
+ defaultSchemaProps: {
693
+ inverted: false
694
+ }
695
+ });
696
+ var displayLabel = getDisplayLabel(schema, uiSchema
697
+ /* TODO: , rootSchema */
698
+ );
699
+
700
+ var _onChange = function _onChange(event, data) {
701
+ return onChange && onChange(data.checked);
702
+ };
703
+
704
+ var _onBlur = function _onBlur() {
705
+ return onBlur && onBlur(id, value);
706
+ };
707
+
708
+ var _onFocus = function _onFocus() {
709
+ return onFocus && onFocus(id, value);
710
+ };
711
+
712
+ var checked = value == "true" || value == true;
713
+ return React.createElement(Form.Checkbox, _extends({
714
+ id: id,
715
+ disabled: disabled || readonly,
716
+ autoFocus: autofocus
717
+ }, semanticProps, {
718
+ checked: typeof value === "undefined" ? false : checked,
719
+ onChange: _onChange,
720
+ onBlur: _onBlur,
721
+ onFocus: _onFocus,
722
+ required: required,
723
+ label: displayLabel ? label || schema.title : false
724
+ }));
725
+ }
726
+
727
+ 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
730
+ // arrays, we need to reorder the updated selection to match the initial order
731
+
732
+ return updated.sort(function (a, b) {
733
+ return all.indexOf(a) > all.indexOf(b);
734
+ });
735
+ }
736
+
737
+ function deselectValue(value, selected) {
738
+ return selected.filter(function (v) {
739
+ return v !== value;
740
+ });
741
+ }
742
+
743
+ 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,
765
+ defaultSchemaProps: {
766
+ inverted: false
767
+ }
768
+ });
769
+
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));
783
+ }
784
+ };
785
+ };
786
+
787
+ var _onBlur = function _onBlur() {
788
+ return onBlur && onBlur(id, value);
789
+ };
790
+
791
+ var _onFocus = function _onFocus() {
792
+ return onFocus && onFocus(id, value);
793
+ };
794
+
795
+ var inlineOption = inline ? {
796
+ inline: true
797
+ } : {
798
+ grouped: true
799
+ };
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({
806
+ id: id + "_" + index,
807
+ key: id + "_" + index,
808
+ label: option.label
809
+ }, semanticProps, {
810
+ checked: checked,
811
+ disabled: disabled || itemDisabled || readonly,
812
+ autoFocus: autofocus && index === 0,
813
+ onChange: _onChange(option),
814
+ onBlur: _onBlur,
815
+ onFocus: _onFocus
816
+ }));
817
+ })));
818
+ }
819
+
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
+ 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
899
+ }); // eslint-disable-next-line no-shadow
900
+
901
+ var _onChange = function _onChange(event, _ref) {
902
+ var eventValue = _ref.value;
903
+ return onChange && onChange(schema.type === "boolean" ? eventValue !== "false" : eventValue);
904
+ };
905
+
906
+ var _onBlur = function _onBlur() {
907
+ return onBlur && onBlur(id, value);
908
+ };
909
+
910
+ var _onFocus = function _onFocus() {
911
+ return onFocus && onFocus(id, value);
912
+ };
913
+
914
+ var inlineOption = options.inline ? {
915
+ inline: true
916
+ } : {
917
+ grouped: true
918
+ };
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({
922
+ required: required,
923
+ control: Radio,
924
+ name: name
925
+ }, semanticProps, {
926
+ onFocus: _onFocus,
927
+ onBlur: _onBlur,
928
+ label: "" + option.label,
929
+ value: "" + option.value,
930
+ key: option.value + "-" + i,
931
+ checked: value == option.value,
932
+ onChange: _onChange,
933
+ disabled: disabled || itemDisabled || readonly
934
+ }));
935
+ }));
936
+ }
937
+
938
+ var rangeSpec = utils.rangeSpec;
939
+
940
+ 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,
958
+ defaultSchemaProps: {
959
+ fluid: true
960
+ }
961
+ }); // eslint-disable-next-line no-shadow
962
+
963
+ var _onChange = function _onChange(_ref) {
964
+ var value = _ref.target.value;
965
+ return onChange && onChange(value === "" ? options.emptyValue : value);
966
+ };
967
+
968
+ var _onBlur = function _onBlur() {
969
+ return onBlur && onBlur(id, value);
970
+ };
971
+
972
+ var _onFocus = function _onFocus() {
973
+ return onFocus && onFocus(id, value);
974
+ };
975
+
976
+ return React.createElement(React.Fragment, null, React.createElement(Input, _extends({
977
+ id: id,
978
+ key: id,
979
+ name: name,
980
+ type: "range",
981
+ required: required,
982
+ disabled: disabled || readonly
983
+ }, rangeSpec(schema), semanticProps, {
984
+ value: value || "",
985
+ onChange: _onChange,
986
+ onBlur: _onBlur,
987
+ onFocus: _onFocus
988
+ })), React.createElement("span", null, value));
989
+ }
990
+
991
+ var asNumber = utils.asNumber,
992
+ guessType = utils.guessType;
993
+ var nums = /*#__PURE__*/new Set(["number", "integer"]);
994
+ /**
995
+ * * Returns and creates an array format required for semantic drop down
996
+ * @param {array} enumOptions- array of items for the dropdown
997
+ * @param {array} enumDisabled - array of enum option values to disable
998
+ * @returns {*}
999
+ */
1000
+
1001
+ 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;
1008
+ return {
1009
+ disabled: disabledOptions.indexOf(value) !== -1,
1010
+ key: label,
1011
+ text: label,
1012
+ value: value
1013
+ };
1014
+ });
1015
+ return options;
1016
+ }
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
+
1055
+ 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,
1078
+ defaultSchemaProps: {
1079
+ inverted: "false",
1080
+ selection: true,
1081
+ fluid: true,
1082
+ scrolling: true,
1083
+ upward: false
1084
+ }
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));
1095
+ }; // eslint-disable-next-line no-shadow
1096
+
1097
+
1098
+ var _onBlur = function _onBlur(_ref3) {
1099
+ var value = _ref3.target.value;
1100
+ return onBlur && onBlur(id, processValue(schema, value));
1101
+ };
1102
+
1103
+ var _onFocus = function _onFocus(_ref4) {
1104
+ var value = _ref4.target.value;
1105
+ return onFocus && onFocus(id, processValue(schema, value));
1106
+ };
1107
+
1108
+ return React.createElement(Form.Dropdown, _extends({
1109
+ key: id,
1110
+ name: name,
1111
+ label: label || schema.title,
1112
+ multiple: typeof multiple === "undefined" ? false : multiple,
1113
+ value: typeof value === "undefined" ? emptyValue : value,
1114
+ disabled: disabled,
1115
+ placeholder: placeholder
1116
+ }, semanticProps, {
1117
+ required: required,
1118
+ autoFocus: autofocus,
1119
+ readOnly: readonly,
1120
+ options: dropdownOptions,
1121
+ onChange: _onChange,
1122
+ onBlur: _onBlur,
1123
+ onFocus: _onFocus
1124
+ }));
1125
+ }
1126
+
1127
+ var getDisplayLabel$2 = utils.getDisplayLabel;
1128
+
1129
+ 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,
1149
+ defaultSchemaProps: {
1150
+ inverted: false
1151
+ }
1152
+ }); // eslint-disable-next-line no-shadow
1153
+
1154
+ var _onChange = function _onChange(_ref) {
1155
+ var value = _ref.target.value;
1156
+ return onChange && onChange(value === "" ? options.emptyValue : value);
1157
+ };
1158
+
1159
+ var _onBlur = function _onBlur() {
1160
+ return onBlur && onBlur(id, value);
1161
+ };
1162
+
1163
+ var _onFocus = function _onFocus() {
1164
+ return onFocus && onFocus(id, value);
1165
+ };
1166
+
1167
+ var displayLabel = getDisplayLabel$2(schema, uiSchema
1168
+ /* TODO: , rootSchema */
1169
+ );
1170
+ return React.createElement(Form.TextArea, _extends({
1171
+ id: id,
1172
+ key: id,
1173
+ label: displayLabel ? label || schema.title : false,
1174
+ placeholder: placeholder,
1175
+ autoFocus: autofocus,
1176
+ required: required,
1177
+ disabled: disabled || readonly,
1178
+ name: name
1179
+ }, semanticProps, {
1180
+ value: value || "",
1181
+ rows: options.rows || 5,
1182
+ onChange: _onChange,
1183
+ onBlur: _onBlur,
1184
+ onFocus: _onFocus
1185
+ }));
1186
+ }
1187
+
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
+ 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
1572
+ };
1573
+
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)
1588
+ };
1589
+
1590
+ var SemanticUIForm = /*#__PURE__*/withTheme(Theme);
1591
+
1592
+ export default SemanticUIForm;
1593
+ export { ArrayFieldTemplate, FieldTemplate, Fields, ObjectFieldTemplate, SemanticUIForm, Theme, Widgets };
1594
+ //# sourceMappingURL=semantic-ui.esm.js.map