ivt 0.3.3 → 0.3.5

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 (257) hide show
  1. package/dist/accordion/index.mjs +19 -1
  2. package/dist/accordion/index.mjs.map +1 -1
  3. package/dist/alert/index.mjs +43 -1
  4. package/dist/alert/index.mjs.map +1 -1
  5. package/dist/alert-dialog/index.mjs +260 -1
  6. package/dist/alert-dialog/index.mjs.map +1 -1
  7. package/dist/avatar/index.mjs +164 -1
  8. package/dist/avatar/index.mjs.map +1 -1
  9. package/dist/badge/index.mjs +6 -1
  10. package/dist/badge/index.mjs.map +1 -1
  11. package/dist/base/index.mjs +760 -1
  12. package/dist/base/index.mjs.map +1 -1
  13. package/dist/button/index.mjs +6 -1
  14. package/dist/button/index.mjs.map +1 -1
  15. package/dist/calendar/index.mjs +11 -1
  16. package/dist/calendar/index.mjs.map +1 -1
  17. package/dist/card/index.mjs +55 -1
  18. package/dist/card/index.mjs.map +1 -1
  19. package/dist/chart/index.mjs +16696 -1
  20. package/dist/chart/index.mjs.map +1 -1
  21. package/dist/checkbox/index.mjs +223 -1
  22. package/dist/checkbox/index.mjs.map +1 -1
  23. package/dist/chunks/_commonjsHelpers-DKISyIRi.mjs +6 -0
  24. package/dist/chunks/_commonjsHelpers-DKISyIRi.mjs.map +1 -0
  25. package/dist/chunks/accordion-CK9Ucbko.mjs +455 -0
  26. package/dist/chunks/{accordion-CdshDFZC.mjs.map → accordion-CK9Ucbko.mjs.map} +1 -1
  27. package/dist/chunks/badge-CT_hmjd2.mjs +57 -0
  28. package/dist/chunks/{badge-BYqshEmA.mjs.map → badge-CT_hmjd2.mjs.map} +1 -1
  29. package/dist/chunks/bundle-mjs-CS-QKnOm.mjs +4491 -0
  30. package/dist/chunks/{bundle-mjs-9BXytT_r.mjs.map → bundle-mjs-CS-QKnOm.mjs.map} +1 -1
  31. package/dist/chunks/button-BHeYV17S.mjs +47 -0
  32. package/dist/chunks/{button-DrFZXJ7z.mjs.map → button-BHeYV17S.mjs.map} +1 -1
  33. package/dist/chunks/calendar-CU6HdJET.mjs +7106 -0
  34. package/dist/chunks/calendar-CU6HdJET.mjs.map +1 -0
  35. package/dist/chunks/check-B3pXhibW.mjs +15 -0
  36. package/dist/chunks/{check-CimnOyD7.mjs.map → check-B3pXhibW.mjs.map} +1 -1
  37. package/dist/chunks/chevron-down-BV5gvmUW.mjs +15 -0
  38. package/dist/chunks/{chevron-down-D3fvbjxE.mjs.map → chevron-down-BV5gvmUW.mjs.map} +1 -1
  39. package/dist/chunks/chevron-left-BjGcH2KQ.mjs +15 -0
  40. package/dist/chunks/{chevron-left-CrN7DlXg.mjs.map → chevron-left-BjGcH2KQ.mjs.map} +1 -1
  41. package/dist/chunks/chevron-right-DmZu0xvo.mjs +15 -0
  42. package/dist/chunks/{chevron-right-BMSCuDGK.mjs.map → chevron-right-DmZu0xvo.mjs.map} +1 -1
  43. package/dist/chunks/chevrons-up-down-COuCmfU7.mjs +22 -0
  44. package/dist/chunks/{chevrons-up-down-DBgvRkZm.mjs.map → chevrons-up-down-COuCmfU7.mjs.map} +1 -1
  45. package/dist/chunks/circle-BKsPjIbw.mjs +17 -0
  46. package/dist/chunks/{circle-CGqt18Bd.mjs.map → circle-BKsPjIbw.mjs.map} +1 -1
  47. package/dist/chunks/command-CUWr3X1X.mjs +611 -0
  48. package/dist/chunks/command-CUWr3X1X.mjs.map +1 -0
  49. package/dist/chunks/createLucideIcon-BSP_Jxu-.mjs +60 -0
  50. package/dist/chunks/{createLucideIcon-L-tld2uc.mjs.map → createLucideIcon-BSP_Jxu-.mjs.map} +1 -1
  51. package/dist/chunks/dialog-zZCazow7.mjs +80 -0
  52. package/dist/chunks/{dialog-36eqHzT3.mjs.map → dialog-zZCazow7.mjs.map} +1 -1
  53. package/dist/chunks/hover-card-C6WPsacG.mjs +274 -0
  54. package/dist/chunks/{hover-card-Cnd58du6.mjs.map → hover-card-C6WPsacG.mjs.map} +1 -1
  55. package/dist/chunks/index-3XcV7C7l.mjs +324 -0
  56. package/dist/chunks/{index-DUNcuWJE.mjs.map → index-3XcV7C7l.mjs.map} +1 -1
  57. package/dist/chunks/index-B1VVz0MP.mjs +266 -0
  58. package/dist/chunks/index-B1VVz0MP.mjs.map +1 -0
  59. package/dist/chunks/index-BFDafXar.mjs +2370 -0
  60. package/dist/chunks/index-BFDafXar.mjs.map +1 -0
  61. package/dist/chunks/index-BF_TaONY.mjs +859 -0
  62. package/dist/chunks/{index-DZHMFdr0.mjs.map → index-BF_TaONY.mjs.map} +1 -1
  63. package/dist/chunks/index-BOOPeiVs.mjs +34 -0
  64. package/dist/chunks/{index-D2sZp5OP.mjs.map → index-BOOPeiVs.mjs.map} +1 -1
  65. package/dist/chunks/index-BYijxgZz.mjs +12 -0
  66. package/dist/chunks/index-BYijxgZz.mjs.map +1 -0
  67. package/dist/chunks/index-BZyzz9k8.mjs +40 -0
  68. package/dist/chunks/index-BZyzz9k8.mjs.map +1 -0
  69. package/dist/chunks/index-Bgiaprdv.mjs +7 -0
  70. package/dist/chunks/{index-CLtWFQL5.mjs.map → index-Bgiaprdv.mjs.map} +1 -1
  71. package/dist/chunks/index-Bl6nVRXe.mjs +110 -0
  72. package/dist/chunks/{index-CCcl327A.mjs.map → index-Bl6nVRXe.mjs.map} +1 -1
  73. package/dist/chunks/index-BwQDLVf8.mjs +151 -0
  74. package/dist/chunks/index-BwQDLVf8.mjs.map +1 -0
  75. package/dist/chunks/index-CHyZo-Tj.mjs +1210 -0
  76. package/dist/chunks/index-CHyZo-Tj.mjs.map +1 -0
  77. package/dist/chunks/index-CZ7Wntp7.mjs +21 -0
  78. package/dist/chunks/index-CZ7Wntp7.mjs.map +1 -0
  79. package/dist/chunks/index-D1yPZAOL.mjs +13 -0
  80. package/dist/chunks/{index-CXszXOf_.mjs.map → index-D1yPZAOL.mjs.map} +1 -1
  81. package/dist/chunks/index-DIBl7n6R.mjs +145 -0
  82. package/dist/chunks/index-DIBl7n6R.mjs.map +1 -0
  83. package/dist/chunks/index-DRk0bB4A.mjs +216 -0
  84. package/dist/chunks/{index-LvOFIVGz.mjs.map → index-DRk0bB4A.mjs.map} +1 -1
  85. package/dist/chunks/index-DUFr75Kc.mjs +77 -0
  86. package/dist/chunks/{index-CybgQKpz.mjs.map → index-DUFr75Kc.mjs.map} +1 -1
  87. package/dist/chunks/index-DrnQ43fz.mjs +18 -0
  88. package/dist/chunks/{index-CRxQlsb9.mjs.map → index-DrnQ43fz.mjs.map} +1 -1
  89. package/dist/chunks/index-Dulm0stf.mjs +12 -0
  90. package/dist/chunks/{index-CU_y1XAz.mjs.map → index-Dulm0stf.mjs.map} +1 -1
  91. package/dist/chunks/index-fWnSEyU5.mjs +50 -0
  92. package/dist/chunks/{index-w9bxia3O.mjs.map → index-fWnSEyU5.mjs.map} +1 -1
  93. package/dist/chunks/index-tNc5GmLL.mjs +51 -0
  94. package/dist/chunks/{index-vmPXTidH.mjs.map → index-tNc5GmLL.mjs.map} +1 -1
  95. package/dist/chunks/input-D9-FhnGc.mjs +14 -0
  96. package/dist/chunks/{input-85UFztMJ.mjs.map → input-D9-FhnGc.mjs.map} +1 -1
  97. package/dist/chunks/label-CiJcd2F9.mjs +32 -0
  98. package/dist/chunks/{label-CICFzZIt.mjs.map → label-CiJcd2F9.mjs.map} +1 -1
  99. package/dist/chunks/pagination-SOhqOW7I.mjs +106 -0
  100. package/dist/chunks/{pagination-CReDQes6.mjs.map → pagination-SOhqOW7I.mjs.map} +1 -1
  101. package/dist/chunks/popover-WlYXFyUl.mjs +308 -0
  102. package/dist/chunks/{popover-Cn2ZTvKd.mjs.map → popover-WlYXFyUl.mjs.map} +1 -1
  103. package/dist/chunks/progress-DdBZJTQG.mjs +99 -0
  104. package/dist/chunks/{progress-CSxQH6-f.mjs.map → progress-DdBZJTQG.mjs.map} +1 -1
  105. package/dist/chunks/scroll-area-B2wNbBRR.mjs +791 -0
  106. package/dist/chunks/scroll-area-B2wNbBRR.mjs.map +1 -0
  107. package/dist/chunks/select-COGYOg3A.mjs +104 -0
  108. package/dist/chunks/{select-BR6_N_Yo.mjs.map → select-COGYOg3A.mjs.map} +1 -1
  109. package/dist/chunks/separator-D6Y96f4g.mjs +48 -0
  110. package/dist/chunks/{separator-BB6-E9Z1.mjs.map → separator-D6Y96f4g.mjs.map} +1 -1
  111. package/dist/chunks/skeleton-CRfBAk8U.mjs +13 -0
  112. package/dist/chunks/{skeleton-XPWWiaac.mjs.map → skeleton-CRfBAk8U.mjs.map} +1 -1
  113. package/dist/chunks/sortable-tiuZWf3S.mjs +4221 -0
  114. package/dist/chunks/sortable-tiuZWf3S.mjs.map +1 -0
  115. package/dist/chunks/table-BlTF56Yn.mjs +62 -0
  116. package/dist/chunks/{table-LQIHzPHi.mjs.map → table-BlTF56Yn.mjs.map} +1 -1
  117. package/dist/chunks/toggle-D5tCYA7L.mjs +65 -0
  118. package/dist/chunks/{toggle-Co72WXGd.mjs.map → toggle-D5tCYA7L.mjs.map} +1 -1
  119. package/dist/chunks/tooltip-BpTMPR5Q.mjs +596 -0
  120. package/dist/chunks/{tooltip-qX2HjdJP.mjs.map → tooltip-BpTMPR5Q.mjs.map} +1 -1
  121. package/dist/chunks/tslib.es6-O3UsmxNe.mjs +61 -0
  122. package/dist/chunks/{tslib.es6-cMGqxriw.mjs.map → tslib.es6-O3UsmxNe.mjs.map} +1 -1
  123. package/dist/chunks/utils-tbIgc9YG.mjs +42 -0
  124. package/dist/chunks/utils-tbIgc9YG.mjs.map +1 -0
  125. package/dist/chunks/x-5oL4uC6I.mjs +22 -0
  126. package/dist/chunks/{x-BNLl0E-E.mjs.map → x-5oL4uC6I.mjs.map} +1 -1
  127. package/dist/combobox/index.mjs +65 -1
  128. package/dist/combobox/index.mjs.map +1 -1
  129. package/dist/command/index.mjs +23 -1
  130. package/dist/command/index.mjs.map +1 -1
  131. package/dist/data-table/index.mjs +673 -1
  132. package/dist/data-table/index.mjs.map +1 -1
  133. package/dist/dialog/index.mjs +22 -1
  134. package/dist/dialog/index.mjs.map +1 -1
  135. package/dist/dropdown-menu/index.mjs +438 -1
  136. package/dist/dropdown-menu/index.mjs.map +1 -1
  137. package/dist/dropzone/index.mjs +7839 -1
  138. package/dist/dropzone/index.mjs.map +1 -1
  139. package/dist/form/index.mjs +649 -1
  140. package/dist/form/index.mjs.map +1 -1
  141. package/dist/hover-card/index.mjs +18 -1
  142. package/dist/hover-card/index.mjs.map +1 -1
  143. package/dist/icon/index.mjs +317 -1
  144. package/dist/icon/index.mjs.map +1 -1
  145. package/dist/index.css +1 -1
  146. package/dist/input/index.mjs +4 -1
  147. package/dist/input/index.mjs.map +1 -1
  148. package/dist/ivt.css +1 -1
  149. package/dist/label/index.mjs +8 -1
  150. package/dist/label/index.mjs.map +1 -1
  151. package/dist/menubar/index.mjs +583 -1
  152. package/dist/menubar/index.mjs.map +1 -1
  153. package/dist/multi-select/index.mjs +297 -1
  154. package/dist/multi-select/index.mjs.map +1 -1
  155. package/dist/pagination/index.mjs +10 -1
  156. package/dist/pagination/index.mjs.map +1 -1
  157. package/dist/popover/index.mjs +21 -1
  158. package/dist/popover/index.mjs.map +1 -1
  159. package/dist/progress/index.mjs +9 -1
  160. package/dist/progress/index.mjs.map +1 -1
  161. package/dist/radio-group/index.mjs +267 -1
  162. package/dist/radio-group/index.mjs.map +1 -1
  163. package/dist/scroll-area/index.mjs +15 -1
  164. package/dist/scroll-area/index.mjs.map +1 -1
  165. package/dist/select/index.mjs +8 -1
  166. package/dist/select/index.mjs.map +1 -1
  167. package/dist/separator/index.mjs +8 -1
  168. package/dist/separator/index.mjs.map +1 -1
  169. package/dist/sheet/index.mjs +96 -1
  170. package/dist/sheet/index.mjs.map +1 -1
  171. package/dist/skeleton/index.mjs +4 -1
  172. package/dist/skeleton/index.mjs.map +1 -1
  173. package/dist/sonner/index.mjs +1140 -1
  174. package/dist/sonner/index.mjs.map +1 -1
  175. package/dist/sortable/index.mjs +8 -1
  176. package/dist/sortable/index.mjs.map +1 -1
  177. package/dist/table/index.mjs +4 -1
  178. package/dist/table/index.mjs.map +1 -1
  179. package/dist/tabs/index.mjs +193 -1
  180. package/dist/tabs/index.mjs.map +1 -1
  181. package/dist/textarea/index.mjs +13 -1
  182. package/dist/textarea/index.mjs.map +1 -1
  183. package/dist/toast/index.mjs +705 -1
  184. package/dist/toast/index.mjs.map +1 -1
  185. package/dist/toggle/index.mjs +12 -1
  186. package/dist/toggle/index.mjs.map +1 -1
  187. package/dist/toggle-group/index.mjs +219 -1
  188. package/dist/toggle-group/index.mjs.map +1 -1
  189. package/dist/tooltip/index.mjs +20 -1
  190. package/dist/tooltip/index.mjs.map +1 -1
  191. package/package.json +6 -5
  192. package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs +0 -2
  193. package/dist/chunks/_commonjsHelpers-6qLFzZa5.mjs.map +0 -1
  194. package/dist/chunks/accordion-CdshDFZC.mjs +0 -2
  195. package/dist/chunks/badge-BYqshEmA.mjs +0 -2
  196. package/dist/chunks/bundle-mjs-9BXytT_r.mjs +0 -2
  197. package/dist/chunks/button-DrFZXJ7z.mjs +0 -2
  198. package/dist/chunks/calendar-BY6t8wdJ.mjs +0 -2
  199. package/dist/chunks/calendar-BY6t8wdJ.mjs.map +0 -1
  200. package/dist/chunks/check-CimnOyD7.mjs +0 -2
  201. package/dist/chunks/chevron-down-D3fvbjxE.mjs +0 -2
  202. package/dist/chunks/chevron-left-CrN7DlXg.mjs +0 -2
  203. package/dist/chunks/chevron-right-BMSCuDGK.mjs +0 -2
  204. package/dist/chunks/chevrons-up-down-DBgvRkZm.mjs +0 -2
  205. package/dist/chunks/circle-CGqt18Bd.mjs +0 -2
  206. package/dist/chunks/command-C6ON-ciq.mjs +0 -2
  207. package/dist/chunks/command-C6ON-ciq.mjs.map +0 -1
  208. package/dist/chunks/createLucideIcon-L-tld2uc.mjs +0 -2
  209. package/dist/chunks/dialog-36eqHzT3.mjs +0 -2
  210. package/dist/chunks/hover-card-Cnd58du6.mjs +0 -2
  211. package/dist/chunks/index-B4QsDzeM.mjs +0 -2
  212. package/dist/chunks/index-B4QsDzeM.mjs.map +0 -1
  213. package/dist/chunks/index-BdpYc58_.mjs +0 -2
  214. package/dist/chunks/index-BdpYc58_.mjs.map +0 -1
  215. package/dist/chunks/index-CCcl327A.mjs +0 -2
  216. package/dist/chunks/index-CLtWFQL5.mjs +0 -2
  217. package/dist/chunks/index-COvW87ew.mjs +0 -2
  218. package/dist/chunks/index-COvW87ew.mjs.map +0 -1
  219. package/dist/chunks/index-CRxQlsb9.mjs +0 -2
  220. package/dist/chunks/index-CU_y1XAz.mjs +0 -2
  221. package/dist/chunks/index-CXszXOf_.mjs +0 -2
  222. package/dist/chunks/index-CdJCOoFA.mjs +0 -2
  223. package/dist/chunks/index-CdJCOoFA.mjs.map +0 -1
  224. package/dist/chunks/index-Cpq7N5Ej.mjs +0 -2
  225. package/dist/chunks/index-Cpq7N5Ej.mjs.map +0 -1
  226. package/dist/chunks/index-CybgQKpz.mjs +0 -2
  227. package/dist/chunks/index-D2sZp5OP.mjs +0 -2
  228. package/dist/chunks/index-DOyt-JEx.mjs +0 -2
  229. package/dist/chunks/index-DOyt-JEx.mjs.map +0 -1
  230. package/dist/chunks/index-DUNcuWJE.mjs +0 -2
  231. package/dist/chunks/index-DZHMFdr0.mjs +0 -2
  232. package/dist/chunks/index-LvOFIVGz.mjs +0 -2
  233. package/dist/chunks/index-lvPXnk5F.mjs +0 -2
  234. package/dist/chunks/index-lvPXnk5F.mjs.map +0 -1
  235. package/dist/chunks/index-vmPXTidH.mjs +0 -2
  236. package/dist/chunks/index-w9bxia3O.mjs +0 -2
  237. package/dist/chunks/index-xew3kygQ.mjs +0 -2
  238. package/dist/chunks/index-xew3kygQ.mjs.map +0 -1
  239. package/dist/chunks/input-85UFztMJ.mjs +0 -2
  240. package/dist/chunks/label-CICFzZIt.mjs +0 -2
  241. package/dist/chunks/pagination-CReDQes6.mjs +0 -2
  242. package/dist/chunks/popover-Cn2ZTvKd.mjs +0 -2
  243. package/dist/chunks/progress-CSxQH6-f.mjs +0 -2
  244. package/dist/chunks/scroll-area-CvCz7cL_.mjs +0 -2
  245. package/dist/chunks/scroll-area-CvCz7cL_.mjs.map +0 -1
  246. package/dist/chunks/select-BR6_N_Yo.mjs +0 -2
  247. package/dist/chunks/separator-BB6-E9Z1.mjs +0 -2
  248. package/dist/chunks/skeleton-XPWWiaac.mjs +0 -2
  249. package/dist/chunks/sortable-CqPFGn8Q.mjs +0 -2
  250. package/dist/chunks/sortable-CqPFGn8Q.mjs.map +0 -1
  251. package/dist/chunks/table-LQIHzPHi.mjs +0 -2
  252. package/dist/chunks/toggle-Co72WXGd.mjs +0 -2
  253. package/dist/chunks/tooltip-qX2HjdJP.mjs +0 -2
  254. package/dist/chunks/tslib.es6-cMGqxriw.mjs +0 -2
  255. package/dist/chunks/utils-BctauAA9.mjs +0 -2
  256. package/dist/chunks/utils-BctauAA9.mjs.map +0 -1
  257. package/dist/chunks/x-BNLl0E-E.mjs +0 -2
@@ -1,2 +1,650 @@
1
- import{Slot as e}from"@radix-ui/react-slot";import*as t from"react";import r from"react";import{c as a}from"../chunks/utils-BctauAA9.mjs";import{L as s}from"../chunks/label-CICFzZIt.mjs";import"../chunks/bundle-mjs-9BXytT_r.mjs";import"../chunks/index-w9bxia3O.mjs";import"react-dom";import"react/jsx-runtime";var o=e=>null==e;var n=e=>!o(e)&&!Array.isArray(e)&&(e=>"object"==typeof e)(e)&&!(e=>e instanceof Date)(e),i=e=>n(e)&&e.target?"checkbox"===e.target.type?e.target.checked:e.target.value:e,l="undefined"!=typeof window&&void 0!==window.HTMLElement&&"undefined"!=typeof document;function c(e){let t;const r=Array.isArray(e),a="undefined"!=typeof FileList&&e instanceof FileList;if(e instanceof Date)t=new Date(e);else{if(l&&(e instanceof Blob||a)||!r&&!n(e))return e;if(t=r?[]:{},r||(e=>{const t=e.constructor&&e.constructor.prototype;return n(t)&&t.hasOwnProperty("isPrototypeOf")})(e))for(const r in e)e.hasOwnProperty(r)&&(t[r]=c(e[r]));else t=e}return t}var u=e=>/^\w*$/.test(e),d=e=>void 0===e,m=e=>{return t=e.replace(/["|']|\]/g,"").split(/\.|\[/),Array.isArray(t)?t.filter(Boolean):[];var t},f=(e,t,r)=>{if(!t||!n(e))return r;const a=(u(t)?[t]:m(t)).reduce((e,t)=>o(e)?e:e[t],e);return d(a)||a===e?d(e[t])?r:e[t]:a},p=e=>"boolean"==typeof e,b=(e,t,r)=>{let a=-1;const s=u(t)?[t]:m(t),o=s.length,i=o-1;for(;++a<o;){const t=s[a];let o=r;if(a!==i){const r=e[t];o=n(r)||Array.isArray(r)?r:isNaN(+s[a+1])?{}:[]}if("__proto__"===t||"constructor"===t||"prototype"===t)return;e[t]=o,e=e[t]}};const g="blur",y="change",_="all",v=r.createContext(null);v.displayName="HookFormContext";const h=()=>r.useContext(v);const x="undefined"!=typeof window?t.useLayoutEffect:t.useEffect;function V(e){const t=h(),{control:a=t.control,disabled:s,name:o,exact:n}=e||{},[i,l]=r.useState(a._formState),c=r.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return x(()=>a._subscribe({name:o,formState:c.current,exact:n,callback:e=>{!s&&l({...a._formState,...e})}}),[o,s,n]),r.useEffect(()=>{c.current.isValid&&a._setValid(!0)},[a]),r.useMemo(()=>((e,t,r,a=!0)=>{const s={defaultValues:t._defaultValues};for(const o in e)Object.defineProperty(s,o,{get:()=>{const s=o;return t._proxyFormState[s]!==_&&(t._proxyFormState[s]=!a||_),r&&(r[s]=!0),e[s]}});return s})(i,a,c.current,!1),[i,a])}function F(e){const t=h(),{control:a=t.control,name:s,defaultValue:o,disabled:n,exact:i}=e||{},l=r.useRef(o),[c,u]=r.useState(a._getWatch(s,l.current));return x(()=>a._subscribe({name:s,formState:{values:!0},exact:i,callback:e=>!n&&u(((e,t,r,a,s)=>"string"==typeof e?f(r,e,s):Array.isArray(e)?e.map(e=>f(r,e)):r)(s,a._names,e.values||a._formValues,0,l.current))}),[s,a,n,i]),r.useEffect(()=>a._removeUnmounted()),c}const E=e=>e.render(function(e){const t=h(),{name:a,disabled:s,control:o=t.control,shouldUnregister:n}=e,l=((e,t)=>e.has((e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e)(t)))(o._names.array,a),u=F({control:o,name:a,defaultValue:f(o._formValues,a,f(o._defaultValues,a,e.defaultValue)),exact:!0}),m=V({control:o,name:a,exact:!0}),_=r.useRef(e),v=r.useRef(o.register(a,{...e.rules,value:u,...p(e.disabled)?{disabled:e.disabled}:{}})),x=r.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!f(m.errors,a)},isDirty:{enumerable:!0,get:()=>!!f(m.dirtyFields,a)},isTouched:{enumerable:!0,get:()=>!!f(m.touchedFields,a)},isValidating:{enumerable:!0,get:()=>!!f(m.validatingFields,a)},error:{enumerable:!0,get:()=>f(m.errors,a)}}),[m,a]),E=r.useCallback(e=>v.current.onChange({target:{value:i(e),name:a},type:y}),[a]),C=r.useCallback(()=>v.current.onBlur({target:{value:f(o._formValues,a),name:a},type:g}),[a,o._formValues]),w=r.useCallback(e=>{const t=f(o._fields,a);t&&e&&(t._f.ref={focus:()=>e.focus&&e.focus(),select:()=>e.select&&e.select(),setCustomValidity:t=>e.setCustomValidity(t),reportValidity:()=>e.reportValidity()})},[o._fields,a]),I=r.useMemo(()=>({name:a,value:u,...p(s)||m.disabled?{disabled:m.disabled||s}:{},onChange:E,onBlur:C,ref:w}),[a,s,m.disabled,E,C,w,u]);return r.useEffect(()=>{const e=o._options.shouldUnregister||n;o.register(a,{..._.current.rules,...p(_.current.disabled)?{disabled:_.current.disabled}:{}});const t=(e,t)=>{const r=f(o._fields,e);r&&r._f&&(r._f.mount=t)};if(t(a,!0),e){const e=c(f(o._options.defaultValues,a));b(o._defaultValues,a,e),d(f(o._formValues,a))&&b(o._formValues,a,e)}return!l&&o.register(a),()=>{(l?e&&!o._state.action:e)?o.unregister(a):t(a,!1)}},[a,o,l,n]),r.useEffect(()=>{o._setDisabledField({disabled:s,name:a})},[s,a,o]),r.useMemo(()=>({field:I,formState:m,fieldState:x}),[I,m,x])}(e)),C=e=>{const{children:t,...a}=e;return r.createElement(v.Provider,{value:a},t)},w=t.createContext({}),I=({...e})=>t.createElement(w.Provider,{value:{name:e.name}},t.createElement(E,e)),k=()=>{const e=t.useContext(w),r=t.useContext(S),{getFieldState:a}=h(),s=V({name:e.name}),o=a(e.name,s);if(!e)throw new Error("useFormField should be used within <FormField>");const{id:n}=r;return{id:n,name:e.name,formItemId:`${n}-form-item`,formDescriptionId:`${n}-form-item-description`,formMessageId:`${n}-form-item-message`,...o}},S=t.createContext({});function N({className:e,...r}){const s=t.useId();return t.createElement(S.Provider,{value:{id:s}},t.createElement("div",{"data-slot":"form-item",className:a("grid gap-2",e),...r}))}function A({className:e,...r}){const{error:o,formItemId:n}=k();return t.createElement(s,{"data-slot":"form-label","data-error":!!o,className:a("data-[error=true]:text-destructive",e),htmlFor:n,...r})}function j({...r}){const{error:a,formItemId:s,formDescriptionId:o,formMessageId:n}=k();return t.createElement(e,{"data-slot":"form-control",id:s,"aria-describedby":a?`${o} ${n}`:`${o}`,"aria-invalid":!!a,...r})}function D({className:e,...r}){const{formDescriptionId:s}=k();return t.createElement("p",{"data-slot":"form-description",id:s,className:a("text-muted-foreground text-sm",e),...r})}function M({className:e,...r}){const{error:s,formMessageId:o}=k(),n=s?String(s?.message??""):r.children;return n?t.createElement("p",{"data-slot":"form-message",id:o,className:a("text-destructive text-sm",e),...r},n):null}export{C as Form,j as FormControl,D as FormDescription,I as FormField,N as FormItem,A as FormLabel,M as FormMessage,k as useFormField};
1
+ import { Slot } from '@radix-ui/react-slot';
2
+ import * as React from 'react';
3
+ import React__default from 'react';
4
+ import { c as cn } from '../chunks/utils-tbIgc9YG.mjs';
5
+ import { L as Label } from '../chunks/label-CiJcd2F9.mjs';
6
+ import '../chunks/bundle-mjs-CS-QKnOm.mjs';
7
+ import '../chunks/index-fWnSEyU5.mjs';
8
+ import 'react-dom';
9
+ import 'react/jsx-runtime';
10
+
11
+ var isCheckBoxInput = (element)=>element.type === 'checkbox';
12
+ var isDateObject = (value1)=>value1 instanceof Date;
13
+ var isNullOrUndefined = (value1)=>value1 == null;
14
+ const isObjectType = (value1)=>typeof value1 === 'object';
15
+ var isObject = (value1)=>!isNullOrUndefined(value1) && !Array.isArray(value1) && isObjectType(value1) && !isDateObject(value1);
16
+ var getEventValue = (event)=>isObject(event) && event.target ? isCheckBoxInput(event.target) ? event.target.checked : event.target.value : event;
17
+ var getNodeParentName = (name)=>name.substring(0, name.search(/\.\d+(\.|$)/)) || name;
18
+ var isNameInFieldArray = (names, name)=>names.has(getNodeParentName(name));
19
+ var isPlainObject = (tempObject)=>{
20
+ const prototypeCopy = tempObject.constructor && tempObject.constructor.prototype;
21
+ return isObject(prototypeCopy) && prototypeCopy.hasOwnProperty('isPrototypeOf');
22
+ };
23
+ var isWeb = typeof window !== 'undefined' && typeof window.HTMLElement !== 'undefined' && typeof document !== 'undefined';
24
+ function cloneObject(data) {
25
+ let copy;
26
+ const isArray = Array.isArray(data);
27
+ const isFileListInstance = typeof FileList !== 'undefined' ? data instanceof FileList : false;
28
+ if (data instanceof Date) {
29
+ copy = new Date(data);
30
+ } else if (!(isWeb && (data instanceof Blob || isFileListInstance)) && (isArray || isObject(data))) {
31
+ copy = isArray ? [] : Object.create(Object.getPrototypeOf(data));
32
+ if (!isArray && !isPlainObject(data)) {
33
+ copy = data;
34
+ } else {
35
+ for(const key in data){
36
+ if (data.hasOwnProperty(key)) {
37
+ copy[key] = cloneObject(data[key]);
38
+ }
39
+ }
40
+ }
41
+ } else {
42
+ return data;
43
+ }
44
+ return copy;
45
+ }
46
+ var isKey = (value1)=>/^\w*$/.test(value1);
47
+ var isUndefined = (val)=>val === undefined;
48
+ var compact = (value1)=>Array.isArray(value1) ? value1.filter(Boolean) : [];
49
+ var stringToPath = (input)=>compact(input.replace(/["|']|\]/g, '').split(/\.|\[/));
50
+ var get = (object, path, defaultValue)=>{
51
+ if (!path || !isObject(object)) {
52
+ return defaultValue;
53
+ }
54
+ const result = (isKey(path) ? [
55
+ path
56
+ ] : stringToPath(path)).reduce((result, key)=>isNullOrUndefined(result) ? result : result[key], object);
57
+ return isUndefined(result) || result === object ? isUndefined(object[path]) ? defaultValue : object[path] : result;
58
+ };
59
+ var isBoolean = (value1)=>typeof value1 === 'boolean';
60
+ var set = (object, path, value1)=>{
61
+ let index = -1;
62
+ const tempPath = isKey(path) ? [
63
+ path
64
+ ] : stringToPath(path);
65
+ const length = tempPath.length;
66
+ const lastIndex = length - 1;
67
+ while(++index < length){
68
+ const key = tempPath[index];
69
+ let newValue = value1;
70
+ if (index !== lastIndex) {
71
+ const objValue = object[key];
72
+ newValue = isObject(objValue) || Array.isArray(objValue) ? objValue : !isNaN(+tempPath[index + 1]) ? [] : {};
73
+ }
74
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
75
+ return;
76
+ }
77
+ object[key] = newValue;
78
+ object = object[key];
79
+ }
80
+ };
81
+ const EVENTS = {
82
+ BLUR: 'blur',
83
+ CHANGE: 'change'
84
+ };
85
+ const VALIDATION_MODE = {
86
+ all: 'all'
87
+ };
88
+ const HookFormContext = React__default.createContext(null);
89
+ HookFormContext.displayName = 'HookFormContext';
90
+ /**
91
+ * This custom hook allows you to access the form context. useFormContext is intended to be used in deeply nested structures, where it would become inconvenient to pass the context as a prop. To be used with {@link FormProvider}.
92
+ *
93
+ * @remarks
94
+ * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
95
+ *
96
+ * @returns return all useForm methods
97
+ *
98
+ * @example
99
+ * ```tsx
100
+ * function App() {
101
+ * const methods = useForm();
102
+ * const onSubmit = data => console.log(data);
103
+ *
104
+ * return (
105
+ * <FormProvider {...methods} >
106
+ * <form onSubmit={methods.handleSubmit(onSubmit)}>
107
+ * <NestedInput />
108
+ * <input type="submit" />
109
+ * </form>
110
+ * </FormProvider>
111
+ * );
112
+ * }
113
+ *
114
+ * function NestedInput() {
115
+ * const { register } = useFormContext(); // retrieve all hook methods
116
+ * return <input {...register("test")} />;
117
+ * }
118
+ * ```
119
+ */ const useFormContext = ()=>React__default.useContext(HookFormContext);
120
+ /**
121
+ * A provider component that propagates the `useForm` methods to all children components via [React Context](https://reactjs.org/docs/context.html) API. To be used with {@link useFormContext}.
122
+ *
123
+ * @remarks
124
+ * [API](https://react-hook-form.com/docs/useformcontext) • [Demo](https://codesandbox.io/s/react-hook-form-v7-form-context-ytudi)
125
+ *
126
+ * @param props - all useForm methods
127
+ *
128
+ * @example
129
+ * ```tsx
130
+ * function App() {
131
+ * const methods = useForm();
132
+ * const onSubmit = data => console.log(data);
133
+ *
134
+ * return (
135
+ * <FormProvider {...methods} >
136
+ * <form onSubmit={methods.handleSubmit(onSubmit)}>
137
+ * <NestedInput />
138
+ * <input type="submit" />
139
+ * </form>
140
+ * </FormProvider>
141
+ * );
142
+ * }
143
+ *
144
+ * function NestedInput() {
145
+ * const { register } = useFormContext(); // retrieve all hook methods
146
+ * return <input {...register("test")} />;
147
+ * }
148
+ * ```
149
+ */ const FormProvider = (props)=>{
150
+ const { children, ...data } = props;
151
+ return React__default.createElement(HookFormContext.Provider, {
152
+ value: data
153
+ }, children);
154
+ };
155
+ var getProxyFormState = (formState, control, localProxyFormState, isRoot = true)=>{
156
+ const result = {
157
+ defaultValues: control._defaultValues
158
+ };
159
+ for(const key in formState){
160
+ Object.defineProperty(result, key, {
161
+ get: ()=>{
162
+ const _key = key;
163
+ if (control._proxyFormState[_key] !== VALIDATION_MODE.all) {
164
+ control._proxyFormState[_key] = !isRoot || VALIDATION_MODE.all;
165
+ }
166
+ localProxyFormState && (localProxyFormState[_key] = true);
167
+ return formState[_key];
168
+ }
169
+ });
170
+ }
171
+ return result;
172
+ };
173
+ const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React__default.useLayoutEffect : React__default.useEffect;
174
+ /**
175
+ * This custom hook allows you to subscribe to each form state, and isolate the re-render at the custom hook level. It has its scope in terms of form state subscription, so it would not affect other useFormState and useForm. Using this hook can reduce the re-render impact on large and complex form application.
176
+ *
177
+ * @remarks
178
+ * [API](https://react-hook-form.com/docs/useformstate) • [Demo](https://codesandbox.io/s/useformstate-75xly)
179
+ *
180
+ * @param props - include options on specify fields to subscribe. {@link UseFormStateReturn}
181
+ *
182
+ * @example
183
+ * ```tsx
184
+ * function App() {
185
+ * const { register, handleSubmit, control } = useForm({
186
+ * defaultValues: {
187
+ * firstName: "firstName"
188
+ * }});
189
+ * const { dirtyFields } = useFormState({
190
+ * control
191
+ * });
192
+ * const onSubmit = (data) => console.log(data);
193
+ *
194
+ * return (
195
+ * <form onSubmit={handleSubmit(onSubmit)}>
196
+ * <input {...register("firstName")} placeholder="First Name" />
197
+ * {dirtyFields.firstName && <p>Field is dirty.</p>}
198
+ * <input type="submit" />
199
+ * </form>
200
+ * );
201
+ * }
202
+ * ```
203
+ */ function useFormState(props) {
204
+ const methods = useFormContext();
205
+ const { control = methods.control, disabled, name, exact } = props || {};
206
+ const [formState, updateFormState] = React__default.useState(control._formState);
207
+ const _localProxyFormState = React__default.useRef({
208
+ isDirty: false,
209
+ isLoading: false,
210
+ dirtyFields: false,
211
+ touchedFields: false,
212
+ validatingFields: false,
213
+ isValidating: false,
214
+ isValid: false,
215
+ errors: false
216
+ });
217
+ useIsomorphicLayoutEffect(()=>control._subscribe({
218
+ name,
219
+ formState: _localProxyFormState.current,
220
+ exact,
221
+ callback: (formState)=>{
222
+ !disabled && updateFormState({
223
+ ...control._formState,
224
+ ...formState
225
+ });
226
+ }
227
+ }), [
228
+ name,
229
+ disabled,
230
+ exact
231
+ ]);
232
+ React__default.useEffect(()=>{
233
+ _localProxyFormState.current.isValid && control._setValid(true);
234
+ }, [
235
+ control
236
+ ]);
237
+ return React__default.useMemo(()=>getProxyFormState(formState, control, _localProxyFormState.current, false), [
238
+ formState,
239
+ control
240
+ ]);
241
+ }
242
+ var isString = (value1)=>typeof value1 === 'string';
243
+ var generateWatchOutput = (names, _names, formValues, isGlobal, defaultValue)=>{
244
+ if (isString(names)) {
245
+ return get(formValues, names, defaultValue);
246
+ }
247
+ if (Array.isArray(names)) {
248
+ return names.map((fieldName)=>(get(formValues, fieldName)));
249
+ }
250
+ return formValues;
251
+ };
252
+ var isPrimitive = (value1)=>isNullOrUndefined(value1) || !isObjectType(value1);
253
+ function deepEqual(object1, object2, _internal_visited = new WeakSet()) {
254
+ if (isPrimitive(object1) || isPrimitive(object2)) {
255
+ return object1 === object2;
256
+ }
257
+ if (isDateObject(object1) && isDateObject(object2)) {
258
+ return object1.getTime() === object2.getTime();
259
+ }
260
+ const keys1 = Object.keys(object1);
261
+ const keys2 = Object.keys(object2);
262
+ if (keys1.length !== keys2.length) {
263
+ return false;
264
+ }
265
+ if (_internal_visited.has(object1) || _internal_visited.has(object2)) {
266
+ return true;
267
+ }
268
+ _internal_visited.add(object1);
269
+ _internal_visited.add(object2);
270
+ for (const key of keys1){
271
+ const val1 = object1[key];
272
+ if (!keys2.includes(key)) {
273
+ return false;
274
+ }
275
+ if (key !== 'ref') {
276
+ const val2 = object2[key];
277
+ if (isDateObject(val1) && isDateObject(val2) || isObject(val1) && isObject(val2) || Array.isArray(val1) && Array.isArray(val2) ? !deepEqual(val1, val2, _internal_visited) : val1 !== val2) {
278
+ return false;
279
+ }
280
+ }
281
+ }
282
+ return true;
283
+ }
284
+ /**
285
+ * Custom hook to subscribe to field change and isolate re-rendering at the component level.
286
+ *
287
+ * @remarks
288
+ *
289
+ * [API](https://react-hook-form.com/docs/usewatch) • [Demo](https://codesandbox.io/s/react-hook-form-v7-ts-usewatch-h9i5e)
290
+ *
291
+ * @example
292
+ * ```tsx
293
+ * const { control } = useForm();
294
+ * const values = useWatch({
295
+ * name: "fieldName"
296
+ * control,
297
+ * })
298
+ * ```
299
+ */ function useWatch(props) {
300
+ const methods = useFormContext();
301
+ const { control = methods.control, name, defaultValue, disabled, exact, compute } = props || {};
302
+ const _defaultValue = React__default.useRef(defaultValue);
303
+ const _compute = React__default.useRef(compute);
304
+ const _computeFormValues = React__default.useRef(undefined);
305
+ _compute.current = compute;
306
+ const defaultValueMemo = React__default.useMemo(()=>control._getWatch(name, _defaultValue.current), [
307
+ control,
308
+ name
309
+ ]);
310
+ const [value1, updateValue] = React__default.useState(_compute.current ? _compute.current(defaultValueMemo) : defaultValueMemo);
311
+ useIsomorphicLayoutEffect(()=>control._subscribe({
312
+ name,
313
+ formState: {
314
+ values: true
315
+ },
316
+ exact,
317
+ callback: (formState)=>{
318
+ if (!disabled) {
319
+ const formValues = generateWatchOutput(name, control._names, formState.values || control._formValues, false, _defaultValue.current);
320
+ if (_compute.current) {
321
+ const computedFormValues = _compute.current(formValues);
322
+ if (!deepEqual(computedFormValues, _computeFormValues.current)) {
323
+ updateValue(computedFormValues);
324
+ _computeFormValues.current = computedFormValues;
325
+ }
326
+ } else {
327
+ updateValue(formValues);
328
+ }
329
+ }
330
+ }
331
+ }), [
332
+ control,
333
+ disabled,
334
+ name,
335
+ exact
336
+ ]);
337
+ React__default.useEffect(()=>control._removeUnmounted());
338
+ return value1;
339
+ }
340
+ /**
341
+ * Custom hook to work with controlled component, this function provide you with both form and field level state. Re-render is isolated at the hook level.
342
+ *
343
+ * @remarks
344
+ * [API](https://react-hook-form.com/docs/usecontroller) • [Demo](https://codesandbox.io/s/usecontroller-0o8px)
345
+ *
346
+ * @param props - the path name to the form field value, and validation rules.
347
+ *
348
+ * @returns field properties, field and form state. {@link UseControllerReturn}
349
+ *
350
+ * @example
351
+ * ```tsx
352
+ * function Input(props) {
353
+ * const { field, fieldState, formState } = useController(props);
354
+ * return (
355
+ * <div>
356
+ * <input {...field} placeholder={props.name} />
357
+ * <p>{fieldState.isTouched && "Touched"}</p>
358
+ * <p>{formState.isSubmitted ? "submitted" : ""}</p>
359
+ * </div>
360
+ * );
361
+ * }
362
+ * ```
363
+ */ function useController(props) {
364
+ const methods = useFormContext();
365
+ const { name, disabled, control = methods.control, shouldUnregister, defaultValue } = props;
366
+ const isArrayField = isNameInFieldArray(control._names.array, name);
367
+ const defaultValueMemo = React__default.useMemo(()=>get(control._formValues, name, get(control._defaultValues, name, defaultValue)), [
368
+ control,
369
+ name,
370
+ defaultValue
371
+ ]);
372
+ const value1 = useWatch({
373
+ control,
374
+ name,
375
+ defaultValue: defaultValueMemo,
376
+ exact: true
377
+ });
378
+ const formState = useFormState({
379
+ control,
380
+ name,
381
+ exact: true
382
+ });
383
+ const _props = React__default.useRef(props);
384
+ const _registerProps = React__default.useRef(control.register(name, {
385
+ ...props.rules,
386
+ value: value1,
387
+ ...isBoolean(props.disabled) ? {
388
+ disabled: props.disabled
389
+ } : {}
390
+ }));
391
+ _props.current = props;
392
+ const fieldState = React__default.useMemo(()=>Object.defineProperties({}, {
393
+ invalid: {
394
+ enumerable: true,
395
+ get: ()=>!!get(formState.errors, name)
396
+ },
397
+ isDirty: {
398
+ enumerable: true,
399
+ get: ()=>!!get(formState.dirtyFields, name)
400
+ },
401
+ isTouched: {
402
+ enumerable: true,
403
+ get: ()=>!!get(formState.touchedFields, name)
404
+ },
405
+ isValidating: {
406
+ enumerable: true,
407
+ get: ()=>!!get(formState.validatingFields, name)
408
+ },
409
+ error: {
410
+ enumerable: true,
411
+ get: ()=>get(formState.errors, name)
412
+ }
413
+ }), [
414
+ formState,
415
+ name
416
+ ]);
417
+ const onChange = React__default.useCallback((event)=>_registerProps.current.onChange({
418
+ target: {
419
+ value: getEventValue(event),
420
+ name: name
421
+ },
422
+ type: EVENTS.CHANGE
423
+ }), [
424
+ name
425
+ ]);
426
+ const onBlur = React__default.useCallback(()=>_registerProps.current.onBlur({
427
+ target: {
428
+ value: get(control._formValues, name),
429
+ name: name
430
+ },
431
+ type: EVENTS.BLUR
432
+ }), [
433
+ name,
434
+ control._formValues
435
+ ]);
436
+ const ref = React__default.useCallback((elm)=>{
437
+ const field = get(control._fields, name);
438
+ if (field && elm) {
439
+ field._f.ref = {
440
+ focus: ()=>elm.focus && elm.focus(),
441
+ select: ()=>elm.select && elm.select(),
442
+ setCustomValidity: (message)=>elm.setCustomValidity(message),
443
+ reportValidity: ()=>elm.reportValidity()
444
+ };
445
+ }
446
+ }, [
447
+ control._fields,
448
+ name
449
+ ]);
450
+ const field = React__default.useMemo(()=>({
451
+ name,
452
+ value: value1,
453
+ ...isBoolean(disabled) || formState.disabled ? {
454
+ disabled: formState.disabled || disabled
455
+ } : {},
456
+ onChange,
457
+ onBlur,
458
+ ref
459
+ }), [
460
+ name,
461
+ disabled,
462
+ formState.disabled,
463
+ onChange,
464
+ onBlur,
465
+ ref,
466
+ value1
467
+ ]);
468
+ React__default.useEffect(()=>{
469
+ const _shouldUnregisterField = control._options.shouldUnregister || shouldUnregister;
470
+ control.register(name, {
471
+ ..._props.current.rules,
472
+ ...isBoolean(_props.current.disabled) ? {
473
+ disabled: _props.current.disabled
474
+ } : {}
475
+ });
476
+ const updateMounted = (name, value1)=>{
477
+ const field = get(control._fields, name);
478
+ if (field && field._f) {
479
+ field._f.mount = value1;
480
+ }
481
+ };
482
+ updateMounted(name, true);
483
+ if (_shouldUnregisterField) {
484
+ const value1 = cloneObject(get(control._options.defaultValues, name));
485
+ set(control._defaultValues, name, value1);
486
+ if (isUndefined(get(control._formValues, name))) {
487
+ set(control._formValues, name, value1);
488
+ }
489
+ }
490
+ !isArrayField && control.register(name);
491
+ return ()=>{
492
+ (isArrayField ? _shouldUnregisterField && !control._state.action : _shouldUnregisterField) ? control.unregister(name) : updateMounted(name, false);
493
+ };
494
+ }, [
495
+ name,
496
+ control,
497
+ isArrayField,
498
+ shouldUnregister
499
+ ]);
500
+ React__default.useEffect(()=>{
501
+ control._setDisabledField({
502
+ disabled,
503
+ name
504
+ });
505
+ }, [
506
+ disabled,
507
+ name,
508
+ control
509
+ ]);
510
+ return React__default.useMemo(()=>({
511
+ field,
512
+ formState,
513
+ fieldState
514
+ }), [
515
+ field,
516
+ formState,
517
+ fieldState
518
+ ]);
519
+ }
520
+ /**
521
+ * Component based on `useController` hook to work with controlled component.
522
+ *
523
+ * @remarks
524
+ * [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
525
+ *
526
+ * @param props - the path name to the form field value, and validation rules.
527
+ *
528
+ * @returns provide field handler functions, field and form state.
529
+ *
530
+ * @example
531
+ * ```tsx
532
+ * function App() {
533
+ * const { control } = useForm<FormValues>({
534
+ * defaultValues: {
535
+ * test: ""
536
+ * }
537
+ * });
538
+ *
539
+ * return (
540
+ * <form>
541
+ * <Controller
542
+ * control={control}
543
+ * name="test"
544
+ * render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
545
+ * <>
546
+ * <input
547
+ * onChange={onChange} // send value to hook form
548
+ * onBlur={onBlur} // notify when input is touched
549
+ * value={value} // return updated value
550
+ * ref={ref} // set ref for focus management
551
+ * />
552
+ * <p>{formState.isSubmitted ? "submitted" : ""}</p>
553
+ * <p>{fieldState.isTouched ? "touched" : ""}</p>
554
+ * </>
555
+ * )}
556
+ * />
557
+ * </form>
558
+ * );
559
+ * }
560
+ * ```
561
+ */ const Controller = (props)=>props.render(useController(props));
562
+
563
+ const Form = FormProvider;
564
+ const FormFieldContext = /*#__PURE__*/ React.createContext({});
565
+ const FormField = ({ ...props })=>{
566
+ return /*#__PURE__*/ React.createElement(FormFieldContext.Provider, {
567
+ value: {
568
+ name: props.name
569
+ }
570
+ }, /*#__PURE__*/ React.createElement(Controller, props));
571
+ };
572
+ const useFormField = ()=>{
573
+ const fieldContext = React.useContext(FormFieldContext);
574
+ const itemContext = React.useContext(FormItemContext);
575
+ const { getFieldState } = useFormContext();
576
+ const formState = useFormState({
577
+ name: fieldContext.name
578
+ });
579
+ const fieldState = getFieldState(fieldContext.name, formState);
580
+ if (!fieldContext) {
581
+ throw new Error("useFormField should be used within <FormField>");
582
+ }
583
+ const { id } = itemContext;
584
+ return {
585
+ id,
586
+ name: fieldContext.name,
587
+ formItemId: `${id}-form-item`,
588
+ formDescriptionId: `${id}-form-item-description`,
589
+ formMessageId: `${id}-form-item-message`,
590
+ ...fieldState
591
+ };
592
+ };
593
+ const FormItemContext = /*#__PURE__*/ React.createContext({});
594
+ function FormItem({ className, ...props }) {
595
+ const id = React.useId();
596
+ return /*#__PURE__*/ React.createElement(FormItemContext.Provider, {
597
+ value: {
598
+ id
599
+ }
600
+ }, /*#__PURE__*/ React.createElement("div", {
601
+ "data-slot": "form-item",
602
+ className: cn("grid gap-2", className),
603
+ ...props
604
+ }));
605
+ }
606
+ function FormLabel({ className, ...props }) {
607
+ const { error, formItemId } = useFormField();
608
+ return /*#__PURE__*/ React.createElement(Label, {
609
+ "data-slot": "form-label",
610
+ "data-error": !!error,
611
+ className: cn("data-[error=true]:text-destructive", className),
612
+ htmlFor: formItemId,
613
+ ...props
614
+ });
615
+ }
616
+ function FormControl({ ...props }) {
617
+ const { error, formItemId, formDescriptionId, formMessageId } = useFormField();
618
+ return /*#__PURE__*/ React.createElement(Slot, {
619
+ "data-slot": "form-control",
620
+ id: formItemId,
621
+ "aria-describedby": !error ? `${formDescriptionId}` : `${formDescriptionId} ${formMessageId}`,
622
+ "aria-invalid": !!error,
623
+ ...props
624
+ });
625
+ }
626
+ function FormDescription({ className, ...props }) {
627
+ const { formDescriptionId } = useFormField();
628
+ return /*#__PURE__*/ React.createElement("p", {
629
+ "data-slot": "form-description",
630
+ id: formDescriptionId,
631
+ className: cn("text-muted-foreground text-sm", className),
632
+ ...props
633
+ });
634
+ }
635
+ function FormMessage({ className, ...props }) {
636
+ const { error, formMessageId } = useFormField();
637
+ const body = error ? String(error?.message ?? "") : props.children;
638
+ if (!body) {
639
+ return null;
640
+ }
641
+ return /*#__PURE__*/ React.createElement("p", {
642
+ "data-slot": "form-message",
643
+ id: formMessageId,
644
+ className: cn("text-destructive text-sm", className),
645
+ ...props
646
+ }, body);
647
+ }
648
+
649
+ export { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, useFormField };
2
650
  //# sourceMappingURL=index.mjs.map