@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
@@ -0,0 +1,1184 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('antd/lib/button'), require('antd/lib/col'), require('antd/lib/row'), require('react/jsx-runtime'), 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/isObject'), require('lodash/isNumber'), require('lodash/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', 'antd/lib/button', 'antd/lib/col', 'antd/lib/row', 'react/jsx-runtime', '@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/isObject', 'lodash/isNumber', 'lodash/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.Button4, global.Col2, global.Row2, global.jsxRuntime, 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, 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, Button4, Col2, Row2, jsxRuntime, utils, classNames, context, Input, InputNumber, Alert, List, Space, ExclamationCircleOutlined, ArrowDownOutlined, ArrowUpOutlined, CopyOutlined, DeleteOutlined, PlusCircleOutlined, Form, isObject, isNumber, isString, react, Checkbox, dayjs, dayjsGenerateConfig, generatePicker, Radio, Slider, Select) { 'use strict';
6
+
7
+ // src/index.ts
8
+ var BTN_GRP_STYLE = {
9
+ width: "100%"
10
+ };
11
+ var BTN_STYLE = {
12
+ width: "calc(100% / 4)"
13
+ };
14
+ function ArrayFieldItemTemplate(props) {
15
+ const {
16
+ children,
17
+ disabled,
18
+ hasCopy,
19
+ hasMoveDown,
20
+ hasMoveUp,
21
+ hasRemove,
22
+ hasToolbar,
23
+ index,
24
+ onCopyIndexClick,
25
+ onDropIndexClick,
26
+ onReorderClick,
27
+ readonly,
28
+ registry,
29
+ uiSchema
30
+ } = props;
31
+ const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
32
+ const { rowGutter = 24, toolbarAlign = "top" } = registry.formContext;
33
+ return /* @__PURE__ */ jsxRuntime.jsxs(Row2, { align: toolbarAlign, gutter: rowGutter, children: [
34
+ /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "1", children }),
35
+ hasToolbar && /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "192px", children: /* @__PURE__ */ jsxRuntime.jsxs(Button4.Group, { style: BTN_GRP_STYLE, children: [
36
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsxRuntime.jsx(
37
+ MoveUpButton2,
38
+ {
39
+ disabled: disabled || readonly || !hasMoveUp,
40
+ onClick: onReorderClick(index, index - 1),
41
+ style: BTN_STYLE,
42
+ uiSchema,
43
+ registry
44
+ }
45
+ ),
46
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsxRuntime.jsx(
47
+ MoveDownButton2,
48
+ {
49
+ disabled: disabled || readonly || !hasMoveDown,
50
+ onClick: onReorderClick(index, index + 1),
51
+ style: BTN_STYLE,
52
+ uiSchema,
53
+ registry
54
+ }
55
+ ),
56
+ hasCopy && /* @__PURE__ */ jsxRuntime.jsx(
57
+ CopyButton2,
58
+ {
59
+ disabled: disabled || readonly,
60
+ onClick: onCopyIndexClick(index),
61
+ style: BTN_STYLE,
62
+ uiSchema,
63
+ registry
64
+ }
65
+ ),
66
+ hasRemove && /* @__PURE__ */ jsxRuntime.jsx(
67
+ RemoveButton2,
68
+ {
69
+ disabled: disabled || readonly,
70
+ onClick: onDropIndexClick(index),
71
+ style: BTN_STYLE,
72
+ uiSchema,
73
+ registry
74
+ }
75
+ )
76
+ ] }) })
77
+ ] }, `array-item-${index}`);
78
+ }
79
+ var DESCRIPTION_COL_STYLE = {
80
+ paddingBottom: "8px"
81
+ };
82
+ function ArrayFieldTemplate(props) {
83
+ const {
84
+ canAdd,
85
+ className,
86
+ disabled,
87
+ formContext,
88
+ idSchema,
89
+ items,
90
+ onAddClick,
91
+ readonly,
92
+ registry,
93
+ required,
94
+ schema,
95
+ title,
96
+ uiSchema
97
+ } = props;
98
+ const uiOptions = utils.getUiOptions(uiSchema);
99
+ const ArrayFieldDescriptionTemplate = utils.getTemplate(
100
+ "ArrayFieldDescriptionTemplate",
101
+ registry,
102
+ uiOptions
103
+ );
104
+ const ArrayFieldItemTemplate2 = utils.getTemplate(
105
+ "ArrayFieldItemTemplate",
106
+ registry,
107
+ uiOptions
108
+ );
109
+ const ArrayFieldTitleTemplate = utils.getTemplate(
110
+ "ArrayFieldTitleTemplate",
111
+ registry,
112
+ uiOptions
113
+ );
114
+ const {
115
+ ButtonTemplates: { AddButton: AddButton2 }
116
+ } = registry.templates;
117
+ const { labelAlign = "right", rowGutter = 24 } = formContext;
118
+ return /* @__PURE__ */ jsxRuntime.jsx(context.ConfigConsumer, { children: (configProps) => {
119
+ const { getPrefixCls } = configProps;
120
+ const prefixCls = getPrefixCls("form");
121
+ const labelClsBasic = `${prefixCls}-item-label`;
122
+ const labelColClassName = classNames(
123
+ labelClsBasic,
124
+ labelAlign === "left" && `${labelClsBasic}-left`
125
+ // labelCol.className,
126
+ );
127
+ return /* @__PURE__ */ jsxRuntime.jsx("fieldset", { className, id: idSchema.$id, children: /* @__PURE__ */ jsxRuntime.jsxs(Row2, { gutter: rowGutter, children: [
128
+ (uiOptions.title || title) && /* @__PURE__ */ jsxRuntime.jsx(Col2, { className: labelColClassName, span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(
129
+ ArrayFieldTitleTemplate,
130
+ {
131
+ idSchema,
132
+ required,
133
+ title: uiOptions.title || title,
134
+ schema,
135
+ uiSchema,
136
+ registry
137
+ }
138
+ ) }),
139
+ (uiOptions.description || schema.description) && /* @__PURE__ */ jsxRuntime.jsx(Col2, { span: 24, style: DESCRIPTION_COL_STYLE, children: /* @__PURE__ */ jsxRuntime.jsx(
140
+ ArrayFieldDescriptionTemplate,
141
+ {
142
+ description: uiOptions.description || schema.description,
143
+ idSchema,
144
+ schema,
145
+ uiSchema,
146
+ registry
147
+ }
148
+ ) }),
149
+ /* @__PURE__ */ jsxRuntime.jsx(Col2, { className: "row array-item-list", span: 24, children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
150
+ canAdd && /* @__PURE__ */ jsxRuntime.jsx(Col2, { span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(Row2, { gutter: rowGutter, justify: "end", children: /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "192px", children: /* @__PURE__ */ jsxRuntime.jsx(
151
+ AddButton2,
152
+ {
153
+ className: "array-item-add",
154
+ disabled: disabled || readonly,
155
+ onClick: onAddClick,
156
+ uiSchema,
157
+ registry
158
+ }
159
+ ) }) }) })
160
+ ] }) });
161
+ } });
162
+ }
163
+ var INPUT_STYLE = {
164
+ width: "100%"
165
+ };
166
+ function BaseInputTemplate(props) {
167
+ const {
168
+ disabled,
169
+ formContext,
170
+ id,
171
+ onBlur,
172
+ onChange,
173
+ onChangeOverride,
174
+ onFocus,
175
+ options,
176
+ placeholder,
177
+ readonly,
178
+ schema,
179
+ value,
180
+ type
181
+ } = props;
182
+ const inputProps = utils.getInputProps(schema, type, options, false);
183
+ const { readonlyAsDisabled = true } = formContext;
184
+ const handleNumberChange = (nextValue) => onChange(nextValue);
185
+ const handleTextChange = onChangeOverride ? onChangeOverride : ({ target }) => onChange(target.value === "" ? options.emptyValue : target.value);
186
+ const handleBlur = ({ target }) => onBlur(id, target.value);
187
+ const handleFocus = ({ target }) => onFocus(id, target.value);
188
+ const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ jsxRuntime.jsx(
189
+ InputNumber,
190
+ {
191
+ disabled: disabled || readonlyAsDisabled && readonly,
192
+ id,
193
+ name: id,
194
+ onBlur: !readonly ? handleBlur : void 0,
195
+ onChange: !readonly ? handleNumberChange : void 0,
196
+ onFocus: !readonly ? handleFocus : void 0,
197
+ placeholder,
198
+ style: INPUT_STYLE,
199
+ list: schema.examples ? utils.examplesId(id) : void 0,
200
+ ...inputProps,
201
+ value,
202
+ "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
203
+ }
204
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
205
+ Input,
206
+ {
207
+ disabled: disabled || readonlyAsDisabled && readonly,
208
+ id,
209
+ name: id,
210
+ onBlur: !readonly ? handleBlur : void 0,
211
+ onChange: !readonly ? handleTextChange : void 0,
212
+ onFocus: !readonly ? handleFocus : void 0,
213
+ placeholder,
214
+ style: INPUT_STYLE,
215
+ list: schema.examples ? utils.examplesId(id) : void 0,
216
+ ...inputProps,
217
+ value,
218
+ "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
219
+ }
220
+ );
221
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
222
+ input,
223
+ Array.isArray(schema.examples) && /* @__PURE__ */ jsxRuntime.jsx("datalist", { id: utils.examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
224
+ return /* @__PURE__ */ jsxRuntime.jsx("option", { value: example }, example);
225
+ }) })
226
+ ] });
227
+ }
228
+ function DescriptionField(props) {
229
+ const { id, description } = props;
230
+ if (!description) {
231
+ return null;
232
+ }
233
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { id, children: description });
234
+ }
235
+ function ErrorList({
236
+ errors,
237
+ registry
238
+ }) {
239
+ const { translateString } = registry;
240
+ const renderErrors = () => /* @__PURE__ */ jsxRuntime.jsx(List, { className: "list-group", size: "small", children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(List.Item, { children: /* @__PURE__ */ jsxRuntime.jsxs(Space, { children: [
241
+ /* @__PURE__ */ jsxRuntime.jsx(ExclamationCircleOutlined, {}),
242
+ error.stack
243
+ ] }) }, index)) });
244
+ return /* @__PURE__ */ jsxRuntime.jsx(
245
+ Alert,
246
+ {
247
+ className: "panel panel-danger errors",
248
+ description: renderErrors(),
249
+ message: translateString(utils.TranslatableString.ErrorsLabel),
250
+ type: "error"
251
+ }
252
+ );
253
+ }
254
+ function IconButton(props) {
255
+ const { iconType = "default", icon, uiSchema, registry, ...otherProps } = props;
256
+ return /* @__PURE__ */ jsxRuntime.jsx(Button4, { type: iconType, icon, ...otherProps });
257
+ }
258
+ function AddButton(props) {
259
+ const {
260
+ registry: { translateString }
261
+ } = props;
262
+ return /* @__PURE__ */ jsxRuntime.jsx(
263
+ IconButton,
264
+ {
265
+ title: translateString(utils.TranslatableString.AddItemButton),
266
+ ...props,
267
+ block: true,
268
+ iconType: "primary",
269
+ icon: /* @__PURE__ */ jsxRuntime.jsx(PlusCircleOutlined, {})
270
+ }
271
+ );
272
+ }
273
+ function CopyButton(props) {
274
+ const {
275
+ registry: { translateString }
276
+ } = props;
277
+ return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.CopyButton), ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(CopyOutlined, {}) });
278
+ }
279
+ function MoveDownButton(props) {
280
+ const {
281
+ registry: { translateString }
282
+ } = props;
283
+ return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.MoveDownButton), ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(ArrowDownOutlined, {}) });
284
+ }
285
+ function MoveUpButton(props) {
286
+ const {
287
+ registry: { translateString }
288
+ } = props;
289
+ return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.MoveUpButton), ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(ArrowUpOutlined, {}) });
290
+ }
291
+ function RemoveButton(props) {
292
+ const options = utils.getUiOptions(props.uiSchema);
293
+ const {
294
+ registry: { translateString }
295
+ } = props;
296
+ return /* @__PURE__ */ jsxRuntime.jsx(
297
+ IconButton,
298
+ {
299
+ title: translateString(utils.TranslatableString.RemoveButton),
300
+ ...props,
301
+ danger: true,
302
+ block: !!options.block,
303
+ iconType: "primary",
304
+ icon: /* @__PURE__ */ jsxRuntime.jsx(DeleteOutlined, {})
305
+ }
306
+ );
307
+ }
308
+ function FieldErrorTemplate(props) {
309
+ const { errors = [], idSchema } = props;
310
+ if (errors.length === 0) {
311
+ return null;
312
+ }
313
+ const id = utils.errorId(idSchema);
314
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { id, children: errors.map((error) => /* @__PURE__ */ jsxRuntime.jsx("div", { children: error }, `field-${id}-error-${error}`)) });
315
+ }
316
+ var VERTICAL_LABEL_COL = { span: 24 };
317
+ var VERTICAL_WRAPPER_COL = { span: 24 };
318
+ function FieldTemplate(props) {
319
+ const {
320
+ children,
321
+ classNames: classNames4,
322
+ style,
323
+ description,
324
+ disabled,
325
+ displayLabel,
326
+ errors,
327
+ formContext,
328
+ help,
329
+ hidden,
330
+ id,
331
+ label,
332
+ onDropPropertyClick,
333
+ onKeyChange,
334
+ rawErrors,
335
+ rawDescription,
336
+ rawHelp,
337
+ readonly,
338
+ registry,
339
+ required,
340
+ schema,
341
+ uiSchema
342
+ } = props;
343
+ const {
344
+ colon,
345
+ labelCol = VERTICAL_LABEL_COL,
346
+ wrapperCol = VERTICAL_WRAPPER_COL,
347
+ wrapperStyle,
348
+ descriptionLocation = "below"
349
+ } = formContext;
350
+ const uiOptions = utils.getUiOptions(uiSchema);
351
+ const WrapIfAdditionalTemplate2 = utils.getTemplate(
352
+ "WrapIfAdditionalTemplate",
353
+ registry,
354
+ uiOptions
355
+ );
356
+ if (hidden) {
357
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "field-hidden", children });
358
+ }
359
+ const descriptionNode = rawDescription ? description : void 0;
360
+ const descriptionProps = {};
361
+ switch (descriptionLocation) {
362
+ case "tooltip":
363
+ descriptionProps.tooltip = descriptionNode;
364
+ break;
365
+ case "below":
366
+ default:
367
+ descriptionProps.extra = descriptionNode;
368
+ break;
369
+ }
370
+ return /* @__PURE__ */ jsxRuntime.jsx(
371
+ WrapIfAdditionalTemplate2,
372
+ {
373
+ classNames: classNames4,
374
+ style,
375
+ disabled,
376
+ id,
377
+ label,
378
+ onDropPropertyClick,
379
+ onKeyChange,
380
+ readonly,
381
+ required,
382
+ schema,
383
+ uiSchema,
384
+ registry,
385
+ children: /* @__PURE__ */ jsxRuntime.jsx(
386
+ Form.Item,
387
+ {
388
+ colon,
389
+ hasFeedback: schema.type !== "array" && schema.type !== "object",
390
+ help: !!rawHelp && help || (rawErrors?.length ? errors : void 0),
391
+ htmlFor: id,
392
+ label: displayLabel && label,
393
+ labelCol,
394
+ required,
395
+ style: wrapperStyle,
396
+ validateStatus: rawErrors?.length ? "error" : void 0,
397
+ wrapperCol,
398
+ ...descriptionProps,
399
+ children
400
+ }
401
+ )
402
+ }
403
+ );
404
+ }
405
+ var DESCRIPTION_COL_STYLE2 = {
406
+ paddingBottom: "8px"
407
+ };
408
+ function ObjectFieldTemplate(props) {
409
+ const {
410
+ description,
411
+ disabled,
412
+ formContext,
413
+ formData,
414
+ idSchema,
415
+ onAddClick,
416
+ properties,
417
+ readonly,
418
+ required,
419
+ registry,
420
+ schema,
421
+ title,
422
+ uiSchema
423
+ } = props;
424
+ const uiOptions = utils.getUiOptions(uiSchema);
425
+ const TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
426
+ const DescriptionFieldTemplate = utils.getTemplate(
427
+ "DescriptionFieldTemplate",
428
+ registry,
429
+ uiOptions
430
+ );
431
+ const {
432
+ ButtonTemplates: { AddButton: AddButton2 }
433
+ } = registry.templates;
434
+ const { colSpan = 24, labelAlign = "right", rowGutter = 24 } = formContext;
435
+ const findSchema = (element) => element.content.props.schema;
436
+ const findSchemaType = (element) => findSchema(element).type;
437
+ const findUiSchema = (element) => element.content.props.uiSchema;
438
+ const findUiSchemaField = (element) => utils.getUiOptions(findUiSchema(element)).field;
439
+ const findUiSchemaWidget = (element) => utils.getUiOptions(findUiSchema(element)).widget;
440
+ const calculateColSpan = (element) => {
441
+ const type = findSchemaType(element);
442
+ const field = findUiSchemaField(element);
443
+ const widget = findUiSchemaWidget(element);
444
+ const defaultColSpan = properties.length < 2 || // Single or no field in object.
445
+ type === "object" || type === "array" || widget === "textarea" ? 24 : 12;
446
+ if (isObject(colSpan)) {
447
+ const colSpanObj = colSpan;
448
+ if (isString(widget)) {
449
+ return colSpanObj[widget];
450
+ }
451
+ if (isString(field)) {
452
+ return colSpanObj[field];
453
+ }
454
+ if (isString(type)) {
455
+ return colSpanObj[type];
456
+ }
457
+ }
458
+ if (isNumber(colSpan)) {
459
+ return colSpan;
460
+ }
461
+ return defaultColSpan;
462
+ };
463
+ return /* @__PURE__ */ jsxRuntime.jsx(context.ConfigConsumer, { children: (configProps) => {
464
+ const { getPrefixCls } = configProps;
465
+ const prefixCls = getPrefixCls("form");
466
+ const labelClsBasic = `${prefixCls}-item-label`;
467
+ const labelColClassName = classNames(
468
+ labelClsBasic,
469
+ labelAlign === "left" && `${labelClsBasic}-left`
470
+ // labelCol.className,
471
+ );
472
+ return /* @__PURE__ */ jsxRuntime.jsxs("fieldset", { id: idSchema.$id, children: [
473
+ /* @__PURE__ */ jsxRuntime.jsxs(Row2, { gutter: rowGutter, children: [
474
+ title && /* @__PURE__ */ jsxRuntime.jsx(Col2, { className: labelColClassName, span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(
475
+ TitleFieldTemplate,
476
+ {
477
+ id: utils.titleId(idSchema),
478
+ title,
479
+ required,
480
+ schema,
481
+ uiSchema,
482
+ registry
483
+ }
484
+ ) }),
485
+ description && /* @__PURE__ */ jsxRuntime.jsx(Col2, { span: 24, style: DESCRIPTION_COL_STYLE2, children: /* @__PURE__ */ jsxRuntime.jsx(
486
+ DescriptionFieldTemplate,
487
+ {
488
+ id: utils.descriptionId(idSchema),
489
+ description,
490
+ schema,
491
+ uiSchema,
492
+ registry
493
+ }
494
+ ) }),
495
+ properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ jsxRuntime.jsx(Col2, { span: calculateColSpan(element), children: element.content }, element.name))
496
+ ] }),
497
+ utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(Col2, { span: 24, children: /* @__PURE__ */ jsxRuntime.jsx(Row2, { gutter: rowGutter, justify: "end", children: /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "192px", children: /* @__PURE__ */ jsxRuntime.jsx(
498
+ AddButton2,
499
+ {
500
+ className: "object-property-expand",
501
+ disabled: disabled || readonly,
502
+ onClick: onAddClick(schema),
503
+ uiSchema,
504
+ registry
505
+ }
506
+ ) }) }) })
507
+ ] });
508
+ } });
509
+ }
510
+ function SubmitButton({ uiSchema }) {
511
+ const { submitText, norender, props: submitButtonProps } = utils.getSubmitButtonOptions(uiSchema);
512
+ if (norender) {
513
+ return null;
514
+ }
515
+ return /* @__PURE__ */ jsxRuntime.jsx(Button4, { type: "submit", ...submitButtonProps, htmlType: "submit", children: submitText });
516
+ }
517
+ function TitleField({
518
+ id,
519
+ required,
520
+ registry,
521
+ title
522
+ }) {
523
+ const { formContext } = registry;
524
+ const { colon = true } = formContext;
525
+ let labelChildren = title;
526
+ if (colon && typeof title === "string" && title.trim() !== "") {
527
+ labelChildren = title.replace(/[::]\s*$/, "");
528
+ }
529
+ const handleLabelClick = () => {
530
+ if (!id) {
531
+ return;
532
+ }
533
+ const control = document.querySelector(`[id="${id}"]`);
534
+ if (control && control.focus) {
535
+ control.focus();
536
+ }
537
+ };
538
+ return title ? /* @__PURE__ */ jsxRuntime.jsx(context.ConfigConsumer, { children: (configProps) => {
539
+ const { getPrefixCls } = configProps;
540
+ const prefixCls = getPrefixCls("form");
541
+ const labelClassName = classNames({
542
+ [`${prefixCls}-item-required`]: required,
543
+ [`${prefixCls}-item-no-colon`]: !colon
544
+ });
545
+ return /* @__PURE__ */ jsxRuntime.jsx(
546
+ "label",
547
+ {
548
+ className: labelClassName,
549
+ htmlFor: id,
550
+ onClick: handleLabelClick,
551
+ title: typeof title === "string" ? title : "",
552
+ children: labelChildren
553
+ }
554
+ );
555
+ } }) : null;
556
+ }
557
+ var VERTICAL_LABEL_COL2 = { span: 24 };
558
+ var VERTICAL_WRAPPER_COL2 = { span: 24 };
559
+ var INPUT_STYLE2 = {
560
+ width: "100%"
561
+ };
562
+ function WrapIfAdditionalTemplate(props) {
563
+ const {
564
+ children,
565
+ classNames: classNames4,
566
+ style,
567
+ disabled,
568
+ id,
569
+ label,
570
+ onDropPropertyClick,
571
+ onKeyChange,
572
+ readonly,
573
+ required,
574
+ registry,
575
+ schema,
576
+ uiSchema
577
+ } = props;
578
+ const {
579
+ colon,
580
+ labelCol = VERTICAL_LABEL_COL2,
581
+ readonlyAsDisabled = true,
582
+ rowGutter = 24,
583
+ toolbarAlign = "top",
584
+ wrapperCol = VERTICAL_WRAPPER_COL2,
585
+ wrapperStyle
586
+ } = registry.formContext;
587
+ const { templates, translateString } = registry;
588
+ const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
589
+ const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
590
+ const additional = utils.ADDITIONAL_PROPERTY_FLAG in schema;
591
+ if (!additional) {
592
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames4, style, children });
593
+ }
594
+ const handleBlur = ({ target }) => onKeyChange(target.value);
595
+ const uiOptions = uiSchema ? uiSchema[utils.UI_OPTIONS_KEY] : {};
596
+ const buttonUiOptions = {
597
+ ...uiSchema,
598
+ [utils.UI_OPTIONS_KEY]: { ...uiOptions, block: true }
599
+ };
600
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames4, style, children: /* @__PURE__ */ jsxRuntime.jsxs(Row2, { align: toolbarAlign, gutter: rowGutter, children: [
601
+ /* @__PURE__ */ jsxRuntime.jsx(Col2, { className: "form-additional", flex: "1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-group", children: /* @__PURE__ */ jsxRuntime.jsx(
602
+ Form.Item,
603
+ {
604
+ colon,
605
+ className: "form-group",
606
+ hasFeedback: true,
607
+ htmlFor: `${id}-key`,
608
+ label: keyLabel,
609
+ labelCol,
610
+ required,
611
+ style: wrapperStyle,
612
+ wrapperCol,
613
+ children: /* @__PURE__ */ jsxRuntime.jsx(
614
+ Input,
615
+ {
616
+ className: "form-control",
617
+ defaultValue: label,
618
+ disabled: disabled || readonlyAsDisabled && readonly,
619
+ id: `${id}-key`,
620
+ name: `${id}-key`,
621
+ onBlur: !readonly ? handleBlur : void 0,
622
+ style: INPUT_STYLE2,
623
+ type: "text"
624
+ }
625
+ )
626
+ }
627
+ ) }) }),
628
+ /* @__PURE__ */ jsxRuntime.jsx(Col2, { className: "form-additional", flex: "1", children }),
629
+ /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "192px", children: /* @__PURE__ */ jsxRuntime.jsx(
630
+ RemoveButton2,
631
+ {
632
+ className: "array-item-remove",
633
+ disabled: disabled || readonly,
634
+ onClick: onDropPropertyClick(label),
635
+ uiSchema: buttonUiOptions,
636
+ registry
637
+ }
638
+ ) })
639
+ ] }) });
640
+ }
641
+
642
+ // src/templates/index.ts
643
+ function generateTemplates() {
644
+ return {
645
+ ArrayFieldItemTemplate,
646
+ ArrayFieldTemplate,
647
+ BaseInputTemplate,
648
+ ButtonTemplates: {
649
+ AddButton,
650
+ CopyButton,
651
+ MoveDownButton,
652
+ MoveUpButton,
653
+ RemoveButton,
654
+ SubmitButton
655
+ },
656
+ DescriptionFieldTemplate: DescriptionField,
657
+ ErrorListTemplate: ErrorList,
658
+ FieldErrorTemplate,
659
+ FieldTemplate,
660
+ ObjectFieldTemplate,
661
+ TitleFieldTemplate: TitleField,
662
+ WrapIfAdditionalTemplate
663
+ };
664
+ }
665
+ var templates_default = generateTemplates();
666
+ var rangeOptions = (start, stop) => {
667
+ const options = [];
668
+ for (let i = start; i <= stop; i++) {
669
+ options.push({ value: i, label: utils.pad(i, 2) });
670
+ }
671
+ return options;
672
+ };
673
+ var readyForChange = (state) => {
674
+ return Object.values(state).every((value) => value !== -1);
675
+ };
676
+ function dateElementProps(state, time, yearsRange = [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]) {
677
+ const { year, month, day, hour, minute, second } = state;
678
+ const data = [
679
+ {
680
+ type: "year",
681
+ range: yearsRange,
682
+ value: year
683
+ },
684
+ { type: "month", range: [1, 12], value: month },
685
+ { type: "day", range: [1, 31], value: day }
686
+ ];
687
+ if (time) {
688
+ data.push(
689
+ { type: "hour", range: [0, 23], value: hour || -1 },
690
+ { type: "minute", range: [0, 59], value: minute || -1 },
691
+ { type: "second", range: [0, 59], value: second || -1 }
692
+ );
693
+ }
694
+ return data;
695
+ }
696
+ function AltDateWidget(props) {
697
+ const {
698
+ autofocus,
699
+ disabled,
700
+ formContext,
701
+ id,
702
+ onBlur,
703
+ onChange,
704
+ onFocus,
705
+ options,
706
+ readonly,
707
+ registry,
708
+ showTime,
709
+ value
710
+ } = props;
711
+ const { translateString, widgets } = registry;
712
+ const { SelectWidget: SelectWidget2 } = widgets;
713
+ const { rowGutter = 24 } = formContext;
714
+ const [state, setState] = react.useState(utils.parseDateString(value, showTime));
715
+ react.useEffect(() => {
716
+ setState(utils.parseDateString(value, showTime));
717
+ }, [showTime, value]);
718
+ const handleChange = (property, nextValue) => {
719
+ const nextState = {
720
+ ...state,
721
+ [property]: typeof nextValue === "undefined" ? -1 : nextValue
722
+ };
723
+ if (readyForChange(nextState)) {
724
+ onChange(utils.toDateString(nextState, showTime));
725
+ } else {
726
+ setState(nextState);
727
+ }
728
+ };
729
+ const handleNow = (event) => {
730
+ event.preventDefault();
731
+ if (disabled || readonly) {
732
+ return;
733
+ }
734
+ const nextState = utils.parseDateString((/* @__PURE__ */ new Date()).toJSON(), showTime);
735
+ onChange(utils.toDateString(nextState, showTime));
736
+ };
737
+ const handleClear = (event) => {
738
+ event.preventDefault();
739
+ if (disabled || readonly) {
740
+ return;
741
+ }
742
+ onChange(void 0);
743
+ };
744
+ const renderDateElement = (elemProps) => /* @__PURE__ */ jsxRuntime.jsx(
745
+ SelectWidget2,
746
+ {
747
+ autofocus: elemProps.autofocus,
748
+ className: "form-control",
749
+ disabled: elemProps.disabled,
750
+ id: elemProps.id,
751
+ name: elemProps.name,
752
+ onBlur: elemProps.onBlur,
753
+ onChange: (elemValue) => elemProps.select(elemProps.type, elemValue),
754
+ onFocus: elemProps.onFocus,
755
+ options: {
756
+ enumOptions: rangeOptions(elemProps.range[0], elemProps.range[1])
757
+ },
758
+ placeholder: elemProps.type,
759
+ readonly: elemProps.readonly,
760
+ schema: { type: "integer" },
761
+ value: elemProps.value,
762
+ registry,
763
+ label: "",
764
+ "aria-describedby": utils.ariaDescribedByIds(id)
765
+ }
766
+ );
767
+ return /* @__PURE__ */ jsxRuntime.jsxs(Row2, { gutter: [Math.floor(rowGutter / 2), Math.floor(rowGutter / 2)], children: [
768
+ dateElementProps(state, showTime, options.yearsRange).map((elemProps, i) => {
769
+ const elemId = id + "_" + elemProps.type;
770
+ return /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "88px", children: renderDateElement({
771
+ ...elemProps,
772
+ autofocus: autofocus && i === 0,
773
+ disabled,
774
+ id: elemId,
775
+ name: id,
776
+ onBlur,
777
+ onFocus,
778
+ readonly,
779
+ registry,
780
+ select: handleChange,
781
+ // NOTE: antd components accept -1 rather than issue a warning
782
+ // like material-ui, so we need to convert -1 to undefined here.
783
+ value: elemProps.value < 0 ? void 0 : elemProps.value
784
+ }) }, elemId);
785
+ }),
786
+ !options.hideNowButton && /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "88px", children: /* @__PURE__ */ jsxRuntime.jsx(Button4, { block: true, className: "btn-now", onClick: handleNow, type: "primary", children: translateString(utils.TranslatableString.NowLabel) }) }),
787
+ !options.hideClearButton && /* @__PURE__ */ jsxRuntime.jsx(Col2, { flex: "88px", children: /* @__PURE__ */ jsxRuntime.jsx(Button4, { block: true, className: "btn-clear", danger: true, onClick: handleClear, type: "primary", children: translateString(utils.TranslatableString.ClearLabel) }) })
788
+ ] });
789
+ }
790
+ AltDateWidget.defaultProps = {
791
+ autofocus: false,
792
+ disabled: false,
793
+ options: {
794
+ yearsRange: [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]
795
+ },
796
+ readonly: false,
797
+ showTime: false
798
+ };
799
+ function AltDateTimeWidget(props) {
800
+ const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
801
+ return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { showTime: true, ...props });
802
+ }
803
+ AltDateTimeWidget.defaultProps = {
804
+ ...AltDateWidget.defaultProps,
805
+ showTime: true
806
+ };
807
+ function CheckboxesWidget({ autofocus, disabled, formContext, id, onBlur, onChange, onFocus, options, readonly, value }) {
808
+ const { readonlyAsDisabled = true } = formContext;
809
+ const { enumOptions, enumDisabled, inline, emptyValue } = options;
810
+ const handleChange = (nextValue) => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
811
+ const handleBlur = ({ target }) => onBlur(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
812
+ const handleFocus = ({ target }) => onFocus(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
813
+ const extraProps = {
814
+ id,
815
+ onBlur: !readonly ? handleBlur : void 0,
816
+ onFocus: !readonly ? handleFocus : void 0
817
+ };
818
+ const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
819
+ return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsx(
820
+ Checkbox.Group,
821
+ {
822
+ disabled: disabled || readonlyAsDisabled && readonly,
823
+ name: id,
824
+ onChange: !readonly ? handleChange : void 0,
825
+ value: selectedIndexes,
826
+ ...extraProps,
827
+ "aria-describedby": utils.ariaDescribedByIds(id),
828
+ children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
829
+ /* @__PURE__ */ jsxRuntime.jsx(
830
+ Checkbox,
831
+ {
832
+ id: utils.optionId(id, i),
833
+ name: id,
834
+ autoFocus: i === 0 ? autofocus : false,
835
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
836
+ value: String(i),
837
+ children: option.label
838
+ }
839
+ ),
840
+ !inline && /* @__PURE__ */ jsxRuntime.jsx("br", {})
841
+ ] }, i))
842
+ }
843
+ ) }) : null;
844
+ }
845
+ function CheckboxWidget(props) {
846
+ const { autofocus, disabled, formContext, id, label, hideLabel, onBlur, onChange, onFocus, readonly, value } = props;
847
+ const { readonlyAsDisabled = true } = formContext;
848
+ const handleChange = ({ target }) => onChange(target.checked);
849
+ const handleBlur = ({ target }) => onBlur(id, target.checked);
850
+ const handleFocus = ({ target }) => onFocus(id, target.checked);
851
+ const extraProps = {
852
+ onBlur: !readonly ? handleBlur : void 0,
853
+ onFocus: !readonly ? handleFocus : void 0
854
+ };
855
+ return /* @__PURE__ */ jsxRuntime.jsx(
856
+ Checkbox,
857
+ {
858
+ autoFocus: autofocus,
859
+ checked: typeof value === "undefined" ? false : value,
860
+ disabled: disabled || readonlyAsDisabled && readonly,
861
+ id,
862
+ name: id,
863
+ onChange: !readonly ? handleChange : void 0,
864
+ ...extraProps,
865
+ "aria-describedby": utils.ariaDescribedByIds(id),
866
+ children: utils.labelValue(label, hideLabel, "")
867
+ }
868
+ );
869
+ }
870
+ var DatePicker = generatePicker(dayjsGenerateConfig);
871
+ var DatePicker_default = DatePicker;
872
+ var DATE_PICKER_STYLE = {
873
+ width: "100%"
874
+ };
875
+ function DateTimeWidget(props) {
876
+ const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
877
+ const { readonlyAsDisabled = true } = formContext;
878
+ const handleChange = (nextValue) => onChange(nextValue && nextValue.toISOString());
879
+ const handleBlur = () => onBlur(id, value);
880
+ const handleFocus = () => onFocus(id, value);
881
+ const getPopupContainer = (node) => node.parentNode;
882
+ return /* @__PURE__ */ jsxRuntime.jsx(
883
+ DatePicker_default,
884
+ {
885
+ disabled: disabled || readonlyAsDisabled && readonly,
886
+ getPopupContainer,
887
+ id,
888
+ name: id,
889
+ onBlur: !readonly ? handleBlur : void 0,
890
+ onChange: !readonly ? handleChange : void 0,
891
+ onFocus: !readonly ? handleFocus : void 0,
892
+ placeholder,
893
+ showTime: true,
894
+ style: DATE_PICKER_STYLE,
895
+ value: value && dayjs(value),
896
+ "aria-describedby": utils.ariaDescribedByIds(id)
897
+ }
898
+ );
899
+ }
900
+ var DATE_PICKER_STYLE2 = {
901
+ width: "100%"
902
+ };
903
+ function DateWidget(props) {
904
+ const { disabled, formContext, id, onBlur, onChange, onFocus, placeholder, readonly, value } = props;
905
+ const { readonlyAsDisabled = true } = formContext;
906
+ const handleChange = (nextValue) => onChange(nextValue && nextValue.format("YYYY-MM-DD"));
907
+ const handleBlur = () => onBlur(id, value);
908
+ const handleFocus = () => onFocus(id, value);
909
+ const getPopupContainer = (node) => node.parentNode;
910
+ return /* @__PURE__ */ jsxRuntime.jsx(
911
+ DatePicker_default,
912
+ {
913
+ disabled: disabled || readonlyAsDisabled && readonly,
914
+ getPopupContainer,
915
+ id,
916
+ name: id,
917
+ onBlur: !readonly ? handleBlur : void 0,
918
+ onChange: !readonly ? handleChange : void 0,
919
+ onFocus: !readonly ? handleFocus : void 0,
920
+ placeholder,
921
+ showTime: false,
922
+ style: DATE_PICKER_STYLE2,
923
+ value: value && dayjs(value),
924
+ "aria-describedby": utils.ariaDescribedByIds(id)
925
+ }
926
+ );
927
+ }
928
+ function PasswordWidget(props) {
929
+ const { disabled, formContext, id, onBlur, onChange, onFocus, options, placeholder, readonly, value } = props;
930
+ const { readonlyAsDisabled = true } = formContext;
931
+ const emptyValue = options.emptyValue || "";
932
+ const handleChange = ({ target }) => onChange(target.value === "" ? emptyValue : target.value);
933
+ const handleBlur = ({ target }) => onBlur(id, target.value);
934
+ const handleFocus = ({ target }) => onFocus(id, target.value);
935
+ return /* @__PURE__ */ jsxRuntime.jsx(
936
+ Input.Password,
937
+ {
938
+ disabled: disabled || readonlyAsDisabled && readonly,
939
+ id,
940
+ name: id,
941
+ onBlur: !readonly ? handleBlur : void 0,
942
+ onChange: !readonly ? handleChange : void 0,
943
+ onFocus: !readonly ? handleFocus : void 0,
944
+ placeholder,
945
+ value: value || "",
946
+ "aria-describedby": utils.ariaDescribedByIds(id)
947
+ }
948
+ );
949
+ }
950
+ function RadioWidget({
951
+ autofocus,
952
+ disabled,
953
+ formContext,
954
+ id,
955
+ onBlur,
956
+ onChange,
957
+ onFocus,
958
+ options,
959
+ readonly,
960
+ value
961
+ }) {
962
+ const { readonlyAsDisabled = true } = formContext;
963
+ const { enumOptions, enumDisabled, emptyValue } = options;
964
+ const handleChange = ({ target: { value: nextValue } }) => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
965
+ const handleBlur = ({ target }) => onBlur(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
966
+ const handleFocus = ({ target }) => onFocus(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
967
+ const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions);
968
+ return /* @__PURE__ */ jsxRuntime.jsx(
969
+ Radio.Group,
970
+ {
971
+ disabled: disabled || readonlyAsDisabled && readonly,
972
+ id,
973
+ name: id,
974
+ onChange: !readonly ? handleChange : void 0,
975
+ onBlur: !readonly ? handleBlur : void 0,
976
+ onFocus: !readonly ? handleFocus : void 0,
977
+ value: selectedIndexes,
978
+ "aria-describedby": utils.ariaDescribedByIds(id),
979
+ children: Array.isArray(enumOptions) && enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
980
+ Radio,
981
+ {
982
+ id: utils.optionId(id, i),
983
+ name: id,
984
+ autoFocus: i === 0 ? autofocus : false,
985
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(value) !== -1,
986
+ value: String(i),
987
+ children: option.label
988
+ },
989
+ i
990
+ ))
991
+ }
992
+ );
993
+ }
994
+ function RangeWidget(props) {
995
+ const {
996
+ autofocus,
997
+ disabled,
998
+ formContext,
999
+ id,
1000
+ onBlur,
1001
+ onChange,
1002
+ onFocus,
1003
+ options,
1004
+ placeholder,
1005
+ readonly,
1006
+ schema,
1007
+ value
1008
+ } = props;
1009
+ const { readonlyAsDisabled = true } = formContext;
1010
+ const { min, max, step } = utils.rangeSpec(schema);
1011
+ const emptyValue = options.emptyValue || "";
1012
+ const handleChange = (nextValue) => onChange(nextValue === "" ? emptyValue : nextValue);
1013
+ const handleBlur = () => onBlur(id, value);
1014
+ const handleFocus = () => onFocus(id, value);
1015
+ const extraProps = {
1016
+ placeholder,
1017
+ onBlur: !readonly ? handleBlur : void 0,
1018
+ onFocus: !readonly ? handleFocus : void 0
1019
+ };
1020
+ return /* @__PURE__ */ jsxRuntime.jsx(
1021
+ Slider,
1022
+ {
1023
+ autoFocus: autofocus,
1024
+ disabled: disabled || readonlyAsDisabled && readonly,
1025
+ id,
1026
+ max,
1027
+ min,
1028
+ onChange: !readonly ? handleChange : void 0,
1029
+ range: false,
1030
+ step,
1031
+ value,
1032
+ ...extraProps,
1033
+ "aria-describedby": utils.ariaDescribedByIds(id)
1034
+ }
1035
+ );
1036
+ }
1037
+ var SELECT_STYLE = {
1038
+ width: "100%"
1039
+ };
1040
+ function SelectWidget({
1041
+ autofocus,
1042
+ disabled,
1043
+ formContext = {},
1044
+ id,
1045
+ multiple,
1046
+ onBlur,
1047
+ onChange,
1048
+ onFocus,
1049
+ options,
1050
+ placeholder,
1051
+ readonly,
1052
+ value
1053
+ }) {
1054
+ const { readonlyAsDisabled = true } = formContext;
1055
+ const { enumOptions, enumDisabled, emptyValue } = options;
1056
+ const handleChange = (nextValue) => onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
1057
+ const handleBlur = () => onBlur(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
1058
+ const handleFocus = () => onFocus(id, utils.enumOptionsValueForIndex(value, enumOptions, emptyValue));
1059
+ const filterOption = (input, option) => {
1060
+ if (option && isString(option.label)) {
1061
+ return option.label.toLowerCase().indexOf(input.toLowerCase()) >= 0;
1062
+ }
1063
+ return false;
1064
+ };
1065
+ const getPopupContainer = (node) => node.parentNode;
1066
+ const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
1067
+ const extraProps = {
1068
+ name: id
1069
+ };
1070
+ return /* @__PURE__ */ jsxRuntime.jsx(
1071
+ Select,
1072
+ {
1073
+ autoFocus: autofocus,
1074
+ disabled: disabled || readonlyAsDisabled && readonly,
1075
+ getPopupContainer,
1076
+ id,
1077
+ mode: multiple ? "multiple" : void 0,
1078
+ onBlur: !readonly ? handleBlur : void 0,
1079
+ onChange: !readonly ? handleChange : void 0,
1080
+ onFocus: !readonly ? handleFocus : void 0,
1081
+ placeholder,
1082
+ style: SELECT_STYLE,
1083
+ value: selectedIndexes,
1084
+ ...extraProps,
1085
+ filterOption,
1086
+ "aria-describedby": utils.ariaDescribedByIds(id),
1087
+ children: Array.isArray(enumOptions) && enumOptions.map(({ value: optionValue, label: optionLabel }, index) => /* @__PURE__ */ jsxRuntime.jsx(
1088
+ Select.Option,
1089
+ {
1090
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(optionValue) !== -1,
1091
+ value: String(index),
1092
+ children: optionLabel
1093
+ },
1094
+ String(index)
1095
+ ))
1096
+ }
1097
+ );
1098
+ }
1099
+ var INPUT_STYLE3 = {
1100
+ width: "100%"
1101
+ };
1102
+ function TextareaWidget({
1103
+ disabled,
1104
+ formContext,
1105
+ id,
1106
+ onBlur,
1107
+ onChange,
1108
+ onFocus,
1109
+ options,
1110
+ placeholder,
1111
+ readonly,
1112
+ value
1113
+ }) {
1114
+ const { readonlyAsDisabled = true } = formContext;
1115
+ const handleChange = ({ target }) => onChange(target.value === "" ? options.emptyValue : target.value);
1116
+ const handleBlur = ({ target }) => onBlur(id, target.value);
1117
+ const handleFocus = ({ target }) => onFocus(id, target.value);
1118
+ const extraProps = {
1119
+ type: "textarea"
1120
+ };
1121
+ return /* @__PURE__ */ jsxRuntime.jsx(
1122
+ Input.TextArea,
1123
+ {
1124
+ disabled: disabled || readonlyAsDisabled && readonly,
1125
+ id,
1126
+ name: id,
1127
+ onBlur: !readonly ? handleBlur : void 0,
1128
+ onChange: !readonly ? handleChange : void 0,
1129
+ onFocus: !readonly ? handleFocus : void 0,
1130
+ placeholder,
1131
+ rows: options.rows || 4,
1132
+ style: INPUT_STYLE3,
1133
+ value,
1134
+ ...extraProps,
1135
+ "aria-describedby": utils.ariaDescribedByIds(id)
1136
+ }
1137
+ );
1138
+ }
1139
+
1140
+ // src/widgets/index.ts
1141
+ function generateWidgets() {
1142
+ return {
1143
+ AltDateTimeWidget,
1144
+ AltDateWidget,
1145
+ CheckboxesWidget,
1146
+ CheckboxWidget,
1147
+ DateTimeWidget,
1148
+ DateWidget,
1149
+ PasswordWidget,
1150
+ RadioWidget,
1151
+ RangeWidget,
1152
+ SelectWidget,
1153
+ TextareaWidget
1154
+ };
1155
+ }
1156
+ var widgets_default = generateWidgets();
1157
+
1158
+ // src/index.ts
1159
+ function generateTheme() {
1160
+ return {
1161
+ templates: generateTemplates(),
1162
+ widgets: generateWidgets()
1163
+ };
1164
+ }
1165
+ var Theme = generateTheme();
1166
+ function generateForm() {
1167
+ return core.withTheme(generateTheme());
1168
+ }
1169
+ var Form3 = generateForm();
1170
+ var src_default = Form3;
1171
+
1172
+ exports.Form = Form3;
1173
+ exports.Templates = templates_default;
1174
+ exports.Theme = Theme;
1175
+ exports.Widgets = widgets_default;
1176
+ exports.default = src_default;
1177
+ exports.generateForm = generateForm;
1178
+ exports.generateTemplates = generateTemplates;
1179
+ exports.generateTheme = generateTheme;
1180
+ exports.generateWidgets = generateWidgets;
1181
+
1182
+ Object.defineProperty(exports, '__esModule', { value: true });
1183
+
1184
+ }));