(props: FormKitProviderProps)
| 104 | * The FormKitProvider component provides FormKit config to descendants. |
| 105 | */ |
| 106 | export function FormKitProvider(props: FormKitProviderProps) { |
| 107 | const { config, children, ...attrs } = props |
| 108 | const providedConfig = useConfig(config) |
| 109 | const renderedChildren = passThroughChildren(children, attrs) |
| 110 | |
| 111 | useEffect(() => { |
| 112 | if (!providedConfig) return |
| 113 | if (typeof window !== 'undefined') { |
| 114 | globalThis.__FORMKIT_CONFIGS__ = ( |
| 115 | globalThis.__FORMKIT_CONFIGS__ || [] |
| 116 | ).concat([providedConfig.rootConfig]) |
| 117 | return () => removeConfig(providedConfig.rootConfig) |
| 118 | } |
| 119 | return |
| 120 | }, [providedConfig]) |
| 121 | |
| 122 | if (!providedConfig) { |
| 123 | return createElement(Fragment, null, renderedChildren) |
| 124 | } |
| 125 | |
| 126 | return createElement( |
| 127 | optionsSymbol.Provider, |
| 128 | { value: providedConfig.options }, |
| 129 | createElement(configSymbol.Provider, { value: providedConfig.rootConfig }, renderedChildren) |
| 130 | ) |
| 131 | } |
| 132 | |
| 133 | function FormKitConfigLoader(props: ConfigLoaderProps) { |
| 134 | const { |
nothing calls this directly
no test coverage detected