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