@effect-app/vue-components 0.14.3 → 0.14.5
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/dist/vue-components.es10.js +171 -123
- package/dist/vue-components.es13.js +1 -1
- package/dist/vue-components.es22.js +1 -1
- package/dist/vue-components.es23.js +2 -90
- package/dist/vue-components.es24.js +90 -11
- package/dist/vue-components.es25.js +11 -2
- package/dist/vue-components.es26.js +1 -1
- package/dist/vue-components.es4.js +1 -1
- package/dist/vue-components.es7.js +17 -36
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaArray.vue +8 -32
- package/src/components/OmegaForm/OmegaFormStuff.ts +74 -6
|
@@ -1,200 +1,248 @@
|
|
|
1
|
-
import { S as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
1
|
+
import { S as n, Option as f, pipe as O } from "effect-app";
|
|
2
|
+
import { useIntl as A } from "./vue-components.es3.js";
|
|
3
|
+
const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), y = (e) => !e || !n.AST.isUnion(e) ? !1 : e.types.find((i) => i._tag === "UndefinedKeyword") ? "undefined" : e.types.find((i) => i === n.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: i = "", property: t, propertySignatures: o }, l = {}) => {
|
|
4
|
+
if (t && t._tag === "Transformation")
|
|
5
5
|
return m({
|
|
6
6
|
parent: i,
|
|
7
7
|
meta: e,
|
|
8
|
-
property:
|
|
8
|
+
property: t.from
|
|
9
9
|
});
|
|
10
|
-
if (
|
|
10
|
+
if (t?._tag === "TypeLiteral" && "propertySignatures" in t)
|
|
11
11
|
return m({
|
|
12
12
|
meta: e,
|
|
13
|
-
propertySignatures:
|
|
13
|
+
propertySignatures: t.propertySignatures
|
|
14
14
|
});
|
|
15
|
-
if (
|
|
16
|
-
for (const
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
(
|
|
15
|
+
if (o) {
|
|
16
|
+
for (const r of o) {
|
|
17
|
+
const u = i ? `${i}.${r.name.toString()}` : r.name.toString(), s = y(r.type), p = !s, b = r.type;
|
|
18
|
+
if (n.AST.isUnion(r.type)) {
|
|
19
|
+
const d = r.type.types.filter(
|
|
20
|
+
(a) => a._tag !== "UndefinedKeyword" && a !== n.Null.ast
|
|
21
21
|
);
|
|
22
|
-
if (
|
|
23
|
-
(
|
|
22
|
+
if (d.some(
|
|
23
|
+
(a) => "propertySignatures" in a
|
|
24
24
|
)) {
|
|
25
|
-
const
|
|
26
|
-
parent:
|
|
27
|
-
property:
|
|
28
|
-
meta: { required:
|
|
25
|
+
const a = m({
|
|
26
|
+
parent: u,
|
|
27
|
+
property: r.type,
|
|
28
|
+
meta: { required: p, nullableOrUndefined: s }
|
|
29
29
|
});
|
|
30
|
-
u
|
|
31
|
-
for (const
|
|
32
|
-
"propertySignatures" in
|
|
33
|
-
|
|
30
|
+
l[u] = a;
|
|
31
|
+
for (const g of d)
|
|
32
|
+
"propertySignatures" in g && Object.assign(
|
|
33
|
+
l,
|
|
34
34
|
m({
|
|
35
|
-
parent:
|
|
36
|
-
propertySignatures:
|
|
37
|
-
meta: { required:
|
|
35
|
+
parent: u,
|
|
36
|
+
propertySignatures: g.propertySignatures,
|
|
37
|
+
meta: { required: p, nullableOrUndefined: s }
|
|
38
38
|
})
|
|
39
39
|
);
|
|
40
40
|
} else {
|
|
41
|
-
const
|
|
42
|
-
parent:
|
|
43
|
-
property:
|
|
44
|
-
meta: { required:
|
|
41
|
+
const a = m({
|
|
42
|
+
parent: u,
|
|
43
|
+
property: r.type,
|
|
44
|
+
meta: { required: p, nullableOrUndefined: s }
|
|
45
45
|
});
|
|
46
|
-
u
|
|
46
|
+
l[u] = a;
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
if ("propertySignatures" in
|
|
49
|
+
if ("propertySignatures" in b)
|
|
50
50
|
Object.assign(
|
|
51
|
-
|
|
51
|
+
l,
|
|
52
52
|
m({
|
|
53
|
-
parent:
|
|
54
|
-
propertySignatures:
|
|
55
|
-
meta: { required:
|
|
53
|
+
parent: u,
|
|
54
|
+
propertySignatures: b.propertySignatures,
|
|
55
|
+
meta: { required: p, nullableOrUndefined: s }
|
|
56
56
|
})
|
|
57
57
|
);
|
|
58
|
+
else if (n.AST.isTupleType(r.type))
|
|
59
|
+
if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
|
|
60
|
+
const S = r.type.rest[0].type;
|
|
61
|
+
if (S._tag === "TypeLiteral" && "propertySignatures" in S)
|
|
62
|
+
for (const a of S.propertySignatures) {
|
|
63
|
+
const g = `${u}.${a.name.toString()}`;
|
|
64
|
+
if (n.AST.isTupleType(a.type) && a.type.rest.length > 0) {
|
|
65
|
+
const c = a.type.rest[0].type;
|
|
66
|
+
if (c._tag === "TypeLiteral" && "propertySignatures" in c)
|
|
67
|
+
for (const T of c.propertySignatures) {
|
|
68
|
+
const h = `${g}.${T.name.toString()}`, x = m({
|
|
69
|
+
parent: h,
|
|
70
|
+
property: T.type,
|
|
71
|
+
meta: {
|
|
72
|
+
required: !y(T.type),
|
|
73
|
+
nullableOrUndefined: y(T.type)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
l[h] = x;
|
|
77
|
+
}
|
|
78
|
+
else
|
|
79
|
+
l[g] = {
|
|
80
|
+
type: "multiple",
|
|
81
|
+
members: a.type.elements,
|
|
82
|
+
rest: a.type.rest,
|
|
83
|
+
required: !y(a.type),
|
|
84
|
+
nullableOrUndefined: y(a.type)
|
|
85
|
+
};
|
|
86
|
+
} else {
|
|
87
|
+
const c = m({
|
|
88
|
+
parent: g,
|
|
89
|
+
property: a.type,
|
|
90
|
+
meta: {
|
|
91
|
+
required: !y(a.type),
|
|
92
|
+
nullableOrUndefined: y(a.type)
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
l[g] = c;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} else
|
|
99
|
+
l[u] = {
|
|
100
|
+
type: "multiple",
|
|
101
|
+
members: r.type.elements,
|
|
102
|
+
rest: r.type.rest,
|
|
103
|
+
required: p,
|
|
104
|
+
nullableOrUndefined: s
|
|
105
|
+
};
|
|
58
106
|
else {
|
|
59
|
-
const
|
|
60
|
-
parent:
|
|
61
|
-
property:
|
|
62
|
-
meta: { required:
|
|
107
|
+
const d = m({
|
|
108
|
+
parent: u,
|
|
109
|
+
property: r.type,
|
|
110
|
+
meta: { required: p, nullableOrUndefined: s }
|
|
63
111
|
});
|
|
64
|
-
u
|
|
112
|
+
l[u] = d;
|
|
65
113
|
}
|
|
66
114
|
}
|
|
67
|
-
return
|
|
115
|
+
return l;
|
|
68
116
|
}
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
if (Object.hasOwnProperty.call(e, "required") || (e.required = !
|
|
72
|
-
const
|
|
73
|
-
(
|
|
117
|
+
if (t) {
|
|
118
|
+
const r = L(t);
|
|
119
|
+
if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
|
|
120
|
+
const s = t.types.find(
|
|
121
|
+
(p) => p._tag !== "UndefinedKeyword" && p !== n.Null.ast
|
|
74
122
|
);
|
|
75
|
-
return "propertySignatures" in
|
|
76
|
-
propertySignatures:
|
|
123
|
+
return "propertySignatures" in s ? m({
|
|
124
|
+
propertySignatures: s.propertySignatures,
|
|
77
125
|
parent: i,
|
|
78
126
|
meta: e
|
|
79
|
-
}) :
|
|
127
|
+
}) : t.types.every(n.AST.isLiteral) ? {
|
|
80
128
|
...e,
|
|
81
129
|
type: "select",
|
|
82
|
-
members:
|
|
130
|
+
members: t.types.map((p) => p.literal)
|
|
83
131
|
} : {
|
|
84
132
|
...e,
|
|
85
133
|
...m({
|
|
86
134
|
parent: i,
|
|
87
135
|
meta: e,
|
|
88
|
-
property:
|
|
136
|
+
property: s
|
|
89
137
|
})
|
|
90
138
|
};
|
|
91
139
|
}
|
|
92
|
-
if (
|
|
140
|
+
if (n.AST.isTupleType(t))
|
|
93
141
|
return {
|
|
94
142
|
...e,
|
|
95
143
|
type: "multiple",
|
|
96
|
-
members:
|
|
97
|
-
rest:
|
|
144
|
+
members: t.elements,
|
|
145
|
+
rest: t.rest
|
|
98
146
|
};
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
).pipe(
|
|
103
|
-
return e = { ...e, ...
|
|
147
|
+
const u = n.AST.getAnnotation(
|
|
148
|
+
t,
|
|
149
|
+
n.AST.JSONSchemaAnnotationId
|
|
150
|
+
).pipe(f.getOrElse(() => ({})));
|
|
151
|
+
return e = { ...e, ...u }, "from" in t ? m({
|
|
104
152
|
parent: i,
|
|
105
153
|
meta: e,
|
|
106
|
-
property:
|
|
107
|
-
}) : (e.type =
|
|
108
|
-
|
|
109
|
-
|
|
154
|
+
property: t.from
|
|
155
|
+
}) : (e.type = n.AST.getAnnotation(
|
|
156
|
+
t,
|
|
157
|
+
n.AST.TitleAnnotationId
|
|
110
158
|
).pipe(
|
|
111
|
-
|
|
159
|
+
f.getOrElse(() => "unknown")
|
|
112
160
|
), e);
|
|
113
161
|
}
|
|
114
|
-
return
|
|
115
|
-
},
|
|
116
|
-
const i = e.ast,
|
|
162
|
+
return l;
|
|
163
|
+
}, v = (e) => {
|
|
164
|
+
const i = e.ast, t = {};
|
|
117
165
|
if (i._tag === "Transformation" || i._tag === "Refinement")
|
|
118
|
-
return
|
|
166
|
+
return v(n.make(i.from));
|
|
119
167
|
if ("propertySignatures" in i) {
|
|
120
|
-
const
|
|
168
|
+
const o = m({
|
|
121
169
|
propertySignatures: i.propertySignatures
|
|
122
170
|
});
|
|
123
|
-
if (Object.values(
|
|
124
|
-
return
|
|
125
|
-
const
|
|
126
|
-
for (const
|
|
127
|
-
const
|
|
128
|
-
s
|
|
171
|
+
if (Object.values(o).every((r) => r && "type" in r))
|
|
172
|
+
return o;
|
|
173
|
+
const l = (r, u = "") => {
|
|
174
|
+
for (const s in r) {
|
|
175
|
+
const p = u ? `${u}.${s}` : s;
|
|
176
|
+
r[s] && typeof r[s] == "object" && "type" in r[s] ? t[p] = r[s] : r[s] && typeof r[s] == "object" && l(r[s], p);
|
|
129
177
|
}
|
|
130
178
|
};
|
|
131
|
-
|
|
179
|
+
l(o);
|
|
132
180
|
}
|
|
133
|
-
return
|
|
134
|
-
},
|
|
135
|
-
const i =
|
|
181
|
+
return t;
|
|
182
|
+
}, N = (e) => n.extend(e, n.Struct({})), _ = (e) => {
|
|
183
|
+
const i = v(e), t = O(
|
|
136
184
|
e.ast,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
({ items:
|
|
185
|
+
f.liftPredicate((o) => o._tag === "Refinement" && "filter" in o),
|
|
186
|
+
f.flatMap((o) => n.AST.getJSONSchemaAnnotation(o)),
|
|
187
|
+
f.filter((o) => "items" in o),
|
|
188
|
+
f.filterMap(
|
|
189
|
+
({ items: o }) => n.decodeUnknownOption(M)(o)
|
|
142
190
|
),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
(
|
|
146
|
-
items:
|
|
147
|
-
message:
|
|
191
|
+
f.zipWith(
|
|
192
|
+
n.AST.getMessageAnnotation(e.ast),
|
|
193
|
+
(o, l) => ({
|
|
194
|
+
items: o,
|
|
195
|
+
message: l("")
|
|
148
196
|
})
|
|
149
197
|
),
|
|
150
|
-
|
|
198
|
+
f.getOrUndefined
|
|
151
199
|
);
|
|
152
|
-
return { schema: e, meta: i, filterItems:
|
|
153
|
-
},
|
|
154
|
-
const { trans: i } =
|
|
155
|
-
let
|
|
200
|
+
return { schema: e, meta: i, filterItems: t };
|
|
201
|
+
}, k = (e) => {
|
|
202
|
+
const { trans: i } = A();
|
|
203
|
+
let t;
|
|
156
204
|
switch (e.type) {
|
|
157
205
|
case "string":
|
|
158
|
-
|
|
206
|
+
t = n.String.annotations({
|
|
159
207
|
message: () => i("validation.empty")
|
|
160
|
-
}), e.format === "email" && (
|
|
161
|
-
|
|
162
|
-
|
|
208
|
+
}), e.format === "email" && (t = n.compose(
|
|
209
|
+
t,
|
|
210
|
+
n.Email.annotations({
|
|
163
211
|
message: () => i("validation.email.invalid")
|
|
164
212
|
})
|
|
165
|
-
)), e.required &&
|
|
213
|
+
)), e.required && t.annotations({
|
|
166
214
|
message: () => i("validation.empty")
|
|
167
|
-
}), e.maxLength && (
|
|
215
|
+
}), e.maxLength && (t = t.pipe(n.maxLength(e.maxLength)).annotations({
|
|
168
216
|
message: () => i("validation.string.maxLength", {
|
|
169
217
|
maxLength: e.maxLength
|
|
170
218
|
})
|
|
171
|
-
})), e.minLength && (
|
|
219
|
+
})), e.minLength && (t = t.pipe(n.minLength(e.minLength)).annotations({
|
|
172
220
|
message: () => i("validation.string.minLength", {
|
|
173
221
|
minLength: e.minLength
|
|
174
222
|
})
|
|
175
223
|
}));
|
|
176
224
|
break;
|
|
177
225
|
case "number":
|
|
178
|
-
|
|
226
|
+
t = n.Number.annotations({
|
|
179
227
|
message: () => i("validation.empty")
|
|
180
|
-
}), e.required &&
|
|
228
|
+
}), e.required && t.annotations({
|
|
181
229
|
message: () => i("validation.empty")
|
|
182
|
-
}), e.minimum && (
|
|
230
|
+
}), e.minimum && (t = t.pipe(n.greaterThanOrEqualTo(e.minimum)).annotations({
|
|
183
231
|
message: () => i("validation.number.min", {
|
|
184
232
|
minimum: e.minimum,
|
|
185
233
|
isExclusive: !0
|
|
186
234
|
})
|
|
187
|
-
})), e.maximum && (
|
|
235
|
+
})), e.maximum && (t = t.pipe(n.lessThanOrEqualTo(e.maximum)).annotations({
|
|
188
236
|
message: () => i("validation.number.max", {
|
|
189
237
|
maximum: e.maximum,
|
|
190
238
|
isExclusive: !0
|
|
191
239
|
})
|
|
192
|
-
})), e.exclusiveMinimum && (
|
|
240
|
+
})), e.exclusiveMinimum && (t = t.pipe(n.greaterThan(e.exclusiveMinimum)).annotations({
|
|
193
241
|
message: () => i("validation.number.min", {
|
|
194
242
|
minimum: e.exclusiveMinimum,
|
|
195
243
|
isExclusive: !1
|
|
196
244
|
})
|
|
197
|
-
})), e.exclusiveMaximum && (
|
|
245
|
+
})), e.exclusiveMaximum && (t = t.pipe(n.lessThan(e.exclusiveMaximum)).annotations({
|
|
198
246
|
message: () => i("validation.number.max", {
|
|
199
247
|
maximum: e.exclusiveMaximum,
|
|
200
248
|
isExclusive: !1
|
|
@@ -202,7 +250,7 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
|
|
|
202
250
|
}));
|
|
203
251
|
break;
|
|
204
252
|
case "select":
|
|
205
|
-
|
|
253
|
+
t = n.Literal(...e.members).annotations({
|
|
206
254
|
message: () => ({
|
|
207
255
|
message: i("validation.not_a_valid", {
|
|
208
256
|
type: "select",
|
|
@@ -213,7 +261,7 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
|
|
|
213
261
|
});
|
|
214
262
|
break;
|
|
215
263
|
case "multiple":
|
|
216
|
-
|
|
264
|
+
t = n.Array(n.String).annotations({
|
|
217
265
|
message: () => i("validation.not_a_valid", {
|
|
218
266
|
type: "multiple",
|
|
219
267
|
message: e.members.join(", ")
|
|
@@ -221,28 +269,28 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
|
|
|
221
269
|
});
|
|
222
270
|
break;
|
|
223
271
|
case "boolean":
|
|
224
|
-
|
|
272
|
+
t = n.Boolean;
|
|
225
273
|
break;
|
|
226
274
|
// todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
|
|
227
275
|
case "unknown":
|
|
228
|
-
|
|
276
|
+
t = n.Unknown;
|
|
229
277
|
break;
|
|
230
278
|
}
|
|
231
|
-
return e.required ?
|
|
232
|
-
|
|
279
|
+
return e.required ? t.pipe(
|
|
280
|
+
n.annotations({
|
|
233
281
|
message: () => i("validation.empty")
|
|
234
282
|
})
|
|
235
|
-
) :
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
decode: (
|
|
239
|
-
encode: (
|
|
283
|
+
) : t = n.NullishOr(t), n.standardSchemaV1(t);
|
|
284
|
+
}, w = (e, i) => n.NullOr(e).pipe(
|
|
285
|
+
n.transform(n.typeSchema(e), {
|
|
286
|
+
decode: (t) => t ?? i(),
|
|
287
|
+
encode: (t) => t
|
|
240
288
|
})
|
|
241
289
|
);
|
|
242
290
|
export {
|
|
243
291
|
m as createMeta,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
292
|
+
N as duplicateSchema,
|
|
293
|
+
k as generateInputStandardSchemaFromFieldMeta,
|
|
294
|
+
_ as generateMetaFromSchema,
|
|
295
|
+
w as nullableInput
|
|
248
296
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as w, computed as f, onBeforeMount as E, watch as j, createElementBlock as v, openBlock as b, withModifiers as F, createElementVNode as M, unref as c, renderSlot as p, createCommentVNode as k, Fragment as V } from "vue";
|
|
2
2
|
import { useStore as g } from "@tanstack/vue-form";
|
|
3
|
-
import { getOmegaStore as B } from "./vue-components.
|
|
3
|
+
import { getOmegaStore as B } from "./vue-components.es25.js";
|
|
4
4
|
import { provideOmegaErrors as C } from "./vue-components.es8.js";
|
|
5
5
|
import { useOmegaForm as I } from "./vue-components.es9.js";
|
|
6
6
|
const $ = ["disabled"], N = /* @__PURE__ */ w({
|
|
@@ -1,92 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { defineComponent as w, getCurrentInstance as x, useId as C, computed as a, watch as f, nextTick as N, onMounted as d, ref as $, watchEffect as k, renderSlot as B, normalizeProps as I, guardReactiveProps as O, createElementVNode as _, normalizeClass as q, createBlock as L, createCommentVNode as P, unref as F, openBlock as S, mergeProps as T } from "vue";
|
|
3
|
-
import { useStore as z } from "@tanstack/vue-form";
|
|
4
|
-
import { useOmegaErrors as A } from "./vue-components.es8.js";
|
|
5
|
-
import D from "./vue-components.es27.js";
|
|
6
|
-
|
|
7
|
-
const J = /* @__PURE__ */ w({
|
|
8
|
-
inheritAttrs: !1,
|
|
9
|
-
__name: "OmegaInternalInput",
|
|
10
|
-
props: {
|
|
11
|
-
field: {},
|
|
12
|
-
meta: {},
|
|
13
|
-
label: {},
|
|
14
|
-
options: {},
|
|
15
|
-
type: {},
|
|
16
|
-
validators: {}
|
|
17
|
-
},
|
|
18
|
-
setup(c) {
|
|
19
|
-
const e = c, v = x()?.appContext.components.VTextField, l = C(), o = e.field, r = z(o.store, (t) => t), m = a(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), n = a(() => r.value.value), g = a(
|
|
20
|
-
() => (
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
-
r.value.meta.errors.map((t) => t?.message).filter(Boolean)
|
|
23
|
-
)
|
|
24
|
-
), y = (t) => t == null || t === !1 || t === "" || Number.isNaN(t);
|
|
25
|
-
f(
|
|
26
|
-
() => !!n.value,
|
|
27
|
-
() => {
|
|
28
|
-
y(n.value) && e.meta?.type !== "boolean" && N(() => {
|
|
29
|
-
o.setValue(
|
|
30
|
-
e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
), d(() => {
|
|
35
|
-
!n.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null" && o.setValue(null);
|
|
36
|
-
});
|
|
37
|
-
const { addError: h, removeError: b, showErrors: E, showErrorsOn: V } = A(), s = $(!1);
|
|
38
|
-
k(() => {
|
|
39
|
-
(E.value || V === "onChange") && (s.value = !0);
|
|
40
|
-
});
|
|
41
|
-
const u = () => {
|
|
42
|
-
s.value = !0;
|
|
43
|
-
};
|
|
44
|
-
d(() => {
|
|
45
|
-
n.value && u();
|
|
46
|
-
});
|
|
47
|
-
const p = a(() => !s.value && m.value !== "select" ? [] : g.value);
|
|
48
|
-
f(
|
|
49
|
-
() => r.value.meta.errors,
|
|
50
|
-
() => {
|
|
51
|
-
r.value.meta.errors.length ? h({
|
|
52
|
-
inputId: l,
|
|
53
|
-
errors: r.value.meta.errors.map((t) => t.message).filter(Boolean),
|
|
54
|
-
label: e.label
|
|
55
|
-
}) : b(l);
|
|
56
|
-
}
|
|
57
|
-
);
|
|
58
|
-
const i = a(() => ({
|
|
59
|
-
id: l,
|
|
60
|
-
required: e.meta?.required,
|
|
61
|
-
minLength: e.meta?.type === "string" && e.meta?.minLength,
|
|
62
|
-
maxLength: e.meta?.type === "string" && e.meta?.maxLength,
|
|
63
|
-
max: e.meta?.type === "number" && e.meta?.maximum,
|
|
64
|
-
min: e.meta?.type === "number" && e.meta?.minimum,
|
|
65
|
-
name: e.field.name,
|
|
66
|
-
modelValue: e.field.state.value,
|
|
67
|
-
errorMessages: p.value,
|
|
68
|
-
error: !!p.value.length,
|
|
69
|
-
field: e.field,
|
|
70
|
-
setRealDirty: u,
|
|
71
|
-
type: m.value,
|
|
72
|
-
label: `${e.label}${e.meta?.required ? " *" : ""}`,
|
|
73
|
-
options: e.options
|
|
74
|
-
}));
|
|
75
|
-
return (t, R) => B(t.$slots, "default", I(O(i.value)), () => [
|
|
76
|
-
_("div", {
|
|
77
|
-
class: q(t.$attrs.class),
|
|
78
|
-
onFocusout: u
|
|
79
|
-
}, [
|
|
80
|
-
F(v) ? (S(), L(D, T({
|
|
81
|
-
key: 0,
|
|
82
|
-
"input-props": i.value
|
|
83
|
-
}, t.$attrs, {
|
|
84
|
-
"vuetify-value": i.value.field.state.value
|
|
85
|
-
}), null, 16, ["input-props", "vuetify-value"])) : P("", !0)
|
|
86
|
-
], 34)
|
|
87
|
-
]);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
1
|
+
const o = (n) => typeof n == "function";
|
|
90
2
|
export {
|
|
91
|
-
|
|
3
|
+
o as isFunction
|
|
92
4
|
};
|
|
@@ -1,13 +1,92 @@
|
|
|
1
|
-
|
|
2
|
-
import { computed as f } from "vue";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");if(i.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(i),window.customElements){const e=window.customElements.define;window.customElements.define=function(s,t){const n=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(n&&n.call(this),this.shadowRoot){const a=document.createElement("style");a.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(a)}},e.call(window.customElements,s,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import { defineComponent as w, getCurrentInstance as x, useId as C, computed as a, watch as f, nextTick as N, onMounted as d, ref as $, watchEffect as k, renderSlot as B, normalizeProps as I, guardReactiveProps as O, createElementVNode as _, normalizeClass as q, createBlock as L, createCommentVNode as P, unref as F, openBlock as S, mergeProps as T } from "vue";
|
|
3
|
+
import { useStore as z } from "@tanstack/vue-form";
|
|
4
|
+
import { useOmegaErrors as A } from "./vue-components.es8.js";
|
|
5
|
+
import D from "./vue-components.es27.js";
|
|
6
|
+
|
|
7
|
+
const J = /* @__PURE__ */ w({
|
|
8
|
+
inheritAttrs: !1,
|
|
9
|
+
__name: "OmegaInternalInput",
|
|
10
|
+
props: {
|
|
11
|
+
field: {},
|
|
12
|
+
meta: {},
|
|
13
|
+
label: {},
|
|
14
|
+
options: {},
|
|
15
|
+
type: {},
|
|
16
|
+
validators: {}
|
|
17
|
+
},
|
|
18
|
+
setup(c) {
|
|
19
|
+
const e = c, v = x()?.appContext.components.VTextField, l = C(), o = e.field, r = z(o.store, (t) => t), m = a(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), n = a(() => r.value.value), g = a(
|
|
20
|
+
() => (
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
r.value.meta.errors.map((t) => t?.message).filter(Boolean)
|
|
23
|
+
)
|
|
24
|
+
), y = (t) => t == null || t === !1 || t === "" || Number.isNaN(t);
|
|
25
|
+
f(
|
|
26
|
+
() => !!n.value,
|
|
27
|
+
() => {
|
|
28
|
+
y(n.value) && e.meta?.type !== "boolean" && N(() => {
|
|
29
|
+
o.setValue(
|
|
30
|
+
e.meta?.nullableOrUndefined === "undefined" ? void 0 : null
|
|
31
|
+
);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
), d(() => {
|
|
35
|
+
!n.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null" && o.setValue(null);
|
|
36
|
+
});
|
|
37
|
+
const { addError: h, removeError: b, showErrors: E, showErrorsOn: V } = A(), s = $(!1);
|
|
38
|
+
k(() => {
|
|
39
|
+
(E.value || V === "onChange") && (s.value = !0);
|
|
40
|
+
});
|
|
41
|
+
const u = () => {
|
|
42
|
+
s.value = !0;
|
|
43
|
+
};
|
|
44
|
+
d(() => {
|
|
45
|
+
n.value && u();
|
|
46
|
+
});
|
|
47
|
+
const p = a(() => !s.value && m.value !== "select" ? [] : g.value);
|
|
48
|
+
f(
|
|
49
|
+
() => r.value.meta.errors,
|
|
50
|
+
() => {
|
|
51
|
+
r.value.meta.errors.length ? h({
|
|
52
|
+
inputId: l,
|
|
53
|
+
errors: r.value.meta.errors.map((t) => t.message).filter(Boolean),
|
|
54
|
+
label: e.label
|
|
55
|
+
}) : b(l);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
const i = a(() => ({
|
|
59
|
+
id: l,
|
|
60
|
+
required: e.meta?.required,
|
|
61
|
+
minLength: e.meta?.type === "string" && e.meta?.minLength,
|
|
62
|
+
maxLength: e.meta?.type === "string" && e.meta?.maxLength,
|
|
63
|
+
max: e.meta?.type === "number" && e.meta?.maximum,
|
|
64
|
+
min: e.meta?.type === "number" && e.meta?.minimum,
|
|
65
|
+
name: e.field.name,
|
|
66
|
+
modelValue: e.field.state.value,
|
|
67
|
+
errorMessages: p.value,
|
|
68
|
+
error: !!p.value.length,
|
|
69
|
+
field: e.field,
|
|
70
|
+
setRealDirty: u,
|
|
71
|
+
type: m.value,
|
|
72
|
+
label: `${e.label}${e.meta?.required ? " *" : ""}`,
|
|
73
|
+
options: e.options
|
|
74
|
+
}));
|
|
75
|
+
return (t, R) => B(t.$slots, "default", I(O(i.value)), () => [
|
|
76
|
+
_("div", {
|
|
77
|
+
class: q(t.$attrs.class),
|
|
78
|
+
onFocusout: u
|
|
79
|
+
}, [
|
|
80
|
+
F(v) ? (S(), L(D, T({
|
|
81
|
+
key: 0,
|
|
82
|
+
"input-props": i.value
|
|
83
|
+
}, t.$attrs, {
|
|
84
|
+
"vuetify-value": i.value.field.state.value
|
|
85
|
+
}), null, 16, ["input-props", "vuetify-value"])) : P("", !0)
|
|
86
|
+
], 34)
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
11
90
|
export {
|
|
12
|
-
|
|
91
|
+
J as default
|
|
13
92
|
};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { useStore as u } from "@tanstack/vue-form";
|
|
2
|
+
import { computed as f } from "vue";
|
|
3
|
+
function c(o, t) {
|
|
4
|
+
return f(() => t ? u(o.store, (n) => {
|
|
5
|
+
const r = {};
|
|
6
|
+
for (const e of t)
|
|
7
|
+
r[e] = n[e];
|
|
8
|
+
return r;
|
|
9
|
+
}).value : {});
|
|
10
|
+
}
|
|
2
11
|
export {
|
|
3
|
-
|
|
12
|
+
c as getOmegaStore
|
|
4
13
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as d, inject as f, computed as o, createBlock as n, openBlock as m, resolveDynamicComponent as v, withCtx as l, createCommentVNode as c, mergeProps as y, renderSlot as g, normalizeProps as h, guardReactiveProps as C } from "vue";
|
|
2
2
|
import { generateInputStandardSchemaFromFieldMeta as F } from "./vue-components.es10.js";
|
|
3
|
-
import b from "./vue-components.
|
|
3
|
+
import b from "./vue-components.es24.js";
|
|
4
4
|
const P = /* @__PURE__ */ d({
|
|
5
5
|
inheritAttrs: !1,
|
|
6
6
|
__name: "OmegaInput",
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
|
|
3
|
-
const C = /* @__PURE__ */ y({
|
|
1
|
+
import { defineComponent as i, computed as m, onMounted as p, provide as g, createElementBlock as h, openBlock as s, Fragment as v, renderList as y, createBlock as F, resolveDynamicComponent as M, withCtx as _, renderSlot as $, mergeProps as k } from "vue";
|
|
2
|
+
const P = /* @__PURE__ */ i({
|
|
4
3
|
inheritAttrs: !1,
|
|
5
4
|
__name: "OmegaArray",
|
|
6
5
|
props: {
|
|
@@ -10,41 +9,23 @@ const C = /* @__PURE__ */ y({
|
|
|
10
9
|
items: {}
|
|
11
10
|
},
|
|
12
11
|
setup(l) {
|
|
13
|
-
const t = l,
|
|
14
|
-
|
|
15
|
-
t.defaultItems && !
|
|
12
|
+
const t = l, u = t.form.useStore((e) => e.values), o = m(() => t.name.replace(/\[/g, ".").replace(/\]/g, "").split(".").reduce((r, a) => r[a], u.value));
|
|
13
|
+
p(async () => {
|
|
14
|
+
t.defaultItems && !o.value && t.form.setFieldValue(t.name, t.defaultItems);
|
|
16
15
|
});
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const a = e.rest.reduce((r, n) => n.type._tag === "TypeLiteral" ? {
|
|
21
|
-
...r,
|
|
22
|
-
propertySignatures: [
|
|
23
|
-
...r.propertySignatures || [],
|
|
24
|
-
...n.type.propertySignatures
|
|
25
|
-
]
|
|
26
|
-
} : {
|
|
27
|
-
...r,
|
|
28
|
-
property: n.type
|
|
29
|
-
}, {}), s = A({ ...a, meta: e });
|
|
30
|
-
return (r) => {
|
|
31
|
-
if (r.endsWith("]")) return s;
|
|
32
|
-
const n = r.split("]."), d = n[n.length - 1];
|
|
33
|
-
return s[d];
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
return (a) => {
|
|
37
|
-
};
|
|
16
|
+
const d = m(() => (r) => {
|
|
17
|
+
const a = r.replace(/\[\d+\]/g, "");
|
|
18
|
+
return t.form.meta[a];
|
|
38
19
|
});
|
|
39
|
-
return g("getMetaFromArray",
|
|
40
|
-
key: `${e.name}[${Number(
|
|
41
|
-
name: `${e.name}[${Number(
|
|
20
|
+
return g("getMetaFromArray", d), (e, r) => (s(!0), h(v, null, y(o.value, (a, n) => (s(), F(M(e.form.Field), {
|
|
21
|
+
key: `${e.name}[${Number(n)}]`,
|
|
22
|
+
name: `${e.name}[${Number(n)}]`
|
|
42
23
|
}, {
|
|
43
|
-
default:
|
|
44
|
-
|
|
45
|
-
subField:
|
|
46
|
-
subState:
|
|
47
|
-
index: Number(
|
|
24
|
+
default: _(({ field: c, state: f }) => [
|
|
25
|
+
$(e.$slots, "default", k({ ref_for: !0 }, {
|
|
26
|
+
subField: c,
|
|
27
|
+
subState: f,
|
|
28
|
+
index: Number(n)
|
|
48
29
|
}))
|
|
49
30
|
]),
|
|
50
31
|
_: 2
|
|
@@ -52,5 +33,5 @@ const C = /* @__PURE__ */ y({
|
|
|
52
33
|
}
|
|
53
34
|
});
|
|
54
35
|
export {
|
|
55
|
-
|
|
36
|
+
P as default
|
|
56
37
|
};
|
package/package.json
CHANGED
|
@@ -29,9 +29,7 @@
|
|
|
29
29
|
>
|
|
30
30
|
import { computed, onMounted, provide } from "vue"
|
|
31
31
|
import {
|
|
32
|
-
type CreateMeta,
|
|
33
32
|
type OmegaInputProps,
|
|
34
|
-
createMeta,
|
|
35
33
|
} from "./OmegaFormStuff"
|
|
36
34
|
import { type DeepValue, type DeepKeys } from "@tanstack/vue-form"
|
|
37
35
|
|
|
@@ -52,10 +50,8 @@ defineOptions({
|
|
|
52
50
|
|
|
53
51
|
const store = props.form.useStore(state => state.values)
|
|
54
52
|
const items = computed(() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return acc[curr]
|
|
58
|
-
}
|
|
53
|
+
const normalizedPath = props.name.replace(/\[/g, ".").replace(/\]/g, "")
|
|
54
|
+
return normalizedPath.split(".").reduce((acc, curr) => {
|
|
59
55
|
return acc[curr] as typeof store.value
|
|
60
56
|
}, store.value)
|
|
61
57
|
})
|
|
@@ -67,34 +63,14 @@ onMounted(async () => {
|
|
|
67
63
|
})
|
|
68
64
|
|
|
69
65
|
const getMetaFromArray = computed(() => {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
if (curr.type._tag === "TypeLiteral") {
|
|
74
|
-
return {
|
|
75
|
-
...acc,
|
|
76
|
-
propertySignatures: [
|
|
77
|
-
...(acc.propertySignatures || []),
|
|
78
|
-
...curr.type.propertySignatures,
|
|
79
|
-
],
|
|
80
|
-
} as CreateMeta
|
|
81
|
-
}
|
|
82
|
-
return {
|
|
83
|
-
...acc,
|
|
84
|
-
property: curr.type,
|
|
85
|
-
} as CreateMeta
|
|
86
|
-
}, {} as CreateMeta)
|
|
66
|
+
const getMeta = (path: string) => {
|
|
67
|
+
// Transform path like 'a[0].b[11].c' into 'a.b.c'
|
|
68
|
+
const simplifiedPath = path.replace(/\[\d+\]/g, '')
|
|
87
69
|
|
|
88
|
-
|
|
89
|
-
const getMeta = (index: string) => {
|
|
90
|
-
if (index.endsWith("]")) return arrayMeta
|
|
91
|
-
const parts = index.split("].")
|
|
92
|
-
const key = parts[parts.length - 1]
|
|
93
|
-
return arrayMeta[key as keyof typeof arrayMeta]
|
|
94
|
-
}
|
|
95
|
-
return getMeta
|
|
70
|
+
return props.form.meta[simplifiedPath as keyof typeof props.form.meta]
|
|
96
71
|
}
|
|
97
|
-
|
|
72
|
+
|
|
73
|
+
return getMeta
|
|
98
74
|
})
|
|
99
75
|
|
|
100
76
|
provide("getMetaFromArray", getMetaFromArray)
|
|
@@ -255,6 +255,7 @@ export const createMeta = <T = any>(
|
|
|
255
255
|
const key = parent ? `${parent}.${p.name.toString()}` : p.name.toString()
|
|
256
256
|
const nullableOrUndefined = isNullableOrUndefined(p.type)
|
|
257
257
|
const isRequired = !nullableOrUndefined
|
|
258
|
+
|
|
258
259
|
|
|
259
260
|
const typeToProcess = p.type
|
|
260
261
|
if (S.AST.isUnion(p.type)) {
|
|
@@ -308,12 +309,79 @@ export const createMeta = <T = any>(
|
|
|
308
309
|
})
|
|
309
310
|
)
|
|
310
311
|
} else {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
312
|
+
// Check if this is an array type
|
|
313
|
+
if (S.AST.isTupleType(p.type)) {
|
|
314
|
+
// Check if it has struct elements
|
|
315
|
+
const hasStructElements = p.type.rest.length > 0 &&
|
|
316
|
+
p.type.rest[0].type._tag === "TypeLiteral" &&
|
|
317
|
+
"propertySignatures" in p.type.rest[0].type
|
|
318
|
+
|
|
319
|
+
if (hasStructElements) {
|
|
320
|
+
// For arrays with struct elements, only create meta for nested fields, not the array itself
|
|
321
|
+
const elementType = p.type.rest[0].type
|
|
322
|
+
if (elementType._tag === "TypeLiteral" && "propertySignatures" in elementType) {
|
|
323
|
+
// Process each property in the array element
|
|
324
|
+
for (const prop of elementType.propertySignatures) {
|
|
325
|
+
const propKey = `${key}.${prop.name.toString()}`
|
|
326
|
+
|
|
327
|
+
// Check if the property is another array
|
|
328
|
+
if (S.AST.isTupleType(prop.type) && prop.type.rest.length > 0) {
|
|
329
|
+
const nestedElementType = prop.type.rest[0].type
|
|
330
|
+
if (nestedElementType._tag === "TypeLiteral" && "propertySignatures" in nestedElementType) {
|
|
331
|
+
// Array with struct elements - process nested fields
|
|
332
|
+
for (const nestedProp of nestedElementType.propertySignatures) {
|
|
333
|
+
const nestedKey = `${propKey}.${nestedProp.name.toString()}`
|
|
334
|
+
const nestedMeta = createMeta<T>({
|
|
335
|
+
parent: nestedKey,
|
|
336
|
+
property: nestedProp.type,
|
|
337
|
+
meta: {
|
|
338
|
+
required: !isNullableOrUndefined(nestedProp.type),
|
|
339
|
+
nullableOrUndefined: isNullableOrUndefined(nestedProp.type)
|
|
340
|
+
}
|
|
341
|
+
})
|
|
342
|
+
acc[nestedKey as NestedKeyOf<T>] = nestedMeta as FieldMeta
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
// Array with primitive elements - create meta for the array itself
|
|
346
|
+
acc[propKey as NestedKeyOf<T>] = {
|
|
347
|
+
type: "multiple",
|
|
348
|
+
members: prop.type.elements,
|
|
349
|
+
rest: prop.type.rest,
|
|
350
|
+
required: !isNullableOrUndefined(prop.type),
|
|
351
|
+
nullableOrUndefined: isNullableOrUndefined(prop.type)
|
|
352
|
+
} as FieldMeta
|
|
353
|
+
}
|
|
354
|
+
} else {
|
|
355
|
+
const fieldMeta = createMeta<T>({
|
|
356
|
+
parent: propKey,
|
|
357
|
+
property: prop.type,
|
|
358
|
+
meta: {
|
|
359
|
+
required: !isNullableOrUndefined(prop.type),
|
|
360
|
+
nullableOrUndefined: isNullableOrUndefined(prop.type)
|
|
361
|
+
}
|
|
362
|
+
})
|
|
363
|
+
acc[propKey as NestedKeyOf<T>] = fieldMeta as FieldMeta
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
} else {
|
|
368
|
+
// For arrays with primitive elements, create the array meta
|
|
369
|
+
acc[key as NestedKeyOf<T>] = {
|
|
370
|
+
type: "multiple",
|
|
371
|
+
members: p.type.elements,
|
|
372
|
+
rest: p.type.rest,
|
|
373
|
+
required: isRequired,
|
|
374
|
+
nullableOrUndefined
|
|
375
|
+
} as FieldMeta
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
const newMeta = createMeta<T>({
|
|
379
|
+
parent: key,
|
|
380
|
+
property: p.type,
|
|
381
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
382
|
+
})
|
|
383
|
+
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
384
|
+
}
|
|
317
385
|
}
|
|
318
386
|
}
|
|
319
387
|
return acc
|