@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
@@ -0,0 +1,37 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-SEXTT3NJ.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-MGBEDCLT.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo, useState } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const [servings, setServings] = useState(1);
14
+ const { config: globalConfig } = useGlobalContext();
15
+ const recipe = useMemo(() => {
16
+ const finalConfig = {
17
+ ...globalConfig,
18
+ ...props.recipe
19
+ };
20
+ const _recipe = RecipeUtils.create(finalConfig);
21
+ return {
22
+ ..._recipe,
23
+ ingredients: _recipe.ingredients.map((ingredient) => ({
24
+ ...ingredient,
25
+ amount: {
26
+ ...ingredient.amount,
27
+ value: ingredient.amount.value * servings
28
+ }
29
+ }))
30
+ };
31
+ }, [globalConfig, props.recipe]);
32
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
33
+ }
34
+
35
+ export {
36
+ Root
37
+ };
@@ -0,0 +1 @@
1
+ import{b as s}from"./chunk-Q6I5J3IJ.mjs";import{b as c}from"./chunk-PBENQR7Y.mjs";import{RecipeUtils as a}from"@recipe-book/core";import{useMemo as u,useState as v}from"react";import{jsx as f}from"react/jsx-runtime";function b(r){let[e,p]=v(1),{config:t}=s(),m=u(()=>{let i={...t,...r.recipe},n=a.create(i);return{...n,ingredients:n.ingredients.map(o=>({...o,amount:{...o.amount,value:o.amount.value*e},conversion:typeof o.conversion=="object"?{...o.conversion,[i.measurements]:o.amount.value*e}:o.conversion}))}},[t,r.recipe,e]);return f(c,{recipe:m,servings:e,setServings:p,children:r.children})}export{b as a};
@@ -0,0 +1 @@
1
+ import{createContext as n,useContext as l}from"react";import{jsx as r}from"react/jsx-runtime";var t=n({});function c(){let o=l(t);return o||{config:{}}}function x({children:o,config:e}){return r(t.Provider,{value:{config:e},children:o})}export{t as a,c as b,x as c};
@@ -0,0 +1,44 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-A5JAKCMG.mjs";
4
+
5
+ // src/components/thumbnail.tsx
6
+ import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function Thumbnail(props) {
9
+ var _a, _b;
10
+ const { thumbnail, name } = useRecipeContext();
11
+ if (!thumbnail) {
12
+ throw new Error("Missing thumbnail image. Did you forget to set one?");
13
+ }
14
+ const propStyle = (_a = props.style) != null ? _a : {};
15
+ return /* @__PURE__ */ jsx(
16
+ AspectRatio,
17
+ {
18
+ "recipe-thumbnail": "",
19
+ className: props.className,
20
+ style: {
21
+ width: "100%",
22
+ ...propStyle
23
+ },
24
+ ratio: props.aspectRatio || 1,
25
+ children: /* @__PURE__ */ jsx(
26
+ "img",
27
+ {
28
+ "recipe-thumbnail-image": "",
29
+ style: {
30
+ objectFit: "cover",
31
+ width: "100%",
32
+ height: "100%"
33
+ },
34
+ src: thumbnail,
35
+ alt: (_b = props.alt) != null ? _b : name
36
+ }
37
+ )
38
+ }
39
+ );
40
+ }
41
+
42
+ export {
43
+ Thumbnail
44
+ };
@@ -0,0 +1,34 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-SEXTT3NJ.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-MGBEDCLT.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo, useState } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const [servings, setServings] = useState(1);
14
+ const { config: globalConfig } = useGlobalContext();
15
+ const recipe = useMemo(() => {
16
+ const finalConfig = {
17
+ ...globalConfig,
18
+ ...props.recipe
19
+ };
20
+ const _recipe = RecipeUtils.create(finalConfig);
21
+ return {
22
+ ..._recipe,
23
+ ingredients: _recipe.ingredients.map((ingredient) => ({
24
+ ...ingredient,
25
+ quantity: ingredient.amount * servings
26
+ }))
27
+ };
28
+ }, [globalConfig, props.recipe]);
29
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
30
+ }
31
+
32
+ export {
33
+ Root
34
+ };
@@ -0,0 +1,34 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-SEXTT3NJ.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-MGBEDCLT.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo, useState } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const [servings, setServings] = useState(1);
14
+ const { config: globalConfig } = useGlobalContext();
15
+ const recipe = useMemo(() => {
16
+ const finalConfig = {
17
+ ...globalConfig,
18
+ ...props.recipe
19
+ };
20
+ const _recipe = RecipeUtils.create(finalConfig);
21
+ return {
22
+ ..._recipe,
23
+ ingredients: _recipe.ingredients.map((ingredient) => ({
24
+ ...ingredient,
25
+ amount: ingredient.amount * servings
26
+ }))
27
+ };
28
+ }, [globalConfig, props.recipe]);
29
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
30
+ }
31
+
32
+ export {
33
+ Root
34
+ };
@@ -0,0 +1,55 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-7SBP7DC5.mjs";
4
+
5
+ // src/components/ingredients/ingredients-list.tsx
6
+ import {
7
+ IngredientUtils
8
+ } from "@recipe-book/core";
9
+ import { useMemo } from "react";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ function getIngredientAmount(ingredient, conversionKey) {
12
+ var _a;
13
+ if (!conversionKey) {
14
+ return ingredient.amount;
15
+ }
16
+ const conversion = (_a = ingredient.conversion) == null ? void 0 : _a[conversionKey];
17
+ if (!conversion) {
18
+ console.warn(
19
+ `No conversion found for ingredient "${ingredient.name}" with key "${conversionKey}"
20
+ Attempting conversion table lookup...`
21
+ );
22
+ const coerced = IngredientUtils.convert(
23
+ ingredient,
24
+ conversionKey
25
+ );
26
+ if (coerced) {
27
+ return coerced.amount;
28
+ }
29
+ return ingredient.amount;
30
+ }
31
+ return conversion;
32
+ }
33
+ function IngredientList(props) {
34
+ const { ingredients, activeConversionKey, measurements } = useRecipeContext();
35
+ const ingredientsWithAmounts = useMemo(() => {
36
+ if (activeConversionKey === measurements) {
37
+ return ingredients;
38
+ }
39
+ ingredients.map((ingredient) => ({
40
+ ...ingredient,
41
+ amount: getIngredientAmount(ingredient, activeConversionKey)
42
+ }));
43
+ }, [ingredients, activeConversionKey, measurements]);
44
+ return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
45
+ ingredient.name,
46
+ " \u2014 ",
47
+ ingredient.amount.value,
48
+ " ",
49
+ ingredient.amount.unit
50
+ ] }, i)) });
51
+ }
52
+
53
+ export {
54
+ IngredientList
55
+ };
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-YZMVAQQG.mjs";import{jsx as a,jsxs as r}from"react/jsx-runtime";function l(i){let{ingredients:n}=t();return a("ul",{"recipe-ingredient-list":"",className:i.className,children:n.map((e,s)=>r("li",{"recipe-ingredient":"",children:[e.name," \u2014 ",e.amount.value," ",e.amount.unit]},s))})}export{l as a};
@@ -0,0 +1,14 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-MGBEDCLT.mjs";
4
+
5
+ // src/components/instructions/instruction-list.tsx
6
+ import { jsx } from "react/jsx-runtime";
7
+ function InstructionList(props) {
8
+ const { instructions } = useRecipeContext();
9
+ return /* @__PURE__ */ jsx("ol", { "recipe-instruction-list": "", className: props.className, children: instructions.map((instruction, i) => /* @__PURE__ */ jsx("li", { "recipe-instruction": i + 1, children: instruction }, i)) });
10
+ }
11
+
12
+ export {
13
+ InstructionList
14
+ };
@@ -0,0 +1,49 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-7SBP7DC5.mjs";
4
+
5
+ // src/components/ingredients/ingredients-list.tsx
6
+ import {
7
+ IngredientUtils
8
+ } from "@recipe-book/core";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ function getIngredientAmount(ingredient, conversionKey) {
11
+ var _a;
12
+ if (!conversionKey) {
13
+ return ingredient.amount;
14
+ }
15
+ const conversion = (_a = ingredient.conversion) == null ? void 0 : _a[conversionKey];
16
+ if (!conversion) {
17
+ console.warn(
18
+ `No conversion found for ingredient "${ingredient.name}" with key "${conversionKey}"
19
+ Attempting conversion table lookup...`
20
+ );
21
+ const coerced = IngredientUtils.convert(
22
+ ingredient,
23
+ conversionKey
24
+ );
25
+ if (coerced) {
26
+ return coerced.amount;
27
+ }
28
+ return ingredient.amount;
29
+ }
30
+ return conversion;
31
+ }
32
+ function IngredientList(props) {
33
+ const { ingredients, activeConversionKey } = useRecipeContext();
34
+ const ingredientsWithAmounts = ingredients.map((ingredient) => ({
35
+ ...ingredient,
36
+ amount: getIngredientAmount(ingredient, activeConversionKey)
37
+ }));
38
+ return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
39
+ ingredient.name,
40
+ " \u2014 ",
41
+ ingredient.amount.value,
42
+ " ",
43
+ ingredient.amount.unit
44
+ ] }, i)) });
45
+ }
46
+
47
+ export {
48
+ IngredientList
49
+ };
@@ -0,0 +1,25 @@
1
+ // src/global-context.tsx
2
+ import { createContext, useContext } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var GlobalContext = createContext({});
5
+ function useGlobalContext() {
6
+ const ctx = useContext(GlobalContext);
7
+ if (!ctx) {
8
+ return {
9
+ config: {}
10
+ };
11
+ }
12
+ return ctx;
13
+ }
14
+ function GlobalContextProvider({
15
+ children,
16
+ config
17
+ }) {
18
+ return /* @__PURE__ */ jsx(GlobalContext.Provider, { value: { config }, children });
19
+ }
20
+
21
+ export {
22
+ GlobalContext,
23
+ useGlobalContext,
24
+ GlobalContextProvider
25
+ };
@@ -0,0 +1,43 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-A5JAKCMG.mjs";
4
+
5
+ // src/components/ingredients/ingredients-list.tsx
6
+ import {
7
+ IngredientUtils
8
+ } from "@recipe-book/core";
9
+ import { jsx, jsxs } from "react/jsx-runtime";
10
+ function getIngredientAmount(ingredient, conversionKey) {
11
+ var _a;
12
+ const conversion = (_a = ingredient.conversion) == null ? void 0 : _a[conversionKey];
13
+ if (!conversion) {
14
+ console.warn(
15
+ `No conversion found for ingredient "${ingredient.name}" with key "${conversionKey}"`
16
+ );
17
+ const maybeConversion = IngredientUtils.convert(
18
+ ingredient,
19
+ conversionKey
20
+ );
21
+ return ingredient.amount;
22
+ }
23
+ return conversion;
24
+ }
25
+ function IngredientList(props) {
26
+ const { ingredients, activeConversionKey } = useRecipeContext();
27
+ console.log("INGEDIENTS LIST:", activeConversionKey);
28
+ const ingredientsWithAmounts = ingredients.map((ingredient) => ({
29
+ ...ingredient,
30
+ amount: getIngredientAmount(ingredient, activeConversionKey)
31
+ }));
32
+ return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
33
+ ingredient.name,
34
+ " \u2014 ",
35
+ ingredient.amount.value,
36
+ " ",
37
+ ingredient.amount.unit
38
+ ] }, i)) });
39
+ }
40
+
41
+ export {
42
+ IngredientList
43
+ };
@@ -0,0 +1 @@
1
+ import{a as n}from"./chunk-PBENQR7Y.mjs";import{jsx as s,jsxs as a}from"react/jsx-runtime";function i(r){let{activeConversionKey:e,setConversionKey:t,measurements:o}=n();if(o===void 0)throw new Error("Cannot select measurement without base measurement");return a("div",{"recipe-measurement-select":"",className:r.className,children:[s("button",{"recipe-measurement-option":"","data-active":e==="us-customary",onClick:()=>t("us-customary"),children:"US"}),s("button",{"recipe-measurement-option":"","data-active":e==="metric",onClick:()=>t("metric"),children:"Metric"})]})}export{i as a};
@@ -0,0 +1,36 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-ENGJXHYU.mjs";
4
+
5
+ // src/components/measurement-select.tsx
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ function MeasurementSelect(props) {
8
+ const { activeConversionKey, setConversionKey, measurements } = useRecipeContext();
9
+ if (measurements === void 0) {
10
+ throw new Error("Cannot select measurement without base measurement");
11
+ }
12
+ return /* @__PURE__ */ jsxs("div", { "recipe-measurement-select": "", className: props.className, children: [
13
+ /* @__PURE__ */ jsx(
14
+ "button",
15
+ {
16
+ "recipe-measurement-option": "",
17
+ "data-active": activeConversionKey === "us-customary",
18
+ onClick: () => setConversionKey("us-customary"),
19
+ children: "US"
20
+ }
21
+ ),
22
+ /* @__PURE__ */ jsx(
23
+ "button",
24
+ {
25
+ "recipe-measurement-option": "",
26
+ "data-active": activeConversionKey === "metric",
27
+ onClick: () => setConversionKey("metric"),
28
+ children: "Metric"
29
+ }
30
+ )
31
+ ] });
32
+ }
33
+
34
+ export {
35
+ MeasurementSelect
36
+ };
@@ -0,0 +1,37 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-SEXTT3NJ.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-MGBEDCLT.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo, useState } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const [servings, setServings] = useState(1);
14
+ const { config: globalConfig } = useGlobalContext();
15
+ const recipe = useMemo(() => {
16
+ const finalConfig = {
17
+ ...globalConfig,
18
+ ...props.recipe
19
+ };
20
+ const _recipe = RecipeUtils.create(finalConfig);
21
+ return {
22
+ ..._recipe,
23
+ ingredients: _recipe.ingredients.map((ingredient) => ({
24
+ ...ingredient,
25
+ amount: {
26
+ ...ingredient.amount,
27
+ value: ingredient.amount * servings
28
+ }
29
+ }))
30
+ };
31
+ }, [globalConfig, props.recipe]);
32
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
33
+ }
34
+
35
+ export {
36
+ Root
37
+ };
@@ -0,0 +1,36 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-A5JAKCMG.mjs";
4
+
5
+ // src/components/ingredients/ingredients-list.tsx
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ function getIngredientAmount(ingredient, conversionKey) {
8
+ var _a;
9
+ const conversion = (_a = ingredient.conversion) == null ? void 0 : _a[conversionKey];
10
+ if (!conversion) {
11
+ console.warn(
12
+ `No conversion found for ingredient "${ingredient.name}" with key "${conversionKey}"`
13
+ );
14
+ return ingredient.amount;
15
+ }
16
+ return conversion;
17
+ }
18
+ function IngredientList(props) {
19
+ const { ingredients, activeConversionKey } = useRecipeContext();
20
+ console.log("INGEDIENTS LIST:", activeConversionKey);
21
+ const ingredientsWithAmounts = ingredients.map((ingredient) => ({
22
+ ...ingredient,
23
+ amount: getIngredientAmount(ingredient, activeConversionKey)
24
+ }));
25
+ return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
26
+ ingredient.name,
27
+ " \u2014 ",
28
+ ingredient.amount.value,
29
+ " ",
30
+ ingredient.amount.unit
31
+ ] }, i)) });
32
+ }
33
+
34
+ export {
35
+ IngredientList
36
+ };
@@ -0,0 +1,26 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-M5D3UUZF.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-N53TONLF.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const { config: globalConfig } = useGlobalContext();
14
+ const recipe = useMemo(() => {
15
+ const finalConfig = {
16
+ ...globalConfig,
17
+ ...props.recipe
18
+ };
19
+ return RecipeUtils.create(finalConfig);
20
+ }, [globalConfig, props.recipe]);
21
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
22
+ }
23
+
24
+ export {
25
+ Root
26
+ };
@@ -0,0 +1,34 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-SEXTT3NJ.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-MGBEDCLT.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const [serving, setServings] = useState(1);
14
+ const { config: globalConfig } = useGlobalContext();
15
+ const recipe = useMemo(() => {
16
+ const finalConfig = {
17
+ ...globalConfig,
18
+ ...props.recipe
19
+ };
20
+ const _recipe = RecipeUtils.create(finalConfig);
21
+ return {
22
+ ..._recipe,
23
+ ingredients: _recipe.ingredients.map((ingredient) => ({
24
+ ...ingredient,
25
+ quantity: ingredient.amount * serving
26
+ }))
27
+ };
28
+ }, [globalConfig, props.recipe]);
29
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
30
+ }
31
+
32
+ export {
33
+ Root
34
+ };
@@ -0,0 +1,44 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-BOG5DA6M.mjs";
4
+
5
+ // src/components/thumbnail.tsx
6
+ import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function Thumbnail(props) {
9
+ var _a, _b;
10
+ const { thumbnail, name } = useRecipeContext();
11
+ if (!thumbnail) {
12
+ throw new Error("Missing thumbnail image. Did you forget to set one?");
13
+ }
14
+ const propStyle = (_a = props.style) != null ? _a : {};
15
+ return /* @__PURE__ */ jsx(
16
+ AspectRatio,
17
+ {
18
+ "recipe-thumbnail": "",
19
+ className: props.className,
20
+ style: {
21
+ width: "100%",
22
+ ...propStyle
23
+ },
24
+ ratio: props.aspectRatio || 1,
25
+ children: /* @__PURE__ */ jsx(
26
+ "img",
27
+ {
28
+ "recipe-thumbnail-image": "",
29
+ style: {
30
+ objectFit: "cover",
31
+ width: "100%",
32
+ height: "100%"
33
+ },
34
+ src: thumbnail,
35
+ alt: (_b = props.alt) != null ? _b : name
36
+ }
37
+ )
38
+ }
39
+ );
40
+ }
41
+
42
+ export {
43
+ Thumbnail
44
+ };
@@ -0,0 +1,34 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-SEXTT3NJ.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-MGBEDCLT.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo, useState } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const [servings, setServings] = useState(1);
14
+ const { config: globalConfig } = useGlobalContext();
15
+ const recipe = useMemo(() => {
16
+ const finalConfig = {
17
+ ...globalConfig,
18
+ ...props.recipe
19
+ };
20
+ const _recipe = RecipeUtils.create(finalConfig);
21
+ return {
22
+ ..._recipe,
23
+ ingredients: _recipe.ingredients.map((ingredient) => ({
24
+ ...ingredient,
25
+ quantity: ingredient.amount * serving
26
+ }))
27
+ };
28
+ }, [globalConfig, props.recipe]);
29
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
30
+ }
31
+
32
+ export {
33
+ Root
34
+ };
@@ -0,0 +1,54 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-SEXTT3NJ.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-ENGJXHYU.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { RecipeUtils } from "@recipe-book/core";
10
+ import { useMemo, useState } from "react";
11
+ import { jsx } from "react/jsx-runtime";
12
+ function Root(props) {
13
+ const [servings, setServings] = useState(1);
14
+ const { config: globalConfig } = useGlobalContext();
15
+ const recipe = useMemo(() => {
16
+ const finalConfig = {
17
+ ...globalConfig,
18
+ ...props.recipe
19
+ };
20
+ const _recipe = RecipeUtils.create(finalConfig);
21
+ return {
22
+ ..._recipe,
23
+ ingredients: _recipe.ingredients.map((ingredient) => ({
24
+ ...ingredient,
25
+ amount: {
26
+ ...ingredient.amount,
27
+ // scale the amount by the number of servings
28
+ value: ingredient.amount.value * servings
29
+ },
30
+ conversion: typeof ingredient.conversion === "object" ? {
31
+ // spread the conversion object and add the new conversion
32
+ ...ingredient.conversion,
33
+ [finalConfig.measurements]: ingredient.amount.value * servings
34
+ } : (
35
+ // if conversion is a string, it's a unit key
36
+ ingredient.conversion
37
+ )
38
+ }))
39
+ };
40
+ }, [globalConfig, props.recipe, servings]);
41
+ return /* @__PURE__ */ jsx(
42
+ RecipeContextProvider,
43
+ {
44
+ recipe,
45
+ servings,
46
+ setServings,
47
+ children: props.children
48
+ }
49
+ );
50
+ }
51
+
52
+ export {
53
+ Root
54
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-KNXMYQVO.mjs";
4
+
5
+ // src/components/instructions/instruction-list.tsx
6
+ import { jsx } from "react/jsx-runtime";
7
+ function InstructionList(props) {
8
+ const { instructions } = useRecipeContext();
9
+ return /* @__PURE__ */ jsx("ol", { "recipe-instruction-list": "", className: props.className, children: instructions.map((instruction, i) => /* @__PURE__ */ jsx("li", { "recipe-instruction": i + 1, children: instruction }, i)) });
10
+ }
11
+
12
+ export {
13
+ InstructionList
14
+ };