File size: 723 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use client"

import { createContext } from "../create-context"
import type { RecipeProps } from "./generated/recipes.gen"
import type { RecipeKey } from "./use-recipe"
import type { SlotRecipeKey } from "./use-slot-recipe"

const [RecipePropsContextProvider, useParentRecipeProps] = createContext<
  RecipeProps<string>
>({
  name: "RecipePropsContext",
  strict: false,
})

interface Props<T> {
  children: React.ReactNode
  value: RecipeProps<T>
}

function RecipePropsProvider<T extends RecipeKey | SlotRecipeKey>(
  props: Props<T>,
) {
  return (
    <RecipePropsContextProvider value={props.value}>
      {props.children}
    </RecipePropsContextProvider>
  )
}

export { RecipePropsProvider, useParentRecipeProps }