@rjsf/mantine 6.0.0-beta.14

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 (173) hide show
  1. package/README.md +153 -0
  2. package/dist/index.js +1918 -0
  3. package/dist/index.js.map +7 -0
  4. package/dist/mantine.esm.js +1967 -0
  5. package/dist/mantine.esm.js.map +7 -0
  6. package/dist/mantine.umd.js +1714 -0
  7. package/lib/Form/index.d.ts +6 -0
  8. package/lib/Form/index.js +7 -0
  9. package/lib/Form/index.js.map +1 -0
  10. package/lib/Theme/index.d.ts +5 -0
  11. package/lib/Theme/index.js +10 -0
  12. package/lib/Theme/index.js.map +1 -0
  13. package/lib/index.d.ts +6 -0
  14. package/lib/index.js +7 -0
  15. package/lib/index.js.map +1 -0
  16. package/lib/templates/ArrayFieldItemTemplate.d.ts +6 -0
  17. package/lib/templates/ArrayFieldItemTemplate.js +14 -0
  18. package/lib/templates/ArrayFieldItemTemplate.js.map +1 -0
  19. package/lib/templates/ArrayFieldTemplate.d.ts +6 -0
  20. package/lib/templates/ArrayFieldTemplate.js +20 -0
  21. package/lib/templates/ArrayFieldTemplate.js.map +1 -0
  22. package/lib/templates/ArrayFieldTitleTemplate.d.ts +7 -0
  23. package/lib/templates/ArrayFieldTitleTemplate.js +18 -0
  24. package/lib/templates/ArrayFieldTitleTemplate.js.map +1 -0
  25. package/lib/templates/BaseInputTemplate.d.ts +8 -0
  26. package/lib/templates/BaseInputTemplate.js +36 -0
  27. package/lib/templates/BaseInputTemplate.js.map +1 -0
  28. package/lib/templates/ButtonTemplates/AddButton.d.ts +4 -0
  29. package/lib/templates/ButtonTemplates/AddButton.js +11 -0
  30. package/lib/templates/ButtonTemplates/AddButton.js.map +1 -0
  31. package/lib/templates/ButtonTemplates/IconButton.d.ts +8 -0
  32. package/lib/templates/ButtonTemplates/IconButton.js +25 -0
  33. package/lib/templates/ButtonTemplates/IconButton.js.map +1 -0
  34. package/lib/templates/ButtonTemplates/SubmitButton.d.ts +4 -0
  35. package/lib/templates/ButtonTemplates/SubmitButton.js +13 -0
  36. package/lib/templates/ButtonTemplates/SubmitButton.js.map +1 -0
  37. package/lib/templates/ButtonTemplates/index.d.ts +3 -0
  38. package/lib/templates/ButtonTemplates/index.js +15 -0
  39. package/lib/templates/ButtonTemplates/index.js.map +1 -0
  40. package/lib/templates/DescriptionField.d.ts +6 -0
  41. package/lib/templates/DescriptionField.js +15 -0
  42. package/lib/templates/DescriptionField.js.map +1 -0
  43. package/lib/templates/ErrorList.d.ts +6 -0
  44. package/lib/templates/ErrorList.js +13 -0
  45. package/lib/templates/ErrorList.js.map +1 -0
  46. package/lib/templates/FieldErrorTemplate.d.ts +6 -0
  47. package/lib/templates/FieldErrorTemplate.js +16 -0
  48. package/lib/templates/FieldErrorTemplate.js.map +1 -0
  49. package/lib/templates/FieldHelpTemplate.d.ts +6 -0
  50. package/lib/templates/FieldHelpTemplate.js +13 -0
  51. package/lib/templates/FieldHelpTemplate.js.map +1 -0
  52. package/lib/templates/FieldTemplate.d.ts +7 -0
  53. package/lib/templates/FieldTemplate.js +18 -0
  54. package/lib/templates/FieldTemplate.js.map +1 -0
  55. package/lib/templates/GridTemplate.d.ts +7 -0
  56. package/lib/templates/GridTemplate.js +20 -0
  57. package/lib/templates/GridTemplate.js.map +1 -0
  58. package/lib/templates/MultiSchemaFieldTemplate.d.ts +2 -0
  59. package/lib/templates/MultiSchemaFieldTemplate.js +6 -0
  60. package/lib/templates/MultiSchemaFieldTemplate.js.map +1 -0
  61. package/lib/templates/ObjectFieldTemplate.d.ts +8 -0
  62. package/lib/templates/ObjectFieldTemplate.js +24 -0
  63. package/lib/templates/ObjectFieldTemplate.js.map +1 -0
  64. package/lib/templates/TitleField.d.ts +6 -0
  65. package/lib/templates/TitleField.js +11 -0
  66. package/lib/templates/TitleField.js.map +1 -0
  67. package/lib/templates/WrapIfAdditionalTemplate.d.ts +7 -0
  68. package/lib/templates/WrapIfAdditionalTemplate.js +29 -0
  69. package/lib/templates/WrapIfAdditionalTemplate.js.map +1 -0
  70. package/lib/templates/icons.d.ts +11 -0
  71. package/lib/templates/icons.js +20 -0
  72. package/lib/templates/icons.js.map +1 -0
  73. package/lib/templates/index.d.ts +4 -0
  74. package/lib/templates/index.js +36 -0
  75. package/lib/templates/index.js.map +1 -0
  76. package/lib/tsconfig.tsbuildinfo +1 -0
  77. package/lib/utils.d.ts +2 -0
  78. package/lib/utils.js +35 -0
  79. package/lib/utils.js.map +1 -0
  80. package/lib/widgets/CheckboxWidget.d.ts +8 -0
  81. package/lib/widgets/CheckboxWidget.js +33 -0
  82. package/lib/widgets/CheckboxWidget.js.map +1 -0
  83. package/lib/widgets/CheckboxesWidget.d.ts +7 -0
  84. package/lib/widgets/CheckboxesWidget.js +33 -0
  85. package/lib/widgets/CheckboxesWidget.js.map +1 -0
  86. package/lib/widgets/ColorWidget.d.ts +6 -0
  87. package/lib/widgets/ColorWidget.js +28 -0
  88. package/lib/widgets/ColorWidget.js.map +1 -0
  89. package/lib/widgets/DateTime/AltDateTimeWidget.d.ts +13 -0
  90. package/lib/widgets/DateTime/AltDateTimeWidget.js +16 -0
  91. package/lib/widgets/DateTime/AltDateTimeWidget.js.map +1 -0
  92. package/lib/widgets/DateTime/AltDateWidget.d.ts +11 -0
  93. package/lib/widgets/DateTime/AltDateWidget.js +51 -0
  94. package/lib/widgets/DateTime/AltDateWidget.js.map +1 -0
  95. package/lib/widgets/DateTime/DateTimeInput.d.ts +5 -0
  96. package/lib/widgets/DateTime/DateTimeInput.js +39 -0
  97. package/lib/widgets/DateTime/DateTimeInput.js.map +1 -0
  98. package/lib/widgets/DateTime/DateTimeWidget.d.ts +6 -0
  99. package/lib/widgets/DateTime/DateTimeWidget.js +11 -0
  100. package/lib/widgets/DateTime/DateTimeWidget.js.map +1 -0
  101. package/lib/widgets/DateTime/DateWidget.d.ts +6 -0
  102. package/lib/widgets/DateTime/DateWidget.js +11 -0
  103. package/lib/widgets/DateTime/DateWidget.js.map +1 -0
  104. package/lib/widgets/DateTime/TimeWidget.d.ts +6 -0
  105. package/lib/widgets/DateTime/TimeWidget.js +27 -0
  106. package/lib/widgets/DateTime/TimeWidget.js.map +1 -0
  107. package/lib/widgets/DateTime/index.d.ts +5 -0
  108. package/lib/widgets/DateTime/index.js +6 -0
  109. package/lib/widgets/DateTime/index.js.map +1 -0
  110. package/lib/widgets/FileWidget.d.ts +7 -0
  111. package/lib/widgets/FileWidget.js +106 -0
  112. package/lib/widgets/FileWidget.js.map +1 -0
  113. package/lib/widgets/PasswordWidget.d.ts +7 -0
  114. package/lib/widgets/PasswordWidget.js +30 -0
  115. package/lib/widgets/PasswordWidget.js.map +1 -0
  116. package/lib/widgets/RadioWidget.d.ts +7 -0
  117. package/lib/widgets/RadioWidget.js +33 -0
  118. package/lib/widgets/RadioWidget.js.map +1 -0
  119. package/lib/widgets/RangeWidget.d.ts +7 -0
  120. package/lib/widgets/RangeWidget.js +34 -0
  121. package/lib/widgets/RangeWidget.js.map +1 -0
  122. package/lib/widgets/SelectWidget.d.ts +7 -0
  123. package/lib/widgets/SelectWidget.js +45 -0
  124. package/lib/widgets/SelectWidget.js.map +1 -0
  125. package/lib/widgets/TextareaWidget.d.ts +7 -0
  126. package/lib/widgets/TextareaWidget.js +30 -0
  127. package/lib/widgets/TextareaWidget.js.map +1 -0
  128. package/lib/widgets/index.d.ts +4 -0
  129. package/lib/widgets/index.js +34 -0
  130. package/lib/widgets/index.js.map +1 -0
  131. package/package.json +110 -0
  132. package/src/Form/index.ts +15 -0
  133. package/src/Theme/index.ts +18 -0
  134. package/src/index.ts +8 -0
  135. package/src/templates/ArrayFieldItemTemplate.tsx +40 -0
  136. package/src/templates/ArrayFieldTemplate.tsx +103 -0
  137. package/src/templates/ArrayFieldTitleTemplate.tsx +33 -0
  138. package/src/templates/BaseInputTemplate.tsx +134 -0
  139. package/src/templates/ButtonTemplates/AddButton.tsx +17 -0
  140. package/src/templates/ButtonTemplates/IconButton.tsx +87 -0
  141. package/src/templates/ButtonTemplates/SubmitButton.tsx +20 -0
  142. package/src/templates/ButtonTemplates/index.ts +21 -0
  143. package/src/templates/DescriptionField.tsx +24 -0
  144. package/src/templates/ErrorList.tsx +36 -0
  145. package/src/templates/FieldErrorTemplate.tsx +27 -0
  146. package/src/templates/FieldHelpTemplate.tsx +22 -0
  147. package/src/templates/FieldTemplate.tsx +66 -0
  148. package/src/templates/GridTemplate.tsx +30 -0
  149. package/src/templates/MultiSchemaFieldTemplate.tsx +15 -0
  150. package/src/templates/ObjectFieldTemplate.tsx +104 -0
  151. package/src/templates/TitleField.tsx +17 -0
  152. package/src/templates/WrapIfAdditionalTemplate.tsx +99 -0
  153. package/src/templates/icons.tsx +141 -0
  154. package/src/templates/index.ts +43 -0
  155. package/src/tsconfig.json +23 -0
  156. package/src/utils.ts +37 -0
  157. package/src/widgets/CheckboxWidget.tsx +110 -0
  158. package/src/widgets/CheckboxesWidget.tsx +112 -0
  159. package/src/widgets/ColorWidget.tsx +85 -0
  160. package/src/widgets/DateTime/AltDateTimeWidget.tsx +22 -0
  161. package/src/widgets/DateTime/AltDateWidget.tsx +139 -0
  162. package/src/widgets/DateTime/DateTimeInput.tsx +97 -0
  163. package/src/widgets/DateTime/DateTimeWidget.tsx +24 -0
  164. package/src/widgets/DateTime/DateWidget.tsx +22 -0
  165. package/src/widgets/DateTime/TimeWidget.tsx +83 -0
  166. package/src/widgets/DateTime/index.ts +5 -0
  167. package/src/widgets/FileWidget.tsx +176 -0
  168. package/src/widgets/PasswordWidget.tsx +88 -0
  169. package/src/widgets/RadioWidget.tsx +103 -0
  170. package/src/widgets/RangeWidget.tsx +95 -0
  171. package/src/widgets/SelectWidget.tsx +109 -0
  172. package/src/widgets/TextareaWidget.tsx +87 -0
  173. package/src/widgets/index.ts +42 -0
@@ -0,0 +1,1714 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@rjsf/core'), require('@rjsf/utils'), require('@mantine/core'), require('react/jsx-runtime'), require('react'), require('dayjs'), require('dayjs/plugin/customParseFormat'), require('@mantine/dates')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@rjsf/core', '@rjsf/utils', '@mantine/core', 'react/jsx-runtime', 'react', 'dayjs', 'dayjs/plugin/customParseFormat', '@mantine/dates'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@rjsf/mantine"] = {}, global.core$1, global.utils, global.core, global.jsxRuntime, global.react, global.dayjs, global.customParseFormat, global.dates));
5
+ })(this, (function (exports, core$1, utils, core, jsxRuntime, react, dayjs, customParseFormat, dates) { 'use strict';
6
+
7
+ // src/Form/index.ts
8
+ function ArrayFieldItemTemplate(props) {
9
+ const { buttonsProps, className, hasToolbar, index, uiSchema, registry, children } = props;
10
+ const uiOptions = utils.getUiOptions(uiSchema);
11
+ const ArrayFieldItemButtonsTemplate = utils.getTemplate(
12
+ "ArrayFieldItemButtonsTemplate",
13
+ registry,
14
+ uiOptions
15
+ );
16
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { className: className || "rjsf-array-item", mb: "xs", children: /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "end", justify: "center", children: [
17
+ /* @__PURE__ */ jsxRuntime.jsx(core.Box, { w: "100%", children }),
18
+ hasToolbar && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { wrap: "nowrap", gap: 2, mb: 7, children: /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemButtonsTemplate, { ...buttonsProps }) })
19
+ ] }) }, `array-item-${index}`);
20
+ }
21
+ function ArrayFieldTemplate(props) {
22
+ const {
23
+ canAdd,
24
+ className,
25
+ disabled,
26
+ idSchema,
27
+ items,
28
+ onAddClick,
29
+ readonly,
30
+ required,
31
+ schema,
32
+ uiSchema,
33
+ title,
34
+ registry
35
+ } = props;
36
+ const uiOptions = utils.getUiOptions(uiSchema);
37
+ const ArrayFieldDescriptionTemplate = utils.getTemplate(
38
+ "ArrayFieldDescriptionTemplate",
39
+ registry,
40
+ uiOptions
41
+ );
42
+ const ArrayFieldItemTemplate2 = utils.getTemplate(
43
+ "ArrayFieldItemTemplate",
44
+ registry,
45
+ uiOptions
46
+ );
47
+ const ArrayFieldTitleTemplate2 = utils.getTemplate(
48
+ "ArrayFieldTitleTemplate",
49
+ registry,
50
+ uiOptions
51
+ );
52
+ const {
53
+ ButtonTemplates: { AddButton: AddButton2 }
54
+ } = registry.templates;
55
+ const legend = (uiOptions.title || title) && /* @__PURE__ */ jsxRuntime.jsx(
56
+ ArrayFieldTitleTemplate2,
57
+ {
58
+ idSchema,
59
+ required,
60
+ title: uiOptions.title || title,
61
+ schema,
62
+ uiSchema,
63
+ registry
64
+ }
65
+ );
66
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Fieldset, { legend, className, id: idSchema.$id, children: [
67
+ (uiOptions.description || schema.description) && /* @__PURE__ */ jsxRuntime.jsx(
68
+ ArrayFieldDescriptionTemplate,
69
+ {
70
+ description: uiOptions.description || schema.description,
71
+ idSchema,
72
+ schema,
73
+ uiSchema,
74
+ registry
75
+ }
76
+ ),
77
+ /* @__PURE__ */ jsxRuntime.jsx(core.Box, { className: "row rjsf-array-item-list", children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsxRuntime.jsx(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
78
+ canAdd && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
79
+ AddButton2,
80
+ {
81
+ id: utils.buttonId(idSchema, "add"),
82
+ className: "rjsf-array-item-add",
83
+ disabled: disabled || readonly,
84
+ onClick: onAddClick,
85
+ uiSchema,
86
+ registry,
87
+ iconType: "md"
88
+ }
89
+ ) })
90
+ ] });
91
+ }
92
+ function ArrayFieldTitleTemplate(props) {
93
+ const { idSchema, title, uiSchema, registry } = props;
94
+ const options = utils.getUiOptions(uiSchema, registry.globalUiOptions);
95
+ const { label: displayLabel = true } = options;
96
+ if (!title || !displayLabel) {
97
+ return null;
98
+ }
99
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Title, { id: utils.titleId(idSchema), order: 4, fw: "normal", children: title });
100
+ }
101
+
102
+ // src/utils.ts
103
+ var uiOptionsKeys = [
104
+ "emptyValue",
105
+ "classNames",
106
+ "title",
107
+ "help",
108
+ "autocomplete",
109
+ "disabled",
110
+ "enumDisabled",
111
+ "hideError",
112
+ "readonly",
113
+ "order",
114
+ "filePreview",
115
+ "inline",
116
+ "inputType",
117
+ "submitButtonOptions",
118
+ "widget",
119
+ "enumNames",
120
+ "addable",
121
+ "copyable",
122
+ "orderable",
123
+ "removable",
124
+ "duplicateKeySuffixSeparator",
125
+ "enumOptions",
126
+ "enableMarkdownInDescription"
127
+ ];
128
+ function cleanupOptions(options) {
129
+ const result = {};
130
+ for (const key in options) {
131
+ if (!uiOptionsKeys.includes(key)) {
132
+ result[key] = options[key];
133
+ }
134
+ }
135
+ return result;
136
+ }
137
+ function BaseInputTemplate(props) {
138
+ const {
139
+ id,
140
+ type,
141
+ schema,
142
+ value,
143
+ placeholder,
144
+ required,
145
+ disabled,
146
+ readonly,
147
+ autofocus,
148
+ label,
149
+ hideLabel,
150
+ onChange,
151
+ onChangeOverride,
152
+ onBlur,
153
+ onFocus,
154
+ options,
155
+ rawErrors,
156
+ children
157
+ } = props;
158
+ const inputProps = utils.getInputProps(schema, type, options, false);
159
+ const themeProps = cleanupOptions(options);
160
+ const handleNumberChange = react.useCallback((value2) => onChange(value2), [onChange]);
161
+ const handleChange = react.useCallback(
162
+ (e) => {
163
+ const handler = onChangeOverride ? onChangeOverride : onChange;
164
+ const value2 = e.target.value === "" ? options.emptyValue ?? "" : e.target.value;
165
+ handler(value2);
166
+ },
167
+ [onChange, onChangeOverride, options]
168
+ );
169
+ const handleBlur = react.useCallback(
170
+ (e) => {
171
+ onBlur(id, e.target && e.target.value);
172
+ },
173
+ [onBlur, id]
174
+ );
175
+ const handleFocus = react.useCallback(
176
+ (e) => {
177
+ onFocus(id, e.target && e.target.value);
178
+ },
179
+ [onFocus, id]
180
+ );
181
+ const input = inputProps.type === "number" || inputProps.type === "integer" ? /* @__PURE__ */ jsxRuntime.jsx(
182
+ core.NumberInput,
183
+ {
184
+ id,
185
+ name: id,
186
+ label: utils.labelValue(label || void 0, hideLabel, false),
187
+ required,
188
+ autoFocus: autofocus,
189
+ disabled: disabled || readonly,
190
+ onBlur: !readonly ? handleBlur : void 0,
191
+ onChange: !readonly ? handleNumberChange : void 0,
192
+ onFocus: !readonly ? handleFocus : void 0,
193
+ placeholder,
194
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
195
+ list: schema.examples ? utils.examplesId(id) : void 0,
196
+ ...inputProps,
197
+ ...themeProps,
198
+ step: typeof inputProps.step === "number" ? inputProps.step : 1,
199
+ type: "text",
200
+ value,
201
+ "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
202
+ }
203
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
204
+ core.TextInput,
205
+ {
206
+ id,
207
+ name: id,
208
+ label: utils.labelValue(label || void 0, hideLabel, false),
209
+ required,
210
+ autoFocus: autofocus,
211
+ disabled: disabled || readonly,
212
+ onBlur: !readonly ? handleBlur : void 0,
213
+ onChange: !readonly ? handleChange : void 0,
214
+ onFocus: !readonly ? handleFocus : void 0,
215
+ placeholder,
216
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
217
+ list: schema.examples ? utils.examplesId(id) : void 0,
218
+ ...inputProps,
219
+ ...themeProps,
220
+ value,
221
+ "aria-describedby": utils.ariaDescribedByIds(id, !!schema.examples)
222
+ }
223
+ );
224
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
225
+ input,
226
+ children,
227
+ 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) => {
228
+ return /* @__PURE__ */ jsxRuntime.jsx("option", { value: example }, example);
229
+ }) })
230
+ ] });
231
+ }
232
+ function DescriptionField(props) {
233
+ const { id, description, registry, uiSchema } = props;
234
+ if (description) {
235
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Text, { id, mt: 3, mb: "sm", children: /* @__PURE__ */ jsxRuntime.jsx(core$1.RichDescription, { description, registry, uiSchema }) });
236
+ }
237
+ return null;
238
+ }
239
+ function Plus({ size, style, ...others }) {
240
+ return /* @__PURE__ */ jsxRuntime.jsxs(
241
+ "svg",
242
+ {
243
+ xmlns: "http://www.w3.org/2000/svg",
244
+ width: "24",
245
+ height: "24",
246
+ viewBox: "0 0 24 24",
247
+ fill: "none",
248
+ stroke: "currentColor",
249
+ strokeWidth: "2",
250
+ strokeLinecap: "round",
251
+ strokeLinejoin: "round",
252
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-plus",
253
+ style: { width: size, height: size, ...style },
254
+ ...others,
255
+ children: [
256
+ /* @__PURE__ */ jsxRuntime.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
257
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 5l0 14" }),
258
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M5 12l14 0" })
259
+ ]
260
+ }
261
+ );
262
+ }
263
+ function Copy({ size, style, ...others }) {
264
+ return /* @__PURE__ */ jsxRuntime.jsxs(
265
+ "svg",
266
+ {
267
+ xmlns: "http://www.w3.org/2000/svg",
268
+ width: "24",
269
+ height: "24",
270
+ viewBox: "0 0 24 24",
271
+ fill: "none",
272
+ stroke: "currentColor",
273
+ strokeWidth: "2",
274
+ strokeLinecap: "round",
275
+ strokeLinejoin: "round",
276
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-copy",
277
+ style: { width: size, height: size, ...style },
278
+ ...others,
279
+ children: [
280
+ /* @__PURE__ */ jsxRuntime.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
281
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" }),
282
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" })
283
+ ]
284
+ }
285
+ );
286
+ }
287
+ function ChevronDown({ size, style, ...others }) {
288
+ return /* @__PURE__ */ jsxRuntime.jsxs(
289
+ "svg",
290
+ {
291
+ xmlns: "http://www.w3.org/2000/svg",
292
+ width: "24",
293
+ height: "24",
294
+ viewBox: "0 0 24 24",
295
+ fill: "none",
296
+ stroke: "currentColor",
297
+ strokeWidth: "2",
298
+ strokeLinecap: "round",
299
+ strokeLinejoin: "round",
300
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-chevron-down",
301
+ style: { width: size, height: size, ...style },
302
+ ...others,
303
+ children: [
304
+ /* @__PURE__ */ jsxRuntime.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
305
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 9l6 6l6 -6" })
306
+ ]
307
+ }
308
+ );
309
+ }
310
+ function ChevronUp({ size, style, ...others }) {
311
+ return /* @__PURE__ */ jsxRuntime.jsxs(
312
+ "svg",
313
+ {
314
+ xmlns: "http://www.w3.org/2000/svg",
315
+ width: "24",
316
+ height: "24",
317
+ viewBox: "0 0 24 24",
318
+ fill: "none",
319
+ stroke: "currentColor",
320
+ strokeWidth: "2",
321
+ strokeLinecap: "round",
322
+ strokeLinejoin: "round",
323
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-chevron-up",
324
+ style: { width: size, height: size, ...style },
325
+ ...others,
326
+ children: [
327
+ /* @__PURE__ */ jsxRuntime.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
328
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 15l6 -6l6 6" })
329
+ ]
330
+ }
331
+ );
332
+ }
333
+ function X({ size, style, ...others }) {
334
+ return /* @__PURE__ */ jsxRuntime.jsxs(
335
+ "svg",
336
+ {
337
+ xmlns: "http://www.w3.org/2000/svg",
338
+ width: "24",
339
+ height: "24",
340
+ viewBox: "0 0 24 24",
341
+ fill: "none",
342
+ stroke: "currentColor",
343
+ strokeWidth: "2",
344
+ strokeLinecap: "round",
345
+ strokeLinejoin: "round",
346
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-x",
347
+ style: { width: size, height: size, ...style },
348
+ ...others,
349
+ children: [
350
+ /* @__PURE__ */ jsxRuntime.jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }),
351
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 6l-12 12" }),
352
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M6 6l12 12" })
353
+ ]
354
+ }
355
+ );
356
+ }
357
+ function ExclamationCircle({ size, style, ...others }) {
358
+ return /* @__PURE__ */ jsxRuntime.jsxs(
359
+ "svg",
360
+ {
361
+ xmlns: "http://www.w3.org/2000/svg",
362
+ width: "24",
363
+ height: "24",
364
+ viewBox: "0 0 24 24",
365
+ fill: "none",
366
+ stroke: "currentColor",
367
+ strokeWidth: "2",
368
+ strokeLinecap: "round",
369
+ strokeLinejoin: "round",
370
+ className: "icon icon-tabler icons-tabler-outline icon-tabler-exclamation-circle",
371
+ style: { width: size, height: size, ...style },
372
+ ...others,
373
+ children: [
374
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 12m-9 0a9 9 0 1 0 18 0a9 9 0 1 0 -18 0" }),
375
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 9v4" }),
376
+ /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 16v.01" })
377
+ ]
378
+ }
379
+ );
380
+ }
381
+ function ErrorList({
382
+ errors,
383
+ registry
384
+ }) {
385
+ const { translateString } = registry;
386
+ return /* @__PURE__ */ jsxRuntime.jsx(
387
+ core.Alert,
388
+ {
389
+ color: "red",
390
+ variant: "transparent",
391
+ title: /* @__PURE__ */ jsxRuntime.jsx(core.Title, { order: 5, fw: "normal", children: translateString(utils.TranslatableString.ErrorsLabel) }),
392
+ icon: /* @__PURE__ */ jsxRuntime.jsx(ExclamationCircle, {}),
393
+ children: /* @__PURE__ */ jsxRuntime.jsx(core.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.List.Item, { c: "red", children: error.stack }, `error-${index}`)) })
394
+ }
395
+ );
396
+ }
397
+ function SubmitButton({ uiSchema }) {
398
+ const { submitText, norender, props: submitButtonProps = {} } = utils.getSubmitButtonOptions(uiSchema);
399
+ if (norender) {
400
+ return null;
401
+ }
402
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Button, { type: "submit", variant: "filled", ...submitButtonProps, children: submitText });
403
+ }
404
+ function IconButton(props) {
405
+ const { icon, iconType = "sm", color, onClick, uiSchema, registry, ...otherProps } = props;
406
+ return /* @__PURE__ */ jsxRuntime.jsx(
407
+ core.ActionIcon,
408
+ {
409
+ size: iconType,
410
+ color,
411
+ onClick,
412
+ ...otherProps,
413
+ children: icon
414
+ }
415
+ );
416
+ }
417
+ function CopyButton(props) {
418
+ const {
419
+ registry: { translateString }
420
+ } = props;
421
+ return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.CopyButton), variant: "subtle", ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(Copy, {}) });
422
+ }
423
+ function MoveDownButton(props) {
424
+ const {
425
+ registry: { translateString }
426
+ } = props;
427
+ return /* @__PURE__ */ jsxRuntime.jsx(
428
+ IconButton,
429
+ {
430
+ title: translateString(utils.TranslatableString.MoveDownButton),
431
+ variant: "subtle",
432
+ ...props,
433
+ icon: /* @__PURE__ */ jsxRuntime.jsx(ChevronDown, {})
434
+ }
435
+ );
436
+ }
437
+ function MoveUpButton(props) {
438
+ const {
439
+ registry: { translateString }
440
+ } = props;
441
+ return /* @__PURE__ */ jsxRuntime.jsx(
442
+ IconButton,
443
+ {
444
+ title: translateString(utils.TranslatableString.MoveUpButton),
445
+ variant: "subtle",
446
+ ...props,
447
+ icon: /* @__PURE__ */ jsxRuntime.jsx(ChevronUp, {})
448
+ }
449
+ );
450
+ }
451
+ function RemoveButton(props) {
452
+ const {
453
+ registry: { translateString }
454
+ } = props;
455
+ return /* @__PURE__ */ jsxRuntime.jsx(
456
+ IconButton,
457
+ {
458
+ title: translateString(utils.TranslatableString.RemoveButton),
459
+ variant: "subtle",
460
+ color: "red",
461
+ ...props,
462
+ icon: /* @__PURE__ */ jsxRuntime.jsx(X, {})
463
+ }
464
+ );
465
+ }
466
+ function AddButton(props) {
467
+ const {
468
+ registry: { translateString }
469
+ } = props;
470
+ return /* @__PURE__ */ jsxRuntime.jsx(IconButton, { title: translateString(utils.TranslatableString.AddItemButton), variant: "subtle", ...props, icon: /* @__PURE__ */ jsxRuntime.jsx(Plus, {}) });
471
+ }
472
+
473
+ // src/templates/ButtonTemplates/index.ts
474
+ function buttonTemplates() {
475
+ return {
476
+ SubmitButton,
477
+ AddButton,
478
+ CopyButton,
479
+ MoveDownButton,
480
+ MoveUpButton,
481
+ RemoveButton
482
+ };
483
+ }
484
+ var ButtonTemplates_default = buttonTemplates;
485
+ function FieldErrorTemplate({ errors, idSchema }) {
486
+ if (!errors || !errors.length) {
487
+ return null;
488
+ }
489
+ const id = utils.errorId(idSchema);
490
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { id, c: "red", display: "none", children: /* @__PURE__ */ jsxRuntime.jsx(core.List, { children: errors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.List.Item, { children: error }, `field-error-${index}`)) }) });
491
+ }
492
+ function FieldTemplate(props) {
493
+ const {
494
+ id,
495
+ classNames,
496
+ style,
497
+ label,
498
+ errors,
499
+ help,
500
+ displayLabel,
501
+ description,
502
+ rawDescription,
503
+ hidden,
504
+ schema,
505
+ uiSchema,
506
+ registry,
507
+ children,
508
+ ...otherProps
509
+ } = props;
510
+ const uiOptions = utils.getUiOptions(uiSchema);
511
+ const WrapIfAdditionalTemplate2 = utils.getTemplate(
512
+ "WrapIfAdditionalTemplate",
513
+ registry,
514
+ uiOptions
515
+ );
516
+ if (hidden) {
517
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { display: "none", children });
518
+ }
519
+ return /* @__PURE__ */ jsxRuntime.jsxs(
520
+ WrapIfAdditionalTemplate2,
521
+ {
522
+ id,
523
+ classNames,
524
+ style,
525
+ label,
526
+ schema,
527
+ uiSchema,
528
+ registry,
529
+ ...otherProps,
530
+ children: [
531
+ children,
532
+ errors,
533
+ help
534
+ ]
535
+ }
536
+ );
537
+ }
538
+ function FieldHelpTemplate(props) {
539
+ const { idSchema, help } = props;
540
+ const id = utils.helpId(idSchema);
541
+ return !help ? null : /* @__PURE__ */ jsxRuntime.jsx(core.Text, { id, size: "sm", my: "xs", c: "dimmed", children: help });
542
+ }
543
+ function GridTemplate(props) {
544
+ const { children, column, fluid = true, ...rest } = props;
545
+ if (column) {
546
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { ...rest, children });
547
+ }
548
+ if (fluid) {
549
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Container, { p: "4", mx: 0, w: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(core.Grid, { ...rest, children }) });
550
+ }
551
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Grid, { grow: true, ...rest, children });
552
+ }
553
+ function ObjectFieldTemplate(props) {
554
+ const {
555
+ title,
556
+ description,
557
+ disabled,
558
+ properties,
559
+ onAddClick,
560
+ readonly,
561
+ required,
562
+ schema,
563
+ uiSchema,
564
+ idSchema,
565
+ formData,
566
+ registry
567
+ } = props;
568
+ const uiOptions = utils.getUiOptions(uiSchema);
569
+ const TitleFieldTemplate = utils.getTemplate("TitleFieldTemplate", registry, uiOptions);
570
+ const DescriptionFieldTemplate = utils.getTemplate(
571
+ "DescriptionFieldTemplate",
572
+ registry,
573
+ uiOptions
574
+ );
575
+ const {
576
+ ButtonTemplates: { AddButton: AddButton2 }
577
+ } = registry.templates;
578
+ const gridCols = typeof uiOptions?.gridCols === "number" && uiOptions?.gridCols || void 0;
579
+ const gridSpacing = uiOptions?.gridSpacing;
580
+ const gridVerticalSpacing = uiOptions?.gridVerticalSpacing;
581
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Container, { id: idSchema.$id, p: 0, children: [
582
+ title && /* @__PURE__ */ jsxRuntime.jsx(
583
+ TitleFieldTemplate,
584
+ {
585
+ id: utils.titleId(idSchema),
586
+ title,
587
+ required,
588
+ schema,
589
+ uiSchema,
590
+ registry
591
+ }
592
+ ),
593
+ description && /* @__PURE__ */ jsxRuntime.jsx(
594
+ DescriptionFieldTemplate,
595
+ {
596
+ id: utils.descriptionId(idSchema),
597
+ description,
598
+ schema,
599
+ uiSchema,
600
+ registry
601
+ }
602
+ ),
603
+ /* @__PURE__ */ jsxRuntime.jsx(
604
+ core.SimpleGrid,
605
+ {
606
+ cols: gridCols,
607
+ spacing: gridSpacing,
608
+ verticalSpacing: gridVerticalSpacing,
609
+ mb: "sm",
610
+ children: properties.filter((e) => !e.hidden).map((element) => /* @__PURE__ */ jsxRuntime.jsx(core.Box, { children: element.content }, element.name))
611
+ }
612
+ ),
613
+ utils.canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsxRuntime.jsx(core.Group, { mt: "xs", justify: "flex-end", children: /* @__PURE__ */ jsxRuntime.jsx(
614
+ AddButton2,
615
+ {
616
+ id: utils.buttonId(idSchema, "add"),
617
+ disabled: disabled || readonly,
618
+ onClick: onAddClick(schema),
619
+ className: "rjsf-object-property-expand",
620
+ uiSchema,
621
+ registry
622
+ }
623
+ ) })
624
+ ] });
625
+ }
626
+ function TitleField(props) {
627
+ const { id, title } = props;
628
+ return title ? /* @__PURE__ */ jsxRuntime.jsx(core.Title, { id, order: 3, fw: "normal", children: title }) : null;
629
+ }
630
+ function WrapIfAdditionalTemplate(props) {
631
+ const {
632
+ id,
633
+ classNames,
634
+ style,
635
+ label,
636
+ required,
637
+ readonly,
638
+ disabled,
639
+ schema,
640
+ uiSchema,
641
+ onKeyChange,
642
+ onDropPropertyClick,
643
+ registry,
644
+ children
645
+ } = props;
646
+ const { templates, translateString } = registry;
647
+ const { RemoveButton: RemoveButton2 } = templates.ButtonTemplates;
648
+ const keyLabel = translateString(utils.TranslatableString.KeyLabel, [label]);
649
+ const additional = utils.ADDITIONAL_PROPERTY_FLAG in schema;
650
+ const handleBlur = react.useCallback(
651
+ ({ target }) => onKeyChange(target && target.value),
652
+ [onKeyChange]
653
+ );
654
+ if (!additional) {
655
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children });
656
+ }
657
+ const uiOptions = uiSchema ? uiSchema[utils.UI_OPTIONS_KEY] : {};
658
+ const buttonUiOptions = {
659
+ ...uiSchema,
660
+ [utils.UI_OPTIONS_KEY]: { ...uiOptions, block: true }
661
+ };
662
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classNames, style, children: /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "end", justify: "center", children: [
663
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Grid, { w: "100%", align: "center", children: [
664
+ /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: 6, className: "form-additional", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "form-group", children: /* @__PURE__ */ jsxRuntime.jsx(
665
+ core.TextInput,
666
+ {
667
+ className: "form-group",
668
+ label: keyLabel,
669
+ defaultValue: label,
670
+ required,
671
+ disabled: disabled || readonly,
672
+ id: `${id}-key`,
673
+ name: `${id}-key`,
674
+ onBlur: !readonly ? handleBlur : void 0
675
+ }
676
+ ) }) }),
677
+ /* @__PURE__ */ jsxRuntime.jsx(core.Grid.Col, { span: 6, className: "form-additional", children })
678
+ ] }),
679
+ /* @__PURE__ */ jsxRuntime.jsx(
680
+ RemoveButton2,
681
+ {
682
+ id: utils.buttonId(id, "remove"),
683
+ iconType: "sm",
684
+ className: "rjsf-array-item-remove",
685
+ disabled: disabled || readonly,
686
+ onClick: onDropPropertyClick(label),
687
+ uiSchema: buttonUiOptions,
688
+ registry
689
+ }
690
+ )
691
+ ] }) });
692
+ }
693
+ function MultiSchemaFieldTemplate({ selector, optionSchemaField }) {
694
+ return /* @__PURE__ */ jsxRuntime.jsxs(core.Stack, { style: { marginBottom: "1rem" }, children: [
695
+ selector,
696
+ optionSchemaField
697
+ ] });
698
+ }
699
+
700
+ // src/templates/index.ts
701
+ function generateTemplates() {
702
+ return {
703
+ ArrayFieldItemTemplate,
704
+ ArrayFieldTemplate,
705
+ ArrayFieldTitleTemplate,
706
+ BaseInputTemplate,
707
+ ButtonTemplates: ButtonTemplates_default(),
708
+ DescriptionFieldTemplate: DescriptionField,
709
+ ErrorListTemplate: ErrorList,
710
+ FieldErrorTemplate,
711
+ FieldTemplate,
712
+ FieldHelpTemplate,
713
+ GridTemplate,
714
+ ObjectFieldTemplate,
715
+ TitleFieldTemplate: TitleField,
716
+ WrapIfAdditionalTemplate,
717
+ MultiSchemaFieldTemplate
718
+ };
719
+ }
720
+ var templates_default = generateTemplates();
721
+ function readyForChange(state) {
722
+ return Object.values(state).every((value) => value !== -1);
723
+ }
724
+ function AltDateWidget(props) {
725
+ const {
726
+ id,
727
+ value,
728
+ required,
729
+ disabled,
730
+ readonly,
731
+ label,
732
+ hideLabel,
733
+ rawErrors,
734
+ options,
735
+ onChange,
736
+ showTime = false,
737
+ registry
738
+ } = props;
739
+ const { translateString } = registry;
740
+ const [state, setState] = react.useState(utils.parseDateString(value, showTime));
741
+ react.useEffect(() => {
742
+ setState(utils.parseDateString(value, showTime));
743
+ }, [showTime, value]);
744
+ const handleChange = react.useCallback(
745
+ (property, nextValue) => {
746
+ const nextState = {
747
+ ...state,
748
+ [property]: typeof nextValue === "undefined" ? -1 : nextValue
749
+ };
750
+ if (readyForChange(nextState)) {
751
+ onChange(utils.toDateString(nextState, showTime));
752
+ } else {
753
+ setState(nextState);
754
+ }
755
+ },
756
+ [state, onChange, showTime]
757
+ );
758
+ const handleSetNow = react.useCallback(() => {
759
+ if (!disabled && !readonly) {
760
+ const nextState = utils.parseDateString((/* @__PURE__ */ new Date()).toJSON(), showTime);
761
+ onChange(utils.toDateString(nextState, showTime));
762
+ }
763
+ }, [disabled, readonly, showTime, onChange]);
764
+ const handleClear = react.useCallback(() => {
765
+ if (!disabled && !readonly) {
766
+ onChange("");
767
+ }
768
+ }, [disabled, readonly, onChange]);
769
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
770
+ !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
771
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", align: "center", wrap: "nowrap", children: [
772
+ utils.getDateElementProps(
773
+ state,
774
+ showTime,
775
+ options.yearsRange,
776
+ options.format
777
+ ).map((elemProps, i) => {
778
+ const elemId = id + "_" + elemProps.type;
779
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Box, { children: /* @__PURE__ */ jsxRuntime.jsx(
780
+ core.Select,
781
+ {
782
+ id: elemId,
783
+ name: elemId,
784
+ placeholder: elemProps.type,
785
+ disabled: disabled || readonly,
786
+ data: utils.dateRangeOptions(elemProps.range[0], elemProps.range[1]).map((item) => item.value.toString()),
787
+ value: !elemProps.value || elemProps.value < 0 ? null : elemProps.value.toString(),
788
+ onChange: (v) => handleChange(elemProps.type, v),
789
+ searchable: false,
790
+ allowDeselect: false,
791
+ comboboxProps: { withinPortal: false },
792
+ "aria-describedby": utils.ariaDescribedByIds(elemId)
793
+ }
794
+ ) }, i);
795
+ }),
796
+ /* @__PURE__ */ jsxRuntime.jsxs(core.Group, { wrap: "nowrap", gap: 3, children: [
797
+ (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core.Button, { variant: "subtle", size: "xs", onClick: handleSetNow, children: translateString(utils.TranslatableString.NowLabel) }),
798
+ (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsxRuntime.jsx(core.Button, { variant: "subtle", size: "xs", onClick: handleClear, children: translateString(utils.TranslatableString.ClearLabel) })
799
+ ] })
800
+ ] }),
801
+ rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Input.Error, { children: error }, `alt-date-widget-input-errors-${index}`))
802
+ ] });
803
+ }
804
+ AltDateWidget.defaultProps = {
805
+ showTime: false
806
+ };
807
+ function AltDateTimeWidget(props) {
808
+ const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
809
+ return /* @__PURE__ */ jsxRuntime.jsx(AltDateWidget2, { showTime: true, ...props });
810
+ }
811
+ AltDateTimeWidget.defaultProps = {
812
+ ...AltDateWidget?.defaultProps,
813
+ showTime: true
814
+ };
815
+ var dateParser = (input, format) => {
816
+ if (!input) {
817
+ return null;
818
+ }
819
+ const d = dayjs(input, format);
820
+ return d.isValid() ? d.toDate() : null;
821
+ };
822
+ var dateFormat = (date, format) => {
823
+ if (!date) {
824
+ return "";
825
+ }
826
+ return dayjs(date).format(format || "YYYY-MM-DD");
827
+ };
828
+ function DateTimeInput(props) {
829
+ const {
830
+ id,
831
+ name,
832
+ value,
833
+ placeholder,
834
+ required,
835
+ disabled,
836
+ readonly,
837
+ autofocus,
838
+ label,
839
+ hideLabel,
840
+ rawErrors,
841
+ options,
842
+ onChange,
843
+ onBlur,
844
+ onFocus,
845
+ valueFormat,
846
+ displayFormat
847
+ } = props;
848
+ const handleChange = react.useCallback(
849
+ (nextValue) => {
850
+ onChange(dateFormat(nextValue, valueFormat));
851
+ },
852
+ [onChange, valueFormat]
853
+ );
854
+ const handleBlur = react.useCallback(() => {
855
+ if (onBlur) {
856
+ onBlur(id, value);
857
+ }
858
+ }, [onBlur, id, value]);
859
+ const handleFocus = react.useCallback(() => {
860
+ if (onFocus) {
861
+ onFocus(id, value);
862
+ }
863
+ }, [onFocus, id, value]);
864
+ return /* @__PURE__ */ jsxRuntime.jsx(
865
+ dates.DateInput,
866
+ {
867
+ id,
868
+ name,
869
+ value: dateParser(value, valueFormat),
870
+ dateParser: (v) => dateParser(v, displayFormat),
871
+ placeholder: placeholder || void 0,
872
+ required,
873
+ disabled: disabled || readonly,
874
+ autoFocus: autofocus,
875
+ label: utils.labelValue(label || void 0, hideLabel, false),
876
+ onChange: handleChange,
877
+ onBlur: handleBlur,
878
+ onFocus: handleFocus,
879
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
880
+ ...options,
881
+ "aria-describedby": utils.ariaDescribedByIds(id),
882
+ popoverProps: { withinPortal: false },
883
+ classNames: typeof options?.classNames === "object" ? options.classNames : void 0,
884
+ valueFormat: displayFormat
885
+ }
886
+ );
887
+ }
888
+ function DateWidget(props) {
889
+ const { valueFormat = "YYYY-MM-DD", displayFormat, ...otherOptions } = props.options;
890
+ return /* @__PURE__ */ jsxRuntime.jsx(
891
+ DateTimeInput,
892
+ {
893
+ ...props,
894
+ options: otherOptions,
895
+ valueFormat,
896
+ displayFormat: displayFormat || valueFormat
897
+ }
898
+ );
899
+ }
900
+ function DateTimeWidget(props) {
901
+ const { valueFormat = "YYYY-MM-DD HH:mm:ss", displayFormat, ...otherOptions } = props.options;
902
+ return /* @__PURE__ */ jsxRuntime.jsx(
903
+ DateTimeInput,
904
+ {
905
+ ...props,
906
+ options: otherOptions,
907
+ valueFormat,
908
+ displayFormat: displayFormat || valueFormat
909
+ }
910
+ );
911
+ }
912
+ function TimeWidget(props) {
913
+ const {
914
+ id,
915
+ name,
916
+ value,
917
+ placeholder,
918
+ required,
919
+ disabled,
920
+ readonly,
921
+ autofocus,
922
+ label,
923
+ hideLabel,
924
+ rawErrors,
925
+ options,
926
+ onChange,
927
+ onBlur,
928
+ onFocus
929
+ } = props;
930
+ const emptyValue = options.emptyValue || "";
931
+ const handleChange = react.useCallback(
932
+ (e) => {
933
+ onChange(e.target.value === "" ? emptyValue : e.target.value);
934
+ },
935
+ [onChange, emptyValue]
936
+ );
937
+ const handleBlur = react.useCallback(
938
+ ({ target }) => {
939
+ if (onBlur) {
940
+ onBlur(id, target && target.value);
941
+ }
942
+ },
943
+ [onBlur, id]
944
+ );
945
+ const handleFocus = react.useCallback(
946
+ ({ target }) => {
947
+ if (onFocus) {
948
+ onFocus(id, target && target.value);
949
+ }
950
+ },
951
+ [onFocus, id]
952
+ );
953
+ return /* @__PURE__ */ jsxRuntime.jsx(
954
+ dates.TimeInput,
955
+ {
956
+ id,
957
+ name,
958
+ value: value || "",
959
+ placeholder: placeholder || void 0,
960
+ required,
961
+ disabled: disabled || readonly,
962
+ autoFocus: autofocus,
963
+ label: utils.labelValue(label || void 0, hideLabel, false),
964
+ onChange: handleChange,
965
+ onBlur: handleBlur,
966
+ onFocus: handleFocus,
967
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
968
+ ...options,
969
+ "aria-describedby": utils.ariaDescribedByIds(id),
970
+ classNames: typeof options?.classNames === "object" ? options.classNames : void 0
971
+ }
972
+ );
973
+ }
974
+ function CheckboxesWidget(props) {
975
+ const {
976
+ id,
977
+ value,
978
+ required,
979
+ disabled,
980
+ readonly,
981
+ autofocus,
982
+ label,
983
+ hideLabel,
984
+ rawErrors,
985
+ options,
986
+ onChange,
987
+ onBlur,
988
+ onFocus
989
+ } = props;
990
+ const { enumOptions, enumDisabled, inline, emptyValue } = options;
991
+ const themeProps = cleanupOptions(options);
992
+ const handleChange = react.useCallback(
993
+ (nextValue) => {
994
+ if (!disabled && !readonly && onChange) {
995
+ onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
996
+ }
997
+ },
998
+ [onChange, disabled, readonly, enumOptions, emptyValue]
999
+ );
1000
+ const handleBlur = react.useCallback(
1001
+ ({ target }) => {
1002
+ if (onBlur) {
1003
+ onBlur(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
1004
+ }
1005
+ },
1006
+ [onBlur, id, enumOptions, emptyValue]
1007
+ );
1008
+ const handleFocus = react.useCallback(
1009
+ ({ target }) => {
1010
+ if (onFocus) {
1011
+ onFocus(id, utils.enumOptionsValueForIndex(target.value, enumOptions, emptyValue));
1012
+ }
1013
+ },
1014
+ [onFocus, id, enumOptions, emptyValue]
1015
+ );
1016
+ const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, true);
1017
+ return Array.isArray(enumOptions) && enumOptions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1018
+ !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
1019
+ /* @__PURE__ */ jsxRuntime.jsx(
1020
+ core.Checkbox.Group,
1021
+ {
1022
+ id,
1023
+ value: selectedIndexes,
1024
+ onChange: handleChange,
1025
+ required,
1026
+ readOnly: disabled || readonly,
1027
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1028
+ "aria-describedby": utils.ariaDescribedByIds(id),
1029
+ ...themeProps,
1030
+ children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
1031
+ core.Checkbox,
1032
+ {
1033
+ id: utils.optionId(id, i),
1034
+ name: id,
1035
+ value: String(i),
1036
+ label: option.label,
1037
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
1038
+ autoFocus: i === 0 && autofocus,
1039
+ onBlur: handleBlur,
1040
+ onFocus: handleFocus
1041
+ },
1042
+ i
1043
+ )) }) : null
1044
+ }
1045
+ )
1046
+ ] }) : null;
1047
+ }
1048
+ function CheckboxWidget(props) {
1049
+ const {
1050
+ id,
1051
+ name,
1052
+ value = false,
1053
+ required,
1054
+ disabled,
1055
+ readonly,
1056
+ autofocus,
1057
+ label,
1058
+ hideLabel,
1059
+ schema,
1060
+ rawErrors,
1061
+ options,
1062
+ onChange,
1063
+ onBlur,
1064
+ onFocus,
1065
+ registry,
1066
+ uiSchema
1067
+ } = props;
1068
+ const themeProps = cleanupOptions(options);
1069
+ const DescriptionFieldTemplate = utils.getTemplate(
1070
+ "DescriptionFieldTemplate",
1071
+ registry,
1072
+ options
1073
+ );
1074
+ const handleCheckboxChange = react.useCallback(
1075
+ (e) => {
1076
+ if (!disabled && !readonly && onChange) {
1077
+ onChange(e.currentTarget.checked);
1078
+ }
1079
+ },
1080
+ [onChange, disabled, readonly]
1081
+ );
1082
+ const handleBlur = react.useCallback(
1083
+ ({ target }) => {
1084
+ if (onBlur) {
1085
+ onBlur(id, target.checked);
1086
+ }
1087
+ },
1088
+ [onBlur, id]
1089
+ );
1090
+ const handleFocus = react.useCallback(
1091
+ ({ target }) => {
1092
+ if (onFocus) {
1093
+ onFocus(id, target.checked);
1094
+ }
1095
+ },
1096
+ [onFocus, id]
1097
+ );
1098
+ const description = options.description || schema.description;
1099
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1100
+ !hideLabel && !!description && /* @__PURE__ */ jsxRuntime.jsx(
1101
+ DescriptionFieldTemplate,
1102
+ {
1103
+ id: utils.descriptionId(id),
1104
+ description,
1105
+ schema,
1106
+ uiSchema,
1107
+ registry
1108
+ }
1109
+ ),
1110
+ /* @__PURE__ */ jsxRuntime.jsx(
1111
+ core.Checkbox,
1112
+ {
1113
+ id,
1114
+ name,
1115
+ label: utils.labelValue(label || void 0, hideLabel, false),
1116
+ disabled: disabled || readonly,
1117
+ required,
1118
+ autoFocus: autofocus,
1119
+ checked: typeof value === "undefined" ? false : value === "true" || value,
1120
+ onChange: handleCheckboxChange,
1121
+ onBlur: handleBlur,
1122
+ onFocus: handleFocus,
1123
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1124
+ "aria-describedby": utils.ariaDescribedByIds(id),
1125
+ ...themeProps
1126
+ }
1127
+ )
1128
+ ] });
1129
+ }
1130
+ function ColorWidget(props) {
1131
+ const {
1132
+ id,
1133
+ name,
1134
+ value,
1135
+ placeholder,
1136
+ required,
1137
+ disabled,
1138
+ readonly,
1139
+ autofocus,
1140
+ label,
1141
+ hideLabel,
1142
+ rawErrors,
1143
+ options,
1144
+ onChange,
1145
+ onBlur,
1146
+ onFocus
1147
+ } = props;
1148
+ const themeProps = cleanupOptions(options);
1149
+ const handleChange = react.useCallback(
1150
+ (nextValue) => {
1151
+ onChange(nextValue);
1152
+ },
1153
+ [onChange]
1154
+ );
1155
+ const handleBlur = react.useCallback(
1156
+ ({ target }) => {
1157
+ if (onBlur) {
1158
+ onBlur(id, target && target.value);
1159
+ }
1160
+ },
1161
+ [onBlur, id]
1162
+ );
1163
+ const handleFocus = react.useCallback(
1164
+ ({ target }) => {
1165
+ if (onFocus) {
1166
+ onFocus(id, target && target.value);
1167
+ }
1168
+ },
1169
+ [onFocus, id]
1170
+ );
1171
+ return /* @__PURE__ */ jsxRuntime.jsx(
1172
+ core.ColorInput,
1173
+ {
1174
+ id,
1175
+ name,
1176
+ value: value || "",
1177
+ placeholder: placeholder || void 0,
1178
+ required,
1179
+ disabled: disabled || readonly,
1180
+ autoFocus: autofocus,
1181
+ label: utils.labelValue(label || void 0, hideLabel, false),
1182
+ onChange: handleChange,
1183
+ onBlur: handleBlur,
1184
+ onFocus: handleFocus,
1185
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1186
+ ...themeProps,
1187
+ "aria-describedby": utils.ariaDescribedByIds(id),
1188
+ popoverProps: { withinPortal: false }
1189
+ }
1190
+ );
1191
+ }
1192
+ function addNameToDataURL(dataURL, name) {
1193
+ if (dataURL === null) {
1194
+ return null;
1195
+ }
1196
+ return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
1197
+ }
1198
+ function processFile(file) {
1199
+ const { name, size, type } = file;
1200
+ return new Promise((resolve, reject) => {
1201
+ const reader = new window.FileReader();
1202
+ reader.onerror = reject;
1203
+ reader.onload = (event) => {
1204
+ if (typeof event.target?.result === "string") {
1205
+ resolve({
1206
+ dataURL: addNameToDataURL(event.target.result, name),
1207
+ name,
1208
+ size,
1209
+ type
1210
+ });
1211
+ } else {
1212
+ resolve({
1213
+ dataURL: null,
1214
+ name,
1215
+ size,
1216
+ type
1217
+ });
1218
+ }
1219
+ };
1220
+ reader.readAsDataURL(file);
1221
+ });
1222
+ }
1223
+ function processFiles(files) {
1224
+ return Promise.all(Array.from(files).map(processFile));
1225
+ }
1226
+ function extractFileInfo(dataURLs) {
1227
+ return dataURLs.reduce((acc, dataURL) => {
1228
+ if (!dataURL) {
1229
+ return acc;
1230
+ }
1231
+ try {
1232
+ const { blob, name } = utils.dataURItoBlob(dataURL);
1233
+ return [
1234
+ ...acc,
1235
+ {
1236
+ dataURL,
1237
+ name,
1238
+ size: blob.size,
1239
+ type: blob.type
1240
+ }
1241
+ ];
1242
+ } catch (e) {
1243
+ console.log(e);
1244
+ return acc;
1245
+ }
1246
+ }, []);
1247
+ }
1248
+ function FileWidget(props) {
1249
+ const {
1250
+ id,
1251
+ name,
1252
+ value,
1253
+ placeholder,
1254
+ required,
1255
+ disabled,
1256
+ readonly,
1257
+ autofocus,
1258
+ label,
1259
+ hideLabel,
1260
+ rawErrors,
1261
+ options,
1262
+ multiple,
1263
+ onChange
1264
+ } = props;
1265
+ const themeProps = cleanupOptions(options);
1266
+ const handleChange = react.useCallback(
1267
+ (files) => {
1268
+ if (typeof files === "object") {
1269
+ processFiles(multiple ? files : [files]).then((filesInfoEvent) => {
1270
+ const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
1271
+ if (multiple) {
1272
+ onChange(value.concat(newValue));
1273
+ } else {
1274
+ onChange(newValue[0]);
1275
+ }
1276
+ });
1277
+ }
1278
+ return;
1279
+ },
1280
+ [multiple, value, onChange]
1281
+ );
1282
+ const handleRemoveFile = react.useCallback(
1283
+ (index) => {
1284
+ if (multiple) {
1285
+ const newValue = value.filter((_, i) => i !== index);
1286
+ onChange(newValue);
1287
+ } else {
1288
+ onChange(void 0);
1289
+ }
1290
+ },
1291
+ [multiple, value, onChange]
1292
+ );
1293
+ const ValueComponent = react.useCallback(
1294
+ (props2) => {
1295
+ const filesInfo = props2.value ? extractFileInfo(Array.isArray(props2.value) ? props2.value : [props2.value]) : null;
1296
+ if (Array.isArray(filesInfo) && filesInfo.length > 0) {
1297
+ return /* @__PURE__ */ jsxRuntime.jsx(core.Pill.Group, { children: filesInfo.map((file, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Pill, { withRemoveButton: true, onRemove: () => handleRemoveFile(index), children: file.name }, index)) });
1298
+ }
1299
+ return null;
1300
+ },
1301
+ [handleRemoveFile]
1302
+ );
1303
+ return /* @__PURE__ */ jsxRuntime.jsx(
1304
+ core.FileInput,
1305
+ {
1306
+ id,
1307
+ name,
1308
+ value: value || "",
1309
+ placeholder: placeholder || void 0,
1310
+ required,
1311
+ disabled: disabled || readonly,
1312
+ autoFocus: autofocus,
1313
+ label: utils.labelValue(label || void 0, hideLabel, false),
1314
+ multiple: !!multiple,
1315
+ valueComponent: ValueComponent,
1316
+ onChange: handleChange,
1317
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1318
+ ...themeProps,
1319
+ "aria-describedby": utils.ariaDescribedByIds(id)
1320
+ }
1321
+ );
1322
+ }
1323
+ function PasswordWidget(props) {
1324
+ const {
1325
+ id,
1326
+ name,
1327
+ value,
1328
+ placeholder,
1329
+ required,
1330
+ disabled,
1331
+ readonly,
1332
+ autofocus,
1333
+ label,
1334
+ hideLabel,
1335
+ rawErrors,
1336
+ options,
1337
+ onChange,
1338
+ onBlur,
1339
+ onFocus
1340
+ } = props;
1341
+ const emptyValue = options.emptyValue || "";
1342
+ const themeProps = cleanupOptions(options);
1343
+ const handleChange = react.useCallback(
1344
+ (e) => {
1345
+ onChange(e.target.value === "" ? emptyValue : e.target.value);
1346
+ },
1347
+ [onChange, emptyValue]
1348
+ );
1349
+ const handleBlur = react.useCallback(
1350
+ ({ target }) => {
1351
+ if (onBlur) {
1352
+ onBlur(id, target && target.value);
1353
+ }
1354
+ },
1355
+ [onBlur, id]
1356
+ );
1357
+ const handleFocus = react.useCallback(
1358
+ ({ target }) => {
1359
+ if (onFocus) {
1360
+ onFocus(id, target && target.value);
1361
+ }
1362
+ },
1363
+ [onFocus, id]
1364
+ );
1365
+ return /* @__PURE__ */ jsxRuntime.jsx(
1366
+ core.PasswordInput,
1367
+ {
1368
+ id,
1369
+ name,
1370
+ value: value || "",
1371
+ placeholder: placeholder || void 0,
1372
+ required,
1373
+ disabled: disabled || readonly,
1374
+ autoFocus: autofocus,
1375
+ label: utils.labelValue(label || void 0, hideLabel, false),
1376
+ onChange: handleChange,
1377
+ onBlur: handleBlur,
1378
+ onFocus: handleFocus,
1379
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1380
+ ...themeProps,
1381
+ "aria-describedby": utils.ariaDescribedByIds(id)
1382
+ }
1383
+ );
1384
+ }
1385
+ function RadioWidget(props) {
1386
+ const {
1387
+ id,
1388
+ value,
1389
+ required,
1390
+ disabled,
1391
+ readonly,
1392
+ autofocus,
1393
+ label,
1394
+ hideLabel,
1395
+ rawErrors,
1396
+ options,
1397
+ onChange,
1398
+ onBlur,
1399
+ onFocus
1400
+ } = props;
1401
+ const { enumOptions, enumDisabled, inline, emptyValue } = options;
1402
+ const themeProps = cleanupOptions(options);
1403
+ const handleChange = react.useCallback(
1404
+ (nextValue) => {
1405
+ if (!disabled && !readonly && onChange) {
1406
+ onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
1407
+ }
1408
+ },
1409
+ [onChange, disabled, readonly, enumOptions, emptyValue]
1410
+ );
1411
+ const handleBlur = react.useCallback(
1412
+ ({ target }) => {
1413
+ if (onBlur) {
1414
+ onBlur(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
1415
+ }
1416
+ },
1417
+ [onBlur, id, enumOptions, emptyValue]
1418
+ );
1419
+ const handleFocus = react.useCallback(
1420
+ ({ target }) => {
1421
+ if (onFocus) {
1422
+ onFocus(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
1423
+ }
1424
+ },
1425
+ [onFocus, id, enumOptions, emptyValue]
1426
+ );
1427
+ const selected = utils.enumOptionsIndexForValue(value, enumOptions);
1428
+ return /* @__PURE__ */ jsxRuntime.jsx(
1429
+ core.Radio.Group,
1430
+ {
1431
+ id,
1432
+ name: id,
1433
+ value: selected,
1434
+ label: !hideLabel ? label : void 0,
1435
+ onChange: handleChange,
1436
+ required,
1437
+ readOnly: disabled || readonly,
1438
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1439
+ "aria-describedby": utils.ariaDescribedByIds(id),
1440
+ ...themeProps,
1441
+ children: Array.isArray(enumOptions) ? /* @__PURE__ */ jsxRuntime.jsx(core.Flex, { mt: "xs", direction: inline ? "row" : "column", gap: "xs", wrap: "wrap", children: enumOptions.map((option, i) => /* @__PURE__ */ jsxRuntime.jsx(
1442
+ core.Radio,
1443
+ {
1444
+ id: utils.optionId(id, i),
1445
+ value: String(i),
1446
+ label: option.label,
1447
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1,
1448
+ autoFocus: i === 0 && autofocus,
1449
+ onBlur: handleBlur,
1450
+ onFocus: handleFocus
1451
+ },
1452
+ i
1453
+ )) }) : null
1454
+ }
1455
+ );
1456
+ }
1457
+ function RangeWidget(props) {
1458
+ const {
1459
+ id,
1460
+ name,
1461
+ value,
1462
+ required,
1463
+ disabled,
1464
+ readonly,
1465
+ autofocus,
1466
+ label,
1467
+ hideLabel,
1468
+ rawErrors,
1469
+ options,
1470
+ onChange,
1471
+ onBlur,
1472
+ onFocus,
1473
+ schema
1474
+ } = props;
1475
+ const themeProps = cleanupOptions(options);
1476
+ const { min, max, step } = utils.rangeSpec(schema);
1477
+ const handleChange = react.useCallback(
1478
+ (nextValue) => {
1479
+ if (!disabled && !readonly && onChange) {
1480
+ onChange(nextValue);
1481
+ }
1482
+ },
1483
+ [onChange, disabled, readonly]
1484
+ );
1485
+ const handleBlur = react.useCallback(() => {
1486
+ if (onBlur) {
1487
+ onBlur(id, value);
1488
+ }
1489
+ }, [onBlur, id, value]);
1490
+ const handleFocus = react.useCallback(() => {
1491
+ if (onFocus) {
1492
+ onFocus(id, value);
1493
+ }
1494
+ }, [onFocus, id, value]);
1495
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1496
+ !hideLabel && !!label && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Label, { id: utils.titleId(id), required, children: label }),
1497
+ options?.description && /* @__PURE__ */ jsxRuntime.jsx(core.Input.Description, { children: options.description }),
1498
+ /* @__PURE__ */ jsxRuntime.jsx(
1499
+ core.Slider,
1500
+ {
1501
+ id,
1502
+ name,
1503
+ value,
1504
+ max,
1505
+ min,
1506
+ step,
1507
+ disabled: disabled || readonly,
1508
+ autoFocus: autofocus,
1509
+ onChange: handleChange,
1510
+ onBlur: handleBlur,
1511
+ onFocus: handleFocus,
1512
+ ...themeProps,
1513
+ "aria-describedby": utils.ariaDescribedByIds(id)
1514
+ }
1515
+ ),
1516
+ rawErrors && rawErrors?.length > 0 && rawErrors.map((error, index) => /* @__PURE__ */ jsxRuntime.jsx(core.Input.Error, { children: error }, `range-widget-input-errors-${index}`))
1517
+ ] });
1518
+ }
1519
+ function SelectWidget(props) {
1520
+ const {
1521
+ id,
1522
+ value,
1523
+ placeholder,
1524
+ required,
1525
+ disabled,
1526
+ readonly,
1527
+ autofocus,
1528
+ label,
1529
+ hideLabel,
1530
+ multiple,
1531
+ rawErrors,
1532
+ options,
1533
+ onChange,
1534
+ onBlur,
1535
+ onFocus
1536
+ } = props;
1537
+ const { enumOptions, enumDisabled, emptyValue } = options;
1538
+ const themeProps = cleanupOptions(options);
1539
+ const handleChange = react.useCallback(
1540
+ (nextValue) => {
1541
+ if (!disabled && !readonly && onChange) {
1542
+ onChange(utils.enumOptionsValueForIndex(nextValue, enumOptions, emptyValue));
1543
+ }
1544
+ },
1545
+ [onChange, disabled, readonly, enumOptions, emptyValue]
1546
+ );
1547
+ const handleBlur = react.useCallback(
1548
+ ({ target }) => {
1549
+ if (onBlur) {
1550
+ onBlur(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
1551
+ }
1552
+ },
1553
+ [onBlur, id, enumOptions, emptyValue]
1554
+ );
1555
+ const handleFocus = react.useCallback(
1556
+ ({ target }) => {
1557
+ if (onFocus) {
1558
+ onFocus(id, utils.enumOptionsValueForIndex(target && target.value, enumOptions, emptyValue));
1559
+ }
1560
+ },
1561
+ [onFocus, id, enumOptions, emptyValue]
1562
+ );
1563
+ const selectedIndexes = utils.enumOptionsIndexForValue(value, enumOptions, multiple);
1564
+ const selectOptions = react.useMemo(() => {
1565
+ if (Array.isArray(enumOptions)) {
1566
+ return enumOptions.map((option, index) => ({
1567
+ key: String(index),
1568
+ value: String(index),
1569
+ label: option.label,
1570
+ disabled: Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1
1571
+ }));
1572
+ }
1573
+ return [];
1574
+ }, [enumDisabled, enumOptions]);
1575
+ const Component = multiple ? core.MultiSelect : core.Select;
1576
+ return /* @__PURE__ */ jsxRuntime.jsx(
1577
+ Component,
1578
+ {
1579
+ id,
1580
+ name: id,
1581
+ label: utils.labelValue(label || void 0, hideLabel, false),
1582
+ data: selectOptions,
1583
+ value: multiple ? selectedIndexes : selectedIndexes,
1584
+ onChange: !readonly ? handleChange : void 0,
1585
+ onBlur: !readonly ? handleBlur : void 0,
1586
+ onFocus: !readonly ? handleFocus : void 0,
1587
+ autoFocus: autofocus,
1588
+ placeholder,
1589
+ disabled: disabled || readonly,
1590
+ required,
1591
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1592
+ searchable: true,
1593
+ ...themeProps,
1594
+ "aria-describedby": utils.ariaDescribedByIds(id),
1595
+ comboboxProps: { withinPortal: false }
1596
+ }
1597
+ );
1598
+ }
1599
+ function TextareaWidget(props) {
1600
+ const {
1601
+ id,
1602
+ name,
1603
+ value,
1604
+ placeholder,
1605
+ required,
1606
+ disabled,
1607
+ readonly,
1608
+ autofocus,
1609
+ label,
1610
+ hideLabel,
1611
+ rawErrors,
1612
+ options,
1613
+ onChange,
1614
+ onBlur,
1615
+ onFocus
1616
+ } = props;
1617
+ const themeProps = cleanupOptions(options);
1618
+ const emptyValue = options?.emptyValue ?? "";
1619
+ const handleChange = react.useCallback(
1620
+ (e) => {
1621
+ onChange(e.target.value === "" ? emptyValue : e.target.value);
1622
+ },
1623
+ [onChange, emptyValue]
1624
+ );
1625
+ const handleBlur = react.useCallback(
1626
+ ({ target }) => {
1627
+ if (onBlur) {
1628
+ onBlur(id, target && target.value);
1629
+ }
1630
+ },
1631
+ [onBlur, id]
1632
+ );
1633
+ const handleFocus = react.useCallback(
1634
+ ({ target }) => {
1635
+ if (onFocus) {
1636
+ onFocus(id, target && target.value);
1637
+ }
1638
+ },
1639
+ [onFocus, id]
1640
+ );
1641
+ return /* @__PURE__ */ jsxRuntime.jsx(
1642
+ core.Textarea,
1643
+ {
1644
+ id,
1645
+ name,
1646
+ value: value || "",
1647
+ placeholder: placeholder || void 0,
1648
+ required,
1649
+ disabled: disabled || readonly,
1650
+ autoFocus: autofocus,
1651
+ label: utils.labelValue(label || void 0, hideLabel, false),
1652
+ onChange: handleChange,
1653
+ onBlur: handleBlur,
1654
+ onFocus: handleFocus,
1655
+ error: rawErrors && rawErrors.length > 0 ? rawErrors.join("\n") : void 0,
1656
+ "aria-describedby": utils.ariaDescribedByIds(id),
1657
+ ...themeProps
1658
+ }
1659
+ );
1660
+ }
1661
+
1662
+ // src/widgets/index.ts
1663
+ dayjs.extend(customParseFormat);
1664
+ function generateWidgets() {
1665
+ return {
1666
+ AltDateTimeWidget,
1667
+ AltDateWidget,
1668
+ CheckboxesWidget,
1669
+ CheckboxWidget,
1670
+ ColorWidget,
1671
+ FileWidget,
1672
+ DateTimeWidget,
1673
+ DateWidget,
1674
+ PasswordWidget,
1675
+ RadioWidget,
1676
+ RangeWidget,
1677
+ SelectWidget,
1678
+ TextareaWidget,
1679
+ TimeWidget
1680
+ };
1681
+ }
1682
+ var widgets_default = generateWidgets();
1683
+
1684
+ // src/Theme/index.ts
1685
+ function generateTheme() {
1686
+ return {
1687
+ templates: generateTemplates(),
1688
+ widgets: generateWidgets()
1689
+ };
1690
+ }
1691
+ var Theme_default = generateTheme();
1692
+
1693
+ // src/Form/index.ts
1694
+ function generateForm() {
1695
+ return core$1.withTheme(generateTheme());
1696
+ }
1697
+ var Form_default = generateForm();
1698
+
1699
+ // src/index.ts
1700
+ var index_default = Form_default;
1701
+
1702
+ exports.Form = Form_default;
1703
+ exports.Templates = templates_default;
1704
+ exports.Theme = Theme_default;
1705
+ exports.Widgets = widgets_default;
1706
+ exports.default = index_default;
1707
+ exports.generateForm = generateForm;
1708
+ exports.generateTemplates = generateTemplates;
1709
+ exports.generateTheme = generateTheme;
1710
+ exports.generateWidgets = generateWidgets;
1711
+
1712
+ Object.defineProperty(exports, '__esModule', { value: true });
1713
+
1714
+ }));