@recipe-book/react 0.0.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 (54) hide show
  1. package/README.md +23 -0
  2. package/dist/chunk-32VQC2BE.mjs +1 -0
  3. package/dist/chunk-6MAELCYD.mjs +1 -0
  4. package/dist/chunk-CB36WMX5.mjs +24 -0
  5. package/dist/chunk-FPLGEKN7.mjs +24 -0
  6. package/dist/chunk-GPTC24DR.mjs +1 -0
  7. package/dist/chunk-J5PZAYLW.mjs +45 -0
  8. package/dist/chunk-JTZVD7JV.mjs +20 -0
  9. package/dist/chunk-KYWBOSOP.mjs +14 -0
  10. package/dist/chunk-M5D3UUZF.mjs +19 -0
  11. package/dist/chunk-MBR257HS.mjs +48 -0
  12. package/dist/chunk-PLID2R4K.mjs +48 -0
  13. package/dist/chunk-PYOGNEQ3.mjs +48 -0
  14. package/dist/chunk-QOCKR2HO.mjs +1 -0
  15. package/dist/chunk-RZGBB6SL.mjs +1 -0
  16. package/dist/chunk-T6BBQT4K.mjs +44 -0
  17. package/dist/chunk-U7TL6PST.mjs +1 -0
  18. package/dist/components/ingredients/ingredients-list.d.mts +10 -0
  19. package/dist/components/ingredients/ingredients-list.d.ts +10 -0
  20. package/dist/components/ingredients/ingredients-list.js +1 -0
  21. package/dist/components/ingredients/ingredients-list.mjs +1 -0
  22. package/dist/components/instructions/instruction-list.d.mts +10 -0
  23. package/dist/components/instructions/instruction-list.d.ts +10 -0
  24. package/dist/components/instructions/instruction-list.js +1 -0
  25. package/dist/components/instructions/instruction-list.mjs +1 -0
  26. package/dist/components/layouts/layout-default.d.mts +7 -0
  27. package/dist/components/layouts/layout-default.d.ts +7 -0
  28. package/dist/components/layouts/layout-default.js +1 -0
  29. package/dist/components/layouts/layout-default.mjs +1 -0
  30. package/dist/components/layouts/layout-types.d.mts +8 -0
  31. package/dist/components/layouts/layout-types.d.ts +8 -0
  32. package/dist/components/layouts/layout-types.js +1 -0
  33. package/dist/components/layouts/layout-types.mjs +0 -0
  34. package/dist/components/root.d.mts +12 -0
  35. package/dist/components/root.d.ts +12 -0
  36. package/dist/components/root.js +1 -0
  37. package/dist/components/root.mjs +1 -0
  38. package/dist/components/thumbnail.d.mts +18 -0
  39. package/dist/components/thumbnail.d.ts +18 -0
  40. package/dist/components/thumbnail.js +1 -0
  41. package/dist/components/thumbnail.mjs +1 -0
  42. package/dist/global-context.d.mts +16 -0
  43. package/dist/global-context.d.ts +16 -0
  44. package/dist/global-context.js +1 -0
  45. package/dist/global-context.mjs +1 -0
  46. package/dist/index.d.mts +8 -0
  47. package/dist/index.d.ts +8 -0
  48. package/dist/index.js +1 -0
  49. package/dist/index.mjs +1 -0
  50. package/dist/recipe-context.d.mts +14 -0
  51. package/dist/recipe-context.d.ts +14 -0
  52. package/dist/recipe-context.js +1 -0
  53. package/dist/recipe-context.mjs +1 -0
  54. package/package.json +29 -0
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @recipe-book/react
2
+
3
+ Unstyled, accessible, compound React components for displaying recipes
4
+
5
+ ## Core concepts
6
+
7
+ ### Compound structure
8
+
9
+ Recipe components are designed to be used as building blocks for displaying recipes. They are unstyled, and can be composed together to create a custom recipe interface.
10
+
11
+ ```jsx
12
+ function MyRecipeComponent() {
13
+ <Recipe.Root>
14
+ <Recipe.Thumbnail />
15
+ <h3>Ingredients</h3>
16
+ <Recipe.Ingredients />
17
+ <h3>Instructions</h3>
18
+ <Recipe.Instructions renderer={(instruction) => <MyInstructionComponent {...instruction}>} />
19
+ <hr />
20
+ <RecipeNotes />
21
+ </Recipe.Root>
22
+ }
23
+ ```
@@ -0,0 +1 @@
1
+ import{createContext as n,useContext as i}from"react";import{jsx as r}from"react/jsx-runtime";var t=n({});function x(){let e=i(t);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}function R({children:e,config:o}){return r(t.Provider,{value:{config:o},children:e})}export{x as a,R as b};
@@ -0,0 +1 @@
1
+ import{b as n}from"./chunk-QOCKR2HO.mjs";import{b as t}from"./chunk-32VQC2BE.mjs";import{useMemo as e}from"react";import{jsx as f}from"react/jsx-runtime";function C(o){let{config:i}=n(),r=e(()=>({...i,...o.config}),[i,o.config]);return f(t,{config:r,children:o.children})}export{C as a};
@@ -0,0 +1,24 @@
1
+ // src/recipe-context.tsx
2
+ import { createContext, useContext } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ var RecipeContext = createContext(
5
+ {}
6
+ );
7
+ function useRecipeContext() {
8
+ const ctx = useContext(RecipeContext);
9
+ if (!ctx) {
10
+ throw new Error("Missing recipe context. Are you using <Recipe.Root />?");
11
+ }
12
+ return ctx;
13
+ }
14
+ function RecipeContextProvider({
15
+ children,
16
+ config
17
+ }) {
18
+ return /* @__PURE__ */ jsx(RecipeContext.Provider, { value: { config }, children });
19
+ }
20
+
21
+ export {
22
+ useRecipeContext,
23
+ RecipeContextProvider
24
+ };
@@ -0,0 +1,24 @@
1
+ import {
2
+ useGlobalContext
3
+ } from "./chunk-M5D3UUZF.mjs";
4
+ import {
5
+ RecipeContextProvider
6
+ } from "./chunk-CB36WMX5.mjs";
7
+
8
+ // src/components/root.tsx
9
+ import { useMemo } from "react";
10
+ import { jsx } from "react/jsx-runtime";
11
+ function Root(props) {
12
+ const { config: globalConfig } = useGlobalContext();
13
+ const finalConfig = useMemo(() => {
14
+ return {
15
+ ...globalConfig,
16
+ ...props.config
17
+ };
18
+ }, [globalConfig, props.config]);
19
+ return /* @__PURE__ */ jsx(RecipeContextProvider, { config: finalConfig, children: props.children });
20
+ }
21
+
22
+ export {
23
+ Root
24
+ };
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-32VQC2BE.mjs";import{jsx as n}from"react/jsx-runtime";function r(){let{config:o}=t();return n("ul",{"recipe-instruction-list":"",children:o.instructions.map((c,i)=>n("li",{"recipe-instruction":i+1,children:c},i))})}export{r as a};
@@ -0,0 +1,45 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-CB36WMX5.mjs";
4
+
5
+ // src/components/thumbnail.tsx
6
+ import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function Thumbnail(props) {
9
+ var _a, _b;
10
+ const { config } = useRecipeContext();
11
+ if (!config.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
+ ref,
20
+ className: props.className,
21
+ style: {
22
+ width: "100%",
23
+ ...propStyle
24
+ },
25
+ ratio: props.aspectRatio || 1,
26
+ children: /* @__PURE__ */ jsx(
27
+ "img",
28
+ {
29
+ "recipe-thumbnail-image": "",
30
+ style: {
31
+ objectFit: "cover",
32
+ width: "100%",
33
+ height: "100%"
34
+ },
35
+ src: config.thumbnail,
36
+ alt: (_b = props.alt) != null ? _b : config.name
37
+ }
38
+ )
39
+ }
40
+ );
41
+ }
42
+
43
+ export {
44
+ Thumbnail
45
+ };
@@ -0,0 +1,20 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-CB36WMX5.mjs";
4
+
5
+ // src/components/ingredients/ingredients-list.tsx
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ function IngredientList() {
8
+ const { config } = useRecipeContext();
9
+ return /* @__PURE__ */ jsx("ul", { "recipe-ingredient-list": "", children: config.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
+ };
@@ -0,0 +1,14 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-CB36WMX5.mjs";
4
+
5
+ // src/components/instructions/instruction-list.tsx
6
+ import { jsx } from "react/jsx-runtime";
7
+ function InstructionList() {
8
+ const { config } = useRecipeContext();
9
+ return /* @__PURE__ */ jsx("ul", { "recipe-instruction-list": "", children: config.instructions.map((instruction, i) => /* @__PURE__ */ jsx("li", { "recipe-instruction": i + 1, children: instruction }, i)) });
10
+ }
11
+
12
+ export {
13
+ InstructionList
14
+ };
@@ -0,0 +1,19 @@
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
+ return useContext(GlobalContext);
7
+ }
8
+ function GlobalContextProvider({
9
+ children,
10
+ config
11
+ }) {
12
+ return /* @__PURE__ */ jsx(GlobalContext.Provider, { value: { config }, children });
13
+ }
14
+
15
+ export {
16
+ GlobalContext,
17
+ useGlobalContext,
18
+ GlobalContextProvider
19
+ };
@@ -0,0 +1,48 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-CB36WMX5.mjs";
4
+
5
+ // src/components/thumbnail.tsx
6
+ import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
+ import { forwardRef } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var Thumbnail = forwardRef(
10
+ (props, ref) => {
11
+ var _a, _b;
12
+ const { config } = useRecipeContext();
13
+ if (!config.thumbnail) {
14
+ throw new Error("Missing thumbnail image. Did you forget to set one?");
15
+ }
16
+ const propStyle = (_a = props.style) != null ? _a : {};
17
+ return /* @__PURE__ */ jsx(
18
+ AspectRatio,
19
+ {
20
+ "recipe-thumbnail": true,
21
+ ref,
22
+ className: props.className,
23
+ style: {
24
+ width: "100%",
25
+ ...propStyle
26
+ },
27
+ ratio: props.aspectRatio || 1,
28
+ children: /* @__PURE__ */ jsx(
29
+ "img",
30
+ {
31
+ "recipe-thumbnail-image": true,
32
+ style: {
33
+ objectFit: "cover",
34
+ width: "100%",
35
+ height: "100%"
36
+ },
37
+ src: config.thumbnail,
38
+ alt: (_b = props.alt) != null ? _b : config.name
39
+ }
40
+ )
41
+ }
42
+ );
43
+ }
44
+ );
45
+
46
+ export {
47
+ Thumbnail
48
+ };
@@ -0,0 +1,48 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-CB36WMX5.mjs";
4
+
5
+ // src/components/thumbnail.tsx
6
+ import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
+ import { forwardRef } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var Thumbnail = forwardRef(
10
+ (props, ref) => {
11
+ var _a, _b;
12
+ const { config } = useRecipeContext();
13
+ if (!config.thumbnail) {
14
+ throw new Error("Missing thumbnail image. Did you forget to set one?");
15
+ }
16
+ const propStyle = (_a = props.style) != null ? _a : {};
17
+ return /* @__PURE__ */ jsx(
18
+ AspectRatio,
19
+ {
20
+ "recipe-thumbnail": "",
21
+ ref,
22
+ className: props.className,
23
+ style: {
24
+ width: "100%",
25
+ ...propStyle
26
+ },
27
+ ratio: props.aspectRatio || 1,
28
+ children: /* @__PURE__ */ jsx(
29
+ "img",
30
+ {
31
+ "recipe-thumbnail-image": true,
32
+ style: {
33
+ objectFit: "cover",
34
+ width: "100%",
35
+ height: "100%"
36
+ },
37
+ src: config.thumbnail,
38
+ alt: (_b = props.alt) != null ? _b : config.name
39
+ }
40
+ )
41
+ }
42
+ );
43
+ }
44
+ );
45
+
46
+ export {
47
+ Thumbnail
48
+ };
@@ -0,0 +1,48 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-CB36WMX5.mjs";
4
+
5
+ // src/components/thumbnail.tsx
6
+ import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
+ import { forwardRef } from "react";
8
+ import { jsx } from "react/jsx-runtime";
9
+ var Thumbnail = forwardRef(
10
+ (props, ref) => {
11
+ var _a, _b;
12
+ const { config } = useRecipeContext();
13
+ if (!config.thumbnail) {
14
+ throw new Error("Missing thumbnail image. Did you forget to set one?");
15
+ }
16
+ const propStyle = (_a = props.style) != null ? _a : {};
17
+ return /* @__PURE__ */ jsx(
18
+ AspectRatio,
19
+ {
20
+ "recipe-thumbnail": "",
21
+ ref,
22
+ className: props.className,
23
+ style: {
24
+ width: "100%",
25
+ ...propStyle
26
+ },
27
+ ratio: props.aspectRatio || 1,
28
+ children: /* @__PURE__ */ jsx(
29
+ "img",
30
+ {
31
+ "recipe-thumbnail-image": "",
32
+ style: {
33
+ objectFit: "cover",
34
+ width: "100%",
35
+ height: "100%"
36
+ },
37
+ src: config.thumbnail,
38
+ alt: (_b = props.alt) != null ? _b : config.name
39
+ }
40
+ )
41
+ }
42
+ );
43
+ }
44
+ );
45
+
46
+ export {
47
+ Thumbnail
48
+ };
@@ -0,0 +1 @@
1
+ import{createContext as l,useContext as n}from"react";import{jsx as r}from"react/jsx-runtime";var o=l({});function C(){return n(o)}function x({children:e,config:t}){return r(o.Provider,{value:{config:t},children:e})}export{o as a,C as b,x as c};
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-32VQC2BE.mjs";import{AspectRatio as m}from"@radix-ui/react-aspect-ratio";import{jsx as r}from"react/jsx-runtime";function c(t){var i,a;let{config:e}=o();if(!e.thumbnail)throw new Error("Missing thumbnail image. Did you forget to set one?");let s=(i=t.style)!=null?i:{};return r(m,{"recipe-thumbnail":"",className:t.className,style:{width:"100%",...s},ratio:t.aspectRatio||1,children:r("img",{"recipe-thumbnail-image":"",style:{objectFit:"cover",width:"100%",height:"100%"},src:e.thumbnail,alt:(a=t.alt)!=null?a:e.name})})}export{c as a};
@@ -0,0 +1,44 @@
1
+ import {
2
+ useRecipeContext
3
+ } from "./chunk-CB36WMX5.mjs";
4
+
5
+ // src/components/thumbnail.tsx
6
+ import { AspectRatio } from "@radix-ui/react-aspect-ratio";
7
+ import { jsx } from "react/jsx-runtime";
8
+ function Thumbnail(props) {
9
+ var _a, _b;
10
+ const { config } = useRecipeContext();
11
+ if (!config.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: config.thumbnail,
35
+ alt: (_b = props.alt) != null ? _b : config.name
36
+ }
37
+ )
38
+ }
39
+ );
40
+ }
41
+
42
+ export {
43
+ Thumbnail
44
+ };
@@ -0,0 +1 @@
1
+ import{a as i}from"./chunk-32VQC2BE.mjs";import{jsx as u,jsxs as o}from"react/jsx-runtime";function l(){let{config:n}=i();return u("ul",{"recipe-ingredient-list":"",children:n.ingredients.map((e,t)=>o("li",{"recipe-ingredient":"",children:[e.name," \u2014 ",e.amount.value," ",e.amount.unit]},t))})}export{l as a};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Renders a list of ingredients from the recipe context.
3
+ *
4
+ * Stylable with the HTML attributes:
5
+ * - `recipe-ingredient-list` (wrapper element)
6
+ * - `recipe-ingredient` (ingredient elements)
7
+ */
8
+ declare function IngredientList(): JSX.Element;
9
+
10
+ export { IngredientList };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Renders a list of ingredients from the recipe context.
3
+ *
4
+ * Stylable with the HTML attributes:
5
+ * - `recipe-ingredient-list` (wrapper element)
6
+ * - `recipe-ingredient` (ingredient elements)
7
+ */
8
+ declare function IngredientList(): JSX.Element;
9
+
10
+ export { IngredientList };
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var C=(t,e)=>{for(var o in e)c(t,o,{get:e[o],enumerable:!0})},d=(t,e,o,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of R(e))!u.call(t,n)&&n!==o&&c(t,n,{get:()=>e[n],enumerable:!(p=x(e,n))||p.enumerable});return t};var f=t=>d(c({},"__esModule",{value:!0}),t);var l={};C(l,{IngredientList:()=>m});module.exports=f(l);var i=require("react"),a=require("react/jsx-runtime"),g=(0,i.createContext)({});function s(){let t=(0,i.useContext)(g);if(!t)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return t}var r=require("react/jsx-runtime");function m(){let{config:t}=s();return(0,r.jsx)("ul",{"recipe-ingredient-list":"",children:t.ingredients.map((e,o)=>(0,r.jsxs)("li",{"recipe-ingredient":"",children:[e.name," \u2014 ",e.amount.value," ",e.amount.unit]},o))})}0&&(module.exports={IngredientList});
@@ -0,0 +1 @@
1
+ import{a}from"../../chunk-U7TL6PST.mjs";import"../../chunk-32VQC2BE.mjs";export{a as IngredientList};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Renders a list of instructions from the recipe context.
3
+ *
4
+ * Stylable with the HTML attributes:
5
+ * - `recipe-instruction-list` (wrapper element)
6
+ * - `recipe-instruction` (instruction elements, value is the instruction number)
7
+ */
8
+ declare function InstructionList(): JSX.Element;
9
+
10
+ export { InstructionList };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Renders a list of instructions from the recipe context.
3
+ *
4
+ * Stylable with the HTML attributes:
5
+ * - `recipe-instruction-list` (wrapper element)
6
+ * - `recipe-instruction` (instruction elements, value is the instruction number)
7
+ */
8
+ declare function InstructionList(): JSX.Element;
9
+
10
+ export { InstructionList };
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var C=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},f=(e,t,o,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of R(t))!u.call(e,i)&&i!==o&&r(e,i,{get:()=>t[i],enumerable:!(p=x(t,i))||p.enumerable});return e};var d=e=>f(r({},"__esModule",{value:!0}),e);var P={};C(P,{InstructionList:()=>l});module.exports=d(P);var n=require("react"),a=require("react/jsx-runtime"),g=(0,n.createContext)({});function s(){let e=(0,n.useContext)(g);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}var c=require("react/jsx-runtime");function l(){let{config:e}=s();return(0,c.jsx)("ul",{"recipe-instruction-list":"",children:e.instructions.map((t,o)=>(0,c.jsx)("li",{"recipe-instruction":o+1,children:t},o))})}0&&(module.exports={InstructionList});
@@ -0,0 +1 @@
1
+ import{a}from"../../chunk-GPTC24DR.mjs";import"../../chunk-32VQC2BE.mjs";export{a as InstructionList};
@@ -0,0 +1,7 @@
1
+ import { LayoutProps } from './layout-types.mjs';
2
+ import 'react';
3
+ import 'recipe-core';
4
+
5
+ declare function DefaultLayout({ children }: LayoutProps): JSX.Element;
6
+
7
+ export { DefaultLayout };
@@ -0,0 +1,7 @@
1
+ import { LayoutProps } from './layout-types.js';
2
+ import 'react';
3
+ import 'recipe-core';
4
+
5
+ declare function DefaultLayout({ children }: LayoutProps): JSX.Element;
6
+
7
+ export { DefaultLayout };
@@ -0,0 +1 @@
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});
@@ -0,0 +1 @@
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};
@@ -0,0 +1,8 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { Recipe } from 'recipe-core';
3
+
4
+ type LayoutProps = PropsWithChildren & {
5
+ recipe: Recipe<any>;
6
+ };
7
+
8
+ export type { LayoutProps };
@@ -0,0 +1,8 @@
1
+ import { PropsWithChildren } from 'react';
2
+ import { Recipe } from 'recipe-core';
3
+
4
+ type LayoutProps = PropsWithChildren & {
5
+ recipe: Recipe<any>;
6
+ };
7
+
8
+ export type { LayoutProps };
@@ -0,0 +1 @@
1
+ var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var n=(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 s=e=>n(o({},"__esModule",{value:!0}),e);var y={};module.exports=s(y);
File without changes
@@ -0,0 +1,12 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ type RootProps = PropsWithChildren & {
4
+ config?: any;
5
+ };
6
+ /**
7
+ * Provides recipe data to children for rendering. Inherits configuration
8
+ * from the global recipe config if available.
9
+ */
10
+ declare function Root(props: RootProps): JSX.Element;
11
+
12
+ export { Root };
@@ -0,0 +1,12 @@
1
+ import { PropsWithChildren } from 'react';
2
+
3
+ type RootProps = PropsWithChildren & {
4
+ config?: any;
5
+ };
6
+ /**
7
+ * Provides recipe data to children for rendering. Inherits configuration
8
+ * from the global recipe config if available.
9
+ */
10
+ declare function Root(props: RootProps): JSX.Element;
11
+
12
+ export { Root };
@@ -0,0 +1 @@
1
+ var i=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var g=(o,e)=>{for(var t in e)i(o,t,{get:e[t],enumerable:!0})},P=(o,e,t,p)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!d.call(o,n)&&n!==t&&i(o,n,{get:()=>e[n],enumerable:!(p=R(e,n))||p.enumerable});return o};var u=o=>P(i({},"__esModule",{value:!0}),o);var y={};g(y,{Root:()=>m});module.exports=u(y);var f=require("react");var c=require("react"),C=require("react/jsx-runtime"),b=(0,c.createContext)({});function l({children:o,config:e}){return(0,C.jsx)(b.Provider,{value:{config:e},children:o})}var r=require("react"),G=require("react/jsx-runtime"),v=(0,r.createContext)({});function x(){return(0,r.useContext)(v)}var a=require("react/jsx-runtime");function m(o){let{config:e}=x(),t=(0,f.useMemo)(()=>({...e,...o.config}),[e,o.config]);return(0,a.jsx)(l,{config:t,children:o.children})}0&&(module.exports={Root});
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-6MAELCYD.mjs";import"../chunk-QOCKR2HO.mjs";import"../chunk-32VQC2BE.mjs";export{a as Root};
@@ -0,0 +1,18 @@
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 };
@@ -0,0 +1,18 @@
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 };
@@ -0,0 +1 @@
1
+ var c=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var o in t)c(e,o,{get:t[o],enumerable:!0})},f=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of R(t))!l.call(e,i)&&i!==o&&c(e,i,{get:()=>t[i],enumerable:!(n=m(t,i))||n.enumerable});return e};var g=e=>f(c({},"__esModule",{value:!0}),e);var h={};u(h,{Thumbnail:()=>d});module.exports=g(h);var p=require("@radix-ui/react-aspect-ratio");var r=require("react"),C=require("react/jsx-runtime"),x=(0,r.createContext)({});function a(){let e=(0,r.useContext)(x);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}var s=require("react/jsx-runtime");function d(e){var n,i;let{config:t}=a();if(!t.thumbnail)throw new Error("Missing thumbnail image. Did you forget to set one?");let o=(n=e.style)!=null?n:{};return(0,s.jsx)(p.AspectRatio,{"recipe-thumbnail":"",className:e.className,style:{width:"100%",...o},ratio:e.aspectRatio||1,children:(0,s.jsx)("img",{"recipe-thumbnail-image":"",style:{objectFit:"cover",width:"100%",height:"100%"},src:t.thumbnail,alt:(i=e.alt)!=null?i:t.name})})}0&&(module.exports={Thumbnail});
@@ -0,0 +1 @@
1
+ import{a}from"../chunk-RZGBB6SL.mjs";import"../chunk-32VQC2BE.mjs";export{a as Thumbnail};
@@ -0,0 +1,16 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { GlobalRecipeConfig } from 'recipe-core';
4
+
5
+ type GlobalContext = {
6
+ config: GlobalRecipeConfig<any>;
7
+ };
8
+ declare const GlobalContext: react.Context<GlobalContext>;
9
+ declare function useGlobalContext(): GlobalContext;
10
+ interface GlobalContextProviderProps {
11
+ children: ReactNode;
12
+ config: GlobalRecipeConfig<any>;
13
+ }
14
+ declare function GlobalContextProvider({ children, config, }: GlobalContextProviderProps): JSX.Element;
15
+
16
+ export { GlobalContext, GlobalContextProvider, useGlobalContext };
@@ -0,0 +1,16 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { GlobalRecipeConfig } from 'recipe-core';
4
+
5
+ type GlobalContext = {
6
+ config: GlobalRecipeConfig<any>;
7
+ };
8
+ declare const GlobalContext: react.Context<GlobalContext>;
9
+ declare function useGlobalContext(): GlobalContext;
10
+ interface GlobalContextProviderProps {
11
+ children: ReactNode;
12
+ config: GlobalRecipeConfig<any>;
13
+ }
14
+ declare function GlobalContextProvider({ children, config, }: GlobalContextProviderProps): JSX.Element;
15
+
16
+ export { GlobalContext, GlobalContextProvider, useGlobalContext };
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var G=(e,o)=>{for(var l in o)r(e,l,{get:o[l],enumerable:!0})},p=(e,o,l,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of b(o))!c.call(e,t)&&t!==l&&r(e,t,{get:()=>o[t],enumerable:!(i=x(o,t))||i.enumerable});return e};var f=e=>p(r({},"__esModule",{value:!0}),e);var u={};G(u,{GlobalContext:()=>a,GlobalContextProvider:()=>P,useGlobalContext:()=>d});module.exports=f(u);var n=require("react"),C=require("react/jsx-runtime"),a=(0,n.createContext)({});function d(){return(0,n.useContext)(a)}function P({children:e,config:o}){return(0,C.jsx)(a.Provider,{value:{config:o},children:e})}0&&(module.exports={GlobalContext,GlobalContextProvider,useGlobalContext});
@@ -0,0 +1 @@
1
+ import{a,b,c}from"./chunk-QOCKR2HO.mjs";export{a as GlobalContext,c as GlobalContextProvider,b as useGlobalContext};
@@ -0,0 +1,8 @@
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 { useRecipeContext as useRecipe } from './recipe-context.mjs';
6
+ export { GlobalContextProvider as Provider } from './global-context.mjs';
7
+ import 'react';
8
+ import 'recipe-core';
@@ -0,0 +1,8 @@
1
+ export { Root as RecipeRoot, Root } from './components/root.js';
2
+ export { IngredientList, IngredientList as RecipeIngredientList } from './components/ingredients/ingredients-list.js';
3
+ export { InstructionList, InstructionList as RecipeInstructionList } from './components/instructions/instruction-list.js';
4
+ export { Thumbnail as RecipeThumbnail, Thumbnail } from './components/thumbnail.js';
5
+ export { useRecipeContext as useRecipe } from './recipe-context.js';
6
+ export { GlobalContextProvider as Provider } from './global-context.js';
7
+ import 'react';
8
+ import 'recipe-core';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var a=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var N=Object.prototype.hasOwnProperty;var I=(e,t)=>{for(var o in t)a(e,o,{get:t[o],enumerable:!0})},A=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of L(t))!N.call(e,i)&&i!==o&&a(e,i,{get:()=>t[i],enumerable:!(r=w(t,i))||r.enumerable});return e};var M=e=>A(a({},"__esModule",{value:!0}),e);var S={};I(S,{IngredientList:()=>v,InstructionList:()=>y,Provider:()=>g,RecipeIngredientList:()=>v,RecipeInstructionList:()=>y,RecipeRoot:()=>P,RecipeThumbnail:()=>T,Root:()=>P,Thumbnail:()=>T,useRecipe:()=>n});module.exports=M(S);var b=require("react");var c=require("react"),R=require("react/jsx-runtime"),f=(0,c.createContext)({});function n(){let e=(0,c.useContext)(f);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}function u({children:e,config:t}){return(0,R.jsx)(f.Provider,{value:{config:t},children:e})}var p=require("react"),d=require("react/jsx-runtime"),C=(0,p.createContext)({});function x(){return(0,p.useContext)(C)}function g({children:e,config:t}){return(0,d.jsx)(C.Provider,{value:{config:t},children:e})}var h=require("react/jsx-runtime");function P(e){let{config:t}=x(),o=(0,b.useMemo)(()=>({...t,...e.config}),[t,e.config]);return(0,h.jsx)(u,{config:o,children:e.children})}var s=require("react/jsx-runtime");function v(){let{config:e}=n();return(0,s.jsx)("ul",{"recipe-ingredient-list":"",children:e.ingredients.map((t,o)=>(0,s.jsxs)("li",{"recipe-ingredient":"",children:[t.name," \u2014 ",t.amount.value," ",t.amount.unit]},o))})}var l=require("react/jsx-runtime");function y(){let{config:e}=n();return(0,l.jsx)("ul",{"recipe-instruction-list":"",children:e.instructions.map((t,o)=>(0,l.jsx)("li",{"recipe-instruction":o+1,children:t},o))})}var G=require("@radix-ui/react-aspect-ratio");var m=require("react/jsx-runtime");function T(e){var r,i;let{config:t}=n();if(!t.thumbnail)throw new Error("Missing thumbnail image. Did you forget to set one?");let o=(r=e.style)!=null?r:{};return(0,m.jsx)(G.AspectRatio,{"recipe-thumbnail":"",className:e.className,style:{width:"100%",...o},ratio:e.aspectRatio||1,children:(0,m.jsx)("img",{"recipe-thumbnail-image":"",style:{objectFit:"cover",width:"100%",height:"100%"},src:t.thumbnail,alt:(i=e.alt)!=null?i:t.name})})}0&&(module.exports={IngredientList,InstructionList,Provider,RecipeIngredientList,RecipeInstructionList,RecipeRoot,RecipeThumbnail,Root,Thumbnail,useRecipe});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{a as t}from"./chunk-U7TL6PST.mjs";import{a as e}from"./chunk-6MAELCYD.mjs";import{c as i}from"./chunk-QOCKR2HO.mjs";import{a as m}from"./chunk-RZGBB6SL.mjs";import{a as r}from"./chunk-GPTC24DR.mjs";import{a as o}from"./chunk-32VQC2BE.mjs";export{t as IngredientList,r as InstructionList,i as Provider,t as RecipeIngredientList,r as RecipeInstructionList,e as RecipeRoot,m as RecipeThumbnail,e as Root,m as Thumbnail,o as useRecipe};
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { RecipeConfig } from 'recipe-core';
3
+
4
+ type RecipeContext<T extends string> = {
5
+ config: RecipeConfig<T>;
6
+ };
7
+ declare function useRecipeContext(): RecipeContext<any>;
8
+ interface RecipeContextProviderProps<T extends string> {
9
+ children: ReactNode;
10
+ config: RecipeConfig<T>;
11
+ }
12
+ declare function RecipeContextProvider<T extends string>({ children, config, }: RecipeContextProviderProps<T>): JSX.Element;
13
+
14
+ export { type RecipeContext, RecipeContextProvider, useRecipeContext };
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { RecipeConfig } from 'recipe-core';
3
+
4
+ type RecipeContext<T extends string> = {
5
+ config: RecipeConfig<T>;
6
+ };
7
+ declare function useRecipeContext(): RecipeContext<any>;
8
+ interface RecipeContextProviderProps<T extends string> {
9
+ children: ReactNode;
10
+ config: RecipeConfig<T>;
11
+ }
12
+ declare function RecipeContextProvider<T extends string>({ children, config, }: RecipeContextProviderProps<T>): JSX.Element;
13
+
14
+ export { type RecipeContext, RecipeContextProvider, useRecipeContext };
@@ -0,0 +1 @@
1
+ var r=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var C=Object.prototype.hasOwnProperty;var d=(e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})},f=(e,t,n,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of s(t))!C.call(e,o)&&o!==n&&r(e,o,{get:()=>t[o],enumerable:!(c=R(t,o))||c.enumerable});return e};var g=e=>f(r({},"__esModule",{value:!0}),e);var P={};d(P,{RecipeContextProvider:()=>a,useRecipeContext:()=>u});module.exports=g(P);var i=require("react"),x=require("react/jsx-runtime"),p=(0,i.createContext)({});function u(){let e=(0,i.useContext)(p);if(!e)throw new Error("Missing recipe context. Are you using <Recipe.Root />?");return e}function a({children:e,config:t}){return(0,x.jsx)(p.Provider,{value:{config:t},children:e})}0&&(module.exports={RecipeContextProvider,useRecipeContext});
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-32VQC2BE.mjs";export{b as RecipeContextProvider,a as useRecipeContext};
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@recipe-book/react",
3
+ "version": "0.0.1",
4
+ "license": "MIT",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "peerDependencies": {
12
+ "react": "^18.0.0",
13
+ "react-dom": "^18.0.0"
14
+ },
15
+ "dependencies": {
16
+ "@radix-ui/react-aspect-ratio": "1.0.3",
17
+ "@radix-ui/react-avatar": "1.0.3",
18
+ "@radix-ui/react-accessible-icon": "1.0.3",
19
+ "recipe-core": "npm:@recipe-book/core@0.0.1"
20
+ },
21
+ "devDependencies": {
22
+ "@types/react": "18.0.15"
23
+ },
24
+ "sideEffects": false,
25
+ "scripts": {
26
+ "build": "tsup src",
27
+ "dev": "tsup src --watch"
28
+ }
29
+ }