@@ -54,8 +54,6 @@ type SingleCollectionProps<T> = {
5454 collection : Collection < T > ;
5555} ;
5656
57- type AccessorMap < T > = { [ K in keyof T ] : Accessor < T [ K ] > } ;
58-
5957type DeferredChildren < T extends QueryMapping > = {
6058 alwaysShowContent ?: false ;
6159 children : ( data : Accessor < { [ K in keyof T ] : T [ K ] } > ) => JSXElement ;
@@ -69,37 +67,23 @@ type EagerChildren<T extends QueryMapping> = {
6967 ) => JSXElement ;
7068} ;
7169
72- type MultiDeferredChildren < T extends QueryMapping > = {
73- alwaysShowContent ?: false ;
74- children : ( data : AccessorMap < { [ K in keyof T ] : T [ K ] } > ) => JSXElement ;
75- } ;
76-
77- type MultiEagerChildren < T extends QueryMapping > = {
78- alwaysShowContent : true ;
79- showLoader ?: true ;
80- children : (
81- data : AccessorMap < { [ K in keyof T ] : T [ K ] | undefined } > ,
82- ) => JSXElement ;
83- } ;
84-
8570type SingleSource < T > = SingleQueryProps < T > | SingleCollectionProps < T > ;
8671type MultiSource < T extends QueryMapping > = QueryProps < T > | CollectionProps < T > ;
87- type SingleChildren < T > = DeferredChildren < T > | EagerChildren < T > ;
88- type MultiChildren < T extends QueryMapping > =
89- | MultiDeferredChildren < T >
90- | MultiEagerChildren < T > ;
72+ type ChildrenProps < T extends QueryMapping > =
73+ | DeferredChildren < T >
74+ | EagerChildren < T > ;
9175
9276export type Props < T extends QueryMapping > = BaseProps &
9377 ( SingleSource < T > | MultiSource < T > ) &
94- ( SingleChildren < T > | MultiChildren < T > ) ;
78+ ChildrenProps < T > ;
9579
9680// Single query/collection overloads
9781function AsyncContent < T > (
98- props : BaseProps & SingleSource < T > & SingleChildren < T > ,
82+ props : BaseProps & SingleSource < T > & ChildrenProps < T > ,
9983) : JSXElement ;
10084// Multi query/collection overloads
10185function AsyncContent < T extends Record < string , unknown > > (
102- props : BaseProps & MultiSource < T > & MultiChildren < T > ,
86+ props : BaseProps & MultiSource < T > & ChildrenProps < T > ,
10387) : JSXElement ;
10488function AsyncContent < T extends QueryMapping > ( props : Props < T > ) : JSXElement {
10589 //@ts -expect-error this is fine
@@ -173,27 +157,6 @@ function AsyncContent<T extends QueryMapping>(props: Props<T>): JSXElement {
173157 false ,
174158 ) ;
175159
176- // Keys are stable for the component lifetime; per-key closures track
177- // reactivity internally via value()/lastResolvedValue().
178- // oxlint-disable solid/reactivity
179- const multi = ! ( "defaultQuery" in source ( ) ) ;
180-
181- const eagerAccessorMap = multi
182- ? ( Object . fromEntries (
183- typedKeys ( source ( ) ) . map ( ( key ) => [ key , ( ) => value ( ) ?. [ key ] ] ) ,
184- ) as AccessorMap < { [ K in keyof T ] : T [ K ] | undefined } > )
185- : undefined ;
186-
187- const deferredAccessorMap = multi
188- ? ( Object . fromEntries (
189- typedKeys ( source ( ) ) . map ( ( key ) => [
190- key ,
191- ( ) => lastResolvedValue ( ) ?. [ key ] ,
192- ] ) ,
193- ) as AccessorMap < { [ K in keyof T ] : T [ K ] } > )
194- : undefined ;
195- // oxlint-enable solid/reactivity
196-
197160 const loader = ( ) : JSXElement =>
198161 props . loader ?? < LoadingCircle class = "p-4 text-center text-2xl" /> ;
199162
@@ -221,16 +184,14 @@ function AsyncContent<T extends QueryMapping>(props: Props<T>): JSXElement {
221184 { ( _ ) =>
222185 // oxlint-disable-next-line typescript/no-explicit-any
223186 ( props . children as ( data : any ) => JSXElement ) (
224- multi ? deferredAccessorMap : lastResolvedValue ,
187+ lastResolvedValue ,
225188 )
226189 }
227190 </ Show >
228191 }
229192 >
230193 { /* oxlint-disable-next-line typescript/no-explicit-any */ }
231- { ( props . children as ( data : any ) => JSXElement ) (
232- multi ? eagerAccessorMap : value ,
233- ) }
194+ { ( props . children as ( data : any ) => JSXElement ) ( value ) }
234195 </ Show >
235196 </ >
236197 }
0 commit comments