@rjsf/mui 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 +1 -0
- package/dist/mui.cjs.development.js +436 -397
- package/dist/mui.cjs.development.js.map +1 -1
- package/dist/mui.cjs.production.min.js +1 -1
- package/dist/mui.cjs.production.min.js.map +1 -1
- package/dist/mui.esm.js +436 -397
- package/dist/mui.esm.js.map +1 -1
- package/dist/mui.umd.development.js +438 -400
- package/dist/mui.umd.development.js.map +1 -1
- package/dist/mui.umd.production.min.js +1 -1
- package/dist/mui.umd.production.min.js.map +1 -1
- package/package.json +14 -14
package/dist/mui.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { withTheme } from '@rjsf/core';
|
|
2
|
-
import
|
|
2
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import AddIcon from '@mui/icons-material/Add';
|
|
4
4
|
import IconButton from '@mui/material/IconButton';
|
|
5
|
-
import { TranslatableString, getUiOptions, getTemplate, getInputProps, examplesId, ariaDescribedByIds, errorId, helpId, titleId, descriptionId, canExpand, getSubmitButtonOptions, ADDITIONAL_PROPERTY_FLAG, schemaRequiresTrueValue, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, enumOptionsValueForIndex,
|
|
5
|
+
import { TranslatableString, getUiOptions, getTemplate, getInputProps, examplesId, ariaDescribedByIds, errorId, helpId, titleId, descriptionId, canExpand, getSubmitButtonOptions, ADDITIONAL_PROPERTY_FLAG, schemaRequiresTrueValue, enumOptionsIsSelected, optionId, enumOptionsSelectValue, enumOptionsDeselectValue, enumOptionsValueForIndex, enumOptionsIndexForValue, rangeSpec } from '@rjsf/utils';
|
|
6
6
|
import Box from '@mui/material/Box';
|
|
7
7
|
import Grid from '@mui/material/Grid';
|
|
8
8
|
import Paper from '@mui/material/Paper';
|
|
@@ -15,6 +15,7 @@ import ListItemIcon from '@mui/material/ListItemIcon';
|
|
|
15
15
|
import ListItemText from '@mui/material/ListItemText';
|
|
16
16
|
import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward';
|
|
17
17
|
import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward';
|
|
18
|
+
import CopyIcon from '@mui/icons-material/ContentCopy';
|
|
18
19
|
import RemoveIcon from '@mui/icons-material/Remove';
|
|
19
20
|
import FormHelperText from '@mui/material/FormHelperText';
|
|
20
21
|
import FormControl from '@mui/material/FormControl';
|
|
@@ -65,11 +66,12 @@ function AddButton(_ref) {
|
|
|
65
66
|
var registry = _ref.registry,
|
|
66
67
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
67
68
|
var translateString = registry.translateString;
|
|
68
|
-
return
|
|
69
|
+
return jsx(IconButton, _extends({
|
|
69
70
|
title: translateString(TranslatableString.AddItemButton)
|
|
70
71
|
}, props, {
|
|
71
|
-
color:
|
|
72
|
-
|
|
72
|
+
color: 'primary',
|
|
73
|
+
children: jsx(AddIcon, {})
|
|
74
|
+
}));
|
|
73
75
|
}
|
|
74
76
|
|
|
75
77
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
@@ -80,16 +82,19 @@ function ArrayFieldItemTemplate(props) {
|
|
|
80
82
|
var children = props.children,
|
|
81
83
|
disabled = props.disabled,
|
|
82
84
|
hasToolbar = props.hasToolbar,
|
|
85
|
+
hasCopy = props.hasCopy,
|
|
83
86
|
hasMoveDown = props.hasMoveDown,
|
|
84
87
|
hasMoveUp = props.hasMoveUp,
|
|
85
88
|
hasRemove = props.hasRemove,
|
|
86
89
|
index = props.index,
|
|
90
|
+
onCopyIndexClick = props.onCopyIndexClick,
|
|
87
91
|
onDropIndexClick = props.onDropIndexClick,
|
|
88
92
|
onReorderClick = props.onReorderClick,
|
|
89
93
|
readonly = props.readonly,
|
|
90
94
|
uiSchema = props.uiSchema,
|
|
91
95
|
registry = props.registry;
|
|
92
96
|
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
97
|
+
CopyButton = _registry$templates$B.CopyButton,
|
|
93
98
|
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
94
99
|
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
95
100
|
RemoveButton = _registry$templates$B.RemoveButton;
|
|
@@ -97,45 +102,57 @@ function ArrayFieldItemTemplate(props) {
|
|
|
97
102
|
flex: 1,
|
|
98
103
|
paddingLeft: 6,
|
|
99
104
|
paddingRight: 6,
|
|
100
|
-
fontWeight:
|
|
105
|
+
fontWeight: 'bold',
|
|
101
106
|
minWidth: 0
|
|
102
107
|
};
|
|
103
|
-
return
|
|
108
|
+
return jsxs(Grid, {
|
|
104
109
|
container: true,
|
|
105
|
-
alignItems:
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
children: [jsx(Grid, {
|
|
112
|
+
item: true,
|
|
113
|
+
xs: true,
|
|
114
|
+
style: {
|
|
115
|
+
overflow: 'auto'
|
|
116
|
+
},
|
|
117
|
+
children: jsx(Box, {
|
|
118
|
+
mb: 2,
|
|
119
|
+
children: jsx(Paper, {
|
|
120
|
+
elevation: 2,
|
|
121
|
+
children: jsx(Box, {
|
|
122
|
+
p: 2,
|
|
123
|
+
children: children
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
})
|
|
127
|
+
}), hasToolbar && jsxs(Grid, {
|
|
128
|
+
item: true,
|
|
129
|
+
children: [(hasMoveUp || hasMoveDown) && jsx(MoveUpButton, {
|
|
130
|
+
style: btnStyle,
|
|
131
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
132
|
+
onClick: onReorderClick(index, index - 1),
|
|
133
|
+
uiSchema: uiSchema,
|
|
134
|
+
registry: registry
|
|
135
|
+
}), (hasMoveUp || hasMoveDown) && jsx(MoveDownButton, {
|
|
136
|
+
style: btnStyle,
|
|
137
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
138
|
+
onClick: onReorderClick(index, index + 1),
|
|
139
|
+
uiSchema: uiSchema,
|
|
140
|
+
registry: registry
|
|
141
|
+
}), hasCopy && jsx(CopyButton, {
|
|
142
|
+
style: btnStyle,
|
|
143
|
+
disabled: disabled || readonly,
|
|
144
|
+
onClick: onCopyIndexClick(index),
|
|
145
|
+
uiSchema: uiSchema,
|
|
146
|
+
registry: registry
|
|
147
|
+
}), hasRemove && jsx(RemoveButton, {
|
|
148
|
+
style: btnStyle,
|
|
149
|
+
disabled: disabled || readonly,
|
|
150
|
+
onClick: onDropIndexClick(index),
|
|
151
|
+
uiSchema: uiSchema,
|
|
152
|
+
registry: registry
|
|
153
|
+
})]
|
|
154
|
+
})]
|
|
155
|
+
});
|
|
139
156
|
}
|
|
140
157
|
|
|
141
158
|
var _excluded$3 = ["key"];
|
|
@@ -156,55 +173,59 @@ function ArrayFieldTemplate(props) {
|
|
|
156
173
|
schema = props.schema,
|
|
157
174
|
title = props.title;
|
|
158
175
|
var uiOptions = getUiOptions(uiSchema);
|
|
159
|
-
var ArrayFieldDescriptionTemplate = getTemplate(
|
|
160
|
-
var ArrayFieldItemTemplate = getTemplate(
|
|
161
|
-
var ArrayFieldTitleTemplate = getTemplate(
|
|
176
|
+
var ArrayFieldDescriptionTemplate = getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
177
|
+
var ArrayFieldItemTemplate = getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
178
|
+
var ArrayFieldTitleTemplate = getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
162
179
|
// Button templates are not overridden in the uiSchema
|
|
163
180
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
164
|
-
return
|
|
165
|
-
elevation: 2
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
181
|
+
return jsx(Paper, {
|
|
182
|
+
elevation: 2,
|
|
183
|
+
children: jsxs(Box, {
|
|
184
|
+
p: 2,
|
|
185
|
+
children: [jsx(ArrayFieldTitleTemplate, {
|
|
186
|
+
idSchema: idSchema,
|
|
187
|
+
title: uiOptions.title || title,
|
|
188
|
+
schema: schema,
|
|
189
|
+
uiSchema: uiSchema,
|
|
190
|
+
required: required,
|
|
191
|
+
registry: registry
|
|
192
|
+
}), jsx(ArrayFieldDescriptionTemplate, {
|
|
193
|
+
idSchema: idSchema,
|
|
194
|
+
description: uiOptions.description || schema.description,
|
|
195
|
+
schema: schema,
|
|
196
|
+
uiSchema: uiSchema,
|
|
197
|
+
registry: registry
|
|
198
|
+
}), jsxs(Grid, {
|
|
199
|
+
container: true,
|
|
200
|
+
children: [items && items.map(function (_ref) {
|
|
201
|
+
var key = _ref.key,
|
|
202
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
203
|
+
return jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
204
|
+
}), canAdd && jsx(Grid, {
|
|
205
|
+
container: true,
|
|
206
|
+
justifyContent: 'flex-end',
|
|
207
|
+
children: jsx(Grid, {
|
|
208
|
+
item: true,
|
|
209
|
+
children: jsx(Box, {
|
|
210
|
+
mt: 2,
|
|
211
|
+
children: jsx(AddButton, {
|
|
212
|
+
className: 'array-item-add',
|
|
213
|
+
onClick: onAddClick,
|
|
214
|
+
disabled: disabled || readonly,
|
|
215
|
+
uiSchema: uiSchema,
|
|
216
|
+
registry: registry
|
|
217
|
+
})
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
})]
|
|
221
|
+
}, "array-item-list-" + idSchema.$id)]
|
|
222
|
+
})
|
|
223
|
+
});
|
|
204
224
|
}
|
|
205
225
|
|
|
206
|
-
var _excluded$2 = ["id", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry"],
|
|
226
|
+
var _excluded$2 = ["id", "name", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onChangeOverride", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry", "InputLabelProps"],
|
|
207
227
|
_excluded2$1 = ["step", "min", "max"];
|
|
228
|
+
var TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file', 'time'];
|
|
208
229
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
209
230
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
210
231
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -221,6 +242,7 @@ function BaseInputTemplate(props) {
|
|
|
221
242
|
label = props.label,
|
|
222
243
|
value = props.value,
|
|
223
244
|
onChange = props.onChange,
|
|
245
|
+
onChangeOverride = props.onChangeOverride,
|
|
224
246
|
onBlur = props.onBlur,
|
|
225
247
|
onFocus = props.onFocus,
|
|
226
248
|
autofocus = props.autofocus,
|
|
@@ -230,6 +252,7 @@ function BaseInputTemplate(props) {
|
|
|
230
252
|
_props$rawErrors = props.rawErrors,
|
|
231
253
|
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
232
254
|
registry = props.registry,
|
|
255
|
+
InputLabelProps = props.InputLabelProps,
|
|
233
256
|
textFieldProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
234
257
|
var inputProps = getInputProps(schema, type, options);
|
|
235
258
|
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
@@ -248,7 +271,7 @@ function BaseInputTemplate(props) {
|
|
|
248
271
|
}, rest);
|
|
249
272
|
var _onChange = function _onChange(_ref) {
|
|
250
273
|
var value = _ref.target.value;
|
|
251
|
-
return onChange(value ===
|
|
274
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
252
275
|
};
|
|
253
276
|
var _onBlur = function _onBlur(_ref2) {
|
|
254
277
|
var value = _ref2.target.value;
|
|
@@ -260,30 +283,36 @@ function BaseInputTemplate(props) {
|
|
|
260
283
|
};
|
|
261
284
|
var schemaUtils = registry.schemaUtils;
|
|
262
285
|
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
286
|
+
var DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? _extends({}, InputLabelProps, {
|
|
287
|
+
shrink: true
|
|
288
|
+
}) : InputLabelProps;
|
|
289
|
+
return jsxs(Fragment, {
|
|
290
|
+
children: [jsx(TextField, _extends({
|
|
291
|
+
id: id,
|
|
292
|
+
name: id,
|
|
293
|
+
placeholder: placeholder,
|
|
294
|
+
label: displayLabel ? label || schema.title : false,
|
|
295
|
+
autoFocus: autofocus,
|
|
296
|
+
required: required,
|
|
297
|
+
disabled: disabled || readonly
|
|
298
|
+
}, otherProps, {
|
|
299
|
+
value: value || value === 0 ? value : '',
|
|
300
|
+
error: rawErrors.length > 0,
|
|
301
|
+
onChange: onChangeOverride || _onChange,
|
|
302
|
+
onBlur: _onBlur,
|
|
303
|
+
onFocus: _onFocus,
|
|
304
|
+
InputLabelProps: DisplayInputLabelProps
|
|
305
|
+
}, textFieldProps, {
|
|
306
|
+
"aria-describedby": ariaDescribedByIds(id, !!schema.examples)
|
|
307
|
+
})), Array.isArray(schema.examples) && jsx("datalist", {
|
|
308
|
+
id: examplesId(id),
|
|
309
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
310
|
+
return jsx("option", {
|
|
311
|
+
value: example
|
|
312
|
+
}, example);
|
|
313
|
+
})
|
|
314
|
+
})]
|
|
315
|
+
});
|
|
287
316
|
}
|
|
288
317
|
|
|
289
318
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
@@ -294,13 +323,14 @@ function DescriptionField(props) {
|
|
|
294
323
|
var id = props.id,
|
|
295
324
|
description = props.description;
|
|
296
325
|
if (description) {
|
|
297
|
-
return
|
|
326
|
+
return jsx(Typography, {
|
|
298
327
|
id: id,
|
|
299
|
-
variant:
|
|
328
|
+
variant: 'subtitle2',
|
|
300
329
|
style: {
|
|
301
|
-
marginTop:
|
|
302
|
-
}
|
|
303
|
-
|
|
330
|
+
marginTop: '5px'
|
|
331
|
+
},
|
|
332
|
+
children: description
|
|
333
|
+
});
|
|
304
334
|
}
|
|
305
335
|
return null;
|
|
306
336
|
}
|
|
@@ -313,24 +343,30 @@ function ErrorList(_ref) {
|
|
|
313
343
|
var errors = _ref.errors,
|
|
314
344
|
registry = _ref.registry;
|
|
315
345
|
var translateString = registry.translateString;
|
|
316
|
-
return
|
|
317
|
-
elevation: 2
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
346
|
+
return jsx(Paper, {
|
|
347
|
+
elevation: 2,
|
|
348
|
+
children: jsxs(Box, {
|
|
349
|
+
mb: 2,
|
|
350
|
+
p: 2,
|
|
351
|
+
children: [jsx(Typography, {
|
|
352
|
+
variant: 'h6',
|
|
353
|
+
children: translateString(TranslatableString.ErrorsLabel)
|
|
354
|
+
}), jsx(List, {
|
|
355
|
+
dense: true,
|
|
356
|
+
children: errors.map(function (error, i) {
|
|
357
|
+
return jsxs(ListItem, {
|
|
358
|
+
children: [jsx(ListItemIcon, {
|
|
359
|
+
children: jsx(ErrorIcon, {
|
|
360
|
+
color: 'error'
|
|
361
|
+
})
|
|
362
|
+
}), jsx(ListItemText, {
|
|
363
|
+
primary: error.stack
|
|
364
|
+
})]
|
|
365
|
+
}, i);
|
|
366
|
+
})
|
|
367
|
+
})]
|
|
368
|
+
})
|
|
369
|
+
});
|
|
334
370
|
}
|
|
335
371
|
|
|
336
372
|
var _excluded$1 = ["icon", "color", "uiSchema", "registry"],
|
|
@@ -339,28 +375,39 @@ function MuiIconButton(props) {
|
|
|
339
375
|
var icon = props.icon,
|
|
340
376
|
color = props.color,
|
|
341
377
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
342
|
-
return
|
|
343
|
-
size:
|
|
344
|
-
color: color
|
|
345
|
-
|
|
378
|
+
return jsx(IconButton, _extends({}, otherProps, {
|
|
379
|
+
size: 'small',
|
|
380
|
+
color: color,
|
|
381
|
+
children: icon
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
function CopyButton(props) {
|
|
385
|
+
var translateString = props.registry.translateString;
|
|
386
|
+
return jsx(MuiIconButton, _extends({
|
|
387
|
+
title: translateString(TranslatableString.CopyButton)
|
|
388
|
+
}, props, {
|
|
389
|
+
icon: jsx(CopyIcon, {
|
|
390
|
+
fontSize: 'small'
|
|
391
|
+
})
|
|
392
|
+
}));
|
|
346
393
|
}
|
|
347
394
|
function MoveDownButton(props) {
|
|
348
395
|
var translateString = props.registry.translateString;
|
|
349
|
-
return
|
|
396
|
+
return jsx(MuiIconButton, _extends({
|
|
350
397
|
title: translateString(TranslatableString.MoveDownButton)
|
|
351
398
|
}, props, {
|
|
352
|
-
icon:
|
|
353
|
-
fontSize:
|
|
399
|
+
icon: jsx(ArrowDownwardIcon, {
|
|
400
|
+
fontSize: 'small'
|
|
354
401
|
})
|
|
355
402
|
}));
|
|
356
403
|
}
|
|
357
404
|
function MoveUpButton(props) {
|
|
358
405
|
var translateString = props.registry.translateString;
|
|
359
|
-
return
|
|
406
|
+
return jsx(MuiIconButton, _extends({
|
|
360
407
|
title: translateString(TranslatableString.MoveUpButton)
|
|
361
408
|
}, props, {
|
|
362
|
-
icon:
|
|
363
|
-
fontSize:
|
|
409
|
+
icon: jsx(ArrowUpwardIcon, {
|
|
410
|
+
fontSize: 'small'
|
|
364
411
|
})
|
|
365
412
|
}));
|
|
366
413
|
}
|
|
@@ -368,12 +415,12 @@ function RemoveButton(props) {
|
|
|
368
415
|
var iconType = props.iconType,
|
|
369
416
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
370
417
|
var translateString = otherProps.registry.translateString;
|
|
371
|
-
return
|
|
418
|
+
return jsx(MuiIconButton, _extends({
|
|
372
419
|
title: translateString(TranslatableString.RemoveButton)
|
|
373
420
|
}, otherProps, {
|
|
374
|
-
color:
|
|
375
|
-
icon:
|
|
376
|
-
fontSize: iconType ===
|
|
421
|
+
color: 'error',
|
|
422
|
+
icon: jsx(RemoveIcon, {
|
|
423
|
+
fontSize: iconType === 'default' ? undefined : 'small'
|
|
377
424
|
})
|
|
378
425
|
}));
|
|
379
426
|
}
|
|
@@ -390,17 +437,19 @@ function FieldErrorTemplate(props) {
|
|
|
390
437
|
return null;
|
|
391
438
|
}
|
|
392
439
|
var id = errorId(idSchema);
|
|
393
|
-
return
|
|
440
|
+
return jsx(List, {
|
|
394
441
|
dense: true,
|
|
395
|
-
disablePadding: true
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
442
|
+
disablePadding: true,
|
|
443
|
+
children: errors.map(function (error, i) {
|
|
444
|
+
return jsx(ListItem, {
|
|
445
|
+
disableGutters: true,
|
|
446
|
+
children: jsx(FormHelperText, {
|
|
447
|
+
id: id,
|
|
448
|
+
children: error
|
|
449
|
+
})
|
|
450
|
+
}, i);
|
|
451
|
+
})
|
|
452
|
+
});
|
|
404
453
|
}
|
|
405
454
|
|
|
406
455
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -414,9 +463,10 @@ function FieldHelpTemplate(props) {
|
|
|
414
463
|
return null;
|
|
415
464
|
}
|
|
416
465
|
var id = helpId(idSchema);
|
|
417
|
-
return
|
|
418
|
-
id: id
|
|
419
|
-
|
|
466
|
+
return jsx(FormHelperText, {
|
|
467
|
+
id: id,
|
|
468
|
+
children: help
|
|
469
|
+
});
|
|
420
470
|
}
|
|
421
471
|
|
|
422
472
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -446,15 +496,16 @@ function FieldTemplate(props) {
|
|
|
446
496
|
uiSchema = props.uiSchema,
|
|
447
497
|
registry = props.registry;
|
|
448
498
|
var uiOptions = getUiOptions(uiSchema);
|
|
449
|
-
var WrapIfAdditionalTemplate = getTemplate(
|
|
499
|
+
var WrapIfAdditionalTemplate = getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
450
500
|
if (hidden) {
|
|
451
|
-
return
|
|
501
|
+
return jsx("div", {
|
|
452
502
|
style: {
|
|
453
|
-
display:
|
|
454
|
-
}
|
|
455
|
-
|
|
503
|
+
display: 'none'
|
|
504
|
+
},
|
|
505
|
+
children: children
|
|
506
|
+
});
|
|
456
507
|
}
|
|
457
|
-
return
|
|
508
|
+
return jsx(WrapIfAdditionalTemplate, {
|
|
458
509
|
classNames: classNames,
|
|
459
510
|
style: style,
|
|
460
511
|
disabled: disabled,
|
|
@@ -466,15 +517,18 @@ function FieldTemplate(props) {
|
|
|
466
517
|
required: required,
|
|
467
518
|
schema: schema,
|
|
468
519
|
uiSchema: uiSchema,
|
|
469
|
-
registry: registry
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
520
|
+
registry: registry,
|
|
521
|
+
children: jsxs(FormControl, {
|
|
522
|
+
fullWidth: true,
|
|
523
|
+
error: rawErrors.length ? true : false,
|
|
524
|
+
required: required,
|
|
525
|
+
children: [children, displayLabel && rawDescription ? jsx(Typography, {
|
|
526
|
+
variant: 'caption',
|
|
527
|
+
color: 'textSecondary',
|
|
528
|
+
children: rawDescription
|
|
529
|
+
}) : null, errors, help]
|
|
530
|
+
})
|
|
531
|
+
});
|
|
478
532
|
}
|
|
479
533
|
|
|
480
534
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -497,54 +551,59 @@ function ObjectFieldTemplate(props) {
|
|
|
497
551
|
onAddClick = props.onAddClick,
|
|
498
552
|
registry = props.registry;
|
|
499
553
|
var uiOptions = getUiOptions(uiSchema);
|
|
500
|
-
var TitleFieldTemplate = getTemplate(
|
|
501
|
-
var DescriptionFieldTemplate = getTemplate(
|
|
554
|
+
var TitleFieldTemplate = getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
555
|
+
var DescriptionFieldTemplate = getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
502
556
|
// Button templates are not overridden in the uiSchema
|
|
503
557
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
504
|
-
return
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
558
|
+
return jsxs(Fragment, {
|
|
559
|
+
children: [(uiOptions.title || title) && jsx(TitleFieldTemplate, {
|
|
560
|
+
id: titleId(idSchema),
|
|
561
|
+
title: title,
|
|
562
|
+
required: required,
|
|
563
|
+
schema: schema,
|
|
564
|
+
uiSchema: uiSchema,
|
|
565
|
+
registry: registry
|
|
566
|
+
}), (uiOptions.description || description) && jsx(DescriptionFieldTemplate, {
|
|
567
|
+
id: descriptionId(idSchema),
|
|
568
|
+
description: uiOptions.description || description,
|
|
569
|
+
schema: schema,
|
|
570
|
+
uiSchema: uiSchema,
|
|
571
|
+
registry: registry
|
|
572
|
+
}), jsxs(Grid, {
|
|
573
|
+
container: true,
|
|
574
|
+
spacing: 2,
|
|
575
|
+
style: {
|
|
576
|
+
marginTop: '10px'
|
|
577
|
+
},
|
|
578
|
+
children: [properties.map(function (element, index) {
|
|
579
|
+
return (
|
|
580
|
+
// Remove the <Grid> if the inner element is hidden as the <Grid>
|
|
581
|
+
// itself would otherwise still take up space.
|
|
582
|
+
element.hidden ? element.content : jsx(Grid, {
|
|
583
|
+
item: true,
|
|
584
|
+
xs: 12,
|
|
585
|
+
style: {
|
|
586
|
+
marginBottom: '10px'
|
|
587
|
+
},
|
|
588
|
+
children: element.content
|
|
589
|
+
}, index)
|
|
590
|
+
);
|
|
591
|
+
}), canExpand(schema, uiSchema, formData) && jsx(Grid, {
|
|
592
|
+
container: true,
|
|
593
|
+
justifyContent: 'flex-end',
|
|
594
|
+
children: jsx(Grid, {
|
|
595
|
+
item: true,
|
|
596
|
+
children: jsx(AddButton, {
|
|
597
|
+
className: 'object-property-expand',
|
|
598
|
+
onClick: onAddClick(schema),
|
|
599
|
+
disabled: disabled || readonly,
|
|
600
|
+
uiSchema: uiSchema,
|
|
601
|
+
registry: registry
|
|
602
|
+
})
|
|
603
|
+
})
|
|
604
|
+
})]
|
|
605
|
+
})]
|
|
606
|
+
});
|
|
548
607
|
}
|
|
549
608
|
|
|
550
609
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -559,13 +618,16 @@ function SubmitButton(_ref) {
|
|
|
559
618
|
if (norender) {
|
|
560
619
|
return null;
|
|
561
620
|
}
|
|
562
|
-
return
|
|
563
|
-
marginTop: 3
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
621
|
+
return jsx(Box, {
|
|
622
|
+
marginTop: 3,
|
|
623
|
+
children: jsx(Button, _extends({
|
|
624
|
+
type: 'submit',
|
|
625
|
+
variant: 'contained',
|
|
626
|
+
color: 'primary'
|
|
627
|
+
}, submitButtonProps, {
|
|
628
|
+
children: submitText
|
|
629
|
+
}))
|
|
630
|
+
});
|
|
569
631
|
}
|
|
570
632
|
|
|
571
633
|
/** The `TitleField` is the template to use to render the title of a field
|
|
@@ -575,13 +637,15 @@ function SubmitButton(_ref) {
|
|
|
575
637
|
function TitleField(_ref) {
|
|
576
638
|
var id = _ref.id,
|
|
577
639
|
title = _ref.title;
|
|
578
|
-
return
|
|
640
|
+
return jsxs(Box, {
|
|
579
641
|
id: id,
|
|
580
642
|
mb: 1,
|
|
581
|
-
mt: 1
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
643
|
+
mt: 1,
|
|
644
|
+
children: [jsx(Typography, {
|
|
645
|
+
variant: 'h5',
|
|
646
|
+
children: title
|
|
647
|
+
}), jsx(Divider, {})]
|
|
648
|
+
});
|
|
585
649
|
}
|
|
586
650
|
|
|
587
651
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -613,51 +677,58 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
613
677
|
flex: 1,
|
|
614
678
|
paddingLeft: 6,
|
|
615
679
|
paddingRight: 6,
|
|
616
|
-
fontWeight:
|
|
680
|
+
fontWeight: 'bold'
|
|
617
681
|
};
|
|
618
682
|
if (!additional) {
|
|
619
|
-
return
|
|
683
|
+
return jsx("div", {
|
|
620
684
|
className: classNames,
|
|
621
|
-
style: style
|
|
622
|
-
|
|
685
|
+
style: style,
|
|
686
|
+
children: children
|
|
687
|
+
});
|
|
623
688
|
}
|
|
624
689
|
var handleBlur = function handleBlur(_ref) {
|
|
625
690
|
var target = _ref.target;
|
|
626
691
|
return onKeyChange(target.value);
|
|
627
692
|
};
|
|
628
|
-
return
|
|
693
|
+
return jsxs(Grid, {
|
|
629
694
|
container: true,
|
|
630
|
-
|
|
631
|
-
alignItems: "center",
|
|
695
|
+
alignItems: 'center',
|
|
632
696
|
spacing: 2,
|
|
633
697
|
className: classNames,
|
|
634
|
-
style: style
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
698
|
+
style: style,
|
|
699
|
+
children: [jsx(Grid, {
|
|
700
|
+
item: true,
|
|
701
|
+
xs: true,
|
|
702
|
+
children: jsxs(FormControl, {
|
|
703
|
+
fullWidth: true,
|
|
704
|
+
required: required,
|
|
705
|
+
children: [jsx(InputLabel, {
|
|
706
|
+
children: keyLabel
|
|
707
|
+
}), jsx(Input, {
|
|
708
|
+
defaultValue: label,
|
|
709
|
+
disabled: disabled || readonly,
|
|
710
|
+
id: id + "-key",
|
|
711
|
+
name: id + "-key",
|
|
712
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
713
|
+
type: 'text'
|
|
714
|
+
})]
|
|
715
|
+
})
|
|
716
|
+
}), jsx(Grid, {
|
|
717
|
+
item: true,
|
|
718
|
+
xs: true,
|
|
719
|
+
children: children
|
|
720
|
+
}), jsx(Grid, {
|
|
721
|
+
item: true,
|
|
722
|
+
children: jsx(RemoveButton, {
|
|
723
|
+
iconType: 'default',
|
|
724
|
+
style: btnStyle,
|
|
725
|
+
disabled: disabled || readonly,
|
|
726
|
+
onClick: onDropPropertyClick(label),
|
|
727
|
+
uiSchema: uiSchema,
|
|
728
|
+
registry: registry
|
|
729
|
+
})
|
|
730
|
+
})]
|
|
731
|
+
}, id + "-key");
|
|
661
732
|
}
|
|
662
733
|
|
|
663
734
|
function generateTemplates() {
|
|
@@ -667,6 +738,7 @@ function generateTemplates() {
|
|
|
667
738
|
BaseInputTemplate: BaseInputTemplate,
|
|
668
739
|
ButtonTemplates: {
|
|
669
740
|
AddButton: AddButton,
|
|
741
|
+
CopyButton: CopyButton,
|
|
670
742
|
MoveDownButton: MoveDownButton,
|
|
671
743
|
MoveUpButton: MoveUpButton,
|
|
672
744
|
RemoveButton: RemoveButton,
|
|
@@ -715,11 +787,11 @@ function CheckboxWidget(props) {
|
|
|
715
787
|
var value = _ref2.target.value;
|
|
716
788
|
return onFocus(id, value);
|
|
717
789
|
};
|
|
718
|
-
return
|
|
719
|
-
control:
|
|
790
|
+
return jsx(FormControlLabel, {
|
|
791
|
+
control: jsx(Checkbox, {
|
|
720
792
|
id: id,
|
|
721
793
|
name: id,
|
|
722
|
-
checked: typeof value ===
|
|
794
|
+
checked: typeof value === 'undefined' ? false : Boolean(value),
|
|
723
795
|
required: required,
|
|
724
796
|
disabled: disabled || readonly,
|
|
725
797
|
autoFocus: autofocus,
|
|
@@ -728,7 +800,7 @@ function CheckboxWidget(props) {
|
|
|
728
800
|
onFocus: _onFocus,
|
|
729
801
|
"aria-describedby": ariaDescribedByIds(id)
|
|
730
802
|
}),
|
|
731
|
-
label: label ||
|
|
803
|
+
label: label || ''
|
|
732
804
|
});
|
|
733
805
|
}
|
|
734
806
|
|
|
@@ -773,73 +845,35 @@ function CheckboxesWidget(_ref) {
|
|
|
773
845
|
var value = _ref4.target.value;
|
|
774
846
|
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
775
847
|
};
|
|
776
|
-
return
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
* the value to undefined when it is falsy during the `onChange` handling.
|
|
806
|
-
*
|
|
807
|
-
* @param props - The `WidgetProps` for this component
|
|
808
|
-
*/
|
|
809
|
-
function DateWidget(props) {
|
|
810
|
-
var options = props.options,
|
|
811
|
-
registry = props.registry;
|
|
812
|
-
var BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
|
|
813
|
-
return /*#__PURE__*/React.createElement(BaseInputTemplate, _extends({
|
|
814
|
-
type: "date",
|
|
815
|
-
InputLabelProps: {
|
|
816
|
-
shrink: true
|
|
817
|
-
}
|
|
818
|
-
}, props));
|
|
819
|
-
}
|
|
820
|
-
|
|
821
|
-
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
822
|
-
* the value to/from utc using the appropriate utility functions.
|
|
823
|
-
*
|
|
824
|
-
* @param props - The `WidgetProps` for this component
|
|
825
|
-
*/
|
|
826
|
-
function DateTimeWidget(props) {
|
|
827
|
-
var options = props.options,
|
|
828
|
-
registry = props.registry;
|
|
829
|
-
var BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
|
|
830
|
-
var value = utcToLocal(props.value);
|
|
831
|
-
var onChange = function onChange(value) {
|
|
832
|
-
props.onChange(localToUTC(value));
|
|
833
|
-
};
|
|
834
|
-
return /*#__PURE__*/React.createElement(BaseInputTemplate, _extends({
|
|
835
|
-
type: "datetime-local",
|
|
836
|
-
InputLabelProps: {
|
|
837
|
-
shrink: true
|
|
838
|
-
}
|
|
839
|
-
}, props, {
|
|
840
|
-
value: value,
|
|
841
|
-
onChange: onChange
|
|
842
|
-
}));
|
|
848
|
+
return jsxs(Fragment, {
|
|
849
|
+
children: [jsx(FormLabel, {
|
|
850
|
+
required: required,
|
|
851
|
+
htmlFor: id,
|
|
852
|
+
children: label || schema.title
|
|
853
|
+
}), jsx(FormGroup, {
|
|
854
|
+
id: id,
|
|
855
|
+
row: !!inline,
|
|
856
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
857
|
+
var checked = enumOptionsIsSelected(option.value, checkboxesValues);
|
|
858
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
859
|
+
var checkbox = jsx(Checkbox, {
|
|
860
|
+
id: optionId(id, index),
|
|
861
|
+
name: id,
|
|
862
|
+
checked: checked,
|
|
863
|
+
disabled: disabled || itemDisabled || readonly,
|
|
864
|
+
autoFocus: autofocus && index === 0,
|
|
865
|
+
onChange: _onChange(index),
|
|
866
|
+
onBlur: _onBlur,
|
|
867
|
+
onFocus: _onFocus,
|
|
868
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
869
|
+
});
|
|
870
|
+
return jsx(FormControlLabel, {
|
|
871
|
+
control: checkbox,
|
|
872
|
+
label: option.label
|
|
873
|
+
}, index);
|
|
874
|
+
})
|
|
875
|
+
})]
|
|
876
|
+
});
|
|
843
877
|
}
|
|
844
878
|
|
|
845
879
|
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
@@ -875,33 +909,36 @@ function RadioWidget(_ref) {
|
|
|
875
909
|
};
|
|
876
910
|
var row = options ? options.inline : false;
|
|
877
911
|
var selectedIndex = enumOptionsIndexForValue(value, enumOptions);
|
|
878
|
-
return
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
912
|
+
return jsxs(Fragment, {
|
|
913
|
+
children: [jsx(FormLabel, {
|
|
914
|
+
required: required,
|
|
915
|
+
htmlFor: id,
|
|
916
|
+
children: label || schema.title
|
|
917
|
+
}), jsx(RadioGroup, {
|
|
918
|
+
id: id,
|
|
919
|
+
name: id,
|
|
920
|
+
value: selectedIndex,
|
|
921
|
+
row: row,
|
|
922
|
+
onChange: _onChange,
|
|
923
|
+
onBlur: _onBlur,
|
|
924
|
+
onFocus: _onFocus,
|
|
925
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
926
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
927
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
928
|
+
var radio = jsx(FormControlLabel, {
|
|
929
|
+
control: jsx(Radio, {
|
|
930
|
+
name: id,
|
|
931
|
+
id: optionId(id, index),
|
|
932
|
+
color: 'primary'
|
|
933
|
+
}),
|
|
934
|
+
label: option.label,
|
|
935
|
+
value: String(index),
|
|
936
|
+
disabled: disabled || itemDisabled || readonly
|
|
937
|
+
}, index);
|
|
938
|
+
return radio;
|
|
939
|
+
})
|
|
940
|
+
})]
|
|
941
|
+
});
|
|
905
942
|
}
|
|
906
943
|
|
|
907
944
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -938,21 +975,24 @@ function RangeWidget(props) {
|
|
|
938
975
|
var value = _ref2.target.value;
|
|
939
976
|
return onFocus(id, value);
|
|
940
977
|
};
|
|
941
|
-
return
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
978
|
+
return jsxs(Fragment, {
|
|
979
|
+
children: [jsx(FormLabel, {
|
|
980
|
+
required: required,
|
|
981
|
+
htmlFor: id,
|
|
982
|
+
children: label || schema.title
|
|
983
|
+
}), jsx(Slider, _extends({
|
|
984
|
+
disabled: disabled || readonly,
|
|
985
|
+
onChange: _onChange,
|
|
986
|
+
onBlur: _onBlur,
|
|
987
|
+
onFocus: _onFocus,
|
|
988
|
+
valueLabelDisplay: 'auto'
|
|
989
|
+
}, sliderProps, {
|
|
990
|
+
"aria-describedby": ariaDescribedByIds(id)
|
|
991
|
+
}))]
|
|
992
|
+
});
|
|
953
993
|
}
|
|
954
994
|
|
|
955
|
-
var _excluded = ["schema", "id", "options", "label", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
|
|
995
|
+
var _excluded = ["schema", "id", "name", "options", "label", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
|
|
956
996
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
957
997
|
* It is typically used with string properties constrained with enum options.
|
|
958
998
|
*
|
|
@@ -979,9 +1019,9 @@ function SelectWidget(_ref) {
|
|
|
979
1019
|
var enumOptions = options.enumOptions,
|
|
980
1020
|
enumDisabled = options.enumDisabled,
|
|
981
1021
|
optEmptyVal = options.emptyValue;
|
|
982
|
-
multiple = typeof multiple ===
|
|
983
|
-
var emptyValue = multiple ? [] :
|
|
984
|
-
var isEmpty = typeof value ===
|
|
1022
|
+
multiple = typeof multiple === 'undefined' ? false : !!multiple;
|
|
1023
|
+
var emptyValue = multiple ? [] : '';
|
|
1024
|
+
var isEmpty = typeof value === 'undefined' || multiple && value.length < 1 || !multiple && value === emptyValue;
|
|
985
1025
|
var _onChange = function _onChange(_ref2) {
|
|
986
1026
|
var value = _ref2.target.value;
|
|
987
1027
|
return onChange(enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
@@ -995,7 +1035,7 @@ function SelectWidget(_ref) {
|
|
|
995
1035
|
return onFocus(id, enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
996
1036
|
};
|
|
997
1037
|
var selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
998
|
-
return
|
|
1038
|
+
return jsx(TextField, _extends({
|
|
999
1039
|
id: id,
|
|
1000
1040
|
name: id,
|
|
1001
1041
|
label: label || schema.title,
|
|
@@ -1017,16 +1057,17 @@ function SelectWidget(_ref) {
|
|
|
1017
1057
|
SelectProps: _extends({}, textFieldProps.SelectProps, {
|
|
1018
1058
|
multiple: multiple
|
|
1019
1059
|
}),
|
|
1020
|
-
"aria-describedby": ariaDescribedByIds(id)
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1060
|
+
"aria-describedby": ariaDescribedByIds(id),
|
|
1061
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (_ref5, i) {
|
|
1062
|
+
var value = _ref5.value,
|
|
1063
|
+
label = _ref5.label;
|
|
1064
|
+
var disabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1;
|
|
1065
|
+
return jsx(MenuItem, {
|
|
1066
|
+
value: String(i),
|
|
1067
|
+
disabled: disabled,
|
|
1068
|
+
children: label
|
|
1069
|
+
}, i);
|
|
1070
|
+
})
|
|
1030
1071
|
}));
|
|
1031
1072
|
}
|
|
1032
1073
|
|
|
@@ -1037,12 +1078,12 @@ function SelectWidget(_ref) {
|
|
|
1037
1078
|
function TextareaWidget(props) {
|
|
1038
1079
|
var options = props.options,
|
|
1039
1080
|
registry = props.registry;
|
|
1040
|
-
var BaseInputTemplate = getTemplate(
|
|
1081
|
+
var BaseInputTemplate = getTemplate('BaseInputTemplate', registry, options);
|
|
1041
1082
|
var rows = 5;
|
|
1042
|
-
if (typeof options.rows ===
|
|
1083
|
+
if (typeof options.rows === 'string' || typeof options.rows === 'number') {
|
|
1043
1084
|
rows = options.rows;
|
|
1044
1085
|
}
|
|
1045
|
-
return
|
|
1086
|
+
return jsx(BaseInputTemplate, _extends({}, props, {
|
|
1046
1087
|
multiline: true,
|
|
1047
1088
|
rows: rows
|
|
1048
1089
|
}));
|
|
@@ -1052,8 +1093,6 @@ function generateWidgets() {
|
|
|
1052
1093
|
return {
|
|
1053
1094
|
CheckboxWidget: CheckboxWidget,
|
|
1054
1095
|
CheckboxesWidget: CheckboxesWidget,
|
|
1055
|
-
DateWidget: DateWidget,
|
|
1056
|
-
DateTimeWidget: DateTimeWidget,
|
|
1057
1096
|
RadioWidget: RadioWidget,
|
|
1058
1097
|
RangeWidget: RangeWidget,
|
|
1059
1098
|
SelectWidget: SelectWidget,
|