@jameskabz/nextcraft-ui 0.6.3 → 0.6.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 (369) hide show
  1. package/dist/components/craft-alert.cjs +69 -0
  2. package/dist/components/craft-alert.cjs.map +1 -0
  3. package/dist/components/craft-alert.d.cts +16 -0
  4. package/dist/components/craft-alert.d.ts +16 -0
  5. package/dist/components/craft-alert.js +45 -0
  6. package/dist/components/craft-alert.js.map +1 -0
  7. package/dist/components/craft-badge.cjs +54 -0
  8. package/dist/components/craft-badge.cjs.map +1 -0
  9. package/dist/components/craft-badge.d.cts +12 -0
  10. package/dist/components/craft-badge.d.ts +12 -0
  11. package/dist/components/craft-badge.js +30 -0
  12. package/dist/components/craft-badge.js.map +1 -0
  13. package/dist/components/craft-button.cjs +66 -0
  14. package/dist/components/craft-button.cjs.map +1 -0
  15. package/dist/components/craft-button.d.cts +15 -0
  16. package/dist/components/craft-button.d.ts +15 -0
  17. package/dist/components/craft-button.js +42 -0
  18. package/dist/components/craft-button.js.map +1 -0
  19. package/dist/components/craft-card.cjs +63 -0
  20. package/dist/components/craft-card.cjs.map +1 -0
  21. package/dist/components/craft-card.d.cts +13 -0
  22. package/dist/components/craft-card.d.ts +13 -0
  23. package/dist/components/craft-card.js +39 -0
  24. package/dist/components/craft-card.js.map +1 -0
  25. package/dist/components/craft-checkbox.cjs +103 -0
  26. package/dist/components/craft-checkbox.cjs.map +1 -0
  27. package/dist/components/craft-checkbox.d.cts +16 -0
  28. package/dist/components/craft-checkbox.d.ts +16 -0
  29. package/dist/components/craft-checkbox.js +69 -0
  30. package/dist/components/craft-checkbox.js.map +1 -0
  31. package/dist/components/craft-command-palette.cjs +134 -0
  32. package/dist/components/craft-command-palette.cjs.map +1 -0
  33. package/dist/components/craft-command-palette.d.cts +28 -0
  34. package/dist/components/craft-command-palette.d.ts +28 -0
  35. package/dist/components/craft-command-palette.js +100 -0
  36. package/dist/components/craft-command-palette.js.map +1 -0
  37. package/dist/components/craft-confirm-dialog.cjs +114 -0
  38. package/dist/components/craft-confirm-dialog.cjs.map +1 -0
  39. package/dist/components/craft-confirm-dialog.d.cts +21 -0
  40. package/dist/components/craft-confirm-dialog.d.ts +21 -0
  41. package/dist/components/craft-confirm-dialog.js +80 -0
  42. package/dist/components/craft-confirm-dialog.js.map +1 -0
  43. package/dist/components/craft-create-edit-drawer.cjs +112 -0
  44. package/dist/components/craft-create-edit-drawer.cjs.map +1 -0
  45. package/dist/components/craft-create-edit-drawer.d.cts +28 -0
  46. package/dist/components/craft-create-edit-drawer.d.ts +28 -0
  47. package/dist/components/craft-create-edit-drawer.js +78 -0
  48. package/dist/components/craft-create-edit-drawer.js.map +1 -0
  49. package/dist/components/craft-currency-input.cjs +68 -0
  50. package/dist/components/craft-currency-input.cjs.map +1 -0
  51. package/dist/components/craft-currency-input.d.cts +14 -0
  52. package/dist/components/craft-currency-input.d.ts +14 -0
  53. package/dist/components/craft-currency-input.js +34 -0
  54. package/dist/components/craft-currency-input.js.map +1 -0
  55. package/dist/components/craft-data-table.cjs +407 -0
  56. package/dist/components/craft-data-table.cjs.map +1 -0
  57. package/dist/components/craft-data-table.d.cts +58 -0
  58. package/dist/components/craft-data-table.d.ts +58 -0
  59. package/dist/{chunk-ZRV4Y374.js → components/craft-data-table.js} +30 -239
  60. package/dist/components/craft-data-table.js.map +1 -0
  61. package/dist/components/craft-date-picker.cjs +226 -0
  62. package/dist/components/craft-date-picker.cjs.map +1 -0
  63. package/dist/components/craft-date-picker.d.cts +17 -0
  64. package/dist/components/craft-date-picker.d.ts +17 -0
  65. package/dist/components/craft-date-picker.js +192 -0
  66. package/dist/components/craft-date-picker.js.map +1 -0
  67. package/dist/components/craft-drawer.cjs +126 -0
  68. package/dist/components/craft-drawer.cjs.map +1 -0
  69. package/dist/components/craft-drawer.d.cts +19 -0
  70. package/dist/components/craft-drawer.d.ts +19 -0
  71. package/dist/components/craft-drawer.js +92 -0
  72. package/dist/components/craft-drawer.js.map +1 -0
  73. package/dist/components/craft-dropdown-menu.cjs +127 -0
  74. package/dist/components/craft-dropdown-menu.cjs.map +1 -0
  75. package/dist/components/craft-dropdown-menu.d.cts +28 -0
  76. package/dist/components/craft-dropdown-menu.d.ts +28 -0
  77. package/dist/components/craft-dropdown-menu.js +93 -0
  78. package/dist/components/craft-dropdown-menu.js.map +1 -0
  79. package/dist/components/craft-empty-state.cjs +58 -0
  80. package/dist/components/craft-empty-state.cjs.map +1 -0
  81. package/dist/components/craft-empty-state.d.cts +14 -0
  82. package/dist/components/craft-empty-state.d.ts +14 -0
  83. package/dist/components/craft-empty-state.js +34 -0
  84. package/dist/components/craft-empty-state.js.map +1 -0
  85. package/dist/components/craft-error-state.cjs +60 -0
  86. package/dist/components/craft-error-state.cjs.map +1 -0
  87. package/dist/components/craft-error-state.d.cts +15 -0
  88. package/dist/components/craft-error-state.d.ts +15 -0
  89. package/dist/components/craft-error-state.js +36 -0
  90. package/dist/components/craft-error-state.js.map +1 -0
  91. package/dist/components/craft-filter-bar.cjs +76 -0
  92. package/dist/components/craft-filter-bar.cjs.map +1 -0
  93. package/dist/components/craft-filter-bar.d.cts +18 -0
  94. package/dist/components/craft-filter-bar.d.ts +18 -0
  95. package/dist/components/craft-filter-bar.js +52 -0
  96. package/dist/components/craft-filter-bar.js.map +1 -0
  97. package/dist/components/craft-form-builder.cjs +330 -0
  98. package/dist/components/craft-form-builder.cjs.map +1 -0
  99. package/dist/components/craft-form-builder.d.cts +57 -0
  100. package/dist/components/craft-form-builder.d.ts +57 -0
  101. package/dist/components/craft-form-builder.js +301 -0
  102. package/dist/components/craft-form-builder.js.map +1 -0
  103. package/dist/components/craft-form-field.cjs +301 -0
  104. package/dist/components/craft-form-field.cjs.map +1 -0
  105. package/dist/components/craft-form-field.d.cts +30 -0
  106. package/dist/components/craft-form-field.d.ts +30 -0
  107. package/dist/components/craft-form-field.js +280 -0
  108. package/dist/components/craft-form-field.js.map +1 -0
  109. package/dist/components/craft-form.cjs +114 -0
  110. package/dist/components/craft-form.cjs.map +1 -0
  111. package/dist/components/craft-form.d.cts +27 -0
  112. package/dist/components/craft-form.d.ts +27 -0
  113. package/dist/components/craft-form.js +80 -0
  114. package/dist/components/craft-form.js.map +1 -0
  115. package/dist/components/craft-icon.cjs +102 -0
  116. package/dist/components/craft-icon.cjs.map +1 -0
  117. package/dist/components/craft-icon.d.cts +19 -0
  118. package/dist/components/craft-icon.d.ts +19 -0
  119. package/dist/{chunk-FEFH5O5K.js → components/craft-icon.js} +31 -13
  120. package/dist/components/craft-icon.js.map +1 -0
  121. package/dist/components/craft-input.cjs +78 -0
  122. package/dist/components/craft-input.cjs.map +1 -0
  123. package/dist/components/craft-input.d.cts +19 -0
  124. package/dist/components/craft-input.d.ts +19 -0
  125. package/dist/{chunk-7SKDTIEK.js → components/craft-input.js} +5 -10
  126. package/dist/components/craft-input.js.map +1 -0
  127. package/dist/components/craft-link.cjs +70 -0
  128. package/dist/components/craft-link.cjs.map +1 -0
  129. package/dist/components/craft-link.d.cts +14 -0
  130. package/dist/components/craft-link.d.ts +14 -0
  131. package/dist/components/craft-link.js +36 -0
  132. package/dist/components/craft-link.js.map +1 -0
  133. package/dist/components/craft-loading-state.cjs +64 -0
  134. package/dist/components/craft-loading-state.cjs.map +1 -0
  135. package/dist/components/craft-loading-state.d.cts +13 -0
  136. package/dist/components/craft-loading-state.d.ts +13 -0
  137. package/dist/components/craft-loading-state.js +40 -0
  138. package/dist/components/craft-loading-state.js.map +1 -0
  139. package/dist/components/craft-modal.cjs +174 -0
  140. package/dist/components/craft-modal.cjs.map +1 -0
  141. package/dist/components/craft-modal.d.cts +19 -0
  142. package/dist/components/craft-modal.d.ts +19 -0
  143. package/dist/components/craft-modal.js +140 -0
  144. package/dist/components/craft-modal.js.map +1 -0
  145. package/dist/components/craft-number-input.cjs +63 -0
  146. package/dist/components/craft-number-input.cjs.map +1 -0
  147. package/dist/components/craft-number-input.d.cts +12 -0
  148. package/dist/components/craft-number-input.d.ts +12 -0
  149. package/dist/components/craft-number-input.js +29 -0
  150. package/dist/components/craft-number-input.js.map +1 -0
  151. package/dist/components/craft-pagination.cjs +130 -0
  152. package/dist/components/craft-pagination.cjs.map +1 -0
  153. package/dist/components/craft-pagination.d.cts +19 -0
  154. package/dist/components/craft-pagination.d.ts +19 -0
  155. package/dist/components/craft-pagination.js +106 -0
  156. package/dist/components/craft-pagination.js.map +1 -0
  157. package/dist/components/craft-popover.cjs +123 -0
  158. package/dist/components/craft-popover.cjs.map +1 -0
  159. package/dist/components/craft-popover.d.cts +20 -0
  160. package/dist/components/craft-popover.d.ts +20 -0
  161. package/dist/components/craft-popover.js +89 -0
  162. package/dist/components/craft-popover.js.map +1 -0
  163. package/dist/components/craft-select.cjs +84 -0
  164. package/dist/components/craft-select.cjs.map +1 -0
  165. package/dist/components/craft-select.d.cts +12 -0
  166. package/dist/components/craft-select.d.ts +12 -0
  167. package/dist/components/craft-select.js +50 -0
  168. package/dist/components/craft-select.js.map +1 -0
  169. package/dist/components/craft-skeleton.cjs +45 -0
  170. package/dist/components/craft-skeleton.cjs.map +1 -0
  171. package/dist/components/craft-skeleton.d.cts +10 -0
  172. package/dist/components/craft-skeleton.d.ts +10 -0
  173. package/dist/components/craft-skeleton.js +21 -0
  174. package/dist/components/craft-skeleton.js.map +1 -0
  175. package/dist/components/craft-stat-card.cjs +67 -0
  176. package/dist/components/craft-stat-card.cjs.map +1 -0
  177. package/dist/components/craft-stat-card.d.cts +17 -0
  178. package/dist/components/craft-stat-card.d.ts +17 -0
  179. package/dist/components/craft-stat-card.js +43 -0
  180. package/dist/components/craft-stat-card.js.map +1 -0
  181. package/dist/components/craft-submit-button.cjs +71 -0
  182. package/dist/components/craft-submit-button.cjs.map +1 -0
  183. package/dist/components/craft-submit-button.d.cts +13 -0
  184. package/dist/components/craft-submit-button.d.ts +13 -0
  185. package/dist/components/craft-submit-button.js +47 -0
  186. package/dist/components/craft-submit-button.js.map +1 -0
  187. package/dist/components/craft-switch.cjs +82 -0
  188. package/dist/components/craft-switch.cjs.map +1 -0
  189. package/dist/components/craft-switch.d.cts +14 -0
  190. package/dist/components/craft-switch.d.ts +14 -0
  191. package/dist/components/craft-switch.js +48 -0
  192. package/dist/components/craft-switch.js.map +1 -0
  193. package/dist/components/craft-table-toolbar.cjs +79 -0
  194. package/dist/components/craft-table-toolbar.cjs.map +1 -0
  195. package/dist/components/craft-table-toolbar.d.cts +19 -0
  196. package/dist/components/craft-table-toolbar.d.ts +19 -0
  197. package/dist/components/craft-table-toolbar.js +55 -0
  198. package/dist/components/craft-table-toolbar.js.map +1 -0
  199. package/dist/components/craft-tabs.cjs +105 -0
  200. package/dist/components/craft-tabs.cjs.map +1 -0
  201. package/dist/components/craft-tabs.d.cts +19 -0
  202. package/dist/components/craft-tabs.d.ts +19 -0
  203. package/dist/components/craft-tabs.js +71 -0
  204. package/dist/components/craft-tabs.js.map +1 -0
  205. package/dist/components/craft-textarea.cjs +69 -0
  206. package/dist/components/craft-textarea.cjs.map +1 -0
  207. package/dist/components/craft-textarea.d.cts +12 -0
  208. package/dist/components/craft-textarea.d.ts +12 -0
  209. package/dist/components/craft-textarea.js +35 -0
  210. package/dist/components/craft-textarea.js.map +1 -0
  211. package/dist/components/craft-toast.cjs +98 -0
  212. package/dist/components/craft-toast.cjs.map +1 -0
  213. package/dist/components/craft-toast.d.cts +24 -0
  214. package/dist/components/craft-toast.d.ts +24 -0
  215. package/dist/components/craft-toast.js +63 -0
  216. package/dist/components/craft-toast.js.map +1 -0
  217. package/dist/components/craft-tooltip.cjs +75 -0
  218. package/dist/components/craft-tooltip.cjs.map +1 -0
  219. package/dist/components/craft-tooltip.d.cts +13 -0
  220. package/dist/components/craft-tooltip.d.ts +13 -0
  221. package/dist/components/craft-tooltip.js +41 -0
  222. package/dist/components/craft-tooltip.js.map +1 -0
  223. package/dist/components/forms/types.cjs +17 -0
  224. package/dist/components/forms/types.cjs.map +1 -0
  225. package/dist/components/forms/types.d.cts +7 -0
  226. package/dist/components/forms/types.d.ts +7 -0
  227. package/dist/components/forms/types.js +1 -0
  228. package/dist/components/forms/types.js.map +1 -0
  229. package/dist/components/glass-card.cjs +64 -0
  230. package/dist/components/glass-card.cjs.map +1 -0
  231. package/dist/components/glass-card.d.cts +12 -0
  232. package/dist/components/glass-card.d.ts +12 -0
  233. package/dist/components/glass-card.js +40 -0
  234. package/dist/components/glass-card.js.map +1 -0
  235. package/dist/components/layout/app-shell.cjs +49 -0
  236. package/dist/components/layout/app-shell.cjs.map +1 -0
  237. package/dist/components/layout/app-shell.d.cts +10 -0
  238. package/dist/components/layout/app-shell.d.ts +10 -0
  239. package/dist/components/layout/app-shell.js +25 -0
  240. package/dist/components/layout/app-shell.js.map +1 -0
  241. package/dist/components/layout/app-template.cjs +104 -0
  242. package/dist/components/layout/app-template.cjs.map +1 -0
  243. package/dist/components/layout/app-template.d.cts +19 -0
  244. package/dist/components/layout/app-template.d.ts +19 -0
  245. package/dist/components/layout/app-template.js +70 -0
  246. package/dist/components/layout/app-template.js.map +1 -0
  247. package/dist/components/layout/auth-layout.cjs +65 -0
  248. package/dist/components/layout/auth-layout.cjs.map +1 -0
  249. package/dist/components/layout/auth-layout.d.cts +12 -0
  250. package/dist/components/layout/auth-layout.d.ts +12 -0
  251. package/dist/components/layout/auth-layout.js +41 -0
  252. package/dist/components/layout/auth-layout.js.map +1 -0
  253. package/dist/components/layout/breadcrumbs.cjs +39 -0
  254. package/dist/components/layout/breadcrumbs.cjs.map +1 -0
  255. package/dist/components/layout/breadcrumbs.d.cts +13 -0
  256. package/dist/components/layout/breadcrumbs.d.ts +13 -0
  257. package/dist/components/layout/breadcrumbs.js +15 -0
  258. package/dist/components/layout/breadcrumbs.js.map +1 -0
  259. package/dist/components/layout/container.cjs +45 -0
  260. package/dist/components/layout/container.cjs.map +1 -0
  261. package/dist/components/layout/container.d.cts +9 -0
  262. package/dist/components/layout/container.d.ts +9 -0
  263. package/dist/components/layout/container.js +21 -0
  264. package/dist/components/layout/container.js.map +1 -0
  265. package/dist/components/layout/grid.cjs +47 -0
  266. package/dist/components/layout/grid.cjs.map +1 -0
  267. package/dist/components/layout/grid.d.cts +10 -0
  268. package/dist/components/layout/grid.d.ts +10 -0
  269. package/dist/components/layout/grid.js +23 -0
  270. package/dist/components/layout/grid.js.map +1 -0
  271. package/dist/components/layout/layout-config.cjs +78 -0
  272. package/dist/components/layout/layout-config.cjs.map +1 -0
  273. package/dist/components/layout/layout-config.d.cts +92 -0
  274. package/dist/components/layout/layout-config.d.ts +92 -0
  275. package/dist/components/layout/layout-config.js +54 -0
  276. package/dist/components/layout/layout-config.js.map +1 -0
  277. package/dist/components/layout/page-header.cjs +52 -0
  278. package/dist/components/layout/page-header.cjs.map +1 -0
  279. package/dist/components/layout/page-header.d.cts +11 -0
  280. package/dist/components/layout/page-header.d.ts +11 -0
  281. package/dist/components/layout/page-header.js +28 -0
  282. package/dist/components/layout/page-header.js.map +1 -0
  283. package/dist/components/layout/sidebar.cjs +64 -0
  284. package/dist/components/layout/sidebar.cjs.map +1 -0
  285. package/dist/components/layout/sidebar.d.cts +17 -0
  286. package/dist/components/layout/sidebar.d.ts +17 -0
  287. package/dist/components/layout/sidebar.js +40 -0
  288. package/dist/components/layout/sidebar.js.map +1 -0
  289. package/dist/components/layout/top-nav.cjs +49 -0
  290. package/dist/components/layout/top-nav.cjs.map +1 -0
  291. package/dist/components/layout/top-nav.d.cts +11 -0
  292. package/dist/components/layout/top-nav.d.ts +11 -0
  293. package/dist/components/layout/top-nav.js +25 -0
  294. package/dist/components/layout/top-nav.js.map +1 -0
  295. package/dist/components/layout/types.cjs +29 -0
  296. package/dist/components/layout/types.cjs.map +1 -0
  297. package/dist/components/layout/types.d.cts +12 -0
  298. package/dist/components/layout/types.d.ts +12 -0
  299. package/dist/components/layout/types.js +5 -0
  300. package/dist/components/layout/types.js.map +1 -0
  301. package/dist/components/table/types.cjs +17 -0
  302. package/dist/components/table/types.cjs.map +1 -0
  303. package/dist/components/table/types.d.cts +7 -0
  304. package/dist/components/table/types.d.ts +7 -0
  305. package/dist/components/table/types.js +1 -0
  306. package/dist/components/table/types.js.map +1 -0
  307. package/dist/components/theme-switcher.cjs +72 -0
  308. package/dist/components/theme-switcher.cjs.map +1 -0
  309. package/dist/components/theme-switcher.d.cts +9 -0
  310. package/dist/components/theme-switcher.d.ts +9 -0
  311. package/dist/components/theme-switcher.js +48 -0
  312. package/dist/components/theme-switcher.js.map +1 -0
  313. package/dist/craft/components.cjs +64 -1779
  314. package/dist/craft/components.cjs.map +1 -1
  315. package/dist/craft/components.d.cts +36 -369
  316. package/dist/craft/components.d.ts +36 -369
  317. package/dist/craft/components.js +31 -42
  318. package/dist/craft/components.js.map +1 -1
  319. package/dist/craft/forms.cjs +6 -1347
  320. package/dist/craft/forms.cjs.map +1 -1
  321. package/dist/craft/forms.d.cts +7 -101
  322. package/dist/craft/forms.d.ts +7 -101
  323. package/dist/craft/forms.js +3 -8
  324. package/dist/craft/forms.js.map +1 -1
  325. package/dist/craft/layout.cjs +20 -374
  326. package/dist/craft/layout.cjs.map +1 -1
  327. package/dist/craft/layout.d.cts +12 -170
  328. package/dist/craft/layout.d.ts +12 -170
  329. package/dist/craft/layout.js +10 -14
  330. package/dist/craft/layout.js.map +1 -1
  331. package/dist/craft/table.cjs +8 -632
  332. package/dist/craft/table.cjs.map +1 -1
  333. package/dist/craft/table.d.cts +7 -99
  334. package/dist/craft/table.d.ts +7 -99
  335. package/dist/craft/table.js +4 -8
  336. package/dist/craft/table.js.map +1 -1
  337. package/dist/craft/theme.cjs +5 -137
  338. package/dist/craft/theme.cjs.map +1 -1
  339. package/dist/craft/theme.d.cts +3 -9
  340. package/dist/craft/theme.d.ts +3 -9
  341. package/dist/craft/theme.js +2 -6
  342. package/dist/craft/theme.js.map +1 -1
  343. package/dist/index.cjs +103 -3426
  344. package/dist/index.cjs.map +1 -1
  345. package/dist/index.d.cts +50 -6
  346. package/dist/index.d.ts +50 -6
  347. package/dist/index.js +50 -70
  348. package/dist/index.js.map +1 -1
  349. package/dist/utils/cn.cjs +31 -0
  350. package/dist/utils/cn.cjs.map +1 -0
  351. package/dist/utils/cn.d.cts +3 -0
  352. package/dist/utils/cn.d.ts +3 -0
  353. package/dist/{chunk-VQ6T3HIX.js → utils/cn.js} +1 -3
  354. package/dist/utils/cn.js.map +1 -0
  355. package/package.json +6 -1
  356. package/dist/chunk-6F7FN2ZF.js +0 -671
  357. package/dist/chunk-6F7FN2ZF.js.map +0 -1
  358. package/dist/chunk-7Q4Z47HT.js +0 -657
  359. package/dist/chunk-7Q4Z47HT.js.map +0 -1
  360. package/dist/chunk-7SKDTIEK.js.map +0 -1
  361. package/dist/chunk-FEFH5O5K.js.map +0 -1
  362. package/dist/chunk-M2EKVXB6.js +0 -127
  363. package/dist/chunk-M2EKVXB6.js.map +0 -1
  364. package/dist/chunk-SBLIF6UU.js +0 -1029
  365. package/dist/chunk-SBLIF6UU.js.map +0 -1
  366. package/dist/chunk-VQ6T3HIX.js.map +0 -1
  367. package/dist/chunk-YVZL4GET.js +0 -328
  368. package/dist/chunk-YVZL4GET.js.map +0 -1
  369. package/dist/chunk-ZRV4Y374.js.map +0 -1
@@ -0,0 +1,301 @@
1
+ "use strict";
2
+ "use client";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+ var craft_form_field_exports = {};
21
+ __export(craft_form_field_exports, {
22
+ CraftFormField: () => CraftFormField
23
+ });
24
+ module.exports = __toCommonJS(craft_form_field_exports);
25
+ var import_jsx_runtime = require("react/jsx-runtime");
26
+ var import_react_hook_form = require("react-hook-form");
27
+ var import_cn = require("@/utils/cn");
28
+ var import_craft_input = require("@/components/craft-input");
29
+ var import_craft_textarea = require("@/components/craft-textarea");
30
+ var import_craft_select = require("@/components/craft-select");
31
+ var import_craft_checkbox = require("@/components/craft-checkbox");
32
+ var import_craft_switch = require("@/components/craft-switch");
33
+ var import_craft_date_picker = require("@/components/craft-date-picker");
34
+ var import_craft_number_input = require("@/components/craft-number-input");
35
+ var import_craft_currency_input = require("@/components/craft-currency-input");
36
+ function getFieldError(errors, name) {
37
+ if (!errors || typeof errors !== "object") return void 0;
38
+ const segments = name.split(".");
39
+ let current = errors;
40
+ for (const segment of segments) {
41
+ if (!current || typeof current !== "object") return void 0;
42
+ current = current[segment];
43
+ }
44
+ return current;
45
+ }
46
+ const baseInputClass = "w-full rounded-2xl border-2 bg-[rgb(var(--nc-surface)/0.08)] text-[rgb(var(--nc-fg))] backdrop-blur-xl shadow-[inset_0_2px_8px_rgba(0,0,0,0.3)] focus:outline-none focus:ring-4 transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed border-[rgb(var(--nc-border)/0.35)] focus:border-[rgb(var(--nc-accent-1)/0.8)] focus:ring-[rgb(var(--nc-accent-1)/0.3)] px-5 py-3 text-base placeholder:text-[rgb(var(--nc-fg-soft))]";
47
+ function CraftFormField({
48
+ name,
49
+ label,
50
+ description,
51
+ type = "text",
52
+ options = [],
53
+ placeholder,
54
+ tone,
55
+ className,
56
+ inputClassName,
57
+ labelClassName,
58
+ descriptionClassName,
59
+ rules,
60
+ disabled,
61
+ fieldProps
62
+ }) {
63
+ const { register, control, formState } = (0, import_react_hook_form.useFormContext)();
64
+ const error = getFieldError(formState.errors, name);
65
+ const errorMessage = typeof (error == null ? void 0 : error.message) === "string" ? error.message : void 0;
66
+ if (type === "hidden") {
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "hidden", ...register(name, rules) });
68
+ }
69
+ const labelNode = label ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
70
+ "label",
71
+ {
72
+ htmlFor: name,
73
+ className: (0, import_cn.cn)(
74
+ "text-sm font-semibold text-[rgb(var(--nc-fg))]",
75
+ labelClassName
76
+ ),
77
+ children: label
78
+ }
79
+ ) : null;
80
+ const descriptionNode = description ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
81
+ "p",
82
+ {
83
+ className: (0, import_cn.cn)(
84
+ "text-xs text-[rgb(var(--nc-fg-muted))]",
85
+ descriptionClassName
86
+ ),
87
+ children: description
88
+ }
89
+ ) : null;
90
+ const errorNode = errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-xs text-[rgb(var(--nc-accent-3))]", children: errorMessage }) : null;
91
+ const renderInput = () => {
92
+ if (type === "textarea") {
93
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
94
+ import_craft_textarea.CraftTextarea,
95
+ {
96
+ id: name,
97
+ placeholder,
98
+ tone,
99
+ className: inputClassName,
100
+ disabled,
101
+ ...fieldProps,
102
+ ...register(name, rules)
103
+ }
104
+ );
105
+ }
106
+ if (type === "select" || type === "multiselect") {
107
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
108
+ import_craft_select.CraftSelect,
109
+ {
110
+ id: name,
111
+ tone,
112
+ className: inputClassName,
113
+ multiple: type === "multiselect",
114
+ disabled,
115
+ ...fieldProps,
116
+ ...register(name, rules),
117
+ children: [
118
+ placeholder && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: "", disabled: true, children: placeholder }),
119
+ options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
120
+ "option",
121
+ {
122
+ value: option.value,
123
+ disabled: option.disabled,
124
+ children: option.label
125
+ },
126
+ option.value
127
+ ))
128
+ ]
129
+ }
130
+ );
131
+ }
132
+ if (type === "checkbox") {
133
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
134
+ import_craft_checkbox.CraftCheckbox,
135
+ {
136
+ tone,
137
+ label,
138
+ description,
139
+ disabled,
140
+ ...fieldProps,
141
+ ...register(name, rules)
142
+ }
143
+ );
144
+ }
145
+ if (type === "switch") {
146
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
147
+ import_craft_switch.CraftSwitch,
148
+ {
149
+ tone,
150
+ label,
151
+ disabled,
152
+ ...fieldProps,
153
+ ...register(name, rules)
154
+ }
155
+ );
156
+ }
157
+ if (type === "date") {
158
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
159
+ import_react_hook_form.Controller,
160
+ {
161
+ control,
162
+ name,
163
+ rules,
164
+ render: ({ field }) => {
165
+ var _a;
166
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
167
+ import_craft_date_picker.CraftDatePicker,
168
+ {
169
+ value: (_a = field.value) != null ? _a : "",
170
+ onChange: field.onChange,
171
+ tone,
172
+ placeholder,
173
+ ...fieldProps
174
+ }
175
+ );
176
+ }
177
+ }
178
+ );
179
+ }
180
+ if (type === "number") {
181
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
182
+ import_craft_number_input.CraftNumberInput,
183
+ {
184
+ id: name,
185
+ tone,
186
+ placeholder,
187
+ className: inputClassName,
188
+ disabled,
189
+ ...fieldProps,
190
+ ...register(name, rules)
191
+ }
192
+ );
193
+ }
194
+ if (type === "currency") {
195
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
196
+ import_craft_currency_input.CraftCurrencyInput,
197
+ {
198
+ id: name,
199
+ tone,
200
+ placeholder,
201
+ className: inputClassName,
202
+ disabled,
203
+ ...fieldProps,
204
+ ...register(name, rules)
205
+ }
206
+ );
207
+ }
208
+ if (type === "radio") {
209
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "grid gap-3", children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
210
+ "label",
211
+ {
212
+ className: (0, import_cn.cn)(
213
+ "flex items-center gap-3 rounded-2xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.08)] px-4 py-3 text-sm text-[rgb(var(--nc-fg))]",
214
+ "transition-all duration-200",
215
+ "focus-within:ring-2 focus-within:ring-[rgb(var(--nc-accent-1)/0.5)]",
216
+ option.disabled ? "opacity-60" : "cursor-pointer"
217
+ ),
218
+ "data-nc-theme": tone,
219
+ children: [
220
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
221
+ "input",
222
+ {
223
+ type: "radio",
224
+ value: option.value,
225
+ disabled: option.disabled || disabled,
226
+ className: "h-4 w-4 accent-[rgb(var(--nc-accent-1))]",
227
+ ...fieldProps,
228
+ ...register(name, rules)
229
+ }
230
+ ),
231
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: option.label })
232
+ ]
233
+ },
234
+ option.value
235
+ )) });
236
+ }
237
+ if (type === "range" || type === "slider") {
238
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
239
+ "input",
240
+ {
241
+ id: name,
242
+ type: "range",
243
+ className: (0, import_cn.cn)(
244
+ "w-full accent-[rgb(var(--nc-accent-1))]",
245
+ inputClassName
246
+ ),
247
+ disabled,
248
+ ...fieldProps,
249
+ ...register(name, rules)
250
+ }
251
+ );
252
+ }
253
+ if (type === "file" || type === "multifile") {
254
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
255
+ "input",
256
+ {
257
+ id: name,
258
+ type: "file",
259
+ multiple: type === "multifile",
260
+ className: (0, import_cn.cn)(
261
+ baseInputClass,
262
+ "file:mr-4 file:rounded-xl file:border-0 file:bg-[rgb(var(--nc-surface)/0.35)] file:px-4 file:py-2 file:text-sm file:font-semibold file:text-[rgb(var(--nc-fg))]",
263
+ inputClassName
264
+ ),
265
+ disabled,
266
+ ...fieldProps,
267
+ ...register(name, rules)
268
+ }
269
+ );
270
+ }
271
+ const inputType = type === "search" || type === "password" || type === "email" || type === "tel" || type === "url" || type === "time" || type === "datetime-local" || type === "month" || type === "week" || type === "color" ? type : "text";
272
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
273
+ import_craft_input.CraftInput,
274
+ {
275
+ id: name,
276
+ type: inputType,
277
+ placeholder,
278
+ tone,
279
+ className: inputClassName,
280
+ disabled,
281
+ ...fieldProps,
282
+ ...register(name, rules)
283
+ }
284
+ );
285
+ };
286
+ const showLabel = type !== "checkbox" && type !== "switch";
287
+ const showDescriptionAbove = type !== "checkbox" && type !== "switch";
288
+ const showDescriptionBelow = type === "switch";
289
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: (0, import_cn.cn)("space-y-2", className), "data-nc-theme": tone, children: [
290
+ showLabel ? labelNode : null,
291
+ showDescriptionAbove ? descriptionNode : null,
292
+ renderInput(),
293
+ showDescriptionBelow ? descriptionNode : null,
294
+ errorNode
295
+ ] });
296
+ }
297
+ // Annotate the CommonJS export names for ESM import in node:
298
+ 0 && (module.exports = {
299
+ CraftFormField
300
+ });
301
+ //# sourceMappingURL=craft-form-field.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/craft-form-field.tsx"],"sourcesContent":["\"use client\";\n\nimport * as React from \"react\";\nimport {\n Controller,\n type FieldValues,\n type Path,\n type RegisterOptions,\n useFormContext,\n} from \"react-hook-form\";\n\nimport { cn } from \"@/utils/cn\";\nimport type { ThemeName } from \"@/theme/theme-context\";\nimport { CraftInput } from \"@/components/craft-input\";\nimport { CraftTextarea } from \"@/components/craft-textarea\";\nimport { CraftSelect } from \"@/components/craft-select\";\nimport { CraftCheckbox } from \"@/components/craft-checkbox\";\nimport { CraftSwitch } from \"@/components/craft-switch\";\nimport { CraftDatePicker } from \"@/components/craft-date-picker\";\nimport { CraftNumberInput } from \"@/components/craft-number-input\";\nimport { CraftCurrencyInput } from \"@/components/craft-currency-input\";\n\nexport type CraftFormFieldOption = {\n label: React.ReactNode;\n value: string;\n disabled?: boolean;\n};\n\nexport type CraftFormFieldType =\n | \"text\"\n | \"number\"\n | \"password\"\n | \"textarea\"\n | \"select\"\n | \"checkbox\"\n | \"slider\"\n | \"date\"\n | \"color\"\n | \"email\"\n | \"tel\"\n | \"url\"\n | \"time\"\n | \"datetime-local\"\n | \"month\"\n | \"week\"\n | \"file\"\n | \"multifile\"\n | \"radio\"\n | \"switch\"\n | \"range\"\n | \"search\"\n | \"hidden\"\n | \"multiselect\"\n | \"currency\";\n\nexport type CraftFormFieldProps<TValues extends FieldValues = FieldValues> = {\n name: Path<TValues>;\n label?: React.ReactNode;\n description?: React.ReactNode;\n type?: CraftFormFieldType;\n options?: CraftFormFieldOption[];\n placeholder?: string;\n tone?: ThemeName;\n className?: string;\n inputClassName?: string;\n labelClassName?: string;\n descriptionClassName?: string;\n rules?: RegisterOptions<TValues>;\n disabled?: boolean;\n fieldProps?: Record<string, unknown>;\n};\n\nfunction getFieldError(errors: unknown, name: string) {\n if (!errors || typeof errors !== \"object\") return undefined;\n const segments = name.split(\".\");\n let current: unknown = errors;\n for (const segment of segments) {\n if (!current || typeof current !== \"object\") return undefined;\n current = (current as Record<string, unknown>)[segment];\n }\n return current;\n}\n\nconst baseInputClass =\n \"w-full rounded-2xl border-2 bg-[rgb(var(--nc-surface)/0.08)] text-[rgb(var(--nc-fg))] backdrop-blur-xl shadow-[inset_0_2px_8px_rgba(0,0,0,0.3)] focus:outline-none focus:ring-4 transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed border-[rgb(var(--nc-border)/0.35)] focus:border-[rgb(var(--nc-accent-1)/0.8)] focus:ring-[rgb(var(--nc-accent-1)/0.3)] px-5 py-3 text-base placeholder:text-[rgb(var(--nc-fg-soft))]\";\n\nexport function CraftFormField<TValues extends FieldValues = FieldValues>({\n name,\n label,\n description,\n type = \"text\",\n options = [],\n placeholder,\n tone,\n className,\n inputClassName,\n labelClassName,\n descriptionClassName,\n rules,\n disabled,\n fieldProps,\n}: CraftFormFieldProps<TValues>) {\n const { register, control, formState } = useFormContext<TValues>();\n const error = getFieldError(formState.errors, name);\n const errorMessage =\n typeof (error as { message?: unknown })?.message === \"string\"\n ? (error as { message: string }).message\n : undefined;\n\n if (type === \"hidden\") {\n return <input type=\"hidden\" {...register(name, rules)} />;\n }\n\n const labelNode = label ? (\n <label\n htmlFor={name}\n className={cn(\n \"text-sm font-semibold text-[rgb(var(--nc-fg))]\",\n labelClassName\n )}\n >\n {label}\n </label>\n ) : null;\n\n const descriptionNode = description ? (\n <p\n className={cn(\n \"text-xs text-[rgb(var(--nc-fg-muted))]\",\n descriptionClassName\n )}\n >\n {description}\n </p>\n ) : null;\n\n const errorNode = errorMessage ? (\n <p className=\"text-xs text-[rgb(var(--nc-accent-3))]\">{errorMessage}</p>\n ) : null;\n\n const renderInput = () => {\n if (type === \"textarea\") {\n return (\n <CraftTextarea\n id={name}\n placeholder={placeholder}\n tone={tone}\n className={inputClassName}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n }\n\n if (type === \"select\" || type === \"multiselect\") {\n return (\n <CraftSelect\n id={name}\n tone={tone}\n className={inputClassName}\n multiple={type === \"multiselect\"}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n >\n {placeholder && (\n <option value=\"\" disabled>\n {placeholder}\n </option>\n )}\n {options.map((option) => (\n <option\n key={option.value}\n value={option.value}\n disabled={option.disabled}\n >\n {option.label}\n </option>\n ))}\n </CraftSelect>\n );\n }\n\n if (type === \"checkbox\") {\n return (\n <CraftCheckbox\n tone={tone}\n label={label}\n description={description}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n }\n\n if (type === \"switch\") {\n return (\n <CraftSwitch\n tone={tone}\n label={label}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n }\n\n if (type === \"date\") {\n return (\n <Controller\n control={control}\n name={name}\n rules={rules}\n render={({ field }) => (\n <CraftDatePicker\n value={field.value ?? \"\"}\n onChange={field.onChange}\n tone={tone}\n placeholder={placeholder}\n {...(fieldProps as Record<string, unknown>)}\n />\n )}\n />\n );\n }\n\n if (type === \"number\") {\n return (\n <CraftNumberInput\n id={name}\n tone={tone}\n placeholder={placeholder}\n className={inputClassName}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n }\n\n if (type === \"currency\") {\n return (\n <CraftCurrencyInput\n id={name}\n tone={tone}\n placeholder={placeholder}\n className={inputClassName}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n }\n\n if (type === \"radio\") {\n return (\n <div className=\"grid gap-3\">\n {options.map((option) => (\n <label\n key={option.value}\n className={cn(\n \"flex items-center gap-3 rounded-2xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.08)] px-4 py-3 text-sm text-[rgb(var(--nc-fg))]\",\n \"transition-all duration-200\",\n \"focus-within:ring-2 focus-within:ring-[rgb(var(--nc-accent-1)/0.5)]\",\n option.disabled ? \"opacity-60\" : \"cursor-pointer\"\n )}\n data-nc-theme={tone}\n >\n <input\n type=\"radio\"\n value={option.value}\n disabled={option.disabled || disabled}\n className=\"h-4 w-4 accent-[rgb(var(--nc-accent-1))]\"\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n <span>{option.label}</span>\n </label>\n ))}\n </div>\n );\n }\n\n if (type === \"range\" || type === \"slider\") {\n return (\n <input\n id={name}\n type=\"range\"\n className={cn(\n \"w-full accent-[rgb(var(--nc-accent-1))]\",\n inputClassName\n )}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n }\n\n if (type === \"file\" || type === \"multifile\") {\n return (\n <input\n id={name}\n type=\"file\"\n multiple={type === \"multifile\"}\n className={cn(\n baseInputClass,\n \"file:mr-4 file:rounded-xl file:border-0 file:bg-[rgb(var(--nc-surface)/0.35)] file:px-4 file:py-2 file:text-sm file:font-semibold file:text-[rgb(var(--nc-fg))]\",\n inputClassName\n )}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n }\n\n const inputType =\n type === \"search\" ||\n type === \"password\" ||\n type === \"email\" ||\n type === \"tel\" ||\n type === \"url\" ||\n type === \"time\" ||\n type === \"datetime-local\" ||\n type === \"month\" ||\n type === \"week\" ||\n type === \"color\"\n ? type\n : \"text\";\n\n return (\n <CraftInput\n id={name}\n type={inputType}\n placeholder={placeholder}\n tone={tone}\n className={inputClassName}\n disabled={disabled}\n {...(fieldProps as Record<string, unknown>)}\n {...register(name, rules)}\n />\n );\n };\n\n const showLabel = type !== \"checkbox\" && type !== \"switch\";\n const showDescriptionAbove = type !== \"checkbox\" && type !== \"switch\";\n const showDescriptionBelow = type === \"switch\";\n\n return (\n <div className={cn(\"space-y-2\", className)} data-nc-theme={tone}>\n {showLabel ? labelNode : null}\n {showDescriptionAbove ? descriptionNode : null}\n {renderInput()}\n {showDescriptionBelow ? descriptionNode : null}\n {errorNode}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8GW;AA3GX,6BAMO;AAEP,gBAAmB;AAEnB,yBAA2B;AAC3B,4BAA8B;AAC9B,0BAA4B;AAC5B,4BAA8B;AAC9B,0BAA4B;AAC5B,+BAAgC;AAChC,gCAAiC;AACjC,kCAAmC;AAoDnC,SAAS,cAAc,QAAiB,MAAc;AACpD,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,QAAM,WAAW,KAAK,MAAM,GAAG;AAC/B,MAAI,UAAmB;AACvB,aAAW,WAAW,UAAU;AAC9B,QAAI,CAAC,WAAW,OAAO,YAAY,SAAU,QAAO;AACpD,cAAW,QAAo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A,UAAM,YACJ,SAAS,YACT,SAAS,cACT,SAAS,WACT,SAAS,SACT,SAAS,SACT,SAAS,UACT,SAAS,oBACT,SAAS,WACT,SAAS,UACT,SAAS,UACL,OACA;AAEN,WACE;AAAA,MAAC;AAAA;AAAA,QACC,IAAI;AAAA,QACJ,MAAM;AAAA,QACN;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX;AAAA,QACC,GAAI;AAAA,QACJ,GAAG,SAAS,MAAM,KAAK;AAAA;AAAA,IAC1B;AAAA,EAEJ;AAEA,QAAM,YAAY,SAAS,cAAc,SAAS;AAClD,QAAM,uBAAuB,SAAS,cAAc,SAAS;AAC7D,QAAM,uBAAuB,SAAS;AAEtC,SACE,6CAAC,SAAI,eAAW,cAAG,aAAa,SAAS,GAAG,iBAAe,MACxD;AAAA,gBAAY,YAAY;AAAA,IACxB,uBAAuB,kBAAkB;AAAA,IACzC,YAAY;AAAA,IACZ,uBAAuB,kBAAkB;AAAA,IACzC;AAAA,KACH;AAEJ;","names":[]}
@@ -0,0 +1,30 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
4
+ import { a as ThemeName } from '../theme-context-EVI9PfKv.cjs';
5
+
6
+ type CraftFormFieldOption = {
7
+ label: React.ReactNode;
8
+ value: string;
9
+ disabled?: boolean;
10
+ };
11
+ type CraftFormFieldType = "text" | "number" | "password" | "textarea" | "select" | "checkbox" | "slider" | "date" | "color" | "email" | "tel" | "url" | "time" | "datetime-local" | "month" | "week" | "file" | "multifile" | "radio" | "switch" | "range" | "search" | "hidden" | "multiselect" | "currency";
12
+ type CraftFormFieldProps<TValues extends FieldValues = FieldValues> = {
13
+ name: Path<TValues>;
14
+ label?: React.ReactNode;
15
+ description?: React.ReactNode;
16
+ type?: CraftFormFieldType;
17
+ options?: CraftFormFieldOption[];
18
+ placeholder?: string;
19
+ tone?: ThemeName;
20
+ className?: string;
21
+ inputClassName?: string;
22
+ labelClassName?: string;
23
+ descriptionClassName?: string;
24
+ rules?: RegisterOptions<TValues>;
25
+ disabled?: boolean;
26
+ fieldProps?: Record<string, unknown>;
27
+ };
28
+ declare function CraftFormField<TValues extends FieldValues = FieldValues>({ name, label, description, type, options, placeholder, tone, className, inputClassName, labelClassName, descriptionClassName, rules, disabled, fieldProps, }: CraftFormFieldProps<TValues>): react_jsx_runtime.JSX.Element;
29
+
30
+ export { CraftFormField, type CraftFormFieldOption, type CraftFormFieldProps, type CraftFormFieldType };
@@ -0,0 +1,30 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import * as React from 'react';
3
+ import { FieldValues, Path, RegisterOptions } from 'react-hook-form';
4
+ import { a as ThemeName } from '../theme-context-EVI9PfKv.js';
5
+
6
+ type CraftFormFieldOption = {
7
+ label: React.ReactNode;
8
+ value: string;
9
+ disabled?: boolean;
10
+ };
11
+ type CraftFormFieldType = "text" | "number" | "password" | "textarea" | "select" | "checkbox" | "slider" | "date" | "color" | "email" | "tel" | "url" | "time" | "datetime-local" | "month" | "week" | "file" | "multifile" | "radio" | "switch" | "range" | "search" | "hidden" | "multiselect" | "currency";
12
+ type CraftFormFieldProps<TValues extends FieldValues = FieldValues> = {
13
+ name: Path<TValues>;
14
+ label?: React.ReactNode;
15
+ description?: React.ReactNode;
16
+ type?: CraftFormFieldType;
17
+ options?: CraftFormFieldOption[];
18
+ placeholder?: string;
19
+ tone?: ThemeName;
20
+ className?: string;
21
+ inputClassName?: string;
22
+ labelClassName?: string;
23
+ descriptionClassName?: string;
24
+ rules?: RegisterOptions<TValues>;
25
+ disabled?: boolean;
26
+ fieldProps?: Record<string, unknown>;
27
+ };
28
+ declare function CraftFormField<TValues extends FieldValues = FieldValues>({ name, label, description, type, options, placeholder, tone, className, inputClassName, labelClassName, descriptionClassName, rules, disabled, fieldProps, }: CraftFormFieldProps<TValues>): react_jsx_runtime.JSX.Element;
29
+
30
+ export { CraftFormField, type CraftFormFieldOption, type CraftFormFieldProps, type CraftFormFieldType };
@@ -0,0 +1,280 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import {
4
+ Controller,
5
+ useFormContext
6
+ } from "react-hook-form";
7
+ import { cn } from "@/utils/cn";
8
+ import { CraftInput } from "@/components/craft-input";
9
+ import { CraftTextarea } from "@/components/craft-textarea";
10
+ import { CraftSelect } from "@/components/craft-select";
11
+ import { CraftCheckbox } from "@/components/craft-checkbox";
12
+ import { CraftSwitch } from "@/components/craft-switch";
13
+ import { CraftDatePicker } from "@/components/craft-date-picker";
14
+ import { CraftNumberInput } from "@/components/craft-number-input";
15
+ import { CraftCurrencyInput } from "@/components/craft-currency-input";
16
+ function getFieldError(errors, name) {
17
+ if (!errors || typeof errors !== "object") return void 0;
18
+ const segments = name.split(".");
19
+ let current = errors;
20
+ for (const segment of segments) {
21
+ if (!current || typeof current !== "object") return void 0;
22
+ current = current[segment];
23
+ }
24
+ return current;
25
+ }
26
+ const baseInputClass = "w-full rounded-2xl border-2 bg-[rgb(var(--nc-surface)/0.08)] text-[rgb(var(--nc-fg))] backdrop-blur-xl shadow-[inset_0_2px_8px_rgba(0,0,0,0.3)] focus:outline-none focus:ring-4 transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed border-[rgb(var(--nc-border)/0.35)] focus:border-[rgb(var(--nc-accent-1)/0.8)] focus:ring-[rgb(var(--nc-accent-1)/0.3)] px-5 py-3 text-base placeholder:text-[rgb(var(--nc-fg-soft))]";
27
+ function CraftFormField({
28
+ name,
29
+ label,
30
+ description,
31
+ type = "text",
32
+ options = [],
33
+ placeholder,
34
+ tone,
35
+ className,
36
+ inputClassName,
37
+ labelClassName,
38
+ descriptionClassName,
39
+ rules,
40
+ disabled,
41
+ fieldProps
42
+ }) {
43
+ const { register, control, formState } = useFormContext();
44
+ const error = getFieldError(formState.errors, name);
45
+ const errorMessage = typeof (error == null ? void 0 : error.message) === "string" ? error.message : void 0;
46
+ if (type === "hidden") {
47
+ return /* @__PURE__ */ jsx("input", { type: "hidden", ...register(name, rules) });
48
+ }
49
+ const labelNode = label ? /* @__PURE__ */ jsx(
50
+ "label",
51
+ {
52
+ htmlFor: name,
53
+ className: cn(
54
+ "text-sm font-semibold text-[rgb(var(--nc-fg))]",
55
+ labelClassName
56
+ ),
57
+ children: label
58
+ }
59
+ ) : null;
60
+ const descriptionNode = description ? /* @__PURE__ */ jsx(
61
+ "p",
62
+ {
63
+ className: cn(
64
+ "text-xs text-[rgb(var(--nc-fg-muted))]",
65
+ descriptionClassName
66
+ ),
67
+ children: description
68
+ }
69
+ ) : null;
70
+ const errorNode = errorMessage ? /* @__PURE__ */ jsx("p", { className: "text-xs text-[rgb(var(--nc-accent-3))]", children: errorMessage }) : null;
71
+ const renderInput = () => {
72
+ if (type === "textarea") {
73
+ return /* @__PURE__ */ jsx(
74
+ CraftTextarea,
75
+ {
76
+ id: name,
77
+ placeholder,
78
+ tone,
79
+ className: inputClassName,
80
+ disabled,
81
+ ...fieldProps,
82
+ ...register(name, rules)
83
+ }
84
+ );
85
+ }
86
+ if (type === "select" || type === "multiselect") {
87
+ return /* @__PURE__ */ jsxs(
88
+ CraftSelect,
89
+ {
90
+ id: name,
91
+ tone,
92
+ className: inputClassName,
93
+ multiple: type === "multiselect",
94
+ disabled,
95
+ ...fieldProps,
96
+ ...register(name, rules),
97
+ children: [
98
+ placeholder && /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: placeholder }),
99
+ options.map((option) => /* @__PURE__ */ jsx(
100
+ "option",
101
+ {
102
+ value: option.value,
103
+ disabled: option.disabled,
104
+ children: option.label
105
+ },
106
+ option.value
107
+ ))
108
+ ]
109
+ }
110
+ );
111
+ }
112
+ if (type === "checkbox") {
113
+ return /* @__PURE__ */ jsx(
114
+ CraftCheckbox,
115
+ {
116
+ tone,
117
+ label,
118
+ description,
119
+ disabled,
120
+ ...fieldProps,
121
+ ...register(name, rules)
122
+ }
123
+ );
124
+ }
125
+ if (type === "switch") {
126
+ return /* @__PURE__ */ jsx(
127
+ CraftSwitch,
128
+ {
129
+ tone,
130
+ label,
131
+ disabled,
132
+ ...fieldProps,
133
+ ...register(name, rules)
134
+ }
135
+ );
136
+ }
137
+ if (type === "date") {
138
+ return /* @__PURE__ */ jsx(
139
+ Controller,
140
+ {
141
+ control,
142
+ name,
143
+ rules,
144
+ render: ({ field }) => {
145
+ var _a;
146
+ return /* @__PURE__ */ jsx(
147
+ CraftDatePicker,
148
+ {
149
+ value: (_a = field.value) != null ? _a : "",
150
+ onChange: field.onChange,
151
+ tone,
152
+ placeholder,
153
+ ...fieldProps
154
+ }
155
+ );
156
+ }
157
+ }
158
+ );
159
+ }
160
+ if (type === "number") {
161
+ return /* @__PURE__ */ jsx(
162
+ CraftNumberInput,
163
+ {
164
+ id: name,
165
+ tone,
166
+ placeholder,
167
+ className: inputClassName,
168
+ disabled,
169
+ ...fieldProps,
170
+ ...register(name, rules)
171
+ }
172
+ );
173
+ }
174
+ if (type === "currency") {
175
+ return /* @__PURE__ */ jsx(
176
+ CraftCurrencyInput,
177
+ {
178
+ id: name,
179
+ tone,
180
+ placeholder,
181
+ className: inputClassName,
182
+ disabled,
183
+ ...fieldProps,
184
+ ...register(name, rules)
185
+ }
186
+ );
187
+ }
188
+ if (type === "radio") {
189
+ return /* @__PURE__ */ jsx("div", { className: "grid gap-3", children: options.map((option) => /* @__PURE__ */ jsxs(
190
+ "label",
191
+ {
192
+ className: cn(
193
+ "flex items-center gap-3 rounded-2xl border border-[rgb(var(--nc-border)/0.35)] bg-[rgb(var(--nc-surface)/0.08)] px-4 py-3 text-sm text-[rgb(var(--nc-fg))]",
194
+ "transition-all duration-200",
195
+ "focus-within:ring-2 focus-within:ring-[rgb(var(--nc-accent-1)/0.5)]",
196
+ option.disabled ? "opacity-60" : "cursor-pointer"
197
+ ),
198
+ "data-nc-theme": tone,
199
+ children: [
200
+ /* @__PURE__ */ jsx(
201
+ "input",
202
+ {
203
+ type: "radio",
204
+ value: option.value,
205
+ disabled: option.disabled || disabled,
206
+ className: "h-4 w-4 accent-[rgb(var(--nc-accent-1))]",
207
+ ...fieldProps,
208
+ ...register(name, rules)
209
+ }
210
+ ),
211
+ /* @__PURE__ */ jsx("span", { children: option.label })
212
+ ]
213
+ },
214
+ option.value
215
+ )) });
216
+ }
217
+ if (type === "range" || type === "slider") {
218
+ return /* @__PURE__ */ jsx(
219
+ "input",
220
+ {
221
+ id: name,
222
+ type: "range",
223
+ className: cn(
224
+ "w-full accent-[rgb(var(--nc-accent-1))]",
225
+ inputClassName
226
+ ),
227
+ disabled,
228
+ ...fieldProps,
229
+ ...register(name, rules)
230
+ }
231
+ );
232
+ }
233
+ if (type === "file" || type === "multifile") {
234
+ return /* @__PURE__ */ jsx(
235
+ "input",
236
+ {
237
+ id: name,
238
+ type: "file",
239
+ multiple: type === "multifile",
240
+ className: cn(
241
+ baseInputClass,
242
+ "file:mr-4 file:rounded-xl file:border-0 file:bg-[rgb(var(--nc-surface)/0.35)] file:px-4 file:py-2 file:text-sm file:font-semibold file:text-[rgb(var(--nc-fg))]",
243
+ inputClassName
244
+ ),
245
+ disabled,
246
+ ...fieldProps,
247
+ ...register(name, rules)
248
+ }
249
+ );
250
+ }
251
+ const inputType = type === "search" || type === "password" || type === "email" || type === "tel" || type === "url" || type === "time" || type === "datetime-local" || type === "month" || type === "week" || type === "color" ? type : "text";
252
+ return /* @__PURE__ */ jsx(
253
+ CraftInput,
254
+ {
255
+ id: name,
256
+ type: inputType,
257
+ placeholder,
258
+ tone,
259
+ className: inputClassName,
260
+ disabled,
261
+ ...fieldProps,
262
+ ...register(name, rules)
263
+ }
264
+ );
265
+ };
266
+ const showLabel = type !== "checkbox" && type !== "switch";
267
+ const showDescriptionAbove = type !== "checkbox" && type !== "switch";
268
+ const showDescriptionBelow = type === "switch";
269
+ return /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", className), "data-nc-theme": tone, children: [
270
+ showLabel ? labelNode : null,
271
+ showDescriptionAbove ? descriptionNode : null,
272
+ renderInput(),
273
+ showDescriptionBelow ? descriptionNode : null,
274
+ errorNode
275
+ ] });
276
+ }
277
+ export {
278
+ CraftFormField
279
+ };
280
+ //# sourceMappingURL=craft-form-field.js.map