Open History to see the last commit
1import { withComponentProps } from '../utils.lib.js'
2import { useFieldContext } from './contexts.lib'
3import type { Component } from 'svelte'
4β
5type AnyFieldComponent = Component<any>
6β
7export function wrapField(
8 Component: AnyFieldComponent,
9 fieldPropKey: string,
10): AnyFieldComponent {
11 return ((internals: any, props: any) =>
12 Component(
13 internals,
14 withComponentProps(props, {
15 [fieldPropKey]: useFieldContext(),
16 }),
17 )) as AnyFieldComponent
18}
19β
20export function brandComponentFactory(): (
21 component: AnyFieldComponent,
22) => AnyFieldComponent {
23 return (component) => component
24}