@recipe-book/react 0.1.0 → 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/dist/index.js CHANGED
@@ -1,14 +1,8 @@
1
1
  "use client";
2
2
 
3
- // src/parts/image.tsx
4
- import {
5
- forwardRef
6
- } from "react";
7
-
8
3
  // src/context.tsx
9
4
  import { RecipeBookError as RecipeBookError2 } from "@recipe-book/core";
10
5
  import {
11
- createContext,
12
6
  useContext,
13
7
  useMemo as useMemo2
14
8
  } from "react";
@@ -25,6 +19,15 @@ var defaultLabels = {
25
19
  to: "to"
26
20
  };
27
21
 
22
+ // src/react.ts
23
+ import {
24
+ cloneElement,
25
+ createContext,
26
+ forwardRef,
27
+ Fragment,
28
+ isValidElement
29
+ } from "react";
30
+
28
31
  // src/state/use-recipe-state.ts
29
32
  import {
30
33
  resolveRecipe
@@ -77,14 +80,8 @@ import {
77
80
  useRef,
78
81
  useState
79
82
  } from "react";
80
- function useControllableState({
81
- prop,
82
- value,
83
- defaultValue,
84
- onChange,
85
- resetKey
86
- }) {
87
- const controlled = value !== void 0;
83
+ function useControllableState(options) {
84
+ const { value, defaultValue, onChange, resetKey } = options;
88
85
  const [internal, setInternal] = useState(defaultValue);
89
86
  const [internalResetKey, setInternalResetKey] = useState(resetKey);
90
87
  let uncontrolled = internal;
@@ -93,22 +90,27 @@ function useControllableState({
93
90
  setInternal(defaultValue);
94
91
  uncontrolled = defaultValue;
95
92
  }
96
- const current = controlled ? value : uncontrolled;
97
- const latest = useRef({ controlled, value: current, onChange });
93
+ const current = value === void 0 ? uncontrolled : value;
94
+ const latest = useRef({ value, current, onChange });
98
95
  useInsertionEffect(() => {
99
- latest.current = { controlled, value: current, onChange };
96
+ latest.current = { value, current, onChange };
100
97
  });
101
98
  const setValue = useCallback((next) => {
102
- const { controlled: controlled2, value: value2, onChange: onChange2 } = latest.current;
103
- if (Object.is(next, value2)) return;
104
- if (!controlled2) {
105
- latest.current.value = next;
99
+ const { value: value2, current: current2, onChange: onChange2 } = latest.current;
100
+ if (Object.is(next, current2)) return;
101
+ if (value2 === void 0) {
102
+ latest.current.current = next;
106
103
  setInternal(next);
107
104
  }
108
105
  onChange2?.(next);
109
106
  }, []);
110
107
  if (process.env.NODE_ENV !== "production") {
111
- useModeWarnings(prop, controlled, controlled && onChange === void 0);
108
+ const controlled = value !== void 0;
109
+ useModeWarnings(
110
+ options.prop,
111
+ controlled,
112
+ controlled && onChange === void 0
113
+ );
112
114
  }
113
115
  return [current, setValue];
114
116
  }
@@ -141,7 +143,7 @@ function useRecipeState(options) {
141
143
  assertParsedRecipe(
142
144
  recipe,
143
145
  "useRecipeState()",
144
- "Call parseRecipe() from @recipe-book/core and pass result.data."
146
+ "Call parseRecipe() from @recipe-book/react/core and pass result.data."
145
147
  );
146
148
  }, [recipe]);
147
149
  }
@@ -199,8 +201,8 @@ function useRecipeState(options) {
199
201
  },
200
202
  [updateSystem]
201
203
  );
202
- const steps = useMemo(() => numberSteps(recipe), [recipe]);
203
- const { scale, canConvert, ingredients } = useMemo(
204
+ const steps = useMemo(() => resolveRecipe(recipe).steps, [recipe]);
205
+ const resolved = useMemo(
204
206
  () => resolveRecipe(recipe, { servings, system }),
205
207
  [recipe, servings, system]
206
208
  );
@@ -209,24 +211,14 @@ function useRecipeState(options) {
209
211
  recipe,
210
212
  servings,
211
213
  setServings,
212
- scale,
214
+ scale: resolved.scale,
213
215
  system,
214
216
  setSystem,
215
- canConvert,
216
- ingredients,
217
+ canConvert: resolved.canConvert,
218
+ ingredients: resolved.ingredients,
217
219
  steps
218
220
  }),
219
- [
220
- recipe,
221
- servings,
222
- setServings,
223
- scale,
224
- system,
225
- setSystem,
226
- canConvert,
227
- ingredients,
228
- steps
229
- ]
221
+ [recipe, servings, setServings, resolved, system, setSystem, steps]
230
222
  );
231
223
  }
232
224
  function useWarning(message) {
@@ -238,27 +230,35 @@ function useWarning(message) {
238
230
  }
239
231
  }, [message]);
240
232
  }
241
- function numberSteps(recipe) {
242
- let number = 0;
243
- return recipe.steps.map((section) => ({
244
- ...section,
245
- items: section.items.map((step) => ({ ...step, number: ++number }))
246
- }));
247
- }
248
233
  function isServings(value) {
249
234
  return typeof value === "number" && Number.isFinite(value) && value > 0;
250
235
  }
251
236
  function servingsBase(recipe) {
252
237
  return [recipe.servings?.amount, recipe.yield?.amount].find(isServings) ?? 1;
253
238
  }
254
- var MIN_SCALE = 1e-6;
255
- var MAX_SCALE = 1e6;
239
+ function servingsWindow(base) {
240
+ const [mantissa, exponent] = base.toExponential().split("e");
241
+ return [
242
+ Number(`${mantissa}e${Number(exponent) - 6}`),
243
+ Number(`${mantissa}e${Number(exponent) + 6}`)
244
+ ];
245
+ }
256
246
  function isServingsFor(value, base) {
257
- return isServings(value) && value / base >= MIN_SCALE && value / base <= MAX_SCALE;
247
+ const [min, max] = servingsWindow(base);
248
+ return isServings(value) && value >= min && value <= max;
258
249
  }
259
250
  function describeRange(base) {
260
- const bound = (value) => String(Number(value.toPrecision(6)));
261
- return `a number from ${bound(base * MIN_SCALE)} to ${bound(base * MAX_SCALE)} for this recipe`;
251
+ const [min, max] = servingsWindow(base);
252
+ return `a number from ${roundInward(min, true)} to ${roundInward(max, false)} for this recipe`;
253
+ }
254
+ function roundInward(bound, up) {
255
+ const nearest = Number(bound.toPrecision(6));
256
+ if (up ? nearest >= bound : nearest <= bound) {
257
+ return nearest;
258
+ }
259
+ const [mantissa, exponent] = bound.toExponential().split("e");
260
+ const digits = Number(mantissa.replace(".", "").slice(0, 6));
261
+ return Number(`${up ? digits + 1 : digits}e${Number(exponent) - 5}`);
262
262
  }
263
263
  function isSystem(value) {
264
264
  return value === "metric" || value === "us";
@@ -312,7 +312,7 @@ function useConfig({
312
312
  }),
313
313
  [outer.labels, labels]
314
314
  ),
315
- defaultSystem: isSystem(defaultSystem) ? defaultSystem : outer.defaultSystem
315
+ defaultSystem: [defaultSystem, outer.defaultSystem].find(isSystem)
316
316
  };
317
317
  }
318
318
  var RecipeDataContext = /* @__PURE__ */ createContext(null);
@@ -352,10 +352,7 @@ var Image = /* @__PURE__ */ forwardRef(function Image2({
352
352
  ...props
353
353
  }, ref) {
354
354
  const { recipe } = useRecipeData("Recipe.Image");
355
- if (recipe.image === void 0) {
356
- return null;
357
- }
358
- return /* @__PURE__ */ jsx2(
355
+ return recipe.image !== void 0 && /* @__PURE__ */ jsx2(
359
356
  Comp,
360
357
  {
361
358
  ...props,
@@ -369,20 +366,11 @@ var Image = /* @__PURE__ */ forwardRef(function Image2({
369
366
 
370
367
  // src/parts/ingredients.tsx
371
368
  import {
372
- cloneElement as cloneElement2,
373
- createContext as createContext2,
374
- forwardRef as forwardRef3,
375
369
  useMemo as useMemo3
376
370
  } from "react";
377
371
 
378
372
  // src/slot.tsx
379
- import {
380
- cloneElement,
381
- forwardRef as forwardRef2,
382
- Fragment,
383
- isValidElement,
384
- useCallback as useCallback3
385
- } from "react";
373
+ import { useCallback as useCallback3 } from "react";
386
374
  function resolveAsChild(part, tag, asChild, children, defaults) {
387
375
  if (asChild) {
388
376
  if (isValidElement(children) && children.type !== Fragment) {
@@ -400,7 +388,7 @@ function resolveAsChild(part, tag, asChild, children, defaults) {
400
388
  }
401
389
  return [tag, isEmpty(children) ? defaults : children];
402
390
  }
403
- var Slot = /* @__PURE__ */ forwardRef2(function Slot2({ children, ...props }, ref) {
391
+ var Slot = /* @__PURE__ */ forwardRef(function Slot2({ children, ...props }, ref) {
404
392
  const child = children;
405
393
  const merged = { ...props, ...child.props };
406
394
  for (const name in child.props) {
@@ -480,7 +468,7 @@ function useFormatIngredient() {
480
468
  labels: { optional }
481
469
  } = useRequired(
482
470
  RecipeDataContext,
483
- "useFormatIngredient() must be called inside <Recipe.Root>. To format ingredients without a Root, call formatIngredient() from @recipe-book/core."
471
+ "useFormatIngredient() must be called inside <Recipe.Root>. To format ingredients without a Root, call formatIngredient() from @recipe-book/react/core."
484
472
  );
485
473
  return useCallback4(
486
474
  (item) => formatLine(item, locale, optional),
@@ -489,9 +477,10 @@ function useFormatIngredient() {
489
477
  }
490
478
  function formatLine(item, locale, optional) {
491
479
  const options = { locale };
480
+ const formatted = formatIngredient(item, options);
492
481
  const quantity = lineQuantity(item);
493
482
  return {
494
- ...formatIngredient(item, options),
483
+ ...formatted,
495
484
  quantityParts: quantity ? formatQuantityToParts(quantity, options) : [],
496
485
  ...item.ingredient.optional && { optional }
497
486
  };
@@ -501,10 +490,10 @@ function lineQuantity(item) {
501
490
  }
502
491
 
503
492
  // src/parts/sections.tsx
504
- import { Fragment as Fragment2, useId } from "react";
493
+ import { useId } from "react";
505
494
  import { jsx as jsx3, jsxs } from "react/jsx-runtime";
506
495
  function renderKeyed(items, render) {
507
- return items.map((item) => /* @__PURE__ */ jsx3(Fragment2, { children: render(item) }, item.id));
496
+ return items.map((item) => /* @__PURE__ */ jsx3(Fragment, { children: render(item) }, item.id));
508
497
  }
509
498
  function SectionBlock({
510
499
  kind,
@@ -514,19 +503,16 @@ function SectionBlock({
514
503
  }) {
515
504
  const headingId = useId();
516
505
  const marker = `data-recipe-${kind}-section`;
517
- if (!title) {
518
- return /* @__PURE__ */ jsx3("div", { ...{ [marker]: "" }, children });
519
- }
520
506
  const Heading = `h${headingLevel}`;
521
- return /* @__PURE__ */ jsxs("section", { ...{ [marker]: "" }, "aria-labelledby": headingId, children: [
507
+ return title ? /* @__PURE__ */ jsxs("section", { ...{ [marker]: "" }, "aria-labelledby": headingId, children: [
522
508
  /* @__PURE__ */ jsx3(Heading, { id: headingId, children: title }),
523
509
  children
524
- ] });
510
+ ] }) : /* @__PURE__ */ jsx3("div", { ...{ [marker]: "" }, children });
525
511
  }
526
512
 
527
513
  // src/parts/ingredients.tsx
528
- import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
529
- var Ingredients = /* @__PURE__ */ forwardRef3(
514
+ import { Fragment as Fragment2, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
515
+ var Ingredients = /* @__PURE__ */ forwardRef(
530
516
  function Ingredients2({ headingLevel = 3, children, ...props }, ref) {
531
517
  const { ingredients } = usePartState("Recipe.Ingredients");
532
518
  const renderSection = children ?? ((section) => /* @__PURE__ */ jsx4(
@@ -541,15 +527,15 @@ var Ingredients = /* @__PURE__ */ forwardRef3(
541
527
  return /* @__PURE__ */ jsx4("div", { ...props, "data-recipe-ingredients": "", ref, children: renderKeyed(ingredients, renderSection) });
542
528
  }
543
529
  );
544
- var IngredientList = /* @__PURE__ */ forwardRef3(
530
+ var IngredientList = /* @__PURE__ */ forwardRef(
545
531
  function IngredientList2({ section, children = (item) => /* @__PURE__ */ jsx4(Ingredient, { item }), ...props }, ref) {
546
532
  const { ingredients } = usePartState("Recipe.IngredientList");
547
533
  const items = section?.items ?? ingredients.flatMap((s) => s.items);
548
534
  return /* @__PURE__ */ jsx4("ul", { ...props, "data-recipe-ingredient-list": "", ref, children: renderKeyed(items, children) });
549
535
  }
550
536
  );
551
- var LineContext = /* @__PURE__ */ createContext2(null);
552
- var Ingredient = /* @__PURE__ */ forwardRef3(
537
+ var LineContext = /* @__PURE__ */ createContext(null);
538
+ var Ingredient = /* @__PURE__ */ forwardRef(
553
539
  function Ingredient2({ item, asChild = false, children, ...props }, ref) {
554
540
  const {
555
541
  labels: { optional, to },
@@ -565,7 +551,7 @@ var Ingredient = /* @__PURE__ */ forwardRef3(
565
551
  "li",
566
552
  asChild,
567
553
  children,
568
- /* @__PURE__ */ jsxs2(Fragment3, { children: [
554
+ /* @__PURE__ */ jsxs2(Fragment2, { children: [
569
555
  /* @__PURE__ */ jsx4(IngredientQuantity, {}),
570
556
  quantity && (quantity.unit === void 0 ? "\xA0" : " "),
571
557
  /* @__PURE__ */ jsx4(IngredientName, {}),
@@ -601,15 +587,15 @@ function ingredientText(name, attribute, read) {
601
587
  return null;
602
588
  }
603
589
  const [Comp, child] = resolveAsChild(part, "span", asChild, children, null);
604
- return /* @__PURE__ */ jsx4(Comp, { ...props, ...{ [attribute]: "" }, ref, children: Comp === "span" ? /* @__PURE__ */ jsxs2(Fragment3, { children: [
590
+ return /* @__PURE__ */ jsx4(Comp, { ...props, ...{ [attribute]: "" }, ref, children: Comp === "span" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
605
591
  children,
606
592
  text
607
- ] }) : cloneElement2(child, void 0, child.props.children, text) });
593
+ ] }) : cloneElement(child, void 0, child.props.children, text) });
608
594
  }
609
595
  if (process.env.NODE_ENV !== "production") {
610
596
  Object.defineProperty(IngredientText, "name", { value: name });
611
597
  }
612
- return forwardRef3(IngredientText);
598
+ return forwardRef(IngredientText);
613
599
  }
614
600
  var IngredientQuantity = /* @__PURE__ */ ingredientText(
615
601
  "IngredientQuantity",
@@ -637,7 +623,7 @@ function renderQuantity(parts, to) {
637
623
  if (!separator) {
638
624
  return join(parts);
639
625
  }
640
- return /* @__PURE__ */ jsxs2(Fragment3, { children: [
626
+ return /* @__PURE__ */ jsxs2(Fragment2, { children: [
641
627
  join(parts.slice(0, dash)),
642
628
  /* @__PURE__ */ jsx4("span", { "data-recipe-range-separator": "", "aria-hidden": "true", children: separator.value }),
643
629
  /* @__PURE__ */ jsx4("span", { style: hiddenStyle, children: ` ${to} ` }),
@@ -664,13 +650,12 @@ var IngredientOptional = /* @__PURE__ */ ingredientText(
664
650
  // src/parts/json-ld.tsx
665
651
  import { toJsonLd } from "@recipe-book/core/schema-org";
666
652
  import {
667
- forwardRef as forwardRef4,
668
653
  useEffect as useEffect3,
669
654
  useMemo as useMemo4,
670
655
  useRef as useRef3
671
656
  } from "react";
672
657
  import { jsx as jsx5 } from "react/jsx-runtime";
673
- var JsonLd = /* @__PURE__ */ forwardRef4(
658
+ var JsonLd = /* @__PURE__ */ forwardRef(
674
659
  function JsonLd2({
675
660
  servings,
676
661
  system,
@@ -682,12 +667,12 @@ var JsonLd = /* @__PURE__ */ forwardRef4(
682
667
  ...props
683
668
  }, ref) {
684
669
  const { recipe } = useRecipeData("Recipe.JsonLd");
685
- const { data, warnings } = useMemo4(
670
+ const result = useMemo4(
686
671
  () => toJsonLd(recipe, { servings, system, url, extra }),
687
672
  [recipe, servings, system, url, extra]
688
673
  );
689
674
  if (process.env.NODE_ENV !== "production") {
690
- useWarningsReport(recipe.name, warnings);
675
+ useWarningsReport(recipe.name, result.warnings);
691
676
  }
692
677
  return /* @__PURE__ */ jsx5(
693
678
  "script",
@@ -696,7 +681,7 @@ var JsonLd = /* @__PURE__ */ forwardRef4(
696
681
  type: "application/ld+json",
697
682
  "data-recipe-json-ld": "",
698
683
  dangerouslySetInnerHTML: {
699
- __html: JSON.stringify(data).replace(/</g, "\\u003c")
684
+ __html: JSON.stringify(result.data).replace(/</g, "\\u003c")
700
685
  },
701
686
  ref
702
687
  }
@@ -726,7 +711,7 @@ import {
726
711
  useRef as useRef4,
727
712
  useState as useState2
728
713
  } from "react";
729
- import { Fragment as Fragment4, jsx as jsx6 } from "react/jsx-runtime";
714
+ import { Fragment as Fragment3, jsx as jsx6 } from "react/jsx-runtime";
730
715
  function Root({
731
716
  recipe,
732
717
  parse,
@@ -741,7 +726,7 @@ function Root({
741
726
  assertParsedRecipe(
742
727
  recipe,
743
728
  "<Recipe.Root>",
744
- "Call parseRecipe() from @recipe-book/core on the server, in a loader, or at build time and pass result.data, or pass parse={parseRecipe} to parse it in the browser."
729
+ "Call parseRecipe() from @recipe-book/react/core on the server, in a loader, or at build time and pass result.data, or pass parse={parseRecipe} to parse it in the browser."
745
730
  );
746
731
  return { success: true, data: recipe, warnings: [] };
747
732
  }, [parse, recipe]);
@@ -749,7 +734,7 @@ function Root({
749
734
  useParseReport(result);
750
735
  }
751
736
  if (!result.success) {
752
- return /* @__PURE__ */ jsx6(Fragment4, { children: fallback });
737
+ return /* @__PURE__ */ jsx6(Fragment3, { children: fallback });
753
738
  }
754
739
  return /* @__PURE__ */ jsx6(RecipeProvider, { ...options, recipe: result.data, children });
755
740
  }
@@ -799,7 +784,6 @@ import {
799
784
  formatYield
800
785
  } from "@recipe-book/core";
801
786
  import {
802
- forwardRef as forwardRef5,
803
787
  useState as useState3
804
788
  } from "react";
805
789
 
@@ -815,7 +799,7 @@ function composeEventHandlers(theirs, ours) {
815
799
 
816
800
  // src/parts/servings.tsx
817
801
  import { jsx as jsx7 } from "react/jsx-runtime";
818
- var ServingsSelect = /* @__PURE__ */ forwardRef5(
802
+ var ServingsSelect = /* @__PURE__ */ forwardRef(
819
803
  function ServingsSelect2({ options, "aria-label": ariaLabel, onChange, ...props }, ref) {
820
804
  const { recipe, labels, locale } = useRecipeData("Recipe.ServingsSelect");
821
805
  const { servings, setServings } = usePartState("Recipe.ServingsSelect");
@@ -843,7 +827,7 @@ var ServingsSelect = /* @__PURE__ */ forwardRef5(
843
827
  );
844
828
  }
845
829
  );
846
- var ServingsInput = /* @__PURE__ */ forwardRef5(
830
+ var ServingsInput = /* @__PURE__ */ forwardRef(
847
831
  function ServingsInput2({
848
832
  min = 1,
849
833
  max,
@@ -928,18 +912,13 @@ import {
928
912
  segmentStepText
929
913
  } from "@recipe-book/core";
930
914
  import {
931
- forwardRef as forwardRef7,
932
915
  useEffect as useEffect5,
933
916
  useMemo as useMemo6
934
917
  } from "react";
935
918
 
936
919
  // src/parts/steps.tsx
937
- import {
938
- createContext as createContext3,
939
- forwardRef as forwardRef6
940
- } from "react";
941
- import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
942
- var Steps = /* @__PURE__ */ forwardRef6(function Steps2({ headingLevel = 3, children, ...props }, ref) {
920
+ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
921
+ var Steps = /* @__PURE__ */ forwardRef(function Steps2({ headingLevel = 3, children, ...props }, ref) {
943
922
  const { steps } = useRecipeData("Recipe.Steps");
944
923
  const renderSection = children ?? ((section) => /* @__PURE__ */ jsx8(
945
924
  SectionBlock,
@@ -952,7 +931,7 @@ var Steps = /* @__PURE__ */ forwardRef6(function Steps2({ headingLevel = 3, chil
952
931
  ));
953
932
  return /* @__PURE__ */ jsx8("div", { ...props, "data-recipe-steps": "", ref, children: renderKeyed(steps, renderSection) });
954
933
  });
955
- var StepList = /* @__PURE__ */ forwardRef6(
934
+ var StepList = /* @__PURE__ */ forwardRef(
956
935
  function StepList2({ section, children = (step) => /* @__PURE__ */ jsx8(Step, { item: step }), start, ...props }, ref) {
957
936
  const { steps } = useRecipeData("Recipe.StepList");
958
937
  const items = section?.items ?? steps.flatMap((s) => s.items);
@@ -968,15 +947,15 @@ var StepList = /* @__PURE__ */ forwardRef6(
968
947
  );
969
948
  }
970
949
  );
971
- var StepContext = /* @__PURE__ */ createContext3(null);
972
- var Step = /* @__PURE__ */ forwardRef6(function Step2({ item, asChild = false, children, ...props }, ref) {
950
+ var StepContext = /* @__PURE__ */ createContext(null);
951
+ var Step = /* @__PURE__ */ forwardRef(function Step2({ item, asChild = false, children, ...props }, ref) {
973
952
  useRecipeData("Recipe.Step");
974
953
  const [Comp, content] = resolveAsChild(
975
954
  "Recipe.Step",
976
955
  "li",
977
956
  asChild,
978
957
  children,
979
- /* @__PURE__ */ jsxs3(Fragment5, { children: [
958
+ /* @__PURE__ */ jsxs3(Fragment4, { children: [
980
959
  /* @__PURE__ */ jsx8(StepName, {}),
981
960
  item.name !== void 0 && " ",
982
961
  item.text
@@ -984,7 +963,7 @@ var Step = /* @__PURE__ */ forwardRef6(function Step2({ item, asChild = false, c
984
963
  );
985
964
  return /* @__PURE__ */ jsx8(StepContext.Provider, { value: item, children: /* @__PURE__ */ jsx8(Comp, { ...props, "data-recipe-step": "", ref, children: content }) });
986
965
  });
987
- var StepName = /* @__PURE__ */ forwardRef6(
966
+ var StepName = /* @__PURE__ */ forwardRef(
988
967
  function StepName2(props, ref) {
989
968
  const step = useRequired(
990
969
  StepContext,
@@ -996,7 +975,7 @@ var StepName = /* @__PURE__ */ forwardRef6(
996
975
 
997
976
  // src/parts/step-text.tsx
998
977
  import { jsx as jsx9 } from "react/jsx-runtime";
999
- var StepText = /* @__PURE__ */ forwardRef7(
978
+ var StepText = /* @__PURE__ */ forwardRef(
1000
979
  function StepText2(props, ref) {
1001
980
  const step = useRequired(
1002
981
  StepContext,
@@ -1016,36 +995,29 @@ function Temperature({ segment }) {
1016
995
  const unit = usePartState("Recipe.StepText").system === "us" ? "F" : "C";
1017
996
  const readings = [segment, ...segment.alternatives];
1018
997
  useEffect5(reportTemperature, [reportTemperature]);
1019
- return /* @__PURE__ */ jsx9("span", { "data-recipe-temperature": "", children: [false, true].flatMap((fan) => {
998
+ return /* @__PURE__ */ jsx9("span", { "data-recipe-temperature": "", children: [false, true].map((fan) => {
1020
999
  const kind = readings.filter((reading2) => reading2.fan === fan);
1021
1000
  const reading = kind.find((each) => each.temperature.unit === unit) ?? kind[0];
1022
- return reading ? [
1023
- formatTemperature(
1024
- convertTemperature(reading.temperature, unit),
1025
- {
1026
- locale,
1027
- rounding: reading.temperature.unit === unit ? "none" : void 0
1028
- }
1029
- ) + (fan && labels.fan ? ` ${labels.fan}` : "")
1030
- ] : [];
1031
- }).join(" / ") });
1001
+ return reading && formatTemperature(convertTemperature(reading.temperature, unit), {
1002
+ locale,
1003
+ rounding: reading.temperature.unit === unit ? "none" : void 0
1004
+ }) + (fan && labels.fan ? ` ${labels.fan}` : "");
1005
+ }).filter(Boolean).join(" / ") });
1032
1006
  }
1033
1007
 
1034
1008
  // src/parts/system-toggle.tsx
1035
1009
  import {
1036
- createContext as createContext4,
1037
- forwardRef as forwardRef8,
1038
1010
  useCallback as useCallback6,
1039
1011
  useEffect as useEffect6,
1040
1012
  useId as useId2,
1041
1013
  useMemo as useMemo7,
1042
1014
  useState as useState4
1043
1015
  } from "react";
1044
- import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
1045
- var ToggleContext = /* @__PURE__ */ createContext4(
1016
+ import { Fragment as Fragment5, jsx as jsx10, jsxs as jsxs4 } from "react/jsx-runtime";
1017
+ var ToggleContext = /* @__PURE__ */ createContext(
1046
1018
  null
1047
1019
  );
1048
- var SystemToggle = /* @__PURE__ */ forwardRef8(
1020
+ var SystemToggle = /* @__PURE__ */ forwardRef(
1049
1021
  function SystemToggle2({ asChild = false, "aria-label": ariaLabel, children, ...props }, ref) {
1050
1022
  const { labels } = useRecipeData("Recipe.SystemToggle");
1051
1023
  const { system, setSystem, canConvert } = usePartState(
@@ -1069,7 +1041,7 @@ var SystemToggle = /* @__PURE__ */ forwardRef8(
1069
1041
  "div",
1070
1042
  asChild,
1071
1043
  children,
1072
- /* @__PURE__ */ jsxs4(Fragment6, { children: [
1044
+ /* @__PURE__ */ jsxs4(Fragment5, { children: [
1073
1045
  /* @__PURE__ */ jsx10(SystemOption, { value: "metric" }),
1074
1046
  /* @__PURE__ */ jsx10(SystemOption, { value: "us" })
1075
1047
  ] })
@@ -1089,7 +1061,7 @@ var SystemToggle = /* @__PURE__ */ forwardRef8(
1089
1061
  ) });
1090
1062
  }
1091
1063
  );
1092
- var SystemOption = /* @__PURE__ */ forwardRef8(
1064
+ var SystemOption = /* @__PURE__ */ forwardRef(
1093
1065
  function SystemOption2({
1094
1066
  value,
1095
1067
  asChild = false,
@@ -1130,6 +1102,7 @@ var SystemOption = /* @__PURE__ */ forwardRef8(
1130
1102
  return /* @__PURE__ */ jsx10(
1131
1103
  Comp,
1132
1104
  {
1105
+ autoComplete: "off",
1133
1106
  ...props,
1134
1107
  type: type ?? "button",
1135
1108
  role: "radio",