@rjsf/core 5.11.2 → 5.12.0

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 (232) hide show
  1. package/dist/core.umd.js +3464 -0
  2. package/dist/index.esm.js +3814 -0
  3. package/dist/index.esm.js.map +7 -0
  4. package/dist/index.js +3714 -5
  5. package/dist/index.js.map +7 -0
  6. package/{dist/index.d.ts → lib/components/Form.d.ts} +321 -337
  7. package/lib/components/Form.js +474 -0
  8. package/lib/components/Form.js.map +1 -0
  9. package/lib/components/fields/ArrayField.d.ts +179 -0
  10. package/lib/components/fields/ArrayField.js +568 -0
  11. package/lib/components/fields/ArrayField.js.map +1 -0
  12. package/lib/components/fields/BooleanField.d.ts +9 -0
  13. package/lib/components/fields/BooleanField.js +62 -0
  14. package/lib/components/fields/BooleanField.js.map +1 -0
  15. package/lib/components/fields/MultiSchemaField.d.ts +47 -0
  16. package/lib/components/fields/MultiSchemaField.js +129 -0
  17. package/lib/components/fields/MultiSchemaField.js.map +1 -0
  18. package/lib/components/fields/NullField.d.ts +8 -0
  19. package/lib/components/fields/NullField.js +17 -0
  20. package/lib/components/fields/NullField.js.map +1 -0
  21. package/lib/components/fields/NumberField.d.ts +21 -0
  22. package/lib/components/fields/NumberField.js +70 -0
  23. package/lib/components/fields/NumberField.js.map +1 -0
  24. package/lib/components/fields/ObjectField.d.ts +73 -0
  25. package/lib/components/fields/ObjectField.js +222 -0
  26. package/lib/components/fields/ObjectField.js.map +1 -0
  27. package/lib/components/fields/SchemaField.d.ts +10 -0
  28. package/lib/components/fields/SchemaField.js +172 -0
  29. package/lib/components/fields/SchemaField.js.map +1 -0
  30. package/lib/components/fields/StringField.d.ts +8 -0
  31. package/lib/components/fields/StringField.js +25 -0
  32. package/lib/components/fields/StringField.js.map +1 -0
  33. package/lib/components/fields/index.d.ts +3 -0
  34. package/lib/components/fields/index.js +24 -0
  35. package/lib/components/fields/index.js.map +1 -0
  36. package/lib/components/templates/ArrayFieldDescriptionTemplate.d.ts +8 -0
  37. package/lib/components/templates/ArrayFieldDescriptionTemplate.js +18 -0
  38. package/lib/components/templates/ArrayFieldDescriptionTemplate.js.map +1 -0
  39. package/lib/components/templates/ArrayFieldItemTemplate.d.ts +7 -0
  40. package/lib/components/templates/ArrayFieldItemTemplate.js +20 -0
  41. package/lib/components/templates/ArrayFieldItemTemplate.js.map +1 -0
  42. package/lib/components/templates/ArrayFieldTemplate.d.ts +7 -0
  43. package/lib/components/templates/ArrayFieldTemplate.js +22 -0
  44. package/lib/components/templates/ArrayFieldTemplate.js.map +1 -0
  45. package/lib/components/templates/ArrayFieldTitleTemplate.d.ts +8 -0
  46. package/lib/components/templates/ArrayFieldTitleTemplate.js +18 -0
  47. package/lib/components/templates/ArrayFieldTitleTemplate.js.map +1 -0
  48. package/lib/components/templates/BaseInputTemplate.d.ts +9 -0
  49. package/lib/components/templates/BaseInputTemplate.js +39 -0
  50. package/lib/components/templates/BaseInputTemplate.js.map +1 -0
  51. package/lib/components/templates/ButtonTemplates/AddButton.d.ts +5 -0
  52. package/lib/components/templates/ButtonTemplates/AddButton.js +10 -0
  53. package/lib/components/templates/ButtonTemplates/AddButton.js.map +1 -0
  54. package/lib/components/templates/ButtonTemplates/IconButton.d.ts +7 -0
  55. package/lib/components/templates/ButtonTemplates/IconButton.js +24 -0
  56. package/lib/components/templates/ButtonTemplates/IconButton.js.map +1 -0
  57. package/lib/components/templates/ButtonTemplates/SubmitButton.d.ts +5 -0
  58. package/lib/components/templates/ButtonTemplates/SubmitButton.js +12 -0
  59. package/lib/components/templates/ButtonTemplates/SubmitButton.js.map +1 -0
  60. package/lib/components/templates/ButtonTemplates/index.d.ts +3 -0
  61. package/lib/components/templates/ButtonTemplates/index.js +15 -0
  62. package/lib/components/templates/ButtonTemplates/index.js.map +1 -0
  63. package/lib/components/templates/DescriptionField.d.ts +7 -0
  64. package/lib/components/templates/DescriptionField.js +18 -0
  65. package/lib/components/templates/DescriptionField.js.map +1 -0
  66. package/lib/components/templates/ErrorList.d.ts +7 -0
  67. package/lib/components/templates/ErrorList.js +13 -0
  68. package/lib/components/templates/ErrorList.js.map +1 -0
  69. package/lib/components/templates/FieldErrorTemplate.d.ts +7 -0
  70. package/lib/components/templates/FieldErrorTemplate.js +19 -0
  71. package/lib/components/templates/FieldErrorTemplate.js.map +1 -0
  72. package/lib/components/templates/FieldHelpTemplate.d.ts +7 -0
  73. package/lib/components/templates/FieldHelpTemplate.js +18 -0
  74. package/lib/components/templates/FieldHelpTemplate.js.map +1 -0
  75. package/lib/components/templates/FieldTemplate/FieldTemplate.d.ts +8 -0
  76. package/lib/components/templates/FieldTemplate/FieldTemplate.js +18 -0
  77. package/lib/components/templates/FieldTemplate/FieldTemplate.js.map +1 -0
  78. package/lib/components/templates/FieldTemplate/Label.d.ts +14 -0
  79. package/lib/components/templates/FieldTemplate/Label.js +14 -0
  80. package/lib/components/templates/FieldTemplate/Label.js.map +1 -0
  81. package/lib/components/templates/FieldTemplate/index.d.ts +2 -0
  82. package/lib/components/templates/FieldTemplate/index.js +3 -0
  83. package/lib/components/templates/FieldTemplate/index.js.map +1 -0
  84. package/lib/components/templates/ObjectFieldTemplate.d.ts +9 -0
  85. package/lib/components/templates/ObjectFieldTemplate.js +18 -0
  86. package/lib/components/templates/ObjectFieldTemplate.js.map +1 -0
  87. package/lib/components/templates/TitleField.d.ts +7 -0
  88. package/lib/components/templates/TitleField.js +11 -0
  89. package/lib/components/templates/TitleField.js.map +1 -0
  90. package/lib/components/templates/UnsupportedField.d.ts +9 -0
  91. package/lib/components/templates/UnsupportedField.js +28 -0
  92. package/lib/components/templates/UnsupportedField.js.map +1 -0
  93. package/lib/components/templates/WrapIfAdditionalTemplate.d.ts +8 -0
  94. package/lib/components/templates/WrapIfAdditionalTemplate.js +21 -0
  95. package/lib/components/templates/WrapIfAdditionalTemplate.js.map +1 -0
  96. package/lib/components/templates/index.d.ts +3 -0
  97. package/lib/components/templates/index.js +36 -0
  98. package/lib/components/templates/index.js.map +1 -0
  99. package/lib/components/widgets/AltDateTimeWidget.d.ts +9 -0
  100. package/lib/components/widgets/AltDateTimeWidget.js +14 -0
  101. package/lib/components/widgets/AltDateTimeWidget.js.map +1 -0
  102. package/lib/components/widgets/AltDateWidget.d.ts +7 -0
  103. package/lib/components/widgets/AltDateWidget.js +77 -0
  104. package/lib/components/widgets/AltDateWidget.js.map +1 -0
  105. package/lib/components/widgets/CheckboxWidget.d.ts +9 -0
  106. package/lib/components/widgets/CheckboxWidget.js +23 -0
  107. package/lib/components/widgets/CheckboxWidget.js.map +1 -0
  108. package/lib/components/widgets/CheckboxesWidget.d.ts +9 -0
  109. package/lib/components/widgets/CheckboxesWidget.js +31 -0
  110. package/lib/components/widgets/CheckboxesWidget.js.map +1 -0
  111. package/lib/components/widgets/ColorWidget.d.ts +8 -0
  112. package/lib/components/widgets/ColorWidget.js +13 -0
  113. package/lib/components/widgets/ColorWidget.js.map +1 -0
  114. package/lib/components/widgets/DateTimeWidget.d.ts +8 -0
  115. package/lib/components/widgets/DateTimeWidget.js +13 -0
  116. package/lib/components/widgets/DateTimeWidget.js.map +1 -0
  117. package/lib/components/widgets/DateWidget.d.ts +8 -0
  118. package/lib/components/widgets/DateWidget.js +15 -0
  119. package/lib/components/widgets/DateWidget.js.map +1 -0
  120. package/lib/components/widgets/EmailWidget.d.ts +7 -0
  121. package/lib/components/widgets/EmailWidget.js +12 -0
  122. package/lib/components/widgets/EmailWidget.js.map +1 -0
  123. package/lib/components/widgets/FileWidget.d.ts +8 -0
  124. package/lib/components/widgets/FileWidget.js +105 -0
  125. package/lib/components/widgets/FileWidget.js.map +1 -0
  126. package/lib/components/widgets/HiddenWidget.d.ts +9 -0
  127. package/lib/components/widgets/HiddenWidget.js +11 -0
  128. package/lib/components/widgets/HiddenWidget.js.map +1 -0
  129. package/lib/components/widgets/PasswordWidget.d.ts +7 -0
  130. package/lib/components/widgets/PasswordWidget.js +12 -0
  131. package/lib/components/widgets/PasswordWidget.js.map +1 -0
  132. package/lib/components/widgets/RadioWidget.d.ts +9 -0
  133. package/lib/components/widgets/RadioWidget.js +24 -0
  134. package/lib/components/widgets/RadioWidget.js.map +1 -0
  135. package/lib/components/widgets/RangeWidget.d.ts +8 -0
  136. package/lib/components/widgets/RangeWidget.js +11 -0
  137. package/lib/components/widgets/RangeWidget.js.map +1 -0
  138. package/lib/components/widgets/SelectWidget.d.ts +9 -0
  139. package/lib/components/widgets/SelectWidget.js +41 -0
  140. package/lib/components/widgets/SelectWidget.js.map +1 -0
  141. package/lib/components/widgets/TextWidget.d.ts +7 -0
  142. package/lib/components/widgets/TextWidget.js +12 -0
  143. package/lib/components/widgets/TextWidget.js.map +1 -0
  144. package/lib/components/widgets/TextareaWidget.d.ts +14 -0
  145. package/lib/components/widgets/TextareaWidget.js +19 -0
  146. package/lib/components/widgets/TextareaWidget.js.map +1 -0
  147. package/lib/components/widgets/TimeWidget.d.ts +8 -0
  148. package/lib/components/widgets/TimeWidget.js +15 -0
  149. package/lib/components/widgets/TimeWidget.js.map +1 -0
  150. package/lib/components/widgets/URLWidget.d.ts +7 -0
  151. package/lib/components/widgets/URLWidget.js +12 -0
  152. package/lib/components/widgets/URLWidget.js.map +1 -0
  153. package/lib/components/widgets/UpDownWidget.d.ts +7 -0
  154. package/lib/components/widgets/UpDownWidget.js +12 -0
  155. package/lib/components/widgets/UpDownWidget.js.map +1 -0
  156. package/lib/components/widgets/index.d.ts +3 -0
  157. package/lib/components/widgets/index.js +44 -0
  158. package/lib/components/widgets/index.js.map +1 -0
  159. package/lib/getDefaultRegistry.d.ts +6 -0
  160. package/lib/getDefaultRegistry.js +19 -0
  161. package/lib/getDefaultRegistry.js.map +1 -0
  162. package/lib/index.d.ts +6 -0
  163. package/lib/index.js +6 -0
  164. package/lib/index.js.map +1 -0
  165. package/lib/withTheme.d.ts +9 -0
  166. package/lib/withTheme.js +16 -0
  167. package/lib/withTheme.js.map +1 -0
  168. package/package.json +23 -16
  169. package/src/components/Form.tsx +853 -0
  170. package/src/components/fields/ArrayField.tsx +875 -0
  171. package/src/components/fields/BooleanField.tsx +114 -0
  172. package/src/components/fields/MultiSchemaField.tsx +221 -0
  173. package/src/components/fields/NullField.tsx +22 -0
  174. package/src/components/fields/NumberField.tsx +86 -0
  175. package/src/components/fields/ObjectField.tsx +331 -0
  176. package/src/components/fields/SchemaField.tsx +360 -0
  177. package/src/components/fields/StringField.tsx +71 -0
  178. package/src/components/fields/index.ts +31 -0
  179. package/src/components/templates/ArrayFieldDescriptionTemplate.tsx +41 -0
  180. package/src/components/templates/ArrayFieldItemTemplate.tsx +90 -0
  181. package/src/components/templates/ArrayFieldTemplate.tsx +88 -0
  182. package/src/components/templates/ArrayFieldTitleTemplate.tsx +43 -0
  183. package/src/components/templates/BaseInputTemplate.tsx +102 -0
  184. package/src/components/templates/ButtonTemplates/AddButton.tsx +29 -0
  185. package/src/components/templates/ButtonTemplates/IconButton.tsx +77 -0
  186. package/src/components/templates/ButtonTemplates/SubmitButton.tsx +21 -0
  187. package/src/components/templates/ButtonTemplates/index.ts +22 -0
  188. package/src/components/templates/DescriptionField.tsx +29 -0
  189. package/src/components/templates/ErrorList.tsx +35 -0
  190. package/src/components/templates/FieldErrorTemplate.tsx +33 -0
  191. package/src/components/templates/FieldHelpTemplate.tsx +29 -0
  192. package/src/components/templates/FieldTemplate/FieldTemplate.tsx +41 -0
  193. package/src/components/templates/FieldTemplate/Label.tsx +27 -0
  194. package/src/components/templates/FieldTemplate/index.ts +3 -0
  195. package/src/components/templates/ObjectFieldTemplate.tsx +83 -0
  196. package/src/components/templates/TitleField.tsx +19 -0
  197. package/src/components/templates/UnsupportedField.tsx +37 -0
  198. package/src/components/templates/WrapIfAdditionalTemplate.tsx +80 -0
  199. package/src/components/templates/index.ts +43 -0
  200. package/src/components/widgets/AltDateTimeWidget.tsx +16 -0
  201. package/src/components/widgets/AltDateWidget.tsx +198 -0
  202. package/src/components/widgets/CheckboxWidget.tsx +92 -0
  203. package/src/components/widgets/CheckboxesWidget.tsx +92 -0
  204. package/src/components/widgets/ColorWidget.tsx +14 -0
  205. package/src/components/widgets/DateTimeWidget.tsx +31 -0
  206. package/src/components/widgets/DateWidget.tsx +17 -0
  207. package/src/components/widgets/EmailWidget.tsx +13 -0
  208. package/src/components/widgets/FileWidget.tsx +178 -0
  209. package/src/components/widgets/HiddenWidget.tsx +15 -0
  210. package/src/components/widgets/PasswordWidget.tsx +15 -0
  211. package/src/components/widgets/RadioWidget.tsx +88 -0
  212. package/src/components/widgets/RangeWidget.tsx +23 -0
  213. package/src/components/widgets/SelectWidget.tsx +100 -0
  214. package/src/components/widgets/TextWidget.tsx +13 -0
  215. package/src/components/widgets/TextareaWidget.tsx +61 -0
  216. package/src/components/widgets/TimeWidget.tsx +17 -0
  217. package/src/components/widgets/URLWidget.tsx +13 -0
  218. package/src/components/widgets/UpDownWidget.tsx +13 -0
  219. package/src/components/widgets/index.ts +51 -0
  220. package/src/getDefaultRegistry.ts +24 -0
  221. package/src/index.ts +8 -0
  222. package/src/withTheme.tsx +42 -0
  223. package/dist/core.cjs.development.js +0 -4403
  224. package/dist/core.cjs.development.js.map +0 -1
  225. package/dist/core.cjs.production.min.js +0 -2
  226. package/dist/core.cjs.production.min.js.map +0 -1
  227. package/dist/core.esm.js +0 -4383
  228. package/dist/core.esm.js.map +0 -1
  229. package/dist/core.umd.development.js +0 -4393
  230. package/dist/core.umd.development.js.map +0 -1
  231. package/dist/core.umd.production.min.js +0 -2
  232. package/dist/core.umd.production.min.js.map +0 -1
@@ -0,0 +1,3814 @@
1
+ // src/components/Form.tsx
2
+ import { Component as Component5, createRef } from "react";
3
+ import {
4
+ createSchemaUtils,
5
+ deepEquals as deepEquals3,
6
+ getTemplate as getTemplate20,
7
+ getUiOptions as getUiOptions12,
8
+ isObject as isObject5,
9
+ mergeObjects as mergeObjects2,
10
+ NAME_KEY,
11
+ RJSF_ADDITONAL_PROPERTIES_FLAG,
12
+ shouldRender,
13
+ SUBMIT_BTN_OPTIONS_KEY,
14
+ toErrorList,
15
+ UI_GLOBAL_OPTIONS_KEY,
16
+ UI_OPTIONS_KEY as UI_OPTIONS_KEY2,
17
+ validationDataMerge
18
+ } from "@rjsf/utils";
19
+ import _get from "lodash/get";
20
+ import _isEmpty from "lodash/isEmpty";
21
+ import _pick from "lodash/pick";
22
+ import _toPath from "lodash/toPath";
23
+
24
+ // src/getDefaultRegistry.ts
25
+ import { englishStringTranslator } from "@rjsf/utils";
26
+
27
+ // src/components/fields/ArrayField.tsx
28
+ import { Component } from "react";
29
+ import {
30
+ getTemplate,
31
+ getWidget,
32
+ getUiOptions,
33
+ isFixedItems,
34
+ allowAdditionalItems,
35
+ isCustomWidget,
36
+ optionsList,
37
+ TranslatableString,
38
+ ITEMS_KEY
39
+ } from "@rjsf/utils";
40
+ import cloneDeep from "lodash/cloneDeep";
41
+ import get from "lodash/get";
42
+ import isObject from "lodash/isObject";
43
+ import set from "lodash/set";
44
+ import { nanoid } from "nanoid";
45
+ import { jsx } from "react/jsx-runtime";
46
+ function generateRowId() {
47
+ return nanoid();
48
+ }
49
+ function generateKeyedFormData(formData) {
50
+ return !Array.isArray(formData) ? [] : formData.map((item) => {
51
+ return {
52
+ key: generateRowId(),
53
+ item
54
+ };
55
+ });
56
+ }
57
+ function keyedToPlainFormData(keyedFormData) {
58
+ if (Array.isArray(keyedFormData)) {
59
+ return keyedFormData.map((keyedItem) => keyedItem.item);
60
+ }
61
+ return [];
62
+ }
63
+ var ArrayField = class extends Component {
64
+ /** Constructs an `ArrayField` from the `props`, generating the initial keyed data from the `formData`
65
+ *
66
+ * @param props - The `FieldProps` for this template
67
+ */
68
+ constructor(props) {
69
+ super(props);
70
+ /** Returns the default form information for an item based on the schema for that item. Deals with the possibility
71
+ * that the schema is fixed and allows additional items.
72
+ */
73
+ this._getNewFormDataRow = () => {
74
+ const { schema, registry } = this.props;
75
+ const { schemaUtils } = registry;
76
+ let itemSchema = schema.items;
77
+ if (isFixedItems(schema) && allowAdditionalItems(schema)) {
78
+ itemSchema = schema.additionalItems;
79
+ }
80
+ return schemaUtils.getDefaultFormState(itemSchema);
81
+ };
82
+ /** Callback handler for when the user clicks on the add button. Creates a new row of keyed form data at the end of
83
+ * the list, adding it into the state, and then returning `onChange()` with the plain form data converted from the
84
+ * keyed data
85
+ *
86
+ * @param event - The event for the click
87
+ */
88
+ this.onAddClick = (event) => {
89
+ this._handleAddClick(event);
90
+ };
91
+ /** Callback handler for when the user clicks on the add button on an existing array element. Creates a new row of
92
+ * keyed form data inserted at the `index`, adding it into the state, and then returning `onChange()` with the plain
93
+ * form data converted from the keyed data
94
+ *
95
+ * @param index - The index at which the add button is clicked
96
+ */
97
+ this.onAddIndexClick = (index) => {
98
+ return (event) => {
99
+ this._handleAddClick(event, index);
100
+ };
101
+ };
102
+ /** Callback handler for when the user clicks on the copy button on an existing array element. Clones the row of
103
+ * keyed form data at the `index` into the next position in the state, and then returning `onChange()` with the plain
104
+ * form data converted from the keyed data
105
+ *
106
+ * @param index - The index at which the copy button is clicked
107
+ */
108
+ this.onCopyIndexClick = (index) => {
109
+ return (event) => {
110
+ if (event) {
111
+ event.preventDefault();
112
+ }
113
+ const { onChange } = this.props;
114
+ const { keyedFormData } = this.state;
115
+ const newKeyedFormDataRow = {
116
+ key: generateRowId(),
117
+ item: cloneDeep(keyedFormData[index].item)
118
+ };
119
+ const newKeyedFormData = [...keyedFormData];
120
+ if (index !== void 0) {
121
+ newKeyedFormData.splice(index + 1, 0, newKeyedFormDataRow);
122
+ } else {
123
+ newKeyedFormData.push(newKeyedFormDataRow);
124
+ }
125
+ this.setState(
126
+ {
127
+ keyedFormData: newKeyedFormData,
128
+ updatedKeyedFormData: true
129
+ },
130
+ () => onChange(keyedToPlainFormData(newKeyedFormData))
131
+ );
132
+ };
133
+ };
134
+ /** Callback handler for when the user clicks on the remove button on an existing array element. Removes the row of
135
+ * keyed form data at the `index` in the state, and then returning `onChange()` with the plain form data converted
136
+ * from the keyed data
137
+ *
138
+ * @param index - The index at which the remove button is clicked
139
+ */
140
+ this.onDropIndexClick = (index) => {
141
+ return (event) => {
142
+ if (event) {
143
+ event.preventDefault();
144
+ }
145
+ const { onChange, errorSchema } = this.props;
146
+ const { keyedFormData } = this.state;
147
+ let newErrorSchema;
148
+ if (errorSchema) {
149
+ newErrorSchema = {};
150
+ for (const idx in errorSchema) {
151
+ const i = parseInt(idx);
152
+ if (i < index) {
153
+ set(newErrorSchema, [i], errorSchema[idx]);
154
+ } else if (i > index) {
155
+ set(newErrorSchema, [i - 1], errorSchema[idx]);
156
+ }
157
+ }
158
+ }
159
+ const newKeyedFormData = keyedFormData.filter((_, i) => i !== index);
160
+ this.setState(
161
+ {
162
+ keyedFormData: newKeyedFormData,
163
+ updatedKeyedFormData: true
164
+ },
165
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
166
+ );
167
+ };
168
+ };
169
+ /** Callback handler for when the user clicks on one of the move item buttons on an existing array element. Moves the
170
+ * row of keyed form data at the `index` to the `newIndex` in the state, and then returning `onChange()` with the
171
+ * plain form data converted from the keyed data
172
+ *
173
+ * @param index - The index of the item to move
174
+ * @param newIndex - The index to where the item is to be moved
175
+ */
176
+ this.onReorderClick = (index, newIndex) => {
177
+ return (event) => {
178
+ if (event) {
179
+ event.preventDefault();
180
+ event.currentTarget.blur();
181
+ }
182
+ const { onChange, errorSchema } = this.props;
183
+ let newErrorSchema;
184
+ if (errorSchema) {
185
+ newErrorSchema = {};
186
+ for (const idx in errorSchema) {
187
+ const i = parseInt(idx);
188
+ if (i == index) {
189
+ set(newErrorSchema, [newIndex], errorSchema[index]);
190
+ } else if (i == newIndex) {
191
+ set(newErrorSchema, [index], errorSchema[newIndex]);
192
+ } else {
193
+ set(newErrorSchema, [idx], errorSchema[i]);
194
+ }
195
+ }
196
+ }
197
+ const { keyedFormData } = this.state;
198
+ function reOrderArray() {
199
+ const _newKeyedFormData = keyedFormData.slice();
200
+ _newKeyedFormData.splice(index, 1);
201
+ _newKeyedFormData.splice(newIndex, 0, keyedFormData[index]);
202
+ return _newKeyedFormData;
203
+ }
204
+ const newKeyedFormData = reOrderArray();
205
+ this.setState(
206
+ {
207
+ keyedFormData: newKeyedFormData
208
+ },
209
+ () => onChange(keyedToPlainFormData(newKeyedFormData), newErrorSchema)
210
+ );
211
+ };
212
+ };
213
+ /** Callback handler used to deal with changing the value of the data in the array at the `index`. Calls the
214
+ * `onChange` callback with the updated form data
215
+ *
216
+ * @param index - The index of the item being changed
217
+ */
218
+ this.onChangeForIndex = (index) => {
219
+ return (value, newErrorSchema, id) => {
220
+ const { formData, onChange, errorSchema } = this.props;
221
+ const arrayData = Array.isArray(formData) ? formData : [];
222
+ const newFormData = arrayData.map((item, i) => {
223
+ const jsonValue = typeof value === "undefined" ? null : value;
224
+ return index === i ? jsonValue : item;
225
+ });
226
+ onChange(
227
+ newFormData,
228
+ errorSchema && errorSchema && {
229
+ ...errorSchema,
230
+ [index]: newErrorSchema
231
+ },
232
+ id
233
+ );
234
+ };
235
+ };
236
+ /** Callback handler used to change the value for a checkbox */
237
+ this.onSelectChange = (value) => {
238
+ const { onChange, idSchema } = this.props;
239
+ onChange(value, void 0, idSchema && idSchema.$id);
240
+ };
241
+ const { formData = [] } = props;
242
+ const keyedFormData = generateKeyedFormData(formData);
243
+ this.state = {
244
+ keyedFormData,
245
+ updatedKeyedFormData: false
246
+ };
247
+ }
248
+ /** React lifecycle method that is called when the props are about to change allowing the state to be updated. It
249
+ * regenerates the keyed form data and returns it
250
+ *
251
+ * @param nextProps - The next set of props data
252
+ * @param prevState - The previous set of state data
253
+ */
254
+ static getDerivedStateFromProps(nextProps, prevState) {
255
+ if (prevState.updatedKeyedFormData) {
256
+ return {
257
+ updatedKeyedFormData: false
258
+ };
259
+ }
260
+ const nextFormData = Array.isArray(nextProps.formData) ? nextProps.formData : [];
261
+ const previousKeyedFormData = prevState.keyedFormData || [];
262
+ const newKeyedFormData = nextFormData.length === previousKeyedFormData.length ? previousKeyedFormData.map((previousKeyedFormDatum, index) => {
263
+ return {
264
+ key: previousKeyedFormDatum.key,
265
+ item: nextFormData[index]
266
+ };
267
+ }) : generateKeyedFormData(nextFormData);
268
+ return {
269
+ keyedFormData: newKeyedFormData
270
+ };
271
+ }
272
+ /** Returns the appropriate title for an item by getting first the title from the schema.items, then falling back to
273
+ * the description from the schema.items, and finally the string "Item"
274
+ */
275
+ get itemTitle() {
276
+ const { schema, registry } = this.props;
277
+ const { translateString } = registry;
278
+ return get(
279
+ schema,
280
+ [ITEMS_KEY, "title"],
281
+ get(schema, [ITEMS_KEY, "description"], translateString(TranslatableString.ArrayItemTitle))
282
+ );
283
+ }
284
+ /** Determines whether the item described in the schema is always required, which is determined by whether any item
285
+ * may be null.
286
+ *
287
+ * @param itemSchema - The schema for the item
288
+ * @return - True if the item schema type does not contain the "null" type
289
+ */
290
+ isItemRequired(itemSchema) {
291
+ if (Array.isArray(itemSchema.type)) {
292
+ return !itemSchema.type.includes("null");
293
+ }
294
+ return itemSchema.type !== "null";
295
+ }
296
+ /** Determines whether more items can be added to the array. If the uiSchema indicates the array doesn't allow adding
297
+ * then false is returned. Otherwise, if the schema indicates that there are a maximum number of items and the
298
+ * `formData` matches that value, then false is returned, otherwise true is returned.
299
+ *
300
+ * @param formItems - The list of items in the form
301
+ * @returns - True if the item is addable otherwise false
302
+ */
303
+ canAddItem(formItems) {
304
+ const { schema, uiSchema, registry } = this.props;
305
+ let { addable } = getUiOptions(uiSchema, registry.globalUiOptions);
306
+ if (addable !== false) {
307
+ if (schema.maxItems !== void 0) {
308
+ addable = formItems.length < schema.maxItems;
309
+ } else {
310
+ addable = true;
311
+ }
312
+ }
313
+ return addable;
314
+ }
315
+ /** Callback handler for when the user clicks on the add or add at index buttons. Creates a new row of keyed form data
316
+ * either at the end of the list (when index is not specified) or inserted at the `index` when it is, adding it into
317
+ * the state, and then returning `onChange()` with the plain form data converted from the keyed data
318
+ *
319
+ * @param event - The event for the click
320
+ * @param [index] - The optional index at which to add the new data
321
+ */
322
+ _handleAddClick(event, index) {
323
+ if (event) {
324
+ event.preventDefault();
325
+ }
326
+ const { onChange } = this.props;
327
+ const { keyedFormData } = this.state;
328
+ const newKeyedFormDataRow = {
329
+ key: generateRowId(),
330
+ item: this._getNewFormDataRow()
331
+ };
332
+ const newKeyedFormData = [...keyedFormData];
333
+ if (index !== void 0) {
334
+ newKeyedFormData.splice(index, 0, newKeyedFormDataRow);
335
+ } else {
336
+ newKeyedFormData.push(newKeyedFormDataRow);
337
+ }
338
+ this.setState(
339
+ {
340
+ keyedFormData: newKeyedFormData,
341
+ updatedKeyedFormData: true
342
+ },
343
+ () => onChange(keyedToPlainFormData(newKeyedFormData))
344
+ );
345
+ }
346
+ /** Renders the `ArrayField` depending on the specific needs of the schema and uischema elements
347
+ */
348
+ render() {
349
+ const { schema, uiSchema, idSchema, registry } = this.props;
350
+ const { schemaUtils, translateString } = registry;
351
+ if (!(ITEMS_KEY in schema)) {
352
+ const uiOptions = getUiOptions(uiSchema);
353
+ const UnsupportedFieldTemplate = getTemplate(
354
+ "UnsupportedFieldTemplate",
355
+ registry,
356
+ uiOptions
357
+ );
358
+ return /* @__PURE__ */ jsx(
359
+ UnsupportedFieldTemplate,
360
+ {
361
+ schema,
362
+ idSchema,
363
+ reason: translateString(TranslatableString.MissingItems),
364
+ registry
365
+ }
366
+ );
367
+ }
368
+ if (schemaUtils.isMultiSelect(schema)) {
369
+ return this.renderMultiSelect();
370
+ }
371
+ if (isCustomWidget(uiSchema)) {
372
+ return this.renderCustomWidget();
373
+ }
374
+ if (isFixedItems(schema)) {
375
+ return this.renderFixedArray();
376
+ }
377
+ if (schemaUtils.isFilesArray(schema, uiSchema)) {
378
+ return this.renderFiles();
379
+ }
380
+ return this.renderNormalArray();
381
+ }
382
+ /** Renders a normal array without any limitations of length
383
+ */
384
+ renderNormalArray() {
385
+ const {
386
+ schema,
387
+ uiSchema = {},
388
+ errorSchema,
389
+ idSchema,
390
+ name,
391
+ disabled = false,
392
+ readonly = false,
393
+ autofocus = false,
394
+ required = false,
395
+ registry,
396
+ onBlur,
397
+ onFocus,
398
+ idPrefix,
399
+ idSeparator = "_",
400
+ rawErrors
401
+ } = this.props;
402
+ const { keyedFormData } = this.state;
403
+ const title = schema.title === void 0 ? name : schema.title;
404
+ const { schemaUtils, formContext } = registry;
405
+ const uiOptions = getUiOptions(uiSchema);
406
+ const _schemaItems = isObject(schema.items) ? schema.items : {};
407
+ const itemsSchema = schemaUtils.retrieveSchema(_schemaItems);
408
+ const formData = keyedToPlainFormData(this.state.keyedFormData);
409
+ const canAdd = this.canAddItem(formData);
410
+ const arrayProps = {
411
+ canAdd,
412
+ items: keyedFormData.map((keyedItem, index) => {
413
+ const { key, item } = keyedItem;
414
+ const itemCast = item;
415
+ const itemSchema = schemaUtils.retrieveSchema(_schemaItems, itemCast);
416
+ const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
417
+ const itemIdPrefix = idSchema.$id + idSeparator + index;
418
+ const itemIdSchema = schemaUtils.toIdSchema(itemSchema, itemIdPrefix, itemCast, idPrefix, idSeparator);
419
+ return this.renderArrayFieldItem({
420
+ key,
421
+ index,
422
+ name: name && `${name}-${index}`,
423
+ canAdd,
424
+ canMoveUp: index > 0,
425
+ canMoveDown: index < formData.length - 1,
426
+ itemSchema,
427
+ itemIdSchema,
428
+ itemErrorSchema,
429
+ itemData: itemCast,
430
+ itemUiSchema: uiSchema.items,
431
+ autofocus: autofocus && index === 0,
432
+ onBlur,
433
+ onFocus,
434
+ rawErrors,
435
+ totalItems: keyedFormData.length
436
+ });
437
+ }),
438
+ className: `field field-array field-array-of-${itemsSchema.type}`,
439
+ disabled,
440
+ idSchema,
441
+ uiSchema,
442
+ onAddClick: this.onAddClick,
443
+ readonly,
444
+ required,
445
+ schema,
446
+ title,
447
+ formContext,
448
+ formData,
449
+ rawErrors,
450
+ registry
451
+ };
452
+ const Template = getTemplate("ArrayFieldTemplate", registry, uiOptions);
453
+ return /* @__PURE__ */ jsx(Template, { ...arrayProps });
454
+ }
455
+ /** Renders an array using the custom widget provided by the user in the `uiSchema`
456
+ */
457
+ renderCustomWidget() {
458
+ const {
459
+ schema,
460
+ idSchema,
461
+ uiSchema,
462
+ disabled = false,
463
+ readonly = false,
464
+ autofocus = false,
465
+ required = false,
466
+ hideError,
467
+ placeholder,
468
+ onBlur,
469
+ onFocus,
470
+ formData: items = [],
471
+ registry,
472
+ rawErrors,
473
+ name
474
+ } = this.props;
475
+ const { widgets: widgets2, formContext, globalUiOptions, schemaUtils } = registry;
476
+ const { widget, title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
477
+ const Widget = getWidget(schema, widget, widgets2);
478
+ const label = uiTitle ?? schema.title ?? name;
479
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
480
+ return /* @__PURE__ */ jsx(
481
+ Widget,
482
+ {
483
+ id: idSchema.$id,
484
+ name,
485
+ multiple: true,
486
+ onChange: this.onSelectChange,
487
+ onBlur,
488
+ onFocus,
489
+ options,
490
+ schema,
491
+ uiSchema,
492
+ registry,
493
+ value: items,
494
+ disabled,
495
+ readonly,
496
+ hideError,
497
+ required,
498
+ label,
499
+ hideLabel: !displayLabel,
500
+ placeholder,
501
+ formContext,
502
+ autofocus,
503
+ rawErrors
504
+ }
505
+ );
506
+ }
507
+ /** Renders an array as a set of checkboxes
508
+ */
509
+ renderMultiSelect() {
510
+ const {
511
+ schema,
512
+ idSchema,
513
+ uiSchema,
514
+ formData: items = [],
515
+ disabled = false,
516
+ readonly = false,
517
+ autofocus = false,
518
+ required = false,
519
+ placeholder,
520
+ onBlur,
521
+ onFocus,
522
+ registry,
523
+ rawErrors,
524
+ name
525
+ } = this.props;
526
+ const { widgets: widgets2, schemaUtils, formContext, globalUiOptions } = registry;
527
+ const itemsSchema = schemaUtils.retrieveSchema(schema.items, items);
528
+ const enumOptions = optionsList(itemsSchema);
529
+ const { widget = "select", title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
530
+ const Widget = getWidget(schema, widget, widgets2);
531
+ const label = uiTitle ?? schema.title ?? name;
532
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
533
+ return /* @__PURE__ */ jsx(
534
+ Widget,
535
+ {
536
+ id: idSchema.$id,
537
+ name,
538
+ multiple: true,
539
+ onChange: this.onSelectChange,
540
+ onBlur,
541
+ onFocus,
542
+ options: { ...options, enumOptions },
543
+ schema,
544
+ uiSchema,
545
+ registry,
546
+ value: items,
547
+ disabled,
548
+ readonly,
549
+ required,
550
+ label,
551
+ hideLabel: !displayLabel,
552
+ placeholder,
553
+ formContext,
554
+ autofocus,
555
+ rawErrors
556
+ }
557
+ );
558
+ }
559
+ /** Renders an array of files using the `FileWidget`
560
+ */
561
+ renderFiles() {
562
+ const {
563
+ schema,
564
+ uiSchema,
565
+ idSchema,
566
+ name,
567
+ disabled = false,
568
+ readonly = false,
569
+ autofocus = false,
570
+ required = false,
571
+ onBlur,
572
+ onFocus,
573
+ registry,
574
+ formData: items = [],
575
+ rawErrors
576
+ } = this.props;
577
+ const { widgets: widgets2, formContext, globalUiOptions, schemaUtils } = registry;
578
+ const { widget = "files", title: uiTitle, ...options } = getUiOptions(uiSchema, globalUiOptions);
579
+ const Widget = getWidget(schema, widget, widgets2);
580
+ const label = uiTitle ?? schema.title ?? name;
581
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
582
+ return /* @__PURE__ */ jsx(
583
+ Widget,
584
+ {
585
+ options,
586
+ id: idSchema.$id,
587
+ name,
588
+ multiple: true,
589
+ onChange: this.onSelectChange,
590
+ onBlur,
591
+ onFocus,
592
+ schema,
593
+ uiSchema,
594
+ value: items,
595
+ disabled,
596
+ readonly,
597
+ required,
598
+ registry,
599
+ formContext,
600
+ autofocus,
601
+ rawErrors,
602
+ label,
603
+ hideLabel: !displayLabel
604
+ }
605
+ );
606
+ }
607
+ /** Renders an array that has a maximum limit of items
608
+ */
609
+ renderFixedArray() {
610
+ const {
611
+ schema,
612
+ uiSchema = {},
613
+ formData = [],
614
+ errorSchema,
615
+ idPrefix,
616
+ idSeparator = "_",
617
+ idSchema,
618
+ name,
619
+ disabled = false,
620
+ readonly = false,
621
+ autofocus = false,
622
+ required = false,
623
+ registry,
624
+ onBlur,
625
+ onFocus,
626
+ rawErrors
627
+ } = this.props;
628
+ const { keyedFormData } = this.state;
629
+ let { formData: items = [] } = this.props;
630
+ const title = schema.title || name;
631
+ const uiOptions = getUiOptions(uiSchema);
632
+ const { schemaUtils, formContext } = registry;
633
+ const _schemaItems = isObject(schema.items) ? schema.items : [];
634
+ const itemSchemas = _schemaItems.map(
635
+ (item, index) => schemaUtils.retrieveSchema(item, formData[index])
636
+ );
637
+ const additionalSchema = isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, formData) : null;
638
+ if (!items || items.length < itemSchemas.length) {
639
+ items = items || [];
640
+ items = items.concat(new Array(itemSchemas.length - items.length));
641
+ }
642
+ const canAdd = this.canAddItem(items) && !!additionalSchema;
643
+ const arrayProps = {
644
+ canAdd,
645
+ className: "field field-array field-array-fixed-items",
646
+ disabled,
647
+ idSchema,
648
+ formData,
649
+ items: keyedFormData.map((keyedItem, index) => {
650
+ const { key, item } = keyedItem;
651
+ const itemCast = item;
652
+ const additional = index >= itemSchemas.length;
653
+ const itemSchema = additional && isObject(schema.additionalItems) ? schemaUtils.retrieveSchema(schema.additionalItems, itemCast) : itemSchemas[index];
654
+ const itemIdPrefix = idSchema.$id + idSeparator + index;
655
+ const itemIdSchema = schemaUtils.toIdSchema(itemSchema, itemIdPrefix, itemCast, idPrefix, idSeparator);
656
+ const itemUiSchema = additional ? uiSchema.additionalItems || {} : Array.isArray(uiSchema.items) ? uiSchema.items[index] : uiSchema.items || {};
657
+ const itemErrorSchema = errorSchema ? errorSchema[index] : void 0;
658
+ return this.renderArrayFieldItem({
659
+ key,
660
+ index,
661
+ name: name && `${name}-${index}`,
662
+ canAdd,
663
+ canRemove: additional,
664
+ canMoveUp: index >= itemSchemas.length + 1,
665
+ canMoveDown: additional && index < items.length - 1,
666
+ itemSchema,
667
+ itemData: itemCast,
668
+ itemUiSchema,
669
+ itemIdSchema,
670
+ itemErrorSchema,
671
+ autofocus: autofocus && index === 0,
672
+ onBlur,
673
+ onFocus,
674
+ rawErrors,
675
+ totalItems: keyedFormData.length
676
+ });
677
+ }),
678
+ onAddClick: this.onAddClick,
679
+ readonly,
680
+ required,
681
+ registry,
682
+ schema,
683
+ uiSchema,
684
+ title,
685
+ formContext,
686
+ rawErrors
687
+ };
688
+ const Template = getTemplate("ArrayFieldTemplate", registry, uiOptions);
689
+ return /* @__PURE__ */ jsx(Template, { ...arrayProps });
690
+ }
691
+ /** Renders the individual array item using a `SchemaField` along with the additional properties required to be send
692
+ * back to the `ArrayFieldItemTemplate`.
693
+ *
694
+ * @param props - The props for the individual array item to be rendered
695
+ */
696
+ renderArrayFieldItem(props) {
697
+ const {
698
+ key,
699
+ index,
700
+ name,
701
+ canAdd,
702
+ canRemove = true,
703
+ canMoveUp,
704
+ canMoveDown,
705
+ itemSchema,
706
+ itemData,
707
+ itemUiSchema,
708
+ itemIdSchema,
709
+ itemErrorSchema,
710
+ autofocus,
711
+ onBlur,
712
+ onFocus,
713
+ rawErrors,
714
+ totalItems
715
+ } = props;
716
+ const { disabled, hideError, idPrefix, idSeparator, readonly, uiSchema, registry, formContext } = this.props;
717
+ const {
718
+ fields: { ArraySchemaField, SchemaField: SchemaField2 },
719
+ globalUiOptions
720
+ } = registry;
721
+ const ItemSchemaField = ArraySchemaField || SchemaField2;
722
+ const { orderable = true, removable = true, copyable = false } = getUiOptions(uiSchema, globalUiOptions);
723
+ const has2 = {
724
+ moveUp: orderable && canMoveUp,
725
+ moveDown: orderable && canMoveDown,
726
+ copy: copyable && canAdd,
727
+ remove: removable && canRemove,
728
+ toolbar: false
729
+ };
730
+ has2.toolbar = Object.keys(has2).some((key2) => has2[key2]);
731
+ return {
732
+ children: /* @__PURE__ */ jsx(
733
+ ItemSchemaField,
734
+ {
735
+ name,
736
+ index,
737
+ schema: itemSchema,
738
+ uiSchema: itemUiSchema,
739
+ formData: itemData,
740
+ formContext,
741
+ errorSchema: itemErrorSchema,
742
+ idPrefix,
743
+ idSeparator,
744
+ idSchema: itemIdSchema,
745
+ required: this.isItemRequired(itemSchema),
746
+ onChange: this.onChangeForIndex(index),
747
+ onBlur,
748
+ onFocus,
749
+ registry,
750
+ disabled,
751
+ readonly,
752
+ hideError,
753
+ autofocus,
754
+ rawErrors
755
+ }
756
+ ),
757
+ className: "array-item",
758
+ disabled,
759
+ canAdd,
760
+ hasCopy: has2.copy,
761
+ hasToolbar: has2.toolbar,
762
+ hasMoveUp: has2.moveUp,
763
+ hasMoveDown: has2.moveDown,
764
+ hasRemove: has2.remove,
765
+ index,
766
+ totalItems,
767
+ key,
768
+ onAddIndexClick: this.onAddIndexClick,
769
+ onCopyIndexClick: this.onCopyIndexClick,
770
+ onDropIndexClick: this.onDropIndexClick,
771
+ onReorderClick: this.onReorderClick,
772
+ readonly,
773
+ registry,
774
+ schema: itemSchema,
775
+ uiSchema: itemUiSchema
776
+ };
777
+ }
778
+ };
779
+ var ArrayField_default = ArrayField;
780
+
781
+ // src/components/fields/BooleanField.tsx
782
+ import {
783
+ getWidget as getWidget2,
784
+ getUiOptions as getUiOptions2,
785
+ optionsList as optionsList2,
786
+ TranslatableString as TranslatableString2
787
+ } from "@rjsf/utils";
788
+ import isObject2 from "lodash/isObject";
789
+ import { jsx as jsx2 } from "react/jsx-runtime";
790
+ function BooleanField(props) {
791
+ const {
792
+ schema,
793
+ name,
794
+ uiSchema,
795
+ idSchema,
796
+ formData,
797
+ registry,
798
+ required,
799
+ disabled,
800
+ readonly,
801
+ autofocus,
802
+ onChange,
803
+ onFocus,
804
+ onBlur,
805
+ rawErrors
806
+ } = props;
807
+ const { title } = schema;
808
+ const { widgets: widgets2, formContext, translateString, globalUiOptions } = registry;
809
+ const {
810
+ widget = "checkbox",
811
+ title: uiTitle,
812
+ // Unlike the other fields, don't use `getDisplayLabel()` since it always returns false for the boolean type
813
+ label: displayLabel = true,
814
+ ...options
815
+ } = getUiOptions2(uiSchema, globalUiOptions);
816
+ const Widget = getWidget2(schema, widget, widgets2);
817
+ const yes = translateString(TranslatableString2.YesLabel);
818
+ const no = translateString(TranslatableString2.NoLabel);
819
+ let enumOptions;
820
+ const label = uiTitle ?? title ?? name;
821
+ if (Array.isArray(schema.oneOf)) {
822
+ enumOptions = optionsList2({
823
+ oneOf: schema.oneOf.map((option) => {
824
+ if (isObject2(option)) {
825
+ return {
826
+ ...option,
827
+ title: option.title || (option.const === true ? yes : no)
828
+ };
829
+ }
830
+ return void 0;
831
+ }).filter((o) => o)
832
+ // cast away the error that typescript can't grok is fixed
833
+ });
834
+ } else {
835
+ const schemaWithEnumNames = schema;
836
+ const enums = schema.enum ?? [true, false];
837
+ if (!schemaWithEnumNames.enumNames && enums.length === 2 && enums.every((v) => typeof v === "boolean")) {
838
+ enumOptions = [
839
+ {
840
+ value: enums[0],
841
+ label: enums[0] ? yes : no
842
+ },
843
+ {
844
+ value: enums[1],
845
+ label: enums[1] ? yes : no
846
+ }
847
+ ];
848
+ } else {
849
+ enumOptions = optionsList2({
850
+ enum: enums,
851
+ // NOTE: enumNames is deprecated, but still supported for now.
852
+ enumNames: schemaWithEnumNames.enumNames
853
+ });
854
+ }
855
+ }
856
+ return /* @__PURE__ */ jsx2(
857
+ Widget,
858
+ {
859
+ options: { ...options, enumOptions },
860
+ schema,
861
+ uiSchema,
862
+ id: idSchema.$id,
863
+ name,
864
+ onChange,
865
+ onFocus,
866
+ onBlur,
867
+ label,
868
+ hideLabel: !displayLabel,
869
+ value: formData,
870
+ required,
871
+ disabled,
872
+ readonly,
873
+ registry,
874
+ formContext,
875
+ autofocus,
876
+ rawErrors
877
+ }
878
+ );
879
+ }
880
+ var BooleanField_default = BooleanField;
881
+
882
+ // src/components/fields/MultiSchemaField.tsx
883
+ import { Component as Component2 } from "react";
884
+ import get2 from "lodash/get";
885
+ import isEmpty from "lodash/isEmpty";
886
+ import omit from "lodash/omit";
887
+ import unset from "lodash/unset";
888
+ import {
889
+ ADDITIONAL_PROPERTY_FLAG,
890
+ deepEquals,
891
+ ERRORS_KEY,
892
+ getDiscriminatorFieldFromSchema,
893
+ getUiOptions as getUiOptions3,
894
+ getWidget as getWidget3,
895
+ mergeSchemas,
896
+ TranslatableString as TranslatableString3
897
+ } from "@rjsf/utils";
898
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
899
+ var AnyOfField = class extends Component2 {
900
+ /** Constructs an `AnyOfField` with the given `props` to initialize the initially selected option in state
901
+ *
902
+ * @param props - The `FieldProps` for this template
903
+ */
904
+ constructor(props) {
905
+ super(props);
906
+ /** Callback handler to remember what the currently selected option is. In addition to that the `formData` is updated
907
+ * to remove properties that are not part of the newly selected option schema, and then the updated data is passed to
908
+ * the `onChange` handler.
909
+ *
910
+ * @param option - The new option value being selected
911
+ */
912
+ this.onOptionChange = (option) => {
913
+ const { selectedOption, retrievedOptions } = this.state;
914
+ const { formData, onChange, registry } = this.props;
915
+ const { schemaUtils } = registry;
916
+ const intOption = option !== void 0 ? parseInt(option, 10) : -1;
917
+ if (intOption === selectedOption) {
918
+ return;
919
+ }
920
+ const newOption = intOption >= 0 ? retrievedOptions[intOption] : void 0;
921
+ const oldOption = selectedOption >= 0 ? retrievedOptions[selectedOption] : void 0;
922
+ let newFormData = schemaUtils.sanitizeDataForNewSchema(newOption, oldOption, formData);
923
+ if (newFormData && newOption) {
924
+ newFormData = schemaUtils.getDefaultFormState(newOption, newFormData, "excludeObjectChildren");
925
+ }
926
+ onChange(newFormData, void 0, this.getFieldId());
927
+ this.setState({ selectedOption: intOption });
928
+ };
929
+ const {
930
+ formData,
931
+ options,
932
+ registry: { schemaUtils }
933
+ } = this.props;
934
+ const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
935
+ this.state = {
936
+ retrievedOptions,
937
+ selectedOption: this.getMatchingOption(0, formData, retrievedOptions)
938
+ };
939
+ }
940
+ /** React lifecycle method that is called when the props and/or state for this component is updated. It recomputes the
941
+ * currently selected option based on the overall `formData`
942
+ *
943
+ * @param prevProps - The previous `FieldProps` for this template
944
+ * @param prevState - The previous `AnyOfFieldState` for this template
945
+ */
946
+ componentDidUpdate(prevProps, prevState) {
947
+ const { formData, options, idSchema } = this.props;
948
+ const { selectedOption } = this.state;
949
+ let newState = this.state;
950
+ if (!deepEquals(prevProps.options, options)) {
951
+ const {
952
+ registry: { schemaUtils }
953
+ } = this.props;
954
+ const retrievedOptions = options.map((opt) => schemaUtils.retrieveSchema(opt, formData));
955
+ newState = { selectedOption, retrievedOptions };
956
+ }
957
+ if (!deepEquals(formData, prevProps.formData) && idSchema.$id === prevProps.idSchema.$id) {
958
+ const { retrievedOptions } = newState;
959
+ const matchingOption = this.getMatchingOption(selectedOption, formData, retrievedOptions);
960
+ if (prevState && matchingOption !== selectedOption) {
961
+ newState = { selectedOption: matchingOption, retrievedOptions };
962
+ }
963
+ }
964
+ if (newState !== this.state) {
965
+ this.setState(newState);
966
+ }
967
+ }
968
+ /** Determines the best matching option for the given `formData` and `options`.
969
+ *
970
+ * @param formData - The new formData
971
+ * @param options - The list of options to choose from
972
+ * @return - The index of the `option` that best matches the `formData`
973
+ */
974
+ getMatchingOption(selectedOption, formData, options) {
975
+ const {
976
+ schema,
977
+ registry: { schemaUtils }
978
+ } = this.props;
979
+ const discriminator = getDiscriminatorFieldFromSchema(schema);
980
+ const option = schemaUtils.getClosestMatchingOption(formData, options, selectedOption, discriminator);
981
+ return option;
982
+ }
983
+ getFieldId() {
984
+ const { idSchema, schema } = this.props;
985
+ return `${idSchema.$id}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`;
986
+ }
987
+ /** Renders the `AnyOfField` selector along with a `SchemaField` for the value of the `formData`
988
+ */
989
+ render() {
990
+ const {
991
+ name,
992
+ disabled = false,
993
+ errorSchema = {},
994
+ formContext,
995
+ onBlur,
996
+ onFocus,
997
+ registry,
998
+ schema,
999
+ uiSchema
1000
+ } = this.props;
1001
+ const { widgets: widgets2, fields: fields2, translateString, globalUiOptions, schemaUtils } = registry;
1002
+ const { SchemaField: _SchemaField } = fields2;
1003
+ const { selectedOption, retrievedOptions } = this.state;
1004
+ const {
1005
+ widget = "select",
1006
+ placeholder,
1007
+ autofocus,
1008
+ autocomplete,
1009
+ title = schema.title,
1010
+ ...uiOptions
1011
+ } = getUiOptions3(uiSchema, globalUiOptions);
1012
+ const Widget = getWidget3({ type: "number" }, widget, widgets2);
1013
+ const rawErrors = get2(errorSchema, ERRORS_KEY, []);
1014
+ const fieldErrorSchema = omit(errorSchema, [ERRORS_KEY]);
1015
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1016
+ const option = selectedOption >= 0 ? retrievedOptions[selectedOption] || null : null;
1017
+ let optionSchema;
1018
+ if (option) {
1019
+ const { oneOf, anyOf, ...remaining } = schema;
1020
+ unset(remaining, ADDITIONAL_PROPERTY_FLAG);
1021
+ optionSchema = !isEmpty(remaining) ? mergeSchemas(remaining, option) : option;
1022
+ }
1023
+ const translateEnum = title ? TranslatableString3.TitleOptionPrefix : TranslatableString3.OptionPrefix;
1024
+ const translateParams = title ? [title] : [];
1025
+ const enumOptions = retrievedOptions.map((opt, index) => ({
1026
+ label: opt.title || translateString(translateEnum, translateParams.concat(String(index + 1))),
1027
+ value: index
1028
+ }));
1029
+ return /* @__PURE__ */ jsxs("div", { className: "panel panel-default panel-body", children: [
1030
+ /* @__PURE__ */ jsx3("div", { className: "form-group", children: /* @__PURE__ */ jsx3(
1031
+ Widget,
1032
+ {
1033
+ id: this.getFieldId(),
1034
+ name: `${name}${schema.oneOf ? "__oneof_select" : "__anyof_select"}`,
1035
+ schema: { type: "number", default: 0 },
1036
+ onChange: this.onOptionChange,
1037
+ onBlur,
1038
+ onFocus,
1039
+ disabled: disabled || isEmpty(enumOptions),
1040
+ multiple: false,
1041
+ rawErrors,
1042
+ errorSchema: fieldErrorSchema,
1043
+ value: selectedOption >= 0 ? selectedOption : void 0,
1044
+ options: { enumOptions, ...uiOptions },
1045
+ registry,
1046
+ formContext,
1047
+ placeholder,
1048
+ autocomplete,
1049
+ autofocus,
1050
+ label: title ?? name,
1051
+ hideLabel: !displayLabel
1052
+ }
1053
+ ) }),
1054
+ option !== null && /* @__PURE__ */ jsx3(_SchemaField, { ...this.props, schema: optionSchema })
1055
+ ] });
1056
+ }
1057
+ };
1058
+ var MultiSchemaField_default = AnyOfField;
1059
+
1060
+ // src/components/fields/NumberField.tsx
1061
+ import { useState, useCallback } from "react";
1062
+ import { asNumber } from "@rjsf/utils";
1063
+ import { jsx as jsx4 } from "react/jsx-runtime";
1064
+ var trailingCharMatcherWithPrefix = /\.([0-9]*0)*$/;
1065
+ var trailingCharMatcher = /[0.]0*$/;
1066
+ function NumberField(props) {
1067
+ const { registry, onChange, formData, value: initialValue } = props;
1068
+ const [lastValue, setLastValue] = useState(initialValue);
1069
+ const { StringField: StringField2 } = registry.fields;
1070
+ let value = formData;
1071
+ const handleChange = useCallback(
1072
+ (value2) => {
1073
+ setLastValue(value2);
1074
+ if (`${value2}`.charAt(0) === ".") {
1075
+ value2 = `0${value2}`;
1076
+ }
1077
+ const processed = typeof value2 === "string" && value2.match(trailingCharMatcherWithPrefix) ? asNumber(value2.replace(trailingCharMatcher, "")) : asNumber(value2);
1078
+ onChange(processed);
1079
+ },
1080
+ [onChange]
1081
+ );
1082
+ if (typeof lastValue === "string" && typeof value === "number") {
1083
+ const re = new RegExp(`${value}`.replace(".", "\\.") + "\\.?0*$");
1084
+ if (lastValue.match(re)) {
1085
+ value = lastValue;
1086
+ }
1087
+ }
1088
+ return /* @__PURE__ */ jsx4(StringField2, { ...props, formData: value, onChange: handleChange });
1089
+ }
1090
+ var NumberField_default = NumberField;
1091
+
1092
+ // src/components/fields/ObjectField.tsx
1093
+ import { Component as Component3 } from "react";
1094
+ import {
1095
+ getTemplate as getTemplate2,
1096
+ getUiOptions as getUiOptions4,
1097
+ orderProperties,
1098
+ TranslatableString as TranslatableString4,
1099
+ ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG2,
1100
+ PROPERTIES_KEY,
1101
+ REF_KEY,
1102
+ ANY_OF_KEY,
1103
+ ONE_OF_KEY
1104
+ } from "@rjsf/utils";
1105
+ import Markdown from "markdown-to-jsx";
1106
+ import get3 from "lodash/get";
1107
+ import has from "lodash/has";
1108
+ import isObject3 from "lodash/isObject";
1109
+ import set2 from "lodash/set";
1110
+ import unset2 from "lodash/unset";
1111
+ import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
1112
+ var ObjectField = class extends Component3 {
1113
+ constructor() {
1114
+ super(...arguments);
1115
+ /** Set up the initial state */
1116
+ this.state = {
1117
+ wasPropertyKeyModified: false,
1118
+ additionalProperties: {}
1119
+ };
1120
+ /** Returns the `onPropertyChange` handler for the `name` field. Handles the special case where a user is attempting
1121
+ * to clear the data for a field added as an additional property. Calls the `onChange()` handler with the updated
1122
+ * formData.
1123
+ *
1124
+ * @param name - The name of the property
1125
+ * @param addedByAdditionalProperties - Flag indicating whether this property is an additional property
1126
+ * @returns - The onPropertyChange callback for the `name` property
1127
+ */
1128
+ this.onPropertyChange = (name, addedByAdditionalProperties = false) => {
1129
+ return (value, newErrorSchema, id) => {
1130
+ const { formData, onChange, errorSchema } = this.props;
1131
+ if (value === void 0 && addedByAdditionalProperties) {
1132
+ value = "";
1133
+ }
1134
+ const newFormData = { ...formData, [name]: value };
1135
+ onChange(
1136
+ newFormData,
1137
+ errorSchema && errorSchema && {
1138
+ ...errorSchema,
1139
+ [name]: newErrorSchema
1140
+ },
1141
+ id
1142
+ );
1143
+ };
1144
+ };
1145
+ /** Returns a callback to handle the onDropPropertyClick event for the given `key` which removes the old `key` data
1146
+ * and calls the `onChange` callback with it
1147
+ *
1148
+ * @param key - The key for which the drop callback is desired
1149
+ * @returns - The drop property click callback
1150
+ */
1151
+ this.onDropPropertyClick = (key) => {
1152
+ return (event) => {
1153
+ event.preventDefault();
1154
+ const { onChange, formData } = this.props;
1155
+ const copiedFormData = { ...formData };
1156
+ unset2(copiedFormData, key);
1157
+ onChange(copiedFormData);
1158
+ };
1159
+ };
1160
+ /** Computes the next available key name from the `preferredKey`, indexing through the already existing keys until one
1161
+ * that is already not assigned is found.
1162
+ *
1163
+ * @param preferredKey - The preferred name of a new key
1164
+ * @param [formData] - The form data in which to check if the desired key already exists
1165
+ * @returns - The name of the next available key from `preferredKey`
1166
+ */
1167
+ this.getAvailableKey = (preferredKey, formData) => {
1168
+ const { uiSchema, registry } = this.props;
1169
+ const { duplicateKeySuffixSeparator = "-" } = getUiOptions4(uiSchema, registry.globalUiOptions);
1170
+ let index = 0;
1171
+ let newKey = preferredKey;
1172
+ while (has(formData, newKey)) {
1173
+ newKey = `${preferredKey}${duplicateKeySuffixSeparator}${++index}`;
1174
+ }
1175
+ return newKey;
1176
+ };
1177
+ /** Returns a callback function that deals with the rename of a key for an additional property for a schema. That
1178
+ * callback will attempt to rename the key and move the existing data to that key, calling `onChange` when it does.
1179
+ *
1180
+ * @param oldValue - The old value of a field
1181
+ * @returns - The key change callback function
1182
+ */
1183
+ this.onKeyChange = (oldValue) => {
1184
+ return (value, newErrorSchema) => {
1185
+ if (oldValue === value) {
1186
+ return;
1187
+ }
1188
+ const { formData, onChange, errorSchema } = this.props;
1189
+ value = this.getAvailableKey(value, formData);
1190
+ const newFormData = {
1191
+ ...formData
1192
+ };
1193
+ const newKeys = { [oldValue]: value };
1194
+ const keyValues = Object.keys(newFormData).map((key) => {
1195
+ const newKey = newKeys[key] || key;
1196
+ return { [newKey]: newFormData[key] };
1197
+ });
1198
+ const renamedObj = Object.assign({}, ...keyValues);
1199
+ this.setState({ wasPropertyKeyModified: true });
1200
+ onChange(
1201
+ renamedObj,
1202
+ errorSchema && errorSchema && {
1203
+ ...errorSchema,
1204
+ [value]: newErrorSchema
1205
+ }
1206
+ );
1207
+ };
1208
+ };
1209
+ /** Handles the adding of a new additional property on the given `schema`. Calls the `onChange` callback once the new
1210
+ * default data for that field has been added to the formData.
1211
+ *
1212
+ * @param schema - The schema element to which the new property is being added
1213
+ */
1214
+ this.handleAddClick = (schema) => () => {
1215
+ if (!schema.additionalProperties) {
1216
+ return;
1217
+ }
1218
+ const { formData, onChange, registry } = this.props;
1219
+ const newFormData = { ...formData };
1220
+ let type = void 0;
1221
+ if (isObject3(schema.additionalProperties)) {
1222
+ type = schema.additionalProperties.type;
1223
+ let apSchema = schema.additionalProperties;
1224
+ if (REF_KEY in apSchema) {
1225
+ const { schemaUtils } = registry;
1226
+ apSchema = schemaUtils.retrieveSchema({ $ref: apSchema[REF_KEY] }, formData);
1227
+ type = apSchema.type;
1228
+ }
1229
+ if (!type && (ANY_OF_KEY in apSchema || ONE_OF_KEY in apSchema)) {
1230
+ type = "object";
1231
+ }
1232
+ }
1233
+ const newKey = this.getAvailableKey("newKey", newFormData);
1234
+ set2(newFormData, newKey, this.getDefaultValue(type));
1235
+ onChange(newFormData);
1236
+ };
1237
+ }
1238
+ /** Returns a flag indicating whether the `name` field is required in the object schema
1239
+ *
1240
+ * @param name - The name of the field to check for required-ness
1241
+ * @returns - True if the field `name` is required, false otherwise
1242
+ */
1243
+ isRequired(name) {
1244
+ const { schema } = this.props;
1245
+ return Array.isArray(schema.required) && schema.required.indexOf(name) !== -1;
1246
+ }
1247
+ /** Returns a default value to be used for a new additional schema property of the given `type`
1248
+ *
1249
+ * @param type - The type of the new additional schema property
1250
+ */
1251
+ getDefaultValue(type) {
1252
+ const {
1253
+ registry: { translateString }
1254
+ } = this.props;
1255
+ switch (type) {
1256
+ case "array":
1257
+ return [];
1258
+ case "boolean":
1259
+ return false;
1260
+ case "null":
1261
+ return null;
1262
+ case "number":
1263
+ return 0;
1264
+ case "object":
1265
+ return {};
1266
+ case "string":
1267
+ default:
1268
+ return translateString(TranslatableString4.NewStringDefault);
1269
+ }
1270
+ }
1271
+ /** Renders the `ObjectField` from the given props
1272
+ */
1273
+ render() {
1274
+ const {
1275
+ schema: rawSchema,
1276
+ uiSchema = {},
1277
+ formData,
1278
+ errorSchema,
1279
+ idSchema,
1280
+ name,
1281
+ required = false,
1282
+ disabled = false,
1283
+ readonly = false,
1284
+ hideError,
1285
+ idPrefix,
1286
+ idSeparator,
1287
+ onBlur,
1288
+ onFocus,
1289
+ registry
1290
+ } = this.props;
1291
+ const { fields: fields2, formContext, schemaUtils, translateString, globalUiOptions } = registry;
1292
+ const { SchemaField: SchemaField2 } = fields2;
1293
+ const schema = schemaUtils.retrieveSchema(rawSchema, formData);
1294
+ const uiOptions = getUiOptions4(uiSchema, globalUiOptions);
1295
+ const { properties: schemaProperties = {} } = schema;
1296
+ const title = uiOptions.title ?? schema.title ?? name;
1297
+ const description = uiOptions.description ?? schema.description;
1298
+ let orderedProperties;
1299
+ try {
1300
+ const properties = Object.keys(schemaProperties);
1301
+ orderedProperties = orderProperties(properties, uiOptions.order);
1302
+ } catch (err) {
1303
+ return /* @__PURE__ */ jsxs2("div", { children: [
1304
+ /* @__PURE__ */ jsx5("p", { className: "config-error", style: { color: "red" }, children: /* @__PURE__ */ jsx5(Markdown, { children: translateString(TranslatableString4.InvalidObjectField, [name || "root", err.message]) }) }),
1305
+ /* @__PURE__ */ jsx5("pre", { children: JSON.stringify(schema) })
1306
+ ] });
1307
+ }
1308
+ const Template = getTemplate2("ObjectFieldTemplate", registry, uiOptions);
1309
+ const templateProps = {
1310
+ // getDisplayLabel() always returns false for object types, so just check the `uiOptions.label`
1311
+ title: uiOptions.label === false ? "" : title,
1312
+ description: uiOptions.label === false ? void 0 : description,
1313
+ properties: orderedProperties.map((name2) => {
1314
+ const addedByAdditionalProperties = has(schema, [PROPERTIES_KEY, name2, ADDITIONAL_PROPERTY_FLAG2]);
1315
+ const fieldUiSchema = addedByAdditionalProperties ? uiSchema.additionalProperties : uiSchema[name2];
1316
+ const hidden = getUiOptions4(fieldUiSchema).widget === "hidden";
1317
+ const fieldIdSchema = get3(idSchema, [name2], {});
1318
+ return {
1319
+ content: /* @__PURE__ */ jsx5(
1320
+ SchemaField2,
1321
+ {
1322
+ name: name2,
1323
+ required: this.isRequired(name2),
1324
+ schema: get3(schema, [PROPERTIES_KEY, name2], {}),
1325
+ uiSchema: fieldUiSchema,
1326
+ errorSchema: get3(errorSchema, name2),
1327
+ idSchema: fieldIdSchema,
1328
+ idPrefix,
1329
+ idSeparator,
1330
+ formData: get3(formData, name2),
1331
+ formContext,
1332
+ wasPropertyKeyModified: this.state.wasPropertyKeyModified,
1333
+ onKeyChange: this.onKeyChange(name2),
1334
+ onChange: this.onPropertyChange(name2, addedByAdditionalProperties),
1335
+ onBlur,
1336
+ onFocus,
1337
+ registry,
1338
+ disabled,
1339
+ readonly,
1340
+ hideError,
1341
+ onDropPropertyClick: this.onDropPropertyClick
1342
+ },
1343
+ name2
1344
+ ),
1345
+ name: name2,
1346
+ readonly,
1347
+ disabled,
1348
+ required,
1349
+ hidden
1350
+ };
1351
+ }),
1352
+ readonly,
1353
+ disabled,
1354
+ required,
1355
+ idSchema,
1356
+ uiSchema,
1357
+ errorSchema,
1358
+ schema,
1359
+ formData,
1360
+ formContext,
1361
+ registry
1362
+ };
1363
+ return /* @__PURE__ */ jsx5(Template, { ...templateProps, onAddClick: this.handleAddClick });
1364
+ }
1365
+ };
1366
+ var ObjectField_default = ObjectField;
1367
+
1368
+ // src/components/fields/SchemaField.tsx
1369
+ import { useCallback as useCallback2, Component as Component4 } from "react";
1370
+ import {
1371
+ ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG3,
1372
+ deepEquals as deepEquals2,
1373
+ descriptionId,
1374
+ getSchemaType,
1375
+ getTemplate as getTemplate3,
1376
+ getUiOptions as getUiOptions5,
1377
+ ID_KEY,
1378
+ mergeObjects,
1379
+ TranslatableString as TranslatableString5,
1380
+ UI_OPTIONS_KEY
1381
+ } from "@rjsf/utils";
1382
+ import isObject4 from "lodash/isObject";
1383
+ import omit2 from "lodash/omit";
1384
+ import Markdown2 from "markdown-to-jsx";
1385
+ import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
1386
+ var COMPONENT_TYPES = {
1387
+ array: "ArrayField",
1388
+ boolean: "BooleanField",
1389
+ integer: "NumberField",
1390
+ number: "NumberField",
1391
+ object: "ObjectField",
1392
+ string: "StringField",
1393
+ null: "NullField"
1394
+ };
1395
+ function getFieldComponent(schema, uiOptions, idSchema, registry) {
1396
+ const field = uiOptions.field;
1397
+ const { fields: fields2, translateString } = registry;
1398
+ if (typeof field === "function") {
1399
+ return field;
1400
+ }
1401
+ if (typeof field === "string" && field in fields2) {
1402
+ return fields2[field];
1403
+ }
1404
+ const schemaType = getSchemaType(schema);
1405
+ const type = Array.isArray(schemaType) ? schemaType[0] : schemaType || "";
1406
+ const schemaId = schema.$id;
1407
+ let componentName = COMPONENT_TYPES[type];
1408
+ if (schemaId && schemaId in fields2) {
1409
+ componentName = schemaId;
1410
+ }
1411
+ if (!componentName && (schema.anyOf || schema.oneOf)) {
1412
+ return () => null;
1413
+ }
1414
+ return componentName in fields2 ? fields2[componentName] : () => {
1415
+ const UnsupportedFieldTemplate = getTemplate3(
1416
+ "UnsupportedFieldTemplate",
1417
+ registry,
1418
+ uiOptions
1419
+ );
1420
+ return /* @__PURE__ */ jsx6(
1421
+ UnsupportedFieldTemplate,
1422
+ {
1423
+ schema,
1424
+ idSchema,
1425
+ reason: translateString(TranslatableString5.UnknownFieldType, [String(schema.type)]),
1426
+ registry
1427
+ }
1428
+ );
1429
+ };
1430
+ }
1431
+ function SchemaFieldRender(props) {
1432
+ const {
1433
+ schema: _schema,
1434
+ idSchema: _idSchema,
1435
+ uiSchema,
1436
+ formData,
1437
+ errorSchema,
1438
+ idPrefix,
1439
+ idSeparator,
1440
+ name,
1441
+ onChange,
1442
+ onKeyChange,
1443
+ onDropPropertyClick,
1444
+ required,
1445
+ registry,
1446
+ wasPropertyKeyModified = false
1447
+ } = props;
1448
+ const { formContext, schemaUtils, globalUiOptions } = registry;
1449
+ const uiOptions = getUiOptions5(uiSchema, globalUiOptions);
1450
+ const FieldTemplate2 = getTemplate3("FieldTemplate", registry, uiOptions);
1451
+ const DescriptionFieldTemplate = getTemplate3(
1452
+ "DescriptionFieldTemplate",
1453
+ registry,
1454
+ uiOptions
1455
+ );
1456
+ const FieldHelpTemplate2 = getTemplate3("FieldHelpTemplate", registry, uiOptions);
1457
+ const FieldErrorTemplate2 = getTemplate3("FieldErrorTemplate", registry, uiOptions);
1458
+ const schema = schemaUtils.retrieveSchema(_schema, formData);
1459
+ const fieldId = _idSchema[ID_KEY];
1460
+ const idSchema = mergeObjects(
1461
+ schemaUtils.toIdSchema(schema, fieldId, formData, idPrefix, idSeparator),
1462
+ _idSchema
1463
+ );
1464
+ const handleFieldComponentChange = useCallback2(
1465
+ (formData2, newErrorSchema, id2) => {
1466
+ const theId = id2 || fieldId;
1467
+ return onChange(formData2, newErrorSchema, theId);
1468
+ },
1469
+ [fieldId, onChange]
1470
+ );
1471
+ const FieldComponent = getFieldComponent(schema, uiOptions, idSchema, registry);
1472
+ const disabled = Boolean(props.disabled || uiOptions.disabled);
1473
+ const readonly = Boolean(props.readonly || uiOptions.readonly || props.schema.readOnly || schema.readOnly);
1474
+ const uiSchemaHideError = uiOptions.hideError;
1475
+ const hideError = uiSchemaHideError === void 0 ? props.hideError : Boolean(uiSchemaHideError);
1476
+ const autofocus = Boolean(props.autofocus || uiOptions.autofocus);
1477
+ if (Object.keys(schema).length === 0) {
1478
+ return null;
1479
+ }
1480
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1481
+ const { __errors, ...fieldErrorSchema } = errorSchema || {};
1482
+ const fieldUiSchema = omit2(uiSchema, ["ui:classNames", "classNames", "ui:style"]);
1483
+ if (UI_OPTIONS_KEY in fieldUiSchema) {
1484
+ fieldUiSchema[UI_OPTIONS_KEY] = omit2(fieldUiSchema[UI_OPTIONS_KEY], ["classNames", "style"]);
1485
+ }
1486
+ const field = /* @__PURE__ */ jsx6(
1487
+ FieldComponent,
1488
+ {
1489
+ ...props,
1490
+ onChange: handleFieldComponentChange,
1491
+ idSchema,
1492
+ schema,
1493
+ uiSchema: fieldUiSchema,
1494
+ disabled,
1495
+ readonly,
1496
+ hideError,
1497
+ autofocus,
1498
+ errorSchema: fieldErrorSchema,
1499
+ formContext,
1500
+ rawErrors: __errors
1501
+ }
1502
+ );
1503
+ const id = idSchema[ID_KEY];
1504
+ let label;
1505
+ if (wasPropertyKeyModified) {
1506
+ label = name;
1507
+ } else {
1508
+ label = ADDITIONAL_PROPERTY_FLAG3 in schema ? name : uiOptions.title || props.schema.title || schema.title || name;
1509
+ }
1510
+ const description = uiOptions.description || props.schema.description || schema.description || "";
1511
+ const richDescription = uiOptions.enableMarkdownInDescription ? /* @__PURE__ */ jsx6(Markdown2, { children: description }) : description;
1512
+ const help = uiOptions.help;
1513
+ const hidden = uiOptions.widget === "hidden";
1514
+ const classNames = ["form-group", "field", `field-${getSchemaType(schema)}`];
1515
+ if (!hideError && __errors && __errors.length > 0) {
1516
+ classNames.push("field-error has-error has-danger");
1517
+ }
1518
+ if (uiSchema?.classNames) {
1519
+ if (true) {
1520
+ console.warn(
1521
+ "'uiSchema.classNames' is deprecated and may be removed in a major release; Use 'ui:classNames' instead."
1522
+ );
1523
+ }
1524
+ classNames.push(uiSchema.classNames);
1525
+ }
1526
+ if (uiOptions.classNames) {
1527
+ classNames.push(uiOptions.classNames);
1528
+ }
1529
+ const helpComponent = /* @__PURE__ */ jsx6(
1530
+ FieldHelpTemplate2,
1531
+ {
1532
+ help,
1533
+ idSchema,
1534
+ schema,
1535
+ uiSchema,
1536
+ hasErrors: !hideError && __errors && __errors.length > 0,
1537
+ registry
1538
+ }
1539
+ );
1540
+ const errorsComponent = hideError || schema.anyOf || schema.oneOf ? void 0 : /* @__PURE__ */ jsx6(
1541
+ FieldErrorTemplate2,
1542
+ {
1543
+ errors: __errors,
1544
+ errorSchema,
1545
+ idSchema,
1546
+ schema,
1547
+ uiSchema,
1548
+ registry
1549
+ }
1550
+ );
1551
+ const fieldProps = {
1552
+ description: /* @__PURE__ */ jsx6(
1553
+ DescriptionFieldTemplate,
1554
+ {
1555
+ id: descriptionId(id),
1556
+ description: richDescription,
1557
+ schema,
1558
+ uiSchema,
1559
+ registry
1560
+ }
1561
+ ),
1562
+ rawDescription: description,
1563
+ help: helpComponent,
1564
+ rawHelp: typeof help === "string" ? help : void 0,
1565
+ errors: errorsComponent,
1566
+ rawErrors: hideError ? void 0 : __errors,
1567
+ id,
1568
+ label,
1569
+ hidden,
1570
+ onChange,
1571
+ onKeyChange,
1572
+ onDropPropertyClick,
1573
+ required,
1574
+ disabled,
1575
+ readonly,
1576
+ hideError,
1577
+ displayLabel,
1578
+ classNames: classNames.join(" ").trim(),
1579
+ style: uiOptions.style,
1580
+ formContext,
1581
+ formData,
1582
+ schema,
1583
+ uiSchema,
1584
+ registry
1585
+ };
1586
+ const _AnyOfField = registry.fields.AnyOfField;
1587
+ const _OneOfField = registry.fields.OneOfField;
1588
+ const isReplacingAnyOrOneOf = uiSchema?.["ui:field"] && uiSchema?.["ui:fieldReplacesAnyOrOneOf"] === true;
1589
+ return /* @__PURE__ */ jsx6(FieldTemplate2, { ...fieldProps, children: /* @__PURE__ */ jsxs3(Fragment, { children: [
1590
+ field,
1591
+ schema.anyOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx6(
1592
+ _AnyOfField,
1593
+ {
1594
+ name,
1595
+ disabled,
1596
+ readonly,
1597
+ hideError,
1598
+ errorSchema,
1599
+ formData,
1600
+ formContext,
1601
+ idPrefix,
1602
+ idSchema,
1603
+ idSeparator,
1604
+ onBlur: props.onBlur,
1605
+ onChange: props.onChange,
1606
+ onFocus: props.onFocus,
1607
+ options: schema.anyOf.map(
1608
+ (_schema2) => schemaUtils.retrieveSchema(isObject4(_schema2) ? _schema2 : {}, formData)
1609
+ ),
1610
+ registry,
1611
+ schema,
1612
+ uiSchema
1613
+ }
1614
+ ),
1615
+ schema.oneOf && !isReplacingAnyOrOneOf && !schemaUtils.isSelect(schema) && /* @__PURE__ */ jsx6(
1616
+ _OneOfField,
1617
+ {
1618
+ name,
1619
+ disabled,
1620
+ readonly,
1621
+ hideError,
1622
+ errorSchema,
1623
+ formData,
1624
+ formContext,
1625
+ idPrefix,
1626
+ idSchema,
1627
+ idSeparator,
1628
+ onBlur: props.onBlur,
1629
+ onChange: props.onChange,
1630
+ onFocus: props.onFocus,
1631
+ options: schema.oneOf.map(
1632
+ (_schema2) => schemaUtils.retrieveSchema(isObject4(_schema2) ? _schema2 : {}, formData)
1633
+ ),
1634
+ registry,
1635
+ schema,
1636
+ uiSchema
1637
+ }
1638
+ )
1639
+ ] }) });
1640
+ }
1641
+ var SchemaField = class extends Component4 {
1642
+ shouldComponentUpdate(nextProps) {
1643
+ return !deepEquals2(this.props, nextProps);
1644
+ }
1645
+ render() {
1646
+ return /* @__PURE__ */ jsx6(SchemaFieldRender, { ...this.props });
1647
+ }
1648
+ };
1649
+ var SchemaField_default = SchemaField;
1650
+
1651
+ // src/components/fields/StringField.tsx
1652
+ import {
1653
+ getWidget as getWidget4,
1654
+ getUiOptions as getUiOptions6,
1655
+ optionsList as optionsList3,
1656
+ hasWidget
1657
+ } from "@rjsf/utils";
1658
+ import { jsx as jsx7 } from "react/jsx-runtime";
1659
+ function StringField(props) {
1660
+ const {
1661
+ schema,
1662
+ name,
1663
+ uiSchema,
1664
+ idSchema,
1665
+ formData,
1666
+ required,
1667
+ disabled = false,
1668
+ readonly = false,
1669
+ autofocus = false,
1670
+ onChange,
1671
+ onBlur,
1672
+ onFocus,
1673
+ registry,
1674
+ rawErrors
1675
+ } = props;
1676
+ const { title, format } = schema;
1677
+ const { widgets: widgets2, formContext, schemaUtils, globalUiOptions } = registry;
1678
+ const enumOptions = schemaUtils.isSelect(schema) ? optionsList3(schema) : void 0;
1679
+ let defaultWidget = enumOptions ? "select" : "text";
1680
+ if (format && hasWidget(schema, format, widgets2)) {
1681
+ defaultWidget = format;
1682
+ }
1683
+ const { widget = defaultWidget, placeholder = "", title: uiTitle, ...options } = getUiOptions6(uiSchema);
1684
+ const displayLabel = schemaUtils.getDisplayLabel(schema, uiSchema, globalUiOptions);
1685
+ const label = uiTitle ?? title ?? name;
1686
+ const Widget = getWidget4(schema, widget, widgets2);
1687
+ return /* @__PURE__ */ jsx7(
1688
+ Widget,
1689
+ {
1690
+ options: { ...options, enumOptions },
1691
+ schema,
1692
+ uiSchema,
1693
+ id: idSchema.$id,
1694
+ name,
1695
+ label,
1696
+ hideLabel: !displayLabel,
1697
+ value: formData,
1698
+ onChange,
1699
+ onBlur,
1700
+ onFocus,
1701
+ required,
1702
+ disabled,
1703
+ readonly,
1704
+ formContext,
1705
+ autofocus,
1706
+ registry,
1707
+ placeholder,
1708
+ rawErrors
1709
+ }
1710
+ );
1711
+ }
1712
+ var StringField_default = StringField;
1713
+
1714
+ // src/components/fields/NullField.tsx
1715
+ import { useEffect } from "react";
1716
+ function NullField(props) {
1717
+ const { formData, onChange } = props;
1718
+ useEffect(() => {
1719
+ if (formData === void 0) {
1720
+ onChange(null);
1721
+ }
1722
+ }, [formData, onChange]);
1723
+ return null;
1724
+ }
1725
+ var NullField_default = NullField;
1726
+
1727
+ // src/components/fields/index.ts
1728
+ function fields() {
1729
+ return {
1730
+ AnyOfField: MultiSchemaField_default,
1731
+ ArrayField: ArrayField_default,
1732
+ // ArrayField falls back to SchemaField if ArraySchemaField is not defined, which it isn't by default
1733
+ BooleanField: BooleanField_default,
1734
+ NumberField: NumberField_default,
1735
+ ObjectField: ObjectField_default,
1736
+ OneOfField: MultiSchemaField_default,
1737
+ SchemaField: SchemaField_default,
1738
+ StringField: StringField_default,
1739
+ NullField: NullField_default
1740
+ };
1741
+ }
1742
+ var fields_default = fields;
1743
+
1744
+ // src/components/templates/ArrayFieldDescriptionTemplate.tsx
1745
+ import {
1746
+ descriptionId as descriptionId2,
1747
+ getTemplate as getTemplate4,
1748
+ getUiOptions as getUiOptions7
1749
+ } from "@rjsf/utils";
1750
+ import { jsx as jsx8 } from "react/jsx-runtime";
1751
+ function ArrayFieldDescriptionTemplate(props) {
1752
+ const { idSchema, description, registry, schema, uiSchema } = props;
1753
+ const options = getUiOptions7(uiSchema, registry.globalUiOptions);
1754
+ const { label: displayLabel = true } = options;
1755
+ if (!description || !displayLabel) {
1756
+ return null;
1757
+ }
1758
+ const DescriptionFieldTemplate = getTemplate4(
1759
+ "DescriptionFieldTemplate",
1760
+ registry,
1761
+ options
1762
+ );
1763
+ return /* @__PURE__ */ jsx8(
1764
+ DescriptionFieldTemplate,
1765
+ {
1766
+ id: descriptionId2(idSchema),
1767
+ description,
1768
+ schema,
1769
+ uiSchema,
1770
+ registry
1771
+ }
1772
+ );
1773
+ }
1774
+
1775
+ // src/components/templates/ArrayFieldItemTemplate.tsx
1776
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
1777
+ function ArrayFieldItemTemplate(props) {
1778
+ const {
1779
+ children,
1780
+ className,
1781
+ disabled,
1782
+ hasToolbar,
1783
+ hasMoveDown,
1784
+ hasMoveUp,
1785
+ hasRemove,
1786
+ hasCopy,
1787
+ index,
1788
+ onCopyIndexClick,
1789
+ onDropIndexClick,
1790
+ onReorderClick,
1791
+ readonly,
1792
+ registry,
1793
+ uiSchema
1794
+ } = props;
1795
+ const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
1796
+ const btnStyle = {
1797
+ flex: 1,
1798
+ paddingLeft: 6,
1799
+ paddingRight: 6,
1800
+ fontWeight: "bold"
1801
+ };
1802
+ return /* @__PURE__ */ jsxs4("div", { className, children: [
1803
+ /* @__PURE__ */ jsx9("div", { className: hasToolbar ? "col-xs-9" : "col-xs-12", children }),
1804
+ hasToolbar && /* @__PURE__ */ jsx9("div", { className: "col-xs-3 array-item-toolbox", children: /* @__PURE__ */ jsxs4(
1805
+ "div",
1806
+ {
1807
+ className: "btn-group",
1808
+ style: {
1809
+ display: "flex",
1810
+ justifyContent: "space-around"
1811
+ },
1812
+ children: [
1813
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx9(
1814
+ MoveUpButton2,
1815
+ {
1816
+ style: btnStyle,
1817
+ disabled: disabled || readonly || !hasMoveUp,
1818
+ onClick: onReorderClick(index, index - 1),
1819
+ uiSchema,
1820
+ registry
1821
+ }
1822
+ ),
1823
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsx9(
1824
+ MoveDownButton2,
1825
+ {
1826
+ style: btnStyle,
1827
+ disabled: disabled || readonly || !hasMoveDown,
1828
+ onClick: onReorderClick(index, index + 1),
1829
+ uiSchema,
1830
+ registry
1831
+ }
1832
+ ),
1833
+ hasCopy && /* @__PURE__ */ jsx9(
1834
+ CopyButton2,
1835
+ {
1836
+ style: btnStyle,
1837
+ disabled: disabled || readonly,
1838
+ onClick: onCopyIndexClick(index),
1839
+ uiSchema,
1840
+ registry
1841
+ }
1842
+ ),
1843
+ hasRemove && /* @__PURE__ */ jsx9(
1844
+ RemoveButton2,
1845
+ {
1846
+ style: btnStyle,
1847
+ disabled: disabled || readonly,
1848
+ onClick: onDropIndexClick(index),
1849
+ uiSchema,
1850
+ registry
1851
+ }
1852
+ )
1853
+ ]
1854
+ }
1855
+ ) })
1856
+ ] });
1857
+ }
1858
+
1859
+ // src/components/templates/ArrayFieldTemplate.tsx
1860
+ import {
1861
+ getTemplate as getTemplate5,
1862
+ getUiOptions as getUiOptions8
1863
+ } from "@rjsf/utils";
1864
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
1865
+ function ArrayFieldTemplate(props) {
1866
+ const {
1867
+ canAdd,
1868
+ className,
1869
+ disabled,
1870
+ idSchema,
1871
+ uiSchema,
1872
+ items,
1873
+ onAddClick,
1874
+ readonly,
1875
+ registry,
1876
+ required,
1877
+ schema,
1878
+ title
1879
+ } = props;
1880
+ const uiOptions = getUiOptions8(uiSchema);
1881
+ const ArrayFieldDescriptionTemplate2 = getTemplate5(
1882
+ "ArrayFieldDescriptionTemplate",
1883
+ registry,
1884
+ uiOptions
1885
+ );
1886
+ const ArrayFieldItemTemplate2 = getTemplate5(
1887
+ "ArrayFieldItemTemplate",
1888
+ registry,
1889
+ uiOptions
1890
+ );
1891
+ const ArrayFieldTitleTemplate2 = getTemplate5(
1892
+ "ArrayFieldTitleTemplate",
1893
+ registry,
1894
+ uiOptions
1895
+ );
1896
+ const {
1897
+ ButtonTemplates: { AddButton: AddButton2 }
1898
+ } = registry.templates;
1899
+ return /* @__PURE__ */ jsxs5("fieldset", { className, id: idSchema.$id, children: [
1900
+ /* @__PURE__ */ jsx10(
1901
+ ArrayFieldTitleTemplate2,
1902
+ {
1903
+ idSchema,
1904
+ title: uiOptions.title || title,
1905
+ required,
1906
+ schema,
1907
+ uiSchema,
1908
+ registry
1909
+ }
1910
+ ),
1911
+ /* @__PURE__ */ jsx10(
1912
+ ArrayFieldDescriptionTemplate2,
1913
+ {
1914
+ idSchema,
1915
+ description: uiOptions.description || schema.description,
1916
+ schema,
1917
+ uiSchema,
1918
+ registry
1919
+ }
1920
+ ),
1921
+ /* @__PURE__ */ jsx10("div", { className: "row array-item-list", children: items && items.map(({ key, ...itemProps }) => /* @__PURE__ */ jsx10(ArrayFieldItemTemplate2, { ...itemProps }, key)) }),
1922
+ canAdd && /* @__PURE__ */ jsx10(
1923
+ AddButton2,
1924
+ {
1925
+ className: "array-item-add",
1926
+ onClick: onAddClick,
1927
+ disabled: disabled || readonly,
1928
+ uiSchema,
1929
+ registry
1930
+ }
1931
+ )
1932
+ ] });
1933
+ }
1934
+
1935
+ // src/components/templates/ArrayFieldTitleTemplate.tsx
1936
+ import {
1937
+ getTemplate as getTemplate6,
1938
+ getUiOptions as getUiOptions9,
1939
+ titleId
1940
+ } from "@rjsf/utils";
1941
+ import { jsx as jsx11 } from "react/jsx-runtime";
1942
+ function ArrayFieldTitleTemplate(props) {
1943
+ const { idSchema, title, schema, uiSchema, required, registry } = props;
1944
+ const options = getUiOptions9(uiSchema, registry.globalUiOptions);
1945
+ const { label: displayLabel = true } = options;
1946
+ if (!title || !displayLabel) {
1947
+ return null;
1948
+ }
1949
+ const TitleFieldTemplate = getTemplate6(
1950
+ "TitleFieldTemplate",
1951
+ registry,
1952
+ options
1953
+ );
1954
+ return /* @__PURE__ */ jsx11(
1955
+ TitleFieldTemplate,
1956
+ {
1957
+ id: titleId(idSchema),
1958
+ title,
1959
+ required,
1960
+ schema,
1961
+ uiSchema,
1962
+ registry
1963
+ }
1964
+ );
1965
+ }
1966
+
1967
+ // src/components/templates/BaseInputTemplate.tsx
1968
+ import { useCallback as useCallback3 } from "react";
1969
+ import {
1970
+ ariaDescribedByIds,
1971
+ examplesId,
1972
+ getInputProps
1973
+ } from "@rjsf/utils";
1974
+ import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs6 } from "react/jsx-runtime";
1975
+ function BaseInputTemplate(props) {
1976
+ const {
1977
+ id,
1978
+ name,
1979
+ // remove this from ...rest
1980
+ value,
1981
+ readonly,
1982
+ disabled,
1983
+ autofocus,
1984
+ onBlur,
1985
+ onFocus,
1986
+ onChange,
1987
+ onChangeOverride,
1988
+ options,
1989
+ schema,
1990
+ uiSchema,
1991
+ formContext,
1992
+ registry,
1993
+ rawErrors,
1994
+ type,
1995
+ hideLabel,
1996
+ // remove this from ...rest
1997
+ hideError,
1998
+ // remove this from ...rest
1999
+ ...rest
2000
+ } = props;
2001
+ if (!id) {
2002
+ console.log("No id for", props);
2003
+ throw new Error(`no id for props ${JSON.stringify(props)}`);
2004
+ }
2005
+ const inputProps = {
2006
+ ...rest,
2007
+ ...getInputProps(schema, type, options)
2008
+ };
2009
+ let inputValue;
2010
+ if (inputProps.type === "number" || inputProps.type === "integer") {
2011
+ inputValue = value || value === 0 ? value : "";
2012
+ } else {
2013
+ inputValue = value == null ? "" : value;
2014
+ }
2015
+ const _onChange = useCallback3(
2016
+ ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
2017
+ [onChange, options]
2018
+ );
2019
+ const _onBlur = useCallback3(({ target: { value: value2 } }) => onBlur(id, value2), [onBlur, id]);
2020
+ const _onFocus = useCallback3(
2021
+ ({ target: { value: value2 } }) => onFocus(id, value2),
2022
+ [onFocus, id]
2023
+ );
2024
+ return /* @__PURE__ */ jsxs6(Fragment2, { children: [
2025
+ /* @__PURE__ */ jsx12(
2026
+ "input",
2027
+ {
2028
+ id,
2029
+ name: id,
2030
+ className: "form-control",
2031
+ readOnly: readonly,
2032
+ disabled,
2033
+ autoFocus: autofocus,
2034
+ value: inputValue,
2035
+ ...inputProps,
2036
+ list: schema.examples ? examplesId(id) : void 0,
2037
+ onChange: onChangeOverride || _onChange,
2038
+ onBlur: _onBlur,
2039
+ onFocus: _onFocus,
2040
+ "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
2041
+ }
2042
+ ),
2043
+ Array.isArray(schema.examples) && /* @__PURE__ */ jsx12("datalist", { id: examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
2044
+ return /* @__PURE__ */ jsx12("option", { value: example }, example);
2045
+ }) }, `datalist_${id}`)
2046
+ ] });
2047
+ }
2048
+
2049
+ // src/components/templates/ButtonTemplates/SubmitButton.tsx
2050
+ import { getSubmitButtonOptions } from "@rjsf/utils";
2051
+ import { jsx as jsx13 } from "react/jsx-runtime";
2052
+ function SubmitButton({ uiSchema }) {
2053
+ const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions(uiSchema);
2054
+ if (norender) {
2055
+ return null;
2056
+ }
2057
+ return /* @__PURE__ */ jsx13("div", { children: /* @__PURE__ */ jsx13("button", { type: "submit", ...submitButtonProps, className: `btn btn-info ${submitButtonProps.className || ""}`, children: submitText }) });
2058
+ }
2059
+
2060
+ // src/components/templates/ButtonTemplates/AddButton.tsx
2061
+ import { TranslatableString as TranslatableString7 } from "@rjsf/utils";
2062
+
2063
+ // src/components/templates/ButtonTemplates/IconButton.tsx
2064
+ import { TranslatableString as TranslatableString6 } from "@rjsf/utils";
2065
+ import { jsx as jsx14 } from "react/jsx-runtime";
2066
+ function IconButton(props) {
2067
+ const { iconType = "default", icon, className, uiSchema, registry, ...otherProps } = props;
2068
+ return /* @__PURE__ */ jsx14("button", { type: "button", className: `btn btn-${iconType} ${className}`, ...otherProps, children: /* @__PURE__ */ jsx14("i", { className: `glyphicon glyphicon-${icon}` }) });
2069
+ }
2070
+ function CopyButton(props) {
2071
+ const {
2072
+ registry: { translateString }
2073
+ } = props;
2074
+ return /* @__PURE__ */ jsx14(
2075
+ IconButton,
2076
+ {
2077
+ title: translateString(TranslatableString6.CopyButton),
2078
+ className: "array-item-copy",
2079
+ ...props,
2080
+ icon: "copy"
2081
+ }
2082
+ );
2083
+ }
2084
+ function MoveDownButton(props) {
2085
+ const {
2086
+ registry: { translateString }
2087
+ } = props;
2088
+ return /* @__PURE__ */ jsx14(
2089
+ IconButton,
2090
+ {
2091
+ title: translateString(TranslatableString6.MoveDownButton),
2092
+ className: "array-item-move-down",
2093
+ ...props,
2094
+ icon: "arrow-down"
2095
+ }
2096
+ );
2097
+ }
2098
+ function MoveUpButton(props) {
2099
+ const {
2100
+ registry: { translateString }
2101
+ } = props;
2102
+ return /* @__PURE__ */ jsx14(
2103
+ IconButton,
2104
+ {
2105
+ title: translateString(TranslatableString6.MoveUpButton),
2106
+ className: "array-item-move-up",
2107
+ ...props,
2108
+ icon: "arrow-up"
2109
+ }
2110
+ );
2111
+ }
2112
+ function RemoveButton(props) {
2113
+ const {
2114
+ registry: { translateString }
2115
+ } = props;
2116
+ return /* @__PURE__ */ jsx14(
2117
+ IconButton,
2118
+ {
2119
+ title: translateString(TranslatableString6.RemoveButton),
2120
+ className: "array-item-remove",
2121
+ ...props,
2122
+ iconType: "danger",
2123
+ icon: "remove"
2124
+ }
2125
+ );
2126
+ }
2127
+
2128
+ // src/components/templates/ButtonTemplates/AddButton.tsx
2129
+ import { jsx as jsx15 } from "react/jsx-runtime";
2130
+ function AddButton({
2131
+ className,
2132
+ onClick,
2133
+ disabled,
2134
+ registry
2135
+ }) {
2136
+ const { translateString } = registry;
2137
+ return /* @__PURE__ */ jsx15("div", { className: "row", children: /* @__PURE__ */ jsx15("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsx15(
2138
+ IconButton,
2139
+ {
2140
+ iconType: "info",
2141
+ icon: "plus",
2142
+ className: "btn-add col-xs-12",
2143
+ title: translateString(TranslatableString7.AddButton),
2144
+ onClick,
2145
+ disabled,
2146
+ registry
2147
+ }
2148
+ ) }) });
2149
+ }
2150
+
2151
+ // src/components/templates/ButtonTemplates/index.ts
2152
+ function buttonTemplates() {
2153
+ return {
2154
+ SubmitButton,
2155
+ AddButton,
2156
+ CopyButton,
2157
+ MoveDownButton,
2158
+ MoveUpButton,
2159
+ RemoveButton
2160
+ };
2161
+ }
2162
+ var ButtonTemplates_default = buttonTemplates;
2163
+
2164
+ // src/components/templates/DescriptionField.tsx
2165
+ import { jsx as jsx16 } from "react/jsx-runtime";
2166
+ function DescriptionField(props) {
2167
+ const { id, description } = props;
2168
+ if (!description) {
2169
+ return null;
2170
+ }
2171
+ if (typeof description === "string") {
2172
+ return /* @__PURE__ */ jsx16("p", { id, className: "field-description", children: description });
2173
+ } else {
2174
+ return /* @__PURE__ */ jsx16("div", { id, className: "field-description", children: description });
2175
+ }
2176
+ }
2177
+
2178
+ // src/components/templates/ErrorList.tsx
2179
+ import {
2180
+ TranslatableString as TranslatableString8
2181
+ } from "@rjsf/utils";
2182
+ import { jsx as jsx17, jsxs as jsxs7 } from "react/jsx-runtime";
2183
+ function ErrorList({
2184
+ errors,
2185
+ registry
2186
+ }) {
2187
+ const { translateString } = registry;
2188
+ return /* @__PURE__ */ jsxs7("div", { className: "panel panel-danger errors", children: [
2189
+ /* @__PURE__ */ jsx17("div", { className: "panel-heading", children: /* @__PURE__ */ jsx17("h3", { className: "panel-title", children: translateString(TranslatableString8.ErrorsLabel) }) }),
2190
+ /* @__PURE__ */ jsx17("ul", { className: "list-group", children: errors.map((error, i) => {
2191
+ return /* @__PURE__ */ jsx17("li", { className: "list-group-item text-danger", children: error.stack }, i);
2192
+ }) })
2193
+ ] });
2194
+ }
2195
+
2196
+ // src/components/templates/FieldTemplate/FieldTemplate.tsx
2197
+ import {
2198
+ getTemplate as getTemplate7,
2199
+ getUiOptions as getUiOptions10
2200
+ } from "@rjsf/utils";
2201
+
2202
+ // src/components/templates/FieldTemplate/Label.tsx
2203
+ import { jsx as jsx18, jsxs as jsxs8 } from "react/jsx-runtime";
2204
+ var REQUIRED_FIELD_SYMBOL = "*";
2205
+ function Label(props) {
2206
+ const { label, required, id } = props;
2207
+ if (!label) {
2208
+ return null;
2209
+ }
2210
+ return /* @__PURE__ */ jsxs8("label", { className: "control-label", htmlFor: id, children: [
2211
+ label,
2212
+ required && /* @__PURE__ */ jsx18("span", { className: "required", children: REQUIRED_FIELD_SYMBOL })
2213
+ ] });
2214
+ }
2215
+
2216
+ // src/components/templates/FieldTemplate/FieldTemplate.tsx
2217
+ import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
2218
+ function FieldTemplate(props) {
2219
+ const { id, label, children, errors, help, description, hidden, required, displayLabel, registry, uiSchema } = props;
2220
+ const uiOptions = getUiOptions10(uiSchema);
2221
+ const WrapIfAdditionalTemplate2 = getTemplate7(
2222
+ "WrapIfAdditionalTemplate",
2223
+ registry,
2224
+ uiOptions
2225
+ );
2226
+ if (hidden) {
2227
+ return /* @__PURE__ */ jsx19("div", { className: "hidden", children });
2228
+ }
2229
+ return /* @__PURE__ */ jsxs9(WrapIfAdditionalTemplate2, { ...props, children: [
2230
+ displayLabel && /* @__PURE__ */ jsx19(Label, { label, required, id }),
2231
+ displayLabel && description ? description : null,
2232
+ children,
2233
+ errors,
2234
+ help
2235
+ ] });
2236
+ }
2237
+
2238
+ // src/components/templates/FieldTemplate/index.ts
2239
+ var FieldTemplate_default = FieldTemplate;
2240
+
2241
+ // src/components/templates/FieldErrorTemplate.tsx
2242
+ import { errorId } from "@rjsf/utils";
2243
+ import { jsx as jsx20 } from "react/jsx-runtime";
2244
+ function FieldErrorTemplate(props) {
2245
+ const { errors = [], idSchema } = props;
2246
+ if (errors.length === 0) {
2247
+ return null;
2248
+ }
2249
+ const id = errorId(idSchema);
2250
+ return /* @__PURE__ */ jsx20("div", { children: /* @__PURE__ */ jsx20("ul", { id, className: "error-detail bs-callout bs-callout-info", children: errors.filter((elem) => !!elem).map((error, index) => {
2251
+ return /* @__PURE__ */ jsx20("li", { className: "text-danger", children: error }, index);
2252
+ }) }) });
2253
+ }
2254
+
2255
+ // src/components/templates/FieldHelpTemplate.tsx
2256
+ import { helpId } from "@rjsf/utils";
2257
+ import { jsx as jsx21 } from "react/jsx-runtime";
2258
+ function FieldHelpTemplate(props) {
2259
+ const { idSchema, help } = props;
2260
+ if (!help) {
2261
+ return null;
2262
+ }
2263
+ const id = helpId(idSchema);
2264
+ if (typeof help === "string") {
2265
+ return /* @__PURE__ */ jsx21("p", { id, className: "help-block", children: help });
2266
+ }
2267
+ return /* @__PURE__ */ jsx21("div", { id, className: "help-block", children: help });
2268
+ }
2269
+
2270
+ // src/components/templates/ObjectFieldTemplate.tsx
2271
+ import {
2272
+ canExpand,
2273
+ descriptionId as descriptionId3,
2274
+ getTemplate as getTemplate8,
2275
+ getUiOptions as getUiOptions11,
2276
+ titleId as titleId2
2277
+ } from "@rjsf/utils";
2278
+ import { jsx as jsx22, jsxs as jsxs10 } from "react/jsx-runtime";
2279
+ function ObjectFieldTemplate(props) {
2280
+ const {
2281
+ description,
2282
+ disabled,
2283
+ formData,
2284
+ idSchema,
2285
+ onAddClick,
2286
+ properties,
2287
+ readonly,
2288
+ registry,
2289
+ required,
2290
+ schema,
2291
+ title,
2292
+ uiSchema
2293
+ } = props;
2294
+ const options = getUiOptions11(uiSchema);
2295
+ const TitleFieldTemplate = getTemplate8("TitleFieldTemplate", registry, options);
2296
+ const DescriptionFieldTemplate = getTemplate8(
2297
+ "DescriptionFieldTemplate",
2298
+ registry,
2299
+ options
2300
+ );
2301
+ const {
2302
+ ButtonTemplates: { AddButton: AddButton2 }
2303
+ } = registry.templates;
2304
+ return /* @__PURE__ */ jsxs10("fieldset", { id: idSchema.$id, children: [
2305
+ title && /* @__PURE__ */ jsx22(
2306
+ TitleFieldTemplate,
2307
+ {
2308
+ id: titleId2(idSchema),
2309
+ title,
2310
+ required,
2311
+ schema,
2312
+ uiSchema,
2313
+ registry
2314
+ }
2315
+ ),
2316
+ description && /* @__PURE__ */ jsx22(
2317
+ DescriptionFieldTemplate,
2318
+ {
2319
+ id: descriptionId3(idSchema),
2320
+ description,
2321
+ schema,
2322
+ uiSchema,
2323
+ registry
2324
+ }
2325
+ ),
2326
+ properties.map((prop) => prop.content),
2327
+ canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx22(
2328
+ AddButton2,
2329
+ {
2330
+ className: "object-property-expand",
2331
+ onClick: onAddClick(schema),
2332
+ disabled: disabled || readonly,
2333
+ uiSchema,
2334
+ registry
2335
+ }
2336
+ )
2337
+ ] });
2338
+ }
2339
+
2340
+ // src/components/templates/TitleField.tsx
2341
+ import { jsx as jsx23, jsxs as jsxs11 } from "react/jsx-runtime";
2342
+ var REQUIRED_FIELD_SYMBOL2 = "*";
2343
+ function TitleField(props) {
2344
+ const { id, title, required } = props;
2345
+ return /* @__PURE__ */ jsxs11("legend", { id, children: [
2346
+ title,
2347
+ required && /* @__PURE__ */ jsx23("span", { className: "required", children: REQUIRED_FIELD_SYMBOL2 })
2348
+ ] });
2349
+ }
2350
+
2351
+ // src/components/templates/UnsupportedField.tsx
2352
+ import { TranslatableString as TranslatableString9 } from "@rjsf/utils";
2353
+ import Markdown3 from "markdown-to-jsx";
2354
+ import { jsx as jsx24, jsxs as jsxs12 } from "react/jsx-runtime";
2355
+ function UnsupportedField(props) {
2356
+ const { schema, idSchema, reason, registry } = props;
2357
+ const { translateString } = registry;
2358
+ let translateEnum = TranslatableString9.UnsupportedField;
2359
+ const translateParams = [];
2360
+ if (idSchema && idSchema.$id) {
2361
+ translateEnum = TranslatableString9.UnsupportedFieldWithId;
2362
+ translateParams.push(idSchema.$id);
2363
+ }
2364
+ if (reason) {
2365
+ translateEnum = translateEnum === TranslatableString9.UnsupportedField ? TranslatableString9.UnsupportedFieldWithReason : TranslatableString9.UnsupportedFieldWithIdAndReason;
2366
+ translateParams.push(reason);
2367
+ }
2368
+ return /* @__PURE__ */ jsxs12("div", { className: "unsupported-field", children: [
2369
+ /* @__PURE__ */ jsx24("p", { children: /* @__PURE__ */ jsx24(Markdown3, { children: translateString(translateEnum, translateParams) }) }),
2370
+ schema && /* @__PURE__ */ jsx24("pre", { children: JSON.stringify(schema, null, 2) })
2371
+ ] });
2372
+ }
2373
+ var UnsupportedField_default = UnsupportedField;
2374
+
2375
+ // src/components/templates/WrapIfAdditionalTemplate.tsx
2376
+ import {
2377
+ ADDITIONAL_PROPERTY_FLAG as ADDITIONAL_PROPERTY_FLAG4,
2378
+ TranslatableString as TranslatableString10
2379
+ } from "@rjsf/utils";
2380
+ import { jsx as jsx25, jsxs as jsxs13 } from "react/jsx-runtime";
2381
+ function WrapIfAdditionalTemplate(props) {
2382
+ const {
2383
+ id,
2384
+ classNames,
2385
+ style,
2386
+ disabled,
2387
+ label,
2388
+ onKeyChange,
2389
+ onDropPropertyClick,
2390
+ readonly,
2391
+ required,
2392
+ schema,
2393
+ children,
2394
+ uiSchema,
2395
+ registry
2396
+ } = props;
2397
+ const { templates: templates2, translateString } = registry;
2398
+ const { RemoveButton: RemoveButton2 } = templates2.ButtonTemplates;
2399
+ const keyLabel = translateString(TranslatableString10.KeyLabel, [label]);
2400
+ const additional = ADDITIONAL_PROPERTY_FLAG4 in schema;
2401
+ if (!additional) {
2402
+ return /* @__PURE__ */ jsx25("div", { className: classNames, style, children });
2403
+ }
2404
+ return /* @__PURE__ */ jsx25("div", { className: classNames, style, children: /* @__PURE__ */ jsxs13("div", { className: "row", children: [
2405
+ /* @__PURE__ */ jsx25("div", { className: "col-xs-5 form-additional", children: /* @__PURE__ */ jsxs13("div", { className: "form-group", children: [
2406
+ /* @__PURE__ */ jsx25(Label, { label: keyLabel, required, id: `${id}-key` }),
2407
+ /* @__PURE__ */ jsx25(
2408
+ "input",
2409
+ {
2410
+ className: "form-control",
2411
+ type: "text",
2412
+ id: `${id}-key`,
2413
+ onBlur: (event) => onKeyChange(event.target.value),
2414
+ defaultValue: label
2415
+ }
2416
+ )
2417
+ ] }) }),
2418
+ /* @__PURE__ */ jsx25("div", { className: "form-additional form-group col-xs-5", children }),
2419
+ /* @__PURE__ */ jsx25("div", { className: "col-xs-2", children: /* @__PURE__ */ jsx25(
2420
+ RemoveButton2,
2421
+ {
2422
+ className: "array-item-remove btn-block",
2423
+ style: { border: "0" },
2424
+ disabled: disabled || readonly,
2425
+ onClick: onDropPropertyClick(label),
2426
+ uiSchema,
2427
+ registry
2428
+ }
2429
+ ) })
2430
+ ] }) });
2431
+ }
2432
+
2433
+ // src/components/templates/index.ts
2434
+ function templates() {
2435
+ return {
2436
+ ArrayFieldDescriptionTemplate,
2437
+ ArrayFieldItemTemplate,
2438
+ ArrayFieldTemplate,
2439
+ ArrayFieldTitleTemplate,
2440
+ ButtonTemplates: ButtonTemplates_default(),
2441
+ BaseInputTemplate,
2442
+ DescriptionFieldTemplate: DescriptionField,
2443
+ ErrorListTemplate: ErrorList,
2444
+ FieldTemplate: FieldTemplate_default,
2445
+ FieldErrorTemplate,
2446
+ FieldHelpTemplate,
2447
+ ObjectFieldTemplate,
2448
+ TitleFieldTemplate: TitleField,
2449
+ UnsupportedFieldTemplate: UnsupportedField_default,
2450
+ WrapIfAdditionalTemplate
2451
+ };
2452
+ }
2453
+ var templates_default = templates;
2454
+
2455
+ // src/components/widgets/AltDateWidget.tsx
2456
+ import { useCallback as useCallback4, useEffect as useEffect2, useReducer, useState as useState2 } from "react";
2457
+ import {
2458
+ ariaDescribedByIds as ariaDescribedByIds2,
2459
+ parseDateString,
2460
+ toDateString,
2461
+ pad,
2462
+ TranslatableString as TranslatableString11
2463
+ } from "@rjsf/utils";
2464
+ import { jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
2465
+ function rangeOptions(start, stop) {
2466
+ const options = [];
2467
+ for (let i = start; i <= stop; i++) {
2468
+ options.push({ value: i, label: pad(i, 2) });
2469
+ }
2470
+ return options;
2471
+ }
2472
+ function readyForChange(state) {
2473
+ return Object.values(state).every((value) => value !== -1);
2474
+ }
2475
+ function dateElementProps(state, time, yearsRange = [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2]) {
2476
+ const { year, month, day, hour, minute, second } = state;
2477
+ const data = [
2478
+ {
2479
+ type: "year",
2480
+ range: yearsRange,
2481
+ value: year
2482
+ },
2483
+ { type: "month", range: [1, 12], value: month },
2484
+ { type: "day", range: [1, 31], value: day }
2485
+ ];
2486
+ if (time) {
2487
+ data.push(
2488
+ { type: "hour", range: [0, 23], value: hour },
2489
+ { type: "minute", range: [0, 59], value: minute },
2490
+ { type: "second", range: [0, 59], value: second }
2491
+ );
2492
+ }
2493
+ return data;
2494
+ }
2495
+ function DateElement({
2496
+ type,
2497
+ range,
2498
+ value,
2499
+ select,
2500
+ rootId,
2501
+ name,
2502
+ disabled,
2503
+ readonly,
2504
+ autofocus,
2505
+ registry,
2506
+ onBlur,
2507
+ onFocus
2508
+ }) {
2509
+ const id = rootId + "_" + type;
2510
+ const { SelectWidget: SelectWidget2 } = registry.widgets;
2511
+ return /* @__PURE__ */ jsx26(
2512
+ SelectWidget2,
2513
+ {
2514
+ schema: { type: "integer" },
2515
+ id,
2516
+ name,
2517
+ className: "form-control",
2518
+ options: { enumOptions: rangeOptions(range[0], range[1]) },
2519
+ placeholder: type,
2520
+ value,
2521
+ disabled,
2522
+ readonly,
2523
+ autofocus,
2524
+ onChange: (value2) => select(type, value2),
2525
+ onBlur,
2526
+ onFocus,
2527
+ registry,
2528
+ label: "",
2529
+ "aria-describedby": ariaDescribedByIds2(rootId)
2530
+ }
2531
+ );
2532
+ }
2533
+ function AltDateWidget({
2534
+ time = false,
2535
+ disabled = false,
2536
+ readonly = false,
2537
+ autofocus = false,
2538
+ options,
2539
+ id,
2540
+ name,
2541
+ registry,
2542
+ onBlur,
2543
+ onFocus,
2544
+ onChange,
2545
+ value
2546
+ }) {
2547
+ const { translateString } = registry;
2548
+ const [lastValue, setLastValue] = useState2(value);
2549
+ const [state, setState] = useReducer((state2, action) => {
2550
+ return { ...state2, ...action };
2551
+ }, parseDateString(value, time));
2552
+ useEffect2(() => {
2553
+ const stateValue = toDateString(state, time);
2554
+ if (readyForChange(state) && stateValue !== value) {
2555
+ onChange(stateValue);
2556
+ } else if (lastValue !== value) {
2557
+ setLastValue(value);
2558
+ setState(parseDateString(value, time));
2559
+ }
2560
+ }, [time, value, onChange, state, lastValue]);
2561
+ const handleChange = useCallback4((property, value2) => {
2562
+ setState({ [property]: value2 });
2563
+ }, []);
2564
+ const handleSetNow = useCallback4(
2565
+ (event) => {
2566
+ event.preventDefault();
2567
+ if (disabled || readonly) {
2568
+ return;
2569
+ }
2570
+ const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), time);
2571
+ onChange(toDateString(nextState, time));
2572
+ },
2573
+ [disabled, readonly, time]
2574
+ );
2575
+ const handleClear = useCallback4(
2576
+ (event) => {
2577
+ event.preventDefault();
2578
+ if (disabled || readonly) {
2579
+ return;
2580
+ }
2581
+ onChange(void 0);
2582
+ },
2583
+ [disabled, readonly, onChange]
2584
+ );
2585
+ return /* @__PURE__ */ jsxs14("ul", { className: "list-inline", children: [
2586
+ dateElementProps(state, time, options.yearsRange).map((elemProps, i) => /* @__PURE__ */ jsx26("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx26(
2587
+ DateElement,
2588
+ {
2589
+ rootId: id,
2590
+ name,
2591
+ select: handleChange,
2592
+ ...elemProps,
2593
+ disabled,
2594
+ readonly,
2595
+ registry,
2596
+ onBlur,
2597
+ onFocus,
2598
+ autofocus: autofocus && i === 0
2599
+ }
2600
+ ) }, i)),
2601
+ (options.hideNowButton !== "undefined" ? !options.hideNowButton : true) && /* @__PURE__ */ jsx26("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx26("a", { href: "#", className: "btn btn-info btn-now", onClick: handleSetNow, children: translateString(TranslatableString11.NowLabel) }) }),
2602
+ (options.hideClearButton !== "undefined" ? !options.hideClearButton : true) && /* @__PURE__ */ jsx26("li", { className: "list-inline-item", children: /* @__PURE__ */ jsx26("a", { href: "#", className: "btn btn-warning btn-clear", onClick: handleClear, children: translateString(TranslatableString11.ClearLabel) }) })
2603
+ ] });
2604
+ }
2605
+ var AltDateWidget_default = AltDateWidget;
2606
+
2607
+ // src/components/widgets/AltDateTimeWidget.tsx
2608
+ import { jsx as jsx27 } from "react/jsx-runtime";
2609
+ function AltDateTimeWidget({
2610
+ time = true,
2611
+ ...props
2612
+ }) {
2613
+ const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
2614
+ return /* @__PURE__ */ jsx27(AltDateWidget2, { time, ...props });
2615
+ }
2616
+ var AltDateTimeWidget_default = AltDateTimeWidget;
2617
+
2618
+ // src/components/widgets/CheckboxWidget.tsx
2619
+ import { useCallback as useCallback5 } from "react";
2620
+ import {
2621
+ ariaDescribedByIds as ariaDescribedByIds3,
2622
+ descriptionId as descriptionId4,
2623
+ getTemplate as getTemplate9,
2624
+ labelValue,
2625
+ schemaRequiresTrueValue
2626
+ } from "@rjsf/utils";
2627
+ import { jsx as jsx28, jsxs as jsxs15 } from "react/jsx-runtime";
2628
+ function CheckboxWidget({
2629
+ schema,
2630
+ uiSchema,
2631
+ options,
2632
+ id,
2633
+ value,
2634
+ disabled,
2635
+ readonly,
2636
+ label,
2637
+ hideLabel,
2638
+ autofocus = false,
2639
+ onBlur,
2640
+ onFocus,
2641
+ onChange,
2642
+ registry
2643
+ }) {
2644
+ const DescriptionFieldTemplate = getTemplate9(
2645
+ "DescriptionFieldTemplate",
2646
+ registry,
2647
+ options
2648
+ );
2649
+ const required = schemaRequiresTrueValue(schema);
2650
+ const handleChange = useCallback5(
2651
+ (event) => onChange(event.target.checked),
2652
+ [onChange]
2653
+ );
2654
+ const handleBlur = useCallback5(
2655
+ (event) => onBlur(id, event.target.checked),
2656
+ [onBlur, id]
2657
+ );
2658
+ const handleFocus = useCallback5(
2659
+ (event) => onFocus(id, event.target.checked),
2660
+ [onFocus, id]
2661
+ );
2662
+ const description = options.description ?? schema.description;
2663
+ return /* @__PURE__ */ jsxs15("div", { className: `checkbox ${disabled || readonly ? "disabled" : ""}`, children: [
2664
+ !hideLabel && !!description && /* @__PURE__ */ jsx28(
2665
+ DescriptionFieldTemplate,
2666
+ {
2667
+ id: descriptionId4(id),
2668
+ description,
2669
+ schema,
2670
+ uiSchema,
2671
+ registry
2672
+ }
2673
+ ),
2674
+ /* @__PURE__ */ jsxs15("label", { children: [
2675
+ /* @__PURE__ */ jsx28(
2676
+ "input",
2677
+ {
2678
+ type: "checkbox",
2679
+ id,
2680
+ name: id,
2681
+ checked: typeof value === "undefined" ? false : value,
2682
+ required,
2683
+ disabled: disabled || readonly,
2684
+ autoFocus: autofocus,
2685
+ onChange: handleChange,
2686
+ onBlur: handleBlur,
2687
+ onFocus: handleFocus,
2688
+ "aria-describedby": ariaDescribedByIds3(id)
2689
+ }
2690
+ ),
2691
+ labelValue(/* @__PURE__ */ jsx28("span", { children: label }), hideLabel)
2692
+ ] })
2693
+ ] });
2694
+ }
2695
+ var CheckboxWidget_default = CheckboxWidget;
2696
+
2697
+ // src/components/widgets/CheckboxesWidget.tsx
2698
+ import { useCallback as useCallback6 } from "react";
2699
+ import {
2700
+ ariaDescribedByIds as ariaDescribedByIds4,
2701
+ enumOptionsDeselectValue,
2702
+ enumOptionsIsSelected,
2703
+ enumOptionsSelectValue,
2704
+ enumOptionsValueForIndex,
2705
+ optionId
2706
+ } from "@rjsf/utils";
2707
+ import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
2708
+ function CheckboxesWidget({
2709
+ id,
2710
+ disabled,
2711
+ options: { inline = false, enumOptions, enumDisabled, emptyValue },
2712
+ value,
2713
+ autofocus = false,
2714
+ readonly,
2715
+ onChange,
2716
+ onBlur,
2717
+ onFocus
2718
+ }) {
2719
+ const checkboxesValues = Array.isArray(value) ? value : [value];
2720
+ const handleBlur = useCallback6(
2721
+ ({ target: { value: value2 } }) => onBlur(id, enumOptionsValueForIndex(value2, enumOptions, emptyValue)),
2722
+ [onBlur, id]
2723
+ );
2724
+ const handleFocus = useCallback6(
2725
+ ({ target: { value: value2 } }) => onFocus(id, enumOptionsValueForIndex(value2, enumOptions, emptyValue)),
2726
+ [onFocus, id]
2727
+ );
2728
+ return /* @__PURE__ */ jsx29("div", { className: "checkboxes", id, children: Array.isArray(enumOptions) && enumOptions.map((option, index) => {
2729
+ const checked = enumOptionsIsSelected(option.value, checkboxesValues);
2730
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
2731
+ const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
2732
+ const handleChange = (event) => {
2733
+ if (event.target.checked) {
2734
+ onChange(enumOptionsSelectValue(index, checkboxesValues, enumOptions));
2735
+ } else {
2736
+ onChange(enumOptionsDeselectValue(index, checkboxesValues, enumOptions));
2737
+ }
2738
+ };
2739
+ const checkbox = /* @__PURE__ */ jsxs16("span", { children: [
2740
+ /* @__PURE__ */ jsx29(
2741
+ "input",
2742
+ {
2743
+ type: "checkbox",
2744
+ id: optionId(id, index),
2745
+ name: id,
2746
+ checked,
2747
+ value: String(index),
2748
+ disabled: disabled || itemDisabled || readonly,
2749
+ autoFocus: autofocus && index === 0,
2750
+ onChange: handleChange,
2751
+ onBlur: handleBlur,
2752
+ onFocus: handleFocus,
2753
+ "aria-describedby": ariaDescribedByIds4(id)
2754
+ }
2755
+ ),
2756
+ /* @__PURE__ */ jsx29("span", { children: option.label })
2757
+ ] });
2758
+ return inline ? /* @__PURE__ */ jsx29("label", { className: `checkbox-inline ${disabledCls}`, children: checkbox }, index) : /* @__PURE__ */ jsx29("div", { className: `checkbox ${disabledCls}`, children: /* @__PURE__ */ jsx29("label", { children: checkbox }) }, index);
2759
+ }) });
2760
+ }
2761
+ var CheckboxesWidget_default = CheckboxesWidget;
2762
+
2763
+ // src/components/widgets/ColorWidget.tsx
2764
+ import { getTemplate as getTemplate10 } from "@rjsf/utils";
2765
+ import { jsx as jsx30 } from "react/jsx-runtime";
2766
+ function ColorWidget(props) {
2767
+ const { disabled, readonly, options, registry } = props;
2768
+ const BaseInputTemplate2 = getTemplate10("BaseInputTemplate", registry, options);
2769
+ return /* @__PURE__ */ jsx30(BaseInputTemplate2, { type: "color", ...props, disabled: disabled || readonly });
2770
+ }
2771
+
2772
+ // src/components/widgets/DateWidget.tsx
2773
+ import { useCallback as useCallback7 } from "react";
2774
+ import { getTemplate as getTemplate11 } from "@rjsf/utils";
2775
+ import { jsx as jsx31 } from "react/jsx-runtime";
2776
+ function DateWidget(props) {
2777
+ const { onChange, options, registry } = props;
2778
+ const BaseInputTemplate2 = getTemplate11("BaseInputTemplate", registry, options);
2779
+ const handleChange = useCallback7((value) => onChange(value || void 0), [onChange]);
2780
+ return /* @__PURE__ */ jsx31(BaseInputTemplate2, { type: "date", ...props, onChange: handleChange });
2781
+ }
2782
+
2783
+ // src/components/widgets/DateTimeWidget.tsx
2784
+ import {
2785
+ getTemplate as getTemplate12,
2786
+ localToUTC,
2787
+ utcToLocal
2788
+ } from "@rjsf/utils";
2789
+ import { jsx as jsx32 } from "react/jsx-runtime";
2790
+ function DateTimeWidget(props) {
2791
+ const { onChange, value, options, registry } = props;
2792
+ const BaseInputTemplate2 = getTemplate12("BaseInputTemplate", registry, options);
2793
+ return /* @__PURE__ */ jsx32(
2794
+ BaseInputTemplate2,
2795
+ {
2796
+ type: "datetime-local",
2797
+ ...props,
2798
+ value: utcToLocal(value),
2799
+ onChange: (value2) => onChange(localToUTC(value2))
2800
+ }
2801
+ );
2802
+ }
2803
+
2804
+ // src/components/widgets/EmailWidget.tsx
2805
+ import { getTemplate as getTemplate13 } from "@rjsf/utils";
2806
+ import { jsx as jsx33 } from "react/jsx-runtime";
2807
+ function EmailWidget(props) {
2808
+ const { options, registry } = props;
2809
+ const BaseInputTemplate2 = getTemplate13("BaseInputTemplate", registry, options);
2810
+ return /* @__PURE__ */ jsx33(BaseInputTemplate2, { type: "email", ...props });
2811
+ }
2812
+
2813
+ // src/components/widgets/FileWidget.tsx
2814
+ import { useCallback as useCallback8, useState as useState3 } from "react";
2815
+ import {
2816
+ dataURItoBlob,
2817
+ getTemplate as getTemplate14,
2818
+ TranslatableString as TranslatableString12
2819
+ } from "@rjsf/utils";
2820
+ import Markdown4 from "markdown-to-jsx";
2821
+ import { Fragment as Fragment3, jsx as jsx34, jsxs as jsxs17 } from "react/jsx-runtime";
2822
+ function addNameToDataURL(dataURL, name) {
2823
+ if (dataURL === null) {
2824
+ return null;
2825
+ }
2826
+ return dataURL.replace(";base64", `;name=${encodeURIComponent(name)};base64`);
2827
+ }
2828
+ function processFile(file) {
2829
+ const { name, size, type } = file;
2830
+ return new Promise((resolve, reject) => {
2831
+ const reader = new window.FileReader();
2832
+ reader.onerror = reject;
2833
+ reader.onload = (event) => {
2834
+ if (typeof event.target?.result === "string") {
2835
+ resolve({
2836
+ dataURL: addNameToDataURL(event.target.result, name),
2837
+ name,
2838
+ size,
2839
+ type
2840
+ });
2841
+ } else {
2842
+ resolve({
2843
+ dataURL: null,
2844
+ name,
2845
+ size,
2846
+ type
2847
+ });
2848
+ }
2849
+ };
2850
+ reader.readAsDataURL(file);
2851
+ });
2852
+ }
2853
+ function processFiles(files) {
2854
+ return Promise.all(Array.from(files).map(processFile));
2855
+ }
2856
+ function FileInfoPreview({
2857
+ fileInfo,
2858
+ registry
2859
+ }) {
2860
+ const { translateString } = registry;
2861
+ const { dataURL, type, name } = fileInfo;
2862
+ if (!dataURL) {
2863
+ return null;
2864
+ }
2865
+ if (type.indexOf("image") !== -1) {
2866
+ return /* @__PURE__ */ jsx34("img", { src: dataURL, style: { maxWidth: "100%" }, className: "file-preview" });
2867
+ }
2868
+ return /* @__PURE__ */ jsxs17(Fragment3, { children: [
2869
+ " ",
2870
+ /* @__PURE__ */ jsx34("a", { download: `preview-${name}`, href: dataURL, className: "file-download", children: translateString(TranslatableString12.PreviewLabel) })
2871
+ ] });
2872
+ }
2873
+ function FilesInfo({
2874
+ filesInfo,
2875
+ registry,
2876
+ preview
2877
+ }) {
2878
+ if (filesInfo.length === 0) {
2879
+ return null;
2880
+ }
2881
+ const { translateString } = registry;
2882
+ return /* @__PURE__ */ jsx34("ul", { className: "file-info", children: filesInfo.map((fileInfo, key) => {
2883
+ const { name, size, type } = fileInfo;
2884
+ return /* @__PURE__ */ jsxs17("li", { children: [
2885
+ /* @__PURE__ */ jsx34(Markdown4, { children: translateString(TranslatableString12.FilesInfo, [name, type, String(size)]) }),
2886
+ preview && /* @__PURE__ */ jsx34(FileInfoPreview, { fileInfo, registry })
2887
+ ] }, key);
2888
+ }) });
2889
+ }
2890
+ function extractFileInfo(dataURLs) {
2891
+ return dataURLs.filter((dataURL) => dataURL).map((dataURL) => {
2892
+ const { blob, name } = dataURItoBlob(dataURL);
2893
+ return {
2894
+ dataURL,
2895
+ name,
2896
+ size: blob.size,
2897
+ type: blob.type
2898
+ };
2899
+ });
2900
+ }
2901
+ function FileWidget(props) {
2902
+ const { disabled, readonly, required, multiple, onChange, value, options, registry } = props;
2903
+ const BaseInputTemplate2 = getTemplate14("BaseInputTemplate", registry, options);
2904
+ const [filesInfo, setFilesInfo] = useState3(
2905
+ Array.isArray(value) ? extractFileInfo(value) : extractFileInfo([value])
2906
+ );
2907
+ const handleChange = useCallback8(
2908
+ (event) => {
2909
+ if (!event.target.files) {
2910
+ return;
2911
+ }
2912
+ processFiles(event.target.files).then((filesInfoEvent) => {
2913
+ const newValue = filesInfoEvent.map((fileInfo) => fileInfo.dataURL);
2914
+ if (multiple) {
2915
+ setFilesInfo(filesInfo.concat(filesInfoEvent[0]));
2916
+ onChange(value.concat(newValue[0]));
2917
+ } else {
2918
+ setFilesInfo(filesInfoEvent);
2919
+ onChange(newValue[0]);
2920
+ }
2921
+ });
2922
+ },
2923
+ [multiple, value, filesInfo, onChange]
2924
+ );
2925
+ return /* @__PURE__ */ jsxs17("div", { children: [
2926
+ /* @__PURE__ */ jsx34(
2927
+ BaseInputTemplate2,
2928
+ {
2929
+ ...props,
2930
+ disabled: disabled || readonly,
2931
+ type: "file",
2932
+ required: value ? false : required,
2933
+ onChangeOverride: handleChange,
2934
+ value: "",
2935
+ accept: options.accept ? String(options.accept) : void 0
2936
+ }
2937
+ ),
2938
+ /* @__PURE__ */ jsx34(FilesInfo, { filesInfo, registry, preview: options.filePreview })
2939
+ ] });
2940
+ }
2941
+ var FileWidget_default = FileWidget;
2942
+
2943
+ // src/components/widgets/HiddenWidget.tsx
2944
+ import { jsx as jsx35 } from "react/jsx-runtime";
2945
+ function HiddenWidget({
2946
+ id,
2947
+ value
2948
+ }) {
2949
+ return /* @__PURE__ */ jsx35("input", { type: "hidden", id, name: id, value: typeof value === "undefined" ? "" : value });
2950
+ }
2951
+ var HiddenWidget_default = HiddenWidget;
2952
+
2953
+ // src/components/widgets/PasswordWidget.tsx
2954
+ import { getTemplate as getTemplate15 } from "@rjsf/utils";
2955
+ import { jsx as jsx36 } from "react/jsx-runtime";
2956
+ function PasswordWidget(props) {
2957
+ const { options, registry } = props;
2958
+ const BaseInputTemplate2 = getTemplate15("BaseInputTemplate", registry, options);
2959
+ return /* @__PURE__ */ jsx36(BaseInputTemplate2, { type: "password", ...props });
2960
+ }
2961
+
2962
+ // src/components/widgets/RadioWidget.tsx
2963
+ import { useCallback as useCallback9 } from "react";
2964
+ import {
2965
+ ariaDescribedByIds as ariaDescribedByIds5,
2966
+ enumOptionsIsSelected as enumOptionsIsSelected2,
2967
+ enumOptionsValueForIndex as enumOptionsValueForIndex2,
2968
+ optionId as optionId2
2969
+ } from "@rjsf/utils";
2970
+ import { jsx as jsx37, jsxs as jsxs18 } from "react/jsx-runtime";
2971
+ function RadioWidget({
2972
+ options,
2973
+ value,
2974
+ required,
2975
+ disabled,
2976
+ readonly,
2977
+ autofocus = false,
2978
+ onBlur,
2979
+ onFocus,
2980
+ onChange,
2981
+ id
2982
+ }) {
2983
+ const { enumOptions, enumDisabled, inline, emptyValue } = options;
2984
+ const handleBlur = useCallback9(
2985
+ ({ target: { value: value2 } }) => onBlur(id, enumOptionsValueForIndex2(value2, enumOptions, emptyValue)),
2986
+ [onBlur, id]
2987
+ );
2988
+ const handleFocus = useCallback9(
2989
+ ({ target: { value: value2 } }) => onFocus(id, enumOptionsValueForIndex2(value2, enumOptions, emptyValue)),
2990
+ [onFocus, id]
2991
+ );
2992
+ return /* @__PURE__ */ jsx37("div", { className: "field-radio-group", id, children: Array.isArray(enumOptions) && enumOptions.map((option, i) => {
2993
+ const checked = enumOptionsIsSelected2(option.value, value);
2994
+ const itemDisabled = Array.isArray(enumDisabled) && enumDisabled.indexOf(option.value) !== -1;
2995
+ const disabledCls = disabled || itemDisabled || readonly ? "disabled" : "";
2996
+ const handleChange = () => onChange(option.value);
2997
+ const radio = /* @__PURE__ */ jsxs18("span", { children: [
2998
+ /* @__PURE__ */ jsx37(
2999
+ "input",
3000
+ {
3001
+ type: "radio",
3002
+ id: optionId2(id, i),
3003
+ checked,
3004
+ name: id,
3005
+ required,
3006
+ value: String(i),
3007
+ disabled: disabled || itemDisabled || readonly,
3008
+ autoFocus: autofocus && i === 0,
3009
+ onChange: handleChange,
3010
+ onBlur: handleBlur,
3011
+ onFocus: handleFocus,
3012
+ "aria-describedby": ariaDescribedByIds5(id)
3013
+ }
3014
+ ),
3015
+ /* @__PURE__ */ jsx37("span", { children: option.label })
3016
+ ] });
3017
+ return inline ? /* @__PURE__ */ jsx37("label", { className: `radio-inline ${disabledCls}`, children: radio }, i) : /* @__PURE__ */ jsx37("div", { className: `radio ${disabledCls}`, children: /* @__PURE__ */ jsx37("label", { children: radio }) }, i);
3018
+ }) });
3019
+ }
3020
+ var RadioWidget_default = RadioWidget;
3021
+
3022
+ // src/components/widgets/RangeWidget.tsx
3023
+ import { jsx as jsx38, jsxs as jsxs19 } from "react/jsx-runtime";
3024
+ function RangeWidget(props) {
3025
+ const {
3026
+ value,
3027
+ registry: {
3028
+ templates: { BaseInputTemplate: BaseInputTemplate2 }
3029
+ }
3030
+ } = props;
3031
+ return /* @__PURE__ */ jsxs19("div", { className: "field-range-wrapper", children: [
3032
+ /* @__PURE__ */ jsx38(BaseInputTemplate2, { type: "range", ...props }),
3033
+ /* @__PURE__ */ jsx38("span", { className: "range-view", children: value })
3034
+ ] });
3035
+ }
3036
+
3037
+ // src/components/widgets/SelectWidget.tsx
3038
+ import { useCallback as useCallback10 } from "react";
3039
+ import {
3040
+ ariaDescribedByIds as ariaDescribedByIds6,
3041
+ enumOptionsIndexForValue,
3042
+ enumOptionsValueForIndex as enumOptionsValueForIndex3
3043
+ } from "@rjsf/utils";
3044
+ import { jsx as jsx39, jsxs as jsxs20 } from "react/jsx-runtime";
3045
+ function getValue(event, multiple) {
3046
+ if (multiple) {
3047
+ return Array.from(event.target.options).slice().filter((o) => o.selected).map((o) => o.value);
3048
+ }
3049
+ return event.target.value;
3050
+ }
3051
+ function SelectWidget({
3052
+ schema,
3053
+ id,
3054
+ options,
3055
+ value,
3056
+ required,
3057
+ disabled,
3058
+ readonly,
3059
+ multiple = false,
3060
+ autofocus = false,
3061
+ onChange,
3062
+ onBlur,
3063
+ onFocus,
3064
+ placeholder
3065
+ }) {
3066
+ const { enumOptions, enumDisabled, emptyValue: optEmptyVal } = options;
3067
+ const emptyValue = multiple ? [] : "";
3068
+ const handleFocus = useCallback10(
3069
+ (event) => {
3070
+ const newValue = getValue(event, multiple);
3071
+ return onFocus(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
3072
+ },
3073
+ [onFocus, id, schema, multiple, options]
3074
+ );
3075
+ const handleBlur = useCallback10(
3076
+ (event) => {
3077
+ const newValue = getValue(event, multiple);
3078
+ return onBlur(id, enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
3079
+ },
3080
+ [onBlur, id, schema, multiple, options]
3081
+ );
3082
+ const handleChange = useCallback10(
3083
+ (event) => {
3084
+ const newValue = getValue(event, multiple);
3085
+ return onChange(enumOptionsValueForIndex3(newValue, enumOptions, optEmptyVal));
3086
+ },
3087
+ [onChange, schema, multiple, options]
3088
+ );
3089
+ const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
3090
+ return /* @__PURE__ */ jsxs20(
3091
+ "select",
3092
+ {
3093
+ id,
3094
+ name: id,
3095
+ multiple,
3096
+ className: "form-control",
3097
+ value: typeof selectedIndexes === "undefined" ? emptyValue : selectedIndexes,
3098
+ required,
3099
+ disabled: disabled || readonly,
3100
+ autoFocus: autofocus,
3101
+ onBlur: handleBlur,
3102
+ onFocus: handleFocus,
3103
+ onChange: handleChange,
3104
+ "aria-describedby": ariaDescribedByIds6(id),
3105
+ children: [
3106
+ !multiple && schema.default === void 0 && /* @__PURE__ */ jsx39("option", { value: "", children: placeholder }),
3107
+ Array.isArray(enumOptions) && enumOptions.map(({ value: value2, label }, i) => {
3108
+ const disabled2 = enumDisabled && enumDisabled.indexOf(value2) !== -1;
3109
+ return /* @__PURE__ */ jsx39("option", { value: String(i), disabled: disabled2, children: label }, i);
3110
+ })
3111
+ ]
3112
+ }
3113
+ );
3114
+ }
3115
+ var SelectWidget_default = SelectWidget;
3116
+
3117
+ // src/components/widgets/TextareaWidget.tsx
3118
+ import { useCallback as useCallback11 } from "react";
3119
+ import { ariaDescribedByIds as ariaDescribedByIds7 } from "@rjsf/utils";
3120
+ import { jsx as jsx40 } from "react/jsx-runtime";
3121
+ function TextareaWidget({
3122
+ id,
3123
+ options = {},
3124
+ placeholder,
3125
+ value,
3126
+ required,
3127
+ disabled,
3128
+ readonly,
3129
+ autofocus = false,
3130
+ onChange,
3131
+ onBlur,
3132
+ onFocus
3133
+ }) {
3134
+ const handleChange = useCallback11(
3135
+ ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
3136
+ [onChange, options.emptyValue]
3137
+ );
3138
+ const handleBlur = useCallback11(
3139
+ ({ target: { value: value2 } }) => onBlur(id, value2),
3140
+ [onBlur, id]
3141
+ );
3142
+ const handleFocus = useCallback11(
3143
+ ({ target: { value: value2 } }) => onFocus(id, value2),
3144
+ [id, onFocus]
3145
+ );
3146
+ return /* @__PURE__ */ jsx40(
3147
+ "textarea",
3148
+ {
3149
+ id,
3150
+ name: id,
3151
+ className: "form-control",
3152
+ value: value ? value : "",
3153
+ placeholder,
3154
+ required,
3155
+ disabled,
3156
+ readOnly: readonly,
3157
+ autoFocus: autofocus,
3158
+ rows: options.rows,
3159
+ onBlur: handleBlur,
3160
+ onFocus: handleFocus,
3161
+ onChange: handleChange,
3162
+ "aria-describedby": ariaDescribedByIds7(id)
3163
+ }
3164
+ );
3165
+ }
3166
+ TextareaWidget.defaultProps = {
3167
+ autofocus: false,
3168
+ options: {}
3169
+ };
3170
+ var TextareaWidget_default = TextareaWidget;
3171
+
3172
+ // src/components/widgets/TextWidget.tsx
3173
+ import { getTemplate as getTemplate16 } from "@rjsf/utils";
3174
+ import { jsx as jsx41 } from "react/jsx-runtime";
3175
+ function TextWidget(props) {
3176
+ const { options, registry } = props;
3177
+ const BaseInputTemplate2 = getTemplate16("BaseInputTemplate", registry, options);
3178
+ return /* @__PURE__ */ jsx41(BaseInputTemplate2, { ...props });
3179
+ }
3180
+
3181
+ // src/components/widgets/TimeWidget.tsx
3182
+ import { useCallback as useCallback12 } from "react";
3183
+ import { getTemplate as getTemplate17 } from "@rjsf/utils";
3184
+ import { jsx as jsx42 } from "react/jsx-runtime";
3185
+ function TimeWidget(props) {
3186
+ const { onChange, options, registry } = props;
3187
+ const BaseInputTemplate2 = getTemplate17("BaseInputTemplate", registry, options);
3188
+ const handleChange = useCallback12((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
3189
+ return /* @__PURE__ */ jsx42(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
3190
+ }
3191
+
3192
+ // src/components/widgets/URLWidget.tsx
3193
+ import { getTemplate as getTemplate18 } from "@rjsf/utils";
3194
+ import { jsx as jsx43 } from "react/jsx-runtime";
3195
+ function URLWidget(props) {
3196
+ const { options, registry } = props;
3197
+ const BaseInputTemplate2 = getTemplate18("BaseInputTemplate", registry, options);
3198
+ return /* @__PURE__ */ jsx43(BaseInputTemplate2, { type: "url", ...props });
3199
+ }
3200
+
3201
+ // src/components/widgets/UpDownWidget.tsx
3202
+ import { getTemplate as getTemplate19 } from "@rjsf/utils";
3203
+ import { jsx as jsx44 } from "react/jsx-runtime";
3204
+ function UpDownWidget(props) {
3205
+ const { options, registry } = props;
3206
+ const BaseInputTemplate2 = getTemplate19("BaseInputTemplate", registry, options);
3207
+ return /* @__PURE__ */ jsx44(BaseInputTemplate2, { type: "number", ...props });
3208
+ }
3209
+
3210
+ // src/components/widgets/index.ts
3211
+ function widgets() {
3212
+ return {
3213
+ AltDateWidget: AltDateWidget_default,
3214
+ AltDateTimeWidget: AltDateTimeWidget_default,
3215
+ CheckboxWidget: CheckboxWidget_default,
3216
+ CheckboxesWidget: CheckboxesWidget_default,
3217
+ ColorWidget,
3218
+ DateWidget,
3219
+ DateTimeWidget,
3220
+ EmailWidget,
3221
+ FileWidget: FileWidget_default,
3222
+ HiddenWidget: HiddenWidget_default,
3223
+ PasswordWidget,
3224
+ RadioWidget: RadioWidget_default,
3225
+ RangeWidget,
3226
+ SelectWidget: SelectWidget_default,
3227
+ TextWidget,
3228
+ TextareaWidget: TextareaWidget_default,
3229
+ TimeWidget,
3230
+ UpDownWidget,
3231
+ URLWidget
3232
+ };
3233
+ }
3234
+ var widgets_default = widgets;
3235
+
3236
+ // src/getDefaultRegistry.ts
3237
+ function getDefaultRegistry() {
3238
+ return {
3239
+ fields: fields_default(),
3240
+ templates: templates_default(),
3241
+ widgets: widgets_default(),
3242
+ rootSchema: {},
3243
+ formContext: {},
3244
+ translateString: englishStringTranslator
3245
+ };
3246
+ }
3247
+
3248
+ // src/components/Form.tsx
3249
+ import { jsx as jsx45, jsxs as jsxs21 } from "react/jsx-runtime";
3250
+ var Form = class extends Component5 {
3251
+ /** Constructs the `Form` from the `props`. Will setup the initial state from the props. It will also call the
3252
+ * `onChange` handler if the initially provided `formData` is modified to add missing default values as part of the
3253
+ * state construction.
3254
+ *
3255
+ * @param props - The initial props for the `Form`
3256
+ */
3257
+ constructor(props) {
3258
+ super(props);
3259
+ /** Returns the `formData` with only the elements specified in the `fields` list
3260
+ *
3261
+ * @param formData - The data for the `Form`
3262
+ * @param fields - The fields to keep while filtering
3263
+ */
3264
+ this.getUsedFormData = (formData, fields2) => {
3265
+ if (fields2.length === 0 && typeof formData !== "object") {
3266
+ return formData;
3267
+ }
3268
+ const data = _pick(formData, fields2);
3269
+ if (Array.isArray(formData)) {
3270
+ return Object.keys(data).map((key) => data[key]);
3271
+ }
3272
+ return data;
3273
+ };
3274
+ /** Returns the list of field names from inspecting the `pathSchema` as well as using the `formData`
3275
+ *
3276
+ * @param pathSchema - The `PathSchema` object for the form
3277
+ * @param [formData] - The form data to use while checking for empty objects/arrays
3278
+ */
3279
+ this.getFieldNames = (pathSchema, formData) => {
3280
+ const getAllPaths = (_obj, acc = [], paths = [[]]) => {
3281
+ Object.keys(_obj).forEach((key) => {
3282
+ if (typeof _obj[key] === "object") {
3283
+ const newPaths = paths.map((path) => [...path, key]);
3284
+ if (_obj[key][RJSF_ADDITONAL_PROPERTIES_FLAG] && _obj[key][NAME_KEY] !== "") {
3285
+ acc.push(_obj[key][NAME_KEY]);
3286
+ } else {
3287
+ getAllPaths(_obj[key], acc, newPaths);
3288
+ }
3289
+ } else if (key === NAME_KEY && _obj[key] !== "") {
3290
+ paths.forEach((path) => {
3291
+ const formValue = _get(formData, path);
3292
+ if (typeof formValue !== "object" || _isEmpty(formValue)) {
3293
+ acc.push(path);
3294
+ }
3295
+ });
3296
+ }
3297
+ });
3298
+ return acc;
3299
+ };
3300
+ return getAllPaths(pathSchema);
3301
+ };
3302
+ /** Function to handle changes made to a field in the `Form`. This handler receives an entirely new copy of the
3303
+ * `formData` along with a new `ErrorSchema`. It will first update the `formData` with any missing default fields and
3304
+ * then, if `omitExtraData` and `liveOmit` are turned on, the `formData` will be filterer to remove any extra data not
3305
+ * in a form field. Then, the resulting formData will be validated if required. The state will be updated with the new
3306
+ * updated (potentially filtered) `formData`, any errors that resulted from validation. Finally the `onChange`
3307
+ * callback will be called if specified with the updated state.
3308
+ *
3309
+ * @param formData - The new form data from a change to a field
3310
+ * @param newErrorSchema - The new `ErrorSchema` based on the field change
3311
+ * @param id - The id of the field that caused the change
3312
+ */
3313
+ this.onChange = (formData, newErrorSchema, id) => {
3314
+ const { extraErrors, omitExtraData, liveOmit, noValidate, liveValidate, onChange } = this.props;
3315
+ const { schemaUtils, schema } = this.state;
3316
+ if (isObject5(formData) || Array.isArray(formData)) {
3317
+ const newState = this.getStateFromProps(this.props, formData);
3318
+ formData = newState.formData;
3319
+ }
3320
+ const mustValidate = !noValidate && liveValidate;
3321
+ let state = { formData, schema };
3322
+ let newFormData = formData;
3323
+ if (omitExtraData === true && liveOmit === true) {
3324
+ const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
3325
+ const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", formData);
3326
+ const fieldNames = this.getFieldNames(pathSchema, formData);
3327
+ newFormData = this.getUsedFormData(formData, fieldNames);
3328
+ state = {
3329
+ formData: newFormData
3330
+ };
3331
+ }
3332
+ if (mustValidate) {
3333
+ const schemaValidation = this.validate(newFormData);
3334
+ let errors = schemaValidation.errors;
3335
+ let errorSchema = schemaValidation.errorSchema;
3336
+ const schemaValidationErrors = errors;
3337
+ const schemaValidationErrorSchema = errorSchema;
3338
+ if (extraErrors) {
3339
+ const merged = validationDataMerge(schemaValidation, extraErrors);
3340
+ errorSchema = merged.errorSchema;
3341
+ errors = merged.errors;
3342
+ }
3343
+ state = {
3344
+ formData: newFormData,
3345
+ errors,
3346
+ errorSchema,
3347
+ schemaValidationErrors,
3348
+ schemaValidationErrorSchema
3349
+ };
3350
+ } else if (!noValidate && newErrorSchema) {
3351
+ const errorSchema = extraErrors ? mergeObjects2(newErrorSchema, extraErrors, "preventDuplicates") : newErrorSchema;
3352
+ state = {
3353
+ formData: newFormData,
3354
+ errorSchema,
3355
+ errors: toErrorList(errorSchema)
3356
+ };
3357
+ }
3358
+ this.setState(state, () => onChange && onChange({ ...this.state, ...state }, id));
3359
+ };
3360
+ /**
3361
+ * Callback function to handle reset form data.
3362
+ * - Reset all fields with default values.
3363
+ * - Reset validations and errors
3364
+ *
3365
+ */
3366
+ this.reset = () => {
3367
+ const { onChange } = this.props;
3368
+ const newState = this.getStateFromProps(this.props, void 0);
3369
+ const newFormData = newState.formData;
3370
+ const state = {
3371
+ formData: newFormData,
3372
+ errorSchema: {},
3373
+ errors: [],
3374
+ schemaValidationErrors: [],
3375
+ schemaValidationErrorSchema: {}
3376
+ };
3377
+ this.setState(state, () => onChange && onChange({ ...this.state, ...state }));
3378
+ };
3379
+ /** Callback function to handle when a field on the form is blurred. Calls the `onBlur` callback for the `Form` if it
3380
+ * was provided.
3381
+ *
3382
+ * @param id - The unique `id` of the field that was blurred
3383
+ * @param data - The data associated with the field that was blurred
3384
+ */
3385
+ this.onBlur = (id, data) => {
3386
+ const { onBlur } = this.props;
3387
+ if (onBlur) {
3388
+ onBlur(id, data);
3389
+ }
3390
+ };
3391
+ /** Callback function to handle when a field on the form is focused. Calls the `onFocus` callback for the `Form` if it
3392
+ * was provided.
3393
+ *
3394
+ * @param id - The unique `id` of the field that was focused
3395
+ * @param data - The data associated with the field that was focused
3396
+ */
3397
+ this.onFocus = (id, data) => {
3398
+ const { onFocus } = this.props;
3399
+ if (onFocus) {
3400
+ onFocus(id, data);
3401
+ }
3402
+ };
3403
+ /** Callback function to handle when the form is submitted. First, it prevents the default event behavior. Nothing
3404
+ * happens if the target and currentTarget of the event are not the same. It will omit any extra data in the
3405
+ * `formData` in the state if `omitExtraData` is true. It will validate the resulting `formData`, reporting errors
3406
+ * via the `onError()` callback unless validation is disabled. Finally, it will add in any `extraErrors` and then call
3407
+ * back the `onSubmit` callback if it was provided.
3408
+ *
3409
+ * @param event - The submit HTML form event
3410
+ */
3411
+ this.onSubmit = (event) => {
3412
+ event.preventDefault();
3413
+ if (event.target !== event.currentTarget) {
3414
+ return;
3415
+ }
3416
+ event.persist();
3417
+ const { omitExtraData, extraErrors, noValidate, onSubmit } = this.props;
3418
+ let { formData: newFormData } = this.state;
3419
+ const { schema, schemaUtils } = this.state;
3420
+ if (omitExtraData === true) {
3421
+ const retrievedSchema = schemaUtils.retrieveSchema(schema, newFormData);
3422
+ const pathSchema = schemaUtils.toPathSchema(retrievedSchema, "", newFormData);
3423
+ const fieldNames = this.getFieldNames(pathSchema, newFormData);
3424
+ newFormData = this.getUsedFormData(newFormData, fieldNames);
3425
+ }
3426
+ if (noValidate || this.validateForm()) {
3427
+ const errorSchema = extraErrors || {};
3428
+ const errors = extraErrors ? toErrorList(extraErrors) : [];
3429
+ this.setState(
3430
+ {
3431
+ formData: newFormData,
3432
+ errors,
3433
+ errorSchema,
3434
+ schemaValidationErrors: [],
3435
+ schemaValidationErrorSchema: {}
3436
+ },
3437
+ () => {
3438
+ if (onSubmit) {
3439
+ onSubmit({ ...this.state, formData: newFormData, status: "submitted" }, event);
3440
+ }
3441
+ }
3442
+ );
3443
+ }
3444
+ };
3445
+ if (!props.validator) {
3446
+ throw new Error("A validator is required for Form functionality to work");
3447
+ }
3448
+ this.state = this.getStateFromProps(props, props.formData);
3449
+ if (this.props.onChange && !deepEquals3(this.state.formData, this.props.formData)) {
3450
+ this.props.onChange(this.state);
3451
+ }
3452
+ this.formElement = createRef();
3453
+ }
3454
+ /** React lifecycle method that gets called before new props are provided, updates the state based on new props. It
3455
+ * will also call the`onChange` handler if the `formData` is modified to add missing default values as part of the
3456
+ * state construction.
3457
+ *
3458
+ * @param nextProps - The new set of props about to be applied to the `Form`
3459
+ */
3460
+ UNSAFE_componentWillReceiveProps(nextProps) {
3461
+ const nextState = this.getStateFromProps(nextProps, nextProps.formData);
3462
+ if (!deepEquals3(nextState.formData, nextProps.formData) && !deepEquals3(nextState.formData, this.state.formData) && nextProps.onChange) {
3463
+ nextProps.onChange(nextState);
3464
+ }
3465
+ this.setState(nextState);
3466
+ }
3467
+ /** Extracts the updated state from the given `props` and `inputFormData`. As part of this process, the
3468
+ * `inputFormData` is first processed to add any missing required defaults. After that, the data is run through the
3469
+ * validation process IF required by the `props`.
3470
+ *
3471
+ * @param props - The props passed to the `Form`
3472
+ * @param inputFormData - The new or current data for the `Form`
3473
+ * @returns - The new state for the `Form`
3474
+ */
3475
+ getStateFromProps(props, inputFormData) {
3476
+ const state = this.state || {};
3477
+ const schema = "schema" in props ? props.schema : this.props.schema;
3478
+ const uiSchema = ("uiSchema" in props ? props.uiSchema : this.props.uiSchema) || {};
3479
+ const edit = typeof inputFormData !== "undefined";
3480
+ const liveValidate = "liveValidate" in props ? props.liveValidate : this.props.liveValidate;
3481
+ const mustValidate = edit && !props.noValidate && liveValidate;
3482
+ const rootSchema = schema;
3483
+ const experimental_defaultFormStateBehavior = "experimental_defaultFormStateBehavior" in props ? props.experimental_defaultFormStateBehavior : this.props.experimental_defaultFormStateBehavior;
3484
+ let schemaUtils = state.schemaUtils;
3485
+ if (!schemaUtils || schemaUtils.doesSchemaUtilsDiffer(props.validator, rootSchema, experimental_defaultFormStateBehavior)) {
3486
+ schemaUtils = createSchemaUtils(props.validator, rootSchema, experimental_defaultFormStateBehavior);
3487
+ }
3488
+ const formData = schemaUtils.getDefaultFormState(schema, inputFormData);
3489
+ const retrievedSchema = schemaUtils.retrieveSchema(schema, formData);
3490
+ const getCurrentErrors = () => {
3491
+ if (props.noValidate) {
3492
+ return { errors: [], errorSchema: {} };
3493
+ } else if (!props.liveValidate) {
3494
+ return {
3495
+ errors: state.schemaValidationErrors || [],
3496
+ errorSchema: state.schemaValidationErrorSchema || {}
3497
+ };
3498
+ }
3499
+ return {
3500
+ errors: state.errors || [],
3501
+ errorSchema: state.errorSchema || {}
3502
+ };
3503
+ };
3504
+ let errors;
3505
+ let errorSchema;
3506
+ let schemaValidationErrors = state.schemaValidationErrors;
3507
+ let schemaValidationErrorSchema = state.schemaValidationErrorSchema;
3508
+ if (mustValidate) {
3509
+ const schemaValidation = this.validate(formData, schema, schemaUtils);
3510
+ errors = schemaValidation.errors;
3511
+ errorSchema = schemaValidation.errorSchema;
3512
+ schemaValidationErrors = errors;
3513
+ schemaValidationErrorSchema = errorSchema;
3514
+ } else {
3515
+ const currentErrors = getCurrentErrors();
3516
+ errors = currentErrors.errors;
3517
+ errorSchema = currentErrors.errorSchema;
3518
+ }
3519
+ if (props.extraErrors) {
3520
+ const merged = validationDataMerge({ errorSchema, errors }, props.extraErrors);
3521
+ errorSchema = merged.errorSchema;
3522
+ errors = merged.errors;
3523
+ }
3524
+ const idSchema = schemaUtils.toIdSchema(
3525
+ retrievedSchema,
3526
+ uiSchema["ui:rootFieldId"],
3527
+ formData,
3528
+ props.idPrefix,
3529
+ props.idSeparator
3530
+ );
3531
+ const nextState = {
3532
+ schemaUtils,
3533
+ schema,
3534
+ uiSchema,
3535
+ idSchema,
3536
+ formData,
3537
+ edit,
3538
+ errors,
3539
+ errorSchema,
3540
+ schemaValidationErrors,
3541
+ schemaValidationErrorSchema
3542
+ };
3543
+ return nextState;
3544
+ }
3545
+ /** React lifecycle method that is used to determine whether component should be updated.
3546
+ *
3547
+ * @param nextProps - The next version of the props
3548
+ * @param nextState - The next version of the state
3549
+ * @returns - True if the component should be updated, false otherwise
3550
+ */
3551
+ shouldComponentUpdate(nextProps, nextState) {
3552
+ return shouldRender(this, nextProps, nextState);
3553
+ }
3554
+ /** Validates the `formData` against the `schema` using the `altSchemaUtils` (if provided otherwise it uses the
3555
+ * `schemaUtils` in the state), returning the results.
3556
+ *
3557
+ * @param formData - The new form data to validate
3558
+ * @param schema - The schema used to validate against
3559
+ * @param altSchemaUtils - The alternate schemaUtils to use for validation
3560
+ */
3561
+ validate(formData, schema = this.props.schema, altSchemaUtils) {
3562
+ const schemaUtils = altSchemaUtils ? altSchemaUtils : this.state.schemaUtils;
3563
+ const { customValidate, transformErrors, uiSchema } = this.props;
3564
+ const resolvedSchema = schemaUtils.retrieveSchema(schema, formData);
3565
+ return schemaUtils.getValidator().validateFormData(formData, resolvedSchema, customValidate, transformErrors, uiSchema);
3566
+ }
3567
+ /** Renders any errors contained in the `state` in using the `ErrorList`, if not disabled by `showErrorList`. */
3568
+ renderErrors(registry) {
3569
+ const { errors, errorSchema, schema, uiSchema } = this.state;
3570
+ const { formContext } = this.props;
3571
+ const options = getUiOptions12(uiSchema);
3572
+ const ErrorListTemplate = getTemplate20("ErrorListTemplate", registry, options);
3573
+ if (errors && errors.length) {
3574
+ return /* @__PURE__ */ jsx45(
3575
+ ErrorListTemplate,
3576
+ {
3577
+ errors,
3578
+ errorSchema: errorSchema || {},
3579
+ schema,
3580
+ uiSchema,
3581
+ formContext,
3582
+ registry
3583
+ }
3584
+ );
3585
+ }
3586
+ return null;
3587
+ }
3588
+ /** Returns the registry for the form */
3589
+ getRegistry() {
3590
+ const { translateString: customTranslateString, uiSchema = {} } = this.props;
3591
+ const { schemaUtils } = this.state;
3592
+ const { fields: fields2, templates: templates2, widgets: widgets2, formContext, translateString } = getDefaultRegistry();
3593
+ return {
3594
+ fields: { ...fields2, ...this.props.fields },
3595
+ templates: {
3596
+ ...templates2,
3597
+ ...this.props.templates,
3598
+ ButtonTemplates: {
3599
+ ...templates2.ButtonTemplates,
3600
+ ...this.props.templates?.ButtonTemplates
3601
+ }
3602
+ },
3603
+ widgets: { ...widgets2, ...this.props.widgets },
3604
+ rootSchema: this.props.schema,
3605
+ formContext: this.props.formContext || formContext,
3606
+ schemaUtils,
3607
+ translateString: customTranslateString || translateString,
3608
+ globalUiOptions: uiSchema[UI_GLOBAL_OPTIONS_KEY]
3609
+ };
3610
+ }
3611
+ /** Provides a function that can be used to programmatically submit the `Form` */
3612
+ submit() {
3613
+ if (this.formElement.current) {
3614
+ this.formElement.current.dispatchEvent(
3615
+ new CustomEvent("submit", {
3616
+ cancelable: true
3617
+ })
3618
+ );
3619
+ this.formElement.current.requestSubmit();
3620
+ }
3621
+ }
3622
+ /** Attempts to focus on the field associated with the `error`. Uses the `property` field to compute path of the error
3623
+ * field, then, using the `idPrefix` and `idSeparator` converts that path into an id. Then the input element with that
3624
+ * id is attempted to be found using the `formElement` ref. If it is located, then it is focused.
3625
+ *
3626
+ * @param error - The error on which to focus
3627
+ */
3628
+ focusOnError(error) {
3629
+ const { idPrefix = "root", idSeparator = "_" } = this.props;
3630
+ const { property } = error;
3631
+ const path = _toPath(property);
3632
+ if (path[0] === "") {
3633
+ path[0] = idPrefix;
3634
+ } else {
3635
+ path.unshift(idPrefix);
3636
+ }
3637
+ const elementId = path.join(idSeparator);
3638
+ let field = this.formElement.current.elements[elementId];
3639
+ if (!field) {
3640
+ field = this.formElement.current.querySelector(`input[id^=${elementId}`);
3641
+ }
3642
+ if (field && field.length) {
3643
+ field = field[0];
3644
+ }
3645
+ if (field) {
3646
+ field.focus();
3647
+ }
3648
+ }
3649
+ /** Programmatically validate the form. If `onError` is provided, then it will be called with the list of errors the
3650
+ * same way as would happen on form submission.
3651
+ *
3652
+ * @returns - True if the form is valid, false otherwise.
3653
+ */
3654
+ validateForm() {
3655
+ const { extraErrors, extraErrorsBlockSubmit, focusOnFirstError, onError } = this.props;
3656
+ const { formData } = this.state;
3657
+ const schemaValidation = this.validate(formData);
3658
+ let errors = schemaValidation.errors;
3659
+ let errorSchema = schemaValidation.errorSchema;
3660
+ const schemaValidationErrors = errors;
3661
+ const schemaValidationErrorSchema = errorSchema;
3662
+ if (errors.length > 0 || extraErrors && extraErrorsBlockSubmit) {
3663
+ if (extraErrors) {
3664
+ const merged = validationDataMerge(schemaValidation, extraErrors);
3665
+ errorSchema = merged.errorSchema;
3666
+ errors = merged.errors;
3667
+ }
3668
+ if (focusOnFirstError) {
3669
+ if (typeof focusOnFirstError === "function") {
3670
+ focusOnFirstError(errors[0]);
3671
+ } else {
3672
+ this.focusOnError(errors[0]);
3673
+ }
3674
+ }
3675
+ this.setState(
3676
+ {
3677
+ errors,
3678
+ errorSchema,
3679
+ schemaValidationErrors,
3680
+ schemaValidationErrorSchema
3681
+ },
3682
+ () => {
3683
+ if (onError) {
3684
+ onError(errors);
3685
+ } else {
3686
+ console.error("Form validation failed", errors);
3687
+ }
3688
+ }
3689
+ );
3690
+ return false;
3691
+ }
3692
+ return true;
3693
+ }
3694
+ /** Renders the `Form` fields inside the <form> | `tagName` or `_internalFormWrapper`, rendering any errors if
3695
+ * needed along with the submit button or any children of the form.
3696
+ */
3697
+ render() {
3698
+ const {
3699
+ children,
3700
+ id,
3701
+ idPrefix,
3702
+ idSeparator,
3703
+ className = "",
3704
+ tagName,
3705
+ name,
3706
+ method,
3707
+ target,
3708
+ action,
3709
+ autoComplete,
3710
+ enctype,
3711
+ acceptcharset,
3712
+ noHtml5Validate = false,
3713
+ disabled = false,
3714
+ readonly = false,
3715
+ formContext,
3716
+ showErrorList = "top",
3717
+ _internalFormWrapper
3718
+ } = this.props;
3719
+ const { schema, uiSchema, formData, errorSchema, idSchema } = this.state;
3720
+ const registry = this.getRegistry();
3721
+ const { SchemaField: _SchemaField } = registry.fields;
3722
+ const { SubmitButton: SubmitButton2 } = registry.templates.ButtonTemplates;
3723
+ const as = _internalFormWrapper ? tagName : void 0;
3724
+ const FormTag = _internalFormWrapper || tagName || "form";
3725
+ let { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions = {} } = getUiOptions12(uiSchema);
3726
+ if (disabled) {
3727
+ submitOptions = { ...submitOptions, props: { ...submitOptions.props, disabled: true } };
3728
+ }
3729
+ const submitUiSchema = { [UI_OPTIONS_KEY2]: { [SUBMIT_BTN_OPTIONS_KEY]: submitOptions } };
3730
+ return /* @__PURE__ */ jsxs21(
3731
+ FormTag,
3732
+ {
3733
+ className: className ? className : "rjsf",
3734
+ id,
3735
+ name,
3736
+ method,
3737
+ target,
3738
+ action,
3739
+ autoComplete,
3740
+ encType: enctype,
3741
+ acceptCharset: acceptcharset,
3742
+ noValidate: noHtml5Validate,
3743
+ onSubmit: this.onSubmit,
3744
+ as,
3745
+ ref: this.formElement,
3746
+ children: [
3747
+ showErrorList === "top" && this.renderErrors(registry),
3748
+ /* @__PURE__ */ jsx45(
3749
+ _SchemaField,
3750
+ {
3751
+ name: "",
3752
+ schema,
3753
+ uiSchema,
3754
+ errorSchema,
3755
+ idSchema,
3756
+ idPrefix,
3757
+ idSeparator,
3758
+ formContext,
3759
+ formData,
3760
+ onChange: this.onChange,
3761
+ onBlur: this.onBlur,
3762
+ onFocus: this.onFocus,
3763
+ registry,
3764
+ disabled,
3765
+ readonly
3766
+ }
3767
+ ),
3768
+ children ? children : /* @__PURE__ */ jsx45(SubmitButton2, { uiSchema: submitUiSchema, registry }),
3769
+ showErrorList === "bottom" && this.renderErrors(registry)
3770
+ ]
3771
+ }
3772
+ );
3773
+ }
3774
+ };
3775
+
3776
+ // src/withTheme.tsx
3777
+ import { forwardRef } from "react";
3778
+ import { jsx as jsx46 } from "react/jsx-runtime";
3779
+ function withTheme(themeProps) {
3780
+ return forwardRef(
3781
+ ({ fields: fields2, widgets: widgets2, templates: templates2, ...directProps }, ref) => {
3782
+ fields2 = { ...themeProps?.fields, ...fields2 };
3783
+ widgets2 = { ...themeProps?.widgets, ...widgets2 };
3784
+ templates2 = {
3785
+ ...themeProps?.templates,
3786
+ ...templates2,
3787
+ ButtonTemplates: {
3788
+ ...themeProps?.templates?.ButtonTemplates,
3789
+ ...templates2?.ButtonTemplates
3790
+ }
3791
+ };
3792
+ return /* @__PURE__ */ jsx46(
3793
+ Form,
3794
+ {
3795
+ ...themeProps,
3796
+ ...directProps,
3797
+ fields: fields2,
3798
+ widgets: widgets2,
3799
+ templates: templates2,
3800
+ ref
3801
+ }
3802
+ );
3803
+ }
3804
+ );
3805
+ }
3806
+
3807
+ // src/index.ts
3808
+ var src_default = Form;
3809
+ export {
3810
+ src_default as default,
3811
+ getDefaultRegistry,
3812
+ withTheme
3813
+ };
3814
+ //# sourceMappingURL=index.esm.js.map