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