@effect-app/vue-components 0.0.3 → 0.0.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/types/components/OmegaForm/OmegaFormStuff.d.ts +1 -1
- package/dist/vue-components.es.js +266 -252
- package/package.json +3 -3
- package/src/components/OmegaForm/OmegaFormStuff.ts +1 -0
- package/src/components/OmegaForm/OmegaInput.vue +36 -49
- package/src/components/OmegaForm/OmegaInternalInput.vue +30 -59
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S, type Effect } from "effect-app";
|
|
2
2
|
import { type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, type FormApi, type VueFormApi, type FieldComponent, type FormOptions, type DeepKeys, type FieldValidateOrFn, type FieldAsyncValidateOrFn, type FormState } from "@tanstack/vue-form";
|
|
3
3
|
import type { Component } from "vue";
|
|
4
|
-
export type TypeOverride = "string" | "number" | "select" | "multiple" | "boolean";
|
|
4
|
+
export type TypeOverride = "string" | "text" | "number" | "select" | "multiple" | "boolean";
|
|
5
5
|
export interface OmegaError {
|
|
6
6
|
label: string;
|
|
7
7
|
inputId: string;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { computed as
|
|
2
|
-
import { useStore as
|
|
3
|
-
import { S as i, pipe as
|
|
4
|
-
import { VTextField as
|
|
5
|
-
import { mdiRefresh as
|
|
6
|
-
function
|
|
7
|
-
return
|
|
8
|
-
const
|
|
1
|
+
import { computed as O, ref as le, readonly as Ae, provide as oe, inject as ue, defineComponent as U, watch as L, createElementBlock as k, openBlock as g, withModifiers as Ie, unref as f, createElementVNode as _, renderSlot as me, useId as Me, onMounted as $e, watchEffect as Ue, resolveComponent as I, createBlock as v, createCommentVNode as T, mergeProps as q, normalizeClass as Le, createVNode as M, resolveDynamicComponent as A, withCtx as E, Transition as Ve, toDisplayString as w, Fragment as ne, renderList as re, createTextVNode as ae, defineCustomElement as V } from "vue";
|
|
2
|
+
import { useStore as $, useForm as Ne } from "@tanstack/vue-form";
|
|
3
|
+
import { S as i, pipe as Ce, Option as S } from "effect-app";
|
|
4
|
+
import { VTextField as se, VSelect as Fe } from "vuetify/components";
|
|
5
|
+
import { mdiRefresh as Be, mdiLink as je } from "@mdi/js";
|
|
6
|
+
function Pe(e, n) {
|
|
7
|
+
return O(() => n ? $(e.store, (s) => {
|
|
8
|
+
const l = {};
|
|
9
9
|
for (const a of n)
|
|
10
|
-
|
|
11
|
-
return
|
|
10
|
+
l[a] = s[a];
|
|
11
|
+
return l;
|
|
12
12
|
}).value : {});
|
|
13
13
|
}
|
|
14
14
|
const N = Symbol();
|
|
15
|
-
function
|
|
16
|
-
const t =
|
|
17
|
-
t.value = t.value.filter((
|
|
18
|
-
},
|
|
19
|
-
|
|
15
|
+
function de(e, n) {
|
|
16
|
+
const t = le([]), s = (u) => {
|
|
17
|
+
t.value = t.value.filter((o) => o.inputId !== u);
|
|
18
|
+
}, l = (u) => {
|
|
19
|
+
s(u.inputId), t.value.push(u);
|
|
20
20
|
}, a = () => {
|
|
21
21
|
t.value = [];
|
|
22
22
|
}, d = {
|
|
23
|
-
errors:
|
|
24
|
-
addError:
|
|
25
|
-
removeError:
|
|
23
|
+
errors: Ae(t),
|
|
24
|
+
addError: l,
|
|
25
|
+
removeError: s,
|
|
26
26
|
clearErrors: a,
|
|
27
27
|
formSubmissionAttempts: e,
|
|
28
28
|
generalErrors: n
|
|
29
29
|
};
|
|
30
|
-
return
|
|
30
|
+
return oe(N, d), d;
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
const e =
|
|
32
|
+
function C() {
|
|
33
|
+
const e = ue(N);
|
|
34
34
|
if (!e)
|
|
35
35
|
throw new Error("useOmegaErrors must be used within an OmegaForm provider");
|
|
36
36
|
return e;
|
|
37
37
|
}
|
|
38
|
-
const
|
|
38
|
+
const Ke = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
39
39
|
__proto__: null,
|
|
40
40
|
OmegaErrorsKey: N,
|
|
41
|
-
provideOmegaErrors:
|
|
42
|
-
useOmegaErrors:
|
|
43
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
44
|
-
const e =
|
|
41
|
+
provideOmegaErrors: de,
|
|
42
|
+
useOmegaErrors: C
|
|
43
|
+
}, Symbol.toStringTag, { value: "Module" })), fe = Symbol(), ge = () => {
|
|
44
|
+
const e = ue(fe);
|
|
45
45
|
if (!e)
|
|
46
46
|
throw new Error("useIntl must be used within a IntlProvider");
|
|
47
47
|
return e;
|
|
48
|
-
},
|
|
48
|
+
}, dt = (e) => oe(fe, e), Re = i.NonEmptyArray(i.String), De = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKeyword" || n === i.Null.ast), xe = (e) => !e || !i.AST.isUnion(e) ? !1 : e.types.find((n) => n._tag === "UndefinedKeyword") ? "undefined" : e.types.find((n) => n === i.Null.ast) ? "null" : !1, y = ({ meta: e = {}, parent: n = "", property: t, propertySignatures: s }, l = {}) => {
|
|
49
49
|
if (t && t._tag === "Transformation")
|
|
50
50
|
return y({
|
|
51
51
|
parent: n,
|
|
@@ -57,37 +57,37 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
57
57
|
meta: e,
|
|
58
58
|
propertySignatures: t.propertySignatures
|
|
59
59
|
});
|
|
60
|
-
if (
|
|
61
|
-
for (const a of
|
|
62
|
-
const d = n ? `${n}.${a.name.toString()}` : a.name.toString(), u =
|
|
60
|
+
if (s) {
|
|
61
|
+
for (const a of s) {
|
|
62
|
+
const d = n ? `${n}.${a.name.toString()}` : a.name.toString(), u = xe(a.type), o = e.required ?? !u;
|
|
63
63
|
let p = a.type;
|
|
64
64
|
if (i.AST.isUnion(a.type) && (p = a.type.types.find(
|
|
65
65
|
(m) => m._tag !== "UndefinedKeyword" && m !== i.Null.ast
|
|
66
66
|
)), "propertySignatures" in p)
|
|
67
67
|
Object.assign(
|
|
68
|
-
|
|
68
|
+
l,
|
|
69
69
|
y({
|
|
70
70
|
parent: d,
|
|
71
71
|
propertySignatures: p.propertySignatures,
|
|
72
|
-
meta: { required:
|
|
72
|
+
meta: { required: o, nullableOrUndefined: u }
|
|
73
73
|
})
|
|
74
74
|
);
|
|
75
75
|
else {
|
|
76
76
|
const m = y({
|
|
77
77
|
parent: d,
|
|
78
78
|
property: a.type,
|
|
79
|
-
meta: { required:
|
|
79
|
+
meta: { required: o, nullableOrUndefined: u }
|
|
80
80
|
});
|
|
81
|
-
|
|
81
|
+
l[d] = m;
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
return
|
|
84
|
+
return l;
|
|
85
85
|
}
|
|
86
86
|
if (t) {
|
|
87
|
-
const a =
|
|
87
|
+
const a = De(t);
|
|
88
88
|
if (Object.hasOwnProperty.call(e, "required") || (e.required = !a), i.AST.isUnion(t)) {
|
|
89
89
|
const u = t.types.find(
|
|
90
|
-
(
|
|
90
|
+
(o) => o._tag !== "UndefinedKeyword" && o !== i.Null.ast
|
|
91
91
|
);
|
|
92
92
|
return "propertySignatures" in u ? y({
|
|
93
93
|
propertySignatures: u.propertySignatures,
|
|
@@ -96,7 +96,7 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
96
96
|
}) : t.types.every(i.AST.isLiteral) ? {
|
|
97
97
|
...e,
|
|
98
98
|
type: "select",
|
|
99
|
-
members: t.types.map((
|
|
99
|
+
members: t.types.map((o) => o.literal)
|
|
100
100
|
} : {
|
|
101
101
|
...e,
|
|
102
102
|
...y({
|
|
@@ -115,7 +115,7 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
115
115
|
const d = i.AST.getAnnotation(
|
|
116
116
|
t,
|
|
117
117
|
i.AST.JSONSchemaAnnotationId
|
|
118
|
-
).pipe(
|
|
118
|
+
).pipe(S.getOrElse(() => ({})));
|
|
119
119
|
return e = { ...e, ...d }, "from" in t ? y({
|
|
120
120
|
parent: n,
|
|
121
121
|
meta: e,
|
|
@@ -124,50 +124,50 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
124
124
|
t,
|
|
125
125
|
i.AST.TitleAnnotationId
|
|
126
126
|
).pipe(
|
|
127
|
-
|
|
127
|
+
S.getOrElse(() => "unknown")
|
|
128
128
|
), e);
|
|
129
129
|
}
|
|
130
|
-
return
|
|
131
|
-
},
|
|
130
|
+
return l;
|
|
131
|
+
}, pe = (e) => {
|
|
132
132
|
const n = e.ast, t = {};
|
|
133
133
|
if (n._tag === "Transformation" || n._tag === "Refinement")
|
|
134
|
-
return
|
|
134
|
+
return pe(i.make(n.from));
|
|
135
135
|
if ("propertySignatures" in n) {
|
|
136
|
-
const
|
|
136
|
+
const s = y({
|
|
137
137
|
propertySignatures: n.propertySignatures
|
|
138
138
|
});
|
|
139
|
-
if (Object.values(
|
|
140
|
-
return
|
|
141
|
-
const
|
|
139
|
+
if (Object.values(s).every((a) => a && "type" in a))
|
|
140
|
+
return s;
|
|
141
|
+
const l = (a, d = "") => {
|
|
142
142
|
for (const u in a) {
|
|
143
|
-
const
|
|
144
|
-
a[u] && typeof a[u] == "object" && "type" in a[u] ? t[
|
|
143
|
+
const o = d ? `${d}.${u}` : u;
|
|
144
|
+
a[u] && typeof a[u] == "object" && "type" in a[u] ? t[o] = a[u] : a[u] && typeof a[u] == "object" && l(a[u], o);
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
|
-
|
|
147
|
+
l(s);
|
|
148
148
|
}
|
|
149
149
|
return t;
|
|
150
|
-
},
|
|
151
|
-
const n =
|
|
150
|
+
}, ze = (e) => i.extend(e, i.Struct({})), ce = (e) => {
|
|
151
|
+
const n = pe(e), t = Ce(
|
|
152
152
|
e.ast,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
({ items:
|
|
153
|
+
S.liftPredicate((s) => s._tag === "Refinement" && "filter" in s),
|
|
154
|
+
S.flatMap((s) => i.AST.getJSONSchemaAnnotation(s)),
|
|
155
|
+
S.filter((s) => "items" in s),
|
|
156
|
+
S.filterMap(
|
|
157
|
+
({ items: s }) => i.decodeUnknownOption(Re)(s)
|
|
158
158
|
),
|
|
159
|
-
|
|
159
|
+
S.zipWith(
|
|
160
160
|
i.AST.getMessageAnnotation(e.ast),
|
|
161
|
-
(
|
|
162
|
-
items:
|
|
163
|
-
message:
|
|
161
|
+
(s, l) => ({
|
|
162
|
+
items: s,
|
|
163
|
+
message: l("")
|
|
164
164
|
})
|
|
165
165
|
),
|
|
166
|
-
|
|
166
|
+
S.getOrUndefined
|
|
167
167
|
);
|
|
168
168
|
return { schema: e, meta: n, filterItems: t };
|
|
169
|
-
},
|
|
170
|
-
const { trans: n } =
|
|
169
|
+
}, ve = (e) => {
|
|
170
|
+
const { trans: n } = ge();
|
|
171
171
|
let t;
|
|
172
172
|
switch (e.type) {
|
|
173
173
|
case "string":
|
|
@@ -249,30 +249,30 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
249
249
|
message: () => n("validation.empty")
|
|
250
250
|
})
|
|
251
251
|
) : t = i.NullishOr(t), i.standardSchemaV1(t);
|
|
252
|
-
},
|
|
252
|
+
}, Je = (e, n) => i.NullOr(e).pipe(
|
|
253
253
|
i.transform(i.typeSchema(e), {
|
|
254
254
|
decode: (t) => t ?? n(),
|
|
255
255
|
encode: (t) => t
|
|
256
256
|
})
|
|
257
|
-
),
|
|
257
|
+
), he = (e, n) => {
|
|
258
258
|
if (!e) throw new Error("Schema is required");
|
|
259
|
-
const t = i.standardSchemaV1(e), { filterItems:
|
|
259
|
+
const t = i.standardSchemaV1(e), { filterItems: s, meta: l } = ce(e), a = Ne({
|
|
260
260
|
...n,
|
|
261
261
|
validators: {
|
|
262
262
|
onSubmit: t,
|
|
263
263
|
...(n == null ? void 0 : n.validators) || {}
|
|
264
264
|
},
|
|
265
|
-
onSubmit: n != null && n.onSubmit ? ({ formApi: u, meta:
|
|
265
|
+
onSubmit: n != null && n.onSubmit ? ({ formApi: u, meta: o, value: p }) => {
|
|
266
266
|
var m;
|
|
267
267
|
return (m = n.onSubmit) == null ? void 0 : m.call(n, {
|
|
268
268
|
formApi: u,
|
|
269
|
-
meta:
|
|
269
|
+
meta: o,
|
|
270
270
|
value: p
|
|
271
271
|
});
|
|
272
272
|
} : void 0
|
|
273
273
|
});
|
|
274
|
-
return Object.assign(a, { meta:
|
|
275
|
-
},
|
|
274
|
+
return Object.assign(a, { meta: l, filterItems: s });
|
|
275
|
+
}, We = ["disabled"], Ge = /* @__PURE__ */ U({
|
|
276
276
|
__name: "OmegaWrapper",
|
|
277
277
|
props: {
|
|
278
278
|
subscribe: {},
|
|
@@ -289,50 +289,51 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
289
289
|
onSubmit: { type: Function }
|
|
290
290
|
},
|
|
291
291
|
setup(e, { expose: n }) {
|
|
292
|
-
const t = e,
|
|
293
|
-
n(
|
|
294
|
-
const a =
|
|
295
|
-
|
|
292
|
+
const t = e, s = t.form ?? he(t.schema, t), l = $(s.store, (o) => o.isSubmitting);
|
|
293
|
+
n(s);
|
|
294
|
+
const a = Pe(
|
|
295
|
+
s,
|
|
296
296
|
t.subscribe
|
|
297
|
-
), d =
|
|
298
|
-
|
|
299
|
-
(
|
|
300
|
-
), u =
|
|
301
|
-
return
|
|
302
|
-
() => [
|
|
297
|
+
), d = $(
|
|
298
|
+
s.store,
|
|
299
|
+
(o) => o.submissionAttempts
|
|
300
|
+
), u = s.useStore((o) => o.errors);
|
|
301
|
+
return L(
|
|
302
|
+
() => [s.filterItems, u.value],
|
|
303
303
|
() => {
|
|
304
|
-
const
|
|
305
|
-
return
|
|
304
|
+
const o = s.filterItems;
|
|
305
|
+
return o ? u.value ? (Object.values(u.value).filter(
|
|
306
306
|
(m) => !!m
|
|
307
307
|
).flatMap(
|
|
308
|
-
(m) => Object.values(m).flat().map((
|
|
309
|
-
).some((m) => m ===
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
...
|
|
308
|
+
(m) => Object.values(m).flat().map((h) => h.message)
|
|
309
|
+
).some((m) => m === o.message) && o.items.forEach((m) => {
|
|
310
|
+
const h = s.getFieldMeta(m);
|
|
311
|
+
s.setFieldMeta(m, {
|
|
312
|
+
...h,
|
|
313
313
|
errorMap: {
|
|
314
|
-
onSubmit: [{ path: [m], message:
|
|
314
|
+
onSubmit: [{ path: [m], message: o.message }]
|
|
315
315
|
}
|
|
316
316
|
});
|
|
317
317
|
}), {}) : {} : {};
|
|
318
318
|
}
|
|
319
|
-
),
|
|
320
|
-
onSubmit: p[0] || (p[0] =
|
|
319
|
+
), de(d, u), (o, p) => (g(), k("form", {
|
|
320
|
+
onSubmit: p[0] || (p[0] = Ie((m) => f(s).handleSubmit(), ["prevent", "stop"]))
|
|
321
321
|
}, [
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
form: f(
|
|
322
|
+
_("fieldset", { disabled: f(l) }, [
|
|
323
|
+
me(o.$slots, "default", {
|
|
324
|
+
form: f(s),
|
|
325
325
|
subscribedValues: f(a)
|
|
326
326
|
}, void 0, !0)
|
|
327
|
-
], 8,
|
|
327
|
+
], 8, We)
|
|
328
328
|
], 32));
|
|
329
329
|
}
|
|
330
|
-
}),
|
|
330
|
+
}), be = (e, n) => {
|
|
331
331
|
const t = e.__vccOpts || e;
|
|
332
|
-
for (const [
|
|
333
|
-
t[
|
|
332
|
+
for (const [s, l] of n)
|
|
333
|
+
t[s] = l;
|
|
334
334
|
return t;
|
|
335
|
-
},
|
|
335
|
+
}, ye = /* @__PURE__ */ be(Ge, [["__scopeId", "data-v-0de09910"]]), He = { class: "omega-input" }, Qe = /* @__PURE__ */ U({
|
|
336
|
+
inheritAttrs: !1,
|
|
336
337
|
__name: "OmegaInternalInput",
|
|
337
338
|
props: {
|
|
338
339
|
field: {},
|
|
@@ -343,107 +344,120 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
343
344
|
validators: {}
|
|
344
345
|
},
|
|
345
346
|
setup(e) {
|
|
346
|
-
const n = e, t =
|
|
347
|
-
var
|
|
348
|
-
return n.type ? n.type : ((
|
|
349
|
-
}), d =
|
|
350
|
-
() =>
|
|
347
|
+
const n = e, t = Me(), s = n.field, l = $(s.store, (r) => r), a = O(() => {
|
|
348
|
+
var r, c;
|
|
349
|
+
return n.type ? n.type : ((r = n.meta) == null ? void 0 : r.type) === "string" ? n.meta.format === "email" ? "email" : "string" : ((c = n.meta) == null ? void 0 : c.type) || "unknown";
|
|
350
|
+
}), d = O(() => l.value.value), u = O(
|
|
351
|
+
() => l.value.meta.errors.map((r) => r.message).filter(Boolean)
|
|
351
352
|
);
|
|
352
|
-
|
|
353
|
+
L(
|
|
353
354
|
() => [!!d.value],
|
|
354
355
|
() => {
|
|
355
|
-
var
|
|
356
|
-
u.value.length && !d.value && !((
|
|
357
|
-
((
|
|
356
|
+
var r, c;
|
|
357
|
+
u.value.length && !d.value && !((r = n.meta) != null && r.required) && s.setValue(
|
|
358
|
+
((c = n.meta) == null ? void 0 : c.nullableOrUndefined) === "undefined" ? void 0 : null
|
|
358
359
|
);
|
|
359
360
|
}
|
|
360
|
-
),
|
|
361
|
-
var
|
|
362
|
-
!d.value && !((
|
|
361
|
+
), $e(() => {
|
|
362
|
+
var r, c;
|
|
363
|
+
!d.value && !((r = n.meta) != null && r.required) && ((c = n.meta) == null ? void 0 : c.nullableOrUndefined) === "null" && s.setValue(null);
|
|
363
364
|
});
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
}, { addError: m, formSubmissionAttempts:
|
|
367
|
-
|
|
368
|
-
|
|
365
|
+
const o = le(!1), p = () => {
|
|
366
|
+
o.value = !0;
|
|
367
|
+
}, { addError: m, formSubmissionAttempts: h, removeError: we } = C();
|
|
368
|
+
Ue(() => {
|
|
369
|
+
h.value > 0 && (o.value = !0);
|
|
369
370
|
});
|
|
370
|
-
const
|
|
371
|
-
return
|
|
372
|
-
() =>
|
|
371
|
+
const b = O(() => !o.value && a.value !== "select" ? [] : u.value);
|
|
372
|
+
return L(
|
|
373
|
+
() => l.value.meta.errors,
|
|
373
374
|
() => {
|
|
374
|
-
|
|
375
|
+
l.value.meta.errors.length ? m({
|
|
375
376
|
inputId: t,
|
|
376
|
-
errors:
|
|
377
|
+
errors: l.value.meta.errors.map((r) => r.message).filter(Boolean),
|
|
377
378
|
label: n.label
|
|
378
|
-
}) :
|
|
379
|
+
}) : we(t);
|
|
379
380
|
}
|
|
380
|
-
), (
|
|
381
|
-
var
|
|
382
|
-
const
|
|
383
|
-
return
|
|
384
|
-
a.value === "email" || a.value === "
|
|
385
|
-
key: 0,
|
|
381
|
+
), (r, c) => {
|
|
382
|
+
var F, B, j, P, K, R, D, x, z, J, W, G, H, Q, X, Y, Z, ee;
|
|
383
|
+
const _e = I("v-textarea"), qe = I("v-btn");
|
|
384
|
+
return g(), k("div", He, [
|
|
385
|
+
a.value === "email" || a.value === "string" ? (g(), v(f(se), q({ key: 0 }, r.$attrs, {
|
|
386
386
|
id: f(t),
|
|
387
|
-
required: (
|
|
388
|
-
"min-length": ((
|
|
389
|
-
"max-length": ((
|
|
387
|
+
required: (F = r.meta) == null ? void 0 : F.required,
|
|
388
|
+
"min-length": ((B = r.meta) == null ? void 0 : B.type) === "string" && ((j = r.meta) == null ? void 0 : j.minLength),
|
|
389
|
+
"max-length": ((P = r.meta) == null ? void 0 : P.type) === "string" && ((K = r.meta) == null ? void 0 : K.maxLength),
|
|
390
390
|
type: a.value,
|
|
391
|
-
name:
|
|
392
|
-
label: `${
|
|
393
|
-
"model-value":
|
|
394
|
-
"error-messages":
|
|
395
|
-
error: !!
|
|
396
|
-
"onUpdate:modelValue":
|
|
391
|
+
name: r.field.name,
|
|
392
|
+
label: `${r.label}${(R = r.meta) != null && R.required ? " *" : ""}`,
|
|
393
|
+
"model-value": r.field.state.value,
|
|
394
|
+
"error-messages": b.value,
|
|
395
|
+
error: !!b.value.length,
|
|
396
|
+
"onUpdate:modelValue": r.field.handleChange,
|
|
397
397
|
onBlur: p
|
|
398
|
-
}, null,
|
|
399
|
-
a.value === "
|
|
400
|
-
key: 1,
|
|
398
|
+
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "model-value", "error-messages", "error", "onUpdate:modelValue"])) : T("", !0),
|
|
399
|
+
a.value === "text" ? (g(), v(_e, q({ key: 1 }, r.$attrs, {
|
|
401
400
|
id: f(t),
|
|
402
|
-
required: (
|
|
403
|
-
min: ((
|
|
404
|
-
max: ((
|
|
401
|
+
required: (D = r.meta) == null ? void 0 : D.required,
|
|
402
|
+
"min-length": ((x = r.meta) == null ? void 0 : x.type) === "string" && ((z = r.meta) == null ? void 0 : z.minLength),
|
|
403
|
+
"max-length": ((J = r.meta) == null ? void 0 : J.type) === "string" && ((W = r.meta) == null ? void 0 : W.maxLength),
|
|
405
404
|
type: a.value,
|
|
406
|
-
name:
|
|
407
|
-
label: `${
|
|
408
|
-
"model-value":
|
|
409
|
-
"error-messages":
|
|
410
|
-
error: !!
|
|
411
|
-
"onUpdate:modelValue":
|
|
412
|
-
|
|
405
|
+
name: r.field.name,
|
|
406
|
+
label: `${r.label}${(G = r.meta) != null && G.required ? " *" : ""}`,
|
|
407
|
+
"model-value": r.field.state.value,
|
|
408
|
+
"error-messages": b.value,
|
|
409
|
+
error: !!b.value.length,
|
|
410
|
+
"onUpdate:modelValue": r.field.handleChange,
|
|
411
|
+
onBlur: p
|
|
412
|
+
}), null, 16, ["id", "required", "min-length", "max-length", "type", "name", "label", "model-value", "error-messages", "error", "onUpdate:modelValue"])) : T("", !0),
|
|
413
|
+
a.value === "number" ? (g(), v(f(se), q({ key: 2 }, r.$attrs, {
|
|
414
|
+
id: f(t),
|
|
415
|
+
required: (H = r.meta) == null ? void 0 : H.required,
|
|
416
|
+
min: ((Q = r.meta) == null ? void 0 : Q.type) === "number" && r.meta.minimum,
|
|
417
|
+
max: ((X = r.meta) == null ? void 0 : X.type) === "number" && r.meta.maximum,
|
|
418
|
+
type: a.value,
|
|
419
|
+
name: r.field.name,
|
|
420
|
+
label: `${r.label}${(Y = r.meta) != null && Y.required ? " *" : ""}`,
|
|
421
|
+
"model-value": r.field.state.value,
|
|
422
|
+
"error-messages": b.value,
|
|
423
|
+
error: !!b.value.length,
|
|
424
|
+
"onUpdate:modelValue": c[0] || (c[0] = (te) => {
|
|
425
|
+
r.field.handleChange(Number(te));
|
|
413
426
|
}),
|
|
414
427
|
onBlur: p
|
|
415
|
-
}, null,
|
|
416
|
-
a.value === "select" || a.value === "multiple" ? (
|
|
417
|
-
key:
|
|
418
|
-
class:
|
|
428
|
+
}), null, 16, ["id", "required", "min", "max", "type", "name", "label", "model-value", "error-messages", "error"])) : T("", !0),
|
|
429
|
+
a.value === "select" || a.value === "multiple" ? (g(), k("div", {
|
|
430
|
+
key: 3,
|
|
431
|
+
class: Le(a.value !== "multiple" && "d-flex align-center")
|
|
419
432
|
}, [
|
|
420
|
-
|
|
433
|
+
M(f(Fe), q(r.$attrs, {
|
|
421
434
|
id: f(t),
|
|
422
|
-
required: (
|
|
435
|
+
required: (Z = r.meta) == null ? void 0 : Z.required,
|
|
423
436
|
multiple: a.value === "multiple",
|
|
424
437
|
chips: a.value === "multiple",
|
|
425
|
-
name:
|
|
426
|
-
"model-value":
|
|
427
|
-
label: `${
|
|
428
|
-
items:
|
|
429
|
-
"error-messages":
|
|
430
|
-
error: !!
|
|
431
|
-
"onUpdate:modelValue":
|
|
438
|
+
name: r.field.name,
|
|
439
|
+
"model-value": r.field.state.value,
|
|
440
|
+
label: `${r.label}${(ee = r.meta) != null && ee.required ? " *" : ""}`,
|
|
441
|
+
items: r.options,
|
|
442
|
+
"error-messages": b.value,
|
|
443
|
+
error: !!b.value.length,
|
|
444
|
+
"onUpdate:modelValue": r.field.handleChange,
|
|
432
445
|
onBlur: p
|
|
433
|
-
}, null,
|
|
434
|
-
a.value !== "multiple" ? (
|
|
446
|
+
}), null, 16, ["id", "required", "multiple", "chips", "name", "model-value", "label", "items", "error-messages", "error", "onUpdate:modelValue"]),
|
|
447
|
+
a.value !== "multiple" ? (g(), v(qe, {
|
|
435
448
|
key: 0,
|
|
436
449
|
"variant-btn": "secondary",
|
|
437
|
-
"variant-icon": f(
|
|
450
|
+
"variant-icon": f(Be),
|
|
438
451
|
class: "mr-2",
|
|
439
452
|
title: "Reset",
|
|
440
|
-
onClick:
|
|
441
|
-
}, null, 8, ["variant-icon"])) :
|
|
442
|
-
], 2)) :
|
|
453
|
+
onClick: c[1] || (c[1] = (te) => r.field.handleChange(void 0))
|
|
454
|
+
}, null, 8, ["variant-icon"])) : T("", !0)
|
|
455
|
+
], 2)) : T("", !0)
|
|
443
456
|
]);
|
|
444
457
|
};
|
|
445
458
|
}
|
|
446
|
-
}),
|
|
459
|
+
}), Se = /* @__PURE__ */ U({
|
|
460
|
+
inheritAttrs: !1,
|
|
447
461
|
__name: "OmegaInput",
|
|
448
462
|
props: {
|
|
449
463
|
form: {},
|
|
@@ -454,86 +468,86 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
454
468
|
type: {}
|
|
455
469
|
},
|
|
456
470
|
setup(e) {
|
|
457
|
-
const n = e, t =
|
|
471
|
+
const n = e, t = O(() => n.form.meta[n.name]), s = O(() => {
|
|
458
472
|
if (!t.value)
|
|
459
473
|
throw new Error("Meta is undefined");
|
|
460
|
-
return
|
|
474
|
+
return ve(t.value);
|
|
461
475
|
});
|
|
462
|
-
return (
|
|
463
|
-
name:
|
|
476
|
+
return (l, a) => (g(), v(A(l.form.Field), {
|
|
477
|
+
name: l.name,
|
|
464
478
|
validators: {
|
|
465
|
-
onChange:
|
|
466
|
-
...
|
|
479
|
+
onChange: s.value,
|
|
480
|
+
...l.validators
|
|
467
481
|
}
|
|
468
482
|
}, {
|
|
469
|
-
default:
|
|
483
|
+
default: E(({
|
|
470
484
|
field: d
|
|
471
485
|
}) => [
|
|
472
|
-
|
|
486
|
+
me(l.$slots, "default", {
|
|
473
487
|
field: d,
|
|
474
|
-
label:
|
|
475
|
-
options:
|
|
488
|
+
label: l.label,
|
|
489
|
+
options: l.options,
|
|
476
490
|
meta: t.value,
|
|
477
|
-
type:
|
|
491
|
+
type: l.type
|
|
478
492
|
}, () => [
|
|
479
|
-
|
|
493
|
+
M(Qe, q(l.$attrs, {
|
|
480
494
|
field: d,
|
|
481
|
-
label:
|
|
482
|
-
options:
|
|
495
|
+
label: l.label,
|
|
496
|
+
options: l.options,
|
|
483
497
|
meta: t.value,
|
|
484
|
-
type:
|
|
485
|
-
}, null,
|
|
498
|
+
type: l.type
|
|
499
|
+
}), null, 16, ["field", "label", "options", "meta", "type"])
|
|
486
500
|
])
|
|
487
501
|
]),
|
|
488
502
|
_: 3
|
|
489
503
|
}, 8, ["name", "validators"]));
|
|
490
504
|
}
|
|
491
|
-
}),
|
|
505
|
+
}), Xe = {
|
|
492
506
|
key: 0,
|
|
493
507
|
class: "error-alert"
|
|
494
|
-
},
|
|
508
|
+
}, Ye = { class: "text-h6 mb-3" }, Ze = { class: "font-weight-medium" }, et = { class: "error-message" }, tt = ["href"], nt = { key: 1 }, rt = /* @__PURE__ */ U({
|
|
495
509
|
__name: "OmegaErrors",
|
|
496
510
|
setup(e) {
|
|
497
|
-
const { errors: n, formSubmissionAttempts: t, generalErrors:
|
|
511
|
+
const { errors: n, formSubmissionAttempts: t, generalErrors: s } = C(), { trans: l } = ge(), a = O(() => s.value ? s.value.filter(
|
|
498
512
|
(d) => !!d
|
|
499
513
|
).flatMap(
|
|
500
514
|
(d) => Object.values(d).filter((u) => !!u).flatMap(
|
|
501
515
|
(u) => u.filter(
|
|
502
|
-
(
|
|
503
|
-
).map((
|
|
516
|
+
(o) => !!(o != null && o.message)
|
|
517
|
+
).map((o) => o.message)
|
|
504
518
|
)
|
|
505
519
|
) : []);
|
|
506
520
|
return (d, u) => {
|
|
507
|
-
const
|
|
508
|
-
return
|
|
509
|
-
default:
|
|
510
|
-
f(t) > 0 && (f(n).length || a.value.length) ? (
|
|
511
|
-
|
|
521
|
+
const o = I("v-icon"), p = I("v-alert");
|
|
522
|
+
return g(), v(Ve, null, {
|
|
523
|
+
default: E(() => [
|
|
524
|
+
f(t) > 0 && (f(n).length || a.value.length) ? (g(), k("div", Xe, [
|
|
525
|
+
M(p, {
|
|
512
526
|
type: "error",
|
|
513
527
|
variant: "tonal",
|
|
514
528
|
role: "alert",
|
|
515
529
|
"aria-live": "polite",
|
|
516
530
|
class: "mb-4"
|
|
517
531
|
}, {
|
|
518
|
-
default:
|
|
519
|
-
|
|
520
|
-
f(n).length ? (
|
|
532
|
+
default: E(() => [
|
|
533
|
+
_("div", Ye, w(f(l)("form.includes_error")) + ":", 1),
|
|
534
|
+
f(n).length ? (g(), v(A(f(n).length > 1 ? "ul" : "div"), {
|
|
521
535
|
key: 0,
|
|
522
536
|
class: "error-list"
|
|
523
537
|
}, {
|
|
524
|
-
default:
|
|
525
|
-
(
|
|
538
|
+
default: E(() => [
|
|
539
|
+
(g(!0), k(ne, null, re(f(n), (m) => (g(), v(A(f(n).length > 1 ? "li" : "div"), {
|
|
526
540
|
key: m.inputId,
|
|
527
541
|
class: "error-item"
|
|
528
542
|
}, {
|
|
529
|
-
default:
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
(
|
|
533
|
-
default:
|
|
534
|
-
(
|
|
535
|
-
default:
|
|
536
|
-
|
|
543
|
+
default: E(() => [
|
|
544
|
+
_("div", Ze, w(m.label), 1),
|
|
545
|
+
_("div", et, [
|
|
546
|
+
(g(), v(A(m.errors.length > 1 ? "ul" : "div"), { class: "error-list" }, {
|
|
547
|
+
default: E(() => [
|
|
548
|
+
(g(!0), k(ne, null, re(m.errors, (h) => (g(), v(A(m.errors.length > 1 ? "li" : "span"), { key: h }, {
|
|
549
|
+
default: E(() => [
|
|
550
|
+
ae(w(h), 1)
|
|
537
551
|
]),
|
|
538
552
|
_: 2
|
|
539
553
|
}, 1024))), 128))
|
|
@@ -541,68 +555,68 @@ const $e = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
541
555
|
_: 2
|
|
542
556
|
}, 1024))
|
|
543
557
|
]),
|
|
544
|
-
|
|
558
|
+
_("a", {
|
|
545
559
|
href: `#${m.inputId}`,
|
|
546
560
|
class: "error-link"
|
|
547
561
|
}, [
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
], 8,
|
|
562
|
+
M(o, { icon: f(je) }, null, 8, ["icon"]),
|
|
563
|
+
ae(" " + w(f(l)("form.fix_input")), 1)
|
|
564
|
+
], 8, tt)
|
|
551
565
|
]),
|
|
552
566
|
_: 2
|
|
553
567
|
}, 1024))), 128))
|
|
554
568
|
]),
|
|
555
569
|
_: 1
|
|
556
|
-
})) : (
|
|
570
|
+
})) : (g(), k("span", nt, w(a.value[0]), 1))
|
|
557
571
|
]),
|
|
558
572
|
_: 1
|
|
559
573
|
})
|
|
560
|
-
])) :
|
|
574
|
+
])) : T("", !0)
|
|
561
575
|
]),
|
|
562
576
|
_: 1
|
|
563
577
|
});
|
|
564
578
|
};
|
|
565
579
|
}
|
|
566
|
-
}),
|
|
567
|
-
function
|
|
568
|
-
customElements.get("omega-form") || customElements.define("omega-form",
|
|
580
|
+
}), Oe = /* @__PURE__ */ be(rt, [["__scopeId", "data-v-55fda615"]]), Ee = V(ye), ke = V(Se), Te = V(Oe);
|
|
581
|
+
function at() {
|
|
582
|
+
customElements.get("omega-form") || customElements.define("omega-form", Ee), customElements.get("omega-input") || customElements.define("omega-input", ke), customElements.get("omega-errors") || customElements.define("omega-errors", Te);
|
|
569
583
|
}
|
|
570
|
-
const
|
|
584
|
+
const ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
571
585
|
__proto__: null,
|
|
572
|
-
OmegaErrors:
|
|
573
|
-
OmegaErrorsCE:
|
|
574
|
-
OmegaErrorsContext:
|
|
575
|
-
OmegaForm:
|
|
576
|
-
OmegaFormCE:
|
|
577
|
-
OmegaInput:
|
|
578
|
-
OmegaInputCE:
|
|
579
|
-
duplicateSchema:
|
|
580
|
-
generateInputStandardSchemaFromFieldMeta:
|
|
581
|
-
generateMetaFromSchema:
|
|
582
|
-
nullableInput:
|
|
583
|
-
registerOmegaForm:
|
|
584
|
-
useOmegaForm:
|
|
586
|
+
OmegaErrors: Oe,
|
|
587
|
+
OmegaErrorsCE: Te,
|
|
588
|
+
OmegaErrorsContext: Ke,
|
|
589
|
+
OmegaForm: ye,
|
|
590
|
+
OmegaFormCE: Ee,
|
|
591
|
+
OmegaInput: Se,
|
|
592
|
+
OmegaInputCE: ke,
|
|
593
|
+
duplicateSchema: ze,
|
|
594
|
+
generateInputStandardSchemaFromFieldMeta: ve,
|
|
595
|
+
generateMetaFromSchema: ce,
|
|
596
|
+
nullableInput: Je,
|
|
597
|
+
registerOmegaForm: at,
|
|
598
|
+
useOmegaForm: he
|
|
585
599
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
586
|
-
function
|
|
587
|
-
for (const n in
|
|
588
|
-
e.component(n,
|
|
600
|
+
function st(e) {
|
|
601
|
+
for (const n in ie)
|
|
602
|
+
e.component(n, ie[n]);
|
|
589
603
|
}
|
|
590
|
-
const
|
|
604
|
+
const ft = { install: st };
|
|
591
605
|
export {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
606
|
+
Oe as OmegaErrors,
|
|
607
|
+
Te as OmegaErrorsCE,
|
|
608
|
+
Ke as OmegaErrorsContext,
|
|
609
|
+
ye as OmegaForm,
|
|
610
|
+
Ee as OmegaFormCE,
|
|
611
|
+
Se as OmegaInput,
|
|
612
|
+
ke as OmegaInputCE,
|
|
613
|
+
ft as default,
|
|
614
|
+
ze as duplicateSchema,
|
|
615
|
+
ve as generateInputStandardSchemaFromFieldMeta,
|
|
616
|
+
ce as generateMetaFromSchema,
|
|
617
|
+
Je as nullableInput,
|
|
618
|
+
dt as provideIntl,
|
|
619
|
+
at as registerOmegaForm,
|
|
620
|
+
ge as useIntl,
|
|
621
|
+
he as useOmegaForm
|
|
608
622
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"@tanstack/vue-form": "^1.1.3",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"./dist/vue-components.css": "./dist/vue-components.css"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@effect-app/vue": "2.39.
|
|
40
|
-
"effect-app": "2.
|
|
39
|
+
"@effect-app/vue": "2.39.4",
|
|
40
|
+
"effect-app": "2.38.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "rimraf dist && vue-tsc && vite build",
|
|
@@ -1,54 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component
|
|
3
|
-
:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
any,
|
|
31
|
-
any,
|
|
32
|
-
any,
|
|
33
|
-
any,
|
|
34
|
-
any
|
|
35
|
-
>
|
|
36
|
-
}"
|
|
37
|
-
>
|
|
38
|
-
<slot
|
|
39
|
-
:field="field"
|
|
40
|
-
:label="label"
|
|
41
|
-
:options="options"
|
|
42
|
-
:meta="meta"
|
|
43
|
-
:type="type"
|
|
2
|
+
<component :is="form.Field" :name="name" :validators="{
|
|
3
|
+
onChange: schema,
|
|
4
|
+
...validators,
|
|
5
|
+
}">
|
|
6
|
+
<template #default="{
|
|
7
|
+
field,
|
|
8
|
+
}: {
|
|
9
|
+
// TODO: exact type
|
|
10
|
+
field: FieldApi<
|
|
11
|
+
any,
|
|
12
|
+
any,
|
|
13
|
+
any,
|
|
14
|
+
any,
|
|
15
|
+
any,
|
|
16
|
+
any,
|
|
17
|
+
any,
|
|
18
|
+
any,
|
|
19
|
+
any,
|
|
20
|
+
any,
|
|
21
|
+
any,
|
|
22
|
+
any,
|
|
23
|
+
any,
|
|
24
|
+
any,
|
|
25
|
+
any,
|
|
26
|
+
any,
|
|
27
|
+
any,
|
|
28
|
+
any,
|
|
29
|
+
any
|
|
44
30
|
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
:
|
|
49
|
-
:meta="meta"
|
|
50
|
-
:type="type"
|
|
51
|
-
/>
|
|
31
|
+
}">
|
|
32
|
+
<slot :field="field" :label="label" :options="options" :meta="meta" :type="type">
|
|
33
|
+
<OmegaInternalInput v-bind="$attrs" :field="field" :label="label" :options="options" :meta="meta"
|
|
34
|
+
:type="type" />
|
|
52
35
|
</slot>
|
|
53
36
|
</template>
|
|
54
37
|
</component>
|
|
@@ -67,6 +50,10 @@ import {
|
|
|
67
50
|
import OmegaInternalInput from "./OmegaInternalInput.vue"
|
|
68
51
|
import type { FieldApi } from "@tanstack/vue-form"
|
|
69
52
|
|
|
53
|
+
defineOptions({
|
|
54
|
+
inheritAttrs: false
|
|
55
|
+
})
|
|
56
|
+
|
|
70
57
|
const props = defineProps<{
|
|
71
58
|
form: FormType<From, To> & {
|
|
72
59
|
meta: MetaRecord<To>
|
|
@@ -1,65 +1,31 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="omega-input">
|
|
3
|
-
<v-text-field
|
|
4
|
-
|
|
5
|
-
:
|
|
6
|
-
:
|
|
7
|
-
:
|
|
8
|
-
|
|
9
|
-
:type="
|
|
10
|
-
:name="field.name"
|
|
11
|
-
:
|
|
12
|
-
:model-value="field.
|
|
13
|
-
|
|
14
|
-
:
|
|
15
|
-
|
|
16
|
-
@
|
|
17
|
-
/>
|
|
18
|
-
<v-text-field
|
|
19
|
-
v-if="fieldType === 'number'"
|
|
20
|
-
:id="id"
|
|
21
|
-
:required="meta?.required"
|
|
22
|
-
:min="meta?.type === 'number' && meta.minimum"
|
|
23
|
-
:max="meta?.type === 'number' && meta.maximum"
|
|
24
|
-
:type="fieldType"
|
|
25
|
-
:name="field.name"
|
|
26
|
-
:label="`${label}${meta?.required ? ' *' : ''}`"
|
|
27
|
-
:model-value="field.state.value"
|
|
28
|
-
:error-messages="showedErrors"
|
|
29
|
-
:error="!!showedErrors.length"
|
|
30
|
-
@update:model-value="
|
|
3
|
+
<v-text-field v-bind="$attrs" v-if="fieldType === 'email' || fieldType === 'string'" :id="id"
|
|
4
|
+
:required="meta?.required" :min-length="meta?.type === 'string' && meta?.minLength"
|
|
5
|
+
:max-length="meta?.type === 'string' && meta?.maxLength" :type="fieldType" :name="field.name"
|
|
6
|
+
:label="`${label}${meta?.required ? ' *' : ''}`" :model-value="field.state.value" :error-messages="showedErrors"
|
|
7
|
+
:error="!!showedErrors.length" @update:model-value="field.handleChange" @blur="setRealDirty" />
|
|
8
|
+
<v-textarea v-bind="$attrs" v-if="fieldType === 'text'" :id="id" :required="meta?.required"
|
|
9
|
+
:min-length="meta?.type === 'string' && meta?.minLength" :max-length="meta?.type === 'string' && meta?.maxLength"
|
|
10
|
+
:type="fieldType" :name="field.name" :label="`${label}${meta?.required ? ' *' : ''}`"
|
|
11
|
+
:model-value="field.state.value" :error-messages="showedErrors" :error="!!showedErrors.length"
|
|
12
|
+
@update:model-value="field.handleChange" @blur="setRealDirty" />
|
|
13
|
+
<v-text-field v-bind="$attrs" v-if="fieldType === 'number'" :id="id" :required="meta?.required"
|
|
14
|
+
:min="meta?.type === 'number' && meta.minimum" :max="meta?.type === 'number' && meta.maximum" :type="fieldType"
|
|
15
|
+
:name="field.name" :label="`${label}${meta?.required ? ' *' : ''}`" :model-value="field.state.value"
|
|
16
|
+
:error-messages="showedErrors" :error="!!showedErrors.length" @update:model-value="
|
|
31
17
|
(e: any) => {
|
|
32
18
|
field.handleChange(Number(e))
|
|
33
19
|
}
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<v-
|
|
42
|
-
|
|
43
|
-
:required="meta?.required"
|
|
44
|
-
:multiple="fieldType === 'multiple'"
|
|
45
|
-
:chips="fieldType === 'multiple'"
|
|
46
|
-
:name="field.name"
|
|
47
|
-
:model-value="field.state.value"
|
|
48
|
-
:label="`${label}${meta?.required ? ' *' : ''}`"
|
|
49
|
-
:items="options"
|
|
50
|
-
:error-messages="showedErrors"
|
|
51
|
-
:error="!!showedErrors.length"
|
|
52
|
-
@update:model-value="field.handleChange"
|
|
53
|
-
@blur="setRealDirty"
|
|
54
|
-
/>
|
|
55
|
-
<v-btn
|
|
56
|
-
v-if="fieldType !== 'multiple'"
|
|
57
|
-
variant-btn="secondary"
|
|
58
|
-
:variant-icon="mdiRefresh"
|
|
59
|
-
class="mr-2"
|
|
60
|
-
title="Reset"
|
|
61
|
-
@click="field.handleChange(undefined)"
|
|
62
|
-
></v-btn>
|
|
20
|
+
" @blur="setRealDirty" />
|
|
21
|
+
<div v-if="fieldType === 'select' || fieldType === 'multiple'"
|
|
22
|
+
:class="fieldType !== 'multiple' && 'd-flex align-center'">
|
|
23
|
+
<v-select v-bind="$attrs" :id="id" :required="meta?.required" :multiple="fieldType === 'multiple'"
|
|
24
|
+
:chips="fieldType === 'multiple'" :name="field.name" :model-value="field.state.value"
|
|
25
|
+
:label="`${label}${meta?.required ? ' *' : ''}`" :items="options" :error-messages="showedErrors"
|
|
26
|
+
:error="!!showedErrors.length" @update:model-value="field.handleChange" @blur="setRealDirty" />
|
|
27
|
+
<v-btn v-if="fieldType !== 'multiple'" variant-btn="secondary" :variant-icon="mdiRefresh" class="mr-2"
|
|
28
|
+
title="Reset" @click="field.handleChange(undefined)"></v-btn>
|
|
63
29
|
</div>
|
|
64
30
|
</div>
|
|
65
31
|
</template>
|
|
@@ -107,6 +73,10 @@ const props = defineProps<{
|
|
|
107
73
|
validators?: FieldValidators<To>
|
|
108
74
|
}>()
|
|
109
75
|
|
|
76
|
+
defineOptions({
|
|
77
|
+
inheritAttrs: false
|
|
78
|
+
})
|
|
79
|
+
|
|
110
80
|
const id = useId()
|
|
111
81
|
|
|
112
82
|
const fieldApi = props.field
|
|
@@ -117,7 +87,7 @@ const fieldType = computed(() => {
|
|
|
117
87
|
if (props.type) return props.type
|
|
118
88
|
if (props.meta?.type === "string") {
|
|
119
89
|
if (props.meta.format === "email") return "email"
|
|
120
|
-
return "
|
|
90
|
+
return "string"
|
|
121
91
|
}
|
|
122
92
|
return props.meta?.type || "unknown"
|
|
123
93
|
})
|
|
@@ -208,7 +178,8 @@ watch(
|
|
|
208
178
|
|
|
209
179
|
& .v-messages {
|
|
210
180
|
transition: all 0.2s;
|
|
211
|
-
|
|
181
|
+
|
|
182
|
+
>* {
|
|
212
183
|
transition-duration: 0s !important;
|
|
213
184
|
}
|
|
214
185
|
}
|