@effect-app/vue-components 0.3.2 → 0.4.1

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,6 +2,19 @@ import { S, type Effect } from "effect-app";
2
2
  import { type FormAsyncValidateOrFn, type FormValidateOrFn, type StandardSchemaV1, type FormApi, type VueFormApi, type FieldComponent, type FormOptions, type DeepKeys, type FieldValidateOrFn, type FieldAsyncValidateOrFn, type FormState } from "@tanstack/vue-form";
3
3
  import type { Component } from "vue";
4
4
  export type ShowErrorsOn = "onChange" | "onBlur" | "onSubmit";
5
+ export type OmegaInputProps<From, To> = {
6
+ form: FormType<From, To> & {
7
+ meta: MetaRecord<To>;
8
+ };
9
+ name: NestedKeyOf<To>;
10
+ validators?: FieldValidators<From>;
11
+ label: string;
12
+ options?: {
13
+ title: string;
14
+ value: string;
15
+ }[];
16
+ type?: TypeOverride;
17
+ };
5
18
  export type TypeOverride = "string" | "text" | "number" | "select" | "multiple" | "boolean" | "autocomplete" | "autocompletemultiple";
6
19
  export interface OmegaError {
7
20
  label: string;
@@ -1,19 +1,7 @@
1
- import { type FieldValidators, type FormType, type MetaRecord, type NestedKeyOf, type TypeOverride } from "./OmegaFormStuff";
1
+ import { type OmegaInputProps } from "./OmegaFormStuff";
2
2
  import type { OmegaFieldInternalApi } from "./InputProps";
3
3
  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<{
4
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & {
5
- form: FormType<From, To> & {
6
- meta: MetaRecord<To>;
7
- };
8
- name: NestedKeyOf<To>;
9
- validators?: FieldValidators<From>;
10
- label: string;
11
- options?: {
12
- title: string;
13
- value: string;
14
- }[];
15
- type?: TypeOverride;
16
- } & Partial<{}>> & import("vue").PublicProps;
4
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & OmegaInputProps<From, To> & Partial<{}>> & import("vue").PublicProps;
17
5
  expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
18
6
  attrs: any;
19
7
  slots: {
@@ -19,13 +19,17 @@ declare const _default: <From extends Record<PropertyKey, any>, To extends Recor
19
19
  form?: undefined;
20
20
  schema: S.Schema<From, To, never>;
21
21
  }))) & Partial<{}>> & import("vue").PublicProps;
22
- expose(exposed: import("vue").ShallowUnwrapRef<OmegaFormReturn<To, From>>): void;
22
+ expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
23
23
  attrs: any;
24
24
  slots: {
25
- default?: ((props: {
25
+ default(): void;
26
+ internalForm(props: {
26
27
  form: OmegaFormReturn<To, From>;
27
28
  subscribedValues: K[] extends undefined[] ? Record<string, never> : Pick<OmegaFormState<To, From>, K>;
28
- }) => any) | undefined;
29
+ }): void;
30
+ externalForm(props: {
31
+ subscribedValues: K[] extends undefined[] ? Record<string, never> : Pick<OmegaFormState<To, From>, K>;
32
+ }): void;
29
33
  };
30
34
  emit: {};
31
35
  }>) => import("vue").VNode & {
@@ -6,48 +6,8 @@ export * from "./OmegaFormStuff";
6
6
  export { useOmegaForm } from "./useOmegaForm";
7
7
  export { default } from "./OmegaWrapper.vue";
8
8
  export { OmegaForm, OmegaInput, OmegaErrors };
9
- declare const OmegaFormCE: new <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, K extends keyof import("./OmegaFormStuff").OmegaFormState<To, From> = keyof import("./OmegaFormStuff").OmegaFormState<To, From>>(initialProps?: Record<string, any>) => import("vue").VueElement & ((({
10
- omegaConfig?: import("./useOmegaForm").OmegaConfig<From> | undefined;
11
- subscribe?: K[] | undefined;
12
- showErrorsOn?: import("./OmegaFormStuff").ShowErrorsOn | undefined;
13
- form: import("./useOmegaForm").OmegaFormReturn<To, From>;
14
- schema?: undefined | undefined;
15
- } | {
16
- omegaConfig?: import("./useOmegaForm").OmegaConfig<From> | undefined;
17
- subscribe?: K[] | undefined;
18
- showErrorsOn?: import("./OmegaFormStuff").ShowErrorsOn | undefined;
19
- defaultValues?: To | undefined;
20
- defaultState?: Partial<import("@tanstack/vue-form").FormState<To, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").StandardSchemaV1<To, From>, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined>> | undefined;
21
- asyncAlways?: boolean | undefined;
22
- asyncDebounceMs?: number | undefined;
23
- validators?: import("@tanstack/vue-form").FormValidators<To, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").StandardSchemaV1<To, From>, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined> | undefined;
24
- onSubmitMeta?: import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined;
25
- onSubmitInvalid?: ((props: {
26
- value: To;
27
- formApi: import("@tanstack/vue-form").FormApi<To, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").StandardSchemaV1<To, From>, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined, import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined>;
28
- }) => void) | undefined;
29
- transform?: import("@tanstack/vue-form").FormTransform<NoInfer<To>, NoInfer<import("@tanstack/vue-form").FormValidateOrFn<To> | undefined>, NoInfer<import("@tanstack/vue-form").FormValidateOrFn<To> | undefined>, NoInfer<import("@tanstack/vue-form").StandardSchemaV1<To, From>>, NoInfer<import("@tanstack/vue-form").FormValidateOrFn<To> | undefined>, NoInfer<import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined>, NoInfer<import("@tanstack/vue-form").FormValidateOrFn<To> | undefined>, NoInfer<import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined>, NoInfer<import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined>, NoInfer<import("@tanstack/vue-form").FormAsyncValidateOrFn<To> | undefined>> | undefined;
30
- onSubmit?: ((props: {
31
- formApi: import("./OmegaFormStuff").OmegaFormParams<To, From>;
32
- meta: any;
33
- value: From;
34
- }) => Promise<any> | any) | undefined;
35
- form?: undefined | undefined;
36
- schema: import("effect/Schema").Schema<From, To, never>;
37
- }) & import("vue").VNodeProps) & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps);
38
- declare const OmegaInputCE: new <From, To>(initialProps?: Record<string, any>) => import("vue").VueElement & {
39
- form: import("./OmegaFormStuff").FormType<From, To> & {
40
- meta: import("./OmegaFormStuff").MetaRecord<To>;
41
- };
42
- name: import("@tanstack/vue-form").DeepKeys<To>;
43
- validators?: import("./OmegaFormStuff").FieldValidators<From> | undefined;
44
- label: string;
45
- options?: {
46
- title: string;
47
- value: string;
48
- }[] | undefined;
49
- type?: import("./OmegaFormStuff").TypeOverride | undefined;
50
- } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps;
9
+ declare const OmegaFormCE: import("vue").VueElementConstructor<unknown>;
10
+ declare const OmegaInputCE: import("vue").VueElementConstructor<unknown>;
51
11
  declare const OmegaErrorsCE: import("vue").VueElementConstructor<unknown>;
52
12
  export { OmegaFormCE, OmegaInputCE, OmegaErrorsCE };
53
13
  export declare function registerOmegaForm(): void;
@@ -1,5 +1,6 @@
1
1
  import { type Record, S } from "effect-app";
2
- import { type NestedKeyOf, type FilterItems, type FormProps, type MetaRecord, type OmegaFormApi } from "./OmegaFormStuff";
2
+ import { type NestedKeyOf, type FilterItems, type FormProps, type MetaRecord, type OmegaFormApi, type OmegaInputProps } from "./OmegaFormStuff";
3
+ import { type DefineComponent } from "vue";
3
4
  type keysRule<T> = {
4
5
  keys?: NestedKeyOf<T>[];
5
6
  banKeys?: "You should only use one of banKeys or keys, not both, moron";
@@ -18,10 +19,13 @@ export type OmegaConfig<T> = {
18
19
  id?: string;
19
20
  } & keysRule<T>;
20
21
  };
21
- export interface OmegaFormReturn<To, From> extends OmegaFormApi<To, From> {
22
+ interface OF<To, From> extends OmegaFormApi<To, From> {
22
23
  meta: MetaRecord<To>;
23
24
  filterItems?: FilterItems;
24
25
  clear: () => void;
25
26
  }
27
+ export interface OmegaFormReturn<To, From> extends OF<To, From> {
28
+ Input: DefineComponent<Omit<OmegaInputProps<From, To>, "form">, {}, {}>;
29
+ }
26
30
  export declare const useOmegaForm: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>>(schema: S.Schema<From, To, never>, tanstackFormOptions?: NoInfer<FormProps<To, From>>, omegaConfig?: OmegaConfig<From>) => OmegaFormReturn<To, From>;
27
31
  export {};
@@ -1,9 +1,9 @@
1
- import { defineComponent as d, watch as b, createElementBlock as g, openBlock as S, withModifiers as v, unref as n, createElementVNode as h, renderSlot as O } from "vue";
2
- import { useStore as i } from "@tanstack/vue-form";
3
- import { getOmegaStore as M } from "./vue-components.es18.js";
4
- import { provideOmegaErrors as y } from "./vue-components.es4.js";
5
- import { useOmegaForm as E } from "./vue-components.es5.js";
6
- const w = ["disabled"], A = /* @__PURE__ */ d({
1
+ import { defineComponent as h, computed as m, watch as F, createElementBlock as c, openBlock as d, withModifiers as y, createElementVNode as O, unref as i, renderSlot as l, createCommentVNode as E, Fragment as M } from "vue";
2
+ import { useStore as p } from "@tanstack/vue-form";
3
+ import { getOmegaStore as V } from "./vue-components.es18.js";
4
+ import { provideOmegaErrors as w } from "./vue-components.es4.js";
5
+ import { useOmegaForm as I } from "./vue-components.es5.js";
6
+ const k = ["disabled"], j = /* @__PURE__ */ h({
7
7
  __name: "OmegaWrapper",
8
8
  props: {
9
9
  omegaConfig: {},
@@ -21,47 +21,57 @@ const w = ["disabled"], A = /* @__PURE__ */ d({
21
21
  transform: {},
22
22
  onSubmit: { type: Function }
23
23
  },
24
- setup(u, { expose: l }) {
25
- const r = u, t = r.form ?? E(r.schema, r, r.omegaConfig), f = i(t.store, (e) => e.isSubmitting);
26
- l(t);
27
- const c = M(
28
- t,
29
- r.subscribe
30
- ), p = i(
31
- t.store,
24
+ setup(b) {
25
+ const t = b, n = m(() => {
26
+ if (!(t.form || !t.schema))
27
+ return I(t.schema, t, t.omegaConfig);
28
+ }), r = m(() => t.form ?? n.value), v = p(
29
+ r.value.store,
30
+ (e) => e.isSubmitting
31
+ ), f = V(
32
+ r.value,
33
+ t.subscribe
34
+ ), g = p(
35
+ r.value.store,
32
36
  (e) => e.submissionAttempts
33
- ), s = t.useStore((e) => e.errors);
34
- return b(
35
- () => [t.filterItems, s.value],
37
+ ), u = m(() => r.value.useStore((e) => e.errors));
38
+ return F(
39
+ () => [r.value.filterItems, u.value.value],
36
40
  () => {
37
- const e = t.filterItems;
38
- return e ? s.value ? (Object.values(s.value).filter(
41
+ const e = r.value.filterItems, s = u.value.value;
42
+ return e ? s ? (Object.values(s).filter(
39
43
  (o) => !!o
40
44
  ).flatMap(
41
- (o) => Object.values(o).flat().map((m) => m.message)
45
+ (o) => Object.values(o).flat().map((a) => a.message)
42
46
  ).some((o) => o === e.message) && e.items.forEach((o) => {
43
- const m = t.getFieldMeta(o);
44
- t.setFieldMeta(o, {
45
- ...m,
47
+ const a = r.value.getFieldMeta(o);
48
+ a && r.value.setFieldMeta(o, {
49
+ ...a,
46
50
  errorMap: {
47
- onSubmit: [{ path: [o], message: e.message }]
51
+ onSubmit: [
52
+ { path: [o], message: e.message }
53
+ ]
48
54
  }
49
55
  });
50
56
  }), {}) : {} : {};
51
57
  }
52
- ), y(p, s, r.showErrorsOn), (e, a) => (S(), g("form", {
58
+ ), w(g, u.value, t.showErrorsOn), (e, s) => (d(), c("form", {
53
59
  novalidate: "",
54
- onSubmit: a[0] || (a[0] = v((o) => n(t).handleSubmit(), ["prevent", "stop"]))
60
+ onSubmit: s[0] || (s[0] = y((S) => r.value.handleSubmit(), ["prevent", "stop"]))
55
61
  }, [
56
- h("fieldset", { disabled: n(f) }, [
57
- O(e.$slots, "default", {
58
- form: n(t),
59
- subscribedValues: n(c)
60
- }, void 0, !0)
61
- ], 8, w)
62
+ O("fieldset", { disabled: i(v) }, [
63
+ t.form ? (d(), c(M, { key: 0 }, [
64
+ l(e.$slots, "externalForm", { subscribedValues: i(f) }, void 0, !0),
65
+ l(e.$slots, "default", {}, void 0, !0)
66
+ ], 64)) : n.value ? l(e.$slots, "internalForm", {
67
+ key: 1,
68
+ form: n.value,
69
+ subscribedValues: i(f)
70
+ }, void 0, !0) : E("", !0)
71
+ ], 8, k)
62
72
  ], 32));
63
73
  }
64
74
  });
65
75
  export {
66
- A as default
76
+ j as default
67
77
  };
@@ -1,125 +1,152 @@
1
- import { useForm as E } from "@tanstack/vue-form";
2
- import { S as I } from "effect-app";
1
+ import { useForm as P } from "@tanstack/vue-form";
2
+ import { S as A } from "effect-app";
3
3
  import { generateMetaFromSchema as N } from "./vue-components.es6.js";
4
- import { computed as a, onUnmounted as R, onMounted as A, onBeforeUnmount as D } from "vue";
5
- import { isObject as J } from "./vue-components.es15.js";
6
- const z = (h, u, i) => {
7
- if (!h) throw new Error("Schema is required");
8
- const b = I.standardSchemaV1(h), { filterItems: V, meta: t } = N(h), c = a(() => {
4
+ import { computed as b, onUnmounted as R, onMounted as p, onBeforeUnmount as q, defineComponent as D, h as J } from "vue";
5
+ import { isObject as K } from "./vue-components.es15.js";
6
+ import M from "./vue-components.es8.js";
7
+ const G = (w, s, i) => {
8
+ if (!w) throw new Error("Schema is required");
9
+ const V = A.standardSchemaV1(w), { filterItems: L, meta: t } = N(w), d = b(() => {
9
10
  var l;
10
11
  if ((l = i == null ? void 0 : i.persistency) != null && l.id)
11
12
  return i.persistency.id;
12
13
  const e = window.location.pathname, r = Object.keys(t);
13
14
  return `${e}-${r.join("-")}`;
14
- }), L = () => {
15
+ }), U = () => {
15
16
  const e = new URLSearchParams(window.location.search);
16
- e.delete(c.value);
17
+ e.delete(d.value);
17
18
  const r = new URL(window.location.href);
18
19
  r.search = e.toString(), window.history.replaceState({}, "", r.toString());
19
20
  };
20
- function f(e, r) {
21
+ function h(e, r) {
21
22
  for (const l in r)
22
- r[l] && J(r[l]) ? (e[l] || (e[l] = {}), f(e[l], r[l])) : e[l] = r[l];
23
+ r[l] && K(r[l]) ? (e[l] || (e[l] = {}), h(e[l], r[l])) : e[l] = r[l];
23
24
  return e;
24
25
  }
25
- const U = a(() => {
26
+ const j = b(() => {
26
27
  var l;
27
- if (u != null && u.defaultValues && !((l = i == null ? void 0 : i.persistency) != null && l.overrideDefaultValues))
28
- return u == null ? void 0 : u.defaultValues;
28
+ if (s != null && s.defaultValues && !((l = i == null ? void 0 : i.persistency) != null && l.overrideDefaultValues))
29
+ return s == null ? void 0 : s.defaultValues;
29
30
  let e;
30
31
  const r = i == null ? void 0 : i.persistency;
31
32
  if (!(r != null && r.policies) || r.policies.length === 0) return {};
32
33
  if (r.policies.includes("querystring"))
33
34
  try {
34
- const d = new URLSearchParams(window.location.search).get(c.value);
35
- L(), d && (e = JSON.parse(d));
36
- } catch (s) {
37
- console.error(s);
35
+ const n = new URLSearchParams(window.location.search).get(d.value);
36
+ U(), n && (e = JSON.parse(n));
37
+ } catch (u) {
38
+ console.error(u);
38
39
  }
39
40
  if (
40
41
  // query string has higher priority than local/session storage
41
42
  !e && (r.policies.includes("local") || r.policies.includes("session"))
42
43
  ) {
43
- const s = r.policies.includes("local") ? localStorage : sessionStorage;
44
- if (s)
44
+ const u = r.policies.includes("local") ? localStorage : sessionStorage;
45
+ if (u)
45
46
  try {
46
- const d = JSON.parse(
47
- s.getItem(c.value) || "{}"
47
+ const n = JSON.parse(
48
+ u.getItem(d.value) || "{}"
48
49
  );
49
- s.removeItem(c.value), e = d;
50
- } catch (d) {
51
- console.error(d);
50
+ u.removeItem(d.value), e = n;
51
+ } catch (n) {
52
+ console.error(n);
52
53
  }
53
54
  }
54
- if (e ?? (e = {}), (u == null ? void 0 : u.defaultValues) == null)
55
+ if (e ?? (e = {}), (s == null ? void 0 : s.defaultValues) == null)
55
56
  return e;
56
57
  {
57
- const s = u == null ? void 0 : u.defaultValues;
58
- return f(s, e);
58
+ const u = s == null ? void 0 : s.defaultValues;
59
+ return h(u, e);
59
60
  }
60
- }), n = E({
61
- ...u,
61
+ }), c = P({
62
+ ...s,
62
63
  validators: {
63
- onSubmit: b,
64
- ...(u == null ? void 0 : u.validators) || {}
64
+ onSubmit: V,
65
+ ...(s == null ? void 0 : s.validators) || {}
65
66
  },
66
- onSubmit: u != null && u.onSubmit ? ({ formApi: e, meta: r, value: l }) => {
67
- var s;
68
- return (s = u.onSubmit) == null ? void 0 : s.call(u, {
67
+ onSubmit: s != null && s.onSubmit ? ({ formApi: e, meta: r, value: l }) => {
68
+ var u;
69
+ return (u = s.onSubmit) == null ? void 0 : u.call(s, {
69
70
  formApi: e,
70
71
  meta: r,
71
72
  value: l
72
73
  });
73
74
  } : void 0,
74
- defaultValues: U.value
75
- }), j = () => {
75
+ defaultValues: j.value
76
+ }), E = () => {
76
77
  Object.keys(t).forEach((e) => {
77
- n.setFieldValue(e, void 0);
78
+ c.setFieldValue(e, void 0);
78
79
  });
79
- }, o = (e) => e.reduce(
80
+ }, a = (e) => e.reduce(
80
81
  (r, l) => {
81
- const s = l.split(".");
82
- return s.reduce((d, w, P) => (P === s.length - 1 ? d[w] = n.getFieldValue(l) : d[w] = d[w] ?? {}, d[w]), r), r;
82
+ const u = l.split(".");
83
+ return u.reduce((n, o, I) => (I === u.length - 1 ? n[o] = c.getFieldValue(l) : n[o] = n[o] ?? {}, n[o]), r), r;
83
84
  },
84
85
  {}
85
- ), v = (e) => {
86
+ ), S = (e) => {
86
87
  if (e) {
87
88
  if (Array.isArray(e.keys))
88
- return o(e.keys);
89
+ return a(e.keys);
89
90
  if (Array.isArray(e.banKeys)) {
90
91
  const r = Object.keys(t).filter(
91
92
  (l) => {
92
- var s;
93
- return (s = e.banKeys) == null ? void 0 : s.includes(l);
93
+ var u;
94
+ return (u = e.banKeys) == null ? void 0 : u.includes(l);
94
95
  }
95
96
  );
96
- return o(r);
97
+ return a(r);
97
98
  }
98
- return n.store.state.values;
99
+ return c.store.state.values;
99
100
  }
100
- }, S = () => {
101
+ }, f = () => {
101
102
  const e = i == null ? void 0 : i.persistency;
102
103
  if (!(!(e != null && e.policies) || e.policies.length === 0) && (e.policies.includes("local") || e.policies.includes("session"))) {
103
104
  const r = e.policies.includes("local") ? localStorage : sessionStorage;
104
105
  if (!r) return;
105
- const l = v(e);
106
- return r.setItem(c.value, JSON.stringify(l));
106
+ const l = S(e);
107
+ return r.setItem(d.value, JSON.stringify(l));
107
108
  }
108
- }, y = () => {
109
+ }, v = () => {
109
110
  const e = i == null ? void 0 : i.persistency;
110
111
  if (!(!(e != null && e.policies) || e.policies.length === 0) && e.policies.includes("querystring")) {
111
- const r = v(e), l = new URLSearchParams(window.location.search);
112
- l.set(c.value, JSON.stringify(r));
113
- const s = new URL(window.location.href);
114
- s.search = l.toString(), window.history.replaceState({}, "", s.toString());
112
+ const r = S(e), l = new URLSearchParams(window.location.search);
113
+ l.set(d.value, JSON.stringify(r));
114
+ const u = new URL(window.location.href);
115
+ u.search = l.toString(), window.history.replaceState({}, "", u.toString());
115
116
  }
116
117
  };
117
- return R(S), A(() => {
118
- window.addEventListener("beforeunload", S), window.addEventListener("blur", y);
119
- }), D(() => {
120
- window.removeEventListener("beforeunload", S), window.removeEventListener("blur", y);
121
- }), Object.assign(n, { meta: t, filterItems: V, clear: j });
118
+ R(f), p(() => {
119
+ window.addEventListener("beforeunload", f), window.addEventListener("blur", v);
120
+ }), q(() => {
121
+ window.removeEventListener("beforeunload", f), window.removeEventListener("blur", v);
122
+ });
123
+ const y = Object.assign(c, {
124
+ meta: t,
125
+ filterItems: L,
126
+ clear: E
127
+ });
128
+ return Object.assign(y, {
129
+ Input: D({
130
+ name: "FormInput",
131
+ inheritAttrs: !0,
132
+ setup(e, { attrs: r, slots: l }) {
133
+ const u = r.name, n = r.label;
134
+ if (!u || !n)
135
+ throw new Error("OmegaForm.Input requires name and label props");
136
+ return () => J(
137
+ M,
138
+ {
139
+ ...r,
140
+ name: u,
141
+ label: n,
142
+ form: y
143
+ },
144
+ l
145
+ );
146
+ }
147
+ })
148
+ });
122
149
  };
123
150
  export {
124
- z as useOmegaForm
151
+ G as useOmegaForm
125
152
  };
@@ -14,7 +14,7 @@ const y = i.NonEmptyArray(i.String), v = (e) => i.AST.isUnion(e) && e.types.find
14
14
  });
15
15
  if (a) {
16
16
  for (const s of a) {
17
- const u = t ? `${t}.${s.name.toString()}` : s.name.toString(), r = x(s.type), o = e.required ?? !r;
17
+ const u = t ? `${t}.${s.name.toString()}` : s.name.toString(), r = x(s.type), o = !r;
18
18
  let d = s.type;
19
19
  if (i.AST.isUnion(s.type) && (d = s.type.types.find(
20
20
  (g) => g._tag !== "UndefinedKeyword" && g !== i.Null.ast
@@ -1,7 +1,7 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var n=document.createElement("style");if(n.appendChild(document.createTextNode("fieldset[data-v-fd152523]{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-fd152523]{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-6833e150]{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-6833e150]{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.es11.js";
3
3
  import m from "./vue-components.es12.js";
4
- const a = /* @__PURE__ */ m(o, [["__scopeId", "data-v-fd152523"]]);
4
+ const a = /* @__PURE__ */ m(o, [["__scopeId", "data-v-6833e150"]]);
5
5
  export {
6
6
  a as default
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "0.3.2",
3
+ "version": "0.4.1",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "@tanstack/vue-form": "^1.2.4",
@@ -50,6 +50,8 @@
50
50
  "./dist/vue-components.css": "./dist/vue-components.css"
51
51
  },
52
52
  "dependencies": {
53
+ "highlight.js": "^11.11.1",
54
+ "vue3-highlightjs": "^1.0.5",
53
55
  "@effect-app/vue": "2.40.1",
54
56
  "effect-app": "2.39.1"
55
57
  },
@@ -18,6 +18,17 @@ import { useIntl } from "../../utils"
18
18
 
19
19
  export type ShowErrorsOn = "onChange" | "onBlur" | "onSubmit"
20
20
 
21
+ export type OmegaInputProps<From, To> = {
22
+ form: FormType<From, To> & {
23
+ meta: MetaRecord<To>
24
+ }
25
+ name: NestedKeyOf<To>
26
+ validators?: FieldValidators<From>
27
+ label: string
28
+ options?: { title: string; value: string }[]
29
+ type?: TypeOverride
30
+ }
31
+
21
32
  export type TypeOverride =
22
33
  | "string"
23
34
  | "text"
@@ -241,7 +252,7 @@ const createMeta = <T = any>(
241
252
  for (const p of propertySignatures) {
242
253
  const key = parent ? `${parent}.${p.name.toString()}` : p.name.toString()
243
254
  const nullableOrUndefined = isNullableOrUndefined(p.type)
244
- const isRequired = meta["required"] ?? !nullableOrUndefined
255
+ const isRequired = !nullableOrUndefined
245
256
 
246
257
  let typeToProcess = p.type
247
258
  if (S.AST.isUnion(p.type)) {
@@ -28,25 +28,12 @@
28
28
  import { computed } from "vue"
29
29
  import {
30
30
  generateInputStandardSchemaFromFieldMeta,
31
- type FieldValidators,
32
- type FormType,
33
- type MetaRecord,
34
- type NestedKeyOf,
35
- type TypeOverride,
31
+ type OmegaInputProps,
36
32
  } from "./OmegaFormStuff"
37
33
  import OmegaInternalInput from "./OmegaInternalInput.vue"
38
34
  import type { OmegaFieldInternalApi } from "./InputProps"
39
35
 
40
- const props = defineProps<{
41
- form: FormType<From, To> & {
42
- meta: MetaRecord<To>
43
- }
44
- name: NestedKeyOf<To>
45
- validators?: FieldValidators<From>
46
- label: string
47
- options?: { title: string; value: string }[]
48
- type?: TypeOverride
49
- }>()
36
+ const props = defineProps<OmegaInputProps<From, To>>()
50
37
 
51
38
  defineOptions({
52
39
  inheritAttrs: false,