@rjsf/antd 5.0.0-beta.14 → 5.0.0-beta.16

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