@effect-app/vue-components 0.14.5 → 0.15.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/dist/types/components/OmegaForm/OmegaArray.vue.d.ts +4 -0
- package/dist/vue-components.es10.js +149 -108
- package/dist/vue-components.es4.js +11 -11
- package/dist/vue-components.es7.js +31 -23
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaArray.vue +5 -1
- package/src/components/OmegaForm/OmegaFormStuff.ts +83 -17
- package/src/components/OmegaForm/OmegaInput.vue +1 -0
|
@@ -13,6 +13,10 @@ declare const _default: <From extends Record<PropertyKey, any>, To extends Recor
|
|
|
13
13
|
subState: import("@tanstack/vue-form").FieldState<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").StandardSchemaV1<From, To>, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>;
|
|
14
14
|
index: number;
|
|
15
15
|
}) => any;
|
|
16
|
+
} & {
|
|
17
|
+
field?: (props: {
|
|
18
|
+
field: import("@tanstack/vue-form").FieldApi<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FieldAsyncValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").StandardSchemaV1<From, To>, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<From> | undefined>;
|
|
19
|
+
}) => any;
|
|
16
20
|
};
|
|
17
21
|
emit: {};
|
|
18
22
|
}>) => import("vue").VNode & {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as n, Option as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
const
|
|
1
|
+
import { S as n, Option as c, pipe as L } from "effect-app";
|
|
2
|
+
import { useIntl as U } from "./vue-components.es3.js";
|
|
3
|
+
const _ = n.NonEmptyArray(n.String), N = (e) => n.AST.isUnion(e) && e.types.find((i) => i._tag === "UndefinedKeyword" || i === n.Null.ast), g = (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: p }, o = {}) => {
|
|
4
4
|
if (t && t._tag === "Transformation")
|
|
5
5
|
return m({
|
|
6
6
|
parent: i,
|
|
@@ -12,128 +12,169 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
12
12
|
meta: e,
|
|
13
13
|
propertySignatures: t.propertySignatures
|
|
14
14
|
});
|
|
15
|
-
if (
|
|
16
|
-
for (const r of
|
|
17
|
-
const
|
|
15
|
+
if (p) {
|
|
16
|
+
for (const r of p) {
|
|
17
|
+
const l = i ? `${i}.${r.name.toString()}` : r.name.toString(), a = g(r.type), u = !a, A = r.type;
|
|
18
18
|
if (n.AST.isUnion(r.type)) {
|
|
19
|
-
const
|
|
20
|
-
(
|
|
19
|
+
const T = r.type.types.filter(
|
|
20
|
+
(s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
|
|
21
21
|
);
|
|
22
|
-
if (
|
|
23
|
-
(
|
|
22
|
+
if (T.some(
|
|
23
|
+
(s) => "propertySignatures" in s
|
|
24
24
|
)) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
if (!a) {
|
|
26
|
+
const s = m({
|
|
27
|
+
parent: l,
|
|
28
|
+
property: r.type,
|
|
29
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
30
|
+
});
|
|
31
|
+
o[l] = s;
|
|
32
|
+
}
|
|
33
|
+
for (const s of T)
|
|
34
|
+
"propertySignatures" in s && Object.assign(
|
|
35
|
+
o,
|
|
34
36
|
m({
|
|
35
|
-
parent:
|
|
36
|
-
propertySignatures:
|
|
37
|
-
meta: { required:
|
|
37
|
+
parent: l,
|
|
38
|
+
propertySignatures: s.propertySignatures,
|
|
39
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
38
40
|
})
|
|
39
41
|
);
|
|
40
42
|
} else {
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const s = T.filter(n.AST.isTupleType);
|
|
44
|
+
if (s.length > 0) {
|
|
45
|
+
const f = s[0];
|
|
46
|
+
if (o[l] = {
|
|
47
|
+
type: "multiple",
|
|
48
|
+
members: f.elements,
|
|
49
|
+
rest: f.rest,
|
|
50
|
+
required: u,
|
|
51
|
+
nullableOrUndefined: a
|
|
52
|
+
}, f.rest && f.rest.length > 0) {
|
|
53
|
+
const d = f.rest[0];
|
|
54
|
+
if (d.type._tag === "TypeLiteral" && "propertySignatures" in d.type)
|
|
55
|
+
for (const y of d.type.propertySignatures) {
|
|
56
|
+
const b = `${l}.${y.name.toString()}`, S = m({
|
|
57
|
+
parent: b,
|
|
58
|
+
property: y.type,
|
|
59
|
+
meta: {
|
|
60
|
+
required: !g(y.type),
|
|
61
|
+
nullableOrUndefined: g(y.type)
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
if (S && typeof S == "object" && "type" in S && (o[b] = S, S.type === "multiple" && n.AST.isTupleType(y.type) && y.type.rest && y.type.rest.length > 0)) {
|
|
65
|
+
const O = y.type.rest[0];
|
|
66
|
+
if (O.type._tag === "TypeLiteral" && "propertySignatures" in O.type)
|
|
67
|
+
for (const v of O.type.propertySignatures) {
|
|
68
|
+
const M = `${b}.${v.name.toString()}`, x = m({
|
|
69
|
+
parent: M,
|
|
70
|
+
property: v.type,
|
|
71
|
+
meta: {
|
|
72
|
+
required: !g(v.type),
|
|
73
|
+
nullableOrUndefined: g(v.type)
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
x && typeof x == "object" && "type" in x && (o[M] = x);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
const f = m({
|
|
83
|
+
parent: l,
|
|
84
|
+
property: r.type,
|
|
85
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
86
|
+
});
|
|
87
|
+
o[l] = f;
|
|
88
|
+
}
|
|
47
89
|
}
|
|
48
|
-
}
|
|
49
|
-
if ("propertySignatures" in b)
|
|
90
|
+
} else if ("propertySignatures" in A)
|
|
50
91
|
Object.assign(
|
|
51
|
-
|
|
92
|
+
o,
|
|
52
93
|
m({
|
|
53
|
-
parent:
|
|
54
|
-
propertySignatures:
|
|
55
|
-
meta: { required:
|
|
94
|
+
parent: l,
|
|
95
|
+
propertySignatures: A.propertySignatures,
|
|
96
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
56
97
|
})
|
|
57
98
|
);
|
|
58
99
|
else if (n.AST.isTupleType(r.type))
|
|
59
100
|
if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
for (const
|
|
63
|
-
const
|
|
64
|
-
if (n.AST.isTupleType(
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
for (const
|
|
68
|
-
const
|
|
69
|
-
parent:
|
|
70
|
-
property:
|
|
101
|
+
const h = r.type.rest[0].type;
|
|
102
|
+
if (h._tag === "TypeLiteral" && "propertySignatures" in h)
|
|
103
|
+
for (const s of h.propertySignatures) {
|
|
104
|
+
const f = `${l}.${s.name.toString()}`;
|
|
105
|
+
if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
|
|
106
|
+
const d = s.type.rest[0].type;
|
|
107
|
+
if (d._tag === "TypeLiteral" && "propertySignatures" in d)
|
|
108
|
+
for (const y of d.propertySignatures) {
|
|
109
|
+
const b = `${f}.${y.name.toString()}`, S = m({
|
|
110
|
+
parent: b,
|
|
111
|
+
property: y.type,
|
|
71
112
|
meta: {
|
|
72
|
-
required: !y
|
|
73
|
-
nullableOrUndefined: y
|
|
113
|
+
required: !g(y.type),
|
|
114
|
+
nullableOrUndefined: g(y.type)
|
|
74
115
|
}
|
|
75
116
|
});
|
|
76
|
-
|
|
117
|
+
o[b] = S;
|
|
77
118
|
}
|
|
78
119
|
else
|
|
79
|
-
|
|
120
|
+
o[f] = {
|
|
80
121
|
type: "multiple",
|
|
81
|
-
members:
|
|
82
|
-
rest:
|
|
83
|
-
required: !
|
|
84
|
-
nullableOrUndefined:
|
|
122
|
+
members: s.type.elements,
|
|
123
|
+
rest: s.type.rest,
|
|
124
|
+
required: !g(s.type),
|
|
125
|
+
nullableOrUndefined: g(s.type)
|
|
85
126
|
};
|
|
86
127
|
} else {
|
|
87
|
-
const
|
|
88
|
-
parent:
|
|
89
|
-
property:
|
|
128
|
+
const d = m({
|
|
129
|
+
parent: f,
|
|
130
|
+
property: s.type,
|
|
90
131
|
meta: {
|
|
91
|
-
required: !
|
|
92
|
-
nullableOrUndefined:
|
|
132
|
+
required: !g(s.type),
|
|
133
|
+
nullableOrUndefined: g(s.type)
|
|
93
134
|
}
|
|
94
135
|
});
|
|
95
|
-
|
|
136
|
+
o[f] = d;
|
|
96
137
|
}
|
|
97
138
|
}
|
|
98
139
|
} else
|
|
99
|
-
l
|
|
140
|
+
o[l] = {
|
|
100
141
|
type: "multiple",
|
|
101
142
|
members: r.type.elements,
|
|
102
143
|
rest: r.type.rest,
|
|
103
|
-
required:
|
|
104
|
-
nullableOrUndefined:
|
|
144
|
+
required: u,
|
|
145
|
+
nullableOrUndefined: a
|
|
105
146
|
};
|
|
106
147
|
else {
|
|
107
|
-
const
|
|
108
|
-
parent:
|
|
148
|
+
const T = m({
|
|
149
|
+
parent: l,
|
|
109
150
|
property: r.type,
|
|
110
|
-
meta: { required:
|
|
151
|
+
meta: { required: u, nullableOrUndefined: a }
|
|
111
152
|
});
|
|
112
|
-
l
|
|
153
|
+
o[l] = T;
|
|
113
154
|
}
|
|
114
155
|
}
|
|
115
|
-
return
|
|
156
|
+
return o;
|
|
116
157
|
}
|
|
117
158
|
if (t) {
|
|
118
|
-
const r =
|
|
159
|
+
const r = N(t);
|
|
119
160
|
if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
|
|
120
|
-
const
|
|
121
|
-
(
|
|
161
|
+
const a = t.types.find(
|
|
162
|
+
(u) => u._tag !== "UndefinedKeyword" && u !== n.Null.ast
|
|
122
163
|
);
|
|
123
|
-
return "propertySignatures" in
|
|
124
|
-
propertySignatures:
|
|
164
|
+
return "propertySignatures" in a ? m({
|
|
165
|
+
propertySignatures: a.propertySignatures,
|
|
125
166
|
parent: i,
|
|
126
167
|
meta: e
|
|
127
168
|
}) : t.types.every(n.AST.isLiteral) ? {
|
|
128
169
|
...e,
|
|
129
170
|
type: "select",
|
|
130
|
-
members: t.types.map((
|
|
171
|
+
members: t.types.map((u) => u.literal)
|
|
131
172
|
} : {
|
|
132
173
|
...e,
|
|
133
174
|
...m({
|
|
134
175
|
parent: i,
|
|
135
176
|
meta: e,
|
|
136
|
-
property:
|
|
177
|
+
property: a
|
|
137
178
|
})
|
|
138
179
|
};
|
|
139
180
|
}
|
|
@@ -144,11 +185,11 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
144
185
|
members: t.elements,
|
|
145
186
|
rest: t.rest
|
|
146
187
|
};
|
|
147
|
-
const
|
|
188
|
+
const l = n.AST.getAnnotation(
|
|
148
189
|
t,
|
|
149
190
|
n.AST.JSONSchemaAnnotationId
|
|
150
|
-
).pipe(
|
|
151
|
-
return e = { ...e, ...
|
|
191
|
+
).pipe(c.getOrElse(() => ({})));
|
|
192
|
+
return e = { ...e, ...l }, "from" in t ? m({
|
|
152
193
|
parent: i,
|
|
153
194
|
meta: e,
|
|
154
195
|
property: t.from
|
|
@@ -156,50 +197,50 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
156
197
|
t,
|
|
157
198
|
n.AST.TitleAnnotationId
|
|
158
199
|
).pipe(
|
|
159
|
-
|
|
200
|
+
c.getOrElse(() => "unknown")
|
|
160
201
|
), e);
|
|
161
202
|
}
|
|
162
|
-
return
|
|
163
|
-
},
|
|
203
|
+
return o;
|
|
204
|
+
}, q = (e) => {
|
|
164
205
|
const i = e.ast, t = {};
|
|
165
206
|
if (i._tag === "Transformation" || i._tag === "Refinement")
|
|
166
|
-
return
|
|
207
|
+
return q(n.make(i.from));
|
|
167
208
|
if ("propertySignatures" in i) {
|
|
168
|
-
const
|
|
209
|
+
const p = m({
|
|
169
210
|
propertySignatures: i.propertySignatures
|
|
170
211
|
});
|
|
171
|
-
if (Object.values(
|
|
172
|
-
return
|
|
173
|
-
const
|
|
174
|
-
for (const
|
|
175
|
-
const
|
|
176
|
-
r[
|
|
212
|
+
if (Object.values(p).every((r) => r && "type" in r))
|
|
213
|
+
return p;
|
|
214
|
+
const o = (r, l = "") => {
|
|
215
|
+
for (const a in r) {
|
|
216
|
+
const u = l ? `${l}.${a}` : a;
|
|
217
|
+
r[a] && typeof r[a] == "object" && "type" in r[a] ? t[u] = r[a] : r[a] && typeof r[a] == "object" && o(r[a], u);
|
|
177
218
|
}
|
|
178
219
|
};
|
|
179
|
-
|
|
220
|
+
o(p);
|
|
180
221
|
}
|
|
181
222
|
return t;
|
|
182
|
-
},
|
|
183
|
-
const i =
|
|
223
|
+
}, w = (e) => n.extend(e, n.Struct({})), $ = (e) => {
|
|
224
|
+
const i = q(e), t = L(
|
|
184
225
|
e.ast,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
({ items:
|
|
226
|
+
c.liftPredicate((p) => p._tag === "Refinement" && "filter" in p),
|
|
227
|
+
c.flatMap((p) => n.AST.getJSONSchemaAnnotation(p)),
|
|
228
|
+
c.filter((p) => "items" in p),
|
|
229
|
+
c.filterMap(
|
|
230
|
+
({ items: p }) => n.decodeUnknownOption(_)(p)
|
|
190
231
|
),
|
|
191
|
-
|
|
232
|
+
c.zipWith(
|
|
192
233
|
n.AST.getMessageAnnotation(e.ast),
|
|
193
|
-
(
|
|
194
|
-
items:
|
|
195
|
-
message:
|
|
234
|
+
(p, o) => ({
|
|
235
|
+
items: p,
|
|
236
|
+
message: o("")
|
|
196
237
|
})
|
|
197
238
|
),
|
|
198
|
-
|
|
239
|
+
c.getOrUndefined
|
|
199
240
|
);
|
|
200
241
|
return { schema: e, meta: i, filterItems: t };
|
|
201
|
-
},
|
|
202
|
-
const { trans: i } =
|
|
242
|
+
}, K = (e) => {
|
|
243
|
+
const { trans: i } = U();
|
|
203
244
|
let t;
|
|
204
245
|
switch (e.type) {
|
|
205
246
|
case "string":
|
|
@@ -281,7 +322,7 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
281
322
|
message: () => i("validation.empty")
|
|
282
323
|
})
|
|
283
324
|
) : t = n.NullishOr(t), n.standardSchemaV1(t);
|
|
284
|
-
},
|
|
325
|
+
}, P = (e, i) => n.NullOr(e).pipe(
|
|
285
326
|
n.transform(n.typeSchema(e), {
|
|
286
327
|
decode: (t) => t ?? i(),
|
|
287
328
|
encode: (t) => t
|
|
@@ -289,8 +330,8 @@ const M = n.NonEmptyArray(n.String), L = (e) => n.AST.isUnion(e) && e.types.find
|
|
|
289
330
|
);
|
|
290
331
|
export {
|
|
291
332
|
m as createMeta,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
333
|
+
w as duplicateSchema,
|
|
334
|
+
K as generateInputStandardSchemaFromFieldMeta,
|
|
335
|
+
$ as generateMetaFromSchema,
|
|
336
|
+
P as nullableInput
|
|
296
337
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent as d, inject as f, computed as
|
|
2
|
-
import { generateInputStandardSchemaFromFieldMeta as
|
|
3
|
-
import
|
|
1
|
+
import { defineComponent as d, inject as f, computed as r, createBlock as n, openBlock as m, resolveDynamicComponent as c, withCtx as l, createCommentVNode as v, mergeProps as y, renderSlot as g, normalizeProps as h, guardReactiveProps as b } from "vue";
|
|
2
|
+
import { generateInputStandardSchemaFromFieldMeta as C } from "./vue-components.es10.js";
|
|
3
|
+
import F from "./vue-components.es24.js";
|
|
4
4
|
const P = /* @__PURE__ */ d({
|
|
5
5
|
inheritAttrs: !1,
|
|
6
6
|
__name: "OmegaInput",
|
|
@@ -13,15 +13,15 @@ const P = /* @__PURE__ */ d({
|
|
|
13
13
|
type: {}
|
|
14
14
|
},
|
|
15
15
|
setup(s) {
|
|
16
|
-
const a = s,
|
|
16
|
+
const a = s, o = f(
|
|
17
17
|
"getMetaFromArray",
|
|
18
18
|
null
|
|
19
|
-
), t =
|
|
19
|
+
), t = r(() => o?.value && o.value(a.name) ? o.value(a.name) : a.form.meta[a.name]), i = r(() => {
|
|
20
20
|
if (!t.value)
|
|
21
|
-
throw new Error("Meta is undefined");
|
|
22
|
-
return
|
|
21
|
+
throw console.log(a.name, Object.keys(a.form.meta), a.form.meta), new Error("Meta is undefined");
|
|
22
|
+
return C(t.value);
|
|
23
23
|
});
|
|
24
|
-
return (e,
|
|
24
|
+
return (e, k) => (m(), n(c(e.form.Field), {
|
|
25
25
|
name: e.name,
|
|
26
26
|
validators: {
|
|
27
27
|
onChange: i.value,
|
|
@@ -29,7 +29,7 @@ const P = /* @__PURE__ */ d({
|
|
|
29
29
|
}
|
|
30
30
|
}, {
|
|
31
31
|
default: l(({ field: p }) => [
|
|
32
|
-
t.value ? (m(), n(
|
|
32
|
+
t.value ? (m(), n(F, y({
|
|
33
33
|
key: 0,
|
|
34
34
|
field: p,
|
|
35
35
|
label: e.label,
|
|
@@ -38,10 +38,10 @@ const P = /* @__PURE__ */ d({
|
|
|
38
38
|
type: e.type
|
|
39
39
|
}, e.$attrs), {
|
|
40
40
|
default: l((u) => [
|
|
41
|
-
g(e.$slots, "default", h(
|
|
41
|
+
g(e.$slots, "default", h(b(u)))
|
|
42
42
|
]),
|
|
43
43
|
_: 2
|
|
44
|
-
}, 1040, ["field", "label", "options", "meta", "type"])) :
|
|
44
|
+
}, 1040, ["field", "label", "options", "meta", "type"])) : v("", !0)
|
|
45
45
|
]),
|
|
46
46
|
_: 3
|
|
47
47
|
}, 8, ["name", "validators"]));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as F, computed as l, onMounted as P, provide as $, createElementBlock as s, openBlock as n, Fragment as u, createBlock as d, renderList as M, resolveDynamicComponent as i, withCtx as f, renderSlot as p, mergeProps as k, normalizeProps as A, guardReactiveProps as b } from "vue";
|
|
2
|
+
const B = /* @__PURE__ */ F({
|
|
3
3
|
inheritAttrs: !1,
|
|
4
4
|
__name: "OmegaArray",
|
|
5
5
|
props: {
|
|
@@ -8,30 +8,38 @@ const P = /* @__PURE__ */ i({
|
|
|
8
8
|
defaultItems: {},
|
|
9
9
|
items: {}
|
|
10
10
|
},
|
|
11
|
-
setup(
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
setup(c) {
|
|
12
|
+
const r = c, g = r.form.useStore((e) => e.values), m = l(() => r.name.replace(/\[/g, ".").replace(/\]/g, "").split(".").reduce((a, t) => a[t], g.value));
|
|
13
|
+
P(async () => {
|
|
14
|
+
r.defaultItems && !m.value && r.form.setFieldValue(r.name, r.defaultItems);
|
|
15
15
|
});
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
return
|
|
16
|
+
const v = l(() => (a) => {
|
|
17
|
+
const t = a.replace(/\[\d+\]/g, "");
|
|
18
|
+
return r.form.meta[t];
|
|
19
19
|
});
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
20
|
+
return $("getMetaFromArray", v), (e, a) => (n(), s(u, null, [
|
|
21
|
+
(n(!0), s(u, null, M(m.value, (t, o) => (n(), d(i(e.form.Field), {
|
|
22
|
+
key: `${e.name}[${Number(o)}]`,
|
|
23
|
+
name: `${e.name}[${Number(o)}]`
|
|
24
|
+
}, {
|
|
25
|
+
default: f(({ field: h, state: y }) => [
|
|
26
|
+
p(e.$slots, "default", k({ ref_for: !0 }, {
|
|
27
|
+
subField: h,
|
|
28
|
+
subState: y,
|
|
29
|
+
index: Number(o)
|
|
30
|
+
}))
|
|
31
|
+
]),
|
|
32
|
+
_: 2
|
|
33
|
+
}, 1032, ["name"]))), 128)),
|
|
34
|
+
(n(), d(i(e.form.Field), { name: e.name }, {
|
|
35
|
+
default: f(({ field: t }) => [
|
|
36
|
+
p(e.$slots, "field", A(b({ field: t })))
|
|
37
|
+
]),
|
|
38
|
+
_: 3
|
|
39
|
+
}, 8, ["name"]))
|
|
40
|
+
], 64));
|
|
33
41
|
}
|
|
34
42
|
});
|
|
35
43
|
export {
|
|
36
|
-
|
|
44
|
+
B as default
|
|
37
45
|
};
|
package/package.json
CHANGED
|
@@ -268,14 +268,16 @@ export const createMeta = <T = any>(
|
|
|
268
268
|
)
|
|
269
269
|
|
|
270
270
|
if (hasStructMembers) {
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
271
|
+
// Only create parent meta for non-NullOr unions to avoid duplicates
|
|
272
|
+
if (!nullableOrUndefined) {
|
|
273
|
+
const parentMeta = createMeta<T>({
|
|
274
|
+
parent: key,
|
|
275
|
+
property: p.type,
|
|
276
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
277
|
+
})
|
|
278
|
+
acc[key as NestedKeyOf<T>] = parentMeta as FieldMeta
|
|
279
|
+
}
|
|
280
|
+
|
|
279
281
|
// Process each non-null type and merge their metadata
|
|
280
282
|
for (const nonNullType of nonNullTypes) {
|
|
281
283
|
if ("propertySignatures" in nonNullType) {
|
|
@@ -290,16 +292,78 @@ export const createMeta = <T = any>(
|
|
|
290
292
|
}
|
|
291
293
|
}
|
|
292
294
|
} else {
|
|
293
|
-
//
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
295
|
+
// Check if any of the union types are arrays (TupleType)
|
|
296
|
+
const arrayTypes = nonNullTypes.filter(S.AST.isTupleType)
|
|
297
|
+
if (arrayTypes.length > 0) {
|
|
298
|
+
const arrayType = arrayTypes[0] // Take the first array type
|
|
299
|
+
|
|
300
|
+
acc[key as NestedKeyOf<T>] = {
|
|
301
|
+
type: "multiple",
|
|
302
|
+
members: arrayType.elements,
|
|
303
|
+
rest: arrayType.rest,
|
|
304
|
+
required: isRequired,
|
|
305
|
+
nullableOrUndefined
|
|
306
|
+
} as FieldMeta
|
|
307
|
+
|
|
308
|
+
// If the array has struct elements, also create metadata for their properties
|
|
309
|
+
if (arrayType.rest && arrayType.rest.length > 0) {
|
|
310
|
+
const restElement = arrayType.rest[0]
|
|
311
|
+
if (restElement.type._tag === "TypeLiteral" && "propertySignatures" in restElement.type) {
|
|
312
|
+
|
|
313
|
+
for (const prop of restElement.type.propertySignatures) {
|
|
314
|
+
const propKey = `${key}.${prop.name.toString()}`
|
|
315
|
+
|
|
316
|
+
const propMeta = createMeta<T>({
|
|
317
|
+
parent: propKey,
|
|
318
|
+
property: prop.type,
|
|
319
|
+
meta: {
|
|
320
|
+
required: !isNullableOrUndefined(prop.type),
|
|
321
|
+
nullableOrUndefined: isNullableOrUndefined(prop.type)
|
|
322
|
+
}
|
|
323
|
+
})
|
|
324
|
+
|
|
325
|
+
// add to accumulator if valid
|
|
326
|
+
if (propMeta && typeof propMeta === 'object' && 'type' in propMeta) {
|
|
327
|
+
acc[propKey as NestedKeyOf<T>] = propMeta as FieldMeta
|
|
328
|
+
|
|
329
|
+
if (propMeta.type === "multiple" && S.AST.isTupleType(prop.type) && prop.type.rest && prop.type.rest.length > 0) {
|
|
330
|
+
const nestedRestElement = prop.type.rest[0]
|
|
331
|
+
if (nestedRestElement.type._tag === "TypeLiteral" && "propertySignatures" in nestedRestElement.type) {
|
|
332
|
+
|
|
333
|
+
for (const nestedProp of nestedRestElement.type.propertySignatures) {
|
|
334
|
+
const nestedPropKey = `${propKey}.${nestedProp.name.toString()}`
|
|
335
|
+
|
|
336
|
+
const nestedPropMeta = createMeta<T>({
|
|
337
|
+
parent: nestedPropKey,
|
|
338
|
+
property: nestedProp.type,
|
|
339
|
+
meta: {
|
|
340
|
+
required: !isNullableOrUndefined(nestedProp.type),
|
|
341
|
+
nullableOrUndefined: isNullableOrUndefined(nestedProp.type)
|
|
342
|
+
}
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
// add to accumulator if valid
|
|
346
|
+
if (nestedPropMeta && typeof nestedPropMeta === 'object' && 'type' in nestedPropMeta) {
|
|
347
|
+
acc[nestedPropKey as NestedKeyOf<T>] = nestedPropMeta as FieldMeta
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
} else {
|
|
357
|
+
// If no struct members and no arrays, process as regular union
|
|
358
|
+
const newMeta = createMeta<T>({
|
|
359
|
+
parent: key,
|
|
360
|
+
property: p.type,
|
|
361
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
362
|
+
})
|
|
363
|
+
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
364
|
+
}
|
|
300
365
|
}
|
|
301
|
-
}
|
|
302
|
-
if ("propertySignatures" in typeToProcess) {
|
|
366
|
+
} else if ("propertySignatures" in typeToProcess) {
|
|
303
367
|
Object.assign(
|
|
304
368
|
acc,
|
|
305
369
|
createMeta<T>({
|
|
@@ -380,6 +444,8 @@ export const createMeta = <T = any>(
|
|
|
380
444
|
property: p.type,
|
|
381
445
|
meta: { required: isRequired, nullableOrUndefined },
|
|
382
446
|
})
|
|
447
|
+
|
|
448
|
+
|
|
383
449
|
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
384
450
|
}
|
|
385
451
|
}
|
|
@@ -54,6 +54,7 @@ const meta = computed(() => {
|
|
|
54
54
|
|
|
55
55
|
const schema = computed(() => {
|
|
56
56
|
if (!meta.value) {
|
|
57
|
+
console.log(props.name, Object.keys(props.form.meta), props.form.meta)
|
|
57
58
|
throw new Error("Meta is undefined")
|
|
58
59
|
}
|
|
59
60
|
return generateInputStandardSchemaFromFieldMeta(meta.value)
|