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