@effect-app/vue-components 0.13.3 → 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;
@@ -98,9 +98,9 @@ export type CreateMeta = {
98
98
  property: S.AST.AST;
99
99
  });
100
100
  export declare const createMeta: <T = any>({ meta, parent, property, propertySignatures }: CreateMeta, acc?: Partial<MetaRecord<T>>) => MetaRecord<T> | FieldMeta;
101
- export declare const duplicateSchema: <From, To>(schema: S.Schema<From, To, never>) => S.extend<S.Schema<From, To, never>, import("effect/Schema").Struct<{}>>;
102
- export declare const generateMetaFromSchema: <From, To>(schema: S.Schema<From, To, never>) => {
103
- schema: S.Schema<From, To, never>;
101
+ export declare const duplicateSchema: <From, To>(schema: S.Schema<To, From, never>) => S.extend<S.Schema<To, From, never>, import("effect/Schema").Struct<{}>>;
102
+ export declare const generateMetaFromSchema: <From, To>(schema: S.Schema<To, From, never>) => {
103
+ schema: S.Schema<To, From, never>;
104
104
  meta: MetaRecord<To>;
105
105
  filterItems?: FilterItems;
106
106
  };
@@ -17,7 +17,7 @@ declare const _default: <From extends Record<PropertyKey, any>, To extends Recor
17
17
  schema?: undefined;
18
18
  } | {
19
19
  form?: undefined;
20
- schema: S.Schema<From, To, never>;
20
+ schema: S.Schema<To, From, never>;
21
21
  }))) & Partial<{}>> & import("vue").PublicProps;
22
22
  expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
23
23
  attrs: any;
@@ -1,8 +1,8 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-b5d2d31e]{display:contents}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(i,t){const d=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(d&&d.call(this),this.shadowRoot){const o=document.createElement("style");o.appendChild(document.createTextNode("fieldset[data-v-b5d2d31e]{display:contents}")),this.shadowRoot.appendChild(o)}},e.call(window.customElements,i,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
1
+ (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-b227b253]{display:contents}")),document.head.appendChild(n),window.customElements){const e=window.customElements.define;window.customElements.define=function(i,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-b227b253]{display:contents}")),this.shadowRoot.appendChild(d)}},e.call(window.customElements,i,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
2
  import o from "./vue-components.es13.js";
3
3
 
4
4
  import r from "./vue-components.es15.js";
5
- const e = /* @__PURE__ */ r(o, [["__scopeId", "data-v-b5d2d31e"]]);
5
+ const m = /* @__PURE__ */ r(o, [["__scopeId", "data-v-b227b253"]]);
6
6
  export {
7
- e as default
7
+ m as default
8
8
  };
@@ -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.3",
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
 
@@ -397,7 +397,7 @@ export const createMeta = <T = any>(
397
397
  }
398
398
 
399
399
  const flattenMeta = <From, To>(
400
- schema: S.Schema<From, To, never>
400
+ schema: S.Schema<To, From, never>
401
401
  ): MetaRecord<To> => {
402
402
  const ast = schema.ast
403
403
  const result: MetaRecord<To> = {}
@@ -436,15 +436,15 @@ const flattenMeta = <From, To>(
436
436
  }
437
437
 
438
438
  export const duplicateSchema = <From, To>(
439
- schema: S.Schema<From, To, never>
439
+ schema: S.Schema<To, From, never>
440
440
  ) => {
441
441
  return S.extend(schema, S.Struct({}))
442
442
  }
443
443
 
444
444
  export const generateMetaFromSchema = <From, To>(
445
- schema: S.Schema<From, To, never>
445
+ schema: S.Schema<To, From, never>
446
446
  ): {
447
- schema: S.Schema<From, To, never>
447
+ schema: S.Schema<To, From, never>
448
448
  meta: MetaRecord<To>
449
449
  filterItems?: FilterItems
450
450
  } => {
@@ -89,7 +89,7 @@ const props = defineProps<
89
89
  }
90
90
  | {
91
91
  form?: undefined
92
- schema: S.Schema<From, To, never>
92
+ schema: S.Schema<To, From, never>
93
93
  }
94
94
  )
95
95
  >()