@effect-app/vue-components 2.3.1 → 2.4.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.
@@ -3,10 +3,10 @@ import { type DeepKeys, type DeepValue, type FieldAsyncValidateOrFn, type FieldV
3
3
  import { type RuntimeFiber } from "effect/Fiber";
4
4
  import { type OmegaFieldInternalApi } from "./InputProps";
5
5
  import { type OF, type OmegaFormReturn } from "./useOmegaForm";
6
- export type Leaves<T, Path extends string = ""> = T extends ReadonlyArray<infer U> ? Leaves<U, `${Path}[${number}]`> & {} : {
7
- [K in keyof T]: T[K] extends string | boolean | number | null | undefined | symbol | bigint ? `${Path extends "" ? "" : `${Path}.`}${K & string}` : Leaves<T[K], `${Path extends "" ? "" : `${Path}.`}${K & string}`> & {};
6
+ export type FieldPath<T, Path extends string = ""> = unknown extends T ? string : T extends string | boolean | number | null | undefined | symbol | bigint ? `${Path extends "" ? "" : `${Path}`}` : T extends ReadonlyArray<infer U> ? (FieldPath<U, `${Path}[${number}]`> & {}) | Path : {
7
+ [K in keyof T]: T[K] extends string | boolean | number | null | undefined | symbol | bigint ? `${Path extends "" ? "" : `${Path}.`}${K & string}` : FieldPath<T[K], `${Path extends "" ? "" : `${Path}.`}${K & string}`> & {};
8
8
  }[keyof T];
9
- export type BaseProps<From, TName extends NestedKeyOf<From> = NestedKeyOf<From>> = {
9
+ export type BaseProps<From, TName extends FieldPath<From> = FieldPath<From>> = {
10
10
  /**
11
11
  * Will fallback to i18n when not specified.
12
12
  * Can also be provided via #label slot for custom HTML labels.
@@ -14,7 +14,7 @@ export type BaseProps<From, TName extends NestedKeyOf<From> = NestedKeyOf<From>>
14
14
  */
15
15
  label?: string;
16
16
  validators?: FieldValidators<From>;
17
- name: TName & Leaves<From>;
17
+ name: TName;
18
18
  /**
19
19
  * Optional class to apply to the input element.
20
20
  * - If a string is provided, it will be used instead of the general class
@@ -2,7 +2,7 @@ import { type DeepKeys, DeepValue, StandardSchemaV1Issue, ValidationError, Valid
2
2
  import { Effect, Order, S } from "effect-app";
3
3
  import { ComputedRef, type InjectionKey } from "vue";
4
4
  import { MergedInputProps } from "./InputProps";
5
- import { BaseProps, DefaultTypeProps, type FormProps, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff";
5
+ import { BaseProps, DefaultTypeProps, FieldPath, type FormProps, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } 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";
@@ -77,8 +77,8 @@ type __VLS_PrettifyLocal<T> = {
77
77
  [K in keyof T]: T[K];
78
78
  } & {};
79
79
  export interface OmegaFormReturn<From extends Record<PropertyKey, any>, To extends Record<PropertyKey, any>, TypeProps = DefaultTypeProps> extends OF<From, To> {
80
- 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<{
81
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, never> & BaseProps<From> & TypeProps & Partial<{}>> & import("vue").PublicProps;
80
+ Input: <Name extends FieldPath<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<{
81
+ 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;
82
82
  expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
83
83
  attrs: any;
84
84
  slots: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect-app/vue-components",
3
- "version": "2.3.1",
3
+ "version": "2.4.0",
4
4
  "peerDependencies": {
5
5
  "@mdi/js": "^7.4.47",
6
6
  "effect": "^3.18.0",
@@ -53,8 +53,8 @@
53
53
  "highlight.js": "^11.11.1",
54
54
  "mitt": "^3.0.1",
55
55
  "vue3-highlightjs": "^1.0.5",
56
- "effect-app": "3.12.0",
57
- "@effect-app/vue": "2.92.1"
56
+ "@effect-app/vue": "2.92.1",
57
+ "effect-app": "3.12.0"
58
58
  },
59
59
  "scripts": {
60
60
  "build": "pnpm build:run",
@@ -7,15 +7,16 @@ import { getTransformationFrom, useIntl } from "../../utils"
7
7
  import { type OmegaFieldInternalApi } from "./InputProps"
8
8
  import { type OF, type OmegaFormReturn } from "./useOmegaForm"
9
9
 
10
- export type Leaves<T, Path extends string = ""> = T extends ReadonlyArray<infer U>
11
- ? Leaves<U, `${Path}[${number}]`> & {}
10
+ export type FieldPath<T, Path extends string = ""> = unknown extends T ? string
11
+ : T extends string | boolean | number | null | undefined | symbol | bigint ? `${Path extends "" ? "" : `${Path}`}`
12
+ : T extends ReadonlyArray<infer U> ? (FieldPath<U, `${Path}[${number}]`> & {}) | Path
12
13
  : {
13
14
  [K in keyof T]: T[K] extends string | boolean | number | null | undefined | symbol | bigint
14
15
  ? `${Path extends "" ? "" : `${Path}.`}${K & string}`
15
- : Leaves<T[K], `${Path extends "" ? "" : `${Path}.`}${K & string}`> & {}
16
+ : FieldPath<T[K], `${Path extends "" ? "" : `${Path}.`}${K & string}`> & {}
16
17
  }[keyof T]
17
18
 
18
- export type BaseProps<From, TName extends NestedKeyOf<From> = NestedKeyOf<From>> = {
19
+ export type BaseProps<From, TName extends FieldPath<From> = FieldPath<From>> = {
19
20
  /**
20
21
  * Will fallback to i18n when not specified.
21
22
  * Can also be provided via #label slot for custom HTML labels.
@@ -24,7 +25,7 @@ export type BaseProps<From, TName extends NestedKeyOf<From> = NestedKeyOf<From>>
24
25
  label?: string
25
26
  validators?: FieldValidators<From>
26
27
  // Use FlexibleArrayPath: if name contains [], just use TName; otherwise intersect with Leaves<From>
27
- name: TName & Leaves<From>
28
+ name: TName
28
29
  /**
29
30
  * Optional class to apply to the input element.
30
31
  * - If a string is provided, it will be used instead of the general class
@@ -10,7 +10,7 @@
10
10
  import { type DeepKeys, type DeepValue } from "@tanstack/vue-form"
11
11
  import { onMounted } from "vue"
12
12
  import { type TaggedUnionOption, type TaggedUnionOptionsArray } from "./InputProps"
13
- import { type Leaves } from "./OmegaFormStuff"
13
+ import { type FieldPath } from "./OmegaFormStuff"
14
14
  import OmegaTaggedUnionInternal from "./OmegaTaggedUnionInternal.vue"
15
15
  import { type useOmegaForm } from "./useOmegaForm"
16
16
 
@@ -46,7 +46,7 @@ onMounted(() => {
46
46
 
47
47
  <template>
48
48
  <form.Input
49
- :name="`${name}._tag` as Leaves<From, ''>"
49
+ :name="`${name}._tag` as FieldPath<From, ''>"
50
50
  :label="label"
51
51
  :type="type ?? 'select'"
52
52
  :options="options as unknown as TaggedUnionOption<From, Name>[]"
@@ -11,7 +11,7 @@ import { MergedInputProps } from "./InputProps"
11
11
  import OmegaArray from "./OmegaArray.vue"
12
12
  import OmegaAutoGen from "./OmegaAutoGen.vue"
13
13
  import OmegaErrorsInternal from "./OmegaErrorsInternal.vue"
14
- import { BaseProps, DefaultTypeProps, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff"
14
+ import { BaseProps, DefaultTypeProps, FieldPath, type FormProps, generateMetaFromSchema, type MetaRecord, type NestedKeyOf, OmegaArrayProps, OmegaAutoGenMeta, OmegaError, type OmegaFormApi, OmegaFormState } from "./OmegaFormStuff"
15
15
  import OmegaInput from "./OmegaInput.vue"
16
16
  import OmegaTaggedUnion from "./OmegaTaggedUnion.vue"
17
17
  import OmegaForm from "./OmegaWrapper.vue"
@@ -213,7 +213,7 @@ export interface OmegaFormReturn<
213
213
  TypeProps = DefaultTypeProps
214
214
  > extends OF<From, To> {
215
215
  // 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..
216
- Input: <Name extends DeepKeys<From>>(
216
+ Input: <Name extends FieldPath<From>>(
217
217
  __VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"],
218
218
  __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>,
219
219
  __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"],
@@ -228,7 +228,7 @@ export interface OmegaFormReturn<
228
228
  >,
229
229
  never
230
230
  >
231
- & BaseProps<From>
231
+ & BaseProps<From, Name>
232
232
  & TypeProps
233
233
  & Partial<{}>
234
234
  >