@recipe-book/react 0.0.3 → 0.1.1
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.
- package/CHANGELOG.md +36 -0
- package/LICENSE +21 -0
- package/README.md +48 -15
- package/core/package.json +5 -0
- package/core/schema-org/package.json +5 -0
- package/dist/core/schema-org.cjs +25 -0
- package/dist/core/schema-org.cjs.map +1 -0
- package/dist/core/schema-org.d.cts +1 -0
- package/dist/core/schema-org.d.ts +1 -0
- package/dist/core/schema-org.js +3 -0
- package/dist/core/schema-org.js.map +1 -0
- package/dist/core.cjs +25 -0
- package/dist/core.cjs.map +1 -0
- package/dist/core.d.cts +1 -0
- package/dist/core.d.ts +1 -0
- package/dist/core.js +3 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +1224 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1276 -0
- package/dist/index.d.ts +1276 -10
- package/dist/index.js +1207 -2
- package/dist/index.js.map +1 -0
- package/package.json +71 -15
- package/dist/chunk-2S2Z4HLL.mjs +0 -46
- package/dist/chunk-2VMRVR3X.mjs +0 -1
- package/dist/chunk-36H6LM2B.mjs +0 -14
- package/dist/chunk-4IWVZEXX.mjs +0 -20
- package/dist/chunk-4XBZKTOL.mjs +0 -1
- package/dist/chunk-6AGILC25.mjs +0 -20
- package/dist/chunk-6AXGEB5P.mjs +0 -14
- package/dist/chunk-6JEDN4VR.mjs +0 -20
- package/dist/chunk-6KLLMLNF.mjs +0 -33
- package/dist/chunk-6LTLY5K7.mjs +0 -20
- package/dist/chunk-6RA4EVIO.mjs +0 -46
- package/dist/chunk-75DF3E6L.mjs +0 -50
- package/dist/chunk-7BWMULSB.mjs +0 -55
- package/dist/chunk-7PPB3PM6.mjs +0 -40
- package/dist/chunk-7SBP7DC5.mjs +0 -42
- package/dist/chunk-7XJBP24U.mjs +0 -20
- package/dist/chunk-A5JAKCMG.mjs +0 -44
- package/dist/chunk-ATOAYKI3.mjs +0 -26
- package/dist/chunk-B5IXKKFC.mjs +0 -38
- package/dist/chunk-BEMMFA52.mjs +0 -49
- package/dist/chunk-BOG5DA6M.mjs +0 -38
- package/dist/chunk-BW4DYFBO.mjs +0 -36
- package/dist/chunk-CDQFOSWR.mjs +0 -34
- package/dist/chunk-CRQVP6PW.mjs +0 -20
- package/dist/chunk-CY27OHOG.mjs +0 -1
- package/dist/chunk-DACFJWGN.mjs +0 -14
- package/dist/chunk-DE5GUZKO.mjs +0 -46
- package/dist/chunk-DNZAFS5G.mjs +0 -48
- package/dist/chunk-DS3O5PAR.mjs +0 -20
- package/dist/chunk-ENGJXHYU.mjs +0 -42
- package/dist/chunk-FIFGRJKD.mjs +0 -26
- package/dist/chunk-FWOMIZEF.mjs +0 -46
- package/dist/chunk-G7XD4VBW.mjs +0 -44
- package/dist/chunk-GBU6MVZL.mjs +0 -14
- package/dist/chunk-GM5F7IUT.mjs +0 -2
- package/dist/chunk-GSGRXRJP.mjs +0 -38
- package/dist/chunk-GZRNU24M.mjs +0 -46
- package/dist/chunk-HNDXCSZY.mjs +0 -44
- package/dist/chunk-HXTUDCO2.mjs +0 -49
- package/dist/chunk-I5TR6PEA.mjs +0 -0
- package/dist/chunk-IXRYSEMS.mjs +0 -30
- package/dist/chunk-J5Q2Z2JG.mjs +0 -38
- package/dist/chunk-JBAAWEV6.mjs +0 -1
- package/dist/chunk-JCPPNN26.mjs +0 -44
- package/dist/chunk-JR3OTSZB.mjs +0 -32
- package/dist/chunk-JWS5RTU3.mjs +0 -46
- package/dist/chunk-K6EZ773Q.mjs +0 -26
- package/dist/chunk-KNXMYQVO.mjs +0 -36
- package/dist/chunk-KRUZ7OA7.mjs +0 -44
- package/dist/chunk-KXCIJBR6.mjs +0 -14
- package/dist/chunk-M5D3UUZF.mjs +0 -19
- package/dist/chunk-MASAOP7L.mjs +0 -55
- package/dist/chunk-MGBEDCLT.mjs +0 -34
- package/dist/chunk-MKBCBPVR.mjs +0 -53
- package/dist/chunk-N53TONLF.mjs +0 -39
- package/dist/chunk-NYDGFRPM.mjs +0 -46
- package/dist/chunk-OPOABKD6.mjs +0 -23
- package/dist/chunk-OX6ITS5C.mjs +0 -20
- package/dist/chunk-PAAVW47I.mjs +0 -50
- package/dist/chunk-PAF5HSSV.mjs +0 -53
- package/dist/chunk-PBENQR7Y.mjs +0 -1
- package/dist/chunk-PH3LQIHZ.mjs +0 -26
- package/dist/chunk-PIB3RAOO.mjs +0 -24
- package/dist/chunk-PIXLJD7Y.mjs +0 -37
- package/dist/chunk-PTS3BZHK.mjs +0 -1
- package/dist/chunk-Q6I5J3IJ.mjs +0 -1
- package/dist/chunk-QOCKR2HO.mjs +0 -1
- package/dist/chunk-QOZCSS3B.mjs +0 -44
- package/dist/chunk-QSFPUODQ.mjs +0 -34
- package/dist/chunk-RY7QUBJI.mjs +0 -34
- package/dist/chunk-RZJRUG2I.mjs +0 -55
- package/dist/chunk-S3GGSQB5.mjs +0 -1
- package/dist/chunk-S3HRT5Z5.mjs +0 -14
- package/dist/chunk-SB7HBCCZ.mjs +0 -49
- package/dist/chunk-SEXTT3NJ.mjs +0 -25
- package/dist/chunk-SKEQCOPX.mjs +0 -43
- package/dist/chunk-TLBRVWD2.mjs +0 -1
- package/dist/chunk-TOOCHDUY.mjs +0 -36
- package/dist/chunk-TSKANLT4.mjs +0 -37
- package/dist/chunk-UAMZEZUI.mjs +0 -36
- package/dist/chunk-UQJ4XNWN.mjs +0 -26
- package/dist/chunk-VDSUUXCH.mjs +0 -34
- package/dist/chunk-VO7RY2ZK.mjs +0 -44
- package/dist/chunk-WJKDFBJ2.mjs +0 -34
- package/dist/chunk-WTC7PY7U.mjs +0 -54
- package/dist/chunk-WXDV7CMB.mjs +0 -14
- package/dist/chunk-X5FG3X6T.mjs +0 -1
- package/dist/chunk-X66DY4AZ.mjs +0 -1
- package/dist/chunk-XXSJXKWQ.mjs +0 -44
- package/dist/chunk-YZMVAQQG.mjs +0 -1
- package/dist/chunk-ZCXPZU7W.mjs +0 -20
- package/dist/chunk-ZJ4PNVYO.mjs +0 -52
- package/dist/chunk-ZU4QJLEY.mjs +0 -53
- package/dist/components/ingredients/ingredients-list.d.mts +0 -13
- package/dist/components/ingredients/ingredients-list.d.ts +0 -13
- package/dist/components/ingredients/ingredients-list.js +0 -2
- package/dist/components/ingredients/ingredients-list.mjs +0 -1
- package/dist/components/instructions/instruction-list.d.mts +0 -13
- package/dist/components/instructions/instruction-list.d.ts +0 -13
- package/dist/components/instructions/instruction-list.js +0 -1
- package/dist/components/instructions/instruction-list.mjs +0 -1
- package/dist/components/layouts/layout-default.d.mts +0 -7
- package/dist/components/layouts/layout-default.d.ts +0 -7
- package/dist/components/layouts/layout-default.js +0 -1
- package/dist/components/layouts/layout-default.mjs +0 -1
- package/dist/components/layouts/layout-types.d.mts +0 -8
- package/dist/components/layouts/layout-types.d.ts +0 -8
- package/dist/components/layouts/layout-types.js +0 -1
- package/dist/components/layouts/layout-types.mjs +0 -0
- package/dist/components/measurement-select.d.mts +0 -13
- package/dist/components/measurement-select.d.ts +0 -13
- package/dist/components/measurement-select.js +0 -1
- package/dist/components/measurement-select.mjs +0 -1
- package/dist/components/root.d.mts +0 -13
- package/dist/components/root.d.ts +0 -13
- package/dist/components/root.js +0 -1
- package/dist/components/root.mjs +0 -1
- package/dist/components/servings-select.d.mts +0 -11
- package/dist/components/servings-select.d.ts +0 -11
- package/dist/components/servings-select.js +0 -1
- package/dist/components/servings-select.mjs +0 -1
- package/dist/components/thumbnail.d.mts +0 -18
- package/dist/components/thumbnail.d.ts +0 -18
- package/dist/components/thumbnail.js +0 -1
- package/dist/components/thumbnail.mjs +0 -1
- package/dist/global-context.d.mts +0 -29
- package/dist/global-context.d.ts +0 -29
- package/dist/global-context.js +0 -1
- package/dist/global-context.mjs +0 -1
- package/dist/hooks/use-controllable.d.mts +0 -15
- package/dist/hooks/use-controllable.d.ts +0 -15
- package/dist/hooks/use-controllable.js +0 -1
- package/dist/hooks/use-controllable.mjs +0 -1
- package/dist/index.d.mts +0 -10
- package/dist/index.mjs +0 -1
- package/dist/recipe-context.d.mts +0 -29
- package/dist/recipe-context.d.ts +0 -29
- package/dist/recipe-context.js +0 -1
- package/dist/recipe-context.mjs +0 -1
- package/dist/types-from-core.d.mts +0 -1
- package/dist/types-from-core.d.ts +0 -1
- package/dist/types-from-core.js +0 -1
- package/dist/types-from-core.mjs +0 -1
package/dist/chunk-6KLLMLNF.mjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
return ingredient.amount;
|
|
12
|
-
}
|
|
13
|
-
return conversion;
|
|
14
|
-
}
|
|
15
|
-
function IngredientList(props) {
|
|
16
|
-
const { ingredients, activeConversionKey } = useRecipeContext();
|
|
17
|
-
console.log("INGEDIENTS LIST:", activeConversionKey);
|
|
18
|
-
const ingredientsWithAmounts = ingredients.map((ingredient) => ({
|
|
19
|
-
...ingredient,
|
|
20
|
-
amount: getIngredientAmount(ingredient, activeConversionKey)
|
|
21
|
-
}));
|
|
22
|
-
return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
|
|
23
|
-
ingredient.name,
|
|
24
|
-
" \u2014 ",
|
|
25
|
-
ingredient.amount.value,
|
|
26
|
-
" ",
|
|
27
|
-
ingredient.amount.unit
|
|
28
|
-
] }, i)) });
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
IngredientList
|
|
33
|
-
};
|
package/dist/chunk-6LTLY5K7.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 IngredientList(props) {
|
|
8
|
-
const { ingredients, activeConversionKey } = useRecipeContext();
|
|
9
|
-
return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredients.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
|
|
10
|
-
ingredient.name,
|
|
11
|
-
" \u2014 ",
|
|
12
|
-
ingredient.amount.value,
|
|
13
|
-
" ",
|
|
14
|
-
ingredient.amount.unit
|
|
15
|
-
] }, i)) });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
IngredientList
|
|
20
|
-
};
|
package/dist/chunk-6RA4EVIO.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useGlobalContext
|
|
3
|
-
} from "./chunk-SEXTT3NJ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
RecipeContextProvider
|
|
6
|
-
} from "./chunk-BOG5DA6M.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
|
-
}))
|
|
31
|
-
};
|
|
32
|
-
}, [globalConfig, props.recipe]);
|
|
33
|
-
return /* @__PURE__ */ jsx(
|
|
34
|
-
RecipeContextProvider,
|
|
35
|
-
{
|
|
36
|
-
recipe,
|
|
37
|
-
servings,
|
|
38
|
-
setServings,
|
|
39
|
-
children: props.children
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
Root
|
|
46
|
-
};
|
package/dist/chunk-75DF3E6L.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
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
|
-
...ingredient.conversion,
|
|
32
|
-
[finalConfig.measurements]: ingredient.amount
|
|
33
|
-
} : ingredient.conversion
|
|
34
|
-
}))
|
|
35
|
-
};
|
|
36
|
-
}, [globalConfig, props.recipe, servings]);
|
|
37
|
-
return /* @__PURE__ */ jsx(
|
|
38
|
-
RecipeContextProvider,
|
|
39
|
-
{
|
|
40
|
-
recipe,
|
|
41
|
-
servings,
|
|
42
|
-
setServings,
|
|
43
|
-
children: props.children
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export {
|
|
49
|
-
Root
|
|
50
|
-
};
|
package/dist/chunk-7BWMULSB.mjs
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useRecipeContext
|
|
3
|
-
} from "./chunk-ENGJXHYU.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
|
-
return 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
|
-
};
|
package/dist/chunk-7PPB3PM6.mjs
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
IngredientUtils.convert(ingredient, conversionKey);
|
|
18
|
-
return ingredient.amount;
|
|
19
|
-
}
|
|
20
|
-
return conversion;
|
|
21
|
-
}
|
|
22
|
-
function IngredientList(props) {
|
|
23
|
-
const { ingredients, activeConversionKey } = useRecipeContext();
|
|
24
|
-
console.log("INGEDIENTS LIST:", activeConversionKey);
|
|
25
|
-
const ingredientsWithAmounts = ingredients.map((ingredient) => ({
|
|
26
|
-
...ingredient,
|
|
27
|
-
amount: getIngredientAmount(ingredient, activeConversionKey)
|
|
28
|
-
}));
|
|
29
|
-
return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
|
|
30
|
-
ingredient.name,
|
|
31
|
-
" \u2014 ",
|
|
32
|
-
ingredient.amount.value,
|
|
33
|
-
" ",
|
|
34
|
-
ingredient.amount.unit
|
|
35
|
-
] }, i)) });
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export {
|
|
39
|
-
IngredientList
|
|
40
|
-
};
|
package/dist/chunk-7SBP7DC5.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// src/recipe-context.tsx
|
|
2
|
-
import { createContext, useContext, useState, useMemo } from "react";
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
var recipeContext = createContext({});
|
|
5
|
-
function useRecipeContext() {
|
|
6
|
-
const ctx = useContext(recipeContext);
|
|
7
|
-
if (!ctx) {
|
|
8
|
-
throw new Error("Missing recipe context. Are you using <Recipe.Root />?");
|
|
9
|
-
}
|
|
10
|
-
return ctx;
|
|
11
|
-
}
|
|
12
|
-
function RecipeContextProvider({
|
|
13
|
-
children,
|
|
14
|
-
recipe,
|
|
15
|
-
servings,
|
|
16
|
-
setServings
|
|
17
|
-
}) {
|
|
18
|
-
const [activeConversionKey, setActiveConversionKey] = useState();
|
|
19
|
-
const recipeContextValue = useMemo(() => {
|
|
20
|
-
return {
|
|
21
|
-
...recipe,
|
|
22
|
-
activeConversionKey,
|
|
23
|
-
setConversionKey: (key) => {
|
|
24
|
-
setActiveConversionKey(key);
|
|
25
|
-
},
|
|
26
|
-
servings,
|
|
27
|
-
setServings
|
|
28
|
-
};
|
|
29
|
-
}, [
|
|
30
|
-
recipe,
|
|
31
|
-
activeConversionKey,
|
|
32
|
-
setActiveConversionKey,
|
|
33
|
-
servings,
|
|
34
|
-
setServings
|
|
35
|
-
]);
|
|
36
|
-
return /* @__PURE__ */ jsx(recipeContext.Provider, { value: recipeContextValue, children });
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
useRecipeContext,
|
|
41
|
-
RecipeContextProvider
|
|
42
|
-
};
|
package/dist/chunk-7XJBP24U.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 IngredientList(props) {
|
|
8
|
-
const { ingredients, servings } = useRecipeContext();
|
|
9
|
-
return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredients.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
|
|
10
|
-
ingredient.name,
|
|
11
|
-
" \u2014 ",
|
|
12
|
-
ingredient.amount.value * servings,
|
|
13
|
-
" ",
|
|
14
|
-
ingredient.amount.unit
|
|
15
|
-
] }, i)) });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
IngredientList
|
|
20
|
-
};
|
package/dist/chunk-A5JAKCMG.mjs
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// src/recipe-context.tsx
|
|
2
|
-
import { createContext, useContext, useState, useMemo } 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
|
-
recipe,
|
|
17
|
-
servings,
|
|
18
|
-
setServings
|
|
19
|
-
}) {
|
|
20
|
-
const [activeConversionKey, setActiveConversionKey] = useState();
|
|
21
|
-
const recipeContextValue = useMemo(() => {
|
|
22
|
-
return {
|
|
23
|
-
...recipe,
|
|
24
|
-
activeConversionKey,
|
|
25
|
-
setConversionKey: (key) => {
|
|
26
|
-
setActiveConversionKey(key);
|
|
27
|
-
},
|
|
28
|
-
servings,
|
|
29
|
-
setServings
|
|
30
|
-
};
|
|
31
|
-
}, [
|
|
32
|
-
recipe,
|
|
33
|
-
activeConversionKey,
|
|
34
|
-
setActiveConversionKey,
|
|
35
|
-
servings,
|
|
36
|
-
setServings
|
|
37
|
-
]);
|
|
38
|
-
return /* @__PURE__ */ jsx(recipeContext.Provider, { value: recipeContextValue, children });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
useRecipeContext,
|
|
43
|
-
RecipeContextProvider
|
|
44
|
-
};
|
package/dist/chunk-ATOAYKI3.mjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useGlobalContext
|
|
3
|
-
} from "./chunk-OPOABKD6.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 { 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
|
-
};
|
package/dist/chunk-B5IXKKFC.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useGlobalContext
|
|
3
|
-
} from "./chunk-SEXTT3NJ.mjs";
|
|
4
|
-
import {
|
|
5
|
-
RecipeContextProvider
|
|
6
|
-
} from "./chunk-BOG5DA6M.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
|
-
}))
|
|
31
|
-
};
|
|
32
|
-
}, [globalConfig, props.recipe]);
|
|
33
|
-
return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export {
|
|
37
|
-
Root
|
|
38
|
-
};
|
package/dist/chunk-BEMMFA52.mjs
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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
|
-
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
|
-
);
|
|
20
|
-
const coerced = IngredientUtils.convert(
|
|
21
|
-
ingredient,
|
|
22
|
-
conversionKey
|
|
23
|
-
);
|
|
24
|
-
if (coerced) {
|
|
25
|
-
return coerced.amount;
|
|
26
|
-
}
|
|
27
|
-
return ingredient.amount;
|
|
28
|
-
}
|
|
29
|
-
return conversion;
|
|
30
|
-
}
|
|
31
|
-
function IngredientList(props) {
|
|
32
|
-
const { ingredients, activeConversionKey } = useRecipeContext();
|
|
33
|
-
console.log("INGEDIENTS LIST:", activeConversionKey);
|
|
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
|
-
};
|
package/dist/chunk-BOG5DA6M.mjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
// src/recipe-context.tsx
|
|
2
|
-
import { createContext, useContext, useState, useMemo } 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
|
-
recipe,
|
|
17
|
-
servings,
|
|
18
|
-
setServings
|
|
19
|
-
}) {
|
|
20
|
-
const [activeConversionKey, setActiveConversionKey] = useState();
|
|
21
|
-
const recipeContextValue = useMemo(() => {
|
|
22
|
-
return {
|
|
23
|
-
...recipe,
|
|
24
|
-
activeConversionKey,
|
|
25
|
-
setConversionKey: (key) => {
|
|
26
|
-
setActiveConversionKey(key);
|
|
27
|
-
},
|
|
28
|
-
servings,
|
|
29
|
-
setServings
|
|
30
|
-
};
|
|
31
|
-
}, [recipe, activeConversionKey, setActiveConversionKey]);
|
|
32
|
-
return /* @__PURE__ */ jsx(recipeContext.Provider, { value: recipeContextValue, children });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export {
|
|
36
|
-
useRecipeContext,
|
|
37
|
-
RecipeContextProvider
|
|
38
|
-
};
|
package/dist/chunk-BW4DYFBO.mjs
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
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 { config: globalConfig } = useGlobalContext();
|
|
14
|
-
const recipe = useMemo(() => {
|
|
15
|
-
const finalConfig = {
|
|
16
|
-
...globalConfig,
|
|
17
|
-
...props.recipe
|
|
18
|
-
};
|
|
19
|
-
const _recipe = RecipeUtils.create(finalConfig);
|
|
20
|
-
return {
|
|
21
|
-
..._recipe,
|
|
22
|
-
ingredients: _recipe.ingredients.map((ingredient) => {
|
|
23
|
-
var _a;
|
|
24
|
-
return {
|
|
25
|
-
...ingredient,
|
|
26
|
-
quantity: (_a = ingredient.quantity) != null ? _a : 0
|
|
27
|
-
};
|
|
28
|
-
})
|
|
29
|
-
};
|
|
30
|
-
}, [globalConfig, props.recipe]);
|
|
31
|
-
return /* @__PURE__ */ jsx(RecipeContextProvider, { recipe, children: props.children });
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export {
|
|
35
|
-
Root
|
|
36
|
-
};
|
package/dist/chunk-CDQFOSWR.mjs
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
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 [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
|
-
};
|
package/dist/chunk-CRQVP6PW.mjs
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
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 IngredientList(props) {
|
|
8
|
-
const { ingredients, activeConversionKey } = useRecipeContext();
|
|
9
|
-
return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredients.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
|
|
10
|
-
ingredient.name,
|
|
11
|
-
" \u2014 ",
|
|
12
|
-
ingredient.amount.value,
|
|
13
|
-
" ",
|
|
14
|
-
ingredient.amount.unit
|
|
15
|
-
] }, i)) });
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export {
|
|
19
|
-
IngredientList
|
|
20
|
-
};
|
package/dist/chunk-CY27OHOG.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as r}from"./chunk-QOCKR2HO.mjs";import{b as i}from"./chunk-YZMVAQQG.mjs";import{useMemo as n}from"react";import{jsx as p}from"react/jsx-runtime";function m(o){let{config:e}=r(),t=n(()=>({...e,...o.recipe}),[e,o.recipe]);return p(i,{recipe:t,children:o.children})}export{m as a};
|
package/dist/chunk-DACFJWGN.mjs
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useRecipeContext
|
|
3
|
-
} from "./chunk-BOG5DA6M.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
|
-
};
|
package/dist/chunk-DE5GUZKO.mjs
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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 coerced = IngredientUtils.convert(
|
|
18
|
-
ingredient,
|
|
19
|
-
conversionKey
|
|
20
|
-
);
|
|
21
|
-
if (coerced) {
|
|
22
|
-
return coerced.amount;
|
|
23
|
-
}
|
|
24
|
-
return ingredient.amount;
|
|
25
|
-
}
|
|
26
|
-
return conversion;
|
|
27
|
-
}
|
|
28
|
-
function IngredientList(props) {
|
|
29
|
-
const { ingredients, activeConversionKey } = useRecipeContext();
|
|
30
|
-
console.log("INGEDIENTS LIST:", activeConversionKey);
|
|
31
|
-
const ingredientsWithAmounts = ingredients.map((ingredient) => ({
|
|
32
|
-
...ingredient,
|
|
33
|
-
amount: getIngredientAmount(ingredient, activeConversionKey)
|
|
34
|
-
}));
|
|
35
|
-
return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
|
|
36
|
-
ingredient.name,
|
|
37
|
-
" \u2014 ",
|
|
38
|
-
ingredient.amount.value,
|
|
39
|
-
" ",
|
|
40
|
-
ingredient.amount.unit
|
|
41
|
-
] }, i)) });
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
IngredientList
|
|
46
|
-
};
|