@effect-app/vue-components 0.7.1 → 0.7.3

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.
@@ -1,6 +1,9 @@
1
1
  import { type OmegaInputProps } from "./OmegaFormStuff";
2
- declare const _default: <From, To>(__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<{
3
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & Omit<OmegaInputProps<From, To>, "type" | "validators" | "label" | "options"> & Partial<{}>> & import("vue").PublicProps;
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,6 +1,6 @@
1
1
  import { defineComponent as w, computed as f, onBeforeMount as E, watch as j, createElementBlock as v, openBlock as b, withModifiers as F, createElementVNode as M, unref as c, renderSlot as p, createCommentVNode as k, Fragment as V } from "vue";
2
2
  import { useStore as g } from "@tanstack/vue-form";
3
- import { getOmegaStore as B } from "./vue-components.es22.js";
3
+ import { getOmegaStore as B } from "./vue-components.es25.js";
4
4
  import { provideOmegaErrors as C } from "./vue-components.es7.js";
5
5
  import { useOmegaForm as I } from "./vue-components.es8.js";
6
6
  const $ = ["disabled"], N = /* @__PURE__ */ w({
@@ -1,4 +1,4 @@
1
- import { isFunction as c } from "./vue-components.es24.js";
1
+ import { isFunction as c } from "./vue-components.es22.js";
2
2
  const s = c, t = (o) => typeof o == "object" && o !== null, i = (o) => t(o) || s(o);
3
3
  export {
4
4
  s as isFunction,
@@ -1,13 +1,4 @@
1
- import { useStore as u } from "@tanstack/vue-form";
2
- import { computed as f } from "vue";
3
- function c(o, t) {
4
- return f(() => t ? u(o.store, (n) => {
5
- const r = {};
6
- for (const e of t)
7
- r[e] = n[e];
8
- return r;
9
- }).value : {});
10
- }
1
+ const o = (n) => typeof n == "function";
11
2
  export {
12
- c as getOmegaStore
3
+ o as isFunction
13
4
  };
@@ -1,101 +1,4 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const a=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(a&&a.call(this),this.shadowRoot){const i=document.createElement("style");i.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(i)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- import { defineComponent as B, getCurrentInstance as L, useId as P, computed as n, watch as w, nextTick as S, onMounted as x, ref as T, watchEffect as z, renderSlot as A, normalizeProps as D, guardReactiveProps as F, createElementVNode as M, normalizeClass as N, createBlock as R, createCommentVNode as U, unref as j, openBlock as G, mergeProps as H } from "vue";
3
- import { useStore as J } from "@tanstack/vue-form";
4
- import { useOmegaErrors as K } from "./vue-components.es7.js";
5
- import Q from "./vue-components.es27.js";
6
-
7
- const te = /* @__PURE__ */ B({
8
- inheritAttrs: !1,
9
- __name: "OmegaInternalInput",
10
- props: {
11
- field: {},
12
- meta: {},
13
- label: {},
14
- options: {},
15
- type: {},
16
- validators: {}
17
- },
18
- setup(C) {
19
- const e = C, o = L(), $ = o == null ? void 0 : o.appContext.components.VTextField, s = P(), u = e.field, a = J(u.store, (t) => t), d = n(() => {
20
- var t, r;
21
- return e.type ? e.type : ((t = e.meta) == null ? void 0 : t.type) === "string" ? e.meta.format === "email" ? "email" : "string" : ((r = e.meta) == null ? void 0 : r.type) || "unknown";
22
- }), i = n(() => a.value.value), k = n(
23
- () => (
24
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
- a.value.meta.errors.map((t) => t == null ? void 0 : t.message).filter(Boolean)
26
- )
27
- );
28
- w(
29
- () => !!i.value,
30
- (t) => {
31
- var r;
32
- !t && ((r = e.meta) == null ? void 0 : r.type) !== "boolean" && S(() => {
33
- var l;
34
- u.setValue(
35
- ((l = e.meta) == null ? void 0 : l.nullableOrUndefined) === "undefined" ? void 0 : null
36
- );
37
- });
38
- }
39
- ), x(() => {
40
- var t, r;
41
- !i.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
42
- });
43
- const { addError: I, removeError: O, showErrors: _, showErrorsOn: q } = K(), m = T(!1);
44
- z(() => {
45
- (_.value || q === "onChange") && (m.value = !0);
46
- });
47
- const p = () => {
48
- m.value = !0;
49
- };
50
- x(() => {
51
- i.value && p();
52
- });
53
- const c = n(() => !m.value && d.value !== "select" ? [] : k.value);
54
- w(
55
- () => a.value.meta.errors,
56
- () => {
57
- a.value.meta.errors.length ? I({
58
- inputId: s,
59
- errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
60
- label: e.label
61
- }) : O(s);
62
- }
63
- );
64
- const f = n(() => {
65
- var t, r, l, v, g, y, h, b, E, V;
66
- return {
67
- id: s,
68
- required: (t = e.meta) == null ? void 0 : t.required,
69
- minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((l = e.meta) == null ? void 0 : l.minLength),
70
- maxLength: ((v = e.meta) == null ? void 0 : v.type) === "string" && ((g = e.meta) == null ? void 0 : g.maxLength),
71
- max: ((y = e.meta) == null ? void 0 : y.type) === "number" && ((h = e.meta) == null ? void 0 : h.maximum),
72
- min: ((b = e.meta) == null ? void 0 : b.type) === "number" && ((E = e.meta) == null ? void 0 : E.minimum),
73
- name: e.field.name,
74
- modelValue: e.field.state.value,
75
- errorMessages: c.value,
76
- error: !!c.value.length,
77
- field: e.field,
78
- setRealDirty: p,
79
- type: d.value,
80
- label: `${e.label}${(V = e.meta) != null && V.required ? " *" : ""}`,
81
- options: e.options
82
- };
83
- });
84
- return (t, r) => A(t.$slots, "default", D(F(f.value)), () => [
85
- M("div", {
86
- class: N(t.$attrs.class),
87
- onFocusout: p
88
- }, [
89
- j($) ? (G(), R(Q, H({
90
- key: 0,
91
- "input-props": f.value
92
- }, t.$attrs, {
93
- "vuetify-value": f.value.field.state.value
94
- }), null, 16, ["input-props", "vuetify-value"])) : U("", !0)
95
- ], 34)
96
- ]);
97
- }
98
- });
1
+ import f from "./vue-components.es21.js";
99
2
  export {
100
- te as default
3
+ f as default
101
4
  };
@@ -1,4 +1,101 @@
1
- const o = (n) => typeof n == "function";
1
+ (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(o,t){const a=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(a&&a.call(this),this.shadowRoot){const i=document.createElement("style");i.appendChild(document.createTextNode(".omega-input .v-input__details:has(.v-messages:empty){grid-template-rows:0fr;transition:all .2s}.omega-input .v-messages:empty{min-height:0}.omega-input .v-input__details:has(.v-messages){transition:all .2s;overflow:hidden;min-height:0;display:grid;grid-template-rows:1fr}.omega-input .v-messages{transition:all .2s}.omega-input .v-messages>*{transition-duration:0s!important}.omega-input [role=alert]:has(.v-messages:empty){padding:0}.omega-input .v-btn{cursor:pointer;width:auto;-webkit-appearance:none;-moz-appearance:none;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(i)}},e.call(window.customElements,o,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import { defineComponent as B, getCurrentInstance as L, useId as P, computed as n, watch as w, nextTick as S, onMounted as x, ref as T, watchEffect as z, renderSlot as A, normalizeProps as D, guardReactiveProps as F, createElementVNode as M, normalizeClass as N, createBlock as R, createCommentVNode as U, unref as j, openBlock as G, mergeProps as H } from "vue";
3
+ import { useStore as J } from "@tanstack/vue-form";
4
+ import { useOmegaErrors as K } from "./vue-components.es7.js";
5
+ import Q from "./vue-components.es27.js";
6
+
7
+ const te = /* @__PURE__ */ B({
8
+ inheritAttrs: !1,
9
+ __name: "OmegaInternalInput",
10
+ props: {
11
+ field: {},
12
+ meta: {},
13
+ label: {},
14
+ options: {},
15
+ type: {},
16
+ validators: {}
17
+ },
18
+ setup(C) {
19
+ const e = C, o = L(), $ = o == null ? void 0 : o.appContext.components.VTextField, s = P(), u = e.field, a = J(u.store, (t) => t), d = n(() => {
20
+ var t, r;
21
+ return e.type ? e.type : ((t = e.meta) == null ? void 0 : t.type) === "string" ? e.meta.format === "email" ? "email" : "string" : ((r = e.meta) == null ? void 0 : r.type) || "unknown";
22
+ }), i = n(() => a.value.value), k = n(
23
+ () => (
24
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
25
+ a.value.meta.errors.map((t) => t == null ? void 0 : t.message).filter(Boolean)
26
+ )
27
+ );
28
+ w(
29
+ () => !!i.value,
30
+ (t) => {
31
+ var r;
32
+ !t && ((r = e.meta) == null ? void 0 : r.type) !== "boolean" && S(() => {
33
+ var l;
34
+ u.setValue(
35
+ ((l = e.meta) == null ? void 0 : l.nullableOrUndefined) === "undefined" ? void 0 : null
36
+ );
37
+ });
38
+ }
39
+ ), x(() => {
40
+ var t, r;
41
+ !i.value && !((t = e.meta) != null && t.required) && ((r = e.meta) == null ? void 0 : r.nullableOrUndefined) === "null" && u.setValue(null);
42
+ });
43
+ const { addError: I, removeError: O, showErrors: _, showErrorsOn: q } = K(), m = T(!1);
44
+ z(() => {
45
+ (_.value || q === "onChange") && (m.value = !0);
46
+ });
47
+ const p = () => {
48
+ m.value = !0;
49
+ };
50
+ x(() => {
51
+ i.value && p();
52
+ });
53
+ const c = n(() => !m.value && d.value !== "select" ? [] : k.value);
54
+ w(
55
+ () => a.value.meta.errors,
56
+ () => {
57
+ a.value.meta.errors.length ? I({
58
+ inputId: s,
59
+ errors: a.value.meta.errors.map((t) => t.message).filter(Boolean),
60
+ label: e.label
61
+ }) : O(s);
62
+ }
63
+ );
64
+ const f = n(() => {
65
+ var t, r, l, v, g, y, h, b, E, V;
66
+ return {
67
+ id: s,
68
+ required: (t = e.meta) == null ? void 0 : t.required,
69
+ minLength: ((r = e.meta) == null ? void 0 : r.type) === "string" && ((l = e.meta) == null ? void 0 : l.minLength),
70
+ maxLength: ((v = e.meta) == null ? void 0 : v.type) === "string" && ((g = e.meta) == null ? void 0 : g.maxLength),
71
+ max: ((y = e.meta) == null ? void 0 : y.type) === "number" && ((h = e.meta) == null ? void 0 : h.maximum),
72
+ min: ((b = e.meta) == null ? void 0 : b.type) === "number" && ((E = e.meta) == null ? void 0 : E.minimum),
73
+ name: e.field.name,
74
+ modelValue: e.field.state.value,
75
+ errorMessages: c.value,
76
+ error: !!c.value.length,
77
+ field: e.field,
78
+ setRealDirty: p,
79
+ type: d.value,
80
+ label: `${e.label}${(V = e.meta) != null && V.required ? " *" : ""}`,
81
+ options: e.options
82
+ };
83
+ });
84
+ return (t, r) => A(t.$slots, "default", D(F(f.value)), () => [
85
+ M("div", {
86
+ class: N(t.$attrs.class),
87
+ onFocusout: p
88
+ }, [
89
+ j($) ? (G(), R(Q, H({
90
+ key: 0,
91
+ "input-props": f.value
92
+ }, t.$attrs, {
93
+ "vuetify-value": f.value.field.state.value
94
+ }), null, 16, ["input-props", "vuetify-value"])) : U("", !0)
95
+ ], 34)
96
+ ]);
97
+ }
98
+ });
2
99
  export {
3
- o as isFunction
100
+ te as default
4
101
  };
@@ -1,4 +1,13 @@
1
- import f from "./vue-components.es21.js";
1
+ import { useStore as u } from "@tanstack/vue-form";
2
+ import { computed as f } from "vue";
3
+ function c(o, t) {
4
+ return f(() => t ? u(o.store, (n) => {
5
+ const r = {};
6
+ for (const e of t)
7
+ r[e] = n[e];
8
+ return r;
9
+ }).value : {});
10
+ }
2
11
  export {
3
- f as default
12
+ c as getOmegaStore
4
13
  };
@@ -1,4 +1,4 @@
1
- import f from "./vue-components.es23.js";
1
+ import f from "./vue-components.es24.js";
2
2
  export {
3
3
  f as default
4
4
  };
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as d, inject as f, computed as r, createBlock as n, openBlock as l, resolveDynamicComponent as v, withCtx as m, createCommentVNode as c, mergeProps as h, renderSlot as y, normalizeProps as g, guardReactiveProps as C } from "vue";
2
2
  import { generateInputStandardSchemaFromFieldMeta as b } from "./vue-components.es9.js";
3
- import k from "./vue-components.es23.js";
3
+ import k from "./vue-components.es24.js";
4
4
  const $ = /* @__PURE__ */ d({
5
5
  inheritAttrs: !1,
6
6
  __name: "OmegaInput",
@@ -1,52 +1,67 @@
1
- import { defineComponent as c, computed as g, provide as M, createBlock as m, openBlock as s, resolveDynamicComponent as u, withCtx as i, createElementBlock as _, renderSlot as l, Fragment as h, renderList as k, mergeProps as v, normalizeProps as F, guardReactiveProps as S } from "vue";
2
- import { createMeta as A } from "./vue-components.es9.js";
3
- const C = /* @__PURE__ */ c({
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 p = f, d = g(() => {
12
- const e = p.form.meta[p.name];
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 n = e.rest.reduce(
15
- (t, r) => (r.type._tag === "TypeLiteral" && t.propertySignatures.push(...r.type.propertySignatures), t),
16
- {
17
- propertySignatures: []
18
- }
19
- ), a = A(n);
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
- const r = t.split("]."), o = r[r.length - 1];
22
- return a[o];
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 (n) => {
40
+ return (o) => {
26
41
  };
27
42
  });
28
- return M("getMetaFromArray", d), (e, n) => (s(), m(u(e.form.Field), { name: e.name }, {
29
- default: i(({ field: a }) => [
30
- (s(!0), _(h, null, k(a.state.value, (y, t) => (s(), m(u(e.form.Field), {
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: i(({ field: r, state: o }) => [
35
- l(e.$slots, "default", v({ ref_for: !0 }, {
36
- field: a,
37
- subField: r,
38
- subState: o,
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
- l(e.$slots, "field", F(S({ field: a })))
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
- C as default
66
+ w as default
52
67
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -54,8 +54,8 @@
54
54
  "dependencies": {
55
55
  "highlight.js": "^11.11.1",
56
56
  "vue3-highlightjs": "^1.0.5",
57
- "effect-app": "2.40.1",
58
- "@effect-app/vue": "2.41.2"
57
+ "@effect-app/vue": "2.41.2",
58
+ "effect-app": "2.40.1"
59
59
  },
60
60
  "scripts": {
61
61
  "build": "pnpm build:run",
@@ -23,37 +23,65 @@
23
23
  </component>
24
24
  </template>
25
25
 
26
- <script setup lang="ts" generic="From, To">
27
- import { computed, provide } from "vue"
28
- import { type OmegaInputProps, createMeta } from "./OmegaFormStuff"
29
- import { type S } from "effect-app"
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
- defineProps<
33
- Omit<OmegaInputProps<From, To>, "validators" | "options" | "label" | "type">
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 propertySignatures = inputMeta.rest.reduce(
44
- (acc, curr) => {
45
- if (curr.type._tag === "TypeLiteral") {
46
- acc.propertySignatures.push(...curr.type.propertySignatures)
47
- }
48
- return acc
49
- },
50
- {
51
- propertySignatures: [],
52
- } as { propertySignatures: S.AST.PropertySignature[] },
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(propertySignatures)
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"
@@ -201,7 +201,7 @@ export const useOmegaForm = <
201
201
 
202
202
  const clear = () => {
203
203
  Object.keys(meta).forEach((key: any) => {
204
- form.setFieldValue(key, undefined)
204
+ form.setFieldValue(key, undefined as any)
205
205
  })
206
206
  }
207
207