@timeax/form-palette 0.0.3 → 0.0.4

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 (503) hide show
  1. package/dist/adapters/axios.d.ts +21 -0
  2. package/dist/adapters/axios.d.ts.map +1 -0
  3. package/dist/adapters/axios.js +74 -0
  4. package/dist/adapters/axios.js.map +1 -0
  5. package/dist/adapters/index.d.ts +35 -0
  6. package/dist/adapters/index.d.ts.map +1 -0
  7. package/dist/adapters/index.js +74 -0
  8. package/dist/adapters/index.js.map +1 -0
  9. package/dist/adapters/inertia.d.ts +24 -0
  10. package/dist/adapters/inertia.d.ts.map +1 -0
  11. package/dist/adapters/inertia.js +126 -0
  12. package/dist/adapters/inertia.js.map +1 -0
  13. package/dist/core/adapter-registry.d.ts +30 -0
  14. package/dist/core/adapter-registry.d.ts.map +1 -0
  15. package/{src/core/adapter-registry.ts → dist/core/adapter-registry.js} +10 -28
  16. package/dist/core/adapter-registry.js.map +1 -0
  17. package/{src/core/bound/bind-host.ts → dist/core/bound/bind-host.d.ts} +2 -3
  18. package/dist/core/bound/bind-host.d.ts.map +1 -0
  19. package/dist/core/bound/bind-host.js +2 -0
  20. package/dist/core/bound/bind-host.js.map +1 -0
  21. package/dist/core/bound/observe-bound-field.d.ts +21 -0
  22. package/dist/core/bound/observe-bound-field.d.ts.map +1 -0
  23. package/dist/core/bound/observe-bound-field.js +116 -0
  24. package/dist/core/bound/observe-bound-field.js.map +1 -0
  25. package/dist/core/bound/wait-for-bound-field.d.ts +5 -0
  26. package/dist/core/bound/wait-for-bound-field.d.ts.map +1 -0
  27. package/dist/core/bound/wait-for-bound-field.js +35 -0
  28. package/dist/core/bound/wait-for-bound-field.js.map +1 -0
  29. package/{src/core/context.ts → dist/core/context.d.ts} +2 -6
  30. package/dist/core/context.d.ts.map +1 -0
  31. package/dist/core/context.js +11 -0
  32. package/dist/core/context.js.map +1 -0
  33. package/dist/core/core-provider.d.ts +22 -0
  34. package/dist/core/core-provider.d.ts.map +1 -0
  35. package/{src/core/core-provider.tsx → dist/core/core-provider.js} +209 -364
  36. package/dist/core/core-provider.js.map +1 -0
  37. package/dist/core/core-root.d.ts +26 -0
  38. package/dist/core/core-root.d.ts.map +1 -0
  39. package/dist/core/core-root.js +38 -0
  40. package/dist/core/core-root.js.map +1 -0
  41. package/dist/core/core-shell.d.ts +22 -0
  42. package/dist/core/core-shell.d.ts.map +1 -0
  43. package/dist/core/core-shell.js +8 -0
  44. package/dist/core/core-shell.js.map +1 -0
  45. package/{src/core/errors/error-strip.tsx → dist/core/errors/error-strip.d.ts} +2 -39
  46. package/dist/core/errors/error-strip.d.ts.map +1 -0
  47. package/dist/core/errors/error-strip.js +18 -0
  48. package/dist/core/errors/error-strip.js.map +1 -0
  49. package/dist/core/errors/index.d.ts +4 -0
  50. package/dist/core/errors/index.d.ts.map +1 -0
  51. package/dist/core/errors/index.js +4 -0
  52. package/dist/core/errors/index.js.map +1 -0
  53. package/dist/core/errors/map-error-bag.d.ts +24 -0
  54. package/dist/core/errors/map-error-bag.d.ts.map +1 -0
  55. package/{src/core/errors/map-error-bag.ts → dist/core/errors/map-error-bag.js} +10 -22
  56. package/dist/core/errors/map-error-bag.js.map +1 -0
  57. package/dist/core/errors/map-zod.d.ts +18 -0
  58. package/dist/core/errors/map-zod.d.ts.map +1 -0
  59. package/{src/core/errors/map-zod.ts → dist/core/errors/map-zod.js} +7 -19
  60. package/dist/core/errors/map-zod.js.map +1 -0
  61. package/dist/core/hooks/use-button.d.ts +73 -0
  62. package/dist/core/hooks/use-button.d.ts.map +1 -0
  63. package/dist/core/hooks/use-button.js +116 -0
  64. package/dist/core/hooks/use-button.js.map +1 -0
  65. package/dist/core/hooks/use-core-context.d.ts +9 -0
  66. package/dist/core/hooks/use-core-context.d.ts.map +1 -0
  67. package/{src/core/hooks/use-core-context.ts → dist/core/hooks/use-core-context.js} +3 -6
  68. package/dist/core/hooks/use-core-context.js.map +1 -0
  69. package/dist/core/hooks/use-core-utility.d.ts +1 -0
  70. package/dist/core/hooks/use-core-utility.d.ts.map +1 -0
  71. package/dist/core/hooks/use-core-utility.js +2 -0
  72. package/dist/core/hooks/use-core-utility.js.map +1 -0
  73. package/{src/core/hooks/use-core.ts → dist/core/hooks/use-core.d.ts} +9 -13
  74. package/dist/core/hooks/use-core.d.ts.map +1 -0
  75. package/dist/core/hooks/use-core.js +11 -0
  76. package/dist/core/hooks/use-core.js.map +1 -0
  77. package/dist/core/hooks/use-field.d.ts +141 -0
  78. package/dist/core/hooks/use-field.d.ts.map +1 -0
  79. package/dist/core/hooks/use-field.js +256 -0
  80. package/dist/core/hooks/use-field.js.map +1 -0
  81. package/dist/core/hooks/use-optional-field.d.ts +9 -0
  82. package/dist/core/hooks/use-optional-field.d.ts.map +1 -0
  83. package/dist/core/hooks/use-optional-field.js +146 -0
  84. package/dist/core/hooks/use-optional-field.js.map +1 -0
  85. package/dist/core/index.d.ts +11 -0
  86. package/dist/core/index.d.ts.map +1 -0
  87. package/dist/core/index.js +11 -0
  88. package/dist/core/index.js.map +1 -0
  89. package/dist/core/registry/binder-registry.d.ts +38 -0
  90. package/dist/core/registry/binder-registry.d.ts.map +1 -0
  91. package/dist/core/registry/binder-registry.js +52 -0
  92. package/dist/core/registry/binder-registry.js.map +1 -0
  93. package/dist/core/registry/field-registry.d.ts +86 -0
  94. package/dist/core/registry/field-registry.d.ts.map +1 -0
  95. package/{src/core/registry/field-registry.ts → dist/core/registry/field-registry.js} +56 -70
  96. package/dist/core/registry/field-registry.js.map +1 -0
  97. package/dist/core/test.d.ts +2 -0
  98. package/dist/core/test.d.ts.map +1 -0
  99. package/dist/core/test.js +9 -0
  100. package/dist/core/test.js.map +1 -0
  101. package/dist/index.d.ts +15 -0
  102. package/dist/index.d.ts.map +1 -0
  103. package/{src/index.ts → dist/index.js} +5 -47
  104. package/dist/index.js.map +1 -0
  105. package/{src/input/index.ts → dist/input/index.d.ts} +1 -2
  106. package/dist/input/index.d.ts.map +1 -0
  107. package/dist/input/index.js +3 -0
  108. package/dist/input/index.js.map +1 -0
  109. package/dist/input/input-field.d.ts +15 -0
  110. package/dist/input/input-field.d.ts.map +1 -0
  111. package/dist/input/input-field.js +413 -0
  112. package/dist/input/input-field.js.map +1 -0
  113. package/dist/input/input-layout-graph.d.ts +77 -0
  114. package/dist/input/input-layout-graph.d.ts.map +1 -0
  115. package/dist/input/input-layout-graph.js +108 -0
  116. package/dist/input/input-layout-graph.js.map +1 -0
  117. package/{src/input/input-props.ts → dist/input/input-props.d.ts} +22 -84
  118. package/dist/input/input-props.d.ts.map +1 -0
  119. package/dist/input/input-props.js +4 -0
  120. package/dist/input/input-props.js.map +1 -0
  121. package/dist/lib/get-global-countries.d.ts +3 -0
  122. package/dist/lib/get-global-countries.d.ts.map +1 -0
  123. package/dist/lib/get-global-countries.js +70 -0
  124. package/dist/lib/get-global-countries.js.map +1 -0
  125. package/dist/lib/utils.d.ts +3 -0
  126. package/dist/lib/utils.d.ts.map +1 -0
  127. package/dist/lib/utils.js +6 -0
  128. package/dist/lib/utils.js.map +1 -0
  129. package/dist/presets/index.d.ts +1 -0
  130. package/dist/presets/index.d.ts.map +1 -0
  131. package/dist/presets/index.js +2 -0
  132. package/dist/presets/index.js.map +1 -0
  133. package/dist/presets/shadcn-preset.d.ts +1 -0
  134. package/dist/presets/shadcn-preset.d.ts.map +1 -0
  135. package/dist/presets/shadcn-preset.js +2 -0
  136. package/dist/presets/shadcn-preset.js.map +1 -0
  137. package/dist/presets/shadcn-variants/checkbox.d.ts +212 -0
  138. package/dist/presets/shadcn-variants/checkbox.d.ts.map +1 -0
  139. package/dist/presets/shadcn-variants/checkbox.js +315 -0
  140. package/dist/presets/shadcn-variants/checkbox.js.map +1 -0
  141. package/dist/presets/shadcn-variants/chips.d.ts +154 -0
  142. package/dist/presets/shadcn-variants/chips.d.ts.map +1 -0
  143. package/dist/presets/shadcn-variants/chips.js +266 -0
  144. package/dist/presets/shadcn-variants/chips.js.map +1 -0
  145. package/dist/presets/shadcn-variants/color.d.ts +63 -0
  146. package/dist/presets/shadcn-variants/color.d.ts.map +1 -0
  147. package/dist/presets/shadcn-variants/color.js +96 -0
  148. package/dist/presets/shadcn-variants/color.js.map +1 -0
  149. package/dist/presets/shadcn-variants/custom.d.ts +94 -0
  150. package/dist/presets/shadcn-variants/custom.d.ts.map +1 -0
  151. package/dist/presets/shadcn-variants/custom.js +80 -0
  152. package/dist/presets/shadcn-variants/custom.js.map +1 -0
  153. package/dist/presets/shadcn-variants/date.d.ts +114 -0
  154. package/dist/presets/shadcn-variants/date.d.ts.map +1 -0
  155. package/dist/presets/shadcn-variants/date.js +414 -0
  156. package/dist/presets/shadcn-variants/date.js.map +1 -0
  157. package/dist/presets/shadcn-variants/file.d.ts +79 -0
  158. package/dist/presets/shadcn-variants/file.d.ts.map +1 -0
  159. package/dist/presets/shadcn-variants/file.js +289 -0
  160. package/dist/presets/shadcn-variants/file.js.map +1 -0
  161. package/dist/presets/shadcn-variants/keyvalue.d.ts +35 -0
  162. package/dist/presets/shadcn-variants/keyvalue.d.ts.map +1 -0
  163. package/dist/presets/shadcn-variants/keyvalue.js +215 -0
  164. package/dist/presets/shadcn-variants/keyvalue.js.map +1 -0
  165. package/dist/presets/shadcn-variants/multiselect.d.ts +210 -0
  166. package/dist/presets/shadcn-variants/multiselect.d.ts.map +1 -0
  167. package/dist/presets/shadcn-variants/multiselect.js +352 -0
  168. package/dist/presets/shadcn-variants/multiselect.js.map +1 -0
  169. package/dist/presets/shadcn-variants/number.d.ts +31 -0
  170. package/dist/presets/shadcn-variants/number.d.ts.map +1 -0
  171. package/dist/presets/shadcn-variants/number.js +64 -0
  172. package/dist/presets/shadcn-variants/number.js.map +1 -0
  173. package/dist/presets/shadcn-variants/password.d.ts +195 -0
  174. package/dist/presets/shadcn-variants/password.d.ts.map +1 -0
  175. package/dist/presets/shadcn-variants/password.js +296 -0
  176. package/dist/presets/shadcn-variants/password.js.map +1 -0
  177. package/dist/presets/shadcn-variants/phone.d.ts +69 -0
  178. package/dist/presets/shadcn-variants/phone.d.ts.map +1 -0
  179. package/dist/presets/shadcn-variants/phone.js +308 -0
  180. package/dist/presets/shadcn-variants/phone.js.map +1 -0
  181. package/dist/presets/shadcn-variants/radio.d.ts +172 -0
  182. package/dist/presets/shadcn-variants/radio.d.ts.map +1 -0
  183. package/dist/presets/shadcn-variants/radio.js +192 -0
  184. package/dist/presets/shadcn-variants/radio.js.map +1 -0
  185. package/dist/presets/shadcn-variants/select.d.ts +203 -0
  186. package/dist/presets/shadcn-variants/select.d.ts.map +1 -0
  187. package/dist/presets/shadcn-variants/select.js +285 -0
  188. package/dist/presets/shadcn-variants/select.js.map +1 -0
  189. package/dist/presets/shadcn-variants/slider.d.ts +131 -0
  190. package/dist/presets/shadcn-variants/slider.d.ts.map +1 -0
  191. package/dist/presets/shadcn-variants/slider.js +151 -0
  192. package/dist/presets/shadcn-variants/slider.js.map +1 -0
  193. package/dist/presets/shadcn-variants/text.d.ts +155 -0
  194. package/dist/presets/shadcn-variants/text.d.ts.map +1 -0
  195. package/dist/presets/shadcn-variants/text.js +98 -0
  196. package/dist/presets/shadcn-variants/text.js.map +1 -0
  197. package/dist/presets/shadcn-variants/textarea.d.ts +18 -0
  198. package/dist/presets/shadcn-variants/textarea.d.ts.map +1 -0
  199. package/dist/presets/shadcn-variants/textarea.js +24 -0
  200. package/dist/presets/shadcn-variants/textarea.js.map +1 -0
  201. package/dist/presets/shadcn-variants/toggle.d.ts +61 -0
  202. package/dist/presets/shadcn-variants/toggle.d.ts.map +1 -0
  203. package/dist/presets/shadcn-variants/toggle.js +67 -0
  204. package/dist/presets/shadcn-variants/toggle.js.map +1 -0
  205. package/dist/presets/shadcn-variants/treeselect.d.ts +81 -0
  206. package/dist/presets/shadcn-variants/treeselect.d.ts.map +1 -0
  207. package/dist/presets/shadcn-variants/treeselect.js +317 -0
  208. package/dist/presets/shadcn-variants/treeselect.js.map +1 -0
  209. package/dist/presets/ui/badge.d.ts +10 -0
  210. package/dist/presets/ui/badge.d.ts.map +1 -0
  211. package/dist/presets/ui/badge.js +23 -0
  212. package/dist/presets/ui/badge.js.map +1 -0
  213. package/dist/presets/ui/button.d.ts +11 -0
  214. package/dist/presets/ui/button.d.ts.map +1 -0
  215. package/dist/presets/ui/button.js +34 -0
  216. package/dist/presets/ui/button.js.map +1 -0
  217. package/dist/presets/ui/calendar.d.ts +9 -0
  218. package/dist/presets/ui/calendar.d.ts.map +1 -0
  219. package/dist/presets/ui/calendar.js +76 -0
  220. package/dist/presets/ui/calendar.js.map +1 -0
  221. package/dist/presets/ui/checkbox.d.ts +18 -0
  222. package/dist/presets/ui/checkbox.d.ts.map +1 -0
  223. package/dist/presets/ui/checkbox.js +61 -0
  224. package/dist/presets/ui/checkbox.js.map +1 -0
  225. package/dist/presets/ui/custom.d.ts +1 -0
  226. package/dist/presets/ui/custom.d.ts.map +1 -0
  227. package/dist/presets/ui/custom.js +2 -0
  228. package/dist/presets/ui/custom.js.map +1 -0
  229. package/dist/presets/ui/dialog.d.ts +16 -0
  230. package/dist/presets/ui/dialog.d.ts.map +1 -0
  231. package/dist/presets/ui/dialog.js +36 -0
  232. package/dist/presets/ui/dialog.js.map +1 -0
  233. package/dist/presets/ui/field.d.ts +25 -0
  234. package/dist/presets/ui/field.d.ts.map +1 -0
  235. package/dist/presets/ui/field.js +76 -0
  236. package/dist/presets/ui/field.js.map +1 -0
  237. package/dist/presets/ui/input-mask.d.ts +34 -0
  238. package/dist/presets/ui/input-mask.d.ts.map +1 -0
  239. package/dist/presets/ui/input-mask.js +561 -0
  240. package/dist/presets/ui/input-mask.js.map +1 -0
  241. package/dist/presets/ui/input-otp.d.ts +12 -0
  242. package/dist/presets/ui/input-otp.d.ts.map +1 -0
  243. package/dist/presets/ui/input-otp.js +22 -0
  244. package/dist/presets/ui/input-otp.js.map +1 -0
  245. package/dist/presets/ui/input.d.ts +83 -0
  246. package/dist/presets/ui/input.d.ts.map +1 -0
  247. package/dist/presets/ui/input.js +436 -0
  248. package/dist/presets/ui/input.js.map +1 -0
  249. package/dist/presets/ui/label.d.ts +5 -0
  250. package/dist/presets/ui/label.d.ts.map +1 -0
  251. package/dist/presets/ui/label.js +8 -0
  252. package/dist/presets/ui/label.js.map +1 -0
  253. package/dist/presets/ui/number.d.ts +60 -0
  254. package/dist/presets/ui/number.d.ts.map +1 -0
  255. package/dist/presets/ui/number.js +1078 -0
  256. package/dist/presets/ui/number.js.map +1 -0
  257. package/dist/presets/ui/popover.d.ts +8 -0
  258. package/dist/presets/ui/popover.d.ts.map +1 -0
  259. package/dist/presets/ui/popover.js +17 -0
  260. package/dist/presets/ui/popover.js.map +1 -0
  261. package/dist/presets/ui/radio-group.d.ts +6 -0
  262. package/dist/presets/ui/radio-group.d.ts.map +1 -0
  263. package/dist/presets/ui/radio-group.js +12 -0
  264. package/dist/presets/ui/radio-group.js.map +1 -0
  265. package/dist/presets/ui/scroll-area.d.ts +6 -0
  266. package/dist/presets/ui/scroll-area.d.ts.map +1 -0
  267. package/dist/presets/ui/scroll-area.js +13 -0
  268. package/dist/presets/ui/scroll-area.js.map +1 -0
  269. package/dist/presets/ui/select.d.ts +21 -0
  270. package/dist/presets/ui/select.d.ts.map +1 -0
  271. package/dist/presets/ui/select.js +38 -0
  272. package/dist/presets/ui/select.js.map +1 -0
  273. package/dist/presets/ui/separator.d.ts +5 -0
  274. package/dist/presets/ui/separator.d.ts.map +1 -0
  275. package/dist/presets/ui/separator.js +9 -0
  276. package/dist/presets/ui/separator.js.map +1 -0
  277. package/dist/presets/ui/slider.d.ts +5 -0
  278. package/dist/presets/ui/slider.d.ts.map +1 -0
  279. package/dist/presets/ui/slider.js +14 -0
  280. package/dist/presets/ui/slider.js.map +1 -0
  281. package/dist/presets/ui/switch.d.ts +7 -0
  282. package/dist/presets/ui/switch.d.ts.map +1 -0
  283. package/dist/presets/ui/switch.js +9 -0
  284. package/dist/presets/ui/switch.js.map +1 -0
  285. package/dist/presets/ui/textarea.d.ts +76 -0
  286. package/dist/presets/ui/textarea.d.ts.map +1 -0
  287. package/dist/presets/ui/textarea.js +291 -0
  288. package/dist/presets/ui/textarea.js.map +1 -0
  289. package/dist/presets/ui/time-dropdowns.d.ts +58 -0
  290. package/dist/presets/ui/time-dropdowns.d.ts.map +1 -0
  291. package/dist/presets/ui/time-dropdowns.js +133 -0
  292. package/dist/presets/ui/time-dropdowns.js.map +1 -0
  293. package/{src/schema/adapter.ts → dist/schema/adapter.d.ts} +7 -35
  294. package/dist/schema/adapter.d.ts.map +1 -0
  295. package/dist/schema/adapter.js +3 -0
  296. package/dist/schema/adapter.js.map +1 -0
  297. package/{src/schema/core.ts → dist/schema/core.d.ts} +17 -117
  298. package/dist/schema/core.d.ts.map +1 -0
  299. package/dist/schema/core.js +4 -0
  300. package/dist/schema/core.js.map +1 -0
  301. package/dist/schema/field-map.d.ts +1 -0
  302. package/dist/schema/field-map.d.ts.map +1 -0
  303. package/dist/schema/field-map.js +2 -0
  304. package/dist/schema/field-map.js.map +1 -0
  305. package/{src/schema/field.ts → dist/schema/field.d.ts} +1 -34
  306. package/dist/schema/field.d.ts.map +1 -0
  307. package/dist/schema/field.js +4 -0
  308. package/dist/schema/field.js.map +1 -0
  309. package/dist/schema/index.d.ts +1 -0
  310. package/dist/schema/index.d.ts.map +1 -0
  311. package/dist/schema/index.js +2 -0
  312. package/dist/schema/index.js.map +1 -0
  313. package/{src/schema/input-field.ts → dist/schema/input-field.d.ts} +6 -43
  314. package/dist/schema/input-field.d.ts.map +1 -0
  315. package/dist/schema/input-field.js +3 -0
  316. package/dist/schema/input-field.js.map +1 -0
  317. package/dist/schema/presets.d.ts +1 -0
  318. package/dist/schema/presets.d.ts.map +1 -0
  319. package/dist/schema/presets.js +2 -0
  320. package/dist/schema/presets.js.map +1 -0
  321. package/{src/schema/variant.ts → dist/schema/variant.d.ts} +24 -64
  322. package/dist/schema/variant.d.ts.map +1 -0
  323. package/dist/schema/variant.js +3 -0
  324. package/dist/schema/variant.js.map +1 -0
  325. package/dist/variants/core/checkbox.d.ts +15 -0
  326. package/dist/variants/core/checkbox.d.ts.map +1 -0
  327. package/dist/variants/core/checkbox.js +27 -0
  328. package/dist/variants/core/checkbox.js.map +1 -0
  329. package/dist/variants/core/chips.d.ts +3 -0
  330. package/dist/variants/core/chips.d.ts.map +1 -0
  331. package/dist/variants/core/chips.js +20 -0
  332. package/dist/variants/core/chips.js.map +1 -0
  333. package/dist/variants/core/color.d.ts +3 -0
  334. package/dist/variants/core/color.d.ts.map +1 -0
  335. package/dist/variants/core/color.js +14 -0
  336. package/dist/variants/core/color.js.map +1 -0
  337. package/dist/variants/core/custom.d.ts +11 -0
  338. package/dist/variants/core/custom.d.ts.map +1 -0
  339. package/{src/variants/core/custom.tsx → dist/variants/core/custom.js} +15 -18
  340. package/dist/variants/core/custom.js.map +1 -0
  341. package/dist/variants/core/date.d.ts +3 -0
  342. package/dist/variants/core/date.d.ts.map +1 -0
  343. package/dist/variants/core/date.js +20 -0
  344. package/dist/variants/core/date.js.map +1 -0
  345. package/dist/variants/core/file.d.ts +3 -0
  346. package/dist/variants/core/file.d.ts.map +1 -0
  347. package/dist/variants/core/file.js +6 -0
  348. package/dist/variants/core/file.js.map +1 -0
  349. package/dist/variants/core/keyvalue.d.ts +3 -0
  350. package/dist/variants/core/keyvalue.d.ts.map +1 -0
  351. package/dist/variants/core/keyvalue.js +9 -0
  352. package/dist/variants/core/keyvalue.js.map +1 -0
  353. package/dist/variants/core/multiselect.d.ts +11 -0
  354. package/dist/variants/core/multiselect.d.ts.map +1 -0
  355. package/dist/variants/core/multiselect.js +15 -0
  356. package/dist/variants/core/multiselect.js.map +1 -0
  357. package/dist/variants/core/number.d.ts +38 -0
  358. package/dist/variants/core/number.d.ts.map +1 -0
  359. package/dist/variants/core/number.js +62 -0
  360. package/dist/variants/core/number.js.map +1 -0
  361. package/dist/variants/core/password.d.ts +11 -0
  362. package/dist/variants/core/password.d.ts.map +1 -0
  363. package/dist/variants/core/password.js +29 -0
  364. package/dist/variants/core/password.js.map +1 -0
  365. package/dist/variants/core/phone.d.ts +3 -0
  366. package/dist/variants/core/phone.d.ts.map +1 -0
  367. package/dist/variants/core/phone.js +14 -0
  368. package/dist/variants/core/phone.js.map +1 -0
  369. package/dist/variants/core/radio.d.ts +8 -0
  370. package/dist/variants/core/radio.d.ts.map +1 -0
  371. package/dist/variants/core/radio.js +34 -0
  372. package/dist/variants/core/radio.js.map +1 -0
  373. package/dist/variants/core/select.d.ts +5 -0
  374. package/dist/variants/core/select.d.ts.map +1 -0
  375. package/dist/variants/core/select.js +11 -0
  376. package/dist/variants/core/select.js.map +1 -0
  377. package/dist/variants/core/slider.d.ts +19 -0
  378. package/dist/variants/core/slider.d.ts.map +1 -0
  379. package/dist/variants/core/slider.js +36 -0
  380. package/dist/variants/core/slider.js.map +1 -0
  381. package/dist/variants/core/text.d.ts +38 -0
  382. package/dist/variants/core/text.d.ts.map +1 -0
  383. package/{src/variants/core/text.tsx → dist/variants/core/text.js} +4 -56
  384. package/dist/variants/core/text.js.map +1 -0
  385. package/dist/variants/core/textarea.d.ts +3 -0
  386. package/dist/variants/core/textarea.d.ts.map +1 -0
  387. package/dist/variants/core/textarea.js +20 -0
  388. package/dist/variants/core/textarea.js.map +1 -0
  389. package/dist/variants/core/toggle.d.ts +6 -0
  390. package/dist/variants/core/toggle.d.ts.map +1 -0
  391. package/dist/variants/core/toggle.js +41 -0
  392. package/dist/variants/core/toggle.js.map +1 -0
  393. package/dist/variants/core/treeselect.d.ts +4 -0
  394. package/dist/variants/core/treeselect.d.ts.map +1 -0
  395. package/dist/variants/core/treeselect.js +7 -0
  396. package/dist/variants/core/treeselect.js.map +1 -0
  397. package/dist/variants/helpers/selection-summary.d.ts +24 -0
  398. package/dist/variants/helpers/selection-summary.d.ts.map +1 -0
  399. package/dist/variants/helpers/selection-summary.js +105 -0
  400. package/dist/variants/helpers/selection-summary.js.map +1 -0
  401. package/dist/variants/index.d.ts +16 -0
  402. package/dist/variants/index.d.ts.map +1 -0
  403. package/{src/variants/index.ts → dist/variants/index.js} +7 -27
  404. package/dist/variants/index.js.map +1 -0
  405. package/dist/variants/registry.d.ts +19 -0
  406. package/dist/variants/registry.d.ts.map +1 -0
  407. package/dist/variants/registry.js +29 -0
  408. package/dist/variants/registry.js.map +1 -0
  409. package/dist/variants/select-shared.d.ts +1 -0
  410. package/dist/variants/select-shared.d.ts.map +1 -0
  411. package/dist/variants/select-shared.js +2 -0
  412. package/dist/variants/select-shared.js.map +1 -0
  413. package/{src/variants/shared.ts → dist/variants/shared.d.ts} +3 -22
  414. package/dist/variants/shared.d.ts.map +1 -0
  415. package/dist/variants/shared.js +3 -0
  416. package/dist/variants/shared.js.map +1 -0
  417. package/package.json +4 -4
  418. package/.scaffold-cache.json +0 -537
  419. package/src/.scaffold-cache.json +0 -544
  420. package/src/adapters/axios.ts +0 -117
  421. package/src/adapters/index.ts +0 -91
  422. package/src/adapters/inertia.ts +0 -187
  423. package/src/core/bound/observe-bound-field.ts +0 -172
  424. package/src/core/bound/wait-for-bound-field.ts +0 -57
  425. package/src/core/core-root.tsx +0 -72
  426. package/src/core/core-shell.tsx +0 -44
  427. package/src/core/errors/index.ts +0 -2
  428. package/src/core/hooks/use-button.ts +0 -220
  429. package/src/core/hooks/use-core-utility.ts +0 -0
  430. package/src/core/hooks/use-field.ts +0 -497
  431. package/src/core/hooks/use-optional-field.ts +0 -28
  432. package/src/core/index.ts +0 -0
  433. package/src/core/registry/binder-registry.ts +0 -82
  434. package/src/core/test.tsx +0 -17
  435. package/src/global.d.ts +0 -14
  436. package/src/input/input-field.tsx +0 -854
  437. package/src/input/input-layout-graph.ts +0 -230
  438. package/src/lib/get-global-countries.ts +0 -87
  439. package/src/lib/utils.ts +0 -6
  440. package/src/presets/index.ts +0 -0
  441. package/src/presets/shadcn-preset.ts +0 -0
  442. package/src/presets/shadcn-variants/checkbox.tsx +0 -849
  443. package/src/presets/shadcn-variants/chips.tsx +0 -756
  444. package/src/presets/shadcn-variants/color.tsx +0 -284
  445. package/src/presets/shadcn-variants/custom.tsx +0 -227
  446. package/src/presets/shadcn-variants/date.tsx +0 -796
  447. package/src/presets/shadcn-variants/file.tsx +0 -764
  448. package/src/presets/shadcn-variants/keyvalue.tsx +0 -556
  449. package/src/presets/shadcn-variants/multiselect.tsx +0 -1132
  450. package/src/presets/shadcn-variants/number.tsx +0 -176
  451. package/src/presets/shadcn-variants/password.tsx +0 -737
  452. package/src/presets/shadcn-variants/phone.tsx +0 -628
  453. package/src/presets/shadcn-variants/radio.tsx +0 -578
  454. package/src/presets/shadcn-variants/select.tsx +0 -956
  455. package/src/presets/shadcn-variants/slider.tsx +0 -622
  456. package/src/presets/shadcn-variants/text.tsx +0 -343
  457. package/src/presets/shadcn-variants/textarea.tsx +0 -66
  458. package/src/presets/shadcn-variants/toggle.tsx +0 -218
  459. package/src/presets/shadcn-variants/treeselect.tsx +0 -784
  460. package/src/presets/ui/badge.tsx +0 -46
  461. package/src/presets/ui/button.tsx +0 -60
  462. package/src/presets/ui/calendar.tsx +0 -214
  463. package/src/presets/ui/checkbox.tsx +0 -115
  464. package/src/presets/ui/custom.tsx +0 -0
  465. package/src/presets/ui/dialog.tsx +0 -141
  466. package/src/presets/ui/field.tsx +0 -246
  467. package/src/presets/ui/input-mask.tsx +0 -739
  468. package/src/presets/ui/input-otp.tsx +0 -77
  469. package/src/presets/ui/input.tsx +0 -1011
  470. package/src/presets/ui/label.tsx +0 -22
  471. package/src/presets/ui/number.tsx +0 -1370
  472. package/src/presets/ui/popover.tsx +0 -46
  473. package/src/presets/ui/radio-group.tsx +0 -43
  474. package/src/presets/ui/scroll-area.tsx +0 -56
  475. package/src/presets/ui/select.tsx +0 -190
  476. package/src/presets/ui/separator.tsx +0 -28
  477. package/src/presets/ui/slider.tsx +0 -61
  478. package/src/presets/ui/switch.tsx +0 -32
  479. package/src/presets/ui/textarea.tsx +0 -634
  480. package/src/presets/ui/time-dropdowns.tsx +0 -350
  481. package/src/schema/field-map.ts +0 -0
  482. package/src/schema/index.ts +0 -0
  483. package/src/schema/presets.ts +0 -0
  484. package/src/variants/core/checkbox.tsx +0 -54
  485. package/src/variants/core/chips.tsx +0 -22
  486. package/src/variants/core/color.tsx +0 -16
  487. package/src/variants/core/date.tsx +0 -25
  488. package/src/variants/core/file.tsx +0 -9
  489. package/src/variants/core/keyvalue.tsx +0 -12
  490. package/src/variants/core/multiselect.tsx +0 -28
  491. package/src/variants/core/number.tsx +0 -115
  492. package/src/variants/core/password.tsx +0 -35
  493. package/src/variants/core/phone.tsx +0 -16
  494. package/src/variants/core/radio.tsx +0 -38
  495. package/src/variants/core/select.tsx +0 -15
  496. package/src/variants/core/slider.tsx +0 -55
  497. package/src/variants/core/textarea.tsx +0 -22
  498. package/src/variants/core/toggle.tsx +0 -50
  499. package/src/variants/core/treeselect.tsx +0 -11
  500. package/src/variants/helpers/selection-summary.tsx +0 -236
  501. package/src/variants/registry.ts +0 -38
  502. package/src/variants/select-shared.ts +0 -0
  503. package/tsconfig.json +0 -14
@@ -1,849 +0,0 @@
1
- import * as React from "react";
2
- import type { VariantBaseProps, ChangeDetail } from "@/variants/shared";
3
- import { cn } from "@/lib/utils";
4
- import { Checkbox } from "@/presets/ui/checkbox";
5
-
6
- // ─────────────────────────────────────────────
7
- // Types
8
- // ─────────────────────────────────────────────
9
-
10
- export type CheckboxSize = "sm" | "md" | "lg";
11
- export type CheckboxDensity = "compact" | "comfortable" | "loose";
12
- export type CheckboxLayoutMode = "list" | "grid";
13
-
14
- /**
15
- * Internal state we store in the value list.
16
- * "none" never goes into the external value.
17
- */
18
- export type CheckboxTriStateValue = true | false;
19
-
20
- /**
21
- * Internal state we pass to the Shadcn checkbox.
22
- * "none" is used to represent "no stance yet".
23
- */
24
- export type CheckboxInternalState = true | false | "none";
25
-
26
- export interface CheckboxGroupEntry<TValue> {
27
- value: TValue;
28
- state: CheckboxTriStateValue; // true or false only
29
- }
30
-
31
- export type CheckboxGroupValue<TValue> =
32
- | readonly CheckboxGroupEntry<TValue>[]
33
- | undefined;
34
-
35
- /**
36
- * Single checkbox value.
37
- * undefined → "none"
38
- */
39
- export type CheckboxSingleValue = boolean | undefined;
40
-
41
- /**
42
- * Public union type for the variant's value.
43
- *
44
- * - In single mode: we expect CheckboxSingleValue
45
- * - In group mode: we expect CheckboxGroupValue<TValue>
46
- *
47
- * At the type level this is a union; at runtime we branch using `single`.
48
- */
49
- export type CheckboxVariantValue<TValue> =
50
- | CheckboxSingleValue
51
- | CheckboxGroupValue<TValue>;
52
-
53
- export interface CheckboxItem<TValue> {
54
- value: TValue;
55
- label: React.ReactNode;
56
- description?: React.ReactNode;
57
- disabled?: boolean;
58
- key?: React.Key;
59
-
60
- /**
61
- * Override tri-state behaviour for this item.
62
- * If undefined, variant-level `tristate` is used.
63
- */
64
- tristate?: boolean;
65
- }
66
-
67
- export interface CheckboxMappers<TItem, TValue> {
68
- getValue: (item: TItem, index: number) => TValue;
69
- getLabel: (item: TItem, index: number) => React.ReactNode;
70
- getDescription?: (item: TItem, index: number) => React.ReactNode;
71
- isDisabled?: (item: TItem, index: number) => boolean;
72
- getKey?: (item: TItem, index: number) => React.Key;
73
- getTristate?: (item: TItem, index: number) => boolean | undefined;
74
- }
75
-
76
- export interface CheckboxRenderOptionContext<TValue> {
77
- item: CheckboxItem<TValue>;
78
- index: number;
79
- state: CheckboxInternalState;
80
- effectiveTristate: boolean;
81
- disabled: boolean;
82
- size: CheckboxSize;
83
- density: CheckboxDensity;
84
- checkboxId?: string;
85
-
86
- /**
87
- * Prebuilt Shadcn checkbox node.
88
- */
89
- checkbox: React.ReactNode;
90
- }
91
-
92
- /**
93
- * UI props for both single and group modes.
94
- */
95
- export interface ShadcnCheckboxUiProps<TItem, TValue> {
96
- /**
97
- * Group mode:
98
- * - Required when `single` is not true.
99
- *
100
- * Single mode:
101
- * - Optional; if provided, `items[0]` can supply label/description.
102
- */
103
- items?: readonly TItem[];
104
-
105
- /**
106
- * Mapping functions for arbitrary item shapes.
107
- * Takes precedence over optionValue/optionLabel.
108
- */
109
- mappers?: CheckboxMappers<TItem, TValue>;
110
-
111
- /**
112
- * Property name that holds the value on each item.
113
- *
114
- * Example:
115
- * items = [{ id: "read", label: "Read" }]
116
- * optionValue = "id"
117
- */
118
- optionValue?: keyof TItem;
119
-
120
- /**
121
- * Property name that holds the label on each item.
122
- *
123
- * Example:
124
- * items = [{ id: "read", title: "Read" }]
125
- * optionLabel = "title"
126
- */
127
- optionLabel?: keyof TItem;
128
-
129
- /**
130
- * Custom renderer for each option row.
131
- */
132
- renderOption?: (
133
- ctx: CheckboxRenderOptionContext<TValue>
134
- ) => React.ReactNode;
135
-
136
- /**
137
- * If true, treat this variant as a single checkbox instead of a group.
138
- *
139
- * Value is then CheckboxSingleValue (boolean | undefined).
140
- */
141
- single?: boolean;
142
-
143
- /**
144
- * Variant-level default tri-state behaviour.
145
- *
146
- * - In single mode: directly controls tri-state for the single checkbox.
147
- * - In group mode: default for all items, unless item.tristate overrides.
148
- */
149
- tristate?: boolean;
150
-
151
- /**
152
- * Layout mode in group mode: vertical list or CSS grid.
153
- */
154
- layout?: CheckboxLayoutMode;
155
-
156
- /**
157
- * Number of columns in grid mode.
158
- * Default: 2.
159
- */
160
- columns?: number;
161
-
162
- /**
163
- * Gap between items in px.
164
- */
165
- itemGapPx?: number;
166
-
167
- /**
168
- * Visual size of the checkbox / text.
169
- * Default: "md".
170
- */
171
- size?: CheckboxSize;
172
-
173
- /**
174
- * Vertical density of each row.
175
- * Default: "comfortable".
176
- */
177
- density?: CheckboxDensity;
178
-
179
- /**
180
- * ARIA attributes for the group wrapper.
181
- */
182
- "aria-label"?: string;
183
- "aria-labelledby"?: string;
184
-
185
- /**
186
- * Wrapper class for the entire group (or single field).
187
- */
188
- groupClassName?: string;
189
-
190
- /**
191
- * Extra classes for each option row (group mode).
192
- */
193
- optionClassName?: string;
194
-
195
- /**
196
- * Extra classes for the option label text.
197
- */
198
- labelClassName?: string;
199
-
200
- /**
201
- * Extra classes for the option description text.
202
- */
203
- descriptionClassName?: string;
204
-
205
- /**
206
- * Single-mode inline label (if you want variant-level text).
207
- * Usually you'll rely on InputField's label instead.
208
- */
209
- singleLabel?: React.ReactNode;
210
-
211
- /**
212
- * Single-mode description text under the label.
213
- */
214
- singleDescription?: React.ReactNode;
215
- }
216
-
217
- /**
218
- * Full props for the Shadcn-based checkbox variant.
219
- *
220
- * TValue: primitive or object key
221
- * TItem: item shape used to build checkbox items
222
- */
223
- export type ShadcnCheckboxVariantProps<
224
- TValue,
225
- TItem = CheckboxItem<TValue>
226
- > = ShadcnCheckboxUiProps<TItem, TValue> &
227
- Pick<
228
- VariantBaseProps<CheckboxVariantValue<TValue>>,
229
- "value" | "onValue" | "error" | "disabled" | "required"
230
- > & {
231
- id?: string;
232
- className?: string; // alias for groupClassName
233
- name?: string; // optional: name for native form post in group mode
234
- "aria-describedby"?: string;
235
- };
236
-
237
- // ─────────────────────────────────────────────
238
- // Helpers
239
- // ─────────────────────────────────────────────
240
-
241
- function paddingForDensity(density: CheckboxDensity): string {
242
- switch (density) {
243
- case "compact":
244
- // return "py-1.5";
245
- case "loose":
246
- return "py-2";
247
- case "comfortable":
248
- default:
249
- return "py-0";
250
- }
251
- }
252
-
253
- function labelTextSize(size: CheckboxSize): string {
254
- switch (size) {
255
- case "sm":
256
- return "text-xs";
257
- case "lg":
258
- return "text-base";
259
- case "md":
260
- default:
261
- return "text-sm";
262
- }
263
- }
264
-
265
- function descriptionTextSize(size: CheckboxSize): string {
266
- switch (size) {
267
- case "sm":
268
- return "text-[0.7rem]";
269
- case "lg":
270
- return "text-sm";
271
- case "md":
272
- default:
273
- return "text-xs";
274
- }
275
- }
276
-
277
- /**
278
- * Normalize arbitrary items to CheckboxItem<TValue>[] using:
279
- * 1) mappers,
280
- * 2) optionValue/optionLabel,
281
- * 3) native CheckboxItem fields.
282
- */
283
- function normalizeItems<TItem, TValue>(
284
- items: readonly TItem[] | undefined,
285
- mappers?: CheckboxMappers<TItem, TValue>,
286
- optionValueKey?: keyof TItem,
287
- optionLabelKey?: keyof TItem
288
- ): CheckboxItem<TValue>[] {
289
- if (!items || !items.length) return [];
290
-
291
- // 1) Explicit mappers win
292
- if (mappers) {
293
- return items.map((item, index) => ({
294
- value: mappers.getValue(item, index),
295
- label: mappers.getLabel(item, index),
296
- description: mappers.getDescription
297
- ? mappers.getDescription(item, index)
298
- : undefined,
299
- disabled: mappers.isDisabled
300
- ? mappers.isDisabled(item, index)
301
- : false,
302
- key: mappers.getKey ? mappers.getKey(item, index) : index,
303
- tristate: mappers.getTristate
304
- ? mappers.getTristate(item, index)
305
- : undefined,
306
- }));
307
- }
308
-
309
- // 2) optionValue / optionLabel
310
- if (optionValueKey || optionLabelKey) {
311
- return items.map((item, index) => {
312
- const anyItem = item as any;
313
-
314
- const rawValue =
315
- optionValueKey != null
316
- ? anyItem[optionValueKey as string]
317
- : anyItem.value;
318
-
319
- const value = rawValue as TValue;
320
-
321
- const rawLabel =
322
- optionLabelKey != null
323
- ? anyItem[optionLabelKey as string]
324
- : anyItem.label ?? String(rawValue ?? index);
325
-
326
- const description = anyItem.description;
327
- const disabled = !!anyItem.disabled;
328
- const key: React.Key = anyItem.key ?? index;
329
- const tristate = anyItem.tristate as boolean | undefined;
330
-
331
- return {
332
- value,
333
- label: rawLabel,
334
- description,
335
- disabled,
336
- key,
337
- tristate,
338
- };
339
- });
340
- }
341
-
342
- // 3) Assume already CheckboxItem<TValue>
343
- return items as unknown as CheckboxItem<TValue>[];
344
- }
345
-
346
- function isEqualValue(a: unknown, b: unknown): boolean {
347
- return Object.is(a, b);
348
- }
349
-
350
- /**
351
- * Extract group value from the union.
352
- */
353
- function asGroupValue<TValue>(
354
- value: CheckboxVariantValue<TValue>
355
- ): CheckboxGroupValue<TValue> {
356
- if (!value) return undefined;
357
- if (Array.isArray(value)) return value;
358
- return undefined;
359
- }
360
-
361
- /**
362
- * Extract single value from the union.
363
- */
364
- function asSingleValue(
365
- value: CheckboxVariantValue<unknown>
366
- ): CheckboxSingleValue {
367
- if (Array.isArray(value)) return undefined;
368
- if (typeof value === "boolean" || value === undefined) return value;
369
- return undefined;
370
- }
371
-
372
- // ─────────────────────────────────────────────
373
- // Component
374
- // ─────────────────────────────────────────────
375
-
376
- const InnerShadcnCheckboxVariant = <
377
- TValue,
378
- TItem = CheckboxItem<TValue>
379
- >(
380
- props: ShadcnCheckboxVariantProps<TValue, TItem>,
381
- ref: React.Ref<HTMLDivElement>
382
- ) => {
383
- const {
384
- // variant base
385
- value,
386
- onValue,
387
- error,
388
- disabled,
389
- required,
390
-
391
- // UI / behaviour
392
- items,
393
- mappers,
394
- optionValue,
395
- optionLabel,
396
- renderOption,
397
- single,
398
- tristate: tristateDefault,
399
- layout = "list",
400
- columns = 2,
401
- itemGapPx,
402
- size = "md",
403
- density = "comfortable",
404
-
405
- "aria-label": ariaLabel,
406
- "aria-labelledby": ariaLabelledBy,
407
- "aria-describedby": ariaDescribedBy,
408
- name,
409
-
410
- groupClassName,
411
- optionClassName,
412
- labelClassName,
413
- descriptionClassName,
414
-
415
- className, // alias for groupClassName
416
-
417
- singleLabel,
418
- singleDescription,
419
-
420
- id,
421
- ...restProps
422
- } = props;
423
-
424
- const hasError = !!error;
425
- const isSingle = !!single;
426
-
427
- // ─────────────────────────────────────────
428
- // Single mode
429
- // ─────────────────────────────────────────
430
- if (isSingle) {
431
- const singleVal = asSingleValue(value);
432
- const effectiveTristate = !!tristateDefault;
433
-
434
- const internalState: CheckboxInternalState = effectiveTristate
435
- ? (singleVal ?? "none")
436
- : !!singleVal;
437
-
438
- const handleSingleChange = (next: CheckboxInternalState) => {
439
- if (!onValue || disabled) return;
440
-
441
- let nextPublic: CheckboxSingleValue;
442
-
443
- if (effectiveTristate) {
444
- // tri-state single:
445
- // "none" → undefined
446
- // true/false → same
447
- nextPublic = next === "none" ? undefined : !!next;
448
- } else {
449
- // non-tristate: behave like normal checkbox
450
- nextPublic = next === true;
451
- }
452
-
453
- const detail: ChangeDetail = {
454
- source: "variant",
455
- raw: nextPublic,
456
- nativeEvent: undefined,
457
- meta: undefined,
458
- };
459
-
460
- onValue(nextPublic, detail);
461
- };
462
-
463
- const labelText = singleLabel ?? undefined;
464
- const descriptionText = singleDescription ?? undefined;
465
-
466
- const labelCls = cn(
467
- "text-foreground",
468
- labelTextSize(size),
469
- labelClassName
470
- );
471
-
472
- const descriptionCls = cn(
473
- "mt-0.5 text-muted-foreground",
474
- descriptionTextSize(size),
475
- descriptionClassName
476
- );
477
-
478
- return (
479
- <div
480
- ref={ref}
481
- role="group"
482
- aria-label={ariaLabel}
483
- aria-labelledby={ariaLabelledBy}
484
- aria-describedby={ariaDescribedBy}
485
- aria-invalid={hasError || undefined}
486
- aria-required={required || undefined}
487
- data-slot="checkbox-single"
488
- className={cn(
489
- "flex items-start gap-3",
490
- paddingForDensity(density),
491
- groupClassName ?? className
492
- )}
493
- {...restProps}
494
- >
495
- <Checkbox
496
- id={id}
497
- checked={internalState}
498
- tristate={effectiveTristate}
499
- disabled={disabled}
500
- onCheckedChange={handleSingleChange}
501
- className="mt-0.5"
502
- />
503
-
504
- {(labelText || descriptionText) && (
505
- <div className="flex min-w-0 flex-col">
506
- {labelText && (
507
- <span className={labelCls}>{labelText}</span>
508
- )}
509
- {descriptionText && (
510
- <span className={descriptionCls}>
511
- {descriptionText}
512
- </span>
513
- )}
514
- </div>
515
- )}
516
- </div>
517
- );
518
- }
519
-
520
- // ─────────────────────────────────────────
521
- // Group mode
522
- // ─────────────────────────────────────────
523
-
524
- const groupValue = asGroupValue<TValue>(value);
525
- const normalized = React.useMemo(
526
- () =>
527
- normalizeItems<TItem, TValue>(
528
- items,
529
- mappers,
530
- optionValue,
531
- optionLabel
532
- ),
533
- [items, mappers, optionValue, optionLabel]
534
- );
535
-
536
- const groupStyle: React.CSSProperties | undefined = React.useMemo(() => {
537
- if (!itemGapPx) {
538
- if (layout === "grid") {
539
- return {
540
- gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
541
- };
542
- }
543
- return undefined;
544
- }
545
-
546
- if (layout === "list") {
547
- return { rowGap: itemGapPx };
548
- }
549
-
550
- return {
551
- gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
552
- gap: itemGapPx,
553
- };
554
- }, [layout, columns, itemGapPx]);
555
-
556
- const groupClasses = cn(
557
- layout === "grid" ? "grid" : "flex flex-col",
558
- groupClassName ?? className
559
- );
560
-
561
- const baseOptionClass = cn(
562
- "relative flex items-start",
563
- "data-[disabled=true]:opacity-60 data-[disabled=true]:cursor-not-allowed",
564
- paddingForDensity(density),
565
- optionClassName
566
- );
567
-
568
- const labelClassesBase = cn(
569
- "font-medium text-foreground",
570
- labelTextSize(size),
571
- labelClassName
572
- );
573
-
574
- const descriptionClassesBase = cn(
575
- "mt-0.5 text-muted-foreground",
576
- descriptionTextSize(size),
577
- descriptionClassName
578
- );
579
-
580
- const findEntryIndex = React.useCallback(
581
- (val: TValue): number => {
582
- if (!groupValue) return -1;
583
- return groupValue.findIndex((e) => isEqualValue(e.value, val));
584
- },
585
- [groupValue]
586
- );
587
-
588
- const getEntryState = React.useCallback(
589
- (val: TValue): CheckboxTriStateValue | "none" => {
590
- const idx = findEntryIndex(val);
591
- if (!groupValue || idx === -1) return "none";
592
- return groupValue[idx].state;
593
- },
594
- [groupValue, findEntryIndex]
595
- );
596
-
597
- const updateGroupValue = React.useCallback(
598
- (
599
- itemValue: TValue,
600
- nextInternal: CheckboxInternalState,
601
- effectiveTristate: boolean
602
- ) => {
603
- if (!onValue || disabled) return;
604
-
605
- const currentList = groupValue ? [...groupValue] : [];
606
- const idx = currentList.findIndex((e) =>
607
- isEqualValue(e.value, itemValue)
608
- );
609
-
610
- let nextList: CheckboxGroupEntry<TValue>[] = currentList;
611
-
612
- if (effectiveTristate) {
613
- // Tri-state:
614
- // "none" → remove
615
- // true/false → ensure entry is present with state
616
- if (nextInternal === "none") {
617
- if (idx !== -1) {
618
- nextList = [
619
- ...currentList.slice(0, idx),
620
- ...currentList.slice(idx + 1),
621
- ];
622
- }
623
- } else {
624
- const nextState: CheckboxTriStateValue =
625
- nextInternal === true;
626
- if (idx === -1) {
627
- nextList = [
628
- ...currentList,
629
- { value: itemValue, state: nextState },
630
- ];
631
- } else {
632
- nextList = [...currentList];
633
- nextList[idx] = {
634
- ...nextList[idx],
635
- state: nextState,
636
- };
637
- }
638
- }
639
- } else {
640
- // Non tri-state:
641
- // true → ensure present
642
- // false/"none" → remove entry (false acts as none)
643
- if (nextInternal === true) {
644
- if (idx === -1) {
645
- nextList = [
646
- ...currentList,
647
- { value: itemValue, state: true },
648
- ];
649
- } else {
650
- nextList = [...currentList];
651
- nextList[idx] = {
652
- ...nextList[idx],
653
- state: true,
654
- };
655
- }
656
- } else {
657
- // false / "none": remove
658
- if (idx !== -1) {
659
- nextList = [
660
- ...currentList.slice(0, idx),
661
- ...currentList.slice(idx + 1),
662
- ];
663
- }
664
- }
665
- }
666
-
667
- const detail: ChangeDetail = {
668
- source: "variant",
669
- raw: nextList,
670
- nativeEvent: undefined,
671
- meta: undefined,
672
- };
673
-
674
- onValue(nextList, detail);
675
- },
676
- [onValue, disabled, groupValue]
677
- );
678
-
679
- return (
680
- <div
681
- ref={ref}
682
- id={id}
683
- role="group"
684
- aria-label={ariaLabel}
685
- aria-labelledby={ariaLabelledBy}
686
- aria-describedby={ariaDescribedBy}
687
- aria-invalid={hasError || undefined}
688
- aria-required={required || undefined}
689
- data-slot="checkbox-group"
690
- className={groupClasses}
691
- style={groupStyle}
692
- {...restProps}
693
- >
694
- {normalized.map((item, index) => {
695
- const effectiveTristate =
696
- item.tristate ?? tristateDefault ?? false;
697
-
698
- const currentState = getEntryState(item.value);
699
- const internalState: CheckboxInternalState =
700
- effectiveTristate
701
- ? currentState // "none" | true | false
702
- : currentState === "none"
703
- ? false
704
- : currentState;
705
-
706
- const optionDisabled = !!disabled || !!item.disabled;
707
- const optionKey = item.key ?? index;
708
- const checkboxId = id
709
- ? `${id}-option-${optionKey}`
710
- : undefined;
711
-
712
- const checkboxNode = (
713
- <Checkbox
714
- id={checkboxId}
715
- checked={internalState}
716
- disabled={optionDisabled}
717
- tristate={effectiveTristate}
718
- onCheckedChange={(next) =>
719
- updateGroupValue(
720
- item.value,
721
- next as CheckboxInternalState,
722
- effectiveTristate
723
- )
724
- }
725
- className="mt-1"
726
- />
727
- );
728
-
729
- const hiddenInput =
730
- name != null ? (
731
- <input
732
- type="hidden"
733
- name={name}
734
- value={String(item.value)}
735
- // Only send if in list; tri-state false still "has standing"
736
- // in code, but native form post is simple and you can
737
- // derive negative states server-side if you want.
738
- disabled={
739
- getEntryState(item.value) === "none"
740
- }
741
- />
742
- ) : null;
743
-
744
- if (renderOption) {
745
- return (
746
- <div
747
- key={optionKey}
748
- data-slot="checkbox-option"
749
- data-disabled={optionDisabled ? "true" : "false"}
750
- className={baseOptionClass}
751
- >
752
- {renderOption({
753
- item,
754
- index,
755
- state: internalState,
756
- effectiveTristate,
757
- disabled: optionDisabled,
758
- size,
759
- density,
760
- checkboxId,
761
- checkbox: checkboxNode,
762
- })}
763
- {hiddenInput}
764
- </div>
765
- );
766
- }
767
-
768
- // Default row layout: checkbox + label + description
769
- return (
770
- <div
771
- key={optionKey}
772
- data-slot="checkbox-option"
773
- data-disabled={optionDisabled ? "true" : "false"}
774
- className={baseOptionClass}
775
- >
776
- <label
777
- htmlFor={checkboxId}
778
- className="flex w-full cursor-pointer items-start gap-3 select-none"
779
- >
780
- {checkboxNode}
781
-
782
- <div className="flex min-w-0 flex-col">
783
- <span className={labelClassesBase}>
784
- {item.label}
785
- </span>
786
- {item.description != null && (
787
- <span
788
- className={descriptionClassesBase}
789
- >
790
- {item.description}
791
- </span>
792
- )}
793
- </div>
794
- </label>
795
-
796
- {hiddenInput}
797
- </div>
798
- );
799
- })}
800
- </div>
801
- );
802
- };
803
-
804
- export const ShadcnCheckboxVariant =
805
- React.forwardRef(InnerShadcnCheckboxVariant) as unknown as <
806
- TValue,
807
- TItem = CheckboxItem<TValue>
808
- >(
809
- props: ShadcnCheckboxVariantProps<TValue, TItem> & {
810
- ref?: React.Ref<HTMLDivElement>;
811
- }
812
- ) => React.ReactElement | null;
813
-
814
- // ShadcnCheckboxVariant.displayName = "ShadcnCheckboxVariant";
815
-
816
- export default ShadcnCheckboxVariant;
817
-
818
-
819
- // ─────────────────────────────────────────────
820
- // Public aliases for the registry
821
- // ─────────────────────────────────────────────
822
-
823
- /**
824
- * Default item value type for the checkbox variant.
825
- *
826
- * You can still use the generic ShadcnCheckboxVariantProps<TValue, TItem>
827
- * directly if you need a different TValue; the registry uses this alias.
828
- */
829
- export type DefaultCheckboxItemValue = string | number;
830
-
831
- /**
832
- * Public "value" type for the checkbox variant used by the registry:
833
- *
834
- * - Single mode: boolean | undefined
835
- * - Group mode: CheckboxGroupEntry<DefaultCheckboxItemValue>[] | undefined
836
- *
837
- * In tri-state group mode, both `true` and `false` entries are present;
838
- * `"none"` never appears in this type.
839
- */
840
- export type CheckboxVariantPublicValue =
841
- CheckboxVariantValue<DefaultCheckboxItemValue>;
842
-
843
- /**
844
- * Public props type for the checkbox variant used by the registry.
845
- *
846
- * This is ShadcnCheckboxVariantProps with TValue fixed to DefaultCheckboxItemValue.
847
- */
848
- export type ShadcnCheckboxVariantPublicProps =
849
- ShadcnCheckboxVariantProps<DefaultCheckboxItemValue>;