@rjsf/antd 5.0.0-beta.9 → 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/antd.cjs.development.js +1062 -1063
- package/dist/antd.cjs.development.js.map +1 -1
- package/dist/antd.cjs.production.min.js +1 -1
- package/dist/antd.cjs.production.min.js.map +1 -1
- package/dist/antd.esm.js +1058 -1065
- package/dist/antd.esm.js.map +1 -1
- package/dist/antd.umd.development.js +1065 -1067
- package/dist/antd.umd.development.js.map +1 -1
- package/dist/antd.umd.production.min.js +1 -1
- package/dist/antd.umd.production.min.js.map +1 -1
- package/dist/index.d.ts +16 -61
- package/package.json +25 -34
- package/dist/components/DatePicker/index.d.ts +0 -17
- package/dist/templates/ArrayFieldItemTemplate/index.d.ts +0 -21
- package/dist/templates/ArrayFieldTemplate/index.d.ts +0 -2
- package/dist/templates/BaseInputTemplate/index.d.ts +0 -15
- package/dist/templates/DescriptionField/index.d.ts +0 -5
- package/dist/templates/ErrorList/index.d.ts +0 -4
- package/dist/templates/FieldErrorTemplate/index.d.ts +0 -5
- package/dist/templates/FieldTemplate/WrapIfAdditional.d.ts +0 -16
- package/dist/templates/FieldTemplate/index.d.ts +0 -23
- package/dist/templates/IconButton/index.d.ts +0 -5
- package/dist/templates/ObjectFieldTemplate/index.d.ts +0 -2
- package/dist/templates/SubmitButton/index.d.ts +0 -4
- package/dist/templates/TitleField/index.d.ts +0 -2
- package/dist/widgets/AltDateTimeWidget/index.d.ts +0 -13
- package/dist/widgets/AltDateWidget/index.d.ts +0 -26
- package/dist/widgets/CheckboxWidget/index.d.ts +0 -13
- package/dist/widgets/CheckboxesWidget/index.d.ts +0 -13
- package/dist/widgets/DateTimeWidget/index.d.ts +0 -12
- package/dist/widgets/DateWidget/index.d.ts +0 -12
- package/dist/widgets/PasswordWidget/index.d.ts +0 -13
- package/dist/widgets/RadioWidget/index.d.ts +0 -14
- package/dist/widgets/RangeWidget/index.d.ts +0 -15
- package/dist/widgets/SelectWidget/index.d.ts +0 -21
- package/dist/widgets/TextareaWidget/index.d.ts +0 -13
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('react'), require('antd/lib/button'), require('antd/lib/col'), require('antd/lib/row'), require('@rjsf/utils'), require('classnames'), require('antd/lib/config-provider/context'), require('antd/lib/input'), require('antd/lib/input-number'), require('antd/lib/alert'), require('antd/lib/list'), require('antd/lib/space'), require('@ant-design/icons/ExclamationCircleOutlined'), require('@ant-design/icons/ArrowDownOutlined'), require('@ant-design/icons/ArrowUpOutlined'), require('@ant-design/icons/DeleteOutlined'), require('@ant-design/icons/PlusCircleOutlined'), require('antd/lib/form'), require('lodash-es/isObject'), require('lodash-es/isNumber'), require('antd/lib/checkbox'), require('dayjs'), require('rc-picker/lib/generate/dayjs'), require('antd/lib/date-picker/generatePicker'), require('antd/lib/radio'), require('antd/lib/slider'), require('antd/lib/select')) :
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '@rjsf/core', 'react', 'antd/lib/button', 'antd/lib/col', 'antd/lib/row', '@rjsf/utils', 'classnames', 'antd/lib/config-provider/context', 'antd/lib/input', 'antd/lib/input-number', 'antd/lib/alert', 'antd/lib/list', 'antd/lib/space', '@ant-design/icons/ExclamationCircleOutlined', '@ant-design/icons/ArrowDownOutlined', '@ant-design/icons/ArrowUpOutlined', '@ant-design/icons/DeleteOutlined', '@ant-design/icons/PlusCircleOutlined', 'antd/lib/form', 'lodash-es/isObject', 'lodash-es/isNumber', 'antd/lib/checkbox', 'dayjs', 'rc-picker/lib/generate/dayjs', 'antd/lib/date-picker/generatePicker', 'antd/lib/radio', 'antd/lib/slider', 'antd/lib/select'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/antd"] = {}, global.core, global.React, global.Button, global.Col, global.Row, global.utils, global.classNames, global.context, global.Input, global.InputNumber, global.Alert, global.List, global.Space, global.ExclamationCircleOutlined, global.ArrowDownOutlined, global.ArrowUpOutlined, global.DeleteOutlined, global.PlusCircleOutlined, global.Form$1, global.isObject, global.isNumber, global.Checkbox, global.dayjs, global.dayjsGenerateConfig, global.generatePicker, global.Radio, global.Slider, global.Select));
|
|
5
|
-
})(this, (function (exports, core, React, Button, Col, Row, utils, classNames, context, Input, InputNumber, Alert, List, Space, ExclamationCircleOutlined, ArrowDownOutlined, ArrowUpOutlined, DeleteOutlined, PlusCircleOutlined, Form$1, isObject, isNumber, Checkbox, dayjs, dayjsGenerateConfig, generatePicker, Radio, Slider, Select) { 'use strict';
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('react'), require('antd/lib/button'), require('antd/lib/col'), require('antd/lib/row'), require('@rjsf/utils'), require('classnames'), require('antd/lib/config-provider/context'), require('antd/lib/input'), require('antd/lib/input-number'), require('antd/lib/alert'), require('antd/lib/list'), require('antd/lib/space'), require('@ant-design/icons/ExclamationCircleOutlined'), require('@ant-design/icons/ArrowDownOutlined'), require('@ant-design/icons/ArrowUpOutlined'), require('@ant-design/icons/DeleteOutlined'), require('@ant-design/icons/PlusCircleOutlined'), require('antd/lib/form'), require('lodash-es/isObject'), require('lodash-es/isNumber'), require('lodash-es/isString'), require('antd/lib/checkbox'), require('dayjs'), require('rc-picker/lib/generate/dayjs'), require('antd/lib/date-picker/generatePicker'), require('antd/lib/radio'), require('antd/lib/slider'), require('antd/lib/select')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@rjsf/core', 'react', 'antd/lib/button', 'antd/lib/col', 'antd/lib/row', '@rjsf/utils', 'classnames', 'antd/lib/config-provider/context', 'antd/lib/input', 'antd/lib/input-number', 'antd/lib/alert', 'antd/lib/list', 'antd/lib/space', '@ant-design/icons/ExclamationCircleOutlined', '@ant-design/icons/ArrowDownOutlined', '@ant-design/icons/ArrowUpOutlined', '@ant-design/icons/DeleteOutlined', '@ant-design/icons/PlusCircleOutlined', 'antd/lib/form', 'lodash-es/isObject', 'lodash-es/isNumber', 'lodash-es/isString', 'antd/lib/checkbox', 'dayjs', 'rc-picker/lib/generate/dayjs', 'antd/lib/date-picker/generatePicker', 'antd/lib/radio', 'antd/lib/slider', 'antd/lib/select'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/antd"] = {}, global.core, global.React, global.Button, global.Col, global.Row, global.utils, global.classNames, global.context, global.Input, global.InputNumber, global.Alert, global.List, global.Space, global.ExclamationCircleOutlined, global.ArrowDownOutlined, global.ArrowUpOutlined, global.DeleteOutlined, global.PlusCircleOutlined, global.Form$1, global.isObject, global.isNumber, global.isString, global.Checkbox, global.dayjs, global.dayjsGenerateConfig, global.generatePicker, global.Radio, global.Slider, global.Select));
|
|
5
|
+
})(this, (function (exports, core, React, Button, Col, Row, utils, classNames, context, Input, InputNumber, Alert, List, Space, ExclamationCircleOutlined, ArrowDownOutlined, ArrowUpOutlined, DeleteOutlined, PlusCircleOutlined, Form$1, isObject, isNumber, isString, Checkbox, dayjs, dayjsGenerateConfig, generatePicker, Radio, Slider, Select) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
8
|
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form$1);
|
|
25
25
|
var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
|
|
26
26
|
var isNumber__default = /*#__PURE__*/_interopDefaultLegacy(isNumber);
|
|
27
|
+
var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
|
|
27
28
|
var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
|
|
28
29
|
var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
|
|
29
30
|
var dayjsGenerateConfig__default = /*#__PURE__*/_interopDefaultLegacy(dayjsGenerateConfig);
|
|
@@ -32,38 +33,38 @@
|
|
|
32
33
|
var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
|
|
33
34
|
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
var BTN_GRP_STYLE = {
|
|
36
37
|
width: "100%"
|
|
37
38
|
};
|
|
38
|
-
|
|
39
|
+
var BTN_STYLE = {
|
|
39
40
|
width: "calc(100% / 3)"
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
MoveDownButton,
|
|
60
|
-
MoveUpButton,
|
|
61
|
-
RemoveButton
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
rowGutter = 24,
|
|
65
|
-
|
|
66
|
-
|
|
42
|
+
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
43
|
+
*
|
|
44
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
45
|
+
*/
|
|
46
|
+
function ArrayFieldItemTemplate(props) {
|
|
47
|
+
var children = props.children,
|
|
48
|
+
disabled = props.disabled,
|
|
49
|
+
hasMoveDown = props.hasMoveDown,
|
|
50
|
+
hasMoveUp = props.hasMoveUp,
|
|
51
|
+
hasRemove = props.hasRemove,
|
|
52
|
+
hasToolbar = props.hasToolbar,
|
|
53
|
+
index = props.index,
|
|
54
|
+
onDropIndexClick = props.onDropIndexClick,
|
|
55
|
+
onReorderClick = props.onReorderClick,
|
|
56
|
+
readonly = props.readonly,
|
|
57
|
+
registry = props.registry,
|
|
58
|
+
uiSchema = props.uiSchema;
|
|
59
|
+
var _registry$templates$B = registry.templates.ButtonTemplates,
|
|
60
|
+
MoveDownButton = _registry$templates$B.MoveDownButton,
|
|
61
|
+
MoveUpButton = _registry$templates$B.MoveUpButton,
|
|
62
|
+
RemoveButton = _registry$templates$B.RemoveButton;
|
|
63
|
+
var _registry$formContext = registry.formContext,
|
|
64
|
+
_registry$formContext2 = _registry$formContext.rowGutter,
|
|
65
|
+
rowGutter = _registry$formContext2 === void 0 ? 24 : _registry$formContext2,
|
|
66
|
+
_registry$formContext3 = _registry$formContext.toolbarAlign,
|
|
67
|
+
toolbarAlign = _registry$formContext3 === void 0 ? "top" : _registry$formContext3;
|
|
67
68
|
return /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
68
69
|
align: toolbarAlign,
|
|
69
70
|
key: "array-item-" + index,
|
|
@@ -78,177 +79,181 @@
|
|
|
78
79
|
disabled: disabled || readonly || !hasMoveUp,
|
|
79
80
|
onClick: onReorderClick(index, index - 1),
|
|
80
81
|
style: BTN_STYLE,
|
|
81
|
-
uiSchema: uiSchema
|
|
82
|
+
uiSchema: uiSchema,
|
|
83
|
+
registry: registry
|
|
82
84
|
}), (hasMoveUp || hasMoveDown) && /*#__PURE__*/React__default["default"].createElement(MoveDownButton, {
|
|
83
85
|
disabled: disabled || readonly || !hasMoveDown,
|
|
84
86
|
onClick: onReorderClick(index, index + 1),
|
|
85
87
|
style: BTN_STYLE,
|
|
86
|
-
uiSchema: uiSchema
|
|
88
|
+
uiSchema: uiSchema,
|
|
89
|
+
registry: registry
|
|
87
90
|
}), hasRemove && /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
88
91
|
disabled: disabled || readonly,
|
|
89
92
|
onClick: onDropIndexClick(index),
|
|
90
93
|
style: BTN_STYLE,
|
|
91
|
-
uiSchema: uiSchema
|
|
94
|
+
uiSchema: uiSchema,
|
|
95
|
+
registry: registry
|
|
92
96
|
}))));
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
ArrayFieldItemTemplate.defaultProps = {
|
|
96
|
-
formContext: {}
|
|
97
|
-
};
|
|
97
|
+
}
|
|
98
98
|
|
|
99
99
|
function _extends() {
|
|
100
100
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
101
101
|
for (var i = 1; i < arguments.length; i++) {
|
|
102
102
|
var source = arguments[i];
|
|
103
|
-
|
|
104
103
|
for (var key in source) {
|
|
105
104
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
106
105
|
target[key] = source[key];
|
|
107
106
|
}
|
|
108
107
|
}
|
|
109
108
|
}
|
|
110
|
-
|
|
111
109
|
return target;
|
|
112
110
|
};
|
|
113
111
|
return _extends.apply(this, arguments);
|
|
114
112
|
}
|
|
113
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
114
|
+
if (source == null) return {};
|
|
115
|
+
var target = {};
|
|
116
|
+
var sourceKeys = Object.keys(source);
|
|
117
|
+
var key, i;
|
|
118
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
119
|
+
key = sourceKeys[i];
|
|
120
|
+
if (excluded.indexOf(key) >= 0) continue;
|
|
121
|
+
target[key] = source[key];
|
|
122
|
+
}
|
|
123
|
+
return target;
|
|
124
|
+
}
|
|
115
125
|
|
|
116
|
-
|
|
126
|
+
var _excluded$1 = ["key"];
|
|
127
|
+
var DESCRIPTION_COL_STYLE$1 = {
|
|
117
128
|
paddingBottom: "8px"
|
|
118
129
|
};
|
|
130
|
+
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
131
|
+
*
|
|
132
|
+
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
133
|
+
*/
|
|
134
|
+
function ArrayFieldTemplate(props) {
|
|
135
|
+
var canAdd = props.canAdd,
|
|
136
|
+
className = props.className,
|
|
137
|
+
disabled = props.disabled,
|
|
138
|
+
formContext = props.formContext,
|
|
139
|
+
idSchema = props.idSchema,
|
|
140
|
+
items = props.items,
|
|
141
|
+
onAddClick = props.onAddClick,
|
|
142
|
+
readonly = props.readonly,
|
|
143
|
+
registry = props.registry,
|
|
144
|
+
required = props.required,
|
|
145
|
+
schema = props.schema,
|
|
146
|
+
title = props.title,
|
|
147
|
+
uiSchema = props.uiSchema;
|
|
148
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
149
|
+
var ArrayFieldDescriptionTemplate = utils.getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
|
|
150
|
+
var ArrayFieldItemTemplate = utils.getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
|
|
151
|
+
var ArrayFieldTitleTemplate = utils.getTemplate("ArrayFieldTitleTemplate", registry, uiOptions);
|
|
152
|
+
// Button templates are not overridden in the uiSchema
|
|
153
|
+
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
154
|
+
var _formContext$labelAli = formContext.labelAlign,
|
|
155
|
+
labelAlign = _formContext$labelAli === void 0 ? "right" : _formContext$labelAli,
|
|
156
|
+
_formContext$rowGutte = formContext.rowGutter,
|
|
157
|
+
rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
|
|
158
|
+
return /*#__PURE__*/React__default["default"].createElement(context.ConfigConsumer, null, function (configProps) {
|
|
159
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
160
|
+
var prefixCls = getPrefixCls("form");
|
|
161
|
+
var labelClsBasic = prefixCls + "-item-label";
|
|
162
|
+
var labelColClassName = classNames__default["default"](labelClsBasic, labelAlign === "left" && labelClsBasic + "-left"
|
|
163
|
+
// labelCol.className,
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
return /*#__PURE__*/React__default["default"].createElement("fieldset", {
|
|
167
|
+
className: className,
|
|
168
|
+
id: idSchema.$id
|
|
169
|
+
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
170
|
+
gutter: rowGutter
|
|
171
|
+
}, (uiOptions.title || title) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
172
|
+
className: labelColClassName,
|
|
173
|
+
span: 24
|
|
174
|
+
}, /*#__PURE__*/React__default["default"].createElement(ArrayFieldTitleTemplate, {
|
|
175
|
+
idSchema: idSchema,
|
|
176
|
+
required: required,
|
|
177
|
+
title: uiOptions.title || title,
|
|
178
|
+
schema: schema,
|
|
179
|
+
uiSchema: uiSchema,
|
|
180
|
+
registry: registry
|
|
181
|
+
})), (uiOptions.description || schema.description) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
182
|
+
span: 24,
|
|
183
|
+
style: DESCRIPTION_COL_STYLE$1
|
|
184
|
+
}, /*#__PURE__*/React__default["default"].createElement(ArrayFieldDescriptionTemplate, {
|
|
185
|
+
description: uiOptions.description || schema.description || "",
|
|
186
|
+
idSchema: idSchema,
|
|
187
|
+
schema: schema,
|
|
188
|
+
uiSchema: uiSchema,
|
|
189
|
+
registry: registry
|
|
190
|
+
})), /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
191
|
+
className: "row array-item-list",
|
|
192
|
+
span: 24
|
|
193
|
+
}, items && items.map(function (_ref) {
|
|
194
|
+
var key = _ref.key,
|
|
195
|
+
itemProps = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
196
|
+
return /*#__PURE__*/React__default["default"].createElement(ArrayFieldItemTemplate, _extends({
|
|
197
|
+
key: key
|
|
198
|
+
}, itemProps));
|
|
199
|
+
})), canAdd && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
200
|
+
span: 24
|
|
201
|
+
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
202
|
+
gutter: rowGutter,
|
|
203
|
+
justify: "end"
|
|
204
|
+
}, /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
205
|
+
flex: "192px"
|
|
206
|
+
}, /*#__PURE__*/React__default["default"].createElement(AddButton, {
|
|
207
|
+
className: "array-item-add",
|
|
208
|
+
disabled: disabled || readonly,
|
|
209
|
+
onClick: onAddClick,
|
|
210
|
+
uiSchema: uiSchema,
|
|
211
|
+
registry: registry
|
|
212
|
+
}))))));
|
|
213
|
+
});
|
|
214
|
+
}
|
|
119
215
|
|
|
120
|
-
|
|
121
|
-
let {
|
|
122
|
-
canAdd,
|
|
123
|
-
className,
|
|
124
|
-
disabled,
|
|
125
|
-
formContext,
|
|
126
|
-
// formData,
|
|
127
|
-
idSchema,
|
|
128
|
-
items,
|
|
129
|
-
onAddClick,
|
|
130
|
-
prefixCls,
|
|
131
|
-
readonly,
|
|
132
|
-
registry,
|
|
133
|
-
required,
|
|
134
|
-
schema,
|
|
135
|
-
title,
|
|
136
|
-
uiSchema
|
|
137
|
-
} = _ref;
|
|
138
|
-
const uiOptions = utils.getUiOptions(uiSchema);
|
|
139
|
-
const ArrayFieldDescriptionTemplate = utils.getTemplate("ArrayFieldDescriptionTemplate", registry, uiOptions);
|
|
140
|
-
const ArrayFieldItemTemplate = utils.getTemplate("ArrayFieldItemTemplate", registry, uiOptions);
|
|
141
|
-
const ArrayFieldTitleTemplate = utils.getTemplate("ArrayFieldTitleTemplate", registry, uiOptions); // Button templates are not overridden in the uiSchema
|
|
142
|
-
|
|
143
|
-
const {
|
|
144
|
-
ButtonTemplates: {
|
|
145
|
-
AddButton
|
|
146
|
-
}
|
|
147
|
-
} = registry.templates;
|
|
148
|
-
const {
|
|
149
|
-
labelAlign = "right",
|
|
150
|
-
rowGutter = 24
|
|
151
|
-
} = formContext;
|
|
152
|
-
const labelClsBasic = prefixCls + "-item-label";
|
|
153
|
-
const labelColClassName = classNames__default["default"](labelClsBasic, labelAlign === "left" && labelClsBasic + "-left" // labelCol.className,
|
|
154
|
-
);
|
|
155
|
-
return /*#__PURE__*/React__default["default"].createElement("fieldset", {
|
|
156
|
-
className: className,
|
|
157
|
-
id: idSchema.$id
|
|
158
|
-
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
159
|
-
gutter: rowGutter
|
|
160
|
-
}, (uiOptions.title || title) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
161
|
-
className: labelColClassName,
|
|
162
|
-
span: 24
|
|
163
|
-
}, /*#__PURE__*/React__default["default"].createElement(ArrayFieldTitleTemplate, {
|
|
164
|
-
idSchema: idSchema,
|
|
165
|
-
required: required,
|
|
166
|
-
title: uiOptions.title || title,
|
|
167
|
-
uiSchema: uiSchema,
|
|
168
|
-
registry: registry
|
|
169
|
-
})), (uiOptions.description || schema.description) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
170
|
-
span: 24,
|
|
171
|
-
style: DESCRIPTION_COL_STYLE$1
|
|
172
|
-
}, /*#__PURE__*/React__default["default"].createElement(ArrayFieldDescriptionTemplate, {
|
|
173
|
-
description: uiOptions.description || schema.description,
|
|
174
|
-
idSchema: idSchema,
|
|
175
|
-
uiSchema: uiSchema,
|
|
176
|
-
registry: registry
|
|
177
|
-
})), /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
178
|
-
className: "row array-item-list",
|
|
179
|
-
span: 24
|
|
180
|
-
}, items && items.map(itemProps => /*#__PURE__*/React__default["default"].createElement(ArrayFieldItemTemplate, _extends({}, itemProps, {
|
|
181
|
-
formContext: formContext
|
|
182
|
-
})))), canAdd && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
183
|
-
span: 24
|
|
184
|
-
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
185
|
-
gutter: rowGutter,
|
|
186
|
-
justify: "end"
|
|
187
|
-
}, /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
188
|
-
flex: "192px"
|
|
189
|
-
}, /*#__PURE__*/React__default["default"].createElement(AddButton, {
|
|
190
|
-
className: "array-item-add",
|
|
191
|
-
disabled: disabled || readonly,
|
|
192
|
-
onClick: onAddClick,
|
|
193
|
-
uiSchema: uiSchema
|
|
194
|
-
}))))));
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
var ArrayFieldTemplate$1 = /*#__PURE__*/context.withConfigConsumer({
|
|
198
|
-
prefixCls: "form"
|
|
199
|
-
})(ArrayFieldTemplate);
|
|
200
|
-
|
|
201
|
-
const INPUT_STYLE$2 = {
|
|
216
|
+
var INPUT_STYLE$2 = {
|
|
202
217
|
width: "100%"
|
|
203
218
|
};
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
readonlyAsDisabled = true
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
let {
|
|
232
|
-
target
|
|
233
|
-
} = _ref2;
|
|
219
|
+
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
220
|
+
* It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
|
|
221
|
+
* It can be customized/overridden for other themes or individual implementations as needed.
|
|
222
|
+
*
|
|
223
|
+
* @param props - The `WidgetProps` for this template
|
|
224
|
+
*/
|
|
225
|
+
function BaseInputTemplate(props) {
|
|
226
|
+
var disabled = props.disabled,
|
|
227
|
+
formContext = props.formContext,
|
|
228
|
+
id = props.id,
|
|
229
|
+
onBlur = props.onBlur,
|
|
230
|
+
onChange = props.onChange,
|
|
231
|
+
onFocus = props.onFocus,
|
|
232
|
+
options = props.options,
|
|
233
|
+
placeholder = props.placeholder,
|
|
234
|
+
readonly = props.readonly,
|
|
235
|
+
schema = props.schema,
|
|
236
|
+
value = props.value,
|
|
237
|
+
type = props.type;
|
|
238
|
+
var inputProps = utils.getInputProps(schema, type, options, false);
|
|
239
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
240
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
241
|
+
var handleNumberChange = function handleNumberChange(nextValue) {
|
|
242
|
+
return onChange(nextValue);
|
|
243
|
+
};
|
|
244
|
+
var handleTextChange = function handleTextChange(_ref) {
|
|
245
|
+
var target = _ref.target;
|
|
234
246
|
return onChange(target.value === "" ? options.emptyValue : target.value);
|
|
235
247
|
};
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
let {
|
|
239
|
-
target
|
|
240
|
-
} = _ref3;
|
|
248
|
+
var handleBlur = function handleBlur(_ref2) {
|
|
249
|
+
var target = _ref2.target;
|
|
241
250
|
return onBlur(id, target.value);
|
|
242
251
|
};
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
let {
|
|
246
|
-
target
|
|
247
|
-
} = _ref4;
|
|
252
|
+
var handleFocus = function handleFocus(_ref3) {
|
|
253
|
+
var target = _ref3.target;
|
|
248
254
|
return onFocus(id, target.value);
|
|
249
255
|
};
|
|
250
|
-
|
|
251
|
-
const input = inputProps.type === "number" || inputProps.type === "integer" ? /*#__PURE__*/React__default["default"].createElement(InputNumber__default["default"], _extends({
|
|
256
|
+
var input = inputProps.type === "number" || inputProps.type === "integer" ? /*#__PURE__*/React__default["default"].createElement(InputNumber__default["default"], _extends({
|
|
252
257
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
253
258
|
id: id,
|
|
254
259
|
name: id,
|
|
@@ -257,9 +262,10 @@
|
|
|
257
262
|
onFocus: !readonly ? handleFocus : undefined,
|
|
258
263
|
placeholder: placeholder,
|
|
259
264
|
style: INPUT_STYLE$2,
|
|
260
|
-
list: schema.examples ?
|
|
265
|
+
list: schema.examples ? utils.examplesId(id) : undefined
|
|
261
266
|
}, inputProps, {
|
|
262
|
-
value: value
|
|
267
|
+
value: value,
|
|
268
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
263
269
|
})) : /*#__PURE__*/React__default["default"].createElement(Input__default["default"], _extends({
|
|
264
270
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
265
271
|
id: id,
|
|
@@ -269,62 +275,66 @@
|
|
|
269
275
|
onFocus: !readonly ? handleFocus : undefined,
|
|
270
276
|
placeholder: placeholder,
|
|
271
277
|
style: INPUT_STYLE$2,
|
|
272
|
-
list: schema.examples ?
|
|
278
|
+
list: schema.examples ? utils.examplesId(id) : undefined
|
|
273
279
|
}, inputProps, {
|
|
274
|
-
value: value
|
|
280
|
+
value: value,
|
|
281
|
+
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
275
282
|
}));
|
|
276
|
-
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, input, schema.examples && /*#__PURE__*/React__default["default"].createElement("datalist", {
|
|
277
|
-
id:
|
|
278
|
-
}, schema.examples.concat(schema.default ? [schema
|
|
283
|
+
return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, input, Array.isArray(schema.examples) && /*#__PURE__*/React__default["default"].createElement("datalist", {
|
|
284
|
+
id: utils.examplesId(id)
|
|
285
|
+
}, schema.examples.concat(schema["default"] && !schema.examples.includes(schema["default"]) ? [schema["default"]] : []).map(function (example) {
|
|
279
286
|
return /*#__PURE__*/React__default["default"].createElement("option", {
|
|
280
287
|
key: example,
|
|
281
288
|
value: example
|
|
282
289
|
});
|
|
283
290
|
})));
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
const DescriptionField = _ref => {
|
|
287
|
-
let {
|
|
288
|
-
description,
|
|
289
|
-
id // registry,
|
|
291
|
+
}
|
|
290
292
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
+
/** The `DescriptionField` is the template to use to render the description of a field
|
|
294
|
+
*
|
|
295
|
+
* @param props - The `DescriptionFieldProps` for this component
|
|
296
|
+
*/
|
|
297
|
+
function DescriptionField(props) {
|
|
298
|
+
var id = props.id,
|
|
299
|
+
description = props.description;
|
|
300
|
+
if (!description) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
return /*#__PURE__*/React__default["default"].createElement("span", {
|
|
293
304
|
id: id
|
|
294
305
|
}, description);
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
const ErrorList = _ref => {
|
|
298
|
-
let {
|
|
299
|
-
// errorSchema,
|
|
300
|
-
errors // formContext,
|
|
301
|
-
// schema,
|
|
302
|
-
// uiSchema,
|
|
303
|
-
|
|
304
|
-
} = _ref;
|
|
305
|
-
|
|
306
|
-
const renderErrors = () => /*#__PURE__*/React__default["default"].createElement(List__default["default"], {
|
|
307
|
-
className: "list-group",
|
|
308
|
-
size: "small"
|
|
309
|
-
}, errors.map((error, index) => /*#__PURE__*/React__default["default"].createElement(List__default["default"].Item, {
|
|
310
|
-
key: index
|
|
311
|
-
}, /*#__PURE__*/React__default["default"].createElement(Space__default["default"], null, /*#__PURE__*/React__default["default"].createElement(ExclamationCircleOutlined__default["default"], null), error.stack))));
|
|
306
|
+
}
|
|
312
307
|
|
|
308
|
+
/** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
|
|
309
|
+
*
|
|
310
|
+
* @param props - The `ErrorListProps` for this component
|
|
311
|
+
*/
|
|
312
|
+
function ErrorList(_ref) {
|
|
313
|
+
var errors = _ref.errors;
|
|
314
|
+
var renderErrors = function renderErrors() {
|
|
315
|
+
return /*#__PURE__*/React__default["default"].createElement(List__default["default"], {
|
|
316
|
+
className: "list-group",
|
|
317
|
+
size: "small"
|
|
318
|
+
}, errors.map(function (error, index) {
|
|
319
|
+
return /*#__PURE__*/React__default["default"].createElement(List__default["default"].Item, {
|
|
320
|
+
key: index
|
|
321
|
+
}, /*#__PURE__*/React__default["default"].createElement(Space__default["default"], null, /*#__PURE__*/React__default["default"].createElement(ExclamationCircleOutlined__default["default"], null), error.stack));
|
|
322
|
+
}));
|
|
323
|
+
};
|
|
313
324
|
return /*#__PURE__*/React__default["default"].createElement(Alert__default["default"], {
|
|
314
325
|
className: "panel panel-danger errors",
|
|
315
326
|
description: renderErrors(),
|
|
316
327
|
message: "Errors",
|
|
317
328
|
type: "error"
|
|
318
329
|
});
|
|
319
|
-
}
|
|
330
|
+
}
|
|
320
331
|
|
|
332
|
+
var _excluded = ["iconType", "icon", "uiSchema", "registry"];
|
|
321
333
|
function IconButton(props) {
|
|
322
|
-
|
|
323
|
-
iconType = "default",
|
|
324
|
-
icon,
|
|
325
|
-
|
|
326
|
-
...otherProps
|
|
327
|
-
} = props;
|
|
334
|
+
var _props$iconType = props.iconType,
|
|
335
|
+
iconType = _props$iconType === void 0 ? "default" : _props$iconType,
|
|
336
|
+
icon = props.icon,
|
|
337
|
+
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
328
338
|
return /*#__PURE__*/React__default["default"].createElement(Button__default["default"], _extends({
|
|
329
339
|
type: iconType,
|
|
330
340
|
icon: icon
|
|
@@ -354,183 +364,90 @@
|
|
|
354
364
|
}));
|
|
355
365
|
}
|
|
356
366
|
function RemoveButton(props) {
|
|
367
|
+
// The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead
|
|
368
|
+
var options = utils.getUiOptions(props.uiSchema);
|
|
357
369
|
return /*#__PURE__*/React__default["default"].createElement(IconButton, _extends({
|
|
358
370
|
title: "Remove"
|
|
359
371
|
}, props, {
|
|
360
372
|
danger: true,
|
|
373
|
+
block: !!options.block,
|
|
361
374
|
iconType: "primary",
|
|
362
375
|
icon: /*#__PURE__*/React__default["default"].createElement(DeleteOutlined__default["default"], null)
|
|
363
376
|
}));
|
|
364
377
|
}
|
|
365
378
|
|
|
366
|
-
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
367
|
-
*
|
|
368
|
-
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
379
|
+
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
380
|
+
*
|
|
381
|
+
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
369
382
|
*/
|
|
370
|
-
|
|
371
383
|
function FieldErrorTemplate(props) {
|
|
372
|
-
|
|
373
|
-
errors = [],
|
|
374
|
-
idSchema
|
|
375
|
-
} = props;
|
|
376
|
-
|
|
384
|
+
var _props$errors = props.errors,
|
|
385
|
+
errors = _props$errors === void 0 ? [] : _props$errors,
|
|
386
|
+
idSchema = props.idSchema;
|
|
377
387
|
if (errors.length === 0) {
|
|
378
388
|
return null;
|
|
379
389
|
}
|
|
380
|
-
|
|
381
|
-
const id = idSchema.$id + "__error";
|
|
390
|
+
var id = utils.errorId(idSchema);
|
|
382
391
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
383
392
|
id: id
|
|
384
|
-
}, errors.map(
|
|
385
|
-
key: "field-" + id + "-error-" + error
|
|
386
|
-
}, error)));
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const VERTICAL_LABEL_COL$1 = {
|
|
390
|
-
span: 24
|
|
391
|
-
};
|
|
392
|
-
const VERTICAL_WRAPPER_COL$1 = {
|
|
393
|
-
span: 24
|
|
394
|
-
};
|
|
395
|
-
const INPUT_STYLE$1 = {
|
|
396
|
-
width: "100%"
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
const WrapIfAdditional = _ref => {
|
|
400
|
-
let {
|
|
401
|
-
children,
|
|
402
|
-
classNames,
|
|
403
|
-
disabled,
|
|
404
|
-
formContext,
|
|
405
|
-
id,
|
|
406
|
-
label,
|
|
407
|
-
onDropPropertyClick,
|
|
408
|
-
onKeyChange,
|
|
409
|
-
readonly,
|
|
410
|
-
required,
|
|
411
|
-
registry,
|
|
412
|
-
schema,
|
|
413
|
-
uiSchema
|
|
414
|
-
} = _ref;
|
|
415
|
-
const {
|
|
416
|
-
colon,
|
|
417
|
-
labelCol = VERTICAL_LABEL_COL$1,
|
|
418
|
-
readonlyAsDisabled = true,
|
|
419
|
-
rowGutter = 24,
|
|
420
|
-
toolbarAlign = "top",
|
|
421
|
-
wrapperCol = VERTICAL_WRAPPER_COL$1,
|
|
422
|
-
wrapperStyle
|
|
423
|
-
} = formContext;
|
|
424
|
-
const {
|
|
425
|
-
RemoveButton
|
|
426
|
-
} = registry.templates.ButtonTemplates;
|
|
427
|
-
const keyLabel = label + " Key"; // i18n ?
|
|
428
|
-
|
|
429
|
-
const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
430
|
-
|
|
431
|
-
if (!additional) {
|
|
393
|
+
}, errors.map(function (error) {
|
|
432
394
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
433
|
-
|
|
434
|
-
},
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
const handleBlur = _ref2 => {
|
|
438
|
-
let {
|
|
439
|
-
target
|
|
440
|
-
} = _ref2;
|
|
441
|
-
return onKeyChange(target.value);
|
|
442
|
-
};
|
|
443
|
-
|
|
444
|
-
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
445
|
-
className: classNames
|
|
446
|
-
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
447
|
-
align: toolbarAlign,
|
|
448
|
-
gutter: rowGutter
|
|
449
|
-
}, /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
450
|
-
className: "form-additional",
|
|
451
|
-
flex: "1"
|
|
452
|
-
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
453
|
-
className: "form-group"
|
|
454
|
-
}, /*#__PURE__*/React__default["default"].createElement(Form__default["default"].Item, {
|
|
455
|
-
colon: colon,
|
|
456
|
-
className: "form-group",
|
|
457
|
-
hasFeedback: true,
|
|
458
|
-
htmlFor: id + "-key",
|
|
459
|
-
label: keyLabel,
|
|
460
|
-
labelCol: labelCol,
|
|
461
|
-
required: required,
|
|
462
|
-
style: wrapperStyle,
|
|
463
|
-
wrapperCol: wrapperCol
|
|
464
|
-
}, /*#__PURE__*/React__default["default"].createElement(Input__default["default"], {
|
|
465
|
-
className: "form-control",
|
|
466
|
-
defaultValue: label,
|
|
467
|
-
disabled: disabled || readonlyAsDisabled && readonly,
|
|
468
|
-
id: id + "-key",
|
|
469
|
-
name: id + "-key",
|
|
470
|
-
onBlur: !readonly ? handleBlur : undefined,
|
|
471
|
-
style: INPUT_STYLE$1,
|
|
472
|
-
type: "text"
|
|
473
|
-
})))), /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
474
|
-
className: "form-additional",
|
|
475
|
-
flex: "1"
|
|
476
|
-
}, children), /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
477
|
-
flex: "192px"
|
|
478
|
-
}, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
479
|
-
block: true,
|
|
480
|
-
className: "array-item-remove",
|
|
481
|
-
disabled: disabled || readonly,
|
|
482
|
-
onClick: onDropPropertyClick(label),
|
|
483
|
-
uiSchema: uiSchema
|
|
484
|
-
}))));
|
|
485
|
-
};
|
|
395
|
+
key: "field-" + id + "-error-" + error
|
|
396
|
+
}, error);
|
|
397
|
+
}));
|
|
398
|
+
}
|
|
486
399
|
|
|
487
|
-
|
|
400
|
+
var VERTICAL_LABEL_COL$1 = {
|
|
488
401
|
span: 24
|
|
489
402
|
};
|
|
490
|
-
|
|
403
|
+
var VERTICAL_WRAPPER_COL$1 = {
|
|
491
404
|
span: 24
|
|
492
405
|
};
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
406
|
+
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
407
|
+
* content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
|
|
408
|
+
*
|
|
409
|
+
* @param props - The `FieldTemplateProps` for this component
|
|
410
|
+
*/
|
|
411
|
+
function FieldTemplate(props) {
|
|
412
|
+
var children = props.children,
|
|
413
|
+
classNames = props.classNames,
|
|
414
|
+
style = props.style,
|
|
415
|
+
description = props.description,
|
|
416
|
+
disabled = props.disabled,
|
|
417
|
+
displayLabel = props.displayLabel,
|
|
418
|
+
errors = props.errors,
|
|
419
|
+
formContext = props.formContext,
|
|
420
|
+
help = props.help,
|
|
421
|
+
hidden = props.hidden,
|
|
422
|
+
id = props.id,
|
|
423
|
+
label = props.label,
|
|
424
|
+
onDropPropertyClick = props.onDropPropertyClick,
|
|
425
|
+
onKeyChange = props.onKeyChange,
|
|
426
|
+
rawErrors = props.rawErrors,
|
|
427
|
+
rawDescription = props.rawDescription,
|
|
428
|
+
rawHelp = props.rawHelp,
|
|
429
|
+
readonly = props.readonly,
|
|
430
|
+
registry = props.registry,
|
|
431
|
+
required = props.required,
|
|
432
|
+
schema = props.schema,
|
|
433
|
+
uiSchema = props.uiSchema;
|
|
434
|
+
var colon = formContext.colon,
|
|
435
|
+
_formContext$labelCol = formContext.labelCol,
|
|
436
|
+
labelCol = _formContext$labelCol === void 0 ? VERTICAL_LABEL_COL$1 : _formContext$labelCol,
|
|
437
|
+
_formContext$wrapperC = formContext.wrapperCol,
|
|
438
|
+
wrapperCol = _formContext$wrapperC === void 0 ? VERTICAL_WRAPPER_COL$1 : _formContext$wrapperC,
|
|
439
|
+
wrapperStyle = formContext.wrapperStyle;
|
|
440
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
441
|
+
var WrapIfAdditionalTemplate = utils.getTemplate("WrapIfAdditionalTemplate", registry, uiOptions);
|
|
524
442
|
if (hidden) {
|
|
525
443
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
526
444
|
className: "field-hidden"
|
|
527
445
|
}, children);
|
|
528
446
|
}
|
|
529
|
-
|
|
530
|
-
return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditional, {
|
|
447
|
+
return /*#__PURE__*/React__default["default"].createElement(WrapIfAdditionalTemplate, {
|
|
531
448
|
classNames: classNames,
|
|
449
|
+
style: style,
|
|
532
450
|
disabled: disabled,
|
|
533
|
-
formContext: formContext,
|
|
534
451
|
id: id,
|
|
535
452
|
label: label,
|
|
536
453
|
onDropPropertyClick: onDropPropertyClick,
|
|
@@ -542,9 +459,9 @@
|
|
|
542
459
|
registry: registry
|
|
543
460
|
}, id === "root" ? children : /*#__PURE__*/React__default["default"].createElement(Form__default["default"].Item, {
|
|
544
461
|
colon: colon,
|
|
545
|
-
extra: description,
|
|
462
|
+
extra: rawDescription && description,
|
|
546
463
|
hasFeedback: schema.type !== "array" && schema.type !== "object",
|
|
547
|
-
help: !!rawHelp && help || errors,
|
|
464
|
+
help: !!rawHelp && help || (rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? errors : undefined),
|
|
548
465
|
htmlFor: id,
|
|
549
466
|
label: displayLabel && label,
|
|
550
467
|
labelCol: labelCol,
|
|
@@ -553,347 +470,469 @@
|
|
|
553
470
|
validateStatus: rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? "error" : undefined,
|
|
554
471
|
wrapperCol: wrapperCol
|
|
555
472
|
}, children));
|
|
556
|
-
}
|
|
473
|
+
}
|
|
557
474
|
|
|
558
|
-
|
|
475
|
+
var DESCRIPTION_COL_STYLE = {
|
|
559
476
|
paddingBottom: "8px"
|
|
560
477
|
};
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
rowGutter = 24
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
)
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
478
|
+
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
479
|
+
* title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
|
|
480
|
+
* the properties.
|
|
481
|
+
*
|
|
482
|
+
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
483
|
+
*/
|
|
484
|
+
function ObjectFieldTemplate(props) {
|
|
485
|
+
var description = props.description,
|
|
486
|
+
disabled = props.disabled,
|
|
487
|
+
formContext = props.formContext,
|
|
488
|
+
formData = props.formData,
|
|
489
|
+
idSchema = props.idSchema,
|
|
490
|
+
onAddClick = props.onAddClick,
|
|
491
|
+
properties = props.properties,
|
|
492
|
+
readonly = props.readonly,
|
|
493
|
+
required = props.required,
|
|
494
|
+
registry = props.registry,
|
|
495
|
+
schema = props.schema,
|
|
496
|
+
title = props.title,
|
|
497
|
+
uiSchema = props.uiSchema;
|
|
498
|
+
var uiOptions = utils.getUiOptions(uiSchema);
|
|
499
|
+
var TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
|
|
500
|
+
var DescriptionFieldTemplate = utils.getTemplate("DescriptionFieldTemplate", registry, uiOptions);
|
|
501
|
+
// Button templates are not overridden in the uiSchema
|
|
502
|
+
var AddButton = registry.templates.ButtonTemplates.AddButton;
|
|
503
|
+
var _formContext$colSpan = formContext.colSpan,
|
|
504
|
+
colSpan = _formContext$colSpan === void 0 ? 24 : _formContext$colSpan,
|
|
505
|
+
_formContext$labelAli = formContext.labelAlign,
|
|
506
|
+
labelAlign = _formContext$labelAli === void 0 ? "right" : _formContext$labelAli,
|
|
507
|
+
_formContext$rowGutte = formContext.rowGutter,
|
|
508
|
+
rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
|
|
509
|
+
var findSchema = function findSchema(element) {
|
|
510
|
+
return element.content.props.schema;
|
|
511
|
+
};
|
|
512
|
+
var findSchemaType = function findSchemaType(element) {
|
|
513
|
+
return findSchema(element).type;
|
|
514
|
+
};
|
|
515
|
+
var findUiSchema = function findUiSchema(element) {
|
|
516
|
+
return element.content.props.uiSchema;
|
|
517
|
+
};
|
|
518
|
+
var findUiSchemaField = function findUiSchemaField(element) {
|
|
519
|
+
return utils.getUiOptions(findUiSchema(element)).field;
|
|
520
|
+
};
|
|
521
|
+
var findUiSchemaWidget = function findUiSchemaWidget(element) {
|
|
522
|
+
return utils.getUiOptions(findUiSchema(element)).widget;
|
|
523
|
+
};
|
|
524
|
+
var calculateColSpan = function calculateColSpan(element) {
|
|
525
|
+
var type = findSchemaType(element);
|
|
526
|
+
var field = findUiSchemaField(element);
|
|
527
|
+
var widget = findUiSchemaWidget(element);
|
|
528
|
+
var defaultColSpan = properties.length < 2 ||
|
|
529
|
+
// Single or no field in object.
|
|
612
530
|
type === "object" || type === "array" || widget === "textarea" ? 24 : 12;
|
|
613
|
-
|
|
614
531
|
if (isObject__default["default"](colSpan)) {
|
|
615
|
-
|
|
532
|
+
var colSpanObj = colSpan;
|
|
533
|
+
if (isString__default["default"](widget)) {
|
|
534
|
+
return colSpanObj[widget];
|
|
535
|
+
}
|
|
536
|
+
if (isString__default["default"](field)) {
|
|
537
|
+
return colSpanObj[field];
|
|
538
|
+
}
|
|
539
|
+
if (isString__default["default"](type)) {
|
|
540
|
+
return colSpanObj[type];
|
|
541
|
+
}
|
|
616
542
|
}
|
|
617
|
-
|
|
618
543
|
if (isNumber__default["default"](colSpan)) {
|
|
619
544
|
return colSpan;
|
|
620
545
|
}
|
|
621
|
-
|
|
622
546
|
return defaultColSpan;
|
|
623
547
|
};
|
|
548
|
+
return /*#__PURE__*/React__default["default"].createElement(context.ConfigConsumer, null, function (configProps) {
|
|
549
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
550
|
+
var prefixCls = getPrefixCls("form");
|
|
551
|
+
var labelClsBasic = prefixCls + "-item-label";
|
|
552
|
+
var labelColClassName = classNames__default["default"](labelClsBasic, labelAlign === "left" && labelClsBasic + "-left"
|
|
553
|
+
// labelCol.className,
|
|
554
|
+
);
|
|
555
|
+
|
|
556
|
+
return /*#__PURE__*/React__default["default"].createElement("fieldset", {
|
|
557
|
+
id: idSchema.$id
|
|
558
|
+
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
559
|
+
gutter: rowGutter
|
|
560
|
+
}, (uiOptions.title || title) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
561
|
+
className: labelColClassName,
|
|
562
|
+
span: 24
|
|
563
|
+
}, /*#__PURE__*/React__default["default"].createElement(TitleFieldTemplate, {
|
|
564
|
+
id: utils.titleId(idSchema),
|
|
565
|
+
title: uiOptions.title || title,
|
|
566
|
+
required: required,
|
|
567
|
+
schema: schema,
|
|
568
|
+
uiSchema: uiSchema,
|
|
569
|
+
registry: registry
|
|
570
|
+
})), (uiOptions.description || description) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
571
|
+
span: 24,
|
|
572
|
+
style: DESCRIPTION_COL_STYLE
|
|
573
|
+
}, /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
574
|
+
id: utils.descriptionId(idSchema),
|
|
575
|
+
description: uiOptions.description || description,
|
|
576
|
+
schema: schema,
|
|
577
|
+
uiSchema: uiSchema,
|
|
578
|
+
registry: registry
|
|
579
|
+
})), properties.filter(function (e) {
|
|
580
|
+
return !e.hidden;
|
|
581
|
+
}).map(function (element) {
|
|
582
|
+
return /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
583
|
+
key: element.name,
|
|
584
|
+
span: calculateColSpan(element)
|
|
585
|
+
}, element.content);
|
|
586
|
+
})), utils.canExpand(schema, uiSchema, formData) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
587
|
+
span: 24
|
|
588
|
+
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
589
|
+
gutter: rowGutter,
|
|
590
|
+
justify: "end"
|
|
591
|
+
}, /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
592
|
+
flex: "192px"
|
|
593
|
+
}, /*#__PURE__*/React__default["default"].createElement(AddButton, {
|
|
594
|
+
className: "object-property-expand",
|
|
595
|
+
disabled: disabled || readonly,
|
|
596
|
+
onClick: onAddClick(schema),
|
|
597
|
+
uiSchema: uiSchema,
|
|
598
|
+
registry: registry
|
|
599
|
+
})))));
|
|
600
|
+
});
|
|
601
|
+
}
|
|
624
602
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
id: idSchema.$id + "-title",
|
|
634
|
-
required: required,
|
|
635
|
-
title: uiOptions.title || title,
|
|
636
|
-
uiSchema: uiSchema,
|
|
637
|
-
registry: registry
|
|
638
|
-
})), uiOptions.description !== false && (uiOptions.description || description) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
639
|
-
span: 24,
|
|
640
|
-
style: DESCRIPTION_COL_STYLE
|
|
641
|
-
}, /*#__PURE__*/React__default["default"].createElement(DescriptionFieldTemplate, {
|
|
642
|
-
description: uiOptions.description || description,
|
|
643
|
-
id: idSchema.$id + "-description",
|
|
644
|
-
registry: registry
|
|
645
|
-
})), properties.filter(e => !e.hidden).map(element => /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
646
|
-
key: element.name,
|
|
647
|
-
span: calculateColSpan(element)
|
|
648
|
-
}, element.content))), utils.canExpand(schema, uiSchema, formData) && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
649
|
-
span: 24
|
|
650
|
-
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
651
|
-
gutter: rowGutter,
|
|
652
|
-
justify: "end"
|
|
653
|
-
}, /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
654
|
-
flex: "192px"
|
|
655
|
-
}, /*#__PURE__*/React__default["default"].createElement(AddButton, {
|
|
656
|
-
className: "object-property-expand",
|
|
657
|
-
disabled: disabled || readonly,
|
|
658
|
-
onClick: onAddClick(schema),
|
|
659
|
-
uiSchema: uiSchema
|
|
660
|
-
})))));
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
var ObjectFieldTemplate$1 = /*#__PURE__*/context.withConfigConsumer({
|
|
664
|
-
prefixCls: "form"
|
|
665
|
-
})(ObjectFieldTemplate);
|
|
666
|
-
|
|
667
|
-
var SubmitButton = (_ref => {
|
|
668
|
-
let {
|
|
669
|
-
uiSchema
|
|
670
|
-
} = _ref;
|
|
671
|
-
const {
|
|
672
|
-
submitText,
|
|
673
|
-
norender,
|
|
674
|
-
props: submitButtonProps
|
|
675
|
-
} = utils.getSubmitButtonOptions(uiSchema);
|
|
676
|
-
|
|
603
|
+
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
604
|
+
*/
|
|
605
|
+
function SubmitButton(_ref) {
|
|
606
|
+
var uiSchema = _ref.uiSchema;
|
|
607
|
+
var _getSubmitButtonOptio = utils.getSubmitButtonOptions(uiSchema),
|
|
608
|
+
submitText = _getSubmitButtonOptio.submitText,
|
|
609
|
+
norender = _getSubmitButtonOptio.norender,
|
|
610
|
+
submitButtonProps = _getSubmitButtonOptio.props;
|
|
677
611
|
if (norender) {
|
|
678
612
|
return null;
|
|
679
613
|
}
|
|
680
|
-
|
|
681
614
|
return /*#__PURE__*/React__default["default"].createElement(Button__default["default"], _extends({
|
|
682
615
|
type: "submit"
|
|
683
616
|
}, submitButtonProps, {
|
|
684
617
|
htmlType: "submit"
|
|
685
618
|
}), submitText);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
const TitleField = _ref => {
|
|
689
|
-
let {
|
|
690
|
-
id,
|
|
691
|
-
prefixCls,
|
|
692
|
-
required,
|
|
693
|
-
registry,
|
|
694
|
-
title
|
|
695
|
-
} = _ref;
|
|
696
|
-
const {
|
|
697
|
-
formContext
|
|
698
|
-
} = registry;
|
|
699
|
-
const {
|
|
700
|
-
colon = true
|
|
701
|
-
} = formContext;
|
|
702
|
-
let labelChildren = title;
|
|
619
|
+
}
|
|
703
620
|
|
|
621
|
+
/** The `TitleField` is the template to use to render the title of a field
|
|
622
|
+
*
|
|
623
|
+
* @param props - The `TitleFieldProps` for this component
|
|
624
|
+
*/
|
|
625
|
+
function TitleField(_ref) {
|
|
626
|
+
var id = _ref.id,
|
|
627
|
+
required = _ref.required,
|
|
628
|
+
registry = _ref.registry,
|
|
629
|
+
title = _ref.title;
|
|
630
|
+
var formContext = registry.formContext;
|
|
631
|
+
var _formContext$colon = formContext.colon,
|
|
632
|
+
colon = _formContext$colon === void 0 ? true : _formContext$colon;
|
|
633
|
+
var labelChildren = title;
|
|
704
634
|
if (colon && typeof title === "string" && title.trim() !== "") {
|
|
705
635
|
labelChildren = title.replace(/[::]\s*$/, "");
|
|
706
636
|
}
|
|
707
|
-
|
|
708
|
-
const labelClassName = classNames__default["default"]({
|
|
709
|
-
[prefixCls + "-item-required"]: required,
|
|
710
|
-
[prefixCls + "-item-no-colon"]: !colon
|
|
711
|
-
});
|
|
712
|
-
|
|
713
|
-
const handleLabelClick = () => {
|
|
637
|
+
var handleLabelClick = function handleLabelClick() {
|
|
714
638
|
if (!id) {
|
|
715
639
|
return;
|
|
716
640
|
}
|
|
717
|
-
|
|
718
|
-
const control = document.querySelector("[id=\"" + id + "\"]");
|
|
719
|
-
|
|
641
|
+
var control = document.querySelector("[id=\"" + id + "\"]");
|
|
720
642
|
if (control && control.focus) {
|
|
721
643
|
control.focus();
|
|
722
644
|
}
|
|
723
645
|
};
|
|
646
|
+
return title ? /*#__PURE__*/React__default["default"].createElement(context.ConfigConsumer, null, function (configProps) {
|
|
647
|
+
var _classNames;
|
|
648
|
+
var getPrefixCls = configProps.getPrefixCls;
|
|
649
|
+
var prefixCls = getPrefixCls("form");
|
|
650
|
+
var labelClassName = classNames__default["default"]((_classNames = {}, _classNames[prefixCls + "-item-required"] = required, _classNames[prefixCls + "-item-no-colon"] = !colon, _classNames));
|
|
651
|
+
return /*#__PURE__*/React__default["default"].createElement("label", {
|
|
652
|
+
className: labelClassName,
|
|
653
|
+
htmlFor: id,
|
|
654
|
+
onClick: handleLabelClick,
|
|
655
|
+
title: typeof title === "string" ? title : ""
|
|
656
|
+
}, labelChildren);
|
|
657
|
+
}) : null;
|
|
658
|
+
}
|
|
724
659
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
htmlFor: id,
|
|
728
|
-
onClick: handleLabelClick,
|
|
729
|
-
title: typeof title === "string" ? title : ""
|
|
730
|
-
}, labelChildren) : null;
|
|
660
|
+
var VERTICAL_LABEL_COL = {
|
|
661
|
+
span: 24
|
|
731
662
|
};
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
formContext: {}
|
|
663
|
+
var VERTICAL_WRAPPER_COL = {
|
|
664
|
+
span: 24
|
|
735
665
|
};
|
|
736
|
-
var
|
|
737
|
-
|
|
738
|
-
}
|
|
666
|
+
var INPUT_STYLE$1 = {
|
|
667
|
+
width: "100%"
|
|
668
|
+
};
|
|
669
|
+
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
670
|
+
* part of an `additionalProperties` part of a schema.
|
|
671
|
+
*
|
|
672
|
+
* @param props - The `WrapIfAdditionalProps` for this component
|
|
673
|
+
*/
|
|
674
|
+
function WrapIfAdditionalTemplate(props) {
|
|
675
|
+
var _extends2;
|
|
676
|
+
var children = props.children,
|
|
677
|
+
classNames = props.classNames,
|
|
678
|
+
style = props.style,
|
|
679
|
+
disabled = props.disabled,
|
|
680
|
+
id = props.id,
|
|
681
|
+
label = props.label,
|
|
682
|
+
onDropPropertyClick = props.onDropPropertyClick,
|
|
683
|
+
onKeyChange = props.onKeyChange,
|
|
684
|
+
readonly = props.readonly,
|
|
685
|
+
required = props.required,
|
|
686
|
+
registry = props.registry,
|
|
687
|
+
schema = props.schema,
|
|
688
|
+
uiSchema = props.uiSchema;
|
|
689
|
+
var _registry$formContext = registry.formContext,
|
|
690
|
+
colon = _registry$formContext.colon,
|
|
691
|
+
_registry$formContext2 = _registry$formContext.labelCol,
|
|
692
|
+
labelCol = _registry$formContext2 === void 0 ? VERTICAL_LABEL_COL : _registry$formContext2,
|
|
693
|
+
_registry$formContext3 = _registry$formContext.readonlyAsDisabled,
|
|
694
|
+
readonlyAsDisabled = _registry$formContext3 === void 0 ? true : _registry$formContext3,
|
|
695
|
+
_registry$formContext4 = _registry$formContext.rowGutter,
|
|
696
|
+
rowGutter = _registry$formContext4 === void 0 ? 24 : _registry$formContext4,
|
|
697
|
+
_registry$formContext5 = _registry$formContext.toolbarAlign,
|
|
698
|
+
toolbarAlign = _registry$formContext5 === void 0 ? "top" : _registry$formContext5,
|
|
699
|
+
_registry$formContext6 = _registry$formContext.wrapperCol,
|
|
700
|
+
wrapperCol = _registry$formContext6 === void 0 ? VERTICAL_WRAPPER_COL : _registry$formContext6,
|
|
701
|
+
wrapperStyle = _registry$formContext.wrapperStyle;
|
|
702
|
+
// Button templates are not overridden in the uiSchema
|
|
703
|
+
var RemoveButton = registry.templates.ButtonTemplates.RemoveButton;
|
|
704
|
+
var keyLabel = label + " Key"; // i18n ?
|
|
705
|
+
var additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
706
|
+
if (!additional) {
|
|
707
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
708
|
+
className: classNames,
|
|
709
|
+
style: style
|
|
710
|
+
}, children);
|
|
711
|
+
}
|
|
712
|
+
var handleBlur = function handleBlur(_ref) {
|
|
713
|
+
var target = _ref.target;
|
|
714
|
+
return onKeyChange(target.value);
|
|
715
|
+
};
|
|
716
|
+
// The `block` prop is not part of the `IconButtonProps` defined in the template, so put it into the uiSchema instead
|
|
717
|
+
var uiOptions = uiSchema ? uiSchema[utils.UI_OPTIONS_KEY] : {};
|
|
718
|
+
var buttonUiOptions = _extends({}, uiSchema, (_extends2 = {}, _extends2[utils.UI_OPTIONS_KEY] = _extends({}, uiOptions, {
|
|
719
|
+
block: true
|
|
720
|
+
}), _extends2));
|
|
721
|
+
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
722
|
+
className: classNames,
|
|
723
|
+
style: style
|
|
724
|
+
}, /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
725
|
+
align: toolbarAlign,
|
|
726
|
+
gutter: rowGutter
|
|
727
|
+
}, /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
728
|
+
className: "form-additional",
|
|
729
|
+
flex: "1"
|
|
730
|
+
}, /*#__PURE__*/React__default["default"].createElement("div", {
|
|
731
|
+
className: "form-group"
|
|
732
|
+
}, /*#__PURE__*/React__default["default"].createElement(Form__default["default"].Item, {
|
|
733
|
+
colon: colon,
|
|
734
|
+
className: "form-group",
|
|
735
|
+
hasFeedback: true,
|
|
736
|
+
htmlFor: id + "-key",
|
|
737
|
+
label: keyLabel,
|
|
738
|
+
labelCol: labelCol,
|
|
739
|
+
required: required,
|
|
740
|
+
style: wrapperStyle,
|
|
741
|
+
wrapperCol: wrapperCol
|
|
742
|
+
}, /*#__PURE__*/React__default["default"].createElement(Input__default["default"], {
|
|
743
|
+
className: "form-control",
|
|
744
|
+
defaultValue: label,
|
|
745
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
746
|
+
id: id + "-key",
|
|
747
|
+
name: id + "-key",
|
|
748
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
749
|
+
style: INPUT_STYLE$1,
|
|
750
|
+
type: "text"
|
|
751
|
+
})))), /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
752
|
+
className: "form-additional",
|
|
753
|
+
flex: "1"
|
|
754
|
+
}, children), /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
755
|
+
flex: "192px"
|
|
756
|
+
}, /*#__PURE__*/React__default["default"].createElement(RemoveButton, {
|
|
757
|
+
className: "array-item-remove",
|
|
758
|
+
disabled: disabled || readonly,
|
|
759
|
+
onClick: onDropPropertyClick(label),
|
|
760
|
+
uiSchema: buttonUiOptions,
|
|
761
|
+
registry: registry
|
|
762
|
+
}))));
|
|
763
|
+
}
|
|
739
764
|
|
|
740
|
-
|
|
741
|
-
|
|
765
|
+
function generateTemplates() {
|
|
766
|
+
return {
|
|
767
|
+
ArrayFieldItemTemplate: ArrayFieldItemTemplate,
|
|
768
|
+
ArrayFieldTemplate: ArrayFieldTemplate,
|
|
769
|
+
BaseInputTemplate: BaseInputTemplate,
|
|
770
|
+
ButtonTemplates: {
|
|
771
|
+
AddButton: AddButton,
|
|
772
|
+
MoveDownButton: MoveDownButton,
|
|
773
|
+
MoveUpButton: MoveUpButton,
|
|
774
|
+
RemoveButton: RemoveButton,
|
|
775
|
+
SubmitButton: SubmitButton
|
|
776
|
+
},
|
|
777
|
+
DescriptionFieldTemplate: DescriptionField,
|
|
778
|
+
ErrorListTemplate: ErrorList,
|
|
779
|
+
FieldErrorTemplate: FieldErrorTemplate,
|
|
780
|
+
FieldTemplate: FieldTemplate,
|
|
781
|
+
ObjectFieldTemplate: ObjectFieldTemplate,
|
|
782
|
+
TitleFieldTemplate: TitleField,
|
|
783
|
+
WrapIfAdditionalTemplate: WrapIfAdditionalTemplate
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
var index$1 = /*#__PURE__*/generateTemplates();
|
|
742
787
|
|
|
743
|
-
|
|
788
|
+
var rangeOptions = function rangeOptions(start, stop) {
|
|
789
|
+
var options = [];
|
|
790
|
+
for (var i = start; i <= stop; i++) {
|
|
744
791
|
options.push({
|
|
745
792
|
value: i,
|
|
746
793
|
label: utils.pad(i, 2)
|
|
747
794
|
});
|
|
748
795
|
}
|
|
749
|
-
|
|
750
796
|
return options;
|
|
751
797
|
};
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
798
|
+
var readyForChange = function readyForChange(state) {
|
|
799
|
+
return Object.values(state).every(function (value) {
|
|
800
|
+
return value !== -1;
|
|
801
|
+
});
|
|
755
802
|
};
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
803
|
+
function dateElementProps(state, time, yearsRange) {
|
|
804
|
+
if (yearsRange === void 0) {
|
|
805
|
+
yearsRange = [1900, new Date().getFullYear() + 2];
|
|
806
|
+
}
|
|
807
|
+
var year = state.year,
|
|
808
|
+
month = state.month,
|
|
809
|
+
day = state.day,
|
|
810
|
+
hour = state.hour,
|
|
811
|
+
minute = state.minute,
|
|
812
|
+
second = state.second;
|
|
813
|
+
var data = [{
|
|
814
|
+
type: "year",
|
|
815
|
+
range: yearsRange,
|
|
816
|
+
value: year
|
|
817
|
+
}, {
|
|
818
|
+
type: "month",
|
|
819
|
+
range: [1, 12],
|
|
820
|
+
value: month
|
|
821
|
+
}, {
|
|
822
|
+
type: "day",
|
|
823
|
+
range: [1, 31],
|
|
824
|
+
value: day
|
|
825
|
+
}];
|
|
826
|
+
if (time) {
|
|
827
|
+
data.push({
|
|
828
|
+
type: "hour",
|
|
829
|
+
range: [0, 23],
|
|
830
|
+
value: hour || -1
|
|
831
|
+
}, {
|
|
832
|
+
type: "minute",
|
|
833
|
+
range: [0, 59],
|
|
834
|
+
value: minute || -1
|
|
835
|
+
}, {
|
|
836
|
+
type: "second",
|
|
837
|
+
range: [0, 59],
|
|
838
|
+
value: second || -1
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
return data;
|
|
842
|
+
}
|
|
843
|
+
function AltDateWidget(props) {
|
|
844
|
+
var autofocus = props.autofocus,
|
|
845
|
+
disabled = props.disabled,
|
|
846
|
+
formContext = props.formContext,
|
|
847
|
+
id = props.id,
|
|
848
|
+
onBlur = props.onBlur,
|
|
849
|
+
onChange = props.onChange,
|
|
850
|
+
onFocus = props.onFocus,
|
|
851
|
+
options = props.options,
|
|
852
|
+
readonly = props.readonly,
|
|
853
|
+
registry = props.registry,
|
|
854
|
+
showTime = props.showTime,
|
|
855
|
+
value = props.value;
|
|
856
|
+
var SelectWidget = registry.widgets.SelectWidget;
|
|
857
|
+
var _formContext$rowGutte = formContext.rowGutter,
|
|
858
|
+
rowGutter = _formContext$rowGutte === void 0 ? 24 : _formContext$rowGutte;
|
|
859
|
+
var _useState = React.useState(utils.parseDateString(value, showTime)),
|
|
860
|
+
state = _useState[0],
|
|
861
|
+
setState = _useState[1];
|
|
862
|
+
React.useEffect(function () {
|
|
780
863
|
setState(utils.parseDateString(value, showTime));
|
|
781
864
|
}, [showTime, value]);
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
[property]: typeof nextValue === "undefined" ? -1 : nextValue
|
|
786
|
-
};
|
|
787
|
-
|
|
865
|
+
var handleChange = function handleChange(property, nextValue) {
|
|
866
|
+
var _extends2;
|
|
867
|
+
var nextState = _extends({}, state, (_extends2 = {}, _extends2[property] = typeof nextValue === "undefined" ? -1 : nextValue, _extends2));
|
|
788
868
|
if (readyForChange(nextState)) {
|
|
789
869
|
onChange(utils.toDateString(nextState, showTime));
|
|
790
870
|
} else {
|
|
791
871
|
setState(nextState);
|
|
792
872
|
}
|
|
793
873
|
};
|
|
794
|
-
|
|
795
|
-
const handleNow = event => {
|
|
874
|
+
var handleNow = function handleNow(event) {
|
|
796
875
|
event.preventDefault();
|
|
797
|
-
|
|
798
876
|
if (disabled || readonly) {
|
|
799
877
|
return;
|
|
800
878
|
}
|
|
801
|
-
|
|
802
|
-
const nextState = utils.parseDateString(new Date().toJSON(), showTime);
|
|
879
|
+
var nextState = utils.parseDateString(new Date().toJSON(), showTime);
|
|
803
880
|
onChange(utils.toDateString(nextState, showTime));
|
|
804
881
|
};
|
|
805
|
-
|
|
806
|
-
const handleClear = event => {
|
|
882
|
+
var handleClear = function handleClear(event) {
|
|
807
883
|
event.preventDefault();
|
|
808
|
-
|
|
809
884
|
if (disabled || readonly) {
|
|
810
885
|
return;
|
|
811
886
|
}
|
|
812
|
-
|
|
813
887
|
onChange(undefined);
|
|
814
888
|
};
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
data.push({
|
|
841
|
-
type: "hour",
|
|
842
|
-
range: [0, 23],
|
|
843
|
-
value: hour
|
|
844
|
-
}, {
|
|
845
|
-
type: "minute",
|
|
846
|
-
range: [0, 59],
|
|
847
|
-
value: minute
|
|
848
|
-
}, {
|
|
849
|
-
type: "second",
|
|
850
|
-
range: [0, 59],
|
|
851
|
-
value: second
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
return data;
|
|
889
|
+
var renderDateElement = function renderDateElement(elemProps) {
|
|
890
|
+
return /*#__PURE__*/React__default["default"].createElement(SelectWidget, {
|
|
891
|
+
autofocus: elemProps.autofocus,
|
|
892
|
+
className: "form-control",
|
|
893
|
+
disabled: elemProps.disabled,
|
|
894
|
+
id: elemProps.id,
|
|
895
|
+
name: elemProps.name,
|
|
896
|
+
onBlur: elemProps.onBlur,
|
|
897
|
+
onChange: function onChange(elemValue) {
|
|
898
|
+
return elemProps.select(elemProps.type, elemValue);
|
|
899
|
+
},
|
|
900
|
+
onFocus: elemProps.onFocus,
|
|
901
|
+
options: {
|
|
902
|
+
enumOptions: rangeOptions(elemProps.range[0], elemProps.range[1])
|
|
903
|
+
},
|
|
904
|
+
placeholder: elemProps.type,
|
|
905
|
+
readonly: elemProps.readonly,
|
|
906
|
+
schema: {
|
|
907
|
+
type: "integer"
|
|
908
|
+
},
|
|
909
|
+
value: elemProps.value,
|
|
910
|
+
registry: registry,
|
|
911
|
+
label: "",
|
|
912
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
913
|
+
});
|
|
856
914
|
};
|
|
857
|
-
|
|
858
|
-
const renderDateElement = elemProps => /*#__PURE__*/React__default["default"].createElement(SelectWidget, {
|
|
859
|
-
autofocus: elemProps.autofocus,
|
|
860
|
-
className: "form-control",
|
|
861
|
-
disabled: elemProps.disabled,
|
|
862
|
-
id: elemProps.id,
|
|
863
|
-
onBlur: elemProps.onBlur,
|
|
864
|
-
onChange: elemValue => elemProps.select(elemProps.type, elemValue),
|
|
865
|
-
onFocus: elemProps.onFocus,
|
|
866
|
-
options: {
|
|
867
|
-
enumOptions: rangeOptions(elemProps.range[0], elemProps.range[1])
|
|
868
|
-
},
|
|
869
|
-
placeholder: elemProps.type,
|
|
870
|
-
readonly: elemProps.readonly,
|
|
871
|
-
schema: {
|
|
872
|
-
type: "integer"
|
|
873
|
-
},
|
|
874
|
-
value: elemProps.value
|
|
875
|
-
});
|
|
876
|
-
|
|
877
915
|
return /*#__PURE__*/React__default["default"].createElement(Row__default["default"], {
|
|
878
916
|
gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)]
|
|
879
|
-
}, dateElementProps().map((elemProps, i)
|
|
880
|
-
|
|
917
|
+
}, dateElementProps(state, showTime, options.yearsRange).map(function (elemProps, i) {
|
|
918
|
+
var elemId = id + "_" + elemProps.type;
|
|
881
919
|
return /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
882
920
|
flex: "88px",
|
|
883
921
|
key: elemId
|
|
884
|
-
}, renderDateElement({
|
|
922
|
+
}, renderDateElement(_extends({}, elemProps, {
|
|
885
923
|
autofocus: autofocus && i === 0,
|
|
886
|
-
disabled,
|
|
924
|
+
disabled: disabled,
|
|
887
925
|
id: elemId,
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
926
|
+
name: id,
|
|
927
|
+
onBlur: onBlur,
|
|
928
|
+
onFocus: onFocus,
|
|
929
|
+
readonly: readonly,
|
|
930
|
+
registry: registry,
|
|
892
931
|
select: handleChange,
|
|
893
932
|
// NOTE: antd components accept -1 rather than issue a warning
|
|
894
933
|
// like material-ui, so we need to convert -1 to undefined here.
|
|
895
934
|
value: elemProps.value < 0 ? undefined : elemProps.value
|
|
896
|
-
}));
|
|
935
|
+
})));
|
|
897
936
|
}), !options.hideNowButton && /*#__PURE__*/React__default["default"].createElement(Col__default["default"], {
|
|
898
937
|
flex: "88px"
|
|
899
938
|
}, /*#__PURE__*/React__default["default"].createElement(Button__default["default"], {
|
|
@@ -910,8 +949,7 @@
|
|
|
910
949
|
onClick: handleClear,
|
|
911
950
|
type: "primary"
|
|
912
951
|
}, "Clear")));
|
|
913
|
-
}
|
|
914
|
-
|
|
952
|
+
}
|
|
915
953
|
AltDateWidget.defaultProps = {
|
|
916
954
|
autofocus: false,
|
|
917
955
|
disabled: false,
|
|
@@ -922,173 +960,159 @@
|
|
|
922
960
|
showTime: false
|
|
923
961
|
};
|
|
924
962
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
AltDateWidget
|
|
928
|
-
} = props.registry.widgets;
|
|
963
|
+
function AltDateTimeWidget(props) {
|
|
964
|
+
var AltDateWidget = props.registry.widgets.AltDateWidget;
|
|
929
965
|
return /*#__PURE__*/React__default["default"].createElement(AltDateWidget, _extends({
|
|
930
966
|
showTime: true
|
|
931
967
|
}, props));
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
AltDateTimeWidget.defaultProps = { ...AltDateWidget.defaultProps,
|
|
968
|
+
}
|
|
969
|
+
AltDateTimeWidget.defaultProps = /*#__PURE__*/_extends({}, AltDateWidget.defaultProps, {
|
|
935
970
|
showTime: true
|
|
936
|
-
};
|
|
937
|
-
|
|
938
|
-
const CheckboxesWidget = _ref => {
|
|
939
|
-
let {
|
|
940
|
-
autofocus,
|
|
941
|
-
disabled,
|
|
942
|
-
formContext,
|
|
943
|
-
id,
|
|
944
|
-
// label,
|
|
945
|
-
onBlur,
|
|
946
|
-
onChange,
|
|
947
|
-
onFocus,
|
|
948
|
-
options,
|
|
949
|
-
// placeholder,
|
|
950
|
-
readonly,
|
|
951
|
-
// required,
|
|
952
|
-
// schema,
|
|
953
|
-
value
|
|
954
|
-
} = _ref;
|
|
955
|
-
const {
|
|
956
|
-
readonlyAsDisabled = true
|
|
957
|
-
} = formContext;
|
|
958
|
-
const {
|
|
959
|
-
enumOptions,
|
|
960
|
-
enumDisabled,
|
|
961
|
-
inline
|
|
962
|
-
} = options;
|
|
963
|
-
|
|
964
|
-
const handleChange = nextValue => onChange(nextValue);
|
|
971
|
+
});
|
|
965
972
|
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
973
|
+
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
974
|
+
* It is typically used to represent an array of enums.
|
|
975
|
+
*
|
|
976
|
+
* @param props - The `WidgetProps` for this component
|
|
977
|
+
*/
|
|
978
|
+
function CheckboxesWidget(_ref) {
|
|
979
|
+
var autofocus = _ref.autofocus,
|
|
980
|
+
disabled = _ref.disabled,
|
|
981
|
+
formContext = _ref.formContext,
|
|
982
|
+
id = _ref.id,
|
|
983
|
+
onBlur = _ref.onBlur,
|
|
984
|
+
onChange = _ref.onChange,
|
|
985
|
+
onFocus = _ref.onFocus,
|
|
986
|
+
options = _ref.options,
|
|
987
|
+
readonly = _ref.readonly,
|
|
988
|
+
value = _ref.value;
|
|
989
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
990
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
991
|
+
var enumOptions = options.enumOptions,
|
|
992
|
+
enumDisabled = options.enumDisabled,
|
|
993
|
+
inline = options.inline,
|
|
994
|
+
emptyValue = options.emptyValue;
|
|
995
|
+
var handleChange = function handleChange(nextValue) {
|
|
996
|
+
return onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
971
997
|
};
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
target
|
|
976
|
-
} = _ref3;
|
|
977
|
-
return onFocus(id, target.value);
|
|
998
|
+
var handleBlur = function handleBlur(_ref2) {
|
|
999
|
+
var target = _ref2.target;
|
|
1000
|
+
return onBlur(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
978
1001
|
};
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
1002
|
+
var handleFocus = function handleFocus(_ref3) {
|
|
1003
|
+
var target = _ref3.target;
|
|
1004
|
+
return onFocus(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1005
|
+
};
|
|
1006
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1007
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1008
|
+
var extraProps = {
|
|
982
1009
|
id: id,
|
|
983
|
-
name: id,
|
|
984
1010
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1011
|
+
onFocus: !readonly ? handleFocus : undefined
|
|
1012
|
+
};
|
|
1013
|
+
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
|
|
1014
|
+
return Array.isArray(enumOptions) && enumOptions.length > 0 ? /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"].Group, _extends({
|
|
1015
|
+
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1016
|
+
name: id,
|
|
985
1017
|
onChange: !readonly ? handleChange : undefined,
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
value: optionValue,
|
|
991
|
-
label: optionLabel
|
|
992
|
-
} = _ref4;
|
|
1018
|
+
value: selectedIndexes
|
|
1019
|
+
}, extraProps, {
|
|
1020
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1021
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
993
1022
|
return /*#__PURE__*/React__default["default"].createElement("span", {
|
|
994
|
-
key:
|
|
1023
|
+
key: i
|
|
995
1024
|
}, /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"], {
|
|
1025
|
+
id: utils.optionId(id, i),
|
|
1026
|
+
name: id,
|
|
996
1027
|
autoFocus: i === 0 ? autofocus : false,
|
|
997
|
-
disabled: enumDisabled && enumDisabled.indexOf(value) !== -1,
|
|
998
|
-
value:
|
|
999
|
-
},
|
|
1028
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1029
|
+
value: String(i)
|
|
1030
|
+
}, option.label), !inline && /*#__PURE__*/React__default["default"].createElement("br", null));
|
|
1000
1031
|
})) : null;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
const CheckboxWidget = _ref => {
|
|
1004
|
-
let {
|
|
1005
|
-
autofocus,
|
|
1006
|
-
disabled,
|
|
1007
|
-
formContext,
|
|
1008
|
-
id,
|
|
1009
|
-
label,
|
|
1010
|
-
onBlur,
|
|
1011
|
-
onChange,
|
|
1012
|
-
onFocus,
|
|
1013
|
-
// options,
|
|
1014
|
-
// placeholder,
|
|
1015
|
-
readonly,
|
|
1016
|
-
// required,
|
|
1017
|
-
// schema,
|
|
1018
|
-
value
|
|
1019
|
-
} = _ref;
|
|
1020
|
-
const {
|
|
1021
|
-
readonlyAsDisabled = true
|
|
1022
|
-
} = formContext;
|
|
1032
|
+
}
|
|
1023
1033
|
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1034
|
+
/** The `CheckBoxWidget` is a widget for rendering boolean properties.
|
|
1035
|
+
* It is typically used to represent a boolean.
|
|
1036
|
+
*
|
|
1037
|
+
* @param props - The `WidgetProps` for this component
|
|
1038
|
+
*/
|
|
1039
|
+
function CheckboxWidget(props) {
|
|
1040
|
+
var autofocus = props.autofocus,
|
|
1041
|
+
disabled = props.disabled,
|
|
1042
|
+
formContext = props.formContext,
|
|
1043
|
+
id = props.id,
|
|
1044
|
+
label = props.label,
|
|
1045
|
+
onBlur = props.onBlur,
|
|
1046
|
+
onChange = props.onChange,
|
|
1047
|
+
onFocus = props.onFocus,
|
|
1048
|
+
readonly = props.readonly,
|
|
1049
|
+
value = props.value;
|
|
1050
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1051
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1052
|
+
var handleChange = function handleChange(_ref) {
|
|
1053
|
+
var target = _ref.target;
|
|
1028
1054
|
return onChange(target.checked);
|
|
1029
1055
|
};
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
let {
|
|
1033
|
-
target
|
|
1034
|
-
} = _ref3;
|
|
1056
|
+
var handleBlur = function handleBlur(_ref2) {
|
|
1057
|
+
var target = _ref2.target;
|
|
1035
1058
|
return onBlur(id, target.checked);
|
|
1036
1059
|
};
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
let {
|
|
1040
|
-
target
|
|
1041
|
-
} = _ref4;
|
|
1060
|
+
var handleFocus = function handleFocus(_ref3) {
|
|
1061
|
+
var target = _ref3.target;
|
|
1042
1062
|
return onFocus(id, target.checked);
|
|
1043
1063
|
};
|
|
1044
|
-
|
|
1045
|
-
|
|
1064
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1065
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1066
|
+
var extraProps = {
|
|
1067
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
1068
|
+
onFocus: !readonly ? handleFocus : undefined
|
|
1069
|
+
};
|
|
1070
|
+
return /*#__PURE__*/React__default["default"].createElement(Checkbox__default["default"], _extends({
|
|
1046
1071
|
autoFocus: autofocus,
|
|
1047
1072
|
checked: typeof value === "undefined" ? false : value,
|
|
1048
1073
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1049
1074
|
id: id,
|
|
1050
1075
|
name: id,
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
}, label);
|
|
1055
|
-
}
|
|
1076
|
+
onChange: !readonly ? handleChange : undefined
|
|
1077
|
+
}, extraProps, {
|
|
1078
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1079
|
+
}), label);
|
|
1080
|
+
}
|
|
1056
1081
|
|
|
1057
|
-
|
|
1082
|
+
var DatePicker = /*#__PURE__*/generatePicker__default["default"](dayjsGenerateConfig__default["default"]);
|
|
1058
1083
|
|
|
1059
|
-
|
|
1084
|
+
var DATE_PICKER_STYLE$1 = {
|
|
1060
1085
|
width: "100%"
|
|
1061
1086
|
};
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
placeholder,
|
|
1075
|
-
readonly,
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1087
|
+
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
1088
|
+
* the value to/from utc using the appropriate utility functions.
|
|
1089
|
+
*
|
|
1090
|
+
* @param props - The `WidgetProps` for this component
|
|
1091
|
+
*/
|
|
1092
|
+
function DateTimeWidget(props) {
|
|
1093
|
+
var disabled = props.disabled,
|
|
1094
|
+
formContext = props.formContext,
|
|
1095
|
+
id = props.id,
|
|
1096
|
+
onBlur = props.onBlur,
|
|
1097
|
+
onChange = props.onChange,
|
|
1098
|
+
onFocus = props.onFocus,
|
|
1099
|
+
placeholder = props.placeholder,
|
|
1100
|
+
readonly = props.readonly,
|
|
1101
|
+
value = props.value;
|
|
1102
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1103
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1104
|
+
var handleChange = function handleChange(nextValue) {
|
|
1105
|
+
return onChange(nextValue && nextValue.toISOString());
|
|
1106
|
+
};
|
|
1107
|
+
var handleBlur = function handleBlur() {
|
|
1108
|
+
return onBlur(id, value);
|
|
1109
|
+
};
|
|
1110
|
+
var handleFocus = function handleFocus() {
|
|
1111
|
+
return onFocus(id, value);
|
|
1112
|
+
};
|
|
1113
|
+
var getPopupContainer = function getPopupContainer(node) {
|
|
1114
|
+
return node.parentNode;
|
|
1115
|
+
};
|
|
1092
1116
|
return /*#__PURE__*/React__default["default"].createElement(DatePicker, {
|
|
1093
1117
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1094
1118
|
getPopupContainer: getPopupContainer,
|
|
@@ -1100,43 +1124,43 @@
|
|
|
1100
1124
|
placeholder: placeholder,
|
|
1101
1125
|
showTime: true,
|
|
1102
1126
|
style: DATE_PICKER_STYLE$1,
|
|
1103
|
-
value: value && dayjs__default["default"](value)
|
|
1127
|
+
value: value && dayjs__default["default"](value),
|
|
1128
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1104
1129
|
});
|
|
1105
|
-
}
|
|
1130
|
+
}
|
|
1106
1131
|
|
|
1107
|
-
|
|
1132
|
+
var DATE_PICKER_STYLE = {
|
|
1108
1133
|
width: "100%"
|
|
1109
1134
|
};
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
placeholder,
|
|
1123
|
-
readonly,
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1135
|
+
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
1136
|
+
* the value to undefined when it is falsy during the `onChange` handling.
|
|
1137
|
+
*
|
|
1138
|
+
* @param props - The `WidgetProps` for this component
|
|
1139
|
+
*/
|
|
1140
|
+
function DateWidget(props) {
|
|
1141
|
+
var disabled = props.disabled,
|
|
1142
|
+
formContext = props.formContext,
|
|
1143
|
+
id = props.id,
|
|
1144
|
+
onBlur = props.onBlur,
|
|
1145
|
+
onChange = props.onChange,
|
|
1146
|
+
onFocus = props.onFocus,
|
|
1147
|
+
placeholder = props.placeholder,
|
|
1148
|
+
readonly = props.readonly,
|
|
1149
|
+
value = props.value;
|
|
1150
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1151
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1152
|
+
var handleChange = function handleChange(nextValue) {
|
|
1153
|
+
return onChange(nextValue && nextValue.format("YYYY-MM-DD"));
|
|
1154
|
+
};
|
|
1155
|
+
var handleBlur = function handleBlur() {
|
|
1156
|
+
return onBlur(id, value);
|
|
1157
|
+
};
|
|
1158
|
+
var handleFocus = function handleFocus() {
|
|
1159
|
+
return onFocus(id, value);
|
|
1160
|
+
};
|
|
1161
|
+
var getPopupContainer = function getPopupContainer(node) {
|
|
1162
|
+
return node.parentNode;
|
|
1163
|
+
};
|
|
1140
1164
|
return /*#__PURE__*/React__default["default"].createElement(DatePicker, {
|
|
1141
1165
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1142
1166
|
getPopupContainer: getPopupContainer,
|
|
@@ -1148,53 +1172,41 @@
|
|
|
1148
1172
|
placeholder: placeholder,
|
|
1149
1173
|
showTime: false,
|
|
1150
1174
|
style: DATE_PICKER_STYLE,
|
|
1151
|
-
value: value && dayjs__default["default"](value)
|
|
1175
|
+
value: value && dayjs__default["default"](value),
|
|
1176
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1152
1177
|
});
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
const PasswordWidget = _ref => {
|
|
1156
|
-
let {
|
|
1157
|
-
// autofocus,
|
|
1158
|
-
disabled,
|
|
1159
|
-
formContext,
|
|
1160
|
-
id,
|
|
1161
|
-
// label,
|
|
1162
|
-
onBlur,
|
|
1163
|
-
onChange,
|
|
1164
|
-
onFocus,
|
|
1165
|
-
options,
|
|
1166
|
-
placeholder,
|
|
1167
|
-
readonly,
|
|
1168
|
-
// required,
|
|
1169
|
-
// schema,
|
|
1170
|
-
value
|
|
1171
|
-
} = _ref;
|
|
1172
|
-
const {
|
|
1173
|
-
readonlyAsDisabled = true
|
|
1174
|
-
} = formContext;
|
|
1175
|
-
const emptyValue = options.emptyValue || "";
|
|
1178
|
+
}
|
|
1176
1179
|
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1180
|
+
/** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
|
|
1181
|
+
*
|
|
1182
|
+
* @param props - The `WidgetProps` for this component
|
|
1183
|
+
*/
|
|
1184
|
+
function PasswordWidget(props) {
|
|
1185
|
+
var disabled = props.disabled,
|
|
1186
|
+
formContext = props.formContext,
|
|
1187
|
+
id = props.id,
|
|
1188
|
+
onBlur = props.onBlur,
|
|
1189
|
+
onChange = props.onChange,
|
|
1190
|
+
onFocus = props.onFocus,
|
|
1191
|
+
options = props.options,
|
|
1192
|
+
placeholder = props.placeholder,
|
|
1193
|
+
readonly = props.readonly,
|
|
1194
|
+
value = props.value;
|
|
1195
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1196
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1197
|
+
var emptyValue = options.emptyValue || "";
|
|
1198
|
+
var handleChange = function handleChange(_ref) {
|
|
1199
|
+
var target = _ref.target;
|
|
1181
1200
|
return onChange(target.value === "" ? emptyValue : target.value);
|
|
1182
1201
|
};
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
let {
|
|
1186
|
-
target
|
|
1187
|
-
} = _ref3;
|
|
1202
|
+
var handleBlur = function handleBlur(_ref2) {
|
|
1203
|
+
var target = _ref2.target;
|
|
1188
1204
|
return onBlur(id, target.value);
|
|
1189
1205
|
};
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
let {
|
|
1193
|
-
target
|
|
1194
|
-
} = _ref4;
|
|
1206
|
+
var handleFocus = function handleFocus(_ref3) {
|
|
1207
|
+
var target = _ref3.target;
|
|
1195
1208
|
return onFocus(id, target.value);
|
|
1196
1209
|
};
|
|
1197
|
-
|
|
1198
1210
|
return /*#__PURE__*/React__default["default"].createElement(Input__default["default"].Password, {
|
|
1199
1211
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1200
1212
|
id: id,
|
|
@@ -1203,251 +1215,238 @@
|
|
|
1203
1215
|
onChange: !readonly ? handleChange : undefined,
|
|
1204
1216
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1205
1217
|
placeholder: placeholder,
|
|
1206
|
-
value: value || ""
|
|
1218
|
+
value: value || "",
|
|
1219
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1207
1220
|
});
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
/* eslint-disable no-else-return */
|
|
1211
|
-
|
|
1212
|
-
const RadioWidget = _ref => {
|
|
1213
|
-
let {
|
|
1214
|
-
autofocus,
|
|
1215
|
-
disabled,
|
|
1216
|
-
formContext,
|
|
1217
|
-
id,
|
|
1218
|
-
// label,
|
|
1219
|
-
onBlur,
|
|
1220
|
-
onChange,
|
|
1221
|
-
onFocus,
|
|
1222
|
-
options,
|
|
1223
|
-
// placeholder,
|
|
1224
|
-
readonly,
|
|
1225
|
-
// required,
|
|
1226
|
-
schema,
|
|
1227
|
-
value
|
|
1228
|
-
} = _ref;
|
|
1229
|
-
const {
|
|
1230
|
-
readonlyAsDisabled = true
|
|
1231
|
-
} = formContext;
|
|
1232
|
-
const {
|
|
1233
|
-
enumOptions,
|
|
1234
|
-
enumDisabled
|
|
1235
|
-
} = options;
|
|
1221
|
+
}
|
|
1236
1222
|
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1223
|
+
/** The `RadioWidget` is a widget for rendering a radio group.
|
|
1224
|
+
* It is typically used with a string property constrained with enum options.
|
|
1225
|
+
*
|
|
1226
|
+
* @param props - The `WidgetProps` for this component
|
|
1227
|
+
*/
|
|
1228
|
+
function RadioWidget(_ref) {
|
|
1229
|
+
var autofocus = _ref.autofocus,
|
|
1230
|
+
disabled = _ref.disabled,
|
|
1231
|
+
formContext = _ref.formContext,
|
|
1232
|
+
id = _ref.id,
|
|
1233
|
+
onBlur = _ref.onBlur,
|
|
1234
|
+
onChange = _ref.onChange,
|
|
1235
|
+
onFocus = _ref.onFocus,
|
|
1236
|
+
options = _ref.options,
|
|
1237
|
+
readonly = _ref.readonly,
|
|
1238
|
+
value = _ref.value;
|
|
1239
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1240
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1241
|
+
var enumOptions = options.enumOptions,
|
|
1242
|
+
enumDisabled = options.enumDisabled,
|
|
1243
|
+
emptyValue = options.emptyValue;
|
|
1244
|
+
var handleChange = function handleChange(_ref2) {
|
|
1245
|
+
var nextValue = _ref2.target.value;
|
|
1246
|
+
return onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1244
1247
|
};
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
target
|
|
1249
|
-
} = _ref3;
|
|
1250
|
-
return onBlur(id, target.value);
|
|
1248
|
+
var handleBlur = function handleBlur(_ref3) {
|
|
1249
|
+
var target = _ref3.target;
|
|
1250
|
+
return onBlur(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1251
1251
|
};
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
target
|
|
1256
|
-
} = _ref4;
|
|
1257
|
-
return onFocus(id, target.value);
|
|
1252
|
+
var handleFocus = function handleFocus(_ref4) {
|
|
1253
|
+
var target = _ref4.target;
|
|
1254
|
+
return onFocus(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1258
1255
|
};
|
|
1259
|
-
|
|
1256
|
+
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions);
|
|
1260
1257
|
return /*#__PURE__*/React__default["default"].createElement(Radio__default["default"].Group, {
|
|
1261
1258
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1262
1259
|
id: id,
|
|
1263
1260
|
name: id,
|
|
1264
|
-
onBlur: !readonly ? handleBlur : undefined,
|
|
1265
1261
|
onChange: !readonly ? handleChange : undefined,
|
|
1262
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
1266
1263
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1267
|
-
value:
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
value: optionValue,
|
|
1271
|
-
label: optionLabel
|
|
1272
|
-
} = _ref5;
|
|
1264
|
+
value: selectedIndexes,
|
|
1265
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1266
|
+
}, Array.isArray(enumOptions) && enumOptions.map(function (option, i) {
|
|
1273
1267
|
return /*#__PURE__*/React__default["default"].createElement(Radio__default["default"], {
|
|
1268
|
+
id: utils.optionId(id, i),
|
|
1269
|
+
name: id,
|
|
1274
1270
|
autoFocus: i === 0 ? autofocus : false,
|
|
1275
|
-
disabled: enumDisabled && enumDisabled.indexOf(value) !== -1,
|
|
1276
|
-
key:
|
|
1277
|
-
value:
|
|
1278
|
-
},
|
|
1271
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1272
|
+
key: i,
|
|
1273
|
+
value: String(i)
|
|
1274
|
+
}, option.label);
|
|
1279
1275
|
}));
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1282
|
-
/* eslint-disable no-else-return */
|
|
1283
|
-
|
|
1284
|
-
const RangeWidget = _ref => {
|
|
1285
|
-
let {
|
|
1286
|
-
autofocus,
|
|
1287
|
-
disabled,
|
|
1288
|
-
formContext,
|
|
1289
|
-
id,
|
|
1290
|
-
// label,
|
|
1291
|
-
onBlur,
|
|
1292
|
-
onChange,
|
|
1293
|
-
onFocus,
|
|
1294
|
-
options,
|
|
1295
|
-
placeholder,
|
|
1296
|
-
readonly,
|
|
1297
|
-
// required,
|
|
1298
|
-
schema,
|
|
1299
|
-
value
|
|
1300
|
-
} = _ref;
|
|
1301
|
-
const {
|
|
1302
|
-
readonlyAsDisabled = true
|
|
1303
|
-
} = formContext;
|
|
1304
|
-
const {
|
|
1305
|
-
min,
|
|
1306
|
-
max,
|
|
1307
|
-
step
|
|
1308
|
-
} = utils.rangeSpec(schema);
|
|
1309
|
-
const emptyValue = options.emptyValue || "";
|
|
1310
|
-
|
|
1311
|
-
const handleChange = nextValue => onChange(nextValue === "" ? emptyValue : nextValue);
|
|
1312
|
-
|
|
1313
|
-
const handleBlur = () => onBlur(id, value);
|
|
1314
|
-
|
|
1315
|
-
const handleFocus = () => onFocus(id, value);
|
|
1276
|
+
}
|
|
1316
1277
|
|
|
1317
|
-
|
|
1278
|
+
/** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
|
|
1279
|
+
* in a div, with the value along side it.
|
|
1280
|
+
*
|
|
1281
|
+
* @param props - The `WidgetProps` for this component
|
|
1282
|
+
*/
|
|
1283
|
+
function RangeWidget(props) {
|
|
1284
|
+
var autofocus = props.autofocus,
|
|
1285
|
+
disabled = props.disabled,
|
|
1286
|
+
formContext = props.formContext,
|
|
1287
|
+
id = props.id,
|
|
1288
|
+
onBlur = props.onBlur,
|
|
1289
|
+
onChange = props.onChange,
|
|
1290
|
+
onFocus = props.onFocus,
|
|
1291
|
+
options = props.options,
|
|
1292
|
+
placeholder = props.placeholder,
|
|
1293
|
+
readonly = props.readonly,
|
|
1294
|
+
schema = props.schema,
|
|
1295
|
+
value = props.value;
|
|
1296
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1297
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1298
|
+
var _rangeSpec = utils.rangeSpec(schema),
|
|
1299
|
+
min = _rangeSpec.min,
|
|
1300
|
+
max = _rangeSpec.max,
|
|
1301
|
+
step = _rangeSpec.step;
|
|
1302
|
+
var emptyValue = options.emptyValue || "";
|
|
1303
|
+
var handleChange = function handleChange(nextValue) {
|
|
1304
|
+
return onChange(nextValue === "" ? emptyValue : nextValue);
|
|
1305
|
+
};
|
|
1306
|
+
var handleBlur = function handleBlur() {
|
|
1307
|
+
return onBlur(id, value);
|
|
1308
|
+
};
|
|
1309
|
+
var handleFocus = function handleFocus() {
|
|
1310
|
+
return onFocus(id, value);
|
|
1311
|
+
};
|
|
1312
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1313
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1314
|
+
var extraProps = {
|
|
1315
|
+
placeholder: placeholder,
|
|
1316
|
+
onBlur: !readonly ? handleBlur : undefined,
|
|
1317
|
+
onFocus: !readonly ? handleFocus : undefined
|
|
1318
|
+
};
|
|
1319
|
+
return /*#__PURE__*/React__default["default"].createElement(Slider__default["default"], _extends({
|
|
1318
1320
|
autoFocus: autofocus,
|
|
1319
1321
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1320
1322
|
id: id,
|
|
1321
1323
|
max: max,
|
|
1322
1324
|
min: min,
|
|
1323
|
-
onBlur: !readonly ? handleBlur : undefined,
|
|
1324
1325
|
onChange: !readonly ? handleChange : undefined,
|
|
1325
|
-
onFocus: !readonly ? handleFocus : undefined,
|
|
1326
|
-
placeholder: placeholder,
|
|
1327
1326
|
range: false,
|
|
1328
1327
|
step: step,
|
|
1329
1328
|
value: value
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1329
|
+
}, extraProps, {
|
|
1330
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1331
|
+
}));
|
|
1332
|
+
}
|
|
1332
1333
|
|
|
1333
|
-
|
|
1334
|
-
const SELECT_STYLE = {
|
|
1334
|
+
var SELECT_STYLE = {
|
|
1335
1335
|
width: "100%"
|
|
1336
1336
|
};
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
readonlyAsDisabled = true
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1337
|
+
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
1338
|
+
* It is typically used with string properties constrained with enum options.
|
|
1339
|
+
*
|
|
1340
|
+
* @param props - The `WidgetProps` for this component
|
|
1341
|
+
*/
|
|
1342
|
+
function SelectWidget(_ref) {
|
|
1343
|
+
var autofocus = _ref.autofocus,
|
|
1344
|
+
disabled = _ref.disabled,
|
|
1345
|
+
_ref$formContext = _ref.formContext,
|
|
1346
|
+
formContext = _ref$formContext === void 0 ? {} : _ref$formContext,
|
|
1347
|
+
id = _ref.id,
|
|
1348
|
+
multiple = _ref.multiple,
|
|
1349
|
+
onBlur = _ref.onBlur,
|
|
1350
|
+
onChange = _ref.onChange,
|
|
1351
|
+
onFocus = _ref.onFocus,
|
|
1352
|
+
options = _ref.options,
|
|
1353
|
+
placeholder = _ref.placeholder,
|
|
1354
|
+
readonly = _ref.readonly,
|
|
1355
|
+
value = _ref.value;
|
|
1356
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1357
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1358
|
+
var enumOptions = options.enumOptions,
|
|
1359
|
+
enumDisabled = options.enumDisabled,
|
|
1360
|
+
emptyValue = options.emptyValue;
|
|
1361
|
+
var handleChange = function handleChange(nextValue) {
|
|
1362
|
+
return onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1363
|
+
};
|
|
1364
|
+
var handleBlur = function handleBlur() {
|
|
1365
|
+
return onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1366
|
+
};
|
|
1367
|
+
var handleFocus = function handleFocus() {
|
|
1368
|
+
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1369
|
+
};
|
|
1370
|
+
var filterOption = function filterOption(input, option) {
|
|
1371
|
+
if (option && isString__default["default"](option.label)) {
|
|
1372
|
+
// labels are strings in this context
|
|
1373
|
+
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
1374
|
+
}
|
|
1375
|
+
return false;
|
|
1376
|
+
};
|
|
1377
|
+
var getPopupContainer = function getPopupContainer(node) {
|
|
1378
|
+
return node.parentNode;
|
|
1379
|
+
};
|
|
1380
|
+
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1381
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1382
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1383
|
+
var extraProps = {
|
|
1384
|
+
name: id
|
|
1385
|
+
};
|
|
1386
|
+
return /*#__PURE__*/React__default["default"].createElement(Select__default["default"], _extends({
|
|
1375
1387
|
autoFocus: autofocus,
|
|
1376
1388
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1377
1389
|
getPopupContainer: getPopupContainer,
|
|
1378
1390
|
id: id,
|
|
1379
1391
|
mode: typeof multiple !== "undefined" ? "multiple" : undefined,
|
|
1380
|
-
name: id,
|
|
1381
1392
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1382
1393
|
onChange: !readonly ? handleChange : undefined,
|
|
1383
1394
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1384
1395
|
placeholder: placeholder,
|
|
1385
1396
|
style: SELECT_STYLE,
|
|
1386
|
-
value:
|
|
1387
|
-
},
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1397
|
+
value: selectedIndexes
|
|
1398
|
+
}, extraProps, {
|
|
1399
|
+
filterOption: filterOption,
|
|
1400
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1401
|
+
}), Array.isArray(enumOptions) && enumOptions.map(function (_ref2, index) {
|
|
1402
|
+
var optionValue = _ref2.value,
|
|
1403
|
+
optionLabel = _ref2.label;
|
|
1392
1404
|
return /*#__PURE__*/React__default["default"].createElement(Select__default["default"].Option, {
|
|
1393
|
-
disabled: enumDisabled && enumDisabled.indexOf(optionValue) !== -1,
|
|
1394
|
-
key: String(
|
|
1395
|
-
value: String(
|
|
1405
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
|
|
1406
|
+
key: String(index),
|
|
1407
|
+
value: String(index)
|
|
1396
1408
|
}, optionLabel);
|
|
1397
1409
|
}));
|
|
1398
|
-
}
|
|
1399
|
-
|
|
1400
|
-
SelectWidget.defaultProps = {
|
|
1401
|
-
formContext: {}
|
|
1402
|
-
};
|
|
1410
|
+
}
|
|
1403
1411
|
|
|
1404
|
-
|
|
1412
|
+
var INPUT_STYLE = {
|
|
1405
1413
|
width: "100%"
|
|
1406
1414
|
};
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
onBlur,
|
|
1416
|
-
onChange,
|
|
1417
|
-
onFocus,
|
|
1418
|
-
options,
|
|
1419
|
-
placeholder,
|
|
1420
|
-
readonly,
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
readonlyAsDisabled = true
|
|
1427
|
-
} = formContext;
|
|
1428
|
-
|
|
1429
|
-
const handleChange = _ref2 => {
|
|
1430
|
-
let {
|
|
1431
|
-
target
|
|
1432
|
-
} = _ref2;
|
|
1415
|
+
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1416
|
+
*
|
|
1417
|
+
* @param props - The `WidgetProps` for this component
|
|
1418
|
+
*/
|
|
1419
|
+
function TextareaWidget(_ref) {
|
|
1420
|
+
var disabled = _ref.disabled,
|
|
1421
|
+
formContext = _ref.formContext,
|
|
1422
|
+
id = _ref.id,
|
|
1423
|
+
onBlur = _ref.onBlur,
|
|
1424
|
+
onChange = _ref.onChange,
|
|
1425
|
+
onFocus = _ref.onFocus,
|
|
1426
|
+
options = _ref.options,
|
|
1427
|
+
placeholder = _ref.placeholder,
|
|
1428
|
+
readonly = _ref.readonly,
|
|
1429
|
+
value = _ref.value;
|
|
1430
|
+
var _formContext$readonly = formContext.readonlyAsDisabled,
|
|
1431
|
+
readonlyAsDisabled = _formContext$readonly === void 0 ? true : _formContext$readonly;
|
|
1432
|
+
var handleChange = function handleChange(_ref2) {
|
|
1433
|
+
var target = _ref2.target;
|
|
1433
1434
|
return onChange(target.value === "" ? options.emptyValue : target.value);
|
|
1434
1435
|
};
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
let {
|
|
1438
|
-
target
|
|
1439
|
-
} = _ref3;
|
|
1436
|
+
var handleBlur = function handleBlur(_ref3) {
|
|
1437
|
+
var target = _ref3.target;
|
|
1440
1438
|
return onBlur(id, target.value);
|
|
1441
1439
|
};
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
let {
|
|
1445
|
-
target
|
|
1446
|
-
} = _ref4;
|
|
1440
|
+
var handleFocus = function handleFocus(_ref4) {
|
|
1441
|
+
var target = _ref4.target;
|
|
1447
1442
|
return onFocus(id, target.value);
|
|
1448
1443
|
};
|
|
1449
|
-
|
|
1450
|
-
|
|
1444
|
+
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1445
|
+
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1446
|
+
var extraProps = {
|
|
1447
|
+
type: "textarea"
|
|
1448
|
+
};
|
|
1449
|
+
return /*#__PURE__*/React__default["default"].createElement(Input__default["default"].TextArea, _extends({
|
|
1451
1450
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1452
1451
|
id: id,
|
|
1453
1452
|
name: id,
|
|
@@ -1457,51 +1456,50 @@
|
|
|
1457
1456
|
placeholder: placeholder,
|
|
1458
1457
|
rows: options.rows || 4,
|
|
1459
1458
|
style: INPUT_STYLE,
|
|
1460
|
-
type: "textarea",
|
|
1461
1459
|
value: value
|
|
1462
|
-
}
|
|
1463
|
-
|
|
1460
|
+
}, extraProps, {
|
|
1461
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1462
|
+
}));
|
|
1463
|
+
}
|
|
1464
1464
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
FieldTemplate,
|
|
1494
|
-
ObjectFieldTemplate: ObjectFieldTemplate$1,
|
|
1495
|
-
TitleFieldTemplate: TitleField$1
|
|
1496
|
-
},
|
|
1497
|
-
widgets: Widgets
|
|
1498
|
-
};
|
|
1499
|
-
const Form = /*#__PURE__*/core.withTheme(Theme);
|
|
1465
|
+
function generateWidgets() {
|
|
1466
|
+
return {
|
|
1467
|
+
AltDateTimeWidget: AltDateTimeWidget,
|
|
1468
|
+
AltDateWidget: AltDateWidget,
|
|
1469
|
+
CheckboxesWidget: CheckboxesWidget,
|
|
1470
|
+
CheckboxWidget: CheckboxWidget,
|
|
1471
|
+
DateTimeWidget: DateTimeWidget,
|
|
1472
|
+
DateWidget: DateWidget,
|
|
1473
|
+
PasswordWidget: PasswordWidget,
|
|
1474
|
+
RadioWidget: RadioWidget,
|
|
1475
|
+
RangeWidget: RangeWidget,
|
|
1476
|
+
SelectWidget: SelectWidget,
|
|
1477
|
+
TextareaWidget: TextareaWidget
|
|
1478
|
+
};
|
|
1479
|
+
}
|
|
1480
|
+
var index = /*#__PURE__*/generateWidgets();
|
|
1481
|
+
|
|
1482
|
+
function generateTheme() {
|
|
1483
|
+
return {
|
|
1484
|
+
templates: generateTemplates(),
|
|
1485
|
+
widgets: generateWidgets()
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1488
|
+
var Theme = /*#__PURE__*/generateTheme();
|
|
1489
|
+
function generateForm() {
|
|
1490
|
+
return core.withTheme(generateTheme());
|
|
1491
|
+
}
|
|
1492
|
+
var Form = /*#__PURE__*/generateForm();
|
|
1500
1493
|
|
|
1501
1494
|
exports.Form = Form;
|
|
1495
|
+
exports.Templates = index$1;
|
|
1502
1496
|
exports.Theme = Theme;
|
|
1503
|
-
exports.Widgets =
|
|
1497
|
+
exports.Widgets = index;
|
|
1504
1498
|
exports["default"] = Form;
|
|
1499
|
+
exports.generateForm = generateForm;
|
|
1500
|
+
exports.generateTemplates = generateTemplates;
|
|
1501
|
+
exports.generateTheme = generateTheme;
|
|
1502
|
+
exports.generateWidgets = generateWidgets;
|
|
1505
1503
|
|
|
1506
1504
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1507
1505
|
|