mlform 0.1.3 → 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.
- package/README.md +224 -152
- package/dist/design-system-CrrSGfFB.js +1352 -0
- package/dist/engine-nnhWPT2L.js +5301 -0
- package/dist/kit-Dt_1Fxlc.js +76 -0
- package/dist/mlform/design-system.mjs +2 -0
- package/dist/mlform/engine.mjs +3 -0
- package/dist/mlform/kit.mjs +3 -0
- package/dist/mlform/primitives.mjs +2 -0
- package/dist/mlform/questionnaire.mjs +640 -0
- package/dist/mlform/transport.mjs +2 -0
- package/dist/mlform.mjs +4 -717
- package/dist/primitives-Pi-ztAr6.js +5063 -0
- package/dist/transport-A1RsnZhD.js +2143 -0
- package/dist/types/src/design-system/constants.d.ts +34 -0
- package/dist/types/src/design-system/contract/component-keys.d.ts +2 -0
- package/dist/types/src/design-system/contract/component-tokens.d.ts +5 -0
- package/dist/types/src/design-system/contract/global-tokens.d.ts +7 -0
- package/dist/types/src/design-system/contract/index.d.ts +4 -0
- package/dist/types/src/design-system/contract/token-keys.d.ts +12 -0
- package/dist/types/src/design-system/index.d.ts +8 -0
- package/dist/types/src/design-system/recipes/contrast.d.ts +2 -0
- package/dist/types/src/design-system/recipes/default.d.ts +2 -0
- package/dist/types/src/design-system/recipes/index.d.ts +4 -0
- package/dist/types/src/design-system/recipes/minimal.d.ts +2 -0
- package/dist/types/src/design-system/recipes/soft.d.ts +2 -0
- package/dist/types/src/design-system/registry/builtins.d.ts +5 -0
- package/dist/types/src/design-system/registry/create-registry.d.ts +2 -0
- package/dist/types/src/design-system/registry/deep-freeze.d.ts +5 -0
- package/dist/types/src/design-system/registry/define-recipe.d.ts +2 -0
- package/dist/types/src/design-system/registry/define-theme.d.ts +2 -0
- package/dist/types/src/design-system/registry/define-token-maps.d.ts +6 -0
- package/dist/types/src/design-system/registry/index.d.ts +5 -0
- package/dist/types/src/design-system/resolve/diagnostics.d.ts +9 -0
- package/dist/types/src/design-system/resolve/index.d.ts +5 -0
- package/dist/types/src/design-system/resolve/merge-config.d.ts +2 -0
- package/dist/types/src/design-system/resolve/migrate-tokens.d.ts +44 -0
- package/dist/types/src/design-system/resolve/resolve-mode.d.ts +6 -0
- package/dist/types/src/design-system/resolve/resolve-recipe.d.ts +2 -0
- package/dist/types/src/design-system/resolve/resolve-theme.d.ts +2 -0
- package/dist/types/src/design-system/resolve/resolve-tokens.d.ts +2 -0
- package/dist/types/src/design-system/runtime/apply-tokens.d.ts +4 -0
- package/dist/types/src/design-system/runtime/attach-design-system.d.ts +11 -0
- package/dist/types/src/design-system/runtime/create-stylesheet.d.ts +11 -0
- package/dist/types/src/design-system/runtime/declarations.d.ts +5 -0
- package/dist/types/src/design-system/runtime/design-system-controller.d.ts +9 -0
- package/dist/types/src/design-system/runtime/host-state.d.ts +3 -0
- package/dist/types/src/design-system/runtime/hydrate-design-system.d.ts +25 -0
- package/dist/types/src/design-system/runtime/index.d.ts +8 -0
- package/dist/types/src/design-system/themes/cobalt.d.ts +2 -0
- package/dist/types/src/design-system/themes/graphite.d.ts +2 -0
- package/dist/types/src/design-system/themes/index.d.ts +5 -0
- package/dist/types/src/design-system/themes/neutral.d.ts +2 -0
- package/dist/types/src/design-system/themes/sage.d.ts +2 -0
- package/dist/types/src/design-system/themes/sunset.d.ts +2 -0
- package/dist/types/src/design-system/tokens/base.d.ts +5 -0
- package/dist/types/src/design-system/tokens/contrast.d.ts +8 -0
- package/dist/types/src/design-system/tokens/density.d.ts +9 -0
- package/dist/types/src/design-system/tokens/forced-colors.d.ts +12 -0
- package/dist/types/src/design-system/tokens/index.d.ts +5 -0
- package/dist/types/src/design-system/tokens/motion.d.ts +2 -0
- package/dist/types/src/design-system/types.d.ts +225 -0
- package/dist/types/src/engine/builtins/fields/boolean.d.ts +8 -0
- package/dist/types/src/engine/builtins/fields/category.d.ts +11 -0
- package/dist/types/src/engine/builtins/fields/date.d.ts +9 -0
- package/dist/types/src/engine/builtins/fields/long-text.d.ts +10 -0
- package/dist/types/src/engine/builtins/fields/multi-choice.d.ts +12 -0
- package/dist/types/src/engine/builtins/fields/number.d.ts +11 -0
- package/dist/types/src/engine/builtins/fields/rating.d.ts +9 -0
- package/dist/types/src/engine/builtins/fields/series.d.ts +20 -0
- package/dist/types/src/engine/builtins/fields/single-choice.d.ts +12 -0
- package/dist/types/src/engine/builtins/fields/text.d.ts +10 -0
- package/dist/types/src/engine/builtins/index.d.ts +97 -0
- package/dist/types/src/engine/builtins/reports/classifier.d.ts +8 -0
- package/dist/types/src/engine/builtins/reports/regressor.d.ts +8 -0
- package/dist/types/src/engine/builtins/shared.d.ts +49 -0
- package/dist/types/src/engine/comparison.d.ts +2 -0
- package/dist/types/src/engine/constants.d.ts +51 -0
- package/dist/types/src/engine/declarative/explanation.d.ts +2 -0
- package/dist/types/src/engine/declarative/field.d.ts +2 -0
- package/dist/types/src/engine/declarative/presentation.d.ts +61 -0
- package/dist/types/src/engine/declarative/report.d.ts +2 -0
- package/dist/types/src/engine/equality.d.ts +4 -0
- package/dist/types/src/engine/errors.d.ts +28 -0
- package/dist/types/src/engine/explanations/controller.d.ts +13 -0
- package/dist/types/src/engine/explanations/index.d.ts +1 -0
- package/dist/types/src/engine/fields/controller.d.ts +30 -0
- package/dist/types/src/engine/fields/index.d.ts +1 -0
- package/dist/types/src/engine/form.d.ts +2 -0
- package/dist/types/src/engine/index.d.ts +11 -0
- package/dist/types/src/engine/paths.d.ts +2 -0
- package/dist/types/src/engine/registry/index.d.ts +26 -0
- package/dist/types/src/engine/reports/controller.d.ts +19 -0
- package/dist/types/src/engine/reports/index.d.ts +1 -0
- package/dist/types/src/engine/schema/index.d.ts +7 -0
- package/dist/types/src/engine/state/engine.d.ts +60 -0
- package/dist/types/src/engine/state/index.d.ts +3 -0
- package/dist/types/src/engine/state/snapshots.d.ts +5 -0
- package/dist/types/src/engine/state/store.d.ts +13 -0
- package/dist/types/src/engine/submission/abort.d.ts +15 -0
- package/dist/types/src/engine/submission/explanations.d.ts +2 -0
- package/dist/types/src/engine/submission/index.d.ts +5 -0
- package/dist/types/src/engine/submission/lifecycle.d.ts +16 -0
- package/dist/types/src/engine/submission/pipeline.d.ts +2 -0
- package/dist/types/src/engine/submission/reports.d.ts +12 -0
- package/dist/types/src/engine/submission/request.d.ts +23 -0
- package/dist/types/src/engine/submission/result.d.ts +4 -0
- package/dist/types/src/engine/submission/submitter.d.ts +40 -0
- package/dist/types/src/engine/types/explanation.d.ts +109 -0
- package/dist/types/src/engine/types/field.d.ts +172 -0
- package/dist/types/src/engine/types/form.d.ts +120 -0
- package/dist/types/src/engine/types/index.d.ts +9 -0
- package/dist/types/src/engine/types/pipeline.d.ts +31 -0
- package/dist/types/src/engine/types/registry.d.ts +17 -0
- package/dist/types/src/engine/types/report.d.ts +87 -0
- package/dist/types/src/engine/types/transport.d.ts +41 -0
- package/dist/types/src/engine/utils.d.ts +9 -0
- package/dist/types/src/engine/validation/conditions.d.ts +11 -0
- package/dist/types/src/engine/validation/field.d.ts +29 -0
- package/dist/types/src/engine/validation/form.d.ts +35 -0
- package/dist/types/src/engine/validation/index.d.ts +3 -0
- package/dist/types/src/engine/values.d.ts +2 -0
- package/dist/types/src/index.d.ts +7 -0
- package/dist/types/src/kit/constants.d.ts +4 -0
- package/dist/types/src/kit/defaults.d.ts +11 -0
- package/dist/types/src/kit/index.d.ts +4 -0
- package/dist/types/src/kit/mount-form.d.ts +3 -0
- package/dist/types/src/kit/types.d.ts +52 -0
- package/dist/types/src/primitives/base-async-report-element.d.ts +19 -0
- package/dist/types/src/primitives/base-explanation-element.d.ts +21 -0
- package/dist/types/src/primitives/base-field-element.d.ts +21 -0
- package/dist/types/src/primitives/base-report-element.d.ts +15 -0
- package/dist/types/src/primitives/components/declarative-explanation.d.ts +5 -0
- package/dist/types/src/primitives/components/declarative-field.d.ts +6 -0
- package/dist/types/src/primitives/components/declarative-report.d.ts +5 -0
- package/dist/types/src/primitives/components/explanation-panel.d.ts +22 -0
- package/dist/types/src/primitives/components/field-frame.d.ts +21 -0
- package/dist/types/src/primitives/components/form-errors.d.ts +19 -0
- package/dist/types/src/primitives/components/form-root.d.ts +29 -0
- package/dist/types/src/primitives/components/presentation.d.ts +4 -0
- package/dist/types/src/primitives/components/report-frame.d.ts +22 -0
- package/dist/types/src/primitives/components/submit-button.d.ts +21 -0
- package/dist/types/src/primitives/components/unsupported-component.d.ts +14 -0
- package/dist/types/src/primitives/constants.d.ts +94 -0
- package/dist/types/src/primitives/controller-binding.d.ts +32 -0
- package/dist/types/src/primitives/fields/boolean-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/category-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/date-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/long-text-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/multi-choice-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/number-field.d.ts +8 -0
- package/dist/types/src/primitives/fields/rating-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/series-field.d.ts +8 -0
- package/dist/types/src/primitives/fields/single-choice-field.d.ts +6 -0
- package/dist/types/src/primitives/fields/text-field.d.ts +6 -0
- package/dist/types/src/primitives/index.d.ts +8 -0
- package/dist/types/src/primitives/mount-form.d.ts +4 -0
- package/dist/types/src/primitives/register.d.ts +0 -0
- package/dist/types/src/primitives/registry.d.ts +3 -0
- package/dist/types/src/primitives/reports/classifier-report.d.ts +5 -0
- package/dist/types/src/primitives/reports/regressor-report.d.ts +5 -0
- package/dist/types/src/primitives/types.d.ts +128 -0
- package/dist/types/src/primitives/utils.d.ts +3 -0
- package/dist/types/src/questionnaire/constants.d.ts +31 -0
- package/dist/types/src/questionnaire/defaults.d.ts +8 -0
- package/dist/types/src/questionnaire/engine/controller.d.ts +12 -0
- package/dist/types/src/questionnaire/engine/schema.d.ts +9 -0
- package/dist/types/src/questionnaire/errors.d.ts +3 -0
- package/dist/types/src/questionnaire/index.d.ts +6 -0
- package/dist/types/src/questionnaire/mount.d.ts +3 -0
- package/dist/types/src/questionnaire/primitives/components/questionnaire-root.d.ts +23 -0
- package/dist/types/src/questionnaire/primitives/components/step-indicator.d.ts +14 -0
- package/dist/types/src/questionnaire/primitives/register.d.ts +0 -0
- package/dist/types/src/questionnaire/types.d.ts +69 -0
- package/dist/types/src/shared/errors.d.ts +3 -0
- package/dist/types/src/shared/index.d.ts +1 -0
- package/dist/types/src/transport/capabilities.d.ts +7 -0
- package/dist/types/src/transport/clone.d.ts +6 -0
- package/dist/types/src/transport/composition/fallback.d.ts +2 -0
- package/dist/types/src/transport/composition/fanout.d.ts +3 -0
- package/dist/types/src/transport/composition/hedged.d.ts +2 -0
- package/dist/types/src/transport/composition/index.d.ts +7 -0
- package/dist/types/src/transport/composition/load-balancing.d.ts +2 -0
- package/dist/types/src/transport/composition/pipeline.d.ts +2 -0
- package/dist/types/src/transport/composition/racing.d.ts +2 -0
- package/dist/types/src/transport/composition/routing.d.ts +3 -0
- package/dist/types/src/transport/constants.d.ts +34 -0
- package/dist/types/src/transport/errors.d.ts +36 -0
- package/dist/types/src/transport/index.d.ts +9 -0
- package/dist/types/src/transport/internal.d.ts +110 -0
- package/dist/types/src/transport/middleware/auth.d.ts +2 -0
- package/dist/types/src/transport/middleware/cache.d.ts +2 -0
- package/dist/types/src/transport/middleware/circuit-breaker.d.ts +2 -0
- package/dist/types/src/transport/middleware/dedup.d.ts +2 -0
- package/dist/types/src/transport/middleware/index.d.ts +12 -0
- package/dist/types/src/transport/middleware/logging.d.ts +2 -0
- package/dist/types/src/transport/middleware/metrics.d.ts +2 -0
- package/dist/types/src/transport/middleware/pipe.d.ts +2 -0
- package/dist/types/src/transport/middleware/rate-limit.d.ts +2 -0
- package/dist/types/src/transport/middleware/retry.d.ts +2 -0
- package/dist/types/src/transport/middleware/timeout.d.ts +2 -0
- package/dist/types/src/transport/middleware/tracing.d.ts +2 -0
- package/dist/types/src/transport/middleware/transform.d.ts +3 -0
- package/dist/types/src/transport/policy-context.d.ts +3 -0
- package/dist/types/src/transport/protocols/graphql.d.ts +2 -0
- package/dist/types/src/transport/protocols/grpc.d.ts +5 -0
- package/dist/types/src/transport/protocols/index.d.ts +5 -0
- package/dist/types/src/transport/protocols/json.d.ts +2 -0
- package/dist/types/src/transport/protocols/sse.d.ts +2 -0
- package/dist/types/src/transport/protocols/websocket.d.ts +2 -0
- package/dist/types/src/transport/runtime.d.ts +4 -0
- package/dist/types/src/transport/state/cache-store.d.ts +2 -0
- package/dist/types/src/transport/state/circuit-breaker.d.ts +2 -0
- package/dist/types/src/transport/state/health.d.ts +2 -0
- package/dist/types/src/transport/state/index.d.ts +5 -0
- package/dist/types/src/transport/state/rate-limiter.d.ts +2 -0
- package/dist/types/src/transport/state/session.d.ts +2 -0
- package/dist/types/src/transport/types/capabilities.d.ts +35 -0
- package/dist/types/src/transport/types/core.d.ts +57 -0
- package/dist/types/src/transport/types/events.d.ts +50 -0
- package/dist/types/src/transport/types/index.d.ts +7 -0
- package/dist/types/src/transport/types/middleware.d.ts +3 -0
- package/dist/types/src/transport/types/options.d.ts +258 -0
- package/dist/types/src/transport/types/session.d.ts +48 -0
- package/dist/types/src/transport/types/state.d.ts +46 -0
- package/package.json +71 -59
- package/dist/FieldStrategy-CW2h8YyB.js +0 -2427
- package/dist/ModelTypes-B9_veCKB.js +0 -5
- package/dist/ReportStrategy-CxPzs4b2.js +0 -23
- package/dist/boolean-field-Dwz0ejWl.js +0 -104
- package/dist/category-field-DIgX--Px.js +0 -73
- package/dist/classifier-prediction-DgiEREf_.js +0 -193
- package/dist/custom-element-DFxkZ1wU.js +0 -8
- package/dist/date-field-91U2Xe46.js +0 -162
- package/dist/error-card-DHdkE18B.js +0 -195
- package/dist/field-wrapper-CBmpN5T_.js +0 -177
- package/dist/ml-layout-BJax9HVW.js +0 -332
- package/dist/mlform/extensions.mjs +0 -38
- package/dist/mlform/strategies.mjs +0 -292
- package/dist/number-field-Bcp45dJb.js +0 -164
- package/dist/property-B2UZ3Oii.js +0 -536
- package/dist/range-field-CD0kkCt0.js +0 -98
- package/dist/regressor-prediction-CPzZXlmA.js +0 -236
- package/dist/src/core/app/DescriptorItem.d.ts +0 -6
- package/dist/src/core/app/DescriptorRegistry.d.ts +0 -13
- package/dist/src/core/app/DescriptorService.d.ts +0 -22
- package/dist/src/core/app/DescriptorStrategy.d.ts +0 -11
- package/dist/src/core/app/index.d.ts +0 -4
- package/dist/src/core/domain/index.d.ts +0 -25
- package/dist/src/core/index.d.ts +0 -3
- package/dist/src/core/ui/error-card.d.ts +0 -38
- package/dist/src/core/ui/field-wrapper.d.ts +0 -23
- package/dist/src/core/ui/index.d.ts +0 -3
- package/dist/src/core/ui/ml-layout.d.ts +0 -23
- package/dist/src/extensions/app/FieldStrategy.d.ts +0 -10
- package/dist/src/extensions/app/ReportStrategy.d.ts +0 -9
- package/dist/src/extensions/app/index.d.ts +0 -2
- package/dist/src/extensions/domain/BaseField.d.ts +0 -7
- package/dist/src/extensions/domain/BaseModel.d.ts +0 -6
- package/dist/src/extensions/domain/index.d.ts +0 -2
- package/dist/src/extensions/index.d.ts +0 -3
- package/dist/src/extensions/ui/field-element.d.ts +0 -9
- package/dist/src/extensions/ui/index.d.ts +0 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/mlform/index.d.ts +0 -1
- package/dist/src/mlform/mlform.d.ts +0 -27
- package/dist/src/mlform/mlform.types.d.ts +0 -11
- package/dist/src/strategies/app/BooleanStrategy.d.ts +0 -12
- package/dist/src/strategies/app/CategoryStrategy.d.ts +0 -13
- package/dist/src/strategies/app/ClassifierStrategy.d.ts +0 -15
- package/dist/src/strategies/app/DateStrategy.d.ts +0 -15
- package/dist/src/strategies/app/NumberStrategy.d.ts +0 -29
- package/dist/src/strategies/app/RegressorStrategy.d.ts +0 -15
- package/dist/src/strategies/app/TextStrategy.d.ts +0 -16
- package/dist/src/strategies/app/index.d.ts +0 -7
- package/dist/src/strategies/domain/BooleanField.d.ts +0 -10
- package/dist/src/strategies/domain/CategoryField.d.ts +0 -11
- package/dist/src/strategies/domain/ClassifierModel.d.ts +0 -11
- package/dist/src/strategies/domain/DateField.d.ts +0 -13
- package/dist/src/strategies/domain/FieldTypes.d.ts +0 -7
- package/dist/src/strategies/domain/ModelTypes.d.ts +0 -4
- package/dist/src/strategies/domain/NumberField.d.ts +0 -15
- package/dist/src/strategies/domain/RegressorModel.d.ts +0 -11
- package/dist/src/strategies/domain/TextField.d.ts +0 -14
- package/dist/src/strategies/domain/index.d.ts +0 -9
- package/dist/src/strategies/index.d.ts +0 -1
- package/dist/src/strategies/ui/boolean-field.d.ts +0 -13
- package/dist/src/strategies/ui/category-field.d.ts +0 -14
- package/dist/src/strategies/ui/classifier-prediction.d.ts +0 -39
- package/dist/src/strategies/ui/date-field.d.ts +0 -18
- package/dist/src/strategies/ui/index.d.ts +0 -8
- package/dist/src/strategies/ui/number-field.d.ts +0 -19
- package/dist/src/strategies/ui/range-field.d.ts +0 -17
- package/dist/src/strategies/ui/regressor-prediction.d.ts +0 -29
- package/dist/src/strategies/ui/text-field.d.ts +0 -17
- package/dist/state-Ba1Gr1cr.js +0 -7
- package/dist/test/_fixtures/DummyField.d.ts +0 -9
- package/dist/test/integration/lifecycle.integration.test.d.ts +0 -1
- package/dist/test/integration/registration.integration.test.d.ts +0 -1
- package/dist/test/integration/state.integration.test.d.ts +0 -1
- package/dist/test/integration/validation.integration.test.d.ts +0 -1
- package/dist/test/setup.d.ts +0 -1
- package/dist/test/unit/DummyField.test.d.ts +0 -1
- package/dist/test/unit/Strategies.extensions.test.d.ts +0 -1
- package/dist/test/unit/Strategies.test.d.ts +0 -1
- package/dist/text-field-CSBBr4gN.js +0 -114
package/README.md
CHANGED
|
@@ -5,209 +5,281 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/mlform)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Schema-driven forms for machine learning applications.
|
|
9
9
|
|
|
10
|
-
|
|
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.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
- [Features](#features)
|
|
14
|
-
- [Installation](#installation)
|
|
15
|
-
- [Quick start](#quick-start)
|
|
16
|
-
- [Schema essentials](#schema-essentials)
|
|
17
|
-
- [Machine learning responses](#machine-learning-responses)
|
|
18
|
-
- [Extensibility](#extensibility)
|
|
19
|
-
- [Runtime utilities](#runtime-utilities)
|
|
20
|
-
- [Tooling & scripts](#tooling--scripts)
|
|
21
|
-
- [Documentation & resources](#documentation--resources)
|
|
22
|
-
- [Contributing](#contributing)
|
|
23
|
-
- [License](#license)
|
|
12
|
+
Version `0.1.4` is the current release in this repository.
|
|
24
13
|
|
|
25
|
-
##
|
|
14
|
+
## Why MLForm
|
|
26
15
|
|
|
27
|
-
|
|
16
|
+
Most ML product forms drift over time:
|
|
28
17
|
|
|
29
|
-
|
|
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
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
- Built-in integration with regression and classification endpoints via fetch
|
|
33
|
-
- Prepackaged strategies for text, number, boolean, category, and date inputs
|
|
34
|
-
- Subscription API (`onSubmit`) and accessors (`lastInputs`, `lastResponse`) for reactive UIs
|
|
35
|
-
- Lazy-loaded Web Components that stay framework-agnostic and usable in any SPA or vanilla app
|
|
36
|
-
- Zod-powered validation, JSON Schema generation, and type definitions out of the box
|
|
23
|
+
MLForm solves that by centering everything on an explicit schema and a transport layer.
|
|
37
24
|
|
|
38
|
-
|
|
25
|
+
Use it for:
|
|
39
26
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
- prediction forms
|
|
28
|
+
- scoring and approval tools
|
|
29
|
+
- forecasting dashboards
|
|
30
|
+
- internal review consoles
|
|
31
|
+
- embedded model workflows inside larger apps
|
|
43
32
|
|
|
44
|
-
|
|
33
|
+
## Install
|
|
45
34
|
|
|
46
|
-
|
|
35
|
+
For application usage:
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
```bash
|
|
38
|
+
npm install mlform
|
|
39
|
+
```
|
|
49
40
|
|
|
50
|
-
|
|
51
|
-
import { MLForm } from "mlform";
|
|
41
|
+
Import from the root package unless you specifically need a lower-level surface:
|
|
52
42
|
|
|
53
|
-
|
|
43
|
+
```ts
|
|
44
|
+
import { createJsonTransport, mountForm } from "mlform";
|
|
45
|
+
```
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
inputs: [
|
|
57
|
-
{ type: "text", title: "Full Name", required: true },
|
|
58
|
-
{ type: "number", title: "Age", min: 0, max: 120, required: true },
|
|
59
|
-
{
|
|
60
|
-
type: "category",
|
|
61
|
-
title: "Department",
|
|
62
|
-
options: ["Engineering", "Sales", "Marketing"],
|
|
63
|
-
required: true,
|
|
64
|
-
},
|
|
65
|
-
],
|
|
66
|
-
outputs: [{ type: "classifier", title: "Access Level" }],
|
|
67
|
-
};
|
|
47
|
+
## Quick Start
|
|
68
48
|
|
|
69
|
-
|
|
70
|
-
console.log("User inputs", inputs);
|
|
71
|
-
console.log("Prediction", response);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
const container = document.getElementById("form-container")!;
|
|
75
|
-
await mlForm.toHTMLElement(schema, container);
|
|
76
|
-
```
|
|
49
|
+
Create a host element:
|
|
77
50
|
|
|
78
51
|
```html
|
|
79
|
-
<div id="form
|
|
80
|
-
<script type="module" src="./main.ts"></script>
|
|
52
|
+
<div id="prediction-form"></div>
|
|
81
53
|
```
|
|
82
54
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
## Schema essentials
|
|
86
|
-
|
|
87
|
-
Schemas follow the `Signature` type exported from `mlform/core` (re-exported as `Signature` in the root package). Each entry is validated with Zod before rendering.
|
|
55
|
+
Mount a form:
|
|
88
56
|
|
|
89
|
-
|
|
57
|
+
```ts
|
|
58
|
+
import { createJsonTransport, mountForm } from "mlform";
|
|
90
59
|
|
|
91
|
-
|
|
92
|
-
| --- | --- | --- |
|
|
93
|
-
| `text` | Single-line text input | `minLength`, `maxLength`, `pattern`, `placeholder`, `value` |
|
|
94
|
-
| `number` | Numeric input with constraints | `min`, `max`, `step`, `value` |
|
|
95
|
-
| `boolean` | Checkbox or toggle | `required` |
|
|
96
|
-
| `category` | Select or radio options | `options`, `multiple` |
|
|
97
|
-
| `date` | Date picker | `min`, `max`, `format`, `value` |
|
|
60
|
+
const container = document.querySelector("#prediction-form");
|
|
98
61
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
| Type | Use case | Typical payload |
|
|
104
|
-
| --- | --- | --- |
|
|
105
|
-
| `classifier` | Discrete predictions | `prediction`, `confidence`, `probabilities`, `execution_time` |
|
|
106
|
-
| `regressor` | Continuous predictions | `prediction`, `confidence_interval`, `std_deviation`, `execution_time` |
|
|
62
|
+
if (!container) {
|
|
63
|
+
throw new Error("Missing #prediction-form container.");
|
|
64
|
+
}
|
|
107
65
|
|
|
108
|
-
|
|
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
|
+
});
|
|
109
106
|
|
|
110
|
-
|
|
107
|
+
window.addEventListener("beforeunload", () => mounted.unmount());
|
|
108
|
+
```
|
|
111
109
|
|
|
112
|
-
|
|
110
|
+
The default JSON transport sends:
|
|
113
111
|
|
|
114
112
|
```json
|
|
115
|
-
// Request payload
|
|
116
113
|
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
114
|
+
"inputs": {
|
|
115
|
+
"prompt": "Example text",
|
|
116
|
+
"threshold": 0.75
|
|
117
|
+
}
|
|
122
118
|
}
|
|
123
119
|
```
|
|
124
120
|
|
|
121
|
+
Return reports keyed by report id:
|
|
122
|
+
|
|
125
123
|
```json
|
|
126
|
-
// Expected response
|
|
127
124
|
{
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
+
}
|
|
141
138
|
}
|
|
142
139
|
```
|
|
143
140
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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
|
+
```
|
|
157
228
|
|
|
158
|
-
|
|
159
|
-
constructor() {
|
|
160
|
-
super("color", ColorSchema, () => import("./color-field"));
|
|
161
|
-
}
|
|
229
|
+
Stay at the declarative `define*Kind` layer unless you truly need fully custom rendering or low-level primitive behavior.
|
|
162
230
|
|
|
163
|
-
|
|
164
|
-
return {
|
|
165
|
-
tag: "color-field",
|
|
166
|
-
props: { value: field.value, label: field.title },
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
}
|
|
231
|
+
## Typical Flow
|
|
170
232
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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.
|
|
174
238
|
|
|
175
|
-
|
|
239
|
+
## Documentation
|
|
176
240
|
|
|
177
|
-
|
|
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/
|
|
178
250
|
|
|
179
|
-
|
|
180
|
-
- `mlForm.schema()` produces a JSON Schema (draft 2020-12) for your current registry configuration, enabling schema introspection or documentation workflows.
|
|
251
|
+
## Development
|
|
181
252
|
|
|
182
|
-
|
|
253
|
+
This repository uses Vite+. Do not use `npm`, `pnpm`, or `yarn` directly for workspace tasks in this repo.
|
|
183
254
|
|
|
184
|
-
|
|
255
|
+
Run the main package checks:
|
|
185
256
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
257
|
+
```bash
|
|
258
|
+
vp install
|
|
259
|
+
vp check
|
|
260
|
+
vp test
|
|
261
|
+
vp build
|
|
262
|
+
```
|
|
191
263
|
|
|
192
|
-
|
|
264
|
+
Docs live in `docs/`:
|
|
193
265
|
|
|
194
|
-
|
|
266
|
+
```bash
|
|
267
|
+
cd docs
|
|
268
|
+
vp install
|
|
269
|
+
vp run typecheck
|
|
270
|
+
vp run build
|
|
271
|
+
vp run dev
|
|
272
|
+
```
|
|
195
273
|
|
|
196
|
-
|
|
197
|
-
- Examples and guides: `docs/`
|
|
198
|
-
- Bundle visualizations: `stats/bundle_size_treemap.html`
|
|
199
|
-
- Issue tracker: https://github.com/UlloaSP/mlform/issues
|
|
274
|
+
The main package targets Node.js `>=24.9.0`.
|
|
200
275
|
|
|
201
|
-
##
|
|
276
|
+
## Release Notes
|
|
202
277
|
|
|
203
|
-
|
|
278
|
+
For `0.1.4`, use the repository release entry and the published docs as the source of truth:
|
|
204
279
|
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
3. Add or update tests and documentation alongside code changes (target 80%+ coverage).
|
|
208
|
-
4. Use Conventional Commit messages when possible.
|
|
209
|
-
5. Open a pull request describing your change and expected impact.
|
|
280
|
+
- GitHub releases: https://github.com/UlloaSP/mlform/releases
|
|
281
|
+
- npm package: https://www.npmjs.com/package/mlform
|
|
210
282
|
|
|
211
283
|
## License
|
|
212
284
|
|
|
213
|
-
|
|
285
|
+
MIT
|