@@ -15,7 +15,11 @@ import type { Templates } from "./templates/index.js";
1515import type { Icons } from "./icons.js" ;
1616import type { InputsValidationMode } from "./validation.js" ;
1717import type { Errors } from "./errors.js" ;
18- import { setFromContext , type FormContext } from "./context/index.js" ;
18+ import {
19+ setFromContext ,
20+ type FormContext ,
21+ type IconOrTranslationData ,
22+ } from "./context/index.js" ;
1923import { DefaultFormMerger , type FormMerger } from "./merger.js" ;
2024import { fields as defaultFields } from "./fields/index.js" ;
2125import { templates as defaultTemplates } from "./templates/index.js" ;
@@ -227,22 +231,26 @@ export function createForm<T, E>(
227231 get schedulerYield ( ) {
228232 return schedulerYield ;
229233 } ,
230- iconOrTranslation : ( < L extends Label > (
234+ IconOrTranslation,
235+ iconOrTranslation : ( (
231236 internals : ComponentInternals ,
232- data : ( ) => [ L , ... Labels [ L ] ]
237+ data : IconOrTranslationData | ( ( ) => IconOrTranslationData )
233238 ) => {
234- IconOrTranslation ( internals , {
235- get data ( ) {
236- return data ( ) ;
237- } ,
238- } ) ;
239- } ) as unknown as Snippet <
240- [
241- {
242- [ L in Label ] : [ L , ...Labels [ L ] ] ;
243- } [ Label ] ,
244- ]
245- > ,
239+ IconOrTranslation (
240+ internals ,
241+ // Looks like during SSR the `data` is not a getter function
242+ // TODO: Clarify how to detect SSR in Svelte (not SvelteKit)
243+ typeof data === "function"
244+ ? {
245+ get data ( ) {
246+ return data ( ) ;
247+ } ,
248+ }
249+ : {
250+ data,
251+ }
252+ ) ;
253+ } ) as unknown as Snippet < [ IconOrTranslationData ] > ,
246254 } ,
247255 {
248256 get value ( ) {
0 commit comments