@effect-app/vue-components 0.15.23 → 0.15.24
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/InputProps.d.ts +3 -3
- package/dist/types/components/OmegaForm/OmegaArray.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaAutoGen.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaErrors.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/OmegaErrorsContext.d.ts +1 -1
- package/dist/types/components/OmegaForm/OmegaFormInput.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaInput.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/OmegaInputVuetify.vue.d.ts +3 -3
- package/dist/types/components/OmegaForm/OmegaInternalInput.vue.d.ts +4 -4
- package/dist/types/components/OmegaForm/OmegaWrapper.vue.d.ts +2 -2
- package/dist/types/components/OmegaForm/getOmegaStore.d.ts +1 -1
- package/dist/types/components/OmegaForm/index.d.ts +7 -7
- package/dist/types/components/OmegaForm/useOmegaForm.d.ts +3 -3
- package/dist/vue-components.es.js +6 -6
- package/dist/vue-components.es10.js +1 -3
- package/dist/vue-components.es11.js +5 -5
- package/dist/vue-components.es12.js +5 -5
- package/dist/vue-components.es13.js +2 -111
- package/dist/vue-components.es14.js +4 -0
- package/dist/vue-components.es15.js +88 -7
- package/dist/vue-components.es17.js +7 -2
- package/dist/vue-components.es18.js +2 -89
- package/dist/vue-components.es2.js +12 -12
- package/dist/vue-components.es20.js +111 -2
- package/dist/vue-components.es23.js +11 -90
- package/dist/vue-components.es24.js +90 -11
- package/dist/vue-components.es26.js +1 -1
- package/dist/vue-components.es4.js +39 -38
- package/dist/vue-components.es5.js +66 -28
- package/dist/vue-components.es6.js +28 -66
- package/dist/vue-components.es7.js +39 -40
- package/dist/vue-components.es9.js +7 -9
- package/package.json +20 -17
- package/src/components/OmegaForm/InputProps.ts +23 -35
- package/src/components/OmegaForm/OmegaArray.vue +24 -14
- package/src/components/OmegaForm/OmegaAutoGen.vue +38 -30
- package/src/components/OmegaForm/OmegaErrors.vue +25 -14
- package/src/components/OmegaForm/OmegaErrorsContext.ts +5 -13
- package/src/components/OmegaForm/OmegaFormInput.vue +17 -10
- package/src/components/OmegaForm/OmegaFormStuff.ts +141 -136
- package/src/components/OmegaForm/OmegaInput.vue +13 -10
- package/src/components/OmegaForm/OmegaInputVuetify.vue +18 -15
- package/src/components/OmegaForm/OmegaInternalInput.vue +34 -34
- package/src/components/OmegaForm/OmegaWrapper.vue +60 -58
- package/src/components/OmegaForm/getOmegaStore.ts +6 -7
- package/src/components/OmegaForm/index.ts +7 -7
- package/src/components/OmegaForm/useOmegaForm.ts +74 -76
- package/src/utils/index.ts +2 -2
- package/dist/vue-components.es16.js +0 -4
- /package/dist/{vue-components.es21.js → vue-components.es19.js} +0 -0
|
@@ -1,72 +1,34 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const
|
|
5
|
-
__name: "
|
|
1
|
+
import { defineComponent as a, inject as t, createBlock as n, openBlock as m, mergeProps as p, unref as s, withCtx as i, renderSlot as l, normalizeProps as f, guardReactiveProps as u } from "vue";
|
|
2
|
+
import d from "./vue-components.es7.js";
|
|
3
|
+
import { OmegaFormKey as c } from "./vue-components.es9.js";
|
|
4
|
+
const w = /* @__PURE__ */ a({
|
|
5
|
+
__name: "OmegaFormInput",
|
|
6
6
|
props: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
order: {},
|
|
13
|
-
sort: {}
|
|
7
|
+
name: {},
|
|
8
|
+
label: {},
|
|
9
|
+
validators: {},
|
|
10
|
+
options: {},
|
|
11
|
+
type: {}
|
|
14
12
|
},
|
|
15
|
-
setup(
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
), b = O(
|
|
33
|
-
() => k(
|
|
34
|
-
o.form.meta,
|
|
35
|
-
// include / exclude
|
|
36
|
-
u(
|
|
37
|
-
(e, r) => o.pick ? o.pick.includes(r) && !o.omit?.includes(r) : !o.omit?.includes(r)
|
|
38
|
-
),
|
|
39
|
-
(e) => e,
|
|
40
|
-
// labelMap and adding name
|
|
41
|
-
m((e, r) => ({
|
|
42
|
-
name: r,
|
|
43
|
-
label: o.labelMap?.(r) || r,
|
|
44
|
-
...e
|
|
45
|
-
})),
|
|
46
|
-
// filterMap
|
|
47
|
-
o.filterMap ? a((e) => {
|
|
48
|
-
const r = o.filterMap?.(e.name, e);
|
|
49
|
-
return r === void 0 || r === !0 ? e : r;
|
|
50
|
-
}) : (e) => e,
|
|
51
|
-
// transform to array
|
|
52
|
-
(e) => Object.values(e),
|
|
53
|
-
// order
|
|
54
|
-
l.sort(d),
|
|
55
|
-
// sort
|
|
56
|
-
o.sort ? l.sort(o.sort) : (e) => e
|
|
57
|
-
)
|
|
58
|
-
);
|
|
59
|
-
return (e, r) => (M(!0), j(E, null, A(b.value, ({ name: t, label: n, ...c }) => F(e.$slots, "default", {
|
|
60
|
-
child: { name: t, label: n, ...c }
|
|
61
|
-
}, () => [
|
|
62
|
-
g(v, h({
|
|
63
|
-
form: o.form,
|
|
64
|
-
name: t,
|
|
65
|
-
label: n
|
|
66
|
-
}, { ref_for: !0 }, c), null, 16, ["form", "name", "label"])
|
|
67
|
-
])), 256));
|
|
13
|
+
setup(g) {
|
|
14
|
+
const o = t(c);
|
|
15
|
+
if (!o)
|
|
16
|
+
throw new Error("OmegaFormInput must be used within an OmegaForm context");
|
|
17
|
+
return (e, b) => (m(), n(d, p(e.$props, {
|
|
18
|
+
form: s(o),
|
|
19
|
+
name: e.name,
|
|
20
|
+
label: e.label,
|
|
21
|
+
validators: e.validators,
|
|
22
|
+
options: e.options,
|
|
23
|
+
type: e.type
|
|
24
|
+
}), {
|
|
25
|
+
default: i((r) => [
|
|
26
|
+
l(e.$slots, "default", f(u(r)))
|
|
27
|
+
]),
|
|
28
|
+
_: 3
|
|
29
|
+
}, 16, ["form", "name", "label", "validators", "options", "type"]));
|
|
68
30
|
}
|
|
69
31
|
});
|
|
70
32
|
export {
|
|
71
|
-
|
|
33
|
+
w as default
|
|
72
34
|
};
|
|
@@ -1,53 +1,52 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
|
|
1
|
+
import { defineComponent as d, inject as f, computed as r, createBlock as n, openBlock as m, resolveDynamicComponent as c, withCtx as l, createCommentVNode as v, mergeProps as y, renderSlot as g, normalizeProps as h, guardReactiveProps as b } from "vue";
|
|
2
|
+
import { generateInputStandardSchemaFromFieldMeta as C } from "./vue-components.es10.js";
|
|
3
|
+
import F from "./vue-components.es24.js";
|
|
4
|
+
const P = /* @__PURE__ */ d({
|
|
3
5
|
inheritAttrs: !1,
|
|
4
|
-
__name: "
|
|
6
|
+
__name: "OmegaInput",
|
|
5
7
|
props: {
|
|
6
8
|
form: {},
|
|
7
9
|
name: {},
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
validators: {},
|
|
11
|
+
label: {},
|
|
12
|
+
options: {},
|
|
13
|
+
type: {}
|
|
10
14
|
},
|
|
11
|
-
setup(
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
M(async () => {
|
|
21
|
-
t.defaultItems && !u.value && t.form.setFieldValue(t.name, t.defaultItems);
|
|
15
|
+
setup(s) {
|
|
16
|
+
const a = s, o = f(
|
|
17
|
+
"getMetaFromArray",
|
|
18
|
+
null
|
|
19
|
+
), t = r(() => o?.value && o.value(a.name) ? o.value(a.name) : a.form.meta[a.name]), i = r(() => {
|
|
20
|
+
if (!t.value)
|
|
21
|
+
throw console.log(a.name, Object.keys(a.form.meta), a.form.meta), new Error("Meta is undefined");
|
|
22
|
+
return C(t.value);
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
24
|
+
return (e, k) => (m(), n(c(e.form.Field), {
|
|
25
|
+
name: e.name,
|
|
26
|
+
validators: {
|
|
27
|
+
onChange: i.value,
|
|
28
|
+
...e.validators
|
|
29
|
+
}
|
|
30
|
+
}, {
|
|
31
|
+
default: l(({ field: p }) => [
|
|
32
|
+
t.value ? (m(), n(F, y({
|
|
33
|
+
key: 0,
|
|
34
|
+
field: p,
|
|
35
|
+
label: e.label,
|
|
36
|
+
options: e.options,
|
|
37
|
+
meta: t.value,
|
|
38
|
+
type: e.type
|
|
39
|
+
}, e.$attrs), {
|
|
40
|
+
default: l((u) => [
|
|
41
|
+
g(e.$slots, "default", h(b(u)))
|
|
41
42
|
]),
|
|
42
|
-
_:
|
|
43
|
-
},
|
|
44
|
-
o(e.$slots, "post-array", s(l({ field: r, state: p }))),
|
|
45
|
-
o(e.$slots, "field", s(l({ field: r })))
|
|
43
|
+
_: 3
|
|
44
|
+
}, 16, ["field", "label", "options", "meta", "type"])) : v("", !0)
|
|
46
45
|
]),
|
|
47
46
|
_: 3
|
|
48
|
-
}, 8, ["name"]));
|
|
47
|
+
}, 8, ["name", "validators"]));
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
50
|
export {
|
|
52
|
-
|
|
51
|
+
P as default
|
|
53
52
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useForm as j } from "@tanstack/vue-form";
|
|
2
2
|
import { S as E } from "effect-app";
|
|
3
|
-
import {
|
|
3
|
+
import { isObject as O } from "./vue-components.es22.js";
|
|
4
4
|
import { computed as v, onUnmounted as P, onMounted as I, onBeforeUnmount as N, provide as R } from "vue";
|
|
5
|
-
import
|
|
6
|
-
import D from "./vue-components.
|
|
5
|
+
import A from "./vue-components.es6.js";
|
|
6
|
+
import { generateMetaFromSchema as D } from "./vue-components.es10.js";
|
|
7
7
|
const F = Symbol("OmegaForm"), $ = (d, i, o) => {
|
|
8
8
|
if (!d) throw new Error("Schema is required");
|
|
9
|
-
const S = E.standardSchemaV1(d), { filterItems: b, meta: a } =
|
|
9
|
+
const S = E.standardSchemaV1(d), { filterItems: b, meta: a } = D(d), n = v(() => {
|
|
10
10
|
if (o?.persistency?.id)
|
|
11
11
|
return o.persistency.id;
|
|
12
12
|
const e = window.location.pathname, r = Object.keys(a);
|
|
@@ -19,7 +19,7 @@ const F = Symbol("OmegaForm"), $ = (d, i, o) => {
|
|
|
19
19
|
};
|
|
20
20
|
function m(e, r) {
|
|
21
21
|
for (const s in r)
|
|
22
|
-
r[s] &&
|
|
22
|
+
r[s] && O(r[s]) ? (e[s] || (e[s] = {}), m(e[s], r[s])) : e[s] = r[s];
|
|
23
23
|
return e;
|
|
24
24
|
}
|
|
25
25
|
const V = v(() => {
|
|
@@ -80,9 +80,7 @@ const F = Symbol("OmegaForm"), $ = (d, i, o) => {
|
|
|
80
80
|
if (Array.isArray(e.keys))
|
|
81
81
|
return p(e.keys);
|
|
82
82
|
if (Array.isArray(e.banKeys)) {
|
|
83
|
-
const r = Object.keys(a).filter(
|
|
84
|
-
(s) => e.banKeys?.includes(s)
|
|
85
|
-
);
|
|
83
|
+
const r = Object.keys(a).filter((s) => e.banKeys?.includes(s));
|
|
86
84
|
return p(r);
|
|
87
85
|
}
|
|
88
86
|
return l.store.state.values;
|
|
@@ -115,7 +113,7 @@ const F = Symbol("OmegaForm"), $ = (d, i, o) => {
|
|
|
115
113
|
clear: L
|
|
116
114
|
});
|
|
117
115
|
return R(F, h), Object.assign(h, {
|
|
118
|
-
Input:
|
|
116
|
+
Input: A,
|
|
119
117
|
Field: l.Field
|
|
120
118
|
});
|
|
121
119
|
};
|
package/package.json
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/vue-components",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.24",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@mdi/js": "^7.4.47",
|
|
6
|
-
"@tanstack/vue-form": "
|
|
7
|
-
"effect": "^3.17.
|
|
6
|
+
"@tanstack/vue-form": "1.2.4",
|
|
7
|
+
"effect": "^3.17.13",
|
|
8
8
|
"intl-messageformat": "^10.7.16",
|
|
9
9
|
"mdi-js": "^1.0.1",
|
|
10
10
|
"primeflex": "^4.0.0",
|
|
11
11
|
"primeicons": "^7.0.0",
|
|
12
|
-
"primevue": "^4.3.
|
|
13
|
-
"vue": "^3.5.
|
|
14
|
-
"vuetify": "^3.9.
|
|
12
|
+
"primevue": "^4.3.8",
|
|
13
|
+
"vue": "^3.5.21",
|
|
14
|
+
"vuetify": "^3.9.7"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"@
|
|
18
|
-
"@
|
|
19
|
-
"
|
|
20
|
-
"@
|
|
21
|
-
"@
|
|
17
|
+
"@dprint/typescript": "^0.95.11",
|
|
18
|
+
"@ben_12/eslint-plugin-dprint": "^1.7.4",
|
|
19
|
+
"dprint": "^0.50.1",
|
|
20
|
+
"@storybook/vue3": "^9.1.4",
|
|
21
|
+
"@storybook/vue3-vite": "^9.1.4",
|
|
22
|
+
"@types/node": "^24.3.1",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "8.42.0",
|
|
24
|
+
"@typescript-eslint/parser": "8.42.0",
|
|
22
25
|
"@vitejs/plugin-vue": "^6.0.1",
|
|
23
26
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
24
27
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
@@ -27,13 +30,13 @@
|
|
|
27
30
|
"eslint-plugin-vue": "^10.4.0",
|
|
28
31
|
"jsdom": "^26.1.0",
|
|
29
32
|
"rimraf": "^6.0.1",
|
|
30
|
-
"sass": "^1.
|
|
31
|
-
"storybook": "^9.1.
|
|
33
|
+
"sass": "^1.92.0",
|
|
34
|
+
"storybook": "^9.1.4",
|
|
32
35
|
"typescript": "~5.9.2",
|
|
33
|
-
"vite": "^7.1.
|
|
36
|
+
"vite": "^7.1.4",
|
|
34
37
|
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
35
38
|
"vitepress": "^1.6.4",
|
|
36
|
-
"vue-tsc": "^
|
|
39
|
+
"vue-tsc": "^3.0.6"
|
|
37
40
|
},
|
|
38
41
|
"files": [
|
|
39
42
|
"src",
|
|
@@ -50,8 +53,8 @@
|
|
|
50
53
|
"dependencies": {
|
|
51
54
|
"highlight.js": "^11.11.1",
|
|
52
55
|
"vue3-highlightjs": "^1.0.5",
|
|
53
|
-
"effect-app": "
|
|
54
|
-
"
|
|
56
|
+
"@effect-app/vue": "2.53.4",
|
|
57
|
+
"effect-app": "3.2.4"
|
|
55
58
|
},
|
|
56
59
|
"scripts": {
|
|
57
60
|
"build": "pnpm build:run",
|
|
@@ -1,33 +1,21 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import type {
|
|
3
|
-
DeepValue,
|
|
4
|
-
DeepKeys,
|
|
5
|
-
FieldApi,
|
|
6
|
-
ValidationError,
|
|
7
|
-
FormAsyncValidateOrFn,
|
|
8
|
-
FormValidateOrFn,
|
|
9
|
-
StandardSchemaV1,
|
|
10
|
-
FieldValidateOrFn,
|
|
11
|
-
FieldValidateFn,
|
|
12
|
-
FieldValidateAsyncFn,
|
|
13
|
-
FieldAsyncValidateOrFn,
|
|
14
|
-
} from "@tanstack/vue-form"
|
|
2
|
+
import type { DeepKeys, DeepValue, FieldApi, FieldAsyncValidateOrFn, FieldValidateAsyncFn, FieldValidateFn, FieldValidateOrFn, FormAsyncValidateOrFn, FormValidateOrFn, StandardSchemaV1 } from "@tanstack/vue-form"
|
|
15
3
|
|
|
16
4
|
export type OmegaFieldInternalApi<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = FieldApi<
|
|
17
|
-
/* in out TParentData*/ From,
|
|
18
|
-
/* in out TName*/ TName,
|
|
19
|
-
/* in out TData*/
|
|
20
|
-
/* in out TOnMount*/
|
|
21
|
-
/* in out TOnChange*/
|
|
22
|
-
/* in out TOnChangeAsync*/
|
|
23
|
-
/* in out TOnBlur*/
|
|
24
|
-
/* in out TOnBlurAsync*/
|
|
25
|
-
/* in out TOnSubmit*/
|
|
26
|
-
/* in out TOnSubmitAsync*/
|
|
27
|
-
/* in out TFormOnMount*/
|
|
28
|
-
/* in out TFormOnChange*/
|
|
29
|
-
// using `any` for now to silence:
|
|
30
|
-
/*
|
|
5
|
+
/* in out TParentData*/ From,
|
|
6
|
+
/* in out TName*/ TName,
|
|
7
|
+
/* in out TData*/ DeepValue<From, TName>,
|
|
8
|
+
/* in out TOnMount*/ FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined,
|
|
9
|
+
/* in out TOnChange*/ StandardSchemaV1<DeepValue<From, TName>, unknown> | FieldValidateFn<From, TName>,
|
|
10
|
+
/* in out TOnChangeAsync*/ StandardSchemaV1<DeepValue<From, TName>, unknown> | FieldValidateAsyncFn<From, TName>,
|
|
11
|
+
/* in out TOnBlur*/ FieldValidateOrFn<From, TName, DeepValue<From, TName>>,
|
|
12
|
+
/* in out TOnBlurAsync*/ FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>>,
|
|
13
|
+
/* in out TOnSubmit*/ FieldValidateOrFn<From, TName, DeepValue<From, TName>> | undefined,
|
|
14
|
+
/* in out TOnSubmitAsync*/ FieldAsyncValidateOrFn<From, TName, DeepValue<From, TName>> | undefined,
|
|
15
|
+
/* in out TFormOnMount*/ FormValidateOrFn<From> | undefined,
|
|
16
|
+
/* in out TFormOnChange*/ FormValidateOrFn<From> | undefined,
|
|
17
|
+
// using `any` for now to silence:
|
|
18
|
+
/*
|
|
31
19
|
Type 'FieldApi<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>, FieldValidateOrFn<From, DeepKeys<From>, DeepValue<From, DeepKeys<...>>> | undefined, ... 14 more ..., FormAsyncValidateOrFn<...> | undefined>' is not assignable to type 'OmegaFieldInternalApi<From, any>'.
|
|
32
20
|
The types of 'form.options.defaultState' are incompatible between these types.
|
|
33
21
|
Type 'Partial<FormState<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, StandardSchemaV1<From, To>, ... 4 more ..., FormAsyncValidateOrFn<...> | undefined>> | undefined' is not assignable to type 'Partial<FormState<From, FormValidateOrFn<From> | undefined, FormValidateOrFn<From> | undefined, FormAsyncValidateOrFn<From>, ... 4 more ..., FormAsyncValidateOrFn<...> | undefined>> | undefined'.
|
|
@@ -36,14 +24,14 @@ Type 'FieldApi<From, DeepKeys<From>, DeepValue<From, DeepKeys<From>>, FieldValid
|
|
|
36
24
|
Type 'FormValidationErrorMap<undefined, undefined, Record<string, StandardSchemaV1Issue[]>, undefined, undefined, undefined, undefined, undefined> | undefined' is not assignable to type 'FormValidationErrorMap<undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined> | undefined'.
|
|
37
25
|
Type 'FormValidationErrorMap<undefined, undefined, Record<string, StandardSchemaV1Issue[]>, undefined, undefined, undefined, undefined, undefined>' is not assignable to type 'FormValidationErrorMap<undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined>'.
|
|
38
26
|
Type 'Record<string, StandardSchemaV1Issue[]>' is not assignable to type 'undefined'.
|
|
39
|
-
*/
|
|
40
|
-
/* in out TFormOnChangeAsync*/ any, // FormAsyncValidateOrFn<From>,
|
|
41
|
-
/* in out TFormOnBlur*/
|
|
42
|
-
/* in out TFormOnBlurAsync*/
|
|
43
|
-
/* in out TFormOnSubmit*/
|
|
44
|
-
/* in out TFormOnSubmitAsync*/
|
|
45
|
-
/* in out TFormOnServer*/
|
|
46
|
-
/* in out TParentSubmitMeta*/
|
|
27
|
+
*/
|
|
28
|
+
/* in out TFormOnChangeAsync*/ any, // FormAsyncValidateOrFn<From>,
|
|
29
|
+
/* in out TFormOnBlur*/ FormValidateOrFn<From> | undefined,
|
|
30
|
+
/* in out TFormOnBlurAsync*/ FormAsyncValidateOrFn<From> | undefined,
|
|
31
|
+
/* in out TFormOnSubmit*/ FormValidateOrFn<From> | undefined,
|
|
32
|
+
/* in out TFormOnSubmitAsync*/ FormAsyncValidateOrFn<From> | undefined,
|
|
33
|
+
/* in out TFormOnServer*/ FormAsyncValidateOrFn<From> | undefined,
|
|
34
|
+
/* in out TParentSubmitMeta*/ FormAsyncValidateOrFn<From> | undefined
|
|
47
35
|
>
|
|
48
36
|
|
|
49
37
|
export type InputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = {
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component
|
|
2
|
+
<component
|
|
3
|
+
:is="form.Field"
|
|
4
|
+
:name="name"
|
|
5
|
+
>
|
|
3
6
|
<template #default="{ field, state }">
|
|
4
|
-
<slot
|
|
7
|
+
<slot
|
|
8
|
+
name="pre-array"
|
|
9
|
+
v-bind="{ field, state }"
|
|
10
|
+
/>
|
|
5
11
|
<component
|
|
6
12
|
:is="form.Field"
|
|
7
13
|
v-for="(_, i) of items"
|
|
8
14
|
:key="`${name}[${Number(i)}]`"
|
|
9
|
-
:name="
|
|
10
|
-
`${name}[${Number(i)}]` as DeepKeys<From>
|
|
11
|
-
"
|
|
15
|
+
:name="`${name}[${Number(i)}]` as DeepKeys<From>"
|
|
12
16
|
>
|
|
13
17
|
<template #default="{ field: subField, state: subState }">
|
|
14
18
|
<slot
|
|
@@ -16,14 +20,20 @@
|
|
|
16
20
|
subField,
|
|
17
21
|
subState,
|
|
18
22
|
index: Number(i),
|
|
19
|
-
field
|
|
23
|
+
field
|
|
20
24
|
}"
|
|
21
25
|
/>
|
|
22
26
|
</template>
|
|
23
27
|
</component>
|
|
24
|
-
<slot
|
|
28
|
+
<slot
|
|
29
|
+
name="post-array"
|
|
30
|
+
v-bind="{ field, state }"
|
|
31
|
+
/>
|
|
25
32
|
<!-- TODO: legacy slot, remove this slot -->
|
|
26
|
-
<slot
|
|
33
|
+
<slot
|
|
34
|
+
name="field"
|
|
35
|
+
v-bind="{ field }"
|
|
36
|
+
/>
|
|
27
37
|
</template>
|
|
28
38
|
</component>
|
|
29
39
|
</template>
|
|
@@ -31,13 +41,13 @@
|
|
|
31
41
|
setup
|
|
32
42
|
lang="ts"
|
|
33
43
|
generic="
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
From extends Record<PropertyKey, any>,
|
|
45
|
+
To extends Record<PropertyKey, any>
|
|
46
|
+
"
|
|
37
47
|
>
|
|
48
|
+
import { type DeepKeys, type DeepValue } from "@tanstack/vue-form"
|
|
38
49
|
import { computed, onMounted, provide } from "vue"
|
|
39
50
|
import { type OmegaInputProps } from "./OmegaFormStuff"
|
|
40
|
-
import { type DeepValue, type DeepKeys } from "@tanstack/vue-form"
|
|
41
51
|
|
|
42
52
|
const props = defineProps<
|
|
43
53
|
Omit<
|
|
@@ -51,10 +61,10 @@ const props = defineProps<
|
|
|
51
61
|
>()
|
|
52
62
|
|
|
53
63
|
defineOptions({
|
|
54
|
-
inheritAttrs: false
|
|
64
|
+
inheritAttrs: false
|
|
55
65
|
})
|
|
56
66
|
|
|
57
|
-
const store = props.form.useStore(state => state.values)
|
|
67
|
+
const store = props.form.useStore((state) => state.values)
|
|
58
68
|
const items = computed(() => {
|
|
59
69
|
const normalizedPath = props.name.replace(/\[/g, ".").replace(/\]/g, "")
|
|
60
70
|
try {
|
|
@@ -1,41 +1,49 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<slot
|
|
3
|
-
v-for="{ name, label, ...attrs } in children"
|
|
3
|
+
v-for="({ name, label, ...attrs }) in children"
|
|
4
4
|
:child="{ name, label, ...attrs }"
|
|
5
5
|
>
|
|
6
|
-
<OmegaInput
|
|
6
|
+
<OmegaInput
|
|
7
|
+
:form="props.form"
|
|
8
|
+
:name="name"
|
|
9
|
+
:label="label"
|
|
10
|
+
v-bind="attrs"
|
|
11
|
+
/>
|
|
7
12
|
</slot>
|
|
8
13
|
</template>
|
|
9
14
|
|
|
10
|
-
<script
|
|
15
|
+
<script
|
|
16
|
+
setup
|
|
17
|
+
lang="ts"
|
|
18
|
+
generic="
|
|
19
|
+
From extends Record<PropertyKey, string>,
|
|
20
|
+
To extends Record<PropertyKey, string>
|
|
21
|
+
"
|
|
22
|
+
>
|
|
23
|
+
import { type DeepKeys } from "@tanstack/vue-form"
|
|
24
|
+
import { Array as A, Order, pipe } from "effect-app"
|
|
11
25
|
import { computed } from "vue"
|
|
12
|
-
import {
|
|
13
|
-
type NestedKeyOf,
|
|
14
|
-
type MetaRecord,
|
|
15
|
-
type FormType,
|
|
16
|
-
type FieldMeta,
|
|
17
|
-
type OmegaInputProps,
|
|
18
|
-
} from "./OmegaFormStuff"
|
|
19
|
-
import { pipe, Order, Array as A } from "effect-app"
|
|
26
|
+
import { type FieldMeta, type OmegaInputProps } from "./OmegaFormStuff"
|
|
20
27
|
import OmegaInput from "./OmegaInput.vue"
|
|
21
|
-
import { DeepKeys } from "@tanstack/vue-form"
|
|
22
|
-
import { OmegaFormReturn } from "./useOmegaForm"
|
|
23
28
|
|
|
24
|
-
export type OmegaAutoGenMeta<
|
|
29
|
+
export type OmegaAutoGenMeta<
|
|
30
|
+
From extends Record<PropertyKey, string>,
|
|
31
|
+
To extends Record<PropertyKey, string>
|
|
32
|
+
> = Omit<OmegaInputProps<From, To>, "form">
|
|
25
33
|
type NewMeta = OmegaAutoGenMeta<From, To>
|
|
26
34
|
|
|
27
35
|
const mapObject =
|
|
28
36
|
<K extends string, A, B>(fn: (value: A, key: K) => B) =>
|
|
29
37
|
(obj: Record<K, A>): Record<K, B> =>
|
|
30
38
|
Object.fromEntries(
|
|
31
|
-
(Object.entries(obj) as [K, A][]).map(([k, v]) => [k, fn(v, k)])
|
|
39
|
+
(Object.entries(obj) as [K, A][]).map(([k, v]) => [k, fn(v, k)])
|
|
32
40
|
) as Record<K, B> // Cast needed for Object.fromEntries
|
|
33
41
|
|
|
34
42
|
const filterRecord =
|
|
35
43
|
<K extends string, V>(predicate: (value: V, key: K) => boolean) =>
|
|
36
44
|
(obj: Record<K, V>): Record<K, V> =>
|
|
37
45
|
Object.fromEntries(
|
|
38
|
-
(Object.entries(obj) as [K, V][]).filter(([k, v]) => predicate(v, k))
|
|
46
|
+
(Object.entries(obj) as [K, V][]).filter(([k, v]) => predicate(v, k))
|
|
39
47
|
) as Record<K, V>
|
|
40
48
|
|
|
41
49
|
const filterMapRecord =
|
|
@@ -49,11 +57,11 @@ const filterMapRecord =
|
|
|
49
57
|
}
|
|
50
58
|
return acc
|
|
51
59
|
},
|
|
52
|
-
{} as Record<K, B
|
|
60
|
+
{} as Record<K, B>
|
|
53
61
|
)
|
|
54
62
|
|
|
55
63
|
const props = defineProps<{
|
|
56
|
-
form: OmegaInputProps<From, To>[
|
|
64
|
+
form: OmegaInputProps<From, To>["form"]
|
|
57
65
|
pick?: DeepKeys<From>[]
|
|
58
66
|
omit?: DeepKeys<From>[]
|
|
59
67
|
labelMap?: (key: DeepKeys<From>) => string | undefined
|
|
@@ -69,7 +77,7 @@ const namePosition = (name: DeepKeys<From>, order: DeepKeys<From>[]) => {
|
|
|
69
77
|
|
|
70
78
|
const orderBy: Order.Order<NewMeta> = Order.mapInput(
|
|
71
79
|
Order.number,
|
|
72
|
-
(x: NewMeta) => namePosition(x.name, props.order || [])
|
|
80
|
+
(x: NewMeta) => namePosition(x.name, props.order || [])
|
|
73
81
|
)
|
|
74
82
|
|
|
75
83
|
const children = computed<NewMeta[]>(() =>
|
|
@@ -79,29 +87,29 @@ const children = computed<NewMeta[]>(() =>
|
|
|
79
87
|
filterRecord((_, metaKey) =>
|
|
80
88
|
props.pick
|
|
81
89
|
? props.pick.includes(metaKey) && !props.omit?.includes(metaKey)
|
|
82
|
-
: !props.omit?.includes(metaKey)
|
|
90
|
+
: !props.omit?.includes(metaKey)
|
|
83
91
|
),
|
|
84
|
-
x => x,
|
|
92
|
+
(x) => x,
|
|
85
93
|
// labelMap and adding name
|
|
86
94
|
mapObject((metaValue, metaKey) => ({
|
|
87
95
|
name: metaKey,
|
|
88
96
|
label: props.labelMap?.(metaKey) || metaKey,
|
|
89
|
-
...metaValue
|
|
97
|
+
...metaValue
|
|
90
98
|
})),
|
|
91
99
|
// filterMap
|
|
92
100
|
props.filterMap
|
|
93
|
-
? filterMapRecord(m => {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
: x => x,
|
|
101
|
+
? filterMapRecord((m) => {
|
|
102
|
+
const result = props.filterMap?.(m.name!, m as NewMeta)
|
|
103
|
+
return result === undefined || result === true ? m : result
|
|
104
|
+
})
|
|
105
|
+
: (x) => x,
|
|
98
106
|
// transform to array
|
|
99
|
-
obj => Object.values(obj) as NewMeta[],
|
|
107
|
+
(obj) => Object.values(obj) as NewMeta[],
|
|
100
108
|
// order
|
|
101
109
|
A.sort(orderBy),
|
|
102
110
|
// sort
|
|
103
|
-
props.sort ? A.sort(props.sort) : x => x
|
|
104
|
-
)
|
|
111
|
+
props.sort ? A.sort(props.sort) : (x) => x
|
|
112
|
+
)
|
|
105
113
|
)
|
|
106
114
|
|
|
107
115
|
defineSlots<{
|