@rjsf/antd 5.10.0 → 5.11.2
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 +777 -780
- 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 +778 -781
- package/dist/antd.esm.js.map +1 -1
- package/dist/antd.umd.development.js +777 -780
- 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/package.json +11 -10
|
@@ -63,10 +63,10 @@ var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
|
|
|
63
63
|
var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
|
|
64
64
|
var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
const BTN_GRP_STYLE = {
|
|
67
67
|
width: '100%'
|
|
68
68
|
};
|
|
69
|
-
|
|
69
|
+
const BTN_STYLE = {
|
|
70
70
|
width: 'calc(100% / 4)'
|
|
71
71
|
};
|
|
72
72
|
/** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
|
|
@@ -74,30 +74,32 @@ var BTN_STYLE = {
|
|
|
74
74
|
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
75
75
|
*/
|
|
76
76
|
function ArrayFieldItemTemplate(props) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
77
|
+
const {
|
|
78
|
+
children,
|
|
79
|
+
disabled,
|
|
80
|
+
hasCopy,
|
|
81
|
+
hasMoveDown,
|
|
82
|
+
hasMoveUp,
|
|
83
|
+
hasRemove,
|
|
84
|
+
hasToolbar,
|
|
85
|
+
index,
|
|
86
|
+
onCopyIndexClick,
|
|
87
|
+
onDropIndexClick,
|
|
88
|
+
onReorderClick,
|
|
89
|
+
readonly,
|
|
90
|
+
registry,
|
|
91
|
+
uiSchema
|
|
92
|
+
} = props;
|
|
93
|
+
const {
|
|
94
|
+
CopyButton,
|
|
95
|
+
MoveDownButton,
|
|
96
|
+
MoveUpButton,
|
|
97
|
+
RemoveButton
|
|
98
|
+
} = registry.templates.ButtonTemplates;
|
|
99
|
+
const {
|
|
100
|
+
rowGutter = 24,
|
|
101
|
+
toolbarAlign = 'top'
|
|
102
|
+
} = registry.formContext;
|
|
101
103
|
return jsxRuntime.jsxs(Row__default["default"], {
|
|
102
104
|
align: toolbarAlign,
|
|
103
105
|
gutter: rowGutter,
|
|
@@ -135,38 +137,10 @@ function ArrayFieldItemTemplate(props) {
|
|
|
135
137
|
})]
|
|
136
138
|
})
|
|
137
139
|
})]
|
|
138
|
-
},
|
|
140
|
+
}, `array-item-${index}`);
|
|
139
141
|
}
|
|
140
142
|
|
|
141
|
-
|
|
142
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
143
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
144
|
-
var source = arguments[i];
|
|
145
|
-
for (var key in source) {
|
|
146
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
147
|
-
target[key] = source[key];
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return target;
|
|
152
|
-
};
|
|
153
|
-
return _extends.apply(this, arguments);
|
|
154
|
-
}
|
|
155
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
156
|
-
if (source == null) return {};
|
|
157
|
-
var target = {};
|
|
158
|
-
var sourceKeys = Object.keys(source);
|
|
159
|
-
var key, i;
|
|
160
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
161
|
-
key = sourceKeys[i];
|
|
162
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
163
|
-
target[key] = source[key];
|
|
164
|
-
}
|
|
165
|
-
return target;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
var _excluded$1 = ["key"];
|
|
169
|
-
var DESCRIPTION_COL_STYLE$1 = {
|
|
143
|
+
const DESCRIPTION_COL_STYLE$1 = {
|
|
170
144
|
paddingBottom: '8px'
|
|
171
145
|
};
|
|
172
146
|
/** The `ArrayFieldTemplate` component is the template used to render all items in an array.
|
|
@@ -174,35 +148,43 @@ var DESCRIPTION_COL_STYLE$1 = {
|
|
|
174
148
|
* @param props - The `ArrayFieldTemplateItemType` props for the component
|
|
175
149
|
*/
|
|
176
150
|
function ArrayFieldTemplate(props) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
151
|
+
const {
|
|
152
|
+
canAdd,
|
|
153
|
+
className,
|
|
154
|
+
disabled,
|
|
155
|
+
formContext,
|
|
156
|
+
idSchema,
|
|
157
|
+
items,
|
|
158
|
+
onAddClick,
|
|
159
|
+
readonly,
|
|
160
|
+
registry,
|
|
161
|
+
required,
|
|
162
|
+
schema,
|
|
163
|
+
title,
|
|
164
|
+
uiSchema
|
|
165
|
+
} = props;
|
|
166
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
167
|
+
const ArrayFieldDescriptionTemplate = utils.getTemplate('ArrayFieldDescriptionTemplate', registry, uiOptions);
|
|
168
|
+
const ArrayFieldItemTemplate = utils.getTemplate('ArrayFieldItemTemplate', registry, uiOptions);
|
|
169
|
+
const ArrayFieldTitleTemplate = utils.getTemplate('ArrayFieldTitleTemplate', registry, uiOptions);
|
|
194
170
|
// Button templates are not overridden in the uiSchema
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
171
|
+
const {
|
|
172
|
+
ButtonTemplates: {
|
|
173
|
+
AddButton
|
|
174
|
+
}
|
|
175
|
+
} = registry.templates;
|
|
176
|
+
const {
|
|
177
|
+
labelAlign = 'right',
|
|
178
|
+
rowGutter = 24
|
|
179
|
+
} = formContext;
|
|
200
180
|
return jsxRuntime.jsx(context.ConfigConsumer, {
|
|
201
|
-
children:
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
181
|
+
children: configProps => {
|
|
182
|
+
const {
|
|
183
|
+
getPrefixCls
|
|
184
|
+
} = configProps;
|
|
185
|
+
const prefixCls = getPrefixCls('form');
|
|
186
|
+
const labelClsBasic = `${prefixCls}-item-label`;
|
|
187
|
+
const labelColClassName = classNames__default["default"](labelClsBasic, labelAlign === 'left' && `${labelClsBasic}-left`
|
|
206
188
|
// labelCol.className,
|
|
207
189
|
);
|
|
208
190
|
|
|
@@ -235,11 +217,12 @@ function ArrayFieldTemplate(props) {
|
|
|
235
217
|
}), jsxRuntime.jsx(Col__default["default"], {
|
|
236
218
|
className: 'row array-item-list',
|
|
237
219
|
span: 24,
|
|
238
|
-
children: items && items.map(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
220
|
+
children: items && items.map(({
|
|
221
|
+
key,
|
|
222
|
+
...itemProps
|
|
223
|
+
}) => jsxRuntime.jsx(ArrayFieldItemTemplate, {
|
|
224
|
+
...itemProps
|
|
225
|
+
}, key))
|
|
243
226
|
}), canAdd && jsxRuntime.jsx(Col__default["default"], {
|
|
244
227
|
span: 24,
|
|
245
228
|
children: jsxRuntime.jsx(Row__default["default"], {
|
|
@@ -263,7 +246,7 @@ function ArrayFieldTemplate(props) {
|
|
|
263
246
|
});
|
|
264
247
|
}
|
|
265
248
|
|
|
266
|
-
|
|
249
|
+
const INPUT_STYLE$2 = {
|
|
267
250
|
width: '100%'
|
|
268
251
|
};
|
|
269
252
|
/** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
|
|
@@ -273,38 +256,36 @@ var INPUT_STYLE$2 = {
|
|
|
273
256
|
* @param props - The `WidgetProps` for this template
|
|
274
257
|
*/
|
|
275
258
|
function BaseInputTemplate(props) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
};
|
|
307
|
-
var input = inputProps.type === 'number' || inputProps.type === 'integer' ? jsxRuntime.jsx(InputNumber__default["default"], _extends({
|
|
259
|
+
const {
|
|
260
|
+
disabled,
|
|
261
|
+
formContext,
|
|
262
|
+
id,
|
|
263
|
+
onBlur,
|
|
264
|
+
onChange,
|
|
265
|
+
onChangeOverride,
|
|
266
|
+
onFocus,
|
|
267
|
+
options,
|
|
268
|
+
placeholder,
|
|
269
|
+
readonly,
|
|
270
|
+
schema,
|
|
271
|
+
value,
|
|
272
|
+
type
|
|
273
|
+
} = props;
|
|
274
|
+
const inputProps = utils.getInputProps(schema, type, options, false);
|
|
275
|
+
const {
|
|
276
|
+
readonlyAsDisabled = true
|
|
277
|
+
} = formContext;
|
|
278
|
+
const handleNumberChange = nextValue => onChange(nextValue);
|
|
279
|
+
const handleTextChange = onChangeOverride ? onChangeOverride : ({
|
|
280
|
+
target
|
|
281
|
+
}) => onChange(target.value === '' ? options.emptyValue : target.value);
|
|
282
|
+
const handleBlur = ({
|
|
283
|
+
target
|
|
284
|
+
}) => onBlur(id, target.value);
|
|
285
|
+
const handleFocus = ({
|
|
286
|
+
target
|
|
287
|
+
}) => onFocus(id, target.value);
|
|
288
|
+
const input = inputProps.type === 'number' || inputProps.type === 'integer' ? jsxRuntime.jsx(InputNumber__default["default"], {
|
|
308
289
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
309
290
|
id: id,
|
|
310
291
|
name: id,
|
|
@@ -313,11 +294,11 @@ function BaseInputTemplate(props) {
|
|
|
313
294
|
onFocus: !readonly ? handleFocus : undefined,
|
|
314
295
|
placeholder: placeholder,
|
|
315
296
|
style: INPUT_STYLE$2,
|
|
316
|
-
list: schema.examples ? utils.examplesId(id) : undefined
|
|
317
|
-
|
|
297
|
+
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
298
|
+
...inputProps,
|
|
318
299
|
value: value,
|
|
319
300
|
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
320
|
-
})
|
|
301
|
+
}) : jsxRuntime.jsx(Input__default["default"], {
|
|
321
302
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
322
303
|
id: id,
|
|
323
304
|
name: id,
|
|
@@ -326,15 +307,15 @@ function BaseInputTemplate(props) {
|
|
|
326
307
|
onFocus: !readonly ? handleFocus : undefined,
|
|
327
308
|
placeholder: placeholder,
|
|
328
309
|
style: INPUT_STYLE$2,
|
|
329
|
-
list: schema.examples ? utils.examplesId(id) : undefined
|
|
330
|
-
|
|
310
|
+
list: schema.examples ? utils.examplesId(id) : undefined,
|
|
311
|
+
...inputProps,
|
|
331
312
|
value: value,
|
|
332
313
|
"aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
|
|
333
|
-
})
|
|
314
|
+
});
|
|
334
315
|
return jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
335
316
|
children: [input, Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
|
|
336
317
|
id: utils.examplesId(id),
|
|
337
|
-
children: schema.examples.concat(schema
|
|
318
|
+
children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map(example => {
|
|
338
319
|
return jsxRuntime.jsx("option", {
|
|
339
320
|
value: example
|
|
340
321
|
}, example);
|
|
@@ -348,8 +329,10 @@ function BaseInputTemplate(props) {
|
|
|
348
329
|
* @param props - The `DescriptionFieldProps` for this component
|
|
349
330
|
*/
|
|
350
331
|
function DescriptionField(props) {
|
|
351
|
-
|
|
352
|
-
|
|
332
|
+
const {
|
|
333
|
+
id,
|
|
334
|
+
description
|
|
335
|
+
} = props;
|
|
353
336
|
if (!description) {
|
|
354
337
|
return null;
|
|
355
338
|
}
|
|
@@ -363,23 +346,22 @@ function DescriptionField(props) {
|
|
|
363
346
|
*
|
|
364
347
|
* @param props - The `ErrorListProps` for this component
|
|
365
348
|
*/
|
|
366
|
-
function ErrorList(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
}, index);
|
|
349
|
+
function ErrorList({
|
|
350
|
+
errors,
|
|
351
|
+
registry
|
|
352
|
+
}) {
|
|
353
|
+
const {
|
|
354
|
+
translateString
|
|
355
|
+
} = registry;
|
|
356
|
+
const renderErrors = () => jsxRuntime.jsx(List__default["default"], {
|
|
357
|
+
className: 'list-group',
|
|
358
|
+
size: 'small',
|
|
359
|
+
children: errors.map((error, index) => jsxRuntime.jsx(List__default["default"].Item, {
|
|
360
|
+
children: jsxRuntime.jsxs(Space__default["default"], {
|
|
361
|
+
children: [jsxRuntime.jsx(ExclamationCircleOutlined__default["default"], {}), error.stack]
|
|
380
362
|
})
|
|
381
|
-
})
|
|
382
|
-
};
|
|
363
|
+
}, index))
|
|
364
|
+
});
|
|
383
365
|
return jsxRuntime.jsx(Alert__default["default"], {
|
|
384
366
|
className: 'panel panel-danger errors',
|
|
385
367
|
description: renderErrors(),
|
|
@@ -388,63 +370,86 @@ function ErrorList(_ref) {
|
|
|
388
370
|
});
|
|
389
371
|
}
|
|
390
372
|
|
|
391
|
-
var _excluded = ["iconType", "icon", "uiSchema", "registry"];
|
|
392
373
|
function IconButton(props) {
|
|
393
|
-
|
|
394
|
-
iconType =
|
|
395
|
-
icon
|
|
396
|
-
|
|
397
|
-
|
|
374
|
+
const {
|
|
375
|
+
iconType = 'default',
|
|
376
|
+
icon,
|
|
377
|
+
uiSchema,
|
|
378
|
+
registry,
|
|
379
|
+
...otherProps
|
|
380
|
+
} = props;
|
|
381
|
+
return jsxRuntime.jsx(Button__default["default"], {
|
|
398
382
|
type: iconType,
|
|
399
|
-
icon: icon
|
|
400
|
-
|
|
383
|
+
icon: icon,
|
|
384
|
+
...otherProps
|
|
385
|
+
});
|
|
401
386
|
}
|
|
402
387
|
function AddButton(props) {
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
388
|
+
const {
|
|
389
|
+
registry: {
|
|
390
|
+
translateString
|
|
391
|
+
}
|
|
392
|
+
} = props;
|
|
393
|
+
return jsxRuntime.jsx(IconButton, {
|
|
394
|
+
title: translateString(utils.TranslatableString.AddItemButton),
|
|
395
|
+
...props,
|
|
407
396
|
block: true,
|
|
408
397
|
iconType: 'primary',
|
|
409
398
|
icon: jsxRuntime.jsx(PlusCircleOutlined__default["default"], {})
|
|
410
|
-
})
|
|
399
|
+
});
|
|
411
400
|
}
|
|
412
401
|
function CopyButton(props) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
402
|
+
const {
|
|
403
|
+
registry: {
|
|
404
|
+
translateString
|
|
405
|
+
}
|
|
406
|
+
} = props;
|
|
407
|
+
return jsxRuntime.jsx(IconButton, {
|
|
408
|
+
title: translateString(utils.TranslatableString.CopyButton),
|
|
409
|
+
...props,
|
|
417
410
|
icon: jsxRuntime.jsx(CopyOutlined__default["default"], {})
|
|
418
|
-
})
|
|
411
|
+
});
|
|
419
412
|
}
|
|
420
413
|
function MoveDownButton(props) {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
414
|
+
const {
|
|
415
|
+
registry: {
|
|
416
|
+
translateString
|
|
417
|
+
}
|
|
418
|
+
} = props;
|
|
419
|
+
return jsxRuntime.jsx(IconButton, {
|
|
420
|
+
title: translateString(utils.TranslatableString.MoveDownButton),
|
|
421
|
+
...props,
|
|
425
422
|
icon: jsxRuntime.jsx(ArrowDownOutlined__default["default"], {})
|
|
426
|
-
})
|
|
423
|
+
});
|
|
427
424
|
}
|
|
428
425
|
function MoveUpButton(props) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
426
|
+
const {
|
|
427
|
+
registry: {
|
|
428
|
+
translateString
|
|
429
|
+
}
|
|
430
|
+
} = props;
|
|
431
|
+
return jsxRuntime.jsx(IconButton, {
|
|
432
|
+
title: translateString(utils.TranslatableString.MoveUpButton),
|
|
433
|
+
...props,
|
|
433
434
|
icon: jsxRuntime.jsx(ArrowUpOutlined__default["default"], {})
|
|
434
|
-
})
|
|
435
|
+
});
|
|
435
436
|
}
|
|
436
437
|
function RemoveButton(props) {
|
|
437
438
|
// The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
439
|
+
const options = utils.getUiOptions(props.uiSchema);
|
|
440
|
+
const {
|
|
441
|
+
registry: {
|
|
442
|
+
translateString
|
|
443
|
+
}
|
|
444
|
+
} = props;
|
|
445
|
+
return jsxRuntime.jsx(IconButton, {
|
|
446
|
+
title: translateString(utils.TranslatableString.RemoveButton),
|
|
447
|
+
...props,
|
|
443
448
|
danger: true,
|
|
444
449
|
block: !!options.block,
|
|
445
450
|
iconType: 'primary',
|
|
446
451
|
icon: jsxRuntime.jsx(DeleteOutlined__default["default"], {})
|
|
447
|
-
})
|
|
452
|
+
});
|
|
448
453
|
}
|
|
449
454
|
|
|
450
455
|
/** The `FieldErrorTemplate` component renders the errors local to the particular field
|
|
@@ -452,27 +457,26 @@ function RemoveButton(props) {
|
|
|
452
457
|
* @param props - The `FieldErrorProps` for the errors being rendered
|
|
453
458
|
*/
|
|
454
459
|
function FieldErrorTemplate(props) {
|
|
455
|
-
|
|
456
|
-
errors =
|
|
457
|
-
idSchema
|
|
460
|
+
const {
|
|
461
|
+
errors = [],
|
|
462
|
+
idSchema
|
|
463
|
+
} = props;
|
|
458
464
|
if (errors.length === 0) {
|
|
459
465
|
return null;
|
|
460
466
|
}
|
|
461
|
-
|
|
467
|
+
const id = utils.errorId(idSchema);
|
|
462
468
|
return jsxRuntime.jsx("div", {
|
|
463
469
|
id: id,
|
|
464
|
-
children: errors.map(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
}, "field-" + id + "-error-" + error);
|
|
468
|
-
})
|
|
470
|
+
children: errors.map(error => jsxRuntime.jsx("div", {
|
|
471
|
+
children: error
|
|
472
|
+
}, `field-${id}-error-${error}`))
|
|
469
473
|
});
|
|
470
474
|
}
|
|
471
475
|
|
|
472
|
-
|
|
476
|
+
const VERTICAL_LABEL_COL$1 = {
|
|
473
477
|
span: 24
|
|
474
478
|
};
|
|
475
|
-
|
|
479
|
+
const VERTICAL_WRAPPER_COL$1 = {
|
|
476
480
|
span: 24
|
|
477
481
|
};
|
|
478
482
|
/** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
|
|
@@ -481,38 +485,39 @@ var VERTICAL_WRAPPER_COL$1 = {
|
|
|
481
485
|
* @param props - The `FieldTemplateProps` for this component
|
|
482
486
|
*/
|
|
483
487
|
function FieldTemplate(props) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
descriptionLocation =
|
|
514
|
-
|
|
515
|
-
|
|
488
|
+
const {
|
|
489
|
+
children,
|
|
490
|
+
classNames,
|
|
491
|
+
style,
|
|
492
|
+
description,
|
|
493
|
+
disabled,
|
|
494
|
+
displayLabel,
|
|
495
|
+
errors,
|
|
496
|
+
formContext,
|
|
497
|
+
help,
|
|
498
|
+
hidden,
|
|
499
|
+
id,
|
|
500
|
+
label,
|
|
501
|
+
onDropPropertyClick,
|
|
502
|
+
onKeyChange,
|
|
503
|
+
rawErrors,
|
|
504
|
+
rawDescription,
|
|
505
|
+
rawHelp,
|
|
506
|
+
readonly,
|
|
507
|
+
registry,
|
|
508
|
+
required,
|
|
509
|
+
schema,
|
|
510
|
+
uiSchema
|
|
511
|
+
} = props;
|
|
512
|
+
const {
|
|
513
|
+
colon,
|
|
514
|
+
labelCol = VERTICAL_LABEL_COL$1,
|
|
515
|
+
wrapperCol = VERTICAL_WRAPPER_COL$1,
|
|
516
|
+
wrapperStyle,
|
|
517
|
+
descriptionLocation = 'below'
|
|
518
|
+
} = formContext;
|
|
519
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
520
|
+
const WrapIfAdditionalTemplate = utils.getTemplate('WrapIfAdditionalTemplate', registry, uiOptions);
|
|
516
521
|
if (hidden) {
|
|
517
522
|
return jsxRuntime.jsx("div", {
|
|
518
523
|
className: 'field-hidden',
|
|
@@ -521,8 +526,8 @@ function FieldTemplate(props) {
|
|
|
521
526
|
}
|
|
522
527
|
// check to see if there is rawDescription(string) before using description(ReactNode)
|
|
523
528
|
// to prevent showing a blank description area
|
|
524
|
-
|
|
525
|
-
|
|
529
|
+
const descriptionNode = rawDescription ? description : undefined;
|
|
530
|
+
const descriptionProps = {};
|
|
526
531
|
switch (descriptionLocation) {
|
|
527
532
|
case 'tooltip':
|
|
528
533
|
descriptionProps.tooltip = descriptionNode;
|
|
@@ -545,7 +550,7 @@ function FieldTemplate(props) {
|
|
|
545
550
|
schema: schema,
|
|
546
551
|
uiSchema: uiSchema,
|
|
547
552
|
registry: registry,
|
|
548
|
-
children: jsxRuntime.jsx(Form__default["default"].Item,
|
|
553
|
+
children: jsxRuntime.jsx(Form__default["default"].Item, {
|
|
549
554
|
colon: colon,
|
|
550
555
|
hasFeedback: schema.type !== 'array' && schema.type !== 'object',
|
|
551
556
|
help: !!rawHelp && help || (rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? errors : undefined),
|
|
@@ -555,14 +560,14 @@ function FieldTemplate(props) {
|
|
|
555
560
|
required: required,
|
|
556
561
|
style: wrapperStyle,
|
|
557
562
|
validateStatus: rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? 'error' : undefined,
|
|
558
|
-
wrapperCol: wrapperCol
|
|
559
|
-
|
|
563
|
+
wrapperCol: wrapperCol,
|
|
564
|
+
...descriptionProps,
|
|
560
565
|
children: children
|
|
561
|
-
})
|
|
566
|
+
})
|
|
562
567
|
});
|
|
563
568
|
}
|
|
564
569
|
|
|
565
|
-
|
|
570
|
+
const DESCRIPTION_COL_STYLE = {
|
|
566
571
|
paddingBottom: '8px'
|
|
567
572
|
};
|
|
568
573
|
/** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
|
|
@@ -572,54 +577,49 @@ var DESCRIPTION_COL_STYLE = {
|
|
|
572
577
|
* @param props - The `ObjectFieldTemplateProps` for this component
|
|
573
578
|
*/
|
|
574
579
|
function ObjectFieldTemplate(props) {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
580
|
+
const {
|
|
581
|
+
description,
|
|
582
|
+
disabled,
|
|
583
|
+
formContext,
|
|
584
|
+
formData,
|
|
585
|
+
idSchema,
|
|
586
|
+
onAddClick,
|
|
587
|
+
properties,
|
|
588
|
+
readonly,
|
|
589
|
+
required,
|
|
590
|
+
registry,
|
|
591
|
+
schema,
|
|
592
|
+
title,
|
|
593
|
+
uiSchema
|
|
594
|
+
} = props;
|
|
595
|
+
const uiOptions = utils.getUiOptions(uiSchema);
|
|
596
|
+
const TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, uiOptions);
|
|
597
|
+
const DescriptionFieldTemplate = utils.getTemplate('DescriptionFieldTemplate', registry, uiOptions);
|
|
591
598
|
// Button templates are not overridden in the uiSchema
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
};
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
return utils.getUiOptions(findUiSchema(element)).widget;
|
|
613
|
-
};
|
|
614
|
-
var calculateColSpan = function calculateColSpan(element) {
|
|
615
|
-
var type = findSchemaType(element);
|
|
616
|
-
var field = findUiSchemaField(element);
|
|
617
|
-
var widget = findUiSchemaWidget(element);
|
|
618
|
-
var defaultColSpan = properties.length < 2 ||
|
|
599
|
+
const {
|
|
600
|
+
ButtonTemplates: {
|
|
601
|
+
AddButton
|
|
602
|
+
}
|
|
603
|
+
} = registry.templates;
|
|
604
|
+
const {
|
|
605
|
+
colSpan = 24,
|
|
606
|
+
labelAlign = 'right',
|
|
607
|
+
rowGutter = 24
|
|
608
|
+
} = formContext;
|
|
609
|
+
const findSchema = element => element.content.props.schema;
|
|
610
|
+
const findSchemaType = element => findSchema(element).type;
|
|
611
|
+
const findUiSchema = element => element.content.props.uiSchema;
|
|
612
|
+
const findUiSchemaField = element => utils.getUiOptions(findUiSchema(element)).field;
|
|
613
|
+
const findUiSchemaWidget = element => utils.getUiOptions(findUiSchema(element)).widget;
|
|
614
|
+
const calculateColSpan = element => {
|
|
615
|
+
const type = findSchemaType(element);
|
|
616
|
+
const field = findUiSchemaField(element);
|
|
617
|
+
const widget = findUiSchemaWidget(element);
|
|
618
|
+
const defaultColSpan = properties.length < 2 ||
|
|
619
619
|
// Single or no field in object.
|
|
620
620
|
type === 'object' || type === 'array' || widget === 'textarea' ? 24 : 12;
|
|
621
621
|
if (isObject__default["default"](colSpan)) {
|
|
622
|
-
|
|
622
|
+
const colSpanObj = colSpan;
|
|
623
623
|
if (isString__default["default"](widget)) {
|
|
624
624
|
return colSpanObj[widget];
|
|
625
625
|
}
|
|
@@ -636,11 +636,13 @@ function ObjectFieldTemplate(props) {
|
|
|
636
636
|
return defaultColSpan;
|
|
637
637
|
};
|
|
638
638
|
return jsxRuntime.jsx(context.ConfigConsumer, {
|
|
639
|
-
children:
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
639
|
+
children: configProps => {
|
|
640
|
+
const {
|
|
641
|
+
getPrefixCls
|
|
642
|
+
} = configProps;
|
|
643
|
+
const prefixCls = getPrefixCls('form');
|
|
644
|
+
const labelClsBasic = `${prefixCls}-item-label`;
|
|
645
|
+
const labelColClassName = classNames__default["default"](labelClsBasic, labelAlign === 'left' && `${labelClsBasic}-left`
|
|
644
646
|
// labelCol.className,
|
|
645
647
|
);
|
|
646
648
|
|
|
@@ -669,14 +671,10 @@ function ObjectFieldTemplate(props) {
|
|
|
669
671
|
uiSchema: uiSchema,
|
|
670
672
|
registry: registry
|
|
671
673
|
})
|
|
672
|
-
}), properties.filter(
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
span: calculateColSpan(element),
|
|
677
|
-
children: element.content
|
|
678
|
-
}, element.name);
|
|
679
|
-
})]
|
|
674
|
+
}), properties.filter(e => !e.hidden).map(element => jsxRuntime.jsx(Col__default["default"], {
|
|
675
|
+
span: calculateColSpan(element),
|
|
676
|
+
children: element.content
|
|
677
|
+
}, element.name))]
|
|
680
678
|
}), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(Col__default["default"], {
|
|
681
679
|
span: 24,
|
|
682
680
|
children: jsxRuntime.jsx(Row__default["default"], {
|
|
@@ -701,54 +699,64 @@ function ObjectFieldTemplate(props) {
|
|
|
701
699
|
|
|
702
700
|
/** The `SubmitButton` renders a button that represent the `Submit` action on a form
|
|
703
701
|
*/
|
|
704
|
-
function SubmitButton(
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
702
|
+
function SubmitButton({
|
|
703
|
+
uiSchema
|
|
704
|
+
}) {
|
|
705
|
+
const {
|
|
706
|
+
submitText,
|
|
707
|
+
norender,
|
|
708
|
+
props: submitButtonProps
|
|
709
|
+
} = utils.getSubmitButtonOptions(uiSchema);
|
|
710
710
|
if (norender) {
|
|
711
711
|
return null;
|
|
712
712
|
}
|
|
713
|
-
return jsxRuntime.jsx(Button__default["default"],
|
|
714
|
-
type: 'submit'
|
|
715
|
-
|
|
713
|
+
return jsxRuntime.jsx(Button__default["default"], {
|
|
714
|
+
type: 'submit',
|
|
715
|
+
...submitButtonProps,
|
|
716
716
|
htmlType: 'submit',
|
|
717
717
|
children: submitText
|
|
718
|
-
})
|
|
718
|
+
});
|
|
719
719
|
}
|
|
720
720
|
|
|
721
721
|
/** The `TitleField` is the template to use to render the title of a field
|
|
722
722
|
*
|
|
723
723
|
* @param props - The `TitleFieldProps` for this component
|
|
724
724
|
*/
|
|
725
|
-
function TitleField(
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
725
|
+
function TitleField({
|
|
726
|
+
id,
|
|
727
|
+
required,
|
|
728
|
+
registry,
|
|
729
|
+
title
|
|
730
|
+
}) {
|
|
731
|
+
const {
|
|
732
|
+
formContext
|
|
733
|
+
} = registry;
|
|
734
|
+
const {
|
|
735
|
+
colon = true
|
|
736
|
+
} = formContext;
|
|
737
|
+
let labelChildren = title;
|
|
734
738
|
if (colon && typeof title === 'string' && title.trim() !== '') {
|
|
735
739
|
labelChildren = title.replace(/[::]\s*$/, '');
|
|
736
740
|
}
|
|
737
|
-
|
|
741
|
+
const handleLabelClick = () => {
|
|
738
742
|
if (!id) {
|
|
739
743
|
return;
|
|
740
744
|
}
|
|
741
|
-
|
|
745
|
+
const control = document.querySelector(`[id="${id}"]`);
|
|
742
746
|
if (control && control.focus) {
|
|
743
747
|
control.focus();
|
|
744
748
|
}
|
|
745
749
|
};
|
|
746
750
|
return title ? jsxRuntime.jsx(context.ConfigConsumer, {
|
|
747
|
-
children:
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
751
|
+
children: configProps => {
|
|
752
|
+
const {
|
|
753
|
+
getPrefixCls
|
|
754
|
+
} = configProps;
|
|
755
|
+
const prefixCls = getPrefixCls('form');
|
|
756
|
+
const labelClassName = classNames__default["default"]({
|
|
757
|
+
[`${prefixCls}-item-required`]: required,
|
|
758
|
+
[`${prefixCls}-item-no-colon`]: !colon
|
|
759
|
+
});
|
|
752
760
|
return jsxRuntime.jsx("label", {
|
|
753
761
|
className: labelClassName,
|
|
754
762
|
htmlFor: id,
|
|
@@ -760,13 +768,13 @@ function TitleField(_ref) {
|
|
|
760
768
|
}) : null;
|
|
761
769
|
}
|
|
762
770
|
|
|
763
|
-
|
|
771
|
+
const VERTICAL_LABEL_COL = {
|
|
764
772
|
span: 24
|
|
765
773
|
};
|
|
766
|
-
|
|
774
|
+
const VERTICAL_WRAPPER_COL = {
|
|
767
775
|
span: 24
|
|
768
776
|
};
|
|
769
|
-
|
|
777
|
+
const INPUT_STYLE$1 = {
|
|
770
778
|
width: '100%'
|
|
771
779
|
};
|
|
772
780
|
/** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
|
|
@@ -775,39 +783,40 @@ var INPUT_STYLE$1 = {
|
|
|
775
783
|
* @param props - The `WrapIfAdditionalProps` for this component
|
|
776
784
|
*/
|
|
777
785
|
function WrapIfAdditionalTemplate(props) {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
classNames
|
|
781
|
-
style
|
|
782
|
-
disabled
|
|
783
|
-
id
|
|
784
|
-
label
|
|
785
|
-
onDropPropertyClick
|
|
786
|
-
onKeyChange
|
|
787
|
-
readonly
|
|
788
|
-
required
|
|
789
|
-
registry
|
|
790
|
-
schema
|
|
791
|
-
uiSchema
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
labelCol =
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
translateString = registry.translateString;
|
|
786
|
+
const {
|
|
787
|
+
children,
|
|
788
|
+
classNames,
|
|
789
|
+
style,
|
|
790
|
+
disabled,
|
|
791
|
+
id,
|
|
792
|
+
label,
|
|
793
|
+
onDropPropertyClick,
|
|
794
|
+
onKeyChange,
|
|
795
|
+
readonly,
|
|
796
|
+
required,
|
|
797
|
+
registry,
|
|
798
|
+
schema,
|
|
799
|
+
uiSchema
|
|
800
|
+
} = props;
|
|
801
|
+
const {
|
|
802
|
+
colon,
|
|
803
|
+
labelCol = VERTICAL_LABEL_COL,
|
|
804
|
+
readonlyAsDisabled = true,
|
|
805
|
+
rowGutter = 24,
|
|
806
|
+
toolbarAlign = 'top',
|
|
807
|
+
wrapperCol = VERTICAL_WRAPPER_COL,
|
|
808
|
+
wrapperStyle
|
|
809
|
+
} = registry.formContext;
|
|
810
|
+
const {
|
|
811
|
+
templates,
|
|
812
|
+
translateString
|
|
813
|
+
} = registry;
|
|
807
814
|
// Button templates are not overridden in the uiSchema
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
815
|
+
const {
|
|
816
|
+
RemoveButton
|
|
817
|
+
} = templates.ButtonTemplates;
|
|
818
|
+
const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
|
|
819
|
+
const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
|
|
811
820
|
if (!additional) {
|
|
812
821
|
return jsxRuntime.jsx("div", {
|
|
813
822
|
className: classNames,
|
|
@@ -815,15 +824,18 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
815
824
|
children: children
|
|
816
825
|
});
|
|
817
826
|
}
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
};
|
|
827
|
+
const handleBlur = ({
|
|
828
|
+
target
|
|
829
|
+
}) => onKeyChange(target.value);
|
|
822
830
|
// The `block` prop is not part of the `IconButtonProps` defined in the template, so put it into the uiSchema instead
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
831
|
+
const uiOptions = uiSchema ? uiSchema[utils.UI_OPTIONS_KEY] : {};
|
|
832
|
+
const buttonUiOptions = {
|
|
833
|
+
...uiSchema,
|
|
834
|
+
[utils.UI_OPTIONS_KEY]: {
|
|
835
|
+
...uiOptions,
|
|
836
|
+
block: true
|
|
837
|
+
}
|
|
838
|
+
};
|
|
827
839
|
return jsxRuntime.jsx("div", {
|
|
828
840
|
className: classNames,
|
|
829
841
|
style: style,
|
|
@@ -839,7 +851,7 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
839
851
|
colon: colon,
|
|
840
852
|
className: 'form-group',
|
|
841
853
|
hasFeedback: true,
|
|
842
|
-
htmlFor: id
|
|
854
|
+
htmlFor: `${id}-key`,
|
|
843
855
|
label: keyLabel,
|
|
844
856
|
labelCol: labelCol,
|
|
845
857
|
required: required,
|
|
@@ -849,8 +861,8 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
849
861
|
className: 'form-control',
|
|
850
862
|
defaultValue: label,
|
|
851
863
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
852
|
-
id: id
|
|
853
|
-
name: id
|
|
864
|
+
id: `${id}-key`,
|
|
865
|
+
name: `${id}-key`,
|
|
854
866
|
onBlur: !readonly ? handleBlur : undefined,
|
|
855
867
|
style: INPUT_STYLE$1,
|
|
856
868
|
type: 'text'
|
|
@@ -877,31 +889,31 @@ function WrapIfAdditionalTemplate(props) {
|
|
|
877
889
|
|
|
878
890
|
function generateTemplates() {
|
|
879
891
|
return {
|
|
880
|
-
ArrayFieldItemTemplate
|
|
881
|
-
ArrayFieldTemplate
|
|
882
|
-
BaseInputTemplate
|
|
892
|
+
ArrayFieldItemTemplate,
|
|
893
|
+
ArrayFieldTemplate,
|
|
894
|
+
BaseInputTemplate,
|
|
883
895
|
ButtonTemplates: {
|
|
884
|
-
AddButton
|
|
885
|
-
CopyButton
|
|
886
|
-
MoveDownButton
|
|
887
|
-
MoveUpButton
|
|
888
|
-
RemoveButton
|
|
889
|
-
SubmitButton
|
|
896
|
+
AddButton,
|
|
897
|
+
CopyButton,
|
|
898
|
+
MoveDownButton,
|
|
899
|
+
MoveUpButton,
|
|
900
|
+
RemoveButton,
|
|
901
|
+
SubmitButton
|
|
890
902
|
},
|
|
891
903
|
DescriptionFieldTemplate: DescriptionField,
|
|
892
904
|
ErrorListTemplate: ErrorList,
|
|
893
|
-
FieldErrorTemplate
|
|
894
|
-
FieldTemplate
|
|
895
|
-
ObjectFieldTemplate
|
|
905
|
+
FieldErrorTemplate,
|
|
906
|
+
FieldTemplate,
|
|
907
|
+
ObjectFieldTemplate,
|
|
896
908
|
TitleFieldTemplate: TitleField,
|
|
897
|
-
WrapIfAdditionalTemplate
|
|
909
|
+
WrapIfAdditionalTemplate
|
|
898
910
|
};
|
|
899
911
|
}
|
|
900
912
|
var index$1 = /*#__PURE__*/generateTemplates();
|
|
901
913
|
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
for (
|
|
914
|
+
const rangeOptions = (start, stop) => {
|
|
915
|
+
const options = [];
|
|
916
|
+
for (let i = start; i <= stop; i++) {
|
|
905
917
|
options.push({
|
|
906
918
|
value: i,
|
|
907
919
|
label: utils.pad(i, 2)
|
|
@@ -909,22 +921,19 @@ var rangeOptions = function rangeOptions(start, stop) {
|
|
|
909
921
|
}
|
|
910
922
|
return options;
|
|
911
923
|
};
|
|
912
|
-
|
|
913
|
-
return Object.values(state).every(
|
|
914
|
-
return value !== -1;
|
|
915
|
-
});
|
|
924
|
+
const readyForChange = state => {
|
|
925
|
+
return Object.values(state).every(value => value !== -1);
|
|
916
926
|
};
|
|
917
|
-
function dateElementProps(state, time, yearsRange) {
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
var data = [{
|
|
927
|
+
function dateElementProps(state, time, yearsRange = [1900, new Date().getFullYear() + 2]) {
|
|
928
|
+
const {
|
|
929
|
+
year,
|
|
930
|
+
month,
|
|
931
|
+
day,
|
|
932
|
+
hour,
|
|
933
|
+
minute,
|
|
934
|
+
second
|
|
935
|
+
} = state;
|
|
936
|
+
const data = [{
|
|
928
937
|
type: 'year',
|
|
929
938
|
range: yearsRange,
|
|
930
939
|
value: year
|
|
@@ -955,99 +964,103 @@ function dateElementProps(state, time, yearsRange) {
|
|
|
955
964
|
return data;
|
|
956
965
|
}
|
|
957
966
|
function AltDateWidget(props) {
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
967
|
+
const {
|
|
968
|
+
autofocus,
|
|
969
|
+
disabled,
|
|
970
|
+
formContext,
|
|
971
|
+
id,
|
|
972
|
+
onBlur,
|
|
973
|
+
onChange,
|
|
974
|
+
onFocus,
|
|
975
|
+
options,
|
|
976
|
+
readonly,
|
|
977
|
+
registry,
|
|
978
|
+
showTime,
|
|
979
|
+
value
|
|
980
|
+
} = props;
|
|
981
|
+
const {
|
|
982
|
+
translateString,
|
|
983
|
+
widgets
|
|
984
|
+
} = registry;
|
|
985
|
+
const {
|
|
986
|
+
SelectWidget
|
|
987
|
+
} = widgets;
|
|
988
|
+
const {
|
|
989
|
+
rowGutter = 24
|
|
990
|
+
} = formContext;
|
|
991
|
+
const [state, setState] = react.useState(utils.parseDateString(value, showTime));
|
|
992
|
+
react.useEffect(() => {
|
|
979
993
|
setState(utils.parseDateString(value, showTime));
|
|
980
994
|
}, [showTime, value]);
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
995
|
+
const handleChange = (property, nextValue) => {
|
|
996
|
+
const nextState = {
|
|
997
|
+
...state,
|
|
998
|
+
[property]: typeof nextValue === 'undefined' ? -1 : nextValue
|
|
999
|
+
};
|
|
984
1000
|
if (readyForChange(nextState)) {
|
|
985
1001
|
onChange(utils.toDateString(nextState, showTime));
|
|
986
1002
|
} else {
|
|
987
1003
|
setState(nextState);
|
|
988
1004
|
}
|
|
989
1005
|
};
|
|
990
|
-
|
|
1006
|
+
const handleNow = event => {
|
|
991
1007
|
event.preventDefault();
|
|
992
1008
|
if (disabled || readonly) {
|
|
993
1009
|
return;
|
|
994
1010
|
}
|
|
995
|
-
|
|
1011
|
+
const nextState = utils.parseDateString(new Date().toJSON(), showTime);
|
|
996
1012
|
onChange(utils.toDateString(nextState, showTime));
|
|
997
1013
|
};
|
|
998
|
-
|
|
1014
|
+
const handleClear = event => {
|
|
999
1015
|
event.preventDefault();
|
|
1000
1016
|
if (disabled || readonly) {
|
|
1001
1017
|
return;
|
|
1002
1018
|
}
|
|
1003
1019
|
onChange(undefined);
|
|
1004
1020
|
};
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
label: '',
|
|
1028
|
-
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1029
|
-
});
|
|
1030
|
-
};
|
|
1021
|
+
const renderDateElement = elemProps => jsxRuntime.jsx(SelectWidget, {
|
|
1022
|
+
autofocus: elemProps.autofocus,
|
|
1023
|
+
className: 'form-control',
|
|
1024
|
+
disabled: elemProps.disabled,
|
|
1025
|
+
id: elemProps.id,
|
|
1026
|
+
name: elemProps.name,
|
|
1027
|
+
onBlur: elemProps.onBlur,
|
|
1028
|
+
onChange: elemValue => elemProps.select(elemProps.type, elemValue),
|
|
1029
|
+
onFocus: elemProps.onFocus,
|
|
1030
|
+
options: {
|
|
1031
|
+
enumOptions: rangeOptions(elemProps.range[0], elemProps.range[1])
|
|
1032
|
+
},
|
|
1033
|
+
placeholder: elemProps.type,
|
|
1034
|
+
readonly: elemProps.readonly,
|
|
1035
|
+
schema: {
|
|
1036
|
+
type: 'integer'
|
|
1037
|
+
},
|
|
1038
|
+
value: elemProps.value,
|
|
1039
|
+
registry: registry,
|
|
1040
|
+
label: '',
|
|
1041
|
+
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1042
|
+
});
|
|
1031
1043
|
return jsxRuntime.jsxs(Row__default["default"], {
|
|
1032
1044
|
gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)],
|
|
1033
|
-
children: [dateElementProps(state, showTime, options.yearsRange).map(
|
|
1034
|
-
|
|
1045
|
+
children: [dateElementProps(state, showTime, options.yearsRange).map((elemProps, i) => {
|
|
1046
|
+
const elemId = id + '_' + elemProps.type;
|
|
1035
1047
|
return jsxRuntime.jsx(Col__default["default"], {
|
|
1036
1048
|
flex: '88px',
|
|
1037
|
-
children: renderDateElement(
|
|
1049
|
+
children: renderDateElement({
|
|
1050
|
+
...elemProps,
|
|
1038
1051
|
autofocus: autofocus && i === 0,
|
|
1039
|
-
disabled
|
|
1052
|
+
disabled,
|
|
1040
1053
|
id: elemId,
|
|
1041
1054
|
name: id,
|
|
1042
|
-
onBlur
|
|
1043
|
-
onFocus
|
|
1044
|
-
readonly
|
|
1045
|
-
registry
|
|
1055
|
+
onBlur,
|
|
1056
|
+
onFocus,
|
|
1057
|
+
readonly,
|
|
1058
|
+
registry,
|
|
1046
1059
|
select: handleChange,
|
|
1047
1060
|
// NOTE: antd components accept -1 rather than issue a warning
|
|
1048
1061
|
// like material-ui, so we need to convert -1 to undefined here.
|
|
1049
1062
|
value: elemProps.value < 0 ? undefined : elemProps.value
|
|
1050
|
-
})
|
|
1063
|
+
})
|
|
1051
1064
|
}, elemId);
|
|
1052
1065
|
}), !options.hideNowButton && jsxRuntime.jsx(Col__default["default"], {
|
|
1053
1066
|
flex: '88px',
|
|
@@ -1082,62 +1095,66 @@ AltDateWidget.defaultProps = {
|
|
|
1082
1095
|
};
|
|
1083
1096
|
|
|
1084
1097
|
function AltDateTimeWidget(props) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1098
|
+
const {
|
|
1099
|
+
AltDateWidget
|
|
1100
|
+
} = props.registry.widgets;
|
|
1101
|
+
return jsxRuntime.jsx(AltDateWidget, {
|
|
1102
|
+
showTime: true,
|
|
1103
|
+
...props
|
|
1104
|
+
});
|
|
1089
1105
|
}
|
|
1090
|
-
AltDateTimeWidget.defaultProps =
|
|
1106
|
+
AltDateTimeWidget.defaultProps = {
|
|
1107
|
+
...AltDateWidget.defaultProps,
|
|
1091
1108
|
showTime: true
|
|
1092
|
-
}
|
|
1109
|
+
};
|
|
1093
1110
|
|
|
1094
1111
|
/** The `CheckboxesWidget` is a widget for rendering checkbox groups.
|
|
1095
1112
|
* It is typically used to represent an array of enums.
|
|
1096
1113
|
*
|
|
1097
1114
|
* @param props - The `WidgetProps` for this component
|
|
1098
1115
|
*/
|
|
1099
|
-
function CheckboxesWidget(
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
};
|
|
1116
|
+
function CheckboxesWidget({
|
|
1117
|
+
autofocus,
|
|
1118
|
+
disabled,
|
|
1119
|
+
formContext,
|
|
1120
|
+
id,
|
|
1121
|
+
label,
|
|
1122
|
+
hideLabel,
|
|
1123
|
+
onBlur,
|
|
1124
|
+
onChange,
|
|
1125
|
+
onFocus,
|
|
1126
|
+
options,
|
|
1127
|
+
readonly,
|
|
1128
|
+
registry,
|
|
1129
|
+
schema,
|
|
1130
|
+
uiSchema,
|
|
1131
|
+
value
|
|
1132
|
+
}) {
|
|
1133
|
+
const {
|
|
1134
|
+
readonlyAsDisabled = true
|
|
1135
|
+
} = formContext;
|
|
1136
|
+
const TitleFieldTemplate = utils.getTemplate('TitleFieldTemplate', registry, options);
|
|
1137
|
+
const {
|
|
1138
|
+
enumOptions,
|
|
1139
|
+
enumDisabled,
|
|
1140
|
+
inline,
|
|
1141
|
+
emptyValue
|
|
1142
|
+
} = options;
|
|
1143
|
+
const handleChange = nextValue => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1144
|
+
const handleBlur = ({
|
|
1145
|
+
target
|
|
1146
|
+
}) => onBlur(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1147
|
+
const handleFocus = ({
|
|
1148
|
+
target
|
|
1149
|
+
}) => onFocus(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1133
1150
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1134
1151
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1135
|
-
|
|
1136
|
-
id
|
|
1152
|
+
const extraProps = {
|
|
1153
|
+
id,
|
|
1137
1154
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1138
1155
|
onFocus: !readonly ? handleFocus : undefined
|
|
1139
1156
|
};
|
|
1140
|
-
|
|
1157
|
+
const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
|
|
1141
1158
|
return Array.isArray(enumOptions) && enumOptions.length > 0 ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
1142
1159
|
children: [!hideLabel && !!label && jsxRuntime.jsx("div", {
|
|
1143
1160
|
children: jsxRuntime.jsx(TitleFieldTemplate, {
|
|
@@ -1147,26 +1164,24 @@ function CheckboxesWidget(_ref) {
|
|
|
1147
1164
|
uiSchema: uiSchema,
|
|
1148
1165
|
registry: registry
|
|
1149
1166
|
})
|
|
1150
|
-
}), jsxRuntime.jsx(Checkbox__default["default"].Group,
|
|
1167
|
+
}), jsxRuntime.jsx(Checkbox__default["default"].Group, {
|
|
1151
1168
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1152
1169
|
name: id,
|
|
1153
1170
|
onChange: !readonly ? handleChange : undefined,
|
|
1154
|
-
value: selectedIndexes
|
|
1155
|
-
|
|
1171
|
+
value: selectedIndexes,
|
|
1172
|
+
...extraProps,
|
|
1156
1173
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
1157
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
})
|
|
1169
|
-
}))]
|
|
1174
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, i) => jsxRuntime.jsxs("span", {
|
|
1175
|
+
children: [jsxRuntime.jsx(Checkbox__default["default"], {
|
|
1176
|
+
id: utils.optionId(id, i),
|
|
1177
|
+
name: id,
|
|
1178
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1179
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1180
|
+
value: String(i),
|
|
1181
|
+
children: option.label
|
|
1182
|
+
}), !inline && jsxRuntime.jsx("br", {})]
|
|
1183
|
+
}, i))
|
|
1184
|
+
})]
|
|
1170
1185
|
}) : null;
|
|
1171
1186
|
}
|
|
1172
1187
|
|
|
@@ -1176,53 +1191,53 @@ function CheckboxesWidget(_ref) {
|
|
|
1176
1191
|
* @param props - The `WidgetProps` for this component
|
|
1177
1192
|
*/
|
|
1178
1193
|
function CheckboxWidget(props) {
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
};
|
|
1194
|
+
const {
|
|
1195
|
+
autofocus,
|
|
1196
|
+
disabled,
|
|
1197
|
+
formContext,
|
|
1198
|
+
id,
|
|
1199
|
+
label,
|
|
1200
|
+
hideLabel,
|
|
1201
|
+
onBlur,
|
|
1202
|
+
onChange,
|
|
1203
|
+
onFocus,
|
|
1204
|
+
readonly,
|
|
1205
|
+
value
|
|
1206
|
+
} = props;
|
|
1207
|
+
const {
|
|
1208
|
+
readonlyAsDisabled = true
|
|
1209
|
+
} = formContext;
|
|
1210
|
+
const handleChange = ({
|
|
1211
|
+
target
|
|
1212
|
+
}) => onChange(target.checked);
|
|
1213
|
+
const handleBlur = ({
|
|
1214
|
+
target
|
|
1215
|
+
}) => onBlur(id, target.checked);
|
|
1216
|
+
const handleFocus = ({
|
|
1217
|
+
target
|
|
1218
|
+
}) => onFocus(id, target.checked);
|
|
1204
1219
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1205
1220
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1206
|
-
|
|
1221
|
+
const extraProps = {
|
|
1207
1222
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1208
1223
|
onFocus: !readonly ? handleFocus : undefined
|
|
1209
1224
|
};
|
|
1210
|
-
return jsxRuntime.jsx(Checkbox__default["default"],
|
|
1225
|
+
return jsxRuntime.jsx(Checkbox__default["default"], {
|
|
1211
1226
|
autoFocus: autofocus,
|
|
1212
1227
|
checked: typeof value === 'undefined' ? false : value,
|
|
1213
1228
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1214
1229
|
id: id,
|
|
1215
1230
|
name: id,
|
|
1216
|
-
onChange: !readonly ? handleChange : undefined
|
|
1217
|
-
|
|
1231
|
+
onChange: !readonly ? handleChange : undefined,
|
|
1232
|
+
...extraProps,
|
|
1218
1233
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
1219
1234
|
children: utils.labelValue(label, hideLabel, '')
|
|
1220
|
-
})
|
|
1235
|
+
});
|
|
1221
1236
|
}
|
|
1222
1237
|
|
|
1223
|
-
|
|
1238
|
+
const DatePicker = /*#__PURE__*/generatePicker__default["default"](dayjsGenerateConfig__default["default"]);
|
|
1224
1239
|
|
|
1225
|
-
|
|
1240
|
+
const DATE_PICKER_STYLE$1 = {
|
|
1226
1241
|
width: '100%'
|
|
1227
1242
|
};
|
|
1228
1243
|
/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
|
|
@@ -1231,29 +1246,24 @@ var DATE_PICKER_STYLE$1 = {
|
|
|
1231
1246
|
* @param props - The `WidgetProps` for this component
|
|
1232
1247
|
*/
|
|
1233
1248
|
function DateTimeWidget(props) {
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
};
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
return onFocus(id, value);
|
|
1253
|
-
};
|
|
1254
|
-
var getPopupContainer = function getPopupContainer(node) {
|
|
1255
|
-
return node.parentNode;
|
|
1256
|
-
};
|
|
1249
|
+
const {
|
|
1250
|
+
disabled,
|
|
1251
|
+
formContext,
|
|
1252
|
+
id,
|
|
1253
|
+
onBlur,
|
|
1254
|
+
onChange,
|
|
1255
|
+
onFocus,
|
|
1256
|
+
placeholder,
|
|
1257
|
+
readonly,
|
|
1258
|
+
value
|
|
1259
|
+
} = props;
|
|
1260
|
+
const {
|
|
1261
|
+
readonlyAsDisabled = true
|
|
1262
|
+
} = formContext;
|
|
1263
|
+
const handleChange = nextValue => onChange(nextValue && nextValue.toISOString());
|
|
1264
|
+
const handleBlur = () => onBlur(id, value);
|
|
1265
|
+
const handleFocus = () => onFocus(id, value);
|
|
1266
|
+
const getPopupContainer = node => node.parentNode;
|
|
1257
1267
|
return jsxRuntime.jsx(DatePicker, {
|
|
1258
1268
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1259
1269
|
getPopupContainer: getPopupContainer,
|
|
@@ -1270,7 +1280,7 @@ function DateTimeWidget(props) {
|
|
|
1270
1280
|
});
|
|
1271
1281
|
}
|
|
1272
1282
|
|
|
1273
|
-
|
|
1283
|
+
const DATE_PICKER_STYLE = {
|
|
1274
1284
|
width: '100%'
|
|
1275
1285
|
};
|
|
1276
1286
|
/** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
|
|
@@ -1279,29 +1289,24 @@ var DATE_PICKER_STYLE = {
|
|
|
1279
1289
|
* @param props - The `WidgetProps` for this component
|
|
1280
1290
|
*/
|
|
1281
1291
|
function DateWidget(props) {
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
};
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
return onFocus(id, value);
|
|
1301
|
-
};
|
|
1302
|
-
var getPopupContainer = function getPopupContainer(node) {
|
|
1303
|
-
return node.parentNode;
|
|
1304
|
-
};
|
|
1292
|
+
const {
|
|
1293
|
+
disabled,
|
|
1294
|
+
formContext,
|
|
1295
|
+
id,
|
|
1296
|
+
onBlur,
|
|
1297
|
+
onChange,
|
|
1298
|
+
onFocus,
|
|
1299
|
+
placeholder,
|
|
1300
|
+
readonly,
|
|
1301
|
+
value
|
|
1302
|
+
} = props;
|
|
1303
|
+
const {
|
|
1304
|
+
readonlyAsDisabled = true
|
|
1305
|
+
} = formContext;
|
|
1306
|
+
const handleChange = nextValue => onChange(nextValue && nextValue.format('YYYY-MM-DD'));
|
|
1307
|
+
const handleBlur = () => onBlur(id, value);
|
|
1308
|
+
const handleFocus = () => onFocus(id, value);
|
|
1309
|
+
const getPopupContainer = node => node.parentNode;
|
|
1305
1310
|
return jsxRuntime.jsx(DatePicker, {
|
|
1306
1311
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1307
1312
|
getPopupContainer: getPopupContainer,
|
|
@@ -1323,31 +1328,31 @@ function DateWidget(props) {
|
|
|
1323
1328
|
* @param props - The `WidgetProps` for this component
|
|
1324
1329
|
*/
|
|
1325
1330
|
function PasswordWidget(props) {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
};
|
|
1331
|
+
const {
|
|
1332
|
+
disabled,
|
|
1333
|
+
formContext,
|
|
1334
|
+
id,
|
|
1335
|
+
onBlur,
|
|
1336
|
+
onChange,
|
|
1337
|
+
onFocus,
|
|
1338
|
+
options,
|
|
1339
|
+
placeholder,
|
|
1340
|
+
readonly,
|
|
1341
|
+
value
|
|
1342
|
+
} = props;
|
|
1343
|
+
const {
|
|
1344
|
+
readonlyAsDisabled = true
|
|
1345
|
+
} = formContext;
|
|
1346
|
+
const emptyValue = options.emptyValue || '';
|
|
1347
|
+
const handleChange = ({
|
|
1348
|
+
target
|
|
1349
|
+
}) => onChange(target.value === '' ? emptyValue : target.value);
|
|
1350
|
+
const handleBlur = ({
|
|
1351
|
+
target
|
|
1352
|
+
}) => onBlur(id, target.value);
|
|
1353
|
+
const handleFocus = ({
|
|
1354
|
+
target
|
|
1355
|
+
}) => onFocus(id, target.value);
|
|
1351
1356
|
return jsxRuntime.jsx(Input__default["default"].Password, {
|
|
1352
1357
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1353
1358
|
id: id,
|
|
@@ -1366,35 +1371,38 @@ function PasswordWidget(props) {
|
|
|
1366
1371
|
*
|
|
1367
1372
|
* @param props - The `WidgetProps` for this component
|
|
1368
1373
|
*/
|
|
1369
|
-
function RadioWidget(
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
};
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
};
|
|
1397
|
-
|
|
1374
|
+
function RadioWidget({
|
|
1375
|
+
autofocus,
|
|
1376
|
+
disabled,
|
|
1377
|
+
formContext,
|
|
1378
|
+
id,
|
|
1379
|
+
onBlur,
|
|
1380
|
+
onChange,
|
|
1381
|
+
onFocus,
|
|
1382
|
+
options,
|
|
1383
|
+
readonly,
|
|
1384
|
+
value
|
|
1385
|
+
}) {
|
|
1386
|
+
const {
|
|
1387
|
+
readonlyAsDisabled = true
|
|
1388
|
+
} = formContext;
|
|
1389
|
+
const {
|
|
1390
|
+
enumOptions,
|
|
1391
|
+
enumDisabled,
|
|
1392
|
+
emptyValue
|
|
1393
|
+
} = options;
|
|
1394
|
+
const handleChange = ({
|
|
1395
|
+
target: {
|
|
1396
|
+
value: nextValue
|
|
1397
|
+
}
|
|
1398
|
+
}) => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1399
|
+
const handleBlur = ({
|
|
1400
|
+
target
|
|
1401
|
+
}) => onBlur(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1402
|
+
const handleFocus = ({
|
|
1403
|
+
target
|
|
1404
|
+
}) => onFocus(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
|
|
1405
|
+
const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions);
|
|
1398
1406
|
return jsxRuntime.jsx(Radio__default["default"].Group, {
|
|
1399
1407
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1400
1408
|
id: id,
|
|
@@ -1404,16 +1412,14 @@ function RadioWidget(_ref) {
|
|
|
1404
1412
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1405
1413
|
value: selectedIndexes,
|
|
1406
1414
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
1407
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
}, i);
|
|
1416
|
-
})
|
|
1415
|
+
children: Array.isArray(enumOptions) && enumOptions.map((option, i) => jsxRuntime.jsx(Radio__default["default"], {
|
|
1416
|
+
id: utils.optionId(id, i),
|
|
1417
|
+
name: id,
|
|
1418
|
+
autoFocus: i === 0 ? autofocus : false,
|
|
1419
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
|
|
1420
|
+
value: String(i),
|
|
1421
|
+
children: option.label
|
|
1422
|
+
}, i))
|
|
1417
1423
|
});
|
|
1418
1424
|
}
|
|
1419
1425
|
|
|
@@ -1423,42 +1429,40 @@ function RadioWidget(_ref) {
|
|
|
1423
1429
|
* @param props - The `WidgetProps` for this component
|
|
1424
1430
|
*/
|
|
1425
1431
|
function RangeWidget(props) {
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
};
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
return onFocus(id, value);
|
|
1453
|
-
};
|
|
1432
|
+
const {
|
|
1433
|
+
autofocus,
|
|
1434
|
+
disabled,
|
|
1435
|
+
formContext,
|
|
1436
|
+
id,
|
|
1437
|
+
onBlur,
|
|
1438
|
+
onChange,
|
|
1439
|
+
onFocus,
|
|
1440
|
+
options,
|
|
1441
|
+
placeholder,
|
|
1442
|
+
readonly,
|
|
1443
|
+
schema,
|
|
1444
|
+
value
|
|
1445
|
+
} = props;
|
|
1446
|
+
const {
|
|
1447
|
+
readonlyAsDisabled = true
|
|
1448
|
+
} = formContext;
|
|
1449
|
+
const {
|
|
1450
|
+
min,
|
|
1451
|
+
max,
|
|
1452
|
+
step
|
|
1453
|
+
} = utils.rangeSpec(schema);
|
|
1454
|
+
const emptyValue = options.emptyValue || '';
|
|
1455
|
+
const handleChange = nextValue => onChange(nextValue === '' ? emptyValue : nextValue);
|
|
1456
|
+
const handleBlur = () => onBlur(id, value);
|
|
1457
|
+
const handleFocus = () => onFocus(id, value);
|
|
1454
1458
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1455
1459
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1456
|
-
|
|
1457
|
-
placeholder
|
|
1460
|
+
const extraProps = {
|
|
1461
|
+
placeholder,
|
|
1458
1462
|
onBlur: !readonly ? handleBlur : undefined,
|
|
1459
1463
|
onFocus: !readonly ? handleFocus : undefined
|
|
1460
1464
|
};
|
|
1461
|
-
return jsxRuntime.jsx(Slider__default["default"],
|
|
1465
|
+
return jsxRuntime.jsx(Slider__default["default"], {
|
|
1462
1466
|
autoFocus: autofocus,
|
|
1463
1467
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1464
1468
|
id: id,
|
|
@@ -1467,13 +1471,13 @@ function RangeWidget(props) {
|
|
|
1467
1471
|
onChange: !readonly ? handleChange : undefined,
|
|
1468
1472
|
range: false,
|
|
1469
1473
|
step: step,
|
|
1470
|
-
value: value
|
|
1471
|
-
|
|
1474
|
+
value: value,
|
|
1475
|
+
...extraProps,
|
|
1472
1476
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1473
|
-
})
|
|
1477
|
+
});
|
|
1474
1478
|
}
|
|
1475
1479
|
|
|
1476
|
-
|
|
1480
|
+
const SELECT_STYLE = {
|
|
1477
1481
|
width: '100%'
|
|
1478
1482
|
};
|
|
1479
1483
|
/** The `SelectWidget` is a widget for rendering dropdowns.
|
|
@@ -1481,51 +1485,46 @@ var SELECT_STYLE = {
|
|
|
1481
1485
|
*
|
|
1482
1486
|
* @param props - The `WidgetProps` for this component
|
|
1483
1487
|
*/
|
|
1484
|
-
function SelectWidget(
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
readonlyAsDisabled =
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
};
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
return onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1511
|
-
};
|
|
1512
|
-
var filterOption = function filterOption(input, option) {
|
|
1488
|
+
function SelectWidget({
|
|
1489
|
+
autofocus,
|
|
1490
|
+
disabled,
|
|
1491
|
+
formContext = {},
|
|
1492
|
+
id,
|
|
1493
|
+
multiple,
|
|
1494
|
+
onBlur,
|
|
1495
|
+
onChange,
|
|
1496
|
+
onFocus,
|
|
1497
|
+
options,
|
|
1498
|
+
placeholder,
|
|
1499
|
+
readonly,
|
|
1500
|
+
value
|
|
1501
|
+
}) {
|
|
1502
|
+
const {
|
|
1503
|
+
readonlyAsDisabled = true
|
|
1504
|
+
} = formContext;
|
|
1505
|
+
const {
|
|
1506
|
+
enumOptions,
|
|
1507
|
+
enumDisabled,
|
|
1508
|
+
emptyValue
|
|
1509
|
+
} = options;
|
|
1510
|
+
const handleChange = nextValue => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
|
|
1511
|
+
const handleBlur = () => onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1512
|
+
const handleFocus = () => onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
|
|
1513
|
+
const filterOption = (input, option) => {
|
|
1513
1514
|
if (option && isString__default["default"](option.label)) {
|
|
1514
1515
|
// labels are strings in this context
|
|
1515
1516
|
return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
|
|
1516
1517
|
}
|
|
1517
1518
|
return false;
|
|
1518
1519
|
};
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
};
|
|
1522
|
-
var selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1520
|
+
const getPopupContainer = node => node.parentNode;
|
|
1521
|
+
const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
|
|
1523
1522
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1524
1523
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1525
|
-
|
|
1524
|
+
const extraProps = {
|
|
1526
1525
|
name: id
|
|
1527
1526
|
};
|
|
1528
|
-
return jsxRuntime.jsx(Select__default["default"],
|
|
1527
|
+
return jsxRuntime.jsx(Select__default["default"], {
|
|
1529
1528
|
autoFocus: autofocus,
|
|
1530
1529
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1531
1530
|
getPopupContainer: getPopupContainer,
|
|
@@ -1536,60 +1535,58 @@ function SelectWidget(_ref) {
|
|
|
1536
1535
|
onFocus: !readonly ? handleFocus : undefined,
|
|
1537
1536
|
placeholder: placeholder,
|
|
1538
1537
|
style: SELECT_STYLE,
|
|
1539
|
-
value: selectedIndexes
|
|
1540
|
-
|
|
1538
|
+
value: selectedIndexes,
|
|
1539
|
+
...extraProps,
|
|
1541
1540
|
filterOption: filterOption,
|
|
1542
1541
|
"aria-describedby": utils.ariaDescribedByIds(id),
|
|
1543
|
-
children: Array.isArray(enumOptions) && enumOptions.map(
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
}));
|
|
1542
|
+
children: Array.isArray(enumOptions) && enumOptions.map(({
|
|
1543
|
+
value: optionValue,
|
|
1544
|
+
label: optionLabel
|
|
1545
|
+
}, index) => jsxRuntime.jsx(Select__default["default"].Option, {
|
|
1546
|
+
disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
|
|
1547
|
+
value: String(index),
|
|
1548
|
+
children: optionLabel
|
|
1549
|
+
}, String(index)))
|
|
1550
|
+
});
|
|
1553
1551
|
}
|
|
1554
1552
|
|
|
1555
|
-
|
|
1553
|
+
const INPUT_STYLE = {
|
|
1556
1554
|
width: '100%'
|
|
1557
1555
|
};
|
|
1558
1556
|
/** The `TextareaWidget` is a widget for rendering input fields as textarea.
|
|
1559
1557
|
*
|
|
1560
1558
|
* @param props - The `WidgetProps` for this component
|
|
1561
1559
|
*/
|
|
1562
|
-
function TextareaWidget(
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
};
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
};
|
|
1560
|
+
function TextareaWidget({
|
|
1561
|
+
disabled,
|
|
1562
|
+
formContext,
|
|
1563
|
+
id,
|
|
1564
|
+
onBlur,
|
|
1565
|
+
onChange,
|
|
1566
|
+
onFocus,
|
|
1567
|
+
options,
|
|
1568
|
+
placeholder,
|
|
1569
|
+
readonly,
|
|
1570
|
+
value
|
|
1571
|
+
}) {
|
|
1572
|
+
const {
|
|
1573
|
+
readonlyAsDisabled = true
|
|
1574
|
+
} = formContext;
|
|
1575
|
+
const handleChange = ({
|
|
1576
|
+
target
|
|
1577
|
+
}) => onChange(target.value === '' ? options.emptyValue : target.value);
|
|
1578
|
+
const handleBlur = ({
|
|
1579
|
+
target
|
|
1580
|
+
}) => onBlur(id, target.value);
|
|
1581
|
+
const handleFocus = ({
|
|
1582
|
+
target
|
|
1583
|
+
}) => onFocus(id, target.value);
|
|
1587
1584
|
// Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
|
|
1588
1585
|
// they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
|
|
1589
|
-
|
|
1586
|
+
const extraProps = {
|
|
1590
1587
|
type: 'textarea'
|
|
1591
1588
|
};
|
|
1592
|
-
return jsxRuntime.jsx(Input__default["default"].TextArea,
|
|
1589
|
+
return jsxRuntime.jsx(Input__default["default"].TextArea, {
|
|
1593
1590
|
disabled: disabled || readonlyAsDisabled && readonly,
|
|
1594
1591
|
id: id,
|
|
1595
1592
|
name: id,
|
|
@@ -1599,25 +1596,25 @@ function TextareaWidget(_ref) {
|
|
|
1599
1596
|
placeholder: placeholder,
|
|
1600
1597
|
rows: options.rows || 4,
|
|
1601
1598
|
style: INPUT_STYLE,
|
|
1602
|
-
value: value
|
|
1603
|
-
|
|
1599
|
+
value: value,
|
|
1600
|
+
...extraProps,
|
|
1604
1601
|
"aria-describedby": utils.ariaDescribedByIds(id)
|
|
1605
|
-
})
|
|
1602
|
+
});
|
|
1606
1603
|
}
|
|
1607
1604
|
|
|
1608
1605
|
function generateWidgets() {
|
|
1609
1606
|
return {
|
|
1610
|
-
AltDateTimeWidget
|
|
1611
|
-
AltDateWidget
|
|
1612
|
-
CheckboxesWidget
|
|
1613
|
-
CheckboxWidget
|
|
1614
|
-
DateTimeWidget
|
|
1615
|
-
DateWidget
|
|
1616
|
-
PasswordWidget
|
|
1617
|
-
RadioWidget
|
|
1618
|
-
RangeWidget
|
|
1619
|
-
SelectWidget
|
|
1620
|
-
TextareaWidget
|
|
1607
|
+
AltDateTimeWidget,
|
|
1608
|
+
AltDateWidget,
|
|
1609
|
+
CheckboxesWidget,
|
|
1610
|
+
CheckboxWidget,
|
|
1611
|
+
DateTimeWidget,
|
|
1612
|
+
DateWidget,
|
|
1613
|
+
PasswordWidget,
|
|
1614
|
+
RadioWidget,
|
|
1615
|
+
RangeWidget,
|
|
1616
|
+
SelectWidget,
|
|
1617
|
+
TextareaWidget
|
|
1621
1618
|
};
|
|
1622
1619
|
}
|
|
1623
1620
|
var index = /*#__PURE__*/generateWidgets();
|
|
@@ -1628,11 +1625,11 @@ function generateTheme() {
|
|
|
1628
1625
|
widgets: generateWidgets()
|
|
1629
1626
|
};
|
|
1630
1627
|
}
|
|
1631
|
-
|
|
1628
|
+
const Theme = /*#__PURE__*/generateTheme();
|
|
1632
1629
|
function generateForm() {
|
|
1633
1630
|
return core.withTheme(generateTheme());
|
|
1634
1631
|
}
|
|
1635
|
-
|
|
1632
|
+
const Form = /*#__PURE__*/generateForm();
|
|
1636
1633
|
|
|
1637
1634
|
exports.Form = Form;
|
|
1638
1635
|
exports.Templates = index$1;
|