@rjsf/semantic-ui 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 +17 -6
- package/dist/semantic-ui.cjs.development.js +819 -843
- package/dist/semantic-ui.cjs.development.js.map +1 -1
- package/dist/semantic-ui.cjs.production.min.js +1 -1
- package/dist/semantic-ui.cjs.production.min.js.map +1 -1
- package/dist/semantic-ui.esm.js +816 -843
- package/dist/semantic-ui.esm.js.map +1 -1
- package/dist/semantic-ui.umd.development.js +822 -845
- package/dist/semantic-ui.umd.development.js.map +1 -1
- package/dist/semantic-ui.umd.production.min.js +1 -1
- package/dist/semantic-ui.umd.production.min.js.map +1 -1
- package/package.json +24 -21
- package/dist/AddButton/AddButton.d.ts +0 -5
- package/dist/AddButton/index.d.ts +0 -2
- package/dist/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +0 -2
- package/dist/ArrayFieldItemTemplate/index.d.ts +0 -2
- package/dist/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +0 -18
- package/dist/ArrayFieldTemplate/index.d.ts +0 -2
- package/dist/BaseInputTemplate/BaseInputTemplate.d.ts +0 -2
- package/dist/BaseInputTemplate/index.d.ts +0 -2
- package/dist/CheckboxWidget/CheckboxWidget.d.ts +0 -2
- package/dist/CheckboxWidget/index.d.ts +0 -2
- package/dist/CheckboxesWidget/CheckboxesWidget.d.ts +0 -2
- package/dist/CheckboxesWidget/index.d.ts +0 -2
- package/dist/DescriptionField/DescriptionField.d.ts +0 -6
- package/dist/DescriptionField/index.d.ts +0 -2
- package/dist/ErrorList/ErrorList.d.ts +0 -26
- package/dist/ErrorList/index.d.ts +0 -2
- package/dist/FieldErrorTemplate/FieldErrorTemplate.d.ts +0 -44
- package/dist/FieldErrorTemplate/index.d.ts +0 -2
- package/dist/FieldHelpTemplate/FieldHelpTemplate.d.ts +0 -14
- package/dist/FieldHelpTemplate/index.d.ts +0 -2
- package/dist/FieldTemplate/FieldTemplate.d.ts +0 -16
- package/dist/FieldTemplate/WrapIfAdditional.d.ts +0 -16
- package/dist/FieldTemplate/index.d.ts +0 -2
- package/dist/IconButton/IconButton.d.ts +0 -11
- package/dist/IconButton/index.d.ts +0 -2
- package/dist/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +0 -15
- package/dist/ObjectFieldTemplate/index.d.ts +0 -2
- package/dist/RadioWidget/RadioWidget.d.ts +0 -2
- package/dist/RadioWidget/index.d.ts +0 -2
- package/dist/RangeWidget/RangeWidget.d.ts +0 -2
- package/dist/RangeWidget/index.d.ts +0 -2
- package/dist/SelectWidget/SelectWidget.d.ts +0 -2
- package/dist/SelectWidget/index.d.ts +0 -2
- package/dist/SemanticUIForm/SemanticUIForm.d.ts +0 -2
- package/dist/SemanticUIForm/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 -35
- package/dist/Templates/index.d.ts +0 -2
- package/dist/TextareaWidget/TextareaWidget.d.ts +0 -2
- package/dist/TextareaWidget/index.d.ts +0 -2
- package/dist/Theme/Theme.d.ts +0 -9
- package/dist/Theme/index.d.ts +0 -2
- package/dist/TitleField/TitleField.d.ts +0 -6
- package/dist/TitleField/index.d.ts +0 -2
- package/dist/Widgets/Widgets.d.ts +0 -15
- package/dist/Widgets/index.d.ts +0 -2
- package/dist/util.d.ts +0 -62
|
@@ -6,191 +6,200 @@ var core = require('@rjsf/core');
|
|
|
6
6
|
var semanticUiReact = require('semantic-ui-react');
|
|
7
7
|
var React = require('react');
|
|
8
8
|
var utils = require('@rjsf/utils');
|
|
9
|
-
var PropTypes = require('prop-types');
|
|
10
9
|
var nanoid = require('nanoid');
|
|
11
|
-
var
|
|
10
|
+
var map = require('lodash/map');
|
|
12
11
|
|
|
13
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
14
13
|
|
|
15
14
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
16
|
-
var
|
|
17
|
-
var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
|
|
15
|
+
var map__default = /*#__PURE__*/_interopDefaultLegacy(map);
|
|
18
16
|
|
|
19
17
|
function _extends() {
|
|
20
18
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
21
19
|
for (var i = 1; i < arguments.length; i++) {
|
|
22
20
|
var source = arguments[i];
|
|
23
|
-
|
|
24
21
|
for (var key in source) {
|
|
25
22
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
26
23
|
target[key] = source[key];
|
|
27
24
|
}
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
|
|
31
27
|
return target;
|
|
32
28
|
};
|
|
33
29
|
return _extends.apply(this, arguments);
|
|
34
30
|
}
|
|
31
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
32
|
+
if (source == null) return {};
|
|
33
|
+
var target = {};
|
|
34
|
+
var sourceKeys = Object.keys(source);
|
|
35
|
+
var key, i;
|
|
36
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
37
|
+
key = sourceKeys[i];
|
|
38
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
39
|
+
target[key] = source[key];
|
|
40
|
+
}
|
|
41
|
+
return target;
|
|
42
|
+
}
|
|
35
43
|
|
|
44
|
+
var _excluded$4 = ["uiSchema", "registry", "color"];
|
|
45
|
+
/** The `AddButton` renders a button that represent the `Add` action on a form
|
|
46
|
+
*/
|
|
36
47
|
function AddButton(_ref) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
...props
|
|
40
|
-
} = _ref;
|
|
48
|
+
var color = _ref.color,
|
|
49
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
41
50
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Button, _extends({
|
|
42
|
-
title: "Add Item"
|
|
51
|
+
title: "Add Item",
|
|
52
|
+
color: color
|
|
43
53
|
}, props, {
|
|
44
54
|
icon: true,
|
|
45
|
-
size: "tiny"
|
|
46
|
-
labelPosition: "left"
|
|
55
|
+
size: "tiny"
|
|
47
56
|
}), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Icon, {
|
|
48
57
|
name: "plus"
|
|
49
58
|
}));
|
|
50
59
|
}
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
* @param {Object
|
|
57
|
-
* @param {Object?} params.
|
|
58
|
-
* @param {Object?} params.
|
|
59
|
-
* @param {Object?} params.
|
|
60
|
-
* @param {Object?} params.
|
|
61
|
-
* @
|
|
61
|
+
var _excluded$3 = ["wrap", "component"];
|
|
62
|
+
/**
|
|
63
|
+
* Extract props meant for semantic UI components from props that are
|
|
64
|
+
* passed to Widgets, Templates and Fields.
|
|
65
|
+
* @param {Object} params
|
|
66
|
+
* @param {Object?} params.formContext
|
|
67
|
+
* @param {Object?} params.uiSchema
|
|
68
|
+
* @param {Object?} params.options
|
|
69
|
+
* @param {Object?} params.defaultSchemaProps
|
|
70
|
+
* @param {Object?} params.defaultContextProps
|
|
71
|
+
* @returns {any}
|
|
62
72
|
*/
|
|
63
|
-
|
|
64
73
|
function getSemanticProps(_ref) {
|
|
65
|
-
|
|
66
|
-
formContext = {},
|
|
67
|
-
uiSchema =
|
|
68
|
-
|
|
69
|
-
|
|
74
|
+
var _ref$formContext = _ref.formContext,
|
|
75
|
+
formContext = _ref$formContext === void 0 ? {} : _ref$formContext,
|
|
76
|
+
_ref$uiSchema = _ref.uiSchema,
|
|
77
|
+
uiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
|
|
78
|
+
_ref$options = _ref.options,
|
|
79
|
+
options = _ref$options === void 0 ? {} : _ref$options,
|
|
80
|
+
_ref$defaultSchemaPro = _ref.defaultSchemaProps,
|
|
81
|
+
defaultSchemaProps = _ref$defaultSchemaPro === void 0 ? {
|
|
70
82
|
fluid: true,
|
|
71
83
|
inverted: false
|
|
72
|
-
},
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
return Object.assign({}, {
|
|
80
|
-
}, { ...(defaultContextProps && defaultContextProps)
|
|
81
|
-
}, schemaProps, optionProps, formContextProps);
|
|
84
|
+
} : _ref$defaultSchemaPro,
|
|
85
|
+
_ref$defaultContextPr = _ref.defaultContextProps,
|
|
86
|
+
defaultContextProps = _ref$defaultContextPr === void 0 ? {} : _ref$defaultContextPr;
|
|
87
|
+
var formContextProps = formContext.semantic;
|
|
88
|
+
var schemaProps = utils.getUiOptions(uiSchema).semantic;
|
|
89
|
+
var optionProps = options.semantic;
|
|
90
|
+
// formContext props should overide other props
|
|
91
|
+
return Object.assign({}, _extends({}, defaultSchemaProps), _extends({}, defaultContextProps), schemaProps, optionProps, formContextProps);
|
|
82
92
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Extract error props meant for semantic UI components from props that are
|
|
85
|
-
* passed to Widgets, Templates and Fields.
|
|
86
|
-
* @param {Object} params
|
|
87
|
-
* @param {Object?} params.formContext
|
|
88
|
-
* @param {Object?} params.uiSchema
|
|
89
|
-
* @param {Object?} params.defaultProps
|
|
90
|
-
* @returns {any}
|
|
93
|
+
/**
|
|
94
|
+
* Extract error props meant for semantic UI components from props that are
|
|
95
|
+
* passed to Widgets, Templates and Fields.
|
|
96
|
+
* @param {Object} params
|
|
97
|
+
* @param {Object?} params.formContext
|
|
98
|
+
* @param {Object?} params.uiSchema
|
|
99
|
+
* @param {Object?} params.defaultProps
|
|
100
|
+
* @returns {any}
|
|
91
101
|
*/
|
|
92
|
-
|
|
93
102
|
function getSemanticErrorProps(_ref2) {
|
|
94
|
-
|
|
95
|
-
formContext = {},
|
|
96
|
-
uiSchema =
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
var _ref2$formContext = _ref2.formContext,
|
|
104
|
+
formContext = _ref2$formContext === void 0 ? {} : _ref2$formContext,
|
|
105
|
+
_ref2$uiSchema = _ref2.uiSchema,
|
|
106
|
+
uiSchema = _ref2$uiSchema === void 0 ? {} : _ref2$uiSchema,
|
|
107
|
+
_ref2$options = _ref2.options,
|
|
108
|
+
options = _ref2$options === void 0 ? {} : _ref2$options,
|
|
109
|
+
_ref2$defaultProps = _ref2.defaultProps,
|
|
110
|
+
defaultProps = _ref2$defaultProps === void 0 ? {
|
|
99
111
|
size: "small",
|
|
100
112
|
pointing: "above"
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return Object.assign({}, {
|
|
107
|
-
}, schemaProps, optionProps, formContextProps);
|
|
113
|
+
} : _ref2$defaultProps;
|
|
114
|
+
var formContextProps = formContext.semantic && formContext.semantic.errorOptions;
|
|
115
|
+
var semanticOptions = utils.getUiOptions(uiSchema).semantic;
|
|
116
|
+
var schemaProps = semanticOptions && semanticOptions.errorOptions;
|
|
117
|
+
var optionProps = options.semantic && options.semantic.errorOptions;
|
|
118
|
+
return Object.assign({}, _extends({}, defaultProps), schemaProps, optionProps, formContextProps);
|
|
108
119
|
}
|
|
109
|
-
/**
|
|
110
|
-
* Combine multiple strings containing class names into a single string,
|
|
111
|
-
* removing duplicates. E.g.
|
|
112
|
-
* cleanClassNames('bar', 'baz bar', 'x y ', undefined)
|
|
113
|
-
* // 'bar baz x y'
|
|
114
|
-
* @param {Array} classNameArr
|
|
115
|
-
* @param {Array} omit
|
|
116
|
-
* @returns {string}
|
|
120
|
+
/**
|
|
121
|
+
* Combine multiple strings containing class names into a single string,
|
|
122
|
+
* removing duplicates. E.g.
|
|
123
|
+
* cleanClassNames('bar', 'baz bar', 'x y ', undefined)
|
|
124
|
+
* // 'bar baz x y'
|
|
125
|
+
* @param {Array} classNameArr
|
|
126
|
+
* @param {Array} omit
|
|
127
|
+
* @returns {string}
|
|
117
128
|
*/
|
|
118
|
-
|
|
119
129
|
function cleanClassNames(classNameArr, omit) {
|
|
120
130
|
if (omit === void 0) {
|
|
121
131
|
omit = [];
|
|
122
132
|
}
|
|
123
|
-
|
|
124
133
|
// Split each arg on whitespace, and add it to an array. Skip false-y args
|
|
125
134
|
// like "" and undefined.
|
|
126
|
-
|
|
135
|
+
var classList = classNameArr.filter(Boolean).reduce(function (previous, current) {
|
|
136
|
+
return previous.concat(current.trim().split(/\s+/));
|
|
137
|
+
}, []);
|
|
138
|
+
// Remove any class names from omit, and make the rest unique before
|
|
127
139
|
// returning them as a string
|
|
128
|
-
|
|
129
|
-
|
|
140
|
+
return [].concat(new Set(classList.filter(function (cn) {
|
|
141
|
+
return !omit.includes(cn);
|
|
142
|
+
}))).join(" ");
|
|
130
143
|
}
|
|
131
|
-
/**
|
|
132
|
-
*
|
|
133
|
-
* @param {boolean} wrap
|
|
134
|
-
* @param Component
|
|
135
|
-
* @param {Object} props
|
|
136
|
-
* @returns {*}
|
|
137
|
-
* @constructor
|
|
144
|
+
/**
|
|
145
|
+
*
|
|
146
|
+
* @param {boolean} wrap
|
|
147
|
+
* @param Component
|
|
148
|
+
* @param {Object} props
|
|
149
|
+
* @returns {*}
|
|
150
|
+
* @constructor
|
|
138
151
|
*/
|
|
139
|
-
|
|
140
152
|
function MaybeWrap(_ref3) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
return wrap ? /*#__PURE__*/React__default["default"].createElement(Component, props) : props.children;
|
|
153
|
+
var wrap = _ref3.wrap,
|
|
154
|
+
_ref3$component = _ref3.component,
|
|
155
|
+
Component = _ref3$component === void 0 ? "div" : _ref3$component,
|
|
156
|
+
props = _objectWithoutPropertiesLoose(_ref3, _excluded$3);
|
|
157
|
+
return wrap ? /*#__PURE__*/React__default["default"].createElement(Component, _extends({}, props)) : props.children;
|
|
147
158
|
}
|
|
148
159
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
RemoveButton
|
|
184
|
-
} = registry.templates.ButtonTemplates;
|
|
160
|
+
var gridStyle = function gridStyle(vertical) {
|
|
161
|
+
return {
|
|
162
|
+
display: "grid",
|
|
163
|
+
gridTemplateColumns: "1fr " + (vertical ? 65 : 110) + "px"
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
167
|
+
*
|
|
168
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
169
|
+
*/
|
|
170
|
+
function ArrayFieldItemTemplate(props) {
|
|
171
|
+
var children = props.children,
|
|
172
|
+
disabled = props.disabled,
|
|
173
|
+
hasToolbar = props.hasToolbar,
|
|
174
|
+
hasMoveDown = props.hasMoveDown,
|
|
175
|
+
hasMoveUp = props.hasMoveUp,
|
|
176
|
+
hasRemove = props.hasRemove,
|
|
177
|
+
index = props.index,
|
|
178
|
+
onDropIndexClick = props.onDropIndexClick,
|
|
179
|
+
onReorderClick = props.onReorderClick,
|
|
180
|
+
readonly = props.readonly,
|
|
181
|
+
uiSchema = props.uiSchema,
|
|
182
|
+
registry = props.registry;
|
|
183
|
+
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
184
|
+
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
185
|
+
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
186
|
+
RemoveButton = _registry$templates$B.RemoveButton;
|
|
187
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
188
|
+
// Pull the semantic props out of the uiOptions that were put in via the ArrayFieldTemplate
|
|
189
|
+
var _uiOptions$semantic = uiOptions.semantic,
|
|
190
|
+
_uiOptions$semantic$h = _uiOptions$semantic.horizontalButtons,
|
|
191
|
+
horizontalButtons = _uiOptions$semantic$h === void 0 ? false : _uiOptions$semantic$h,
|
|
192
|
+
_uiOptions$semantic$w = _uiOptions$semantic.wrapItem,
|
|
193
|
+
wrapItem = _uiOptions$semantic$w === void 0 ? false : _uiOptions$semantic$w;
|
|
185
194
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
186
195
|
className: "array-item"
|
|
187
196
|
}, /*#__PURE__*/React__default["default"].createElement(MaybeWrap, {
|
|
188
197
|
wrap: wrapItem,
|
|
189
198
|
component: semanticUiReact.Segment
|
|
190
199
|
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid, {
|
|
191
|
-
style:
|
|
200
|
+
style: index !== 0 ? _extends({}, gridStyle(!horizontalButtons), {
|
|
192
201
|
alignItems: "center"
|
|
193
|
-
} : gridStyle(!horizontalButtons)
|
|
202
|
+
}) : gridStyle(!horizontalButtons)
|
|
194
203
|
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, {
|
|
195
204
|
width: 16,
|
|
196
205
|
verticalAlign: "middle"
|
|
@@ -201,85 +210,97 @@ const ArrayFieldItemTemplate = props => {
|
|
|
201
210
|
className: "array-item-move-up",
|
|
202
211
|
disabled: disabled || readonly || !hasMoveUp,
|
|
203
212
|
onClick: onReorderClick(index, index - 1),
|
|
204
|
-
uiSchema: uiSchema
|
|
213
|
+
uiSchema: uiSchema,
|
|
214
|
+
registry: registry
|
|
205
215
|
}), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React__default["default"].createElement(MoveDownButton, {
|
|
206
216
|
className: "array-item-move-down",
|
|
207
217
|
disabled: disabled || readonly || !hasMoveDown,
|
|
208
218
|
onClick: onReorderClick(index, index + 1),
|
|
209
|
-
uiSchema: uiSchema
|
|
219
|
+
uiSchema: uiSchema,
|
|
220
|
+
registry: registry
|
|
210
221
|
}), hasRemove && /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
211
222
|
className: "array-item-remove",
|
|
212
223
|
disabled: disabled || readonly,
|
|
213
224
|
onClick: onDropIndexClick(index),
|
|
214
|
-
uiSchema: uiSchema
|
|
225
|
+
uiSchema: uiSchema,
|
|
226
|
+
registry: registry
|
|
215
227
|
}))))));
|
|
216
|
-
}
|
|
228
|
+
}
|
|
217
229
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
uiSchema,
|
|
239
|
-
formContext,
|
|
230
|
+
var _excluded$2 = ["key", "uiSchema"];
|
|
231
|
+
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
232
|
+
*
|
|
233
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
234
|
+
*/
|
|
235
|
+
function ArrayFieldTemplate(props) {
|
|
236
|
+
var uiSchema = props.uiSchema,
|
|
237
|
+
idSchema = props.idSchema,
|
|
238
|
+
canAdd = props.canAdd,
|
|
239
|
+
className = props.className,
|
|
240
|
+
disabled = props.disabled,
|
|
241
|
+
formContext = props.formContext,
|
|
242
|
+
items = props.items,
|
|
243
|
+
onAddClick = props.onAddClick,
|
|
244
|
+
readonly = props.readonly,
|
|
245
|
+
required = props.required,
|
|
246
|
+
schema = props.schema,
|
|
247
|
+
title = props.title,
|
|
248
|
+
registry = props.registry;
|
|
249
|
+
var semanticProps = getSemanticProps({
|
|
250
|
+
uiSchema: uiSchema,
|
|
251
|
+
formContext: formContext,
|
|
240
252
|
defaultSchemaProps: {
|
|
241
253
|
horizontalButtons: false,
|
|
242
254
|
wrapItem: false
|
|
243
255
|
}
|
|
244
256
|
});
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
horizontalButtons,
|
|
251
|
-
wrapItem
|
|
257
|
+
var horizontalButtons = semanticProps.horizontalButtons,
|
|
258
|
+
wrapItem = semanticProps.wrapItem;
|
|
259
|
+
var semantic = {
|
|
260
|
+
horizontalButtons: horizontalButtons,
|
|
261
|
+
wrapItem: wrapItem
|
|
252
262
|
};
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
ButtonTemplates: {
|
|
260
|
-
AddButton
|
|
261
|
-
}
|
|
262
|
-
} = registry.templates;
|
|
263
|
-
const fieldTitle = uiOptions.title || title;
|
|
264
|
-
const fieldDescription = uiOptions.description || schema.description;
|
|
263
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
264
|
+
var ArrayFieldDescriptionTemplate = utils.getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
|
|
265
|
+
var ArrayFieldItemTemplate = utils.getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
|
|
266
|
+
var ArrayFieldTitleTemplate = utils.getTemplate("ArrayFieldTitleTemplate", registry, uiOptions);
|
|
267
|
+
// Button templates are not overridden in the uiSchema
|
|
268
|
+
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
265
269
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
266
|
-
className: cleanClassNames([className,
|
|
270
|
+
className: cleanClassNames([className, utils.isFixedItems(schema) ? "" : "sortable-form-fields"])
|
|
267
271
|
}, /*#__PURE__*/React__default["default"].createElement(ArrayFieldTitleTemplate, {
|
|
268
272
|
idSchema: idSchema,
|
|
269
|
-
title:
|
|
273
|
+
title: uiOptions.title || title,
|
|
274
|
+
schema: schema,
|
|
270
275
|
uiSchema: uiSchema,
|
|
271
276
|
required: required,
|
|
272
277
|
registry: registry
|
|
273
|
-
}),
|
|
278
|
+
}), /*#__PURE__*/React__default["default"].createElement(ArrayFieldDescriptionTemplate, {
|
|
274
279
|
idSchema: idSchema,
|
|
275
|
-
description:
|
|
280
|
+
description: uiOptions.description || schema.description,
|
|
281
|
+
schema: schema,
|
|
276
282
|
uiSchema: uiSchema,
|
|
277
283
|
registry: registry
|
|
278
284
|
}), /*#__PURE__*/React__default["default"].createElement("div", {
|
|
279
285
|
key: "array-item-list-" + idSchema.$id
|
|
280
286
|
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
281
287
|
className: "row array-item-list"
|
|
282
|
-
}, items && items.map(
|
|
288
|
+
}, items && items.map(function (_ref) {
|
|
289
|
+
var _extends2;
|
|
290
|
+
var key = _ref.key,
|
|
291
|
+
_ref$uiSchema = _ref.uiSchema,
|
|
292
|
+
itemUiSchema = _ref$uiSchema === void 0 ? {} : _ref$uiSchema,
|
|
293
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
294
|
+
// Merge in the semantic props from the ArrayFieldTemplate into each of the items
|
|
295
|
+
var mergedUiSchema = _extends({}, itemUiSchema, (_extends2 = {}, _extends2[utils.UI_OPTIONS_KEY] = _extends({}, itemUiSchema[utils.UI_OPTIONS_KEY], {
|
|
296
|
+
semantic: semantic
|
|
297
|
+
}), _extends2));
|
|
298
|
+
return /*#__PURE__*/React__default["default"].createElement(ArrayFieldItemTemplate, _extends({
|
|
299
|
+
key: key
|
|
300
|
+
}, props, {
|
|
301
|
+
uiSchema: mergedUiSchema
|
|
302
|
+
}));
|
|
303
|
+
})), canAdd && /*#__PURE__*/React__default["default"].createElement("div", {
|
|
283
304
|
style: {
|
|
284
305
|
marginTop: "1rem",
|
|
285
306
|
position: "relative",
|
|
@@ -287,77 +308,77 @@ function ArrayFieldTemplate(_ref) {
|
|
|
287
308
|
}
|
|
288
309
|
}, /*#__PURE__*/React__default["default"].createElement(AddButton, {
|
|
289
310
|
onClick: onAddClick,
|
|
290
|
-
disabled: disabled ||
|
|
291
|
-
uiSchema: uiSchema
|
|
311
|
+
disabled: disabled || readonly,
|
|
312
|
+
uiSchema: uiSchema,
|
|
313
|
+
registry: registry
|
|
292
314
|
}))));
|
|
293
315
|
}
|
|
294
316
|
|
|
317
|
+
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
318
|
+
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
319
|
+
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
320
|
+
*
|
|
321
|
+
* @param props - The `WidgetProps` for this template
|
|
322
|
+
*/
|
|
295
323
|
function BaseInputTemplate(props) {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
formContext,
|
|
321
|
-
options
|
|
324
|
+
var id = props.id,
|
|
325
|
+
placeholder = props.placeholder,
|
|
326
|
+
label = props.label,
|
|
327
|
+
value = props.value,
|
|
328
|
+
required = props.required,
|
|
329
|
+
readonly = props.readonly,
|
|
330
|
+
disabled = props.disabled,
|
|
331
|
+
onChange = props.onChange,
|
|
332
|
+
onBlur = props.onBlur,
|
|
333
|
+
onFocus = props.onFocus,
|
|
334
|
+
autofocus = props.autofocus,
|
|
335
|
+
options = props.options,
|
|
336
|
+
schema = props.schema,
|
|
337
|
+
uiSchema = props.uiSchema,
|
|
338
|
+
formContext = props.formContext,
|
|
339
|
+
type = props.type,
|
|
340
|
+
registry = props.registry,
|
|
341
|
+
_props$rawErrors = props.rawErrors,
|
|
342
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
|
|
343
|
+
var inputProps = utils.getInputProps(schema, type, options);
|
|
344
|
+
var semanticProps = getSemanticProps({
|
|
345
|
+
uiSchema: uiSchema,
|
|
346
|
+
formContext: formContext,
|
|
347
|
+
options: options
|
|
322
348
|
});
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const _onChange = _ref => {
|
|
328
|
-
let {
|
|
329
|
-
target: {
|
|
330
|
-
value
|
|
331
|
-
}
|
|
332
|
-
} = _ref;
|
|
349
|
+
var schemaUtils = registry.schemaUtils;
|
|
350
|
+
var _onChange = function _onChange(_ref) {
|
|
351
|
+
var value = _ref.target.value;
|
|
333
352
|
return onChange(value === "" ? options.emptyValue : value);
|
|
334
353
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
354
|
+
var _onBlur = function _onBlur() {
|
|
355
|
+
return onBlur && onBlur(id, value);
|
|
356
|
+
};
|
|
357
|
+
var _onFocus = function _onFocus() {
|
|
358
|
+
return onFocus && onFocus(id, value);
|
|
359
|
+
};
|
|
360
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
341
361
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Input, _extends({
|
|
342
362
|
key: id,
|
|
343
363
|
id: id,
|
|
364
|
+
name: id,
|
|
344
365
|
placeholder: placeholder
|
|
345
366
|
}, inputProps, {
|
|
346
367
|
label: displayLabel ? label || schema.title : false,
|
|
347
368
|
required: required,
|
|
348
369
|
autoFocus: autofocus,
|
|
349
370
|
disabled: disabled || readonly,
|
|
350
|
-
|
|
351
|
-
list: schema.examples ? "examples_" + id : undefined
|
|
371
|
+
list: schema.examples ? utils.examplesId(id) : undefined
|
|
352
372
|
}, semanticProps, {
|
|
353
373
|
value: value || value === 0 ? value : "",
|
|
354
374
|
error: rawErrors.length > 0,
|
|
355
375
|
onChange: _onChange,
|
|
356
376
|
onBlur: _onBlur,
|
|
357
|
-
onFocus: _onFocus
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
377
|
+
onFocus: _onFocus,
|
|
378
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
379
|
+
})), Array.isArray(schema.examples) && /*#__PURE__*/React__default["default"].createElement("datalist", {
|
|
380
|
+
id: utils.examplesId(id)
|
|
381
|
+
}, schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
361
382
|
return /*#__PURE__*/React__default["default"].createElement("option", {
|
|
362
383
|
key: example,
|
|
363
384
|
value: example
|
|
@@ -365,65 +386,51 @@ function BaseInputTemplate(props) {
|
|
|
365
386
|
})));
|
|
366
387
|
}
|
|
367
388
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
if (description) {
|
|
378
|
-
return /*#__PURE__*/React__default["default"].createElement("p", {
|
|
379
|
-
id: id,
|
|
380
|
-
className: className || "sui-description"
|
|
381
|
-
}, description);
|
|
389
|
+
/** The `DescriptionField` is the template to use to render the description of a field
|
|
390
|
+
*
|
|
391
|
+
* @param props - The `DescriptionFieldProps` for this component
|
|
392
|
+
*/
|
|
393
|
+
function DescriptionField(props) {
|
|
394
|
+
var id = props.id,
|
|
395
|
+
description = props.description;
|
|
396
|
+
if (!description) {
|
|
397
|
+
return null;
|
|
382
398
|
}
|
|
399
|
+
return /*#__PURE__*/React__default["default"].createElement("p", {
|
|
400
|
+
id: id,
|
|
401
|
+
className: "sui-description"
|
|
402
|
+
}, description);
|
|
383
403
|
}
|
|
384
404
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
*
|
|
388
|
-
* @param errors
|
|
389
|
-
* @returns {*}
|
|
390
|
-
* @constructor
|
|
405
|
+
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
406
|
+
*
|
|
407
|
+
* @param props - The `ErrorListProps` for this component
|
|
391
408
|
*/
|
|
392
|
-
|
|
393
409
|
function ErrorList(_ref) {
|
|
394
|
-
|
|
395
|
-
errors
|
|
396
|
-
} = _ref;
|
|
410
|
+
var errors = _ref.errors;
|
|
397
411
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Message, {
|
|
398
412
|
negative: true
|
|
399
|
-
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Message.Header, null, "Errors"), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Message.List, null, errors.map((error, index)
|
|
400
|
-
|
|
401
|
-
|
|
413
|
+
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Message.Header, null, "Errors"), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Message.List, null, errors.map(function (error, index) {
|
|
414
|
+
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Message.Item, {
|
|
415
|
+
key: "error-" + index
|
|
416
|
+
}, error.stack);
|
|
417
|
+
})));
|
|
402
418
|
}
|
|
403
419
|
|
|
404
|
-
|
|
405
|
-
errors: PropTypes__default["default"].array
|
|
406
|
-
};
|
|
407
|
-
|
|
420
|
+
var _excluded$1 = ["icon", "iconType", "color", "className", "uiSchema", "registry"];
|
|
408
421
|
function IconButton(props) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
className,
|
|
413
|
-
|
|
414
|
-
...otherProps
|
|
415
|
-
} = props;
|
|
422
|
+
var icon = props.icon,
|
|
423
|
+
iconType = props.iconType,
|
|
424
|
+
color = props.color,
|
|
425
|
+
className = props.className,
|
|
426
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
416
427
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Button, _extends({
|
|
417
428
|
icon: icon,
|
|
418
429
|
size: iconType,
|
|
430
|
+
color: color,
|
|
419
431
|
className: className
|
|
420
432
|
}, otherProps));
|
|
421
433
|
}
|
|
422
|
-
|
|
423
|
-
IconButton.propTypes = {
|
|
424
|
-
icon: PropTypes__default["default"].string.isRequired,
|
|
425
|
-
className: PropTypes__default["default"].string
|
|
426
|
-
};
|
|
427
434
|
function MoveDownButton(props) {
|
|
428
435
|
return /*#__PURE__*/React__default["default"].createElement(IconButton, _extends({
|
|
429
436
|
title: "Move down"
|
|
@@ -446,37 +453,31 @@ function RemoveButton(props) {
|
|
|
446
453
|
}));
|
|
447
454
|
}
|
|
448
455
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
*
|
|
456
|
+
var DEFAULT_OPTIONS$1 = {
|
|
457
|
+
options: {
|
|
458
|
+
pointing: "above",
|
|
459
|
+
size: "small"
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
463
|
+
*
|
|
464
|
+
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
457
465
|
*/
|
|
458
|
-
|
|
459
466
|
function FieldErrorTemplate(_ref) {
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
const options = getSemanticErrorProps({
|
|
470
|
-
formContext,
|
|
471
|
-
uiSchema
|
|
467
|
+
var errors = _ref.errors,
|
|
468
|
+
idSchema = _ref.idSchema,
|
|
469
|
+
uiSchema = _ref.uiSchema,
|
|
470
|
+
registry = _ref.registry;
|
|
471
|
+
var formContext = registry.formContext;
|
|
472
|
+
var options = getSemanticErrorProps({
|
|
473
|
+
formContext: formContext,
|
|
474
|
+
uiSchema: uiSchema,
|
|
475
|
+
defaultProps: DEFAULT_OPTIONS$1
|
|
472
476
|
});
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
size
|
|
476
|
-
} = options;
|
|
477
|
-
|
|
477
|
+
var pointing = options.pointing,
|
|
478
|
+
size = options.size;
|
|
478
479
|
if (errors && errors.length > 0) {
|
|
479
|
-
|
|
480
|
+
var id = idSchema.$id + "__error";
|
|
480
481
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Label, {
|
|
481
482
|
id: id,
|
|
482
483
|
color: "red",
|
|
@@ -485,38 +486,24 @@ function FieldErrorTemplate(_ref) {
|
|
|
485
486
|
basic: true
|
|
486
487
|
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.List, {
|
|
487
488
|
bulleted: true
|
|
488
|
-
}, errors.map(
|
|
489
|
-
|
|
490
|
-
|
|
489
|
+
}, errors.map(function (error) {
|
|
490
|
+
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.List.Item, {
|
|
491
|
+
key: nanoid.nanoid()
|
|
492
|
+
}, error);
|
|
493
|
+
})));
|
|
491
494
|
}
|
|
492
|
-
|
|
493
495
|
return null;
|
|
494
496
|
}
|
|
495
497
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
size: "small"
|
|
500
|
-
}
|
|
501
|
-
};
|
|
502
|
-
FieldErrorTemplate.propTypes = {
|
|
503
|
-
options: PropTypes__default["default"].object,
|
|
504
|
-
errors: PropTypes__default["default"].array
|
|
505
|
-
};
|
|
506
|
-
|
|
507
|
-
/* eslint-disable react/prop-types */
|
|
508
|
-
/**
|
|
509
|
-
* @return {null}
|
|
498
|
+
/** The `FieldHelpTemplate` component renders any help desired for a field
|
|
499
|
+
*
|
|
500
|
+
* @param props - The `FieldHelpProps` to be rendered
|
|
510
501
|
*/
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
help,
|
|
515
|
-
idSchema
|
|
516
|
-
} = _ref;
|
|
517
|
-
|
|
502
|
+
function FieldHelpTemplate(props) {
|
|
503
|
+
var idSchema = props.idSchema,
|
|
504
|
+
help = props.help;
|
|
518
505
|
if (help) {
|
|
519
|
-
|
|
506
|
+
var id = idSchema.$id + "__help";
|
|
520
507
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Message, {
|
|
521
508
|
size: "mini",
|
|
522
509
|
info: true,
|
|
@@ -524,116 +511,36 @@ function FieldHelpTemplate(_ref) {
|
|
|
524
511
|
content: help
|
|
525
512
|
});
|
|
526
513
|
}
|
|
527
|
-
|
|
528
514
|
return null;
|
|
529
515
|
}
|
|
530
516
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
label,
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
} = formContext;
|
|
559
|
-
const keyLabel = label + " Key"; // i18n ?
|
|
560
|
-
|
|
561
|
-
const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
562
|
-
|
|
563
|
-
if (!additional) {
|
|
564
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
565
|
-
className: classNames
|
|
566
|
-
}, children);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
const handleBlur = _ref2 => {
|
|
570
|
-
let {
|
|
571
|
-
target
|
|
572
|
-
} = _ref2;
|
|
573
|
-
return onKeyChange(target.value);
|
|
574
|
-
};
|
|
575
|
-
|
|
576
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
577
|
-
className: classNames,
|
|
578
|
-
key: id + "-key"
|
|
579
|
-
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid, {
|
|
580
|
-
columns: "equal"
|
|
581
|
-
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Row, null, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, {
|
|
582
|
-
className: "form-additional"
|
|
583
|
-
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Group, {
|
|
584
|
-
widths: "equal",
|
|
585
|
-
grouped: true
|
|
586
|
-
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Input, {
|
|
587
|
-
className: "form-group",
|
|
588
|
-
hasFeedback: true,
|
|
589
|
-
fluid: true,
|
|
590
|
-
htmlFor: "" + id,
|
|
591
|
-
label: keyLabel,
|
|
592
|
-
required: required,
|
|
593
|
-
defaultValue: label,
|
|
594
|
-
disabled: disabled || readonlyAsDisabled && readonly,
|
|
595
|
-
id: "" + id,
|
|
596
|
-
name: "" + id,
|
|
597
|
-
onBlur: !readonly ? handleBlur : undefined,
|
|
598
|
-
style: wrapperStyle,
|
|
599
|
-
type: "text"
|
|
600
|
-
}))), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, {
|
|
601
|
-
className: "form-additional",
|
|
602
|
-
verticalAlign: "middle"
|
|
603
|
-
}, children), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, null, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
604
|
-
iconType: "mini",
|
|
605
|
-
className: "array-item-remove",
|
|
606
|
-
disabled: disabled || readonly,
|
|
607
|
-
onClick: onDropPropertyClick(label),
|
|
608
|
-
uiSchema: uiSchema
|
|
609
|
-
})))));
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
function FieldTemplate(_ref) {
|
|
613
|
-
let {
|
|
614
|
-
id,
|
|
615
|
-
children,
|
|
616
|
-
className,
|
|
617
|
-
// pass className for styling libs (like styled-components)
|
|
618
|
-
classNames,
|
|
619
|
-
displayLabel,
|
|
620
|
-
label,
|
|
621
|
-
errors,
|
|
622
|
-
help,
|
|
623
|
-
hidden,
|
|
624
|
-
rawDescription,
|
|
625
|
-
registry,
|
|
626
|
-
uiSchema,
|
|
627
|
-
...props
|
|
628
|
-
} = _ref;
|
|
629
|
-
const semanticProps = getSemanticProps(props);
|
|
630
|
-
const {
|
|
631
|
-
wrapLabel,
|
|
632
|
-
wrapContent
|
|
633
|
-
} = semanticProps;
|
|
634
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
635
|
-
const DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
|
|
636
|
-
|
|
517
|
+
var _excluded = ["id", "children", "classNames", "style", "displayLabel", "label", "errors", "help", "hidden", "rawDescription", "registry", "schema", "uiSchema"];
|
|
518
|
+
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
519
|
+
* content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
|
|
520
|
+
*
|
|
521
|
+
* @param props - The `FieldTemplateProps` for this component
|
|
522
|
+
*/
|
|
523
|
+
function FieldTemplate(props) {
|
|
524
|
+
var id = props.id,
|
|
525
|
+
children = props.children,
|
|
526
|
+
classNames = props.classNames,
|
|
527
|
+
style = props.style,
|
|
528
|
+
displayLabel = props.displayLabel,
|
|
529
|
+
label = props.label,
|
|
530
|
+
errors = props.errors,
|
|
531
|
+
help = props.help,
|
|
532
|
+
hidden = props.hidden,
|
|
533
|
+
rawDescription = props.rawDescription,
|
|
534
|
+
registry = props.registry,
|
|
535
|
+
schema = props.schema,
|
|
536
|
+
uiSchema = props.uiSchema,
|
|
537
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
538
|
+
var semanticProps = getSemanticProps(otherProps);
|
|
539
|
+
var wrapLabel = semanticProps.wrapLabel,
|
|
540
|
+
wrapContent = semanticProps.wrapContent;
|
|
541
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
542
|
+
var WrapIfAdditionalTemplate = utils.getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
|
|
543
|
+
var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
|
|
637
544
|
if (hidden) {
|
|
638
545
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
639
546
|
style: {
|
|
@@ -641,14 +548,15 @@ function FieldTemplate(_ref) {
|
|
|
641
548
|
}
|
|
642
549
|
}, children);
|
|
643
550
|
}
|
|
644
|
-
|
|
645
|
-
return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditional, _extends({
|
|
551
|
+
return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditionalTemplate, _extends({
|
|
646
552
|
classNames: classNames,
|
|
553
|
+
style: style,
|
|
647
554
|
id: id,
|
|
648
555
|
label: label,
|
|
649
556
|
registry: registry,
|
|
557
|
+
schema: schema,
|
|
650
558
|
uiSchema: uiSchema
|
|
651
|
-
},
|
|
559
|
+
}, otherProps), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Group, {
|
|
652
560
|
key: id,
|
|
653
561
|
widths: "equal",
|
|
654
562
|
grouped: true
|
|
@@ -659,50 +567,56 @@ function FieldTemplate(_ref) {
|
|
|
659
567
|
wrap: wrapLabel,
|
|
660
568
|
className: "sui-field-label"
|
|
661
569
|
}, rawDescription && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
662
|
-
id: id
|
|
663
|
-
description: rawDescription
|
|
570
|
+
id: utils.descriptionId(id),
|
|
571
|
+
description: rawDescription,
|
|
572
|
+
schema: schema,
|
|
573
|
+
uiSchema: uiSchema,
|
|
574
|
+
registry: registry
|
|
664
575
|
})), help, errors)));
|
|
665
576
|
}
|
|
666
577
|
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
const fieldTitle = uiOptions.title || title;
|
|
694
|
-
const fieldDescription = uiOptions.description || description;
|
|
578
|
+
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
579
|
+
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
580
|
+
* the properties.
|
|
581
|
+
*
|
|
582
|
+
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
583
|
+
*/
|
|
584
|
+
function ObjectFieldTemplate(props) {
|
|
585
|
+
var description = props.description,
|
|
586
|
+
onAddClick = props.onAddClick,
|
|
587
|
+
title = props.title,
|
|
588
|
+
properties = props.properties,
|
|
589
|
+
disabled = props.disabled,
|
|
590
|
+
readonly = props.readonly,
|
|
591
|
+
required = props.required,
|
|
592
|
+
uiSchema = props.uiSchema,
|
|
593
|
+
schema = props.schema,
|
|
594
|
+
formData = props.formData,
|
|
595
|
+
idSchema = props.idSchema,
|
|
596
|
+
registry = props.registry;
|
|
597
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
598
|
+
var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
|
|
599
|
+
var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
|
|
600
|
+
// Button templates are not overridden in the uiSchema
|
|
601
|
+
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
602
|
+
var fieldTitle = uiOptions.title || title;
|
|
603
|
+
var fieldDescription = uiOptions.description || description;
|
|
695
604
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, fieldTitle && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
696
|
-
id: idSchema
|
|
605
|
+
id: utils.titleId(idSchema),
|
|
697
606
|
title: fieldTitle,
|
|
698
607
|
required: required,
|
|
608
|
+
schema: schema,
|
|
699
609
|
uiSchema: uiSchema,
|
|
700
610
|
registry: registry
|
|
701
611
|
}), fieldDescription && /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
702
|
-
id: idSchema
|
|
612
|
+
id: utils.descriptionId(idSchema),
|
|
703
613
|
description: fieldDescription,
|
|
614
|
+
schema: schema,
|
|
615
|
+
uiSchema: uiSchema,
|
|
704
616
|
registry: registry
|
|
705
|
-
}), properties.map(
|
|
617
|
+
}), properties.map(function (prop) {
|
|
618
|
+
return prop.content;
|
|
619
|
+
}), utils.canExpand(schema, uiSchema, formData) && /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, {
|
|
706
620
|
width: 16,
|
|
707
621
|
verticalAlign: "middle"
|
|
708
622
|
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Row, null, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -713,120 +627,201 @@ function ObjectFieldTemplate(_ref) {
|
|
|
713
627
|
}
|
|
714
628
|
}, /*#__PURE__*/React__default["default"].createElement(AddButton, {
|
|
715
629
|
onClick: onAddClick(schema),
|
|
716
|
-
disabled: disabled ||
|
|
717
|
-
uiSchema: uiSchema
|
|
630
|
+
disabled: disabled || readonly,
|
|
631
|
+
uiSchema: uiSchema,
|
|
632
|
+
registry: registry
|
|
718
633
|
})))));
|
|
719
634
|
}
|
|
720
635
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
submitText,
|
|
727
|
-
norender,
|
|
728
|
-
props
|
|
729
|
-
|
|
730
|
-
|
|
636
|
+
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
637
|
+
*/
|
|
638
|
+
function SubmitButton(_ref) {
|
|
639
|
+
var uiSchema = _ref.uiSchema;
|
|
640
|
+
var _getSubmitButtonOptio = utils.getSubmitButtonOptions(uiSchema),
|
|
641
|
+
submitText = _getSubmitButtonOptio.submitText,
|
|
642
|
+
norender = _getSubmitButtonOptio.norender,
|
|
643
|
+
_getSubmitButtonOptio2 = _getSubmitButtonOptio.props,
|
|
644
|
+
submitButtonProps = _getSubmitButtonOptio2 === void 0 ? {} : _getSubmitButtonOptio2;
|
|
731
645
|
if (norender) {
|
|
732
646
|
return null;
|
|
733
647
|
}
|
|
734
|
-
|
|
735
648
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Button, _extends({
|
|
736
649
|
type: "submit",
|
|
737
650
|
primary: true
|
|
738
651
|
}, submitButtonProps), submitText);
|
|
739
|
-
}
|
|
652
|
+
}
|
|
740
653
|
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
dividing: true
|
|
745
|
-
}
|
|
654
|
+
var DEFAULT_OPTIONS = {
|
|
655
|
+
inverted: false,
|
|
656
|
+
dividing: true
|
|
746
657
|
};
|
|
747
|
-
|
|
658
|
+
/** The `TitleField` is the template to use to render the title of a field
|
|
659
|
+
*
|
|
660
|
+
* @param props - The `TitleFieldProps` for this component
|
|
661
|
+
*/
|
|
748
662
|
function TitleField(_ref) {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
663
|
+
var id = _ref.id,
|
|
664
|
+
title = _ref.title,
|
|
665
|
+
uiSchema = _ref.uiSchema;
|
|
666
|
+
var semanticProps = getSemanticProps({
|
|
667
|
+
uiSchema: uiSchema,
|
|
668
|
+
defaultSchemaProps: DEFAULT_OPTIONS
|
|
669
|
+
});
|
|
670
|
+
if (!title) {
|
|
671
|
+
return null;
|
|
672
|
+
}
|
|
673
|
+
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Header, _extends({
|
|
674
|
+
id: id
|
|
675
|
+
}, semanticProps, {
|
|
676
|
+
as: "h5"
|
|
677
|
+
}), title);
|
|
678
|
+
}
|
|
758
679
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
680
|
+
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
681
|
+
* part of an `additionalProperties` part of a schema.
|
|
682
|
+
*
|
|
683
|
+
* @param props - The `WrapIfAdditionalProps` for this component
|
|
684
|
+
*/
|
|
685
|
+
function WrapIfAdditionalTemplate(props) {
|
|
686
|
+
var children = props.children,
|
|
687
|
+
classNames = props.classNames,
|
|
688
|
+
style = props.style,
|
|
689
|
+
disabled = props.disabled,
|
|
690
|
+
id = props.id,
|
|
691
|
+
label = props.label,
|
|
692
|
+
onDropPropertyClick = props.onDropPropertyClick,
|
|
693
|
+
onKeyChange = props.onKeyChange,
|
|
694
|
+
readonly = props.readonly,
|
|
695
|
+
required = props.required,
|
|
696
|
+
schema = props.schema,
|
|
697
|
+
uiSchema = props.uiSchema,
|
|
698
|
+
registry = props.registry;
|
|
699
|
+
// Button templates are not overridden in the uiSchema
|
|
700
|
+
var RemoveButton = registry.templates.ButtonTemplates.RemoveButton;
|
|
701
|
+
var _registry$formContext = registry.formContext,
|
|
702
|
+
_registry$formContext2 = _registry$formContext.readonlyAsDisabled,
|
|
703
|
+
readonlyAsDisabled = _registry$formContext2 === void 0 ? true : _registry$formContext2,
|
|
704
|
+
wrapperStyle = _registry$formContext.wrapperStyle;
|
|
705
|
+
var keyLabel = label + " Key"; // i18n ?
|
|
706
|
+
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
707
|
+
if (!additional) {
|
|
708
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
709
|
+
className: classNames,
|
|
710
|
+
style: style
|
|
711
|
+
}, children);
|
|
765
712
|
}
|
|
713
|
+
var handleBlur = function handleBlur(_ref) {
|
|
714
|
+
var target = _ref.target;
|
|
715
|
+
return onKeyChange(target.value);
|
|
716
|
+
};
|
|
717
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
718
|
+
className: classNames,
|
|
719
|
+
style: style,
|
|
720
|
+
key: id + "-key"
|
|
721
|
+
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid, {
|
|
722
|
+
columns: "equal"
|
|
723
|
+
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Row, null, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, {
|
|
724
|
+
className: "form-additional"
|
|
725
|
+
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Group, {
|
|
726
|
+
widths: "equal",
|
|
727
|
+
grouped: true
|
|
728
|
+
}, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Input, {
|
|
729
|
+
className: "form-group",
|
|
730
|
+
hasFeedback: true,
|
|
731
|
+
fluid: true,
|
|
732
|
+
htmlFor: "" + id,
|
|
733
|
+
label: keyLabel,
|
|
734
|
+
required: required,
|
|
735
|
+
defaultValue: label,
|
|
736
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
737
|
+
id: "" + id,
|
|
738
|
+
name: "" + id,
|
|
739
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
740
|
+
style: wrapperStyle,
|
|
741
|
+
type: "text"
|
|
742
|
+
}))), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, {
|
|
743
|
+
className: "form-additional",
|
|
744
|
+
verticalAlign: "middle"
|
|
745
|
+
}, children), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Grid.Column, null, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
746
|
+
iconType: "mini",
|
|
747
|
+
className: "array-item-remove",
|
|
748
|
+
disabled: disabled || readonly,
|
|
749
|
+
onClick: onDropPropertyClick(label),
|
|
750
|
+
uiSchema: uiSchema,
|
|
751
|
+
registry: registry
|
|
752
|
+
})))));
|
|
766
753
|
}
|
|
767
754
|
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
755
|
+
function generateTemplates() {
|
|
756
|
+
return {
|
|
757
|
+
ArrayFieldItemTemplate: ArrayFieldItemTemplate,
|
|
758
|
+
ArrayFieldTemplate: ArrayFieldTemplate,
|
|
759
|
+
BaseInputTemplate: BaseInputTemplate,
|
|
760
|
+
ButtonTemplates: {
|
|
761
|
+
AddButton: AddButton,
|
|
762
|
+
MoveDownButton: MoveDownButton,
|
|
763
|
+
MoveUpButton: MoveUpButton,
|
|
764
|
+
RemoveButton: RemoveButton,
|
|
765
|
+
SubmitButton: SubmitButton
|
|
766
|
+
},
|
|
767
|
+
DescriptionFieldTemplate: DescriptionField,
|
|
768
|
+
ErrorListTemplate: ErrorList,
|
|
769
|
+
FieldErrorTemplate: FieldErrorTemplate,
|
|
770
|
+
FieldHelpTemplate: FieldHelpTemplate,
|
|
771
|
+
FieldTemplate: FieldTemplate,
|
|
772
|
+
ObjectFieldTemplate: ObjectFieldTemplate,
|
|
773
|
+
TitleFieldTemplate: TitleField,
|
|
774
|
+
WrapIfAdditionalTemplate: WrapIfAdditionalTemplate
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
var Templates = /*#__PURE__*/generateTemplates();
|
|
787
778
|
|
|
779
|
+
/** The `CheckBoxWidget` is a widget for rendering boolean properties.
|
|
780
|
+
* It is typically used to represent a boolean.
|
|
781
|
+
*
|
|
782
|
+
* @param props - The `WidgetProps` for this component
|
|
783
|
+
*/
|
|
788
784
|
function CheckboxWidget(props) {
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
options,
|
|
809
|
-
formContext,
|
|
810
|
-
schema,
|
|
811
|
-
uiSchema,
|
|
785
|
+
var id = props.id,
|
|
786
|
+
value = props.value,
|
|
787
|
+
disabled = props.disabled,
|
|
788
|
+
readonly = props.readonly,
|
|
789
|
+
label = props.label,
|
|
790
|
+
autofocus = props.autofocus,
|
|
791
|
+
onChange = props.onChange,
|
|
792
|
+
onBlur = props.onBlur,
|
|
793
|
+
options = props.options,
|
|
794
|
+
onFocus = props.onFocus,
|
|
795
|
+
formContext = props.formContext,
|
|
796
|
+
schema = props.schema,
|
|
797
|
+
uiSchema = props.uiSchema,
|
|
798
|
+
_props$rawErrors = props.rawErrors,
|
|
799
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
|
|
800
|
+
var semanticProps = getSemanticProps({
|
|
801
|
+
options: options,
|
|
802
|
+
formContext: formContext,
|
|
803
|
+
uiSchema: uiSchema,
|
|
812
804
|
defaultSchemaProps: {
|
|
813
805
|
inverted: false
|
|
814
806
|
}
|
|
815
807
|
});
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
808
|
+
// Because an unchecked checkbox will cause html5 validation to fail, only add
|
|
809
|
+
// the "required" attribute if the field value must be "true", due to the
|
|
810
|
+
// "const" or "enum" keywords
|
|
811
|
+
var required = utils.schemaRequiresTrueValue(schema);
|
|
812
|
+
var _onChange = function _onChange(_, data) {
|
|
813
|
+
return onChange && onChange(data.checked);
|
|
814
|
+
};
|
|
815
|
+
var _onBlur = function _onBlur() {
|
|
816
|
+
return onBlur && onBlur(id, value);
|
|
817
|
+
};
|
|
818
|
+
var _onFocus = function _onFocus() {
|
|
819
|
+
return onFocus && onFocus(id, value);
|
|
820
|
+
};
|
|
821
|
+
var checked = value == "true" || value == true;
|
|
828
822
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Checkbox, _extends({
|
|
829
823
|
id: id,
|
|
824
|
+
name: id,
|
|
830
825
|
disabled: disabled || readonly,
|
|
831
826
|
autoFocus: autofocus
|
|
832
827
|
}, semanticProps, {
|
|
@@ -836,219 +831,206 @@ function CheckboxWidget(props) {
|
|
|
836
831
|
onBlur: _onBlur,
|
|
837
832
|
onFocus: _onFocus,
|
|
838
833
|
required: required,
|
|
839
|
-
label:
|
|
834
|
+
label: label || "",
|
|
835
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
840
836
|
}));
|
|
841
837
|
}
|
|
842
838
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
return updated.sort((a, b) => all.indexOf(a) > all.indexOf(b));
|
|
849
|
-
}
|
|
850
|
-
|
|
851
|
-
function deselectValue(value, selected) {
|
|
852
|
-
return selected.filter(v => v !== value);
|
|
853
|
-
}
|
|
854
|
-
|
|
839
|
+
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
840
|
+
* It is typically used to represent an array of enums.
|
|
841
|
+
*
|
|
842
|
+
* @param props - The `WidgetProps` for this component
|
|
843
|
+
*/
|
|
855
844
|
function CheckboxesWidget(props) {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
rawErrors = [],
|
|
870
|
-
registry
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
const semanticProps = getSemanticProps({
|
|
882
|
-
options,
|
|
883
|
-
formContext,
|
|
884
|
-
schema,
|
|
885
|
-
uiSchema,
|
|
845
|
+
var id = props.id,
|
|
846
|
+
disabled = props.disabled,
|
|
847
|
+
options = props.options,
|
|
848
|
+
value = props.value,
|
|
849
|
+
autofocus = props.autofocus,
|
|
850
|
+
readonly = props.readonly,
|
|
851
|
+
onChange = props.onChange,
|
|
852
|
+
onBlur = props.onBlur,
|
|
853
|
+
onFocus = props.onFocus,
|
|
854
|
+
formContext = props.formContext,
|
|
855
|
+
schema = props.schema,
|
|
856
|
+
uiSchema = props.uiSchema,
|
|
857
|
+
_props$rawErrors = props.rawErrors,
|
|
858
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors,
|
|
859
|
+
registry = props.registry;
|
|
860
|
+
var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, options);
|
|
861
|
+
var enumOptions = options.enumOptions,
|
|
862
|
+
enumDisabled = options.enumDisabled,
|
|
863
|
+
inline = options.inline;
|
|
864
|
+
var checkboxesValues = Array.isArray(value) ? value : [value];
|
|
865
|
+
var title = schema.title;
|
|
866
|
+
var semanticProps = getSemanticProps({
|
|
867
|
+
options: options,
|
|
868
|
+
formContext: formContext,
|
|
869
|
+
uiSchema: uiSchema,
|
|
886
870
|
defaultSchemaProps: {
|
|
887
871
|
inverted: false
|
|
888
872
|
}
|
|
889
873
|
});
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
874
|
+
var _onChange = function _onChange(index) {
|
|
875
|
+
return function (_ref) {
|
|
876
|
+
var checked = _ref.target.checked;
|
|
877
|
+
// eslint-disable-next-line no-shadow
|
|
878
|
+
if (checked) {
|
|
879
|
+
onChange(utils.enumOptionsSelectValue(index, checkboxesValues, enumOptions));
|
|
880
|
+
} else {
|
|
881
|
+
onChange(utils.enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
|
|
895
882
|
}
|
|
896
|
-
}
|
|
897
|
-
// eslint-disable-next-line no-shadow
|
|
898
|
-
const all = enumOptions.map(_ref2 => {
|
|
899
|
-
let {
|
|
900
|
-
value
|
|
901
|
-
} = _ref2;
|
|
902
|
-
return value;
|
|
903
|
-
});
|
|
904
|
-
|
|
905
|
-
if (checked) {
|
|
906
|
-
onChange(selectValue(option.value, value, all));
|
|
907
|
-
} else {
|
|
908
|
-
onChange(deselectValue(option.value, value));
|
|
909
|
-
}
|
|
883
|
+
};
|
|
910
884
|
};
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
885
|
+
var _onBlur = function _onBlur() {
|
|
886
|
+
return onBlur(id, value);
|
|
887
|
+
};
|
|
888
|
+
var _onFocus = function _onFocus() {
|
|
889
|
+
return onFocus(id, value);
|
|
890
|
+
};
|
|
891
|
+
var inlineOption = inline ? {
|
|
917
892
|
inline: true
|
|
918
893
|
} : {
|
|
919
894
|
grouped: true
|
|
920
895
|
};
|
|
921
896
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, title && /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
922
|
-
id: id
|
|
897
|
+
id: utils.titleId(id),
|
|
923
898
|
title: title,
|
|
899
|
+
schema: schema,
|
|
924
900
|
uiSchema: uiSchema,
|
|
925
901
|
registry: registry
|
|
926
902
|
}), /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Group, _extends({
|
|
927
|
-
id: id
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
903
|
+
id: id,
|
|
904
|
+
name: id
|
|
905
|
+
}, inlineOption), Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
906
|
+
var checked = utils.enumOptionsIsSelected(option.value, checkboxesValues);
|
|
907
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
931
908
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Checkbox, _extends({
|
|
932
|
-
id: id
|
|
933
|
-
|
|
909
|
+
id: utils.optionId(id, index),
|
|
910
|
+
name: id,
|
|
911
|
+
key: index,
|
|
934
912
|
label: option.label
|
|
935
913
|
}, semanticProps, {
|
|
936
914
|
checked: checked,
|
|
937
915
|
error: rawErrors.length > 0,
|
|
938
916
|
disabled: disabled || itemDisabled || readonly,
|
|
939
917
|
autoFocus: autofocus && index === 0,
|
|
940
|
-
onChange: _onChange(
|
|
918
|
+
onChange: _onChange(index),
|
|
941
919
|
onBlur: _onBlur,
|
|
942
|
-
onFocus: _onFocus
|
|
920
|
+
onFocus: _onFocus,
|
|
921
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
943
922
|
}));
|
|
944
923
|
})));
|
|
945
924
|
}
|
|
946
925
|
|
|
926
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
927
|
+
* It is typically used with a string property constrained with enum options.
|
|
928
|
+
*
|
|
929
|
+
* @param props - The `WidgetProps` for this component
|
|
930
|
+
*/
|
|
947
931
|
function RadioWidget(props) {
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
const _onChange = (event, _ref) => {
|
|
974
|
-
let {
|
|
975
|
-
value: eventValue
|
|
976
|
-
} = _ref;
|
|
977
|
-
return onChange && onChange(schema.type === "boolean" ? eventValue !== "false" : eventValue);
|
|
932
|
+
var id = props.id,
|
|
933
|
+
value = props.value,
|
|
934
|
+
required = props.required,
|
|
935
|
+
disabled = props.disabled,
|
|
936
|
+
readonly = props.readonly,
|
|
937
|
+
onChange = props.onChange,
|
|
938
|
+
onBlur = props.onBlur,
|
|
939
|
+
onFocus = props.onFocus,
|
|
940
|
+
options = props.options,
|
|
941
|
+
formContext = props.formContext,
|
|
942
|
+
uiSchema = props.uiSchema,
|
|
943
|
+
_props$rawErrors = props.rawErrors,
|
|
944
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
|
|
945
|
+
var enumOptions = options.enumOptions,
|
|
946
|
+
enumDisabled = options.enumDisabled,
|
|
947
|
+
emptyValue = options.emptyValue;
|
|
948
|
+
var semanticProps = getSemanticProps({
|
|
949
|
+
formContext: formContext,
|
|
950
|
+
options: options,
|
|
951
|
+
uiSchema: uiSchema
|
|
952
|
+
});
|
|
953
|
+
var _onChange = function _onChange(_, _ref) {
|
|
954
|
+
var eventValue = _ref.value;
|
|
955
|
+
return onChange(utils.enumOptionsValueForIndex(eventValue, enumOptions, emptyValue));
|
|
978
956
|
};
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
957
|
+
var _onBlur = function _onBlur() {
|
|
958
|
+
return onBlur(id, value);
|
|
959
|
+
};
|
|
960
|
+
var _onFocus = function _onFocus() {
|
|
961
|
+
return onFocus(id, value);
|
|
962
|
+
};
|
|
963
|
+
var inlineOption = options.inline ? {
|
|
985
964
|
inline: true
|
|
986
965
|
} : {
|
|
987
966
|
grouped: true
|
|
988
967
|
};
|
|
989
|
-
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Group, inlineOption, enumOptions.map((option,
|
|
990
|
-
|
|
968
|
+
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Group, _extends({}, inlineOption), Array.isArray(enumOptions) && enumOptions.map(function (option, index) {
|
|
969
|
+
var checked = utils.enumOptionsIsSelected(option.value, value);
|
|
970
|
+
var itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
|
|
991
971
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Field, _extends({
|
|
992
972
|
required: required,
|
|
993
973
|
control: semanticUiReact.Radio,
|
|
994
|
-
|
|
974
|
+
id: utils.optionId(id, index),
|
|
975
|
+
name: id
|
|
995
976
|
}, semanticProps, {
|
|
996
977
|
onFocus: _onFocus,
|
|
997
978
|
onBlur: _onBlur,
|
|
998
|
-
label: "" + option.label,
|
|
999
|
-
value: "" + option.value,
|
|
1000
|
-
error: rawErrors.length > 0,
|
|
1001
|
-
key: option.value + "-" + i,
|
|
1002
|
-
checked: value == option.value,
|
|
1003
979
|
onChange: _onChange,
|
|
1004
|
-
|
|
980
|
+
label: option.label,
|
|
981
|
+
value: String(index),
|
|
982
|
+
error: rawErrors.length > 0,
|
|
983
|
+
key: index,
|
|
984
|
+
checked: checked,
|
|
985
|
+
disabled: disabled || itemDisabled || readonly,
|
|
986
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1005
987
|
}));
|
|
1006
988
|
}));
|
|
1007
989
|
}
|
|
1008
990
|
|
|
991
|
+
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
992
|
+
* in a div, with the value along side it.
|
|
993
|
+
*
|
|
994
|
+
* @param props - The `WidgetProps` for this component
|
|
995
|
+
*/
|
|
1009
996
|
function RangeWidget(props) {
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
options,
|
|
1029
|
-
uiSchema,
|
|
997
|
+
var id = props.id,
|
|
998
|
+
value = props.value,
|
|
999
|
+
required = props.required,
|
|
1000
|
+
readonly = props.readonly,
|
|
1001
|
+
disabled = props.disabled,
|
|
1002
|
+
onChange = props.onChange,
|
|
1003
|
+
onBlur = props.onBlur,
|
|
1004
|
+
onFocus = props.onFocus,
|
|
1005
|
+
options = props.options,
|
|
1006
|
+
schema = props.schema,
|
|
1007
|
+
uiSchema = props.uiSchema,
|
|
1008
|
+
formContext = props.formContext,
|
|
1009
|
+
_props$rawErrors = props.rawErrors,
|
|
1010
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
|
|
1011
|
+
var semanticProps = getSemanticProps({
|
|
1012
|
+
formContext: formContext,
|
|
1013
|
+
options: options,
|
|
1014
|
+
uiSchema: uiSchema,
|
|
1030
1015
|
defaultSchemaProps: {
|
|
1031
1016
|
fluid: true
|
|
1032
1017
|
}
|
|
1033
|
-
});
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
target: {
|
|
1038
|
-
value
|
|
1039
|
-
}
|
|
1040
|
-
} = _ref;
|
|
1018
|
+
});
|
|
1019
|
+
// eslint-disable-next-line no-shadow
|
|
1020
|
+
var _onChange = function _onChange(_ref) {
|
|
1021
|
+
var value = _ref.target.value;
|
|
1041
1022
|
return onChange && onChange(value === "" ? options.emptyValue : value);
|
|
1042
1023
|
};
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1024
|
+
var _onBlur = function _onBlur() {
|
|
1025
|
+
return onBlur && onBlur(id, value);
|
|
1026
|
+
};
|
|
1027
|
+
var _onFocus = function _onFocus() {
|
|
1028
|
+
return onFocus && onFocus(id, value);
|
|
1029
|
+
};
|
|
1048
1030
|
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Input, _extends({
|
|
1049
1031
|
id: id,
|
|
1050
1032
|
key: id,
|
|
1051
|
-
name:
|
|
1033
|
+
name: id,
|
|
1052
1034
|
type: "range",
|
|
1053
1035
|
required: required,
|
|
1054
1036
|
disabled: disabled || readonly
|
|
@@ -1057,62 +1039,59 @@ function RangeWidget(props) {
|
|
|
1057
1039
|
error: rawErrors.length > 0,
|
|
1058
1040
|
onChange: _onChange,
|
|
1059
1041
|
onBlur: _onBlur,
|
|
1060
|
-
onFocus: _onFocus
|
|
1042
|
+
onFocus: _onFocus,
|
|
1043
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1061
1044
|
})), /*#__PURE__*/React__default["default"].createElement("span", null, value));
|
|
1062
1045
|
}
|
|
1063
1046
|
|
|
1064
|
-
/**
|
|
1065
|
-
*
|
|
1066
|
-
* @param {array} enumOptions- array of items for the dropdown
|
|
1067
|
-
* @param {array} enumDisabled - array of enum option values to disable
|
|
1068
|
-
* @returns {*}
|
|
1047
|
+
/**
|
|
1048
|
+
* Returns and creates an array format required for semantic drop down
|
|
1049
|
+
* @param {array} enumOptions- array of items for the dropdown
|
|
1050
|
+
* @param {array} enumDisabled - array of enum option values to disable
|
|
1051
|
+
* @returns {*}
|
|
1069
1052
|
*/
|
|
1070
|
-
|
|
1071
1053
|
function createDefaultValueOptionsForDropDown(enumOptions, enumDisabled) {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
let {
|
|
1077
|
-
label,
|
|
1078
|
-
value
|
|
1079
|
-
} = _ref;
|
|
1054
|
+
var disabledOptions = enumDisabled || [];
|
|
1055
|
+
var options = map__default["default"](enumOptions, function (_ref, index) {
|
|
1056
|
+
var label = _ref.label,
|
|
1057
|
+
value = _ref.value;
|
|
1080
1058
|
return {
|
|
1081
1059
|
disabled: disabledOptions.indexOf(value) !== -1,
|
|
1082
1060
|
key: label,
|
|
1083
1061
|
text: label,
|
|
1084
|
-
value
|
|
1062
|
+
value: String(index)
|
|
1085
1063
|
};
|
|
1086
1064
|
});
|
|
1087
1065
|
return options;
|
|
1088
1066
|
}
|
|
1089
|
-
|
|
1067
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
1068
|
+
* It is typically used with string properties constrained with enum options.
|
|
1069
|
+
*
|
|
1070
|
+
* @param props - The `WidgetProps` for this component
|
|
1071
|
+
*/
|
|
1090
1072
|
function SelectWidget(props) {
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
uiSchema,
|
|
1114
|
-
formContext,
|
|
1115
|
-
options,
|
|
1073
|
+
var schema = props.schema,
|
|
1074
|
+
uiSchema = props.uiSchema,
|
|
1075
|
+
formContext = props.formContext,
|
|
1076
|
+
id = props.id,
|
|
1077
|
+
options = props.options,
|
|
1078
|
+
label = props.label,
|
|
1079
|
+
required = props.required,
|
|
1080
|
+
disabled = props.disabled,
|
|
1081
|
+
readonly = props.readonly,
|
|
1082
|
+
value = props.value,
|
|
1083
|
+
multiple = props.multiple,
|
|
1084
|
+
placeholder = props.placeholder,
|
|
1085
|
+
autofocus = props.autofocus,
|
|
1086
|
+
onChange = props.onChange,
|
|
1087
|
+
onBlur = props.onBlur,
|
|
1088
|
+
onFocus = props.onFocus,
|
|
1089
|
+
_props$rawErrors = props.rawErrors,
|
|
1090
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
|
|
1091
|
+
var semanticProps = getSemanticProps({
|
|
1092
|
+
uiSchema: uiSchema,
|
|
1093
|
+
formContext: formContext,
|
|
1094
|
+
options: options,
|
|
1116
1095
|
defaultSchemaProps: {
|
|
1117
1096
|
inverted: "false",
|
|
1118
1097
|
selection: true,
|
|
@@ -1121,47 +1100,32 @@ function SelectWidget(props) {
|
|
|
1121
1100
|
upward: false
|
|
1122
1101
|
}
|
|
1123
1102
|
});
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
_ref2) => {
|
|
1133
|
-
let {
|
|
1134
|
-
value
|
|
1135
|
-
} = _ref2;
|
|
1136
|
-
return onChange && onChange(utils.processSelectValue(schema, value, options));
|
|
1137
|
-
}; // eslint-disable-next-line no-shadow
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
const _onBlur = _ref3 => {
|
|
1141
|
-
let {
|
|
1142
|
-
target: {
|
|
1143
|
-
value
|
|
1144
|
-
}
|
|
1145
|
-
} = _ref3;
|
|
1146
|
-
return onBlur && onBlur(id, utils.processSelectValue(schema, value, options));
|
|
1103
|
+
var enumDisabled = options.enumDisabled,
|
|
1104
|
+
enumOptions = options.enumOptions,
|
|
1105
|
+
optEmptyVal = options.emptyValue;
|
|
1106
|
+
var emptyValue = multiple ? [] : "";
|
|
1107
|
+
var dropdownOptions = createDefaultValueOptionsForDropDown(enumOptions, enumDisabled);
|
|
1108
|
+
var _onChange = function _onChange(_, _ref2) {
|
|
1109
|
+
var value = _ref2.value;
|
|
1110
|
+
return onChange(utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1147
1111
|
};
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
target: {
|
|
1153
|
-
value
|
|
1154
|
-
}
|
|
1155
|
-
} = _ref4;
|
|
1156
|
-
return onFocus && onFocus(id, utils.processSelectValue(schema, value, options));
|
|
1112
|
+
// eslint-disable-next-line no-shadow
|
|
1113
|
+
var _onBlur = function _onBlur(_, _ref3) {
|
|
1114
|
+
var value = _ref3.target.value;
|
|
1115
|
+
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1157
1116
|
};
|
|
1158
|
-
|
|
1117
|
+
var _onFocus = function _onFocus(_, _ref4) {
|
|
1118
|
+
var value = _ref4.target.value;
|
|
1119
|
+
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, optEmptyVal));
|
|
1120
|
+
};
|
|
1121
|
+
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1159
1122
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.Dropdown, _extends({
|
|
1160
1123
|
key: id,
|
|
1161
|
-
|
|
1124
|
+
id: id,
|
|
1125
|
+
name: id,
|
|
1162
1126
|
label: label || schema.title,
|
|
1163
1127
|
multiple: typeof multiple === "undefined" ? false : multiple,
|
|
1164
|
-
value: typeof value === "undefined" ? emptyValue :
|
|
1128
|
+
value: typeof value === "undefined" ? emptyValue : selectedIndexes,
|
|
1165
1129
|
error: rawErrors.length > 0,
|
|
1166
1130
|
disabled: disabled,
|
|
1167
1131
|
placeholder: placeholder
|
|
@@ -1172,95 +1136,107 @@ function SelectWidget(props) {
|
|
|
1172
1136
|
options: dropdownOptions,
|
|
1173
1137
|
onChange: _onChange,
|
|
1174
1138
|
onBlur: _onBlur,
|
|
1175
|
-
onFocus: _onFocus
|
|
1139
|
+
onFocus: _onFocus,
|
|
1140
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1176
1141
|
}));
|
|
1177
1142
|
}
|
|
1178
1143
|
|
|
1144
|
+
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1145
|
+
*
|
|
1146
|
+
* @param props - The `WidgetProps` for this component
|
|
1147
|
+
*/
|
|
1179
1148
|
function TextareaWidget(props) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
formContext,
|
|
1202
|
-
options,
|
|
1149
|
+
var id = props.id,
|
|
1150
|
+
placeholder = props.placeholder,
|
|
1151
|
+
value = props.value,
|
|
1152
|
+
required = props.required,
|
|
1153
|
+
disabled = props.disabled,
|
|
1154
|
+
autofocus = props.autofocus,
|
|
1155
|
+
label = props.label,
|
|
1156
|
+
readonly = props.readonly,
|
|
1157
|
+
onBlur = props.onBlur,
|
|
1158
|
+
onFocus = props.onFocus,
|
|
1159
|
+
onChange = props.onChange,
|
|
1160
|
+
options = props.options,
|
|
1161
|
+
schema = props.schema,
|
|
1162
|
+
uiSchema = props.uiSchema,
|
|
1163
|
+
formContext = props.formContext,
|
|
1164
|
+
registry = props.registry,
|
|
1165
|
+
_props$rawErrors = props.rawErrors,
|
|
1166
|
+
rawErrors = _props$rawErrors === void 0 ? [] : _props$rawErrors;
|
|
1167
|
+
var semanticProps = getSemanticProps({
|
|
1168
|
+
formContext: formContext,
|
|
1169
|
+
options: options,
|
|
1203
1170
|
defaultSchemaProps: {
|
|
1204
1171
|
inverted: false
|
|
1205
1172
|
}
|
|
1206
1173
|
});
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
const _onChange = _ref => {
|
|
1212
|
-
let {
|
|
1213
|
-
target: {
|
|
1214
|
-
value
|
|
1215
|
-
}
|
|
1216
|
-
} = _ref;
|
|
1174
|
+
var schemaUtils = registry.schemaUtils;
|
|
1175
|
+
// eslint-disable-next-line no-shadow
|
|
1176
|
+
var _onChange = function _onChange(_ref) {
|
|
1177
|
+
var value = _ref.target.value;
|
|
1217
1178
|
return onChange && onChange(value === "" ? options.emptyValue : value);
|
|
1218
1179
|
};
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1180
|
+
var _onBlur = function _onBlur() {
|
|
1181
|
+
return onBlur && onBlur(id, value);
|
|
1182
|
+
};
|
|
1183
|
+
var _onFocus = function _onFocus() {
|
|
1184
|
+
return onFocus && onFocus(id, value);
|
|
1185
|
+
};
|
|
1186
|
+
var displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema);
|
|
1225
1187
|
return /*#__PURE__*/React__default["default"].createElement(semanticUiReact.Form.TextArea, _extends({
|
|
1226
1188
|
id: id,
|
|
1227
1189
|
key: id,
|
|
1190
|
+
name: id,
|
|
1228
1191
|
label: displayLabel ? label || schema.title : false,
|
|
1229
1192
|
placeholder: placeholder,
|
|
1230
1193
|
autoFocus: autofocus,
|
|
1231
1194
|
required: required,
|
|
1232
|
-
disabled: disabled || readonly
|
|
1233
|
-
name: name
|
|
1195
|
+
disabled: disabled || readonly
|
|
1234
1196
|
}, semanticProps, {
|
|
1235
1197
|
value: value || "",
|
|
1236
1198
|
error: rawErrors.length > 0,
|
|
1237
1199
|
rows: options.rows || 5,
|
|
1238
1200
|
onChange: _onChange,
|
|
1239
1201
|
onBlur: _onBlur,
|
|
1240
|
-
onFocus: _onFocus
|
|
1202
|
+
onFocus: _onFocus,
|
|
1203
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1241
1204
|
}));
|
|
1242
1205
|
}
|
|
1243
1206
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1207
|
+
function generateWidgets() {
|
|
1208
|
+
return {
|
|
1209
|
+
CheckboxWidget: CheckboxWidget,
|
|
1210
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
1211
|
+
RadioWidget: RadioWidget,
|
|
1212
|
+
RangeWidget: RangeWidget,
|
|
1213
|
+
SelectWidget: SelectWidget,
|
|
1214
|
+
TextareaWidget: TextareaWidget
|
|
1215
|
+
};
|
|
1216
|
+
}
|
|
1217
|
+
var Widgets = /*#__PURE__*/generateWidgets();
|
|
1252
1218
|
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1219
|
+
function generateTheme() {
|
|
1220
|
+
return {
|
|
1221
|
+
templates: generateTemplates(),
|
|
1222
|
+
widgets: generateWidgets(),
|
|
1223
|
+
_internalFormWrapper: semanticUiReact.Form
|
|
1224
|
+
};
|
|
1225
|
+
}
|
|
1226
|
+
var Theme = /*#__PURE__*/generateTheme();
|
|
1258
1227
|
|
|
1259
|
-
|
|
1228
|
+
function generateForm() {
|
|
1229
|
+
return core.withTheme(generateTheme());
|
|
1230
|
+
}
|
|
1231
|
+
var SemanticUIForm = /*#__PURE__*/generateForm();
|
|
1260
1232
|
|
|
1261
1233
|
exports.Form = SemanticUIForm;
|
|
1262
1234
|
exports.Templates = Templates;
|
|
1263
1235
|
exports.Theme = Theme;
|
|
1264
1236
|
exports.Widgets = Widgets;
|
|
1265
1237
|
exports["default"] = SemanticUIForm;
|
|
1238
|
+
exports.generateForm = generateForm;
|
|
1239
|
+
exports.generateTemplates = generateTemplates;
|
|
1240
|
+
exports.generateTheme = generateTheme;
|
|
1241
|
+
exports.generateWidgets = generateWidgets;
|
|
1266
1242
|
//# sourceMappingURL=semantic-ui.cjs.development.js.map
|