Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/shy-carpets-stick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-app/vue-components": patch
---

fixes leaves recursion
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ if (!form) {
}

defineProps<
BaseProps<From, Name> & DefaultTypeProps
BaseProps<From> & DefaultTypeProps
>()

defineSlots<{
Expand Down
16 changes: 6 additions & 10 deletions packages/vue-components/src/components/OmegaForm/OmegaFormStuff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ import { getTransformationFrom, useIntl } from "../../utils"
import { type OmegaFieldInternalApi } from "./InputProps"
import { type OF, type OmegaFormReturn } from "./useOmegaForm"

export type Leaves<T, Path extends string = ""> = T extends ReadonlyArray<infer U> ? Leaves<U, `${Path}[number]`> & {}
export type Leaves<T, Path extends string = ""> = T extends ReadonlyArray<infer U>
? Leaves<U, `${Path}[${number}]`> & {}
: {
[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}`> & {}
}[keyof T]

// Helper type to make array indices flexible - accepts both [number] and numeric literals [0], [1], etc.
// Simplified: if there's a [] in the path, just use TName to avoid excessive type complexity
export type FlexibleArrayPath<T extends string> = T extends `${string}[${string}]${string}` ? T
: never

export type BaseProps<From, TName extends DeepKeys<From> = DeepKeys<From>> = {
export type BaseProps<From> = {
/**
* Will fallback to i18n when not specified.
* Can also be provided via #label slot for custom HTML labels.
Expand All @@ -28,7 +24,7 @@ export type BaseProps<From, TName extends DeepKeys<From> = DeepKeys<From>> = {
label?: string
validators?: FieldValidators<From>
// Use FlexibleArrayPath: if name contains [], just use TName; otherwise intersect with Leaves<From>
name: FlexibleArrayPath<TName> extends never ? Leaves<From> : TName
name: Leaves<From>
/**
* Optional class to apply to the input element.
* - If a string is provided, it will be used instead of the general class
Expand Down Expand Up @@ -60,7 +56,7 @@ export type OmegaInputPropsBase<
meta: MetaRecord<From>
i18nNamespace?: string
}
} & BaseProps<From, NestedKeyOf<From>>
} & BaseProps<From>

export type OmegaInputProps<
From extends Record<PropertyKey, any>,
Expand All @@ -71,7 +67,7 @@ export type OmegaInputProps<
meta: MetaRecord<From>
i18nNamespace?: string
}
} & BaseProps<From, NestedKeyOf<From>>
} & BaseProps<From>

export type OmegaArrayProps<
From extends Record<PropertyKey, any>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export interface OmegaFormReturn<
>,
never
>
& BaseProps<From, Name>
& BaseProps<From>
& TypeProps
& Partial<{}>
>
Expand Down