@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.
Files changed (167) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE +21 -0
  3. package/README.md +48 -15
  4. package/core/package.json +5 -0
  5. package/core/schema-org/package.json +5 -0
  6. package/dist/core/schema-org.cjs +25 -0
  7. package/dist/core/schema-org.cjs.map +1 -0
  8. package/dist/core/schema-org.d.cts +1 -0
  9. package/dist/core/schema-org.d.ts +1 -0
  10. package/dist/core/schema-org.js +3 -0
  11. package/dist/core/schema-org.js.map +1 -0
  12. package/dist/core.cjs +25 -0
  13. package/dist/core.cjs.map +1 -0
  14. package/dist/core.d.cts +1 -0
  15. package/dist/core.d.ts +1 -0
  16. package/dist/core.js +3 -0
  17. package/dist/core.js.map +1 -0
  18. package/dist/index.cjs +1224 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.cts +1276 -0
  21. package/dist/index.d.ts +1276 -10
  22. package/dist/index.js +1207 -2
  23. package/dist/index.js.map +1 -0
  24. package/package.json +71 -15
  25. package/dist/chunk-2S2Z4HLL.mjs +0 -46
  26. package/dist/chunk-2VMRVR3X.mjs +0 -1
  27. package/dist/chunk-36H6LM2B.mjs +0 -14
  28. package/dist/chunk-4IWVZEXX.mjs +0 -20
  29. package/dist/chunk-4XBZKTOL.mjs +0 -1
  30. package/dist/chunk-6AGILC25.mjs +0 -20
  31. package/dist/chunk-6AXGEB5P.mjs +0 -14
  32. package/dist/chunk-6JEDN4VR.mjs +0 -20
  33. package/dist/chunk-6KLLMLNF.mjs +0 -33
  34. package/dist/chunk-6LTLY5K7.mjs +0 -20
  35. package/dist/chunk-6RA4EVIO.mjs +0 -46
  36. package/dist/chunk-75DF3E6L.mjs +0 -50
  37. package/dist/chunk-7BWMULSB.mjs +0 -55
  38. package/dist/chunk-7PPB3PM6.mjs +0 -40
  39. package/dist/chunk-7SBP7DC5.mjs +0 -42
  40. package/dist/chunk-7XJBP24U.mjs +0 -20
  41. package/dist/chunk-A5JAKCMG.mjs +0 -44
  42. package/dist/chunk-ATOAYKI3.mjs +0 -26
  43. package/dist/chunk-B5IXKKFC.mjs +0 -38
  44. package/dist/chunk-BEMMFA52.mjs +0 -49
  45. package/dist/chunk-BOG5DA6M.mjs +0 -38
  46. package/dist/chunk-BW4DYFBO.mjs +0 -36
  47. package/dist/chunk-CDQFOSWR.mjs +0 -34
  48. package/dist/chunk-CRQVP6PW.mjs +0 -20
  49. package/dist/chunk-CY27OHOG.mjs +0 -1
  50. package/dist/chunk-DACFJWGN.mjs +0 -14
  51. package/dist/chunk-DE5GUZKO.mjs +0 -46
  52. package/dist/chunk-DNZAFS5G.mjs +0 -48
  53. package/dist/chunk-DS3O5PAR.mjs +0 -20
  54. package/dist/chunk-ENGJXHYU.mjs +0 -42
  55. package/dist/chunk-FIFGRJKD.mjs +0 -26
  56. package/dist/chunk-FWOMIZEF.mjs +0 -46
  57. package/dist/chunk-G7XD4VBW.mjs +0 -44
  58. package/dist/chunk-GBU6MVZL.mjs +0 -14
  59. package/dist/chunk-GM5F7IUT.mjs +0 -2
  60. package/dist/chunk-GSGRXRJP.mjs +0 -38
  61. package/dist/chunk-GZRNU24M.mjs +0 -46
  62. package/dist/chunk-HNDXCSZY.mjs +0 -44
  63. package/dist/chunk-HXTUDCO2.mjs +0 -49
  64. package/dist/chunk-I5TR6PEA.mjs +0 -0
  65. package/dist/chunk-IXRYSEMS.mjs +0 -30
  66. package/dist/chunk-J5Q2Z2JG.mjs +0 -38
  67. package/dist/chunk-JBAAWEV6.mjs +0 -1
  68. package/dist/chunk-JCPPNN26.mjs +0 -44
  69. package/dist/chunk-JR3OTSZB.mjs +0 -32
  70. package/dist/chunk-JWS5RTU3.mjs +0 -46
  71. package/dist/chunk-K6EZ773Q.mjs +0 -26
  72. package/dist/chunk-KNXMYQVO.mjs +0 -36
  73. package/dist/chunk-KRUZ7OA7.mjs +0 -44
  74. package/dist/chunk-KXCIJBR6.mjs +0 -14
  75. package/dist/chunk-M5D3UUZF.mjs +0 -19
  76. package/dist/chunk-MASAOP7L.mjs +0 -55
  77. package/dist/chunk-MGBEDCLT.mjs +0 -34
  78. package/dist/chunk-MKBCBPVR.mjs +0 -53
  79. package/dist/chunk-N53TONLF.mjs +0 -39
  80. package/dist/chunk-NYDGFRPM.mjs +0 -46
  81. package/dist/chunk-OPOABKD6.mjs +0 -23
  82. package/dist/chunk-OX6ITS5C.mjs +0 -20
  83. package/dist/chunk-PAAVW47I.mjs +0 -50
  84. package/dist/chunk-PAF5HSSV.mjs +0 -53
  85. package/dist/chunk-PBENQR7Y.mjs +0 -1
  86. package/dist/chunk-PH3LQIHZ.mjs +0 -26
  87. package/dist/chunk-PIB3RAOO.mjs +0 -24
  88. package/dist/chunk-PIXLJD7Y.mjs +0 -37
  89. package/dist/chunk-PTS3BZHK.mjs +0 -1
  90. package/dist/chunk-Q6I5J3IJ.mjs +0 -1
  91. package/dist/chunk-QOCKR2HO.mjs +0 -1
  92. package/dist/chunk-QOZCSS3B.mjs +0 -44
  93. package/dist/chunk-QSFPUODQ.mjs +0 -34
  94. package/dist/chunk-RY7QUBJI.mjs +0 -34
  95. package/dist/chunk-RZJRUG2I.mjs +0 -55
  96. package/dist/chunk-S3GGSQB5.mjs +0 -1
  97. package/dist/chunk-S3HRT5Z5.mjs +0 -14
  98. package/dist/chunk-SB7HBCCZ.mjs +0 -49
  99. package/dist/chunk-SEXTT3NJ.mjs +0 -25
  100. package/dist/chunk-SKEQCOPX.mjs +0 -43
  101. package/dist/chunk-TLBRVWD2.mjs +0 -1
  102. package/dist/chunk-TOOCHDUY.mjs +0 -36
  103. package/dist/chunk-TSKANLT4.mjs +0 -37
  104. package/dist/chunk-UAMZEZUI.mjs +0 -36
  105. package/dist/chunk-UQJ4XNWN.mjs +0 -26
  106. package/dist/chunk-VDSUUXCH.mjs +0 -34
  107. package/dist/chunk-VO7RY2ZK.mjs +0 -44
  108. package/dist/chunk-WJKDFBJ2.mjs +0 -34
  109. package/dist/chunk-WTC7PY7U.mjs +0 -54
  110. package/dist/chunk-WXDV7CMB.mjs +0 -14
  111. package/dist/chunk-X5FG3X6T.mjs +0 -1
  112. package/dist/chunk-X66DY4AZ.mjs +0 -1
  113. package/dist/chunk-XXSJXKWQ.mjs +0 -44
  114. package/dist/chunk-YZMVAQQG.mjs +0 -1
  115. package/dist/chunk-ZCXPZU7W.mjs +0 -20
  116. package/dist/chunk-ZJ4PNVYO.mjs +0 -52
  117. package/dist/chunk-ZU4QJLEY.mjs +0 -53
  118. package/dist/components/ingredients/ingredients-list.d.mts +0 -13
  119. package/dist/components/ingredients/ingredients-list.d.ts +0 -13
  120. package/dist/components/ingredients/ingredients-list.js +0 -2
  121. package/dist/components/ingredients/ingredients-list.mjs +0 -1
  122. package/dist/components/instructions/instruction-list.d.mts +0 -13
  123. package/dist/components/instructions/instruction-list.d.ts +0 -13
  124. package/dist/components/instructions/instruction-list.js +0 -1
  125. package/dist/components/instructions/instruction-list.mjs +0 -1
  126. package/dist/components/layouts/layout-default.d.mts +0 -7
  127. package/dist/components/layouts/layout-default.d.ts +0 -7
  128. package/dist/components/layouts/layout-default.js +0 -1
  129. package/dist/components/layouts/layout-default.mjs +0 -1
  130. package/dist/components/layouts/layout-types.d.mts +0 -8
  131. package/dist/components/layouts/layout-types.d.ts +0 -8
  132. package/dist/components/layouts/layout-types.js +0 -1
  133. package/dist/components/layouts/layout-types.mjs +0 -0
  134. package/dist/components/measurement-select.d.mts +0 -13
  135. package/dist/components/measurement-select.d.ts +0 -13
  136. package/dist/components/measurement-select.js +0 -1
  137. package/dist/components/measurement-select.mjs +0 -1
  138. package/dist/components/root.d.mts +0 -13
  139. package/dist/components/root.d.ts +0 -13
  140. package/dist/components/root.js +0 -1
  141. package/dist/components/root.mjs +0 -1
  142. package/dist/components/servings-select.d.mts +0 -11
  143. package/dist/components/servings-select.d.ts +0 -11
  144. package/dist/components/servings-select.js +0 -1
  145. package/dist/components/servings-select.mjs +0 -1
  146. package/dist/components/thumbnail.d.mts +0 -18
  147. package/dist/components/thumbnail.d.ts +0 -18
  148. package/dist/components/thumbnail.js +0 -1
  149. package/dist/components/thumbnail.mjs +0 -1
  150. package/dist/global-context.d.mts +0 -29
  151. package/dist/global-context.d.ts +0 -29
  152. package/dist/global-context.js +0 -1
  153. package/dist/global-context.mjs +0 -1
  154. package/dist/hooks/use-controllable.d.mts +0 -15
  155. package/dist/hooks/use-controllable.d.ts +0 -15
  156. package/dist/hooks/use-controllable.js +0 -1
  157. package/dist/hooks/use-controllable.mjs +0 -1
  158. package/dist/index.d.mts +0 -10
  159. package/dist/index.mjs +0 -1
  160. package/dist/recipe-context.d.mts +0 -29
  161. package/dist/recipe-context.d.ts +0 -29
  162. package/dist/recipe-context.js +0 -1
  163. package/dist/recipe-context.mjs +0 -1
  164. package/dist/types-from-core.d.mts +0 -1
  165. package/dist/types-from-core.d.ts +0 -1
  166. package/dist/types-from-core.js +0 -1
  167. package/dist/types-from-core.mjs +0 -1
@@ -1,52 +0,0 @@
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
- ingredients.map((ingredient) => ({
37
- ...ingredient,
38
- amount: getIngredientAmount(ingredient, activeConversionKey)
39
- }));
40
- }, [ingredients, activeConversionKey, measurements]);
41
- return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", className: props.className, children: ingredientsWithAmounts.map((ingredient, i) => /* @__PURE__ */ jsxs("li", { "recipe-ingredient": "", children: [
42
- ingredient.name,
43
- " \u2014 ",
44
- ingredient.amount.value,
45
- " ",
46
- ingredient.amount.unit
47
- ] }, i)) });
48
- }
49
-
50
- export {
51
- IngredientList
52
- };
@@ -1,53 +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
- } : (
34
- // if conversion is a string, it's a unit key
35
- ingredient.conversion
36
- )
37
- }))
38
- };
39
- }, [globalConfig, props.recipe, servings]);
40
- return /* @__PURE__ */ jsx(
41
- RecipeContextProvider,
42
- {
43
- recipe,
44
- servings,
45
- setServings,
46
- children: props.children
47
- }
48
- );
49
- }
50
-
51
- export {
52
- Root
53
- };
@@ -1,13 +0,0 @@
1
- type IngredientListProps = {
2
- className?: string;
3
- };
4
- /**
5
- * Renders a list of ingredients from the recipe context.
6
- *
7
- * Stylable with the HTML attributes:
8
- * - `recipe-ingredient-list` (wrapper element)
9
- * - `recipe-ingredient` (ingredient elements)
10
- */
11
- declare function IngredientList(props: IngredientListProps): JSX.Element;
12
-
13
- export { IngredientList };
@@ -1,13 +0,0 @@
1
- type IngredientListProps = {
2
- className?: string;
3
- };
4
- /**
5
- * Renders a list of ingredients from the recipe context.
6
- *
7
- * Stylable with the HTML attributes:
8
- * - `recipe-ingredient-list` (wrapper element)
9
- * - `recipe-ingredient` (ingredient elements)
10
- */
11
- declare function IngredientList(props: IngredientListProps): JSX.Element;
12
-
13
- export { IngredientList };
@@ -1,2 +0,0 @@
1
- var u=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var f=(e,n)=>{for(var t in n)u(e,t,{get:n[t],enumerable:!0})},g=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of l(n))!d.call(e,o)&&o!==t&&u(e,o,{get:()=>n[o],enumerable:!(r=C(n,o))||r.enumerable});return e};var x=e=>g(u({},"__esModule",{value:!0}),e);var P={};f(P,{IngredientList:()=>I});module.exports=x(P);var m=require("@recipe-book/core");var s=require("react"),b=require("react/jsx-runtime"),R=(0,s.createContext)({});function a(){let e=(0,s.useContext)(R);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}var p=require("react"),c=require("react/jsx-runtime");function y(e,n){var r;if(!n)return e.amount;let t=(r=e.conversion)==null?void 0:r[n];if(!t){console.warn(`No conversion found for ingredient "${e.name}" with key "${n}"
2
- Attempting conversion table lookup...`);let o=m.IngredientUtils.convert(e,n);return o?o.amount:e.amount}return t}function I(e){let{ingredients:n,activeConversionKey:t,measurements:r}=a(),o=(0,p.useMemo)(()=>t===r?n:n.map(i=>({...i,amount:y(i,t)})),[n,t,r]);return(0,c.jsx)("ul",{"recipe-ingredient-list":"",className:e.className,children:o.map((i,v)=>(0,c.jsxs)("li",{"recipe-ingredient":"",children:[i.name," \u2014 ",i.amount.value," ",i.amount.unit]},v))})}0&&(module.exports={IngredientList});
@@ -1 +0,0 @@
1
- import{a}from"../../chunk-GM5F7IUT.mjs";import"../../chunk-PBENQR7Y.mjs";export{a as IngredientList};
@@ -1,13 +0,0 @@
1
- type InstructionListProps = {
2
- className?: string;
3
- };
4
- /**
5
- * Renders a list of instructions from the recipe context.
6
- *
7
- * Stylable with the HTML attributes:
8
- * - `recipe-instruction-list` (wrapper element)
9
- * - `recipe-instruction` (instruction elements, value is the instruction number)
10
- */
11
- declare function InstructionList(props: InstructionListProps): JSX.Element;
12
-
13
- export { InstructionList };
@@ -1,13 +0,0 @@
1
- type InstructionListProps = {
2
- className?: string;
3
- };
4
- /**
5
- * Renders a list of instructions from the recipe context.
6
- *
7
- * Stylable with the HTML attributes:
8
- * - `recipe-instruction-list` (wrapper element)
9
- * - `recipe-instruction` (instruction elements, value is the instruction number)
10
- */
11
- declare function InstructionList(props: InstructionListProps): JSX.Element;
12
-
13
- export { InstructionList };
@@ -1 +0,0 @@
1
- var s=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var a=(e,o)=>{for(var t in o)s(e,t,{get:o[t],enumerable:!0})},l=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of v(o))!C.call(e,r)&&r!==t&&s(e,r,{get:()=>o[r],enumerable:!(i=u(o,r))||i.enumerable});return e};var x=e=>l(s({},"__esModule",{value:!0}),e);var f={};a(f,{InstructionList:()=>d});module.exports=x(f);var n=require("react"),m=require("react/jsx-runtime"),R=(0,n.createContext)({});function p(){let e=(0,n.useContext)(R);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}var c=require("react/jsx-runtime");function d(e){let{instructions:o}=p();return(0,c.jsx)("ol",{"recipe-instruction-list":"",className:e.className,children:o.map((t,i)=>(0,c.jsx)("li",{"recipe-instruction":i+1,children:t},i))})}0&&(module.exports={InstructionList});
@@ -1 +0,0 @@
1
- import{a}from"../../chunk-2VMRVR3X.mjs";import"../../chunk-PBENQR7Y.mjs";export{a as InstructionList};
@@ -1,7 +0,0 @@
1
- import { LayoutProps } from './layout-types.mjs';
2
- import 'react';
3
- import '@recipe-book/core';
4
-
5
- declare function DefaultLayout({ children }: LayoutProps): JSX.Element;
6
-
7
- export { DefaultLayout };
@@ -1,7 +0,0 @@
1
- import { LayoutProps } from './layout-types.js';
2
- import 'react';
3
- import '@recipe-book/core';
4
-
5
- declare function DefaultLayout({ children }: LayoutProps): JSX.Element;
6
-
7
- export { DefaultLayout };
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var e=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var n=Object.prototype.hasOwnProperty;var r=(a,o)=>{for(var u in o)l(a,u,{get:o[u],enumerable:!0})},s=(a,o,u,m)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of f(o))!n.call(a,t)&&t!==u&&l(a,t,{get:()=>o[t],enumerable:!(m=e(o,t))||m.enumerable});return a};var y=a=>s(l({},"__esModule",{value:!0}),a);var p={};r(p,{DefaultLayout:()=>d});module.exports=y(p);var i=require("react/jsx-runtime");function d({children:a}){return(0,i.jsx)("div",{className:"default-layout",children:(0,i.jsx)("main",{className:"default-layout__main",children:a})})}0&&(module.exports={DefaultLayout});
@@ -1 +0,0 @@
1
- import{jsx as a}from"react/jsx-runtime";function t({children:o}){return a("div",{className:"default-layout",children:a("main",{className:"default-layout__main",children:o})})}export{t as DefaultLayout};
@@ -1,8 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- import { Recipe } from '@recipe-book/core';
3
-
4
- type LayoutProps = PropsWithChildren & {
5
- recipe: Recipe;
6
- };
7
-
8
- export type { LayoutProps };
@@ -1,8 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- import { Recipe } from '@recipe-book/core';
3
-
4
- type LayoutProps = PropsWithChildren & {
5
- recipe: Recipe;
6
- };
7
-
8
- export type { LayoutProps };
@@ -1 +0,0 @@
1
- var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var s=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let p of m(r))!c.call(e,p)&&p!==t&&o(e,p,{get:()=>r[p],enumerable:!(i=h(r,p))||i.enumerable});return e};var P=e=>s(o({},"__esModule",{value:!0}),e);var d={};module.exports=P(d);
File without changes
@@ -1,13 +0,0 @@
1
- type MeasurementSelectProps = {
2
- className?: string;
3
- };
4
- /**
5
- * A component that allows the user to select between US and metric
6
- * measurements.
7
- *
8
- * TODO - Rename this component
9
- * TODO - Allow more robust styling, fully composable with className
10
- */
11
- declare function MeasurementSelect(props: MeasurementSelectProps): JSX.Element;
12
-
13
- export { MeasurementSelect };
@@ -1,13 +0,0 @@
1
- type MeasurementSelectProps = {
2
- className?: string;
3
- };
4
- /**
5
- * A component that allows the user to select between US and metric
6
- * measurements.
7
- *
8
- * TODO - Rename this component
9
- * TODO - Allow more robust styling, fully composable with className
10
- */
11
- declare function MeasurementSelect(props: MeasurementSelectProps): JSX.Element;
12
-
13
- export { MeasurementSelect };
@@ -1 +0,0 @@
1
- var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var v=(e,t)=>{for(var o in t)c(e,o,{get:t[o],enumerable:!0})},C=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of p(t))!m.call(e,r)&&r!==o&&c(e,r,{get:()=>t[r],enumerable:!(s=u(t,r))||s.enumerable});return e};var l=e=>C(c({},"__esModule",{value:!0}),e);var b={};v(b,{MeasurementSelect:()=>R});module.exports=l(b);var n=require("react"),x=require("react/jsx-runtime"),d=(0,n.createContext)({});function a(){let e=(0,n.useContext)(d);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}var i=require("react/jsx-runtime");function R(e){let{activeConversionKey:t,setConversionKey:o,measurements:s}=a();if(s===void 0)throw new Error("Cannot select measurement without base measurement");return(0,i.jsxs)("div",{"recipe-measurement-select":"",className:e.className,children:[(0,i.jsx)("button",{"recipe-measurement-option":"","data-active":t==="us-customary",onClick:()=>o("us-customary"),children:"US"}),(0,i.jsx)("button",{"recipe-measurement-option":"","data-active":t==="metric",onClick:()=>o("metric"),children:"Metric"})]})}0&&(module.exports={MeasurementSelect});
@@ -1 +0,0 @@
1
- import{a}from"../chunk-TLBRVWD2.mjs";import"../chunk-PBENQR7Y.mjs";export{a as MeasurementSelect};
@@ -1,13 +0,0 @@
1
- import { RecipeConfig } from '@recipe-book/core';
2
- import { PropsWithChildren } from 'react';
3
-
4
- type RootProps = PropsWithChildren & {
5
- recipe?: RecipeConfig;
6
- };
7
- /**
8
- * Provides recipe data to children for rendering. Inherits configuration
9
- * from the global recipe config if available.
10
- */
11
- declare function Root(props: RootProps): JSX.Element;
12
-
13
- export { Root };
@@ -1,13 +0,0 @@
1
- import { RecipeConfig } from '@recipe-book/core';
2
- import { PropsWithChildren } from 'react';
3
-
4
- type RootProps = PropsWithChildren & {
5
- recipe?: RecipeConfig;
6
- };
7
- /**
8
- * Provides recipe data to children for rendering. Inherits configuration
9
- * from the global recipe config if available.
10
- */
11
- declare function Root(props: RootProps): JSX.Element;
12
-
13
- export { Root };
@@ -1 +0,0 @@
1
- var C=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var P=(o,e)=>{for(var n in e)C(o,n,{get:e[n],enumerable:!0})},g=(o,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of b(e))!d.call(o,t)&&t!==n&&C(o,t,{get:()=>e[t],enumerable:!(i=R(e,t))||i.enumerable});return o};var G=o=>g(C({},"__esModule",{value:!0}),o);var T={};P(T,{Root:()=>S});module.exports=G(T);var f=require("@recipe-book/core"),a=require("react");var s=require("react"),u=require("react/jsx-runtime"),y=(0,s.createContext)({});function v({children:o,recipe:e,servings:n,setServings:i}){let[t,c]=(0,s.useState)(e.measurements),p=(0,s.useMemo)(()=>({...e,activeConversionKey:t,setConversionKey:r=>{c(r)},servings:n,setServings:i}),[e,t,c,n,i]);return(0,u.jsx)(y.Provider,{value:p,children:o})}var l=require("react"),K=require("react/jsx-runtime"),h=(0,l.createContext)({});function x(){let o=(0,l.useContext)(h);return o||{config:{}}}var m=require("react/jsx-runtime");function S(o){let[e,n]=(0,a.useState)(1),{config:i}=x(),t=(0,a.useMemo)(()=>{let c={...i,...o.recipe},p=f.RecipeUtils.create(c);return{...p,ingredients:p.ingredients.map(r=>({...r,amount:{...r.amount,value:r.amount.value*e},conversion:typeof r.conversion=="object"?{...r.conversion,[c.measurements]:r.amount.value*e}:r.conversion}))}},[i,o.recipe,e]);return(0,m.jsx)(v,{recipe:t,servings:e,setServings:n,children:o.children})}0&&(module.exports={Root});
@@ -1 +0,0 @@
1
- import{a}from"../chunk-PTS3BZHK.mjs";import"../chunk-Q6I5J3IJ.mjs";import"../chunk-PBENQR7Y.mjs";export{a as Root};
@@ -1,11 +0,0 @@
1
- type ServingsSelectProps = {
2
- className?: string | undefined;
3
- };
4
- /**
5
- * Select component for choosing the number of servings.
6
- * TODO: Rename this component
7
- * TODO: Add preset props, inherit from global
8
- */
9
- declare function ServingsSelect(props: ServingsSelectProps): JSX.Element;
10
-
11
- export { ServingsSelect };
@@ -1,11 +0,0 @@
1
- type ServingsSelectProps = {
2
- className?: string | undefined;
3
- };
4
- /**
5
- * Select component for choosing the number of servings.
6
- * TODO: Rename this component
7
- * TODO: Add preset props, inherit from global
8
- */
9
- declare function ServingsSelect(props: ServingsSelectProps): JSX.Element;
10
-
11
- export { ServingsSelect };
@@ -1 +0,0 @@
1
- var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var C=(e,o)=>{for(var t in o)c(e,t,{get:o[t],enumerable:!0})},l=(e,o,t,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let i of a(o))!u.call(e,i)&&i!==t&&c(e,i,{get:()=>o[i],enumerable:!(n=p(o,i))||n.enumerable});return e};var x=e=>l(c({},"__esModule",{value:!0}),e);var f={};C(f,{ServingsSelect:()=>d});module.exports=x(f);var r=require("react"),g=require("react/jsx-runtime"),R=(0,r.createContext)({});function v(){let e=(0,r.useContext)(R);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}var s=require("react/jsx-runtime"),m=[.5,1,2,3];function d(e){let{servings:o,setServings:t}=v();return(0,s.jsx)("select",{className:e.className,"recipe-servings-select":"",value:o,onChange:n=>{t(Number(n.target.value))},children:m.map(n=>(0,s.jsxs)("option",{value:n,children:[n," serving",n!==1?"s":""]},n))})}0&&(module.exports={ServingsSelect});
@@ -1 +0,0 @@
1
- import{a}from"../chunk-X66DY4AZ.mjs";import"../chunk-PBENQR7Y.mjs";export{a as ServingsSelect};
@@ -1,18 +0,0 @@
1
- type ThumbnailProps = {
2
- alt?: string;
3
- aspectRatio?: number;
4
- className?: string;
5
- style?: React.CSSProperties;
6
- };
7
- /**
8
- * Renders a thumbnail image from the recipe context. The image is
9
- * automatically cropped to a square, but can be overridden with the
10
- * `aspectRatio` prop.
11
- *
12
- * Stylable with the HTML attributes:
13
- * - `recipe-thumbnail` (wrapper element)
14
- * - `recipe-thumbnail-image` (<img /> element)
15
- */
16
- declare function Thumbnail(props: ThumbnailProps): JSX.Element;
17
-
18
- export { Thumbnail };
@@ -1,18 +0,0 @@
1
- type ThumbnailProps = {
2
- alt?: string;
3
- aspectRatio?: number;
4
- className?: string;
5
- style?: React.CSSProperties;
6
- };
7
- /**
8
- * Renders a thumbnail image from the recipe context. The image is
9
- * automatically cropped to a square, but can be overridden with the
10
- * `aspectRatio` prop.
11
- *
12
- * Stylable with the HTML attributes:
13
- * - `recipe-thumbnail` (wrapper element)
14
- * - `recipe-thumbnail-image` (<img /> element)
15
- */
16
- declare function Thumbnail(props: ThumbnailProps): JSX.Element;
17
-
18
- export { Thumbnail };
@@ -1 +0,0 @@
1
- var s=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var i in t)s(e,i,{get:t[i],enumerable:!0})},R=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of m(t))!v.call(e,o)&&o!==i&&s(e,o,{get:()=>t[o],enumerable:!(r=l(t,o))||r.enumerable});return e};var b=e=>R(s({},"__esModule",{value:!0}),e);var g={};C(g,{Thumbnail:()=>d});module.exports=b(g);var u=require("@radix-ui/react-aspect-ratio");var n=require("react"),y=require("react/jsx-runtime"),x=(0,n.createContext)({});function p(){let e=(0,n.useContext)(x);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}var c=require("react/jsx-runtime");function d(e){var o,a;let{thumbnail:t,name:i}=p();if(!t)throw new Error("Missing thumbnail image. Did you forget to set one?");let r=(o=e.style)!=null?o:{};return(0,c.jsx)(u.AspectRatio,{"recipe-thumbnail":"",className:e.className,style:{width:"100%",...r},ratio:e.aspectRatio||1,children:(0,c.jsx)("img",{"recipe-thumbnail-image":"",style:{objectFit:"cover",width:"100%",height:"100%"},src:t,alt:(a=e.alt)!=null?a:i})})}0&&(module.exports={Thumbnail});
@@ -1 +0,0 @@
1
- import{a}from"../chunk-4XBZKTOL.mjs";import"../chunk-PBENQR7Y.mjs";export{a as Thumbnail};
@@ -1,29 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import { GlobalRecipeConfig } from '@recipe-book/core';
4
-
5
- type GlobalContext = {
6
- config: GlobalRecipeConfig;
7
- };
8
- /** The global `recipe-book` context. */
9
- declare const GlobalContext: react.Context<GlobalContext>;
10
- /**
11
- * Hook to access the global `recipe-book` context.
12
- */
13
- declare function useGlobalContext(): {
14
- readonly config: {};
15
- };
16
- interface GlobalContextProviderProps {
17
- children: ReactNode;
18
- config: GlobalRecipeConfig;
19
- }
20
- /**
21
- * Provider for the global `recipe-book` context. This provider
22
- * is used to create a global configuration that is inherited
23
- * by individual recipe `Root`s.
24
- *
25
- * @param props -- The global configuration to be used by all recipes
26
- */
27
- declare function GlobalContextProvider({ children, config, }: GlobalContextProviderProps): JSX.Element;
28
-
29
- export { GlobalContext, GlobalContextProvider, useGlobalContext };
@@ -1,29 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import { GlobalRecipeConfig } from '@recipe-book/core';
4
-
5
- type GlobalContext = {
6
- config: GlobalRecipeConfig;
7
- };
8
- /** The global `recipe-book` context. */
9
- declare const GlobalContext: react.Context<GlobalContext>;
10
- /**
11
- * Hook to access the global `recipe-book` context.
12
- */
13
- declare function useGlobalContext(): {
14
- readonly config: {};
15
- };
16
- interface GlobalContextProviderProps {
17
- children: ReactNode;
18
- config: GlobalRecipeConfig;
19
- }
20
- /**
21
- * Provider for the global `recipe-book` context. This provider
22
- * is used to create a global configuration that is inherited
23
- * by individual recipe `Root`s.
24
- *
25
- * @param props -- The global configuration to be used by all recipes
26
- */
27
- declare function GlobalContextProvider({ children, config, }: GlobalContextProviderProps): JSX.Element;
28
-
29
- export { GlobalContext, GlobalContextProvider, useGlobalContext };
@@ -1 +0,0 @@
1
- var r=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var C=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var G=(o,t)=>{for(var n in t)r(o,n,{get:t[n],enumerable:!0})},f=(o,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of C(t))!b.call(o,e)&&e!==n&&r(o,e,{get:()=>t[e],enumerable:!(a=x(t,e))||a.enumerable});return o};var p=o=>f(r({},"__esModule",{value:!0}),o);var u={};G(u,{GlobalContext:()=>i,GlobalContextProvider:()=>s,useGlobalContext:()=>d});module.exports=p(u);var l=require("react"),c=require("react/jsx-runtime"),i=(0,l.createContext)({});function d(){let o=(0,l.useContext)(i);return o||{config:{}}}function s({children:o,config:t}){return(0,c.jsx)(i.Provider,{value:{config:t},children:o})}0&&(module.exports={GlobalContext,GlobalContextProvider,useGlobalContext});
@@ -1 +0,0 @@
1
- import{a,b,c}from"./chunk-Q6I5J3IJ.mjs";export{a as GlobalContext,c as GlobalContextProvider,b as useGlobalContext};
@@ -1,15 +0,0 @@
1
- type UseControllableParams<T> = {
2
- props?: T | undefined;
3
- defaultProps?: T | undefined;
4
- onChange?: (value: T) => void | undefined;
5
- };
6
- /**
7
- * Hook for creating a controlled component. This hook is used to create
8
- * controlled components that can be used with or without a value prop.
9
- */
10
- declare function useControllable<T>({ props, defaultProps, onChange, }: UseControllableParams<T>): {
11
- value: T;
12
- onChange: (value: T) => void;
13
- };
14
-
15
- export { useControllable };
@@ -1,15 +0,0 @@
1
- type UseControllableParams<T> = {
2
- props?: T | undefined;
3
- defaultProps?: T | undefined;
4
- onChange?: (value: T) => void | undefined;
5
- };
6
- /**
7
- * Hook for creating a controlled component. This hook is used to create
8
- * controlled components that can be used with or without a value prop.
9
- */
10
- declare function useControllable<T>({ props, defaultProps, onChange, }: UseControllableParams<T>): {
11
- value: T;
12
- onChange: (value: T) => void;
13
- };
14
-
15
- export { useControllable };
@@ -1 +0,0 @@
1
- var t=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var i=Object.getOwnPropertyNames;var f=Object.prototype.hasOwnProperty;var T=(n,e)=>{for(var l in e)t(n,l,{get:e[l],enumerable:!0})},C=(n,e,l,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of i(e))!f.call(n,o)&&o!==l&&t(n,o,{get:()=>e[o],enumerable:!(a=s(e,o))||a.enumerable});return n};var c=n=>C(t({},"__esModule",{value:!0}),n);var m={};T(m,{useControllable:()=>h});module.exports=c(m);var r=require("react");function h({props:n,defaultProps:e,onChange:l}){let[a,o]=(0,r.useState)(e),d=n!==void 0;return{value:d?n:a,onChange:d?l:u=>{o(u),l&&l(u)}}}0&&(module.exports={useControllable});
@@ -1 +0,0 @@
1
- import{useState as u}from"react";function i({props:n,defaultProps:a,onChange:e}){let[t,d]=u(a),l=n!==void 0;return{value:l?n:t,onChange:l?e:o=>{d(o),e&&e(o)}}}export{i as useControllable};
package/dist/index.d.mts DELETED
@@ -1,10 +0,0 @@
1
- export { Root as RecipeRoot, Root } from './components/root.mjs';
2
- export { IngredientList, IngredientList as RecipeIngredientList } from './components/ingredients/ingredients-list.mjs';
3
- export { InstructionList, InstructionList as RecipeInstructionList } from './components/instructions/instruction-list.mjs';
4
- export { Thumbnail as RecipeThumbnail, Thumbnail } from './components/thumbnail.mjs';
5
- export { ServingsSelect as RecipeServingsSelect, ServingsSelect } from './components/servings-select.mjs';
6
- export { MeasurementSelect, MeasurementSelect as RecipeMeasurementSelect } from './components/measurement-select.mjs';
7
- export { useRecipeContext as useRecipe } from './recipe-context.mjs';
8
- export { GlobalContextProvider as Provider } from './global-context.mjs';
9
- export { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from '@recipe-book/core';
10
- import 'react';
package/dist/index.mjs DELETED
@@ -1 +0,0 @@
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,29 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { RecipeConfig, ConversionTables, Recipe } from '@recipe-book/core';
3
-
4
- type RecipeContext = RecipeConfig & {
5
- activeConversionKey: ConversionTables;
6
- setConversionKey: (key: ConversionTables) => void;
7
- servings: number;
8
- setServings: (value: number) => void;
9
- };
10
- /**
11
- * Hook to access the recipe context.
12
- */
13
- declare function useRecipeContext(): RecipeContext;
14
- interface RecipeContextProviderProps {
15
- children: ReactNode;
16
- recipe: Recipe;
17
- servings: number;
18
- setServings: (value: number) => void;
19
- }
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;
28
-
29
- export { type RecipeContext, RecipeContextProvider, useRecipeContext };
@@ -1,29 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { RecipeConfig, ConversionTables, Recipe } from '@recipe-book/core';
3
-
4
- type RecipeContext = RecipeConfig & {
5
- activeConversionKey: ConversionTables;
6
- setConversionKey: (key: ConversionTables) => void;
7
- servings: number;
8
- setServings: (value: number) => void;
9
- };
10
- /**
11
- * Hook to access the recipe context.
12
- */
13
- declare function useRecipeContext(): RecipeContext;
14
- interface RecipeContextProviderProps {
15
- children: ReactNode;
16
- recipe: Recipe;
17
- servings: number;
18
- setServings: (value: number) => void;
19
- }
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;
28
-
29
- export { type RecipeContext, RecipeContextProvider, useRecipeContext };
@@ -1 +0,0 @@
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 +0,0 @@
1
- import{a,b}from"./chunk-PBENQR7Y.mjs";export{b as RecipeContextProvider,a as useRecipeContext};
@@ -1 +0,0 @@
1
- export { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from '@recipe-book/core';
@@ -1 +0,0 @@
1
- export { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from '@recipe-book/core';
@@ -1 +0,0 @@
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);
@@ -1 +0,0 @@
1
- import"./chunk-I5TR6PEA.mjs";