@effect-app/vue-components 0.13.4 → 0.14.0

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.
@@ -2,7 +2,8 @@ import { type OmegaInputProps } from "./OmegaFormStuff";
2
2
  import { type DeepValue, type DeepKeys } from "@tanstack/vue-form";
3
3
  declare const _default: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>>(__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
4
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & (Omit<OmegaInputProps<From, To>, "type" | "label" | "items" | "options" | "validators"> & {
5
- items?: DeepValue<To, DeepKeys<To>>;
5
+ defaultItems?: DeepValue<To, DeepKeys<To>>;
6
+ items?: "please use `defaultItems` instead";
6
7
  }) & Partial<{}>> & import("vue").PublicProps;
7
8
  expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
8
9
  attrs: any;
@@ -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.es25.js";
3
+ import { getOmegaStore as B } from "./vue-components.es23.js";
4
4
  import { provideOmegaErrors as C } from "./vue-components.es8.js";
5
5
  import { useOmegaForm as I } from "./vue-components.es9.js";
6
6
  const $ = ["disabled"], N = /* @__PURE__ */ w({
@@ -1,4 +1,4 @@
1
- import { isFunction as c } from "./vue-components.es23.js";
1
+ import { isFunction as c } from "./vue-components.es25.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,4 +1,13 @@
1
- const o = (n) => typeof n == "function";
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
- o as isFunction
12
+ c as getOmegaStore
4
13
  };
@@ -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,57 +1,58 @@
1
- import { defineComponent as g, onMounted as c, computed as M, provide as F, createBlock as p, 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 _, guardReactiveProps as A } from "vue";
2
- import { createMeta as S } from "./vue-components.es10.js";
3
- const C = /* @__PURE__ */ g({
1
+ import { defineComponent as c, onMounted as M, computed as v, provide as F, createBlock as u, openBlock as s, resolveDynamicComponent as p, withCtx as l, createElementBlock as $, renderSlot as i, Fragment as h, renderList as k, mergeProps as S, normalizeProps as _, guardReactiveProps as A } from "vue";
2
+ import { createMeta as I } from "./vue-components.es10.js";
3
+ const C = /* @__PURE__ */ c({
4
4
  inheritAttrs: !1,
5
5
  __name: "OmegaArray",
6
6
  props: {
7
7
  form: {},
8
8
  name: {},
9
+ defaultItems: {},
9
10
  items: {}
10
11
  },
11
12
  setup(f) {
12
- const n = f;
13
- c(() => {
14
- n.items && n.form.setFieldValue(n.name, n.items);
13
+ const r = f, d = r.form.useStore((e) => e.values[r.name]);
14
+ M(() => {
15
+ r.defaultItems && !d.value && r.form.setFieldValue(r.name, r.defaultItems);
15
16
  });
16
- const d = M(() => {
17
- const e = n.form.meta[n.name];
17
+ const y = v(() => {
18
+ const e = r.form.meta[r.name];
18
19
  if (e && e.type === "multiple") {
19
- const o = e.rest.reduce((t, r) => r.type._tag === "TypeLiteral" ? {
20
+ const o = e.rest.reduce((t, a) => a.type._tag === "TypeLiteral" ? {
20
21
  ...t,
21
22
  propertySignatures: [
22
23
  ...t.propertySignatures || [],
23
- ...r.type.propertySignatures
24
+ ...a.type.propertySignatures
24
25
  ]
25
26
  } : {
26
27
  ...t,
27
- property: r.type
28
- }, {}), a = S({ ...o, meta: e });
28
+ property: a.type
29
+ }, {}), n = I({ ...o, meta: e });
29
30
  return (t) => {
30
- if (t.endsWith("]")) return a;
31
- const r = t.split("]."), m = r[r.length - 1];
32
- return a[m];
31
+ if (t.endsWith("]")) return n;
32
+ const a = t.split("]."), m = a[a.length - 1];
33
+ return n[m];
33
34
  };
34
35
  }
35
36
  return (o) => {
36
37
  };
37
38
  });
38
- return F("getMetaFromArray", d), (e, o) => (s(), p(u(e.form.Field), { name: e.name }, {
39
- default: i(({ field: a }) => [
40
- (s(!0), $(h, null, k(a.state.value, (y, t) => (s(), p(u(e.form.Field), {
39
+ return F("getMetaFromArray", y), (e, o) => (s(), u(p(e.form.Field), { name: e.name }, {
40
+ default: l(({ field: n }) => [
41
+ (s(!0), $(h, null, k(n.state.value, (g, t) => (s(), u(p(e.form.Field), {
41
42
  key: `${e.name}[${Number(t)}]`,
42
43
  name: `${e.name}[${Number(t)}]`
43
44
  }, {
44
- default: i(({ field: r, state: m }) => [
45
- l(e.$slots, "default", v({ ref_for: !0 }, {
46
- field: a,
47
- subField: r,
45
+ default: l(({ field: a, state: m }) => [
46
+ i(e.$slots, "default", S({ ref_for: !0 }, {
47
+ field: n,
48
+ subField: a,
48
49
  subState: m,
49
50
  index: Number(t)
50
51
  }))
51
52
  ]),
52
53
  _: 2
53
54
  }, 1032, ["name"]))), 128)),
54
- l(e.$slots, "field", _(A({ field: a })))
55
+ i(e.$slots, "field", _(A({ field: n })))
55
56
  ]),
56
57
  _: 3
57
58
  }, 8, ["name"]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.13.4",
3
+ "version": "0.14.0",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -33,13 +33,16 @@ import {
33
33
  createMeta,
34
34
  } from "./OmegaFormStuff"
35
35
  import { type DeepValue, type DeepKeys } from "@tanstack/vue-form"
36
+ import { S } from "effect-app"
36
37
 
37
38
  const props = defineProps<
38
39
  Omit<
39
40
  OmegaInputProps<From, To>,
40
41
  "validators" | "options" | "label" | "type" | "items"
41
42
  > & {
42
- items?: DeepValue<To, DeepKeys<To>>
43
+ defaultItems?: DeepValue<To, DeepKeys<To>>
44
+ // deprecated items, caused bugs in state update, use defaultItems instead. It's not a simple Never, because Volar explodes
45
+ items?: "please use `defaultItems` instead"
43
46
  }
44
47
  >()
45
48
 
@@ -47,9 +50,11 @@ defineOptions({
47
50
  inheritAttrs: false,
48
51
  })
49
52
 
53
+ const storeItems = props.form.useStore(state => state.values[props.name])
54
+
50
55
  onMounted(() => {
51
- if (props.items) {
52
- props.form.setFieldValue(props.name as any, props.items)
56
+ if (props.defaultItems && !storeItems.value) {
57
+ props.form.setFieldValue(props.name, props.defaultItems)
53
58
  }
54
59
  })
55
60