@rjsf/antd 5.11.2 → 5.12.1

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.
Files changed (124) hide show
  1. package/dist/antd.esm.js +891 -1117
  2. package/dist/antd.esm.js.map +7 -1
  3. package/dist/antd.umd.js +1184 -0
  4. package/dist/index.js +1347 -5
  5. package/dist/index.js.map +7 -0
  6. package/lib/components/DatePicker/index.d.ts +48 -0
  7. package/lib/components/DatePicker/index.js +5 -0
  8. package/lib/components/DatePicker/index.js.map +1 -0
  9. package/lib/index.d.ts +11 -0
  10. package/lib/index.js +17 -0
  11. package/lib/index.js.map +1 -0
  12. package/lib/templates/ArrayFieldItemTemplate/index.d.ts +7 -0
  13. package/lib/templates/ArrayFieldItemTemplate/index.js +21 -0
  14. package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -0
  15. package/lib/templates/ArrayFieldTemplate/index.d.ts +7 -0
  16. package/lib/templates/ArrayFieldTemplate/index.js +38 -0
  17. package/lib/templates/ArrayFieldTemplate/index.js.map +1 -0
  18. package/lib/templates/BaseInputTemplate/index.d.ts +9 -0
  19. package/lib/templates/BaseInputTemplate/index.js +31 -0
  20. package/lib/templates/BaseInputTemplate/index.js.map +1 -0
  21. package/lib/templates/DescriptionField/index.d.ts +7 -0
  22. package/lib/templates/DescriptionField/index.js +13 -0
  23. package/lib/templates/DescriptionField/index.js.map +1 -0
  24. package/lib/templates/ErrorList/index.d.ts +7 -0
  25. package/lib/templates/ErrorList/index.js +16 -0
  26. package/lib/templates/ErrorList/index.js.map +1 -0
  27. package/lib/templates/FieldErrorTemplate/index.d.ts +7 -0
  28. package/lib/templates/FieldErrorTemplate/index.js +15 -0
  29. package/lib/templates/FieldErrorTemplate/index.js.map +1 -0
  30. package/lib/templates/FieldTemplate/index.d.ts +8 -0
  31. package/lib/templates/FieldTemplate/index.js +34 -0
  32. package/lib/templates/FieldTemplate/index.js.map +1 -0
  33. package/lib/templates/IconButton/index.d.ts +10 -0
  34. package/lib/templates/IconButton/index.js +36 -0
  35. package/lib/templates/IconButton/index.js.map +1 -0
  36. package/lib/templates/ObjectFieldTemplate/index.d.ts +9 -0
  37. package/lib/templates/ObjectFieldTemplate/index.js +71 -0
  38. package/lib/templates/ObjectFieldTemplate/index.js.map +1 -0
  39. package/lib/templates/SubmitButton/index.d.ts +5 -0
  40. package/lib/templates/SubmitButton/index.js +13 -0
  41. package/lib/templates/SubmitButton/index.js.map +1 -0
  42. package/lib/templates/TitleField/index.d.ts +7 -0
  43. package/lib/templates/TitleField/index.js +34 -0
  44. package/lib/templates/TitleField/index.js.map +1 -0
  45. package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +8 -0
  46. package/lib/templates/WrapIfAdditionalTemplate/index.js +34 -0
  47. package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -0
  48. package/lib/templates/index.d.ts +4 -0
  49. package/lib/templates/index.js +36 -0
  50. package/lib/templates/index.js.map +1 -0
  51. package/lib/widgets/AltDateTimeWidget/index.d.ts +15 -0
  52. package/lib/widgets/AltDateTimeWidget/index.js +8 -0
  53. package/lib/widgets/AltDateTimeWidget/index.js.map +1 -0
  54. package/lib/widgets/AltDateWidget/index.d.ts +15 -0
  55. package/lib/widgets/AltDateWidget/index.js +89 -0
  56. package/lib/widgets/AltDateWidget/index.js.map +1 -0
  57. package/lib/widgets/CheckboxWidget/index.d.ts +8 -0
  58. package/lib/widgets/CheckboxWidget/index.js +23 -0
  59. package/lib/widgets/CheckboxWidget/index.js.map +1 -0
  60. package/lib/widgets/CheckboxesWidget/index.d.ts +8 -0
  61. package/lib/widgets/CheckboxesWidget/index.js +26 -0
  62. package/lib/widgets/CheckboxesWidget/index.js.map +1 -0
  63. package/lib/widgets/DateTimeWidget/index.d.ts +8 -0
  64. package/lib/widgets/DateTimeWidget/index.js +22 -0
  65. package/lib/widgets/DateTimeWidget/index.js.map +1 -0
  66. package/lib/widgets/DateWidget/index.d.ts +8 -0
  67. package/lib/widgets/DateWidget/index.js +22 -0
  68. package/lib/widgets/DateWidget/index.js.map +1 -0
  69. package/lib/widgets/PasswordWidget/index.d.ts +7 -0
  70. package/lib/widgets/PasswordWidget/index.js +17 -0
  71. package/lib/widgets/PasswordWidget/index.js.map +1 -0
  72. package/lib/widgets/RadioWidget/index.d.ts +8 -0
  73. package/lib/widgets/RadioWidget/index.js +19 -0
  74. package/lib/widgets/RadioWidget/index.js.map +1 -0
  75. package/lib/widgets/RangeWidget/index.d.ts +8 -0
  76. package/lib/widgets/RangeWidget/index.js +26 -0
  77. package/lib/widgets/RangeWidget/index.js.map +1 -0
  78. package/lib/widgets/SelectWidget/index.d.ts +8 -0
  79. package/lib/widgets/SelectWidget/index.js +36 -0
  80. package/lib/widgets/SelectWidget/index.js.map +1 -0
  81. package/lib/widgets/TextareaWidget/index.d.ts +7 -0
  82. package/lib/widgets/TextareaWidget/index.js +23 -0
  83. package/lib/widgets/TextareaWidget/index.js.map +1 -0
  84. package/lib/widgets/index.d.ts +4 -0
  85. package/lib/widgets/index.js +28 -0
  86. package/lib/widgets/index.js.map +1 -0
  87. package/package.json +24 -16
  88. package/src/components/DatePicker/index.ts +6 -0
  89. package/src/index.less +38 -0
  90. package/src/index.ts +33 -0
  91. package/src/templates/ArrayFieldItemTemplate/index.tsx +90 -0
  92. package/src/templates/ArrayFieldTemplate/index.tsx +132 -0
  93. package/src/templates/BaseInputTemplate/index.tsx +105 -0
  94. package/src/templates/DescriptionField/index.tsx +17 -0
  95. package/src/templates/ErrorList/index.tsx +37 -0
  96. package/src/templates/FieldErrorTemplate/index.tsx +25 -0
  97. package/src/templates/FieldTemplate/index.tsx +114 -0
  98. package/src/templates/IconButton/index.tsx +94 -0
  99. package/src/templates/ObjectFieldTemplate/index.tsx +175 -0
  100. package/src/templates/SubmitButton/index.tsx +20 -0
  101. package/src/templates/TitleField/index.tsx +57 -0
  102. package/src/templates/WrapIfAdditionalTemplate/index.tsx +124 -0
  103. package/src/templates/index.ts +43 -0
  104. package/src/widgets/AltDateTimeWidget/index.tsx +17 -0
  105. package/src/widgets/AltDateWidget/index.tsx +197 -0
  106. package/src/widgets/CheckboxWidget/index.tsx +52 -0
  107. package/src/widgets/CheckboxesWidget/index.tsx +75 -0
  108. package/src/widgets/DateTimeWidget/index.tsx +54 -0
  109. package/src/widgets/DateWidget/index.tsx +52 -0
  110. package/src/widgets/PasswordWidget/index.tsx +46 -0
  111. package/src/widgets/RadioWidget/index.tsx +73 -0
  112. package/src/widgets/RangeWidget/index.tsx +69 -0
  113. package/src/widgets/SelectWidget/index.tsx +97 -0
  114. package/src/widgets/TextareaWidget/index.tsx +67 -0
  115. package/src/widgets/index.ts +35 -0
  116. package/dist/antd.cjs.development.js +0 -1643
  117. package/dist/antd.cjs.development.js.map +0 -1
  118. package/dist/antd.cjs.production.min.js +0 -2
  119. package/dist/antd.cjs.production.min.js.map +0 -1
  120. package/dist/antd.umd.development.js +0 -1617
  121. package/dist/antd.umd.development.js.map +0 -1
  122. package/dist/antd.umd.production.min.js +0 -2
  123. package/dist/antd.umd.production.min.js.map +0 -1
  124. package/dist/index.d.ts +0 -16
@@ -1,1643 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@rjsf/core');
6
- var jsxRuntime = require('react/jsx-runtime');
7
- var Button = require('antd/lib/button');
8
- var Col = require('antd/lib/col');
9
- var Row = require('antd/lib/row');
10
- var utils = require('@rjsf/utils');
11
- var classNames = require('classnames');
12
- var context = require('antd/lib/config-provider/context');
13
- var Input = require('antd/lib/input');
14
- var InputNumber = require('antd/lib/input-number');
15
- var Alert = require('antd/lib/alert');
16
- var List = require('antd/lib/list');
17
- var Space = require('antd/lib/space');
18
- var ExclamationCircleOutlined = require('@ant-design/icons/ExclamationCircleOutlined');
19
- var ArrowDownOutlined = require('@ant-design/icons/ArrowDownOutlined');
20
- var ArrowUpOutlined = require('@ant-design/icons/ArrowUpOutlined');
21
- var CopyOutlined = require('@ant-design/icons/CopyOutlined');
22
- var DeleteOutlined = require('@ant-design/icons/DeleteOutlined');
23
- var PlusCircleOutlined = require('@ant-design/icons/PlusCircleOutlined');
24
- var Form$1 = require('antd/lib/form');
25
- var isObject = require('lodash/isObject');
26
- var isNumber = require('lodash/isNumber');
27
- var isString = require('lodash/isString');
28
- var react = require('react');
29
- var Checkbox = require('antd/lib/checkbox');
30
- var dayjs = require('dayjs');
31
- var dayjsGenerateConfig = require('rc-picker/lib/generate/dayjs');
32
- var generatePicker = require('antd/lib/date-picker/generatePicker');
33
- var Radio = require('antd/lib/radio');
34
- var Slider = require('antd/lib/slider');
35
- var Select = require('antd/lib/select');
36
-
37
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
38
-
39
- var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
40
- var Col__default = /*#__PURE__*/_interopDefaultLegacy(Col);
41
- var Row__default = /*#__PURE__*/_interopDefaultLegacy(Row);
42
- var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
43
- var Input__default = /*#__PURE__*/_interopDefaultLegacy(Input);
44
- var InputNumber__default = /*#__PURE__*/_interopDefaultLegacy(InputNumber);
45
- var Alert__default = /*#__PURE__*/_interopDefaultLegacy(Alert);
46
- var List__default = /*#__PURE__*/_interopDefaultLegacy(List);
47
- var Space__default = /*#__PURE__*/_interopDefaultLegacy(Space);
48
- var ExclamationCircleOutlined__default = /*#__PURE__*/_interopDefaultLegacy(ExclamationCircleOutlined);
49
- var ArrowDownOutlined__default = /*#__PURE__*/_interopDefaultLegacy(ArrowDownOutlined);
50
- var ArrowUpOutlined__default = /*#__PURE__*/_interopDefaultLegacy(ArrowUpOutlined);
51
- var CopyOutlined__default = /*#__PURE__*/_interopDefaultLegacy(CopyOutlined);
52
- var DeleteOutlined__default = /*#__PURE__*/_interopDefaultLegacy(DeleteOutlined);
53
- var PlusCircleOutlined__default = /*#__PURE__*/_interopDefaultLegacy(PlusCircleOutlined);
54
- var Form__default = /*#__PURE__*/_interopDefaultLegacy(Form$1);
55
- var isObject__default = /*#__PURE__*/_interopDefaultLegacy(isObject);
56
- var isNumber__default = /*#__PURE__*/_interopDefaultLegacy(isNumber);
57
- var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);
58
- var Checkbox__default = /*#__PURE__*/_interopDefaultLegacy(Checkbox);
59
- var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
60
- var dayjsGenerateConfig__default = /*#__PURE__*/_interopDefaultLegacy(dayjsGenerateConfig);
61
- var generatePicker__default = /*#__PURE__*/_interopDefaultLegacy(generatePicker);
62
- var Radio__default = /*#__PURE__*/_interopDefaultLegacy(Radio);
63
- var Slider__default = /*#__PURE__*/_interopDefaultLegacy(Slider);
64
- var Select__default = /*#__PURE__*/_interopDefaultLegacy(Select);
65
-
66
- const BTN_GRP_STYLE = {
67
- width: '100%'
68
- };
69
- const BTN_STYLE = {
70
- width: 'calc(100% / 4)'
71
- };
72
- /** The `ArrayFieldItemTemplate` component is the template used to render an items of an array.
73
- *
74
- * @param props - The `ArrayFieldTemplateItemType` props for the component
75
- */
76
- function ArrayFieldItemTemplate(props) {
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;
103
- return jsxRuntime.jsxs(Row__default["default"], {
104
- align: toolbarAlign,
105
- gutter: rowGutter,
106
- children: [jsxRuntime.jsx(Col__default["default"], {
107
- flex: '1',
108
- children: children
109
- }), hasToolbar && jsxRuntime.jsx(Col__default["default"], {
110
- flex: '192px',
111
- children: jsxRuntime.jsxs(Button__default["default"].Group, {
112
- style: BTN_GRP_STYLE,
113
- children: [(hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveUpButton, {
114
- disabled: disabled || readonly || !hasMoveUp,
115
- onClick: onReorderClick(index, index - 1),
116
- style: BTN_STYLE,
117
- uiSchema: uiSchema,
118
- registry: registry
119
- }), (hasMoveUp || hasMoveDown) && jsxRuntime.jsx(MoveDownButton, {
120
- disabled: disabled || readonly || !hasMoveDown,
121
- onClick: onReorderClick(index, index + 1),
122
- style: BTN_STYLE,
123
- uiSchema: uiSchema,
124
- registry: registry
125
- }), hasCopy && jsxRuntime.jsx(CopyButton, {
126
- disabled: disabled || readonly,
127
- onClick: onCopyIndexClick(index),
128
- style: BTN_STYLE,
129
- uiSchema: uiSchema,
130
- registry: registry
131
- }), hasRemove && jsxRuntime.jsx(RemoveButton, {
132
- disabled: disabled || readonly,
133
- onClick: onDropIndexClick(index),
134
- style: BTN_STYLE,
135
- uiSchema: uiSchema,
136
- registry: registry
137
- })]
138
- })
139
- })]
140
- }, `array-item-${index}`);
141
- }
142
-
143
- const DESCRIPTION_COL_STYLE$1 = {
144
- paddingBottom: '8px'
145
- };
146
- /** The `ArrayFieldTemplate` component is the template used to render all items in an array.
147
- *
148
- * @param props - The `ArrayFieldTemplateItemType` props for the component
149
- */
150
- function ArrayFieldTemplate(props) {
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);
170
- // Button templates are not overridden in the uiSchema
171
- const {
172
- ButtonTemplates: {
173
- AddButton
174
- }
175
- } = registry.templates;
176
- const {
177
- labelAlign = 'right',
178
- rowGutter = 24
179
- } = formContext;
180
- return jsxRuntime.jsx(context.ConfigConsumer, {
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`
188
- // labelCol.className,
189
- );
190
-
191
- return jsxRuntime.jsx("fieldset", {
192
- className: className,
193
- id: idSchema.$id,
194
- children: jsxRuntime.jsxs(Row__default["default"], {
195
- gutter: rowGutter,
196
- children: [(uiOptions.title || title) && jsxRuntime.jsx(Col__default["default"], {
197
- className: labelColClassName,
198
- span: 24,
199
- children: jsxRuntime.jsx(ArrayFieldTitleTemplate, {
200
- idSchema: idSchema,
201
- required: required,
202
- title: uiOptions.title || title,
203
- schema: schema,
204
- uiSchema: uiSchema,
205
- registry: registry
206
- })
207
- }), (uiOptions.description || schema.description) && jsxRuntime.jsx(Col__default["default"], {
208
- span: 24,
209
- style: DESCRIPTION_COL_STYLE$1,
210
- children: jsxRuntime.jsx(ArrayFieldDescriptionTemplate, {
211
- description: uiOptions.description || schema.description,
212
- idSchema: idSchema,
213
- schema: schema,
214
- uiSchema: uiSchema,
215
- registry: registry
216
- })
217
- }), jsxRuntime.jsx(Col__default["default"], {
218
- className: 'row array-item-list',
219
- span: 24,
220
- children: items && items.map(({
221
- key,
222
- ...itemProps
223
- }) => jsxRuntime.jsx(ArrayFieldItemTemplate, {
224
- ...itemProps
225
- }, key))
226
- }), canAdd && jsxRuntime.jsx(Col__default["default"], {
227
- span: 24,
228
- children: jsxRuntime.jsx(Row__default["default"], {
229
- gutter: rowGutter,
230
- justify: 'end',
231
- children: jsxRuntime.jsx(Col__default["default"], {
232
- flex: '192px',
233
- children: jsxRuntime.jsx(AddButton, {
234
- className: 'array-item-add',
235
- disabled: disabled || readonly,
236
- onClick: onAddClick,
237
- uiSchema: uiSchema,
238
- registry: registry
239
- })
240
- })
241
- })
242
- })]
243
- })
244
- });
245
- }
246
- });
247
- }
248
-
249
- const INPUT_STYLE$2 = {
250
- width: '100%'
251
- };
252
- /** The `BaseInputTemplate` is the template to use to render the basic `<input>` component for the `core` theme.
253
- * It is used as the template for rendering many of the <input> based widgets that differ by `type` and callbacks only.
254
- * It can be customized/overridden for other themes or individual implementations as needed.
255
- *
256
- * @param props - The `WidgetProps` for this template
257
- */
258
- function BaseInputTemplate(props) {
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"], {
289
- disabled: disabled || readonlyAsDisabled && readonly,
290
- id: id,
291
- name: id,
292
- onBlur: !readonly ? handleBlur : undefined,
293
- onChange: !readonly ? handleNumberChange : undefined,
294
- onFocus: !readonly ? handleFocus : undefined,
295
- placeholder: placeholder,
296
- style: INPUT_STYLE$2,
297
- list: schema.examples ? utils.examplesId(id) : undefined,
298
- ...inputProps,
299
- value: value,
300
- "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
301
- }) : jsxRuntime.jsx(Input__default["default"], {
302
- disabled: disabled || readonlyAsDisabled && readonly,
303
- id: id,
304
- name: id,
305
- onBlur: !readonly ? handleBlur : undefined,
306
- onChange: !readonly ? handleTextChange : undefined,
307
- onFocus: !readonly ? handleFocus : undefined,
308
- placeholder: placeholder,
309
- style: INPUT_STYLE$2,
310
- list: schema.examples ? utils.examplesId(id) : undefined,
311
- ...inputProps,
312
- value: value,
313
- "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
314
- });
315
- return jsxRuntime.jsxs(jsxRuntime.Fragment, {
316
- children: [input, Array.isArray(schema.examples) && jsxRuntime.jsx("datalist", {
317
- id: utils.examplesId(id),
318
- children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map(example => {
319
- return jsxRuntime.jsx("option", {
320
- value: example
321
- }, example);
322
- })
323
- })]
324
- });
325
- }
326
-
327
- /** The `DescriptionField` is the template to use to render the description of a field
328
- *
329
- * @param props - The `DescriptionFieldProps` for this component
330
- */
331
- function DescriptionField(props) {
332
- const {
333
- id,
334
- description
335
- } = props;
336
- if (!description) {
337
- return null;
338
- }
339
- return jsxRuntime.jsx("span", {
340
- id: id,
341
- children: description
342
- });
343
- }
344
-
345
- /** The `ErrorList` component is the template that renders the all the errors associated with the fields in the `Form`
346
- *
347
- * @param props - The `ErrorListProps` for this component
348
- */
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]
362
- })
363
- }, index))
364
- });
365
- return jsxRuntime.jsx(Alert__default["default"], {
366
- className: 'panel panel-danger errors',
367
- description: renderErrors(),
368
- message: translateString(utils.TranslatableString.ErrorsLabel),
369
- type: 'error'
370
- });
371
- }
372
-
373
- function IconButton(props) {
374
- const {
375
- iconType = 'default',
376
- icon,
377
- uiSchema,
378
- registry,
379
- ...otherProps
380
- } = props;
381
- return jsxRuntime.jsx(Button__default["default"], {
382
- type: iconType,
383
- icon: icon,
384
- ...otherProps
385
- });
386
- }
387
- function AddButton(props) {
388
- const {
389
- registry: {
390
- translateString
391
- }
392
- } = props;
393
- return jsxRuntime.jsx(IconButton, {
394
- title: translateString(utils.TranslatableString.AddItemButton),
395
- ...props,
396
- block: true,
397
- iconType: 'primary',
398
- icon: jsxRuntime.jsx(PlusCircleOutlined__default["default"], {})
399
- });
400
- }
401
- function CopyButton(props) {
402
- const {
403
- registry: {
404
- translateString
405
- }
406
- } = props;
407
- return jsxRuntime.jsx(IconButton, {
408
- title: translateString(utils.TranslatableString.CopyButton),
409
- ...props,
410
- icon: jsxRuntime.jsx(CopyOutlined__default["default"], {})
411
- });
412
- }
413
- function MoveDownButton(props) {
414
- const {
415
- registry: {
416
- translateString
417
- }
418
- } = props;
419
- return jsxRuntime.jsx(IconButton, {
420
- title: translateString(utils.TranslatableString.MoveDownButton),
421
- ...props,
422
- icon: jsxRuntime.jsx(ArrowDownOutlined__default["default"], {})
423
- });
424
- }
425
- function MoveUpButton(props) {
426
- const {
427
- registry: {
428
- translateString
429
- }
430
- } = props;
431
- return jsxRuntime.jsx(IconButton, {
432
- title: translateString(utils.TranslatableString.MoveUpButton),
433
- ...props,
434
- icon: jsxRuntime.jsx(ArrowUpOutlined__default["default"], {})
435
- });
436
- }
437
- function RemoveButton(props) {
438
- // The `block` prop is not part of the `IconButtonProps` defined in the template, so get it from the uiSchema instead
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,
448
- danger: true,
449
- block: !!options.block,
450
- iconType: 'primary',
451
- icon: jsxRuntime.jsx(DeleteOutlined__default["default"], {})
452
- });
453
- }
454
-
455
- /** The `FieldErrorTemplate` component renders the errors local to the particular field
456
- *
457
- * @param props - The `FieldErrorProps` for the errors being rendered
458
- */
459
- function FieldErrorTemplate(props) {
460
- const {
461
- errors = [],
462
- idSchema
463
- } = props;
464
- if (errors.length === 0) {
465
- return null;
466
- }
467
- const id = utils.errorId(idSchema);
468
- return jsxRuntime.jsx("div", {
469
- id: id,
470
- children: errors.map(error => jsxRuntime.jsx("div", {
471
- children: error
472
- }, `field-${id}-error-${error}`))
473
- });
474
- }
475
-
476
- const VERTICAL_LABEL_COL$1 = {
477
- span: 24
478
- };
479
- const VERTICAL_WRAPPER_COL$1 = {
480
- span: 24
481
- };
482
- /** The `FieldTemplate` component is the template used by `SchemaField` to render any field. It renders the field
483
- * content, (label, description, children, errors and help) inside of a `WrapIfAdditional` component.
484
- *
485
- * @param props - The `FieldTemplateProps` for this component
486
- */
487
- function FieldTemplate(props) {
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);
521
- if (hidden) {
522
- return jsxRuntime.jsx("div", {
523
- className: 'field-hidden',
524
- children: children
525
- });
526
- }
527
- // check to see if there is rawDescription(string) before using description(ReactNode)
528
- // to prevent showing a blank description area
529
- const descriptionNode = rawDescription ? description : undefined;
530
- const descriptionProps = {};
531
- switch (descriptionLocation) {
532
- case 'tooltip':
533
- descriptionProps.tooltip = descriptionNode;
534
- break;
535
- case 'below':
536
- default:
537
- descriptionProps.extra = descriptionNode;
538
- break;
539
- }
540
- return jsxRuntime.jsx(WrapIfAdditionalTemplate, {
541
- classNames: classNames,
542
- style: style,
543
- disabled: disabled,
544
- id: id,
545
- label: label,
546
- onDropPropertyClick: onDropPropertyClick,
547
- onKeyChange: onKeyChange,
548
- readonly: readonly,
549
- required: required,
550
- schema: schema,
551
- uiSchema: uiSchema,
552
- registry: registry,
553
- children: jsxRuntime.jsx(Form__default["default"].Item, {
554
- colon: colon,
555
- hasFeedback: schema.type !== 'array' && schema.type !== 'object',
556
- help: !!rawHelp && help || (rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? errors : undefined),
557
- htmlFor: id,
558
- label: displayLabel && label,
559
- labelCol: labelCol,
560
- required: required,
561
- style: wrapperStyle,
562
- validateStatus: rawErrors !== null && rawErrors !== void 0 && rawErrors.length ? 'error' : undefined,
563
- wrapperCol: wrapperCol,
564
- ...descriptionProps,
565
- children: children
566
- })
567
- });
568
- }
569
-
570
- const DESCRIPTION_COL_STYLE = {
571
- paddingBottom: '8px'
572
- };
573
- /** The `ObjectFieldTemplate` is the template to use to render all the inner properties of an object along with the
574
- * title and description if available. If the object is expandable, then an `AddButton` is also rendered after all
575
- * the properties.
576
- *
577
- * @param props - The `ObjectFieldTemplateProps` for this component
578
- */
579
- function ObjectFieldTemplate(props) {
580
- 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);
598
- // Button templates are not overridden in the uiSchema
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
- // Single or no field in object.
620
- type === 'object' || type === 'array' || widget === 'textarea' ? 24 : 12;
621
- if (isObject__default["default"](colSpan)) {
622
- const colSpanObj = colSpan;
623
- if (isString__default["default"](widget)) {
624
- return colSpanObj[widget];
625
- }
626
- if (isString__default["default"](field)) {
627
- return colSpanObj[field];
628
- }
629
- if (isString__default["default"](type)) {
630
- return colSpanObj[type];
631
- }
632
- }
633
- if (isNumber__default["default"](colSpan)) {
634
- return colSpan;
635
- }
636
- return defaultColSpan;
637
- };
638
- return jsxRuntime.jsx(context.ConfigConsumer, {
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`
646
- // labelCol.className,
647
- );
648
-
649
- return jsxRuntime.jsxs("fieldset", {
650
- id: idSchema.$id,
651
- children: [jsxRuntime.jsxs(Row__default["default"], {
652
- gutter: rowGutter,
653
- children: [title && jsxRuntime.jsx(Col__default["default"], {
654
- className: labelColClassName,
655
- span: 24,
656
- children: jsxRuntime.jsx(TitleFieldTemplate, {
657
- id: utils.titleId(idSchema),
658
- title: title,
659
- required: required,
660
- schema: schema,
661
- uiSchema: uiSchema,
662
- registry: registry
663
- })
664
- }), description && jsxRuntime.jsx(Col__default["default"], {
665
- span: 24,
666
- style: DESCRIPTION_COL_STYLE,
667
- children: jsxRuntime.jsx(DescriptionFieldTemplate, {
668
- id: utils.descriptionId(idSchema),
669
- description: description,
670
- schema: schema,
671
- uiSchema: uiSchema,
672
- registry: registry
673
- })
674
- }), properties.filter(e => !e.hidden).map(element => jsxRuntime.jsx(Col__default["default"], {
675
- span: calculateColSpan(element),
676
- children: element.content
677
- }, element.name))]
678
- }), utils.canExpand(schema, uiSchema, formData) && jsxRuntime.jsx(Col__default["default"], {
679
- span: 24,
680
- children: jsxRuntime.jsx(Row__default["default"], {
681
- gutter: rowGutter,
682
- justify: 'end',
683
- children: jsxRuntime.jsx(Col__default["default"], {
684
- flex: '192px',
685
- children: jsxRuntime.jsx(AddButton, {
686
- className: 'object-property-expand',
687
- disabled: disabled || readonly,
688
- onClick: onAddClick(schema),
689
- uiSchema: uiSchema,
690
- registry: registry
691
- })
692
- })
693
- })
694
- })]
695
- });
696
- }
697
- });
698
- }
699
-
700
- /** The `SubmitButton` renders a button that represent the `Submit` action on a form
701
- */
702
- function SubmitButton({
703
- uiSchema
704
- }) {
705
- const {
706
- submitText,
707
- norender,
708
- props: submitButtonProps
709
- } = utils.getSubmitButtonOptions(uiSchema);
710
- if (norender) {
711
- return null;
712
- }
713
- return jsxRuntime.jsx(Button__default["default"], {
714
- type: 'submit',
715
- ...submitButtonProps,
716
- htmlType: 'submit',
717
- children: submitText
718
- });
719
- }
720
-
721
- /** The `TitleField` is the template to use to render the title of a field
722
- *
723
- * @param props - The `TitleFieldProps` for this component
724
- */
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;
738
- if (colon && typeof title === 'string' && title.trim() !== '') {
739
- labelChildren = title.replace(/[::]\s*$/, '');
740
- }
741
- const handleLabelClick = () => {
742
- if (!id) {
743
- return;
744
- }
745
- const control = document.querySelector(`[id="${id}"]`);
746
- if (control && control.focus) {
747
- control.focus();
748
- }
749
- };
750
- return title ? jsxRuntime.jsx(context.ConfigConsumer, {
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
- });
760
- return jsxRuntime.jsx("label", {
761
- className: labelClassName,
762
- htmlFor: id,
763
- onClick: handleLabelClick,
764
- title: typeof title === 'string' ? title : '',
765
- children: labelChildren
766
- });
767
- }
768
- }) : null;
769
- }
770
-
771
- const VERTICAL_LABEL_COL = {
772
- span: 24
773
- };
774
- const VERTICAL_WRAPPER_COL = {
775
- span: 24
776
- };
777
- const INPUT_STYLE$1 = {
778
- width: '100%'
779
- };
780
- /** The `WrapIfAdditional` component is used by the `FieldTemplate` to rename, or remove properties that are
781
- * part of an `additionalProperties` part of a schema.
782
- *
783
- * @param props - The `WrapIfAdditionalProps` for this component
784
- */
785
- function WrapIfAdditionalTemplate(props) {
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;
814
- // Button templates are not overridden in the uiSchema
815
- const {
816
- RemoveButton
817
- } = templates.ButtonTemplates;
818
- const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
819
- const additional = (utils.ADDITIONAL_PROPERTY_FLAG in schema);
820
- if (!additional) {
821
- return jsxRuntime.jsx("div", {
822
- className: classNames,
823
- style: style,
824
- children: children
825
- });
826
- }
827
- const handleBlur = ({
828
- target
829
- }) => onKeyChange(target.value);
830
- // The `block` prop is not part of the `IconButtonProps` defined in the template, so put it into the uiSchema instead
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
- };
839
- return jsxRuntime.jsx("div", {
840
- className: classNames,
841
- style: style,
842
- children: jsxRuntime.jsxs(Row__default["default"], {
843
- align: toolbarAlign,
844
- gutter: rowGutter,
845
- children: [jsxRuntime.jsx(Col__default["default"], {
846
- className: 'form-additional',
847
- flex: '1',
848
- children: jsxRuntime.jsx("div", {
849
- className: 'form-group',
850
- children: jsxRuntime.jsx(Form__default["default"].Item, {
851
- colon: colon,
852
- className: 'form-group',
853
- hasFeedback: true,
854
- htmlFor: `${id}-key`,
855
- label: keyLabel,
856
- labelCol: labelCol,
857
- required: required,
858
- style: wrapperStyle,
859
- wrapperCol: wrapperCol,
860
- children: jsxRuntime.jsx(Input__default["default"], {
861
- className: 'form-control',
862
- defaultValue: label,
863
- disabled: disabled || readonlyAsDisabled && readonly,
864
- id: `${id}-key`,
865
- name: `${id}-key`,
866
- onBlur: !readonly ? handleBlur : undefined,
867
- style: INPUT_STYLE$1,
868
- type: 'text'
869
- })
870
- })
871
- })
872
- }), jsxRuntime.jsx(Col__default["default"], {
873
- className: 'form-additional',
874
- flex: '1',
875
- children: children
876
- }), jsxRuntime.jsx(Col__default["default"], {
877
- flex: '192px',
878
- children: jsxRuntime.jsx(RemoveButton, {
879
- className: 'array-item-remove',
880
- disabled: disabled || readonly,
881
- onClick: onDropPropertyClick(label),
882
- uiSchema: buttonUiOptions,
883
- registry: registry
884
- })
885
- })]
886
- })
887
- });
888
- }
889
-
890
- function generateTemplates() {
891
- return {
892
- ArrayFieldItemTemplate,
893
- ArrayFieldTemplate,
894
- BaseInputTemplate,
895
- ButtonTemplates: {
896
- AddButton,
897
- CopyButton,
898
- MoveDownButton,
899
- MoveUpButton,
900
- RemoveButton,
901
- SubmitButton
902
- },
903
- DescriptionFieldTemplate: DescriptionField,
904
- ErrorListTemplate: ErrorList,
905
- FieldErrorTemplate,
906
- FieldTemplate,
907
- ObjectFieldTemplate,
908
- TitleFieldTemplate: TitleField,
909
- WrapIfAdditionalTemplate
910
- };
911
- }
912
- var index$1 = /*#__PURE__*/generateTemplates();
913
-
914
- const rangeOptions = (start, stop) => {
915
- const options = [];
916
- for (let i = start; i <= stop; i++) {
917
- options.push({
918
- value: i,
919
- label: utils.pad(i, 2)
920
- });
921
- }
922
- return options;
923
- };
924
- const readyForChange = state => {
925
- return Object.values(state).every(value => value !== -1);
926
- };
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 = [{
937
- type: 'year',
938
- range: yearsRange,
939
- value: year
940
- }, {
941
- type: 'month',
942
- range: [1, 12],
943
- value: month
944
- }, {
945
- type: 'day',
946
- range: [1, 31],
947
- value: day
948
- }];
949
- if (time) {
950
- data.push({
951
- type: 'hour',
952
- range: [0, 23],
953
- value: hour || -1
954
- }, {
955
- type: 'minute',
956
- range: [0, 59],
957
- value: minute || -1
958
- }, {
959
- type: 'second',
960
- range: [0, 59],
961
- value: second || -1
962
- });
963
- }
964
- return data;
965
- }
966
- function AltDateWidget(props) {
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(() => {
993
- setState(utils.parseDateString(value, showTime));
994
- }, [showTime, value]);
995
- const handleChange = (property, nextValue) => {
996
- const nextState = {
997
- ...state,
998
- [property]: typeof nextValue === 'undefined' ? -1 : nextValue
999
- };
1000
- if (readyForChange(nextState)) {
1001
- onChange(utils.toDateString(nextState, showTime));
1002
- } else {
1003
- setState(nextState);
1004
- }
1005
- };
1006
- const handleNow = event => {
1007
- event.preventDefault();
1008
- if (disabled || readonly) {
1009
- return;
1010
- }
1011
- const nextState = utils.parseDateString(new Date().toJSON(), showTime);
1012
- onChange(utils.toDateString(nextState, showTime));
1013
- };
1014
- const handleClear = event => {
1015
- event.preventDefault();
1016
- if (disabled || readonly) {
1017
- return;
1018
- }
1019
- onChange(undefined);
1020
- };
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
- });
1043
- return jsxRuntime.jsxs(Row__default["default"], {
1044
- gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)],
1045
- children: [dateElementProps(state, showTime, options.yearsRange).map((elemProps, i) => {
1046
- const elemId = id + '_' + elemProps.type;
1047
- return jsxRuntime.jsx(Col__default["default"], {
1048
- flex: '88px',
1049
- children: renderDateElement({
1050
- ...elemProps,
1051
- autofocus: autofocus && i === 0,
1052
- disabled,
1053
- id: elemId,
1054
- name: id,
1055
- onBlur,
1056
- onFocus,
1057
- readonly,
1058
- registry,
1059
- select: handleChange,
1060
- // NOTE: antd components accept -1 rather than issue a warning
1061
- // like material-ui, so we need to convert -1 to undefined here.
1062
- value: elemProps.value < 0 ? undefined : elemProps.value
1063
- })
1064
- }, elemId);
1065
- }), !options.hideNowButton && jsxRuntime.jsx(Col__default["default"], {
1066
- flex: '88px',
1067
- children: jsxRuntime.jsx(Button__default["default"], {
1068
- block: true,
1069
- className: 'btn-now',
1070
- onClick: handleNow,
1071
- type: 'primary',
1072
- children: translateString(utils.TranslatableString.NowLabel)
1073
- })
1074
- }), !options.hideClearButton && jsxRuntime.jsx(Col__default["default"], {
1075
- flex: '88px',
1076
- children: jsxRuntime.jsx(Button__default["default"], {
1077
- block: true,
1078
- className: 'btn-clear',
1079
- danger: true,
1080
- onClick: handleClear,
1081
- type: 'primary',
1082
- children: translateString(utils.TranslatableString.ClearLabel)
1083
- })
1084
- })]
1085
- });
1086
- }
1087
- AltDateWidget.defaultProps = {
1088
- autofocus: false,
1089
- disabled: false,
1090
- options: {
1091
- yearsRange: [1900, /*#__PURE__*/new Date().getFullYear() + 2]
1092
- },
1093
- readonly: false,
1094
- showTime: false
1095
- };
1096
-
1097
- function AltDateTimeWidget(props) {
1098
- const {
1099
- AltDateWidget
1100
- } = props.registry.widgets;
1101
- return jsxRuntime.jsx(AltDateWidget, {
1102
- showTime: true,
1103
- ...props
1104
- });
1105
- }
1106
- AltDateTimeWidget.defaultProps = {
1107
- ...AltDateWidget.defaultProps,
1108
- showTime: true
1109
- };
1110
-
1111
- /** The `CheckboxesWidget` is a widget for rendering checkbox groups.
1112
- * It is typically used to represent an array of enums.
1113
- *
1114
- * @param props - The `WidgetProps` for this component
1115
- */
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));
1150
- // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
1151
- // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
1152
- const extraProps = {
1153
- id,
1154
- onBlur: !readonly ? handleBlur : undefined,
1155
- onFocus: !readonly ? handleFocus : undefined
1156
- };
1157
- const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
1158
- return Array.isArray(enumOptions) && enumOptions.length > 0 ? jsxRuntime.jsxs(jsxRuntime.Fragment, {
1159
- children: [!hideLabel && !!label && jsxRuntime.jsx("div", {
1160
- children: jsxRuntime.jsx(TitleFieldTemplate, {
1161
- id: utils.titleId(id),
1162
- title: label,
1163
- schema: schema,
1164
- uiSchema: uiSchema,
1165
- registry: registry
1166
- })
1167
- }), jsxRuntime.jsx(Checkbox__default["default"].Group, {
1168
- disabled: disabled || readonlyAsDisabled && readonly,
1169
- name: id,
1170
- onChange: !readonly ? handleChange : undefined,
1171
- value: selectedIndexes,
1172
- ...extraProps,
1173
- "aria-describedby": utils.ariaDescribedByIds(id),
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
- })]
1185
- }) : null;
1186
- }
1187
-
1188
- /** The `CheckBoxWidget` is a widget for rendering boolean properties.
1189
- * It is typically used to represent a boolean.
1190
- *
1191
- * @param props - The `WidgetProps` for this component
1192
- */
1193
- function CheckboxWidget(props) {
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);
1219
- // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
1220
- // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
1221
- const extraProps = {
1222
- onBlur: !readonly ? handleBlur : undefined,
1223
- onFocus: !readonly ? handleFocus : undefined
1224
- };
1225
- return jsxRuntime.jsx(Checkbox__default["default"], {
1226
- autoFocus: autofocus,
1227
- checked: typeof value === 'undefined' ? false : value,
1228
- disabled: disabled || readonlyAsDisabled && readonly,
1229
- id: id,
1230
- name: id,
1231
- onChange: !readonly ? handleChange : undefined,
1232
- ...extraProps,
1233
- "aria-describedby": utils.ariaDescribedByIds(id),
1234
- children: utils.labelValue(label, hideLabel, '')
1235
- });
1236
- }
1237
-
1238
- const DatePicker = /*#__PURE__*/generatePicker__default["default"](dayjsGenerateConfig__default["default"]);
1239
-
1240
- const DATE_PICKER_STYLE$1 = {
1241
- width: '100%'
1242
- };
1243
- /** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms
1244
- * the value to/from utc using the appropriate utility functions.
1245
- *
1246
- * @param props - The `WidgetProps` for this component
1247
- */
1248
- function DateTimeWidget(props) {
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;
1267
- return jsxRuntime.jsx(DatePicker, {
1268
- disabled: disabled || readonlyAsDisabled && readonly,
1269
- getPopupContainer: getPopupContainer,
1270
- id: id,
1271
- name: id,
1272
- onBlur: !readonly ? handleBlur : undefined,
1273
- onChange: !readonly ? handleChange : undefined,
1274
- onFocus: !readonly ? handleFocus : undefined,
1275
- placeholder: placeholder,
1276
- showTime: true,
1277
- style: DATE_PICKER_STYLE$1,
1278
- value: value && dayjs__default["default"](value),
1279
- "aria-describedby": utils.ariaDescribedByIds(id)
1280
- });
1281
- }
1282
-
1283
- const DATE_PICKER_STYLE = {
1284
- width: '100%'
1285
- };
1286
- /** The `DateWidget` component uses the `BaseInputTemplate` changing the type to `date` and transforms
1287
- * the value to undefined when it is falsy during the `onChange` handling.
1288
- *
1289
- * @param props - The `WidgetProps` for this component
1290
- */
1291
- function DateWidget(props) {
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;
1310
- return jsxRuntime.jsx(DatePicker, {
1311
- disabled: disabled || readonlyAsDisabled && readonly,
1312
- getPopupContainer: getPopupContainer,
1313
- id: id,
1314
- name: id,
1315
- onBlur: !readonly ? handleBlur : undefined,
1316
- onChange: !readonly ? handleChange : undefined,
1317
- onFocus: !readonly ? handleFocus : undefined,
1318
- placeholder: placeholder,
1319
- showTime: false,
1320
- style: DATE_PICKER_STYLE,
1321
- value: value && dayjs__default["default"](value),
1322
- "aria-describedby": utils.ariaDescribedByIds(id)
1323
- });
1324
- }
1325
-
1326
- /** The `PasswordWidget` component uses the `BaseInputTemplate` changing the type to `password`.
1327
- *
1328
- * @param props - The `WidgetProps` for this component
1329
- */
1330
- function PasswordWidget(props) {
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);
1356
- return jsxRuntime.jsx(Input__default["default"].Password, {
1357
- disabled: disabled || readonlyAsDisabled && readonly,
1358
- id: id,
1359
- name: id,
1360
- onBlur: !readonly ? handleBlur : undefined,
1361
- onChange: !readonly ? handleChange : undefined,
1362
- onFocus: !readonly ? handleFocus : undefined,
1363
- placeholder: placeholder,
1364
- value: value || '',
1365
- "aria-describedby": utils.ariaDescribedByIds(id)
1366
- });
1367
- }
1368
-
1369
- /** The `RadioWidget` is a widget for rendering a radio group.
1370
- * It is typically used with a string property constrained with enum options.
1371
- *
1372
- * @param props - The `WidgetProps` for this component
1373
- */
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);
1406
- return jsxRuntime.jsx(Radio__default["default"].Group, {
1407
- disabled: disabled || readonlyAsDisabled && readonly,
1408
- id: id,
1409
- name: id,
1410
- onChange: !readonly ? handleChange : undefined,
1411
- onBlur: !readonly ? handleBlur : undefined,
1412
- onFocus: !readonly ? handleFocus : undefined,
1413
- value: selectedIndexes,
1414
- "aria-describedby": utils.ariaDescribedByIds(id),
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))
1423
- });
1424
- }
1425
-
1426
- /** The `RangeWidget` component uses the `BaseInputTemplate` changing the type to `range` and wrapping the result
1427
- * in a div, with the value along side it.
1428
- *
1429
- * @param props - The `WidgetProps` for this component
1430
- */
1431
- function RangeWidget(props) {
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);
1458
- // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
1459
- // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
1460
- const extraProps = {
1461
- placeholder,
1462
- onBlur: !readonly ? handleBlur : undefined,
1463
- onFocus: !readonly ? handleFocus : undefined
1464
- };
1465
- return jsxRuntime.jsx(Slider__default["default"], {
1466
- autoFocus: autofocus,
1467
- disabled: disabled || readonlyAsDisabled && readonly,
1468
- id: id,
1469
- max: max,
1470
- min: min,
1471
- onChange: !readonly ? handleChange : undefined,
1472
- range: false,
1473
- step: step,
1474
- value: value,
1475
- ...extraProps,
1476
- "aria-describedby": utils.ariaDescribedByIds(id)
1477
- });
1478
- }
1479
-
1480
- const SELECT_STYLE = {
1481
- width: '100%'
1482
- };
1483
- /** The `SelectWidget` is a widget for rendering dropdowns.
1484
- * It is typically used with string properties constrained with enum options.
1485
- *
1486
- * @param props - The `WidgetProps` for this component
1487
- */
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) => {
1514
- if (option && isString__default["default"](option.label)) {
1515
- // labels are strings in this context
1516
- return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
1517
- }
1518
- return false;
1519
- };
1520
- const getPopupContainer = node => node.parentNode;
1521
- const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
1522
- // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
1523
- // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
1524
- const extraProps = {
1525
- name: id
1526
- };
1527
- return jsxRuntime.jsx(Select__default["default"], {
1528
- autoFocus: autofocus,
1529
- disabled: disabled || readonlyAsDisabled && readonly,
1530
- getPopupContainer: getPopupContainer,
1531
- id: id,
1532
- mode: multiple ? 'multiple' : undefined,
1533
- onBlur: !readonly ? handleBlur : undefined,
1534
- onChange: !readonly ? handleChange : undefined,
1535
- onFocus: !readonly ? handleFocus : undefined,
1536
- placeholder: placeholder,
1537
- style: SELECT_STYLE,
1538
- value: selectedIndexes,
1539
- ...extraProps,
1540
- filterOption: filterOption,
1541
- "aria-describedby": utils.ariaDescribedByIds(id),
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
- });
1551
- }
1552
-
1553
- const INPUT_STYLE = {
1554
- width: '100%'
1555
- };
1556
- /** The `TextareaWidget` is a widget for rendering input fields as textarea.
1557
- *
1558
- * @param props - The `WidgetProps` for this component
1559
- */
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);
1584
- // Antd's typescript definitions do not contain the following props that are actually necessary and, if provided,
1585
- // they are used, so hacking them in via by spreading `extraProps` on the component to avoid typescript errors
1586
- const extraProps = {
1587
- type: 'textarea'
1588
- };
1589
- return jsxRuntime.jsx(Input__default["default"].TextArea, {
1590
- disabled: disabled || readonlyAsDisabled && readonly,
1591
- id: id,
1592
- name: id,
1593
- onBlur: !readonly ? handleBlur : undefined,
1594
- onChange: !readonly ? handleChange : undefined,
1595
- onFocus: !readonly ? handleFocus : undefined,
1596
- placeholder: placeholder,
1597
- rows: options.rows || 4,
1598
- style: INPUT_STYLE,
1599
- value: value,
1600
- ...extraProps,
1601
- "aria-describedby": utils.ariaDescribedByIds(id)
1602
- });
1603
- }
1604
-
1605
- function generateWidgets() {
1606
- return {
1607
- AltDateTimeWidget,
1608
- AltDateWidget,
1609
- CheckboxesWidget,
1610
- CheckboxWidget,
1611
- DateTimeWidget,
1612
- DateWidget,
1613
- PasswordWidget,
1614
- RadioWidget,
1615
- RangeWidget,
1616
- SelectWidget,
1617
- TextareaWidget
1618
- };
1619
- }
1620
- var index = /*#__PURE__*/generateWidgets();
1621
-
1622
- function generateTheme() {
1623
- return {
1624
- templates: generateTemplates(),
1625
- widgets: generateWidgets()
1626
- };
1627
- }
1628
- const Theme = /*#__PURE__*/generateTheme();
1629
- function generateForm() {
1630
- return core.withTheme(generateTheme());
1631
- }
1632
- const Form = /*#__PURE__*/generateForm();
1633
-
1634
- exports.Form = Form;
1635
- exports.Templates = index$1;
1636
- exports.Theme = Theme;
1637
- exports.Widgets = index;
1638
- exports["default"] = Form;
1639
- exports.generateForm = generateForm;
1640
- exports.generateTemplates = generateTemplates;
1641
- exports.generateTheme = generateTheme;
1642
- exports.generateWidgets = generateWidgets;
1643
- //# sourceMappingURL=antd.cjs.development.js.map