@effect-app/vue-components 0.14.3 → 0.14.6
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 +174 -125
- 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 +11 -11
- package/dist/vue-components.es7.js +31 -42
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaArray.vue +13 -33
- package/src/components/OmegaForm/OmegaFormStuff.ts +85 -16
- 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,200 +1,249 @@
|
|
|
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), 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: 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(), a = g(r.type), p = !a, b = r.type;
|
|
18
|
+
if (n.AST.isUnion(r.type)) {
|
|
19
|
+
const y = r.type.types.filter(
|
|
20
|
+
(s) => s._tag !== "UndefinedKeyword" && s !== n.Null.ast
|
|
21
21
|
);
|
|
22
|
-
if (
|
|
23
|
-
(
|
|
22
|
+
if (y.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: u,
|
|
28
|
+
property: r.type,
|
|
29
|
+
meta: { required: p, nullableOrUndefined: a }
|
|
30
|
+
});
|
|
31
|
+
l[u] = s;
|
|
32
|
+
}
|
|
33
|
+
for (const s of y)
|
|
34
|
+
"propertySignatures" in s && Object.assign(
|
|
35
|
+
l,
|
|
34
36
|
m({
|
|
35
|
-
parent:
|
|
36
|
-
propertySignatures:
|
|
37
|
-
meta: { required:
|
|
37
|
+
parent: u,
|
|
38
|
+
propertySignatures: s.propertySignatures,
|
|
39
|
+
meta: { required: p, nullableOrUndefined: a }
|
|
38
40
|
})
|
|
39
41
|
);
|
|
40
42
|
} else {
|
|
41
|
-
const
|
|
42
|
-
parent:
|
|
43
|
-
property:
|
|
44
|
-
meta: { required:
|
|
43
|
+
const s = m({
|
|
44
|
+
parent: u,
|
|
45
|
+
property: r.type,
|
|
46
|
+
meta: { required: p, nullableOrUndefined: a }
|
|
45
47
|
});
|
|
46
|
-
u
|
|
48
|
+
l[u] = s;
|
|
47
49
|
}
|
|
48
|
-
}
|
|
49
|
-
if ("propertySignatures" in d)
|
|
50
|
+
} else if ("propertySignatures" in b)
|
|
50
51
|
Object.assign(
|
|
51
|
-
|
|
52
|
+
l,
|
|
52
53
|
m({
|
|
53
|
-
parent:
|
|
54
|
-
propertySignatures:
|
|
55
|
-
meta: { required:
|
|
54
|
+
parent: u,
|
|
55
|
+
propertySignatures: b.propertySignatures,
|
|
56
|
+
meta: { required: p, nullableOrUndefined: a }
|
|
56
57
|
})
|
|
57
58
|
);
|
|
59
|
+
else if (n.AST.isTupleType(r.type))
|
|
60
|
+
if (r.type.rest.length > 0 && r.type.rest[0].type._tag === "TypeLiteral" && "propertySignatures" in r.type.rest[0].type) {
|
|
61
|
+
const c = r.type.rest[0].type;
|
|
62
|
+
if (c._tag === "TypeLiteral" && "propertySignatures" in c)
|
|
63
|
+
for (const s of c.propertySignatures) {
|
|
64
|
+
const S = `${u}.${s.name.toString()}`;
|
|
65
|
+
if (n.AST.isTupleType(s.type) && s.type.rest.length > 0) {
|
|
66
|
+
const d = s.type.rest[0].type;
|
|
67
|
+
if (d._tag === "TypeLiteral" && "propertySignatures" in d)
|
|
68
|
+
for (const T of d.propertySignatures) {
|
|
69
|
+
const h = `${S}.${T.name.toString()}`, x = m({
|
|
70
|
+
parent: h,
|
|
71
|
+
property: T.type,
|
|
72
|
+
meta: {
|
|
73
|
+
required: !g(T.type),
|
|
74
|
+
nullableOrUndefined: g(T.type)
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
l[h] = x;
|
|
78
|
+
}
|
|
79
|
+
else
|
|
80
|
+
l[S] = {
|
|
81
|
+
type: "multiple",
|
|
82
|
+
members: s.type.elements,
|
|
83
|
+
rest: s.type.rest,
|
|
84
|
+
required: !g(s.type),
|
|
85
|
+
nullableOrUndefined: g(s.type)
|
|
86
|
+
};
|
|
87
|
+
} else {
|
|
88
|
+
const d = m({
|
|
89
|
+
parent: S,
|
|
90
|
+
property: s.type,
|
|
91
|
+
meta: {
|
|
92
|
+
required: !g(s.type),
|
|
93
|
+
nullableOrUndefined: g(s.type)
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
l[S] = d;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} else
|
|
100
|
+
l[u] = {
|
|
101
|
+
type: "multiple",
|
|
102
|
+
members: r.type.elements,
|
|
103
|
+
rest: r.type.rest,
|
|
104
|
+
required: p,
|
|
105
|
+
nullableOrUndefined: a
|
|
106
|
+
};
|
|
58
107
|
else {
|
|
59
|
-
const
|
|
60
|
-
parent:
|
|
61
|
-
property:
|
|
62
|
-
meta: { required:
|
|
108
|
+
const y = m({
|
|
109
|
+
parent: u,
|
|
110
|
+
property: r.type,
|
|
111
|
+
meta: { required: p, nullableOrUndefined: a }
|
|
63
112
|
});
|
|
64
|
-
u
|
|
113
|
+
l[u] = y;
|
|
65
114
|
}
|
|
66
115
|
}
|
|
67
|
-
return
|
|
116
|
+
return l;
|
|
68
117
|
}
|
|
69
|
-
if (
|
|
70
|
-
const
|
|
71
|
-
if (Object.hasOwnProperty.call(e, "required") || (e.required = !
|
|
72
|
-
const
|
|
73
|
-
(
|
|
118
|
+
if (t) {
|
|
119
|
+
const r = L(t);
|
|
120
|
+
if (Object.hasOwnProperty.call(e, "required") || (e.required = !r), n.AST.isUnion(t)) {
|
|
121
|
+
const a = t.types.find(
|
|
122
|
+
(p) => p._tag !== "UndefinedKeyword" && p !== n.Null.ast
|
|
74
123
|
);
|
|
75
|
-
return "propertySignatures" in
|
|
76
|
-
propertySignatures:
|
|
124
|
+
return "propertySignatures" in a ? m({
|
|
125
|
+
propertySignatures: a.propertySignatures,
|
|
77
126
|
parent: i,
|
|
78
127
|
meta: e
|
|
79
|
-
}) :
|
|
128
|
+
}) : t.types.every(n.AST.isLiteral) ? {
|
|
80
129
|
...e,
|
|
81
130
|
type: "select",
|
|
82
|
-
members:
|
|
131
|
+
members: t.types.map((p) => p.literal)
|
|
83
132
|
} : {
|
|
84
133
|
...e,
|
|
85
134
|
...m({
|
|
86
135
|
parent: i,
|
|
87
136
|
meta: e,
|
|
88
|
-
property:
|
|
137
|
+
property: a
|
|
89
138
|
})
|
|
90
139
|
};
|
|
91
140
|
}
|
|
92
|
-
if (
|
|
141
|
+
if (n.AST.isTupleType(t))
|
|
93
142
|
return {
|
|
94
143
|
...e,
|
|
95
144
|
type: "multiple",
|
|
96
|
-
members:
|
|
97
|
-
rest:
|
|
145
|
+
members: t.elements,
|
|
146
|
+
rest: t.rest
|
|
98
147
|
};
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
).pipe(
|
|
103
|
-
return e = { ...e, ...
|
|
148
|
+
const u = n.AST.getAnnotation(
|
|
149
|
+
t,
|
|
150
|
+
n.AST.JSONSchemaAnnotationId
|
|
151
|
+
).pipe(f.getOrElse(() => ({})));
|
|
152
|
+
return e = { ...e, ...u }, "from" in t ? m({
|
|
104
153
|
parent: i,
|
|
105
154
|
meta: e,
|
|
106
|
-
property:
|
|
107
|
-
}) : (e.type =
|
|
108
|
-
|
|
109
|
-
|
|
155
|
+
property: t.from
|
|
156
|
+
}) : (e.type = n.AST.getAnnotation(
|
|
157
|
+
t,
|
|
158
|
+
n.AST.TitleAnnotationId
|
|
110
159
|
).pipe(
|
|
111
|
-
|
|
160
|
+
f.getOrElse(() => "unknown")
|
|
112
161
|
), e);
|
|
113
162
|
}
|
|
114
|
-
return
|
|
115
|
-
},
|
|
116
|
-
const i = e.ast,
|
|
163
|
+
return l;
|
|
164
|
+
}, v = (e) => {
|
|
165
|
+
const i = e.ast, t = {};
|
|
117
166
|
if (i._tag === "Transformation" || i._tag === "Refinement")
|
|
118
|
-
return
|
|
167
|
+
return v(n.make(i.from));
|
|
119
168
|
if ("propertySignatures" in i) {
|
|
120
|
-
const
|
|
169
|
+
const o = m({
|
|
121
170
|
propertySignatures: i.propertySignatures
|
|
122
171
|
});
|
|
123
|
-
if (Object.values(
|
|
124
|
-
return
|
|
125
|
-
const
|
|
126
|
-
for (const
|
|
127
|
-
const
|
|
128
|
-
|
|
172
|
+
if (Object.values(o).every((r) => r && "type" in r))
|
|
173
|
+
return o;
|
|
174
|
+
const l = (r, u = "") => {
|
|
175
|
+
for (const a in r) {
|
|
176
|
+
const p = u ? `${u}.${a}` : a;
|
|
177
|
+
r[a] && typeof r[a] == "object" && "type" in r[a] ? t[p] = r[a] : r[a] && typeof r[a] == "object" && l(r[a], p);
|
|
129
178
|
}
|
|
130
179
|
};
|
|
131
|
-
|
|
180
|
+
l(o);
|
|
132
181
|
}
|
|
133
|
-
return
|
|
134
|
-
},
|
|
135
|
-
const i =
|
|
182
|
+
return t;
|
|
183
|
+
}, N = (e) => n.extend(e, n.Struct({})), _ = (e) => {
|
|
184
|
+
const i = v(e), t = O(
|
|
136
185
|
e.ast,
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
({ items:
|
|
186
|
+
f.liftPredicate((o) => o._tag === "Refinement" && "filter" in o),
|
|
187
|
+
f.flatMap((o) => n.AST.getJSONSchemaAnnotation(o)),
|
|
188
|
+
f.filter((o) => "items" in o),
|
|
189
|
+
f.filterMap(
|
|
190
|
+
({ items: o }) => n.decodeUnknownOption(M)(o)
|
|
142
191
|
),
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
(
|
|
146
|
-
items:
|
|
147
|
-
message:
|
|
192
|
+
f.zipWith(
|
|
193
|
+
n.AST.getMessageAnnotation(e.ast),
|
|
194
|
+
(o, l) => ({
|
|
195
|
+
items: o,
|
|
196
|
+
message: l("")
|
|
148
197
|
})
|
|
149
198
|
),
|
|
150
|
-
|
|
199
|
+
f.getOrUndefined
|
|
151
200
|
);
|
|
152
|
-
return { schema: e, meta: i, filterItems:
|
|
153
|
-
},
|
|
154
|
-
const { trans: i } =
|
|
155
|
-
let
|
|
201
|
+
return { schema: e, meta: i, filterItems: t };
|
|
202
|
+
}, k = (e) => {
|
|
203
|
+
const { trans: i } = A();
|
|
204
|
+
let t;
|
|
156
205
|
switch (e.type) {
|
|
157
206
|
case "string":
|
|
158
|
-
|
|
207
|
+
t = n.String.annotations({
|
|
159
208
|
message: () => i("validation.empty")
|
|
160
|
-
}), e.format === "email" && (
|
|
161
|
-
|
|
162
|
-
|
|
209
|
+
}), e.format === "email" && (t = n.compose(
|
|
210
|
+
t,
|
|
211
|
+
n.Email.annotations({
|
|
163
212
|
message: () => i("validation.email.invalid")
|
|
164
213
|
})
|
|
165
|
-
)), e.required &&
|
|
214
|
+
)), e.required && t.annotations({
|
|
166
215
|
message: () => i("validation.empty")
|
|
167
|
-
}), e.maxLength && (
|
|
216
|
+
}), e.maxLength && (t = t.pipe(n.maxLength(e.maxLength)).annotations({
|
|
168
217
|
message: () => i("validation.string.maxLength", {
|
|
169
218
|
maxLength: e.maxLength
|
|
170
219
|
})
|
|
171
|
-
})), e.minLength && (
|
|
220
|
+
})), e.minLength && (t = t.pipe(n.minLength(e.minLength)).annotations({
|
|
172
221
|
message: () => i("validation.string.minLength", {
|
|
173
222
|
minLength: e.minLength
|
|
174
223
|
})
|
|
175
224
|
}));
|
|
176
225
|
break;
|
|
177
226
|
case "number":
|
|
178
|
-
|
|
227
|
+
t = n.Number.annotations({
|
|
179
228
|
message: () => i("validation.empty")
|
|
180
|
-
}), e.required &&
|
|
229
|
+
}), e.required && t.annotations({
|
|
181
230
|
message: () => i("validation.empty")
|
|
182
|
-
}), e.minimum && (
|
|
231
|
+
}), e.minimum && (t = t.pipe(n.greaterThanOrEqualTo(e.minimum)).annotations({
|
|
183
232
|
message: () => i("validation.number.min", {
|
|
184
233
|
minimum: e.minimum,
|
|
185
234
|
isExclusive: !0
|
|
186
235
|
})
|
|
187
|
-
})), e.maximum && (
|
|
236
|
+
})), e.maximum && (t = t.pipe(n.lessThanOrEqualTo(e.maximum)).annotations({
|
|
188
237
|
message: () => i("validation.number.max", {
|
|
189
238
|
maximum: e.maximum,
|
|
190
239
|
isExclusive: !0
|
|
191
240
|
})
|
|
192
|
-
})), e.exclusiveMinimum && (
|
|
241
|
+
})), e.exclusiveMinimum && (t = t.pipe(n.greaterThan(e.exclusiveMinimum)).annotations({
|
|
193
242
|
message: () => i("validation.number.min", {
|
|
194
243
|
minimum: e.exclusiveMinimum,
|
|
195
244
|
isExclusive: !1
|
|
196
245
|
})
|
|
197
|
-
})), e.exclusiveMaximum && (
|
|
246
|
+
})), e.exclusiveMaximum && (t = t.pipe(n.lessThan(e.exclusiveMaximum)).annotations({
|
|
198
247
|
message: () => i("validation.number.max", {
|
|
199
248
|
maximum: e.exclusiveMaximum,
|
|
200
249
|
isExclusive: !1
|
|
@@ -202,7 +251,7 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
|
|
|
202
251
|
}));
|
|
203
252
|
break;
|
|
204
253
|
case "select":
|
|
205
|
-
|
|
254
|
+
t = n.Literal(...e.members).annotations({
|
|
206
255
|
message: () => ({
|
|
207
256
|
message: i("validation.not_a_valid", {
|
|
208
257
|
type: "select",
|
|
@@ -213,7 +262,7 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
|
|
|
213
262
|
});
|
|
214
263
|
break;
|
|
215
264
|
case "multiple":
|
|
216
|
-
|
|
265
|
+
t = n.Array(n.String).annotations({
|
|
217
266
|
message: () => i("validation.not_a_valid", {
|
|
218
267
|
type: "multiple",
|
|
219
268
|
message: e.members.join(", ")
|
|
@@ -221,28 +270,28 @@ const x = t.NonEmptyArray(t.String), T = (e) => t.AST.isUnion(e) && e.types.find
|
|
|
221
270
|
});
|
|
222
271
|
break;
|
|
223
272
|
case "boolean":
|
|
224
|
-
|
|
273
|
+
t = n.Boolean;
|
|
225
274
|
break;
|
|
226
275
|
// todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
|
|
227
276
|
case "unknown":
|
|
228
|
-
|
|
277
|
+
t = n.Unknown;
|
|
229
278
|
break;
|
|
230
279
|
}
|
|
231
|
-
return e.required ?
|
|
232
|
-
|
|
280
|
+
return e.required ? t.pipe(
|
|
281
|
+
n.annotations({
|
|
233
282
|
message: () => i("validation.empty")
|
|
234
283
|
})
|
|
235
|
-
) :
|
|
236
|
-
},
|
|
237
|
-
|
|
238
|
-
decode: (
|
|
239
|
-
encode: (
|
|
284
|
+
) : t = n.NullishOr(t), n.standardSchemaV1(t);
|
|
285
|
+
}, w = (e, i) => n.NullOr(e).pipe(
|
|
286
|
+
n.transform(n.typeSchema(e), {
|
|
287
|
+
decode: (t) => t ?? i(),
|
|
288
|
+
encode: (t) => t
|
|
240
289
|
})
|
|
241
290
|
);
|
|
242
291
|
export {
|
|
243
292
|
m as createMeta,
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
293
|
+
N as duplicateSchema,
|
|
294
|
+
k as generateInputStandardSchemaFromFieldMeta,
|
|
295
|
+
_ as generateMetaFromSchema,
|
|
296
|
+
w as nullableInput
|
|
248
297
|
};
|
|
@@ -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
|
-
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,6 +1,5 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
|
|
3
|
-
const C = /* @__PURE__ */ y({
|
|
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({
|
|
4
3
|
inheritAttrs: !1,
|
|
5
4
|
__name: "OmegaArray",
|
|
6
5
|
props: {
|
|
@@ -9,48 +8,38 @@ const C = /* @__PURE__ */ y({
|
|
|
9
8
|
defaultItems: {},
|
|
10
9
|
items: {}
|
|
11
10
|
},
|
|
12
|
-
setup(
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
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);
|
|
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 v = l(() => (a) => {
|
|
17
|
+
const t = a.replace(/\[\d+\]/g, "");
|
|
18
|
+
return r.form.meta[t];
|
|
38
19
|
});
|
|
39
|
-
return
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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));
|
|
52
41
|
}
|
|
53
42
|
});
|
|
54
43
|
export {
|
|
55
|
-
|
|
44
|
+
B as default
|
|
56
45
|
};
|
package/package.json
CHANGED
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
/>
|
|
18
18
|
</template>
|
|
19
19
|
</component>
|
|
20
|
+
<component :is="form.Field" :name="name">
|
|
21
|
+
<template #default="{ field }">
|
|
22
|
+
<slot name="field" v-bind="{ field }" />
|
|
23
|
+
</template>
|
|
24
|
+
</component>
|
|
20
25
|
</template>
|
|
21
|
-
|
|
22
26
|
<script
|
|
23
27
|
setup
|
|
24
28
|
lang="ts"
|
|
@@ -29,9 +33,7 @@
|
|
|
29
33
|
>
|
|
30
34
|
import { computed, onMounted, provide } from "vue"
|
|
31
35
|
import {
|
|
32
|
-
type CreateMeta,
|
|
33
36
|
type OmegaInputProps,
|
|
34
|
-
createMeta,
|
|
35
37
|
} from "./OmegaFormStuff"
|
|
36
38
|
import { type DeepValue, type DeepKeys } from "@tanstack/vue-form"
|
|
37
39
|
|
|
@@ -52,10 +54,8 @@ defineOptions({
|
|
|
52
54
|
|
|
53
55
|
const store = props.form.useStore(state => state.values)
|
|
54
56
|
const items = computed(() => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return acc[curr]
|
|
58
|
-
}
|
|
57
|
+
const normalizedPath = props.name.replace(/\[/g, ".").replace(/\]/g, "")
|
|
58
|
+
return normalizedPath.split(".").reduce((acc, curr) => {
|
|
59
59
|
return acc[curr] as typeof store.value
|
|
60
60
|
}, store.value)
|
|
61
61
|
})
|
|
@@ -67,34 +67,14 @@ onMounted(async () => {
|
|
|
67
67
|
})
|
|
68
68
|
|
|
69
69
|
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)
|
|
70
|
+
const getMeta = (path: string) => {
|
|
71
|
+
// Transform path like 'a[0].b[11].c' into 'a.b.c'
|
|
72
|
+
const simplifiedPath = path.replace(/\[\d+\]/g, '')
|
|
87
73
|
|
|
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
|
|
74
|
+
return props.form.meta[simplifiedPath as keyof typeof props.form.meta]
|
|
96
75
|
}
|
|
97
|
-
|
|
76
|
+
|
|
77
|
+
return getMeta
|
|
98
78
|
})
|
|
99
79
|
|
|
100
80
|
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)) {
|
|
@@ -267,14 +268,16 @@ export const createMeta = <T = any>(
|
|
|
267
268
|
)
|
|
268
269
|
|
|
269
270
|
if (hasStructMembers) {
|
|
270
|
-
//
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
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
|
+
|
|
278
281
|
// Process each non-null type and merge their metadata
|
|
279
282
|
for (const nonNullType of nonNullTypes) {
|
|
280
283
|
if ("propertySignatures" in nonNullType) {
|
|
@@ -297,8 +300,7 @@ export const createMeta = <T = any>(
|
|
|
297
300
|
})
|
|
298
301
|
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
299
302
|
}
|
|
300
|
-
}
|
|
301
|
-
if ("propertySignatures" in typeToProcess) {
|
|
303
|
+
} else if ("propertySignatures" in typeToProcess) {
|
|
302
304
|
Object.assign(
|
|
303
305
|
acc,
|
|
304
306
|
createMeta<T>({
|
|
@@ -308,12 +310,79 @@ export const createMeta = <T = any>(
|
|
|
308
310
|
})
|
|
309
311
|
)
|
|
310
312
|
} else {
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
// Check if this is an array type
|
|
314
|
+
if (S.AST.isTupleType(p.type)) {
|
|
315
|
+
// Check if it has struct elements
|
|
316
|
+
const hasStructElements = p.type.rest.length > 0 &&
|
|
317
|
+
p.type.rest[0].type._tag === "TypeLiteral" &&
|
|
318
|
+
"propertySignatures" in p.type.rest[0].type
|
|
319
|
+
|
|
320
|
+
if (hasStructElements) {
|
|
321
|
+
// For arrays with struct elements, only create meta for nested fields, not the array itself
|
|
322
|
+
const elementType = p.type.rest[0].type
|
|
323
|
+
if (elementType._tag === "TypeLiteral" && "propertySignatures" in elementType) {
|
|
324
|
+
// Process each property in the array element
|
|
325
|
+
for (const prop of elementType.propertySignatures) {
|
|
326
|
+
const propKey = `${key}.${prop.name.toString()}`
|
|
327
|
+
|
|
328
|
+
// Check if the property is another array
|
|
329
|
+
if (S.AST.isTupleType(prop.type) && prop.type.rest.length > 0) {
|
|
330
|
+
const nestedElementType = prop.type.rest[0].type
|
|
331
|
+
if (nestedElementType._tag === "TypeLiteral" && "propertySignatures" in nestedElementType) {
|
|
332
|
+
// Array with struct elements - process nested fields
|
|
333
|
+
for (const nestedProp of nestedElementType.propertySignatures) {
|
|
334
|
+
const nestedKey = `${propKey}.${nestedProp.name.toString()}`
|
|
335
|
+
const nestedMeta = createMeta<T>({
|
|
336
|
+
parent: nestedKey,
|
|
337
|
+
property: nestedProp.type,
|
|
338
|
+
meta: {
|
|
339
|
+
required: !isNullableOrUndefined(nestedProp.type),
|
|
340
|
+
nullableOrUndefined: isNullableOrUndefined(nestedProp.type)
|
|
341
|
+
}
|
|
342
|
+
})
|
|
343
|
+
acc[nestedKey as NestedKeyOf<T>] = nestedMeta as FieldMeta
|
|
344
|
+
}
|
|
345
|
+
} else {
|
|
346
|
+
// Array with primitive elements - create meta for the array itself
|
|
347
|
+
acc[propKey as NestedKeyOf<T>] = {
|
|
348
|
+
type: "multiple",
|
|
349
|
+
members: prop.type.elements,
|
|
350
|
+
rest: prop.type.rest,
|
|
351
|
+
required: !isNullableOrUndefined(prop.type),
|
|
352
|
+
nullableOrUndefined: isNullableOrUndefined(prop.type)
|
|
353
|
+
} as FieldMeta
|
|
354
|
+
}
|
|
355
|
+
} else {
|
|
356
|
+
const fieldMeta = createMeta<T>({
|
|
357
|
+
parent: propKey,
|
|
358
|
+
property: prop.type,
|
|
359
|
+
meta: {
|
|
360
|
+
required: !isNullableOrUndefined(prop.type),
|
|
361
|
+
nullableOrUndefined: isNullableOrUndefined(prop.type)
|
|
362
|
+
}
|
|
363
|
+
})
|
|
364
|
+
acc[propKey as NestedKeyOf<T>] = fieldMeta as FieldMeta
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
// For arrays with primitive elements, create the array meta
|
|
370
|
+
acc[key as NestedKeyOf<T>] = {
|
|
371
|
+
type: "multiple",
|
|
372
|
+
members: p.type.elements,
|
|
373
|
+
rest: p.type.rest,
|
|
374
|
+
required: isRequired,
|
|
375
|
+
nullableOrUndefined
|
|
376
|
+
} as FieldMeta
|
|
377
|
+
}
|
|
378
|
+
} else {
|
|
379
|
+
const newMeta = createMeta<T>({
|
|
380
|
+
parent: key,
|
|
381
|
+
property: p.type,
|
|
382
|
+
meta: { required: isRequired, nullableOrUndefined },
|
|
383
|
+
})
|
|
384
|
+
acc[key as NestedKeyOf<T>] = newMeta as FieldMeta
|
|
385
|
+
}
|
|
317
386
|
}
|
|
318
387
|
}
|
|
319
388
|
return acc
|
|
@@ -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)
|