Skip to content
Open
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
17 changes: 12 additions & 5 deletions libs/components/src/render/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
type JSXOutput,
type QwikIntrinsicElements,
type Signal,
Slot
Slot,
} from "@qwik.dev/core";

// keyof slows the type server a bunch, instead we use the most common fallbacks
Expand All @@ -19,7 +19,8 @@ export type AllowedFallbacks =
| "ul"
| "li";

type RenderInternalProps<T extends AllowedFallbacks> = {
type RenderInternalProps<T extends AllowedFallbacks> =
{
/** The default element and types if a render prop is not provided */
fallback: T;
/**
Expand All @@ -29,8 +30,12 @@ type RenderInternalProps<T extends AllowedFallbacks> = {

jsxType?: unknown;
movedProps?: Record<string, unknown>;
} & QwikIntrinsicElements[T] &
Record<`${string}$`, unknown>;
} & QwikIntrinsicElements[T];

type RenderProps<
P extends object = object,
T extends AllowedFallbacks = AllowedFallbacks,
> = RenderInternalProps<T> & P;

/**
* Creates an object that overrides bind:* props with undefined to prevent them from rendering in the DOM.
Expand Down Expand Up @@ -60,7 +65,9 @@ function getBindOverrides(props: Record<string, unknown>): Record<string, undefi
* Qwik's reactivity tracking while preventing these attributes from appearing in the DOM.
*/
export const Render = component$(
<T extends AllowedFallbacks>(props: RenderInternalProps<T>): JSXOutput => {
<P extends object = object, T extends AllowedFallbacks = AllowedFallbacks>(
props: RenderProps<P | object, T>,
): JSXOutput => {
const {
fallback: _fallback,
jsxType: _jsxType,
Expand Down
Loading