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