@rjsf/mui 5.1.0 → 5.2.1
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 +433 -407
- 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 +433 -406
- package/dist/mui.esm.js.map +1 -1
- package/dist/mui.umd.development.js +435 -409
- 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 +5 -5
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@rjsf/core');
|
|
6
|
-
var
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var AddIcon = require('@mui/icons-material/Add');
|
|
8
8
|
var IconButton = require('@mui/material/IconButton');
|
|
9
|
+
var utils = require('@rjsf/utils');
|
|
9
10
|
var Box = require('@mui/material/Box');
|
|
10
11
|
var Grid = require('@mui/material/Grid');
|
|
11
12
|
var Paper = require('@mui/material/Paper');
|
|
12
|
-
var utils = require('@rjsf/utils');
|
|
13
13
|
var TextField = require('@mui/material/TextField');
|
|
14
14
|
var Typography = require('@mui/material/Typography');
|
|
15
15
|
var ErrorIcon = require('@mui/icons-material/Error');
|
|
@@ -37,7 +37,6 @@ var MenuItem = require('@mui/material/MenuItem');
|
|
|
37
37
|
|
|
38
38
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
39
39
|
|
|
40
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
41
40
|
var AddIcon__default = /*#__PURE__*/_interopDefaultLegacy(AddIcon);
|
|
42
41
|
var IconButton__default = /*#__PURE__*/_interopDefaultLegacy(IconButton);
|
|
43
42
|
var Box__default = /*#__PURE__*/_interopDefaultLegacy(Box);
|
|
@@ -99,12 +98,15 @@ var _excluded$4 = ["uiSchema", "registry"];
|
|
|
99
98
|
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
100
99
|
*/
|
|
101
100
|
function AddButton(_ref) {
|
|
102
|
-
var
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
var registry = _ref.registry,
|
|
102
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
103
|
+
var translateString = registry.translateString;
|
|
104
|
+
return jsxRuntime.jsx(IconButton__default["default"], _extends({
|
|
105
|
+
title: translateString(utils.TranslatableString.AddItemButton)
|
|
105
106
|
}, props, {
|
|
106
|
-
color:
|
|
107
|
-
|
|
107
|
+
color: 'primary',
|
|
108
|
+
children: jsxRuntime.jsx(AddIcon__default["default"], {})
|
|
109
|
+
}));
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
@@ -132,45 +134,51 @@ function ArrayFieldItemTemplate(props) {
|
|
|
132
134
|
flex: 1,
|
|
133
135
|
paddingLeft: 6,
|
|
134
136
|
paddingRight: 6,
|
|
135
|
-
fontWeight:
|
|
137
|
+
fontWeight: 'bold',
|
|
136
138
|
minWidth: 0
|
|
137
139
|
};
|
|
138
|
-
return
|
|
140
|
+
return jsxRuntime.jsxs(Grid__default["default"], {
|
|
139
141
|
container: true,
|
|
140
|
-
alignItems:
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
142
|
+
alignItems: 'center',
|
|
143
|
+
children: [jsxRuntime.jsx(Grid__default["default"], {
|
|
144
|
+
item: true,
|
|
145
|
+
xs: true,
|
|
146
|
+
style: {
|
|
147
|
+
overflow: 'auto'
|
|
148
|
+
},
|
|
149
|
+
children: jsxRuntime.jsx(Box__default["default"], {
|
|
150
|
+
mb: 2,
|
|
151
|
+
children: jsxRuntime.jsx(Paper__default["default"], {
|
|
152
|
+
elevation: 2,
|
|
153
|
+
children: jsxRuntime.jsx(Box__default["default"], {
|
|
154
|
+
p: 2,
|
|
155
|
+
children: children
|
|
156
|
+
})
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
|
+
}), hasToolbar && jsxRuntime.jsxs(Grid__default["default"], {
|
|
160
|
+
item: true,
|
|
161
|
+
children: [(hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveUpButton, {
|
|
162
|
+
style: btnStyle,
|
|
163
|
+
disabled: disabled || readonly || !hasMoveUp,
|
|
164
|
+
onClick: onReorderClick(index, index - 1),
|
|
165
|
+
uiSchema: uiSchema,
|
|
166
|
+
registry: registry
|
|
167
|
+
}), (hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveDownButton, {
|
|
168
|
+
style: btnStyle,
|
|
169
|
+
disabled: disabled || readonly || !hasMoveDown,
|
|
170
|
+
onClick: onReorderClick(index, index + 1),
|
|
171
|
+
uiSchema: uiSchema,
|
|
172
|
+
registry: registry
|
|
173
|
+
}), hasRemove && jsxRuntime.jsx(RemoveButton, {
|
|
174
|
+
style: btnStyle,
|
|
175
|
+
disabled: disabled || readonly,
|
|
176
|
+
onClick: onDropIndexClick(index),
|
|
177
|
+
uiSchema: uiSchema,
|
|
178
|
+
registry: registry
|
|
179
|
+
})]
|
|
180
|
+
})]
|
|
181
|
+
});
|
|
174
182
|
}
|
|
175
183
|
|
|
176
184
|
var _excluded$3 = ["key"];
|
|
@@ -191,55 +199,59 @@ function ArrayFieldTemplate(props) {
|
|
|
191
199
|
schema = props.schema,
|
|
192
200
|
title = props.title;
|
|
193
201
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
194
|
-
var ArrayFieldDescriptionTemplate = utils.getTemplate(
|
|
195
|
-
var ArrayFieldItemTemplate = utils.getTemplate(
|
|
196
|
-
var ArrayFieldTitleTemplate = utils.getTemplate(
|
|
202
|
+
var ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
203
|
+
var ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
204
|
+
var ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
197
205
|
// Button templates are not overridden in the uiSchema
|
|
198
206
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
199
|
-
return
|
|
200
|
-
elevation: 2
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
207
|
+
return jsxRuntime.jsx(Paper__default["default"], {
|
|
208
|
+
elevation: 2,
|
|
209
|
+
children: jsxRuntime.jsxs(Box__default["default"], {
|
|
210
|
+
p: 2,
|
|
211
|
+
children: [jsxRuntime.jsx(ArrayFieldTitleTemplate, {
|
|
212
|
+
idSchema: idSchema,
|
|
213
|
+
title: uiOptions.title || title,
|
|
214
|
+
schema: schema,
|
|
215
|
+
uiSchema: uiSchema,
|
|
216
|
+
required: required,
|
|
217
|
+
registry: registry
|
|
218
|
+
}), jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
|
|
219
|
+
idSchema: idSchema,
|
|
220
|
+
description: uiOptions.description || schema.description,
|
|
221
|
+
schema: schema,
|
|
222
|
+
uiSchema: uiSchema,
|
|
223
|
+
registry: registry
|
|
224
|
+
}), jsxRuntime.jsxs(Grid__default["default"], {
|
|
225
|
+
container: true,
|
|
226
|
+
children: [items && items.map(function (_ref) {
|
|
227
|
+
var key = _ref.key,
|
|
228
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
229
|
+
return jsxRuntime.jsx(ArrayFieldItemTemplate, _extends({}, itemProps), key);
|
|
230
|
+
}), canAdd && jsxRuntime.jsx(Grid__default["default"], {
|
|
231
|
+
container: true,
|
|
232
|
+
justifyContent: 'flex-end',
|
|
233
|
+
children: jsxRuntime.jsx(Grid__default["default"], {
|
|
234
|
+
item: true,
|
|
235
|
+
children: jsxRuntime.jsx(Box__default["default"], {
|
|
236
|
+
mt: 2,
|
|
237
|
+
children: jsxRuntime.jsx(AddButton, {
|
|
238
|
+
className: 'array-item-add',
|
|
239
|
+
onClick: onAddClick,
|
|
240
|
+
disabled: disabled || readonly,
|
|
241
|
+
uiSchema: uiSchema,
|
|
242
|
+
registry: registry
|
|
243
|
+
})
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
})]
|
|
247
|
+
}, "array-item-list-" + idSchema.$id)]
|
|
248
|
+
})
|
|
249
|
+
});
|
|
239
250
|
}
|
|
240
251
|
|
|
241
|
-
var _excluded$2 = ["id", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry"],
|
|
252
|
+
var _excluded$2 = ["id", "name", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onChangeOverride", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry", "InputLabelProps"],
|
|
242
253
|
_excluded2$1 = ["step", "min", "max"];
|
|
254
|
+
var TYPES_THAT_SHRINK_LABEL = ['date', 'datetime-local', 'file'];
|
|
243
255
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
244
256
|
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
245
257
|
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
@@ -256,6 +268,7 @@ function BaseInputTemplate(props) {
|
|
|
256
268
|
label = props.label,
|
|
257
269
|
value = props.value,
|
|
258
270
|
onChange = props.onChange,
|
|
271
|
+
onChangeOverride = props.onChangeOverride,
|
|
259
272
|
onBlur = props.onBlur,
|
|
260
273
|
onFocus = props.onFocus,
|
|
261
274
|
autofocus = props.autofocus,
|
|
@@ -265,6 +278,7 @@ function BaseInputTemplate(props) {
|
|
|
265
278
|
_props$rawErrors = props.rawErrors,
|
|
266
279
|
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
267
280
|
registry = props.registry,
|
|
281
|
+
InputLabelProps = props.InputLabelProps,
|
|
268
282
|
textFieldProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
269
283
|
var inputProps = utils.getInputProps(schema, type, options);
|
|
270
284
|
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
@@ -283,7 +297,7 @@ function BaseInputTemplate(props) {
|
|
|
283
297
|
}, rest);
|
|
284
298
|
var _onChange = function _onChange(_ref) {
|
|
285
299
|
var value = _ref.target.value;
|
|
286
|
-
return onChange(value ===
|
|
300
|
+
return onChange(value === '' ? options.emptyValue : value);
|
|
287
301
|
};
|
|
288
302
|
var _onBlur = function _onBlur(_ref2) {
|
|
289
303
|
var value = _ref2.target.value;
|
|
@@ -295,30 +309,36 @@ function BaseInputTemplate(props) {
|
|
|
295
309
|
};
|
|
296
310
|
var schemaUtils = registry.schemaUtils;
|
|
297
311
|
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
312
|
+
var DisplayInputLabelProps = TYPES_THAT_SHRINK_LABEL.includes(type) ? _extends({}, InputLabelProps, {
|
|
313
|
+
shrink: true
|
|
314
|
+
}) : InputLabelProps;
|
|
315
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
316
|
+
children: [jsxRuntime.jsx(TextField__default["default"], _extends({
|
|
317
|
+
id: id,
|
|
318
|
+
name: id,
|
|
319
|
+
placeholder: placeholder,
|
|
320
|
+
label: displayLabel ? label || schema.title : false,
|
|
321
|
+
autoFocus: autofocus,
|
|
322
|
+
required: required,
|
|
323
|
+
disabled: disabled || readonly
|
|
324
|
+
}, otherProps, {
|
|
325
|
+
value: value || value === 0 ? value : '',
|
|
326
|
+
error: rawErrors.length > 0,
|
|
327
|
+
onChange: onChangeOverride || _onChange,
|
|
328
|
+
onBlur: _onBlur,
|
|
329
|
+
onFocus: _onFocus,
|
|
330
|
+
InputLabelProps: DisplayInputLabelProps
|
|
331
|
+
}, textFieldProps, {
|
|
332
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
333
|
+
})), Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
|
|
334
|
+
id: utils.examplesId(id),
|
|
335
|
+
children: schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
336
|
+
return jsxRuntime.jsx("option", {
|
|
337
|
+
value: example
|
|
338
|
+
}, example);
|
|
339
|
+
})
|
|
340
|
+
})]
|
|
341
|
+
});
|
|
322
342
|
}
|
|
323
343
|
|
|
324
344
|
/** The `DescriptionField` is the template to use to render the description of a field
|
|
@@ -329,13 +349,14 @@ function DescriptionField(props) {
|
|
|
329
349
|
var id = props.id,
|
|
330
350
|
description = props.description;
|
|
331
351
|
if (description) {
|
|
332
|
-
return
|
|
352
|
+
return jsxRuntime.jsx(Typography__default["default"], {
|
|
333
353
|
id: id,
|
|
334
|
-
variant:
|
|
354
|
+
variant: 'subtitle2',
|
|
335
355
|
style: {
|
|
336
|
-
marginTop:
|
|
337
|
-
}
|
|
338
|
-
|
|
356
|
+
marginTop: '5px'
|
|
357
|
+
},
|
|
358
|
+
children: description
|
|
359
|
+
});
|
|
339
360
|
}
|
|
340
361
|
return null;
|
|
341
362
|
}
|
|
@@ -345,25 +366,33 @@ function DescriptionField(props) {
|
|
|
345
366
|
* @param props - The `ErrorListProps` for this component
|
|
346
367
|
*/
|
|
347
368
|
function ErrorList(_ref) {
|
|
348
|
-
var errors = _ref.errors
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
369
|
+
var errors = _ref.errors,
|
|
370
|
+
registry = _ref.registry;
|
|
371
|
+
var translateString = registry.translateString;
|
|
372
|
+
return jsxRuntime.jsx(Paper__default["default"], {
|
|
373
|
+
elevation: 2,
|
|
374
|
+
children: jsxRuntime.jsxs(Box__default["default"], {
|
|
375
|
+
mb: 2,
|
|
376
|
+
p: 2,
|
|
377
|
+
children: [jsxRuntime.jsx(Typography__default["default"], {
|
|
378
|
+
variant: 'h6',
|
|
379
|
+
children: translateString(utils.TranslatableString.ErrorsLabel)
|
|
380
|
+
}), jsxRuntime.jsx(List__default["default"], {
|
|
381
|
+
dense: true,
|
|
382
|
+
children: errors.map(function (error, i) {
|
|
383
|
+
return jsxRuntime.jsxs(ListItem__default["default"], {
|
|
384
|
+
children: [jsxRuntime.jsx(ListItemIcon__default["default"], {
|
|
385
|
+
children: jsxRuntime.jsx(ErrorIcon__default["default"], {
|
|
386
|
+
color: 'error'
|
|
387
|
+
})
|
|
388
|
+
}), jsxRuntime.jsx(ListItemText__default["default"], {
|
|
389
|
+
primary: error.stack
|
|
390
|
+
})]
|
|
391
|
+
}, i);
|
|
392
|
+
})
|
|
393
|
+
})]
|
|
394
|
+
})
|
|
395
|
+
});
|
|
367
396
|
}
|
|
368
397
|
|
|
369
398
|
var _excluded$1 = ["icon", "color", "uiSchema", "registry"],
|
|
@@ -372,38 +401,42 @@ function MuiIconButton(props) {
|
|
|
372
401
|
var icon = props.icon,
|
|
373
402
|
color = props.color,
|
|
374
403
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
375
|
-
return
|
|
376
|
-
size:
|
|
377
|
-
color: color
|
|
378
|
-
|
|
404
|
+
return jsxRuntime.jsx(IconButton__default["default"], _extends({}, otherProps, {
|
|
405
|
+
size: 'small',
|
|
406
|
+
color: color,
|
|
407
|
+
children: icon
|
|
408
|
+
}));
|
|
379
409
|
}
|
|
380
410
|
function MoveDownButton(props) {
|
|
381
|
-
|
|
382
|
-
|
|
411
|
+
var translateString = props.registry.translateString;
|
|
412
|
+
return jsxRuntime.jsx(MuiIconButton, _extends({
|
|
413
|
+
title: translateString(utils.TranslatableString.MoveDownButton)
|
|
383
414
|
}, props, {
|
|
384
|
-
icon:
|
|
385
|
-
fontSize:
|
|
415
|
+
icon: jsxRuntime.jsx(ArrowDownwardIcon__default["default"], {
|
|
416
|
+
fontSize: 'small'
|
|
386
417
|
})
|
|
387
418
|
}));
|
|
388
419
|
}
|
|
389
420
|
function MoveUpButton(props) {
|
|
390
|
-
|
|
391
|
-
|
|
421
|
+
var translateString = props.registry.translateString;
|
|
422
|
+
return jsxRuntime.jsx(MuiIconButton, _extends({
|
|
423
|
+
title: translateString(utils.TranslatableString.MoveUpButton)
|
|
392
424
|
}, props, {
|
|
393
|
-
icon:
|
|
394
|
-
fontSize:
|
|
425
|
+
icon: jsxRuntime.jsx(ArrowUpwardIcon__default["default"], {
|
|
426
|
+
fontSize: 'small'
|
|
395
427
|
})
|
|
396
428
|
}));
|
|
397
429
|
}
|
|
398
430
|
function RemoveButton(props) {
|
|
399
431
|
var iconType = props.iconType,
|
|
400
432
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
401
|
-
|
|
402
|
-
|
|
433
|
+
var translateString = otherProps.registry.translateString;
|
|
434
|
+
return jsxRuntime.jsx(MuiIconButton, _extends({
|
|
435
|
+
title: translateString(utils.TranslatableString.RemoveButton)
|
|
403
436
|
}, otherProps, {
|
|
404
|
-
color:
|
|
405
|
-
icon:
|
|
406
|
-
fontSize: iconType ===
|
|
437
|
+
color: 'error',
|
|
438
|
+
icon: jsxRuntime.jsx(RemoveIcon__default["default"], {
|
|
439
|
+
fontSize: iconType === 'default' ? undefined : 'small'
|
|
407
440
|
})
|
|
408
441
|
}));
|
|
409
442
|
}
|
|
@@ -420,17 +453,19 @@ function FieldErrorTemplate(props) {
|
|
|
420
453
|
return null;
|
|
421
454
|
}
|
|
422
455
|
var id = utils.errorId(idSchema);
|
|
423
|
-
return
|
|
456
|
+
return jsxRuntime.jsx(List__default["default"], {
|
|
424
457
|
dense: true,
|
|
425
|
-
disablePadding: true
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
458
|
+
disablePadding: true,
|
|
459
|
+
children: errors.map(function (error, i) {
|
|
460
|
+
return jsxRuntime.jsx(ListItem__default["default"], {
|
|
461
|
+
disableGutters: true,
|
|
462
|
+
children: jsxRuntime.jsx(FormHelperText__default["default"], {
|
|
463
|
+
id: id,
|
|
464
|
+
children: error
|
|
465
|
+
})
|
|
466
|
+
}, i);
|
|
467
|
+
})
|
|
468
|
+
});
|
|
434
469
|
}
|
|
435
470
|
|
|
436
471
|
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
@@ -444,9 +479,10 @@ function FieldHelpTemplate(props) {
|
|
|
444
479
|
return null;
|
|
445
480
|
}
|
|
446
481
|
var id = utils.helpId(idSchema);
|
|
447
|
-
return
|
|
448
|
-
id: id
|
|
449
|
-
|
|
482
|
+
return jsxRuntime.jsx(FormHelperText__default["default"], {
|
|
483
|
+
id: id,
|
|
484
|
+
children: help
|
|
485
|
+
});
|
|
450
486
|
}
|
|
451
487
|
|
|
452
488
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -476,15 +512,16 @@ function FieldTemplate(props) {
|
|
|
476
512
|
uiSchema = props.uiSchema,
|
|
477
513
|
registry = props.registry;
|
|
478
514
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
479
|
-
var WrapIfAdditionalTemplate = utils.getTemplate(
|
|
515
|
+
var WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
480
516
|
if (hidden) {
|
|
481
|
-
return
|
|
517
|
+
return jsxRuntime.jsx("div", {
|
|
482
518
|
style: {
|
|
483
|
-
display:
|
|
484
|
-
}
|
|
485
|
-
|
|
519
|
+
display: 'none'
|
|
520
|
+
},
|
|
521
|
+
children: children
|
|
522
|
+
});
|
|
486
523
|
}
|
|
487
|
-
return
|
|
524
|
+
return jsxRuntime.jsx(WrapIfAdditionalTemplate, {
|
|
488
525
|
classNames: classNames,
|
|
489
526
|
style: style,
|
|
490
527
|
disabled: disabled,
|
|
@@ -496,15 +533,18 @@ function FieldTemplate(props) {
|
|
|
496
533
|
required: required,
|
|
497
534
|
schema: schema,
|
|
498
535
|
uiSchema: uiSchema,
|
|
499
|
-
registry: registry
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
536
|
+
registry: registry,
|
|
537
|
+
children: jsxRuntime.jsxs(FormControl__default["default"], {
|
|
538
|
+
fullWidth: true,
|
|
539
|
+
error: rawErrors.length ? true : false,
|
|
540
|
+
required: required,
|
|
541
|
+
children: [children, displayLabel && rawDescription ? jsxRuntime.jsx(Typography__default["default"], {
|
|
542
|
+
variant: 'caption',
|
|
543
|
+
color: 'textSecondary',
|
|
544
|
+
children: rawDescription
|
|
545
|
+
}) : null, errors, help]
|
|
546
|
+
})
|
|
547
|
+
});
|
|
508
548
|
}
|
|
509
549
|
|
|
510
550
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -527,54 +567,59 @@ function ObjectFieldTemplate(props) {
|
|
|
527
567
|
onAddClick = props.onAddClick,
|
|
528
568
|
registry = props.registry;
|
|
529
569
|
var uiOptions = utils.getUiOptions(uiSchema);
|
|
530
|
-
var TitleFieldTemplate = utils.getTemplate(
|
|
531
|
-
var DescriptionFieldTemplate = utils.getTemplate(
|
|
570
|
+
var TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
571
|
+
var DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
532
572
|
// Button templates are not overridden in the uiSchema
|
|
533
573
|
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
534
|
-
return
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
574
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
575
|
+
children: [(uiOptions.title || title) && jsxRuntime.jsx(TitleFieldTemplate, {
|
|
576
|
+
id: utils.titleId(idSchema),
|
|
577
|
+
title: title,
|
|
578
|
+
required: required,
|
|
579
|
+
schema: schema,
|
|
580
|
+
uiSchema: uiSchema,
|
|
581
|
+
registry: registry
|
|
582
|
+
}), (uiOptions.description || description) && jsxRuntime.jsx(DescriptionFieldTemplate, {
|
|
583
|
+
id: utils.descriptionId(idSchema),
|
|
584
|
+
description: uiOptions.description || description,
|
|
585
|
+
schema: schema,
|
|
586
|
+
uiSchema: uiSchema,
|
|
587
|
+
registry: registry
|
|
588
|
+
}), jsxRuntime.jsxs(Grid__default["default"], {
|
|
589
|
+
container: true,
|
|
590
|
+
spacing: 2,
|
|
591
|
+
style: {
|
|
592
|
+
marginTop: '10px'
|
|
593
|
+
},
|
|
594
|
+
children: [properties.map(function (element, index) {
|
|
595
|
+
return (
|
|
596
|
+
// Remove the <Grid> if the inner element is hidden as the <Grid>
|
|
597
|
+
// itself would otherwise still take up space.
|
|
598
|
+
element.hidden ? element.content : jsxRuntime.jsx(Grid__default["default"], {
|
|
599
|
+
item: true,
|
|
600
|
+
xs: 12,
|
|
601
|
+
style: {
|
|
602
|
+
marginBottom: '10px'
|
|
603
|
+
},
|
|
604
|
+
children: element.content
|
|
605
|
+
}, index)
|
|
606
|
+
);
|
|
607
|
+
}), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(Grid__default["default"], {
|
|
608
|
+
container: true,
|
|
609
|
+
justifyContent: 'flex-end',
|
|
610
|
+
children: jsxRuntime.jsx(Grid__default["default"], {
|
|
611
|
+
item: true,
|
|
612
|
+
children: jsxRuntime.jsx(AddButton, {
|
|
613
|
+
className: 'object-property-expand',
|
|
614
|
+
onClick: onAddClick(schema),
|
|
615
|
+
disabled: disabled || readonly,
|
|
616
|
+
uiSchema: uiSchema,
|
|
617
|
+
registry: registry
|
|
618
|
+
})
|
|
619
|
+
})
|
|
620
|
+
})]
|
|
621
|
+
})]
|
|
622
|
+
});
|
|
578
623
|
}
|
|
579
624
|
|
|
580
625
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
@@ -589,13 +634,16 @@ function SubmitButton(_ref) {
|
|
|
589
634
|
if (norender) {
|
|
590
635
|
return null;
|
|
591
636
|
}
|
|
592
|
-
return
|
|
593
|
-
marginTop: 3
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
637
|
+
return jsxRuntime.jsx(Box__default["default"], {
|
|
638
|
+
marginTop: 3,
|
|
639
|
+
children: jsxRuntime.jsx(Button__default["default"], _extends({
|
|
640
|
+
type: 'submit',
|
|
641
|
+
variant: 'contained',
|
|
642
|
+
color: 'primary'
|
|
643
|
+
}, submitButtonProps, {
|
|
644
|
+
children: submitText
|
|
645
|
+
}))
|
|
646
|
+
});
|
|
599
647
|
}
|
|
600
648
|
|
|
601
649
|
/** The `TitleField` is the template to use to render the title of a field
|
|
@@ -605,13 +653,15 @@ function SubmitButton(_ref) {
|
|
|
605
653
|
function TitleField(_ref) {
|
|
606
654
|
var id = _ref.id,
|
|
607
655
|
title = _ref.title;
|
|
608
|
-
return
|
|
656
|
+
return jsxRuntime.jsxs(Box__default["default"], {
|
|
609
657
|
id: id,
|
|
610
658
|
mb: 1,
|
|
611
|
-
mt: 1
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
659
|
+
mt: 1,
|
|
660
|
+
children: [jsxRuntime.jsx(Typography__default["default"], {
|
|
661
|
+
variant: 'h5',
|
|
662
|
+
children: title
|
|
663
|
+
}), jsxRuntime.jsx(Divider__default["default"], {})]
|
|
664
|
+
});
|
|
615
665
|
}
|
|
616
666
|
|
|
617
667
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -633,59 +683,68 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
633
683
|
schema = props.schema,
|
|
634
684
|
uiSchema = props.uiSchema,
|
|
635
685
|
registry = props.registry;
|
|
686
|
+
var templates = registry.templates,
|
|
687
|
+
translateString = registry.translateString;
|
|
636
688
|
// Button templates are not overridden in the uiSchema
|
|
637
|
-
var RemoveButton =
|
|
638
|
-
var keyLabel = label
|
|
689
|
+
var RemoveButton = templates.ButtonTemplates.RemoveButton;
|
|
690
|
+
var keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
639
691
|
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
640
692
|
var btnStyle = {
|
|
641
693
|
flex: 1,
|
|
642
694
|
paddingLeft: 6,
|
|
643
695
|
paddingRight: 6,
|
|
644
|
-
fontWeight:
|
|
696
|
+
fontWeight: 'bold'
|
|
645
697
|
};
|
|
646
698
|
if (!additional) {
|
|
647
|
-
return
|
|
699
|
+
return jsxRuntime.jsx("div", {
|
|
648
700
|
className: classNames,
|
|
649
|
-
style: style
|
|
650
|
-
|
|
701
|
+
style: style,
|
|
702
|
+
children: children
|
|
703
|
+
});
|
|
651
704
|
}
|
|
652
705
|
var handleBlur = function handleBlur(_ref) {
|
|
653
706
|
var target = _ref.target;
|
|
654
707
|
return onKeyChange(target.value);
|
|
655
708
|
};
|
|
656
|
-
return
|
|
709
|
+
return jsxRuntime.jsxs(Grid__default["default"], {
|
|
657
710
|
container: true,
|
|
658
|
-
|
|
659
|
-
alignItems: "center",
|
|
711
|
+
alignItems: 'center',
|
|
660
712
|
spacing: 2,
|
|
661
713
|
className: classNames,
|
|
662
|
-
style: style
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
714
|
+
style: style,
|
|
715
|
+
children: [jsxRuntime.jsx(Grid__default["default"], {
|
|
716
|
+
item: true,
|
|
717
|
+
xs: true,
|
|
718
|
+
children: jsxRuntime.jsxs(FormControl__default["default"], {
|
|
719
|
+
fullWidth: true,
|
|
720
|
+
required: required,
|
|
721
|
+
children: [jsxRuntime.jsx(InputLabel__default["default"], {
|
|
722
|
+
children: keyLabel
|
|
723
|
+
}), jsxRuntime.jsx(Input__default["default"], {
|
|
724
|
+
defaultValue: label,
|
|
725
|
+
disabled: disabled || readonly,
|
|
726
|
+
id: id + "-key",
|
|
727
|
+
name: id + "-key",
|
|
728
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
729
|
+
type: 'text'
|
|
730
|
+
})]
|
|
731
|
+
})
|
|
732
|
+
}), jsxRuntime.jsx(Grid__default["default"], {
|
|
733
|
+
item: true,
|
|
734
|
+
xs: true,
|
|
735
|
+
children: children
|
|
736
|
+
}), jsxRuntime.jsx(Grid__default["default"], {
|
|
737
|
+
item: true,
|
|
738
|
+
children: jsxRuntime.jsx(RemoveButton, {
|
|
739
|
+
iconType: 'default',
|
|
740
|
+
style: btnStyle,
|
|
741
|
+
disabled: disabled || readonly,
|
|
742
|
+
onClick: onDropPropertyClick(label),
|
|
743
|
+
uiSchema: uiSchema,
|
|
744
|
+
registry: registry
|
|
745
|
+
})
|
|
746
|
+
})]
|
|
747
|
+
}, id + "-key");
|
|
689
748
|
}
|
|
690
749
|
|
|
691
750
|
function generateTemplates() {
|
|
@@ -743,11 +802,11 @@ function CheckboxWidget(props) {
|
|
|
743
802
|
var value = _ref2.target.value;
|
|
744
803
|
return onFocus(id, value);
|
|
745
804
|
};
|
|
746
|
-
return
|
|
747
|
-
control:
|
|
805
|
+
return jsxRuntime.jsx(FormControlLabel__default["default"], {
|
|
806
|
+
control: jsxRuntime.jsx(Checkbox__default["default"], {
|
|
748
807
|
id: id,
|
|
749
808
|
name: id,
|
|
750
|
-
checked: typeof value ===
|
|
809
|
+
checked: typeof value === 'undefined' ? false : Boolean(value),
|
|
751
810
|
required: required,
|
|
752
811
|
disabled: disabled || readonly,
|
|
753
812
|
autoFocus: autofocus,
|
|
@@ -756,7 +815,7 @@ function CheckboxWidget(props) {
|
|
|
756
815
|
onFocus: _onFocus,
|
|
757
816
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
758
817
|
}),
|
|
759
|
-
label: label ||
|
|
818
|
+
label: label || ''
|
|
760
819
|
});
|
|
761
820
|
}
|
|
762
821
|
|
|
@@ -801,73 +860,35 @@ function CheckboxesWidget(_ref) {
|
|
|
801
860
|
var value = _ref4.target.value;
|
|
802
861
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
803
862
|
};
|
|
804
|
-
return
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
* the value to undefined when it is falsy during the `onChange` handling.
|
|
834
|
-
*
|
|
835
|
-
* @param props - The `WidgetProps` for this component
|
|
836
|
-
*/
|
|
837
|
-
function DateWidget(props) {
|
|
838
|
-
var options = props.options,
|
|
839
|
-
registry = props.registry;
|
|
840
|
-
var BaseInputTemplate = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
841
|
-
return /*#__PURE__*/React__default["default"].createElement(BaseInputTemplate, _extends({
|
|
842
|
-
type: "date",
|
|
843
|
-
InputLabelProps: {
|
|
844
|
-
shrink: true
|
|
845
|
-
}
|
|
846
|
-
}, props));
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
850
|
-
* the value to/from utc using the appropriate utility functions.
|
|
851
|
-
*
|
|
852
|
-
* @param props - The `WidgetProps` for this component
|
|
853
|
-
*/
|
|
854
|
-
function DateTimeWidget(props) {
|
|
855
|
-
var options = props.options,
|
|
856
|
-
registry = props.registry;
|
|
857
|
-
var BaseInputTemplate = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
858
|
-
var value = utils.utcToLocal(props.value);
|
|
859
|
-
var onChange = function onChange(value) {
|
|
860
|
-
props.onChange(utils.localToUTC(value));
|
|
861
|
-
};
|
|
862
|
-
return /*#__PURE__*/React__default["default"].createElement(BaseInputTemplate, _extends({
|
|
863
|
-
type: "datetime-local",
|
|
864
|
-
InputLabelProps: {
|
|
865
|
-
shrink: true
|
|
866
|
-
}
|
|
867
|
-
}, props, {
|
|
868
|
-
value: value,
|
|
869
|
-
onChange: onChange
|
|
870
|
-
}));
|
|
863
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
864
|
+
children: [jsxRuntime.jsx(FormLabel__default["default"], {
|
|
865
|
+
required: required,
|
|
866
|
+
htmlFor: id,
|
|
867
|
+
children: label || schema.title
|
|
868
|
+
}), jsxRuntime.jsx(FormGroup__default["default"], {
|
|
869
|
+
id: id,
|
|
870
|
+
row: !!inline,
|
|
871
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
872
|
+
var checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
873
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
874
|
+
var checkbox = jsxRuntime.jsx(Checkbox__default["default"], {
|
|
875
|
+
id: utils.optionId(id, index),
|
|
876
|
+
name: id,
|
|
877
|
+
checked: checked,
|
|
878
|
+
disabled: disabled || itemDisabled || readonly,
|
|
879
|
+
autoFocus: autofocus && index === 0,
|
|
880
|
+
onChange: _onChange(index),
|
|
881
|
+
onBlur: _onBlur,
|
|
882
|
+
onFocus: _onFocus,
|
|
883
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
884
|
+
});
|
|
885
|
+
return jsxRuntime.jsx(FormControlLabel__default["default"], {
|
|
886
|
+
control: checkbox,
|
|
887
|
+
label: option.label
|
|
888
|
+
}, index);
|
|
889
|
+
})
|
|
890
|
+
})]
|
|
891
|
+
});
|
|
871
892
|
}
|
|
872
893
|
|
|
873
894
|
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
@@ -903,33 +924,36 @@ function RadioWidget(_ref) {
|
|
|
903
924
|
};
|
|
904
925
|
var row = options ? options.inline : false;
|
|
905
926
|
var selectedIndex = utils.enumOptionsIndexForValue(value, enumOptions);
|
|
906
|
-
return
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
927
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
928
|
+
children: [jsxRuntime.jsx(FormLabel__default["default"], {
|
|
929
|
+
required: required,
|
|
930
|
+
htmlFor: id,
|
|
931
|
+
children: label || schema.title
|
|
932
|
+
}), jsxRuntime.jsx(RadioGroup__default["default"], {
|
|
933
|
+
id: id,
|
|
934
|
+
name: id,
|
|
935
|
+
value: selectedIndex,
|
|
936
|
+
row: row,
|
|
937
|
+
onChange: _onChange,
|
|
938
|
+
onBlur: _onBlur,
|
|
939
|
+
onFocus: _onFocus,
|
|
940
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
941
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
942
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
943
|
+
var radio = jsxRuntime.jsx(FormControlLabel__default["default"], {
|
|
944
|
+
control: jsxRuntime.jsx(Radio__default["default"], {
|
|
945
|
+
name: id,
|
|
946
|
+
id: utils.optionId(id, index),
|
|
947
|
+
color: 'primary'
|
|
948
|
+
}),
|
|
949
|
+
label: option.label,
|
|
950
|
+
value: String(index),
|
|
951
|
+
disabled: disabled || itemDisabled || readonly
|
|
952
|
+
}, index);
|
|
953
|
+
return radio;
|
|
954
|
+
})
|
|
955
|
+
})]
|
|
956
|
+
});
|
|
933
957
|
}
|
|
934
958
|
|
|
935
959
|
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
@@ -956,7 +980,7 @@ function RangeWidget(props) {
|
|
|
956
980
|
name: id
|
|
957
981
|
}, utils.rangeSpec(schema));
|
|
958
982
|
var _onChange = function _onChange(_, value) {
|
|
959
|
-
onChange(value ? value : options.emptyValue);
|
|
983
|
+
onChange(value != null ? value : options.emptyValue);
|
|
960
984
|
};
|
|
961
985
|
var _onBlur = function _onBlur(_ref) {
|
|
962
986
|
var value = _ref.target.value;
|
|
@@ -966,21 +990,24 @@ function RangeWidget(props) {
|
|
|
966
990
|
var value = _ref2.target.value;
|
|
967
991
|
return onFocus(id, value);
|
|
968
992
|
};
|
|
969
|
-
return
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
993
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
994
|
+
children: [jsxRuntime.jsx(FormLabel__default["default"], {
|
|
995
|
+
required: required,
|
|
996
|
+
htmlFor: id,
|
|
997
|
+
children: label || schema.title
|
|
998
|
+
}), jsxRuntime.jsx(Slider__default["default"], _extends({
|
|
999
|
+
disabled: disabled || readonly,
|
|
1000
|
+
onChange: _onChange,
|
|
1001
|
+
onBlur: _onBlur,
|
|
1002
|
+
onFocus: _onFocus,
|
|
1003
|
+
valueLabelDisplay: 'auto'
|
|
1004
|
+
}, sliderProps, {
|
|
1005
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1006
|
+
}))]
|
|
1007
|
+
});
|
|
981
1008
|
}
|
|
982
1009
|
|
|
983
|
-
var _excluded = ["schema", "id", "options", "label", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
|
|
1010
|
+
var _excluded = ["schema", "id", "name", "options", "label", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
|
|
984
1011
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
985
1012
|
* It is typically used with string properties constrained with enum options.
|
|
986
1013
|
*
|
|
@@ -1007,9 +1034,9 @@ function SelectWidget(_ref) {
|
|
|
1007
1034
|
var enumOptions = options.enumOptions,
|
|
1008
1035
|
enumDisabled = options.enumDisabled,
|
|
1009
1036
|
optEmptyVal = options.emptyValue;
|
|
1010
|
-
multiple = typeof multiple ===
|
|
1011
|
-
var emptyValue = multiple ? [] :
|
|
1012
|
-
var isEmpty = typeof value ===
|
|
1037
|
+
multiple = typeof multiple === 'undefined' ? false : !!multiple;
|
|
1038
|
+
var emptyValue = multiple ? [] : '';
|
|
1039
|
+
var isEmpty = typeof value === 'undefined' || multiple && value.length < 1 || !multiple && value === emptyValue;
|
|
1013
1040
|
var _onChange = function _onChange(_ref2) {
|
|
1014
1041
|
var value = _ref2.target.value;
|
|
1015
1042
|
return onChange(utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
@@ -1023,7 +1050,7 @@ function SelectWidget(_ref) {
|
|
|
1023
1050
|
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1024
1051
|
};
|
|
1025
1052
|
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1026
|
-
return
|
|
1053
|
+
return jsxRuntime.jsx(TextField__default["default"], _extends({
|
|
1027
1054
|
id: id,
|
|
1028
1055
|
name: id,
|
|
1029
1056
|
label: label || schema.title,
|
|
@@ -1045,16 +1072,17 @@ function SelectWidget(_ref) {
|
|
|
1045
1072
|
SelectProps: _extends({}, textFieldProps.SelectProps, {
|
|
1046
1073
|
multiple: multiple
|
|
1047
1074
|
}),
|
|
1048
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1075
|
+
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
1076
|
+
children: Array.isArray(enumOptions) && enumOptions.map(function (_ref5, i) {
|
|
1077
|
+
var value = _ref5.value,
|
|
1078
|
+
label = _ref5.label;
|
|
1079
|
+
var disabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1;
|
|
1080
|
+
return jsxRuntime.jsx(MenuItem__default["default"], {
|
|
1081
|
+
value: String(i),
|
|
1082
|
+
disabled: disabled,
|
|
1083
|
+
children: label
|
|
1084
|
+
}, i);
|
|
1085
|
+
})
|
|
1058
1086
|
}));
|
|
1059
1087
|
}
|
|
1060
1088
|
|
|
@@ -1065,12 +1093,12 @@ function SelectWidget(_ref) {
|
|
|
1065
1093
|
function TextareaWidget(props) {
|
|
1066
1094
|
var options = props.options,
|
|
1067
1095
|
registry = props.registry;
|
|
1068
|
-
var BaseInputTemplate = utils.getTemplate(
|
|
1096
|
+
var BaseInputTemplate = utils.getTemplate('BaseInputTemplate', registry, options);
|
|
1069
1097
|
var rows = 5;
|
|
1070
|
-
if (typeof options.rows ===
|
|
1098
|
+
if (typeof options.rows === 'string' || typeof options.rows === 'number') {
|
|
1071
1099
|
rows = options.rows;
|
|
1072
1100
|
}
|
|
1073
|
-
return
|
|
1101
|
+
return jsxRuntime.jsx(BaseInputTemplate, _extends({}, props, {
|
|
1074
1102
|
multiline: true,
|
|
1075
1103
|
rows: rows
|
|
1076
1104
|
}));
|
|
@@ -1080,8 +1108,6 @@ function generateWidgets() {
|
|
|
1080
1108
|
return {
|
|
1081
1109
|
CheckboxWidget: CheckboxWidget,
|
|
1082
1110
|
CheckboxesWidget: CheckboxesWidget,
|
|
1083
|
-
DateWidget: DateWidget,
|
|
1084
|
-
DateTimeWidget: DateTimeWidget,
|
|
1085
1111
|
RadioWidget: RadioWidget,
|
|
1086
1112
|
RangeWidget: RangeWidget,
|
|
1087
1113
|
SelectWidget: SelectWidget,
|