@effect-app/vue-components 0.5.0 → 0.6.2
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/OmegaAutoGen.vue.d.ts +30 -0
- package/dist/types/components/OmegaForm/index.d.ts +3 -7
- package/dist/vue-components.es.js +24 -27
- package/dist/vue-components.es10.js +6 -23
- package/dist/vue-components.es11.js +3 -3
- package/dist/vue-components.es15.js +1 -1
- package/dist/vue-components.es17.js +2 -5
- package/dist/vue-components.es18.js +5 -32
- package/dist/vue-components.es19.js +32 -2
- package/dist/vue-components.es2.js +16 -19
- package/dist/vue-components.es20.js +2 -2
- package/dist/vue-components.es21.js +2 -98
- package/dist/vue-components.es22.js +98 -11
- package/dist/vue-components.es23.js +11 -2
- package/dist/vue-components.es24.js +2 -115
- package/dist/vue-components.es25.js +117 -0
- package/dist/{vue-components.es26.js → vue-components.es27.js} +1 -1
- package/dist/vue-components.es3.js +3 -3
- package/dist/vue-components.es4.js +2 -2
- package/dist/vue-components.es5.js +78 -36
- package/dist/vue-components.es6.js +34 -131
- package/dist/vue-components.es7.js +128 -211
- package/dist/vue-components.es8.js +216 -6
- package/dist/vue-components.es9.js +4 -4
- package/package.json +9 -3
- package/src/components/OmegaForm/OmegaAutoGen.vue +110 -0
- package/src/components/OmegaForm/OmegaWrapper.vue +1 -1
- package/src/components/OmegaForm/index.ts +3 -21
- package/src/env.d.ts +0 -8
- package/src/stories/OmegaForm/Clearable.vue +0 -20
- package/src/stories/OmegaForm/ComplexForm.vue +0 -87
- package/src/stories/OmegaForm/EmailForm.vue +0 -48
- package/src/stories/OmegaForm/Meta.vue +0 -47
- package/src/stories/OmegaForm/OneHundredWaysToWriteAForm.vue +0 -188
- package/src/stories/OmegaForm/PersistencyForm.vue +0 -58
- package/src/stories/OmegaForm/SimpleForm.vue +0 -30
- package/src/stories/OmegaForm/SimpleFormVuetifyDefault.vue +0 -15
- package/src/stories/OmegaForm/SumExample.vue +0 -37
- package/src/stories/OmegaForm/form.Input.vue +0 -98
- package/src/stories/OmegaForm.stories.ts +0 -114
- package/src/stories/README.md +0 -29
- package/src/stories/tsconfig.json +0 -4
|
@@ -1,218 +1,135 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { useForm as I } from "@tanstack/vue-form";
|
|
2
|
+
import { S as N } from "effect-app";
|
|
3
|
+
import { generateMetaFromSchema as R } from "./vue-components.es8.js";
|
|
4
|
+
import { computed as b, onUnmounted as A, onMounted as D, onBeforeUnmount as J, provide as K } from "vue";
|
|
5
|
+
import { isObject as q } from "./vue-components.es18.js";
|
|
6
|
+
import M from "./vue-components.es19.js";
|
|
7
|
+
const x = Symbol("OmegaForm"), H = (w, s, i) => {
|
|
8
|
+
if (!w) throw new Error("Schema is required");
|
|
9
|
+
const V = N.standardSchemaV1(w), { filterItems: L, meta: t } = R(w), d = b(() => {
|
|
10
|
+
var l;
|
|
11
|
+
if ((l = i == null ? void 0 : i.persistency) != null && l.id)
|
|
12
|
+
return i.persistency.id;
|
|
13
|
+
const e = window.location.pathname, r = Object.keys(t);
|
|
14
|
+
return `${e}-${r.join("-")}`;
|
|
15
|
+
}), U = () => {
|
|
16
|
+
const e = new URLSearchParams(window.location.search);
|
|
17
|
+
e.delete(d.value);
|
|
18
|
+
const r = new URL(window.location.href);
|
|
19
|
+
r.search = e.toString(), window.history.replaceState({}, "", r.toString());
|
|
20
|
+
};
|
|
21
|
+
function v(e, r) {
|
|
22
|
+
for (const l in r)
|
|
23
|
+
r[l] && q(r[l]) ? (e[l] || (e[l] = {}), v(e[l], r[l])) : e[l] = r[l];
|
|
24
|
+
return e;
|
|
25
|
+
}
|
|
26
|
+
const j = b(() => {
|
|
27
|
+
var l;
|
|
28
|
+
if (s != null && s.defaultValues && !((l = i == null ? void 0 : i.persistency) != null && l.overrideDefaultValues))
|
|
29
|
+
return s == null ? void 0 : s.defaultValues;
|
|
30
|
+
let e;
|
|
31
|
+
const r = i == null ? void 0 : i.persistency;
|
|
32
|
+
if (!(r != null && r.policies) || r.policies.length === 0) return {};
|
|
33
|
+
if (r.policies.includes("querystring"))
|
|
34
|
+
try {
|
|
35
|
+
const c = new URLSearchParams(window.location.search).get(d.value);
|
|
36
|
+
U(), c && (e = JSON.parse(c));
|
|
37
|
+
} catch (u) {
|
|
38
|
+
console.error(u);
|
|
37
39
|
}
|
|
40
|
+
if (
|
|
41
|
+
// query string has higher priority than local/session storage
|
|
42
|
+
!e && (r.policies.includes("local") || r.policies.includes("session"))
|
|
43
|
+
) {
|
|
44
|
+
const u = r.policies.includes("local") ? localStorage : sessionStorage;
|
|
45
|
+
if (u)
|
|
46
|
+
try {
|
|
47
|
+
const c = JSON.parse(
|
|
48
|
+
u.getItem(d.value) || "{}"
|
|
49
|
+
);
|
|
50
|
+
u.removeItem(d.value), e = c;
|
|
51
|
+
} catch (c) {
|
|
52
|
+
console.error(c);
|
|
53
|
+
}
|
|
38
54
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const r = n.types.find(
|
|
45
|
-
(o) => o._tag !== "UndefinedKeyword" && o !== i.Null.ast
|
|
46
|
-
);
|
|
47
|
-
return "propertySignatures" in r ? m({
|
|
48
|
-
propertySignatures: r.propertySignatures,
|
|
49
|
-
parent: t,
|
|
50
|
-
meta: e
|
|
51
|
-
}) : n.types.every(i.AST.isLiteral) ? {
|
|
52
|
-
...e,
|
|
53
|
-
type: "select",
|
|
54
|
-
members: n.types.map((o) => o.literal)
|
|
55
|
-
} : {
|
|
56
|
-
...e,
|
|
57
|
-
...m({
|
|
58
|
-
parent: t,
|
|
59
|
-
meta: e,
|
|
60
|
-
property: r
|
|
61
|
-
})
|
|
62
|
-
};
|
|
55
|
+
if (e ?? (e = {}), (s == null ? void 0 : s.defaultValues) == null)
|
|
56
|
+
return e;
|
|
57
|
+
{
|
|
58
|
+
const u = s == null ? void 0 : s.defaultValues;
|
|
59
|
+
return v(u, e);
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
f.getOrElse(() => "unknown")
|
|
83
|
-
), e);
|
|
84
|
-
}
|
|
85
|
-
return l;
|
|
86
|
-
}, c = (e) => {
|
|
87
|
-
const t = e.ast, n = {};
|
|
88
|
-
if (t._tag === "Transformation" || t._tag === "Refinement")
|
|
89
|
-
return c(i.make(t.from));
|
|
90
|
-
if ("propertySignatures" in t) {
|
|
91
|
-
const a = m({
|
|
92
|
-
propertySignatures: t.propertySignatures
|
|
61
|
+
}), n = I({
|
|
62
|
+
...s,
|
|
63
|
+
validators: {
|
|
64
|
+
onSubmit: V,
|
|
65
|
+
...(s == null ? void 0 : s.validators) || {}
|
|
66
|
+
},
|
|
67
|
+
onSubmit: s != null && s.onSubmit ? ({ formApi: e, meta: r, value: l }) => {
|
|
68
|
+
var u;
|
|
69
|
+
return (u = s.onSubmit) == null ? void 0 : u.call(s, {
|
|
70
|
+
formApi: e,
|
|
71
|
+
meta: r,
|
|
72
|
+
value: l
|
|
73
|
+
});
|
|
74
|
+
} : void 0,
|
|
75
|
+
defaultValues: j.value
|
|
76
|
+
}), E = () => {
|
|
77
|
+
Object.keys(t).forEach((e) => {
|
|
78
|
+
n.setFieldValue(e, void 0);
|
|
93
79
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
80
|
+
}, S = (e) => e.reduce(
|
|
81
|
+
(r, l) => {
|
|
82
|
+
const u = l.split(".");
|
|
83
|
+
return u.reduce((c, o, P) => (P === u.length - 1 ? c[o] = n.getFieldValue(l) : c[o] = c[o] ?? {}, c[o]), r), r;
|
|
84
|
+
},
|
|
85
|
+
{}
|
|
86
|
+
), f = (e) => {
|
|
87
|
+
if (e) {
|
|
88
|
+
if (Array.isArray(e.keys))
|
|
89
|
+
return S(e.keys);
|
|
90
|
+
if (Array.isArray(e.banKeys)) {
|
|
91
|
+
const r = Object.keys(t).filter(
|
|
92
|
+
(l) => {
|
|
93
|
+
var u;
|
|
94
|
+
return (u = e.banKeys) == null ? void 0 : u.includes(l);
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
return S(r);
|
|
100
98
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
)
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
message: () => t("validation.email.invalid")
|
|
135
|
-
})
|
|
136
|
-
)), e.required && n.annotations({
|
|
137
|
-
message: () => t("validation.empty")
|
|
138
|
-
}), e.maxLength && (n = n.pipe(i.maxLength(e.maxLength)).annotations({
|
|
139
|
-
message: () => t("validation.string.maxLength", {
|
|
140
|
-
maxLength: e.maxLength
|
|
141
|
-
})
|
|
142
|
-
})), e.minLength && (n = n.pipe(i.minLength(e.minLength)).annotations({
|
|
143
|
-
message: () => t("validation.string.minLength", {
|
|
144
|
-
minLength: e.minLength
|
|
145
|
-
})
|
|
146
|
-
}));
|
|
147
|
-
break;
|
|
148
|
-
case "number":
|
|
149
|
-
n = i.Number.annotations({
|
|
150
|
-
message: () => t("validation.empty")
|
|
151
|
-
}), e.required && n.annotations({
|
|
152
|
-
message: () => t("validation.empty")
|
|
153
|
-
}), e.minimum && (n = n.pipe(i.greaterThanOrEqualTo(e.minimum)).annotations({
|
|
154
|
-
message: () => t("validation.number.min", {
|
|
155
|
-
minimum: e.minimum,
|
|
156
|
-
isExclusive: !0
|
|
157
|
-
})
|
|
158
|
-
})), e.maximum && (n = n.pipe(i.lessThanOrEqualTo(e.maximum)).annotations({
|
|
159
|
-
message: () => t("validation.number.max", {
|
|
160
|
-
maximum: e.maximum,
|
|
161
|
-
isExclusive: !0
|
|
162
|
-
})
|
|
163
|
-
})), e.exclusiveMinimum && (n = n.pipe(i.greaterThan(e.exclusiveMinimum)).annotations({
|
|
164
|
-
message: () => t("validation.number.min", {
|
|
165
|
-
minimum: e.exclusiveMinimum,
|
|
166
|
-
isExclusive: !1
|
|
167
|
-
})
|
|
168
|
-
})), e.exclusiveMaximum && (n = n.pipe(i.lessThan(e.exclusiveMaximum)).annotations({
|
|
169
|
-
message: () => t("validation.number.max", {
|
|
170
|
-
maximum: e.exclusiveMaximum,
|
|
171
|
-
isExclusive: !1
|
|
172
|
-
})
|
|
173
|
-
}));
|
|
174
|
-
break;
|
|
175
|
-
case "select":
|
|
176
|
-
n = i.Literal(...e.members).annotations({
|
|
177
|
-
message: () => ({
|
|
178
|
-
message: t("validation.not_a_valid", {
|
|
179
|
-
type: "select",
|
|
180
|
-
message: e.members.join(", ")
|
|
181
|
-
}),
|
|
182
|
-
override: !0
|
|
183
|
-
})
|
|
184
|
-
});
|
|
185
|
-
break;
|
|
186
|
-
case "multiple":
|
|
187
|
-
n = i.Array(i.String).annotations({
|
|
188
|
-
message: () => t("validation.not_a_valid", {
|
|
189
|
-
type: "multiple",
|
|
190
|
-
message: e.members.join(", ")
|
|
191
|
-
})
|
|
192
|
-
});
|
|
193
|
-
break;
|
|
194
|
-
case "boolean":
|
|
195
|
-
n = i.Boolean;
|
|
196
|
-
break;
|
|
197
|
-
// todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
|
|
198
|
-
case "unknown":
|
|
199
|
-
n = i.Unknown;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
return e.required ? n.pipe(
|
|
203
|
-
i.annotations({
|
|
204
|
-
message: () => t("validation.empty")
|
|
205
|
-
})
|
|
206
|
-
) : n = i.NullishOr(n), i.standardSchemaV1(n);
|
|
207
|
-
}, L = (e, t) => i.NullOr(e).pipe(
|
|
208
|
-
i.transform(i.typeSchema(e), {
|
|
209
|
-
decode: (n) => n ?? t(),
|
|
210
|
-
encode: (n) => n
|
|
211
|
-
})
|
|
212
|
-
);
|
|
99
|
+
return n.store.state.values;
|
|
100
|
+
}
|
|
101
|
+
}, h = () => {
|
|
102
|
+
const e = i == null ? void 0 : i.persistency;
|
|
103
|
+
if (!(!(e != null && e.policies) || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
|
|
104
|
+
const r = e.policies.includes("local") ? localStorage : sessionStorage;
|
|
105
|
+
if (!r) return;
|
|
106
|
+
const l = f(e);
|
|
107
|
+
return r.setItem(d.value, JSON.stringify(l));
|
|
108
|
+
}
|
|
109
|
+
}, a = () => {
|
|
110
|
+
const e = i == null ? void 0 : i.persistency;
|
|
111
|
+
if (!(!(e != null && e.policies) || e.policies.length === 0) && e.policies.includes("querystring")) {
|
|
112
|
+
const r = f(e), l = new URLSearchParams(window.location.search);
|
|
113
|
+
l.set(d.value, JSON.stringify(r));
|
|
114
|
+
const u = new URL(window.location.href);
|
|
115
|
+
u.search = l.toString(), window.history.replaceState({}, "", u.toString());
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
A(h), D(() => {
|
|
119
|
+
window.addEventListener("beforeunload", h), window.addEventListener("blur", a);
|
|
120
|
+
}), J(() => {
|
|
121
|
+
window.removeEventListener("beforeunload", h), window.removeEventListener("blur", a);
|
|
122
|
+
});
|
|
123
|
+
const y = Object.assign(n, {
|
|
124
|
+
meta: t,
|
|
125
|
+
filterItems: L,
|
|
126
|
+
clear: E
|
|
127
|
+
});
|
|
128
|
+
return K(x, y), Object.assign(y, {
|
|
129
|
+
Input: M
|
|
130
|
+
});
|
|
131
|
+
};
|
|
213
132
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
A as generateMetaFromSchema,
|
|
217
|
-
L as nullableInput
|
|
133
|
+
x as OmegaFormKey,
|
|
134
|
+
H as useOmegaForm
|
|
218
135
|
};
|
|
@@ -1,8 +1,218 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { S as i, pipe as p, Option as f } from "effect-app";
|
|
2
|
+
import { useIntl as S } from "./vue-components.es3.js";
|
|
3
|
+
const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find((t) => t._tag === "UndefinedKeyword" || t === i.Null.ast), x = (e) => !e || !i.AST.isUnion(e) ? !1 : e.types.find((t) => t._tag === "UndefinedKeyword") ? "undefined" : e.types.find((t) => t === i.Null.ast) ? "null" : !1, m = ({ meta: e = {}, parent: t = "", property: n, propertySignatures: a }, l = {}) => {
|
|
4
|
+
if (n && n._tag === "Transformation")
|
|
5
|
+
return m({
|
|
6
|
+
parent: t,
|
|
7
|
+
meta: e,
|
|
8
|
+
property: n.from
|
|
9
|
+
});
|
|
10
|
+
if ((n == null ? void 0 : n._tag) === "TypeLiteral" && "propertySignatures" in n)
|
|
11
|
+
return m({
|
|
12
|
+
meta: e,
|
|
13
|
+
propertySignatures: n.propertySignatures
|
|
14
|
+
});
|
|
15
|
+
if (a) {
|
|
16
|
+
for (const s of a) {
|
|
17
|
+
const u = t ? `${t}.${s.name.toString()}` : s.name.toString(), r = x(s.type), o = !r;
|
|
18
|
+
let d = s.type;
|
|
19
|
+
if (i.AST.isUnion(s.type) && (d = s.type.types.find(
|
|
20
|
+
(g) => g._tag !== "UndefinedKeyword" && g !== i.Null.ast
|
|
21
|
+
)), "propertySignatures" in d)
|
|
22
|
+
Object.assign(
|
|
23
|
+
l,
|
|
24
|
+
m({
|
|
25
|
+
parent: u,
|
|
26
|
+
propertySignatures: d.propertySignatures,
|
|
27
|
+
meta: { required: o, nullableOrUndefined: r }
|
|
28
|
+
})
|
|
29
|
+
);
|
|
30
|
+
else {
|
|
31
|
+
const g = m({
|
|
32
|
+
parent: u,
|
|
33
|
+
property: s.type,
|
|
34
|
+
meta: { required: o, nullableOrUndefined: r }
|
|
35
|
+
});
|
|
36
|
+
l[u] = g;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return l;
|
|
40
|
+
}
|
|
41
|
+
if (n) {
|
|
42
|
+
const s = v(n);
|
|
43
|
+
if (Object.hasOwnProperty.call(e, "required") || (e.required = !s), i.AST.isUnion(n)) {
|
|
44
|
+
const r = n.types.find(
|
|
45
|
+
(o) => o._tag !== "UndefinedKeyword" && o !== i.Null.ast
|
|
46
|
+
);
|
|
47
|
+
return "propertySignatures" in r ? m({
|
|
48
|
+
propertySignatures: r.propertySignatures,
|
|
49
|
+
parent: t,
|
|
50
|
+
meta: e
|
|
51
|
+
}) : n.types.every(i.AST.isLiteral) ? {
|
|
52
|
+
...e,
|
|
53
|
+
type: "select",
|
|
54
|
+
members: n.types.map((o) => o.literal)
|
|
55
|
+
} : {
|
|
56
|
+
...e,
|
|
57
|
+
...m({
|
|
58
|
+
parent: t,
|
|
59
|
+
meta: e,
|
|
60
|
+
property: r
|
|
61
|
+
})
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (i.AST.isTupleType(n))
|
|
65
|
+
return {
|
|
66
|
+
...e,
|
|
67
|
+
type: "multiple",
|
|
68
|
+
members: n.elements
|
|
69
|
+
};
|
|
70
|
+
const u = i.AST.getAnnotation(
|
|
71
|
+
n,
|
|
72
|
+
i.AST.JSONSchemaAnnotationId
|
|
73
|
+
).pipe(f.getOrElse(() => ({})));
|
|
74
|
+
return e = { ...e, ...u }, "from" in n ? m({
|
|
75
|
+
parent: t,
|
|
76
|
+
meta: e,
|
|
77
|
+
property: n.from
|
|
78
|
+
}) : (e.type = i.AST.getAnnotation(
|
|
79
|
+
n,
|
|
80
|
+
i.AST.TitleAnnotationId
|
|
81
|
+
).pipe(
|
|
82
|
+
f.getOrElse(() => "unknown")
|
|
83
|
+
), e);
|
|
84
|
+
}
|
|
85
|
+
return l;
|
|
86
|
+
}, c = (e) => {
|
|
87
|
+
const t = e.ast, n = {};
|
|
88
|
+
if (t._tag === "Transformation" || t._tag === "Refinement")
|
|
89
|
+
return c(i.make(t.from));
|
|
90
|
+
if ("propertySignatures" in t) {
|
|
91
|
+
const a = m({
|
|
92
|
+
propertySignatures: t.propertySignatures
|
|
93
|
+
});
|
|
94
|
+
if (Object.values(a).every((s) => s && "type" in s))
|
|
95
|
+
return a;
|
|
96
|
+
const l = (s, u = "") => {
|
|
97
|
+
for (const r in s) {
|
|
98
|
+
const o = u ? `${u}.${r}` : r;
|
|
99
|
+
s[r] && typeof s[r] == "object" && "type" in s[r] ? n[o] = s[r] : s[r] && typeof s[r] == "object" && l(s[r], o);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
l(a);
|
|
103
|
+
}
|
|
104
|
+
return n;
|
|
105
|
+
}, b = (e) => i.extend(e, i.Struct({})), A = (e) => {
|
|
106
|
+
const t = c(e), n = p(
|
|
107
|
+
e.ast,
|
|
108
|
+
f.liftPredicate((a) => a._tag === "Refinement" && "filter" in a),
|
|
109
|
+
f.flatMap((a) => i.AST.getJSONSchemaAnnotation(a)),
|
|
110
|
+
f.filter((a) => "items" in a),
|
|
111
|
+
f.filterMap(
|
|
112
|
+
({ items: a }) => i.decodeUnknownOption(y)(a)
|
|
113
|
+
),
|
|
114
|
+
f.zipWith(
|
|
115
|
+
i.AST.getMessageAnnotation(e.ast),
|
|
116
|
+
(a, l) => ({
|
|
117
|
+
items: a,
|
|
118
|
+
message: l("")
|
|
119
|
+
})
|
|
120
|
+
),
|
|
121
|
+
f.getOrUndefined
|
|
122
|
+
);
|
|
123
|
+
return { schema: e, meta: t, filterItems: n };
|
|
124
|
+
}, O = (e) => {
|
|
125
|
+
const { trans: t } = S();
|
|
126
|
+
let n;
|
|
127
|
+
switch (e.type) {
|
|
128
|
+
case "string":
|
|
129
|
+
n = i.String.annotations({
|
|
130
|
+
message: () => t("validation.empty")
|
|
131
|
+
}), e.format === "email" && (n = i.compose(
|
|
132
|
+
n,
|
|
133
|
+
i.Email.annotations({
|
|
134
|
+
message: () => t("validation.email.invalid")
|
|
135
|
+
})
|
|
136
|
+
)), e.required && n.annotations({
|
|
137
|
+
message: () => t("validation.empty")
|
|
138
|
+
}), e.maxLength && (n = n.pipe(i.maxLength(e.maxLength)).annotations({
|
|
139
|
+
message: () => t("validation.string.maxLength", {
|
|
140
|
+
maxLength: e.maxLength
|
|
141
|
+
})
|
|
142
|
+
})), e.minLength && (n = n.pipe(i.minLength(e.minLength)).annotations({
|
|
143
|
+
message: () => t("validation.string.minLength", {
|
|
144
|
+
minLength: e.minLength
|
|
145
|
+
})
|
|
146
|
+
}));
|
|
147
|
+
break;
|
|
148
|
+
case "number":
|
|
149
|
+
n = i.Number.annotations({
|
|
150
|
+
message: () => t("validation.empty")
|
|
151
|
+
}), e.required && n.annotations({
|
|
152
|
+
message: () => t("validation.empty")
|
|
153
|
+
}), e.minimum && (n = n.pipe(i.greaterThanOrEqualTo(e.minimum)).annotations({
|
|
154
|
+
message: () => t("validation.number.min", {
|
|
155
|
+
minimum: e.minimum,
|
|
156
|
+
isExclusive: !0
|
|
157
|
+
})
|
|
158
|
+
})), e.maximum && (n = n.pipe(i.lessThanOrEqualTo(e.maximum)).annotations({
|
|
159
|
+
message: () => t("validation.number.max", {
|
|
160
|
+
maximum: e.maximum,
|
|
161
|
+
isExclusive: !0
|
|
162
|
+
})
|
|
163
|
+
})), e.exclusiveMinimum && (n = n.pipe(i.greaterThan(e.exclusiveMinimum)).annotations({
|
|
164
|
+
message: () => t("validation.number.min", {
|
|
165
|
+
minimum: e.exclusiveMinimum,
|
|
166
|
+
isExclusive: !1
|
|
167
|
+
})
|
|
168
|
+
})), e.exclusiveMaximum && (n = n.pipe(i.lessThan(e.exclusiveMaximum)).annotations({
|
|
169
|
+
message: () => t("validation.number.max", {
|
|
170
|
+
maximum: e.exclusiveMaximum,
|
|
171
|
+
isExclusive: !1
|
|
172
|
+
})
|
|
173
|
+
}));
|
|
174
|
+
break;
|
|
175
|
+
case "select":
|
|
176
|
+
n = i.Literal(...e.members).annotations({
|
|
177
|
+
message: () => ({
|
|
178
|
+
message: t("validation.not_a_valid", {
|
|
179
|
+
type: "select",
|
|
180
|
+
message: e.members.join(", ")
|
|
181
|
+
}),
|
|
182
|
+
override: !0
|
|
183
|
+
})
|
|
184
|
+
});
|
|
185
|
+
break;
|
|
186
|
+
case "multiple":
|
|
187
|
+
n = i.Array(i.String).annotations({
|
|
188
|
+
message: () => t("validation.not_a_valid", {
|
|
189
|
+
type: "multiple",
|
|
190
|
+
message: e.members.join(", ")
|
|
191
|
+
})
|
|
192
|
+
});
|
|
193
|
+
break;
|
|
194
|
+
case "boolean":
|
|
195
|
+
n = i.Boolean;
|
|
196
|
+
break;
|
|
197
|
+
// todo: switch must be exhaustive or have default case, otherwise falls through with schema undefined.
|
|
198
|
+
case "unknown":
|
|
199
|
+
n = i.Unknown;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
return e.required ? n.pipe(
|
|
203
|
+
i.annotations({
|
|
204
|
+
message: () => t("validation.empty")
|
|
205
|
+
})
|
|
206
|
+
) : n = i.NullishOr(n), i.standardSchemaV1(n);
|
|
207
|
+
}, L = (e, t) => i.NullOr(e).pipe(
|
|
208
|
+
i.transform(i.typeSchema(e), {
|
|
209
|
+
decode: (n) => n ?? t(),
|
|
210
|
+
encode: (n) => n
|
|
211
|
+
})
|
|
212
|
+
);
|
|
6
213
|
export {
|
|
7
|
-
|
|
214
|
+
b as duplicateSchema,
|
|
215
|
+
O as generateInputStandardSchemaFromFieldMeta,
|
|
216
|
+
A as generateMetaFromSchema,
|
|
217
|
+
L as nullableInput
|
|
8
218
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(){"use strict";try{if(typeof document<"u"){var
|
|
2
|
-
import o from "./vue-components.
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-a32b1c91]{display:contents}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(c,t){const o=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(o&&o.call(this),this.shadowRoot){const d=document.createElement("style");d.appendChild(document.createTextNode("fieldset[data-v-a32b1c91]{display:contents}")),this.shadowRoot.appendChild(d)}},e.call(window.customElements,c,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
import o from "./vue-components.es11.js";
|
|
3
3
|
|
|
4
4
|
import r from "./vue-components.es13.js";
|
|
5
|
-
const
|
|
5
|
+
const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-a32b1c91"]]);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
m as default
|
|
8
8
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
6
|
"@tanstack/vue-form": "^1.2.4",
|
|
@@ -26,8 +26,10 @@
|
|
|
26
26
|
"@vitejs/plugin-vue": "^5.2.3",
|
|
27
27
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
28
28
|
"@vue/eslint-config-typescript": "^14.5.0",
|
|
29
|
+
"@vue/test-utils": "^2.4.6",
|
|
29
30
|
"eslint-plugin-prettier": "^5.2.6",
|
|
30
31
|
"eslint-plugin-vue": "^10.0.0",
|
|
32
|
+
"jsdom": "^26.1.0",
|
|
31
33
|
"rimraf": "^6.0.1",
|
|
32
34
|
"sass": "^1.86.0",
|
|
33
35
|
"storybook": "^8.6.12",
|
|
@@ -56,13 +58,17 @@
|
|
|
56
58
|
"effect-app": "2.40.1"
|
|
57
59
|
},
|
|
58
60
|
"scripts": {
|
|
59
|
-
"build": "
|
|
61
|
+
"build": "pnpm build:run",
|
|
62
|
+
"build:run": "rimraf dist && vue-tsc && vite build",
|
|
60
63
|
"docs:dev": "vitepress dev docs",
|
|
61
64
|
"docs:build": "vitepress build docs",
|
|
62
65
|
"docs:serve": "vitepress serve docs",
|
|
63
66
|
"lint": "NODE_OPTIONS=--max-old-space-size=8192 eslint src",
|
|
64
67
|
"autofix": "pnpm lint --fix",
|
|
65
68
|
"storybook": "storybook dev -p 6006",
|
|
66
|
-
"build-storybook": "storybook build"
|
|
69
|
+
"build-storybook": "storybook build",
|
|
70
|
+
"test": "vitest",
|
|
71
|
+
"test:run": "vitest run",
|
|
72
|
+
"test:watch": "vitest watch"
|
|
67
73
|
}
|
|
68
74
|
}
|