@rjsf/daisyui 6.0.0-beta.2

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 (315) hide show
  1. package/README.md +231 -0
  2. package/dist/chakra-ui.esm.js +2192 -0
  3. package/dist/chakra-ui.esm.js.map +7 -0
  4. package/dist/chakra-ui.umd.js +2011 -0
  5. package/dist/index.js +2180 -0
  6. package/dist/index.js.map +7 -0
  7. package/lib/DaisyUIForm.d.ts +5 -0
  8. package/lib/DaisyUIForm.js +8 -0
  9. package/lib/DaisyUIForm.js.map +1 -0
  10. package/lib/DaisyUIFrameProvider.d.ts +35 -0
  11. package/lib/DaisyUIFrameProvider.js +93 -0
  12. package/lib/DaisyUIFrameProvider.js.map +1 -0
  13. package/lib/daisyForm/DaisyForm.d.ts +12 -0
  14. package/lib/daisyForm/DaisyForm.js +15 -0
  15. package/lib/daisyForm/DaisyForm.js.map +1 -0
  16. package/lib/daisyForm/index.d.ts +2 -0
  17. package/lib/daisyForm/index.js +3 -0
  18. package/lib/daisyForm/index.js.map +1 -0
  19. package/lib/index.d.ts +10 -0
  20. package/lib/index.js +11 -0
  21. package/lib/index.js.map +1 -0
  22. package/lib/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.d.ts +7 -0
  23. package/lib/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.js +11 -0
  24. package/lib/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.js.map +1 -0
  25. package/lib/templates/ArrayFieldDescriptionTemplate/index.d.ts +2 -0
  26. package/lib/templates/ArrayFieldDescriptionTemplate/index.js +3 -0
  27. package/lib/templates/ArrayFieldDescriptionTemplate/index.js.map +1 -0
  28. package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.d.ts +5 -0
  29. package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js +20 -0
  30. package/lib/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.js.map +1 -0
  31. package/lib/templates/ArrayFieldItemButtonsTemplate/index.d.ts +2 -0
  32. package/lib/templates/ArrayFieldItemButtonsTemplate/index.js +3 -0
  33. package/lib/templates/ArrayFieldItemButtonsTemplate/index.js.map +1 -0
  34. package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.d.ts +14 -0
  35. package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js +27 -0
  36. package/lib/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.js.map +1 -0
  37. package/lib/templates/ArrayFieldItemTemplate/index.d.ts +2 -0
  38. package/lib/templates/ArrayFieldItemTemplate/index.js +3 -0
  39. package/lib/templates/ArrayFieldItemTemplate/index.js.map +1 -0
  40. package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.d.ts +15 -0
  41. package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js +37 -0
  42. package/lib/templates/ArrayFieldTemplate/ArrayFieldTemplate.js.map +1 -0
  43. package/lib/templates/ArrayFieldTemplate/index.d.ts +2 -0
  44. package/lib/templates/ArrayFieldTemplate/index.js +3 -0
  45. package/lib/templates/ArrayFieldTemplate/index.js.map +1 -0
  46. package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.d.ts +7 -0
  47. package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js +11 -0
  48. package/lib/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.js.map +1 -0
  49. package/lib/templates/ArrayFieldTitleTemplate/index.d.ts +2 -0
  50. package/lib/templates/ArrayFieldTitleTemplate/index.js +3 -0
  51. package/lib/templates/ArrayFieldTitleTemplate/index.js.map +1 -0
  52. package/lib/templates/BaseInputTemplate/BaseInputTemplate.d.ts +16 -0
  53. package/lib/templates/BaseInputTemplate/BaseInputTemplate.js +33 -0
  54. package/lib/templates/BaseInputTemplate/BaseInputTemplate.js.map +1 -0
  55. package/lib/templates/BaseInputTemplate/index.d.ts +2 -0
  56. package/lib/templates/BaseInputTemplate/index.js +3 -0
  57. package/lib/templates/BaseInputTemplate/index.js.map +1 -0
  58. package/lib/templates/ButtonTemplates/AddButton.d.ts +6 -0
  59. package/lib/templates/ButtonTemplates/AddButton.js +15 -0
  60. package/lib/templates/ButtonTemplates/AddButton.js.map +1 -0
  61. package/lib/templates/ButtonTemplates/DaisyUIButton.d.ts +18 -0
  62. package/lib/templates/ButtonTemplates/DaisyUIButton.js +15 -0
  63. package/lib/templates/ButtonTemplates/DaisyUIButton.js.map +1 -0
  64. package/lib/templates/ButtonTemplates/IconButton.d.ts +5 -0
  65. package/lib/templates/ButtonTemplates/IconButton.js +21 -0
  66. package/lib/templates/ButtonTemplates/IconButton.js.map +1 -0
  67. package/lib/templates/ButtonTemplates/SubmitButton.d.ts +4 -0
  68. package/lib/templates/ButtonTemplates/SubmitButton.js +12 -0
  69. package/lib/templates/ButtonTemplates/SubmitButton.js.map +1 -0
  70. package/lib/templates/ButtonTemplates/index.d.ts +15 -0
  71. package/lib/templates/ButtonTemplates/index.js +17 -0
  72. package/lib/templates/ButtonTemplates/index.js.map +1 -0
  73. package/lib/templates/DescriptionField/DescriptionField.d.ts +8 -0
  74. package/lib/templates/DescriptionField/DescriptionField.js +16 -0
  75. package/lib/templates/DescriptionField/DescriptionField.js.map +1 -0
  76. package/lib/templates/DescriptionField/index.d.ts +2 -0
  77. package/lib/templates/DescriptionField/index.js +3 -0
  78. package/lib/templates/DescriptionField/index.js.map +1 -0
  79. package/lib/templates/ErrorList/ErrorList.d.ts +7 -0
  80. package/lib/templates/ErrorList/ErrorList.js +11 -0
  81. package/lib/templates/ErrorList/ErrorList.js.map +1 -0
  82. package/lib/templates/ErrorList/index.d.ts +2 -0
  83. package/lib/templates/ErrorList/index.js +3 -0
  84. package/lib/templates/ErrorList/index.js.map +1 -0
  85. package/lib/templates/FieldErrorTemplate/FieldErrorTemplate.d.ts +10 -0
  86. package/lib/templates/FieldErrorTemplate/FieldErrorTemplate.js +15 -0
  87. package/lib/templates/FieldErrorTemplate/FieldErrorTemplate.js.map +1 -0
  88. package/lib/templates/FieldErrorTemplate/index.d.ts +2 -0
  89. package/lib/templates/FieldErrorTemplate/index.js +3 -0
  90. package/lib/templates/FieldErrorTemplate/index.js.map +1 -0
  91. package/lib/templates/FieldHelpTemplate/FieldHelpTemplate.d.ts +11 -0
  92. package/lib/templates/FieldHelpTemplate/FieldHelpTemplate.js +15 -0
  93. package/lib/templates/FieldHelpTemplate/FieldHelpTemplate.js.map +1 -0
  94. package/lib/templates/FieldHelpTemplate/index.d.ts +2 -0
  95. package/lib/templates/FieldHelpTemplate/index.js +3 -0
  96. package/lib/templates/FieldHelpTemplate/index.js.map +1 -0
  97. package/lib/templates/FieldTemplate/FieldTemplate.d.ts +15 -0
  98. package/lib/templates/FieldTemplate/FieldTemplate.js +23 -0
  99. package/lib/templates/FieldTemplate/FieldTemplate.js.map +1 -0
  100. package/lib/templates/FieldTemplate/index.d.ts +2 -0
  101. package/lib/templates/FieldTemplate/index.js +3 -0
  102. package/lib/templates/FieldTemplate/index.js.map +1 -0
  103. package/lib/templates/GridTemplate/GridTemplate.d.ts +7 -0
  104. package/lib/templates/GridTemplate/GridTemplate.js +16 -0
  105. package/lib/templates/GridTemplate/GridTemplate.js.map +1 -0
  106. package/lib/templates/GridTemplate/index.d.ts +2 -0
  107. package/lib/templates/GridTemplate/index.js +3 -0
  108. package/lib/templates/GridTemplate/index.js.map +1 -0
  109. package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.d.ts +13 -0
  110. package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js +25 -0
  111. package/lib/templates/ObjectFieldTemplate/ObjectFieldTemplate.js.map +1 -0
  112. package/lib/templates/ObjectFieldTemplate/index.d.ts +2 -0
  113. package/lib/templates/ObjectFieldTemplate/index.js +3 -0
  114. package/lib/templates/ObjectFieldTemplate/index.js.map +1 -0
  115. package/lib/templates/Templates.d.ts +19 -0
  116. package/lib/templates/Templates.js +56 -0
  117. package/lib/templates/Templates.js.map +1 -0
  118. package/lib/templates/TitleField/TitleField.d.ts +13 -0
  119. package/lib/templates/TitleField/TitleField.js +19 -0
  120. package/lib/templates/TitleField/TitleField.js.map +1 -0
  121. package/lib/templates/TitleField/index.d.ts +2 -0
  122. package/lib/templates/TitleField/index.js +3 -0
  123. package/lib/templates/TitleField/index.js.map +1 -0
  124. package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.d.ts +7 -0
  125. package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js +20 -0
  126. package/lib/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.js.map +1 -0
  127. package/lib/templates/WrapIfAdditionalTemplate/index.d.ts +2 -0
  128. package/lib/templates/WrapIfAdditionalTemplate/index.js +3 -0
  129. package/lib/templates/WrapIfAdditionalTemplate/index.js.map +1 -0
  130. package/lib/templates/index.d.ts +19 -0
  131. package/lib/templates/index.js +20 -0
  132. package/lib/templates/index.js.map +1 -0
  133. package/lib/theme/Theme.d.ts +43 -0
  134. package/lib/theme/Theme.js +68 -0
  135. package/lib/theme/Theme.js.map +1 -0
  136. package/lib/theme/index.d.ts +2 -0
  137. package/lib/theme/index.js +3 -0
  138. package/lib/theme/index.js.map +1 -0
  139. package/lib/tsconfig.tsbuildinfo +1 -0
  140. package/lib/types/DaisyProps.d.ts +5 -0
  141. package/lib/types/DaisyProps.js +2 -0
  142. package/lib/types/DaisyProps.js.map +1 -0
  143. package/lib/utils.d.ts +13 -0
  144. package/lib/utils.js +5 -0
  145. package/lib/utils.js.map +1 -0
  146. package/lib/widgets/AltDateTimeWidget/AltDateTimeWidget.d.ts +6 -0
  147. package/lib/widgets/AltDateTimeWidget/AltDateTimeWidget.js +10 -0
  148. package/lib/widgets/AltDateTimeWidget/AltDateTimeWidget.js.map +1 -0
  149. package/lib/widgets/AltDateTimeWidget/index.d.ts +2 -0
  150. package/lib/widgets/AltDateTimeWidget/index.js +3 -0
  151. package/lib/widgets/AltDateTimeWidget/index.js.map +1 -0
  152. package/lib/widgets/AltDateWidget/AltDateWidget.d.ts +15 -0
  153. package/lib/widgets/AltDateWidget/AltDateWidget.js +138 -0
  154. package/lib/widgets/AltDateWidget/AltDateWidget.js.map +1 -0
  155. package/lib/widgets/AltDateWidget/index.d.ts +2 -0
  156. package/lib/widgets/AltDateWidget/index.js +3 -0
  157. package/lib/widgets/AltDateWidget/index.js.map +1 -0
  158. package/lib/widgets/CheckboxWidget/CheckboxWidget.d.ts +13 -0
  159. package/lib/widgets/CheckboxWidget/CheckboxWidget.js +43 -0
  160. package/lib/widgets/CheckboxWidget/CheckboxWidget.js.map +1 -0
  161. package/lib/widgets/CheckboxWidget/index.d.ts +2 -0
  162. package/lib/widgets/CheckboxWidget/index.js +3 -0
  163. package/lib/widgets/CheckboxWidget/index.js.map +1 -0
  164. package/lib/widgets/CheckboxesWidget/CheckboxesWidget.d.ts +16 -0
  165. package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js +73 -0
  166. package/lib/widgets/CheckboxesWidget/CheckboxesWidget.js.map +1 -0
  167. package/lib/widgets/CheckboxesWidget/index.d.ts +2 -0
  168. package/lib/widgets/CheckboxesWidget/index.js +3 -0
  169. package/lib/widgets/CheckboxesWidget/index.js.map +1 -0
  170. package/lib/widgets/DateTimeWidget/DateTimeWidget.d.ts +14 -0
  171. package/lib/widgets/DateTimeWidget/DateTimeWidget.js +207 -0
  172. package/lib/widgets/DateTimeWidget/DateTimeWidget.js.map +1 -0
  173. package/lib/widgets/DateTimeWidget/index.d.ts +2 -0
  174. package/lib/widgets/DateTimeWidget/index.js +3 -0
  175. package/lib/widgets/DateTimeWidget/index.js.map +1 -0
  176. package/lib/widgets/DateWidget/DateWidget.d.ts +14 -0
  177. package/lib/widgets/DateWidget/DateWidget.js +274 -0
  178. package/lib/widgets/DateWidget/DateWidget.js.map +1 -0
  179. package/lib/widgets/DateWidget/index.d.ts +2 -0
  180. package/lib/widgets/DateWidget/index.js +3 -0
  181. package/lib/widgets/DateWidget/index.js.map +1 -0
  182. package/lib/widgets/FileWidget/FileWidget.d.ts +12 -0
  183. package/lib/widgets/FileWidget/FileWidget.js +57 -0
  184. package/lib/widgets/FileWidget/FileWidget.js.map +1 -0
  185. package/lib/widgets/FileWidget/index.d.ts +2 -0
  186. package/lib/widgets/FileWidget/index.js +3 -0
  187. package/lib/widgets/FileWidget/index.js.map +1 -0
  188. package/lib/widgets/RadioWidget/RadioWidget.d.ts +14 -0
  189. package/lib/widgets/RadioWidget/RadioWidget.js +67 -0
  190. package/lib/widgets/RadioWidget/RadioWidget.js.map +1 -0
  191. package/lib/widgets/RadioWidget/index.d.ts +2 -0
  192. package/lib/widgets/RadioWidget/index.js +3 -0
  193. package/lib/widgets/RadioWidget/index.js.map +1 -0
  194. package/lib/widgets/RangeWidget/RangeWidget.d.ts +13 -0
  195. package/lib/widgets/RangeWidget/RangeWidget.js +42 -0
  196. package/lib/widgets/RangeWidget/RangeWidget.js.map +1 -0
  197. package/lib/widgets/RangeWidget/index.d.ts +2 -0
  198. package/lib/widgets/RangeWidget/index.js +3 -0
  199. package/lib/widgets/RangeWidget/index.js.map +1 -0
  200. package/lib/widgets/RatingWidget/RatingWidget.d.ts +17 -0
  201. package/lib/widgets/RatingWidget/RatingWidget.js +64 -0
  202. package/lib/widgets/RatingWidget/RatingWidget.js.map +1 -0
  203. package/lib/widgets/RatingWidget/index.d.ts +2 -0
  204. package/lib/widgets/RatingWidget/index.js +3 -0
  205. package/lib/widgets/RatingWidget/index.js.map +1 -0
  206. package/lib/widgets/SelectWidget/SelectWidget.d.ts +14 -0
  207. package/lib/widgets/SelectWidget/SelectWidget.js +74 -0
  208. package/lib/widgets/SelectWidget/SelectWidget.js.map +1 -0
  209. package/lib/widgets/SelectWidget/index.d.ts +2 -0
  210. package/lib/widgets/SelectWidget/index.js +3 -0
  211. package/lib/widgets/SelectWidget/index.js.map +1 -0
  212. package/lib/widgets/TextareaWidget/TextareaWidget.d.ts +12 -0
  213. package/lib/widgets/TextareaWidget/TextareaWidget.js +44 -0
  214. package/lib/widgets/TextareaWidget/TextareaWidget.js.map +1 -0
  215. package/lib/widgets/TextareaWidget/index.d.ts +2 -0
  216. package/lib/widgets/TextareaWidget/index.js +3 -0
  217. package/lib/widgets/TextareaWidget/index.js.map +1 -0
  218. package/lib/widgets/TimeWidget/TimeWidget.d.ts +12 -0
  219. package/lib/widgets/TimeWidget/TimeWidget.js +42 -0
  220. package/lib/widgets/TimeWidget/TimeWidget.js.map +1 -0
  221. package/lib/widgets/TimeWidget/index.d.ts +2 -0
  222. package/lib/widgets/TimeWidget/index.js +3 -0
  223. package/lib/widgets/TimeWidget/index.js.map +1 -0
  224. package/lib/widgets/ToggleWidget/ToggleWidget.d.ts +13 -0
  225. package/lib/widgets/ToggleWidget/ToggleWidget.js +40 -0
  226. package/lib/widgets/ToggleWidget/ToggleWidget.js.map +1 -0
  227. package/lib/widgets/ToggleWidget/index.d.ts +2 -0
  228. package/lib/widgets/ToggleWidget/index.js +3 -0
  229. package/lib/widgets/ToggleWidget/index.js.map +1 -0
  230. package/lib/widgets/Widgets.d.ts +18 -0
  231. package/lib/widgets/Widgets.js +35 -0
  232. package/lib/widgets/Widgets.js.map +1 -0
  233. package/lib/widgets/index.d.ts +2 -0
  234. package/lib/widgets/index.js +3 -0
  235. package/lib/widgets/index.js.map +1 -0
  236. package/package.json +95 -0
  237. package/src/DaisyUIForm.tsx +9 -0
  238. package/src/DaisyUIFrameProvider.tsx +107 -0
  239. package/src/daisyForm/DaisyForm.tsx +20 -0
  240. package/src/daisyForm/index.ts +2 -0
  241. package/src/index.ts +13 -0
  242. package/src/styles.css +9 -0
  243. package/src/templates/ArrayFieldDescriptionTemplate/ArrayFieldDescriptionTemplate.tsx +19 -0
  244. package/src/templates/ArrayFieldDescriptionTemplate/index.ts +2 -0
  245. package/src/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.tsx +89 -0
  246. package/src/templates/ArrayFieldItemButtonsTemplate/index.ts +2 -0
  247. package/src/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx +55 -0
  248. package/src/templates/ArrayFieldItemTemplate/index.ts +2 -0
  249. package/src/templates/ArrayFieldTemplate/ArrayFieldTemplate.tsx +120 -0
  250. package/src/templates/ArrayFieldTemplate/index.ts +2 -0
  251. package/src/templates/ArrayFieldTitleTemplate/ArrayFieldTitleTemplate.tsx +15 -0
  252. package/src/templates/ArrayFieldTitleTemplate/index.ts +2 -0
  253. package/src/templates/BaseInputTemplate/BaseInputTemplate.tsx +104 -0
  254. package/src/templates/BaseInputTemplate/index.ts +2 -0
  255. package/src/templates/ButtonTemplates/AddButton.tsx +38 -0
  256. package/src/templates/ButtonTemplates/DaisyUIButton.tsx +31 -0
  257. package/src/templates/ButtonTemplates/IconButton.tsx +62 -0
  258. package/src/templates/ButtonTemplates/SubmitButton.tsx +25 -0
  259. package/src/templates/ButtonTemplates/index.ts +19 -0
  260. package/src/templates/DescriptionField/DescriptionField.tsx +26 -0
  261. package/src/templates/DescriptionField/index.ts +2 -0
  262. package/src/templates/ErrorList/ErrorList.tsx +21 -0
  263. package/src/templates/ErrorList/index.ts +2 -0
  264. package/src/templates/FieldErrorTemplate/FieldErrorTemplate.tsx +22 -0
  265. package/src/templates/FieldErrorTemplate/index.ts +2 -0
  266. package/src/templates/FieldHelpTemplate/FieldHelpTemplate.tsx +23 -0
  267. package/src/templates/FieldHelpTemplate/index.ts +2 -0
  268. package/src/templates/FieldTemplate/FieldTemplate.tsx +66 -0
  269. package/src/templates/FieldTemplate/index.ts +2 -0
  270. package/src/templates/GridTemplate/GridTemplate.tsx +26 -0
  271. package/src/templates/GridTemplate/index.ts +2 -0
  272. package/src/templates/ObjectFieldTemplate/ObjectFieldTemplate.tsx +108 -0
  273. package/src/templates/ObjectFieldTemplate/index.ts +2 -0
  274. package/src/templates/Templates.tsx +63 -0
  275. package/src/templates/TitleField/TitleField.tsx +26 -0
  276. package/src/templates/TitleField/index.ts +2 -0
  277. package/src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx +74 -0
  278. package/src/templates/WrapIfAdditionalTemplate/index.ts +2 -0
  279. package/src/templates/index.ts +22 -0
  280. package/src/theme/Theme.tsx +93 -0
  281. package/src/theme/index.ts +2 -0
  282. package/src/tsconfig.json +26 -0
  283. package/src/types/DaisyProps.ts +5 -0
  284. package/src/types.d.ts +4 -0
  285. package/src/utils.ts +18 -0
  286. package/src/widgets/AltDateTimeWidget/AltDateTimeWidget.tsx +14 -0
  287. package/src/widgets/AltDateTimeWidget/index.ts +2 -0
  288. package/src/widgets/AltDateWidget/AltDateWidget.tsx +328 -0
  289. package/src/widgets/AltDateWidget/index.ts +2 -0
  290. package/src/widgets/CheckboxWidget/CheckboxWidget.tsx +108 -0
  291. package/src/widgets/CheckboxWidget/index.ts +2 -0
  292. package/src/widgets/CheckboxesWidget/CheckboxesWidget.tsx +124 -0
  293. package/src/widgets/CheckboxesWidget/index.ts +2 -0
  294. package/src/widgets/DateTimeWidget/DateTimeWidget.tsx +343 -0
  295. package/src/widgets/DateTimeWidget/index.ts +2 -0
  296. package/src/widgets/DateWidget/DateWidget.tsx +393 -0
  297. package/src/widgets/DateWidget/index.ts +2 -0
  298. package/src/widgets/FileWidget/FileWidget.tsx +86 -0
  299. package/src/widgets/FileWidget/index.ts +2 -0
  300. package/src/widgets/RadioWidget/RadioWidget.tsx +114 -0
  301. package/src/widgets/RadioWidget/index.ts +2 -0
  302. package/src/widgets/RangeWidget/RangeWidget.tsx +78 -0
  303. package/src/widgets/RangeWidget/index.ts +2 -0
  304. package/src/widgets/RatingWidget/RatingWidget.tsx +120 -0
  305. package/src/widgets/RatingWidget/index.ts +2 -0
  306. package/src/widgets/SelectWidget/SelectWidget.tsx +161 -0
  307. package/src/widgets/SelectWidget/index.ts +2 -0
  308. package/src/widgets/TextareaWidget/TextareaWidget.tsx +77 -0
  309. package/src/widgets/TextareaWidget/index.ts +2 -0
  310. package/src/widgets/TimeWidget/TimeWidget.tsx +72 -0
  311. package/src/widgets/TimeWidget/index.ts +2 -0
  312. package/src/widgets/ToggleWidget/ToggleWidget.tsx +70 -0
  313. package/src/widgets/ToggleWidget/index.ts +2 -0
  314. package/src/widgets/Widgets.tsx +58 -0
  315. package/src/widgets/index.ts +2 -0
@@ -0,0 +1,2192 @@
1
+ // src/index.ts
2
+ import { withTheme as withTheme2 } from "@rjsf/core";
3
+
4
+ // src/theme/Theme.tsx
5
+ import { createContext, useCallback as useCallback17, useContext, useState as useState4 } from "react";
6
+ import { getDefaultRegistry } from "@rjsf/core";
7
+
8
+ // src/templates/ArrayFieldItemButtonsTemplate/ArrayFieldItemButtonsTemplate.tsx
9
+ import { useMemo } from "react";
10
+ import {
11
+ buttonId
12
+ } from "@rjsf/utils";
13
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
+ function ArrayFieldItemButtonsTemplate(props) {
15
+ const {
16
+ disabled,
17
+ hasCopy,
18
+ hasMoveDown,
19
+ hasMoveUp,
20
+ hasRemove,
21
+ idSchema,
22
+ index,
23
+ onCopyIndexClick,
24
+ onDropIndexClick,
25
+ onReorderClick,
26
+ readonly,
27
+ registry,
28
+ uiSchema
29
+ } = props;
30
+ const { CopyButton: CopyButton2, MoveDownButton: MoveDownButton2, MoveUpButton: MoveUpButton2, RemoveButton: RemoveButton2 } = registry.templates.ButtonTemplates;
31
+ const onCopyClick = useMemo(() => onCopyIndexClick(index), [index, onCopyIndexClick]);
32
+ const onRemoveClick = useMemo(() => onDropIndexClick(index), [index, onDropIndexClick]);
33
+ const onArrowUpClick = useMemo(() => onReorderClick(index, index - 1), [index, onReorderClick]);
34
+ const onArrowDownClick = useMemo(() => onReorderClick(index, index + 1), [index, onReorderClick]);
35
+ const renderMany = [hasMoveUp || hasMoveDown, hasCopy, hasRemove].filter(Boolean).length > 1;
36
+ const btnClass = renderMany ? "join-item btn btn-sm px-2" : "btn btn-sm px-2 rounded-sm";
37
+ const removeBtnClass = renderMany ? "join-item btn btn-sm btn-error px-2" : "btn btn-sm btn-error px-2 rounded-sm";
38
+ const buttons = /* @__PURE__ */ jsxs(Fragment, { children: [
39
+ (hasMoveUp || hasMoveDown) && /* @__PURE__ */ jsxs(Fragment, { children: [
40
+ /* @__PURE__ */ jsx(
41
+ MoveUpButton2,
42
+ {
43
+ id: buttonId(idSchema, "moveUp"),
44
+ className: `rjsf-array-item-move-up ${btnClass}`,
45
+ disabled: disabled || readonly || !hasMoveUp,
46
+ onClick: onArrowUpClick,
47
+ uiSchema,
48
+ registry
49
+ }
50
+ ),
51
+ /* @__PURE__ */ jsx(
52
+ MoveDownButton2,
53
+ {
54
+ id: buttonId(idSchema, "moveDown"),
55
+ className: `rjsf-array-item-move-down ${btnClass}`,
56
+ disabled: disabled || readonly || !hasMoveDown,
57
+ onClick: onArrowDownClick,
58
+ uiSchema,
59
+ registry
60
+ }
61
+ )
62
+ ] }),
63
+ hasCopy && /* @__PURE__ */ jsx(
64
+ CopyButton2,
65
+ {
66
+ id: buttonId(idSchema, "copy"),
67
+ className: `rjsf-array-item-copy ${btnClass}`,
68
+ disabled: disabled || readonly,
69
+ onClick: onCopyClick,
70
+ uiSchema,
71
+ registry
72
+ }
73
+ ),
74
+ hasRemove && /* @__PURE__ */ jsx(
75
+ RemoveButton2,
76
+ {
77
+ id: buttonId(idSchema, "remove"),
78
+ className: `rjsf-array-item-remove ${removeBtnClass}`,
79
+ disabled: disabled || readonly,
80
+ onClick: onRemoveClick,
81
+ uiSchema,
82
+ registry
83
+ }
84
+ )
85
+ ] });
86
+ return renderMany ? /* @__PURE__ */ jsx("div", { className: "join", children: buttons }) : buttons;
87
+ }
88
+
89
+ // src/templates/ArrayFieldItemTemplate/ArrayFieldItemTemplate.tsx
90
+ import {
91
+ getTemplate,
92
+ getUiOptions
93
+ } from "@rjsf/utils";
94
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
95
+ function ArrayFieldItemTemplate(props) {
96
+ const { children, buttonsProps, hasToolbar, registry, uiSchema, index, totalItems } = props;
97
+ const uiOptions = getUiOptions(uiSchema);
98
+ const ArrayFieldItemButtonsTemplate2 = getTemplate(
99
+ "ArrayFieldItemButtonsTemplate",
100
+ registry,
101
+ uiOptions
102
+ );
103
+ const isFirstItem = index === 0;
104
+ const isLastItem = index === totalItems - 1;
105
+ const borderRadius = isFirstItem ? "rounded-t-lg" : isLastItem ? "rounded-b-lg" : "";
106
+ const marginBottom = isLastItem ? "" : "mb-[-1px]";
107
+ const zIndex = index === void 0 ? "" : "z-" + (10 - Math.min(index, 9));
108
+ return /* @__PURE__ */ jsxs2("fieldset", { className: `fieldset bg-base-100 border border-base-300 p-4 ${borderRadius} ${marginBottom} ${zIndex}`, children: [
109
+ children,
110
+ hasToolbar && /* @__PURE__ */ jsx2("div", { className: "flex justify-end mt-2", children: /* @__PURE__ */ jsx2(ArrayFieldItemButtonsTemplate2, { ...buttonsProps }) })
111
+ ] });
112
+ }
113
+
114
+ // src/templates/ArrayFieldTemplate/ArrayFieldTemplate.tsx
115
+ import { useCallback } from "react";
116
+ import {
117
+ getTemplate as getTemplate2,
118
+ getUiOptions as getUiOptions2,
119
+ TranslatableString,
120
+ buttonId as buttonId2
121
+ } from "@rjsf/utils";
122
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
123
+ function ArrayFieldTemplate(props) {
124
+ const {
125
+ canAdd,
126
+ className,
127
+ disabled,
128
+ idSchema,
129
+ items,
130
+ onAddClick,
131
+ readonly,
132
+ registry,
133
+ required,
134
+ schema,
135
+ title,
136
+ uiSchema
137
+ } = props;
138
+ const uiOptions = getUiOptions2(uiSchema);
139
+ const ArrayFieldDescriptionTemplate = getTemplate2(
140
+ "ArrayFieldDescriptionTemplate",
141
+ registry,
142
+ uiOptions
143
+ );
144
+ const ArrayFieldItemTemplate2 = getTemplate2(
145
+ "ArrayFieldItemTemplate",
146
+ registry,
147
+ uiOptions
148
+ );
149
+ const ArrayFieldTitleTemplate = getTemplate2(
150
+ "ArrayFieldTitleTemplate",
151
+ registry,
152
+ uiOptions
153
+ );
154
+ const {
155
+ ButtonTemplates: { AddButton: AddButton2 }
156
+ } = registry.templates;
157
+ const handleAddClick = useCallback(
158
+ (e) => {
159
+ e.preventDefault();
160
+ e.stopPropagation();
161
+ onAddClick(e);
162
+ },
163
+ [onAddClick]
164
+ );
165
+ return /* @__PURE__ */ jsxs3("div", { className: `array-field-template ${className}`, children: [
166
+ /* @__PURE__ */ jsx3(
167
+ ArrayFieldTitleTemplate,
168
+ {
169
+ idSchema,
170
+ title: uiOptions.title || title,
171
+ schema,
172
+ uiSchema,
173
+ required,
174
+ registry
175
+ }
176
+ ),
177
+ /* @__PURE__ */ jsx3(
178
+ ArrayFieldDescriptionTemplate,
179
+ {
180
+ idSchema,
181
+ description: uiOptions.description || schema.description,
182
+ schema,
183
+ uiSchema,
184
+ registry
185
+ }
186
+ ),
187
+ /* @__PURE__ */ jsxs3("div", { className: "flex flex-col gap-4", children: [
188
+ /* @__PURE__ */ jsxs3("div", { className: "rjsf-array-item-list", children: [
189
+ items && items.map(({ key, ...itemProps }, index) => /* @__PURE__ */ jsx3(ArrayFieldItemTemplate2, { ...itemProps, index, totalItems: items.length }, key)),
190
+ items && items.length === 0 && canAdd && /* @__PURE__ */ jsx3("div", { className: "text-center italic text-base-content/70", children: TranslatableString.EmptyArray })
191
+ ] }),
192
+ canAdd && /* @__PURE__ */ jsx3("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx3(
193
+ AddButton2,
194
+ {
195
+ id: buttonId2(idSchema, "add"),
196
+ className: "rjsf-array-item-add btn btn-primary btn-sm",
197
+ onClick: handleAddClick,
198
+ disabled: disabled || readonly,
199
+ uiSchema,
200
+ registry
201
+ }
202
+ ) })
203
+ ] })
204
+ ] });
205
+ }
206
+
207
+ // src/templates/BaseInputTemplate/BaseInputTemplate.tsx
208
+ import { useCallback as useCallback2 } from "react";
209
+ import {
210
+ getInputProps,
211
+ ariaDescribedByIds,
212
+ examplesId
213
+ } from "@rjsf/utils";
214
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
215
+ function BaseInputTemplate(props) {
216
+ const {
217
+ id,
218
+ value,
219
+ required,
220
+ disabled,
221
+ readonly,
222
+ autofocus,
223
+ onChange,
224
+ onBlur,
225
+ onFocus,
226
+ onChangeOverride,
227
+ options,
228
+ schema,
229
+ type,
230
+ label,
231
+ placeholder
232
+ } = props;
233
+ const inputProps = getInputProps(schema, type, options);
234
+ const { step, min, max, accept, ...rest } = inputProps;
235
+ const htmlInputProps = { step, min, max, accept, ...schema.examples ? { list: examplesId(id) } : void 0 };
236
+ const _onChange = useCallback2(
237
+ ({ target: { value: value2 } }) => onChange(value2 === "" ? options.emptyValue : value2),
238
+ [onChange, options]
239
+ );
240
+ const _onBlur = useCallback2(
241
+ ({ target }) => onBlur && onBlur(id, target.value),
242
+ [onBlur, id]
243
+ );
244
+ const _onFocus = useCallback2(
245
+ ({ target }) => onFocus && onFocus(id, target.value),
246
+ [onFocus, id]
247
+ );
248
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
249
+ /* @__PURE__ */ jsxs4("div", { className: "form-control", children: [
250
+ /* @__PURE__ */ jsx4("label", { htmlFor: id, className: "label hidden", style: { display: "none" }, children: /* @__PURE__ */ jsx4("span", { className: "label-text", children: label }) }),
251
+ /* @__PURE__ */ jsx4(
252
+ "input",
253
+ {
254
+ id,
255
+ name: id,
256
+ value: value || value === 0 ? value : "",
257
+ placeholder,
258
+ required,
259
+ disabled: disabled || readonly,
260
+ autoFocus: autofocus,
261
+ className: "input input-bordered",
262
+ ...rest,
263
+ ...htmlInputProps,
264
+ onChange: onChangeOverride || _onChange,
265
+ onBlur: _onBlur,
266
+ onFocus: _onFocus,
267
+ "aria-describedby": ariaDescribedByIds(id, !!schema.examples)
268
+ }
269
+ )
270
+ ] }),
271
+ Array.isArray(schema.examples) && /* @__PURE__ */ jsx4("datalist", { id: examplesId(id), children: schema.examples.concat(schema.default && !schema.examples.includes(schema.default) ? [schema.default] : []).map((example) => {
272
+ return /* @__PURE__ */ jsx4("option", { value: example }, example);
273
+ }) })
274
+ ] });
275
+ }
276
+
277
+ // src/templates/ButtonTemplates/AddButton.tsx
278
+ import { TranslatableString as TranslatableString2 } from "@rjsf/utils";
279
+ import { library } from "@fortawesome/fontawesome-svg-core";
280
+ import { faArrowDown, faArrowUp, faCopy, faTrash, faPlus } from "@fortawesome/free-solid-svg-icons";
281
+
282
+ // src/templates/ButtonTemplates/DaisyUIButton.tsx
283
+ import { memo } from "react";
284
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
285
+ import { jsx as jsx5 } from "react/jsx-runtime";
286
+ function DaisyUIButton(props) {
287
+ const { icon, iconType, uiSchema, registry, className, ...otherProps } = props;
288
+ return /* @__PURE__ */ jsx5("button", { type: "button", className, "aria-label": props.title, ...otherProps, children: /* @__PURE__ */ jsx5(FontAwesomeIcon, { icon, className: "h-5 w-5" }) });
289
+ }
290
+ DaisyUIButton.displayName = "DaisyUIButton";
291
+ var DaisyUIButton_default = memo(DaisyUIButton);
292
+
293
+ // src/templates/ButtonTemplates/AddButton.tsx
294
+ import { jsx as jsx6 } from "react/jsx-runtime";
295
+ library.add(faPlus, faCopy, faArrowDown, faArrowUp, faTrash);
296
+ function AddButton({
297
+ className,
298
+ onClick,
299
+ disabled,
300
+ registry,
301
+ ...otherProps
302
+ }) {
303
+ const { translateString } = registry;
304
+ return /* @__PURE__ */ jsx6("div", { className: "row", children: /* @__PURE__ */ jsx6("p", { className: `col-xs-3 col-xs-offset-9 text-right ${className}`, children: /* @__PURE__ */ jsx6(
305
+ DaisyUIButton_default,
306
+ {
307
+ ...otherProps,
308
+ iconType: "info",
309
+ icon: faPlus,
310
+ className: "btn-add col-xs-12 btn-primary btn-primary-content",
311
+ title: translateString(TranslatableString2.AddButton),
312
+ onClick,
313
+ disabled,
314
+ registry
315
+ }
316
+ ) }) });
317
+ }
318
+
319
+ // src/templates/ButtonTemplates/SubmitButton.tsx
320
+ import { getSubmitButtonOptions } from "@rjsf/utils";
321
+ import { jsx as jsx7 } from "react/jsx-runtime";
322
+ function SubmitButton({ uiSchema }) {
323
+ const { submitText, norender, props: submitButtonProps = {} } = getSubmitButtonOptions(uiSchema);
324
+ if (norender) {
325
+ return null;
326
+ }
327
+ return /* @__PURE__ */ jsx7("div", { children: /* @__PURE__ */ jsx7(
328
+ "button",
329
+ {
330
+ type: "submit",
331
+ ...submitButtonProps,
332
+ className: `btn btn-primary btn-primary-content ${submitButtonProps.className || ""}`,
333
+ children: submitText
334
+ }
335
+ ) });
336
+ }
337
+
338
+ // src/templates/ButtonTemplates/IconButton.tsx
339
+ import { TranslatableString as TranslatableString3 } from "@rjsf/utils";
340
+ import { faCopy as faCopy2, faArrowDown as faArrowDown2, faArrowUp as faArrowUp2, faTrash as faTrash2 } from "@fortawesome/free-solid-svg-icons";
341
+ import { jsx as jsx8 } from "react/jsx-runtime";
342
+ function CopyButton(props) {
343
+ const {
344
+ registry: { translateString }
345
+ } = props;
346
+ return /* @__PURE__ */ jsx8(DaisyUIButton_default, { ...props, title: translateString(TranslatableString3.CopyButton), icon: faCopy2 });
347
+ }
348
+ function MoveDownButton(props) {
349
+ const {
350
+ registry: { translateString }
351
+ } = props;
352
+ return /* @__PURE__ */ jsx8(
353
+ DaisyUIButton_default,
354
+ {
355
+ ...props,
356
+ title: translateString(TranslatableString3.MoveDownButton),
357
+ icon: faArrowDown2
358
+ }
359
+ );
360
+ }
361
+ function MoveUpButton(props) {
362
+ const {
363
+ registry: { translateString }
364
+ } = props;
365
+ return /* @__PURE__ */ jsx8(
366
+ DaisyUIButton_default,
367
+ {
368
+ ...props,
369
+ title: translateString(TranslatableString3.MoveUpButton),
370
+ icon: faArrowUp2
371
+ }
372
+ );
373
+ }
374
+ function RemoveButton(props) {
375
+ const {
376
+ registry: { translateString }
377
+ } = props;
378
+ return /* @__PURE__ */ jsx8(
379
+ DaisyUIButton_default,
380
+ {
381
+ ...props,
382
+ title: translateString(TranslatableString3.RemoveButton),
383
+ iconType: "danger",
384
+ icon: faTrash2
385
+ }
386
+ );
387
+ }
388
+
389
+ // src/templates/DescriptionField/DescriptionField.tsx
390
+ import { RichDescription } from "@rjsf/core";
391
+ import { jsx as jsx9 } from "react/jsx-runtime";
392
+ function DescriptionField(props) {
393
+ const { id, description, registry, uiSchema } = props;
394
+ if (!description) {
395
+ return null;
396
+ }
397
+ return /* @__PURE__ */ jsx9("div", { id, className: "description-field my-4", children: /* @__PURE__ */ jsx9("div", { className: "text-sm text-base-content/80", children: /* @__PURE__ */ jsx9(RichDescription, { description, registry, uiSchema }) }) });
398
+ }
399
+
400
+ // src/templates/ErrorList/ErrorList.tsx
401
+ import { jsx as jsx10 } from "react/jsx-runtime";
402
+ function ErrorList(props) {
403
+ const { errors } = props;
404
+ return /* @__PURE__ */ jsx10("div", { className: "error-list", children: /* @__PURE__ */ jsx10("ul", { className: "list-disc list-inside text-red-600", children: errors.map((error, index) => /* @__PURE__ */ jsx10("li", { children: error.stack }, index)) }) });
405
+ }
406
+
407
+ // src/templates/FieldErrorTemplate/FieldErrorTemplate.tsx
408
+ import { jsx as jsx11 } from "react/jsx-runtime";
409
+ function FieldErrorTemplate(props) {
410
+ const { errors } = props;
411
+ return /* @__PURE__ */ jsx11("div", { className: "rjsf-field-error-template text-red-600", children: /* @__PURE__ */ jsx11("ul", { className: "list-disc list-inside", children: errors?.map((error, index) => /* @__PURE__ */ jsx11("li", { children: error }, index)) ?? [] }) });
412
+ }
413
+
414
+ // src/templates/FieldHelpTemplate/FieldHelpTemplate.tsx
415
+ import { jsx as jsx12 } from "react/jsx-runtime";
416
+ function FieldHelpTemplate(props) {
417
+ const { help } = props;
418
+ return /* @__PURE__ */ jsx12("div", { className: "rjsf-field-help-template text-gray-500 text-sm", children: /* @__PURE__ */ jsx12("div", { children: help }) });
419
+ }
420
+
421
+ // src/templates/FieldTemplate/FieldTemplate.tsx
422
+ import { jsx as jsx13, jsxs as jsxs5 } from "react/jsx-runtime";
423
+ function FieldTemplate(props) {
424
+ const {
425
+ id,
426
+ label,
427
+ children,
428
+ errors,
429
+ formContext,
430
+ formData,
431
+ help,
432
+ hideError,
433
+ displayLabel,
434
+ classNames,
435
+ // Destructure props we don't want to pass to div
436
+ onKeyChange,
437
+ onDropPropertyClick,
438
+ uiSchema,
439
+ schema,
440
+ readonly,
441
+ required,
442
+ rawErrors,
443
+ rawHelp,
444
+ rawDescription,
445
+ hidden,
446
+ onChange,
447
+ registry,
448
+ ...divProps
449
+ } = props;
450
+ const isCheckbox = schema.type === "boolean";
451
+ return /* @__PURE__ */ jsxs5("div", { className: `field-template mb-3 ${classNames || ""}`, ...divProps, children: [
452
+ displayLabel && !isCheckbox && /* @__PURE__ */ jsx13("label", { htmlFor: id, className: "label", children: /* @__PURE__ */ jsxs5("span", { className: "label-text font-medium", children: [
453
+ label,
454
+ required && /* @__PURE__ */ jsx13("span", { className: "text-error ml-1", children: "*" })
455
+ ] }) }),
456
+ children,
457
+ errors,
458
+ help
459
+ ] });
460
+ }
461
+
462
+ // src/templates/GridTemplate/GridTemplate.tsx
463
+ import { jsx as jsx14 } from "react/jsx-runtime";
464
+ function GridTemplate(props) {
465
+ const { children, column, ...rest } = props;
466
+ if (column) {
467
+ return /* @__PURE__ */ jsx14("div", { className: "flex-grow", ...rest, children });
468
+ }
469
+ return /* @__PURE__ */ jsx14("div", { className: "flex flex-wrap gap-4", ...rest, children });
470
+ }
471
+
472
+ // src/templates/ObjectFieldTemplate/ObjectFieldTemplate.tsx
473
+ import {
474
+ canExpand,
475
+ descriptionId,
476
+ getTemplate as getTemplate3,
477
+ getUiOptions as getUiOptions3,
478
+ titleId,
479
+ buttonId as buttonId3
480
+ } from "@rjsf/utils";
481
+ import { jsx as jsx15, jsxs as jsxs6 } from "react/jsx-runtime";
482
+ function ObjectFieldTemplate(props) {
483
+ const {
484
+ description,
485
+ title,
486
+ properties,
487
+ required,
488
+ disabled,
489
+ readonly,
490
+ uiSchema,
491
+ idSchema,
492
+ schema,
493
+ formData,
494
+ onAddClick,
495
+ registry
496
+ } = props;
497
+ const uiOptions = getUiOptions3(uiSchema);
498
+ const TitleFieldTemplate = getTemplate3("TitleFieldTemplate", registry, uiOptions);
499
+ const DescriptionFieldTemplate = getTemplate3(
500
+ "DescriptionFieldTemplate",
501
+ registry,
502
+ uiOptions
503
+ );
504
+ const {
505
+ ButtonTemplates: { AddButton: AddButton2 }
506
+ } = registry.templates;
507
+ const isRoot = idSchema.$id === "root";
508
+ return /* @__PURE__ */ jsxs6("div", { className: `form-control ${isRoot ? "bg-base-100 p-6 rounded-xl shadow-lg" : ""}`, children: [
509
+ title && /* @__PURE__ */ jsx15(
510
+ TitleFieldTemplate,
511
+ {
512
+ id: titleId(idSchema),
513
+ title,
514
+ required,
515
+ schema,
516
+ uiSchema,
517
+ registry
518
+ }
519
+ ),
520
+ description && /* @__PURE__ */ jsx15(
521
+ DescriptionFieldTemplate,
522
+ {
523
+ id: descriptionId(idSchema),
524
+ description,
525
+ schema,
526
+ uiSchema,
527
+ registry
528
+ }
529
+ ),
530
+ /* @__PURE__ */ jsxs6("div", { className: `grid grid-cols-1 gap-${description ? 3 : 4} ${isRoot ? "" : "mb-4"}`, children: [
531
+ properties.map(
532
+ (element, index) => element.hidden ? element.content : /* @__PURE__ */ jsx15(
533
+ "div",
534
+ {
535
+ className: idSchema.$id === "root" && element.name === "tasks" ? "mt-2" : "",
536
+ children: element.content
537
+ },
538
+ `${idSchema.$id}-${element.name}-${index}`
539
+ )
540
+ ),
541
+ canExpand(schema, uiSchema, formData) && /* @__PURE__ */ jsx15("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx15(
542
+ AddButton2,
543
+ {
544
+ id: buttonId3(idSchema, "add"),
545
+ className: "rjsf-object-property-expand btn btn-primary btn-sm",
546
+ onClick: onAddClick(schema),
547
+ disabled: disabled || readonly,
548
+ uiSchema,
549
+ registry
550
+ }
551
+ ) })
552
+ ] })
553
+ ] });
554
+ }
555
+
556
+ // src/templates/TitleField/TitleField.tsx
557
+ import { getUiOptions as getUiOptions4 } from "@rjsf/utils";
558
+ import { jsx as jsx16, jsxs as jsxs7 } from "react/jsx-runtime";
559
+ function TitleField(props) {
560
+ const { id, title, uiSchema } = props;
561
+ const uiOptions = getUiOptions4(uiSchema);
562
+ return /* @__PURE__ */ jsxs7("div", { id, className: "title-field mb-6", children: [
563
+ /* @__PURE__ */ jsx16("h2", { className: "text-3xl font-bold text-primary mb-2", children: uiOptions.title || title }),
564
+ /* @__PURE__ */ jsx16("div", { className: "divider divider-primary" })
565
+ ] });
566
+ }
567
+
568
+ // src/templates/WrapIfAdditionalTemplate/WrapIfAdditionalTemplate.tsx
569
+ import { useCallback as useCallback3 } from "react";
570
+ import {
571
+ TranslatableString as TranslatableString4,
572
+ buttonId as buttonId4
573
+ } from "@rjsf/utils";
574
+ import { jsx as jsx17, jsxs as jsxs8 } from "react/jsx-runtime";
575
+ function WrapIfAdditionalTemplate(props) {
576
+ const {
577
+ children,
578
+ classNames,
579
+ disabled,
580
+ id,
581
+ label,
582
+ readonly,
583
+ required,
584
+ schema,
585
+ onKeyChange,
586
+ onDropPropertyClick,
587
+ registry,
588
+ ...rest
589
+ } = props;
590
+ const { translateString } = registry;
591
+ const handleBlur = useCallback3(
592
+ (event) => {
593
+ onKeyChange(event.target.value);
594
+ },
595
+ [onKeyChange]
596
+ );
597
+ const handleRemove = useCallback3(() => {
598
+ onDropPropertyClick(label)();
599
+ }, [onDropPropertyClick, label]);
600
+ return /* @__PURE__ */ jsxs8("div", { className: `wrap-if-additional-template ${classNames}`, ...rest, children: [
601
+ /* @__PURE__ */ jsxs8("div", { className: "flex items-center", children: [
602
+ /* @__PURE__ */ jsx17(
603
+ "input",
604
+ {
605
+ type: "text",
606
+ className: "input input-bordered",
607
+ id: `${id}-key`,
608
+ onBlur: handleBlur,
609
+ defaultValue: label,
610
+ disabled: disabled || readonly
611
+ }
612
+ ),
613
+ schema.additionalProperties && /* @__PURE__ */ jsx17(
614
+ "button",
615
+ {
616
+ id: buttonId4(id, "remove"),
617
+ className: "rjsf-array-item-remove btn btn-danger ml-2",
618
+ onClick: handleRemove,
619
+ disabled: disabled || readonly,
620
+ children: translateString(TranslatableString4.RemoveButton)
621
+ }
622
+ )
623
+ ] }),
624
+ children
625
+ ] });
626
+ }
627
+
628
+ // src/templates/Templates.tsx
629
+ function generateTemplates() {
630
+ return {
631
+ ArrayFieldItemTemplate,
632
+ ArrayFieldTemplate,
633
+ ArrayFieldItemButtonsTemplate,
634
+ BaseInputTemplate,
635
+ ButtonTemplates: {
636
+ AddButton,
637
+ SubmitButton,
638
+ CopyButton,
639
+ MoveDownButton,
640
+ MoveUpButton,
641
+ RemoveButton
642
+ },
643
+ DescriptionFieldTemplate: DescriptionField,
644
+ ErrorListTemplate: ErrorList,
645
+ FieldErrorTemplate,
646
+ FieldHelpTemplate,
647
+ FieldTemplate,
648
+ GridTemplate,
649
+ ObjectFieldTemplate,
650
+ TitleFieldTemplate: TitleField,
651
+ WrapIfAdditionalTemplate
652
+ };
653
+ }
654
+ var Templates_default = generateTemplates();
655
+
656
+ // src/widgets/AltDateTimeWidget/AltDateTimeWidget.tsx
657
+ import { jsx as jsx18 } from "react/jsx-runtime";
658
+ function AltDateTimeWidget({
659
+ time = true,
660
+ ...props
661
+ }) {
662
+ const { AltDateWidget: AltDateWidget2 } = props.registry.widgets;
663
+ return /* @__PURE__ */ jsx18(AltDateWidget2, { time, ...props });
664
+ }
665
+ var AltDateTimeWidget_default = AltDateTimeWidget;
666
+
667
+ // src/widgets/AltDateWidget/AltDateWidget.tsx
668
+ import { useCallback as useCallback4, useEffect, useReducer, useState } from "react";
669
+ import {
670
+ ariaDescribedByIds as ariaDescribedByIds2,
671
+ TranslatableString as TranslatableString5,
672
+ parseDateString,
673
+ toDateString,
674
+ dateRangeOptions
675
+ } from "@rjsf/utils";
676
+ import { jsx as jsx19, jsxs as jsxs9 } from "react/jsx-runtime";
677
+ function readyForChange(state, time = false) {
678
+ return state.year && state.month && state.day && (!time || state.hour && state.minute && state.second);
679
+ }
680
+ function getDateElementProps(state, time, yearsRange, format3 = "YMD") {
681
+ const rangeOptions = yearsRange ?? [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2];
682
+ const formats = {
683
+ YMD: ["year", "month", "day"],
684
+ MDY: ["month", "day", "year"],
685
+ DMY: ["day", "month", "year"]
686
+ };
687
+ const dateElements = formats[format3].map((key) => ({
688
+ type: key,
689
+ value: state[key],
690
+ range: key === "year" ? rangeOptions : key === "month" ? [1, 12] : key === "day" ? [1, 31] : [0, 59]
691
+ }));
692
+ if (time) {
693
+ dateElements.push(
694
+ { type: "hour", value: state.hour, range: [0, 23] },
695
+ { type: "minute", value: state.minute, range: [0, 59] },
696
+ { type: "second", value: state.second, range: [0, 59] }
697
+ );
698
+ }
699
+ return dateElements;
700
+ }
701
+ function DateElement({
702
+ type,
703
+ range,
704
+ value,
705
+ select,
706
+ rootId,
707
+ name,
708
+ disabled,
709
+ readonly,
710
+ autofocus,
711
+ registry,
712
+ onBlur,
713
+ onFocus
714
+ }) {
715
+ const id = `${rootId}_${type}`;
716
+ const { SelectWidget: SelectWidget2 } = registry.widgets;
717
+ const handleChange = useCallback4(
718
+ (value2) => {
719
+ select(type, value2);
720
+ },
721
+ [select, type]
722
+ );
723
+ return /* @__PURE__ */ jsx19(
724
+ SelectWidget2,
725
+ {
726
+ schema: { type: "integer" },
727
+ id,
728
+ name,
729
+ className: "select select-bordered select-sm w-full",
730
+ options: { enumOptions: dateRangeOptions(range[0], range[1]) },
731
+ placeholder: type,
732
+ value,
733
+ disabled,
734
+ readonly,
735
+ autofocus,
736
+ onChange: handleChange,
737
+ onBlur,
738
+ onFocus,
739
+ registry,
740
+ label: "",
741
+ "aria-describedby": ariaDescribedByIds2(rootId),
742
+ required: false
743
+ }
744
+ );
745
+ }
746
+ function convertToRJSFDateObject(dateObj) {
747
+ return {
748
+ year: dateObj.year ? parseInt(dateObj.year) : 0,
749
+ month: dateObj.month ? parseInt(dateObj.month) : 0,
750
+ day: dateObj.day ? parseInt(dateObj.day) : 0,
751
+ hour: dateObj.hour ? parseInt(dateObj.hour) : 0,
752
+ minute: dateObj.minute ? parseInt(dateObj.minute) : 0,
753
+ second: dateObj.second ? parseInt(dateObj.second) : 0
754
+ };
755
+ }
756
+ function AltDateWidget({
757
+ time = false,
758
+ disabled = false,
759
+ readonly = false,
760
+ autofocus = false,
761
+ options = {},
762
+ id,
763
+ name,
764
+ registry,
765
+ onBlur,
766
+ onFocus,
767
+ onChange,
768
+ value
769
+ }) {
770
+ const { translateString } = registry;
771
+ const [lastValue, setLastValue] = useState(value);
772
+ const initialState = parseDateString(value, time);
773
+ const dateReducer = (state2, action) => {
774
+ return { ...state2, ...action };
775
+ };
776
+ const [state, setState] = useReducer(dateReducer, initialState);
777
+ useEffect(() => {
778
+ const rjsfDateObj = convertToRJSFDateObject(state);
779
+ const stateValue = toDateString(rjsfDateObj, time);
780
+ if (readyForChange(state, time) && stateValue !== value) {
781
+ onChange(stateValue);
782
+ } else if (lastValue !== value) {
783
+ setLastValue(value);
784
+ setState(parseDateString(value, time));
785
+ }
786
+ }, [time, value, onChange, state, lastValue]);
787
+ const handleChange = useCallback4((property, value2) => {
788
+ setState({ [property]: value2 });
789
+ }, []);
790
+ const handleSetNow = useCallback4(
791
+ (event) => {
792
+ event.preventDefault();
793
+ if (disabled || readonly) {
794
+ return;
795
+ }
796
+ const nextState = parseDateString((/* @__PURE__ */ new Date()).toJSON(), time);
797
+ const rjsfDateObj = convertToRJSFDateObject(nextState);
798
+ onChange(toDateString(rjsfDateObj, time));
799
+ },
800
+ [disabled, readonly, time, onChange]
801
+ );
802
+ const handleClear = useCallback4(
803
+ (event) => {
804
+ event.preventDefault();
805
+ if (disabled || readonly) {
806
+ return;
807
+ }
808
+ onChange(void 0);
809
+ },
810
+ [disabled, readonly, onChange]
811
+ );
812
+ return /* @__PURE__ */ jsxs9("div", { className: "space-y-3", children: [
813
+ /* @__PURE__ */ jsx19("div", { className: "grid grid-cols-3 gap-2", children: getDateElementProps(
814
+ state,
815
+ time,
816
+ options.yearsRange,
817
+ options.format
818
+ ).map((elemProps, i) => /* @__PURE__ */ jsxs9("div", { className: "form-control", children: [
819
+ /* @__PURE__ */ jsx19("label", { className: "label", children: /* @__PURE__ */ jsx19("span", { className: "label-text capitalize", children: elemProps.type }) }),
820
+ /* @__PURE__ */ jsx19(
821
+ DateElement,
822
+ {
823
+ rootId: id,
824
+ name,
825
+ select: handleChange,
826
+ type: elemProps.type,
827
+ range: elemProps.range,
828
+ value: elemProps.value,
829
+ disabled,
830
+ readonly,
831
+ registry,
832
+ onBlur,
833
+ onFocus,
834
+ autofocus: autofocus && i === 0
835
+ }
836
+ )
837
+ ] }, i)) }),
838
+ /* @__PURE__ */ jsxs9("div", { className: "flex justify-start space-x-2", children: [
839
+ (options.hideNowButton !== void 0 ? !options.hideNowButton : true) && /* @__PURE__ */ jsx19(
840
+ "button",
841
+ {
842
+ type: "button",
843
+ className: "btn btn-sm btn-primary",
844
+ onClick: handleSetNow,
845
+ disabled: disabled || readonly,
846
+ children: translateString(TranslatableString5.NowLabel)
847
+ }
848
+ ),
849
+ (options.hideClearButton !== void 0 ? !options.hideClearButton : true) && /* @__PURE__ */ jsx19(
850
+ "button",
851
+ {
852
+ type: "button",
853
+ className: "btn btn-sm btn-secondary",
854
+ onClick: handleClear,
855
+ disabled: disabled || readonly,
856
+ children: translateString(TranslatableString5.ClearLabel)
857
+ }
858
+ )
859
+ ] })
860
+ ] });
861
+ }
862
+
863
+ // src/widgets/CheckboxWidget/CheckboxWidget.tsx
864
+ import { useCallback as useCallback5 } from "react";
865
+ import { getTemplate as getTemplate4, descriptionId as descriptionId2 } from "@rjsf/utils";
866
+ import { jsx as jsx20, jsxs as jsxs10 } from "react/jsx-runtime";
867
+ function CheckboxWidget(props) {
868
+ const {
869
+ id,
870
+ value,
871
+ required,
872
+ disabled,
873
+ hideLabel,
874
+ label,
875
+ readonly,
876
+ registry,
877
+ options,
878
+ schema,
879
+ uiSchema,
880
+ onChange,
881
+ onFocus,
882
+ onBlur
883
+ } = props;
884
+ const DescriptionFieldTemplate = getTemplate4(
885
+ "DescriptionFieldTemplate",
886
+ registry,
887
+ options
888
+ );
889
+ const description = options.description || schema.description;
890
+ const handleFocus = useCallback5(() => {
891
+ if (onFocus) {
892
+ onFocus(id, value);
893
+ }
894
+ }, [onFocus, id, value]);
895
+ const handleBlur = useCallback5(() => {
896
+ if (onBlur) {
897
+ onBlur(id, value);
898
+ }
899
+ }, [onBlur, id, value]);
900
+ const handleChange = useCallback5(
901
+ (event) => {
902
+ onChange(event.target.checked);
903
+ },
904
+ [onChange]
905
+ );
906
+ const input = /* @__PURE__ */ jsx20(
907
+ "input",
908
+ {
909
+ type: "checkbox",
910
+ id,
911
+ checked: value,
912
+ required,
913
+ disabled: disabled || readonly,
914
+ onChange: handleChange,
915
+ onFocus: handleFocus,
916
+ onBlur: handleBlur,
917
+ className: "checkbox"
918
+ }
919
+ );
920
+ return /* @__PURE__ */ jsxs10("div", { className: "form-control", children: [
921
+ !hideLabel && description && /* @__PURE__ */ jsx20(
922
+ DescriptionFieldTemplate,
923
+ {
924
+ id: descriptionId2(id),
925
+ description,
926
+ schema,
927
+ uiSchema,
928
+ registry
929
+ }
930
+ ),
931
+ hideLabel || !label ? input : /* @__PURE__ */ jsxs10("label", { className: "label cursor-pointer justify-start", children: [
932
+ /* @__PURE__ */ jsx20("div", { className: "mr-2", children: input }),
933
+ /* @__PURE__ */ jsxs10("span", { className: "label-text", children: [
934
+ label,
935
+ required && /* @__PURE__ */ jsx20("span", { className: "text-error ml-1", children: "*" })
936
+ ] })
937
+ ] })
938
+ ] });
939
+ }
940
+
941
+ // src/widgets/CheckboxesWidget/CheckboxesWidget.tsx
942
+ import { useCallback as useCallback6 } from "react";
943
+ import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
944
+ function CheckboxesWidget({
945
+ id,
946
+ disabled,
947
+ options,
948
+ value,
949
+ readonly,
950
+ required,
951
+ onChange,
952
+ onFocus,
953
+ onBlur
954
+ }) {
955
+ const { enumOptions } = options;
956
+ const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
957
+ const isChecked = useCallback6(
958
+ (option) => {
959
+ if (!Array.isArray(value)) {
960
+ return false;
961
+ }
962
+ if (isEnumeratedObject) {
963
+ return value.some((v) => v.name === option.value.name);
964
+ }
965
+ return value.includes(option.value);
966
+ },
967
+ [value, isEnumeratedObject]
968
+ );
969
+ const handleChange = useCallback6(
970
+ (event) => {
971
+ const index = Number(event.target.dataset.index);
972
+ const option = enumOptions?.[index];
973
+ if (!option) {
974
+ return;
975
+ }
976
+ const newValue = Array.isArray(value) ? [...value] : [];
977
+ const optionValue = isEnumeratedObject ? option.value : option.value;
978
+ if (isChecked(option)) {
979
+ onChange(newValue.filter((v) => isEnumeratedObject ? v.name !== optionValue.name : v !== optionValue));
980
+ } else {
981
+ onChange([...newValue, optionValue]);
982
+ }
983
+ },
984
+ [onChange, value, isChecked, isEnumeratedObject, enumOptions]
985
+ );
986
+ const handleFocus = useCallback6(
987
+ (event) => {
988
+ if (onFocus) {
989
+ const index = Number(event.target.dataset.index);
990
+ const option = enumOptions?.[index];
991
+ if (option) {
992
+ onFocus(id, option.value);
993
+ }
994
+ }
995
+ },
996
+ [onFocus, id, enumOptions]
997
+ );
998
+ const handleBlur = useCallback6(
999
+ (event) => {
1000
+ if (onBlur) {
1001
+ const index = Number(event.target.dataset.index);
1002
+ const option = enumOptions?.[index];
1003
+ if (option) {
1004
+ onBlur(id, option.value);
1005
+ }
1006
+ }
1007
+ },
1008
+ [onBlur, id, enumOptions]
1009
+ );
1010
+ return /* @__PURE__ */ jsx21("div", { className: "form-control", children: /* @__PURE__ */ jsx21("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxs11("label", { className: "flex items-center cursor-pointer gap-2", children: [
1011
+ /* @__PURE__ */ jsx21(
1012
+ "input",
1013
+ {
1014
+ type: "checkbox",
1015
+ id: `${id}-${option.value}`,
1016
+ className: "checkbox",
1017
+ name: id,
1018
+ checked: isChecked(option),
1019
+ required,
1020
+ disabled: disabled || readonly,
1021
+ "data-index": index,
1022
+ onChange: handleChange,
1023
+ onFocus: handleFocus,
1024
+ onBlur: handleBlur
1025
+ }
1026
+ ),
1027
+ /* @__PURE__ */ jsx21("span", { className: "label-text", children: option.label })
1028
+ ] }, option.value)) }) });
1029
+ }
1030
+
1031
+ // src/widgets/DateTimeWidget/DateTimeWidget.tsx
1032
+ import { memo as memo2, useCallback as useCallback7, useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
1033
+ import { faCalendar } from "@fortawesome/free-solid-svg-icons";
1034
+ import { FontAwesomeIcon as FontAwesomeIcon2 } from "@fortawesome/react-fontawesome";
1035
+ import { format, isSameDay, isToday, isValid } from "date-fns";
1036
+ import { DayPicker, UI } from "react-day-picker";
1037
+ import "react-day-picker/dist/style.css";
1038
+ import { jsx as jsx22, jsxs as jsxs12 } from "react/jsx-runtime";
1039
+ function useDatePickerState(initialDate) {
1040
+ const [isOpen, setIsOpen] = useState2(false);
1041
+ const [month, setMonth] = useState2(initialDate ?? /* @__PURE__ */ new Date());
1042
+ return { isOpen, setIsOpen, month, setMonth };
1043
+ }
1044
+ function useClickOutside(ref, callback) {
1045
+ useEffect2(() => {
1046
+ const handleClickOutside = (event) => {
1047
+ if (ref.current && !ref.current.contains(event.target)) {
1048
+ callback();
1049
+ }
1050
+ };
1051
+ document.addEventListener("mousedown", handleClickOutside);
1052
+ return () => document.removeEventListener("mousedown", handleClickOutside);
1053
+ }, [ref, callback]);
1054
+ }
1055
+ var dayPickerStyles = {
1056
+ classNames: {
1057
+ [UI.Root]: "relative",
1058
+ [UI.Nav]: "hidden",
1059
+ [UI.Chevron]: "hidden",
1060
+ [UI.CaptionLabel]: "hidden",
1061
+ [UI.Dropdowns]: "flex justify-between gap-4 px-4 pb-4",
1062
+ [UI.Dropdown]: "select select-bordered select-sm w-32",
1063
+ [UI.MonthsDropdown]: "select select-bordered select-sm",
1064
+ [UI.YearsDropdown]: "select select-bordered select-sm",
1065
+ [UI.Months]: "flex justify-center",
1066
+ [UI.Month]: "w-full",
1067
+ [UI.MonthCaption]: "flex justify-center",
1068
+ [UI.MonthGrid]: "w-full",
1069
+ [UI.Weekdays]: "grid grid-cols-7 text-center border-b mb-2 pb-1 text-base-content/60 uppercase",
1070
+ [UI.Weekday]: "p-1 font-medium text-base-content/60 text-sm",
1071
+ [UI.Week]: "grid grid-cols-7",
1072
+ [UI.Day]: "w-10 h-8 p-0 relative rounded-md",
1073
+ [UI.DayButton]: "btn btn-ghost absolute inset-0 flex items-center justify-center w-full h-full cursor-pointer rounded-md hover:btn-primary"
1074
+ },
1075
+ modifiers: {
1076
+ selected: "btn btn-accent min-h-0 h-full",
1077
+ outside: "text-base-content/30 hover:btn-ghost",
1078
+ disabled: "opacity-50 cursor-not-allowed hover:btn-disabled"
1079
+ }
1080
+ };
1081
+ function DateTimePickerPopup({ selectedDate, month, onMonthChange, onSelect, onTimeChange }) {
1082
+ const customDayModifiers = {
1083
+ selected: selectedDate,
1084
+ "custom-today": (date) => isToday(date) && !(selectedDate && isSameDay(date, selectedDate))
1085
+ };
1086
+ const customModifiersClassNames = {
1087
+ ...dayPickerStyles.modifiers,
1088
+ "custom-today": "btn btn-outline btn-info min-h-0 h-full"
1089
+ };
1090
+ const handleClick = useCallback7((e) => {
1091
+ e.stopPropagation();
1092
+ }, []);
1093
+ return /* @__PURE__ */ jsxs12("div", { className: "p-3", children: [
1094
+ /* @__PURE__ */ jsx22(
1095
+ DayPicker,
1096
+ {
1097
+ mode: "single",
1098
+ selected: selectedDate,
1099
+ month,
1100
+ onMonthChange,
1101
+ onSelect,
1102
+ captionLayout: "dropdown",
1103
+ fromYear: 1900,
1104
+ toYear: (/* @__PURE__ */ new Date()).getFullYear() + 10,
1105
+ showOutsideDays: true,
1106
+ classNames: dayPickerStyles.classNames,
1107
+ modifiers: customDayModifiers,
1108
+ modifiersClassNames: customModifiersClassNames
1109
+ }
1110
+ ),
1111
+ /* @__PURE__ */ jsx22("div", { className: "mt-3 border-t border-base-300 pt-3", children: /* @__PURE__ */ jsxs12("div", { className: "form-control w-full", children: [
1112
+ /* @__PURE__ */ jsx22("label", { className: "label", children: /* @__PURE__ */ jsx22("span", { className: "label-text", children: "Time" }) }),
1113
+ /* @__PURE__ */ jsx22(
1114
+ "input",
1115
+ {
1116
+ type: "time",
1117
+ className: "input input-bordered w-full",
1118
+ value: selectedDate ? format(selectedDate, "HH:mm") : "",
1119
+ onChange: onTimeChange,
1120
+ onClick: handleClick
1121
+ }
1122
+ )
1123
+ ] }) })
1124
+ ] });
1125
+ }
1126
+ var MemoizedDateTimePickerPopup = memo2(DateTimePickerPopup);
1127
+ function DateTimeWidget(props) {
1128
+ const { id, value, onChange, onFocus, onBlur, schema } = props;
1129
+ const initialDate = useMemo2(() => value ? new Date(value) : void 0, [value]);
1130
+ const [localDate, setLocalDate] = useState2(initialDate);
1131
+ useEffect2(() => {
1132
+ setLocalDate(initialDate);
1133
+ }, [initialDate]);
1134
+ const { isOpen, setIsOpen, month, setMonth } = useDatePickerState(initialDate);
1135
+ const containerRef = useRef(null);
1136
+ const inputRef = useRef(null);
1137
+ useClickOutside(containerRef, () => {
1138
+ if (isOpen) {
1139
+ setIsOpen(false);
1140
+ onChange(localDate ? localDate.toISOString() : "");
1141
+ if (onBlur) {
1142
+ onBlur(id, value);
1143
+ }
1144
+ }
1145
+ });
1146
+ useEffect2(() => {
1147
+ if (localDate) {
1148
+ setMonth(localDate);
1149
+ }
1150
+ }, [localDate, setMonth]);
1151
+ const handleMonthChange = useCallback7((date) => setMonth(date), [setMonth]);
1152
+ const handleSelect = useCallback7(
1153
+ (date) => {
1154
+ if (date) {
1155
+ if (localDate) {
1156
+ date.setHours(localDate.getHours(), localDate.getMinutes());
1157
+ }
1158
+ setLocalDate(date);
1159
+ }
1160
+ },
1161
+ [localDate]
1162
+ );
1163
+ const handleTimeChange = useCallback7(
1164
+ (e) => {
1165
+ if (localDate) {
1166
+ const [hours, minutes] = e.target.value.split(":");
1167
+ const newDate = new Date(localDate);
1168
+ newDate.setHours(parseInt(hours, 10), parseInt(minutes, 10));
1169
+ setLocalDate(newDate);
1170
+ }
1171
+ },
1172
+ [localDate]
1173
+ );
1174
+ const togglePicker = useCallback7(
1175
+ (e) => {
1176
+ e.stopPropagation();
1177
+ setIsOpen((prev) => !prev);
1178
+ if (!isOpen && onFocus) {
1179
+ onFocus(id, value);
1180
+ }
1181
+ },
1182
+ [isOpen, id, onFocus, setIsOpen, value]
1183
+ );
1184
+ const handleFocus = useCallback7(() => {
1185
+ if (onFocus) {
1186
+ onFocus(id, value);
1187
+ }
1188
+ }, [id, onFocus, value]);
1189
+ const handleBlur = useCallback7(() => {
1190
+ if (!isOpen && onBlur) {
1191
+ onBlur(id, value);
1192
+ }
1193
+ }, [id, onBlur, value, isOpen]);
1194
+ const handleKeyDown = useCallback7(
1195
+ (e) => {
1196
+ if (e.key === "Enter" || e.key === " ") {
1197
+ togglePicker(e);
1198
+ }
1199
+ },
1200
+ [togglePicker]
1201
+ );
1202
+ const handleContainerClick = useCallback7((e) => {
1203
+ e.stopPropagation();
1204
+ }, []);
1205
+ useEffect2(() => {
1206
+ const handleEscape = (e) => {
1207
+ if (e.key === "Escape" && isOpen) {
1208
+ setIsOpen(false);
1209
+ if (onBlur) {
1210
+ onBlur(id, value);
1211
+ }
1212
+ }
1213
+ };
1214
+ document.addEventListener("keydown", handleEscape);
1215
+ return () => document.removeEventListener("keydown", handleEscape);
1216
+ }, [id, isOpen, onBlur, value]);
1217
+ const handleDoneClick = useCallback7(() => {
1218
+ setIsOpen(false);
1219
+ onChange(localDate ? localDate.toISOString() : "");
1220
+ if (onBlur) {
1221
+ onBlur(id, value);
1222
+ }
1223
+ inputRef.current?.focus();
1224
+ }, [localDate, onChange, onBlur, id, value]);
1225
+ return /* @__PURE__ */ jsx22("div", { className: "form-control my-4 w-full relative", children: /* @__PURE__ */ jsxs12(
1226
+ "div",
1227
+ {
1228
+ className: "w-full",
1229
+ tabIndex: 0,
1230
+ onKeyDown: handleKeyDown,
1231
+ onFocus: handleFocus,
1232
+ onBlur: handleBlur,
1233
+ ref: inputRef,
1234
+ children: [
1235
+ /* @__PURE__ */ jsxs12(
1236
+ "div",
1237
+ {
1238
+ id,
1239
+ className: `input input-bordered w-full flex items-center justify-between cursor-pointer ${isOpen ? "ring-2 ring-primary/50" : ""}`,
1240
+ onClick: togglePicker,
1241
+ role: "button",
1242
+ "aria-haspopup": "true",
1243
+ "aria-expanded": isOpen,
1244
+ tabIndex: -1,
1245
+ children: [
1246
+ /* @__PURE__ */ jsx22("span", { className: localDate && isValid(localDate) ? "" : "text-base-content/50", children: localDate && isValid(localDate) ? format(localDate, "PP p") : schema.title }),
1247
+ /* @__PURE__ */ jsx22(FontAwesomeIcon2, { icon: faCalendar, className: "ml-2 h-4 w-4 text-primary" })
1248
+ ]
1249
+ }
1250
+ ),
1251
+ isOpen && /* @__PURE__ */ jsxs12(
1252
+ "div",
1253
+ {
1254
+ ref: containerRef,
1255
+ className: "absolute z-[100] mt-2 w-full max-w-xs bg-base-100 border border-base-300 shadow-lg rounded-box",
1256
+ onClick: handleContainerClick,
1257
+ children: [
1258
+ /* @__PURE__ */ jsx22(
1259
+ MemoizedDateTimePickerPopup,
1260
+ {
1261
+ selectedDate: localDate,
1262
+ month,
1263
+ onMonthChange: handleMonthChange,
1264
+ onSelect: handleSelect,
1265
+ onTimeChange: handleTimeChange
1266
+ }
1267
+ ),
1268
+ /* @__PURE__ */ jsx22("div", { className: "p-3 flex justify-end border-t border-base-300", children: /* @__PURE__ */ jsx22("button", { type: "button", className: "btn btn-sm btn-primary", onClick: handleDoneClick, children: "Done" }) })
1269
+ ]
1270
+ }
1271
+ )
1272
+ ]
1273
+ }
1274
+ ) });
1275
+ }
1276
+
1277
+ // src/widgets/DateWidget/DateWidget.tsx
1278
+ import { memo as memo3, useCallback as useCallback8, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
1279
+ import { faCalendar as faCalendar2 } from "@fortawesome/free-solid-svg-icons";
1280
+ import { FontAwesomeIcon as FontAwesomeIcon3 } from "@fortawesome/react-fontawesome";
1281
+ import { format as format2, isSameDay as isSameDay2, isToday as isToday2, isValid as isValid2 } from "date-fns";
1282
+ import { DayPicker as DayPicker2, UI as UI2 } from "react-day-picker";
1283
+ import "react-day-picker/dist/style.css";
1284
+ import { jsx as jsx23, jsxs as jsxs13 } from "react/jsx-runtime";
1285
+ function useDatePickerState2(initialDate) {
1286
+ const [isOpen, setIsOpen] = useState3(false);
1287
+ const [month, setMonth] = useState3(initialDate ?? /* @__PURE__ */ new Date());
1288
+ return { isOpen, setIsOpen, month, setMonth };
1289
+ }
1290
+ function useClickOutside2(ref, callback) {
1291
+ useEffect3(() => {
1292
+ const handleClickOutside = (event) => {
1293
+ if (ref.current && !ref.current.contains(event.target)) {
1294
+ callback();
1295
+ }
1296
+ };
1297
+ document.addEventListener("mousedown", handleClickOutside);
1298
+ return () => document.removeEventListener("mousedown", handleClickOutside);
1299
+ }, [ref, callback]);
1300
+ }
1301
+ var dayPickerStyles2 = {
1302
+ classNames: {
1303
+ [UI2.Root]: "relative",
1304
+ [UI2.Nav]: "hidden",
1305
+ [UI2.Chevron]: "hidden",
1306
+ [UI2.CaptionLabel]: "hidden",
1307
+ [UI2.Dropdowns]: "flex justify-between gap-4 px-4 pb-4",
1308
+ [UI2.Dropdown]: "select select-bordered select-sm w-32",
1309
+ [UI2.MonthsDropdown]: "select select-bordered select-sm",
1310
+ [UI2.YearsDropdown]: "select select-bordered select-sm",
1311
+ [UI2.Months]: "flex justify-center",
1312
+ [UI2.Month]: "w-full",
1313
+ [UI2.MonthCaption]: "flex justify-center",
1314
+ [UI2.MonthGrid]: "w-full",
1315
+ [UI2.Weekdays]: "grid grid-cols-7 text-center border-b mb-2 pb-1 text-base-content/60 uppercase",
1316
+ [UI2.Weekday]: "p-1 font-medium text-base-content/60 text-sm",
1317
+ [UI2.Week]: "grid grid-cols-7",
1318
+ [UI2.Day]: "w-10 h-8 p-0 relative rounded-md",
1319
+ [UI2.DayButton]: "btn btn-ghost absolute inset-0 flex items-center justify-center w-full h-full cursor-pointer rounded-md hover:btn-primary"
1320
+ },
1321
+ modifiers: {
1322
+ selected: "btn btn-accent min-h-0 h-full",
1323
+ outside: "text-base-content/30 hover:btn-ghost",
1324
+ disabled: "opacity-50 cursor-not-allowed hover:btn-disabled"
1325
+ }
1326
+ };
1327
+ function DatePickerPopup({ selectedDate, month, onMonthChange, onSelect }) {
1328
+ const customDayModifiers = {
1329
+ selected: selectedDate,
1330
+ "custom-today": (date) => isToday2(date) && !(selectedDate && isSameDay2(date, selectedDate))
1331
+ };
1332
+ const customModifiersClassNames = {
1333
+ ...dayPickerStyles2.modifiers,
1334
+ "custom-today": "btn btn-outline btn-info min-h-0 h-full"
1335
+ };
1336
+ return /* @__PURE__ */ jsx23("div", { className: "p-3", style: { minWidth: "320px", minHeight: "350px" }, children: /* @__PURE__ */ jsx23(
1337
+ DayPicker2,
1338
+ {
1339
+ mode: "single",
1340
+ selected: selectedDate,
1341
+ month,
1342
+ onMonthChange,
1343
+ onSelect,
1344
+ captionLayout: "dropdown",
1345
+ fromYear: 1900,
1346
+ toYear: (/* @__PURE__ */ new Date()).getFullYear() + 10,
1347
+ showOutsideDays: true,
1348
+ classNames: dayPickerStyles2.classNames,
1349
+ modifiers: customDayModifiers,
1350
+ modifiersClassNames: customModifiersClassNames
1351
+ }
1352
+ ) });
1353
+ }
1354
+ var MemoizedDatePickerPopup = memo3(DatePickerPopup);
1355
+ function DateWidget(props) {
1356
+ const { id, value, onChange, onFocus, onBlur, schema } = props;
1357
+ const initialDate = useMemo3(() => value ? new Date(value) : void 0, [value]);
1358
+ const [localDate, setLocalDate] = useState3(initialDate);
1359
+ useEffect3(() => {
1360
+ setLocalDate(initialDate);
1361
+ }, [initialDate]);
1362
+ const { isOpen, setIsOpen, month, setMonth } = useDatePickerState2(initialDate);
1363
+ const containerRef = useRef2(null);
1364
+ const inputRef = useRef2(null);
1365
+ useClickOutside2(containerRef, () => {
1366
+ if (isOpen) {
1367
+ setIsOpen(false);
1368
+ onChange(localDate ? localDate.toISOString() : "");
1369
+ if (onBlur) {
1370
+ onBlur(id, value);
1371
+ }
1372
+ }
1373
+ });
1374
+ useEffect3(() => {
1375
+ if (localDate) {
1376
+ setMonth(localDate);
1377
+ }
1378
+ }, [localDate, setMonth]);
1379
+ const handleMonthChange = useCallback8((date) => setMonth(date), [setMonth]);
1380
+ const handleSelect = useCallback8((date) => {
1381
+ if (date) {
1382
+ date.setHours(0, 0, 0, 0);
1383
+ setLocalDate(date);
1384
+ }
1385
+ }, []);
1386
+ useEffect3(() => {
1387
+ let portalContainer = document.getElementById("date-picker-portal");
1388
+ if (!portalContainer) {
1389
+ portalContainer = document.createElement("div");
1390
+ portalContainer.id = "date-picker-portal";
1391
+ document.body.appendChild(portalContainer);
1392
+ }
1393
+ return () => {
1394
+ const container = document.getElementById("date-picker-portal");
1395
+ if (container && document.querySelectorAll(".date-picker-popup").length === 0) {
1396
+ container.remove();
1397
+ }
1398
+ };
1399
+ }, []);
1400
+ const getDocumentAndWindow = () => {
1401
+ let doc = document;
1402
+ let win = window;
1403
+ try {
1404
+ if (window.frameElement) {
1405
+ const iframe = window.frameElement;
1406
+ if (iframe.contentDocument) {
1407
+ doc = iframe.contentDocument;
1408
+ }
1409
+ if (iframe.contentWindow) {
1410
+ win = iframe.contentWindow;
1411
+ }
1412
+ }
1413
+ } catch (e) {
1414
+ console.log("Unable to access parent frame:", e);
1415
+ }
1416
+ return { doc, win };
1417
+ };
1418
+ const renderCalendar = useCallback8(() => {
1419
+ if (!containerRef.current || !inputRef.current) {
1420
+ return;
1421
+ }
1422
+ const { win } = getDocumentAndWindow();
1423
+ const inputRect = inputRef.current.getBoundingClientRect();
1424
+ const containerWidth = 320;
1425
+ containerRef.current.style.position = "fixed";
1426
+ containerRef.current.style.top = `${inputRect.bottom + 5}px`;
1427
+ const rightEdge = inputRect.left + containerWidth;
1428
+ const windowWidth = win.innerWidth;
1429
+ if (rightEdge > windowWidth - 20) {
1430
+ containerRef.current.style.left = `${Math.max(20, windowWidth - 20 - containerWidth)}px`;
1431
+ } else {
1432
+ containerRef.current.style.left = `${inputRect.left}px`;
1433
+ }
1434
+ containerRef.current.style.zIndex = "99999";
1435
+ }, [containerRef, inputRef]);
1436
+ useEffect3(() => {
1437
+ if (!isOpen) {
1438
+ return;
1439
+ }
1440
+ renderCalendar();
1441
+ window.addEventListener("resize", renderCalendar);
1442
+ window.addEventListener("scroll", renderCalendar);
1443
+ return () => {
1444
+ window.removeEventListener("resize", renderCalendar);
1445
+ window.removeEventListener("scroll", renderCalendar);
1446
+ };
1447
+ }, [isOpen, renderCalendar]);
1448
+ const togglePicker = useCallback8(
1449
+ (e) => {
1450
+ e.stopPropagation();
1451
+ setIsOpen((prev) => !prev);
1452
+ if (!isOpen && onFocus) {
1453
+ onFocus(id, value);
1454
+ }
1455
+ },
1456
+ [isOpen, id, onFocus, setIsOpen, value]
1457
+ );
1458
+ const handleFocus = useCallback8(() => {
1459
+ if (onFocus) {
1460
+ onFocus(id, value);
1461
+ }
1462
+ }, [id, onFocus, value]);
1463
+ const handleBlur = useCallback8(() => {
1464
+ if (!isOpen && onBlur) {
1465
+ onBlur(id, value);
1466
+ }
1467
+ }, [id, onBlur, value, isOpen]);
1468
+ useEffect3(() => {
1469
+ const handleEscape = (e) => {
1470
+ if (e.key === "Escape" && isOpen) {
1471
+ setIsOpen(false);
1472
+ if (onBlur) {
1473
+ onBlur(id, value);
1474
+ }
1475
+ }
1476
+ };
1477
+ document.addEventListener("keydown", handleEscape);
1478
+ return () => document.removeEventListener("keydown", handleEscape);
1479
+ }, [id, isOpen, onBlur, value]);
1480
+ const handleDoneClick = useCallback8(() => {
1481
+ setIsOpen(false);
1482
+ onChange(localDate ? localDate.toISOString() : "");
1483
+ if (onBlur) {
1484
+ onBlur(id, value);
1485
+ }
1486
+ inputRef.current?.focus();
1487
+ }, [localDate, onChange, onBlur, id, value]);
1488
+ return /* @__PURE__ */ jsx23("div", { className: "form-control my-4 w-full relative", children: /* @__PURE__ */ jsxs13(
1489
+ "div",
1490
+ {
1491
+ className: "w-full",
1492
+ tabIndex: 0,
1493
+ onKeyDown: (e) => {
1494
+ if (e.key === "Enter" || e.key === " ") {
1495
+ togglePicker(e);
1496
+ }
1497
+ },
1498
+ onFocus: handleFocus,
1499
+ onBlur: handleBlur,
1500
+ ref: inputRef,
1501
+ children: [
1502
+ /* @__PURE__ */ jsxs13(
1503
+ "div",
1504
+ {
1505
+ id,
1506
+ className: `input input-bordered w-full flex items-center justify-between cursor-pointer ${isOpen ? "ring-2 ring-primary/50" : ""}`,
1507
+ onClick: togglePicker,
1508
+ role: "button",
1509
+ "aria-haspopup": "true",
1510
+ "aria-expanded": isOpen,
1511
+ tabIndex: -1,
1512
+ children: [
1513
+ /* @__PURE__ */ jsx23("span", { className: localDate && isValid2(localDate) ? "" : "text-base-content/50", children: localDate && isValid2(localDate) ? format2(localDate, "PP") : schema.title }),
1514
+ /* @__PURE__ */ jsx23(FontAwesomeIcon3, { icon: faCalendar2, className: "ml-2 h-4 w-4 text-primary" })
1515
+ ]
1516
+ }
1517
+ ),
1518
+ isOpen && /* @__PURE__ */ jsxs13(
1519
+ "div",
1520
+ {
1521
+ ref: containerRef,
1522
+ className: "date-picker-popup fixed z-[99999] w-full max-w-xs bg-base-100 border border-base-300 shadow-lg rounded-box",
1523
+ style: {
1524
+ maxHeight: "none",
1525
+ overflow: "visible"
1526
+ },
1527
+ onClick: (e) => e.stopPropagation(),
1528
+ children: [
1529
+ /* @__PURE__ */ jsx23(
1530
+ MemoizedDatePickerPopup,
1531
+ {
1532
+ selectedDate: localDate,
1533
+ month,
1534
+ onMonthChange: handleMonthChange,
1535
+ onSelect: handleSelect
1536
+ }
1537
+ ),
1538
+ /* @__PURE__ */ jsx23("div", { className: "p-3 flex justify-end border-t border-base-300", children: /* @__PURE__ */ jsx23("button", { type: "button", className: "btn btn-sm btn-primary", onClick: handleDoneClick, children: "Done" }) })
1539
+ ]
1540
+ }
1541
+ )
1542
+ ]
1543
+ }
1544
+ ) });
1545
+ }
1546
+
1547
+ // src/widgets/FileWidget/FileWidget.tsx
1548
+ import { useCallback as useCallback9 } from "react";
1549
+ import { jsx as jsx24 } from "react/jsx-runtime";
1550
+ function FileWidget(props) {
1551
+ const { id, required, disabled, readonly, schema, onChange, onFocus, onBlur, options = {} } = props;
1552
+ const isMulti = schema.type === "array" || Boolean(options.multiple);
1553
+ const accept = typeof options.accept === "string" ? options.accept : void 0;
1554
+ const handleChange = useCallback9(
1555
+ (event) => {
1556
+ if (!event.target.files) {
1557
+ return;
1558
+ }
1559
+ const fileList = Array.from(event.target.files);
1560
+ if (isMulti) {
1561
+ onChange(fileList);
1562
+ } else {
1563
+ onChange(fileList[0] || null);
1564
+ }
1565
+ },
1566
+ [onChange, isMulti]
1567
+ );
1568
+ const handleFocus = useCallback9(
1569
+ (event) => {
1570
+ if (onFocus) {
1571
+ onFocus(id, event.target.files ? Array.from(event.target.files) : null);
1572
+ }
1573
+ },
1574
+ [onFocus, id]
1575
+ );
1576
+ const handleBlur = useCallback9(
1577
+ (event) => {
1578
+ if (onBlur) {
1579
+ onBlur(id, event.target.files ? Array.from(event.target.files) : null);
1580
+ }
1581
+ },
1582
+ [onBlur, id]
1583
+ );
1584
+ return /* @__PURE__ */ jsx24(
1585
+ "input",
1586
+ {
1587
+ id,
1588
+ type: "file",
1589
+ className: "file-input w-full",
1590
+ required,
1591
+ disabled: disabled || readonly,
1592
+ onChange: handleChange,
1593
+ onFocus: handleFocus,
1594
+ onBlur: handleBlur,
1595
+ multiple: isMulti,
1596
+ accept
1597
+ }
1598
+ );
1599
+ }
1600
+
1601
+ // src/widgets/RadioWidget/RadioWidget.tsx
1602
+ import { useCallback as useCallback10 } from "react";
1603
+ import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
1604
+ function RadioWidget({
1605
+ id,
1606
+ options,
1607
+ value,
1608
+ required,
1609
+ disabled,
1610
+ readonly,
1611
+ onChange,
1612
+ onFocus,
1613
+ onBlur
1614
+ }) {
1615
+ const { enumOptions } = options;
1616
+ const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
1617
+ const getValue = (option) => {
1618
+ return option.value;
1619
+ };
1620
+ const isChecked = (option) => {
1621
+ if (isEnumeratedObject) {
1622
+ return value && value.name === option.value.name;
1623
+ }
1624
+ return value === option.value;
1625
+ };
1626
+ const handleFocus = useCallback10(
1627
+ (event) => {
1628
+ if (onFocus) {
1629
+ const index = Number(event.target.dataset.index);
1630
+ const optionValue = enumOptions?.[index]?.value;
1631
+ onFocus(id, optionValue);
1632
+ }
1633
+ },
1634
+ [onFocus, id, enumOptions]
1635
+ );
1636
+ const handleBlur = useCallback10(
1637
+ (event) => {
1638
+ if (onBlur) {
1639
+ const index = Number(event.target.dataset.index);
1640
+ const optionValue = enumOptions?.[index]?.value;
1641
+ onBlur(id, optionValue);
1642
+ }
1643
+ },
1644
+ [onBlur, id, enumOptions]
1645
+ );
1646
+ const handleChange = useCallback10(
1647
+ (event) => {
1648
+ const index = Number(event.target.dataset.index);
1649
+ const option = enumOptions?.[index];
1650
+ if (option) {
1651
+ onChange(isEnumeratedObject ? option.value : option.value);
1652
+ event.target.blur();
1653
+ }
1654
+ },
1655
+ [onChange, isEnumeratedObject, enumOptions]
1656
+ );
1657
+ return /* @__PURE__ */ jsx25("div", { className: "form-control", children: /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-2 mt-1", children: enumOptions?.map((option, index) => /* @__PURE__ */ jsxs14("label", { className: "flex items-center cursor-pointer gap-2", children: [
1658
+ /* @__PURE__ */ jsx25(
1659
+ "input",
1660
+ {
1661
+ type: "radio",
1662
+ id: `${id}-${option.value}`,
1663
+ className: "radio",
1664
+ name: id,
1665
+ value: getValue(option),
1666
+ checked: isChecked(option),
1667
+ required,
1668
+ disabled: disabled || readonly,
1669
+ "data-index": index,
1670
+ onChange: handleChange,
1671
+ onFocus: handleFocus,
1672
+ onBlur: handleBlur
1673
+ }
1674
+ ),
1675
+ /* @__PURE__ */ jsx25("span", { className: "label-text", children: option.label })
1676
+ ] }, option.value)) }) });
1677
+ }
1678
+
1679
+ // src/widgets/RangeWidget/RangeWidget.tsx
1680
+ import { useCallback as useCallback11 } from "react";
1681
+ import { jsx as jsx26, jsxs as jsxs15 } from "react/jsx-runtime";
1682
+ function RangeWidget({
1683
+ id,
1684
+ value,
1685
+ required,
1686
+ disabled,
1687
+ readonly,
1688
+ onChange,
1689
+ onFocus,
1690
+ onBlur,
1691
+ schema
1692
+ }) {
1693
+ const handleFocus = (event) => {
1694
+ if (onFocus) {
1695
+ onFocus(id, event.target.value);
1696
+ }
1697
+ };
1698
+ const handleBlur = (event) => {
1699
+ if (onBlur) {
1700
+ onBlur(id, event.target.value);
1701
+ }
1702
+ };
1703
+ const handleChange = useCallback11(
1704
+ (event) => {
1705
+ onChange(event.target.value);
1706
+ },
1707
+ [onChange]
1708
+ );
1709
+ return /* @__PURE__ */ jsx26("div", { className: "form-control", children: /* @__PURE__ */ jsxs15("div", { className: "flex items-center", children: [
1710
+ /* @__PURE__ */ jsx26(
1711
+ "input",
1712
+ {
1713
+ type: "range",
1714
+ id,
1715
+ className: "range",
1716
+ value: value || schema.default,
1717
+ required,
1718
+ disabled: disabled || readonly,
1719
+ min: schema.minimum,
1720
+ max: schema.maximum,
1721
+ step: schema.multipleOf || 1,
1722
+ onChange: handleChange,
1723
+ onFocus: handleFocus,
1724
+ onBlur: handleBlur
1725
+ }
1726
+ ),
1727
+ /* @__PURE__ */ jsx26("span", { className: "label-text ml-4", children: value })
1728
+ ] }) });
1729
+ }
1730
+
1731
+ // src/widgets/RatingWidget/RatingWidget.tsx
1732
+ import { useCallback as useCallback12 } from "react";
1733
+ import { jsx as jsx27 } from "react/jsx-runtime";
1734
+ function RatingWidget({
1735
+ id,
1736
+ value,
1737
+ required,
1738
+ disabled,
1739
+ readonly,
1740
+ autofocus,
1741
+ onChange,
1742
+ onFocus,
1743
+ onBlur,
1744
+ schema,
1745
+ options
1746
+ }) {
1747
+ const { stars = 5, shape = "star", color = "orange", size = "md", colorGradient = false } = options;
1748
+ const numStars = schema.maximum ? Math.min(schema.maximum, 5) : Math.min(Math.max(stars, 1), 5);
1749
+ const min = schema.minimum || 0;
1750
+ const maskClass = shape === "heart" ? "mask-heart" : "mask-star-2";
1751
+ const sizeClass = size === "md" ? "" : `rating-${size}`;
1752
+ const _onChange = useCallback12(
1753
+ ({ target: { value: value2 } }) => {
1754
+ onChange(parseInt(value2));
1755
+ },
1756
+ [onChange]
1757
+ );
1758
+ const handleFocus = useCallback12(
1759
+ (event) => {
1760
+ if (onFocus) {
1761
+ const starValue = Number(event.target.value);
1762
+ onFocus(id, starValue);
1763
+ }
1764
+ },
1765
+ [onFocus, id]
1766
+ );
1767
+ const handleBlur = useCallback12(
1768
+ (event) => {
1769
+ if (onBlur) {
1770
+ const starValue = Number(event.target.value);
1771
+ onBlur(id, starValue);
1772
+ }
1773
+ },
1774
+ [onBlur, id]
1775
+ );
1776
+ const getColorClass = (index) => {
1777
+ if (!colorGradient) {
1778
+ return `bg-${color}-400`;
1779
+ }
1780
+ const colors = ["red", "orange", "yellow", "lime", "green"];
1781
+ const colorIdx = Math.min(index, colors.length - 1);
1782
+ return `bg-${colors[colorIdx]}-400`;
1783
+ };
1784
+ return /* @__PURE__ */ jsx27("div", { className: "form-control w-full", children: /* @__PURE__ */ jsx27("div", { className: `rating gap-1 ${sizeClass}`, children: [...Array(numStars)].map((_, index) => {
1785
+ const starValue = min + index;
1786
+ return /* @__PURE__ */ jsx27(
1787
+ "input",
1788
+ {
1789
+ type: "radio",
1790
+ name: id,
1791
+ value: starValue,
1792
+ checked: value === starValue,
1793
+ onChange: _onChange,
1794
+ onFocus: handleFocus,
1795
+ onBlur: handleBlur,
1796
+ className: `mask ${maskClass} ${getColorClass(index)}`,
1797
+ disabled: disabled || readonly,
1798
+ required,
1799
+ autoFocus: autofocus && index === 0,
1800
+ "aria-label": `${starValue} ${shape === "heart" ? "heart" : "star"}${starValue === 1 ? "" : "s"}`
1801
+ },
1802
+ index
1803
+ );
1804
+ }) }) });
1805
+ }
1806
+
1807
+ // src/widgets/SelectWidget/SelectWidget.tsx
1808
+ import { useCallback as useCallback13 } from "react";
1809
+ import {
1810
+ enumOptionsIndexForValue,
1811
+ enumOptionsValueForIndex
1812
+ } from "@rjsf/utils";
1813
+ import { jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
1814
+ function SelectWidget({
1815
+ schema,
1816
+ id,
1817
+ options,
1818
+ label,
1819
+ disabled,
1820
+ placeholder,
1821
+ readonly,
1822
+ value,
1823
+ multiple,
1824
+ onChange,
1825
+ onBlur,
1826
+ onFocus
1827
+ }) {
1828
+ const { enumOptions, emptyValue: optEmptyVal } = options;
1829
+ multiple = typeof multiple === "undefined" ? false : !!multiple;
1830
+ const getDisplayValue = (val) => {
1831
+ if (!val) {
1832
+ return "";
1833
+ }
1834
+ if (typeof val === "object") {
1835
+ if (val.name) {
1836
+ return val.name;
1837
+ }
1838
+ return val.label || JSON.stringify(val);
1839
+ }
1840
+ return String(val);
1841
+ };
1842
+ const isEnumeratedObject = enumOptions && enumOptions[0]?.value && typeof enumOptions[0].value === "object";
1843
+ const handleOptionClick = useCallback13(
1844
+ (event) => {
1845
+ const index = Number(event.currentTarget.dataset.value);
1846
+ if (isNaN(index)) {
1847
+ return;
1848
+ }
1849
+ if (multiple) {
1850
+ const currentValue = Array.isArray(value) ? value : [];
1851
+ const optionValue = isEnumeratedObject ? enumOptions[index].value : enumOptionsValueForIndex(String(index), enumOptions, optEmptyVal);
1852
+ const newValue = currentValue.includes(optionValue) ? currentValue.filter((v) => v !== optionValue) : [...currentValue, optionValue];
1853
+ onChange(newValue);
1854
+ } else {
1855
+ onChange(
1856
+ isEnumeratedObject ? enumOptions[index].value : enumOptionsValueForIndex(String(index), enumOptions, optEmptyVal)
1857
+ );
1858
+ }
1859
+ },
1860
+ [value, multiple, isEnumeratedObject, enumOptions, optEmptyVal, onChange]
1861
+ );
1862
+ const _onBlur = useCallback13(
1863
+ ({ target }) => {
1864
+ const dataValue = target?.getAttribute("data-value");
1865
+ if (dataValue !== null) {
1866
+ onBlur(id, enumOptionsValueForIndex(dataValue, enumOptions, optEmptyVal));
1867
+ }
1868
+ },
1869
+ [onBlur, id, enumOptions, optEmptyVal]
1870
+ );
1871
+ const _onFocus = useCallback13(
1872
+ ({ target }) => {
1873
+ const dataValue = target?.getAttribute("data-value");
1874
+ if (dataValue !== null) {
1875
+ onFocus(id, enumOptionsValueForIndex(dataValue, enumOptions, optEmptyVal));
1876
+ }
1877
+ },
1878
+ [onFocus, id, enumOptions, optEmptyVal]
1879
+ );
1880
+ const selectedIndexes = enumOptionsIndexForValue(value, enumOptions, multiple);
1881
+ const selectedValues = Array.isArray(selectedIndexes) ? selectedIndexes : [selectedIndexes];
1882
+ const optionsList = enumOptions || (Array.isArray(schema.examples) ? schema.examples.map((example) => ({ value: example, label: example })) : []);
1883
+ return /* @__PURE__ */ jsx28("div", { className: "form-control w-full", children: /* @__PURE__ */ jsxs16("div", { className: "dropdown w-full", children: [
1884
+ /* @__PURE__ */ jsxs16(
1885
+ "div",
1886
+ {
1887
+ tabIndex: 0,
1888
+ role: "button",
1889
+ className: `btn btn-outline w-full text-left flex justify-between items-center ${disabled || readonly ? "btn-disabled" : ""}`,
1890
+ onBlur: _onBlur,
1891
+ onFocus: _onFocus,
1892
+ children: [
1893
+ /* @__PURE__ */ jsx28("span", { className: "truncate", children: selectedValues.length > 0 ? selectedValues.map((index) => optionsList[Number(index)]?.label).join(", ") : placeholder || label || "Select..." }),
1894
+ /* @__PURE__ */ jsx28("span", { className: "ml-2", children: "\u25BC" })
1895
+ ]
1896
+ }
1897
+ ),
1898
+ /* @__PURE__ */ jsx28("ul", { className: "dropdown-content z-[1] bg-base-100 w-full max-h-60 overflow-auto rounded-box shadow-lg", children: optionsList.map(({ label: label2 }, i) => /* @__PURE__ */ jsx28(
1899
+ "li",
1900
+ {
1901
+ role: "button",
1902
+ tabIndex: 0,
1903
+ className: `px-4 py-2 hover:bg-base-200 cursor-pointer ${selectedValues.includes(String(i)) ? "bg-primary/10" : ""}`,
1904
+ onClick: handleOptionClick,
1905
+ "data-value": i,
1906
+ children: /* @__PURE__ */ jsxs16("div", { className: "flex items-center gap-2", children: [
1907
+ multiple && /* @__PURE__ */ jsx28(
1908
+ "input",
1909
+ {
1910
+ type: "checkbox",
1911
+ className: "checkbox checkbox-sm",
1912
+ checked: selectedValues.includes(String(i)),
1913
+ readOnly: true
1914
+ }
1915
+ ),
1916
+ /* @__PURE__ */ jsx28("span", { children: isEnumeratedObject ? label2 : getDisplayValue(label2) })
1917
+ ] })
1918
+ },
1919
+ i
1920
+ )) })
1921
+ ] }) });
1922
+ }
1923
+
1924
+ // src/widgets/TextareaWidget/TextareaWidget.tsx
1925
+ import { useCallback as useCallback14 } from "react";
1926
+ import { jsx as jsx29 } from "react/jsx-runtime";
1927
+ function TextareaWidget(props) {
1928
+ const { id, value, required, disabled, readonly, onChange, onFocus, onBlur, options } = props;
1929
+ const handleFocus = useCallback14(
1930
+ (event) => {
1931
+ if (onFocus) {
1932
+ onFocus(id, event.target.value);
1933
+ }
1934
+ },
1935
+ [onFocus, id]
1936
+ );
1937
+ const handleBlur = useCallback14(
1938
+ (event) => {
1939
+ if (onBlur) {
1940
+ onBlur(id, event.target.value);
1941
+ }
1942
+ },
1943
+ [onBlur, id]
1944
+ );
1945
+ const handleChange = useCallback14(
1946
+ (event) => {
1947
+ onChange(event.target.value);
1948
+ },
1949
+ [onChange]
1950
+ );
1951
+ const rows = options?.rows || 5;
1952
+ return /* @__PURE__ */ jsx29("div", { className: "form-control", children: /* @__PURE__ */ jsx29(
1953
+ "textarea",
1954
+ {
1955
+ id,
1956
+ value: value || "",
1957
+ required,
1958
+ disabled: disabled || readonly,
1959
+ readOnly: readonly,
1960
+ rows,
1961
+ onChange: handleChange,
1962
+ onFocus: handleFocus,
1963
+ onBlur: handleBlur,
1964
+ className: "textarea textarea-bordered w-full"
1965
+ }
1966
+ ) });
1967
+ }
1968
+
1969
+ // src/widgets/TimeWidget/TimeWidget.tsx
1970
+ import { useCallback as useCallback15 } from "react";
1971
+ import { jsx as jsx30 } from "react/jsx-runtime";
1972
+ function TimeWidget(props) {
1973
+ const { id, value, onChange, onFocus, onBlur, required, disabled, readonly } = props;
1974
+ const handleFocus = useCallback15(
1975
+ (event) => {
1976
+ if (onFocus) {
1977
+ onFocus(id, event.target.value);
1978
+ }
1979
+ },
1980
+ [onFocus, id]
1981
+ );
1982
+ const handleBlur = useCallback15(
1983
+ (event) => {
1984
+ if (onBlur) {
1985
+ onBlur(id, event.target.value);
1986
+ }
1987
+ },
1988
+ [onBlur, id]
1989
+ );
1990
+ const handleChange = useCallback15(
1991
+ (event) => {
1992
+ onChange(event.target.value);
1993
+ },
1994
+ [onChange]
1995
+ );
1996
+ return /* @__PURE__ */ jsx30("div", { className: "form-control", children: /* @__PURE__ */ jsx30(
1997
+ "input",
1998
+ {
1999
+ type: "time",
2000
+ id,
2001
+ className: "input input-bordered w-full",
2002
+ value: value || "",
2003
+ required,
2004
+ disabled: disabled || readonly,
2005
+ readOnly: readonly,
2006
+ onChange: handleChange,
2007
+ onFocus: handleFocus,
2008
+ onBlur: handleBlur
2009
+ }
2010
+ ) });
2011
+ }
2012
+
2013
+ // src/widgets/ToggleWidget/ToggleWidget.tsx
2014
+ import { useCallback as useCallback16 } from "react";
2015
+ import { jsx as jsx31, jsxs as jsxs17 } from "react/jsx-runtime";
2016
+ function ToggleWidget({ id, value, required, disabled, readonly, autofocus, onChange, onFocus, onBlur, options }) {
2017
+ const _onChange = useCallback16(
2018
+ ({ target: { checked } }) => onChange(checked),
2019
+ [onChange]
2020
+ );
2021
+ const handleFocus = useCallback16(() => {
2022
+ if (onFocus) {
2023
+ onFocus(id, value);
2024
+ }
2025
+ }, [onFocus, id, value]);
2026
+ const handleBlur = useCallback16(() => {
2027
+ if (onBlur) {
2028
+ onBlur(id, value);
2029
+ }
2030
+ }, [onBlur, id, value]);
2031
+ const { size = "md" } = options;
2032
+ const sizeClass = size !== "md" ? `toggle-${size}` : "";
2033
+ return /* @__PURE__ */ jsx31("div", { className: "form-control", children: /* @__PURE__ */ jsxs17("label", { className: "cursor-pointer label my-auto", children: [
2034
+ /* @__PURE__ */ jsx31(
2035
+ "input",
2036
+ {
2037
+ type: "checkbox",
2038
+ id,
2039
+ checked: value,
2040
+ required,
2041
+ disabled: disabled || readonly,
2042
+ autoFocus: autofocus,
2043
+ onChange: _onChange,
2044
+ onFocus: handleFocus,
2045
+ onBlur: handleBlur,
2046
+ className: `toggle ${sizeClass}`
2047
+ }
2048
+ ),
2049
+ /* @__PURE__ */ jsx31("span", { className: "label-text", children: options.label })
2050
+ ] }) });
2051
+ }
2052
+
2053
+ // src/widgets/Widgets.tsx
2054
+ function generateWidgets() {
2055
+ return {
2056
+ AltDateTimeWidget: AltDateTimeWidget_default,
2057
+ AltDateWidget,
2058
+ CheckboxesWidget,
2059
+ CheckboxWidget,
2060
+ DateTimeWidget,
2061
+ DateWidget,
2062
+ FileWidget,
2063
+ RadioWidget,
2064
+ RangeWidget,
2065
+ RatingWidget,
2066
+ SelectWidget,
2067
+ TextareaWidget,
2068
+ TimeWidget,
2069
+ toggle: ToggleWidget
2070
+ };
2071
+ }
2072
+ var Widgets_default = generateWidgets;
2073
+
2074
+ // src/theme/Theme.tsx
2075
+ import { jsx as jsx32 } from "react/jsx-runtime";
2076
+ function generateTheme() {
2077
+ const { fields } = getDefaultRegistry();
2078
+ const generatedWidgets = generateWidgets();
2079
+ const templates = generateTemplates();
2080
+ return {
2081
+ templates,
2082
+ widgets: {
2083
+ ...generatedWidgets,
2084
+ boolean: generatedWidgets.toggle
2085
+ },
2086
+ fields
2087
+ };
2088
+ }
2089
+ var Theme = generateTheme();
2090
+ var Theme_default = Theme;
2091
+ var ThemeContext = createContext({
2092
+ theme: "night",
2093
+ setTheme: () => {
2094
+ }
2095
+ });
2096
+ function ThemeProvider({ children }) {
2097
+ const [theme, setTheme] = useState4(() => {
2098
+ try {
2099
+ return localStorage.getItem("daisyui-theme") || "cupcake";
2100
+ } catch {
2101
+ return "cupcake";
2102
+ }
2103
+ });
2104
+ const handleSetTheme = useCallback17((newTheme) => {
2105
+ try {
2106
+ localStorage.setItem("daisyui-theme", newTheme);
2107
+ setTheme(newTheme);
2108
+ } catch {
2109
+ }
2110
+ }, []);
2111
+ return /* @__PURE__ */ jsx32(ThemeContext.Provider, { value: { theme, setTheme: handleSetTheme }, children });
2112
+ }
2113
+ var useTheme = () => useContext(ThemeContext);
2114
+
2115
+ // src/DaisyUIForm.tsx
2116
+ import { withTheme } from "@rjsf/core";
2117
+ var DaisyUIForm = withTheme(Theme_default);
2118
+ var DaisyUIForm_default = DaisyUIForm;
2119
+
2120
+ // src/DaisyUIFrameProvider.tsx
2121
+ import { useEffect as useEffect4 } from "react";
2122
+ import { jsx as jsx33 } from "react/jsx-runtime";
2123
+ function DaisyUIFrameComponent(props) {
2124
+ const { children, subtheme = {}, document: document2 } = props;
2125
+ const theme = (() => {
2126
+ try {
2127
+ if (subtheme?.dataTheme) {
2128
+ localStorage.setItem("daisyui-theme", subtheme.dataTheme);
2129
+ return subtheme.dataTheme;
2130
+ }
2131
+ return localStorage.getItem("daisyui-theme") || "cupcake";
2132
+ } catch {
2133
+ return "cupcake";
2134
+ }
2135
+ })();
2136
+ useEffect4(() => {
2137
+ if (document2) {
2138
+ const configScript = document2.createElement("script");
2139
+ configScript.textContent = `
2140
+ window.tailwind = window.tailwind || {};
2141
+ window.tailwind.config = {
2142
+ daisyui: {
2143
+ themes: true,
2144
+ },
2145
+ future: {
2146
+ disableProductionWarning: true
2147
+ }
2148
+ }
2149
+ `;
2150
+ document2.head.appendChild(configScript);
2151
+ const tailwindScript = document2.createElement("script");
2152
+ tailwindScript.src = "https://unpkg.com/@tailwindcss/browser@4.1.3";
2153
+ document2.head.appendChild(tailwindScript);
2154
+ const daisyLink = document2.createElement("link");
2155
+ daisyLink.rel = "stylesheet";
2156
+ daisyLink.href = "https://cdn.jsdelivr.net/npm/daisyui@5.0.20";
2157
+ document2.head.appendChild(daisyLink);
2158
+ const daisyLinkAllThemes = document2.createElement("link");
2159
+ daisyLinkAllThemes.rel = "stylesheet";
2160
+ daisyLinkAllThemes.href = "https://cdn.jsdelivr.net/npm/daisyui@5.0.20/themes.css";
2161
+ document2.head.appendChild(daisyLinkAllThemes);
2162
+ return () => {
2163
+ configScript.remove();
2164
+ tailwindScript.remove();
2165
+ daisyLink.remove();
2166
+ daisyLinkAllThemes.remove();
2167
+ };
2168
+ }
2169
+ return void 0;
2170
+ }, [document2]);
2171
+ return /* @__PURE__ */ jsx33("div", { "data-theme": theme, className: "daisy-ui-theme", children });
2172
+ }
2173
+ var __createDaisyUIFrameProvider = (props) => {
2174
+ return function DaisyUIFrame({ document: document2 }) {
2175
+ return /* @__PURE__ */ jsx33(DaisyUIFrameComponent, { document: document2, ...props });
2176
+ };
2177
+ };
2178
+
2179
+ // src/index.ts
2180
+ var index_default = withTheme2(Theme_default);
2181
+ export {
2182
+ DaisyUIForm_default as Form,
2183
+ GridTemplate,
2184
+ Templates_default as Templates,
2185
+ Theme_default as Theme,
2186
+ ThemeProvider,
2187
+ Widgets_default as Widgets,
2188
+ __createDaisyUIFrameProvider,
2189
+ index_default as default,
2190
+ useTheme
2191
+ };
2192
+ //# sourceMappingURL=chakra-ui.esm.js.map