@rjsf/mui 5.0.0-beta.9 → 5.0.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/dist/index.d.ts +10 -52
- package/dist/mui.cjs.development.js +694 -702
- 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 +690 -702
- package/dist/mui.esm.js.map +1 -1
- package/dist/mui.umd.development.js +696 -704
- 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 +17 -17
|
@@ -22,10 +22,10 @@ var ArrowUpwardIcon = require('@mui/icons-material/ArrowUpward');
|
|
|
22
22
|
var RemoveIcon = require('@mui/icons-material/Remove');
|
|
23
23
|
var FormHelperText = require('@mui/material/FormHelperText');
|
|
24
24
|
var FormControl = require('@mui/material/FormControl');
|
|
25
|
-
var InputLabel = require('@mui/material/InputLabel');
|
|
26
|
-
var Input = require('@mui/material/OutlinedInput');
|
|
27
25
|
var Button = require('@mui/material/Button');
|
|
28
26
|
var Divider = require('@mui/material/Divider');
|
|
27
|
+
var InputLabel = require('@mui/material/InputLabel');
|
|
28
|
+
var Input = require('@mui/material/OutlinedInput');
|
|
29
29
|
var Checkbox = require('@mui/material/Checkbox');
|
|
30
30
|
var FormControlLabel = require('@mui/material/FormControlLabel');
|
|
31
31
|
var FormGroup = require('@mui/material/FormGroup');
|
|
@@ -55,10 +55,10 @@ var ArrowUpwardIcon__default = /*#__PURE__*/_interopDefaultLegacy(ArrowUpwardIco
|
|
|
55
55
|
var RemoveIcon__default = /*#__PURE__*/_interopDefaultLegacy(RemoveIcon);
|
|
56
56
|
var FormHelperText__default = /*#__PURE__*/_interopDefaultLegacy(FormHelperText);
|
|
57
57
|
var FormControl__default = /*#__PURE__*/_interopDefaultLegacy(FormControl);
|
|
58
|
-
var InputLabel__default = /*#__PURE__*/_interopDefaultLegacy(InputLabel);
|
|
59
|
-
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
60
58
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
61
59
|
var Divider__default = /*#__PURE__*/_interopDefaultLegacy(Divider);
|
|
60
|
+
var InputLabel__default = /*#__PURE__*/_interopDefaultLegacy(InputLabel);
|
|
61
|
+
var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
|
|
62
62
|
var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
|
|
63
63
|
var FormControlLabel__default = /*#__PURE__*/_interopDefaultLegacy(FormControlLabel);
|
|
64
64
|
var FormGroup__default = /*#__PURE__*/_interopDefaultLegacy(FormGroup);
|
|
@@ -68,39 +68,67 @@ var RadioGroup__default = /*#__PURE__*/_interopDefaultLegacy(RadioGroup);
|
|
|
68
68
|
var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
|
|
69
69
|
var MenuItem__default = /*#__PURE__*/_interopDefaultLegacy(MenuItem);
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
71
|
+
function _extends() {
|
|
72
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
73
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
74
|
+
var source = arguments[i];
|
|
75
|
+
for (var key in source) {
|
|
76
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
77
|
+
target[key] = source[key];
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return target;
|
|
82
|
+
};
|
|
83
|
+
return _extends.apply(this, arguments);
|
|
84
|
+
}
|
|
85
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
86
|
+
if (source == null) return {};
|
|
87
|
+
var target = {};
|
|
88
|
+
var sourceKeys = Object.keys(source);
|
|
89
|
+
var key, i;
|
|
90
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
91
|
+
key = sourceKeys[i];
|
|
92
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
93
|
+
target[key] = source[key];
|
|
94
|
+
}
|
|
95
|
+
return target;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var _excluded$4 = ["uiSchema", "registry"];
|
|
99
|
+
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
100
|
+
*/
|
|
101
|
+
function AddButton(_ref) {
|
|
102
|
+
var props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
103
|
+
return /*#__PURE__*/React__default["default"].createElement(IconButton__default["default"], _extends({
|
|
104
|
+
title: "Add Item"
|
|
105
|
+
}, props, {
|
|
79
106
|
color: "primary"
|
|
80
|
-
}, /*#__PURE__*/React__default["default"].createElement(AddIcon__default["default"], null));
|
|
81
|
-
}
|
|
107
|
+
}), /*#__PURE__*/React__default["default"].createElement(AddIcon__default["default"], null));
|
|
108
|
+
}
|
|
82
109
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
110
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
111
|
+
*
|
|
112
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
113
|
+
*/
|
|
114
|
+
function ArrayFieldItemTemplate(props) {
|
|
115
|
+
var children = props.children,
|
|
116
|
+
disabled = props.disabled,
|
|
117
|
+
hasToolbar = props.hasToolbar,
|
|
118
|
+
hasMoveDown = props.hasMoveDown,
|
|
119
|
+
hasMoveUp = props.hasMoveUp,
|
|
120
|
+
hasRemove = props.hasRemove,
|
|
121
|
+
index = props.index,
|
|
122
|
+
onDropIndexClick = props.onDropIndexClick,
|
|
123
|
+
onReorderClick = props.onReorderClick,
|
|
124
|
+
readonly = props.readonly,
|
|
125
|
+
uiSchema = props.uiSchema,
|
|
126
|
+
registry = props.registry;
|
|
127
|
+
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
128
|
+
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
129
|
+
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
130
|
+
RemoveButton = _registry$templates$B.RemoveButton;
|
|
131
|
+
var btnStyle = {
|
|
104
132
|
flex: 1,
|
|
105
133
|
paddingLeft: 6,
|
|
106
134
|
paddingRight: 6,
|
|
@@ -128,44 +156,46 @@ const ArrayFieldItemTemplate = props => {
|
|
|
128
156
|
style: btnStyle,
|
|
129
157
|
disabled: disabled || readonly || !hasMoveUp,
|
|
130
158
|
onClick: onReorderClick(index, index - 1),
|
|
131
|
-
uiSchema: uiSchema
|
|
159
|
+
uiSchema: uiSchema,
|
|
160
|
+
registry: registry
|
|
132
161
|
}), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React__default["default"].createElement(MoveDownButton, {
|
|
133
162
|
style: btnStyle,
|
|
134
163
|
disabled: disabled || readonly || !hasMoveDown,
|
|
135
164
|
onClick: onReorderClick(index, index + 1),
|
|
136
|
-
uiSchema: uiSchema
|
|
165
|
+
uiSchema: uiSchema,
|
|
166
|
+
registry: registry
|
|
137
167
|
}), hasRemove && /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
138
168
|
style: btnStyle,
|
|
139
169
|
disabled: disabled || readonly,
|
|
140
170
|
onClick: onDropIndexClick(index),
|
|
141
|
-
uiSchema: uiSchema
|
|
171
|
+
uiSchema: uiSchema,
|
|
172
|
+
registry: registry
|
|
142
173
|
})));
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
const ArrayFieldTemplate = props => {
|
|
146
|
-
const {
|
|
147
|
-
canAdd,
|
|
148
|
-
disabled,
|
|
149
|
-
idSchema,
|
|
150
|
-
uiSchema,
|
|
151
|
-
items,
|
|
152
|
-
onAddClick,
|
|
153
|
-
readonly,
|
|
154
|
-
registry,
|
|
155
|
-
required,
|
|
156
|
-
schema,
|
|
157
|
-
title
|
|
158
|
-
} = props;
|
|
159
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
160
|
-
const ArrayFieldDescriptionTemplate = utils.getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
|
|
161
|
-
const ArrayFieldItemTemplate = utils.getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
|
|
162
|
-
const ArrayFieldTitleTemplate = utils.getTemplate("ArrayFieldTitleTemplate", registry, uiOptions); // Button templates are not overridden in the uiSchema
|
|
174
|
+
}
|
|
163
175
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
176
|
+
var _excluded$3 = ["key"];
|
|
177
|
+
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
178
|
+
*
|
|
179
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
180
|
+
*/
|
|
181
|
+
function ArrayFieldTemplate(props) {
|
|
182
|
+
var canAdd = props.canAdd,
|
|
183
|
+
disabled = props.disabled,
|
|
184
|
+
idSchema = props.idSchema,
|
|
185
|
+
uiSchema = props.uiSchema,
|
|
186
|
+
items = props.items,
|
|
187
|
+
onAddClick = props.onAddClick,
|
|
188
|
+
readonly = props.readonly,
|
|
189
|
+
registry = props.registry,
|
|
190
|
+
required = props.required,
|
|
191
|
+
schema = props.schema,
|
|
192
|
+
title = props.title;
|
|
193
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
194
|
+
var ArrayFieldDescriptionTemplate = utils.getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
|
|
195
|
+
var ArrayFieldItemTemplate = utils.getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
|
|
196
|
+
var ArrayFieldTitleTemplate = utils.getTemplate("ArrayFieldTitleTemplate", registry, uiOptions);
|
|
197
|
+
// Button templates are not overridden in the uiSchema
|
|
198
|
+
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
169
199
|
return /*#__PURE__*/React__default["default"].createElement(Paper__default["default"], {
|
|
170
200
|
elevation: 2
|
|
171
201
|
}, /*#__PURE__*/React__default["default"].createElement(Box__default["default"], {
|
|
@@ -173,26 +203,25 @@ const ArrayFieldTemplate = props => {
|
|
|
173
203
|
}, /*#__PURE__*/React__default["default"].createElement(ArrayFieldTitleTemplate, {
|
|
174
204
|
idSchema: idSchema,
|
|
175
205
|
title: uiOptions.title || title,
|
|
206
|
+
schema: schema,
|
|
176
207
|
uiSchema: uiSchema,
|
|
177
208
|
required: required,
|
|
178
209
|
registry: registry
|
|
179
|
-
}),
|
|
210
|
+
}), /*#__PURE__*/React__default["default"].createElement(ArrayFieldDescriptionTemplate, {
|
|
180
211
|
idSchema: idSchema,
|
|
181
212
|
description: uiOptions.description || schema.description,
|
|
213
|
+
schema: schema,
|
|
182
214
|
uiSchema: uiSchema,
|
|
183
215
|
registry: registry
|
|
184
216
|
}), /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
185
217
|
container: true,
|
|
186
218
|
key: "array-item-list-" + idSchema.$id
|
|
187
|
-
}, items && items.map(_ref
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
key: key,
|
|
194
|
-
...itemProps
|
|
195
|
-
});
|
|
219
|
+
}, items && items.map(function (_ref) {
|
|
220
|
+
var key = _ref.key,
|
|
221
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
222
|
+
return /*#__PURE__*/React__default["default"].createElement(ArrayFieldItemTemplate, _extends({
|
|
223
|
+
key: key
|
|
224
|
+
}, itemProps));
|
|
196
225
|
}), canAdd && /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
197
226
|
container: true,
|
|
198
227
|
justifyContent: "flex-end"
|
|
@@ -204,113 +233,101 @@ const ArrayFieldTemplate = props => {
|
|
|
204
233
|
className: "array-item-add",
|
|
205
234
|
onClick: onAddClick,
|
|
206
235
|
disabled: disabled || readonly,
|
|
207
|
-
uiSchema: uiSchema
|
|
236
|
+
uiSchema: uiSchema,
|
|
237
|
+
registry: registry
|
|
208
238
|
})))))));
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const BaseInputTemplate = _ref => {
|
|
212
|
-
let {
|
|
213
|
-
id,
|
|
214
|
-
placeholder,
|
|
215
|
-
required,
|
|
216
|
-
readonly,
|
|
217
|
-
disabled,
|
|
218
|
-
type,
|
|
219
|
-
label,
|
|
220
|
-
value,
|
|
221
|
-
onChange,
|
|
222
|
-
onBlur,
|
|
223
|
-
onFocus,
|
|
224
|
-
autofocus,
|
|
225
|
-
options,
|
|
226
|
-
schema,
|
|
227
|
-
uiSchema,
|
|
228
|
-
rawErrors = [],
|
|
229
|
-
formContext,
|
|
230
|
-
registry,
|
|
231
|
-
...textFieldProps
|
|
232
|
-
} = _ref;
|
|
233
|
-
const inputProps = utils.getInputProps(schema, type, options); // Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
234
|
-
|
|
235
|
-
const {
|
|
236
|
-
step,
|
|
237
|
-
min,
|
|
238
|
-
max,
|
|
239
|
-
...rest
|
|
240
|
-
} = inputProps;
|
|
241
|
-
const otherProps = {
|
|
242
|
-
inputProps: {
|
|
243
|
-
step,
|
|
244
|
-
min,
|
|
245
|
-
max,
|
|
246
|
-
...(schema.examples ? {
|
|
247
|
-
list: "examples_" + id
|
|
248
|
-
} : undefined)
|
|
249
|
-
},
|
|
250
|
-
...rest
|
|
251
|
-
};
|
|
239
|
+
}
|
|
252
240
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
241
|
+
var _excluded$2 = ["id", "placeholder", "required", "readonly", "disabled", "type", "label", "value", "onChange", "onBlur", "onFocus", "autofocus", "options", "schema", "uiSchema", "rawErrors", "formContext", "registry"],
|
|
242
|
+
_excluded2$1 = ["step", "min", "max"];
|
|
243
|
+
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
244
|
+
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
245
|
+
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
246
|
+
*
|
|
247
|
+
* @param props - The `WidgetProps` for this template
|
|
248
|
+
*/
|
|
249
|
+
function BaseInputTemplate(props) {
|
|
250
|
+
var id = props.id,
|
|
251
|
+
placeholder = props.placeholder,
|
|
252
|
+
required = props.required,
|
|
253
|
+
readonly = props.readonly,
|
|
254
|
+
disabled = props.disabled,
|
|
255
|
+
type = props.type,
|
|
256
|
+
label = props.label,
|
|
257
|
+
value = props.value,
|
|
258
|
+
onChange = props.onChange,
|
|
259
|
+
onBlur = props.onBlur,
|
|
260
|
+
onFocus = props.onFocus,
|
|
261
|
+
autofocus = props.autofocus,
|
|
262
|
+
options = props.options,
|
|
263
|
+
schema = props.schema,
|
|
264
|
+
uiSchema = props.uiSchema,
|
|
265
|
+
_props$rawErrors = props.rawErrors,
|
|
266
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
267
|
+
registry = props.registry,
|
|
268
|
+
textFieldProps = _objectWithoutPropertiesLoose(props, _excluded$2);
|
|
269
|
+
var inputProps = utils.getInputProps(schema, type, options);
|
|
270
|
+
// Now we need to pull out the step, min, max into an inner `inputProps` for material-ui
|
|
271
|
+
var step = inputProps.step,
|
|
272
|
+
min = inputProps.min,
|
|
273
|
+
max = inputProps.max,
|
|
274
|
+
rest = _objectWithoutPropertiesLoose(inputProps, _excluded2$1);
|
|
275
|
+
var otherProps = _extends({
|
|
276
|
+
inputProps: _extends({
|
|
277
|
+
step: step,
|
|
278
|
+
min: min,
|
|
279
|
+
max: max
|
|
280
|
+
}, schema.examples ? {
|
|
281
|
+
list: utils.examplesId(id)
|
|
282
|
+
} : undefined)
|
|
283
|
+
}, rest);
|
|
284
|
+
var _onChange = function _onChange(_ref) {
|
|
285
|
+
var value = _ref.target.value;
|
|
259
286
|
return onChange(value === "" ? options.emptyValue : value);
|
|
260
287
|
};
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
let {
|
|
264
|
-
target: {
|
|
265
|
-
value
|
|
266
|
-
}
|
|
267
|
-
} = _ref3;
|
|
288
|
+
var _onBlur = function _onBlur(_ref2) {
|
|
289
|
+
var value = _ref2.target.value;
|
|
268
290
|
return onBlur(id, value);
|
|
269
291
|
};
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
let {
|
|
273
|
-
target: {
|
|
274
|
-
value
|
|
275
|
-
}
|
|
276
|
-
} = _ref4;
|
|
292
|
+
var _onFocus = function _onFocus(_ref3) {
|
|
293
|
+
var value = _ref3.target.value;
|
|
277
294
|
return onFocus(id, value);
|
|
278
295
|
};
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
} = registry;
|
|
283
|
-
const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
284
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(TextField__default["default"], {
|
|
296
|
+
var schemaUtils = registry.schemaUtils;
|
|
297
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
298
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(TextField__default["default"], _extends({
|
|
285
299
|
id: id,
|
|
300
|
+
name: id,
|
|
286
301
|
placeholder: placeholder,
|
|
287
302
|
label: displayLabel ? label || schema.title : false,
|
|
288
303
|
autoFocus: autofocus,
|
|
289
304
|
required: required,
|
|
290
|
-
disabled: disabled || readonly
|
|
291
|
-
|
|
305
|
+
disabled: disabled || readonly
|
|
306
|
+
}, otherProps, {
|
|
292
307
|
value: value || value === 0 ? value : "",
|
|
293
308
|
error: rawErrors.length > 0,
|
|
294
309
|
onChange: _onChange,
|
|
295
310
|
onBlur: _onBlur,
|
|
296
|
-
onFocus: _onFocus
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
311
|
+
onFocus: _onFocus
|
|
312
|
+
}, textFieldProps, {
|
|
313
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
314
|
+
})), Array.isArray(schema.examples) && /*#__PURE__*/React__default["default"].createElement("datalist", {
|
|
315
|
+
id: utils.examplesId(id)
|
|
316
|
+
}, schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
301
317
|
return /*#__PURE__*/React__default["default"].createElement("option", {
|
|
302
318
|
key: example,
|
|
303
319
|
value: example
|
|
304
320
|
});
|
|
305
321
|
})));
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
const DescriptionField = _ref => {
|
|
309
|
-
let {
|
|
310
|
-
description,
|
|
311
|
-
id
|
|
312
|
-
} = _ref;
|
|
322
|
+
}
|
|
313
323
|
|
|
324
|
+
/** The `DescriptionField` is the template to use to render the description of a field
|
|
325
|
+
*
|
|
326
|
+
* @param props - The `DescriptionFieldProps` for this component
|
|
327
|
+
*/
|
|
328
|
+
function DescriptionField(props) {
|
|
329
|
+
var id = props.id,
|
|
330
|
+
description = props.description;
|
|
314
331
|
if (description) {
|
|
315
332
|
return /*#__PURE__*/React__default["default"].createElement(Typography__default["default"], {
|
|
316
333
|
id: id,
|
|
@@ -320,14 +337,15 @@ const DescriptionField = _ref => {
|
|
|
320
337
|
}
|
|
321
338
|
}, description);
|
|
322
339
|
}
|
|
323
|
-
|
|
324
340
|
return null;
|
|
325
|
-
}
|
|
341
|
+
}
|
|
326
342
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
343
|
+
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
344
|
+
*
|
|
345
|
+
* @param props - The `ErrorListProps` for this component
|
|
346
|
+
*/
|
|
347
|
+
function ErrorList(_ref) {
|
|
348
|
+
var errors = _ref.errors;
|
|
331
349
|
return /*#__PURE__*/React__default["default"].createElement(Paper__default["default"], {
|
|
332
350
|
elevation: 2
|
|
333
351
|
}, /*#__PURE__*/React__default["default"].createElement(Box__default["default"], {
|
|
@@ -337,7 +355,7 @@ const ErrorList = _ref => {
|
|
|
337
355
|
variant: "h6"
|
|
338
356
|
}, "Errors"), /*#__PURE__*/React__default["default"].createElement(List__default["default"], {
|
|
339
357
|
dense: true
|
|
340
|
-
}, errors.map((error, i)
|
|
358
|
+
}, errors.map(function (error, i) {
|
|
341
359
|
return /*#__PURE__*/React__default["default"].createElement(ListItem__default["default"], {
|
|
342
360
|
key: i
|
|
343
361
|
}, /*#__PURE__*/React__default["default"].createElement(ListItemIcon__default["default"], null, /*#__PURE__*/React__default["default"].createElement(ErrorIcon__default["default"], {
|
|
@@ -346,73 +364,66 @@ const ErrorList = _ref => {
|
|
|
346
364
|
primary: error.stack
|
|
347
365
|
}));
|
|
348
366
|
}))));
|
|
349
|
-
}
|
|
367
|
+
}
|
|
350
368
|
|
|
369
|
+
var _excluded$1 = ["icon", "color", "uiSchema", "registry"],
|
|
370
|
+
_excluded2 = ["iconType"];
|
|
351
371
|
function MuiIconButton(props) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
...otherProps
|
|
357
|
-
} = props;
|
|
358
|
-
return /*#__PURE__*/React__default["default"].createElement(IconButton__default["default"], { ...otherProps,
|
|
372
|
+
var icon = props.icon,
|
|
373
|
+
color = props.color,
|
|
374
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
375
|
+
return /*#__PURE__*/React__default["default"].createElement(IconButton__default["default"], _extends({}, otherProps, {
|
|
359
376
|
size: "small",
|
|
360
377
|
color: color
|
|
361
|
-
}, icon);
|
|
378
|
+
}), icon);
|
|
362
379
|
}
|
|
363
380
|
function MoveDownButton(props) {
|
|
364
|
-
return /*#__PURE__*/React__default["default"].createElement(MuiIconButton, {
|
|
365
|
-
title: "Move down"
|
|
366
|
-
|
|
381
|
+
return /*#__PURE__*/React__default["default"].createElement(MuiIconButton, _extends({
|
|
382
|
+
title: "Move down"
|
|
383
|
+
}, props, {
|
|
367
384
|
icon: /*#__PURE__*/React__default["default"].createElement(ArrowDownwardIcon__default["default"], {
|
|
368
385
|
fontSize: "small"
|
|
369
386
|
})
|
|
370
|
-
});
|
|
387
|
+
}));
|
|
371
388
|
}
|
|
372
389
|
function MoveUpButton(props) {
|
|
373
|
-
return /*#__PURE__*/React__default["default"].createElement(MuiIconButton, {
|
|
374
|
-
title: "Move up"
|
|
375
|
-
|
|
390
|
+
return /*#__PURE__*/React__default["default"].createElement(MuiIconButton, _extends({
|
|
391
|
+
title: "Move up"
|
|
392
|
+
}, props, {
|
|
376
393
|
icon: /*#__PURE__*/React__default["default"].createElement(ArrowUpwardIcon__default["default"], {
|
|
377
394
|
fontSize: "small"
|
|
378
395
|
})
|
|
379
|
-
});
|
|
396
|
+
}));
|
|
380
397
|
}
|
|
381
398
|
function RemoveButton(props) {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
title: "Remove",
|
|
388
|
-
...otherProps,
|
|
399
|
+
var iconType = props.iconType,
|
|
400
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded2);
|
|
401
|
+
return /*#__PURE__*/React__default["default"].createElement(MuiIconButton, _extends({
|
|
402
|
+
title: "Remove"
|
|
403
|
+
}, otherProps, {
|
|
389
404
|
color: "error",
|
|
390
405
|
icon: /*#__PURE__*/React__default["default"].createElement(RemoveIcon__default["default"], {
|
|
391
406
|
fontSize: iconType === "default" ? undefined : "small"
|
|
392
407
|
})
|
|
393
|
-
});
|
|
408
|
+
}));
|
|
394
409
|
}
|
|
395
410
|
|
|
396
411
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
397
412
|
*
|
|
398
413
|
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
399
414
|
*/
|
|
400
|
-
|
|
401
415
|
function FieldErrorTemplate(props) {
|
|
402
|
-
|
|
403
|
-
errors = [],
|
|
404
|
-
idSchema
|
|
405
|
-
} = props;
|
|
406
|
-
|
|
416
|
+
var _props$errors = props.errors,
|
|
417
|
+
errors = _props$errors === void 0 ? [] : _props$errors,
|
|
418
|
+
idSchema = props.idSchema;
|
|
407
419
|
if (errors.length === 0) {
|
|
408
420
|
return null;
|
|
409
421
|
}
|
|
410
|
-
|
|
411
|
-
const id = idSchema.$id + "__error";
|
|
422
|
+
var id = utils.errorId(idSchema);
|
|
412
423
|
return /*#__PURE__*/React__default["default"].createElement(List__default["default"], {
|
|
413
424
|
dense: true,
|
|
414
425
|
disablePadding: true
|
|
415
|
-
}, errors.map((error, i)
|
|
426
|
+
}, errors.map(function (error, i) {
|
|
416
427
|
return /*#__PURE__*/React__default["default"].createElement(ListItem__default["default"], {
|
|
417
428
|
key: i,
|
|
418
429
|
disableGutters: true
|
|
@@ -426,119 +437,46 @@ function FieldErrorTemplate(props) {
|
|
|
426
437
|
*
|
|
427
438
|
* @param props - The `FieldHelpProps` to be rendered
|
|
428
439
|
*/
|
|
429
|
-
|
|
430
440
|
function FieldHelpTemplate(props) {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
help
|
|
434
|
-
} = props;
|
|
435
|
-
|
|
441
|
+
var idSchema = props.idSchema,
|
|
442
|
+
help = props.help;
|
|
436
443
|
if (!help) {
|
|
437
444
|
return null;
|
|
438
445
|
}
|
|
439
|
-
|
|
440
|
-
const id = idSchema.$id + "__help";
|
|
446
|
+
var id = utils.helpId(idSchema);
|
|
441
447
|
return /*#__PURE__*/React__default["default"].createElement(FormHelperText__default["default"], {
|
|
442
448
|
id: id
|
|
443
449
|
}, help);
|
|
444
450
|
}
|
|
445
451
|
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
if (!additional) {
|
|
475
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
476
|
-
className: classNames
|
|
477
|
-
}, children);
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
const handleBlur = _ref2 => {
|
|
481
|
-
let {
|
|
482
|
-
target
|
|
483
|
-
} = _ref2;
|
|
484
|
-
return onKeyChange(target.value);
|
|
485
|
-
};
|
|
486
|
-
|
|
487
|
-
return /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
488
|
-
container: true,
|
|
489
|
-
key: id + "-key",
|
|
490
|
-
alignItems: "center",
|
|
491
|
-
spacing: 2,
|
|
492
|
-
className: classNames
|
|
493
|
-
}, /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
494
|
-
item: true,
|
|
495
|
-
xs: true
|
|
496
|
-
}, /*#__PURE__*/React__default["default"].createElement(FormControl__default["default"], {
|
|
497
|
-
fullWidth: true,
|
|
498
|
-
required: required
|
|
499
|
-
}, /*#__PURE__*/React__default["default"].createElement(InputLabel__default["default"], null, keyLabel), /*#__PURE__*/React__default["default"].createElement(Input__default["default"], {
|
|
500
|
-
defaultValue: label,
|
|
501
|
-
disabled: disabled || readonly,
|
|
502
|
-
id: id + "-key",
|
|
503
|
-
name: id + "-key",
|
|
504
|
-
onBlur: !readonly ? handleBlur : undefined,
|
|
505
|
-
type: "text"
|
|
506
|
-
}))), /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
507
|
-
item: true,
|
|
508
|
-
xs: true
|
|
509
|
-
}, children), /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
510
|
-
item: true
|
|
511
|
-
}, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
512
|
-
iconType: "default",
|
|
513
|
-
style: btnStyle,
|
|
514
|
-
disabled: disabled || readonly,
|
|
515
|
-
onClick: onDropPropertyClick(label),
|
|
516
|
-
uiSchema: uiSchema
|
|
517
|
-
})));
|
|
518
|
-
};
|
|
519
|
-
|
|
520
|
-
const FieldTemplate = _ref => {
|
|
521
|
-
let {
|
|
522
|
-
id,
|
|
523
|
-
children,
|
|
524
|
-
classNames,
|
|
525
|
-
disabled,
|
|
526
|
-
displayLabel,
|
|
527
|
-
hidden,
|
|
528
|
-
label,
|
|
529
|
-
onDropPropertyClick,
|
|
530
|
-
onKeyChange,
|
|
531
|
-
readonly,
|
|
532
|
-
required,
|
|
533
|
-
rawErrors = [],
|
|
534
|
-
errors,
|
|
535
|
-
help,
|
|
536
|
-
rawDescription,
|
|
537
|
-
schema,
|
|
538
|
-
uiSchema,
|
|
539
|
-
registry
|
|
540
|
-
} = _ref;
|
|
541
|
-
|
|
452
|
+
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
453
|
+
* content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
|
|
454
|
+
*
|
|
455
|
+
* @param props - The `FieldTemplateProps` for this component
|
|
456
|
+
*/
|
|
457
|
+
function FieldTemplate(props) {
|
|
458
|
+
var id = props.id,
|
|
459
|
+
children = props.children,
|
|
460
|
+
classNames = props.classNames,
|
|
461
|
+
style = props.style,
|
|
462
|
+
disabled = props.disabled,
|
|
463
|
+
displayLabel = props.displayLabel,
|
|
464
|
+
hidden = props.hidden,
|
|
465
|
+
label = props.label,
|
|
466
|
+
onDropPropertyClick = props.onDropPropertyClick,
|
|
467
|
+
onKeyChange = props.onKeyChange,
|
|
468
|
+
readonly = props.readonly,
|
|
469
|
+
required = props.required,
|
|
470
|
+
_props$rawErrors = props.rawErrors,
|
|
471
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
472
|
+
errors = props.errors,
|
|
473
|
+
help = props.help,
|
|
474
|
+
rawDescription = props.rawDescription,
|
|
475
|
+
schema = props.schema,
|
|
476
|
+
uiSchema = props.uiSchema,
|
|
477
|
+
registry = props.registry;
|
|
478
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
479
|
+
var WrapIfAdditionalTemplate = utils.getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
|
|
542
480
|
if (hidden) {
|
|
543
481
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
544
482
|
style: {
|
|
@@ -546,9 +484,9 @@ const FieldTemplate = _ref => {
|
|
|
546
484
|
}
|
|
547
485
|
}, children);
|
|
548
486
|
}
|
|
549
|
-
|
|
550
|
-
return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditional, {
|
|
487
|
+
return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditionalTemplate, {
|
|
551
488
|
classNames: classNames,
|
|
489
|
+
style: style,
|
|
552
490
|
disabled: disabled,
|
|
553
491
|
id: id,
|
|
554
492
|
label: label,
|
|
@@ -567,41 +505,44 @@ const FieldTemplate = _ref => {
|
|
|
567
505
|
variant: "caption",
|
|
568
506
|
color: "textSecondary"
|
|
569
507
|
}, rawDescription) : null, errors, help));
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
const ObjectFieldTemplate = _ref => {
|
|
573
|
-
let {
|
|
574
|
-
description,
|
|
575
|
-
title,
|
|
576
|
-
properties,
|
|
577
|
-
required,
|
|
578
|
-
disabled,
|
|
579
|
-
readonly,
|
|
580
|
-
uiSchema,
|
|
581
|
-
idSchema,
|
|
582
|
-
schema,
|
|
583
|
-
formData,
|
|
584
|
-
onAddClick,
|
|
585
|
-
registry
|
|
586
|
-
} = _ref;
|
|
587
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
588
|
-
const TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
|
|
589
|
-
const DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions); // Button templates are not overridden in the uiSchema
|
|
508
|
+
}
|
|
590
509
|
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
510
|
+
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
511
|
+
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
512
|
+
* the properties.
|
|
513
|
+
*
|
|
514
|
+
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
515
|
+
*/
|
|
516
|
+
function ObjectFieldTemplate(props) {
|
|
517
|
+
var description = props.description,
|
|
518
|
+
title = props.title,
|
|
519
|
+
properties = props.properties,
|
|
520
|
+
required = props.required,
|
|
521
|
+
disabled = props.disabled,
|
|
522
|
+
readonly = props.readonly,
|
|
523
|
+
uiSchema = props.uiSchema,
|
|
524
|
+
idSchema = props.idSchema,
|
|
525
|
+
schema = props.schema,
|
|
526
|
+
formData = props.formData,
|
|
527
|
+
onAddClick = props.onAddClick,
|
|
528
|
+
registry = props.registry;
|
|
529
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
530
|
+
var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
|
|
531
|
+
var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
|
|
532
|
+
// Button templates are not overridden in the uiSchema
|
|
533
|
+
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
596
534
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, (uiOptions.title || title) && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
597
|
-
id: idSchema
|
|
535
|
+
id: utils.titleId(idSchema),
|
|
598
536
|
title: title,
|
|
599
537
|
required: required,
|
|
538
|
+
schema: schema,
|
|
600
539
|
uiSchema: uiSchema,
|
|
601
540
|
registry: registry
|
|
602
541
|
}), (uiOptions.description || description) && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
603
|
-
id: idSchema
|
|
542
|
+
id: utils.descriptionId(idSchema),
|
|
604
543
|
description: uiOptions.description || description,
|
|
544
|
+
schema: schema,
|
|
545
|
+
uiSchema: uiSchema,
|
|
605
546
|
registry: registry
|
|
606
547
|
}), /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
607
548
|
container: true,
|
|
@@ -609,16 +550,20 @@ const ObjectFieldTemplate = _ref => {
|
|
|
609
550
|
style: {
|
|
610
551
|
marginTop: "10px"
|
|
611
552
|
}
|
|
612
|
-
}, properties.map((element, index)
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
553
|
+
}, properties.map(function (element, index) {
|
|
554
|
+
return (
|
|
555
|
+
// Remove the <Grid> if the inner element is hidden as the <Grid>
|
|
556
|
+
// itself would otherwise still take up space.
|
|
557
|
+
element.hidden ? element.content : /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
558
|
+
item: true,
|
|
559
|
+
xs: 12,
|
|
560
|
+
key: index,
|
|
561
|
+
style: {
|
|
562
|
+
marginBottom: "10px"
|
|
563
|
+
}
|
|
564
|
+
}, element.content)
|
|
565
|
+
);
|
|
566
|
+
}), utils.canExpand(schema, uiSchema, formData) && /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
622
567
|
container: true,
|
|
623
568
|
justifyContent: "flex-end"
|
|
624
569
|
}, /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
@@ -627,36 +572,39 @@ const ObjectFieldTemplate = _ref => {
|
|
|
627
572
|
className: "object-property-expand",
|
|
628
573
|
onClick: onAddClick(schema),
|
|
629
574
|
disabled: disabled || readonly,
|
|
630
|
-
uiSchema: uiSchema
|
|
575
|
+
uiSchema: uiSchema,
|
|
576
|
+
registry: registry
|
|
631
577
|
})))));
|
|
632
|
-
}
|
|
633
|
-
|
|
634
|
-
const SubmitButton = props => {
|
|
635
|
-
const {
|
|
636
|
-
submitText,
|
|
637
|
-
norender,
|
|
638
|
-
props: submitButtonProps
|
|
639
|
-
} = utils.getSubmitButtonOptions(props.uiSchema);
|
|
578
|
+
}
|
|
640
579
|
|
|
580
|
+
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
581
|
+
*/
|
|
582
|
+
function SubmitButton(_ref) {
|
|
583
|
+
var uiSchema = _ref.uiSchema;
|
|
584
|
+
var _getSubmitButtonOptio = utils.getSubmitButtonOptions(uiSchema),
|
|
585
|
+
submitText = _getSubmitButtonOptio.submitText,
|
|
586
|
+
norender = _getSubmitButtonOptio.norender,
|
|
587
|
+
_getSubmitButtonOptio2 = _getSubmitButtonOptio.props,
|
|
588
|
+
submitButtonProps = _getSubmitButtonOptio2 === void 0 ? {} : _getSubmitButtonOptio2;
|
|
641
589
|
if (norender) {
|
|
642
590
|
return null;
|
|
643
591
|
}
|
|
644
|
-
|
|
645
592
|
return /*#__PURE__*/React__default["default"].createElement(Box__default["default"], {
|
|
646
593
|
marginTop: 3
|
|
647
|
-
}, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
|
|
594
|
+
}, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], _extends({
|
|
648
595
|
type: "submit",
|
|
649
596
|
variant: "contained",
|
|
650
|
-
color: "primary"
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
};
|
|
597
|
+
color: "primary"
|
|
598
|
+
}, submitButtonProps), submitText));
|
|
599
|
+
}
|
|
654
600
|
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
601
|
+
/** The `TitleField` is the template to use to render the title of a field
|
|
602
|
+
*
|
|
603
|
+
* @param props - The `TitleFieldProps` for this component
|
|
604
|
+
*/
|
|
605
|
+
function TitleField(_ref) {
|
|
606
|
+
var id = _ref.id,
|
|
607
|
+
title = _ref.title;
|
|
660
608
|
return /*#__PURE__*/React__default["default"].createElement(Box__default["default"], {
|
|
661
609
|
id: id,
|
|
662
610
|
mb: 1,
|
|
@@ -664,169 +612,214 @@ const TitleField = _ref => {
|
|
|
664
612
|
}, /*#__PURE__*/React__default["default"].createElement(Typography__default["default"], {
|
|
665
613
|
variant: "h5"
|
|
666
614
|
}, title), /*#__PURE__*/React__default["default"].createElement(Divider__default["default"], null));
|
|
667
|
-
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
618
|
+
* part of an `additionalProperties` part of a schema.
|
|
619
|
+
*
|
|
620
|
+
* @param props - The `WrapIfAdditionalProps` for this component
|
|
621
|
+
*/
|
|
622
|
+
function WrapIfAdditionalTemplate(props) {
|
|
623
|
+
var children = props.children,
|
|
624
|
+
classNames = props.classNames,
|
|
625
|
+
style = props.style,
|
|
626
|
+
disabled = props.disabled,
|
|
627
|
+
id = props.id,
|
|
628
|
+
label = props.label,
|
|
629
|
+
onDropPropertyClick = props.onDropPropertyClick,
|
|
630
|
+
onKeyChange = props.onKeyChange,
|
|
631
|
+
readonly = props.readonly,
|
|
632
|
+
required = props.required,
|
|
633
|
+
schema = props.schema,
|
|
634
|
+
uiSchema = props.uiSchema,
|
|
635
|
+
registry = props.registry;
|
|
636
|
+
// Button templates are not overridden in the uiSchema
|
|
637
|
+
var RemoveButton = registry.templates.ButtonTemplates.RemoveButton;
|
|
638
|
+
var keyLabel = label + " Key"; // i18n ?
|
|
639
|
+
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
640
|
+
var btnStyle = {
|
|
641
|
+
flex: 1,
|
|
642
|
+
paddingLeft: 6,
|
|
643
|
+
paddingRight: 6,
|
|
644
|
+
fontWeight: "bold"
|
|
645
|
+
};
|
|
646
|
+
if (!additional) {
|
|
647
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
648
|
+
className: classNames,
|
|
649
|
+
style: style
|
|
650
|
+
}, children);
|
|
651
|
+
}
|
|
652
|
+
var handleBlur = function handleBlur(_ref) {
|
|
653
|
+
var target = _ref.target;
|
|
654
|
+
return onKeyChange(target.value);
|
|
655
|
+
};
|
|
656
|
+
return /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
657
|
+
container: true,
|
|
658
|
+
key: id + "-key",
|
|
659
|
+
alignItems: "center",
|
|
660
|
+
spacing: 2,
|
|
661
|
+
className: classNames,
|
|
662
|
+
style: style
|
|
663
|
+
}, /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
664
|
+
item: true,
|
|
665
|
+
xs: true
|
|
666
|
+
}, /*#__PURE__*/React__default["default"].createElement(FormControl__default["default"], {
|
|
667
|
+
fullWidth: true,
|
|
668
|
+
required: required
|
|
669
|
+
}, /*#__PURE__*/React__default["default"].createElement(InputLabel__default["default"], null, keyLabel), /*#__PURE__*/React__default["default"].createElement(Input__default["default"], {
|
|
670
|
+
defaultValue: label,
|
|
671
|
+
disabled: disabled || readonly,
|
|
672
|
+
id: id + "-key",
|
|
673
|
+
name: id + "-key",
|
|
674
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
675
|
+
type: "text"
|
|
676
|
+
}))), /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
677
|
+
item: true,
|
|
678
|
+
xs: true
|
|
679
|
+
}, children), /*#__PURE__*/React__default["default"].createElement(Grid__default["default"], {
|
|
680
|
+
item: true
|
|
681
|
+
}, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
682
|
+
iconType: "default",
|
|
683
|
+
style: btnStyle,
|
|
684
|
+
disabled: disabled || readonly,
|
|
685
|
+
onClick: onDropPropertyClick(label),
|
|
686
|
+
uiSchema: uiSchema,
|
|
687
|
+
registry: registry
|
|
688
|
+
})));
|
|
689
|
+
}
|
|
668
690
|
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
691
|
+
function generateTemplates() {
|
|
692
|
+
return {
|
|
693
|
+
ArrayFieldItemTemplate: ArrayFieldItemTemplate,
|
|
694
|
+
ArrayFieldTemplate: ArrayFieldTemplate,
|
|
695
|
+
BaseInputTemplate: BaseInputTemplate,
|
|
696
|
+
ButtonTemplates: {
|
|
697
|
+
AddButton: AddButton,
|
|
698
|
+
MoveDownButton: MoveDownButton,
|
|
699
|
+
MoveUpButton: MoveUpButton,
|
|
700
|
+
RemoveButton: RemoveButton,
|
|
701
|
+
SubmitButton: SubmitButton
|
|
702
|
+
},
|
|
703
|
+
DescriptionFieldTemplate: DescriptionField,
|
|
704
|
+
ErrorListTemplate: ErrorList,
|
|
705
|
+
FieldErrorTemplate: FieldErrorTemplate,
|
|
706
|
+
FieldHelpTemplate: FieldHelpTemplate,
|
|
707
|
+
FieldTemplate: FieldTemplate,
|
|
708
|
+
ObjectFieldTemplate: ObjectFieldTemplate,
|
|
709
|
+
TitleFieldTemplate: TitleField,
|
|
710
|
+
WrapIfAdditionalTemplate: WrapIfAdditionalTemplate
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
var Templates = /*#__PURE__*/generateTemplates();
|
|
688
714
|
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
715
|
+
/** The `CheckBoxWidget` is a widget for rendering boolean properties.
|
|
716
|
+
* It is typically used to represent a boolean.
|
|
717
|
+
*
|
|
718
|
+
* @param props - The `WidgetProps` for this component
|
|
719
|
+
*/
|
|
720
|
+
function CheckboxWidget(props) {
|
|
721
|
+
var schema = props.schema,
|
|
722
|
+
id = props.id,
|
|
723
|
+
value = props.value,
|
|
724
|
+
disabled = props.disabled,
|
|
725
|
+
readonly = props.readonly,
|
|
726
|
+
label = props.label,
|
|
727
|
+
autofocus = props.autofocus,
|
|
728
|
+
onChange = props.onChange,
|
|
729
|
+
onBlur = props.onBlur,
|
|
730
|
+
onFocus = props.onFocus;
|
|
731
|
+
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
702
732
|
// the "required" attribute if the field value must be "true", due to the
|
|
703
733
|
// "const" or "enum" keywords
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
let {
|
|
711
|
-
target: {
|
|
712
|
-
value
|
|
713
|
-
}
|
|
714
|
-
} = _ref;
|
|
734
|
+
var required = utils.schemaRequiresTrueValue(schema);
|
|
735
|
+
var _onChange = function _onChange(_, checked) {
|
|
736
|
+
return onChange(checked);
|
|
737
|
+
};
|
|
738
|
+
var _onBlur = function _onBlur(_ref) {
|
|
739
|
+
var value = _ref.target.value;
|
|
715
740
|
return onBlur(id, value);
|
|
716
741
|
};
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
let {
|
|
720
|
-
target: {
|
|
721
|
-
value
|
|
722
|
-
}
|
|
723
|
-
} = _ref2;
|
|
742
|
+
var _onFocus = function _onFocus(_ref2) {
|
|
743
|
+
var value = _ref2.target.value;
|
|
724
744
|
return onFocus(id, value);
|
|
725
745
|
};
|
|
726
|
-
|
|
727
746
|
return /*#__PURE__*/React__default["default"].createElement(FormControlLabel__default["default"], {
|
|
728
747
|
control: /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"], {
|
|
729
748
|
id: id,
|
|
749
|
+
name: id,
|
|
730
750
|
checked: typeof value === "undefined" ? false : Boolean(value),
|
|
731
751
|
required: required,
|
|
732
752
|
disabled: disabled || readonly,
|
|
733
753
|
autoFocus: autofocus,
|
|
734
754
|
onChange: _onChange,
|
|
735
755
|
onBlur: _onBlur,
|
|
736
|
-
onFocus: _onFocus
|
|
756
|
+
onFocus: _onFocus,
|
|
757
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
737
758
|
}),
|
|
738
759
|
label: label || ""
|
|
739
760
|
});
|
|
740
|
-
}
|
|
741
|
-
|
|
742
|
-
const selectValue = (value, selected, all) => {
|
|
743
|
-
const at = all.indexOf(value);
|
|
744
|
-
const updated = selected.slice(0, at).concat(value, selected.slice(at)); // As inserting values at predefined index positions doesn't work with empty
|
|
745
|
-
// arrays, we need to reorder the updated selection to match the initial order
|
|
746
|
-
|
|
747
|
-
return updated.sort((a, b) => all.indexOf(a) > all.indexOf(b));
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
const deselectValue = (value, selected) => {
|
|
751
|
-
return selected.filter(v => v !== value);
|
|
752
|
-
};
|
|
753
|
-
|
|
754
|
-
const CheckboxesWidget = _ref => {
|
|
755
|
-
let {
|
|
756
|
-
schema,
|
|
757
|
-
label,
|
|
758
|
-
id,
|
|
759
|
-
disabled,
|
|
760
|
-
options,
|
|
761
|
-
value,
|
|
762
|
-
autofocus,
|
|
763
|
-
readonly,
|
|
764
|
-
required,
|
|
765
|
-
onChange,
|
|
766
|
-
onBlur,
|
|
767
|
-
onFocus
|
|
768
|
-
} = _ref;
|
|
769
|
-
const {
|
|
770
|
-
enumOptions,
|
|
771
|
-
enumDisabled,
|
|
772
|
-
inline
|
|
773
|
-
} = options;
|
|
761
|
+
}
|
|
774
762
|
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
763
|
+
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
764
|
+
* It is typically used to represent an array of enums.
|
|
765
|
+
*
|
|
766
|
+
* @param props - The `WidgetProps` for this component
|
|
767
|
+
*/
|
|
768
|
+
function CheckboxesWidget(_ref) {
|
|
769
|
+
var schema = _ref.schema,
|
|
770
|
+
label = _ref.label,
|
|
771
|
+
id = _ref.id,
|
|
772
|
+
disabled = _ref.disabled,
|
|
773
|
+
options = _ref.options,
|
|
774
|
+
value = _ref.value,
|
|
775
|
+
autofocus = _ref.autofocus,
|
|
776
|
+
readonly = _ref.readonly,
|
|
777
|
+
required = _ref.required,
|
|
778
|
+
onChange = _ref.onChange,
|
|
779
|
+
onBlur = _ref.onBlur,
|
|
780
|
+
onFocus = _ref.onFocus;
|
|
781
|
+
var enumOptions = options.enumOptions,
|
|
782
|
+
enumDisabled = options.enumDisabled,
|
|
783
|
+
inline = options.inline,
|
|
784
|
+
emptyValue = options.emptyValue;
|
|
785
|
+
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
786
|
+
var _onChange = function _onChange(index) {
|
|
787
|
+
return function (_ref2) {
|
|
788
|
+
var checked = _ref2.target.checked;
|
|
789
|
+
if (checked) {
|
|
790
|
+
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
791
|
+
} else {
|
|
792
|
+
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
779
793
|
}
|
|
780
|
-
}
|
|
781
|
-
const all = enumOptions.map(_ref3 => {
|
|
782
|
-
let {
|
|
783
|
-
value
|
|
784
|
-
} = _ref3;
|
|
785
|
-
return value;
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
if (checked) {
|
|
789
|
-
onChange(selectValue(option.value, value, all));
|
|
790
|
-
} else {
|
|
791
|
-
onChange(deselectValue(option.value, value));
|
|
792
|
-
}
|
|
794
|
+
};
|
|
793
795
|
};
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
target: {
|
|
798
|
-
value
|
|
799
|
-
}
|
|
800
|
-
} = _ref4;
|
|
801
|
-
return onBlur(id, value);
|
|
796
|
+
var _onBlur = function _onBlur(_ref3) {
|
|
797
|
+
var value = _ref3.target.value;
|
|
798
|
+
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
802
799
|
};
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
target: {
|
|
807
|
-
value
|
|
808
|
-
}
|
|
809
|
-
} = _ref5;
|
|
810
|
-
return onFocus(id, value);
|
|
800
|
+
var _onFocus = function _onFocus(_ref4) {
|
|
801
|
+
var value = _ref4.target.value;
|
|
802
|
+
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
811
803
|
};
|
|
812
|
-
|
|
813
804
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(FormLabel__default["default"], {
|
|
814
805
|
required: required,
|
|
815
806
|
htmlFor: id
|
|
816
807
|
}, label || schema.title), /*#__PURE__*/React__default["default"].createElement(FormGroup__default["default"], {
|
|
817
808
|
id: id,
|
|
818
809
|
row: !!inline
|
|
819
|
-
}, enumOptions.map((option, index)
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
id: id
|
|
810
|
+
}, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
811
|
+
var checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
812
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
813
|
+
var checkbox = /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"], {
|
|
814
|
+
id: utils.optionId(id, index),
|
|
815
|
+
name: id,
|
|
824
816
|
checked: checked,
|
|
825
817
|
disabled: disabled || itemDisabled || readonly,
|
|
826
818
|
autoFocus: autofocus && index === 0,
|
|
827
|
-
onChange: _onChange(
|
|
819
|
+
onChange: _onChange(index),
|
|
828
820
|
onBlur: _onBlur,
|
|
829
|
-
onFocus: _onFocus
|
|
821
|
+
onFocus: _onFocus,
|
|
822
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
830
823
|
});
|
|
831
824
|
return /*#__PURE__*/React__default["default"].createElement(FormControlLabel__default["default"], {
|
|
832
825
|
control: checkbox,
|
|
@@ -834,290 +827,289 @@ const CheckboxesWidget = _ref => {
|
|
|
834
827
|
label: option.label
|
|
835
828
|
});
|
|
836
829
|
})));
|
|
837
|
-
}
|
|
830
|
+
}
|
|
838
831
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
832
|
+
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
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({
|
|
846
842
|
type: "date",
|
|
847
843
|
InputLabelProps: {
|
|
848
844
|
shrink: true
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
};
|
|
853
|
-
|
|
854
|
-
const DateTimeWidget = props => {
|
|
855
|
-
const {
|
|
856
|
-
options,
|
|
857
|
-
registry
|
|
858
|
-
} = props;
|
|
859
|
-
const BaseInputTemplate = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
860
|
-
const value = utils.utcToLocal(props.value);
|
|
845
|
+
}
|
|
846
|
+
}, props));
|
|
847
|
+
}
|
|
861
848
|
|
|
862
|
-
|
|
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) {
|
|
863
860
|
props.onChange(utils.localToUTC(value));
|
|
864
861
|
};
|
|
865
|
-
|
|
866
|
-
return /*#__PURE__*/React__default["default"].createElement(BaseInputTemplate, {
|
|
862
|
+
return /*#__PURE__*/React__default["default"].createElement(BaseInputTemplate, _extends({
|
|
867
863
|
type: "datetime-local",
|
|
868
864
|
InputLabelProps: {
|
|
869
865
|
shrink: true
|
|
870
|
-
}
|
|
871
|
-
|
|
866
|
+
}
|
|
867
|
+
}, props, {
|
|
872
868
|
value: value,
|
|
873
869
|
onChange: onChange
|
|
874
|
-
});
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
const RadioWidget = _ref => {
|
|
878
|
-
let {
|
|
879
|
-
id,
|
|
880
|
-
schema,
|
|
881
|
-
options,
|
|
882
|
-
value,
|
|
883
|
-
required,
|
|
884
|
-
disabled,
|
|
885
|
-
readonly,
|
|
886
|
-
label,
|
|
887
|
-
onChange,
|
|
888
|
-
onBlur,
|
|
889
|
-
onFocus
|
|
890
|
-
} = _ref;
|
|
891
|
-
const {
|
|
892
|
-
enumOptions,
|
|
893
|
-
enumDisabled
|
|
894
|
-
} = options;
|
|
895
|
-
|
|
896
|
-
const _onChange = (_, value) => onChange(schema.type == "boolean" ? value !== "false" : value);
|
|
870
|
+
}));
|
|
871
|
+
}
|
|
897
872
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
873
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
874
|
+
* It is typically used with a string property constrained with enum options.
|
|
875
|
+
*
|
|
876
|
+
* @param props - The `WidgetProps` for this component
|
|
877
|
+
*/
|
|
878
|
+
function RadioWidget(_ref) {
|
|
879
|
+
var id = _ref.id,
|
|
880
|
+
schema = _ref.schema,
|
|
881
|
+
options = _ref.options,
|
|
882
|
+
value = _ref.value,
|
|
883
|
+
required = _ref.required,
|
|
884
|
+
disabled = _ref.disabled,
|
|
885
|
+
readonly = _ref.readonly,
|
|
886
|
+
label = _ref.label,
|
|
887
|
+
onChange = _ref.onChange,
|
|
888
|
+
onBlur = _ref.onBlur,
|
|
889
|
+
onFocus = _ref.onFocus;
|
|
890
|
+
var enumOptions = options.enumOptions,
|
|
891
|
+
enumDisabled = options.enumDisabled,
|
|
892
|
+
emptyValue = options.emptyValue;
|
|
893
|
+
var _onChange = function _onChange(_, value) {
|
|
894
|
+
return onChange(utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
905
895
|
};
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
target: {
|
|
910
|
-
value
|
|
911
|
-
}
|
|
912
|
-
} = _ref3;
|
|
913
|
-
return onFocus(id, value);
|
|
896
|
+
var _onBlur = function _onBlur(_ref2) {
|
|
897
|
+
var value = _ref2.target.value;
|
|
898
|
+
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
914
899
|
};
|
|
915
|
-
|
|
916
|
-
|
|
900
|
+
var _onFocus = function _onFocus(_ref3) {
|
|
901
|
+
var value = _ref3.target.value;
|
|
902
|
+
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
903
|
+
};
|
|
904
|
+
var row = options ? options.inline : false;
|
|
905
|
+
var selectedIndex = utils.enumOptionsIndexForValue(value, enumOptions);
|
|
917
906
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(FormLabel__default["default"], {
|
|
918
907
|
required: required,
|
|
919
908
|
htmlFor: id
|
|
920
909
|
}, label || schema.title), /*#__PURE__*/React__default["default"].createElement(RadioGroup__default["default"], {
|
|
921
910
|
id: id,
|
|
922
|
-
|
|
911
|
+
name: id,
|
|
912
|
+
value: selectedIndex,
|
|
923
913
|
row: row,
|
|
924
914
|
onChange: _onChange,
|
|
925
915
|
onBlur: _onBlur,
|
|
926
|
-
onFocus: _onFocus
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
916
|
+
onFocus: _onFocus,
|
|
917
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
918
|
+
}, Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
919
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
920
|
+
var radio = /*#__PURE__*/React__default["default"].createElement(FormControlLabel__default["default"], {
|
|
930
921
|
control: /*#__PURE__*/React__default["default"].createElement(Radio__default["default"], {
|
|
931
|
-
name: id
|
|
932
|
-
|
|
933
|
-
|
|
922
|
+
name: id,
|
|
923
|
+
id: utils.optionId(id, index),
|
|
924
|
+
color: "primary"
|
|
934
925
|
}),
|
|
935
|
-
label:
|
|
936
|
-
value:
|
|
937
|
-
key:
|
|
926
|
+
label: option.label,
|
|
927
|
+
value: String(index),
|
|
928
|
+
key: index,
|
|
938
929
|
disabled: disabled || itemDisabled || readonly
|
|
939
930
|
});
|
|
940
931
|
return radio;
|
|
941
932
|
})));
|
|
942
|
-
}
|
|
943
|
-
|
|
944
|
-
const RangeWidget = _ref => {
|
|
945
|
-
let {
|
|
946
|
-
value,
|
|
947
|
-
readonly,
|
|
948
|
-
disabled,
|
|
949
|
-
onBlur,
|
|
950
|
-
onFocus,
|
|
951
|
-
options,
|
|
952
|
-
schema,
|
|
953
|
-
onChange,
|
|
954
|
-
required,
|
|
955
|
-
label,
|
|
956
|
-
id
|
|
957
|
-
} = _ref;
|
|
958
|
-
const sliderProps = {
|
|
959
|
-
value,
|
|
960
|
-
label,
|
|
961
|
-
id,
|
|
962
|
-
...utils.rangeSpec(schema)
|
|
963
|
-
};
|
|
933
|
+
}
|
|
964
934
|
|
|
965
|
-
|
|
966
|
-
|
|
935
|
+
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
936
|
+
* in a div, with the value along side it.
|
|
937
|
+
*
|
|
938
|
+
* @param props - The `WidgetProps` for this component
|
|
939
|
+
*/
|
|
940
|
+
function RangeWidget(props) {
|
|
941
|
+
var value = props.value,
|
|
942
|
+
readonly = props.readonly,
|
|
943
|
+
disabled = props.disabled,
|
|
944
|
+
onBlur = props.onBlur,
|
|
945
|
+
onFocus = props.onFocus,
|
|
946
|
+
options = props.options,
|
|
947
|
+
schema = props.schema,
|
|
948
|
+
onChange = props.onChange,
|
|
949
|
+
required = props.required,
|
|
950
|
+
label = props.label,
|
|
951
|
+
id = props.id;
|
|
952
|
+
var sliderProps = _extends({
|
|
953
|
+
value: value,
|
|
954
|
+
label: label,
|
|
955
|
+
id: id,
|
|
956
|
+
name: id
|
|
957
|
+
}, utils.rangeSpec(schema));
|
|
958
|
+
var _onChange = function _onChange(_, value) {
|
|
959
|
+
onChange(value ? value : options.emptyValue);
|
|
967
960
|
};
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
let {
|
|
971
|
-
target: {
|
|
972
|
-
value
|
|
973
|
-
}
|
|
974
|
-
} = _ref2;
|
|
961
|
+
var _onBlur = function _onBlur(_ref) {
|
|
962
|
+
var value = _ref.target.value;
|
|
975
963
|
return onBlur(id, value);
|
|
976
964
|
};
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
let {
|
|
980
|
-
target: {
|
|
981
|
-
value
|
|
982
|
-
}
|
|
983
|
-
} = _ref3;
|
|
965
|
+
var _onFocus = function _onFocus(_ref2) {
|
|
966
|
+
var value = _ref2.target.value;
|
|
984
967
|
return onFocus(id, value);
|
|
985
968
|
};
|
|
986
|
-
|
|
987
969
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(FormLabel__default["default"], {
|
|
988
970
|
required: required,
|
|
989
|
-
|
|
990
|
-
}, label), /*#__PURE__*/React__default["default"].createElement(Slider__default["default"], {
|
|
971
|
+
htmlFor: id
|
|
972
|
+
}, label || schema.title), /*#__PURE__*/React__default["default"].createElement(Slider__default["default"], _extends({
|
|
991
973
|
disabled: disabled || readonly,
|
|
992
974
|
onChange: _onChange,
|
|
993
975
|
onBlur: _onBlur,
|
|
994
976
|
onFocus: _onFocus,
|
|
995
|
-
valueLabelDisplay: "auto"
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
};
|
|
999
|
-
|
|
1000
|
-
const SelectWidget = _ref => {
|
|
1001
|
-
let {
|
|
1002
|
-
schema,
|
|
1003
|
-
id,
|
|
1004
|
-
options,
|
|
1005
|
-
label,
|
|
1006
|
-
required,
|
|
1007
|
-
disabled,
|
|
1008
|
-
readonly,
|
|
1009
|
-
value,
|
|
1010
|
-
multiple,
|
|
1011
|
-
autofocus,
|
|
1012
|
-
onChange,
|
|
1013
|
-
onBlur,
|
|
1014
|
-
onFocus,
|
|
1015
|
-
rawErrors = []
|
|
1016
|
-
} = _ref;
|
|
1017
|
-
const {
|
|
1018
|
-
enumOptions,
|
|
1019
|
-
enumDisabled
|
|
1020
|
-
} = options;
|
|
1021
|
-
const emptyValue = multiple ? [] : "";
|
|
977
|
+
valueLabelDisplay: "auto"
|
|
978
|
+
}, sliderProps, {
|
|
979
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
980
|
+
})));
|
|
981
|
+
}
|
|
1022
982
|
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
983
|
+
var _excluded = ["schema", "id", "options", "label", "required", "disabled", "placeholder", "readonly", "value", "multiple", "autofocus", "onChange", "onBlur", "onFocus", "rawErrors", "registry", "uiSchema", "hideError", "formContext"];
|
|
984
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
985
|
+
* It is typically used with string properties constrained with enum options.
|
|
986
|
+
*
|
|
987
|
+
* @param props - The `WidgetProps` for this component
|
|
988
|
+
*/
|
|
989
|
+
function SelectWidget(_ref) {
|
|
990
|
+
var schema = _ref.schema,
|
|
991
|
+
id = _ref.id,
|
|
992
|
+
options = _ref.options,
|
|
993
|
+
label = _ref.label,
|
|
994
|
+
required = _ref.required,
|
|
995
|
+
disabled = _ref.disabled,
|
|
996
|
+
placeholder = _ref.placeholder,
|
|
997
|
+
readonly = _ref.readonly,
|
|
998
|
+
value = _ref.value,
|
|
999
|
+
multiple = _ref.multiple,
|
|
1000
|
+
autofocus = _ref.autofocus,
|
|
1001
|
+
onChange = _ref.onChange,
|
|
1002
|
+
onBlur = _ref.onBlur,
|
|
1003
|
+
onFocus = _ref.onFocus,
|
|
1004
|
+
_ref$rawErrors = _ref.rawErrors,
|
|
1005
|
+
rawErrors = _ref$rawErrors === void 0 ? [] : _ref$rawErrors,
|
|
1006
|
+
textFieldProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1007
|
+
var enumOptions = options.enumOptions,
|
|
1008
|
+
enumDisabled = options.enumDisabled,
|
|
1009
|
+
optEmptyVal = options.emptyValue;
|
|
1010
|
+
multiple = typeof multiple === "undefined" ? false : !!multiple;
|
|
1011
|
+
var emptyValue = multiple ? [] : "";
|
|
1012
|
+
var isEmpty = typeof value === "undefined" || multiple && value.length < 1 || !multiple && value === emptyValue;
|
|
1013
|
+
var _onChange = function _onChange(_ref2) {
|
|
1014
|
+
var value = _ref2.target.value;
|
|
1015
|
+
return onChange(utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1030
1016
|
};
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
target: {
|
|
1035
|
-
value
|
|
1036
|
-
}
|
|
1037
|
-
} = _ref3;
|
|
1038
|
-
return onBlur(id, utils.processSelectValue(schema, value, options));
|
|
1017
|
+
var _onBlur = function _onBlur(_ref3) {
|
|
1018
|
+
var value = _ref3.target.value;
|
|
1019
|
+
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1039
1020
|
};
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
target: {
|
|
1044
|
-
value
|
|
1045
|
-
}
|
|
1046
|
-
} = _ref4;
|
|
1047
|
-
return onFocus(id, utils.processSelectValue(schema, value, options));
|
|
1021
|
+
var _onFocus = function _onFocus(_ref4) {
|
|
1022
|
+
var value = _ref4.target.value;
|
|
1023
|
+
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1048
1024
|
};
|
|
1049
|
-
|
|
1050
|
-
return /*#__PURE__*/React__default["default"].createElement(TextField__default["default"], {
|
|
1025
|
+
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1026
|
+
return /*#__PURE__*/React__default["default"].createElement(TextField__default["default"], _extends({
|
|
1051
1027
|
id: id,
|
|
1028
|
+
name: id,
|
|
1052
1029
|
label: label || schema.title,
|
|
1053
|
-
|
|
1054
|
-
value: typeof value === "undefined" ? emptyValue : value,
|
|
1030
|
+
value: isEmpty ? emptyValue : selectedIndexes,
|
|
1055
1031
|
required: required,
|
|
1056
1032
|
disabled: disabled || readonly,
|
|
1057
1033
|
autoFocus: autofocus,
|
|
1034
|
+
placeholder: placeholder,
|
|
1058
1035
|
error: rawErrors.length > 0,
|
|
1059
1036
|
onChange: _onChange,
|
|
1060
1037
|
onBlur: _onBlur,
|
|
1061
|
-
onFocus: _onFocus
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1038
|
+
onFocus: _onFocus
|
|
1039
|
+
}, textFieldProps, {
|
|
1040
|
+
select // Apply this and the following props after the potential overrides defined in textFieldProps
|
|
1041
|
+
: true,
|
|
1042
|
+
InputLabelProps: _extends({}, textFieldProps.InputLabelProps, {
|
|
1043
|
+
shrink: !isEmpty
|
|
1044
|
+
}),
|
|
1045
|
+
SelectProps: _extends({}, textFieldProps.SelectProps, {
|
|
1046
|
+
multiple: multiple
|
|
1047
|
+
}),
|
|
1048
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1049
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (_ref5, i) {
|
|
1050
|
+
var value = _ref5.value,
|
|
1051
|
+
label = _ref5.label;
|
|
1052
|
+
var disabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1;
|
|
1074
1053
|
return /*#__PURE__*/React__default["default"].createElement(MenuItem__default["default"], {
|
|
1075
1054
|
key: i,
|
|
1076
|
-
value:
|
|
1055
|
+
value: String(i),
|
|
1077
1056
|
disabled: disabled
|
|
1078
1057
|
}, label);
|
|
1079
1058
|
}));
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
const TextareaWidget = props => {
|
|
1083
|
-
const {
|
|
1084
|
-
options,
|
|
1085
|
-
registry
|
|
1086
|
-
} = props;
|
|
1087
|
-
const BaseInputTemplate = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
1088
|
-
let rows = 5;
|
|
1059
|
+
}
|
|
1089
1060
|
|
|
1061
|
+
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1062
|
+
*
|
|
1063
|
+
* @param props - The `WidgetProps` for this component
|
|
1064
|
+
*/
|
|
1065
|
+
function TextareaWidget(props) {
|
|
1066
|
+
var options = props.options,
|
|
1067
|
+
registry = props.registry;
|
|
1068
|
+
var BaseInputTemplate = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
1069
|
+
var rows = 5;
|
|
1090
1070
|
if (typeof options.rows === "string" || typeof options.rows === "number") {
|
|
1091
1071
|
rows = options.rows;
|
|
1092
1072
|
}
|
|
1093
|
-
|
|
1094
|
-
return /*#__PURE__*/React__default["default"].createElement(BaseInputTemplate, { ...props,
|
|
1073
|
+
return /*#__PURE__*/React__default["default"].createElement(BaseInputTemplate, _extends({}, props, {
|
|
1095
1074
|
multiline: true,
|
|
1096
1075
|
rows: rows
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1076
|
+
}));
|
|
1077
|
+
}
|
|
1099
1078
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1079
|
+
function generateWidgets() {
|
|
1080
|
+
return {
|
|
1081
|
+
CheckboxWidget: CheckboxWidget,
|
|
1082
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
1083
|
+
DateWidget: DateWidget,
|
|
1084
|
+
DateTimeWidget: DateTimeWidget,
|
|
1085
|
+
RadioWidget: RadioWidget,
|
|
1086
|
+
RangeWidget: RangeWidget,
|
|
1087
|
+
SelectWidget: SelectWidget,
|
|
1088
|
+
TextareaWidget: TextareaWidget
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
var Widgets = /*#__PURE__*/generateWidgets();
|
|
1110
1092
|
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1093
|
+
function generateTheme() {
|
|
1094
|
+
return {
|
|
1095
|
+
templates: generateTemplates(),
|
|
1096
|
+
widgets: generateWidgets()
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
var Theme = /*#__PURE__*/generateTheme();
|
|
1115
1100
|
|
|
1116
|
-
|
|
1101
|
+
function generateForm() {
|
|
1102
|
+
return core.withTheme(generateTheme());
|
|
1103
|
+
}
|
|
1104
|
+
var MuiForm = /*#__PURE__*/generateForm();
|
|
1117
1105
|
|
|
1118
1106
|
exports.Form = MuiForm;
|
|
1119
1107
|
exports.Templates = Templates;
|
|
1120
1108
|
exports.Theme = Theme;
|
|
1121
1109
|
exports.Widgets = Widgets;
|
|
1122
1110
|
exports["default"] = MuiForm;
|
|
1111
|
+
exports.generateForm = generateForm;
|
|
1112
|
+
exports.generateTemplates = generateTemplates;
|
|
1113
|
+
exports.generateTheme = generateTheme;
|
|
1114
|
+
exports.generateWidgets = generateWidgets;
|
|
1123
1115
|
//# sourceMappingURL=mui.cjs.development.js.map
|