@effect-app/vue-components 0.7.2 → 0.7.4
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/OmegaArray.vue.d.ts +5 -2
- package/dist/types/components/OmegaForm/OmegaFormStuff.d.ts +1 -2
- package/dist/vue-components.es6.js +40 -25
- package/package.json +1 -1
- package/src/components/OmegaForm/OmegaArray.vue +48 -20
- package/src/components/OmegaForm/OmegaFormStuff.ts +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { type OmegaInputProps } from "./OmegaFormStuff";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { type DeepValue, type DeepKeys } from "@tanstack/vue-form";
|
|
3
|
+
declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & (Omit<OmegaInputProps<T, T>, "type" | "validators" | "items" | "label" | "options"> & {
|
|
5
|
+
items?: DeepValue<T, DeepKeys<T>>;
|
|
6
|
+
}) & Partial<{}>> & import("vue").PublicProps;
|
|
4
7
|
expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
|
|
5
8
|
attrs: any;
|
|
6
9
|
slots: {
|
|
@@ -85,7 +85,7 @@ export type FilterItems = {
|
|
|
85
85
|
readonly message: string | Effect.Effect<string>;
|
|
86
86
|
};
|
|
87
87
|
};
|
|
88
|
-
type CreateMeta = {
|
|
88
|
+
export type CreateMeta = {
|
|
89
89
|
parent?: string;
|
|
90
90
|
meta?: Record<string, any>;
|
|
91
91
|
nullableOrUndefined?: false | "undefined" | "null";
|
|
@@ -107,4 +107,3 @@ export declare const generateInputStandardSchemaFromFieldMeta: (meta: FieldMeta)
|
|
|
107
107
|
export declare const nullableInput: <A, I, R>(schema: S.Schema<A, I, R>, defaultValue: () => A) => S.transform<import("effect/Schema").NullOr<S.Schema<A, I, R>> & {
|
|
108
108
|
withDefault: S.PropertySignature<":", A | null, never, ":", I | null, true, R>;
|
|
109
109
|
}, S.SchemaClass<A, A, never>>;
|
|
110
|
-
export {};
|
|
@@ -1,52 +1,67 @@
|
|
|
1
|
-
import { defineComponent as c,
|
|
2
|
-
import { createMeta as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as c, onMounted as g, watch as M, computed as F, provide as h, createBlock as p, openBlock as m, resolveDynamicComponent as i, withCtx as l, createElementBlock as _, renderSlot as u, Fragment as k, renderList as v, mergeProps as A, normalizeProps as S, guardReactiveProps as $ } from "vue";
|
|
2
|
+
import { createMeta as B } from "./vue-components.es9.js";
|
|
3
|
+
const w = /* @__PURE__ */ c({
|
|
4
4
|
inheritAttrs: !1,
|
|
5
5
|
__name: "OmegaArray",
|
|
6
6
|
props: {
|
|
7
7
|
form: {},
|
|
8
|
-
name: {}
|
|
8
|
+
name: {},
|
|
9
|
+
items: {}
|
|
9
10
|
},
|
|
10
11
|
setup(f) {
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const r = f;
|
|
13
|
+
g(() => {
|
|
14
|
+
r.items && r.form.setFieldValue(r.name, r.items);
|
|
15
|
+
}), M(
|
|
16
|
+
() => r.items,
|
|
17
|
+
async (e) => {
|
|
18
|
+
e && r.form.setFieldValue(r.name, e);
|
|
19
|
+
}
|
|
20
|
+
);
|
|
21
|
+
const d = F(() => {
|
|
22
|
+
const e = r.form.meta[r.name];
|
|
13
23
|
if (e && e.type === "multiple") {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
propertySignatures
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const o = e.rest.reduce((t, a) => a.type._tag === "TypeLiteral" ? {
|
|
25
|
+
...t,
|
|
26
|
+
propertySignatures: [
|
|
27
|
+
...t.propertySignatures || [],
|
|
28
|
+
...a.type.propertySignatures
|
|
29
|
+
]
|
|
30
|
+
} : {
|
|
31
|
+
...t,
|
|
32
|
+
property: a.type
|
|
33
|
+
}, {}), n = B({ ...o, meta: e });
|
|
20
34
|
return (t) => {
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
if (t.endsWith("]")) return n;
|
|
36
|
+
const a = t.split("]."), s = a[a.length - 1];
|
|
37
|
+
return n[s];
|
|
23
38
|
};
|
|
24
39
|
}
|
|
25
|
-
return (
|
|
40
|
+
return (o) => {
|
|
26
41
|
};
|
|
27
42
|
});
|
|
28
|
-
return
|
|
29
|
-
default:
|
|
30
|
-
(
|
|
43
|
+
return h("getMetaFromArray", d), (e, o) => (m(), p(i(e.form.Field), { name: e.name }, {
|
|
44
|
+
default: l(({ field: n }) => [
|
|
45
|
+
(m(!0), _(k, null, v(n.state.value, (y, t) => (m(), p(i(e.form.Field), {
|
|
31
46
|
key: t,
|
|
32
47
|
name: `${e.name}[${t}]`
|
|
33
48
|
}, {
|
|
34
|
-
default:
|
|
35
|
-
|
|
36
|
-
field:
|
|
37
|
-
subField:
|
|
38
|
-
subState:
|
|
49
|
+
default: l(({ field: a, state: s }) => [
|
|
50
|
+
u(e.$slots, "default", A({ ref_for: !0 }, {
|
|
51
|
+
field: n,
|
|
52
|
+
subField: a,
|
|
53
|
+
subState: s,
|
|
39
54
|
index: t
|
|
40
55
|
}))
|
|
41
56
|
]),
|
|
42
57
|
_: 2
|
|
43
58
|
}, 1032, ["name"]))), 128)),
|
|
44
|
-
|
|
59
|
+
u(e.$slots, "field", S($({ field: n })))
|
|
45
60
|
]),
|
|
46
61
|
_: 3
|
|
47
62
|
}, 8, ["name"]));
|
|
48
63
|
}
|
|
49
64
|
});
|
|
50
65
|
export {
|
|
51
|
-
|
|
66
|
+
w as default
|
|
52
67
|
};
|
package/package.json
CHANGED
|
@@ -23,37 +23,65 @@
|
|
|
23
23
|
</component>
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
|
-
<script setup lang="ts" generic="
|
|
27
|
-
import { computed, provide } from "vue"
|
|
28
|
-
import {
|
|
29
|
-
|
|
26
|
+
<script setup lang="ts" generic="T">
|
|
27
|
+
import { computed, onMounted, provide, watch } from "vue"
|
|
28
|
+
import {
|
|
29
|
+
type CreateMeta,
|
|
30
|
+
type OmegaInputProps,
|
|
31
|
+
createMeta,
|
|
32
|
+
} from "./OmegaFormStuff"
|
|
33
|
+
import { type DeepValue, type DeepKeys } from "@tanstack/vue-form"
|
|
30
34
|
|
|
31
|
-
const props =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
const props = defineProps<
|
|
36
|
+
Omit<
|
|
37
|
+
OmegaInputProps<T, T>,
|
|
38
|
+
"validators" | "options" | "label" | "type" | "items"
|
|
39
|
+
> & {
|
|
40
|
+
items?: DeepValue<T, DeepKeys<T>>
|
|
41
|
+
}
|
|
42
|
+
>()
|
|
35
43
|
|
|
36
44
|
defineOptions({
|
|
37
45
|
inheritAttrs: false,
|
|
38
46
|
})
|
|
39
47
|
|
|
48
|
+
onMounted(() => {
|
|
49
|
+
if (props.items) {
|
|
50
|
+
props.form.setFieldValue(props.name, props.items)
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
watch(
|
|
55
|
+
() => props.items,
|
|
56
|
+
async items => {
|
|
57
|
+
if (items) {
|
|
58
|
+
props.form.setFieldValue(props.name, items)
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
)
|
|
62
|
+
|
|
40
63
|
const getMetaFromArray = computed(() => {
|
|
41
64
|
const inputMeta = props.form.meta[props.name]
|
|
42
65
|
if (inputMeta && inputMeta.type === "multiple") {
|
|
43
|
-
const
|
|
44
|
-
(
|
|
45
|
-
|
|
46
|
-
acc
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
66
|
+
const result = inputMeta.rest.reduce<CreateMeta>((acc, curr) => {
|
|
67
|
+
if (curr.type._tag === "TypeLiteral") {
|
|
68
|
+
return {
|
|
69
|
+
...acc,
|
|
70
|
+
propertySignatures: [
|
|
71
|
+
...(acc.propertySignatures || []),
|
|
72
|
+
...curr.type.propertySignatures,
|
|
73
|
+
],
|
|
74
|
+
} as CreateMeta
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
...acc,
|
|
78
|
+
property: curr.type,
|
|
79
|
+
} as CreateMeta
|
|
80
|
+
}, {} as CreateMeta)
|
|
54
81
|
|
|
55
|
-
const arrayMeta = createMeta(
|
|
82
|
+
const arrayMeta = createMeta({ ...result, meta: inputMeta })
|
|
56
83
|
const getMeta = (index: string) => {
|
|
84
|
+
if (index.endsWith("]")) return arrayMeta
|
|
57
85
|
const parts = index.split("].")
|
|
58
86
|
const key = parts[parts.length - 1]
|
|
59
87
|
return arrayMeta[key as keyof typeof arrayMeta]
|
|
@@ -201,7 +201,7 @@ export type FilterItems = {
|
|
|
201
201
|
| { readonly message: string | Effect.Effect<string> }
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
-
type CreateMeta = {
|
|
204
|
+
export type CreateMeta = {
|
|
205
205
|
parent?: string
|
|
206
206
|
meta?: Record<string, any>
|
|
207
207
|
nullableOrUndefined?: false | "undefined" | "null"
|