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,195 @@
|
|
|
1
|
+
import { i as u, r as g, x as s, a as b, n as p } from "./property-jKFNMQpR.js";
|
|
2
|
+
import { t as x } from "./custom-element-ttkHUa8w.js";
|
|
3
|
+
var f = Object.defineProperty, m = Object.getOwnPropertyDescriptor, h = (e, r, t) => r in e ? f(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, d = (e, r, t, a) => {
|
|
4
|
+
for (var i = a > 1 ? void 0 : a ? m(r, t) : r, n = e.length - 1, c; n >= 0; n--)
|
|
5
|
+
(c = e[n]) && (i = (a ? c(r, t, i) : c(i)) || i);
|
|
6
|
+
return a && i && f(r, t, i), i;
|
|
7
|
+
}, l = (e, r, t) => h(e, typeof r != "symbol" ? r + "" : r, t);
|
|
8
|
+
class w extends Error {
|
|
9
|
+
statusCode;
|
|
10
|
+
code;
|
|
11
|
+
details;
|
|
12
|
+
constructor(r, t) {
|
|
13
|
+
super(r), this.name = "ApiError", this.statusCode = t?.statusCode, this.code = t?.code, this.details = t?.details;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
let o = class extends u {
|
|
17
|
+
error = null;
|
|
18
|
+
retry;
|
|
19
|
+
/**
|
|
20
|
+
* Registers custom error configurations.
|
|
21
|
+
* @param map A record where keys are error identifiers and values are ErrorConfig objects.
|
|
22
|
+
*/
|
|
23
|
+
static register(e) {
|
|
24
|
+
for (const r in e)
|
|
25
|
+
Object.hasOwn(e, r) && o._errorMap.set(r, e[r]);
|
|
26
|
+
}
|
|
27
|
+
constructor() {
|
|
28
|
+
super(), o.register(o.defaultErrorConfigs);
|
|
29
|
+
}
|
|
30
|
+
_getErrorConfig() {
|
|
31
|
+
return this.error ? o._errorMap.get("generic-error") || o.defaultErrorConfigs["generic-error"] : o._errorMap.get("generic-error");
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
if (!this.error)
|
|
35
|
+
return null;
|
|
36
|
+
const e = this._getErrorConfig(), r = e.details && this.error ? e.details(this.error) : [];
|
|
37
|
+
return s`
|
|
38
|
+
<div role="alertdialog" class="error-card-container">
|
|
39
|
+
<div class="error-card-icon">
|
|
40
|
+
${g(e.icon)}
|
|
41
|
+
</div>
|
|
42
|
+
<h2 class="error-card-title">${e.title}</h2>
|
|
43
|
+
<p class="error-card-description">${e.description}</p>
|
|
44
|
+
|
|
45
|
+
${r.length > 0 ? s`
|
|
46
|
+
<ul class="error-card-details-list">
|
|
47
|
+
${r.map((t) => s`<li>${t}</li>`)}
|
|
48
|
+
</ul>
|
|
49
|
+
` : ""}
|
|
50
|
+
|
|
51
|
+
<div class="error-card-actions">
|
|
52
|
+
<slot></slot>
|
|
53
|
+
${this.retry ? s`
|
|
54
|
+
<button @click=${this.retry} class="error-card-button">
|
|
55
|
+
Retry
|
|
56
|
+
</button>
|
|
57
|
+
` : ""}
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
l(o, "styles", b`
|
|
64
|
+
:host {
|
|
65
|
+
display: flex;
|
|
66
|
+
flex-direction: column;
|
|
67
|
+
align-items: center;
|
|
68
|
+
justify-content: center;
|
|
69
|
+
height: 100dvh;
|
|
70
|
+
margin: 20px;
|
|
71
|
+
--card-bg: #ffffff;
|
|
72
|
+
--card-border: #e5e7eb;
|
|
73
|
+
--text-primary: #1f2937;
|
|
74
|
+
--text-secondary: #4b5563;
|
|
75
|
+
--error-icon-color: #ef4444;
|
|
76
|
+
--button-bg: #f3f4f6;
|
|
77
|
+
--button-text: #1f2937;
|
|
78
|
+
--button-hover-bg: #e5e7eb;
|
|
79
|
+
--list-text: #6b7280;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* Dark mode styles */
|
|
83
|
+
html.dark :host {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
align-items: center;
|
|
87
|
+
justify-content: center;
|
|
88
|
+
height: 100dvh;
|
|
89
|
+
margin: 20px;
|
|
90
|
+
--card-bg: #1f2937;
|
|
91
|
+
--card-border: #374151;
|
|
92
|
+
--text-primary: #f9fafb;
|
|
93
|
+
--text-secondary: #d1d5db;
|
|
94
|
+
--error-icon-color: #f87171;
|
|
95
|
+
--button-bg: #374151;
|
|
96
|
+
--button-text: #e5e7eb;
|
|
97
|
+
--button-hover-bg: #4b5563;
|
|
98
|
+
--list-text: #9ca3af;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.error-card-container {
|
|
102
|
+
background-color: var(--card-bg);
|
|
103
|
+
color: var(--text-primary);
|
|
104
|
+
border-radius: 5px; /* rounded-2xl */
|
|
105
|
+
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* subtle shadow */
|
|
106
|
+
padding: 1.5rem; /* p-6 */
|
|
107
|
+
border: 1px solid var(--card-border);
|
|
108
|
+
display: flex;
|
|
109
|
+
height: 100%;
|
|
110
|
+
width: 100%;
|
|
111
|
+
flex-direction: column;
|
|
112
|
+
align-items: center;
|
|
113
|
+
text-align: center;
|
|
114
|
+
gap: 1rem; /* space-y-4 */
|
|
115
|
+
animation: fade-slide-in 200ms ease-out forwards;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.error-card-icon {
|
|
119
|
+
color: var(--error-icon-color);
|
|
120
|
+
width: 3rem; /* w-12 */
|
|
121
|
+
height: 3rem; /* h-12 */
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.error-card-title {
|
|
125
|
+
font-size: 1.25rem; /* text-xl */
|
|
126
|
+
font-weight: 600; /* font-semibold */
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.error-card-description {
|
|
130
|
+
color: var(--text-secondary);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.error-card-details-list {
|
|
134
|
+
list-style: disc;
|
|
135
|
+
list-style-position: inside;
|
|
136
|
+
font-size: 0.875rem; /* text-sm */
|
|
137
|
+
color: var(--list-text);
|
|
138
|
+
text-align: left;
|
|
139
|
+
width: 100%;
|
|
140
|
+
max-width: 16rem; /* max-w-xs */
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.error-card-actions {
|
|
144
|
+
display: flex;
|
|
145
|
+
justify-content: center;
|
|
146
|
+
gap: 1rem; /* gap-4 */
|
|
147
|
+
padding-top: 0.5rem; /* pt-2 */
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.error-card-button {
|
|
151
|
+
padding: 0.5rem 1rem; /* px-4 py-2 */
|
|
152
|
+
background-color: var(--button-bg);
|
|
153
|
+
color: var(--button-text);
|
|
154
|
+
border-radius: 0.375rem; /* rounded-md */
|
|
155
|
+
transition: background-color 150ms ease-in-out; /* transition-colors */
|
|
156
|
+
cursor: pointer;
|
|
157
|
+
border: none;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.error-card-button:hover {
|
|
161
|
+
background-color: var(--button-hover-bg);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@keyframes fade-slide-in {
|
|
165
|
+
from {
|
|
166
|
+
opacity: 0;
|
|
167
|
+
transform: translateY(20px);
|
|
168
|
+
}
|
|
169
|
+
to {
|
|
170
|
+
opacity: 1;
|
|
171
|
+
transform: translateY(0);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
`);
|
|
175
|
+
l(o, "_errorMap", /* @__PURE__ */ new Map());
|
|
176
|
+
l(o, "defaultErrorConfigs", {
|
|
177
|
+
"generic-error": {
|
|
178
|
+
icon: "",
|
|
179
|
+
title: "An Unexpected Error Occurred",
|
|
180
|
+
description: "We're sorry, something went wrong. Please try again."
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
d([
|
|
184
|
+
p({ type: Object })
|
|
185
|
+
], o.prototype, "error", 2);
|
|
186
|
+
d([
|
|
187
|
+
p({ type: Function })
|
|
188
|
+
], o.prototype, "retry", 2);
|
|
189
|
+
o = d([
|
|
190
|
+
x("error-card")
|
|
191
|
+
], o);
|
|
192
|
+
export {
|
|
193
|
+
w as ApiError,
|
|
194
|
+
o as ErrorCard
|
|
195
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { i as b, x as h, a as m, n as p } from "./property-jKFNMQpR.js";
|
|
2
|
+
import { r as l } from "./state-CLlTRyl1.js";
|
|
3
|
+
import { t as u } from "./custom-element-ttkHUa8w.js";
|
|
4
|
+
var d = Object.defineProperty, f = Object.getOwnPropertyDescriptor, v = (e, t, s) => t in e ? d(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, i = (e, t, s, a) => {
|
|
5
|
+
for (var o = a > 1 ? void 0 : a ? f(t, s) : t, n = e.length - 1, c; n >= 0; n--)
|
|
6
|
+
(c = e[n]) && (o = (a ? c(t, s, o) : c(o)) || o);
|
|
7
|
+
return a && o && d(t, s, o), o;
|
|
8
|
+
}, g = (e, t, s) => v(e, t + "", s);
|
|
9
|
+
let r = class extends b {
|
|
10
|
+
stateClass = "empty";
|
|
11
|
+
connectedCallback() {
|
|
12
|
+
super.connectedCallback(), this.addEventListener("field-state", this.onFieldState);
|
|
13
|
+
}
|
|
14
|
+
disconnectedCallback() {
|
|
15
|
+
this.removeEventListener("field-state", this.onFieldState), super.disconnectedCallback();
|
|
16
|
+
}
|
|
17
|
+
firstUpdated() {
|
|
18
|
+
this.name = this.title.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, "_").replace(/[^\w_]/g, ""), this.descriptionVisible = !1, this.dispatchState();
|
|
19
|
+
}
|
|
20
|
+
toggleDescription = () => {
|
|
21
|
+
this.descriptionVisible = !this.descriptionVisible;
|
|
22
|
+
};
|
|
23
|
+
onFieldState = (e) => {
|
|
24
|
+
e.stopPropagation(), this.stateClass = e.detail.state, this.feedback = e.detail.message ?? "", this.value = e.detail.value, this.stateClass !== "empty" && this.name && this.dispatchState();
|
|
25
|
+
};
|
|
26
|
+
dispatchState() {
|
|
27
|
+
this.dispatchEvent(
|
|
28
|
+
new CustomEvent("wrapper", {
|
|
29
|
+
detail: { name: this.title, state: this.stateClass, value: this.value },
|
|
30
|
+
bubbles: !0,
|
|
31
|
+
composed: !0
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const e = this.stateClass !== "empty" ? this.stateClass : "";
|
|
37
|
+
return h`
|
|
38
|
+
<div class="tile ${e}">
|
|
39
|
+
<header>
|
|
40
|
+
<label>${this.title}</label>
|
|
41
|
+
<button
|
|
42
|
+
class="help-btn"
|
|
43
|
+
aria-label="Help"
|
|
44
|
+
aria-expanded=${this.descriptionVisible}
|
|
45
|
+
?disabled=${!this.description}
|
|
46
|
+
@click=${this.toggleDescription}
|
|
47
|
+
>
|
|
48
|
+
?
|
|
49
|
+
</button>
|
|
50
|
+
</header>
|
|
51
|
+
<pre class="description ${this.descriptionVisible ? "show" : ""}">
|
|
52
|
+
${this.description}
|
|
53
|
+
</pre
|
|
54
|
+
>
|
|
55
|
+
|
|
56
|
+
<slot></slot>
|
|
57
|
+
|
|
58
|
+
<pre class="feedback ${this.stateClass}">${this.feedback}</pre>
|
|
59
|
+
</div>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
g(r, "styles", m`
|
|
64
|
+
:host {
|
|
65
|
+
display: block;
|
|
66
|
+
margin: 10px;
|
|
67
|
+
}
|
|
68
|
+
.tile {
|
|
69
|
+
position: relative;
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
gap: 0.5rem;
|
|
73
|
+
background: var(--ml-color-surface);
|
|
74
|
+
border: 1px solid var(--ml-color-border);
|
|
75
|
+
border-radius: var(--radius);
|
|
76
|
+
overflow: hidden;
|
|
77
|
+
padding: 1.5rem 2rem;
|
|
78
|
+
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
|
|
79
|
+
transition: box-shadow 0.2s ease;
|
|
80
|
+
}
|
|
81
|
+
.tile:hover {
|
|
82
|
+
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
|
|
83
|
+
}
|
|
84
|
+
.tile::before {
|
|
85
|
+
content: "";
|
|
86
|
+
position: absolute;
|
|
87
|
+
left: 0;
|
|
88
|
+
top: 0;
|
|
89
|
+
width: 6px;
|
|
90
|
+
height: 100%;
|
|
91
|
+
background: var(--ml-color-accent);
|
|
92
|
+
transition: background 0.2s ease;
|
|
93
|
+
}
|
|
94
|
+
.tile.success::before {
|
|
95
|
+
background: var(--ml-color-success);
|
|
96
|
+
}
|
|
97
|
+
.tile.error::before {
|
|
98
|
+
background: var(--ml-color-error);
|
|
99
|
+
}
|
|
100
|
+
header {
|
|
101
|
+
display: flex;
|
|
102
|
+
justify-content: space-between;
|
|
103
|
+
align-items: center;
|
|
104
|
+
gap: 0.25rem;
|
|
105
|
+
}
|
|
106
|
+
label {
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
font-size: 1rem;
|
|
109
|
+
color: var(--ml-color-primary);
|
|
110
|
+
}
|
|
111
|
+
.help-btn {
|
|
112
|
+
display: inline-flex;
|
|
113
|
+
align-items: center;
|
|
114
|
+
justify-content: center;
|
|
115
|
+
width: 28px;
|
|
116
|
+
height: 28px;
|
|
117
|
+
border: none;
|
|
118
|
+
border-radius: 50%;
|
|
119
|
+
background: var(--ml-color-accent);
|
|
120
|
+
color: #fff;
|
|
121
|
+
font-size: 1rem;
|
|
122
|
+
cursor: pointer;
|
|
123
|
+
transition: background 0.2s ease;
|
|
124
|
+
}
|
|
125
|
+
.help-btn:hover {
|
|
126
|
+
background: var(--ml-color-accent-h);
|
|
127
|
+
}
|
|
128
|
+
.help-btn:disabled {
|
|
129
|
+
background: var(--ml-color-secondary);
|
|
130
|
+
cursor: not-allowed;
|
|
131
|
+
}
|
|
132
|
+
.description {
|
|
133
|
+
display: none;
|
|
134
|
+
font-size: 0.875rem;
|
|
135
|
+
color: var(--ml-color-secondary);
|
|
136
|
+
}
|
|
137
|
+
.description.show {
|
|
138
|
+
display: block;
|
|
139
|
+
}
|
|
140
|
+
.feedback {
|
|
141
|
+
font-size: 0.8rem;
|
|
142
|
+
margin-top: 0.25rem;
|
|
143
|
+
}
|
|
144
|
+
.feedback.error {
|
|
145
|
+
color: var(--ml-color-error);
|
|
146
|
+
}
|
|
147
|
+
.feedback.success {
|
|
148
|
+
color: var(--ml-color-success);
|
|
149
|
+
}
|
|
150
|
+
`);
|
|
151
|
+
i([
|
|
152
|
+
p({ type: String })
|
|
153
|
+
], r.prototype, "title", 2);
|
|
154
|
+
i([
|
|
155
|
+
p({ type: String })
|
|
156
|
+
], r.prototype, "description", 2);
|
|
157
|
+
i([
|
|
158
|
+
l()
|
|
159
|
+
], r.prototype, "descriptionVisible", 2);
|
|
160
|
+
i([
|
|
161
|
+
l()
|
|
162
|
+
], r.prototype, "stateClass", 2);
|
|
163
|
+
i([
|
|
164
|
+
l()
|
|
165
|
+
], r.prototype, "feedback", 2);
|
|
166
|
+
i([
|
|
167
|
+
l()
|
|
168
|
+
], r.prototype, "value", 2);
|
|
169
|
+
i([
|
|
170
|
+
p({ type: String, reflect: !0 })
|
|
171
|
+
], r.prototype, "name", 2);
|
|
172
|
+
r = i([
|
|
173
|
+
u("field-wrapper")
|
|
174
|
+
], r);
|
|
175
|
+
export {
|
|
176
|
+
r as FieldWrapper
|
|
177
|
+
};
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { i as m, B as u, x as n, a as b, n as h } from "./property-jKFNMQpR.js";
|
|
2
|
+
import { r as f } from "./state-CLlTRyl1.js";
|
|
3
|
+
import { t as p } from "./custom-element-ttkHUa8w.js";
|
|
4
|
+
var d = Object.defineProperty, g = Object.getOwnPropertyDescriptor, v = (r, e, o) => e in r ? d(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o, c = (r, e, o, t) => {
|
|
5
|
+
for (var l = t > 1 ? void 0 : t ? g(e, o) : e, a = r.length - 1, i; a >= 0; a--)
|
|
6
|
+
(i = r[a]) && (l = (t ? i(e, o, l) : i(l)) || l);
|
|
7
|
+
return t && l && d(e, o, l), l;
|
|
8
|
+
}, y = (r, e, o) => v(r, e + "", o);
|
|
9
|
+
let s = class extends m {
|
|
10
|
+
inputs = {};
|
|
11
|
+
label = "Predict";
|
|
12
|
+
_mo;
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
super.connectedCallback(), this.addEventListener("wrapper", this._onWrapperChange);
|
|
15
|
+
const r = () => {
|
|
16
|
+
document.documentElement.classList.contains("dark") ? this.setAttribute("theme", "dark") : this.removeAttribute("theme");
|
|
17
|
+
};
|
|
18
|
+
r(), this._mo = new MutationObserver(r), this._mo.observe(document.documentElement, {
|
|
19
|
+
attributes: !0,
|
|
20
|
+
attributeFilter: ["class"]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
disconnectedCallback() {
|
|
24
|
+
this.removeEventListener("wrapper", this._onWrapperChange), this._mo?.disconnect(), super.disconnectedCallback();
|
|
25
|
+
}
|
|
26
|
+
_onWrapperChange(r) {
|
|
27
|
+
this.inputs[r.detail.name] = [r.detail.value, r.detail.state], this.requestUpdate();
|
|
28
|
+
}
|
|
29
|
+
get _disableButton() {
|
|
30
|
+
const r = Object.values(this.inputs).every(
|
|
31
|
+
([, t]) => t === "success"
|
|
32
|
+
), e = this.querySelectorAll("field-wrapper").length, o = Object.keys(this.inputs).length;
|
|
33
|
+
return !(r && e === o);
|
|
34
|
+
}
|
|
35
|
+
async _onSubmit() {
|
|
36
|
+
const r = Object.fromEntries(
|
|
37
|
+
Object.entries(this.inputs).map(([e, [o]]) => [
|
|
38
|
+
e,
|
|
39
|
+
o instanceof Date ? o.toISOString() : o
|
|
40
|
+
])
|
|
41
|
+
);
|
|
42
|
+
this._hideError();
|
|
43
|
+
try {
|
|
44
|
+
const e = await this.modelService.submit(r);
|
|
45
|
+
if (e === void 0)
|
|
46
|
+
throw new Error(
|
|
47
|
+
"La respuesta del servicio no es válida o llegó vacía."
|
|
48
|
+
);
|
|
49
|
+
this.dispatchEvent(
|
|
50
|
+
new CustomEvent("ml-submit", {
|
|
51
|
+
detail: { inputs: r, response: e },
|
|
52
|
+
bubbles: !0,
|
|
53
|
+
composed: !0
|
|
54
|
+
})
|
|
55
|
+
);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
this._clearSlot(), this._showError(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
_clearSlot() {
|
|
61
|
+
const r = document.querySelector('div[slot="report"]');
|
|
62
|
+
r && (r.innerHTML = "");
|
|
63
|
+
}
|
|
64
|
+
_showError(r) {
|
|
65
|
+
const e = this.shadowRoot?.querySelector(
|
|
66
|
+
"div[id='results-area']"
|
|
67
|
+
);
|
|
68
|
+
e && e.classList.remove("scroll-y");
|
|
69
|
+
const o = this.querySelector("div[slot='report']"), t = this.querySelector("div[slot='error']");
|
|
70
|
+
o && (o.style.display = "none"), t && (t.style.display = "block"), t && (t.innerHTML = "", u(
|
|
71
|
+
n`<error-card .error=${r.message}></error-card>`,
|
|
72
|
+
t
|
|
73
|
+
));
|
|
74
|
+
}
|
|
75
|
+
_hideError() {
|
|
76
|
+
const r = this.shadowRoot?.querySelector(
|
|
77
|
+
"div[id='results-area']"
|
|
78
|
+
);
|
|
79
|
+
r && r.classList.add("scroll-y");
|
|
80
|
+
const e = this.querySelector("div[slot='report']"), o = this.querySelector("div[slot='error']");
|
|
81
|
+
e && (e.style.display = "block"), o && (o.style.display = "none");
|
|
82
|
+
}
|
|
83
|
+
render() {
|
|
84
|
+
return n`
|
|
85
|
+
<section class="left-section">
|
|
86
|
+
<form
|
|
87
|
+
id="dynamic-form"
|
|
88
|
+
method="post"
|
|
89
|
+
enctype="multipart/form-data"
|
|
90
|
+
style="display:flex;flex-direction:column;height:100%"
|
|
91
|
+
>
|
|
92
|
+
<div class="form-inputs scroll-y">
|
|
93
|
+
<div class="sticky-header"><h2>Form</h2></div>
|
|
94
|
+
<slot name="inputs"></slot>
|
|
95
|
+
</div>
|
|
96
|
+
<div class="form-actions">
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
class="predict-button"
|
|
100
|
+
@click=${this._onSubmit}
|
|
101
|
+
?disabled=${this._disableButton}
|
|
102
|
+
>
|
|
103
|
+
${this.label}
|
|
104
|
+
</button>
|
|
105
|
+
</div>
|
|
106
|
+
</form>
|
|
107
|
+
</section>
|
|
108
|
+
|
|
109
|
+
<section class="right-section">
|
|
110
|
+
<div id="results-area" class="results-area scroll-y">
|
|
111
|
+
<div class="sticky-header"><h2>Report</h2></div>
|
|
112
|
+
<slot name="report"></slot>
|
|
113
|
+
<slot name="error"></slot>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</section>
|
|
117
|
+
`;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
y(s, "styles", b`
|
|
121
|
+
/* Light defaults (tokens live INSIDE the component) */
|
|
122
|
+
:host {
|
|
123
|
+
color-scheme: light;
|
|
124
|
+
|
|
125
|
+
/* --- Design tokens (light) --- */
|
|
126
|
+
--ml-color-bg: #f5f7fa;
|
|
127
|
+
--ml-color-surface: #ffffff;
|
|
128
|
+
--ml-color-primary: #0f172a; /* primary text */
|
|
129
|
+
--ml-color-secondary: #475569; /* secondary text */
|
|
130
|
+
--ml-color-accent: #1e40af; /* brand / CTA */
|
|
131
|
+
--ml-color-accent-h: #1d4ed8; /* brand hover */
|
|
132
|
+
--ml-color-accent-bg: rgba(29, 78, 216, 0.10);
|
|
133
|
+
--ml-color-bg-light: #f5f7fa;
|
|
134
|
+
--ml-color-bg-panel: #ffffff;
|
|
135
|
+
--ml-color-bg-header: rgba(255, 255, 255, 0.60); /* frosted header overlay */
|
|
136
|
+
--ml-color-border: #e2e8f0;
|
|
137
|
+
--ml-color-hv-light: #c7d2fe;
|
|
138
|
+
--ml-color-shadow: rgba(0, 0, 0, 0.04);
|
|
139
|
+
--ml-color-hv-shadow: rgba(0, 0, 0, 0.06);
|
|
140
|
+
--ml-color-error: #dc2626;
|
|
141
|
+
--ml-color-success: #059669;
|
|
142
|
+
--ml-color-focus-ring: rgba(29, 78, 216, 0.45);
|
|
143
|
+
|
|
144
|
+
--radius: 12px;
|
|
145
|
+
--skew: -12deg;
|
|
146
|
+
--unit-w: 1rem;
|
|
147
|
+
--blur-header: 3px;
|
|
148
|
+
|
|
149
|
+
/* --- Host box/layout --- */
|
|
150
|
+
display: flex;
|
|
151
|
+
flex-grow: 1;
|
|
152
|
+
overflow: hidden;
|
|
153
|
+
margin: 0;
|
|
154
|
+
background: var(--ml-color-bg); /* FIX: was --ml-color-primary */
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* Dark overrides via attribute (cross-browser, no :host-context) */
|
|
158
|
+
:host([theme="dark"]) {
|
|
159
|
+
color-scheme: dark;
|
|
160
|
+
|
|
161
|
+
/* Surfaces & text */
|
|
162
|
+
--ml-color-bg: #020617; /* app background */
|
|
163
|
+
--ml-color-surface: #0f172a; /* cards/panels */
|
|
164
|
+
--ml-color-primary: #e5e7eb; /* primary text */
|
|
165
|
+
--ml-color-secondary: #94a3b8; /* secondary text */
|
|
166
|
+
|
|
167
|
+
/* Brand & interaction */
|
|
168
|
+
--ml-color-accent: #1d4ed8;
|
|
169
|
+
--ml-color-accent-h: #60a5fa;
|
|
170
|
+
--ml-color-accent-bg: rgba(29, 78, 216, 0.22);
|
|
171
|
+
|
|
172
|
+
/* Background variants */
|
|
173
|
+
--ml-color-bg-light: #0b1220;
|
|
174
|
+
--ml-color-bg-panel: #0f172a;
|
|
175
|
+
--ml-color-bg-header: rgba(255, 255, 255, 0.06);
|
|
176
|
+
|
|
177
|
+
/* Strokes, highlights, elevation */
|
|
178
|
+
--ml-color-border: #334155;
|
|
179
|
+
--ml-color-hv-light: #1e3a8a;
|
|
180
|
+
--ml-color-shadow: rgba(0, 0, 0, 0.60);
|
|
181
|
+
--ml-color-hv-shadow: rgba(0, 0, 0, 0.80);
|
|
182
|
+
|
|
183
|
+
/* Status */
|
|
184
|
+
--ml-color-error: #ef4444;
|
|
185
|
+
--ml-color-success: #10b981;
|
|
186
|
+
|
|
187
|
+
/* Focus */
|
|
188
|
+
--ml-color-focus-ring: rgba(96, 165, 250, 0.55);
|
|
189
|
+
|
|
190
|
+
/* Geometry */
|
|
191
|
+
--blur-header: 6px;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Ensure flex children can actually scroll */
|
|
195
|
+
.left-section,
|
|
196
|
+
.right-section,
|
|
197
|
+
.form-inputs,
|
|
198
|
+
.results-area {
|
|
199
|
+
min-height: 0;
|
|
200
|
+
min-width: 0;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* Shared scrolling container */
|
|
204
|
+
.scroll-y {
|
|
205
|
+
overflow-y: auto;
|
|
206
|
+
overflow-x: hidden;
|
|
207
|
+
|
|
208
|
+
/* Firefox scrollbar */
|
|
209
|
+
scrollbar-color: #cbd5e1 transparent;
|
|
210
|
+
}
|
|
211
|
+
:host([theme="dark"]) .scroll-y {
|
|
212
|
+
scrollbar-color: #475569 transparent;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* WebKit scrollbar */
|
|
216
|
+
.scroll-y::-webkit-scrollbar { width: 8px; }
|
|
217
|
+
.scroll-y::-webkit-scrollbar-thumb {
|
|
218
|
+
background: #cbd5e1;
|
|
219
|
+
border-radius: 4px;
|
|
220
|
+
}
|
|
221
|
+
:host([theme="dark"]) .scroll-y::-webkit-scrollbar-thumb {
|
|
222
|
+
background: #475569;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/* Sticky header */
|
|
226
|
+
.sticky-header {
|
|
227
|
+
position: sticky;
|
|
228
|
+
top: 0;
|
|
229
|
+
z-index: 10;
|
|
230
|
+
backdrop-filter: blur(var(--blur-header));
|
|
231
|
+
-webkit-backdrop-filter: blur(var(--blur-header));
|
|
232
|
+
background: var(--ml-color-bg-header);
|
|
233
|
+
padding: 0.5rem 2rem;
|
|
234
|
+
border-bottom: 1px solid var(--ml-color-border);
|
|
235
|
+
}
|
|
236
|
+
.sticky-header h2 {
|
|
237
|
+
margin: 0;
|
|
238
|
+
font-size: 1rem;
|
|
239
|
+
font-weight: 600;
|
|
240
|
+
color: var(--ml-color-primary);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/* Left / Right panes */
|
|
244
|
+
.left-section {
|
|
245
|
+
resize: horizontal;
|
|
246
|
+
overflow: hidden;
|
|
247
|
+
min-width: 22rem;
|
|
248
|
+
max-width: 48rem;
|
|
249
|
+
background: var(--ml-color-bg-panel);
|
|
250
|
+
border-right: 1px solid var(--ml-color-border);
|
|
251
|
+
display: flex;
|
|
252
|
+
flex-direction: column;
|
|
253
|
+
border-radius: 0; /* keep square; adjust if you need rounded panels */
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.right-section {
|
|
257
|
+
flex: 1 1 0%;
|
|
258
|
+
min-width: 24rem;
|
|
259
|
+
overflow: hidden;
|
|
260
|
+
background: var(--ml-color-bg-panel);
|
|
261
|
+
border-left: 1px solid var(--ml-color-border);
|
|
262
|
+
display: flex;
|
|
263
|
+
flex-direction: column;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* Form regions */
|
|
267
|
+
.form-inputs { flex: 1 1 auto; }
|
|
268
|
+
.form-actions {
|
|
269
|
+
padding: 1rem 2rem;
|
|
270
|
+
border-top: 1px solid var(--ml-color-border);
|
|
271
|
+
background: var(--ml-color-bg-light); /* tokenized (was hardcoded) */
|
|
272
|
+
align-items: center;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/* Results region */
|
|
276
|
+
.results-area { flex: 1 1 auto; }
|
|
277
|
+
|
|
278
|
+
/* Buttons */
|
|
279
|
+
button {
|
|
280
|
+
width: 100%;
|
|
281
|
+
padding: 0.75rem;
|
|
282
|
+
background-color: var(--ml-color-accent);
|
|
283
|
+
color: #ffffff;
|
|
284
|
+
border: none;
|
|
285
|
+
border-radius: var(--radius);
|
|
286
|
+
cursor: pointer;
|
|
287
|
+
font-size: 1rem;
|
|
288
|
+
transition:
|
|
289
|
+
background-color 0.2s ease-in-out,
|
|
290
|
+
transform 0.2s ease-in-out,
|
|
291
|
+
box-shadow 0.2s ease-in-out;
|
|
292
|
+
transform: skew(var(--skew));
|
|
293
|
+
will-change: transform;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
button:hover:not([disabled]) {
|
|
297
|
+
background-color: var(--ml-color-accent-h);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
button[disabled] {
|
|
301
|
+
opacity: 0.6;
|
|
302
|
+
cursor: not-allowed;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
button:active:not([disabled]) {
|
|
306
|
+
transform: scale(0.95) skew(var(--skew));
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
button:focus-visible {
|
|
310
|
+
outline: none;
|
|
311
|
+
box-shadow: 0 0 0 3px var(--ml-color-focus-ring);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* Respect reduced motion */
|
|
315
|
+
@media (prefers-reduced-motion: reduce) {
|
|
316
|
+
button { transition: background-color 0.2s ease-in-out; }
|
|
317
|
+
button:active:not([disabled]) { transform: skew(var(--skew)); }
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
`);
|
|
321
|
+
c([
|
|
322
|
+
f()
|
|
323
|
+
], s.prototype, "inputs", 2);
|
|
324
|
+
c([
|
|
325
|
+
h({ attribute: !1 })
|
|
326
|
+
], s.prototype, "modelService", 2);
|
|
327
|
+
s = c([
|
|
328
|
+
p("ml-layout")
|
|
329
|
+
], s);
|
|
330
|
+
export {
|
|
331
|
+
s as MLLayout
|
|
332
|
+
};
|