@effect-app/vue-components 2.10.5 → 2.10.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/useOmegaForm.d.ts +1 -0
- package/dist/vue-components.es10.js +129 -124
- package/dist/vue-components.es11.js +2 -2
- package/dist/vue-components.es12.js +1 -1
- package/dist/vue-components.es16.js +11 -4
- package/dist/vue-components.es17.js +4 -10
- package/dist/vue-components.es18.js +10 -55
- package/dist/vue-components.es19.js +50 -63
- package/dist/vue-components.es20.js +68 -6
- package/dist/vue-components.es21.js +5 -5
- package/dist/vue-components.es22.js +6 -3
- package/dist/vue-components.es23.js +3 -3
- package/dist/vue-components.es24.js +3 -2
- package/dist/vue-components.es25.js +1 -1
- package/dist/vue-components.es26.js +1 -1
- package/dist/vue-components.es27.js +1 -1
- package/dist/vue-components.es28.js +2 -17
- package/dist/vue-components.es29.js +16 -10
- package/dist/vue-components.es31.js +1 -1
- package/dist/vue-components.es32.js +1 -1
- package/dist/vue-components.es5.js +1 -1
- package/dist/vue-components.es6.js +32 -32
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaFormStuff.ts +0 -6
- package/src/components/OmegaForm/OmegaInput.vue +3 -17
- package/src/components/OmegaForm/useOmegaForm.ts +24 -1
|
@@ -25,6 +25,7 @@ export declare class FormErrors<From> extends FormErrors_base<{
|
|
|
25
25
|
}>;
|
|
26
26
|
}> {
|
|
27
27
|
}
|
|
28
|
+
export declare const useErrorLabel: (form: OF<any, any>) => (propsName: string) => string;
|
|
28
29
|
export type Policies = "local" | "session" | "querystring";
|
|
29
30
|
export type defaultValuesPriorityUnion = "tanstack" | "persistency" | "schema";
|
|
30
31
|
export type OmegaConfig<T> = {
|
|
@@ -1,233 +1,238 @@
|
|
|
1
1
|
import { useForm as B } from "@tanstack/vue-form";
|
|
2
|
-
import { Data as K, S as
|
|
3
|
-
import { runtimeFiberAsPromise as T } from "./vue-components.
|
|
4
|
-
import { computed as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import re from "./vue-components.
|
|
10
|
-
import te from "./vue-components.
|
|
11
|
-
import se from "./vue-components.
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
2
|
+
import { Data as K, S as V, Effect as f, Fiber as $, Option as P, Array as F } from "effect-app";
|
|
3
|
+
import { runtimeFiberAsPromise as T } from "./vue-components.es18.js";
|
|
4
|
+
import { computed as x, onUnmounted as W, onMounted as z, onBeforeUnmount as G, watch as D, ref as Z, h as H } from "vue";
|
|
5
|
+
import { useIntl as Q } from "./vue-components.es3.js";
|
|
6
|
+
import X from "./vue-components.es19.js";
|
|
7
|
+
import Y from "./vue-components.es20.js";
|
|
8
|
+
import C from "./vue-components.es21.js";
|
|
9
|
+
import { generateMetaFromSchema as ee, deepMerge as R, defaultsValueFromSchema as re } from "./vue-components.es12.js";
|
|
10
|
+
import te from "./vue-components.es6.js";
|
|
11
|
+
import se from "./vue-components.es8.js";
|
|
12
|
+
import ne from "./vue-components.es22.js";
|
|
13
|
+
import { trace as N } from "./vue-components.es23.js";
|
|
14
|
+
import { context as U } from "./vue-components.es24.js";
|
|
15
|
+
class oe extends K.TaggedError("FormErrors") {
|
|
15
16
|
}
|
|
16
|
-
const g = (
|
|
17
|
+
const g = (i) => function(n) {
|
|
17
18
|
return {
|
|
18
19
|
render() {
|
|
19
20
|
return H(n, {
|
|
20
|
-
form:
|
|
21
|
+
form: i,
|
|
21
22
|
...this.$attrs
|
|
22
23
|
}, this.$slots);
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
|
-
},
|
|
26
|
+
}, ie = (i) => {
|
|
27
|
+
const { formatMessage: l } = Q(), n = (a) => a.replace(/([A-Z])/g, " $1").replace(/^./, (d) => d.toUpperCase()).trim(), m = (a) => l ? l({ id: `general.fields.${a}`, defaultMessage: n(a) }) : n(a);
|
|
28
|
+
return (a) => i.i18nNamespace ? l({ id: `${i.i18nNamespace}.fields.${a}`, defaultMessage: m(a) }) : m(a);
|
|
29
|
+
}, ae = (i) => function(n) {
|
|
26
30
|
return {
|
|
27
31
|
setup() {
|
|
28
|
-
const { fieldMap:
|
|
29
|
-
const
|
|
30
|
-
Object.entries(
|
|
31
|
-
([
|
|
32
|
-
const
|
|
33
|
-
if (!
|
|
34
|
-
const
|
|
35
|
-
return
|
|
36
|
-
label:
|
|
37
|
-
inputId:
|
|
32
|
+
const { fieldMap: m, form: p } = i, a = p.useStore((s) => s.errors), d = p.useStore((s) => s.fieldMeta), M = p.useStore((s) => s.errorMap), j = ie(p), A = x(() => {
|
|
33
|
+
const s = F.filterMap(
|
|
34
|
+
Object.entries(d.value),
|
|
35
|
+
([E, v]) => {
|
|
36
|
+
const h = v.errors ?? [];
|
|
37
|
+
if (!h.length) return P.none();
|
|
38
|
+
const u = m.value.get(E);
|
|
39
|
+
return u ? P.some({
|
|
40
|
+
label: u.label,
|
|
41
|
+
inputId: u.id,
|
|
38
42
|
// Only show the first error
|
|
39
|
-
errors: [
|
|
43
|
+
errors: [h[0]?.message].filter(Boolean)
|
|
40
44
|
}) : P.none();
|
|
41
45
|
}
|
|
42
|
-
),
|
|
46
|
+
), O = [];
|
|
43
47
|
if (M.value.onSubmit) {
|
|
44
|
-
for (const [
|
|
45
|
-
if (F.isArray(
|
|
46
|
-
for (const
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
const
|
|
50
|
-
if (!
|
|
51
|
-
|
|
52
|
-
label:
|
|
53
|
-
inputId:
|
|
54
|
-
errors: [
|
|
48
|
+
for (const [E, v] of Object.entries(M.value.onSubmit))
|
|
49
|
+
if (F.isArray(v) && v.length)
|
|
50
|
+
for (const h of v) {
|
|
51
|
+
const u = h;
|
|
52
|
+
if (u?.path && F.isArray(u.path) && u.path.length) {
|
|
53
|
+
const y = u.path.join(".");
|
|
54
|
+
if (!m.value.has(y)) {
|
|
55
|
+
O.push({
|
|
56
|
+
label: j(y),
|
|
57
|
+
inputId: y,
|
|
58
|
+
errors: [u.message].filter(Boolean)
|
|
55
59
|
});
|
|
56
60
|
break;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
|
-
return [...
|
|
65
|
+
return [...s, ...O];
|
|
62
66
|
});
|
|
63
67
|
return {
|
|
64
|
-
generalErrors:
|
|
65
|
-
errors:
|
|
68
|
+
generalErrors: a,
|
|
69
|
+
errors: A
|
|
66
70
|
};
|
|
67
71
|
},
|
|
68
|
-
render({ errors:
|
|
72
|
+
render({ errors: m, generalErrors: p }) {
|
|
69
73
|
return H(n, {
|
|
70
|
-
errors:
|
|
71
|
-
generalErrors:
|
|
74
|
+
errors: m,
|
|
75
|
+
generalErrors: p,
|
|
72
76
|
...this.$attrs
|
|
73
77
|
}, this.$slots);
|
|
74
78
|
}
|
|
75
79
|
};
|
|
76
|
-
},
|
|
77
|
-
if (!
|
|
78
|
-
const
|
|
80
|
+
}, b = (i, l) => i.includes(l), ge = (i, l, n) => {
|
|
81
|
+
if (!i) throw new Error("Schema is required");
|
|
82
|
+
const m = V.standardSchemaV1(i), p = V.decode(i), { meta: a } = ee(i), d = x(() => {
|
|
79
83
|
if (n?.persistency?.id)
|
|
80
84
|
return n.persistency.id;
|
|
81
|
-
const e = window.location.pathname, r = Object.keys(
|
|
85
|
+
const e = window.location.pathname, r = Object.keys(a);
|
|
82
86
|
return `${e}-${r.join("-")}`;
|
|
83
87
|
}), M = () => {
|
|
84
88
|
const e = new URLSearchParams(window.location.search);
|
|
85
|
-
e.delete(
|
|
89
|
+
e.delete(d.value);
|
|
86
90
|
const r = new URL(window.location.href);
|
|
87
91
|
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
88
|
-
}, j =
|
|
92
|
+
}, j = x(() => {
|
|
89
93
|
let e;
|
|
90
94
|
const r = n?.persistency;
|
|
91
95
|
if (
|
|
92
96
|
// query string has higher priority than local/session storage
|
|
93
|
-
r?.policies && !e && (
|
|
97
|
+
r?.policies && !e && (b(r.policies, "local") || b(r.policies, "session"))
|
|
94
98
|
) {
|
|
95
|
-
const
|
|
96
|
-
if (
|
|
99
|
+
const o = b(r.policies, "local") ? localStorage : sessionStorage;
|
|
100
|
+
if (o)
|
|
97
101
|
try {
|
|
98
102
|
const t = JSON.parse(
|
|
99
|
-
|
|
103
|
+
o.getItem(d.value) || "{}"
|
|
100
104
|
);
|
|
101
|
-
|
|
105
|
+
o.removeItem(d.value), e = t;
|
|
102
106
|
} catch (t) {
|
|
103
107
|
console.error(t);
|
|
104
108
|
}
|
|
105
109
|
}
|
|
106
|
-
if (r?.policies &&
|
|
110
|
+
if (r?.policies && b(r.policies, "querystring"))
|
|
107
111
|
try {
|
|
108
|
-
const t = new URLSearchParams(window.location.search).get(
|
|
109
|
-
M(), t && (e =
|
|
110
|
-
} catch (
|
|
111
|
-
console.error(
|
|
112
|
+
const t = new URLSearchParams(window.location.search).get(d.value);
|
|
113
|
+
M(), t && (e = R(e || {}, JSON.parse(t)));
|
|
114
|
+
} catch (o) {
|
|
115
|
+
console.error(o);
|
|
112
116
|
}
|
|
113
117
|
e ??= {};
|
|
114
|
-
const
|
|
115
|
-
tanstack:
|
|
118
|
+
const c = {
|
|
119
|
+
tanstack: l?.defaultValues || {},
|
|
116
120
|
persistency: e,
|
|
117
|
-
schema:
|
|
121
|
+
schema: re(i)
|
|
118
122
|
};
|
|
119
123
|
return (n?.defaultValuesPriority || ["tanstack", "persistency", "schema"]).reverse().reduce(
|
|
120
|
-
(
|
|
124
|
+
(o, t) => Object.keys(o).length ? R(o, c[t]) : c[t],
|
|
121
125
|
{}
|
|
122
126
|
);
|
|
123
|
-
}),
|
|
124
|
-
...
|
|
127
|
+
}), A = (e, r) => e ? U.with(N.setSpan(U.active(), e), r) : r(), s = B({
|
|
128
|
+
...l,
|
|
125
129
|
validators: {
|
|
126
|
-
onSubmit:
|
|
127
|
-
...
|
|
130
|
+
onSubmit: m,
|
|
131
|
+
...l?.validators || {}
|
|
128
132
|
},
|
|
129
|
-
onSubmit:
|
|
130
|
-
const
|
|
133
|
+
onSubmit: l?.onSubmit ? ({ formApi: e, meta: r, value: c }) => A(r?.currentSpan, async () => {
|
|
134
|
+
const o = await f.runPromise(p(c)), t = l.onSubmit({
|
|
131
135
|
formApi: e,
|
|
132
136
|
meta: r,
|
|
133
|
-
value:
|
|
137
|
+
value: o
|
|
134
138
|
});
|
|
135
|
-
return
|
|
139
|
+
return $.isFiber(t) && $.isRuntimeFiber(t) ? await T(t) : f.isEffect(t) ? await f.runPromise(
|
|
136
140
|
t.pipe(
|
|
137
141
|
// meta?.currentSpan
|
|
138
142
|
// ? Effect.withParentSpan(meta.currentSpan)
|
|
139
143
|
// : (_) => _,
|
|
140
|
-
|
|
144
|
+
f.flatMap((S) => $.join(S))
|
|
141
145
|
)
|
|
142
146
|
) : t;
|
|
143
147
|
}) : void 0,
|
|
144
148
|
defaultValues: j.value
|
|
145
149
|
}), O = () => {
|
|
146
|
-
Object.keys(
|
|
147
|
-
|
|
150
|
+
Object.keys(a).forEach((e) => {
|
|
151
|
+
s.setFieldValue(e, void 0);
|
|
148
152
|
});
|
|
149
|
-
},
|
|
150
|
-
const
|
|
151
|
-
return
|
|
152
|
-
}, {}),
|
|
153
|
+
}, E = (e) => e.reduce((r, c) => {
|
|
154
|
+
const o = c.split(".");
|
|
155
|
+
return o.reduce((t, S, _) => (_ === o.length - 1 ? t[S] = s.getFieldValue(c) : t[S] = t[S] ?? {}, t[S]), r), r;
|
|
156
|
+
}, {}), v = (e) => {
|
|
153
157
|
if (e) {
|
|
154
158
|
if (F.isArray(e.keys))
|
|
155
|
-
return
|
|
159
|
+
return E(e.keys);
|
|
156
160
|
if (F.isArray(e.banKeys)) {
|
|
157
|
-
const r = Object.keys(
|
|
158
|
-
return
|
|
161
|
+
const r = Object.keys(a).filter((c) => e.banKeys?.includes(c));
|
|
162
|
+
return E(r);
|
|
159
163
|
}
|
|
160
|
-
return
|
|
164
|
+
return s.store.state.values;
|
|
161
165
|
}
|
|
162
|
-
},
|
|
166
|
+
}, h = () => {
|
|
163
167
|
const e = n?.persistency;
|
|
164
|
-
if (!(!e?.policies || e.policies.length === 0) && (
|
|
165
|
-
const r =
|
|
168
|
+
if (!(!e?.policies || e.policies.length === 0) && (b(e.policies, "local") || b(e.policies, "session"))) {
|
|
169
|
+
const r = b(e.policies, "local") ? localStorage : sessionStorage;
|
|
166
170
|
if (!r) return;
|
|
167
|
-
const
|
|
168
|
-
return r.setItem(
|
|
171
|
+
const c = v(e);
|
|
172
|
+
return r.setItem(d.value, JSON.stringify(c));
|
|
169
173
|
}
|
|
170
|
-
},
|
|
174
|
+
}, u = () => {
|
|
171
175
|
const e = n?.persistency;
|
|
172
|
-
if (!(!e?.policies || e.policies.length === 0) &&
|
|
173
|
-
const r =
|
|
174
|
-
|
|
175
|
-
const
|
|
176
|
-
|
|
176
|
+
if (!(!e?.policies || e.policies.length === 0) && b(e.policies, "querystring")) {
|
|
177
|
+
const r = v(e), c = new URLSearchParams(window.location.search);
|
|
178
|
+
c.set(d.value, JSON.stringify(r));
|
|
179
|
+
const o = new URL(window.location.href);
|
|
180
|
+
o.search = c.toString(), window.history.replaceState({}, "", o.toString());
|
|
177
181
|
}
|
|
178
|
-
},
|
|
179
|
-
|
|
182
|
+
}, y = (e) => {
|
|
183
|
+
s.store.state.isDirty && e.preventDefault();
|
|
180
184
|
};
|
|
181
|
-
if (
|
|
182
|
-
window.addEventListener("beforeunload",
|
|
183
|
-
}),
|
|
184
|
-
window.removeEventListener("beforeunload",
|
|
185
|
+
if (W(h), z(() => {
|
|
186
|
+
window.addEventListener("beforeunload", h), window.addEventListener("blur", u), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.addEventListener("beforeunload", y);
|
|
187
|
+
}), G(() => {
|
|
188
|
+
window.removeEventListener("beforeunload", h), window.removeEventListener("blur", u), n?.preventWindowExit && n.preventWindowExit !== "nope" && window.removeEventListener("beforeunload", y);
|
|
185
189
|
}), n?.preventWindowExit === "prevent-and-reset") {
|
|
186
|
-
const e =
|
|
187
|
-
|
|
188
|
-
|
|
190
|
+
const e = s.useStore((t) => t.isSubmitting), r = s.useStore((t) => t.submissionAttempts), c = s.useStore((t) => t.canSubmit), o = s.useStore((t) => t.values);
|
|
191
|
+
D([e, r], ([t, S], [_]) => {
|
|
192
|
+
_ && !t && S > 0 && c.value && s.reset(o.value);
|
|
189
193
|
});
|
|
190
194
|
}
|
|
191
|
-
const k = (e) =>
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
(r) =>
|
|
195
|
+
const k = (e) => f.currentSpan.pipe(
|
|
196
|
+
f.option,
|
|
197
|
+
f.flatMap(
|
|
198
|
+
(r) => f.promise(() => s.handleSubmit(P.isSome(r) ? { currentSpan: r.value, ...e } : e))
|
|
195
199
|
)
|
|
196
|
-
), J = (e) => e?.checkErrors ? k(e?.meta).pipe(
|
|
197
|
-
const r =
|
|
200
|
+
), J = (e) => e?.checkErrors ? k(e?.meta).pipe(f.flatMap(f.fnUntraced(function* () {
|
|
201
|
+
const r = s.getAllErrors();
|
|
198
202
|
if (Object.keys(r.fields).length || r.form.errors.length)
|
|
199
|
-
return yield* new
|
|
200
|
-
}))) : k(e?.meta), q =
|
|
203
|
+
return yield* new oe({ form: r.form, fields: r.fields });
|
|
204
|
+
}))) : k(e?.meta), q = s.handleSubmit, L = Z(/* @__PURE__ */ new Map()), w = Object.assign(s, {
|
|
201
205
|
i18nNamespace: n?.i18nNamespace,
|
|
202
206
|
ignorePreventCloseEvents: n?.ignorePreventCloseEvents,
|
|
203
|
-
meta:
|
|
207
|
+
meta: a,
|
|
204
208
|
clear: O,
|
|
205
209
|
handleSubmit: (e) => {
|
|
206
|
-
const r =
|
|
210
|
+
const r = N.getSpan(U.active());
|
|
207
211
|
return q({ currentSpan: r, ...e });
|
|
208
212
|
},
|
|
209
213
|
// /** @experimental */
|
|
210
214
|
handleSubmitEffect: J,
|
|
211
215
|
registerField: (e) => {
|
|
212
|
-
|
|
216
|
+
D(e, (r) => L.value.set(r.name, { label: r.label, id: r.id }), { immediate: !0 }), W(() => L.value.delete(e.value.name));
|
|
213
217
|
}
|
|
214
|
-
}), I = { form: w, fieldMap:
|
|
218
|
+
}), I = { form: w, fieldMap: L };
|
|
215
219
|
return Object.assign(w, {
|
|
216
220
|
// Type-level properties for performance optimization (not used at runtime)
|
|
217
221
|
_paths: void 0,
|
|
218
222
|
_keys: void 0,
|
|
219
|
-
_schema:
|
|
223
|
+
_schema: i,
|
|
220
224
|
errorContext: I,
|
|
221
|
-
Form: g(w)(
|
|
222
|
-
Input: g(w)(n?.input ??
|
|
223
|
-
TaggedUnion: g(w)(
|
|
224
|
-
Field:
|
|
225
|
-
Errors:
|
|
225
|
+
Form: g(w)(ne),
|
|
226
|
+
Input: g(w)(n?.input ?? te),
|
|
227
|
+
TaggedUnion: g(w)(se),
|
|
228
|
+
Field: s.Field,
|
|
229
|
+
Errors: ae(I)(C),
|
|
226
230
|
Array: g(w)(X),
|
|
227
231
|
AutoGen: g(w)(Y)
|
|
228
232
|
});
|
|
229
233
|
};
|
|
230
234
|
export {
|
|
231
|
-
|
|
232
|
-
|
|
235
|
+
oe as FormErrors,
|
|
236
|
+
ie as useErrorLabel,
|
|
237
|
+
ge as useOmegaForm
|
|
233
238
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import l from "./vue-components.
|
|
1
|
+
import l from "./vue-components.es29.js";
|
|
2
2
|
import { inject as c, provide as u } from "vue";
|
|
3
|
-
import { onMountedWithCleanup as f } from "./vue-components.
|
|
3
|
+
import { onMountedWithCleanup as f } from "./vue-components.es16.js";
|
|
4
4
|
const p = () => l(), i = Symbol("DialogBus"), r = () => c(i, null), g = () => {
|
|
5
5
|
const n = p();
|
|
6
6
|
return u(i, n), n;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { S as i, Option as M } from "effect-app";
|
|
2
2
|
import { getMetadataFromSchema as k } from "@effect-app/vue/form";
|
|
3
3
|
import { useIntl as V, getTransformationFrom as q } from "./vue-components.es3.js";
|
|
4
|
-
import { isObject as E } from "./vue-components.
|
|
4
|
+
import { isObject as E } from "./vue-components.es17.js";
|
|
5
5
|
const $ = (e) => i.AST.isUnion(e) && e.types.find((n) => n._tag === "UndefinedKeyword" || n === i.Null.ast), g = (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, w = (e) => {
|
|
6
6
|
const n = [];
|
|
7
7
|
for (const t of e)
|
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import "vue";
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { onMounted as e, onUnmounted as u } from "vue";
|
|
2
|
+
function p(t) {
|
|
3
|
+
let n;
|
|
4
|
+
e(() => {
|
|
5
|
+
const o = t();
|
|
6
|
+
o && (n = o);
|
|
7
|
+
}), u(() => {
|
|
8
|
+
n && n();
|
|
9
|
+
});
|
|
10
|
+
}
|
|
4
11
|
export {
|
|
5
|
-
|
|
12
|
+
p as onMountedWithCleanup
|
|
6
13
|
};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
n(2, (e, t) => a(e, { ...e, ...m(t) ? t(e) : t }));
|
|
5
|
-
const p = (e, t) => new Promise((o, s) => e.addObserver((r) => {
|
|
6
|
-
c.isSuccess(r) ? o(r.value) : s(u.makeFiberFailure(r.cause));
|
|
7
|
-
}));
|
|
1
|
+
import "vue";
|
|
2
|
+
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
3
|
+
const t = Object.prototype.toString, c = (o) => t.call(o) === "[object Object]";
|
|
8
4
|
export {
|
|
9
|
-
|
|
10
|
-
i as cloneTrait,
|
|
11
|
-
p as runtimeFiberAsPromise
|
|
5
|
+
c as isObject
|
|
12
6
|
};
|
|
@@ -1,57 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
name: {},
|
|
9
|
-
defaultItems: {},
|
|
10
|
-
items: {}
|
|
11
|
-
},
|
|
12
|
-
setup(n) {
|
|
13
|
-
const a = n, y = a.form.useStore((e) => e.values), i = f(() => {
|
|
14
|
-
const e = a.name.replace(/\[/g, ".").replace(/\]/g, "");
|
|
15
|
-
try {
|
|
16
|
-
return e.split(".").reduce((r, t) => r && r[t], y.value);
|
|
17
|
-
} catch (r) {
|
|
18
|
-
return console.error(r), [];
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
M(async () => {
|
|
22
|
-
a.defaultItems && !i.value && a.form.setFieldValue(a.name, a.defaultItems);
|
|
23
|
-
});
|
|
24
|
-
const $ = f(() => (r) => {
|
|
25
|
-
const t = r.replace(/\[\d+\]/g, "");
|
|
26
|
-
return a.form.meta[t];
|
|
27
|
-
});
|
|
28
|
-
return P("getMetaFromArray", $), (e, r) => (s(), c(p(n.form.Field), { name: n.name }, {
|
|
29
|
-
default: g(({ field: t, state: d }) => [
|
|
30
|
-
o(e.$slots, "pre-array", l(u({ field: t, state: d }))),
|
|
31
|
-
(s(!0), k(A, null, C(i.value, (B, m) => (s(), c(p(n.form.Field), {
|
|
32
|
-
key: `${n.name}[${Number(m)}]`,
|
|
33
|
-
name: (
|
|
34
|
-
// eslint-disable-next-line
|
|
35
|
-
`${n.name}[${Number(m)}]`
|
|
36
|
-
)
|
|
37
|
-
}, {
|
|
38
|
-
default: g(({ field: v, state: h }) => [
|
|
39
|
-
o(e.$slots, "default", b({ ref_for: !0 }, {
|
|
40
|
-
subField: v,
|
|
41
|
-
subState: h,
|
|
42
|
-
index: Number(m),
|
|
43
|
-
field: t
|
|
44
|
-
}))
|
|
45
|
-
]),
|
|
46
|
-
_: 2
|
|
47
|
-
}, 1032, ["name"]))), 128)),
|
|
48
|
-
o(e.$slots, "post-array", l(u({ field: t, state: d }))),
|
|
49
|
-
o(e.$slots, "field", l(u({ field: t })))
|
|
50
|
-
]),
|
|
51
|
-
_: 3
|
|
52
|
-
}, 8, ["name"]));
|
|
53
|
-
}
|
|
54
|
-
});
|
|
1
|
+
import { Exit as c, Runtime as u } from "effect";
|
|
2
|
+
import { dual as n, isFunction as m } from "./vue-components.es30.js";
|
|
3
|
+
const i = Symbol.for("clone-trait"), a = n(2, (e, t) => i in e ? e[i](t) : Object.setPrototypeOf(t, Object.getPrototypeOf(e)));
|
|
4
|
+
n(2, (e, t) => a(e, { ...e, ...m(t) ? t(e) : t }));
|
|
5
|
+
const p = (e, t) => new Promise((o, s) => e.addObserver((r) => {
|
|
6
|
+
c.isSuccess(r) ? o(r.value) : s(u.makeFiberFailure(r.cause));
|
|
7
|
+
}));
|
|
55
8
|
export {
|
|
56
|
-
|
|
9
|
+
a as clone,
|
|
10
|
+
i as cloneTrait,
|
|
11
|
+
p as runtimeFiberAsPromise
|
|
57
12
|
};
|
|
@@ -1,70 +1,57 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
__name: "
|
|
1
|
+
import { defineComponent as F, computed as f, onMounted as M, provide as P, createBlock as c, openBlock as s, resolveDynamicComponent as p, withCtx as g, renderSlot as o, createElementBlock as k, normalizeProps as l, guardReactiveProps as u, Fragment as A, renderList as C, mergeProps as b } from "vue";
|
|
2
|
+
const N = /* @__PURE__ */ F({
|
|
3
|
+
inheritAttrs: !1,
|
|
4
|
+
__name: "OmegaArray",
|
|
5
5
|
props: {
|
|
6
6
|
form: {},
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
order: {},
|
|
12
|
-
sort: {}
|
|
7
|
+
inputClass: {},
|
|
8
|
+
name: {},
|
|
9
|
+
defaultItems: {},
|
|
10
|
+
items: {}
|
|
13
11
|
},
|
|
14
|
-
setup(
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
n.form.
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
(e
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
n.sort ? u.sort(n.sort) : (e) => e
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
return (e, r) => (_(!0), M(E, null, A(b.value, ({ name: t, label: o, ...c }) => F(e.$slots, "default", {
|
|
59
|
-
child: { name: t, label: o, ...c }
|
|
60
|
-
}, () => [
|
|
61
|
-
g(h(i.form).Input, k({
|
|
62
|
-
name: t,
|
|
63
|
-
label: o
|
|
64
|
-
}, { ref_for: !0 }, c), null, 16, ["name", "label"])
|
|
65
|
-
])), 256));
|
|
12
|
+
setup(n) {
|
|
13
|
+
const a = n, y = a.form.useStore((e) => e.values), i = f(() => {
|
|
14
|
+
const e = a.name.replace(/\[/g, ".").replace(/\]/g, "");
|
|
15
|
+
try {
|
|
16
|
+
return e.split(".").reduce((r, t) => r && r[t], y.value);
|
|
17
|
+
} catch (r) {
|
|
18
|
+
return console.error(r), [];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
M(async () => {
|
|
22
|
+
a.defaultItems && !i.value && a.form.setFieldValue(a.name, a.defaultItems);
|
|
23
|
+
});
|
|
24
|
+
const $ = f(() => (r) => {
|
|
25
|
+
const t = r.replace(/\[\d+\]/g, "");
|
|
26
|
+
return a.form.meta[t];
|
|
27
|
+
});
|
|
28
|
+
return P("getMetaFromArray", $), (e, r) => (s(), c(p(n.form.Field), { name: n.name }, {
|
|
29
|
+
default: g(({ field: t, state: d }) => [
|
|
30
|
+
o(e.$slots, "pre-array", l(u({ field: t, state: d }))),
|
|
31
|
+
(s(!0), k(A, null, C(i.value, (B, m) => (s(), c(p(n.form.Field), {
|
|
32
|
+
key: `${n.name}[${Number(m)}]`,
|
|
33
|
+
name: (
|
|
34
|
+
// eslint-disable-next-line
|
|
35
|
+
`${n.name}[${Number(m)}]`
|
|
36
|
+
)
|
|
37
|
+
}, {
|
|
38
|
+
default: g(({ field: v, state: h }) => [
|
|
39
|
+
o(e.$slots, "default", b({ ref_for: !0 }, {
|
|
40
|
+
subField: v,
|
|
41
|
+
subState: h,
|
|
42
|
+
index: Number(m),
|
|
43
|
+
field: t
|
|
44
|
+
}))
|
|
45
|
+
]),
|
|
46
|
+
_: 2
|
|
47
|
+
}, 1032, ["name"]))), 128)),
|
|
48
|
+
o(e.$slots, "post-array", l(u({ field: t, state: d }))),
|
|
49
|
+
o(e.$slots, "field", l(u({ field: t })))
|
|
50
|
+
]),
|
|
51
|
+
_: 3
|
|
52
|
+
}, 8, ["name"]));
|
|
66
53
|
}
|
|
67
54
|
});
|
|
68
55
|
export {
|
|
69
|
-
|
|
56
|
+
N as default
|
|
70
57
|
};
|
|
@@ -1,8 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { defineComponent as O, computed as j, createElementBlock as M, openBlock as _, Fragment as E, renderList as A, renderSlot as F, createVNode as g, unref as h, mergeProps as k } from "vue";
|
|
2
|
+
import { Order as l, pipe as v, Array as u } from "effect-app";
|
|
3
|
+
const I = /* @__PURE__ */ O({
|
|
4
|
+
__name: "OmegaAutoGen",
|
|
5
|
+
props: {
|
|
6
|
+
form: {},
|
|
7
|
+
pick: {},
|
|
8
|
+
omit: {},
|
|
9
|
+
labelMap: { type: Function },
|
|
10
|
+
filterMap: { type: Function },
|
|
11
|
+
order: {},
|
|
12
|
+
sort: {}
|
|
13
|
+
},
|
|
14
|
+
setup(i) {
|
|
15
|
+
const p = (e) => (r) => Object.fromEntries(
|
|
16
|
+
Object.entries(r).map(([t, o]) => [t, e(o, t)])
|
|
17
|
+
), a = (e) => (r) => Object.fromEntries(
|
|
18
|
+
Object.entries(r).filter(([t, o]) => e(o, t))
|
|
19
|
+
), m = (e) => (r) => Object.entries(r).reduce(
|
|
20
|
+
(t, [o, c]) => {
|
|
21
|
+
const s = e(c, o);
|
|
22
|
+
return s !== !1 && (t[o] = s), t;
|
|
23
|
+
},
|
|
24
|
+
{}
|
|
25
|
+
), n = i, f = (e, r) => {
|
|
26
|
+
const t = r?.indexOf(e) ?? -1;
|
|
27
|
+
return t === -1 ? Number.MAX_SAFE_INTEGER : t;
|
|
28
|
+
}, d = l.mapInput(
|
|
29
|
+
l.number,
|
|
30
|
+
(e) => f(e.name, n.order || [])
|
|
31
|
+
), b = j(
|
|
32
|
+
() => v(
|
|
33
|
+
n.form.meta,
|
|
34
|
+
// include / exclude
|
|
35
|
+
a(
|
|
36
|
+
(e, r) => n.pick ? n.pick.includes(r) && !n.omit?.includes(r) : !n.omit?.includes(r)
|
|
37
|
+
),
|
|
38
|
+
(e) => e,
|
|
39
|
+
// labelMap and adding name
|
|
40
|
+
p((e, r) => ({
|
|
41
|
+
name: r,
|
|
42
|
+
label: n.labelMap?.(r) || r,
|
|
43
|
+
...e
|
|
44
|
+
})),
|
|
45
|
+
// filterMap
|
|
46
|
+
n.filterMap ? m((e) => {
|
|
47
|
+
const r = n.filterMap?.(e.name, e);
|
|
48
|
+
return r === void 0 || r === !0 ? e : r;
|
|
49
|
+
}) : (e) => e,
|
|
50
|
+
// transform to array
|
|
51
|
+
(e) => Object.values(e),
|
|
52
|
+
// order
|
|
53
|
+
u.sort(d),
|
|
54
|
+
// sort
|
|
55
|
+
n.sort ? u.sort(n.sort) : (e) => e
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
return (e, r) => (_(!0), M(E, null, A(b.value, ({ name: t, label: o, ...c }) => F(e.$slots, "default", {
|
|
59
|
+
child: { name: t, label: o, ...c }
|
|
60
|
+
}, () => [
|
|
61
|
+
g(h(i.form).Input, k({
|
|
62
|
+
name: t,
|
|
63
|
+
label: o
|
|
64
|
+
}, { ref_for: !0 }, c), null, 16, ["name", "label"])
|
|
65
|
+
])), 256));
|
|
66
|
+
}
|
|
67
|
+
});
|
|
6
68
|
export {
|
|
7
|
-
|
|
69
|
+
I as default
|
|
8
70
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var
|
|
2
|
-
import
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var a=document.createElement("style");if(a.appendChild(document.createTextNode('.v-enter-from[data-v-6b2bf87e],.v-leave-to[data-v-6b2bf87e]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-6b2bf87e],.v-leave-active[data-v-6b2bf87e]{display:grid;transition:all .15s}.v-enter-to[data-v-6b2bf87e],.v-leave-from[data-v-6b2bf87e]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-6b2bf87e]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-6b2bf87e]{min-height:0}.error-list[data-v-6b2bf87e]{list-style-position:inside}.error-list [data-v-6b2bf87e]::marker{margin:0;padding:0}.error-alert-content[data-v-6b2bf87e]{background-color:var(--error-background, #fff5f5);color:var(--error-color, #c92a2a);padding:1em}.error-link[data-v-6b2bf87e]{font-weight:700;position:relative;color:var(--error-color, #c92a2a);cursor:pointer}.error-link[data-v-6b2bf87e]:after{content:"";position:absolute;left:0;right:0;bottom:0;height:1px;background:rgba(from var(--error-color, #c92a2a) r g b / .5)}.text-h6[data-v-6b2bf87e]{font-weight:700;font-size:1.25em}.error-message[data-v-6b2bf87e]{font-style:italic}.error-item[data-v-6b2bf87e]{margin-bottom:.5em;overflow:hidden}.error-item>div[data-v-6b2bf87e]{float:right;width:100%;max-width:calc(100% - 1.5em)}.container[data-v-6b2bf87e]{display:flex;gap:1.5em}.container svg[data-v-6b2bf87e]{width:3em}.container .single-error[data-v-6b2bf87e]{display:inline-block}')),document.head.appendChild(a),window.customElements){const e=window.customElements.define;window.customElements.define=function(i,t){const r=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(r&&r.call(this),this.shadowRoot){const o=document.createElement("style");o.appendChild(document.createTextNode('.v-enter-from[data-v-6b2bf87e],.v-leave-to[data-v-6b2bf87e]{max-height:0px;grid-template-rows:0fr;opacity:0}.v-enter-active[data-v-6b2bf87e],.v-leave-active[data-v-6b2bf87e]{display:grid;transition:all .15s}.v-enter-to[data-v-6b2bf87e],.v-leave-from[data-v-6b2bf87e]{grid-template-rows:1fr;max-height:50vh;opacity:1}.error-alert[data-v-6b2bf87e]{transition-behavior:allow-discrete;display:grid;overflow:hidden;min-height:0}.error-alert>*[data-v-6b2bf87e]{min-height:0}.error-list[data-v-6b2bf87e]{list-style-position:inside}.error-list [data-v-6b2bf87e]::marker{margin:0;padding:0}.error-alert-content[data-v-6b2bf87e]{background-color:var(--error-background, #fff5f5);color:var(--error-color, #c92a2a);padding:1em}.error-link[data-v-6b2bf87e]{font-weight:700;position:relative;color:var(--error-color, #c92a2a);cursor:pointer}.error-link[data-v-6b2bf87e]:after{content:"";position:absolute;left:0;right:0;bottom:0;height:1px;background:rgba(from var(--error-color, #c92a2a) r g b / .5)}.text-h6[data-v-6b2bf87e]{font-weight:700;font-size:1.25em}.error-message[data-v-6b2bf87e]{font-style:italic}.error-item[data-v-6b2bf87e]{margin-bottom:.5em;overflow:hidden}.error-item>div[data-v-6b2bf87e]{float:right;width:100%;max-width:calc(100% - 1.5em)}.container[data-v-6b2bf87e]{display:flex;gap:1.5em}.container svg[data-v-6b2bf87e]{width:3em}.container .single-error[data-v-6b2bf87e]{display:inline-block}')),this.shadowRoot.appendChild(o)}},e.call(window.customElements,i,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import r from "./vue-components.es33.js";
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
const
|
|
4
|
+
import o from "./vue-components.es35.js";
|
|
5
|
+
const m = /* @__PURE__ */ o(r, [["__scopeId", "data-v-6b2bf87e"]]);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
m as default
|
|
8
8
|
};
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-8c9cb27c]{display:contents}fieldset[disabled][data-v-8c9cb27c]>*{pointer-events:none}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const d=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(d&&d.call(this),this.shadowRoot){const c=document.createElement("style");c.appendChild(document.createTextNode("fieldset[data-v-8c9cb27c]{display:contents}fieldset[disabled][data-v-8c9cb27c]>*{pointer-events:none}")),this.shadowRoot.appendChild(c)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import o from "./vue-components.es36.js";
|
|
3
|
+
|
|
4
|
+
import m from "./vue-components.es35.js";
|
|
5
|
+
const a = /* @__PURE__ */ m(o, [["__scopeId", "data-v-8c9cb27c"]]);
|
|
3
6
|
export {
|
|
4
|
-
|
|
7
|
+
a as default
|
|
5
8
|
};
|
|
@@ -1,19 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
return { all: t = t || /* @__PURE__ */ new Map(), on: function(e, f) {
|
|
3
|
-
var i = t.get(e);
|
|
4
|
-
i ? i.push(f) : t.set(e, [f]);
|
|
5
|
-
}, off: function(e, f) {
|
|
6
|
-
var i = t.get(e);
|
|
7
|
-
i && (f ? i.splice(i.indexOf(f) >>> 0, 1) : t.set(e, []));
|
|
8
|
-
}, emit: function(e, f) {
|
|
9
|
-
var i = t.get(e);
|
|
10
|
-
i && i.slice().map(function(a) {
|
|
11
|
-
a(f);
|
|
12
|
-
}), (i = t.get("*")) && i.slice().map(function(a) {
|
|
13
|
-
a(e, f);
|
|
14
|
-
});
|
|
15
|
-
} };
|
|
16
|
-
}
|
|
1
|
+
import f from "./vue-components.es9.js";
|
|
17
2
|
export {
|
|
18
|
-
|
|
3
|
+
f as default
|
|
19
4
|
};
|
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
function c(t) {
|
|
2
|
+
return { all: t = t || /* @__PURE__ */ new Map(), on: function(e, f) {
|
|
3
|
+
var i = t.get(e);
|
|
4
|
+
i ? i.push(f) : t.set(e, [f]);
|
|
5
|
+
}, off: function(e, f) {
|
|
6
|
+
var i = t.get(e);
|
|
7
|
+
i && (f ? i.splice(i.indexOf(f) >>> 0, 1) : t.set(e, []));
|
|
8
|
+
}, emit: function(e, f) {
|
|
9
|
+
var i = t.get(e);
|
|
10
|
+
i && i.slice().map(function(a) {
|
|
11
|
+
a(f);
|
|
12
|
+
}), (i = t.get("*")) && i.slice().map(function(a) {
|
|
13
|
+
a(e, f);
|
|
14
|
+
});
|
|
15
|
+
} };
|
|
10
16
|
}
|
|
11
17
|
export {
|
|
12
|
-
|
|
18
|
+
c as default
|
|
13
19
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as v, mergeModels as C, useModel as k, useSlots as V, computed as _, resolveComponent as g, createBlock as y, openBlock as B, unref as a, createSlots as E, withCtx as u, renderSlot as d, renderList as M, normalizeProps as S, guardReactiveProps as w } from "vue";
|
|
2
2
|
import { useOnClose as L } from "./vue-components.es11.js";
|
|
3
|
-
import { onMountedWithCleanup as h } from "./vue-components.
|
|
3
|
+
import { onMountedWithCleanup as h } from "./vue-components.es16.js";
|
|
4
4
|
const z = /* @__PURE__ */ v({
|
|
5
5
|
__name: "Dialog",
|
|
6
6
|
props: /* @__PURE__ */ C({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import B from "./vue-components.
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as y, computed as o, useAttrs as F, inject as $, createBlock as u, openBlock as i, resolveDynamicComponent as k, withCtx as m, createCommentVNode as A, mergeProps as M, unref as S, createSlots as w, renderSlot as f, normalizeProps as d, guardReactiveProps as c } from "vue";
|
|
2
|
+
import { generateInputStandardSchemaFromFieldMeta as P } from "./vue-components.es12.js";
|
|
3
|
+
import j from "./vue-components.es7.js";
|
|
4
|
+
import { useErrorLabel as B } from "./vue-components.es10.js";
|
|
5
|
+
const D = /* @__PURE__ */ y({
|
|
6
6
|
inheritAttrs: !1,
|
|
7
7
|
__name: "OmegaInput",
|
|
8
8
|
props: {
|
|
@@ -12,51 +12,51 @@ const U = /* @__PURE__ */ F({
|
|
|
12
12
|
name: {},
|
|
13
13
|
inputClass: {}
|
|
14
14
|
},
|
|
15
|
-
setup(
|
|
16
|
-
const e =
|
|
15
|
+
setup(a) {
|
|
16
|
+
const e = a, l = o(() => e.name), v = F(), p = o(() => {
|
|
17
17
|
if (e.inputClass !== null)
|
|
18
|
-
return e.inputClass !== void 0 ? e.inputClass :
|
|
19
|
-
}),
|
|
18
|
+
return e.inputClass !== void 0 ? e.inputClass : v.class;
|
|
19
|
+
}), n = $(
|
|
20
20
|
"getMetaFromArray",
|
|
21
21
|
null
|
|
22
|
-
),
|
|
23
|
-
if (!
|
|
22
|
+
), r = o(() => n?.value && n.value(e.name) ? n.value(l.value) : e.form.meta[l.value]), g = o(() => {
|
|
23
|
+
if (!r.value)
|
|
24
24
|
throw console.log(e.name, Object.keys(e.form.meta), e.form.meta), new Error("Meta is undefined");
|
|
25
|
-
return
|
|
26
|
-
}),
|
|
27
|
-
return (
|
|
28
|
-
name:
|
|
25
|
+
return P(r.value);
|
|
26
|
+
}), C = B(e.form);
|
|
27
|
+
return (t, E) => (i(), u(k(a.form.Field), {
|
|
28
|
+
name: a.name,
|
|
29
29
|
validators: {
|
|
30
|
-
onChange:
|
|
31
|
-
...
|
|
30
|
+
onChange: g.value,
|
|
31
|
+
...a.validators
|
|
32
32
|
}
|
|
33
33
|
}, {
|
|
34
|
-
default:
|
|
35
|
-
|
|
36
|
-
field:
|
|
37
|
-
state:
|
|
38
|
-
register:
|
|
39
|
-
label:
|
|
40
|
-
meta:
|
|
41
|
-
}),
|
|
42
|
-
default:
|
|
43
|
-
|
|
34
|
+
default: m(({ field: b, state: h }) => [
|
|
35
|
+
r.value ? (i(), u(j, M({ key: 0 }, { ...t.$attrs, ...t.$props, inputClass: p.value }, {
|
|
36
|
+
field: b,
|
|
37
|
+
state: h,
|
|
38
|
+
register: a.form.registerField,
|
|
39
|
+
label: a.label ?? S(C)(l.value),
|
|
40
|
+
meta: r.value
|
|
41
|
+
}), w({
|
|
42
|
+
default: m((s) => [
|
|
43
|
+
f(t.$slots, "default", d(c(s)))
|
|
44
44
|
]),
|
|
45
45
|
_: 2
|
|
46
46
|
}, [
|
|
47
|
-
|
|
47
|
+
t.$slots.label ? {
|
|
48
48
|
name: "label",
|
|
49
|
-
fn:
|
|
50
|
-
|
|
49
|
+
fn: m((s) => [
|
|
50
|
+
f(t.$slots, "label", d(c(s)))
|
|
51
51
|
]),
|
|
52
52
|
key: "0"
|
|
53
53
|
} : void 0
|
|
54
|
-
]), 1040, ["field", "state", "register", "label", "meta"])) :
|
|
54
|
+
]), 1040, ["field", "state", "register", "label", "meta"])) : A("", !0)
|
|
55
55
|
]),
|
|
56
56
|
_: 3
|
|
57
57
|
}, 8, ["name", "validators"]));
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
export {
|
|
61
|
-
|
|
61
|
+
D as default
|
|
62
62
|
};
|
package/package.json
CHANGED
|
@@ -8,12 +8,6 @@ import { getTransformationFrom, useIntl } from "../../utils"
|
|
|
8
8
|
import { type OmegaFieldInternalApi } from "./InputProps"
|
|
9
9
|
import { type OF, type OmegaFormReturn } from "./useOmegaForm"
|
|
10
10
|
|
|
11
|
-
type Compute<T> =
|
|
12
|
-
& {
|
|
13
|
-
[K in keyof T]: T[K]
|
|
14
|
-
}
|
|
15
|
-
& {}
|
|
16
|
-
|
|
17
11
|
export type FieldPath<T> = unknown extends T ? string
|
|
18
12
|
// technically we cannot have primitive at the root
|
|
19
13
|
: T extends string | boolean | number | null | undefined | symbol | bigint ? ""
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
:field="field"
|
|
15
15
|
:state="state"
|
|
16
16
|
:register="form.registerField"
|
|
17
|
-
:label="label ??
|
|
17
|
+
:label="label ?? errori18n(propsName)"
|
|
18
18
|
:meta="meta"
|
|
19
19
|
>
|
|
20
20
|
<template
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
>
|
|
42
42
|
import { type DeepKeys } from "@tanstack/vue-form"
|
|
43
43
|
import { computed, inject, type Ref, useAttrs } from "vue"
|
|
44
|
-
import { useIntl } from "../../utils"
|
|
45
44
|
import { type FieldMeta, generateInputStandardSchemaFromFieldMeta, type OmegaInputPropsBase } from "./OmegaFormStuff"
|
|
46
45
|
import OmegaInternalInput from "./OmegaInternalInput.vue"
|
|
46
|
+
import { useErrorLabel } from "./useOmegaForm"
|
|
47
47
|
|
|
48
48
|
const props = defineProps<OmegaInputPropsBase<From, To, Name>>()
|
|
49
49
|
|
|
@@ -88,19 +88,5 @@ const schema = computed(() => {
|
|
|
88
88
|
return generateInputStandardSchemaFromFieldMeta(meta.value)
|
|
89
89
|
})
|
|
90
90
|
|
|
91
|
-
const
|
|
92
|
-
const humanize = (str: string) => {
|
|
93
|
-
return str
|
|
94
|
-
.replace(/([A-Z])/g, " $1") // Add space before capital letters
|
|
95
|
-
.replace(/^./, (char) => char.toUpperCase()) // Capitalize the first letter
|
|
96
|
-
.trim() // Remove leading/trailing spaces
|
|
97
|
-
}
|
|
98
|
-
const fallback = () =>
|
|
99
|
-
formatMessage
|
|
100
|
-
? formatMessage({ id: `general.fields.${propsName.value}`, defaultMessage: humanize(props.name) })
|
|
101
|
-
: humanize(props.name)
|
|
102
|
-
const i18n = () =>
|
|
103
|
-
props.form.i18nNamespace
|
|
104
|
-
? formatMessage({ id: `${props.form.i18nNamespace}.fields.${propsName.value}`, defaultMessage: fallback() })
|
|
105
|
-
: fallback()
|
|
91
|
+
const errori18n = useErrorLabel(props.form)
|
|
106
92
|
</script>
|
|
@@ -6,6 +6,7 @@ import { type DeepKeys, DeepValue, type FormAsyncValidateOrFn, type FormValidate
|
|
|
6
6
|
import { Array, Data, Effect, Fiber, Option, Order, S } from "effect-app"
|
|
7
7
|
import { runtimeFiberAsPromise, UnionToTuples } from "effect-app/utils"
|
|
8
8
|
import { Component, computed, ComputedRef, ConcreteComponent, h, type InjectionKey, onBeforeUnmount, onMounted, onUnmounted, Ref, ref, watch } from "vue"
|
|
9
|
+
import { useIntl } from "../../utils"
|
|
9
10
|
import { MergedInputProps } from "./InputProps"
|
|
10
11
|
import OmegaArray from "./OmegaArray.vue"
|
|
11
12
|
import OmegaAutoGen from "./OmegaAutoGen.vue"
|
|
@@ -63,6 +64,26 @@ const fHoc = (form: OF<any, any>) => {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
export const useErrorLabel = (form: OF<any, any>) => {
|
|
68
|
+
const { formatMessage } = useIntl()
|
|
69
|
+
const humanize = (str: string) => {
|
|
70
|
+
return str
|
|
71
|
+
.replace(/([A-Z])/g, " $1") // Add space before capital letters
|
|
72
|
+
.replace(/^./, (char) => char.toUpperCase()) // Capitalize the first letter
|
|
73
|
+
.trim() // Remove leading/trailing spaces
|
|
74
|
+
}
|
|
75
|
+
const fallback = (propsName: string) =>
|
|
76
|
+
formatMessage
|
|
77
|
+
? formatMessage({ id: `general.fields.${propsName}`, defaultMessage: humanize(propsName) })
|
|
78
|
+
: humanize(propsName)
|
|
79
|
+
const i18n = (propsName: string) =>
|
|
80
|
+
form.i18nNamespace
|
|
81
|
+
? formatMessage({ id: `${form.i18nNamespace}.fields.${propsName}`, defaultMessage: fallback(propsName) })
|
|
82
|
+
: fallback(propsName)
|
|
83
|
+
|
|
84
|
+
return i18n
|
|
85
|
+
}
|
|
86
|
+
|
|
66
87
|
const eHoc = (errorProps: {
|
|
67
88
|
form: OF<any, any>
|
|
68
89
|
fieldMap: Ref<Map<string, { id: string; label: string }>>
|
|
@@ -77,6 +98,8 @@ const eHoc = (errorProps: {
|
|
|
77
98
|
const fieldMeta = form.useStore((state) => state.fieldMeta)
|
|
78
99
|
const errorMap = form.useStore((state) => state.errorMap)
|
|
79
100
|
|
|
101
|
+
const errorLabel = useErrorLabel(form)
|
|
102
|
+
|
|
80
103
|
const errors = computed(() => {
|
|
81
104
|
// Collect errors from fieldMeta (field-level errors for registered fields)
|
|
82
105
|
const fieldErrors = Array.filterMap(
|
|
@@ -114,7 +137,7 @@ const eHoc = (errorProps: {
|
|
|
114
137
|
// Registered fields will already have their errors from fieldMeta
|
|
115
138
|
if (!fieldMap.value.has(fieldPath)) {
|
|
116
139
|
submitErrors.push({
|
|
117
|
-
label: fieldPath,
|
|
140
|
+
label: errorLabel(fieldPath),
|
|
118
141
|
inputId: fieldPath,
|
|
119
142
|
errors: [issAny.message].filter(Boolean)
|
|
120
143
|
})
|