@skybin-tech/nebula-ui 0.0.26 → 0.0.28

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 (293) hide show
  1. package/README.md +6 -4
  2. package/dist/cjs/_virtual/_rolldown/runtime.cjs +24 -0
  3. package/dist/cjs/components/Accordion/Accordion.cjs +20 -10
  4. package/dist/cjs/components/Accordion/Accordion.cjs.map +1 -1
  5. package/dist/cjs/components/Alert/Alert.cjs +19 -9
  6. package/dist/cjs/components/Alert/Alert.cjs.map +1 -1
  7. package/dist/cjs/components/Avatar/Avatar.cjs +19 -9
  8. package/dist/cjs/components/Avatar/Avatar.cjs.map +1 -1
  9. package/dist/cjs/components/Badge/Badge.cjs +8 -7
  10. package/dist/cjs/components/Badge/Badge.cjs.map +1 -1
  11. package/dist/cjs/components/Button/Button.cjs +37 -47
  12. package/dist/cjs/components/Button/Button.cjs.map +1 -1
  13. package/dist/cjs/components/Card/Card.cjs +31 -12
  14. package/dist/cjs/components/Card/Card.cjs.map +1 -1
  15. package/dist/cjs/components/Checkbox/Checkbox.cjs +12 -7
  16. package/dist/cjs/components/Checkbox/Checkbox.cjs.map +1 -1
  17. package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs +55 -21
  18. package/dist/cjs/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
  19. package/dist/cjs/components/Form/Checkbox.cjs +128 -142
  20. package/dist/cjs/components/Form/Checkbox.cjs.map +1 -1
  21. package/dist/cjs/components/Form/Form.cjs +106 -105
  22. package/dist/cjs/components/Form/Form.cjs.map +1 -1
  23. package/dist/cjs/components/Form/FormSwitch.cjs +126 -0
  24. package/dist/cjs/components/Form/FormSwitch.cjs.map +1 -0
  25. package/dist/cjs/components/Form/Radio.cjs +157 -172
  26. package/dist/cjs/components/Form/Radio.cjs.map +1 -1
  27. package/dist/cjs/components/Form/Select.cjs +131 -0
  28. package/dist/cjs/components/Form/Select.cjs.map +1 -0
  29. package/dist/cjs/components/Form/TextArea.cjs +137 -152
  30. package/dist/cjs/components/Form/TextArea.cjs.map +1 -1
  31. package/dist/cjs/components/Form/TextBox.cjs +184 -206
  32. package/dist/cjs/components/Form/TextBox.cjs.map +1 -1
  33. package/dist/cjs/components/Form/context.cjs +109 -122
  34. package/dist/cjs/components/Form/context.cjs.map +1 -1
  35. package/dist/cjs/components/Form/hooks.cjs +34 -24
  36. package/dist/cjs/components/Form/hooks.cjs.map +1 -1
  37. package/dist/cjs/components/Form/index.cjs +29 -0
  38. package/dist/cjs/components/Form/variants.cjs +14 -14
  39. package/dist/cjs/components/Form/variants.cjs.map +1 -1
  40. package/dist/cjs/components/Input/Input.cjs +11 -7
  41. package/dist/cjs/components/Input/Input.cjs.map +1 -1
  42. package/dist/cjs/components/Label/Label.cjs +11 -7
  43. package/dist/cjs/components/Label/Label.cjs.map +1 -1
  44. package/dist/cjs/components/Pagination/Pagination.cjs +58 -95
  45. package/dist/cjs/components/Pagination/Pagination.cjs.map +1 -1
  46. package/dist/cjs/components/Separator/Separator.cjs +11 -7
  47. package/dist/cjs/components/Separator/Separator.cjs.map +1 -1
  48. package/dist/cjs/components/Skeleton/Skeleton.cjs +7 -6
  49. package/dist/cjs/components/Skeleton/Skeleton.cjs.map +1 -1
  50. package/dist/cjs/components/Switch/Switch.cjs +14 -0
  51. package/dist/cjs/components/Switch/Switch.cjs.map +1 -0
  52. package/dist/cjs/components/Tabs/Tabs.cjs +23 -10
  53. package/dist/cjs/components/Tabs/Tabs.cjs.map +1 -1
  54. package/dist/cjs/components/Textarea/Textarea.cjs +11 -7
  55. package/dist/cjs/components/Textarea/Textarea.cjs.map +1 -1
  56. package/dist/cjs/components/Tooltip/Tooltip.cjs +14 -10
  57. package/dist/cjs/components/Tooltip/Tooltip.cjs.map +1 -1
  58. package/dist/cjs/hooks/useDebounce.cjs +22 -14
  59. package/dist/cjs/hooks/useDebounce.cjs.map +1 -1
  60. package/dist/cjs/hooks/useToast.cjs +105 -84
  61. package/dist/cjs/hooks/useToast.cjs.map +1 -1
  62. package/dist/cjs/hooks/useToggle.cjs +15 -9
  63. package/dist/cjs/hooks/useToggle.cjs.map +1 -1
  64. package/dist/cjs/index.cjs +172 -170
  65. package/dist/cjs/primitives/accordion.cjs +38 -61
  66. package/dist/cjs/primitives/accordion.cjs.map +1 -1
  67. package/dist/cjs/primitives/alert.cjs +33 -63
  68. package/dist/cjs/primitives/alert.cjs.map +1 -1
  69. package/dist/cjs/primitives/avatar.cjs +29 -58
  70. package/dist/cjs/primitives/avatar.cjs.map +1 -1
  71. package/dist/cjs/primitives/badge.cjs +26 -27
  72. package/dist/cjs/primitives/badge.cjs.map +1 -1
  73. package/dist/cjs/primitives/button.cjs +44 -63
  74. package/dist/cjs/primitives/button.cjs.map +1 -1
  75. package/dist/cjs/primitives/calendar.cjs +41 -44
  76. package/dist/cjs/primitives/calendar.cjs.map +1 -1
  77. package/dist/cjs/primitives/card.cjs +39 -70
  78. package/dist/cjs/primitives/card.cjs.map +1 -1
  79. package/dist/cjs/primitives/checkbox.cjs +22 -45
  80. package/dist/cjs/primitives/checkbox.cjs.map +1 -1
  81. package/dist/cjs/primitives/command.cjs +65 -73
  82. package/dist/cjs/primitives/command.cjs.map +1 -1
  83. package/dist/cjs/primitives/dialog.cjs +55 -84
  84. package/dist/cjs/primitives/dialog.cjs.map +1 -1
  85. package/dist/cjs/primitives/dropdown-menu.cjs +82 -153
  86. package/dist/cjs/primitives/dropdown-menu.cjs.map +1 -1
  87. package/dist/cjs/primitives/input.cjs +17 -39
  88. package/dist/cjs/primitives/input.cjs.map +1 -1
  89. package/dist/cjs/primitives/label.cjs +19 -38
  90. package/dist/cjs/primitives/label.cjs.map +1 -1
  91. package/dist/cjs/primitives/popover.cjs +22 -42
  92. package/dist/cjs/primitives/popover.cjs.map +1 -1
  93. package/dist/cjs/primitives/radio-group.cjs +31 -50
  94. package/dist/cjs/primitives/radio-group.cjs.map +1 -1
  95. package/dist/cjs/primitives/scroll-area.cjs +33 -55
  96. package/dist/cjs/primitives/scroll-area.cjs.map +1 -1
  97. package/dist/cjs/primitives/select.cjs +76 -133
  98. package/dist/cjs/primitives/select.cjs.map +1 -1
  99. package/dist/cjs/primitives/separator.cjs +20 -42
  100. package/dist/cjs/primitives/separator.cjs.map +1 -1
  101. package/dist/cjs/primitives/skeleton.cjs +10 -12
  102. package/dist/cjs/primitives/skeleton.cjs.map +1 -1
  103. package/dist/cjs/primitives/sonner.cjs +16 -20
  104. package/dist/cjs/primitives/sonner.cjs.map +1 -1
  105. package/dist/cjs/primitives/switch.cjs +19 -45
  106. package/dist/cjs/primitives/switch.cjs.map +1 -1
  107. package/dist/cjs/primitives/table.cjs +52 -61
  108. package/dist/cjs/primitives/table.cjs.map +1 -1
  109. package/dist/cjs/primitives/tabs.cjs +30 -62
  110. package/dist/cjs/primitives/tabs.cjs.map +1 -1
  111. package/dist/cjs/primitives/textarea.cjs +15 -35
  112. package/dist/cjs/primitives/textarea.cjs.map +1 -1
  113. package/dist/cjs/primitives/textbox.cjs +17 -39
  114. package/dist/cjs/primitives/textbox.cjs.map +1 -1
  115. package/dist/cjs/primitives/toast.cjs +59 -107
  116. package/dist/cjs/primitives/toast.cjs.map +1 -1
  117. package/dist/cjs/primitives/toggle.cjs +39 -55
  118. package/dist/cjs/primitives/toggle.cjs.map +1 -1
  119. package/dist/cjs/primitives/tooltip.cjs +21 -41
  120. package/dist/cjs/primitives/tooltip.cjs.map +1 -1
  121. package/dist/cjs/utils/cn.cjs +11 -6
  122. package/dist/cjs/utils/cn.cjs.map +1 -1
  123. package/dist/components/Accordion/Accordion.js +20 -13
  124. package/dist/components/Accordion/Accordion.js.map +1 -1
  125. package/dist/components/Alert/Alert.js +19 -11
  126. package/dist/components/Alert/Alert.js.map +1 -1
  127. package/dist/components/Avatar/Avatar.js +19 -11
  128. package/dist/components/Avatar/Avatar.js.map +1 -1
  129. package/dist/components/Badge/Badge.d.ts +1 -1
  130. package/dist/components/Badge/Badge.d.ts.map +1 -1
  131. package/dist/components/Badge/Badge.js +8 -8
  132. package/dist/components/Badge/Badge.js.map +1 -1
  133. package/dist/components/Button/Button.js +37 -48
  134. package/dist/components/Button/Button.js.map +1 -1
  135. package/dist/components/Card/Card.js +31 -17
  136. package/dist/components/Card/Card.js.map +1 -1
  137. package/dist/components/Checkbox/Checkbox.js +12 -7
  138. package/dist/components/Checkbox/Checkbox.js.map +1 -1
  139. package/dist/components/DropdownMenu/DropdownMenu.d.ts +4 -4
  140. package/dist/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
  141. package/dist/components/DropdownMenu/DropdownMenu.js +55 -35
  142. package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
  143. package/dist/components/Form/Checkbox.js +126 -140
  144. package/dist/components/Form/Checkbox.js.map +1 -1
  145. package/dist/components/Form/Form.d.ts +1 -1
  146. package/dist/components/Form/Form.d.ts.map +1 -1
  147. package/dist/components/Form/Form.js +104 -103
  148. package/dist/components/Form/Form.js.map +1 -1
  149. package/dist/components/Form/{Switch.d.ts → FormSwitch.d.ts} +3 -3
  150. package/dist/components/Form/FormSwitch.d.ts.map +1 -0
  151. package/dist/components/Form/FormSwitch.js +126 -0
  152. package/dist/components/Form/FormSwitch.js.map +1 -0
  153. package/dist/components/Form/Radio.d.ts +1 -1
  154. package/dist/components/Form/Radio.d.ts.map +1 -1
  155. package/dist/components/Form/Radio.js +155 -171
  156. package/dist/components/Form/Radio.js.map +1 -1
  157. package/dist/components/Form/Select.d.ts +1 -1
  158. package/dist/components/Form/Select.d.ts.map +1 -1
  159. package/dist/components/Form/Select.js +131 -0
  160. package/dist/components/Form/Select.js.map +1 -0
  161. package/dist/components/Form/TextArea.js +134 -149
  162. package/dist/components/Form/TextArea.js.map +1 -1
  163. package/dist/components/Form/TextBox.js +179 -201
  164. package/dist/components/Form/TextBox.js.map +1 -1
  165. package/dist/components/Form/context.d.ts +3 -5
  166. package/dist/components/Form/context.d.ts.map +1 -1
  167. package/dist/components/Form/context.js +109 -125
  168. package/dist/components/Form/context.js.map +1 -1
  169. package/dist/components/Form/hooks.js +35 -28
  170. package/dist/components/Form/hooks.js.map +1 -1
  171. package/dist/components/Form/index.d.ts +4 -4
  172. package/dist/components/Form/index.d.ts.map +1 -1
  173. package/dist/components/Form/index.js +11 -0
  174. package/dist/components/Form/variants.js +15 -14
  175. package/dist/components/Form/variants.js.map +1 -1
  176. package/dist/components/Input/Input.js +11 -7
  177. package/dist/components/Input/Input.js.map +1 -1
  178. package/dist/components/Label/Label.js +11 -7
  179. package/dist/components/Label/Label.js.map +1 -1
  180. package/dist/components/Pagination/Pagination.d.ts +5 -5
  181. package/dist/components/Pagination/Pagination.js +55 -83
  182. package/dist/components/Pagination/Pagination.js.map +1 -1
  183. package/dist/components/Separator/Separator.js +11 -7
  184. package/dist/components/Separator/Separator.js.map +1 -1
  185. package/dist/components/Skeleton/Skeleton.d.ts +1 -1
  186. package/dist/components/Skeleton/Skeleton.d.ts.map +1 -1
  187. package/dist/components/Skeleton/Skeleton.js +7 -6
  188. package/dist/components/Skeleton/Skeleton.js.map +1 -1
  189. package/dist/components/Switch/Switch.d.ts +4 -1
  190. package/dist/components/Switch/Switch.d.ts.map +1 -1
  191. package/dist/components/Switch/Switch.js +14 -0
  192. package/dist/components/Switch/Switch.js.map +1 -0
  193. package/dist/components/Switch/index.d.ts +1 -0
  194. package/dist/components/Switch/index.d.ts.map +1 -1
  195. package/dist/components/Tabs/Tabs.js +23 -13
  196. package/dist/components/Tabs/Tabs.js.map +1 -1
  197. package/dist/components/Textarea/Textarea.js +11 -7
  198. package/dist/components/Textarea/Textarea.js.map +1 -1
  199. package/dist/components/Tooltip/Tooltip.js +14 -13
  200. package/dist/components/Tooltip/Tooltip.js.map +1 -1
  201. package/dist/hooks/useDebounce.js +23 -15
  202. package/dist/hooks/useDebounce.js.map +1 -1
  203. package/dist/hooks/useToast.js +103 -69
  204. package/dist/hooks/useToast.js.map +1 -1
  205. package/dist/hooks/useToggle.js +16 -10
  206. package/dist/hooks/useToggle.js.map +1 -1
  207. package/dist/index.d.ts +6 -2
  208. package/dist/index.d.ts.map +1 -1
  209. package/dist/index.js +30 -160
  210. package/dist/primitives/accordion.js +32 -43
  211. package/dist/primitives/accordion.js.map +1 -1
  212. package/dist/primitives/alert.js +30 -47
  213. package/dist/primitives/alert.js.map +1 -1
  214. package/dist/primitives/avatar.js +22 -38
  215. package/dist/primitives/avatar.js.map +1 -1
  216. package/dist/primitives/badge.d.ts +1 -1
  217. package/dist/primitives/badge.d.ts.map +1 -1
  218. package/dist/primitives/badge.js +23 -27
  219. package/dist/primitives/badge.js.map +1 -1
  220. package/dist/primitives/button.js +41 -46
  221. package/dist/primitives/button.js.map +1 -1
  222. package/dist/primitives/calendar.d.ts +1 -1
  223. package/dist/primitives/calendar.d.ts.map +1 -1
  224. package/dist/primitives/calendar.js +37 -42
  225. package/dist/primitives/calendar.js.map +1 -1
  226. package/dist/primitives/card.js +37 -58
  227. package/dist/primitives/card.js.map +1 -1
  228. package/dist/primitives/checkbox.js +17 -25
  229. package/dist/primitives/checkbox.js.map +1 -1
  230. package/dist/primitives/command.d.ts +2 -2
  231. package/dist/primitives/command.d.ts.map +1 -1
  232. package/dist/primitives/command.js +70 -71
  233. package/dist/primitives/command.js.map +1 -1
  234. package/dist/primitives/dialog.d.ts +2 -2
  235. package/dist/primitives/dialog.js +47 -70
  236. package/dist/primitives/dialog.js.map +1 -1
  237. package/dist/primitives/dropdown-menu.d.ts +1 -1
  238. package/dist/primitives/dropdown-menu.js +70 -140
  239. package/dist/primitives/dropdown-menu.js.map +1 -1
  240. package/dist/primitives/input.js +15 -22
  241. package/dist/primitives/input.js.map +1 -1
  242. package/dist/primitives/label.js +14 -18
  243. package/dist/primitives/label.js.map +1 -1
  244. package/dist/primitives/popover.js +17 -25
  245. package/dist/primitives/popover.js.map +1 -1
  246. package/dist/primitives/radio-group.js +25 -30
  247. package/dist/primitives/radio-group.js.map +1 -1
  248. package/dist/primitives/scroll-area.js +27 -35
  249. package/dist/primitives/scroll-area.js.map +1 -1
  250. package/dist/primitives/select.js +65 -116
  251. package/dist/primitives/select.js.map +1 -1
  252. package/dist/primitives/separator.js +15 -22
  253. package/dist/primitives/separator.js.map +1 -1
  254. package/dist/primitives/skeleton.d.ts +1 -1
  255. package/dist/primitives/skeleton.d.ts.map +1 -1
  256. package/dist/primitives/skeleton.js +10 -12
  257. package/dist/primitives/skeleton.js.map +1 -1
  258. package/dist/primitives/sonner.d.ts +1 -1
  259. package/dist/primitives/sonner.d.ts.map +1 -1
  260. package/dist/primitives/sonner.js +17 -21
  261. package/dist/primitives/sonner.js.map +1 -1
  262. package/dist/primitives/switch.js +14 -25
  263. package/dist/primitives/switch.js.map +1 -1
  264. package/dist/primitives/table.js +50 -51
  265. package/dist/primitives/table.js.map +1 -1
  266. package/dist/primitives/tabs.js +23 -43
  267. package/dist/primitives/tabs.js.map +1 -1
  268. package/dist/primitives/textarea.js +13 -18
  269. package/dist/primitives/textarea.js.map +1 -1
  270. package/dist/primitives/textbox.js +15 -22
  271. package/dist/primitives/textbox.js.map +1 -1
  272. package/dist/primitives/toast.js +48 -87
  273. package/dist/primitives/toast.js.map +1 -1
  274. package/dist/primitives/toggle.js +34 -36
  275. package/dist/primitives/toggle.js.map +1 -1
  276. package/dist/primitives/tooltip.js +16 -24
  277. package/dist/primitives/tooltip.js.map +1 -1
  278. package/dist/stories/Button.d.ts +1 -1
  279. package/dist/stories/Button.d.ts.map +1 -1
  280. package/dist/stories/Button.stories.d.ts +1 -1
  281. package/dist/stories/Header.d.ts +1 -1
  282. package/dist/stories/Header.d.ts.map +1 -1
  283. package/dist/stories/Header.stories.d.ts +1 -1
  284. package/dist/utils/cn.js +10 -5
  285. package/dist/utils/cn.js.map +1 -1
  286. package/package.json +503 -497
  287. package/dist/cjs/components/Form/Switch.cjs +0 -126
  288. package/dist/cjs/components/Form/Switch.cjs.map +0 -1
  289. package/dist/cjs/index.cjs.map +0 -1
  290. package/dist/components/Form/Switch.d.ts.map +0 -1
  291. package/dist/components/Form/Switch.js +0 -126
  292. package/dist/components/Form/Switch.js.map +0 -1
  293. package/dist/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.cjs","sources":["../../../../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\nimport type { ComponentPropsWithoutRef, ElementRef, HTMLAttributes } from \"react\"\nimport {\n DropdownMenu as DropdownMenuPrimitive,\n DropdownMenuTrigger as DropdownMenuTriggerPrimitive,\n DropdownMenuContent as DropdownMenuContentPrimitive,\n DropdownMenuItem as DropdownMenuItemPrimitive,\n DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive,\n DropdownMenuRadioItem as DropdownMenuRadioItemPrimitive,\n DropdownMenuLabel as DropdownMenuLabelPrimitive,\n DropdownMenuSeparator as DropdownMenuSeparatorPrimitive,\n DropdownMenuShortcut as DropdownMenuShortcutPrimitive,\n DropdownMenuGroup as DropdownMenuGroupPrimitive,\n DropdownMenuPortal as DropdownMenuPortalPrimitive,\n DropdownMenuSub as DropdownMenuSubPrimitive,\n DropdownMenuSubContent as DropdownMenuSubContentPrimitive,\n DropdownMenuSubTrigger as DropdownMenuSubTriggerPrimitive,\n DropdownMenuRadioGroup as DropdownMenuRadioGroupPrimitive,\n} from \"../../primitives/dropdown-menu\"\n\n// Root / context-only components (no DOM element to ref)\nexport function DropdownMenu(props: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive>) {\n return <DropdownMenuPrimitive {...props} />\n}\n\nexport function DropdownMenuPortal(props: ComponentPropsWithoutRef<typeof DropdownMenuPortalPrimitive>) {\n return <DropdownMenuPortalPrimitive {...props} />\n}\n\nexport function DropdownMenuSub(props: ComponentPropsWithoutRef<typeof DropdownMenuSubPrimitive>) {\n return <DropdownMenuSubPrimitive {...props} />\n}\n\n// DOM-rendering components (forwardRef)\nexport const DropdownMenuTrigger = forwardRef<\n ElementRef<typeof DropdownMenuTriggerPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuTriggerPrimitive>\n>((props, ref) => <DropdownMenuTriggerPrimitive ref={ref} {...props} />)\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\"\n\nexport const DropdownMenuGroup = forwardRef<\n ElementRef<typeof DropdownMenuGroupPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuGroupPrimitive>\n>((props, ref) => <DropdownMenuGroupPrimitive ref={ref} {...props} />)\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\"\n\nexport const DropdownMenuRadioGroup = forwardRef<\n ElementRef<typeof DropdownMenuRadioGroupPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuRadioGroupPrimitive>\n>((props, ref) => <DropdownMenuRadioGroupPrimitive ref={ref} {...props} />)\nDropdownMenuRadioGroup.displayName = \"DropdownMenuRadioGroup\"\n\nexport const DropdownMenuContent = forwardRef<\n ElementRef<typeof DropdownMenuContentPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuContentPrimitive>\n>((props, ref) => <DropdownMenuContentPrimitive ref={ref} {...props} />)\nDropdownMenuContent.displayName = \"DropdownMenuContent\"\n\nexport const DropdownMenuSubContent = forwardRef<\n ElementRef<typeof DropdownMenuSubContentPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuSubContentPrimitive>\n>((props, ref) => <DropdownMenuSubContentPrimitive ref={ref} {...props} />)\nDropdownMenuSubContent.displayName = \"DropdownMenuSubContent\"\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ElementRef<typeof DropdownMenuSubTriggerPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuSubTriggerPrimitive>\n>((props, ref) => <DropdownMenuSubTriggerPrimitive ref={ref} {...props} />)\nDropdownMenuSubTrigger.displayName = \"DropdownMenuSubTrigger\"\n\nexport const DropdownMenuItem = forwardRef<\n ElementRef<typeof DropdownMenuItemPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuItemPrimitive>\n>((props, ref) => <DropdownMenuItemPrimitive ref={ref} {...props} />)\nDropdownMenuItem.displayName = \"DropdownMenuItem\"\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ElementRef<typeof DropdownMenuCheckboxItemPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuCheckboxItemPrimitive>\n>((props, ref) => <DropdownMenuCheckboxItemPrimitive ref={ref} {...props} />)\nDropdownMenuCheckboxItem.displayName = \"DropdownMenuCheckboxItem\"\n\nexport const DropdownMenuRadioItem = forwardRef<\n ElementRef<typeof DropdownMenuRadioItemPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuRadioItemPrimitive>\n>((props, ref) => <DropdownMenuRadioItemPrimitive ref={ref} {...props} />)\nDropdownMenuRadioItem.displayName = \"DropdownMenuRadioItem\"\n\nexport const DropdownMenuLabel = forwardRef<\n ElementRef<typeof DropdownMenuLabelPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuLabelPrimitive>\n>((props, ref) => <DropdownMenuLabelPrimitive ref={ref} {...props} />)\nDropdownMenuLabel.displayName = \"DropdownMenuLabel\"\n\nexport const DropdownMenuSeparator = forwardRef<\n ElementRef<typeof DropdownMenuSeparatorPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuSeparatorPrimitive>\n>((props, ref) => <DropdownMenuSeparatorPrimitive ref={ref} {...props} />)\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\"\n\n// Utility span — no ref needed\nexport function DropdownMenuShortcut(props: HTMLAttributes<HTMLSpanElement>) {\n return <DropdownMenuShortcutPrimitive {...props} />\n}\nDropdownMenuShortcut.displayName = \"DropdownMenuShortcut\"\n"],"names":["jsx","DropdownMenuPrimitive","DropdownMenuPortalPrimitive","DropdownMenuSubPrimitive","forwardRef","DropdownMenuTriggerPrimitive","DropdownMenuGroupPrimitive","DropdownMenuRadioGroupPrimitive","DropdownMenuContentPrimitive","DropdownMenuSubContentPrimitive","DropdownMenuSubTriggerPrimitive","DropdownMenuItemPrimitive","DropdownMenuCheckboxItemPrimitive","DropdownMenuR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;AAExB,MAAM,2BAA2BP,MAAAA,WAGtC,CAAC,OAAO,uCAASQ,aAAAA,0BAAA,EAAkC,KAAW,GAAG,OAAO,CAAE;AAC5E,yBAAyB,cAAc;AAEhC,MAAM,wBAAwBR,MAAAA,WAGnC,CAAC,OAAO,uCAASS,aAAAA,uBAAA,EAA+B,KAAW,GAAG,OAAO,CAAE;AACzE,sBAAsB,cAAc;AAE7B,MAAM,oBAAoBT,MAAAA,WAG/B,CAAC,OAAO,uCAASU,aAAAA,mBAAA,EAA2B,KAAW,GAAG,OAAO,CAAE;AACrE,kBAAkB,cAAc;AAEzB,MAAM,wBAAwBV,MAAAA,WAGnC,CAAC,OAAO,uCAASW,aAAAA,uBAAA,EAA+B,KAAW,GAAG,OAAO,CAAE;AACzE,sBAAsB,cAAc;AAG7B,SAAS,qBAAqB,OAAwC;AAC3E,SAAOf,+BAACgB,aAAAA,sBAAA,EAA+B,GAAG,MAAA,CAAO;AACnD;AACA,qBAAqB,cAAc;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"DropdownMenu.cjs","names":[],"sources":["../../../../src/components/DropdownMenu/DropdownMenu.tsx"],"sourcesContent":["import { forwardRef } from \"react\"\nimport type { ComponentPropsWithoutRef, ElementRef, HTMLAttributes } from \"react\"\nimport {\n DropdownMenu as DropdownMenuPrimitive,\n DropdownMenuTrigger as DropdownMenuTriggerPrimitive,\n DropdownMenuContent as DropdownMenuContentPrimitive,\n DropdownMenuItem as DropdownMenuItemPrimitive,\n DropdownMenuCheckboxItem as DropdownMenuCheckboxItemPrimitive,\n DropdownMenuRadioItem as DropdownMenuRadioItemPrimitive,\n DropdownMenuLabel as DropdownMenuLabelPrimitive,\n DropdownMenuSeparator as DropdownMenuSeparatorPrimitive,\n DropdownMenuShortcut as DropdownMenuShortcutPrimitive,\n DropdownMenuGroup as DropdownMenuGroupPrimitive,\n DropdownMenuPortal as DropdownMenuPortalPrimitive,\n DropdownMenuSub as DropdownMenuSubPrimitive,\n DropdownMenuSubContent as DropdownMenuSubContentPrimitive,\n DropdownMenuSubTrigger as DropdownMenuSubTriggerPrimitive,\n DropdownMenuRadioGroup as DropdownMenuRadioGroupPrimitive,\n} from \"../../primitives/dropdown-menu\"\n\n// Root / context-only components (no DOM element to ref)\nexport function DropdownMenu(props: ComponentPropsWithoutRef<typeof DropdownMenuPrimitive>) {\n return <DropdownMenuPrimitive {...props} />\n}\n\nexport function DropdownMenuPortal(props: ComponentPropsWithoutRef<typeof DropdownMenuPortalPrimitive>) {\n return <DropdownMenuPortalPrimitive {...props} />\n}\n\nexport function DropdownMenuSub(props: ComponentPropsWithoutRef<typeof DropdownMenuSubPrimitive>) {\n return <DropdownMenuSubPrimitive {...props} />\n}\n\n// DOM-rendering components (forwardRef)\nexport const DropdownMenuTrigger = forwardRef<\n ElementRef<typeof DropdownMenuTriggerPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuTriggerPrimitive>\n>((props, ref) => <DropdownMenuTriggerPrimitive ref={ref} {...props} />)\nDropdownMenuTrigger.displayName = \"DropdownMenuTrigger\"\n\nexport const DropdownMenuGroup = forwardRef<\n ElementRef<typeof DropdownMenuGroupPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuGroupPrimitive>\n>((props, ref) => <DropdownMenuGroupPrimitive ref={ref} {...props} />)\nDropdownMenuGroup.displayName = \"DropdownMenuGroup\"\n\nexport const DropdownMenuRadioGroup = forwardRef<\n ElementRef<typeof DropdownMenuRadioGroupPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuRadioGroupPrimitive>\n>((props, ref) => <DropdownMenuRadioGroupPrimitive ref={ref} {...props} />)\nDropdownMenuRadioGroup.displayName = \"DropdownMenuRadioGroup\"\n\nexport const DropdownMenuContent = forwardRef<\n ElementRef<typeof DropdownMenuContentPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuContentPrimitive>\n>((props, ref) => <DropdownMenuContentPrimitive ref={ref} {...props} />)\nDropdownMenuContent.displayName = \"DropdownMenuContent\"\n\nexport const DropdownMenuSubContent = forwardRef<\n ElementRef<typeof DropdownMenuSubContentPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuSubContentPrimitive>\n>((props, ref) => <DropdownMenuSubContentPrimitive ref={ref} {...props} />)\nDropdownMenuSubContent.displayName = \"DropdownMenuSubContent\"\n\nexport const DropdownMenuSubTrigger = forwardRef<\n ElementRef<typeof DropdownMenuSubTriggerPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuSubTriggerPrimitive>\n>((props, ref) => <DropdownMenuSubTriggerPrimitive ref={ref} {...props} />)\nDropdownMenuSubTrigger.displayName = \"DropdownMenuSubTrigger\"\n\nexport const DropdownMenuItem = forwardRef<\n ElementRef<typeof DropdownMenuItemPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuItemPrimitive>\n>((props, ref) => <DropdownMenuItemPrimitive ref={ref} {...props} />)\nDropdownMenuItem.displayName = \"DropdownMenuItem\"\n\nexport const DropdownMenuCheckboxItem = forwardRef<\n ElementRef<typeof DropdownMenuCheckboxItemPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuCheckboxItemPrimitive>\n>((props, ref) => <DropdownMenuCheckboxItemPrimitive ref={ref} {...props} />)\nDropdownMenuCheckboxItem.displayName = \"DropdownMenuCheckboxItem\"\n\nexport const DropdownMenuRadioItem = forwardRef<\n ElementRef<typeof DropdownMenuRadioItemPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuRadioItemPrimitive>\n>((props, ref) => <DropdownMenuRadioItemPrimitive ref={ref} {...props} />)\nDropdownMenuRadioItem.displayName = \"DropdownMenuRadioItem\"\n\nexport const DropdownMenuLabel = forwardRef<\n ElementRef<typeof DropdownMenuLabelPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuLabelPrimitive>\n>((props, ref) => <DropdownMenuLabelPrimitive ref={ref} {...props} />)\nDropdownMenuLabel.displayName = \"DropdownMenuLabel\"\n\nexport const DropdownMenuSeparator = forwardRef<\n ElementRef<typeof DropdownMenuSeparatorPrimitive>,\n ComponentPropsWithoutRef<typeof DropdownMenuSeparatorPrimitive>\n>((props, ref) => <DropdownMenuSeparatorPrimitive ref={ref} {...props} />)\nDropdownMenuSeparator.displayName = \"DropdownMenuSeparator\"\n\n// Utility span — no ref needed\nexport function DropdownMenuShortcut(props: HTMLAttributes<HTMLSpanElement>) {\n return <DropdownMenuShortcutPrimitive {...props} />\n}\nDropdownMenuShortcut.displayName = \"DropdownMenuShortcut\"\n"],"mappings":";;;;;AAqBA,SAAgB,aAAa,OAA+D;CAC1F,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,sBAAA,cAAD,EAAuB,GAAI,MAAQ,CAAA;AAC5C;AAEA,SAAgB,mBAAmB,OAAqE;CACtG,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,sBAAA,oBAAD,EAA6B,GAAI,MAAQ,CAAA;AAClD;AAEA,SAAgB,gBAAgB,OAAkE;CAChG,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,sBAAA,iBAAD,EAA0B,GAAI,MAAQ,CAAA;AAC/C;AAGA,IAAa,uBAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,sBAAA,qBAAD;CAAmC;CAAK,GAAI;AAAQ,CAAA,CAAC;AACvE,oBAAoB,cAAc;AAElC,IAAa,qBAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,sBAAA,mBAAD;CAAiC;CAAK,GAAI;AAAQ,CAAA,CAAC;AACrE,kBAAkB,cAAc;AAEhC,IAAa,0BAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,GAAA,kBAAA,IAAA,CAAC,sBAAA,wBAAD;CAAsC;CAAK,GAAI;AAAQ,CAAA,CAAC;AAC1E,uBAAuB,cAAc;AAErC,IAAa,uBAAA,GAAA,MAAA,WAAA,EAGV,OAAO,QAAQ,iBAAA,G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AsB,cAAc;AAGpC,SAAgB,qBAAqB,OAAwC;CAC3E,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,sBAAA,sBAAD,EAA+B,GAAI,MAAQ,CAAA;AACpD;AACA,qBAAqB,cAAc"}
@@ -1,146 +1,132 @@
1
1
  "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("react/jsx-runtime");
5
- const React = require("react");
6
- const reactHookForm = require("react-hook-form");
7
- const classVarianceAuthority = require("class-variance-authority");
8
- const cn = require("../../utils/cn.cjs");
9
- const context = require("./context.cjs");
10
- const checkbox = require("../../primitives/checkbox.cjs");
11
- const label = require("../../primitives/label.cjs");
12
- const checkboxSizeVariants = classVarianceAuthority.cva(
13
- "",
14
- {
15
- variants: {
16
- size: {
17
- sm: "h-4 w-4",
18
- md: "h-5 w-5",
19
- lg: "h-6 w-6"
20
- }
21
- },
22
- defaultVariants: {
23
- size: "md"
24
- }
25
- }
26
- );
27
- const labelVariants = classVarianceAuthority.cva(
28
- "text-sm font-medium cursor-pointer select-none",
29
- {
30
- variants: {
31
- required: {
32
- true: "after:content-['*'] after:ml-0.5 after:text-destructive",
33
- false: ""
34
- },
35
- disabled: {
36
- true: "cursor-not-allowed opacity-50",
37
- false: ""
38
- }
39
- },
40
- defaultVariants: {
41
- required: false,
42
- disabled: false
43
- }
44
- }
45
- );
46
- function CheckboxInner({
47
- name,
48
- label: label$1,
49
- helperText,
50
- showError = true,
51
- error: customError,
52
- size,
53
- variant,
54
- className,
55
- disabled,
56
- id: providedId,
57
- control: externalControl,
58
- // Validation props
59
- required,
60
- validate,
61
- ...props
62
- }, ref) {
63
- const generatedId = React.useId();
64
- const inputId = providedId ?? generatedId;
65
- const formConfigContext = React.useContext(context.FormConfigContext);
66
- const formConfig = formConfigContext ?? {};
67
- const rhfContext = reactHookForm.useFormContext();
68
- const control = externalControl ?? rhfContext?.control;
69
- React.useEffect(() => {
70
- if (formConfigContext?.registerFieldValidation) {
71
- const rules = {};
72
- if (required !== void 0) rules.required = required;
73
- if (validate !== void 0) rules.validate = validate;
74
- formConfigContext.registerFieldValidation({
75
- name,
76
- type: "boolean",
77
- rules
78
- });
79
- return () => {
80
- formConfigContext.unregisterFieldValidation(name);
81
- };
82
- }
83
- }, [formConfigContext, name, required, validate]);
84
- const { field, fieldState } = reactHookForm.useController({
85
- name,
86
- control
87
- });
88
- const fieldError = fieldState.error?.message;
89
- const errorMessage = customError ?? fieldError;
90
- const hasError = !!errorMessage;
91
- const effectiveSize = size ?? formConfig.size ?? "md";
92
- const effectiveDisabled = disabled ?? formConfig.disabled;
93
- const effectiveVariant = hasError ? "error" : variant;
94
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1.5", children: [
95
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
96
- /* @__PURE__ */ jsxRuntime.jsx(
97
- checkbox.Checkbox,
98
- {
99
- ...props,
100
- ref,
101
- id: inputId,
102
- checked: field.value ?? false,
103
- onCheckedChange: (checked) => field.onChange(checked === true),
104
- onBlur: field.onBlur,
105
- disabled: effectiveDisabled,
106
- "aria-invalid": hasError,
107
- "aria-describedby": hasError ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
108
- className: cn.cn(
109
- checkboxSizeVariants({ size: effectiveSize }),
110
- effectiveVariant === "error" && "border-destructive",
111
- className
112
- )
113
- }
114
- ),
115
- label$1 && /* @__PURE__ */ jsxRuntime.jsx(
116
- label.Label,
117
- {
118
- htmlFor: inputId,
119
- className: labelVariants({ required: !!required, disabled: effectiveDisabled }),
120
- children: label$1
121
- }
122
- )
123
- ] }),
124
- showError && hasError && /* @__PURE__ */ jsxRuntime.jsx(
125
- "p",
126
- {
127
- id: `${inputId}-error`,
128
- className: "text-sm text-destructive ml-7",
129
- role: "alert",
130
- children: errorMessage
131
- }
132
- ),
133
- helperText && !hasError && /* @__PURE__ */ jsxRuntime.jsx(
134
- "p",
135
- {
136
- id: `${inputId}-helper`,
137
- className: "text-sm text-muted-foreground ml-7",
138
- children: helperText
139
- }
140
- )
141
- ] });
2
+ "use client";
3
+ const require_cn = require("../../utils/cn.cjs");
4
+ const require_context = require("./context.cjs");
5
+ const require_label = require("../../primitives/label.cjs");
6
+ const require_checkbox = require("../../primitives/checkbox.cjs");
7
+ let react = require("react");
8
+ let class_variance_authority = require("class-variance-authority");
9
+ let react_jsx_runtime = require("react/jsx-runtime");
10
+ let react_hook_form = require("react-hook-form");
11
+ //#region src/components/Form/Checkbox.tsx
12
+ var checkboxSizeVariants = (0, class_variance_authority.cva)("", {
13
+ variants: { size: {
14
+ sm: "h-4 w-4",
15
+ md: "h-5 w-5",
16
+ lg: "h-6 w-6"
17
+ } },
18
+ defaultVariants: { size: "md" }
19
+ });
20
+ var labelVariants = (0, class_variance_authority.cva)("text-sm font-medium cursor-pointer select-none", {
21
+ variants: {
22
+ required: {
23
+ true: "after:content-['*'] after:ml-0.5 after:text-destructive",
24
+ false: ""
25
+ },
26
+ disabled: {
27
+ true: "cursor-not-allowed opacity-50",
28
+ false: ""
29
+ }
30
+ },
31
+ defaultVariants: {
32
+ required: false,
33
+ disabled: false
34
+ }
35
+ });
36
+ /**
37
+ * Checkbox component with form integration
38
+ *
39
+ * This is a wrapper around the shadcn/ui Checkbox primitive that adds:
40
+ * - Form integration with react-hook-form
41
+ * - Automatic validation registration
42
+ * - Label, helper text, and error message support
43
+ *
44
+ * @example
45
+ * ```tsx
46
+ * // Inside a Form component
47
+ * <Checkbox name="terms" label="I agree to the terms and conditions" required />
48
+ * <Checkbox name="newsletter" label="Subscribe to newsletter" />
49
+ * ```
50
+ */
51
+ function CheckboxInner({ name, label, helperText, showError = true, error: customError, size, variant, className, disabled, id: providedId, control: externalControl, required, validate, ...props }, ref) {
52
+ const generatedId = (0, react.useId)();
53
+ const inputId = providedId ?? generatedId;
54
+ const formConfigContext = (0, react.useContext)(require_context.FormConfigContext);
55
+ const formConfig = formConfigContext ?? {};
56
+ const rhfContext = (0, react_hook_form.useFormContext)();
57
+ const control = externalControl ?? rhfContext?.control;
58
+ (0, react.useEffect)(() => {
59
+ if (formConfigContext?.registerFieldValidation) {
60
+ const rules = {};
61
+ if (required !== void 0) rules.required = required;
62
+ if (validate !== void 0) rules.validate = validate;
63
+ formConfigContext.registerFieldValidation({
64
+ name,
65
+ type: "boolean",
66
+ rules
67
+ });
68
+ return () => {
69
+ formConfigContext.unregisterFieldValidation(name);
70
+ };
71
+ }
72
+ }, [
73
+ formConfigContext,
74
+ name,
75
+ required,
76
+ validate
77
+ ]);
78
+ const { field, fieldState } = (0, react_hook_form.useController)({
79
+ name,
80
+ control
81
+ });
82
+ const fieldError = fieldState.error?.message;
83
+ const errorMessage = customError ?? fieldError;
84
+ const hasError = !!errorMessage;
85
+ const effectiveSize = size ?? formConfig.size ?? "md";
86
+ const effectiveDisabled = disabled ?? formConfig.disabled;
87
+ const effectiveVariant = hasError ? "error" : variant;
88
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
89
+ className: "space-y-1.5",
90
+ children: [
91
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
92
+ className: "flex items-center gap-2",
93
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_checkbox.Checkbox, {
94
+ ...props,
95
+ ref,
96
+ id: inputId,
97
+ checked: field.value ?? false,
98
+ onCheckedChange: (checked) => field.onChange(checked === true),
99
+ onBlur: field.onBlur,
100
+ disabled: effectiveDisabled,
101
+ "aria-invalid": hasError,
102
+ "aria-describedby": hasError ? `${inputId}-error` : helperText ? `${inputId}-helper` : void 0,
103
+ className: require_cn.cn(checkboxSizeVariants({ size: effectiveSize }), effectiveVariant === "error" && "border-destructive", className)
104
+ }), label && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_label.Label, {
105
+ htmlFor: inputId,
106
+ className: labelVariants({
107
+ required: !!required,
108
+ disabled: effectiveDisabled
109
+ }),
110
+ children: label
111
+ })]
112
+ }),
113
+ showError && hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
114
+ id: `${inputId}-error`,
115
+ className: "text-sm text-destructive ml-7",
116
+ role: "alert",
117
+ children: errorMessage
118
+ }),
119
+ helperText && !hasError && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
120
+ id: `${inputId}-helper`,
121
+ className: "text-sm text-muted-foreground ml-7",
122
+ children: helperText
123
+ })
124
+ ]
125
+ });
142
126
  }
143
- const Checkbox = React.forwardRef(CheckboxInner);
127
+ var Checkbox = (0, react.forwardRef)(CheckboxInner);
144
128
  Checkbox.displayName = "Checkbox";
129
+ //#endregion
145
130
  exports.Checkbox = Checkbox;
146
- //# sourceMappingURL=Checkbox.cjs.map
131
+
132
+ //# sourceMappingURL=Checkbox.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Checkbox.cjs","sources":["../../../../src/components/Form/Checkbox.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useId, useContext, useEffect } from \"react\";\nimport type { ReactNode, ComponentPropsWithoutRef } from \"react\";\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"../../utils/cn\";\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\nimport { Checkbox as ShadcnCheckbox } from \"../../primitives/checkbox\";\nimport { Label } from \"../../primitives/label\";\nimport type * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\n\nconst checkboxSizeVariants = cva(\n \"\",\n {\n variants: {\n size: {\n sm: \"h-4 w-4\",\n md: \"h-5 w-5\",\n lg: \"h-6 w-6\",\n },\n },\n defaultVariants: {\n size: \"md\",\n },\n }\n);\n\nconst labelVariants = cva(\n \"text-sm font-medium cursor-pointer select-none\",\n {\n variants: {\n required: {\n true: \"after:content-['*'] after:ml-0.5 after:text-destructive\",\n false: \"\",\n },\n disabled: {\n true: \"cursor-not-allowed opacity-50\",\n false: \"\",\n },\n },\n defaultVariants: {\n required: false,\n disabled: false,\n },\n }\n);\n\nexport interface CheckboxProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, \"name\" | \"checked\" | \"onCheckedChange\" | \"required\">,\n VariantProps<typeof checkboxSizeVariants> {\n /** Field name - required for form integration */\n name: TName;\n /** Label text for the checkbox */\n label?: ReactNode;\n /** Helper text displayed below the checkbox */\n helperText?: string;\n /** Whether to show the error message */\n showError?: boolean;\n /** Custom error message (overrides form error) */\n error?: string;\n /** External control (for use outside Form) */\n control?: Control<TFieldValues>;\n /** Variant style */\n variant?: \"default\" | \"error\";\n \n // Validation props\n /** Field is required (must be checked) */\n required?: boolean | string;\n /** Custom validation function */\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\n}\n\n/**\n * Checkbox component with form integration\n * \n * This is a wrapper around the shadcn/ui Checkbox primitive that adds:\n * - Form integration with react-hook-form\n * - Automatic validation registration\n * - Label, helper text, and error message support\n * \n * @example\n * ```tsx\n * // Inside a Form component\n * <Checkbox name=\"terms\" label=\"I agree to the terms and conditions\" required />\n * <Checkbox name=\"newsletter\" label=\"Subscribe to newsletter\" />\n * ```\n */\nfunction CheckboxInner<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>(\n {\n name,\n label,\n helperText,\n showError = true,\n error: customError,\n size,\n variant,\n className,\n disabled,\n id: providedId,\n control: externalControl,\n // Validation props\n required,\n validate,\n ...props\n }: CheckboxProps<TFieldValues, TName>,\n ref: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>>\n) {\n const generatedId = useId();\n const inputId = providedId ?? generatedId;\n \n // Try to get form context\n const formConfigContext = useContext(FormConfigContext);\n const formConfig: FormConfig = formConfigContext ?? {};\n \n // Get form context from react-hook-form\n const rhfContext = useRHFFormContext<TFieldValues>();\n const control = externalControl ?? rhfContext?.control;\n\n // Register validation rules with the form\n useEffect(() => {\n if (formConfigContext?.registerFieldValidation) {\n const rules: FieldValidationRules = {};\n \n if (required !== undefined) rules.required = required;\n if (validate !== undefined) rules.validate = validate;\n\n formConfigContext.registerFieldValidation({\n name: name as string,\n type: \"boolean\",\n rules,\n });\n\n return () => {\n formConfigContext.unregisterFieldValidation(name as string);\n };\n }\n }, [formConfigContext, name, required, validate]);\n\n // Use controller for form integration\n const { field, fieldState } = useController<TFieldValues, TName>({\n name,\n control,\n });\n\n const fieldError = fieldState.error?.message;\n const errorMessage = customError ?? fieldError;\n const hasError = !!errorMessage;\n \n // Merge sizes - prop takes precedence over form config\n const effectiveSize = size ?? formConfig.size ?? \"md\";\n const effectiveDisabled = disabled ?? formConfig.disabled;\n \n // Determine variant based on error state\n const effectiveVariant = hasError ? \"error\" : variant;\n\n return (\n <div className=\"space-y-1.5\">\n <div className=\"flex items-center gap-2\">\n <ShadcnCheckbox\n {...props}\n ref={ref}\n id={inputId}\n checked={field.value ?? false}\n onCheckedChange={(checked) => field.onChange(checked === true)}\n onBlur={field.onBlur}\n disabled={effectiveDisabled}\n aria-invalid={hasError}\n aria-describedby={\n hasError\n ? `${inputId}-error`\n : helperText\n ? `${inputId}-helper`\n : undefined\n }\n className={cn(\n checkboxSizeVariants({ size: effectiveSize }),\n effectiveVariant === \"error\" && \"border-destructive\",\n className\n )}\n />\n \n {label && (\n <Label\n htmlFor={inputId}\n className={labelVariants({ required: !!required, disabled: effectiveDisabled })}\n >\n {label}\n </Label>\n )}\n </div>\n\n {showError && hasError && (\n <p\n id={`${inputId}-error`}\n className=\"text-sm text-destructive ml-7\"\n role=\"alert\"\n >\n {errorMessage}\n </p>\n )}\n \n {helperText && !hasError && (\n <p\n id={`${inputId}-helper`}\n className=\"text-sm text-muted-foreground ml-7\"\n >\n {helperText}\n </p>\n )}\n </div>\n );\n}\n\n// Use forwardRef with generic support\nexport const Checkbox = forwardRef(CheckboxInner) as <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>(\n props: CheckboxProps<TFieldValues, TName> & { ref?: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>> }\n) => React.ReactElement;\n\n(Checkbox as React.FC).displayName = \"Checkbox\";\n"],"names":["cva","label","useId","useContext","FormConfigContext","useRHFFormContext","useEffect","useController","jsxs","jsx","ShadcnCheckbox","cn","Label","forwardRef"],"mappings":";;;;;;;;;;;AAYA,MAAM,uBAAuBA,uBAAAA;AAAAA,EAC3B;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,MAAM;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,QACJ,IAAI;AAAA,MAAA;AAAA,IACN;AAAA,IAEF,iBAAiB;AAAA,MACf,MAAM;AAAA,IAAA;AAAA,EACR;AAEJ;AAEA,MAAM,gBAAgBA,uBAAAA;AAAAA,EACpB;AAAA,EACA;AAAA,IACE,UAAU;AAAA,MACR,UAAU;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,MAET,UAAU;AAAA,QACR,MAAM;AAAA,QACN,OAAO;AAAA,MAAA;AAAA,IACT;AAAA,IAEF,iBAAiB;AAAA,MACf,UAAU;AAAA,MACV,UAAU;AAAA,IAAA;AAAA,EACZ;AAEJ;AA4CA,SAAS,cAIP;AAAA,EACE;AAAA,EAAA,OACAC;AAAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,OAAO;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,IAAI;AAAA,EACJ,SAAS;AAAA;AAAA,EAET;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,KACA;AACA,QAAM,cAAcC,MAAAA,MAAA;AACpB,QAAM,UAAU,cAAc;AAG9B,QAAM,oBAAoBC,MAAAA,WAAWC,yBAAiB;AACtD,QAAM,aAAyB,qBAAqB,CAAA;AAGpD,QAAM,aAAaC,cA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ACF;AAAA,MAAA;AAAA,MAGDV,WACCQ,2BAAAA;AAAAA,QAACG,MAAAA;AAAAA,QAAA;AAAA,UACC,SAAS;AAAA,UACT,WAAW,cAAc,EAAE,UAAU,CAAC,CAAC,UAAU,UAAU,mBAAmB;AAAA,UAE7E,UAAAX;AAAAA,QAAA;AAAA,MAAA;AAAA,IACH,GAEJ;AAAA,IAEC,aAAa,YACZQ,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,GAAG,OAAO;AAAA,QACd,WAAU;AAAA,QACV,MAAK;AAAA,QAEJ,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,IAIJ,cAAc,CAAC,YACdA,2BAAAA;AAAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAI,GAAG,OAAO;AAAA,QACd,WAAU;AAAA,QAET,UAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GAEJ;AAEJ;AAGO,MAAM,WAAWI,MAAAA,WAAW,aAAa;AAO/C,SAAsB,cAAc;;"}
1
+ {"version":3,"file":"Checkbox.cjs","names":[],"sources":["../../../../src/components/Form/Checkbox.tsx"],"sourcesContent":["'use client';\n\nimport { forwardRef, useId, useContext, useEffect } from \"react\";\nimport type { ReactNode, ComponentPropsWithoutRef } from \"react\";\nimport { useController, useFormContext as useRHFFormContext, type FieldValues, type FieldPath, type Control } from \"react-hook-form\";\nimport { cva, type VariantProps } from \"class-variance-authority\";\nimport { cn } from \"../../utils/cn\";\nimport { FormConfigContext, type FormConfig, type FieldValidationRules } from \"../Form/context\";\nimport { Checkbox as ShadcnCheckbox } from \"../../primitives/checkbox\";\nimport { Label } from \"../../primitives/label\";\nimport type * as CheckboxPrimitive from \"@radix-ui/react-checkbox\";\n\nconst checkboxSizeVariants = cva(\n \"\",\n {\n variants: {\n size: {\n sm: \"h-4 w-4\",\n md: \"h-5 w-5\",\n lg: \"h-6 w-6\",\n },\n },\n defaultVariants: {\n size: \"md\",\n },\n }\n);\n\nconst labelVariants = cva(\n \"text-sm font-medium cursor-pointer select-none\",\n {\n variants: {\n required: {\n true: \"after:content-['*'] after:ml-0.5 after:text-destructive\",\n false: \"\",\n },\n disabled: {\n true: \"cursor-not-allowed opacity-50\",\n false: \"\",\n },\n },\n defaultVariants: {\n required: false,\n disabled: false,\n },\n }\n);\n\nexport interface CheckboxProps<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n> extends Omit<ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>, \"name\" | \"checked\" | \"onCheckedChange\" | \"required\">,\n VariantProps<typeof checkboxSizeVariants> {\n /** Field name - required for form integration */\n name: TName;\n /** Label text for the checkbox */\n label?: ReactNode;\n /** Helper text displayed below the checkbox */\n helperText?: string;\n /** Whether to show the error message */\n showError?: boolean;\n /** Custom error message (overrides form error) */\n error?: string;\n /** External control (for use outside Form) */\n control?: Control<TFieldValues>;\n /** Variant style */\n variant?: \"default\" | \"error\";\n \n // Validation props\n /** Field is required (must be checked) */\n required?: boolean | string;\n /** Custom validation function */\n validate?: (value: unknown) => boolean | string | Promise<boolean | string>;\n}\n\n/**\n * Checkbox component with form integration\n * \n * This is a wrapper around the shadcn/ui Checkbox primitive that adds:\n * - Form integration with react-hook-form\n * - Automatic validation registration\n * - Label, helper text, and error message support\n * \n * @example\n * ```tsx\n * // Inside a Form component\n * <Checkbox name=\"terms\" label=\"I agree to the terms and conditions\" required />\n * <Checkbox name=\"newsletter\" label=\"Subscribe to newsletter\" />\n * ```\n */\nfunction CheckboxInner<\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>(\n {\n name,\n label,\n helperText,\n showError = true,\n error: customError,\n size,\n variant,\n className,\n disabled,\n id: providedId,\n control: externalControl,\n // Validation props\n required,\n validate,\n ...props\n }: CheckboxProps<TFieldValues, TName>,\n ref: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>>\n) {\n const generatedId = useId();\n const inputId = providedId ?? generatedId;\n \n // Try to get form context\n const formConfigContext = useContext(FormConfigContext);\n const formConfig: FormConfig = formConfigContext ?? {};\n \n // Get form context from react-hook-form\n const rhfContext = useRHFFormContext<TFieldValues>();\n const control = externalControl ?? rhfContext?.control;\n\n // Register validation rules with the form\n useEffect(() => {\n if (formConfigContext?.registerFieldValidation) {\n const rules: FieldValidationRules = {};\n \n if (required !== undefined) rules.required = required;\n if (validate !== undefined) rules.validate = validate;\n\n formConfigContext.registerFieldValidation({\n name: name as string,\n type: \"boolean\",\n rules,\n });\n\n return () => {\n formConfigContext.unregisterFieldValidation(name as string);\n };\n }\n }, [formConfigContext, name, required, validate]);\n\n // Use controller for form integration\n const { field, fieldState } = useController<TFieldValues, TName>({\n name,\n control,\n });\n\n const fieldError = fieldState.error?.message;\n const errorMessage = customError ?? fieldError;\n const hasError = !!errorMessage;\n \n // Merge sizes - prop takes precedence over form config\n const effectiveSize = size ?? formConfig.size ?? \"md\";\n const effectiveDisabled = disabled ?? formConfig.disabled;\n \n // Determine variant based on error state\n const effectiveVariant = hasError ? \"error\" : variant;\n\n return (\n <div className=\"space-y-1.5\">\n <div className=\"flex items-center gap-2\">\n <ShadcnCheckbox\n {...props}\n ref={ref}\n id={inputId}\n checked={field.value ?? false}\n onCheckedChange={(checked) => field.onChange(checked === true)}\n onBlur={field.onBlur}\n disabled={effectiveDisabled}\n aria-invalid={hasError}\n aria-describedby={\n hasError\n ? `${inputId}-error`\n : helperText\n ? `${inputId}-helper`\n : undefined\n }\n className={cn(\n checkboxSizeVariants({ size: effectiveSize }),\n effectiveVariant === \"error\" && \"border-destructive\",\n className\n )}\n />\n \n {label && (\n <Label\n htmlFor={inputId}\n className={labelVariants({ required: !!required, disabled: effectiveDisabled })}\n >\n {label}\n </Label>\n )}\n </div>\n\n {showError && hasError && (\n <p\n id={`${inputId}-error`}\n className=\"text-sm text-destructive ml-7\"\n role=\"alert\"\n >\n {errorMessage}\n </p>\n )}\n \n {helperText && !hasError && (\n <p\n id={`${inputId}-helper`}\n className=\"text-sm text-muted-foreground ml-7\"\n >\n {helperText}\n </p>\n )}\n </div>\n );\n}\n\n// Use forwardRef with generic support\nexport const Checkbox = forwardRef(CheckboxInner) as <\n TFieldValues extends FieldValues = FieldValues,\n TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>\n>(\n props: CheckboxProps<TFieldValues, TName> & { ref?: React.ForwardedRef<React.ElementRef<typeof CheckboxPrimitive.Root>> }\n) => React.ReactElement;\n\n(Checkbox as React.FC).displayName = \"Checkbox\";\n"],"mappings":";;;;;;;;;;;AAYA,IAAM,wBAAA,GAAA,yBAAA,IAAA,CACJ,IACA;CACE,UAAU,EACR,MAAM;EACJ,IAAI;EACJ,IAAI;EACJ,IAAI;CACN,EACF;CACA,iBAAiB,EACf,MAAM,KACR;AACF,CACF;AAEA,IAAM,iBAAA,GAAA,yBAAA,IAAA,CACJ,kDACA;CACE,UAAU;EACR,UAAU;GACR,MAAM;GACN,OAAO;EACT;EACA,UAAU;GACR,MAAM;GACN,OAAO;EACT;CACF;CACA,iBAAiB;EACf,UAAU;EACV,UAAU;CACZ;AACF,CACF;;;;;;;;;;;;;;;;AA4CA,SAAS,cAIP,EACE,MACA,OACA,YACA,YAAY,MACZ,OAAO,aACP,MACA,SACA,WACA,UACA,IAAI,YACJ,SAAS,iBAET,UACA,UACA,GAAG,SAEL,KACA;CACA,MAAM,eAAA,GAAA,MAAA,MAAA,CAAoB;CAC1B,MAAM,UAAU,cAAc;CAG9B,MAAM,qBAAA,GAAA,MAAA,WAAA,CAA+B,gBAAA,iBAAiB;CACtD,MAAM,aAAyB,qBAAqB,CAAC;CAGrD,MAAM,cAAA,GAAA,gBAAA,eAAA,CAA6C;CACnD,MAAM,UAAU,mBAAmB,YAAY;CAG/C,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,mBAAmB,yBAAyB;GAC9C,MAAM,QAA8B,CAAC;GAErC,IAAI,aAAa,KAAA,GAAW,MAAM,WAAW;G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GAGJ,cAAc,CAAC,YACd,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;IACE,IAAI,GAAG,QAAQ;IACf,WAAU;cAET;GACA,CAAA;EAEF;;AAET;AAGA,IAAa,YAAA,GAAA,MAAA,WAAA,CAAsB,aAAa;AAOhD,SAAuB,cAAc"}
@@ -1,109 +1,110 @@
1
1
  "use client";
2
- "use strict";
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const jsxRuntime = require("react/jsx-runtime");
5
- const React = require("react");
6
- const reactHookForm = require("react-hook-form");
7
- const zod$1 = require("@hookform/resolvers/zod");
8
- const zod = require("zod");
9
- const context = require("./context.cjs");
10
- function Form({
11
- schema: baseSchema,
12
- defaultValues,
13
- values,
14
- onSubmit,
15
- onError,
16
- config,
17
- children,
18
- form: externalForm,
19
- mode = "onBlur",
20
- reValidateMode = "onChange",
21
- resolver: customResolver,
22
- ...formProps
23
- }) {
24
- const mergedConfig = { ...context.defaultFormConfig, ...config };
25
- const {
26
- registerFieldValidation,
27
- unregisterFieldValidation,
28
- getValidationSchema
29
- } = context.useFieldValidationRegistry();
30
- const dynamicResolver = React.useCallback(
31
- async (vals, context2, options) => {
32
- if (customResolver) {
33
- return customResolver(vals, context2, options);
34
- }
35
- const fieldSchema = getValidationSchema();
36
- let finalSchema;
37
- if (baseSchema instanceof zod.z.ZodObject) {
38
- finalSchema = baseSchema.merge(fieldSchema);
39
- } else {
40
- finalSchema = baseSchema ?? fieldSchema;
41
- }
42
- return zod$1.zodResolver(finalSchema)(vals, context2, options);
43
- },
44
- // getValidationSchema reads a ref — always current, intentionally omitted.
45
- // eslint-disable-next-line react-hooks/exhaustive-deps
46
- [baseSchema, customResolver]
47
- );
48
- const internalForm = reactHookForm.useForm({
49
- resolver: dynamicResolver,
50
- defaultValues,
51
- values,
52
- mode,
53
- reValidateMode
54
- });
55
- const form = externalForm ?? internalForm;
56
- const triggerValidation = React.useCallback(async (name) => {
57
- return form.trigger(name);
58
- }, [form]);
59
- const handleSubmit = (e) => {
60
- e.preventDefault();
61
- if (onSubmit) {
62
- form.handleSubmit(onSubmit, onError)(e);
63
- }
64
- };
65
- const contextValue = React.useMemo(
66
- () => ({
67
- form,
68
- registerFieldValidation,
69
- unregisterFieldValidation,
70
- getValidationSchema,
71
- triggerValidation,
72
- showInlineErrors: mergedConfig.showInlineErrors,
73
- validateOnBlur: mergedConfig.validateOnBlur,
74
- validateOnChange: mergedConfig.validateOnChange,
75
- size: mergedConfig.size,
76
- layout: mergedConfig.layout,
77
- labelWidth: mergedConfig.labelWidth,
78
- disabled: mergedConfig.disabled,
79
- colon: mergedConfig.colon
80
- }),
81
- [
82
- form,
83
- registerFieldValidation,
84
- unregisterFieldValidation,
85
- getValidationSchema,
86
- triggerValidation,
87
- mergedConfig.showInlineErrors,
88
- mergedConfig.validateOnBlur,
89
- mergedConfig.validateOnChange,
90
- mergedConfig.size,
91
- mergedConfig.layout,
92
- mergedConfig.labelWidth,
93
- mergedConfig.disabled,
94
- mergedConfig.colon
95
- ]
96
- );
97
- return /* @__PURE__ */ jsxRuntime.jsx(context.FormConfigContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: /* @__PURE__ */ jsxRuntime.jsx(
98
- "form",
99
- {
100
- ...formProps,
101
- onSubmit: handleSubmit,
102
- noValidate: true,
103
- children
104
- }
105
- ) }) });
2
+ "use client";
3
+ const require_context = require("./context.cjs");
4
+ let react = require("react");
5
+ let react_jsx_runtime = require("react/jsx-runtime");
6
+ let react_hook_form = require("react-hook-form");
7
+ let _hookform_resolvers_zod = require("@hookform/resolvers/zod");
8
+ let zod = require("zod");
9
+ //#region src/components/Form/Form.tsx
10
+ /**
11
+ * Form component that provides form context and validation
12
+ *
13
+ * Child components like TextBox can register their validation rules automatically.
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * // Validation is automatically built from component props
18
+ * <Form onSubmit={handleSubmit} defaultValues={{ username: "", email: "" }}>
19
+ * <TextBox name="username" label="Username" required minLength={3} maxLength={50} />
20
+ * <TextBox name="email" label="Email" type="email" required email />
21
+ * <Button type="submit">Submit</Button>
22
+ * </Form>
23
+ *
24
+ * // Or with a base schema that gets extended
25
+ * const baseSchema = z.object({
26
+ * username: z.string(),
27
+ * email: z.string(),
28
+ * });
29
+ *
30
+ * <Form schema={baseSchema} onSubmit={handleSubmit}>
31
+ * <TextBox name="username" required minLength={3} /> // Adds required + minLength
32
+ * <TextBox name="email" required email /> // Adds required + email validation
33
+ * </Form>
34
+ * ```
35
+ */
36
+ function Form({ schema: baseSchema, defaultValues, values, onSubmit, onError, config, children, form: externalForm, mode = "onBlur", reValidateMode = "onChange", resolver: customResolver, ...formProps }) {
37
+ const mergedConfig = {
38
+ ...require_context.defaultFormConfig,
39
+ ...config
40
+ };
41
+ const { registerFieldValidation, unregisterFieldValidation, getValidationSchema } = require_context.useFieldValidationRegistry();
42
+ const internalForm = (0, react_hook_form.useForm)({
43
+ resolver: (0, react.useCallback)(async (vals, context, options) => {
44
+ if (customResolver) return customResolver(vals, context, options);
45
+ const fieldSchema = getValidationSchema();
46
+ let finalSchema;
47
+ if (baseSchema instanceof zod.z.ZodObject) finalSchema = baseSchema.merge(fieldSchema);
48
+ else finalSchema = baseSchema ?? fieldSchema;
49
+ return (0, _hookform_resolvers_zod.zodResolver)(finalSchema)(vals, context, options);
50
+ }, [baseSchema, customResolver]),
51
+ defaultValues,
52
+ values,
53
+ mode,
54
+ reValidateMode
55
+ });
56
+ const form = externalForm ?? internalForm;
57
+ const triggerValidation = (0, react.useCallback)(async (name) => {
58
+ return form.trigger(name);
59
+ }, [form]);
60
+ const handleSubmit = (e) => {
61
+ e.preventDefault();
62
+ if (onSubmit) form.handleSubmit(onSubmit, onError)(e);
63
+ };
64
+ const contextValue = (0, react.useMemo)(() => ({
65
+ form,
66
+ registerFieldValidation,
67
+ unregisterFieldValidation,
68
+ getValidationSchema,
69
+ triggerValidation,
70
+ showInlineErrors: mergedConfig.showInlineErrors,
71
+ validateOnBlur: mergedConfig.validateOnBlur,
72
+ validateOnChange: mergedConfig.validateOnChange,
73
+ size: mergedConfig.size,
74
+ layout: mergedConfig.layout,
75
+ labelWidth: mergedConfig.labelWidth,
76
+ disabled: mergedConfig.disabled,
77
+ colon: mergedConfig.colon
78
+ }), [
79
+ form,
80
+ registerFieldValidation,
81
+ unregisterFieldValidation,
82
+ getValidationSchema,
83
+ triggerValidation,
84
+ mergedConfig.showInlineErrors,
85
+ mergedConfig.validateOnBlur,
86
+ mergedConfig.validateOnChange,
87
+ mergedConfig.size,
88
+ mergedConfig.layout,
89
+ mergedConfig.labelWidth,
90
+ mergedConfig.disabled,
91
+ mergedConfig.colon
92
+ ]);
93
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_context.FormConfigContext.Provider, {
94
+ value: contextValue,
95
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_hook_form.FormProvider, {
96
+ ...form,
97
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
98
+ ...formProps,
99
+ onSubmit: handleSubmit,
100
+ noValidate: true,
101
+ children
102
+ })
103
+ })
104
+ });
106
105
  }
107
106
  Form.displayName = "Form";
107
+ //#endregion
108
108
  exports.Form = Form;
109
- //# sourceMappingURL=Form.cjs.map
109
+
110
+ //# sourceMappingURL=Form.cjs.map