mlform 0.1.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.
- package/LICENSE +21 -0
- package/README.md +132 -0
- package/dist/FieldStrategy-pPekBtH-.js +2318 -0
- package/dist/ModelTypes-B9_veCKB.js +5 -0
- package/dist/ReportStrategy-DY3GC_mJ.js +23 -0
- package/dist/boolean-field-Cd3uhIPj.js +104 -0
- package/dist/category-field-D_Ms1x9u.js +73 -0
- package/dist/classifier-prediction-C5QzorTo.js +193 -0
- package/dist/custom-element-ttkHUa8w.js +13 -0
- package/dist/date-field-Cg_ja679.js +162 -0
- package/dist/error-card-BwjPChwf.js +195 -0
- package/dist/field-wrapper-DqIQl76d.js +177 -0
- package/dist/ml-layout-Dx63KKf7.js +332 -0
- package/dist/mlform/extensions.mjs +38 -0
- package/dist/mlform/strategies.mjs +292 -0
- package/dist/mlform.mjs +709 -0
- package/dist/number-field-CC2DrVEb.js +165 -0
- package/dist/property-jKFNMQpR.js +561 -0
- package/dist/range-field-Cr7LEtsJ.js +98 -0
- package/dist/regressor-prediction-C18dHlfK.js +236 -0
- package/dist/src/core/app/DescriptorItem.d.ts +6 -0
- package/dist/src/core/app/DescriptorRegistry.d.ts +13 -0
- package/dist/src/core/app/DescriptorService.d.ts +22 -0
- package/dist/src/core/app/DescriptorStrategy.d.ts +11 -0
- package/dist/src/core/app/index.d.ts +4 -0
- package/dist/src/core/domain/index.d.ts +24 -0
- package/dist/src/core/index.d.ts +3 -0
- package/dist/src/core/ui/error-card.d.ts +38 -0
- package/dist/src/core/ui/field-wrapper.d.ts +23 -0
- package/dist/src/core/ui/index.d.ts +3 -0
- package/dist/src/core/ui/ml-layout.d.ts +23 -0
- package/dist/src/extensions/app/FieldStrategy.d.ts +10 -0
- package/dist/src/extensions/app/ReportStrategy.d.ts +9 -0
- package/dist/src/extensions/app/index.d.ts +2 -0
- package/dist/src/extensions/domain/BaseField.d.ts +7 -0
- package/dist/src/extensions/domain/BaseModel.d.ts +6 -0
- package/dist/src/extensions/domain/index.d.ts +2 -0
- package/dist/src/extensions/index.d.ts +3 -0
- package/dist/src/extensions/ui/field-element.d.ts +9 -0
- package/dist/src/extensions/ui/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/mlform/index.d.ts +1 -0
- package/dist/src/mlform/mlform.d.ts +27 -0
- package/dist/src/mlform/mlform.types.d.ts +11 -0
- package/dist/src/strategies/app/BooleanStrategy.d.ts +12 -0
- package/dist/src/strategies/app/CategoryStrategy.d.ts +13 -0
- package/dist/src/strategies/app/ClassifierStrategy.d.ts +15 -0
- package/dist/src/strategies/app/DateStrategy.d.ts +15 -0
- package/dist/src/strategies/app/NumberStrategy.d.ts +29 -0
- package/dist/src/strategies/app/RegressorStrategy.d.ts +15 -0
- package/dist/src/strategies/app/TextStrategy.d.ts +16 -0
- package/dist/src/strategies/app/index.d.ts +7 -0
- package/dist/src/strategies/domain/BooleanField.d.ts +10 -0
- package/dist/src/strategies/domain/CategoryField.d.ts +11 -0
- package/dist/src/strategies/domain/ClassifierModel.d.ts +11 -0
- package/dist/src/strategies/domain/DateField.d.ts +13 -0
- package/dist/src/strategies/domain/FieldTypes.d.ts +7 -0
- package/dist/src/strategies/domain/ModelTypes.d.ts +4 -0
- package/dist/src/strategies/domain/NumberField.d.ts +15 -0
- package/dist/src/strategies/domain/RegressorModel.d.ts +11 -0
- package/dist/src/strategies/domain/TextField.d.ts +14 -0
- package/dist/src/strategies/domain/index.d.ts +9 -0
- package/dist/src/strategies/index.d.ts +1 -0
- package/dist/src/strategies/ui/boolean-field.d.ts +13 -0
- package/dist/src/strategies/ui/category-field.d.ts +14 -0
- package/dist/src/strategies/ui/classifier-prediction.d.ts +39 -0
- package/dist/src/strategies/ui/date-field.d.ts +18 -0
- package/dist/src/strategies/ui/index.d.ts +8 -0
- package/dist/src/strategies/ui/number-field.d.ts +19 -0
- package/dist/src/strategies/ui/range-field.d.ts +17 -0
- package/dist/src/strategies/ui/regressor-prediction.d.ts +29 -0
- package/dist/src/strategies/ui/text-field.d.ts +17 -0
- package/dist/state-CLlTRyl1.js +12 -0
- package/dist/test/_fixtures/DummyField.d.ts +9 -0
- package/dist/test/setup.d.ts +1 -0
- package/dist/test/unit/DummyField.test.d.ts +1 -0
- package/dist/text-field-DwP-Fa1w.js +114 -0
- package/package.json +57 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { i as m, x as l, a as v, n as c } from "./property-jKFNMQpR.js";
|
|
2
|
+
import { t as h } from "./custom-element-ttkHUa8w.js";
|
|
3
|
+
var p = Object.defineProperty, u = Object.getOwnPropertyDescriptor, x = (t, i, e) => i in t ? p(t, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[i] = e, o = (t, i, e, r) => {
|
|
4
|
+
for (var a = r > 1 ? void 0 : r ? u(i, e) : i, n = t.length - 1, d; n >= 0; n--)
|
|
5
|
+
(d = t[n]) && (a = (r ? d(i, e, a) : d(a)) || a);
|
|
6
|
+
return r && a && p(i, e, a), a;
|
|
7
|
+
}, b = (t, i, e) => x(t, i + "", e);
|
|
8
|
+
let s = class extends m {
|
|
9
|
+
title = "";
|
|
10
|
+
values = [];
|
|
11
|
+
unit = "";
|
|
12
|
+
firstUpdated() {
|
|
13
|
+
if (this.interval !== void 0)
|
|
14
|
+
this.min = this.interval[0], this.max = this.interval[1];
|
|
15
|
+
else {
|
|
16
|
+
this.values = this.values.map((e) => Number(e));
|
|
17
|
+
const t = this.values.reduce((e, r) => e + r, 0) / this.values.length, i = this.values.reduce((e, r) => e + r, 0);
|
|
18
|
+
this.min = t - i, this.max = t + i;
|
|
19
|
+
}
|
|
20
|
+
this.requestUpdate();
|
|
21
|
+
}
|
|
22
|
+
/* —— Utilidades —— */
|
|
23
|
+
_barExtents() {
|
|
24
|
+
const t = this.max - this.min;
|
|
25
|
+
return [this.min - t, this.max + t];
|
|
26
|
+
}
|
|
27
|
+
/* —— Utilidades —— */
|
|
28
|
+
_hasInterval() {
|
|
29
|
+
return this.interval !== void 0 && this.min !== void 0 && this.max !== void 0;
|
|
30
|
+
}
|
|
31
|
+
_calcPercent(t) {
|
|
32
|
+
const [i, e] = this._barExtents();
|
|
33
|
+
return (t - i) / (e - i) * 100;
|
|
34
|
+
}
|
|
35
|
+
/** Gradiente lineal continuo: rojo → naranja → amarillo → verde → amarillo → naranja → rojo */
|
|
36
|
+
_buildGradient() {
|
|
37
|
+
const t = this._calcPercent(this.min), i = this._calcPercent(this.max), e = this._calcPercent((this.min + this.max) / 2), r = 10, a = Math.max(t - r, 0), n = Math.min(i + r, 100);
|
|
38
|
+
return `linear-gradient(to right,
|
|
39
|
+
#c62828 0%,
|
|
40
|
+
#ff6d00 ${a}%,
|
|
41
|
+
#ffea00 ${t}%,
|
|
42
|
+
#00c853 ${e}%,
|
|
43
|
+
#ffea00 ${i}%,
|
|
44
|
+
#ff6d00 ${n}%,
|
|
45
|
+
#c62828 100%)`;
|
|
46
|
+
}
|
|
47
|
+
/* —— Render —— */
|
|
48
|
+
render() {
|
|
49
|
+
return this._hasInterval() ? l`
|
|
50
|
+
<div class="prediction-card">
|
|
51
|
+
${this.title ? l`<div class="title">${this.title}</div>` : null}
|
|
52
|
+
${this.values.map(
|
|
53
|
+
(t) => l`
|
|
54
|
+
<div class="item">
|
|
55
|
+
<div class="value">${t} ${this.unit}</div>
|
|
56
|
+
|
|
57
|
+
<div
|
|
58
|
+
class="bar-wrapper"
|
|
59
|
+
style="background: ${this._buildGradient()};"
|
|
60
|
+
>
|
|
61
|
+
<!-- Límite inferior -->
|
|
62
|
+
<div
|
|
63
|
+
class="limit-wrapper"
|
|
64
|
+
style="left: ${this._calcPercent(this.min)}%; top: -12px;"
|
|
65
|
+
>
|
|
66
|
+
<div class="limit-line"></div>
|
|
67
|
+
<div class="limit-label">${this.min} ${this.unit}</div>
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<!-- Límite superior -->
|
|
71
|
+
<div
|
|
72
|
+
class="limit-wrapper"
|
|
73
|
+
style="left: ${this._calcPercent(this.max)}%; top: -12px;"
|
|
74
|
+
>
|
|
75
|
+
<div class="limit-line"></div>
|
|
76
|
+
<div class="limit-label">${this.max} ${this.unit}</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<!-- Valor actual -->
|
|
80
|
+
<span
|
|
81
|
+
class="value-marker"
|
|
82
|
+
style="left: ${Math.min(
|
|
83
|
+
Math.max(this._calcPercent(t), 0),
|
|
84
|
+
98.45
|
|
85
|
+
)}%;
|
|
86
|
+
top: 10%;"
|
|
87
|
+
></span>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
`
|
|
91
|
+
)}
|
|
92
|
+
</div>
|
|
93
|
+
` : l`<div class="prediction-card">
|
|
94
|
+
${this.title ? l`<div class="title">${this.title}</div>` : null}
|
|
95
|
+
${this.values.map(
|
|
96
|
+
(t) => l`
|
|
97
|
+
<div class="item">
|
|
98
|
+
<div class="value">${t} ${this.unit}</div>
|
|
99
|
+
</div>
|
|
100
|
+
</div>
|
|
101
|
+
`
|
|
102
|
+
)}
|
|
103
|
+
</div>`;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
b(s, "styles", v`
|
|
107
|
+
:host {
|
|
108
|
+
--marker-width: 4px; /* valor actual */
|
|
109
|
+
--limit-line-width: 3px; /* nuevo: marcador de límite */
|
|
110
|
+
--limit-line-height: 28px; /* sobresale 6px por arriba y por abajo (barra = 16px) */
|
|
111
|
+
|
|
112
|
+
display: block;
|
|
113
|
+
margin: 10px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.prediction-card {
|
|
117
|
+
padding: 25px;
|
|
118
|
+
border: 1px solid var(--ml-color-border);
|
|
119
|
+
border-radius: var(--radius);
|
|
120
|
+
box-shadow: 0 4px 12px var(--ml-color-shadow);
|
|
121
|
+
background: var(--ml-color-surface);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.title {
|
|
125
|
+
font-size: 1rem;
|
|
126
|
+
font-weight: 600;
|
|
127
|
+
text-transform: uppercase;
|
|
128
|
+
color: var(--ml-color-secondary);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.value {
|
|
132
|
+
display: flex;
|
|
133
|
+
justify-content: flex-end;
|
|
134
|
+
font-size: 1rem;
|
|
135
|
+
font-weight: 700;
|
|
136
|
+
color: var(--ml-color-primary);
|
|
137
|
+
margin-bottom: 5px;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.item {
|
|
141
|
+
margin-top: 15px;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.bar-wrapper {
|
|
145
|
+
position: relative;
|
|
146
|
+
height: 16px;
|
|
147
|
+
border-radius: 5px;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/* —— Marcador de la medida —— */
|
|
151
|
+
.value-marker {
|
|
152
|
+
position: absolute;
|
|
153
|
+
height: 14px;
|
|
154
|
+
width: 14px;
|
|
155
|
+
border-radius: 50%;
|
|
156
|
+
background: radial-gradient(circle, var(--ml-color-accent), var(--ml-color-accent-h));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* —— Wrapper del límite: línea + etiqueta —— */
|
|
160
|
+
.limit-wrapper {
|
|
161
|
+
position: absolute;
|
|
162
|
+
top: calc(
|
|
163
|
+
-1 * (var(--limit-line-height) - 16px) / 2
|
|
164
|
+
); /* centra la línea respecto a la barra y hace que sobresalga */
|
|
165
|
+
transform: translateX(-50%);
|
|
166
|
+
display: flex;
|
|
167
|
+
flex-direction: column;
|
|
168
|
+
align-items: center;
|
|
169
|
+
pointer-events: none;
|
|
170
|
+
z-index: 2;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.limit-line {
|
|
174
|
+
width: var(--limit-line-width);
|
|
175
|
+
height: var(--limit-line-height);
|
|
176
|
+
background: var(--ml-color-primary);
|
|
177
|
+
opacity: 0.6;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.limit-label {
|
|
181
|
+
font-size: 0.75rem;
|
|
182
|
+
color: var(--ml-color-secondary);
|
|
183
|
+
margin-top: 4px;
|
|
184
|
+
white-space: nowrap;
|
|
185
|
+
}
|
|
186
|
+
`);
|
|
187
|
+
o([
|
|
188
|
+
c({ type: String })
|
|
189
|
+
], s.prototype, "title", 2);
|
|
190
|
+
o([
|
|
191
|
+
c({
|
|
192
|
+
type: Array,
|
|
193
|
+
attribute: "values",
|
|
194
|
+
converter: {
|
|
195
|
+
fromAttribute: (t) => {
|
|
196
|
+
if (!t) return [];
|
|
197
|
+
try {
|
|
198
|
+
const i = JSON.parse(t);
|
|
199
|
+
return Array.isArray(i) ? i.map(Number) : [i];
|
|
200
|
+
} catch {
|
|
201
|
+
return t.split(/[,;]/).map((i) => Number(i.trim()));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
})
|
|
206
|
+
], s.prototype, "values", 2);
|
|
207
|
+
o([
|
|
208
|
+
c({ type: String })
|
|
209
|
+
], s.prototype, "unit", 2);
|
|
210
|
+
o([
|
|
211
|
+
c({
|
|
212
|
+
type: Object,
|
|
213
|
+
attribute: "interval",
|
|
214
|
+
converter: {
|
|
215
|
+
fromAttribute: (t) => {
|
|
216
|
+
if (t) {
|
|
217
|
+
try {
|
|
218
|
+
const e = JSON.parse(t);
|
|
219
|
+
if (Array.isArray(e) && e.length === 2 && e.every((r) => typeof r == "number"))
|
|
220
|
+
return e;
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
const i = t.split(/[,;]/).map((e) => Number(e.trim()));
|
|
224
|
+
return [i[0], i[1]];
|
|
225
|
+
} else
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
})
|
|
230
|
+
], s.prototype, "interval", 2);
|
|
231
|
+
s = o([
|
|
232
|
+
h("regressor-prediction")
|
|
233
|
+
], s);
|
|
234
|
+
export {
|
|
235
|
+
s as RegressorPrediction
|
|
236
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Schema } from '../domain';
|
|
2
|
+
import { DescriptorStrategy } from './DescriptorStrategy';
|
|
3
|
+
export declare class DescriptorRegistry {
|
|
4
|
+
private readonly catalog;
|
|
5
|
+
private combinedSchema;
|
|
6
|
+
get schema(): Schema;
|
|
7
|
+
get(type: string): DescriptorStrategy | undefined;
|
|
8
|
+
values(): IterableIterator<DescriptorStrategy>;
|
|
9
|
+
register(item: DescriptorStrategy): void;
|
|
10
|
+
unregister(type: string): void;
|
|
11
|
+
update(item: DescriptorStrategy): void;
|
|
12
|
+
private rebuildSchema;
|
|
13
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Base, Output } from '../domain';
|
|
2
|
+
import { DescriptorItem } from './DescriptorItem';
|
|
3
|
+
import { DescriptorRegistry } from './DescriptorRegistry';
|
|
4
|
+
export declare class DescriptorService {
|
|
5
|
+
protected readonly registry: DescriptorRegistry;
|
|
6
|
+
protected backendUrl: string;
|
|
7
|
+
private readonly loadedTypes;
|
|
8
|
+
protected temporalOutputs: unknown;
|
|
9
|
+
constructor(backendUrl?: string);
|
|
10
|
+
get reg(): DescriptorRegistry;
|
|
11
|
+
set tmpOutputs(value: unknown);
|
|
12
|
+
mount(data: Base, host: HTMLElement): Promise<void>;
|
|
13
|
+
protected ensureComponents(data: Base): Promise<void>;
|
|
14
|
+
protected renderDescriptors(data: Base): DescriptorItem[];
|
|
15
|
+
protected descriptorsToInnerHtml(list: DescriptorItem[]): string;
|
|
16
|
+
protected reportDescriptorsToInnerHtml(descriptors: DescriptorItem[]): string;
|
|
17
|
+
render(data: Output): Promise<void>;
|
|
18
|
+
submit(data: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
19
|
+
private renderDescriptor;
|
|
20
|
+
/** Serializa el objeto `props` a atributos HTML. */
|
|
21
|
+
private propsToAttrs;
|
|
22
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Infer, Schema } from '../domain';
|
|
2
|
+
import { DescriptorItem } from './DescriptorItem';
|
|
3
|
+
export declare abstract class DescriptorStrategy<S extends Schema = Schema> {
|
|
4
|
+
readonly type: string;
|
|
5
|
+
readonly schema: S;
|
|
6
|
+
readonly loader: () => Promise<unknown>;
|
|
7
|
+
constructor(type: string, schema: S, loader: () => Promise<unknown>);
|
|
8
|
+
abstract buildDescriptor(payload: Record<string, unknown>): DescriptorItem;
|
|
9
|
+
validate(data: S): boolean;
|
|
10
|
+
parse(data: S): Infer<S>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ZodType, array as zArray, infer as zInfer, union as zUnion } from 'zod';
|
|
2
|
+
import { FieldTypes, ModelTypes } from '../../strategies/domain';
|
|
3
|
+
export declare const array: typeof zArray;
|
|
4
|
+
export declare const union: typeof zUnion;
|
|
5
|
+
export type Schema = ZodType;
|
|
6
|
+
export type Infer<T extends ZodType> = zInfer<T>;
|
|
7
|
+
declare const BaseSchema: import('zod').ZodArray<import('zod').ZodObject<{
|
|
8
|
+
type: import('zod').ZodUnion<import('zod').ZodLiteral<FieldTypes>[]>;
|
|
9
|
+
}, import('zod/v4/core').$loose>>;
|
|
10
|
+
declare const OutputSchema: import('zod').ZodObject<{
|
|
11
|
+
type: import('zod').ZodUnion<import('zod').ZodLiteral<ModelTypes>[]>;
|
|
12
|
+
}, import('zod/v4/core').$loose>;
|
|
13
|
+
declare const Signature: import('zod').ZodObject<{
|
|
14
|
+
inputs: import('zod').ZodArray<import('zod').ZodObject<{
|
|
15
|
+
type: import('zod').ZodUnion<import('zod').ZodLiteral<FieldTypes>[]>;
|
|
16
|
+
}, import('zod/v4/core').$loose>>;
|
|
17
|
+
outputs: import('zod').ZodArray<import('zod').ZodObject<{
|
|
18
|
+
type: import('zod').ZodUnion<import('zod').ZodLiteral<FieldTypes>[]>;
|
|
19
|
+
}, import('zod/v4/core').$loose>>;
|
|
20
|
+
}, import('zod/v4/core').$strict>;
|
|
21
|
+
export type Base = Infer<typeof BaseSchema>;
|
|
22
|
+
export type Output = Infer<typeof OutputSchema>;
|
|
23
|
+
export type Signature = Infer<typeof Signature>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class ApiError extends Error {
|
|
3
|
+
statusCode?: number;
|
|
4
|
+
code?: string;
|
|
5
|
+
details?: string[];
|
|
6
|
+
constructor(message: string, options?: {
|
|
7
|
+
statusCode?: number;
|
|
8
|
+
code?: string;
|
|
9
|
+
details?: string[];
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
interface ErrorConfig {
|
|
13
|
+
icon: string;
|
|
14
|
+
title: string;
|
|
15
|
+
description: string;
|
|
16
|
+
details?: (error: unknown) => string[];
|
|
17
|
+
}
|
|
18
|
+
export declare class ErrorCard extends LitElement {
|
|
19
|
+
static styles: import('lit').CSSResult;
|
|
20
|
+
error: Error | null;
|
|
21
|
+
retry?: () => void;
|
|
22
|
+
private static _errorMap;
|
|
23
|
+
/**
|
|
24
|
+
* Registers custom error configurations.
|
|
25
|
+
* @param map A record where keys are error identifiers and values are ErrorConfig objects.
|
|
26
|
+
*/
|
|
27
|
+
static register(map: Record<string, ErrorConfig>): void;
|
|
28
|
+
private static defaultErrorConfigs;
|
|
29
|
+
constructor();
|
|
30
|
+
private _getErrorConfig;
|
|
31
|
+
render(): import('lit-html').TemplateResult<1> | null;
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
"error-card": ErrorCard;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
export declare class FieldWrapper extends LitElement {
|
|
3
|
+
static styles: import('lit').CSSResult;
|
|
4
|
+
title: string;
|
|
5
|
+
description: string;
|
|
6
|
+
private descriptionVisible;
|
|
7
|
+
private stateClass;
|
|
8
|
+
feedback: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
name: string;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
firstUpdated(): void;
|
|
14
|
+
private toggleDescription;
|
|
15
|
+
private onFieldState;
|
|
16
|
+
private dispatchState;
|
|
17
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
"field-wrapper": FieldWrapper;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { DescriptorService } from '../app';
|
|
3
|
+
export declare class MLLayout extends LitElement {
|
|
4
|
+
static styles: import('lit').CSSResult;
|
|
5
|
+
private inputs;
|
|
6
|
+
modelService: DescriptorService;
|
|
7
|
+
private label;
|
|
8
|
+
private _mo?;
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
private _onWrapperChange;
|
|
12
|
+
private get _disableButton();
|
|
13
|
+
private _onSubmit;
|
|
14
|
+
private _clearSlot;
|
|
15
|
+
private _showError;
|
|
16
|
+
private _hideError;
|
|
17
|
+
render(): import('lit-html').TemplateResult<1>;
|
|
18
|
+
}
|
|
19
|
+
declare global {
|
|
20
|
+
interface HTMLElementTagNameMap {
|
|
21
|
+
"ml-layout": MLLayout;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DescriptorItem, DescriptorStrategy } from '../../core/app';
|
|
2
|
+
import { Infer, Schema } from '../../core/domain';
|
|
3
|
+
export declare abstract class FieldStrategy<S extends Schema = Schema> extends DescriptorStrategy<S> {
|
|
4
|
+
private static readonly FIELD_SLOT;
|
|
5
|
+
protected abstract buildControl(field: Infer<S>): {
|
|
6
|
+
tag: string;
|
|
7
|
+
props: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
buildDescriptor(field: Infer<S>): DescriptorItem;
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DescriptorItem, DescriptorStrategy } from '../../core/app';
|
|
2
|
+
import { Infer, Schema } from '../../core/domain';
|
|
3
|
+
export declare abstract class ReportStrategy<S extends Schema = Schema> extends DescriptorStrategy<S> {
|
|
4
|
+
protected abstract buildControl(field: Infer<S>): {
|
|
5
|
+
tag: string;
|
|
6
|
+
props: Record<string, unknown>;
|
|
7
|
+
};
|
|
8
|
+
buildDescriptor(field: Infer<S>): DescriptorItem;
|
|
9
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CSSResultGroup, LitElement, TemplateResult } from 'lit';
|
|
2
|
+
export type FieldState = "empty" | "success" | "error";
|
|
3
|
+
export declare abstract class FieldElement<V = unknown> extends LitElement {
|
|
4
|
+
protected static baseStyles: CSSResultGroup;
|
|
5
|
+
protected value: V;
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
protected dispatchState(state: FieldState, message?: string): void;
|
|
8
|
+
abstract render(): TemplateResult;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FieldElement } from './field-element';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MLForm } from './mlform';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { MLForm } from './mlform';
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Signature } from '../core';
|
|
2
|
+
import { Output } from '../core/domain';
|
|
3
|
+
import { FieldStrategy, ReportStrategy } from '../extensions/app';
|
|
4
|
+
import { IMLForm } from './mlform.types';
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
type SubmitCallback = (inputs: Record<string, unknown>, response: Output) => void;
|
|
7
|
+
export declare class MLForm implements IMLForm {
|
|
8
|
+
private readonly backendUrl;
|
|
9
|
+
private readonly fieldService;
|
|
10
|
+
private readonly modelService;
|
|
11
|
+
private _lastInputs;
|
|
12
|
+
private _lastResponse;
|
|
13
|
+
private readonly _listeners;
|
|
14
|
+
constructor(backendUrl: string);
|
|
15
|
+
register(descriptor: FieldStrategy | ReportStrategy): void;
|
|
16
|
+
update(descriptor: FieldStrategy | ReportStrategy): void;
|
|
17
|
+
unregister(descriptor: FieldStrategy | ReportStrategy): void;
|
|
18
|
+
/** Lectura sincrónica del último envío */
|
|
19
|
+
get lastInputs(): Record<string, unknown> | null;
|
|
20
|
+
get lastResponse(): Output | null;
|
|
21
|
+
/** Suscripción reactiva; devuelve la función para des‑suscribirse */
|
|
22
|
+
onSubmit(cb: SubmitCallback): () => void;
|
|
23
|
+
toHTMLElement(data: Signature, container: HTMLElement): Promise<HTMLElement>;
|
|
24
|
+
validateSchema(data: Signature): Promise<unknown>;
|
|
25
|
+
schema(): z.core.JSONSchema.JSONSchema;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Signature } from '../core/domain';
|
|
2
|
+
import { FieldStrategy, ReportStrategy } from '../extensions/app';
|
|
3
|
+
export interface IMLForm {
|
|
4
|
+
register(descriptor: FieldStrategy): void;
|
|
5
|
+
register(descriptor: ReportStrategy): void;
|
|
6
|
+
update(descriptor: FieldStrategy): void;
|
|
7
|
+
update(descriptor: ReportStrategy): void;
|
|
8
|
+
unregister(descriptor: FieldStrategy): void;
|
|
9
|
+
unregister(descriptor: ReportStrategy): void;
|
|
10
|
+
toHTMLElement(data: Signature, container: HTMLElement): Promise<HTMLElement>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Infer } from '../../core/domain';
|
|
2
|
+
import { FieldStrategy } from '../../extensions/app';
|
|
3
|
+
import { BooleanFieldSchema } from '../domain';
|
|
4
|
+
export declare class BooleanStrategy extends FieldStrategy<typeof BooleanFieldSchema> {
|
|
5
|
+
constructor();
|
|
6
|
+
protected buildControl(field: Infer<typeof BooleanFieldSchema>): {
|
|
7
|
+
tag: string;
|
|
8
|
+
props: {
|
|
9
|
+
defaultValue: string | undefined;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Infer } from '../../core/domain';
|
|
2
|
+
import { FieldStrategy } from '../../extensions/app';
|
|
3
|
+
import { CategoryFieldSchema } from '../domain';
|
|
4
|
+
export declare class CategoryStrategy extends FieldStrategy<typeof CategoryFieldSchema> {
|
|
5
|
+
constructor();
|
|
6
|
+
protected buildControl(field: Infer<typeof CategoryFieldSchema>): {
|
|
7
|
+
tag: string;
|
|
8
|
+
props: {
|
|
9
|
+
defaultValue: string;
|
|
10
|
+
optionList: string[];
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Infer } from '../../core/domain';
|
|
2
|
+
import { ReportStrategy } from '../../extensions/app';
|
|
3
|
+
import { ClassifierModelSchema } from '../domain';
|
|
4
|
+
export declare class ClassifierStrategy extends ReportStrategy<typeof ClassifierModelSchema> {
|
|
5
|
+
constructor();
|
|
6
|
+
buildControl(model: Infer<typeof ClassifierModelSchema>): {
|
|
7
|
+
tag: string;
|
|
8
|
+
props: {
|
|
9
|
+
title: string | undefined;
|
|
10
|
+
mapping: string[] | undefined;
|
|
11
|
+
probabilities: number[][] | undefined;
|
|
12
|
+
details: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Infer } from '../../core/domain';
|
|
2
|
+
import { FieldStrategy } from '../../extensions/app';
|
|
3
|
+
import { DateFieldSchema } from '../domain';
|
|
4
|
+
export declare class DateStrategy extends FieldStrategy<typeof DateFieldSchema> {
|
|
5
|
+
constructor();
|
|
6
|
+
buildControl(field: Infer<typeof DateFieldSchema>): {
|
|
7
|
+
tag: string;
|
|
8
|
+
props: {
|
|
9
|
+
min: string | undefined;
|
|
10
|
+
max: string | undefined;
|
|
11
|
+
step: number | undefined;
|
|
12
|
+
defaultValue: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Infer } from '../../core/domain';
|
|
2
|
+
import { FieldStrategy } from '../../extensions/app';
|
|
3
|
+
import { NumberFieldSchema } from '../domain';
|
|
4
|
+
export declare class NumberStrategy extends FieldStrategy<typeof NumberFieldSchema> {
|
|
5
|
+
constructor();
|
|
6
|
+
buildControl(field: Infer<typeof NumberFieldSchema>): {
|
|
7
|
+
tag: string;
|
|
8
|
+
props: {
|
|
9
|
+
unit: string | undefined;
|
|
10
|
+
min: number | undefined;
|
|
11
|
+
max: number | undefined;
|
|
12
|
+
step: number | undefined;
|
|
13
|
+
defaultValue: number | undefined;
|
|
14
|
+
placeholder?: undefined;
|
|
15
|
+
};
|
|
16
|
+
slot: string;
|
|
17
|
+
} | {
|
|
18
|
+
tag: string;
|
|
19
|
+
props: {
|
|
20
|
+
unit: string | undefined;
|
|
21
|
+
min: number | undefined;
|
|
22
|
+
max: number | undefined;
|
|
23
|
+
step: number | undefined;
|
|
24
|
+
defaultValue: number | undefined;
|
|
25
|
+
placeholder: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
slot?: undefined;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Infer } from '../../core/domain';
|
|
2
|
+
import { ReportStrategy } from '../../extensions/app';
|
|
3
|
+
import { RegressorModelSchema } from '../domain';
|
|
4
|
+
export declare class RegressorStrategy extends ReportStrategy<typeof RegressorModelSchema> {
|
|
5
|
+
constructor();
|
|
6
|
+
buildControl(model: Infer<typeof RegressorModelSchema>): {
|
|
7
|
+
tag: string;
|
|
8
|
+
props: {
|
|
9
|
+
title: string | undefined;
|
|
10
|
+
values: number[] | undefined;
|
|
11
|
+
unit: string | undefined;
|
|
12
|
+
interval: [number, number] | undefined;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Infer } from '../../core/domain';
|
|
2
|
+
import { FieldStrategy } from '../../extensions/app';
|
|
3
|
+
import { TextFieldSchema } from '../domain';
|
|
4
|
+
export declare class TextStrategy extends FieldStrategy<typeof TextFieldSchema> {
|
|
5
|
+
constructor();
|
|
6
|
+
buildControl(field: Infer<typeof TextFieldSchema>): {
|
|
7
|
+
tag: string;
|
|
8
|
+
props: {
|
|
9
|
+
minlength: number | undefined;
|
|
10
|
+
maxlength: number | undefined;
|
|
11
|
+
placeholder: string | undefined;
|
|
12
|
+
defaultValue: string | undefined;
|
|
13
|
+
pattern: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}
|