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