mlform 0.1.15 → 0.1.18
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 +2 -2
- package/dist/{builtins-CcS-sHJa.js → builtins-STiTwaH9.js} +102 -107
- package/dist/mlform/builtins.mjs +2 -2
- package/dist/mlform/kit.mjs +251 -231
- package/dist/mlform/primitives.mjs +1 -1
- package/dist/mlform/runtime.mjs +3 -3
- package/dist/mlform/schema.mjs +2 -2
- package/dist/mlform/transport.mjs +1 -1
- package/dist/{primitives-9obTthA6.js → primitives-BcXt2QWI.js} +83 -53
- package/dist/{runtime-Bn_x46y-.js → runtime-Eo_q4pgg.js} +610 -506
- package/dist/schema-CNKKJZRx.js +173 -0
- package/dist/{transport-D173EDlB.js → transport-Cloa_erk.js} +204 -196
- package/dist/types/src/builtins/constants.d.ts +0 -4
- package/dist/types/src/builtins/definitions/fields/series-helpers.d.ts +1 -0
- package/dist/types/src/builtins/definitions/shared.d.ts +1 -1
- package/dist/types/src/kit/mount-types.d.ts +2 -0
- package/dist/types/src/kit/view-core-types.d.ts +4 -1
- package/dist/types/src/primitives/components/form-root-templates.d.ts +3 -1
- package/dist/types/src/primitives/components/form-root.d.ts +3 -1
- package/dist/types/src/primitives/components/report-frame.d.ts +2 -1
- package/dist/types/src/primitives/controller-types.d.ts +46 -2
- package/dist/types/src/primitives/types.d.ts +6 -2
- package/dist/types/src/runtime/index.d.ts +4 -2
- package/dist/types/src/runtime/submission/index.d.ts +2 -0
- package/dist/types/src/runtime/submission/multi-backend.d.ts +25 -0
- package/dist/types/src/runtime/submission/request.d.ts +14 -0
- package/dist/types/src/runtime/submission/snapshot.d.ts +12 -0
- package/dist/types/src/runtime/types/behavior.d.ts +4 -0
- package/dist/types/src/runtime/types/field.d.ts +1 -0
- package/dist/types/src/runtime/types/form.d.ts +4 -0
- package/dist/types/src/runtime/types/transport.d.ts +11 -2
- package/dist/types/src/schema/index.d.ts +2 -0
- package/dist/types/src/schema/mapped-to.d.ts +3 -2
- package/dist/types/src/schema/onehot-display.d.ts +15 -0
- package/dist/types/src/schema/report-context.d.ts +17 -0
- package/dist/types/src/schema/types/field.d.ts +1 -0
- package/dist/types/src/schema/types/report.d.ts +7 -2
- package/dist/types/src/schema/types/submit.d.ts +31 -1
- package/dist/types/src/transport/types/core.d.ts +19 -2
- package/package.json +2 -1
- package/dist/schema-DYDo_1VV.js +0 -95
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ 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
|
-
Version `0.1.
|
|
12
|
+
Version `0.1.18` is the current release in this repository.
|
|
13
13
|
|
|
14
14
|
## Why MLForm
|
|
15
15
|
|
|
@@ -306,7 +306,7 @@ The main package targets Node.js `>=24.9.0`.
|
|
|
306
306
|
|
|
307
307
|
## Release Notes
|
|
308
308
|
|
|
309
|
-
For `0.1.
|
|
309
|
+
For `0.1.18`, use the repository release entry and the published docs as the source of truth:
|
|
310
310
|
|
|
311
311
|
- GitHub releases: https://github.com/UlloaSP/mlform/releases
|
|
312
312
|
- npm package: https://www.npmjs.com/package/mlform
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { s as r } from "./primitives-
|
|
1
|
+
import { d as e, m as t, s as n } from "./schema-CNKKJZRx.js";
|
|
2
|
+
import { s as r } from "./primitives-BcXt2QWI.js";
|
|
3
3
|
import * as i from "zod";
|
|
4
4
|
//#region src/builtins/constants.ts
|
|
5
5
|
var a = {
|
|
6
6
|
classifier: "classifier",
|
|
7
7
|
regressor: "regressor"
|
|
8
8
|
}, o = {
|
|
9
|
-
classifier: a.classifier,
|
|
10
|
-
regressor: a.regressor
|
|
11
|
-
}, ee = {
|
|
12
9
|
text: "text",
|
|
13
10
|
number: "number",
|
|
14
11
|
boolean: "boolean",
|
|
@@ -23,10 +20,10 @@ var a = {
|
|
|
23
20
|
}, s = {
|
|
24
21
|
classifier: "Classifier report",
|
|
25
22
|
regressor: "Regressor report"
|
|
26
|
-
},
|
|
23
|
+
}, c = {
|
|
27
24
|
unknownPrediction: "Unknown",
|
|
28
25
|
classifierClassLabel: (e) => `Class ${e + 1}`
|
|
29
|
-
},
|
|
26
|
+
}, l = {
|
|
30
27
|
invalidNumber: "Value must be a valid number.",
|
|
31
28
|
textPatternMismatch: "Value does not match the expected pattern.",
|
|
32
29
|
categoryOptionMismatch: "Value must match one of the available options.",
|
|
@@ -47,7 +44,7 @@ var a = {
|
|
|
47
44
|
timestampsUnique: "Timestamps must be unique.",
|
|
48
45
|
timestampsAscending: "Timestamps must be sorted in ascending order.",
|
|
49
46
|
timestampsDescending: "Timestamps must be sorted in descending order."
|
|
50
|
-
},
|
|
47
|
+
}, u = i.record(i.string(), i.unknown()).optional(), d = i.union([i.string().min(1), i.number().int().nonnegative()]), f = i.union([d, i.record(i.string().min(1), d.nullish())]).optional(), ee = i.custom((e) => typeof e == "function"), p = i.enum([
|
|
51
48
|
"idle",
|
|
52
49
|
"editing",
|
|
53
50
|
"validating",
|
|
@@ -106,7 +103,7 @@ var a = {
|
|
|
106
103
|
kind: i.literal("not"),
|
|
107
104
|
condition: m
|
|
108
105
|
})
|
|
109
|
-
])), h = i.union([
|
|
106
|
+
])), h = i.union([ee, m]), g = {
|
|
110
107
|
id: i.string().optional(),
|
|
111
108
|
label: i.string().min(1),
|
|
112
109
|
description: i.string().optional(),
|
|
@@ -125,23 +122,21 @@ var a = {
|
|
|
125
122
|
"reset-on-hide"
|
|
126
123
|
]).optional(),
|
|
127
124
|
includeInSubmission: i.boolean().optional(),
|
|
128
|
-
|
|
125
|
+
displayKey: i.string().min(1).optional(),
|
|
126
|
+
mappedTo: f,
|
|
129
127
|
valuePath: i.union([i.string().min(1), i.array(i.string().min(1)).min(1)]).optional(),
|
|
130
128
|
defaultValue: i.unknown().optional(),
|
|
131
|
-
ui:
|
|
129
|
+
ui: u
|
|
132
130
|
}, _ = {
|
|
133
131
|
id: i.string().optional(),
|
|
134
132
|
label: i.string().optional(),
|
|
135
133
|
description: i.string().optional(),
|
|
136
|
-
mappedTo:
|
|
137
|
-
ui:
|
|
134
|
+
mappedTo: f,
|
|
135
|
+
ui: u
|
|
138
136
|
}, v = i.union([i.string(), i.object({
|
|
139
137
|
label: i.string(),
|
|
140
138
|
value: i.string()
|
|
141
|
-
})]), y = (e, t) => {
|
|
142
|
-
let n = e.raw;
|
|
143
|
-
if (!(typeof n != "object" || !n || !("outputs" in n) || !Array.isArray(n.outputs))) return n.outputs.find((e) => e.type === t);
|
|
144
|
-
}, b = (e, t, n) => ({
|
|
139
|
+
})]), y = (e, t, n) => ({
|
|
145
140
|
component: e,
|
|
146
141
|
props: {
|
|
147
142
|
id: t.id,
|
|
@@ -154,7 +149,7 @@ var a = {
|
|
|
154
149
|
...n,
|
|
155
150
|
...t.ui
|
|
156
151
|
}
|
|
157
|
-
}),
|
|
152
|
+
}), b = {
|
|
158
153
|
kind: "boolean",
|
|
159
154
|
schema: i.object({
|
|
160
155
|
kind: i.literal("boolean"),
|
|
@@ -169,7 +164,7 @@ var a = {
|
|
|
169
164
|
return e == null || e === "" ? null : e === !0 || e === "true" ? !0 : e === !1 || e === "false" ? !1 : !!e;
|
|
170
165
|
},
|
|
171
166
|
describe(e, t) {
|
|
172
|
-
return
|
|
167
|
+
return y("boolean-field", e, {
|
|
173
168
|
checked: t.state.value,
|
|
174
169
|
trueLabel: e.trueLabel,
|
|
175
170
|
falseLabel: e.falseLabel,
|
|
@@ -177,7 +172,7 @@ var a = {
|
|
|
177
172
|
errors: t.state.errors
|
|
178
173
|
});
|
|
179
174
|
}
|
|
180
|
-
},
|
|
175
|
+
}, x = {
|
|
181
176
|
kind: "category",
|
|
182
177
|
schema: i.object({
|
|
183
178
|
kind: i.literal("category"),
|
|
@@ -191,27 +186,27 @@ var a = {
|
|
|
191
186
|
return e == null || e === "" ? null : typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? `${e}` : null;
|
|
192
187
|
},
|
|
193
188
|
validate(e, t) {
|
|
194
|
-
return e === null || t.options.map((e) => typeof e == "string" ? e : e.value).includes(e) ? [] : [
|
|
189
|
+
return e === null || t.options.map((e) => typeof e == "string" ? e : e.value).includes(e) ? [] : [l.categoryOptionMismatch];
|
|
195
190
|
},
|
|
196
191
|
describe(e, t) {
|
|
197
|
-
return
|
|
192
|
+
return y("category-field", e, {
|
|
198
193
|
value: t.state.value,
|
|
199
194
|
options: e.options,
|
|
200
195
|
state: t.state.status,
|
|
201
196
|
errors: t.state.errors
|
|
202
197
|
});
|
|
203
198
|
}
|
|
204
|
-
},
|
|
199
|
+
}, te = i.object({
|
|
205
200
|
label: i.string(),
|
|
206
201
|
value: i.string(),
|
|
207
202
|
mapping: i.record(i.string(), i.unknown())
|
|
208
|
-
}),
|
|
203
|
+
}), S = {
|
|
209
204
|
kind: "mapped-category",
|
|
210
205
|
schema: i.object({
|
|
211
206
|
kind: i.literal("mapped-category"),
|
|
212
207
|
...g,
|
|
213
208
|
includeInSubmission: i.boolean().optional().default(!1),
|
|
214
|
-
options: i.array(
|
|
209
|
+
options: i.array(te).min(1)
|
|
215
210
|
}),
|
|
216
211
|
getDefaultValue(e) {
|
|
217
212
|
return typeof e.defaultValue == "string" ? e.defaultValue : null;
|
|
@@ -220,10 +215,10 @@ var a = {
|
|
|
220
215
|
return e == null || e === "" ? null : typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? `${e}` : null;
|
|
221
216
|
},
|
|
222
217
|
validate(e, t) {
|
|
223
|
-
return e === null || t.options.map((e) => e.value).includes(e) ? [] : [
|
|
218
|
+
return e === null || t.options.map((e) => e.value).includes(e) ? [] : [l.categoryOptionMismatch];
|
|
224
219
|
},
|
|
225
220
|
describe(e, t) {
|
|
226
|
-
return
|
|
221
|
+
return y("category-field", e, {
|
|
227
222
|
value: t.state.value,
|
|
228
223
|
options: e.options.map((e) => ({
|
|
229
224
|
label: e.label,
|
|
@@ -233,17 +228,17 @@ var a = {
|
|
|
233
228
|
errors: t.state.errors
|
|
234
229
|
});
|
|
235
230
|
}
|
|
236
|
-
},
|
|
231
|
+
}, C = i.object({
|
|
237
232
|
label: i.string(),
|
|
238
233
|
value: i.string(),
|
|
239
|
-
mappedTo:
|
|
240
|
-
}),
|
|
234
|
+
mappedTo: f.unwrap()
|
|
235
|
+
}), w = {
|
|
241
236
|
kind: "onehot-category",
|
|
242
237
|
schema: i.object({
|
|
243
238
|
kind: i.literal("onehot-category"),
|
|
244
239
|
...g,
|
|
245
240
|
includeInSubmission: i.boolean().optional().default(!0),
|
|
246
|
-
options: i.array(
|
|
241
|
+
options: i.array(C).min(1)
|
|
247
242
|
}),
|
|
248
243
|
getDefaultValue(e) {
|
|
249
244
|
return typeof e.defaultValue == "string" ? e.defaultValue : null;
|
|
@@ -252,10 +247,10 @@ var a = {
|
|
|
252
247
|
return e == null || e === "" ? null : typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? `${e}` : null;
|
|
253
248
|
},
|
|
254
249
|
validate(e, t) {
|
|
255
|
-
return e === null || t.options.some((t) => t.value === e) ? [] : [
|
|
250
|
+
return e === null || t.options.some((t) => t.value === e) ? [] : [l.categoryOptionMismatch];
|
|
256
251
|
},
|
|
257
252
|
describe(e, t) {
|
|
258
|
-
return
|
|
253
|
+
return y("category-field", e, {
|
|
259
254
|
value: t.state.value,
|
|
260
255
|
options: e.options.map((e) => ({
|
|
261
256
|
label: e.label,
|
|
@@ -265,14 +260,14 @@ var a = {
|
|
|
265
260
|
errors: t.state.errors
|
|
266
261
|
});
|
|
267
262
|
}
|
|
268
|
-
},
|
|
263
|
+
}, T = (e) => typeof e == "object" && !!e && !Array.isArray(e), E = (e) => {
|
|
269
264
|
if (e instanceof Date) return Number.isNaN(e.getTime()) ? null : e;
|
|
270
265
|
if (typeof e == "string" || typeof e == "number") {
|
|
271
266
|
let t = new Date(e);
|
|
272
267
|
return Number.isNaN(t.getTime()) ? null : t;
|
|
273
268
|
}
|
|
274
269
|
return null;
|
|
275
|
-
},
|
|
270
|
+
}, D = {
|
|
276
271
|
kind: "date",
|
|
277
272
|
schema: i.object({
|
|
278
273
|
kind: i.literal("date"),
|
|
@@ -282,25 +277,25 @@ var a = {
|
|
|
282
277
|
step: i.number().positive().optional()
|
|
283
278
|
}),
|
|
284
279
|
getDefaultValue(e) {
|
|
285
|
-
return
|
|
280
|
+
return E(e.defaultValue) ?? null;
|
|
286
281
|
},
|
|
287
282
|
normalizeValue(e) {
|
|
288
|
-
return
|
|
283
|
+
return E(e);
|
|
289
284
|
},
|
|
290
285
|
serializeValue(e) {
|
|
291
286
|
return e instanceof Date ? e.toISOString() : e;
|
|
292
287
|
},
|
|
293
288
|
validate(e, t) {
|
|
294
|
-
let n = [], r =
|
|
295
|
-
if (r && i && r.getTime() > i.getTime() && n.push(
|
|
296
|
-
if (r && e.getTime() < r.getTime() && n.push(
|
|
289
|
+
let n = [], r = E(t.min), i = E(t.max);
|
|
290
|
+
if (r && i && r.getTime() > i.getTime() && n.push(l.invalidDateRange), e === null) return n;
|
|
291
|
+
if (r && e.getTime() < r.getTime() && n.push(l.dateOnOrAfter(String(t.min))), i && e.getTime() > i.getTime() && n.push(l.dateOnOrBefore(String(t.max))), t.step !== void 0) {
|
|
297
292
|
let i = r ?? /* @__PURE__ */ new Date("1970-01-01T00:00:00Z");
|
|
298
|
-
Math.round(Math.abs(e.getTime() - i.getTime()) / 864e5) % t.step !== 0 && n.push(
|
|
293
|
+
Math.round(Math.abs(e.getTime() - i.getTime()) / 864e5) % t.step !== 0 && n.push(l.stepDate(t.step));
|
|
299
294
|
}
|
|
300
295
|
return n;
|
|
301
296
|
},
|
|
302
297
|
describe(e, t) {
|
|
303
|
-
return
|
|
298
|
+
return y("date-field", e, {
|
|
304
299
|
value: t.state.value instanceof Date ? t.state.value.toISOString().slice(0, 10) : t.state.value,
|
|
305
300
|
min: e.min,
|
|
306
301
|
max: e.max,
|
|
@@ -309,7 +304,7 @@ var a = {
|
|
|
309
304
|
errors: t.state.errors
|
|
310
305
|
});
|
|
311
306
|
}
|
|
312
|
-
},
|
|
307
|
+
}, O = {
|
|
313
308
|
kind: "long-text",
|
|
314
309
|
schema: i.object({
|
|
315
310
|
kind: i.literal("long-text"),
|
|
@@ -327,10 +322,10 @@ var a = {
|
|
|
327
322
|
},
|
|
328
323
|
validate(e, t) {
|
|
329
324
|
let n = [];
|
|
330
|
-
return t.minLength !== void 0 && t.maxLength !== void 0 && t.minLength > t.maxLength && n.push(
|
|
325
|
+
return t.minLength !== void 0 && t.maxLength !== void 0 && t.minLength > t.maxLength && n.push(l.invalidTextLengthRange), e.length === 0 ? n : (t.minLength !== void 0 && e.length < t.minLength && n.push(l.minLength(t.minLength)), t.maxLength !== void 0 && e.length > t.maxLength && n.push(l.maxLength(t.maxLength)), n);
|
|
331
326
|
},
|
|
332
327
|
describe(e, t) {
|
|
333
|
-
return
|
|
328
|
+
return y("long-text-field", e, {
|
|
334
329
|
value: t.state.value,
|
|
335
330
|
placeholder: e.placeholder ?? "",
|
|
336
331
|
minLength: e.minLength,
|
|
@@ -340,7 +335,7 @@ var a = {
|
|
|
340
335
|
errors: t.state.errors
|
|
341
336
|
});
|
|
342
337
|
}
|
|
343
|
-
},
|
|
338
|
+
}, k = {
|
|
344
339
|
kind: "multi-choice",
|
|
345
340
|
schema: i.object({
|
|
346
341
|
kind: i.literal("multi-choice"),
|
|
@@ -363,10 +358,10 @@ var a = {
|
|
|
363
358
|
validate(e, t) {
|
|
364
359
|
if (e.length === 0) return [];
|
|
365
360
|
let n = t.options.map((e) => typeof e == "string" ? e : e.value);
|
|
366
|
-
return e.filter((e) => !n.includes(e)).length > 0 ? [
|
|
361
|
+
return e.filter((e) => !n.includes(e)).length > 0 ? [l.categoryOptionMismatch] : [];
|
|
367
362
|
},
|
|
368
363
|
describe(e, t) {
|
|
369
|
-
return
|
|
364
|
+
return y("multi-choice-field", e, {
|
|
370
365
|
value: t.state.value,
|
|
371
366
|
options: e.options,
|
|
372
367
|
layout: e.layout ?? "vertical",
|
|
@@ -374,7 +369,7 @@ var a = {
|
|
|
374
369
|
errors: t.state.errors
|
|
375
370
|
});
|
|
376
371
|
}
|
|
377
|
-
},
|
|
372
|
+
}, A = {
|
|
378
373
|
kind: "number",
|
|
379
374
|
schema: i.object({
|
|
380
375
|
kind: i.literal("number"),
|
|
@@ -402,17 +397,17 @@ var a = {
|
|
|
402
397
|
},
|
|
403
398
|
validate(e, t) {
|
|
404
399
|
let n = [];
|
|
405
|
-
if (t.min !== void 0 && t.max !== void 0 && t.min > t.max && n.push(
|
|
406
|
-
if (typeof e != "number") return n.push(
|
|
407
|
-
if (t.min !== void 0 && e < t.min && n.push(
|
|
400
|
+
if (t.min !== void 0 && t.max !== void 0 && t.min > t.max && n.push(l.invalidNumericRange), e === null) return n;
|
|
401
|
+
if (typeof e != "number") return n.push(l.invalidNumber), n;
|
|
402
|
+
if (t.min !== void 0 && e < t.min && n.push(l.minValue(t.min)), t.max !== void 0 && e > t.max && n.push(l.maxValue(t.max)), t.step !== void 0) {
|
|
408
403
|
let r = t.min ?? 0, i = Math.abs(e - r) % t.step, a = t.step * 1e-9;
|
|
409
|
-
i > a && Math.abs(i - t.step) > a && n.push(
|
|
404
|
+
i > a && Math.abs(i - t.step) > a && n.push(l.stepValue(t.step));
|
|
410
405
|
}
|
|
411
406
|
return n;
|
|
412
407
|
},
|
|
413
408
|
describe(e, t) {
|
|
414
409
|
let n = e.min !== void 0 && e.max !== void 0 && !e.required && t.state.value !== null;
|
|
415
|
-
return
|
|
410
|
+
return y("number-field", e, {
|
|
416
411
|
value: t.state.value,
|
|
417
412
|
min: e.min,
|
|
418
413
|
max: e.max,
|
|
@@ -424,7 +419,7 @@ var a = {
|
|
|
424
419
|
errors: t.state.errors
|
|
425
420
|
});
|
|
426
421
|
}
|
|
427
|
-
},
|
|
422
|
+
}, j = {
|
|
428
423
|
kind: "rating",
|
|
429
424
|
schema: i.object({
|
|
430
425
|
kind: i.literal("rating"),
|
|
@@ -444,10 +439,10 @@ var a = {
|
|
|
444
439
|
validate(e, t) {
|
|
445
440
|
if (e === null) return [];
|
|
446
441
|
let n = [], r = t.min ?? 1, i = t.max;
|
|
447
|
-
return r > i ? (n.push(
|
|
442
|
+
return r > i ? (n.push(l.invalidNumericRange), n) : (e < r && n.push(l.minValue(r)), e > i && n.push(l.maxValue(i)), n);
|
|
448
443
|
},
|
|
449
444
|
describe(e, t) {
|
|
450
|
-
return
|
|
445
|
+
return y("rating-field", e, {
|
|
451
446
|
value: t.state.value,
|
|
452
447
|
min: e.min ?? 1,
|
|
453
448
|
max: e.max,
|
|
@@ -456,7 +451,7 @@ var a = {
|
|
|
456
451
|
errors: t.state.errors
|
|
457
452
|
});
|
|
458
453
|
}
|
|
459
|
-
},
|
|
454
|
+
}, M = {
|
|
460
455
|
kind: "text",
|
|
461
456
|
schema: i.object({
|
|
462
457
|
kind: i.literal("text"),
|
|
@@ -474,10 +469,10 @@ var a = {
|
|
|
474
469
|
},
|
|
475
470
|
validate(e, t) {
|
|
476
471
|
let n = [];
|
|
477
|
-
return t.minLength !== void 0 && t.maxLength !== void 0 && t.minLength > t.maxLength && n.push(
|
|
472
|
+
return t.minLength !== void 0 && t.maxLength !== void 0 && t.minLength > t.maxLength && n.push(l.invalidTextLengthRange), e.length === 0 ? n : (t.minLength !== void 0 && e.length < t.minLength && n.push(l.minLength(t.minLength)), t.maxLength !== void 0 && e.length > t.maxLength && n.push(l.maxLength(t.maxLength)), t.pattern && !new RegExp(t.pattern).test(e) && n.push(l.textPatternMismatch), n);
|
|
478
473
|
},
|
|
479
474
|
describe(e, t) {
|
|
480
|
-
return
|
|
475
|
+
return y("text-field", e, {
|
|
481
476
|
value: t.state.value,
|
|
482
477
|
placeholder: e.placeholder ?? "",
|
|
483
478
|
minLength: e.minLength,
|
|
@@ -487,23 +482,23 @@ var a = {
|
|
|
487
482
|
errors: t.state.errors
|
|
488
483
|
});
|
|
489
484
|
}
|
|
490
|
-
},
|
|
485
|
+
}, N = i.object({
|
|
491
486
|
kind: i.string().min(1),
|
|
492
487
|
label: i.string().min(1),
|
|
493
488
|
required: i.boolean().optional()
|
|
494
|
-
}).passthrough(),
|
|
489
|
+
}).passthrough(), P = i.object({
|
|
495
490
|
kind: i.literal("series"),
|
|
496
491
|
...g,
|
|
497
|
-
field1:
|
|
498
|
-
field2:
|
|
492
|
+
field1: N,
|
|
493
|
+
field2: N,
|
|
499
494
|
minPoints: i.number().int().nonnegative().optional(),
|
|
500
495
|
maxPoints: i.number().int().nonnegative().optional()
|
|
501
|
-
}),
|
|
502
|
-
text:
|
|
503
|
-
number:
|
|
504
|
-
date:
|
|
505
|
-
category:
|
|
506
|
-
},
|
|
496
|
+
}), F = "This field is required.", I = (e) => e.toISOString().slice(0, 10), L = {
|
|
497
|
+
text: M,
|
|
498
|
+
number: A,
|
|
499
|
+
date: D,
|
|
500
|
+
category: x
|
|
501
|
+
}, R = (e) => L[e], ne = (e) => {
|
|
507
502
|
if (e == null || e === "") return null;
|
|
508
503
|
if (typeof e == "boolean") return e;
|
|
509
504
|
if (typeof e == "string") {
|
|
@@ -512,19 +507,19 @@ var a = {
|
|
|
512
507
|
}
|
|
513
508
|
return !!e;
|
|
514
509
|
}, z = (e, t) => {
|
|
515
|
-
if (e.kind ===
|
|
516
|
-
let n =
|
|
510
|
+
if (e.kind === b.kind) return ne(t);
|
|
511
|
+
let n = R(e.kind);
|
|
517
512
|
return n?.normalizeValue ? n.normalizeValue(t, e) : t;
|
|
518
513
|
}, B = (e, t) => {
|
|
519
514
|
if (t == null) return null;
|
|
520
|
-
if (e.kind === "date" && t instanceof Date) return
|
|
521
|
-
let n =
|
|
515
|
+
if (e.kind === "date" && t instanceof Date) return I(t);
|
|
516
|
+
let n = R(e.kind);
|
|
522
517
|
return n?.serializeValue ? n.serializeValue(t, e) : t;
|
|
523
|
-
},
|
|
524
|
-
if (e.required &&
|
|
525
|
-
if (e.kind ===
|
|
518
|
+
}, re = (e, t) => t == null ? !0 : typeof t == "string" ? t.trim().length === 0 : e.kind === b.kind ? t == null : !1, V = (e, t) => {
|
|
519
|
+
if (e.required && re(e, t)) return [F];
|
|
520
|
+
if (e.kind === b.kind) {
|
|
526
521
|
if (t === null) return [];
|
|
527
|
-
let n =
|
|
522
|
+
let n = b.validate?.(t, e, {
|
|
528
523
|
field: {
|
|
529
524
|
...e,
|
|
530
525
|
id: e.label
|
|
@@ -536,7 +531,7 @@ var a = {
|
|
|
536
531
|
});
|
|
537
532
|
return Array.isArray(n) ? n : [];
|
|
538
533
|
}
|
|
539
|
-
let n =
|
|
534
|
+
let n = R(e.kind);
|
|
540
535
|
if (!n?.validate) return [];
|
|
541
536
|
let r = n.validate(t, e, {
|
|
542
537
|
field: {
|
|
@@ -554,7 +549,7 @@ var a = {
|
|
|
554
549
|
field1: e[0],
|
|
555
550
|
field2: e[1]
|
|
556
551
|
} : null;
|
|
557
|
-
if (!
|
|
552
|
+
if (!T(e)) return null;
|
|
558
553
|
if ("field1" in e || "field2" in e) return {
|
|
559
554
|
field1: e.field1,
|
|
560
555
|
field2: e.field2
|
|
@@ -572,10 +567,10 @@ var a = {
|
|
|
572
567
|
} : null;
|
|
573
568
|
}, G = (e, t) => {
|
|
574
569
|
let n = /* @__PURE__ */ new Set();
|
|
575
|
-
return t.minPoints !== void 0 && t.maxPoints !== void 0 && t.minPoints > t.maxPoints && n.add(
|
|
570
|
+
return t.minPoints !== void 0 && t.maxPoints !== void 0 && t.minPoints > t.maxPoints && n.add(l.invalidPointCountRange), t.minPoints !== void 0 && e.length < t.minPoints && n.add(l.minPoints(t.minPoints)), t.maxPoints !== void 0 && e.length > t.maxPoints && n.add(l.maxPoints(t.maxPoints)), n;
|
|
576
571
|
}, K = {
|
|
577
572
|
kind: "series",
|
|
578
|
-
schema:
|
|
573
|
+
schema: P,
|
|
579
574
|
getDefaultValue(e) {
|
|
580
575
|
return Array.isArray(e.defaultValue) ? e.defaultValue.map((t) => W(t, e)).filter((e) => e !== null) : [];
|
|
581
576
|
},
|
|
@@ -596,8 +591,8 @@ var a = {
|
|
|
596
591
|
}), [...n];
|
|
597
592
|
},
|
|
598
593
|
describe(e, t) {
|
|
599
|
-
return
|
|
600
|
-
value: Array.isArray(t.state.value) ? t.state.value.map((t) =>
|
|
594
|
+
return y("series-field", e, {
|
|
595
|
+
value: Array.isArray(t.state.value) ? t.state.value.map((t) => T(t) ? {
|
|
601
596
|
field1: B(e.field1, t.field1),
|
|
602
597
|
field2: B(e.field2, t.field2)
|
|
603
598
|
} : t) : [],
|
|
@@ -624,10 +619,10 @@ var a = {
|
|
|
624
619
|
return e == null || e === "" ? null : typeof e == "string" || typeof e == "number" || typeof e == "boolean" || typeof e == "bigint" ? `${e}` : null;
|
|
625
620
|
},
|
|
626
621
|
validate(e, t) {
|
|
627
|
-
return e === null || t.options.map((e) => typeof e == "string" ? e : e.value).includes(e) ? [] : [
|
|
622
|
+
return e === null || t.options.map((e) => typeof e == "string" ? e : e.value).includes(e) ? [] : [l.categoryOptionMismatch];
|
|
628
623
|
},
|
|
629
624
|
describe(e, t) {
|
|
630
|
-
return
|
|
625
|
+
return y("single-choice-field", e, {
|
|
631
626
|
value: t.state.value,
|
|
632
627
|
options: e.options,
|
|
633
628
|
layout: e.layout ?? "vertical",
|
|
@@ -645,7 +640,7 @@ var a = {
|
|
|
645
640
|
showClassProbabilities: i.boolean().optional().default(!0)
|
|
646
641
|
}),
|
|
647
642
|
resolvePayload(t, n) {
|
|
648
|
-
return e(n.report, n.result)
|
|
643
|
+
return e(n.report, n.result);
|
|
649
644
|
},
|
|
650
645
|
describe(e, t) {
|
|
651
646
|
return t.state.status === "idle" && t.payload === void 0 ? null : {
|
|
@@ -674,7 +669,7 @@ var a = {
|
|
|
674
669
|
precision: i.number().int().nonnegative().optional().default(2)
|
|
675
670
|
}),
|
|
676
671
|
resolvePayload(t, n) {
|
|
677
|
-
return e(n.report, n.result)
|
|
672
|
+
return e(n.report, n.result);
|
|
678
673
|
},
|
|
679
674
|
describe(e, t) {
|
|
680
675
|
return t.state.status === "idle" && t.payload === void 0 ? null : {
|
|
@@ -693,7 +688,7 @@ var a = {
|
|
|
693
688
|
}
|
|
694
689
|
};
|
|
695
690
|
}
|
|
696
|
-
}, X = (e) => e.kind === "mapped-category" ? e.config : null, Z = (e,
|
|
691
|
+
}, X = (e) => e.kind === "mapped-category" ? e.config : null, Z = (e, n) => e.getField(n) ?? e.getField(t(n)), ie = async (e, t) => {
|
|
697
692
|
let n = t.getField(e.fieldId);
|
|
698
693
|
if (!n) return;
|
|
699
694
|
let r = X(n);
|
|
@@ -717,40 +712,40 @@ var a = {
|
|
|
717
712
|
}
|
|
718
713
|
},
|
|
719
714
|
async onValuesChanged(e, t) {
|
|
720
|
-
await
|
|
715
|
+
await ie(e, t);
|
|
721
716
|
}
|
|
722
|
-
}),
|
|
723
|
-
|
|
724
|
-
|
|
717
|
+
}), ae = [
|
|
718
|
+
M,
|
|
719
|
+
A,
|
|
720
|
+
b,
|
|
725
721
|
x,
|
|
726
722
|
S,
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
O,
|
|
723
|
+
w,
|
|
724
|
+
D,
|
|
730
725
|
K,
|
|
731
|
-
|
|
726
|
+
O,
|
|
732
727
|
q,
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
],
|
|
728
|
+
k,
|
|
729
|
+
j
|
|
730
|
+
], oe = [J, Y], $ = (e, t) => {
|
|
736
731
|
!t.describe || e.getField(t.kind) || e.registerField({
|
|
737
732
|
kind: t.kind,
|
|
738
733
|
describe: t.describe
|
|
739
734
|
});
|
|
740
|
-
},
|
|
735
|
+
}, se = (e, t) => {
|
|
741
736
|
!t.describe || e.getReport(t.kind) || e.registerReport({
|
|
742
737
|
kind: t.kind,
|
|
743
738
|
describe: t.describe
|
|
744
739
|
});
|
|
745
|
-
},
|
|
746
|
-
let e =
|
|
747
|
-
for (let
|
|
748
|
-
for (let
|
|
740
|
+
}, ce = () => n().registerReport(J).registerReport(Y), le = () => {
|
|
741
|
+
let e = n(), t = r();
|
|
742
|
+
for (let n of ae) e.registerField(n), $(t, n);
|
|
743
|
+
for (let n of oe) e.registerReport(n), se(t, n);
|
|
749
744
|
return {
|
|
750
745
|
registry: e,
|
|
751
|
-
descriptorRegistry:
|
|
746
|
+
descriptorRegistry: t,
|
|
752
747
|
behaviors: [Q()]
|
|
753
748
|
};
|
|
754
749
|
};
|
|
755
750
|
//#endregion
|
|
756
|
-
export {
|
|
751
|
+
export { l as S, b as _, J as a, a as b, M as c, k as d, O as f, x as g, S as h, Y as i, j as l, w as m, le as n, q as o, D as p, Q as r, K as s, ce as t, A as u, o as v, s as x, c as y };
|
package/dist/mlform/builtins.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { S as e, _ as t, a as n, b as r, c as i, d as a, f as o, g as s, h as c, i as l, l as u, m as d, n as f, o as p, p as m, r as h, s as g, t as _, u as v, v as y, x as b, y as x } from "../builtins-STiTwaH9.js";
|
|
2
|
+
export { t as booleanFieldDefinition, y as builtinFieldKinds, x as builtinReportFallbacks, r as builtinReportKinds, b as builtinReportLabels, e as builtinValidationMessages, s as categoryFieldDefinition, n as classifierReportDefinition, _ as createBuiltinMlRegistry, h as createMappedCategoryBehavior, f as createMlRegistryPack, m as dateFieldDefinition, o as longTextFieldDefinition, c as mappedCategoryFieldDefinition, a as multiChoiceFieldDefinition, v as numberFieldDefinition, d as oneHotCategoryFieldDefinition, u as ratingFieldDefinition, l as regressorReportDefinition, g as seriesFieldDefinition, p as singleChoiceFieldDefinition, i as textFieldDefinition };
|