import { SchemaContextModel } from '@vev/utils';
import React, { ReactNode } from 'react';

type SilkeSchemaScopeProps<T extends Record<string, any>> = {
  context: SchemaContextModel<T>;
  children?: ReactNode;
};

const SchemaContext = React.createContext<SchemaContextModel>({});

export function useSchemaContext() {
  return React.useContext(SchemaContext);
}

export function SilkeSchemaContext<T extends Record<string, any>>({
  context,
  children,
}: SilkeSchemaScopeProps<T>) {
  return <SchemaContext.Provider value={context}>{children}</SchemaContext.Provider>;
}
