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