@recipe-book/react 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/dist/chunk-2S2Z4HLL.mjs +46 -0
  2. package/dist/chunk-2VMRVR3X.mjs +1 -0
  3. package/dist/chunk-36H6LM2B.mjs +14 -0
  4. package/dist/{chunk-JTZVD7JV.mjs → chunk-4IWVZEXX.mjs} +4 -4
  5. package/dist/chunk-4XBZKTOL.mjs +1 -0
  6. package/dist/chunk-6AGILC25.mjs +20 -0
  7. package/dist/chunk-6AXGEB5P.mjs +14 -0
  8. package/dist/chunk-6JEDN4VR.mjs +20 -0
  9. package/dist/chunk-6KLLMLNF.mjs +33 -0
  10. package/dist/chunk-6LTLY5K7.mjs +20 -0
  11. package/dist/chunk-6RA4EVIO.mjs +46 -0
  12. package/dist/chunk-75DF3E6L.mjs +50 -0
  13. package/dist/chunk-7BWMULSB.mjs +55 -0
  14. package/dist/chunk-7PPB3PM6.mjs +40 -0
  15. package/dist/chunk-7SBP7DC5.mjs +42 -0
  16. package/dist/chunk-7XJBP24U.mjs +20 -0
  17. package/dist/chunk-A5JAKCMG.mjs +44 -0
  18. package/dist/chunk-ATOAYKI3.mjs +26 -0
  19. package/dist/chunk-B5IXKKFC.mjs +38 -0
  20. package/dist/chunk-BEMMFA52.mjs +49 -0
  21. package/dist/chunk-BOG5DA6M.mjs +38 -0
  22. package/dist/chunk-BW4DYFBO.mjs +36 -0
  23. package/dist/chunk-CDQFOSWR.mjs +34 -0
  24. package/dist/chunk-CRQVP6PW.mjs +20 -0
  25. package/dist/chunk-CY27OHOG.mjs +1 -0
  26. package/dist/chunk-DACFJWGN.mjs +14 -0
  27. package/dist/chunk-DE5GUZKO.mjs +46 -0
  28. package/dist/chunk-DNZAFS5G.mjs +48 -0
  29. package/dist/chunk-DS3O5PAR.mjs +20 -0
  30. package/dist/chunk-ENGJXHYU.mjs +42 -0
  31. package/dist/chunk-FIFGRJKD.mjs +26 -0
  32. package/dist/chunk-FWOMIZEF.mjs +46 -0
  33. package/dist/{chunk-T6BBQT4K.mjs → chunk-G7XD4VBW.mjs} +5 -5
  34. package/dist/chunk-GBU6MVZL.mjs +14 -0
  35. package/dist/chunk-GM5F7IUT.mjs +2 -0
  36. package/dist/chunk-GSGRXRJP.mjs +38 -0
  37. package/dist/chunk-GZRNU24M.mjs +46 -0
  38. package/dist/{chunk-J5PZAYLW.mjs → chunk-HNDXCSZY.mjs} +5 -6
  39. package/dist/chunk-HXTUDCO2.mjs +49 -0
  40. package/dist/chunk-I5TR6PEA.mjs +0 -0
  41. package/dist/chunk-IXRYSEMS.mjs +30 -0
  42. package/dist/chunk-J5Q2Z2JG.mjs +38 -0
  43. package/dist/chunk-JBAAWEV6.mjs +1 -0
  44. package/dist/chunk-JCPPNN26.mjs +44 -0
  45. package/dist/chunk-JR3OTSZB.mjs +32 -0
  46. package/dist/chunk-JWS5RTU3.mjs +46 -0
  47. package/dist/chunk-K6EZ773Q.mjs +26 -0
  48. package/dist/chunk-KNXMYQVO.mjs +36 -0
  49. package/dist/chunk-KRUZ7OA7.mjs +44 -0
  50. package/dist/chunk-KXCIJBR6.mjs +14 -0
  51. package/dist/chunk-MASAOP7L.mjs +55 -0
  52. package/dist/chunk-MGBEDCLT.mjs +34 -0
  53. package/dist/chunk-MKBCBPVR.mjs +53 -0
  54. package/dist/chunk-N53TONLF.mjs +39 -0
  55. package/dist/chunk-NYDGFRPM.mjs +46 -0
  56. package/dist/chunk-OPOABKD6.mjs +23 -0
  57. package/dist/chunk-OX6ITS5C.mjs +20 -0
  58. package/dist/chunk-PAAVW47I.mjs +50 -0
  59. package/dist/chunk-PAF5HSSV.mjs +53 -0
  60. package/dist/chunk-PBENQR7Y.mjs +1 -0
  61. package/dist/chunk-PH3LQIHZ.mjs +26 -0
  62. package/dist/{chunk-FPLGEKN7.mjs → chunk-PIB3RAOO.mjs} +4 -4
  63. package/dist/chunk-PIXLJD7Y.mjs +37 -0
  64. package/dist/chunk-PTS3BZHK.mjs +1 -0
  65. package/dist/chunk-Q6I5J3IJ.mjs +1 -0
  66. package/dist/chunk-QOZCSS3B.mjs +44 -0
  67. package/dist/chunk-QSFPUODQ.mjs +34 -0
  68. package/dist/chunk-RY7QUBJI.mjs +34 -0
  69. package/dist/chunk-RZJRUG2I.mjs +55 -0
  70. package/dist/chunk-S3GGSQB5.mjs +1 -0
  71. package/dist/chunk-S3HRT5Z5.mjs +14 -0
  72. package/dist/chunk-SB7HBCCZ.mjs +49 -0
  73. package/dist/chunk-SEXTT3NJ.mjs +25 -0
  74. package/dist/chunk-SKEQCOPX.mjs +43 -0
  75. package/dist/chunk-TLBRVWD2.mjs +1 -0
  76. package/dist/chunk-TOOCHDUY.mjs +36 -0
  77. package/dist/chunk-TSKANLT4.mjs +37 -0
  78. package/dist/chunk-UAMZEZUI.mjs +36 -0
  79. package/dist/chunk-UQJ4XNWN.mjs +26 -0
  80. package/dist/chunk-VDSUUXCH.mjs +34 -0
  81. package/dist/chunk-VO7RY2ZK.mjs +44 -0
  82. package/dist/chunk-WJKDFBJ2.mjs +34 -0
  83. package/dist/chunk-WTC7PY7U.mjs +54 -0
  84. package/dist/chunk-WXDV7CMB.mjs +14 -0
  85. package/dist/chunk-X5FG3X6T.mjs +1 -0
  86. package/dist/chunk-X66DY4AZ.mjs +1 -0
  87. package/dist/chunk-XXSJXKWQ.mjs +44 -0
  88. package/dist/chunk-YZMVAQQG.mjs +1 -0
  89. package/dist/chunk-ZCXPZU7W.mjs +20 -0
  90. package/dist/chunk-ZJ4PNVYO.mjs +52 -0
  91. package/dist/chunk-ZU4QJLEY.mjs +53 -0
  92. package/dist/components/ingredients/ingredients-list.d.mts +4 -1
  93. package/dist/components/ingredients/ingredients-list.d.ts +4 -1
  94. package/dist/components/ingredients/ingredients-list.js +2 -1
  95. package/dist/components/ingredients/ingredients-list.mjs +1 -1
  96. package/dist/components/instructions/instruction-list.d.mts +4 -1
  97. package/dist/components/instructions/instruction-list.d.ts +4 -1
  98. package/dist/components/instructions/instruction-list.js +1 -1
  99. package/dist/components/instructions/instruction-list.mjs +1 -1
  100. package/dist/components/layouts/layout-default.d.mts +1 -1
  101. package/dist/components/layouts/layout-default.d.ts +1 -1
  102. package/dist/components/layouts/layout-types.d.mts +2 -2
  103. package/dist/components/layouts/layout-types.d.ts +2 -2
  104. package/dist/components/layouts/layout-types.js +1 -1
  105. package/dist/components/measurement-select.d.mts +13 -0
  106. package/dist/components/measurement-select.d.ts +13 -0
  107. package/dist/components/measurement-select.js +1 -0
  108. package/dist/components/measurement-select.mjs +1 -0
  109. package/dist/components/root.d.mts +2 -1
  110. package/dist/components/root.d.ts +2 -1
  111. package/dist/components/root.js +1 -1
  112. package/dist/components/root.mjs +1 -1
  113. package/dist/components/servings-select.d.mts +11 -0
  114. package/dist/components/servings-select.d.ts +11 -0
  115. package/dist/components/servings-select.js +1 -0
  116. package/dist/components/servings-select.mjs +1 -0
  117. package/dist/components/thumbnail.js +1 -1
  118. package/dist/components/thumbnail.mjs +1 -1
  119. package/dist/global-context.d.mts +17 -4
  120. package/dist/global-context.d.ts +17 -4
  121. package/dist/global-context.js +1 -1
  122. package/dist/global-context.mjs +1 -1
  123. package/dist/hooks/use-controllable.d.mts +15 -0
  124. package/dist/hooks/use-controllable.d.ts +15 -0
  125. package/dist/hooks/use-controllable.js +1 -0
  126. package/dist/hooks/use-controllable.mjs +1 -0
  127. package/dist/index.d.mts +3 -1
  128. package/dist/index.d.ts +3 -1
  129. package/dist/index.js +2 -1
  130. package/dist/index.mjs +1 -1
  131. package/dist/recipe-context.d.mts +22 -7
  132. package/dist/recipe-context.d.ts +22 -7
  133. package/dist/recipe-context.js +1 -1
  134. package/dist/recipe-context.mjs +1 -1
  135. package/dist/types-from-core.d.mts +1 -0
  136. package/dist/types-from-core.d.ts +1 -0
  137. package/dist/types-from-core.js +1 -0
  138. package/dist/types-from-core.mjs +1 -0
  139. package/package.json +2 -2
  140. package/dist/chunk-32VQC2BE.mjs +0 -1
  141. package/dist/chunk-6MAELCYD.mjs +0 -1
  142. package/dist/chunk-CB36WMX5.mjs +0 -24
  143. package/dist/chunk-GPTC24DR.mjs +0 -1
  144. package/dist/chunk-KYWBOSOP.mjs +0 -14
  145. package/dist/chunk-MBR257HS.mjs +0 -48
  146. package/dist/chunk-PLID2R4K.mjs +0 -48
  147. package/dist/chunk-PYOGNEQ3.mjs +0 -48
  148. package/dist/chunk-RZGBB6SL.mjs +0 -1
  149. package/dist/chunk-U7TL6PST.mjs +0 -1
package/dist/index.js CHANGED
@@ -1 +1,2 @@
1
- var a=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var o in t)a(e,o,{get:t[o],enumerable:!0})},A=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of L(t))!N.call(e,i)&&i!==o&&a(e,i,{get:()=>t[i],enumerable:!(r=w(t,i))||r.enumerable});return e};var M=e=>A(a({},"__esModule",{value:!0}),e);var S={};I(S,{IngredientList:()=>v,InstructionList:()=>y,Provider:()=>g,RecipeIngredientList:()=>v,RecipeInstructionList:()=>y,RecipeRoot:()=>P,RecipeThumbnail:()=>T,Root:()=>P,Thumbnail:()=>T,useRecipe:()=>n});module.exports=M(S);var b=require("react");var c=require("react"),R=require("react/jsx-runtime"),f=(0,c.createContext)({});function n(){let e=(0,c.useContext)(f);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}function u({children:e,config:t}){return(0,R.jsx)(f.Provider,{value:{config:t},children:e})}var p=require("react"),d=require("react/jsx-runtime"),C=(0,p.createContext)({});function x(){return(0,p.useContext)(C)}function g({children:e,config:t}){return(0,d.jsx)(C.Provider,{value:{config:t},children:e})}var h=require("react/jsx-runtime");function P(e){let{config:t}=x(),o=(0,b.useMemo)(()=>({...t,...e.config}),[t,e.config]);return(0,h.jsx)(u,{config:o,children:e.children})}var s=require("react/jsx-runtime");function v(){let{config:e}=n();return(0,s.jsx)("ul",{"recipe-ingredient-list":"",children:e.ingredients.map((t,o)=>(0,s.jsxs)("li",{"recipe-ingredient":"",children:[t.name," \u2014 ",t.amount.value," ",t.amount.unit]},o))})}var l=require("react/jsx-runtime");function y(){let{config:e}=n();return(0,l.jsx)("ul",{"recipe-instruction-list":"",children:e.instructions.map((t,o)=>(0,l.jsx)("li",{"recipe-instruction":o+1,children:t},o))})}var G=require("@radix-ui/react-aspect-ratio");var m=require("react/jsx-runtime");function T(e){var r,i;let{config:t}=n();if(!t.thumbnail)throw new Error("Missing thumbnail image. Did you forget to set one?");let o=(r=e.style)!=null?r:{};return(0,m.jsx)(G.AspectRatio,{"recipe-thumbnail":"",className:e.className,style:{width:"100%",...o},ratio:e.aspectRatio||1,children:(0,m.jsx)("img",{"recipe-thumbnail-image":"",style:{objectFit:"cover",width:"100%",height:"100%"},src:t.thumbnail,alt:(i=e.alt)!=null?i:t.name})})}0&&(module.exports={IngredientList,InstructionList,Provider,RecipeIngredientList,RecipeInstructionList,RecipeRoot,RecipeThumbnail,Root,Thumbnail,useRecipe});
1
+ var C=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var F=(e,t)=>{for(var n in t)C(e,n,{get:t[n],enumerable:!0})},V=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of W(t))!D.call(e,r)&&r!==n&&C(e,r,{get:()=>t[r],enumerable:!(o=E(t,r))||o.enumerable});return e};var _=e=>V(C({},"__esModule",{value:!0}),e);var B={};F(B,{IngredientList:()=>A,InstructionList:()=>L,MeasurementSelect:()=>U,Provider:()=>h,RecipeIngredientList:()=>A,RecipeInstructionList:()=>L,RecipeMeasurementSelect:()=>U,RecipeRoot:()=>I,RecipeServingsSelect:()=>K,RecipeThumbnail:()=>k,Root:()=>I,ServingsSelect:()=>K,Thumbnail:()=>k,useRecipe:()=>s});module.exports=_(B);var N=require("@recipe-book/core"),l=require("react");var a=require("react"),x=require("react/jsx-runtime"),b=(0,a.createContext)({});function s(){let e=(0,a.useContext)(b);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}function d({children:e,recipe:t,servings:n,setServings:o}){let[r,i]=(0,a.useState)(t.measurements),m=(0,a.useMemo)(()=>({...t,activeConversionKey:r,setConversionKey:c=>{i(c)},servings:n,setServings:o}),[t,r,i,n,o]);return(0,x.jsx)(b.Provider,{value:m,children:e})}var u=require("react"),S=require("react/jsx-runtime"),P=(0,u.createContext)({});function y(){let e=(0,u.useContext)(P);return e||{config:{}}}function h({children:e,config:t}){return(0,S.jsx)(P.Provider,{value:{config:t},children:e})}var G=require("react/jsx-runtime");function I(e){let[t,n]=(0,l.useState)(1),{config:o}=y(),r=(0,l.useMemo)(()=>{let i={...o,...e.recipe},m=N.RecipeUtils.create(i);return{...m,ingredients:m.ingredients.map(c=>({...c,amount:{...c.amount,value:c.amount.value*t},conversion:typeof c.conversion=="object"?{...c.conversion,[i.measurements]:c.amount.value*t}:c.conversion}))}},[o,e.recipe,t]);return(0,G.jsx)(d,{recipe:r,servings:t,setServings:n,children:e.children})}var T=require("@recipe-book/core");var w=require("react"),v=require("react/jsx-runtime");function $(e,t){var o;if(!t)return e.amount;let n=(o=e.conversion)==null?void 0:o[t];if(!n){console.warn(`No conversion found for ingredient "${e.name}" with key "${t}"
2
+ Attempting conversion table lookup...`);let r=T.IngredientUtils.convert(e,t);return r?r.amount:e.amount}return n}function A(e){let{ingredients:t,activeConversionKey:n,measurements:o}=s(),r=(0,w.useMemo)(()=>n===o?t:t.map(i=>({...i,amount:$(i,n)})),[t,n,o]);return(0,v.jsx)("ul",{"recipe-ingredient-list":"",className:e.className,children:r.map((i,m)=>(0,v.jsxs)("li",{"recipe-ingredient":"",children:[i.name," \u2014 ",i.amount.value," ",i.amount.unit]},m))})}var g=require("react/jsx-runtime");function L(e){let{instructions:t}=s();return(0,g.jsx)("ol",{"recipe-instruction-list":"",className:e.className,children:t.map((n,o)=>(0,g.jsx)("li",{"recipe-instruction":o+1,children:n},o))})}var M=require("@radix-ui/react-aspect-ratio");var R=require("react/jsx-runtime");function k(e){var r,i;let{thumbnail:t,name:n}=s();if(!t)throw new Error("Missing thumbnail image. Did you forget to set one?");let o=(r=e.style)!=null?r:{};return(0,R.jsx)(M.AspectRatio,{"recipe-thumbnail":"",className:e.className,style:{width:"100%",...o},ratio:e.aspectRatio||1,children:(0,R.jsx)("img",{"recipe-thumbnail-image":"",style:{objectFit:"cover",width:"100%",height:"100%"},src:t,alt:(i=e.alt)!=null?i:n})})}var f=require("react/jsx-runtime"),q=[.5,1,2,3];function K(e){let{servings:t,setServings:n}=s();return(0,f.jsx)("select",{className:e.className,"recipe-servings-select":"",value:t,onChange:o=>{n(Number(o.target.value))},children:q.map(o=>(0,f.jsxs)("option",{value:o,children:[o," serving",o!==1?"s":""]},o))})}var p=require("react/jsx-runtime");function U(e){let{activeConversionKey:t,setConversionKey:n,measurements:o}=s();if(o===void 0)throw new Error("Cannot select measurement without base measurement");return(0,p.jsxs)("div",{"recipe-measurement-select":"",className:e.className,children:[(0,p.jsx)("button",{"recipe-measurement-option":"","data-active":t==="us-customary",onClick:()=>n("us-customary"),children:"US"}),(0,p.jsx)("button",{"recipe-measurement-option":"","data-active":t==="metric",onClick:()=>n("metric"),children:"Metric"})]})}0&&(module.exports={IngredientList,InstructionList,MeasurementSelect,Provider,RecipeIngredientList,RecipeInstructionList,RecipeMeasurementSelect,RecipeRoot,RecipeServingsSelect,RecipeThumbnail,Root,ServingsSelect,Thumbnail,useRecipe});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as t}from"./chunk-U7TL6PST.mjs";import{a as e}from"./chunk-6MAELCYD.mjs";import{c as i}from"./chunk-QOCKR2HO.mjs";import{a as m}from"./chunk-RZGBB6SL.mjs";import{a as r}from"./chunk-GPTC24DR.mjs";import{a as o}from"./chunk-32VQC2BE.mjs";export{t as IngredientList,r as InstructionList,i as Provider,t as RecipeIngredientList,r as RecipeInstructionList,e as RecipeRoot,m as RecipeThumbnail,e as Root,m as Thumbnail,o as useRecipe};
1
+ import{a as i}from"./chunk-GM5F7IUT.mjs";import{a as o}from"./chunk-2VMRVR3X.mjs";import"./chunk-I5TR6PEA.mjs";import{a as p}from"./chunk-TLBRVWD2.mjs";import{a as r}from"./chunk-PTS3BZHK.mjs";import{c as e}from"./chunk-Q6I5J3IJ.mjs";import{a as s}from"./chunk-X66DY4AZ.mjs";import{a as m}from"./chunk-4XBZKTOL.mjs";import{a as t}from"./chunk-PBENQR7Y.mjs";export{i as IngredientList,o as InstructionList,p as MeasurementSelect,e as Provider,i as RecipeIngredientList,o as RecipeInstructionList,p as RecipeMeasurementSelect,r as RecipeRoot,s as RecipeServingsSelect,m as RecipeThumbnail,r as Root,s as ServingsSelect,m as Thumbnail,t as useRecipe};
@@ -1,14 +1,29 @@
1
1
  import { ReactNode } from 'react';
2
- import { RecipeConfig } from 'recipe-core';
2
+ import { RecipeConfig, ConversionTables, Recipe } from '@recipe-book/core';
3
3
 
4
- type RecipeContext<T extends string> = {
5
- config: RecipeConfig<T>;
4
+ type RecipeContext = RecipeConfig & {
5
+ activeConversionKey: ConversionTables;
6
+ setConversionKey: (key: ConversionTables) => void;
7
+ servings: number;
8
+ setServings: (value: number) => void;
6
9
  };
7
- declare function useRecipeContext(): RecipeContext<any>;
8
- interface RecipeContextProviderProps<T extends string> {
10
+ /**
11
+ * Hook to access the recipe context.
12
+ */
13
+ declare function useRecipeContext(): RecipeContext;
14
+ interface RecipeContextProviderProps {
9
15
  children: ReactNode;
10
- config: RecipeConfig<T>;
16
+ recipe: Recipe;
17
+ servings: number;
18
+ setServings: (value: number) => void;
11
19
  }
12
- declare function RecipeContextProvider<T extends string>({ children, config, }: RecipeContextProviderProps<T>): JSX.Element;
20
+ /**
21
+ * Provider for the recipe context. This provider is used to create
22
+ * a recipe-specific configuration that is inherited by all components
23
+ * within the recipe.
24
+ *
25
+ * @param {RecipeContextProviderProps} The recipe configuration to be used by all components
26
+ */
27
+ declare function RecipeContextProvider({ children, recipe, servings, setServings, }: RecipeContextProviderProps): JSX.Element;
13
28
 
14
29
  export { type RecipeContext, RecipeContextProvider, useRecipeContext };
@@ -1,14 +1,29 @@
1
1
  import { ReactNode } from 'react';
2
- import { RecipeConfig } from 'recipe-core';
2
+ import { RecipeConfig, ConversionTables, Recipe } from '@recipe-book/core';
3
3
 
4
- type RecipeContext<T extends string> = {
5
- config: RecipeConfig<T>;
4
+ type RecipeContext = RecipeConfig & {
5
+ activeConversionKey: ConversionTables;
6
+ setConversionKey: (key: ConversionTables) => void;
7
+ servings: number;
8
+ setServings: (value: number) => void;
6
9
  };
7
- declare function useRecipeContext(): RecipeContext<any>;
8
- interface RecipeContextProviderProps<T extends string> {
10
+ /**
11
+ * Hook to access the recipe context.
12
+ */
13
+ declare function useRecipeContext(): RecipeContext;
14
+ interface RecipeContextProviderProps {
9
15
  children: ReactNode;
10
- config: RecipeConfig<T>;
16
+ recipe: Recipe;
17
+ servings: number;
18
+ setServings: (value: number) => void;
11
19
  }
12
- declare function RecipeContextProvider<T extends string>({ children, config, }: RecipeContextProviderProps<T>): JSX.Element;
20
+ /**
21
+ * Provider for the recipe context. This provider is used to create
22
+ * a recipe-specific configuration that is inherited by all components
23
+ * within the recipe.
24
+ *
25
+ * @param {RecipeContextProviderProps} The recipe configuration to be used by all components
26
+ */
27
+ declare function RecipeContextProvider({ children, recipe, servings, setServings, }: RecipeContextProviderProps): JSX.Element;
13
28
 
14
29
  export { type RecipeContext, RecipeContextProvider, useRecipeContext };
@@ -1 +1 @@
1
- var r=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of s(t))!C.call(e,o)&&o!==n&&r(e,o,{get:()=>t[o],enumerable:!(c=R(t,o))||c.enumerable});return e};var g=e=>f(r({},"__esModule",{value:!0}),e);var P={};d(P,{RecipeContextProvider:()=>a,useRecipeContext:()=>u});module.exports=g(P);var i=require("react"),x=require("react/jsx-runtime"),p=(0,i.createContext)({});function u(){let e=(0,i.useContext)(p);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}function a({children:e,config:t}){return(0,x.jsx)(p.Provider,{value:{config:t},children:e})}0&&(module.exports={RecipeContextProvider,useRecipeContext});
1
+ var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var d=(o,e)=>{for(var r in e)s(o,r,{get:e[r],enumerable:!0})},l=(o,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!R.call(o,n)&&n!==r&&s(o,n,{get:()=>e[n],enumerable:!(i=a(e,n))||i.enumerable});return o};var m=o=>l(s({},"__esModule",{value:!0}),o);var y={};d(y,{RecipeContextProvider:()=>f,useRecipeContext:()=>b});module.exports=m(y);var t=require("react"),C=require("react/jsx-runtime"),v=(0,t.createContext)({});function b(){let o=(0,t.useContext)(v);if(!o)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return o}function f({children:o,recipe:e,servings:r,setServings:i}){let[n,c]=(0,t.useState)(e.measurements),p=(0,t.useMemo)(()=>({...e,activeConversionKey:n,setConversionKey:u=>{c(u)},servings:r,setServings:i}),[e,n,c,r,i]);return(0,C.jsx)(v.Provider,{value:p,children:o})}0&&(module.exports={RecipeContextProvider,useRecipeContext});
@@ -1 +1 @@
1
- import{a,b}from"./chunk-32VQC2BE.mjs";export{b as RecipeContextProvider,a as useRecipeContext};
1
+ import{a,b}from"./chunk-PBENQR7Y.mjs";export{b as RecipeContextProvider,a as useRecipeContext};
@@ -0,0 +1 @@
1
+ export { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from '@recipe-book/core';
@@ -0,0 +1 @@
1
+ export { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from '@recipe-book/core';
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var g=(i,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of c(e))!b.call(i,n)&&n!==r&&t(i,n,{get:()=>e[n],enumerable:!(o=p(e,n))||o.enumerable});return i};var U=i=>g(t({},"__esModule",{value:!0}),i);var a={};module.exports=U(a);
@@ -0,0 +1 @@
1
+ import"./chunk-I5TR6PEA.mjs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@recipe-book/react",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -16,7 +16,7 @@
16
16
  "@radix-ui/react-aspect-ratio": "1.0.3",
17
17
  "@radix-ui/react-avatar": "1.0.3",
18
18
  "@radix-ui/react-accessible-icon": "1.0.3",
19
- "recipe-core": "npm:@recipe-book/core@0.0.1"
19
+ "@recipe-book/core": "0.0.3"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/react": "18.0.15"
@@ -1 +0,0 @@
1
- import{createContext as n,useContext as i}from"react";import{jsx as r}from"react/jsx-runtime";var t=n({});function x(){let e=i(t);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}function R({children:e,config:o}){return r(t.Provider,{value:{config:o},children:e})}export{x as a,R as b};
@@ -1 +0,0 @@
1
- import{b as n}from"./chunk-QOCKR2HO.mjs";import{b as t}from"./chunk-32VQC2BE.mjs";import{useMemo as e}from"react";import{jsx as f}from"react/jsx-runtime";function C(o){let{config:i}=n(),r=e(()=>({...i,...o.config}),[i,o.config]);return f(t,{config:r,children:o.children})}export{C as a};
@@ -1,24 +0,0 @@
1
- // src/recipe-context.tsx
2
- import { createContext, useContext } from "react";
3
- import { jsx } from "react/jsx-runtime";
4
- var RecipeContext = createContext(
5
- {}
6
- );
7
- function useRecipeContext() {
8
- const ctx = useContext(RecipeContext);
9
- if (!ctx) {
10
- throw new Error("Missing recipe context. Are you using <Recipe.Root />?");
11
- }
12
- return ctx;
13
- }
14
- function RecipeContextProvider({
15
- children,
16
- config
17
- }) {
18
- return /* @__PURE__ */ jsx(RecipeContext.Provider, { value: { config }, children });
19
- }
20
-
21
- export {
22
- useRecipeContext,
23
- RecipeContextProvider
24
- };
@@ -1 +0,0 @@
1
- import{a as t}from"./chunk-32VQC2BE.mjs";import{jsx as n}from"react/jsx-runtime";function r(){let{config:o}=t();return n("ul",{"recipe-instruction-list":"",children:o.instructions.map((c,i)=>n("li",{"recipe-instruction":i+1,children:c},i))})}export{r as a};
@@ -1,14 +0,0 @@
1
- import {
2
- useRecipeContext
3
- } from "./chunk-CB36WMX5.mjs";
4
-
5
- // src/components/instructions/instruction-list.tsx
6
- import { jsx } from "react/jsx-runtime";
7
- function InstructionList() {
8
- const { config } = useRecipeContext();
9
- return /* @__PURE__ */ jsx("ul", { "recipe-instruction-list": "", children: config.instructions.map((instruction, i) => /* @__PURE__ */ jsx("li", { "recipe-instruction": i + 1, children: instruction }, i)) });
10
- }
11
-
12
- export {
13
- InstructionList
14
- };
@@ -1,48 +0,0 @@
1
- import {
2
- useRecipeContext
3
- } from "./chunk-CB36WMX5.mjs";
4
-
5
- // src/components/thumbnail.tsx
6
- import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
- import { forwardRef } from "react";
8
- import { jsx } from "react/jsx-runtime";
9
- var Thumbnail = forwardRef(
10
- (props, ref) => {
11
- var _a, _b;
12
- const { config } = useRecipeContext();
13
- if (!config.thumbnail) {
14
- throw new Error("Missing thumbnail image. Did you forget to set one?");
15
- }
16
- const propStyle = (_a = props.style) != null ? _a : {};
17
- return /* @__PURE__ */ jsx(
18
- AspectRatio,
19
- {
20
- "recipe-thumbnail": true,
21
- ref,
22
- className: props.className,
23
- style: {
24
- width: "100%",
25
- ...propStyle
26
- },
27
- ratio: props.aspectRatio || 1,
28
- children: /* @__PURE__ */ jsx(
29
- "img",
30
- {
31
- "recipe-thumbnail-image": true,
32
- style: {
33
- objectFit: "cover",
34
- width: "100%",
35
- height: "100%"
36
- },
37
- src: config.thumbnail,
38
- alt: (_b = props.alt) != null ? _b : config.name
39
- }
40
- )
41
- }
42
- );
43
- }
44
- );
45
-
46
- export {
47
- Thumbnail
48
- };
@@ -1,48 +0,0 @@
1
- import {
2
- useRecipeContext
3
- } from "./chunk-CB36WMX5.mjs";
4
-
5
- // src/components/thumbnail.tsx
6
- import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
- import { forwardRef } from "react";
8
- import { jsx } from "react/jsx-runtime";
9
- var Thumbnail = forwardRef(
10
- (props, ref) => {
11
- var _a, _b;
12
- const { config } = useRecipeContext();
13
- if (!config.thumbnail) {
14
- throw new Error("Missing thumbnail image. Did you forget to set one?");
15
- }
16
- const propStyle = (_a = props.style) != null ? _a : {};
17
- return /* @__PURE__ */ jsx(
18
- AspectRatio,
19
- {
20
- "recipe-thumbnail": "",
21
- ref,
22
- className: props.className,
23
- style: {
24
- width: "100%",
25
- ...propStyle
26
- },
27
- ratio: props.aspectRatio || 1,
28
- children: /* @__PURE__ */ jsx(
29
- "img",
30
- {
31
- "recipe-thumbnail-image": true,
32
- style: {
33
- objectFit: "cover",
34
- width: "100%",
35
- height: "100%"
36
- },
37
- src: config.thumbnail,
38
- alt: (_b = props.alt) != null ? _b : config.name
39
- }
40
- )
41
- }
42
- );
43
- }
44
- );
45
-
46
- export {
47
- Thumbnail
48
- };
@@ -1,48 +0,0 @@
1
- import {
2
- useRecipeContext
3
- } from "./chunk-CB36WMX5.mjs";
4
-
5
- // src/components/thumbnail.tsx
6
- import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
- import { forwardRef } from "react";
8
- import { jsx } from "react/jsx-runtime";
9
- var Thumbnail = forwardRef(
10
- (props, ref) => {
11
- var _a, _b;
12
- const { config } = useRecipeContext();
13
- if (!config.thumbnail) {
14
- throw new Error("Missing thumbnail image. Did you forget to set one?");
15
- }
16
- const propStyle = (_a = props.style) != null ? _a : {};
17
- return /* @__PURE__ */ jsx(
18
- AspectRatio,
19
- {
20
- "recipe-thumbnail": "",
21
- ref,
22
- className: props.className,
23
- style: {
24
- width: "100%",
25
- ...propStyle
26
- },
27
- ratio: props.aspectRatio || 1,
28
- children: /* @__PURE__ */ jsx(
29
- "img",
30
- {
31
- "recipe-thumbnail-image": "",
32
- style: {
33
- objectFit: "cover",
34
- width: "100%",
35
- height: "100%"
36
- },
37
- src: config.thumbnail,
38
- alt: (_b = props.alt) != null ? _b : config.name
39
- }
40
- )
41
- }
42
- );
43
- }
44
- );
45
-
46
- export {
47
- Thumbnail
48
- };
@@ -1 +0,0 @@
1
- import{a as o}from"./chunk-32VQC2BE.mjs";import{AspectRatio as m}from"@radix-ui/react-aspect-ratio";import{jsx as r}from"react/jsx-runtime";function c(t){var i,a;let{config:e}=o();if(!e.thumbnail)throw new Error("Missing thumbnail image. Did you forget to set one?");let s=(i=t.style)!=null?i:{};return r(m,{"recipe-thumbnail":"",className:t.className,style:{width:"100%",...s},ratio:t.aspectRatio||1,children:r("img",{"recipe-thumbnail-image":"",style:{objectFit:"cover",width:"100%",height:"100%"},src:e.thumbnail,alt:(a=t.alt)!=null?a:e.name})})}export{c as a};
@@ -1 +0,0 @@
1
- import{a as i}from"./chunk-32VQC2BE.mjs";import{jsx as u,jsxs as o}from"react/jsx-runtime";function l(){let{config:n}=i();return u("ul",{"recipe-ingredient-list":"",children:n.ingredients.map((e,t)=>o("li",{"recipe-ingredient":"",children:[e.name," \u2014 ",e.amount.value," ",e.amount.unit]},t))})}export{l as a};