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