( options?: FormKitOptions )
| 3418 | * @public |
| 3419 | */ |
| 3420 | export function createNode<V = unknown>( |
| 3421 | options?: FormKitOptions |
| 3422 | ): FormKitNode<V> { |
| 3423 | const ops = options || {} |
| 3424 | const context = createContext(ops) as FormKitContext |
| 3425 | // Note: The typing for the proxy object cannot be fully modeled, thus we are |
| 3426 | // force-typing to a FormKitNode. See: |
| 3427 | // https://github.com/microsoft/TypeScript/issues/28067 |
| 3428 | const node = new Proxy(context, { |
| 3429 | get(...args) { |
| 3430 | const [, property] = args |
| 3431 | if (property === '__FKNode__') return true |
| 3432 | const trap = context.traps.get(property) |
| 3433 | if (trap && trap.get) return trap.get(node, context) |
| 3434 | return Reflect.get(...args) |
| 3435 | }, |
| 3436 | set(...args) { |
| 3437 | const [, property, value] = args |
| 3438 | const trap = context.traps.get(property) |
| 3439 | if (trap && trap.set) return trap.set(node, context, property, value) |
| 3440 | return Reflect.set(...args) |
| 3441 | }, |
| 3442 | }) as unknown as FormKitNode |
| 3443 | |
| 3444 | return nodeInit(node, ops) |
| 3445 | } |
no test coverage detected