@effect-app/vue-components 1.6.7 → 1.7.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.
@@ -11,13 +11,19 @@ export type InputProps<From extends Record<PropertyKey, any>, TName extends Deep
11
11
  errorMessages: string[];
12
12
  error: boolean;
13
13
  setRealDirty: () => void;
14
- type: string;
15
14
  label: string;
15
+ type: string;
16
+ };
17
+ field: OmegaFieldInternalApi<From, TName>;
18
+ };
19
+ export type MergedInputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = InputProps<From, TName>["inputProps"] & Pick<InputProps<From, TName>, "field">;
20
+ export type VuetifyInputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = {
21
+ inputProps: InputProps<From, TName>["inputProps"] & {
22
+ type: string;
16
23
  options?: {
17
24
  title: string;
18
25
  value: string;
19
26
  }[];
20
27
  };
21
- field: OmegaFieldInternalApi<From, TName>;
28
+ field: InputProps<From, TName>["field"];
22
29
  };
23
- export type MergedInputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = InputProps<From, TName>["inputProps"] & Pick<InputProps<From, TName>, "field">;
@@ -1,10 +1,8 @@
1
1
  import { type DeepKeys } from "@tanstack/vue-form";
2
2
  import type { MergedInputProps } from "./InputProps";
3
- import type { DefaultInputProps } from "./OmegaFormStuff";
3
+ import type { BaseProps, DefaultTypeProps } from "./OmegaFormStuff";
4
4
  declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Name extends DeepKeys<From>>(__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<{
5
- props: __VLS_PrettifyLocal<{
6
- name: Name;
7
- } & DefaultInputProps<From>> & import("vue").PublicProps;
5
+ props: __VLS_PrettifyLocal<BaseProps<From, Name> & DefaultTypeProps> & import("vue").PublicProps;
8
6
  expose: (exposed: {}) => void;
9
7
  attrs: any;
10
8
  slots: {
@@ -4,29 +4,35 @@ import { type RuntimeFiber } from "effect/Fiber";
4
4
  import { type OmegaFieldInternalApi } from "./InputProps";
5
5
  import { type OF, type OmegaFormReturn } from "./useOmegaForm";
6
6
  export type ShowErrorsOn = "onChange" | "onBlur" | "onSubmit";
7
- export type DefaultInputProps<From> = {
7
+ export type BaseProps<From, TName extends DeepKeys<From>> = {
8
+ /** Will fallback to i18n when not specified */
8
9
  label?: string;
9
10
  validators?: FieldValidators<From>;
11
+ name: TName;
12
+ };
13
+ export type TypesWithOptions = "radio" | "select" | "multiple" | "autocomplete" | "autocompletemultiple";
14
+ export type DefaultTypeProps = {
15
+ type?: TypeOverride;
16
+ options?: undefined;
17
+ } | {
18
+ type?: TypesWithOptions;
10
19
  options?: {
11
20
  title: string;
12
21
  value: string;
13
22
  }[];
14
- type?: TypeOverride;
15
23
  };
16
24
  export type OmegaInputPropsBase<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>> = {
17
25
  form: OF<From, To> & {
18
26
  meta: MetaRecord<From>;
19
27
  i18nNamespace?: string;
20
28
  };
21
- name: NestedKeyOf<From>;
22
- } & DefaultInputProps<From>;
23
- export type OmegaInputProps<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, InputProps = DefaultInputProps<From>> = {
24
- form: OmegaFormReturn<From, To, InputProps> & {
29
+ } & BaseProps<From, NestedKeyOf<From>>;
30
+ export type OmegaInputProps<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, TypeProps = DefaultTypeProps> = {
31
+ form: OmegaFormReturn<From, To, TypeProps> & {
25
32
  meta: MetaRecord<From>;
26
33
  i18nNamespace?: string;
27
34
  };
28
- name: NestedKeyOf<From>;
29
- } & DefaultInputProps<From>;
35
+ } & BaseProps<From, NestedKeyOf<From>>;
30
36
  export type TypeOverride = "string" | "text" | "number" | "select" | "multiple" | "boolean" | "radio" | "autocomplete" | "autocompletemultiple" | "switch" | "range" | "password" | "email";
31
37
  export interface OmegaError {
32
38
  label: string;
@@ -15,12 +15,8 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends R
15
15
  errorMessages: string[];
16
16
  error: boolean;
17
17
  setRealDirty: () => void;
18
- type: string;
19
18
  label: string;
20
- options?: {
21
- title: string;
22
- value: string;
23
- }[];
19
+ type: string;
24
20
  }) => any;
25
21
  };
26
22
  emit: {};
@@ -1,7 +1,7 @@
1
1
  import { type DeepKeys } from "@tanstack/vue-form";
2
- import type { InputProps } from "./InputProps";
2
+ import type { VuetifyInputProps } from "./InputProps";
3
3
  declare const __VLS_export: <From extends Record<PropertyKey, any>, Name extends DeepKeys<From>>(__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<InputProps<From, Name> & {
4
+ props: __VLS_PrettifyLocal<VuetifyInputProps<From, Name> & {
5
5
  onBlur?: ((event: Event) => any) | undefined;
6
6
  onFocus?: ((event: Event) => any) | undefined;
7
7
  }> & import("vue").PublicProps;
@@ -6,10 +6,6 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, Name extends
6
6
  field: OmegaFieldInternalApi<From, Name>;
7
7
  meta: MetaRecord<From>[NestedKeyOf<From>];
8
8
  label: string;
9
- options?: {
10
- title: string;
11
- value: string;
12
- }[];
13
9
  type?: TypeOverride;
14
10
  validators?: FieldValidators<From>;
15
11
  }> & import("vue").PublicProps;
@@ -27,12 +23,8 @@ declare const __VLS_export: <From extends Record<PropertyKey, any>, Name extends
27
23
  errorMessages: string[];
28
24
  error: boolean;
29
25
  setRealDirty: () => void;
30
- type: string;
31
26
  label: string;
32
- options?: {
33
- title: string;
34
- value: string;
35
- }[];
27
+ type: string;
36
28
  }) => any;
37
29
  };
38
30
  emit: {};
@@ -1,6 +1,6 @@
1
- import { type DefaultInputProps, type OmegaFormState } from "./OmegaFormStuff";
1
+ import { type DefaultTypeProps, type OmegaFormState } from "./OmegaFormStuff";
2
2
  import { type OmegaFormReturn } from "./useOmegaForm";
3
- declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, K extends keyof OmegaFormState<From, To> = keyof OmegaFormState<From, To>, Props = DefaultInputProps<From>>(__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
+ declare const __VLS_export: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, K extends keyof OmegaFormState<From, To> = keyof OmegaFormState<From, To>, Props = DefaultTypeProps>(__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<{
5
5
  form: OmegaFormReturn<From, To, Props>;
6
6
  disabled?: boolean;
@@ -1,4 +1,4 @@
1
1
  import { type Component } from "vue";
2
- import { type DefaultInputProps } from "./OmegaFormStuff";
2
+ import { type DefaultTypeProps } from "./OmegaFormStuff";
3
3
  import { useOmegaForm } from "./useOmegaForm";
4
- export declare const createUseFormWithCustomInput: (CustomInputComponent: Component) => <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Props = DefaultInputProps<From>>(...args: Parameters<typeof useOmegaForm<From, To>>) => import("./useOmegaForm").OmegaFormReturn<From, To, Props>;
4
+ export declare const createUseFormWithCustomInput: <TypeProps = DefaultTypeProps>(CustomInputComponent: Component) => <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>>(...args: Parameters<typeof useOmegaForm<From, To>>) => import("./useOmegaForm").OmegaFormReturn<From, To, TypeProps>;
@@ -2,7 +2,7 @@ import { type DeepKeys, DeepValue, StandardSchemaV1Issue, ValidationError, Valid
2
2
  import { Effect, Order, S } from "effect-app";
3
3
  import { type InjectionKey } from "vue";
4
4
  import { MergedInputProps } from "./InputProps";
5
- import { DefaultInputProps, type FilterItems, type FormProps, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff";
5
+ import { BaseProps, DefaultTypeProps, type FilterItems, type FormProps, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff";
6
6
  type keysRule<T> = {
7
7
  keys?: NestedKeyOf<T>[];
8
8
  banKeys?: "You should only use one of banKeys or keys, not both, moron";
@@ -63,11 +63,9 @@ export declare const OmegaFormKey: InjectionKey<OF<any, any>>;
63
63
  type __VLS_PrettifyLocal<T> = {
64
64
  [K in keyof T]: T[K];
65
65
  } & {};
66
- export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Props = DefaultInputProps<From>> extends OF<From, To> {
66
+ export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, TypeProps = DefaultTypeProps> extends OF<From, To> {
67
67
  Input: <Name extends DeepKeys<From>>(__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<{
68
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & {
69
- name: Name;
70
- } & Props & Partial<{}>> & import("vue").PublicProps;
68
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & BaseProps<From, Name> & TypeProps & Partial<{}>> & import("vue").PublicProps;
71
69
  expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
72
70
  attrs: any;
73
71
  slots: {
@@ -161,5 +159,5 @@ export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To exten
161
159
  __ctx?: Awaited<typeof __VLS_setup>;
162
160
  };
163
161
  }
164
- export declare const useOmegaForm: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, Props = DefaultInputProps<From>>(schema: S.Schema<To, From, never>, tanstackFormOptions?: NoInfer<FormProps<From, To>>, omegaConfig?: OmegaConfig<To>) => OmegaFormReturn<From, To, Props>;
162
+ export declare const useOmegaForm: <From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, TypeProps = DefaultTypeProps>(schema: S.Schema<To, From, never>, tanstackFormOptions?: NoInfer<FormProps<From, To>>, omegaConfig?: OmegaConfig<To>) => OmegaFormReturn<From, To, TypeProps>;
165
163
  export {};
@@ -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-440e1a59]{display:contents}fieldset[disabled][data-v-440e1a59]>*{pointer-events:none}")),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-440e1a59]{display:contents}fieldset[disabled][data-v-440e1a59]>*{pointer-events:none}")),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-8fe92df3]{display:contents}fieldset[disabled][data-v-8fe92df3]>*{pointer-events:none}")),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-8fe92df3]{display:contents}fieldset[disabled][data-v-8fe92df3]>*{pointer-events:none}")),this.shadowRoot.appendChild(o)}},e.call(window.customElements,i,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
2
  import o from "./vue-components.es31.js";
3
3
 
4
4
  import m from "./vue-components.es30.js";
5
- const e = /* @__PURE__ */ m(o, [["__scopeId", "data-v-440e1a59"]]);
5
+ const a = /* @__PURE__ */ m(o, [["__scopeId", "data-v-8fe92df3"]]);
6
6
  export {
7
- e as default
7
+ a as default
8
8
  };
@@ -1,48 +1,44 @@
1
- import { defineComponent as y, inject as h, computed as s, createBlock as i, openBlock as u, resolveDynamicComponent as M, withCtx as c, createCommentVNode as $, mergeProps as b, renderSlot as C, normalizeProps as k, guardReactiveProps as F } from "vue";
1
+ import { defineComponent as h, inject as $, computed as s, createBlock as i, openBlock as u, resolveDynamicComponent as M, withCtx as f, createCommentVNode as b, mergeProps as C, renderSlot as k, normalizeProps as y, guardReactiveProps as F } from "vue";
2
2
  import { useIntl as A } from "./vue-components.es3.js";
3
3
  import { generateInputStandardSchemaFromFieldMeta as w } from "./vue-components.es9.js";
4
4
  import I from "./vue-components.es5.js";
5
- const z = /* @__PURE__ */ y({
5
+ const z = /* @__PURE__ */ h({
6
6
  inheritAttrs: !1,
7
7
  __name: "OmegaInput",
8
8
  props: {
9
9
  form: {},
10
- name: {},
11
10
  label: {},
12
11
  validators: {},
13
- options: {},
14
- type: {}
12
+ name: {}
15
13
  },
16
14
  setup(a) {
17
- const e = a, r = h(
15
+ const e = a, n = $(
18
16
  "getMetaFromArray",
19
17
  null
20
- ), t = s(() => r?.value && r.value(e.name) ? r.value(e.name) : e.form.meta[e.name]), f = s(() => {
21
- if (!t.value)
18
+ ), r = s(() => n?.value && n.value(e.name) ? n.value(e.name) : e.form.meta[e.name]), c = s(() => {
19
+ if (!r.value)
22
20
  throw console.log(e.name, Object.keys(e.form.meta), e.form.meta), new Error("Meta is undefined");
23
- return w(t.value);
24
- }), { formatMessage: o } = A(), d = (n) => n.replace(/([A-Z])/g, " $1").replace(/^./, (l) => l.toUpperCase()).trim(), m = () => o({ id: `general.fields.${e.name}`, defaultMessage: d(e.name) }), p = () => e.form.i18nNamespace ? o({ id: `${e.form.i18nNamespace}.fields.${e.name}`, defaultMessage: m() }) : m();
25
- return (n, l) => (u(), i(M(a.form.Field), {
21
+ return w(r.value);
22
+ }), { formatMessage: o } = A(), d = (t) => t.replace(/([A-Z])/g, " $1").replace(/^./, (l) => l.toUpperCase()).trim(), m = () => o({ id: `general.fields.${e.name}`, defaultMessage: d(e.name) }), p = () => e.form.i18nNamespace ? o({ id: `${e.form.i18nNamespace}.fields.${e.name}`, defaultMessage: m() }) : m();
23
+ return (t, l) => (u(), i(M(a.form.Field), {
26
24
  name: a.name,
27
25
  validators: {
28
- onChange: f.value,
26
+ onChange: c.value,
29
27
  ...a.validators
30
28
  }
31
29
  }, {
32
- default: c(({ field: v }) => [
33
- t.value ? (u(), i(I, b({
30
+ default: f(({ field: v }) => [
31
+ r.value ? (u(), i(I, C({
34
32
  key: 0,
35
33
  field: v,
36
34
  label: a.label ?? p(),
37
- options: a.options,
38
- meta: t.value,
39
- type: a.type
40
- }, n.$attrs), {
41
- default: c((g) => [
42
- C(n.$slots, "default", k(F(g)))
35
+ meta: r.value
36
+ }, { ...t.$attrs, ...t.$props }), {
37
+ default: f((g) => [
38
+ k(t.$slots, "default", y(F(g)))
43
39
  ]),
44
40
  _: 3
45
- }, 16, ["field", "label", "options", "meta", "type"])) : $("", !0)
41
+ }, 16, ["field", "label", "meta"])) : b("", !0)
46
42
  ]),
47
43
  _: 3
48
44
  }, 8, ["name", "validators"]));
@@ -1,24 +1,23 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var i=document.createElement("style");if(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;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),document.head.appendChild(i),window.customElements){const e=window.customElements.define;window.customElements.define=function(s,t){const n=t.prototype.connectedCallback;return t.prototype.connectedCallback=function(){if(n&&n.call(this),this.shadowRoot){const a=document.createElement("style");a.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;appearance:none;box-shadow:none;display:block;min-width:auto;height:auto;padding:.5em .5em .5em 1em}")),this.shadowRoot.appendChild(a)}},e.call(window.customElements,s,t)}}}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
- import { defineComponent as $, getCurrentInstance as B, useId as I, computed as n, onMounted as g, ref as V, watchEffect as k, watch as q, onUnmounted as D, renderSlot as F, normalizeProps as h, guardReactiveProps as L, createElementVNode as O, normalizeClass as M, createBlock as R, createCommentVNode as S, unref as U, openBlock as z, mergeProps as A } from "vue";
3
- import { useStore as T } from "@tanstack/vue-form";
4
- import Z from "./vue-components.es23.js";
2
+ import { defineComponent as I, getCurrentInstance as V, useId as $, computed as n, onMounted as g, ref as k, watchEffect as q, watch as D, onUnmounted as F, useAttrs as L, renderSlot as O, normalizeProps as h, guardReactiveProps as A, createElementVNode as M, normalizeClass as R, createBlock as S, createCommentVNode as U, unref as z, openBlock as T, mergeProps as Z } from "vue";
3
+ import { useStore as j } from "@tanstack/vue-form";
4
+ import G from "./vue-components.es23.js";
5
5
 
6
- const Y = /* @__PURE__ */ $({
6
+ const te = /* @__PURE__ */ I({
7
7
  inheritAttrs: !1,
8
8
  __name: "OmegaInternalInput",
9
9
  props: {
10
10
  field: {},
11
11
  meta: {},
12
12
  label: {},
13
- options: {},
14
13
  type: {},
15
14
  validators: {}
16
15
  },
17
16
  setup(v) {
18
- const e = v, y = B()?.appContext.components.VTextField, a = I(), l = e.field, o = T(l.store, (t) => t), m = n(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), p = n(() => o.value.value), d = n(() => o.value.meta.errors ?? []), b = n(
17
+ const e = v, y = V()?.appContext.components.VTextField, a = $(), l = e.field, o = j(l.store, (t) => t), m = n(() => e.type ? e.type : e.meta?.type === "string" ? e.meta.format === "email" ? "email" : "string" : e.meta?.type || "unknown"), d = n(() => o.value.value), f = n(() => o.value.meta.errors ?? []), b = n(
19
18
  () => (
20
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
21
- d.value.map((t) => t?.message).filter(Boolean)
20
+ f.value.map((t) => t?.message).filter(Boolean)
22
21
  )
23
22
  ), C = (t) => t == null || t === !1 || t === "" || Number.isNaN(t), x = (t) => {
24
23
  C(t) && e.meta?.type !== "boolean" ? e.field.handleChange(
@@ -26,68 +25,68 @@ const Y = /* @__PURE__ */ $({
26
25
  ) : e.field.handleChange(t);
27
26
  };
28
27
  g(() => {
29
- if (!p.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null") {
28
+ if (!d.value && !e.meta?.required && e.meta?.nullableOrUndefined === "null") {
30
29
  const t = o.value.meta.isDirty;
31
30
  l.setValue(null), l.setMeta((r) => ({ ...r, isDirty: t }));
32
31
  }
33
32
  });
34
- const { mapError: w, removeError: f, showErrors: _, showErrorsOn: E } = e.field.form.errorContext, s = V(!1);
35
- k(() => {
36
- (_.value || E === "onChange") && (s.value = !0);
33
+ const { mapError: _, removeError: c, showErrors: w, showErrorsOn: E } = e.field.form.errorContext, s = k(!1);
34
+ q(() => {
35
+ (w.value || E === "onChange") && (s.value = !0);
37
36
  });
38
37
  const i = () => {
39
38
  s.value = !0;
40
39
  };
41
40
  g(() => {
42
- p.value && i();
41
+ d.value && i();
43
42
  });
44
- const c = n(() => !s.value && m.value !== "select" ? [] : b.value);
45
- q(
46
- d,
43
+ const p = n(() => !s.value && m.value !== "select" ? [] : b.value);
44
+ D(
45
+ f,
47
46
  (t) => {
48
- t.length ? w({
47
+ t.length ? _({
49
48
  inputId: a,
50
49
  errors: o.value.meta.errors.map((r) => r.message).filter(Boolean),
51
50
  label: e.label
52
- }) : f(a);
51
+ }) : c(a);
53
52
  }
54
- ), D(() => {
55
- f(a);
53
+ ), F(() => {
54
+ c(a);
56
55
  });
57
56
  const P = (t) => {
58
57
  const r = {
59
- get(H, N, J) {
60
- return N === "handleChange" ? x : Reflect.get(...arguments);
58
+ get(K, B, Q) {
59
+ return B === "handleChange" ? x : Reflect.get(...arguments);
61
60
  }
62
61
  };
63
62
  return new Proxy(t, r);
64
- }, u = n(() => ({
63
+ }, N = L(), u = n(() => ({
65
64
  inputProps: {
65
+ ...N,
66
66
  id: a,
67
67
  required: e.meta?.required,
68
68
  minLength: e.meta?.type === "string" && e.meta?.minLength,
69
69
  maxLength: e.meta?.type === "string" && e.meta?.maxLength,
70
70
  max: e.meta?.type === "number" && e.meta?.maximum,
71
71
  min: e.meta?.type === "number" && e.meta?.minimum,
72
- errorMessages: c.value,
73
- error: !!c.value.length,
72
+ errorMessages: p.value,
73
+ error: !!p.value.length,
74
74
  setRealDirty: i,
75
75
  type: m.value,
76
- label: `${e.label}${e.meta?.required ? " *" : ""}`,
77
- options: e.options
76
+ label: `${e.label}${e.meta?.required ? " *" : ""}`
78
77
  },
79
78
  field: P(e.field)
80
79
  }));
81
- return (t, r) => F(t.$slots, "default", h(L({ ...u.value.inputProps, field: u.value.field })), () => [
82
- O("div", {
83
- class: M(t.$attrs.class),
80
+ return (t, r) => O(t.$slots, "default", h(A({ ...u.value.inputProps, field: u.value.field })), () => [
81
+ M("div", {
82
+ class: R(t.$attrs.class),
84
83
  onFocusout: i
85
84
  }, [
86
- U(y) ? (z(), R(Z, h(A({ key: 0 }, { ...u.value, ...t.$attrs })), null, 16)) : S("", !0)
85
+ z(y) ? (T(), S(G, h(Z({ key: 0 }, u.value)), null, 16)) : U("", !0)
87
86
  ], 34)
88
87
  ]);
89
88
  }
90
89
  });
91
90
  export {
92
- Y as default
91
+ te as default
93
92
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "1.6.7",
3
+ "version": "1.7.1",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.18.0",
@@ -51,8 +51,8 @@
51
51
  "highlight.js": "^11.11.1",
52
52
  "mitt": "^3.0.1",
53
53
  "vue3-highlightjs": "^1.0.5",
54
- "@effect-app/vue": "2.84.2",
55
- "effect-app": "3.10.1"
54
+ "effect-app": "3.10.1",
55
+ "@effect-app/vue": "2.84.2"
56
56
  },
57
57
  "scripts": {
58
58
  "build": "pnpm build:run",
@@ -38,9 +38,8 @@ export type InputProps<From extends Record<PropertyKey, any>, TName extends Deep
38
38
  errorMessages: string[]
39
39
  error: boolean
40
40
  setRealDirty: () => void
41
- type: string
42
41
  label: string
43
- options?: { title: string; value: string }[]
42
+ type: string
44
43
  }
45
44
  field: OmegaFieldInternalApi<From, TName>
46
45
  }
@@ -48,3 +47,11 @@ export type InputProps<From extends Record<PropertyKey, any>, TName extends Deep
48
47
  export type MergedInputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> =
49
48
  & InputProps<From, TName>["inputProps"]
50
49
  & Pick<InputProps<From, TName>, "field">
50
+
51
+ export type VuetifyInputProps<From extends Record<PropertyKey, any>, TName extends DeepKeys<From>> = {
52
+ inputProps: InputProps<From, TName>["inputProps"] & {
53
+ type: string
54
+ options?: { title: string; value: string }[]
55
+ }
56
+ field: InputProps<From, TName>["field"]
57
+ }
@@ -2,11 +2,6 @@
2
2
  <OmegaInput
3
3
  v-bind="$props"
4
4
  :form="form"
5
- :name="name"
6
- :label="label"
7
- :validators="validators"
8
- :options="options"
9
- :type="type"
10
5
  >
11
6
  <template #default="slotProps">
12
7
  <slot v-bind="slotProps" />
@@ -26,7 +21,7 @@
26
21
  import { type DeepKeys } from "@tanstack/vue-form"
27
22
  import { inject } from "vue"
28
23
  import type { MergedInputProps } from "./InputProps"
29
- import type { DefaultInputProps, OmegaInputProps } from "./OmegaFormStuff"
24
+ import type { BaseProps, DefaultTypeProps, OmegaInputProps } from "./OmegaFormStuff"
30
25
  import OmegaInput from "./OmegaInput.vue"
31
26
  import { OmegaFormKey } from "./useOmegaForm"
32
27
 
@@ -40,9 +35,7 @@ if (!form) {
40
35
  }
41
36
 
42
37
  defineProps<
43
- {
44
- name: Name
45
- } & DefaultInputProps<From>
38
+ BaseProps<From, Name> & DefaultTypeProps
46
39
  >()
47
40
 
48
41
  defineSlots<{
@@ -9,14 +9,25 @@ import { type OF, type OmegaFormReturn } from "./useOmegaForm"
9
9
 
10
10
  export type ShowErrorsOn = "onChange" | "onBlur" | "onSubmit"
11
11
 
12
- export type DefaultInputProps<From> = {
12
+ export type BaseProps<From, TName extends DeepKeys<From>> = {
13
+ /** Will fallback to i18n when not specified */
13
14
  label?: string
14
15
  validators?: FieldValidators<From>
16
+ name: TName
17
+ }
18
+
19
+ export type TypesWithOptions = "radio" | "select" | "multiple" | "autocomplete" | "autocompletemultiple"
20
+ export type DefaultTypeProps = {
21
+ type?: TypeOverride
22
+ options?: undefined
23
+ } | {
24
+ type?: TypesWithOptions
25
+ // TODO: options should depend on `type`, but since there is auto-type, we can't currently enforce it.
26
+ // hence we allow it also for type? (undefined) atm
15
27
  options?: {
16
28
  title: string
17
29
  value: string
18
30
  }[]
19
- type?: TypeOverride
20
31
  }
21
32
 
22
33
  export type OmegaInputPropsBase<
@@ -27,20 +38,18 @@ export type OmegaInputPropsBase<
27
38
  meta: MetaRecord<From>
28
39
  i18nNamespace?: string
29
40
  }
30
- name: NestedKeyOf<From>
31
- } & DefaultInputProps<From>
41
+ } & BaseProps<From, NestedKeyOf<From>>
32
42
 
33
43
  export type OmegaInputProps<
34
44
  From extends Record<PropertyKey, any>,
35
45
  To extends Record<PropertyKey, any>,
36
- InputProps = DefaultInputProps<From>
46
+ TypeProps = DefaultTypeProps
37
47
  > = {
38
- form: OmegaFormReturn<From, To, InputProps> & {
48
+ form: OmegaFormReturn<From, To, TypeProps> & {
39
49
  meta: MetaRecord<From>
40
50
  i18nNamespace?: string
41
51
  }
42
- name: NestedKeyOf<From>
43
- } & DefaultInputProps<From> // InputProps // TODO
52
+ } & BaseProps<From, NestedKeyOf<From>>
44
53
 
45
54
  export type TypeOverride =
46
55
  | "string"
@@ -12,10 +12,8 @@
12
12
  v-if="meta"
13
13
  :field="field"
14
14
  :label="label ?? i18n()"
15
- :options="options"
16
15
  :meta="meta"
17
- :type="type"
18
- v-bind="$attrs"
16
+ v-bind="{ ...$attrs, ...$props }"
19
17
  >
20
18
  <template #default="inputProps">
21
19
  <slot v-bind="inputProps" />
@@ -133,9 +133,9 @@
133
133
  >
134
134
  import { type DeepKeys } from "@tanstack/vue-form"
135
135
  import { getInputType } from "../OmegaForm/OmegaFormStuff"
136
- import type { InputProps } from "./InputProps"
136
+ import type { VuetifyInputProps } from "./InputProps"
137
137
 
138
- defineProps<InputProps<From, Name>>()
138
+ defineProps<VuetifyInputProps<From, Name>>()
139
139
 
140
140
  defineEmits<{
141
141
  (e: "focus", event: Event): void
@@ -6,7 +6,7 @@
6
6
  >
7
7
  <OmegaInputVuetify
8
8
  v-if="vuetified"
9
- v-bind="{ ...inputProps, ...$attrs }"
9
+ v-bind="inputProps"
10
10
  />
11
11
  </div>
12
12
  </slot>
@@ -18,7 +18,7 @@
18
18
  generic="From extends Record<PropertyKey, any>, Name extends DeepKeys<From>"
19
19
  >
20
20
  import { type DeepKeys, useStore } from "@tanstack/vue-form"
21
- import { computed, type ComputedRef, getCurrentInstance, onMounted, onUnmounted, ref, useId, watch, watchEffect } from "vue"
21
+ import { computed, type ComputedRef, getCurrentInstance, onMounted, onUnmounted, ref, useAttrs, useId, watch, watchEffect } from "vue"
22
22
  import type { InputProps, OmegaFieldInternalApi } from "./InputProps"
23
23
  import type { FieldValidators, MetaRecord, NestedKeyOf, TypeOverride } from "./OmegaFormStuff"
24
24
  import OmegaInputVuetify from "./OmegaInputVuetify.vue"
@@ -31,7 +31,6 @@ const props = defineProps<{
31
31
  field: OmegaFieldInternalApi<From, Name>
32
32
  meta: MetaRecord<From>[NestedKeyOf<From>]
33
33
  label: string
34
- options?: { title: string; value: string }[]
35
34
  type?: TypeOverride
36
35
  validators?: FieldValidators<From>
37
36
  }>()
@@ -160,8 +159,11 @@ const wrapField = (field: OmegaFieldInternalApi<From, Name>) => {
160
159
  return proxy3 as typeof field
161
160
  }
162
161
 
162
+ const attrs = useAttrs()
163
+
163
164
  const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
164
165
  inputProps: {
166
+ ...attrs,
165
167
  id,
166
168
  required: props.meta?.required,
167
169
  minLength: props.meta?.type === "string" && props.meta?.minLength,
@@ -172,8 +174,7 @@ const inputProps: ComputedRef<InputProps<From, Name>> = computed(() => ({
172
174
  error: !!showedErrors.value.length,
173
175
  setRealDirty,
174
176
  type: fieldType.value,
175
- label: `${props.label}${props.meta?.required ? " *" : ""}`,
176
- options: props.options
177
+ label: `${props.label}${props.meta?.required ? " *" : ""}`
177
178
  },
178
179
 
179
180
  field: wrapField(props.field)
@@ -16,7 +16,7 @@
16
16
  From extends Record<PropertyKey, any>,
17
17
  To extends Record<PropertyKey, any>,
18
18
  K extends keyof OmegaFormState<From, To> = keyof OmegaFormState<From, To>,
19
- Props = DefaultInputProps<From>
19
+ Props = DefaultTypeProps
20
20
  "
21
21
  >
22
22
  /**
@@ -31,7 +31,7 @@
31
31
  /* eslint-disable @typescript-eslint/no-explicit-any */
32
32
  import { useStore } from "@tanstack/vue-form"
33
33
  import { getOmegaStore } from "./getOmegaStore"
34
- import { type DefaultInputProps, type OmegaFormApi, type OmegaFormState } from "./OmegaFormStuff"
34
+ import { type DefaultTypeProps, type OmegaFormApi, type OmegaFormState } from "./OmegaFormStuff"
35
35
  import { type OmegaFormReturn } from "./useOmegaForm"
36
36
 
37
37
  type OmegaWrapperProps = {
@@ -1,15 +1,16 @@
1
1
  import type { DeepKeys } from "@tanstack/vue-form"
2
2
  import { type Component, h } from "vue"
3
3
  import type { MergedInputProps } from "./InputProps"
4
- import { type DefaultInputProps } from "./OmegaFormStuff"
4
+ import { type DefaultTypeProps } from "./OmegaFormStuff"
5
5
  import OmegaInput from "./OmegaInput.vue"
6
6
  import { useOmegaForm } from "./useOmegaForm"
7
7
 
8
- export const createUseFormWithCustomInput = (CustomInputComponent: Component) => {
8
+ export const createUseFormWithCustomInput = <
9
+ TypeProps = DefaultTypeProps
10
+ >(CustomInputComponent: Component) => {
9
11
  return <
10
12
  From extends Record<PropertyKey, any>,
11
- To extends Record<PropertyKey, any>,
12
- Props = DefaultInputProps<From>
13
+ To extends Record<PropertyKey, any>
13
14
  >(
14
15
  ...args: Parameters<typeof useOmegaForm<From, To>>
15
16
  ) => {
@@ -33,7 +34,7 @@ export const createUseFormWithCustomInput = (CustomInputComponent: Component) =>
33
34
  }
34
35
  }
35
36
 
36
- const form = useOmegaForm<From, To, Props>(
37
+ const form = useOmegaForm<From, To, TypeProps>(
37
38
  schema,
38
39
  tanstackFormOptions,
39
40
  {
@@ -13,7 +13,7 @@ import OmegaArray from "./OmegaArray.vue"
13
13
  import OmegaAutoGen from "./OmegaAutoGen.vue"
14
14
  import { buildOmegaErrors } from "./OmegaErrorsContext"
15
15
  import OmegaErrorsInternal from "./OmegaErrorsInternal.vue"
16
- import { DefaultInputProps, type FilterItems, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff"
16
+ import { BaseProps, DefaultTypeProps, type FilterItems, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState, OmegaInputProps, ShowErrorsOn } from "./OmegaFormStuff"
17
17
  import OmegaInput from "./OmegaInput.vue"
18
18
  import OmegaForm from "./OmegaWrapper.vue"
19
19
 
@@ -133,7 +133,7 @@ type __VLS_PrettifyLocal<T> =
133
133
  export interface OmegaFormReturn<
134
134
  From extends Record<PropertyKey, any>,
135
135
  To extends Record<PropertyKey, any>,
136
- Props = DefaultInputProps<From>
136
+ TypeProps = DefaultTypeProps
137
137
  > extends OF<From, To> {
138
138
  // this crazy thing here is copied from the OmegaFormInput.vue.d.ts, with `From` removed as Generic, instead closed over from the From generic above..
139
139
  Input: <Name extends DeepKeys<From>>(
@@ -151,10 +151,8 @@ export interface OmegaFormReturn<
151
151
  >,
152
152
  never
153
153
  >
154
- & {
155
- name: Name
156
- }
157
- & Props
154
+ & BaseProps<From, Name>
155
+ & TypeProps
158
156
  & Partial<{}>
159
157
  >
160
158
  & import("vue").PublicProps
@@ -589,12 +587,12 @@ export const useOmegaForm = <
589
587
  From extends Record<PropertyKey, any>,
590
588
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
591
589
  To extends Record<PropertyKey, any>,
592
- Props = DefaultInputProps<From>
590
+ TypeProps = DefaultTypeProps
593
591
  >(
594
592
  schema: S.Schema<To, From, never>,
595
593
  tanstackFormOptions?: NoInfer<FormProps<From, To>>,
596
594
  omegaConfig?: OmegaConfig<To>
597
- ): OmegaFormReturn<From, To, Props> => {
595
+ ): OmegaFormReturn<From, To, TypeProps> => {
598
596
  if (!schema) throw new Error("Schema is required")
599
597
  const standardSchema = S.standardSchemaV1(schema)
600
598
  const decode = S.decode(schema)