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