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