mlform 0.1.2 → 0.1.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 (299) hide show
  1. package/README.md +241 -88
  2. package/dist/design-system-CrrSGfFB.js +1352 -0
  3. package/dist/engine-nnhWPT2L.js +5301 -0
  4. package/dist/kit-Dt_1Fxlc.js +76 -0
  5. package/dist/mlform/design-system.mjs +2 -0
  6. package/dist/mlform/engine.mjs +3 -0
  7. package/dist/mlform/kit.mjs +3 -0
  8. package/dist/mlform/primitives.mjs +2 -0
  9. package/dist/mlform/questionnaire.mjs +640 -0
  10. package/dist/mlform/transport.mjs +2 -0
  11. package/dist/mlform.mjs +4 -709
  12. package/dist/primitives-Pi-ztAr6.js +5063 -0
  13. package/dist/transport-A1RsnZhD.js +2143 -0
  14. package/dist/types/src/design-system/constants.d.ts +34 -0
  15. package/dist/types/src/design-system/contract/component-keys.d.ts +2 -0
  16. package/dist/types/src/design-system/contract/component-tokens.d.ts +5 -0
  17. package/dist/types/src/design-system/contract/global-tokens.d.ts +7 -0
  18. package/dist/types/src/design-system/contract/index.d.ts +4 -0
  19. package/dist/types/src/design-system/contract/token-keys.d.ts +12 -0
  20. package/dist/types/src/design-system/index.d.ts +8 -0
  21. package/dist/types/src/design-system/recipes/contrast.d.ts +2 -0
  22. package/dist/types/src/design-system/recipes/default.d.ts +2 -0
  23. package/dist/types/src/design-system/recipes/index.d.ts +4 -0
  24. package/dist/types/src/design-system/recipes/minimal.d.ts +2 -0
  25. package/dist/types/src/design-system/recipes/soft.d.ts +2 -0
  26. package/dist/types/src/design-system/registry/builtins.d.ts +5 -0
  27. package/dist/types/src/design-system/registry/create-registry.d.ts +2 -0
  28. package/dist/types/src/design-system/registry/deep-freeze.d.ts +5 -0
  29. package/dist/types/src/design-system/registry/define-recipe.d.ts +2 -0
  30. package/dist/types/src/design-system/registry/define-theme.d.ts +2 -0
  31. package/dist/types/src/design-system/registry/define-token-maps.d.ts +6 -0
  32. package/dist/types/src/design-system/registry/index.d.ts +5 -0
  33. package/dist/types/src/design-system/resolve/diagnostics.d.ts +9 -0
  34. package/dist/types/src/design-system/resolve/index.d.ts +5 -0
  35. package/dist/types/src/design-system/resolve/merge-config.d.ts +2 -0
  36. package/dist/types/src/design-system/resolve/migrate-tokens.d.ts +44 -0
  37. package/dist/types/src/design-system/resolve/resolve-mode.d.ts +6 -0
  38. package/dist/types/src/design-system/resolve/resolve-recipe.d.ts +2 -0
  39. package/dist/types/src/design-system/resolve/resolve-theme.d.ts +2 -0
  40. package/dist/types/src/design-system/resolve/resolve-tokens.d.ts +2 -0
  41. package/dist/types/src/design-system/runtime/apply-tokens.d.ts +4 -0
  42. package/dist/types/src/design-system/runtime/attach-design-system.d.ts +11 -0
  43. package/dist/types/src/design-system/runtime/create-stylesheet.d.ts +11 -0
  44. package/dist/types/src/design-system/runtime/declarations.d.ts +5 -0
  45. package/dist/types/src/design-system/runtime/design-system-controller.d.ts +9 -0
  46. package/dist/types/src/design-system/runtime/host-state.d.ts +3 -0
  47. package/dist/types/src/design-system/runtime/hydrate-design-system.d.ts +25 -0
  48. package/dist/types/src/design-system/runtime/index.d.ts +8 -0
  49. package/dist/types/src/design-system/themes/cobalt.d.ts +2 -0
  50. package/dist/types/src/design-system/themes/graphite.d.ts +2 -0
  51. package/dist/types/src/design-system/themes/index.d.ts +5 -0
  52. package/dist/types/src/design-system/themes/neutral.d.ts +2 -0
  53. package/dist/types/src/design-system/themes/sage.d.ts +2 -0
  54. package/dist/types/src/design-system/themes/sunset.d.ts +2 -0
  55. package/dist/types/src/design-system/tokens/base.d.ts +5 -0
  56. package/dist/types/src/design-system/tokens/contrast.d.ts +8 -0
  57. package/dist/types/src/design-system/tokens/density.d.ts +9 -0
  58. package/dist/types/src/design-system/tokens/forced-colors.d.ts +12 -0
  59. package/dist/types/src/design-system/tokens/index.d.ts +5 -0
  60. package/dist/types/src/design-system/tokens/motion.d.ts +2 -0
  61. package/dist/types/src/design-system/types.d.ts +225 -0
  62. package/dist/types/src/engine/builtins/fields/boolean.d.ts +8 -0
  63. package/dist/types/src/engine/builtins/fields/category.d.ts +11 -0
  64. package/dist/types/src/engine/builtins/fields/date.d.ts +9 -0
  65. package/dist/types/src/engine/builtins/fields/long-text.d.ts +10 -0
  66. package/dist/types/src/engine/builtins/fields/multi-choice.d.ts +12 -0
  67. package/dist/types/src/engine/builtins/fields/number.d.ts +11 -0
  68. package/dist/types/src/engine/builtins/fields/rating.d.ts +9 -0
  69. package/dist/types/src/engine/builtins/fields/series.d.ts +20 -0
  70. package/dist/types/src/engine/builtins/fields/single-choice.d.ts +12 -0
  71. package/dist/types/src/engine/builtins/fields/text.d.ts +10 -0
  72. package/dist/types/src/engine/builtins/index.d.ts +97 -0
  73. package/dist/types/src/engine/builtins/reports/classifier.d.ts +8 -0
  74. package/dist/types/src/engine/builtins/reports/regressor.d.ts +8 -0
  75. package/dist/types/src/engine/builtins/shared.d.ts +49 -0
  76. package/dist/types/src/engine/comparison.d.ts +2 -0
  77. package/dist/types/src/engine/constants.d.ts +51 -0
  78. package/dist/types/src/engine/declarative/explanation.d.ts +2 -0
  79. package/dist/types/src/engine/declarative/field.d.ts +2 -0
  80. package/dist/types/src/engine/declarative/presentation.d.ts +61 -0
  81. package/dist/types/src/engine/declarative/report.d.ts +2 -0
  82. package/dist/types/src/engine/equality.d.ts +4 -0
  83. package/dist/types/src/engine/errors.d.ts +28 -0
  84. package/dist/types/src/engine/explanations/controller.d.ts +13 -0
  85. package/dist/types/src/engine/explanations/index.d.ts +1 -0
  86. package/dist/types/src/engine/fields/controller.d.ts +30 -0
  87. package/dist/types/src/engine/fields/index.d.ts +1 -0
  88. package/dist/types/src/engine/form.d.ts +2 -0
  89. package/dist/types/src/engine/index.d.ts +11 -0
  90. package/dist/types/src/engine/paths.d.ts +2 -0
  91. package/dist/types/src/engine/registry/index.d.ts +26 -0
  92. package/dist/types/src/engine/reports/controller.d.ts +19 -0
  93. package/dist/types/src/engine/reports/index.d.ts +1 -0
  94. package/dist/types/src/engine/schema/index.d.ts +7 -0
  95. package/dist/types/src/engine/state/engine.d.ts +60 -0
  96. package/dist/types/src/engine/state/index.d.ts +3 -0
  97. package/dist/types/src/engine/state/snapshots.d.ts +5 -0
  98. package/dist/types/src/engine/state/store.d.ts +13 -0
  99. package/dist/types/src/engine/submission/abort.d.ts +15 -0
  100. package/dist/types/src/engine/submission/explanations.d.ts +2 -0
  101. package/dist/types/src/engine/submission/index.d.ts +5 -0
  102. package/dist/types/src/engine/submission/lifecycle.d.ts +16 -0
  103. package/dist/types/src/engine/submission/pipeline.d.ts +2 -0
  104. package/dist/types/src/engine/submission/reports.d.ts +12 -0
  105. package/dist/types/src/engine/submission/request.d.ts +23 -0
  106. package/dist/types/src/engine/submission/result.d.ts +4 -0
  107. package/dist/types/src/engine/submission/submitter.d.ts +40 -0
  108. package/dist/types/src/engine/types/explanation.d.ts +109 -0
  109. package/dist/types/src/engine/types/field.d.ts +172 -0
  110. package/dist/types/src/engine/types/form.d.ts +120 -0
  111. package/dist/types/src/engine/types/index.d.ts +9 -0
  112. package/dist/types/src/engine/types/pipeline.d.ts +31 -0
  113. package/dist/types/src/engine/types/registry.d.ts +17 -0
  114. package/dist/types/src/engine/types/report.d.ts +87 -0
  115. package/dist/types/src/engine/types/transport.d.ts +41 -0
  116. package/dist/types/src/engine/utils.d.ts +9 -0
  117. package/dist/types/src/engine/validation/conditions.d.ts +11 -0
  118. package/dist/types/src/engine/validation/field.d.ts +29 -0
  119. package/dist/types/src/engine/validation/form.d.ts +35 -0
  120. package/dist/types/src/engine/validation/index.d.ts +3 -0
  121. package/dist/types/src/engine/values.d.ts +2 -0
  122. package/dist/types/src/index.d.ts +7 -0
  123. package/dist/types/src/kit/constants.d.ts +4 -0
  124. package/dist/types/src/kit/defaults.d.ts +11 -0
  125. package/dist/types/src/kit/index.d.ts +4 -0
  126. package/dist/types/src/kit/mount-form.d.ts +3 -0
  127. package/dist/types/src/kit/types.d.ts +52 -0
  128. package/dist/types/src/primitives/base-async-report-element.d.ts +19 -0
  129. package/dist/types/src/primitives/base-explanation-element.d.ts +21 -0
  130. package/dist/types/src/primitives/base-field-element.d.ts +21 -0
  131. package/dist/types/src/primitives/base-report-element.d.ts +15 -0
  132. package/dist/types/src/primitives/components/declarative-explanation.d.ts +5 -0
  133. package/dist/types/src/primitives/components/declarative-field.d.ts +6 -0
  134. package/dist/types/src/primitives/components/declarative-report.d.ts +5 -0
  135. package/dist/types/src/primitives/components/explanation-panel.d.ts +22 -0
  136. package/dist/types/src/primitives/components/field-frame.d.ts +21 -0
  137. package/dist/types/src/primitives/components/form-errors.d.ts +19 -0
  138. package/dist/types/src/primitives/components/form-root.d.ts +29 -0
  139. package/dist/types/src/primitives/components/presentation.d.ts +4 -0
  140. package/dist/types/src/primitives/components/report-frame.d.ts +22 -0
  141. package/dist/types/src/primitives/components/submit-button.d.ts +21 -0
  142. package/dist/types/src/primitives/components/unsupported-component.d.ts +14 -0
  143. package/dist/types/src/primitives/constants.d.ts +94 -0
  144. package/dist/types/src/primitives/controller-binding.d.ts +32 -0
  145. package/dist/types/src/primitives/fields/boolean-field.d.ts +6 -0
  146. package/dist/types/src/primitives/fields/category-field.d.ts +6 -0
  147. package/dist/types/src/primitives/fields/date-field.d.ts +6 -0
  148. package/dist/types/src/primitives/fields/long-text-field.d.ts +6 -0
  149. package/dist/types/src/primitives/fields/multi-choice-field.d.ts +6 -0
  150. package/dist/types/src/primitives/fields/number-field.d.ts +8 -0
  151. package/dist/types/src/primitives/fields/rating-field.d.ts +6 -0
  152. package/dist/types/src/primitives/fields/series-field.d.ts +8 -0
  153. package/dist/types/src/primitives/fields/single-choice-field.d.ts +6 -0
  154. package/dist/types/src/primitives/fields/text-field.d.ts +6 -0
  155. package/dist/types/src/primitives/index.d.ts +8 -0
  156. package/dist/types/src/primitives/mount-form.d.ts +4 -0
  157. package/dist/types/src/primitives/register.d.ts +0 -0
  158. package/dist/types/src/primitives/registry.d.ts +3 -0
  159. package/dist/types/src/primitives/reports/classifier-report.d.ts +5 -0
  160. package/dist/types/src/primitives/reports/regressor-report.d.ts +5 -0
  161. package/dist/types/src/primitives/types.d.ts +128 -0
  162. package/dist/types/src/primitives/utils.d.ts +3 -0
  163. package/dist/types/src/questionnaire/constants.d.ts +31 -0
  164. package/dist/types/src/questionnaire/defaults.d.ts +8 -0
  165. package/dist/types/src/questionnaire/engine/controller.d.ts +12 -0
  166. package/dist/types/src/questionnaire/engine/schema.d.ts +9 -0
  167. package/dist/types/src/questionnaire/errors.d.ts +3 -0
  168. package/dist/types/src/questionnaire/index.d.ts +6 -0
  169. package/dist/types/src/questionnaire/mount.d.ts +3 -0
  170. package/dist/types/src/questionnaire/primitives/components/questionnaire-root.d.ts +23 -0
  171. package/dist/types/src/questionnaire/primitives/components/step-indicator.d.ts +14 -0
  172. package/dist/types/src/questionnaire/primitives/register.d.ts +0 -0
  173. package/dist/types/src/questionnaire/types.d.ts +69 -0
  174. package/dist/types/src/shared/errors.d.ts +3 -0
  175. package/dist/types/src/shared/index.d.ts +1 -0
  176. package/dist/types/src/transport/capabilities.d.ts +7 -0
  177. package/dist/types/src/transport/clone.d.ts +6 -0
  178. package/dist/types/src/transport/composition/fallback.d.ts +2 -0
  179. package/dist/types/src/transport/composition/fanout.d.ts +3 -0
  180. package/dist/types/src/transport/composition/hedged.d.ts +2 -0
  181. package/dist/types/src/transport/composition/index.d.ts +7 -0
  182. package/dist/types/src/transport/composition/load-balancing.d.ts +2 -0
  183. package/dist/types/src/transport/composition/pipeline.d.ts +2 -0
  184. package/dist/types/src/transport/composition/racing.d.ts +2 -0
  185. package/dist/types/src/transport/composition/routing.d.ts +3 -0
  186. package/dist/types/src/transport/constants.d.ts +34 -0
  187. package/dist/types/src/transport/errors.d.ts +36 -0
  188. package/dist/types/src/transport/index.d.ts +9 -0
  189. package/dist/types/src/transport/internal.d.ts +110 -0
  190. package/dist/types/src/transport/middleware/auth.d.ts +2 -0
  191. package/dist/types/src/transport/middleware/cache.d.ts +2 -0
  192. package/dist/types/src/transport/middleware/circuit-breaker.d.ts +2 -0
  193. package/dist/types/src/transport/middleware/dedup.d.ts +2 -0
  194. package/dist/types/src/transport/middleware/index.d.ts +12 -0
  195. package/dist/types/src/transport/middleware/logging.d.ts +2 -0
  196. package/dist/types/src/transport/middleware/metrics.d.ts +2 -0
  197. package/dist/types/src/transport/middleware/pipe.d.ts +2 -0
  198. package/dist/types/src/transport/middleware/rate-limit.d.ts +2 -0
  199. package/dist/types/src/transport/middleware/retry.d.ts +2 -0
  200. package/dist/types/src/transport/middleware/timeout.d.ts +2 -0
  201. package/dist/types/src/transport/middleware/tracing.d.ts +2 -0
  202. package/dist/types/src/transport/middleware/transform.d.ts +3 -0
  203. package/dist/types/src/transport/policy-context.d.ts +3 -0
  204. package/dist/types/src/transport/protocols/graphql.d.ts +2 -0
  205. package/dist/types/src/transport/protocols/grpc.d.ts +5 -0
  206. package/dist/types/src/transport/protocols/index.d.ts +5 -0
  207. package/dist/types/src/transport/protocols/json.d.ts +2 -0
  208. package/dist/types/src/transport/protocols/sse.d.ts +2 -0
  209. package/dist/types/src/transport/protocols/websocket.d.ts +2 -0
  210. package/dist/types/src/transport/runtime.d.ts +4 -0
  211. package/dist/types/src/transport/state/cache-store.d.ts +2 -0
  212. package/dist/types/src/transport/state/circuit-breaker.d.ts +2 -0
  213. package/dist/types/src/transport/state/health.d.ts +2 -0
  214. package/dist/types/src/transport/state/index.d.ts +5 -0
  215. package/dist/types/src/transport/state/rate-limiter.d.ts +2 -0
  216. package/dist/types/src/transport/state/session.d.ts +2 -0
  217. package/dist/types/src/transport/types/capabilities.d.ts +35 -0
  218. package/dist/types/src/transport/types/core.d.ts +57 -0
  219. package/dist/types/src/transport/types/events.d.ts +50 -0
  220. package/dist/types/src/transport/types/index.d.ts +7 -0
  221. package/dist/types/src/transport/types/middleware.d.ts +3 -0
  222. package/dist/types/src/transport/types/options.d.ts +258 -0
  223. package/dist/types/src/transport/types/session.d.ts +48 -0
  224. package/dist/types/src/transport/types/state.d.ts +46 -0
  225. package/package.json +93 -37
  226. package/dist/FieldStrategy-pPekBtH-.js +0 -2318
  227. package/dist/ModelTypes-B9_veCKB.js +0 -5
  228. package/dist/ReportStrategy-DY3GC_mJ.js +0 -23
  229. package/dist/boolean-field-Cd3uhIPj.js +0 -104
  230. package/dist/category-field-D_Ms1x9u.js +0 -73
  231. package/dist/classifier-prediction-C5QzorTo.js +0 -193
  232. package/dist/custom-element-ttkHUa8w.js +0 -13
  233. package/dist/date-field-Cg_ja679.js +0 -162
  234. package/dist/error-card-BwjPChwf.js +0 -195
  235. package/dist/field-wrapper-DqIQl76d.js +0 -177
  236. package/dist/ml-layout-Dx63KKf7.js +0 -332
  237. package/dist/mlform/extensions.mjs +0 -38
  238. package/dist/mlform/strategies.mjs +0 -292
  239. package/dist/number-field-CC2DrVEb.js +0 -165
  240. package/dist/property-jKFNMQpR.js +0 -561
  241. package/dist/range-field-Cr7LEtsJ.js +0 -98
  242. package/dist/regressor-prediction-C18dHlfK.js +0 -236
  243. package/dist/src/core/app/DescriptorItem.d.ts +0 -6
  244. package/dist/src/core/app/DescriptorRegistry.d.ts +0 -13
  245. package/dist/src/core/app/DescriptorService.d.ts +0 -22
  246. package/dist/src/core/app/DescriptorStrategy.d.ts +0 -11
  247. package/dist/src/core/app/index.d.ts +0 -4
  248. package/dist/src/core/domain/index.d.ts +0 -24
  249. package/dist/src/core/index.d.ts +0 -3
  250. package/dist/src/core/ui/error-card.d.ts +0 -38
  251. package/dist/src/core/ui/field-wrapper.d.ts +0 -23
  252. package/dist/src/core/ui/index.d.ts +0 -3
  253. package/dist/src/core/ui/ml-layout.d.ts +0 -23
  254. package/dist/src/extensions/app/FieldStrategy.d.ts +0 -10
  255. package/dist/src/extensions/app/ReportStrategy.d.ts +0 -9
  256. package/dist/src/extensions/app/index.d.ts +0 -2
  257. package/dist/src/extensions/domain/BaseField.d.ts +0 -7
  258. package/dist/src/extensions/domain/BaseModel.d.ts +0 -6
  259. package/dist/src/extensions/domain/index.d.ts +0 -2
  260. package/dist/src/extensions/index.d.ts +0 -3
  261. package/dist/src/extensions/ui/field-element.d.ts +0 -9
  262. package/dist/src/extensions/ui/index.d.ts +0 -1
  263. package/dist/src/index.d.ts +0 -1
  264. package/dist/src/mlform/index.d.ts +0 -1
  265. package/dist/src/mlform/mlform.d.ts +0 -27
  266. package/dist/src/mlform/mlform.types.d.ts +0 -11
  267. package/dist/src/strategies/app/BooleanStrategy.d.ts +0 -12
  268. package/dist/src/strategies/app/CategoryStrategy.d.ts +0 -13
  269. package/dist/src/strategies/app/ClassifierStrategy.d.ts +0 -15
  270. package/dist/src/strategies/app/DateStrategy.d.ts +0 -15
  271. package/dist/src/strategies/app/NumberStrategy.d.ts +0 -29
  272. package/dist/src/strategies/app/RegressorStrategy.d.ts +0 -15
  273. package/dist/src/strategies/app/TextStrategy.d.ts +0 -16
  274. package/dist/src/strategies/app/index.d.ts +0 -7
  275. package/dist/src/strategies/domain/BooleanField.d.ts +0 -10
  276. package/dist/src/strategies/domain/CategoryField.d.ts +0 -11
  277. package/dist/src/strategies/domain/ClassifierModel.d.ts +0 -11
  278. package/dist/src/strategies/domain/DateField.d.ts +0 -13
  279. package/dist/src/strategies/domain/FieldTypes.d.ts +0 -7
  280. package/dist/src/strategies/domain/ModelTypes.d.ts +0 -4
  281. package/dist/src/strategies/domain/NumberField.d.ts +0 -15
  282. package/dist/src/strategies/domain/RegressorModel.d.ts +0 -11
  283. package/dist/src/strategies/domain/TextField.d.ts +0 -14
  284. package/dist/src/strategies/domain/index.d.ts +0 -9
  285. package/dist/src/strategies/index.d.ts +0 -1
  286. package/dist/src/strategies/ui/boolean-field.d.ts +0 -13
  287. package/dist/src/strategies/ui/category-field.d.ts +0 -14
  288. package/dist/src/strategies/ui/classifier-prediction.d.ts +0 -39
  289. package/dist/src/strategies/ui/date-field.d.ts +0 -18
  290. package/dist/src/strategies/ui/index.d.ts +0 -8
  291. package/dist/src/strategies/ui/number-field.d.ts +0 -19
  292. package/dist/src/strategies/ui/range-field.d.ts +0 -17
  293. package/dist/src/strategies/ui/regressor-prediction.d.ts +0 -29
  294. package/dist/src/strategies/ui/text-field.d.ts +0 -17
  295. package/dist/state-CLlTRyl1.js +0 -12
  296. package/dist/test/_fixtures/DummyField.d.ts +0 -9
  297. package/dist/test/setup.d.ts +0 -1
  298. package/dist/test/unit/DummyField.test.d.ts +0 -1
  299. package/dist/text-field-DwP-Fa1w.js +0 -114
package/README.md CHANGED
@@ -2,131 +2,284 @@
2
2
 
3
3
  [![CI Pipeline](https://github.com/UlloaSP/mlform/actions/workflows/ci.yml/badge.svg)](https://github.com/UlloaSP/mlform/actions/workflows/ci.yml)
4
4
  [![Release](https://github.com/UlloaSP/mlform/actions/workflows/release.yml/badge.svg)](https://github.com/UlloaSP/mlform/actions/workflows/release.yml)
5
+ [![npm version](https://img.shields.io/npm/v/mlform.svg)](https://www.npmjs.com/package/mlform)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
5
7
 
6
- Un framework para crear formularios dinámicos con capacidades de machine learning.
8
+ Schema-driven forms for machine learning applications.
7
9
 
8
- ## 🚀 Características
10
+ MLForm gives you a predictable UI layer between users and model backends. You describe inputs and reports with a schema, MLForm renders accessible Web Components, validates values, submits structured payloads, and displays model results in the same host container.
9
11
 
10
- - **Formularios dinámicos**: Genera formularios basados en esquemas JSON
11
- - **Integración ML**: Soporte para modelos de clasificación y regresión
12
- - **Web Components**: Componentes reutilizables basados en Lit
13
- - **TypeScript**: Totalmente tipado para mejor DX
14
- - **Validación**: Validación robusta con Zod
12
+ Version `0.1.4` is the current release in this repository.
15
13
 
16
- ## 📦 Instalación
14
+ ## Why MLForm
17
15
 
18
- ```bash
19
- npm install mlform
20
- ```
16
+ Most ML product forms drift over time:
21
17
 
22
- ## 🏗️ Desarrollo
18
+ - the frontend shape stops matching the backend contract
19
+ - validation rules end up duplicated across components
20
+ - model outputs are rendered ad hoc in each screen
21
+ - design and accessibility regress when teams move fast
23
22
 
24
- ### Requisitos previos
23
+ MLForm solves that by centering everything on an explicit schema and a transport layer.
25
24
 
26
- - Node.js >= 18
27
- - npm >= 9
25
+ Use it for:
28
26
 
29
- ### Configuración del entorno
27
+ - prediction forms
28
+ - scoring and approval tools
29
+ - forecasting dashboards
30
+ - internal review consoles
31
+ - embedded model workflows inside larger apps
30
32
 
31
- ```bash
32
- # Clonar el repositorio
33
- git clone https://github.com/UlloaSP/mlform.git
34
- cd mlform
33
+ ## Install
35
34
 
36
- # Instalar dependencias
37
- npm install
35
+ For application usage:
38
36
 
39
- # Ejecutar tests
40
- npm test
37
+ ```bash
38
+ npm install mlform
39
+ ```
41
40
 
42
- # Verificar código
43
- npm run lint
41
+ Import from the root package unless you specifically need a lower-level surface:
44
42
 
45
- # Formatear código
46
- npm run format
43
+ ```ts
44
+ import { createJsonTransport, mountForm } from "mlform";
45
+ ```
47
46
 
48
- # Verificar tipos
49
- npm run type
47
+ ## Quick Start
50
48
 
51
- # Construir proyecto
52
- npm run build
49
+ Create a host element:
53
50
 
54
- # Generar documentación
55
- npm run docs
51
+ ```html
52
+ <div id="prediction-form"></div>
56
53
  ```
57
54
 
58
- ### Scripts disponibles
55
+ Mount a form:
56
+
57
+ ```ts
58
+ import { createJsonTransport, mountForm } from "mlform";
59
+
60
+ const container = document.querySelector("#prediction-form");
61
+
62
+ if (!container) {
63
+ throw new Error("Missing #prediction-form container.");
64
+ }
65
+
66
+ const mounted = mountForm(container as HTMLElement, {
67
+ transport: createJsonTransport({ endpoint: "/api/predict" }),
68
+ schema: {
69
+ fields: [
70
+ {
71
+ id: "prompt",
72
+ kind: "text",
73
+ label: "Prompt",
74
+ required: true,
75
+ minLength: 3,
76
+ },
77
+ {
78
+ id: "threshold",
79
+ kind: "number",
80
+ label: "Confidence threshold",
81
+ min: 0,
82
+ max: 1,
83
+ step: 0.05,
84
+ defaultValue: 0.75,
85
+ },
86
+ ],
87
+ reports: [
88
+ {
89
+ id: "prediction",
90
+ kind: "classifier",
91
+ label: "Prediction",
92
+ },
93
+ ],
94
+ },
95
+ labels: {
96
+ submit: "Run prediction",
97
+ submitting: "Running...",
98
+ },
99
+ layout: "split",
100
+ designSystem: {
101
+ mode: "auto",
102
+ theme: "cobalt",
103
+ recipe: "soft",
104
+ },
105
+ });
106
+
107
+ window.addEventListener("beforeunload", () => mounted.unmount());
108
+ ```
59
109
 
60
- - `npm run lint` - Ejecuta ESLint
61
- - `npm run lint:fix` - Corrige automáticamente los errores de linting
62
- - `npm run format` - Formatea el código con Prettier
63
- - `npm run format:check` - Verifica el formato del código
64
- - `npm run type` - Verifica tipos con TypeScript
65
- - `npm run test` - Ejecuta tests con Vitest
66
- - `npm run test:watch` - Ejecuta tests en modo watch
67
- - `npm run coverage` - Genera reporte de cobertura
68
- - `npm run build` - Construye el proyecto para producción
69
- - `npm run docs` - Genera documentación con TypeDoc
70
- - `npm run ci` - Ejecuta todo el pipeline de CI localmente
110
+ The default JSON transport sends:
71
111
 
72
- ## 🔄 CI/CD Pipeline
112
+ ```json
113
+ {
114
+ "inputs": {
115
+ "prompt": "Example text",
116
+ "threshold": 0.75
117
+ }
118
+ }
119
+ ```
73
120
 
74
- El proyecto incluye un pipeline completo de CI/CD con GitHub Actions:
121
+ Return reports keyed by report id:
122
+
123
+ ```json
124
+ {
125
+ "reports": {
126
+ "prediction": {
127
+ "label": "Approved",
128
+ "confidence": 0.91,
129
+ "probabilities": {
130
+ "Approved": 0.91,
131
+ "Rejected": 0.09
132
+ }
133
+ }
134
+ },
135
+ "meta": {
136
+ "model": "credit-risk-v2"
137
+ }
138
+ }
139
+ ```
75
140
 
76
- ### Pipeline de CI (`.github/workflows/ci.yml`)
141
+ ## What You Get
142
+
143
+ - Schema-driven fields, reports, conditions, defaults, and serialization
144
+ - Accessible Web Components for form inputs, submit actions, and result rendering
145
+ - Built-in JSON transport plus composable transport middleware
146
+ - Headless engine APIs for custom orchestration and registries
147
+ - Runtime design system with themes, recipes, density, motion, and token overrides
148
+ - Extension points for custom field, report, and explanation kinds
149
+
150
+ Built-in fields:
151
+
152
+ - `text`
153
+ - `number`
154
+ - `boolean`
155
+ - `category`
156
+ - `date`
157
+ - `time-series`
158
+
159
+ Built-in reports:
160
+
161
+ - `classifier`
162
+ - `regressor`
163
+
164
+ Built-in themes:
165
+
166
+ - `neutral`
167
+ - `cobalt`
168
+ - `graphite`
169
+ - `sage`
170
+ - `sunset`
171
+
172
+ Built-in recipes:
173
+
174
+ - `default`
175
+ - `minimal`
176
+ - `soft`
177
+ - `contrast`
178
+
179
+ ## Package Surfaces
180
+
181
+ | Surface | Use it for |
182
+ | ---------------------- | ---------------------------------------------------------------------------------------- |
183
+ | `mlform` | Application-first API for mounting forms with sensible defaults. |
184
+ | `mlform/kit` | Explicit kit entrypoint with mount, transport, labels, and lifecycle utilities. |
185
+ | `mlform/engine` | Headless state, validation, registries, hooks, conditions, and submission orchestration. |
186
+ | `mlform/primitives` | Web Component renderers and custom renderer registries. |
187
+ | `mlform/design-system` | Themes, recipes, tokens, mode resolution, and host integration. |
188
+ | `mlform/transport` | Transport composition, middleware, resilience policies, and orchestration helpers. |
189
+
190
+ ## Custom Domain Kinds
191
+
192
+ When built-in kinds are not enough, define your own field and report kinds without rewriting the normal rendering path.
193
+
194
+ ```ts
195
+ import { createBuiltinRegistry, defineFieldKind } from "mlform/engine";
196
+ import { z } from "zod";
197
+
198
+ const registry = createBuiltinRegistry();
199
+
200
+ registry.registerField(
201
+ defineFieldKind({
202
+ kind: "score",
203
+ schema: z.object({
204
+ kind: z.literal("score"),
205
+ id: z.string().optional(),
206
+ label: z.string(),
207
+ min: z.number().default(0),
208
+ max: z.number().default(100),
209
+ }),
210
+ value: {
211
+ default: () => 0,
212
+ normalize: (value) => Number(value ?? 0),
213
+ serialize: (value) => value,
214
+ },
215
+ validate: ({ value, config }) =>
216
+ value < config.min || value > config.max ? ["Score out of range."] : [],
217
+ render: {
218
+ widget: "number",
219
+ hints: ({ config }) => ({
220
+ min: config.min,
221
+ max: config.max,
222
+ unit: "%",
223
+ }),
224
+ },
225
+ }),
226
+ );
227
+ ```
77
228
 
78
- Se ejecuta en cada push y pull request e incluye:
229
+ Stay at the declarative `define*Kind` layer unless you truly need fully custom rendering or low-level primitive behavior.
79
230
 
80
- 1. **🔍 Lint & Format** - Verificación de código con ESLint y Prettier
81
- 2. **📝 Type Check** - Verificación de tipos TypeScript
82
- 3. **🧪 Testing** - Tests unitarios en múltiples versiones de Node.js (18, 20, 22)
83
- 4. **🏗️ Build** - Construcción del proyecto
84
- 5. **📚 Documentation** - Generación de documentación (solo en main/docs)
85
- 6. **🔒 Security** - Auditoría de seguridad de dependencias
231
+ ## Typical Flow
86
232
 
87
- ### Pipeline de Release (`.github/workflows/release.yml`)
233
+ 1. Define the schema with `fields` and `reports`.
234
+ 2. Mount the form with `mountForm`.
235
+ 3. Point the transport at your model endpoint or custom backend adapter.
236
+ 4. Return normalized reports from the backend.
237
+ 5. Customize theme, recipe, labels, or registries only where your product needs it.
88
238
 
89
- Se ejecuta en tags de versión e incluye:
239
+ ## Documentation
90
240
 
91
- 1. **🚀 Release** - Creación de releases en GitHub
92
- 2. **📦 NPM Publish** - Publicación automática en NPM
241
+ - Docs home: https://ulloasp.github.io/mlform/
242
+ - Quick start: https://ulloasp.github.io/mlform/getting-started/quick-start/
243
+ - Installation: https://ulloasp.github.io/mlform/getting-started/installation/
244
+ - Backend contract: https://ulloasp.github.io/mlform/guides/backend-contract/
245
+ - Transport guide: https://ulloasp.github.io/mlform/kit/transport/
246
+ - Design system: https://ulloasp.github.io/mlform/design-system/overview/
247
+ - API reference: https://ulloasp.github.io/mlform/reference/kit/
248
+ - Migration guide: https://ulloasp.github.io/mlform/migration/from-legacy-mlform/
249
+ - Versioning notes: https://ulloasp.github.io/mlform/support/versioning/
93
250
 
94
- ### Configuración de Quality Gates
251
+ ## Development
95
252
 
96
- - **Cobertura de tests**: 80% mínimo
97
- - **Linting**: Sin errores
98
- - **Formato**: Código debe seguir las reglas de Prettier
99
- - **Tipos**: Sin errores de TypeScript
100
- - **Build**: Debe compilar sin errores
253
+ This repository uses Vite+. Do not use `npm`, `pnpm`, or `yarn` directly for workspace tasks in this repo.
101
254
 
102
- ## 📊 Reportes
255
+ Run the main package checks:
103
256
 
104
- - **Cobertura de tests**: Generada con Vitest y c8
105
- - **Bundle size**: Visualización con rollup-plugin-visualizer en `stats/`
106
- - **Documentación**: Disponible en `docs/` después de ejecutar `npm run docs`
257
+ ```bash
258
+ vp install
259
+ vp check
260
+ vp test
261
+ vp build
262
+ ```
107
263
 
108
- ## 🤝 Contribución
264
+ Docs live in `docs/`:
109
265
 
110
- 1. Fork el proyecto
111
- 2. Crea una rama para tu feature (`git checkout -b feature/AmazingFeature`)
112
- 3. Commit tus cambios (`git commit -m 'Add some AmazingFeature'`)
113
- 4. Push a la rama (`git push origin feature/AmazingFeature`)
114
- 5. Abre un Pull Request
266
+ ```bash
267
+ cd docs
268
+ vp install
269
+ vp run typecheck
270
+ vp run build
271
+ vp run dev
272
+ ```
115
273
 
116
- ### Guidelines de contribución
274
+ The main package targets Node.js `>=24.9.0`.
117
275
 
118
- - Sigue las reglas de ESLint y Prettier
119
- - Escribe tests para nuevas funcionalidades
120
- - Mantén la cobertura de tests >= 80%
121
- - Documenta el código con JSDoc
122
- - Usa Conventional Commits para mensajes de commit
276
+ ## Release Notes
123
277
 
124
- ## 📝 Licencia
278
+ For `0.1.4`, use the repository release entry and the published docs as the source of truth:
125
279
 
126
- Este proyecto está bajo la Licencia MIT. Ver el archivo `LICENSE` para más detalles.
280
+ - GitHub releases: https://github.com/UlloaSP/mlform/releases
281
+ - npm package: https://www.npmjs.com/package/mlform
127
282
 
128
- ## 🔗 Enlaces
283
+ ## License
129
284
 
130
- - [Documentación](https://ulloasp.github.io/mlform/)
131
- - [Issues](https://github.com/UlloaSP/mlform/issues)
132
- - [NPM Package](https://www.npmjs.com/package/mlform)
285
+ MIT