@rjsf/semantic-ui 5.2.0 → 5.3.0
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.
- package/LICENSE.md +183 -183
- package/README.md +15 -12
- package/dist/semantic-ui.cjs.development.js +407 -341
- package/dist/semantic-ui.cjs.development.js.map +1 -1
- package/dist/semantic-ui.cjs.production.min.js +1 -1
- package/dist/semantic-ui.cjs.production.min.js.map +1 -1
- package/dist/semantic-ui.esm.js +407 -340
- package/dist/semantic-ui.esm.js.map +1 -1
- package/dist/semantic-ui.umd.development.js +409 -344
- package/dist/semantic-ui.umd.development.js.map +1 -1
- package/dist/semantic-ui.umd.production.min.js +1 -1
- package/dist/semantic-ui.umd.production.min.js.map +1 -1
- package/package.json +11 -11
package/dist/semantic-ui.esm.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { withTheme } from '@rjsf/core';
|
|
2
2
|
import { Button, Icon, Segment, Grid, Form, Message, Label, List, Header, Radio, Input } from 'semantic-ui-react';
|
|
3
|
-
import
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
4
|
import { TranslatableString, getUiOptions, getTemplate, isFixedItems, UI_OPTIONS_KEY, getInputProps, examplesId, ariaDescribedByIds, errorId, helpId, descriptionId, titleId, canExpand, getSubmitButtonOptions, ADDITIONAL_PROPERTY_FLAG, schemaRequiresTrueValue, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, enumOptionsValueForIndex, rangeSpec, enumOptionsIndexForValue } from '@rjsf/utils';
|
|
5
5
|
import { nanoid } from 'nanoid';
|
|
6
|
+
import { createElement } from 'react';
|
|
6
7
|
import map from 'lodash-es/map';
|
|
7
8
|
|
|
8
9
|
function _extends() {
|
|
@@ -40,14 +41,15 @@ function AddButton(_ref) {
|
|
|
40
41
|
color = _ref.color,
|
|
41
42
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
42
43
|
var translateString = registry.translateString;
|
|
43
|
-
return
|
|
44
|
+
return jsx(Button, _extends({
|
|
44
45
|
title: translateString(TranslatableString.AddItemButton),
|
|
45
46
|
color: color
|
|
46
47
|
}, props, {
|
|
47
48
|
icon: true,
|
|
48
|
-
size:
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
size: 'tiny',
|
|
50
|
+
children: jsx(Icon, {
|
|
51
|
+
name: 'plus'
|
|
52
|
+
})
|
|
51
53
|
}));
|
|
52
54
|
}
|
|
53
55
|
|
|
@@ -101,8 +103,8 @@ function getSemanticErrorProps(_ref2) {
|
|
|
101
103
|
options = _ref2$options === void 0 ? {} : _ref2$options,
|
|
102
104
|
_ref2$defaultProps = _ref2.defaultProps,
|
|
103
105
|
defaultProps = _ref2$defaultProps === void 0 ? {
|
|
104
|
-
size:
|
|
105
|
-
pointing:
|
|
106
|
+
size: 'small',
|
|
107
|
+
pointing: 'above'
|
|
106
108
|
} : _ref2$defaultProps;
|
|
107
109
|
var formContextProps = formContext.semantic && formContext.semantic.errorOptions;
|
|
108
110
|
var semanticOptions = getUiOptions(uiSchema).semantic;
|
|
@@ -132,7 +134,7 @@ function cleanClassNames(classNameArr, omit) {
|
|
|
132
134
|
// returning them as a string
|
|
133
135
|
return [].concat(new Set(classList.filter(function (cn) {
|
|
134
136
|
return !omit.includes(cn);
|
|
135
|
-
}))).join(
|
|
137
|
+
}))).join(' ');
|
|
136
138
|
}
|
|
137
139
|
/**
|
|
138
140
|
*
|
|
@@ -145,15 +147,15 @@ function cleanClassNames(classNameArr, omit) {
|
|
|
145
147
|
function MaybeWrap(_ref3) {
|
|
146
148
|
var wrap = _ref3.wrap,
|
|
147
149
|
_ref3$component = _ref3.component,
|
|
148
|
-
Component = _ref3$component === void 0 ?
|
|
150
|
+
Component = _ref3$component === void 0 ? 'div' : _ref3$component,
|
|
149
151
|
props = _objectWithoutPropertiesLoose(_ref3, _excluded$3);
|
|
150
|
-
return wrap ?
|
|
152
|
+
return wrap ? jsx(Component, _extends({}, props)) : props.children;
|
|
151
153
|
}
|
|
152
154
|
|
|
153
155
|
var gridStyle = function gridStyle(vertical) {
|
|
154
156
|
return {
|
|
155
|
-
display:
|
|
156
|
-
gridTemplateColumns: "1fr " + (vertical ? 65 :
|
|
157
|
+
display: 'grid',
|
|
158
|
+
gridTemplateColumns: "1fr " + (vertical ? 65 : 150) + "px"
|
|
157
159
|
};
|
|
158
160
|
};
|
|
159
161
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
@@ -164,16 +166,19 @@ function ArrayFieldItemTemplate(props) {
|
|
|
164
166
|
var children = props.children,
|
|
165
167
|
disabled = props.disabled,
|
|
166
168
|
hasToolbar = props.hasToolbar,
|
|
169
|
+
hasCopy = props.hasCopy,
|
|
167
170
|
hasMoveDown = props.hasMoveDown,
|
|
168
171
|
hasMoveUp = props.hasMoveUp,
|
|
169
172
|
hasRemove = props.hasRemove,
|
|
170
173
|
index = props.index,
|
|
174
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
171
175
|
onDropIndexClick = props.onDropIndexClick,
|
|
172
176
|
onReorderClick = props.onReorderClick,
|
|
173
177
|
readonly = props.readonly,
|
|
174
178
|
uiSchema = props.uiSchema,
|
|
175
179
|
registry = props.registry;
|
|
176
180
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
181
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
177
182
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
178
183
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
179
184
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -181,43 +186,56 @@ function ArrayFieldItemTemplate(props) {
|
|
|
181
186
|
// Pull the semantic props out of the uiOptions that were put in via the ArrayFieldTemplate
|
|
182
187
|
var _uiOptions$semantic = uiOptions.semantic,
|
|
183
188
|
_uiOptions$semantic$h = _uiOptions$semantic.horizontalButtons,
|
|
184
|
-
horizontalButtons = _uiOptions$semantic$h === void 0 ?
|
|
189
|
+
horizontalButtons = _uiOptions$semantic$h === void 0 ? true : _uiOptions$semantic$h,
|
|
185
190
|
_uiOptions$semantic$w = _uiOptions$semantic.wrapItem,
|
|
186
191
|
wrapItem = _uiOptions$semantic$w === void 0 ? false : _uiOptions$semantic$w;
|
|
187
|
-
return
|
|
188
|
-
className:
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
192
|
+
return jsx("div", {
|
|
193
|
+
className: 'array-item',
|
|
194
|
+
children: jsx(MaybeWrap, {
|
|
195
|
+
wrap: wrapItem,
|
|
196
|
+
component: Segment,
|
|
197
|
+
children: jsxs(Grid, {
|
|
198
|
+
style: _extends({}, gridStyle(!horizontalButtons), {
|
|
199
|
+
alignItems: 'center'
|
|
200
|
+
}),
|
|
201
|
+
children: [jsx(Grid.Column, {
|
|
202
|
+
width: 16,
|
|
203
|
+
verticalAlign: 'middle',
|
|
204
|
+
children: children
|
|
205
|
+
}), hasToolbar && jsx(Grid.Column, {
|
|
206
|
+
children: (hasMoveUp || hasMoveDown || hasRemove) && jsxs(Button.Group, {
|
|
207
|
+
size: 'mini',
|
|
208
|
+
vertical: !horizontalButtons,
|
|
209
|
+
children: [(hasMoveUp || hasMoveDown) && jsx(MoveUpButton, {
|
|
210
|
+
className: 'array-item-move-up',
|
|
211
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
212
|
+
onClick: onReorderClick(index, index - 1),
|
|
213
|
+
uiSchema: uiSchema,
|
|
214
|
+
registry: registry
|
|
215
|
+
}), (hasMoveUp || hasMoveDown) && jsx(MoveDownButton, {
|
|
216
|
+
className: 'array-item-move-down',
|
|
217
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
218
|
+
onClick: onReorderClick(index, index + 1),
|
|
219
|
+
uiSchema: uiSchema,
|
|
220
|
+
registry: registry
|
|
221
|
+
}), hasCopy && jsx(CopyButton, {
|
|
222
|
+
className: 'array-item-copy',
|
|
223
|
+
disabled: disabled || readonly,
|
|
224
|
+
onClick: onCopyIndexClick(index),
|
|
225
|
+
uiSchema: uiSchema,
|
|
226
|
+
registry: registry
|
|
227
|
+
}), hasRemove && jsx(RemoveButton, {
|
|
228
|
+
className: 'array-item-remove',
|
|
229
|
+
disabled: disabled || readonly,
|
|
230
|
+
onClick: onDropIndexClick(index),
|
|
231
|
+
uiSchema: uiSchema,
|
|
232
|
+
registry: registry
|
|
233
|
+
})]
|
|
234
|
+
})
|
|
235
|
+
})]
|
|
236
|
+
})
|
|
237
|
+
})
|
|
238
|
+
});
|
|
221
239
|
}
|
|
222
240
|
|
|
223
241
|
var _excluded$2 = ["key", "uiSchema"];
|
|
@@ -243,7 +261,7 @@ function ArrayFieldTemplate(props) {
|
|
|
243
261
|
uiSchema: uiSchema,
|
|
244
262
|
formContext: formContext,
|
|
245
263
|
defaultSchemaProps: {
|
|
246
|
-
horizontalButtons:
|
|
264
|
+
horizontalButtons: true,
|
|
247
265
|
wrapItem: false
|
|
248
266
|
}
|
|
249
267
|
});
|
|
@@ -254,57 +272,58 @@ function ArrayFieldTemplate(props) {
|
|
|
254
272
|
wrapItem: wrapItem
|
|
255
273
|
};
|
|
256
274
|
var uiOptions = getUiOptions(uiSchema);
|
|
257
|
-
var ArrayFieldDescriptionTemplate = getTemplate(
|
|
258
|
-
var ArrayFieldItemTemplate = getTemplate(
|
|
259
|
-
var ArrayFieldTitleTemplate = getTemplate(
|
|
275
|
+
var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
276
|
+
var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
277
|
+
var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
260
278
|
// Button templates are not overridden in the uiSchema
|
|
261
279
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
262
|
-
return
|
|
263
|
-
className: cleanClassNames([className, isFixedItems(schema) ?
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
280
|
+
return jsxs("div", {
|
|
281
|
+
className: cleanClassNames([className, isFixedItems(schema) ? '' : 'sortable-form-fields']),
|
|
282
|
+
children: [jsx(ArrayFieldTitleTemplate, {
|
|
283
|
+
idSchema: idSchema,
|
|
284
|
+
title: uiOptions.title || title,
|
|
285
|
+
schema: schema,
|
|
286
|
+
uiSchema: uiSchema,
|
|
287
|
+
required: required,
|
|
288
|
+
registry: registry
|
|
289
|
+
}), jsx(ArrayFieldDescriptionTemplate, {
|
|
290
|
+
idSchema: idSchema,
|
|
291
|
+
description: uiOptions.description || schema.description,
|
|
292
|
+
schema: schema,
|
|
293
|
+
uiSchema: uiSchema,
|
|
294
|
+
registry: registry
|
|
295
|
+
}), jsxs("div", {
|
|
296
|
+
children: [jsx("div", {
|
|
297
|
+
className: 'row array-item-list',
|
|
298
|
+
children: items && items.map(function (_ref) {
|
|
299
|
+
var _extends2;
|
|
300
|
+
var key = _ref.key,
|
|
301
|
+
_ref$uiSchema = _ref.uiSchema,
|
|
302
|
+
itemUiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
|
|
303
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
304
|
+
// Merge in the semantic props from the ArrayFieldTemplate into each of the items
|
|
305
|
+
var mergedUiSchema = _extends({}, itemUiSchema, (_extends2 = {}, _extends2[UI_OPTIONS_KEY] = _extends({}, itemUiSchema[UI_OPTIONS_KEY], {
|
|
306
|
+
semantic: semantic
|
|
307
|
+
}), _extends2));
|
|
308
|
+
return jsx(ArrayFieldItemTemplate, _extends({}, props, {
|
|
309
|
+
uiSchema: mergedUiSchema
|
|
310
|
+
}), key);
|
|
311
|
+
})
|
|
312
|
+
}), canAdd && jsx("div", {
|
|
313
|
+
style: {
|
|
314
|
+
marginTop: '1rem',
|
|
315
|
+
position: 'relative',
|
|
316
|
+
textAlign: 'right'
|
|
317
|
+
},
|
|
318
|
+
children: jsx(AddButton, {
|
|
319
|
+
onClick: onAddClick,
|
|
320
|
+
disabled: disabled || readonly,
|
|
321
|
+
uiSchema: uiSchema,
|
|
322
|
+
registry: registry
|
|
323
|
+
})
|
|
324
|
+
})]
|
|
325
|
+
}, "array-item-list-" + idSchema.$id)]
|
|
326
|
+
});
|
|
308
327
|
}
|
|
309
328
|
|
|
310
329
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
@@ -322,6 +341,7 @@ function BaseInputTemplate(props) {
|
|
|
322
341
|
readonly = props.readonly,
|
|
323
342
|
disabled = props.disabled,
|
|
324
343
|
onChange = props.onChange,
|
|
344
|
+
onChangeOverride = props.onChangeOverride,
|
|
325
345
|
onBlur = props.onBlur,
|
|
326
346
|
onFocus = props.onFocus,
|
|
327
347
|
autofocus = props.autofocus,
|
|
@@ -342,7 +362,7 @@ function BaseInputTemplate(props) {
|
|
|
342
362
|
var schemaUtils = registry.schemaUtils;
|
|
343
363
|
var _onChange = function _onChange(_ref) {
|
|
344
364
|
var value = _ref.target.value;
|
|
345
|
-
return onChange(value ===
|
|
365
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
346
366
|
};
|
|
347
367
|
var _onBlur = function _onBlur() {
|
|
348
368
|
return onBlur && onBlur(id, value);
|
|
@@ -351,32 +371,33 @@ function BaseInputTemplate(props) {
|
|
|
351
371
|
return onFocus && onFocus(id, value);
|
|
352
372
|
};
|
|
353
373
|
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
354
|
-
return
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
374
|
+
return jsxs(Fragment, {
|
|
375
|
+
children: [jsx(Form.Input, _extends({
|
|
376
|
+
id: id,
|
|
377
|
+
name: id,
|
|
378
|
+
placeholder: placeholder
|
|
379
|
+
}, inputProps, {
|
|
380
|
+
label: displayLabel ? label || schema.title : false,
|
|
381
|
+
required: required,
|
|
382
|
+
autoFocus: autofocus,
|
|
383
|
+
disabled: disabled || readonly,
|
|
384
|
+
list: schema.examples ? examplesId(id) : undefined
|
|
385
|
+
}, semanticProps, {
|
|
386
|
+
value: value || value === 0 ? value : '',
|
|
387
|
+
error: rawErrors.length > 0,
|
|
388
|
+
onChange: onChangeOverride || _onChange,
|
|
389
|
+
onBlur: _onBlur,
|
|
390
|
+
onFocus: _onFocus,
|
|
391
|
+
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
392
|
+
}), id), Array.isArray(schema.examples) && jsx("datalist", {
|
|
393
|
+
id: examplesId(id),
|
|
394
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
395
|
+
return jsx("option", {
|
|
396
|
+
value: example
|
|
397
|
+
}, example);
|
|
398
|
+
})
|
|
399
|
+
})]
|
|
400
|
+
});
|
|
380
401
|
}
|
|
381
402
|
|
|
382
403
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
@@ -389,10 +410,11 @@ function DescriptionField(props) {
|
|
|
389
410
|
if (!description) {
|
|
390
411
|
return null;
|
|
391
412
|
}
|
|
392
|
-
return
|
|
413
|
+
return jsx("p", {
|
|
393
414
|
id: id,
|
|
394
|
-
className:
|
|
395
|
-
|
|
415
|
+
className: 'sui-description',
|
|
416
|
+
children: description
|
|
417
|
+
});
|
|
396
418
|
}
|
|
397
419
|
|
|
398
420
|
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
@@ -403,13 +425,18 @@ function ErrorList(_ref) {
|
|
|
403
425
|
var errors = _ref.errors,
|
|
404
426
|
registry = _ref.registry;
|
|
405
427
|
var translateString = registry.translateString;
|
|
406
|
-
return
|
|
407
|
-
negative: true
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
428
|
+
return jsxs(Message, {
|
|
429
|
+
negative: true,
|
|
430
|
+
children: [jsx(Message.Header, {
|
|
431
|
+
children: translateString(TranslatableString.ErrorsLabel)
|
|
432
|
+
}), jsx(Message.List, {
|
|
433
|
+
children: errors.map(function (error, index) {
|
|
434
|
+
return jsx(Message.Item, {
|
|
435
|
+
children: error.stack
|
|
436
|
+
}, "error-" + index);
|
|
437
|
+
})
|
|
438
|
+
})]
|
|
439
|
+
});
|
|
413
440
|
}
|
|
414
441
|
|
|
415
442
|
var _excluded$1 = ["icon", "iconType", "color", "className", "uiSchema", "registry"];
|
|
@@ -419,42 +446,50 @@ function IconButton(props) {
|
|
|
419
446
|
color = props.color,
|
|
420
447
|
className = props.className,
|
|
421
448
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
422
|
-
return
|
|
449
|
+
return jsx(Button, _extends({
|
|
423
450
|
icon: icon,
|
|
424
451
|
size: iconType,
|
|
425
452
|
color: color,
|
|
426
453
|
className: className
|
|
427
454
|
}, otherProps));
|
|
428
455
|
}
|
|
456
|
+
function CopyButton(props) {
|
|
457
|
+
var translateString = props.registry.translateString;
|
|
458
|
+
return jsx(IconButton, _extends({
|
|
459
|
+
title: translateString(TranslatableString.CopyButton)
|
|
460
|
+
}, props, {
|
|
461
|
+
icon: 'copy'
|
|
462
|
+
}));
|
|
463
|
+
}
|
|
429
464
|
function MoveDownButton(props) {
|
|
430
465
|
var translateString = props.registry.translateString;
|
|
431
|
-
return
|
|
466
|
+
return jsx(IconButton, _extends({
|
|
432
467
|
title: translateString(TranslatableString.MoveDownButton)
|
|
433
468
|
}, props, {
|
|
434
|
-
icon:
|
|
469
|
+
icon: 'angle down'
|
|
435
470
|
}));
|
|
436
471
|
}
|
|
437
472
|
function MoveUpButton(props) {
|
|
438
473
|
var translateString = props.registry.translateString;
|
|
439
|
-
return
|
|
474
|
+
return jsx(IconButton, _extends({
|
|
440
475
|
title: translateString(TranslatableString.MoveUpButton)
|
|
441
476
|
}, props, {
|
|
442
|
-
icon:
|
|
477
|
+
icon: 'angle up'
|
|
443
478
|
}));
|
|
444
479
|
}
|
|
445
480
|
function RemoveButton(props) {
|
|
446
481
|
var translateString = props.registry.translateString;
|
|
447
|
-
return
|
|
482
|
+
return jsx(IconButton, _extends({
|
|
448
483
|
title: translateString(TranslatableString.RemoveButton)
|
|
449
484
|
}, props, {
|
|
450
|
-
icon:
|
|
485
|
+
icon: 'trash'
|
|
451
486
|
}));
|
|
452
487
|
}
|
|
453
488
|
|
|
454
489
|
var DEFAULT_OPTIONS$1 = {
|
|
455
490
|
options: {
|
|
456
|
-
pointing:
|
|
457
|
-
size:
|
|
491
|
+
pointing: 'above',
|
|
492
|
+
size: 'small'
|
|
458
493
|
}
|
|
459
494
|
};
|
|
460
495
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -476,19 +511,21 @@ function FieldErrorTemplate(_ref) {
|
|
|
476
511
|
size = options.size;
|
|
477
512
|
if (errors && errors.length > 0) {
|
|
478
513
|
var id = errorId(idSchema);
|
|
479
|
-
return
|
|
514
|
+
return jsx(Label, {
|
|
480
515
|
id: id,
|
|
481
|
-
color:
|
|
482
|
-
pointing: pointing ||
|
|
483
|
-
size: size ||
|
|
484
|
-
basic: true
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
516
|
+
color: 'red',
|
|
517
|
+
pointing: pointing || 'above',
|
|
518
|
+
size: size || 'small',
|
|
519
|
+
basic: true,
|
|
520
|
+
children: jsx(List, {
|
|
521
|
+
bulleted: true,
|
|
522
|
+
children: errors.map(function (error) {
|
|
523
|
+
return jsx(List.Item, {
|
|
524
|
+
children: error
|
|
525
|
+
}, nanoid());
|
|
526
|
+
})
|
|
527
|
+
})
|
|
528
|
+
});
|
|
492
529
|
}
|
|
493
530
|
return null;
|
|
494
531
|
}
|
|
@@ -502,8 +539,8 @@ function FieldHelpTemplate(props) {
|
|
|
502
539
|
help = props.help;
|
|
503
540
|
if (help) {
|
|
504
541
|
var id = helpId(idSchema);
|
|
505
|
-
return
|
|
506
|
-
size:
|
|
542
|
+
return jsx(Message, {
|
|
543
|
+
size: 'mini',
|
|
507
544
|
info: true,
|
|
508
545
|
id: id,
|
|
509
546
|
content: help
|
|
@@ -537,16 +574,17 @@ function FieldTemplate(props) {
|
|
|
537
574
|
var wrapLabel = semanticProps.wrapLabel,
|
|
538
575
|
wrapContent = semanticProps.wrapContent;
|
|
539
576
|
var uiOptions = getUiOptions(uiSchema);
|
|
540
|
-
var WrapIfAdditionalTemplate = getTemplate(
|
|
541
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
577
|
+
var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
578
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
542
579
|
if (hidden) {
|
|
543
|
-
return
|
|
580
|
+
return jsx("div", {
|
|
544
581
|
style: {
|
|
545
|
-
display:
|
|
546
|
-
}
|
|
547
|
-
|
|
582
|
+
display: 'none'
|
|
583
|
+
},
|
|
584
|
+
children: children
|
|
585
|
+
});
|
|
548
586
|
}
|
|
549
|
-
return
|
|
587
|
+
return jsx(WrapIfAdditionalTemplate, _extends({
|
|
550
588
|
classNames: classNames,
|
|
551
589
|
style: style,
|
|
552
590
|
id: id,
|
|
@@ -554,23 +592,27 @@ function FieldTemplate(props) {
|
|
|
554
592
|
registry: registry,
|
|
555
593
|
schema: schema,
|
|
556
594
|
uiSchema: uiSchema
|
|
557
|
-
}, otherProps
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
595
|
+
}, otherProps, {
|
|
596
|
+
children: jsx(Form.Group, {
|
|
597
|
+
widths: 'equal',
|
|
598
|
+
grouped: true,
|
|
599
|
+
children: jsxs(MaybeWrap, {
|
|
600
|
+
wrap: wrapContent,
|
|
601
|
+
className: 'sui-field-content',
|
|
602
|
+
children: [children, displayLabel && rawDescription && jsx(MaybeWrap, {
|
|
603
|
+
wrap: wrapLabel,
|
|
604
|
+
className: 'sui-field-label',
|
|
605
|
+
children: rawDescription && jsx(DescriptionFieldTemplate, {
|
|
606
|
+
id: descriptionId(id),
|
|
607
|
+
description: rawDescription,
|
|
608
|
+
schema: schema,
|
|
609
|
+
uiSchema: uiSchema,
|
|
610
|
+
registry: registry
|
|
611
|
+
})
|
|
612
|
+
}), help, errors]
|
|
613
|
+
})
|
|
614
|
+
}, id)
|
|
615
|
+
}));
|
|
574
616
|
}
|
|
575
617
|
|
|
576
618
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -593,42 +635,48 @@ function ObjectFieldTemplate(props) {
|
|
|
593
635
|
idSchema = props.idSchema,
|
|
594
636
|
registry = props.registry;
|
|
595
637
|
var uiOptions = getUiOptions(uiSchema);
|
|
596
|
-
var TitleFieldTemplate = getTemplate(
|
|
597
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
638
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
639
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
598
640
|
// Button templates are not overridden in the uiSchema
|
|
599
641
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
600
642
|
var fieldTitle = uiOptions.title || title;
|
|
601
643
|
var fieldDescription = uiOptions.description || description;
|
|
602
|
-
return
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
644
|
+
return jsxs(Fragment, {
|
|
645
|
+
children: [fieldTitle && jsx(TitleFieldTemplate, {
|
|
646
|
+
id: titleId(idSchema),
|
|
647
|
+
title: fieldTitle,
|
|
648
|
+
required: required,
|
|
649
|
+
schema: schema,
|
|
650
|
+
uiSchema: uiSchema,
|
|
651
|
+
registry: registry
|
|
652
|
+
}), fieldDescription && jsx(DescriptionFieldTemplate, {
|
|
653
|
+
id: descriptionId(idSchema),
|
|
654
|
+
description: fieldDescription,
|
|
655
|
+
schema: schema,
|
|
656
|
+
uiSchema: uiSchema,
|
|
657
|
+
registry: registry
|
|
658
|
+
}), properties.map(function (prop) {
|
|
659
|
+
return prop.content;
|
|
660
|
+
}), canExpand(schema, uiSchema, formData) && jsx(Grid.Column, {
|
|
661
|
+
width: 16,
|
|
662
|
+
verticalAlign: 'middle',
|
|
663
|
+
children: jsx(Grid.Row, {
|
|
664
|
+
children: jsx("div", {
|
|
665
|
+
style: {
|
|
666
|
+
marginTop: '1rem',
|
|
667
|
+
position: 'relative',
|
|
668
|
+
textAlign: 'right'
|
|
669
|
+
},
|
|
670
|
+
children: jsx(AddButton, {
|
|
671
|
+
onClick: onAddClick(schema),
|
|
672
|
+
disabled: disabled || readonly,
|
|
673
|
+
uiSchema: uiSchema,
|
|
674
|
+
registry: registry
|
|
675
|
+
})
|
|
676
|
+
})
|
|
677
|
+
})
|
|
678
|
+
})]
|
|
679
|
+
});
|
|
632
680
|
}
|
|
633
681
|
|
|
634
682
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -643,10 +691,12 @@ function SubmitButton(_ref) {
|
|
|
643
691
|
if (norender) {
|
|
644
692
|
return null;
|
|
645
693
|
}
|
|
646
|
-
return
|
|
647
|
-
type:
|
|
694
|
+
return jsx(Button, _extends({
|
|
695
|
+
type: 'submit',
|
|
648
696
|
primary: true
|
|
649
|
-
}, submitButtonProps
|
|
697
|
+
}, submitButtonProps, {
|
|
698
|
+
children: submitText
|
|
699
|
+
}));
|
|
650
700
|
}
|
|
651
701
|
|
|
652
702
|
var DEFAULT_OPTIONS = {
|
|
@@ -668,11 +718,12 @@ function TitleField(_ref) {
|
|
|
668
718
|
if (!title) {
|
|
669
719
|
return null;
|
|
670
720
|
}
|
|
671
|
-
return
|
|
721
|
+
return jsx(Header, _extends({
|
|
672
722
|
id: id
|
|
673
723
|
}, semanticProps, {
|
|
674
|
-
as:
|
|
675
|
-
|
|
724
|
+
as: 'h5',
|
|
725
|
+
children: title
|
|
726
|
+
}));
|
|
676
727
|
}
|
|
677
728
|
|
|
678
729
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -705,51 +756,60 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
705
756
|
wrapperStyle = _registry$formContext.wrapperStyle;
|
|
706
757
|
var additional = (ADDITIONAL_PROPERTY_FLAG in schema);
|
|
707
758
|
if (!additional) {
|
|
708
|
-
return
|
|
759
|
+
return jsx("div", {
|
|
709
760
|
className: classNames,
|
|
710
|
-
style: style
|
|
711
|
-
|
|
761
|
+
style: style,
|
|
762
|
+
children: children
|
|
763
|
+
});
|
|
712
764
|
}
|
|
713
765
|
var handleBlur = function handleBlur(_ref) {
|
|
714
766
|
var target = _ref.target;
|
|
715
767
|
return onKeyChange(target.value);
|
|
716
768
|
};
|
|
717
|
-
return
|
|
769
|
+
return jsx("div", {
|
|
718
770
|
className: classNames,
|
|
719
771
|
style: style,
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
772
|
+
children: jsx(Grid, {
|
|
773
|
+
columns: 'equal',
|
|
774
|
+
children: jsxs(Grid.Row, {
|
|
775
|
+
children: [jsx(Grid.Column, {
|
|
776
|
+
className: 'form-additional',
|
|
777
|
+
children: jsx(Form.Group, {
|
|
778
|
+
widths: 'equal',
|
|
779
|
+
grouped: true,
|
|
780
|
+
children: jsx(Form.Input, {
|
|
781
|
+
className: 'form-group',
|
|
782
|
+
hasFeedback: true,
|
|
783
|
+
fluid: true,
|
|
784
|
+
htmlFor: "" + id,
|
|
785
|
+
label: keyLabel,
|
|
786
|
+
required: required,
|
|
787
|
+
defaultValue: label,
|
|
788
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
789
|
+
id: "" + id,
|
|
790
|
+
name: "" + id,
|
|
791
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
792
|
+
style: wrapperStyle,
|
|
793
|
+
type: 'text'
|
|
794
|
+
})
|
|
795
|
+
})
|
|
796
|
+
}), jsx(Grid.Column, {
|
|
797
|
+
className: 'form-additional',
|
|
798
|
+
verticalAlign: 'middle',
|
|
799
|
+
children: children
|
|
800
|
+
}), jsx(Grid.Column, {
|
|
801
|
+
children: jsx(RemoveButton, {
|
|
802
|
+
iconType: 'mini',
|
|
803
|
+
className: 'array-item-remove',
|
|
804
|
+
disabled: disabled || readonly,
|
|
805
|
+
onClick: onDropPropertyClick(label),
|
|
806
|
+
uiSchema: uiSchema,
|
|
807
|
+
registry: registry
|
|
808
|
+
})
|
|
809
|
+
})]
|
|
810
|
+
})
|
|
811
|
+
})
|
|
812
|
+
}, id + "-key");
|
|
753
813
|
}
|
|
754
814
|
|
|
755
815
|
function generateTemplates() {
|
|
@@ -759,6 +819,7 @@ function generateTemplates() {
|
|
|
759
819
|
BaseInputTemplate: BaseInputTemplate,
|
|
760
820
|
ButtonTemplates: {
|
|
761
821
|
AddButton: AddButton,
|
|
822
|
+
CopyButton: CopyButton,
|
|
762
823
|
MoveDownButton: MoveDownButton,
|
|
763
824
|
MoveUpButton: MoveUpButton,
|
|
764
825
|
RemoveButton: RemoveButton,
|
|
@@ -802,7 +863,7 @@ function CheckboxWidget(props) {
|
|
|
802
863
|
formContext: formContext,
|
|
803
864
|
uiSchema: uiSchema,
|
|
804
865
|
defaultSchemaProps: {
|
|
805
|
-
inverted: false
|
|
866
|
+
inverted: 'false'
|
|
806
867
|
}
|
|
807
868
|
});
|
|
808
869
|
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
@@ -818,20 +879,20 @@ function CheckboxWidget(props) {
|
|
|
818
879
|
var _onFocus = function _onFocus() {
|
|
819
880
|
return onFocus && onFocus(id, value);
|
|
820
881
|
};
|
|
821
|
-
var checked = value ==
|
|
822
|
-
return
|
|
882
|
+
var checked = value == 'true' || value == true;
|
|
883
|
+
return jsx(Form.Checkbox, _extends({
|
|
823
884
|
id: id,
|
|
824
885
|
name: id,
|
|
825
886
|
disabled: disabled || readonly,
|
|
826
887
|
autoFocus: autofocus
|
|
827
888
|
}, semanticProps, {
|
|
828
|
-
checked: typeof value ===
|
|
889
|
+
checked: typeof value === 'undefined' ? false : checked,
|
|
829
890
|
error: rawErrors.length > 0,
|
|
830
891
|
onChange: _onChange,
|
|
831
892
|
onBlur: _onBlur,
|
|
832
893
|
onFocus: _onFocus,
|
|
833
894
|
required: required,
|
|
834
|
-
label: label ||
|
|
895
|
+
label: label || '',
|
|
835
896
|
"aria-describedby": ariaDescribedByIds(id)
|
|
836
897
|
}));
|
|
837
898
|
}
|
|
@@ -857,7 +918,7 @@ function CheckboxesWidget(props) {
|
|
|
857
918
|
_props$rawErrors = props.rawErrors,
|
|
858
919
|
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
859
920
|
registry = props.registry;
|
|
860
|
-
var TitleFieldTemplate = getTemplate(
|
|
921
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, options);
|
|
861
922
|
var enumOptions = options.enumOptions,
|
|
862
923
|
enumDisabled = options.enumDisabled,
|
|
863
924
|
inline = options.inline;
|
|
@@ -868,7 +929,7 @@ function CheckboxesWidget(props) {
|
|
|
868
929
|
formContext: formContext,
|
|
869
930
|
uiSchema: uiSchema,
|
|
870
931
|
defaultSchemaProps: {
|
|
871
|
-
inverted: false
|
|
932
|
+
inverted: 'false'
|
|
872
933
|
}
|
|
873
934
|
});
|
|
874
935
|
var _onChange = function _onChange(index) {
|
|
@@ -893,34 +954,37 @@ function CheckboxesWidget(props) {
|
|
|
893
954
|
} : {
|
|
894
955
|
grouped: true
|
|
895
956
|
};
|
|
896
|
-
return
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
957
|
+
return jsxs(Fragment, {
|
|
958
|
+
children: [title && jsx(TitleFieldTemplate, {
|
|
959
|
+
id: titleId(id),
|
|
960
|
+
title: title,
|
|
961
|
+
schema: schema,
|
|
962
|
+
uiSchema: uiSchema,
|
|
963
|
+
registry: registry
|
|
964
|
+
}), jsx(Form.Group, _extends({
|
|
965
|
+
id: id,
|
|
966
|
+
name: id
|
|
967
|
+
}, inlineOption, {
|
|
968
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
969
|
+
var checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
970
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
971
|
+
return jsx(Form.Checkbox, _extends({
|
|
972
|
+
id: optionId(id, index),
|
|
973
|
+
name: id,
|
|
974
|
+
label: option.label
|
|
975
|
+
}, semanticProps, {
|
|
976
|
+
checked: checked,
|
|
977
|
+
error: rawErrors.length > 0,
|
|
978
|
+
disabled: disabled || itemDisabled || readonly,
|
|
979
|
+
autoFocus: autofocus && index === 0,
|
|
980
|
+
onChange: _onChange(index),
|
|
981
|
+
onBlur: _onBlur,
|
|
982
|
+
onFocus: _onFocus,
|
|
983
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
984
|
+
}), index);
|
|
985
|
+
})
|
|
986
|
+
}))]
|
|
987
|
+
});
|
|
924
988
|
}
|
|
925
989
|
|
|
926
990
|
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
@@ -965,26 +1029,28 @@ function RadioWidget(props) {
|
|
|
965
1029
|
} : {
|
|
966
1030
|
grouped: true
|
|
967
1031
|
};
|
|
968
|
-
return
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1032
|
+
return jsx(Form.Group, _extends({}, inlineOption, {
|
|
1033
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
1034
|
+
var checked = enumOptionsIsSelected(option.value, value);
|
|
1035
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
1036
|
+
return /*#__PURE__*/createElement(Form.Field, _extends({
|
|
1037
|
+
required: required,
|
|
1038
|
+
control: Radio,
|
|
1039
|
+
id: optionId(id, index),
|
|
1040
|
+
name: id
|
|
1041
|
+
}, semanticProps, {
|
|
1042
|
+
onFocus: _onFocus,
|
|
1043
|
+
onBlur: _onBlur,
|
|
1044
|
+
onChange: _onChange,
|
|
1045
|
+
label: option.label,
|
|
1046
|
+
value: String(index),
|
|
1047
|
+
error: rawErrors.length > 0,
|
|
1048
|
+
key: index,
|
|
1049
|
+
checked: checked,
|
|
1050
|
+
disabled: disabled || itemDisabled || readonly,
|
|
1051
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
1052
|
+
}));
|
|
1053
|
+
})
|
|
988
1054
|
}));
|
|
989
1055
|
}
|
|
990
1056
|
|
|
@@ -1019,7 +1085,7 @@ function RangeWidget(props) {
|
|
|
1019
1085
|
// eslint-disable-next-line no-shadow
|
|
1020
1086
|
var _onChange = function _onChange(_ref) {
|
|
1021
1087
|
var value = _ref.target.value;
|
|
1022
|
-
return onChange && onChange(value ===
|
|
1088
|
+
return onChange && onChange(value === '' ? options.emptyValue : value);
|
|
1023
1089
|
};
|
|
1024
1090
|
var _onBlur = function _onBlur() {
|
|
1025
1091
|
return onBlur && onBlur(id, value);
|
|
@@ -1027,21 +1093,24 @@ function RangeWidget(props) {
|
|
|
1027
1093
|
var _onFocus = function _onFocus() {
|
|
1028
1094
|
return onFocus && onFocus(id, value);
|
|
1029
1095
|
};
|
|
1030
|
-
return
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1096
|
+
return jsxs(Fragment, {
|
|
1097
|
+
children: [jsx(Input, _extends({
|
|
1098
|
+
id: id,
|
|
1099
|
+
name: id,
|
|
1100
|
+
type: 'range',
|
|
1101
|
+
required: required,
|
|
1102
|
+
disabled: disabled || readonly
|
|
1103
|
+
}, rangeSpec(schema), semanticProps, {
|
|
1104
|
+
value: value || '',
|
|
1105
|
+
error: rawErrors.length > 0,
|
|
1106
|
+
onChange: _onChange,
|
|
1107
|
+
onBlur: _onBlur,
|
|
1108
|
+
onFocus: _onFocus,
|
|
1109
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
1110
|
+
}), id), jsx("span", {
|
|
1111
|
+
children: value
|
|
1112
|
+
})]
|
|
1113
|
+
});
|
|
1045
1114
|
}
|
|
1046
1115
|
|
|
1047
1116
|
/**
|
|
@@ -1093,7 +1162,7 @@ function SelectWidget(props) {
|
|
|
1093
1162
|
formContext: formContext,
|
|
1094
1163
|
options: options,
|
|
1095
1164
|
defaultSchemaProps: {
|
|
1096
|
-
inverted:
|
|
1165
|
+
inverted: 'false',
|
|
1097
1166
|
selection: true,
|
|
1098
1167
|
fluid: true,
|
|
1099
1168
|
scrolling: true,
|
|
@@ -1103,7 +1172,7 @@ function SelectWidget(props) {
|
|
|
1103
1172
|
var enumDisabled = options.enumDisabled,
|
|
1104
1173
|
enumOptions = options.enumOptions,
|
|
1105
1174
|
optEmptyVal = options.emptyValue;
|
|
1106
|
-
var emptyValue = multiple ? [] :
|
|
1175
|
+
var emptyValue = multiple ? [] : '';
|
|
1107
1176
|
var dropdownOptions = createDefaultValueOptionsForDropDown(enumOptions, enumDisabled);
|
|
1108
1177
|
var _onChange = function _onChange(_, _ref2) {
|
|
1109
1178
|
var value = _ref2.value;
|
|
@@ -1119,13 +1188,12 @@ function SelectWidget(props) {
|
|
|
1119
1188
|
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1120
1189
|
};
|
|
1121
1190
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1122
|
-
return
|
|
1123
|
-
key: id,
|
|
1191
|
+
return jsx(Form.Dropdown, _extends({
|
|
1124
1192
|
id: id,
|
|
1125
1193
|
name: id,
|
|
1126
1194
|
label: label || schema.title,
|
|
1127
|
-
multiple: typeof multiple ===
|
|
1128
|
-
value: typeof value ===
|
|
1195
|
+
multiple: typeof multiple === 'undefined' ? false : multiple,
|
|
1196
|
+
value: typeof value === 'undefined' ? emptyValue : selectedIndexes,
|
|
1129
1197
|
error: rawErrors.length > 0,
|
|
1130
1198
|
disabled: disabled,
|
|
1131
1199
|
placeholder: placeholder
|
|
@@ -1138,7 +1206,7 @@ function SelectWidget(props) {
|
|
|
1138
1206
|
onBlur: _onBlur,
|
|
1139
1207
|
onFocus: _onFocus,
|
|
1140
1208
|
"aria-describedby": ariaDescribedByIds(id)
|
|
1141
|
-
}));
|
|
1209
|
+
}), id);
|
|
1142
1210
|
}
|
|
1143
1211
|
|
|
1144
1212
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
@@ -1168,14 +1236,14 @@ function TextareaWidget(props) {
|
|
|
1168
1236
|
formContext: formContext,
|
|
1169
1237
|
options: options,
|
|
1170
1238
|
defaultSchemaProps: {
|
|
1171
|
-
inverted: false
|
|
1239
|
+
inverted: 'false'
|
|
1172
1240
|
}
|
|
1173
1241
|
});
|
|
1174
1242
|
var schemaUtils = registry.schemaUtils;
|
|
1175
1243
|
// eslint-disable-next-line no-shadow
|
|
1176
1244
|
var _onChange = function _onChange(_ref) {
|
|
1177
1245
|
var value = _ref.target.value;
|
|
1178
|
-
return onChange && onChange(value ===
|
|
1246
|
+
return onChange && onChange(value === '' ? options.emptyValue : value);
|
|
1179
1247
|
};
|
|
1180
1248
|
var _onBlur = function _onBlur() {
|
|
1181
1249
|
return onBlur && onBlur(id, value);
|
|
@@ -1184,9 +1252,8 @@ function TextareaWidget(props) {
|
|
|
1184
1252
|
return onFocus && onFocus(id, value);
|
|
1185
1253
|
};
|
|
1186
1254
|
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
1187
|
-
return
|
|
1255
|
+
return jsx(Form.TextArea, _extends({
|
|
1188
1256
|
id: id,
|
|
1189
|
-
key: id,
|
|
1190
1257
|
name: id,
|
|
1191
1258
|
label: displayLabel ? label || schema.title : false,
|
|
1192
1259
|
placeholder: placeholder,
|
|
@@ -1194,14 +1261,14 @@ function TextareaWidget(props) {
|
|
|
1194
1261
|
required: required,
|
|
1195
1262
|
disabled: disabled || readonly
|
|
1196
1263
|
}, semanticProps, {
|
|
1197
|
-
value: value ||
|
|
1264
|
+
value: value || '',
|
|
1198
1265
|
error: rawErrors.length > 0,
|
|
1199
1266
|
rows: options.rows || 5,
|
|
1200
1267
|
onChange: _onChange,
|
|
1201
1268
|
onBlur: _onBlur,
|
|
1202
1269
|
onFocus: _onFocus,
|
|
1203
1270
|
"aria-describedby": ariaDescribedByIds(id)
|
|
1204
|
-
}));
|
|
1271
|
+
}), id);
|
|
1205
1272
|
}
|
|
1206
1273
|
|
|
1207
1274
|
function generateWidgets() {
|