@bquery/bquery 1.5.0 → 1.7.0

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 (380) hide show
  1. package/README.md +193 -23
  2. package/dist/a11y/announce.d.ts +43 -0
  3. package/dist/a11y/announce.d.ts.map +1 -0
  4. package/dist/a11y/audit.d.ts +42 -0
  5. package/dist/a11y/audit.d.ts.map +1 -0
  6. package/dist/a11y/index.d.ts +53 -0
  7. package/dist/a11y/index.d.ts.map +1 -0
  8. package/dist/a11y/media-preferences.d.ts +77 -0
  9. package/dist/a11y/media-preferences.d.ts.map +1 -0
  10. package/dist/a11y/roving-tab-index.d.ts +38 -0
  11. package/dist/a11y/roving-tab-index.d.ts.map +1 -0
  12. package/dist/a11y/skip-link.d.ts +37 -0
  13. package/dist/a11y/skip-link.d.ts.map +1 -0
  14. package/dist/a11y/trap-focus.d.ts +49 -0
  15. package/dist/a11y/trap-focus.d.ts.map +1 -0
  16. package/dist/a11y/types.d.ts +152 -0
  17. package/dist/a11y/types.d.ts.map +1 -0
  18. package/dist/a11y-C5QOVvRn.js +421 -0
  19. package/dist/a11y-C5QOVvRn.js.map +1 -0
  20. package/dist/a11y.es.mjs +14 -0
  21. package/dist/component/component.d.ts +13 -5
  22. package/dist/component/component.d.ts.map +1 -1
  23. package/dist/component/html.d.ts +40 -3
  24. package/dist/component/html.d.ts.map +1 -1
  25. package/dist/component/index.d.ts +3 -2
  26. package/dist/component/index.d.ts.map +1 -1
  27. package/dist/component/library.d.ts.map +1 -1
  28. package/dist/component/scope.d.ts +138 -0
  29. package/dist/component/scope.d.ts.map +1 -0
  30. package/dist/component/types.d.ts +184 -17
  31. package/dist/component/types.d.ts.map +1 -1
  32. package/dist/component-CuuTijA6.js +684 -0
  33. package/dist/component-CuuTijA6.js.map +1 -0
  34. package/dist/component.es.mjs +10 -6
  35. package/dist/{config-DRmZZno3.js → config-BW35FKuA.js} +4 -4
  36. package/dist/config-BW35FKuA.js.map +1 -0
  37. package/dist/constraints-3lV9yyBw.js +100 -0
  38. package/dist/constraints-3lV9yyBw.js.map +1 -0
  39. package/dist/core/collection.d.ts +48 -0
  40. package/dist/core/collection.d.ts.map +1 -1
  41. package/dist/core/element.d.ts +92 -0
  42. package/dist/core/element.d.ts.map +1 -1
  43. package/dist/core/env.d.ts +18 -0
  44. package/dist/core/env.d.ts.map +1 -0
  45. package/dist/core/index.d.ts +1 -0
  46. package/dist/core/index.d.ts.map +1 -1
  47. package/dist/core/shared.d.ts +8 -0
  48. package/dist/core/shared.d.ts.map +1 -1
  49. package/dist/core/utils/index.d.ts +52 -41
  50. package/dist/core/utils/index.d.ts.map +1 -1
  51. package/dist/core-Cjl7GUu8.js +717 -0
  52. package/dist/core-Cjl7GUu8.js.map +1 -0
  53. package/dist/{core-DPdbItcq.js → core-DnlyjbF2.js} +1 -1
  54. package/dist/{core-DPdbItcq.js.map → core-DnlyjbF2.js.map} +1 -1
  55. package/dist/core.es.mjs +45 -44
  56. package/dist/custom-directives-7wAShnnd.js +9 -0
  57. package/dist/custom-directives-7wAShnnd.js.map +1 -0
  58. package/dist/devtools/devtools.d.ts +212 -0
  59. package/dist/devtools/devtools.d.ts.map +1 -0
  60. package/dist/devtools/index.d.ts +20 -0
  61. package/dist/devtools/index.d.ts.map +1 -0
  62. package/dist/devtools/types.d.ts +69 -0
  63. package/dist/devtools/types.d.ts.map +1 -0
  64. package/dist/devtools-D2fQLhDN.js +122 -0
  65. package/dist/devtools-D2fQLhDN.js.map +1 -0
  66. package/dist/devtools.es.mjs +19 -0
  67. package/dist/dnd/draggable.d.ts +51 -0
  68. package/dist/dnd/draggable.d.ts.map +1 -0
  69. package/dist/dnd/droppable.d.ts +38 -0
  70. package/dist/dnd/droppable.d.ts.map +1 -0
  71. package/dist/dnd/index.d.ts +47 -0
  72. package/dist/dnd/index.d.ts.map +1 -0
  73. package/dist/dnd/sortable.d.ts +43 -0
  74. package/dist/dnd/sortable.d.ts.map +1 -0
  75. package/dist/dnd/types.d.ts +250 -0
  76. package/dist/dnd/types.d.ts.map +1 -0
  77. package/dist/dnd-B8EgyzaI.js +244 -0
  78. package/dist/dnd-B8EgyzaI.js.map +1 -0
  79. package/dist/dnd.es.mjs +6 -0
  80. package/dist/env-NeVmr4Gf.js +19 -0
  81. package/dist/env-NeVmr4Gf.js.map +1 -0
  82. package/dist/forms/create-form.d.ts +49 -0
  83. package/dist/forms/create-form.d.ts.map +1 -0
  84. package/dist/forms/index.d.ts +39 -0
  85. package/dist/forms/index.d.ts.map +1 -0
  86. package/dist/forms/types.d.ts +139 -0
  87. package/dist/forms/types.d.ts.map +1 -0
  88. package/dist/forms/validators.d.ts +179 -0
  89. package/dist/forms/validators.d.ts.map +1 -0
  90. package/dist/forms-C3yovgH9.js +141 -0
  91. package/dist/forms-C3yovgH9.js.map +1 -0
  92. package/dist/forms.es.mjs +14 -0
  93. package/dist/full.d.ts +37 -9
  94. package/dist/full.d.ts.map +1 -1
  95. package/dist/full.es.mjs +186 -91
  96. package/dist/full.iife.js +47 -31
  97. package/dist/full.iife.js.map +1 -1
  98. package/dist/full.umd.js +47 -31
  99. package/dist/full.umd.js.map +1 -1
  100. package/dist/i18n/formatting.d.ts +40 -0
  101. package/dist/i18n/formatting.d.ts.map +1 -0
  102. package/dist/i18n/i18n.d.ts +48 -0
  103. package/dist/i18n/i18n.d.ts.map +1 -0
  104. package/dist/i18n/index.d.ts +57 -0
  105. package/dist/i18n/index.d.ts.map +1 -0
  106. package/dist/i18n/translate.d.ts +83 -0
  107. package/dist/i18n/translate.d.ts.map +1 -0
  108. package/dist/i18n/types.d.ts +156 -0
  109. package/dist/i18n/types.d.ts.map +1 -0
  110. package/dist/i18n-BnnhTFOS.js +89 -0
  111. package/dist/i18n-BnnhTFOS.js.map +1 -0
  112. package/dist/i18n.es.mjs +6 -0
  113. package/dist/index.d.ts +11 -0
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.es.mjs +233 -138
  116. package/dist/media/battery.d.ts +35 -0
  117. package/dist/media/battery.d.ts.map +1 -0
  118. package/dist/media/breakpoints.d.ts +51 -0
  119. package/dist/media/breakpoints.d.ts.map +1 -0
  120. package/dist/media/clipboard.d.ts +30 -0
  121. package/dist/media/clipboard.d.ts.map +1 -0
  122. package/dist/media/device-sensors.d.ts +54 -0
  123. package/dist/media/device-sensors.d.ts.map +1 -0
  124. package/dist/media/geolocation.d.ts +38 -0
  125. package/dist/media/geolocation.d.ts.map +1 -0
  126. package/dist/media/index.d.ts +42 -0
  127. package/dist/media/index.d.ts.map +1 -0
  128. package/dist/media/media-query.d.ts +36 -0
  129. package/dist/media/media-query.d.ts.map +1 -0
  130. package/dist/media/network.d.ts +35 -0
  131. package/dist/media/network.d.ts.map +1 -0
  132. package/dist/media/types.d.ts +173 -0
  133. package/dist/media/types.d.ts.map +1 -0
  134. package/dist/media/viewport.d.ts +32 -0
  135. package/dist/media/viewport.d.ts.map +1 -0
  136. package/dist/media-Di2Ta22s.js +340 -0
  137. package/dist/media-Di2Ta22s.js.map +1 -0
  138. package/dist/media.es.mjs +12 -0
  139. package/dist/motion/index.d.ts +7 -3
  140. package/dist/motion/index.d.ts.map +1 -1
  141. package/dist/motion/morph.d.ts +27 -0
  142. package/dist/motion/morph.d.ts.map +1 -0
  143. package/dist/motion/parallax.d.ts +30 -0
  144. package/dist/motion/parallax.d.ts.map +1 -0
  145. package/dist/motion/reduced-motion.d.ts +36 -3
  146. package/dist/motion/reduced-motion.d.ts.map +1 -1
  147. package/dist/motion/types.d.ts +58 -0
  148. package/dist/motion/types.d.ts.map +1 -1
  149. package/dist/motion/typewriter.d.ts +31 -0
  150. package/dist/motion/typewriter.d.ts.map +1 -0
  151. package/dist/motion-qPj_TYGv.js +530 -0
  152. package/dist/motion-qPj_TYGv.js.map +1 -0
  153. package/dist/motion.es.mjs +27 -23
  154. package/dist/mount-SM07RUa6.js +403 -0
  155. package/dist/mount-SM07RUa6.js.map +1 -0
  156. package/dist/{object-qGpWr6-J.js → object-BCk-1c8T.js} +5 -4
  157. package/dist/{object-qGpWr6-J.js.map → object-BCk-1c8T.js.map} +1 -1
  158. package/dist/{platform-B7JhGBc7.js → platform-CPbCprb6.js} +3 -3
  159. package/dist/platform-CPbCprb6.js.map +1 -0
  160. package/dist/platform.es.mjs +2 -2
  161. package/dist/plugin/index.d.ts +22 -0
  162. package/dist/plugin/index.d.ts.map +1 -0
  163. package/dist/plugin/registry.d.ts +108 -0
  164. package/dist/plugin/registry.d.ts.map +1 -0
  165. package/dist/plugin/types.d.ts +110 -0
  166. package/dist/plugin/types.d.ts.map +1 -0
  167. package/dist/plugin-cPoOHFLY.js +64 -0
  168. package/dist/plugin-cPoOHFLY.js.map +1 -0
  169. package/dist/plugin.es.mjs +9 -0
  170. package/dist/reactive/computed.d.ts +7 -0
  171. package/dist/reactive/computed.d.ts.map +1 -1
  172. package/dist/reactive-Cfv0RK6x.js +233 -0
  173. package/dist/reactive-Cfv0RK6x.js.map +1 -0
  174. package/dist/reactive.es.mjs +18 -17
  175. package/dist/registry-CWf368tT.js +26 -0
  176. package/dist/registry-CWf368tT.js.map +1 -0
  177. package/dist/router/bq-link.d.ts +112 -0
  178. package/dist/router/bq-link.d.ts.map +1 -0
  179. package/dist/router/constraints.d.ts +9 -0
  180. package/dist/router/constraints.d.ts.map +1 -0
  181. package/dist/router/index.d.ts +14 -6
  182. package/dist/router/index.d.ts.map +1 -1
  183. package/dist/router/match.d.ts +0 -1
  184. package/dist/router/match.d.ts.map +1 -1
  185. package/dist/router/path-pattern.d.ts +14 -0
  186. package/dist/router/path-pattern.d.ts.map +1 -0
  187. package/dist/router/query.d.ts.map +1 -1
  188. package/dist/router/router.d.ts +3 -1
  189. package/dist/router/router.d.ts.map +1 -1
  190. package/dist/router/types.d.ts +48 -4
  191. package/dist/router/types.d.ts.map +1 -1
  192. package/dist/router/use-route.d.ts +50 -0
  193. package/dist/router/use-route.d.ts.map +1 -0
  194. package/dist/router/utils.d.ts +3 -0
  195. package/dist/router/utils.d.ts.map +1 -1
  196. package/dist/router-BrthaP_z.js +473 -0
  197. package/dist/router-BrthaP_z.js.map +1 -0
  198. package/dist/router.es.mjs +13 -10
  199. package/dist/{sanitize-jyJ2ryE2.js → sanitize-B1V4JswB.js} +95 -83
  200. package/dist/sanitize-B1V4JswB.js.map +1 -0
  201. package/dist/security/index.d.ts +2 -0
  202. package/dist/security/index.d.ts.map +1 -1
  203. package/dist/security/sanitize.d.ts +4 -1
  204. package/dist/security/sanitize.d.ts.map +1 -1
  205. package/dist/security/trusted-html.d.ts +53 -0
  206. package/dist/security/trusted-html.d.ts.map +1 -0
  207. package/dist/security.es.mjs +10 -9
  208. package/dist/ssr/hydrate.d.ts +65 -0
  209. package/dist/ssr/hydrate.d.ts.map +1 -0
  210. package/dist/ssr/index.d.ts +59 -0
  211. package/dist/ssr/index.d.ts.map +1 -0
  212. package/dist/ssr/render.d.ts +62 -0
  213. package/dist/ssr/render.d.ts.map +1 -0
  214. package/dist/ssr/serialize.d.ts +118 -0
  215. package/dist/ssr/serialize.d.ts.map +1 -0
  216. package/dist/ssr/types.d.ts +70 -0
  217. package/dist/ssr/types.d.ts.map +1 -0
  218. package/dist/ssr-B2qd_WBB.js +248 -0
  219. package/dist/ssr-B2qd_WBB.js.map +1 -0
  220. package/dist/ssr.es.mjs +9 -0
  221. package/dist/store/create-store.d.ts.map +1 -1
  222. package/dist/store/define-store.d.ts +1 -1
  223. package/dist/store/define-store.d.ts.map +1 -1
  224. package/dist/store/index.d.ts +1 -1
  225. package/dist/store/index.d.ts.map +1 -1
  226. package/dist/store/mapping.d.ts +1 -1
  227. package/dist/store/mapping.d.ts.map +1 -1
  228. package/dist/store/persisted.d.ts +38 -4
  229. package/dist/store/persisted.d.ts.map +1 -1
  230. package/dist/store/types.d.ts +140 -3
  231. package/dist/store/types.d.ts.map +1 -1
  232. package/dist/store/utils.d.ts +2 -2
  233. package/dist/store/utils.d.ts.map +1 -1
  234. package/dist/store/watch.d.ts +1 -1
  235. package/dist/store/watch.d.ts.map +1 -1
  236. package/dist/store-DWpyH6p5.js +338 -0
  237. package/dist/store-DWpyH6p5.js.map +1 -0
  238. package/dist/store.es.mjs +11 -10
  239. package/dist/storybook/index.d.ts +37 -0
  240. package/dist/storybook/index.d.ts.map +1 -0
  241. package/dist/storybook.es.mjs +151 -0
  242. package/dist/storybook.es.mjs.map +1 -0
  243. package/dist/testing/index.d.ts +23 -0
  244. package/dist/testing/index.d.ts.map +1 -0
  245. package/dist/testing/testing.d.ts +156 -0
  246. package/dist/testing/testing.d.ts.map +1 -0
  247. package/dist/testing/types.d.ts +134 -0
  248. package/dist/testing/types.d.ts.map +1 -0
  249. package/dist/testing-CsqjNUyy.js +224 -0
  250. package/dist/testing-CsqjNUyy.js.map +1 -0
  251. package/dist/testing.es.mjs +9 -0
  252. package/dist/type-guards-Do9DWgNp.js +44 -0
  253. package/dist/type-guards-Do9DWgNp.js.map +1 -0
  254. package/dist/untrack-DJVQQ2WM.js +33 -0
  255. package/dist/untrack-DJVQQ2WM.js.map +1 -0
  256. package/dist/view/custom-directives.d.ts +20 -0
  257. package/dist/view/custom-directives.d.ts.map +1 -0
  258. package/dist/view/evaluate.d.ts.map +1 -1
  259. package/dist/view/process.d.ts.map +1 -1
  260. package/dist/view.es.mjs +11 -10
  261. package/package.json +52 -11
  262. package/src/a11y/announce.ts +131 -0
  263. package/src/a11y/audit.ts +314 -0
  264. package/src/a11y/index.ts +68 -0
  265. package/src/a11y/media-preferences.ts +255 -0
  266. package/src/a11y/roving-tab-index.ts +164 -0
  267. package/src/a11y/skip-link.ts +255 -0
  268. package/src/a11y/trap-focus.ts +184 -0
  269. package/src/a11y/types.ts +183 -0
  270. package/src/component/component.ts +345 -65
  271. package/src/component/html.ts +153 -53
  272. package/src/component/index.ts +12 -2
  273. package/src/component/library.ts +66 -28
  274. package/src/component/scope.ts +212 -0
  275. package/src/component/types.ts +238 -19
  276. package/src/core/collection.ts +707 -628
  277. package/src/core/element.ts +981 -774
  278. package/src/core/env.ts +60 -0
  279. package/src/core/index.ts +49 -48
  280. package/src/core/shared.ts +62 -13
  281. package/src/core/utils/index.ts +148 -83
  282. package/src/devtools/devtools.ts +410 -0
  283. package/src/devtools/index.ts +48 -0
  284. package/src/devtools/types.ts +104 -0
  285. package/src/dnd/draggable.ts +296 -0
  286. package/src/dnd/droppable.ts +228 -0
  287. package/src/dnd/index.ts +62 -0
  288. package/src/dnd/sortable.ts +307 -0
  289. package/src/dnd/types.ts +293 -0
  290. package/src/forms/create-form.ts +278 -0
  291. package/src/forms/index.ts +65 -0
  292. package/src/forms/types.ts +154 -0
  293. package/src/forms/validators.ts +265 -0
  294. package/src/full.ts +260 -3
  295. package/src/i18n/formatting.ts +67 -0
  296. package/src/i18n/i18n.ts +200 -0
  297. package/src/i18n/index.ts +67 -0
  298. package/src/i18n/translate.ts +182 -0
  299. package/src/i18n/types.ts +171 -0
  300. package/src/index.ts +108 -36
  301. package/src/media/battery.ts +116 -0
  302. package/src/media/breakpoints.ts +131 -0
  303. package/src/media/clipboard.ts +80 -0
  304. package/src/media/device-sensors.ts +158 -0
  305. package/src/media/geolocation.ts +119 -0
  306. package/src/media/index.ts +76 -0
  307. package/src/media/media-query.ts +92 -0
  308. package/src/media/network.ts +115 -0
  309. package/src/media/types.ts +177 -0
  310. package/src/media/viewport.ts +84 -0
  311. package/src/motion/index.ts +57 -48
  312. package/src/motion/morph.ts +151 -0
  313. package/src/motion/parallax.ts +120 -0
  314. package/src/motion/reduced-motion.ts +66 -17
  315. package/src/motion/transition.ts +97 -97
  316. package/src/motion/types.ts +63 -0
  317. package/src/motion/typewriter.ts +164 -0
  318. package/src/platform/announcer.ts +208 -208
  319. package/src/platform/config.ts +163 -163
  320. package/src/platform/cookies.ts +165 -165
  321. package/src/platform/index.ts +39 -39
  322. package/src/platform/meta.ts +168 -168
  323. package/src/plugin/index.ts +37 -0
  324. package/src/plugin/registry.ts +269 -0
  325. package/src/plugin/types.ts +137 -0
  326. package/src/reactive/async-data.ts +486 -486
  327. package/src/reactive/computed.ts +130 -92
  328. package/src/reactive/index.ts +37 -37
  329. package/src/reactive/signal.ts +29 -29
  330. package/src/router/bq-link.ts +279 -0
  331. package/src/router/constraints.ts +201 -0
  332. package/src/router/index.ts +49 -41
  333. package/src/router/match.ts +312 -106
  334. package/src/router/path-pattern.ts +52 -0
  335. package/src/router/query.ts +38 -35
  336. package/src/router/router.ts +402 -211
  337. package/src/router/types.ts +139 -93
  338. package/src/router/use-route.ts +68 -0
  339. package/src/router/utils.ts +157 -116
  340. package/src/security/constants.ts +211 -211
  341. package/src/security/index.ts +12 -10
  342. package/src/security/sanitize.ts +6 -2
  343. package/src/security/trusted-html.ts +71 -0
  344. package/src/ssr/hydrate.ts +82 -0
  345. package/src/ssr/index.ts +70 -0
  346. package/src/ssr/render.ts +508 -0
  347. package/src/ssr/serialize.ts +296 -0
  348. package/src/ssr/types.ts +81 -0
  349. package/src/store/create-store.ts +467 -329
  350. package/src/store/define-store.ts +2 -1
  351. package/src/store/index.ts +27 -22
  352. package/src/store/mapping.ts +2 -1
  353. package/src/store/persisted.ts +249 -61
  354. package/src/store/types.ts +247 -94
  355. package/src/store/utils.ts +135 -141
  356. package/src/store/watch.ts +2 -1
  357. package/src/storybook/index.ts +480 -0
  358. package/src/testing/index.ts +42 -0
  359. package/src/testing/testing.ts +593 -0
  360. package/src/testing/types.ts +170 -0
  361. package/src/view/custom-directives.ts +30 -0
  362. package/src/view/evaluate.ts +292 -290
  363. package/src/view/process.ts +108 -92
  364. package/dist/component-CY5MVoYN.js +0 -531
  365. package/dist/component-CY5MVoYN.js.map +0 -1
  366. package/dist/config-DRmZZno3.js.map +0 -1
  367. package/dist/core-CK2Mfpf4.js +0 -648
  368. package/dist/core-CK2Mfpf4.js.map +0 -1
  369. package/dist/motion-C5DRdPnO.js +0 -415
  370. package/dist/motion-C5DRdPnO.js.map +0 -1
  371. package/dist/platform-B7JhGBc7.js.map +0 -1
  372. package/dist/reactive-BDya-ia8.js +0 -253
  373. package/dist/reactive-BDya-ia8.js.map +0 -1
  374. package/dist/router-CijiICxt.js +0 -188
  375. package/dist/router-CijiICxt.js.map +0 -1
  376. package/dist/sanitize-jyJ2ryE2.js.map +0 -1
  377. package/dist/store-CPK9E62U.js +0 -262
  378. package/dist/store-CPK9E62U.js.map +0 -1
  379. package/dist/view-Cdi0g-qo.js +0 -396
  380. package/dist/view-Cdi0g-qo.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-form.d.ts","sourceRoot":"","sources":["../../src/forms/create-form.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAGV,IAAI,EACJ,UAAU,EAMX,MAAM,SAAS,CAAC;AA4EjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,UAAU,CAAC,CAAC,CAAC,KAAG,IAAI,CAAC,CAAC,CA8I3F,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Form handling module for bQuery.js.
3
+ *
4
+ * Provides a reactive, TypeScript-first form API with field-level
5
+ * and cross-field validation, dirty/touched tracking, and submission
6
+ * handling — all backed by bQuery's signal-based reactivity system.
7
+ *
8
+ * @module bquery/forms
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { createForm, required, email, min } from '@bquery/bquery/forms';
13
+ *
14
+ * const form = createForm({
15
+ * fields: {
16
+ * name: { initialValue: '', validators: [required()] },
17
+ * email: { initialValue: '', validators: [required(), email()] },
18
+ * age: { initialValue: 0, validators: [min(18, 'Must be 18+')] },
19
+ * },
20
+ * onSubmit: async (values) => {
21
+ * await fetch('/api/register', {
22
+ * method: 'POST',
23
+ * body: JSON.stringify(values),
24
+ * });
25
+ * },
26
+ * });
27
+ *
28
+ * // Reactive access
29
+ * console.log(form.isValid.value); // boolean
30
+ * console.log(form.fields.name.error.value); // '' or error message
31
+ *
32
+ * // Submit
33
+ * await form.handleSubmit();
34
+ * ```
35
+ */
36
+ export { createForm } from './create-form';
37
+ export { custom, customAsync, email, max, maxLength, min, minLength, pattern, required, url, } from './validators';
38
+ export type { AsyncValidator, CrossFieldValidator, FieldConfig, Form, FormConfig, FormErrors, FormField, FormFields, SubmitHandler, SyncValidator, ValidationResult, Validator, } from './types';
39
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forms/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EACL,MAAM,EACN,WAAW,EACX,KAAK,EACL,GAAG,EACH,SAAS,EACT,GAAG,EACH,SAAS,EACT,OAAO,EACP,QAAQ,EACR,GAAG,GACJ,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,IAAI,EACJ,UAAU,EACV,UAAU,EACV,SAAS,EACT,UAAU,EACV,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,SAAS,GACV,MAAM,SAAS,CAAC"}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Form module types and interfaces.
3
+ *
4
+ * @module bquery/forms
5
+ */
6
+ import type { Computed, Signal } from '../reactive/index';
7
+ /**
8
+ * Result of a single validation rule.
9
+ * A string indicates an error message; `true` or `undefined` means valid.
10
+ */
11
+ export type ValidationResult = string | true | undefined;
12
+ /**
13
+ * Synchronous validator function.
14
+ *
15
+ * @param value - The current field value
16
+ * @returns A validation result — `true` / `undefined` for valid, or an error string
17
+ */
18
+ export type SyncValidator<T = unknown> = (value: T) => ValidationResult;
19
+ /**
20
+ * Asynchronous validator function.
21
+ *
22
+ * @param value - The current field value
23
+ * @returns A promise resolving to a validation result
24
+ */
25
+ export type AsyncValidator<T = unknown> = (value: T) => Promise<ValidationResult>;
26
+ /**
27
+ * Either a sync or async validator.
28
+ */
29
+ export type Validator<T = unknown> = SyncValidator<T> | AsyncValidator<T>;
30
+ /**
31
+ * Configuration for a single form field.
32
+ *
33
+ * @template T - The type of the field value
34
+ */
35
+ export type FieldConfig<T = unknown> = {
36
+ /** Initial value for this field */
37
+ initialValue: T;
38
+ /** Validation rules applied in order; stops at first failure */
39
+ validators?: Validator<T>[];
40
+ };
41
+ /**
42
+ * Reactive state for a single form field.
43
+ *
44
+ * @template T - The type of the field value
45
+ */
46
+ export type FormField<T = unknown> = {
47
+ /** Reactive signal holding the current value */
48
+ value: Signal<T>;
49
+ /** Reactive signal for the first validation error (empty string when valid) */
50
+ error: Signal<string>;
51
+ /** Whether the field value differs from its initial value */
52
+ isDirty: Computed<boolean>;
53
+ /** Whether the field has been interacted with (blur / explicit touch) */
54
+ isTouched: Signal<boolean>;
55
+ /** Whether the field has never been modified */
56
+ isPristine: Computed<boolean>;
57
+ /** Mark the field as touched */
58
+ touch: () => void;
59
+ /** Reset the field to its initial value and clear errors */
60
+ reset: () => void;
61
+ };
62
+ /**
63
+ * Map of field names to their reactive field state.
64
+ */
65
+ export type FormFields<T extends Record<string, unknown>> = {
66
+ [K in keyof T]: FormField<T[K]>;
67
+ };
68
+ /**
69
+ * Map of field names to their error strings (reactive signals).
70
+ */
71
+ export type FormErrors<T extends Record<string, unknown>> = {
72
+ [K in keyof T]: Signal<string>;
73
+ };
74
+ /**
75
+ * Cross-field validation function.
76
+ * Receives all current field values and returns a map of field name → error message,
77
+ * or an empty object / undefined if all fields are valid.
78
+ */
79
+ export type CrossFieldValidator<T extends Record<string, unknown>> = (values: T) => Partial<Record<keyof T, string>> | undefined | Promise<Partial<Record<keyof T, string>> | undefined>;
80
+ /**
81
+ * Submit handler function.
82
+ *
83
+ * @template T - Shape of the form values
84
+ */
85
+ export type SubmitHandler<T extends Record<string, unknown>> = (values: T) => void | Promise<void>;
86
+ /**
87
+ * Configuration for `createForm()`.
88
+ *
89
+ * @template T - Shape of the form values
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * const config: FormConfig<{ name: string; age: number }> = {
94
+ * fields: {
95
+ * name: { initialValue: '', validators: [required('Name is required')] },
96
+ * age: { initialValue: 0, validators: [min(1, 'Must be positive')] },
97
+ * },
98
+ * onSubmit: (values) => console.log(values),
99
+ * };
100
+ * ```
101
+ */
102
+ export type FormConfig<T extends Record<string, unknown>> = {
103
+ /** Per-field configuration with initial values and validators */
104
+ fields: {
105
+ [K in keyof T]: FieldConfig<T[K]>;
106
+ };
107
+ /** Optional cross-field validators run after per-field validation */
108
+ crossValidators?: CrossFieldValidator<T>[];
109
+ /** Callback invoked on successful form submission */
110
+ onSubmit?: SubmitHandler<T>;
111
+ };
112
+ /**
113
+ * Return value of `createForm()`.
114
+ *
115
+ * @template T - Shape of the form values
116
+ */
117
+ export type Form<T extends Record<string, unknown>> = {
118
+ /** Reactive field objects keyed by field name */
119
+ fields: FormFields<T>;
120
+ /** Shorthand error signals keyed by field name */
121
+ errors: FormErrors<T>;
122
+ /** Computed signal: `true` when all fields pass validation */
123
+ isValid: Computed<boolean>;
124
+ /** Computed signal: `true` when any field value differs from initial */
125
+ isDirty: Computed<boolean>;
126
+ /** Reactive signal: `true` while the submit handler is executing */
127
+ isSubmitting: Signal<boolean>;
128
+ /** Validate all fields and, if valid, call the `onSubmit` handler */
129
+ handleSubmit: () => Promise<void>;
130
+ /** Validate a single field by name */
131
+ validateField: (name: keyof T & string) => Promise<void>;
132
+ /** Validate all fields without submitting */
133
+ validate: () => Promise<boolean>;
134
+ /** Reset the entire form to initial values */
135
+ reset: () => void;
136
+ /** Get a snapshot of all current field values */
137
+ getValues: () => T;
138
+ };
139
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/forms/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,EA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CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACpD,iDAAiD;IACjD,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,kDAAkD;IAClD,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtB,8DAA8D;IAC9D,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,wEAAwE;IACxE,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,oEAAoE;IACpE,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,qEAAqE;IACrE,YAAY,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC,sCAAsC;IACtC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,6CAA6C;IAC7C,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACjC,8CAA8C;IAC9C,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC,CAAC;CACpB,CAAC"}
@@ -0,0 +1,179 @@
1
+ /**
2
+ * Built-in validation functions for form fields.
3
+ *
4
+ * Each factory returns a {@link SyncValidator} that can be passed
5
+ * to a field's `validators` array in {@link FormConfig}.
6
+ *
7
+ * @module bquery/forms
8
+ */
9
+ import type { AsyncValidator, SyncValidator } from './types';
10
+ /**
11
+ * Requires a non-empty value.
12
+ *
13
+ * Fails for `undefined`, `null`, empty strings (after trim), and empty arrays.
14
+ *
15
+ * @param message - Custom error message (default: `'This field is required'`)
16
+ * @returns A sync validator function
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * import { required } from '@bquery/bquery/forms';
21
+ * const validate = required('Name is required');
22
+ * validate(''); // 'Name is required'
23
+ * validate('Ada'); // true
24
+ * ```
25
+ */
26
+ export declare const required: (message?: string) => SyncValidator;
27
+ /**
28
+ * Requires a string to have at least `len` characters.
29
+ *
30
+ * Non-string values are coerced via `String()` before checking length.
31
+ *
32
+ * @param len - Minimum length
33
+ * @param message - Custom error message
34
+ * @returns A sync validator function
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * import { minLength } from '@bquery/bquery/forms';
39
+ * const validate = minLength(3);
40
+ * validate('ab'); // 'Must be at least 3 characters'
41
+ * validate('abc'); // true
42
+ * ```
43
+ */
44
+ export declare const minLength: (len: number, message?: string) => SyncValidator<unknown>;
45
+ /**
46
+ * Requires a string to have at most `len` characters.
47
+ *
48
+ * Non-string values are coerced via `String()` before checking length.
49
+ *
50
+ * @param len - Maximum length
51
+ * @param message - Custom error message
52
+ * @returns A sync validator function
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import { maxLength } from '@bquery/bquery/forms';
57
+ * const validate = maxLength(10);
58
+ * validate('hello world!!'); // 'Must be at most 10 characters'
59
+ * validate('hello'); // true
60
+ * ```
61
+ */
62
+ export declare const maxLength: (len: number, message?: string) => SyncValidator<unknown>;
63
+ /**
64
+ * Requires a string to match a regular expression pattern.
65
+ *
66
+ * Non-string values are coerced via `String()` before testing.
67
+ *
68
+ * @param regex - Pattern to test against
69
+ * @param message - Custom error message (default: `'Invalid format'`)
70
+ * @returns A sync validator function
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * import { pattern } from '@bquery/bquery/forms';
75
+ * const validate = pattern(/^\d+$/, 'Numbers only');
76
+ * validate('abc'); // 'Numbers only'
77
+ * validate('123'); // true
78
+ * ```
79
+ */
80
+ export declare const pattern: (regex: RegExp, message?: string) => SyncValidator<unknown>;
81
+ /**
82
+ * RFC 5322–simplified email validation.
83
+ *
84
+ * @param message - Custom error message (default: `'Invalid email address'`)
85
+ * @returns A sync validator function
86
+ *
87
+ * @example
88
+ * ```ts
89
+ * import { email } from '@bquery/bquery/forms';
90
+ * const validate = email();
91
+ * validate('nope'); // 'Invalid email address'
92
+ * validate('ada@lovelace'); // 'Invalid email address'
93
+ * validate('ada@love.co'); // true
94
+ * ```
95
+ */
96
+ export declare const email: (message?: string) => SyncValidator<unknown>;
97
+ /**
98
+ * Requires a string to be a valid URL.
99
+ *
100
+ * Uses the native `URL` constructor for validation.
101
+ *
102
+ * @param message - Custom error message (default: `'Invalid URL'`)
103
+ * @returns A sync validator function
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import { url } from '@bquery/bquery/forms';
108
+ * const validate = url();
109
+ * validate('not-a-url'); // 'Invalid URL'
110
+ * validate('https://example.com'); // true
111
+ * ```
112
+ */
113
+ export declare const url: (message?: string) => SyncValidator<unknown>;
114
+ /**
115
+ * Requires a numeric value to be at least `limit`.
116
+ *
117
+ * @param limit - Minimum allowed value (inclusive)
118
+ * @param message - Custom error message
119
+ * @returns A sync validator function
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { min } from '@bquery/bquery/forms';
124
+ * const validate = min(1, 'Must be positive');
125
+ * validate(0); // 'Must be positive'
126
+ * validate(1); // true
127
+ * ```
128
+ */
129
+ export declare const min: (limit: number, message?: string) => SyncValidator<unknown>;
130
+ /**
131
+ * Requires a numeric value to be at most `limit`.
132
+ *
133
+ * @param limit - Maximum allowed value (inclusive)
134
+ * @param message - Custom error message
135
+ * @returns A sync validator function
136
+ *
137
+ * @example
138
+ * ```ts
139
+ * import { max } from '@bquery/bquery/forms';
140
+ * const validate = max(100, 'Too high');
141
+ * validate(101); // 'Too high'
142
+ * validate(100); // true
143
+ * ```
144
+ */
145
+ export declare const max: (limit: number, message?: string) => SyncValidator<unknown>;
146
+ /**
147
+ * Creates a custom synchronous validator from any predicate function.
148
+ *
149
+ * @param fn - Predicate that returns `true` when the value is valid
150
+ * @param message - Error message when the predicate returns `false`
151
+ * @returns A sync validator function
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * import { custom } from '@bquery/bquery/forms';
156
+ * const isEven = custom((v: number) => v % 2 === 0, 'Must be even');
157
+ * isEven(3); // 'Must be even'
158
+ * isEven(4); // true
159
+ * ```
160
+ */
161
+ export declare const custom: <T = unknown>(fn: (value: T) => boolean, message: string) => SyncValidator<T>;
162
+ /**
163
+ * Creates a custom asynchronous validator.
164
+ *
165
+ * @param fn - Async predicate that resolves to `true` when valid
166
+ * @param message - Error message when the predicate resolves to `false`
167
+ * @returns An async validator function
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * import { customAsync } from '@bquery/bquery/forms';
172
+ * const isUnique = customAsync(
173
+ * async (name: string) => !(await checkExists(name)),
174
+ * 'Already taken',
175
+ * );
176
+ * ```
177
+ */
178
+ export declare const customAsync: <T = unknown>(fn: (value: T) => Promise<boolean>, message: string) => AsyncValidator<T>;
179
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/forms/validators.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,QAAQ,GAAI,gBAAkC,KAAG,aAO7D,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,KAAG,aAAa,CAAC,OAAO,CAM9E,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS,GAAI,KAAK,MAAM,EAAE,UAAU,MAAM,KAAG,aAAa,CAAC,OAAO,CAM9E,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,MAAM,EAAE,gBAA0B,KAAG,aAAa,CAAC,OAAO,CAWxF,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,KAAK,GAAI,gBAAiC,KAAG,aAAa,CAAC,OAAO,CAS9E,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,GAAG,GAAI,gBAAuB,KAAG,aAAa,CAAC,OAAO,CAWlE,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,KAAG,aAAa,CAAC,OAAO,CAQ1E,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,MAAM,EAAE,UAAU,MAAM,KAAG,aAAa,CAAC,OAAO,CAQ1E,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,MAAM,GAAI,CAAC,GAAG,OAAO,EAChC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EACzB,SAAS,MAAM,KACd,aAAa,CAAC,CAAC,CAEjB,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,GAAG,OAAO,EACrC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,EAClC,SAAS,MAAM,KACd,cAAc,CAAC,CAAC,CAElB,CAAC"}
@@ -0,0 +1,141 @@
1
+ import { l as V } from "./type-guards-Do9DWgNp.js";
2
+ import { n as f } from "./core-DnlyjbF2.js";
3
+ import { r as l } from "./untrack-DJVQQ2WM.js";
4
+ var j = (r) => r === !0 || r === void 0, O = async (r, s) => {
5
+ const t = r(s), e = V(t) ? await t : t;
6
+ return j(e) ? void 0 : e;
7
+ }, F = (r) => {
8
+ const s = r.initialValue, t = f(s), e = f(""), o = f(!1), u = l(() => !Object.is(t.value, s));
9
+ return {
10
+ value: t,
11
+ error: e,
12
+ isDirty: u,
13
+ isTouched: o,
14
+ isPristine: l(() => !u.value),
15
+ touch: () => {
16
+ o.value = !0;
17
+ },
18
+ reset: () => {
19
+ t.value = s, e.value = "", o.value = !1;
20
+ }
21
+ };
22
+ }, v = async (r, s) => {
23
+ if (!s || s.length === 0)
24
+ return r.error.value = "", "";
25
+ for (const t of s) {
26
+ const e = await O(t, r.value.value);
27
+ if (e)
28
+ return r.error.value = e, e;
29
+ }
30
+ return r.error.value = "", "";
31
+ }, D = (r) => {
32
+ const s = Object.entries(r.fields), t = {}, e = {};
33
+ for (const [n, a] of s) {
34
+ const i = F(a);
35
+ t[n] = i, e[n] = i.error;
36
+ }
37
+ const o = f(!1), u = l(() => {
38
+ for (const n of Object.keys(t)) if (t[n].error.value !== "") return !1;
39
+ return !0;
40
+ }), b = l(() => {
41
+ for (const n of Object.keys(t)) if (t[n].isDirty.value) return !0;
42
+ return !1;
43
+ }), p = async (n) => {
44
+ const a = t[n], i = r.fields[n];
45
+ !a || !i || await v(a, i.validators);
46
+ }, y = async () => {
47
+ let n = !1;
48
+ for (const [a, i] of s) {
49
+ const c = t[a];
50
+ await v(c, i.validators) && (n = !0);
51
+ }
52
+ if (r.crossValidators && r.crossValidators.length > 0) {
53
+ const a = d();
54
+ for (const i of r.crossValidators) {
55
+ const c = await i(a);
56
+ if (c) {
57
+ for (const [S, g] of Object.entries(c)) if (g) {
58
+ const m = t[S];
59
+ m && (m.error.value === "" && (m.error.value = g), n = !0);
60
+ }
61
+ }
62
+ }
63
+ }
64
+ return !n;
65
+ }, h = async () => {
66
+ if (!o.value) {
67
+ o.value = !0;
68
+ try {
69
+ if (!await y()) return;
70
+ r.onSubmit && await r.onSubmit(d());
71
+ } finally {
72
+ o.value = !1;
73
+ }
74
+ }
75
+ }, w = () => {
76
+ for (const n of Object.keys(t)) t[n].reset();
77
+ }, d = () => {
78
+ const n = {};
79
+ for (const a of Object.keys(t)) n[a] = t[a].value.value;
80
+ return n;
81
+ };
82
+ return {
83
+ fields: t,
84
+ errors: e,
85
+ isValid: u,
86
+ isDirty: b,
87
+ isSubmitting: o,
88
+ handleSubmit: h,
89
+ validateField: p,
90
+ validate: y,
91
+ reset: w,
92
+ getValues: d
93
+ };
94
+ }, E = (r = "This field is required") => (s) => s == null || typeof s == "string" && s.trim() === "" || Array.isArray(s) && s.length === 0 ? r : !0, I = (r, s) => {
95
+ const t = s ?? `Must be at least ${r} characters`;
96
+ return (e) => (typeof e == "string" ? e : String(e ?? "")).length >= r ? !0 : t;
97
+ }, L = (r, s) => {
98
+ const t = s ?? `Must be at most ${r} characters`;
99
+ return (e) => (typeof e == "string" ? e : String(e ?? "")).length <= r ? !0 : t;
100
+ }, R = (r, s = "Invalid format") => {
101
+ const t = r.global || r.sticky ? new RegExp(r.source, r.flags.replace(/[gy]/g, "")) : r;
102
+ return (e) => {
103
+ const o = typeof e == "string" ? e : String(e ?? "");
104
+ return t.lastIndex = 0, t.test(o) ? !0 : s;
105
+ };
106
+ }, A = (r = "Invalid email address") => {
107
+ const s = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
108
+ return (t) => {
109
+ const e = typeof t == "string" ? t : String(t ?? "");
110
+ return e === "" || s.test(e) ? !0 : r;
111
+ };
112
+ }, C = (r = "Invalid URL") => (s) => {
113
+ const t = typeof s == "string" ? s : String(s ?? "");
114
+ if (t === "") return !0;
115
+ try {
116
+ return new URL(t), !0;
117
+ } catch {
118
+ return r;
119
+ }
120
+ }, N = (r, s) => {
121
+ const t = s ?? `Must be at least ${r}`;
122
+ return (e) => e == null || typeof e == "string" && e.trim() === "" || (typeof e == "number" ? e : Number(e)) >= r ? !0 : t;
123
+ }, q = (r, s) => {
124
+ const t = s ?? `Must be at most ${r}`;
125
+ return (e) => e == null || typeof e == "string" && e.trim() === "" || (typeof e == "number" ? e : Number(e)) <= r ? !0 : t;
126
+ }, x = (r, s) => (t) => r(t) ? !0 : s, P = (r, s) => async (t) => await r(t) ? !0 : s;
127
+ export {
128
+ L as a,
129
+ R as c,
130
+ D as d,
131
+ q as i,
132
+ E as l,
133
+ P as n,
134
+ N as o,
135
+ A as r,
136
+ I as s,
137
+ x as t,
138
+ C as u
139
+ };
140
+
141
+ //# sourceMappingURL=forms-C3yovgH9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"forms-C3yovgH9.js","names":[],"sources":["../src/forms/create-form.ts","../src/forms/validators.ts"],"sourcesContent":["/**\r\n * Reactive form creation and management.\r\n *\r\n * @module bquery/forms\r\n */\r\n\r\nimport { computed, signal } from '../reactive/index';\r\nimport { isPromise } from '../core/utils/type-guards';\r\nimport type {\r\n CrossFieldValidator,\r\n FieldConfig,\r\n Form,\r\n FormConfig,\r\n FormErrors,\r\n FormField,\r\n FormFields,\r\n ValidationResult,\r\n Validator,\r\n} from './types';\r\n\r\n/**\r\n * Determines whether a validator returned a valid result.\r\n * @internal\r\n */\r\nconst isValid = (result: ValidationResult): boolean => result === true || result === undefined;\r\n\r\n/**\r\n * Runs a single validator, normalising sync and async results.\r\n * @internal\r\n */\r\nconst runValidator = async <T>(validator: Validator<T>, value: T): Promise<string | undefined> => {\r\n const result = validator(value);\r\n const resolved = isPromise(result) ? await result : result;\r\n return isValid(resolved) ? undefined : (resolved as string);\r\n};\r\n\r\n/**\r\n * Creates a reactive form field from its configuration.\r\n * @internal\r\n */\r\nconst createField = <T>(config: FieldConfig<T>): FormField<T> => {\r\n const initial = config.initialValue;\r\n const value = signal<T>(initial);\r\n const error = signal('');\r\n const isTouched = signal(false);\r\n\r\n const isDirty = computed(() => !Object.is(value.value, initial));\r\n const isPristine = computed(() => !isDirty.value);\r\n\r\n return {\r\n value,\r\n error,\r\n isDirty,\r\n isTouched,\r\n isPristine,\r\n touch: () => {\r\n isTouched.value = true;\r\n },\r\n reset: () => {\r\n value.value = initial;\r\n error.value = '';\r\n isTouched.value = false;\r\n },\r\n };\r\n};\r\n\r\n/**\r\n * Validates a single field against its validators.\r\n * Sets the field's error signal.\r\n *\r\n * @returns The first error message, or an empty string if valid.\r\n * @internal\r\n */\r\nconst validateSingleField = async <T>(\r\n field: FormField<T>,\r\n validators: Validator<T>[] | undefined\r\n): Promise<string> => {\r\n if (!validators || validators.length === 0) {\r\n field.error.value = '';\r\n return '';\r\n }\r\n\r\n for (const validator of validators) {\r\n const errorMsg = await runValidator(validator, field.value.value);\r\n if (errorMsg) {\r\n field.error.value = errorMsg;\r\n return errorMsg;\r\n }\r\n }\r\n\r\n field.error.value = '';\r\n return '';\r\n};\r\n\r\n/**\r\n * Creates a fully reactive form with field-level validation,\r\n * dirty/touched tracking, cross-field validation, and submission handling.\r\n *\r\n * Each field's `value`, `error`, `isDirty`, `isTouched`, and `isPristine`\r\n * are reactive signals/computed values that can be used in effects, computed\r\n * values, or directly read/written.\r\n *\r\n * @template T - Shape of the form values (e.g. `{ name: string; age: number }`)\r\n * @param config - Form configuration with field definitions, validators, and submit handler\r\n * @returns A reactive {@link Form} instance\r\n *\r\n * @example\r\n * ```ts\r\n * import { createForm, required, email, min } from '@bquery/bquery/forms';\r\n *\r\n * const form = createForm({\r\n * fields: {\r\n * name: { initialValue: '', validators: [required()] },\r\n * email: { initialValue: '', validators: [required(), email()] },\r\n * age: { initialValue: 0, validators: [min(18, 'Must be 18+')] },\r\n * },\r\n * onSubmit: async (values) => {\r\n * await fetch('/api/register', {\r\n * method: 'POST',\r\n * body: JSON.stringify(values),\r\n * });\r\n * },\r\n * });\r\n *\r\n * // Read reactive state\r\n * console.log(form.isValid.value); // true (initially, before validation runs)\r\n * console.log(form.fields.name.value.value); // ''\r\n *\r\n * // Update a field\r\n * form.fields.name.value.value = 'Ada';\r\n *\r\n * // Validate and submit\r\n * await form.handleSubmit();\r\n * ```\r\n */\r\nexport const createForm = <T extends Record<string, unknown>>(config: FormConfig<T>): Form<T> => {\r\n // Build reactive field objects\r\n const fieldEntries = Object.entries(config.fields) as [\r\n keyof T & string,\r\n FieldConfig<T[keyof T]>,\r\n ][];\r\n\r\n const fields = {} as FormFields<T>;\r\n const errors = {} as FormErrors<T>;\r\n\r\n for (const [name, fieldConfig] of fieldEntries) {\r\n const field = createField(fieldConfig as FieldConfig<T[typeof name]>);\r\n (fields as Record<string, FormField>)[name] = field;\r\n (errors as Record<string, typeof field.error>)[name] = field.error;\r\n }\r\n\r\n const isSubmitting = signal(false);\r\n\r\n // Computed: form is valid when all error signals are empty\r\n const isFormValid = computed(() => {\r\n for (const name of Object.keys(fields)) {\r\n if ((fields as Record<string, FormField>)[name].error.value !== '') {\r\n return false;\r\n }\r\n }\r\n return true;\r\n });\r\n\r\n // Computed: form is dirty when any field is dirty\r\n const isFormDirty = computed(() => {\r\n for (const name of Object.keys(fields)) {\r\n if ((fields as Record<string, FormField>)[name].isDirty.value) {\r\n return true;\r\n }\r\n }\r\n return false;\r\n });\r\n\r\n /**\r\n * Validate a single field by name.\r\n */\r\n const validateField = async (name: keyof T & string): Promise<void> => {\r\n const field = (fields as Record<string, FormField>)[name];\r\n const fieldConfig = (config.fields as Record<string, FieldConfig>)[name];\r\n if (!field || !fieldConfig) return;\r\n await validateSingleField(field, fieldConfig.validators);\r\n };\r\n\r\n /**\r\n * Validate all fields (per-field + cross-field).\r\n * Returns `true` if the entire form is valid.\r\n */\r\n const validate = async (): Promise<boolean> => {\r\n let hasError = false;\r\n\r\n // Per-field validation\r\n for (const [name, fieldConfig] of fieldEntries) {\r\n const field = (fields as Record<string, FormField>)[name];\r\n const error = await validateSingleField(field, (fieldConfig as FieldConfig).validators);\r\n if (error) hasError = true;\r\n }\r\n\r\n // Cross-field validation\r\n if (config.crossValidators && config.crossValidators.length > 0) {\r\n const values = getValues();\r\n for (const crossValidator of config.crossValidators as CrossFieldValidator<T>[]) {\r\n const crossErrors = await crossValidator(values);\r\n if (crossErrors) {\r\n for (const [fieldName, errorMsg] of Object.entries(crossErrors) as [\r\n string,\r\n string | undefined,\r\n ][]) {\r\n if (errorMsg) {\r\n const field = (fields as Record<string, FormField>)[fieldName];\r\n if (field) {\r\n // Only set cross-field error if no per-field error exists\r\n if (field.error.value === '') {\r\n field.error.value = errorMsg;\r\n }\r\n hasError = true;\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n\r\n return !hasError;\r\n };\r\n\r\n /**\r\n * Validate all fields and, if valid, invoke the onSubmit handler.\r\n * Prevents concurrent submissions by setting isSubmitting before validation.\r\n */\r\n const handleSubmit = async (): Promise<void> => {\r\n if (isSubmitting.value) return;\r\n isSubmitting.value = true;\r\n\r\n try {\r\n const valid = await validate();\r\n if (!valid) return;\r\n\r\n if (config.onSubmit) {\r\n await config.onSubmit(getValues());\r\n }\r\n } finally {\r\n isSubmitting.value = false;\r\n }\r\n };\r\n\r\n /**\r\n * Reset every field to its initial value and clear all errors.\r\n */\r\n const reset = (): void => {\r\n for (const name of Object.keys(fields)) {\r\n (fields as Record<string, FormField>)[name].reset();\r\n }\r\n };\r\n\r\n /**\r\n * Return a plain object snapshot of all current field values.\r\n */\r\n const getValues = (): T => {\r\n const values = {} as Record<string, unknown>;\r\n for (const name of Object.keys(fields)) {\r\n values[name] = (fields as Record<string, FormField>)[name].value.value;\r\n }\r\n return values as T;\r\n };\r\n\r\n return {\r\n fields,\r\n errors,\r\n isValid: isFormValid,\r\n isDirty: isFormDirty,\r\n isSubmitting,\r\n handleSubmit,\r\n validateField,\r\n validate,\r\n reset,\r\n getValues,\r\n };\r\n};\r\n","/**\r\n * Built-in validation functions for form fields.\r\n *\r\n * Each factory returns a {@link SyncValidator} that can be passed\r\n * to a field's `validators` array in {@link FormConfig}.\r\n *\r\n * @module bquery/forms\r\n */\r\n\r\nimport type { AsyncValidator, SyncValidator } from './types';\r\n\r\n/**\r\n * Requires a non-empty value.\r\n *\r\n * Fails for `undefined`, `null`, empty strings (after trim), and empty arrays.\r\n *\r\n * @param message - Custom error message (default: `'This field is required'`)\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { required } from '@bquery/bquery/forms';\r\n * const validate = required('Name is required');\r\n * validate(''); // 'Name is required'\r\n * validate('Ada'); // true\r\n * ```\r\n */\r\nexport const required = (message = 'This field is required'): SyncValidator => {\r\n return (value: unknown) => {\r\n if (value == null) return message;\r\n if (typeof value === 'string' && value.trim() === '') return message;\r\n if (Array.isArray(value) && value.length === 0) return message;\r\n return true;\r\n };\r\n};\r\n\r\n/**\r\n * Requires a string to have at least `len` characters.\r\n *\r\n * Non-string values are coerced via `String()` before checking length.\r\n *\r\n * @param len - Minimum length\r\n * @param message - Custom error message\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { minLength } from '@bquery/bquery/forms';\r\n * const validate = minLength(3);\r\n * validate('ab'); // 'Must be at least 3 characters'\r\n * validate('abc'); // true\r\n * ```\r\n */\r\nexport const minLength = (len: number, message?: string): SyncValidator<unknown> => {\r\n const msg = message ?? `Must be at least ${len} characters`;\r\n return (value: unknown) => {\r\n const str = typeof value === 'string' ? value : String(value ?? '');\r\n return str.length >= len ? true : msg;\r\n };\r\n};\r\n\r\n/**\r\n * Requires a string to have at most `len` characters.\r\n *\r\n * Non-string values are coerced via `String()` before checking length.\r\n *\r\n * @param len - Maximum length\r\n * @param message - Custom error message\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { maxLength } from '@bquery/bquery/forms';\r\n * const validate = maxLength(10);\r\n * validate('hello world!!'); // 'Must be at most 10 characters'\r\n * validate('hello'); // true\r\n * ```\r\n */\r\nexport const maxLength = (len: number, message?: string): SyncValidator<unknown> => {\r\n const msg = message ?? `Must be at most ${len} characters`;\r\n return (value: unknown) => {\r\n const str = typeof value === 'string' ? value : String(value ?? '');\r\n return str.length <= len ? true : msg;\r\n };\r\n};\r\n\r\n/**\r\n * Requires a string to match a regular expression pattern.\r\n *\r\n * Non-string values are coerced via `String()` before testing.\r\n *\r\n * @param regex - Pattern to test against\r\n * @param message - Custom error message (default: `'Invalid format'`)\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { pattern } from '@bquery/bquery/forms';\r\n * const validate = pattern(/^\\d+$/, 'Numbers only');\r\n * validate('abc'); // 'Numbers only'\r\n * validate('123'); // true\r\n * ```\r\n */\r\nexport const pattern = (regex: RegExp, message = 'Invalid format'): SyncValidator<unknown> => {\r\n const safeRegex =\r\n regex.global || regex.sticky\r\n ? new RegExp(regex.source, regex.flags.replace(/[gy]/g, ''))\r\n : regex;\r\n\r\n return (value: unknown) => {\r\n const str = typeof value === 'string' ? value : String(value ?? '');\r\n safeRegex.lastIndex = 0;\r\n return safeRegex.test(str) ? true : message;\r\n };\r\n};\r\n\r\n/**\r\n * RFC 5322–simplified email validation.\r\n *\r\n * @param message - Custom error message (default: `'Invalid email address'`)\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { email } from '@bquery/bquery/forms';\r\n * const validate = email();\r\n * validate('nope'); // 'Invalid email address'\r\n * validate('ada@lovelace'); // 'Invalid email address'\r\n * validate('ada@love.co'); // true\r\n * ```\r\n */\r\nexport const email = (message = 'Invalid email address'): SyncValidator<unknown> => {\r\n // Intentionally simple — covers the vast majority of valid addresses\r\n // without re-implementing the full RFC 5322 grammar.\r\n const re = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\r\n return (value: unknown) => {\r\n const str = typeof value === 'string' ? value : String(value ?? '');\r\n if (str === '') return true; // empty is handled by `required`\r\n return re.test(str) ? true : message;\r\n };\r\n};\r\n\r\n/**\r\n * Requires a string to be a valid URL.\r\n *\r\n * Uses the native `URL` constructor for validation.\r\n *\r\n * @param message - Custom error message (default: `'Invalid URL'`)\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { url } from '@bquery/bquery/forms';\r\n * const validate = url();\r\n * validate('not-a-url'); // 'Invalid URL'\r\n * validate('https://example.com'); // true\r\n * ```\r\n */\r\nexport const url = (message = 'Invalid URL'): SyncValidator<unknown> => {\r\n return (value: unknown) => {\r\n const str = typeof value === 'string' ? value : String(value ?? '');\r\n if (str === '') return true; // empty is handled by `required`\r\n try {\r\n new URL(str);\r\n return true;\r\n } catch {\r\n return message;\r\n }\r\n };\r\n};\r\n\r\n/**\r\n * Requires a numeric value to be at least `limit`.\r\n *\r\n * @param limit - Minimum allowed value (inclusive)\r\n * @param message - Custom error message\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { min } from '@bquery/bquery/forms';\r\n * const validate = min(1, 'Must be positive');\r\n * validate(0); // 'Must be positive'\r\n * validate(1); // true\r\n * ```\r\n */\r\nexport const min = (limit: number, message?: string): SyncValidator<unknown> => {\r\n const msg = message ?? `Must be at least ${limit}`;\r\n return (value: unknown) => {\r\n if (value == null) return true;\r\n if (typeof value === 'string' && value.trim() === '') return true;\r\n const num = typeof value === 'number' ? value : Number(value);\r\n return num >= limit ? true : msg;\r\n };\r\n};\r\n\r\n/**\r\n * Requires a numeric value to be at most `limit`.\r\n *\r\n * @param limit - Maximum allowed value (inclusive)\r\n * @param message - Custom error message\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { max } from '@bquery/bquery/forms';\r\n * const validate = max(100, 'Too high');\r\n * validate(101); // 'Too high'\r\n * validate(100); // true\r\n * ```\r\n */\r\nexport const max = (limit: number, message?: string): SyncValidator<unknown> => {\r\n const msg = message ?? `Must be at most ${limit}`;\r\n return (value: unknown) => {\r\n if (value == null) return true;\r\n if (typeof value === 'string' && value.trim() === '') return true;\r\n const num = typeof value === 'number' ? value : Number(value);\r\n return num <= limit ? true : msg;\r\n };\r\n};\r\n\r\n/**\r\n * Creates a custom synchronous validator from any predicate function.\r\n *\r\n * @param fn - Predicate that returns `true` when the value is valid\r\n * @param message - Error message when the predicate returns `false`\r\n * @returns A sync validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { custom } from '@bquery/bquery/forms';\r\n * const isEven = custom((v: number) => v % 2 === 0, 'Must be even');\r\n * isEven(3); // 'Must be even'\r\n * isEven(4); // true\r\n * ```\r\n */\r\nexport const custom = <T = unknown>(\r\n fn: (value: T) => boolean,\r\n message: string\r\n): SyncValidator<T> => {\r\n return (value: T) => (fn(value) ? true : message);\r\n};\r\n\r\n/**\r\n * Creates a custom asynchronous validator.\r\n *\r\n * @param fn - Async predicate that resolves to `true` when valid\r\n * @param message - Error message when the predicate resolves to `false`\r\n * @returns An async validator function\r\n *\r\n * @example\r\n * ```ts\r\n * import { customAsync } from '@bquery/bquery/forms';\r\n * const isUnique = customAsync(\r\n * async (name: string) => !(await checkExists(name)),\r\n * 'Already taken',\r\n * );\r\n * ```\r\n */\r\nexport const customAsync = <T = unknown>(\r\n fn: (value: T) => Promise<boolean>,\r\n message: string\r\n): AsyncValidator<T> => {\r\n return async (value: T) => ((await fn(value)) ? true : message);\r\n};\r\n"],"mappings":";;;AAwBA,IAAM,IAAA,CAAW,MAAsC,MAAW,MAAQ,MAAW,QAM/E,IAAe,OAAU,GAAyB,MAA0C;AAChG,QAAM,IAAS,EAAU,CAAA,GACnB,IAAW,EAAU,CAAA,IAAU,MAAM,IAAS;AACpD,SAAO,EAAQ,CAAA,IAAY,SAAa;GAOpC,IAAA,CAAkB,MAAyC;AAC/D,QAAM,IAAU,EAAO,cACjB,IAAQ,EAAU,CAAA,GAClB,IAAQ,EAAO,EAAA,GACf,IAAY,EAAO,EAAA,GAEnB,IAAU,EAAA,MAAe,CAAC,OAAO,GAAG,EAAM,OAAO,CAAA,CAAQ;AAG/D,SAAO;AAAA,IACL,OAAA;AAAA,IACA,OAAA;AAAA,IACA,SAAA;AAAA,IACA,WAAA;AAAA,IACA,YAPiB,EAAA,MAAe,CAAC,EAAQ,KAAA;AAAA,IAQzC,OAAA,MAAa;AACX,MAAA,EAAU,QAAQ;AAAA;IAEpB,OAAA,MAAa;AACX,MAAA,EAAM,QAAQ,GACd,EAAM,QAAQ,IACd,EAAU,QAAQ;AAAA;;GAYlB,IAAsB,OAC1B,GACA,MACoB;AACpB,MAAI,CAAC,KAAc,EAAW,WAAW;AACvC,WAAA,EAAM,MAAM,QAAQ,IACb;AAGT,aAAW,KAAa,GAAY;AAClC,UAAM,IAAW,MAAM,EAAa,GAAW,EAAM,MAAM,KAAA;AAC3D,QAAI;AACF,aAAA,EAAM,MAAM,QAAQ,GACb;AAAA;AAIX,SAAA,EAAM,MAAM,QAAQ,IACb;GA4CI,IAAA,CAAiD,MAAmC;AAE/F,QAAM,IAAe,OAAO,QAAQ,EAAO,MAAA,GAKrC,I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";
2
+ export {
3
+ r as createForm,
4
+ u as custom,
5
+ n as customAsync,
6
+ i as email,
7
+ t as max,
8
+ s as maxLength,
9
+ o as min,
10
+ c as minLength,
11
+ m as pattern,
12
+ e as required,
13
+ l as url
14
+ };
package/dist/full.d.ts CHANGED
@@ -35,20 +35,48 @@
35
35
  * ```
36
36
  */
37
37
  export { $, $$, BQueryCollection, BQueryElement, utils } from './core/index';
38
+ export type { BQueryUtils } from './core/index';
38
39
  export { Computed, Signal, batch, computed, createUseFetch, effect, isComputed, isSignal, linkedSignal, persistedSignal, readonly, signal, useAsyncData, useFetch, untrack, watch, } from './reactive/index';
39
40
  export type { AsyncDataState, AsyncDataStatus, AsyncWatchSource, CleanupFn, FetchInput, LinkedSignal, Observer, ReadonlySignal, UseAsyncDataOptions, UseFetchOptions, } from './reactive/index';
40
- export { component, html, registerDefaultComponents, safeHtml } from './component/index';
41
- export type { ComponentDefinition, DefaultComponentLibraryOptions, PropDefinition, RegisteredDefaultComponents, } from './component/index';
42
- export { animate, capturePosition, easeInCubic, easeInOutCubic, easeInOutQuad, easeInQuad, easeOutBack, easeOutCubic, easeOutExpo, easeOutQuad, easingPresets, flip, flipElements, flipList, keyframePresets, linear, prefersReducedMotion, scrollAnimate, sequence, spring, springPresets, stagger, timeline, transition, } from './motion/index';
43
- export type { AnimateOptions, EasingFunction, ElementBounds, FlipGroupOptions, FlipOptions, ScrollAnimateCleanup, ScrollAnimateOptions, SequenceOptions, SequenceStep, Spring, SpringConfig, StaggerFunction, StaggerOptions, TimelineConfig, TimelineControls, TimelineStep, TransitionOptions, } from './motion/index';
44
- export { createTrustedHtml, escapeHtml, generateNonce, getTrustedTypesPolicy, hasCSPDirective, isTrustedTypesSupported, sanitize, sanitizeHtml, stripTags, } from './security/index';
45
- export type { SanitizeOptions } from './security/index';
41
+ export { bool, component, defineComponent, html, registerDefaultComponents, safeHtml, useComputed, useEffect, useSignal, } from './component/index';
42
+ export type { AttributeChange, ComponentDefinition, ComponentRenderContext, ComponentStateKey, ComponentSignalLike, ComponentSignals, DefaultComponentLibraryOptions, PropDefinition, RegisteredDefaultComponents, ShadowMode, } from './component/index';
43
+ export { animate, capturePosition, easeInCubic, easeInOutCubic, easeInOutQuad, easeInQuad, easeOutBack, easeOutCubic, easeOutExpo, easeOutQuad, easingPresets, flip, flipElements, flipList, keyframePresets, linear, morphElement, parallax, prefersReducedMotion, scrollAnimate, sequence, setReducedMotion, spring, springPresets, stagger, timeline, transition, typewriter, } from './motion/index';
44
+ export type { AnimateOptions, EasingFunction, ElementBounds, FlipGroupOptions, FlipOptions, MorphOptions, ParallaxCleanup, ParallaxOptions, ScrollAnimateCleanup, ScrollAnimateOptions, SequenceOptions, SequenceStep, Spring, SpringConfig, StaggerFunction, StaggerOptions, TimelineConfig, TimelineControls, TimelineStep, TransitionOptions, TypewriterControls, TypewriterOptions, } from './motion/index';
45
+ export { createTrustedHtml, escapeHtml, generateNonce, getTrustedTypesPolicy, hasCSPDirective, isTrustedTypesSupported, sanitize, sanitizeHtml, stripTags, trusted, } from './security/index';
46
+ export type { SanitizedHtml, SanitizeOptions, TrustedHtml } from './security/index';
46
47
  export { buckets, cache, defineBqueryConfig, definePageMeta, getBqueryConfig, notifications, storage, useAnnouncer, useCookie, } from './platform/index';
47
48
  export type { AnnounceOptions, AnnouncerHandle, Bucket, BqueryConfig, CacheHandle, IndexedDBOptions, NotificationOptions, PageMetaDefinition, StorageAdapter, UseAnnouncerOptions, UseCookieOptions, } from './platform/index';
48
- export { back, createRouter, currentRoute, forward, interceptLinks, isActive, isActiveSignal, link, navigate, resolve, } from './router/index';
49
- export type { NavigationGuard, Route, RouteDefinition, Router, RouterOptions, } from './router/index';
49
+ export { back, BqLinkElement, createRouter, currentRoute, forward, interceptLinks, isActive, isActiveSignal, link, navigate, registerBqLink, resolve, useRoute, } from './router/index';
50
+ export type { NavigationGuard, Route, RouteDefinition, Router, RouterOptions, UseRouteReturn, } from './router/index';
50
51
  export { createPersistedStore, createStore, destroyStore, getStore, listStores, mapActions, mapState, registerPlugin, } from './store/index';
51
- export type { StateFactory, Store, StoreDefinition, StorePlugin } from './store/index';
52
+ export type { ActionContext, OnActionCallback, PersistedStoreOptions, StateFactory, StorageBackend, Store, StoreDefinition, StorePlugin, StoreSerializer, } from './store/index';
52
53
  export { createTemplate, mount } from './view/index';
53
54
  export type { BindingContext, MountOptions, View } from './view/index';
55
+ export { createForm, custom, customAsync, email, max, maxLength, min, minLength, pattern, required, url, } from './forms/index';
56
+ export type { AsyncValidator, CrossFieldValidator, FieldConfig, Form, FormConfig, FormErrors, FormField, FormFields, SubmitHandler, SyncValidator, ValidationResult, Validator, } from './forms/index';
57
+ export { createI18n, formatDate, formatNumber } from './i18n/index';
58
+ export type { DateFormatOptions, I18nConfig, I18nInstance, LocaleLoader, LocaleMessages, Messages, NumberFormatOptions, TranslateParams, } from './i18n/index';
59
+ export { announceToScreenReader, auditA11y, clearAnnouncements, getFocusableElements, prefersColorScheme, prefersContrast, releaseFocus, rovingTabIndex, skipLink, trapFocus, } from './a11y/index';
60
+ export type { AnnouncePriority, AuditFinding, AuditResult, AuditSeverity, ColorScheme, ContrastPreference, FocusTrapHandle, RovingTabIndexHandle, RovingTabIndexOptions, SkipLinkHandle, SkipLinkOptions, TrapFocusOptions, } from './a11y/index';
61
+ export { draggable } from './dnd/index';
62
+ export { droppable } from './dnd/index';
63
+ export { sortable } from './dnd/index';
64
+ export type { BoundsRect, DragAxis, DragBounds, DragEventData, DragPosition, DraggableHandle, DraggableOptions, DropEventData, DroppableHandle, DroppableOptions, SortEventData, SortableHandle, SortableOptions, } from './dnd/index';
65
+ export { mediaQuery } from './media/index';
66
+ export { breakpoints } from './media/index';
67
+ export { useViewport } from './media/index';
68
+ export { useNetworkStatus } from './media/index';
69
+ export { useBattery } from './media/index';
70
+ export { useGeolocation } from './media/index';
71
+ export { useDeviceMotion, useDeviceOrientation } from './media/index';
72
+ export { clipboard } from './media/index';
73
+ export type { BatteryState, BreakpointMap, ClipboardAPI, DeviceMotionState, DeviceOrientationState, GeolocationOptions, GeolocationState, NetworkState, ViewportState, } from './media/index';
74
+ export { use, isInstalled, getInstalledPlugins, getCustomDirective, getCustomDirectives, resetPlugins, } from './plugin/index';
75
+ export type { BQueryPlugin, CustomDirective, CustomDirectiveHandler, PluginInstallContext, } from './plugin/index';
76
+ export { enableDevtools, isDevtoolsEnabled, trackSignal, untrackSignal, generateSignalLabel, inspectSignals, inspectStores, inspectComponents, recordEvent, getTimeline, clearTimeline, getDevtoolsState, logSignals, logStores, logComponents, logTimeline, } from './devtools/index';
77
+ export type { ComponentSnapshot, DevtoolsOptions, DevtoolsState, SignalSnapshot, StoreSnapshot, TimelineEntry, TimelineEventType, } from './devtools/index';
78
+ export { renderComponent, flushEffects, mockSignal, mockRouter, fireEvent, waitFor, } from './testing/index';
79
+ export type { FireEventOptions, MockRouter, MockRouterOptions, MockSignal, RenderComponentOptions, RenderResult, TestRoute, WaitForOptions, } from './testing/index';
80
+ export { renderToString, hydrateMount, serializeStoreState, deserializeStoreState, hydrateStore, hydrateStores, } from './ssr/index';
81
+ export type { DeserializedStoreState, HydrateMountOptions, HydrationOptions, RenderOptions, SSRResult, SerializeOptions, SerializeResult, } from './ssr/index';
54
82
  //# sourceMappingURL=full.d.ts.map