@terrafirmagreg-team/recipe 1.2.28 → 1.2.30

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 (44) hide show
  1. package/package.json +11 -11
  2. package/src/components/cards/slot-hitbox.tsx +22 -4
  3. package/src/components/tree.tsx +4 -4
  4. package/src/components/views/alloy/list.tsx +1 -0
  5. package/src/components/views/browser/axis-switcher.tsx +6 -7
  6. package/src/components/views/browser/card-grid.tsx +10 -2
  7. package/src/components/views/browser/index.tsx +23 -9
  8. package/src/components/views/browser/item-panel/index.tsx +125 -75
  9. package/src/components/views/browser/item-panel-grid/cell.tsx +0 -6
  10. package/src/components/views/browser/item-panel-grid/index.tsx +10 -5
  11. package/src/components/views/browser/item-view/tags.tsx +2 -0
  12. package/src/components/views/browser/type-view.tsx +5 -4
  13. package/src/components/views/calc/calculator/index.tsx +2 -0
  14. package/src/components/views/calc/sidebar.tsx +4 -1
  15. package/src/components/views/forge/list.tsx +1 -0
  16. package/src/hooks/alloy/use-fluid-colors.ts +2 -3
  17. package/src/hooks/alloy/use-mix-state.ts +2 -0
  18. package/src/hooks/calc/use-actions.ts +6 -4
  19. package/src/hooks/calc/use-data.ts +1 -0
  20. package/src/hooks/calc/use-share.ts +6 -4
  21. package/src/hooks/use-add-to-calc.ts +3 -2
  22. package/src/hooks/use-index.ts +19 -8
  23. package/src/hooks/use-item-press.ts +1 -3
  24. package/src/hooks/use-mount-limit.ts +9 -3
  25. package/src/hooks/use-panel-warmup.ts +129 -0
  26. package/src/hooks/use-query.ts +8 -2
  27. package/src/hooks/use-session.ts +11 -4
  28. package/src/lib/browser/fluid-outputs.ts +2 -3
  29. package/src/lib/calc/storage/entry.ts +1 -1
  30. package/src/lib/calc/storage/keys.ts +2 -2
  31. package/src/lib/cards/model.ts +5 -1
  32. package/src/lib/client/recipe.ts +23 -29
  33. package/src/lib/client-index/catalog.ts +2 -3
  34. package/src/lib/client-index/chrome.test.ts +87 -0
  35. package/src/lib/client-index/chrome.ts +27 -134
  36. package/src/lib/client-index/prepared-catalog.ts +80 -0
  37. package/src/lib/client-index/registry.ts +3 -4
  38. package/src/lib/client-index/rows.test.ts +127 -0
  39. package/src/lib/client-index/rows.ts +51 -194
  40. package/src/lib/client-index/store.ts +2 -3
  41. package/src/lib/client-index/tooltips.ts +2 -3
  42. package/src/lib/links.ts +10 -3
  43. package/src/types/catalog.ts +18 -0
  44. package/src/types/index.ts +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrafirmagreg-team/recipe",
3
- "version": "1.2.28",
3
+ "version": "1.2.30",
4
4
  "type": "module",
5
5
  "description": "Recipe viewer and calculator",
6
6
  "license": "LGPL-3.0-only",
@@ -23,19 +23,19 @@
23
23
  "./styles.css": "./styles.css"
24
24
  },
25
25
  "dependencies": {
26
- "@terrafirmagreg-team/data": "^1.2.13",
27
- "@terrafirmagreg-team/dump": "^1.2.21",
28
- "@terrafirmagreg-team/game": "^1.2.12",
29
- "@terrafirmagreg-team/kit": "^1.2.29",
30
- "@terrafirmagreg-team/mdx": "^1.2.12",
31
- "@terrafirmagreg-team/preview": "^1.2.7",
32
- "@terrafirmagreg-team/sites": "^1.2.4",
33
- "@terrafirmagreg-team/translate": "^1.2.13",
34
- "@terrafirmagreg-team/ui": "^1.2.20",
26
+ "@terrafirmagreg-team/data": "^1.2.14",
27
+ "@terrafirmagreg-team/dump": "^1.2.23",
28
+ "@terrafirmagreg-team/game": "^1.2.14",
29
+ "@terrafirmagreg-team/kit": "^1.2.30",
30
+ "@terrafirmagreg-team/mdx": "^1.2.13",
31
+ "@terrafirmagreg-team/preview": "^1.2.8",
32
+ "@terrafirmagreg-team/sites": "^1.2.5",
33
+ "@terrafirmagreg-team/translate": "^1.2.14",
34
+ "@terrafirmagreg-team/ui": "^1.2.23",
35
35
  "@types/pathfinding": "^0.1.0",
36
36
  "comlink": "^4.4.2",
37
37
  "fflate": "0.8.3",
38
- "lucide-react": "^1.70.0",
38
+ "lucide-react": "^1.72.0",
39
39
  "pathfinding": "0.4.18",
40
40
  "server-only": "^0.0.1"
41
41
  },
@@ -79,7 +79,10 @@ export function SlotHitbox({
79
79
 
80
80
  tooltipLevel?: EntryTooltipLevel;
81
81
  }) {
82
- const name = stackDisplayName(langMap, widget.id);
82
+ const name =
83
+ widget.kind === 'tag'
84
+ ? `#${widget.id.replace(/^#+/, '')}`
85
+ : stackDisplayName(langMap, widget.id);
83
86
  const kind =
84
87
  widget.kind === 'fluid' || widget.kind === 'tag' ? widget.kind : 'item';
85
88
  const checkKind = kind === 'tag' || !interactive ? undefined : kind;
@@ -114,9 +117,11 @@ export function SlotHitbox({
114
117
  ? (alternatives[altIndex] ?? alternatives[0]!)
115
118
  : widget.id;
116
119
  const iconKind = alternatives?.length
117
- ? widget.tagKind === 'fluid' || widget.tagKind === 'block'
118
- ? widget.tagKind
119
- : undefined
120
+ ? widget.kind === 'fluid'
121
+ ? 'fluid'
122
+ : widget.tagKind === 'fluid' || widget.tagKind === 'block'
123
+ ? widget.tagKind
124
+ : undefined
120
125
  : widgetRefKind(widget);
121
126
  const icon = (
122
127
  <span className="pointer-events-none flex size-full items-center justify-center">
@@ -134,6 +139,19 @@ export function SlotHitbox({
134
139
  size={iconSize}
135
140
  missing="placeholder"
136
141
  />
142
+ {widget.kind === 'tag' ? (
143
+ <span
144
+ aria-hidden
145
+ className="font-mc pointer-events-none absolute top-0 left-0 leading-none text-amber-300"
146
+ style={{
147
+ paddingLeft: scale / 2,
148
+ fontSize: (Math.min(widget.w, widget.h) / 16) * 7 * scale,
149
+ textShadow: `${scale}px ${scale}px 0 var(--color-mc-arrow)`,
150
+ }}
151
+ >
152
+ #
153
+ </span>
154
+ ) : null}
137
155
  </span>
138
156
  );
139
157
  const pos = {
@@ -1,5 +1,6 @@
1
1
  import 'server-only';
2
- import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
2
+ import { datasetCacheKey, type DatasetRef } from '@terrafirmagreg-team/sites/location';
3
+ import { resolveDatasetSnapshot } from '@terrafirmagreg-team/dump/lib/dump/snapshot';
3
4
  import { createElement } from 'react';
4
5
  import type * as PageTree from 'fumadocs-core/page-tree';
5
6
  import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
@@ -50,7 +51,7 @@ function categoryLeaf(
50
51
  name: creativeTabName(map, category.display?.name),
51
52
  url: `${recipeBasePath(dataset)}?type=${encodeQueryValue(category.id)}`,
52
53
  icon: categoryIcon(dataset, category),
53
- $id: `${dataset.id}/${dataset.version ?? ''}/type/${category.id}`,
54
+ $id: datasetCacheKey(dataset, 'type', category.id),
54
55
  }) as PageTree.Item;
55
56
  }
56
57
 
@@ -70,7 +71,7 @@ async function buildRecipeTrees(lang: Lang): Promise<SectionTrees> {
70
71
  const trees: SectionTrees = {};
71
72
  for (const { id, title: datasetTitle, languages } of datasets) {
72
73
  if (!(languages ?? [defaultLanguage]).includes(lang)) continue;
73
- const ref = { id };
74
+ const ref = await resolveDatasetSnapshot({ id });
74
75
  const map = await clientDumpLangNames(ref, lang);
75
76
  const source = getRecipeSource();
76
77
  const categories = await source.categories(ref);
@@ -97,4 +98,3 @@ async function buildRecipeTrees(lang: Lang): Promise<SectionTrees> {
97
98
  }
98
99
  return trees;
99
100
  }
100
-
@@ -41,6 +41,7 @@ export function AlloyList({ session }: { session: RecipeSession }) {
41
41
  id: recipe.id,
42
42
  unit: session.alloyUnit,
43
43
  tab: session.tab,
44
+ version: session.nav.version,
44
45
  }),
45
46
  name: (
46
47
  <>
@@ -13,7 +13,8 @@ import {
13
13
  isDatasetFailed,
14
14
  useFailedDatasets,
15
15
  } from '@terrafirmagreg-team/kit/hooks/use-dump-status';
16
- import { useVersionPreference } from '@terrafirmagreg-team/kit/hooks/use-version-pref';
16
+ import { useVersionedDataset } from '@terrafirmagreg-team/kit/hooks/use-versioned-dataset';
17
+ import { useSectionCatalog } from '@terrafirmagreg-team/kit/hooks/use-catalog';
17
18
 
18
19
  export function RecipeAxisSwitcher() {
19
20
  const t = useTranslations();
@@ -22,12 +23,10 @@ export function RecipeAxisSwitcher() {
22
23
  const params = useLocationSearchParams();
23
24
  const axis = recipePlaceFromParams(params).kind;
24
25
  const failed = useFailedDatasets();
25
- const preferred = useVersionPreference(datasetId);
26
- const dataset = {
27
- id: datasetId ?? '',
28
- version: params.get('version') ?? preferred,
29
- };
30
- if (!datasetId || isDatasetFailed(failed, dataset)) return null;
26
+ const catalog = useSectionCatalog();
27
+ const meta = catalog.recipe?.find(({ id }) => id === datasetId);
28
+ const dataset = useVersionedDataset(datasetId, meta);
29
+ if (!datasetId || !dataset || isDatasetFailed(failed, dataset)) return null;
31
30
  return (
32
31
  <Switcher
33
32
  options={[
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import { useEffect, useState, type ReactNode, type RefObject } from 'react';
4
- import { useAsyncValue } from '@terrafirmagreg-team/ui/hooks/use-async-value';
4
+ import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
5
5
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
6
6
  import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
7
7
  import { PagedCard } from '@terrafirmagreg-team/recipe/components/cards/paged-card';
@@ -17,6 +17,7 @@ import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
17
17
  import { loadClientRecipe } from '@terrafirmagreg-team/recipe/lib/client/recipe';
18
18
  import { pushUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
19
19
  import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
20
+ import { dismissOpenTooltips } from '@terrafirmagreg-team/ui/lib/dismiss-tooltips';
20
21
  import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
21
22
  import { recipeTitle } from '@terrafirmagreg-team/recipe/lib/data/parse';
22
23
  import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
@@ -69,10 +70,12 @@ function RecipeGridCard({
69
70
  const t = useTranslations();
70
71
  const resolved = useResolvedLang();
71
72
  const { dataset, lang, langMap, names, nav, index } = session;
72
- const recipe = useAsyncValue(
73
+ const recipeRes = useAsyncResult(
73
74
  () => loadClientRecipe(dataset, row.id, row.bucket),
74
75
  [dataset, row.id, row.bucket],
75
76
  );
77
+ const recipe = recipeRes.value;
78
+ const recipeMissing = !recipeRes.pending && !recipe;
76
79
  const [failed, setFailed] = useState(false);
77
80
 
78
81
  const title = recipe
@@ -188,6 +191,10 @@ function RecipeGridCard({
188
191
  onError={() => setFailed(true)}
189
192
  className="block rounded-sm"
190
193
  />
194
+ ) : recipeMissing ? (
195
+ <EmptyState variant="empty">
196
+ {t('No recipe image in dump.', { note: 'recipe.no_image' })}
197
+ </EmptyState>
191
198
  ) : (
192
199
  <Skeleton
193
200
  className="rounded-sm"
@@ -267,6 +274,7 @@ export function RecipeCardGrid({
267
274
  <div
268
275
  ref={boxRef}
269
276
  {...swipe}
277
+ onScroll={dismissOpenTooltips}
270
278
  className="flex min-h-0 flex-1 flex-col items-center justify-start gap-2 overflow-x-auto overflow-y-clip"
271
279
  >
272
280
  {body}
@@ -29,6 +29,9 @@ import { EntryProvider } from '@terrafirmagreg-team/game/hooks/use-entry-context
29
29
  import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
30
30
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
31
31
  import type { RecipePageData } from '@terrafirmagreg-team/recipe/types';
32
+ import type { DatasetSnapshot } from '@terrafirmagreg-team/sites/location';
33
+ import { useVersionedDataset } from '@terrafirmagreg-team/kit/hooks/use-versioned-dataset';
34
+ import { SnapshotBoundary } from '@terrafirmagreg-team/kit/components/dump-status/snapshot-boundary';
32
35
 
33
36
  export function RecipeBrowserFallback() {
34
37
  return (
@@ -54,20 +57,32 @@ export function RecipeBrowserFallback() {
54
57
  );
55
58
  }
56
59
 
57
- export function RecipeBrowser({
58
- dataset: id,
59
- datasetTitle,
60
- lang,
61
- versions,
62
- }: {
60
+ type RecipeBrowserProps = {
63
61
  dataset: string;
64
62
  datasetTitle: string;
65
63
  lang: Lang;
66
64
  versions?: readonly string[];
67
- }) {
65
+ };
66
+
67
+ export function RecipeBrowser(props: RecipeBrowserProps) {
68
+ const selection = useVersionedDataset(props.dataset, { versions: props.versions }) ??
69
+ { id: props.dataset };
70
+ return (
71
+ <SnapshotBoundary selection={selection} fallback={<RecipeBrowserFallback />}>
72
+ {(dataset) => <RecipeBrowserContent {...props} dataset={dataset} />}
73
+ </SnapshotBoundary>
74
+ );
75
+ }
76
+
77
+ function RecipeBrowserContent({
78
+ dataset: pinnedDataset,
79
+ datasetTitle,
80
+ lang,
81
+ versions,
82
+ }: Omit<RecipeBrowserProps, 'dataset'> & { dataset: DatasetSnapshot }) {
68
83
  const page: RecipePageData = {
69
84
  title: datasetTitle,
70
- dataset: { id },
85
+ dataset: pinnedDataset,
71
86
  lang,
72
87
  versions: versions as string[] | undefined,
73
88
  };
@@ -149,4 +164,3 @@ export function RecipeBrowser({
149
164
  </EntryProvider>
150
165
  );
151
166
  }
152
-
@@ -9,7 +9,6 @@ import {
9
9
  useMemo,
10
10
  useRef,
11
11
  useState,
12
- type UIEvent,
13
12
  } from 'react';
14
13
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
15
14
  import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
@@ -33,9 +32,11 @@ import { RecipeSettings } from '@terrafirmagreg-team/recipe/components/views/bro
33
32
  import { QuerySearch } from '@terrafirmagreg-team/recipe/components/views/browser/query-controls';
34
33
  import { Pager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
35
34
  import { usePanelPage } from '@terrafirmagreg-team/recipe/hooks/use-panel-page';
35
+ import { dismissOpenTooltips } from '@terrafirmagreg-team/ui/lib/dismiss-tooltips';
36
36
  import { useItemPress } from '@terrafirmagreg-team/recipe/hooks/use-item-press';
37
37
  import { usePanelCells } from '@terrafirmagreg-team/recipe/hooks/use-panel-cells';
38
38
  import { usePanelTabs } from '@terrafirmagreg-team/recipe/hooks/use-panel-tabs';
39
+ import { usePanelWarmup } from '@terrafirmagreg-team/recipe/hooks/use-panel-warmup';
39
40
  import {
40
41
  RecipePanelSkeleton,
41
42
  RecipeTabsSkeleton,
@@ -111,6 +112,15 @@ export const ItemPanel = memo(function ItemPanel({
111
112
  const favIds = useMemo(() => new Set(favoriteIds), [favoriteIds]);
112
113
  const { page: panelPage, setPage: setPanelPage } = usePanelPage(dataset);
113
114
  const list = usePagedList(cells, panelPage, pageSize);
115
+ const stripRef = useRef<HTMLDivElement | null>(null);
116
+ const drag = useRef(false);
117
+ const suppressScroll = useRef(0);
118
+ const lastWheelAt = useRef(0);
119
+ const flyTimer = useRef<number | undefined>(undefined);
120
+ const [flying, setFlying] = useState(false);
121
+ const [viewPage, setViewPage] = useState(list.page);
122
+ useEffect(() => setViewPage(list.page), [list.page]);
123
+ usePanelWarmup(dataset, cells, viewPage, pageSize);
114
124
 
115
125
  const gridResetKey = mode;
116
126
  const onToggleGroup = useCallback((groupId: string) => {
@@ -131,6 +141,7 @@ export const ItemPanel = memo(function ItemPanel({
131
141
  tool: navTool,
132
142
  unit: navUnit,
133
143
  mix: navMix,
144
+ version: navVersion,
134
145
  } = nav;
135
146
  const cellNav = useMemo<RecipeHrefOpts>(
136
147
  () => ({
@@ -139,15 +150,16 @@ export const ItemPanel = memo(function ItemPanel({
139
150
  tool: navTool,
140
151
  unit: navUnit,
141
152
  mix: navMix,
153
+ version: navVersion,
142
154
  }),
143
- [navTab, navSearch, navTool, navUnit, navMix],
155
+ [navTab, navSearch, navTool, navUnit, navMix, navVersion],
144
156
  );
145
157
  const onHover = useCallback((target: FavoriteHoverTarget | undefined) => {
146
158
  favoriteHover.base = target;
147
159
  }, []);
148
160
 
149
161
  const setTab = (next: string) => {
150
- setPanelPage(0);
162
+ selectPage(0);
151
163
  replaceUrlState(
152
164
  recipeHref(dataset, resolved, {
153
165
  ...nav,
@@ -156,70 +168,90 @@ export const ItemPanel = memo(function ItemPanel({
156
168
  );
157
169
  };
158
170
 
159
- const stripRef = useRef<HTMLDivElement | null>(null);
160
- const fromScroll = useRef(false);
161
171
  const pageRef = useRef(list.page);
162
- pageRef.current = list.page;
163
- const [startRaw, setStartRaw] = useState(list.page - (PAGE_WINDOW >> 1));
164
- const maxStart = Math.max(0, list.pages - PAGE_WINDOW);
165
- const start = Math.max(
166
- 0,
167
- Math.min(
168
- maxStart,
169
- Math.max(list.page - (PAGE_WINDOW - 1), Math.min(startRaw, list.page)),
170
- ),
171
- );
172
+ useEffect(() => {
173
+ pageRef.current = list.page;
174
+ }, [list.page]);
175
+ const selectPage = (next: number) => {
176
+ const total = list.pages;
177
+ const wrapped = total > 1 ? ((next % total) + total) % total : 0;
178
+ pageRef.current = wrapped;
179
+ setViewPage(wrapped);
180
+ setPanelPage(wrapped);
181
+ };
182
+ const circular = list.pages > PAGE_WINDOW;
183
+ const base = circular
184
+ ? ((list.page - (PAGE_WINDOW >> 1)) % list.pages + list.pages) % list.pages
185
+ : 0;
172
186
  const windowPages = useMemo(() => {
173
- const end = Math.min(list.pages, start + PAGE_WINDOW);
174
- const out: number[] = [];
175
- for (let i = start; i < end; i++) out.push(i);
176
- return out;
177
- }, [start, list.pages]);
187
+ if (!circular) {
188
+ return Array.from({ length: list.pages }, (_, i) => i);
189
+ }
190
+ return Array.from(
191
+ { length: PAGE_WINDOW },
192
+ (_, i) => (base + i) % list.pages,
193
+ );
194
+ }, [circular, base, list.pages]);
178
195
  const windowCells = useMemo(
179
196
  () =>
180
197
  windowPages.map((p) => cells.slice(p * pageSize, (p + 1) * pageSize)),
181
198
  [cells, windowPages, pageSize],
182
199
  );
183
200
 
184
- const didInitScroll = useRef(false);
185
201
  useLayoutEffect(() => {
186
202
  const el = stripRef.current;
187
203
  if (!el || w <= 0) return;
188
- const target = list.page * w;
204
+ const target = (circular ? PAGE_WINDOW >> 1 : list.page) * w;
189
205
  if (Math.abs(el.scrollLeft - target) > 2) {
190
- el.scrollTo({
191
- left: target,
192
- behavior:
193
- fromScroll.current || !didInitScroll.current
194
- ? 'instant'
195
- : 'smooth',
196
- });
206
+ suppressScroll.current = performance.now() + 120;
207
+ el.scrollLeft = target;
197
208
  }
198
- didInitScroll.current = true;
199
- fromScroll.current = false;
200
- }, [list.page, w]);
209
+ }, [list.page, circular, w]);
201
210
 
202
211
  const idle = useRef<number | undefined>(undefined);
203
212
  const [scrolling, setScrolling] = useState(false);
204
- useEffect(() => () => window.clearTimeout(idle.current), []);
213
+ useEffect(() => {
214
+ const up = () => {
215
+ drag.current = false;
216
+ };
217
+ window.addEventListener('pointerup', up);
218
+ window.addEventListener('pointercancel', up);
219
+ return () => {
220
+ window.removeEventListener('pointerup', up);
221
+ window.removeEventListener('pointercancel', up);
222
+ window.clearTimeout(idle.current);
223
+ window.clearTimeout(flyTimer.current);
224
+ };
225
+ }, []);
226
+ const endScroll = useCallback(() => {
227
+ const el = stripRef.current;
228
+ if (!el || w <= 0) return;
229
+ setScrolling(false);
230
+ const pos = Math.round(el.scrollLeft / w);
231
+ const next = circular
232
+ ? (((base + pos) % list.pages) + list.pages) % list.pages
233
+ : Math.max(0, Math.min(list.pages - 1, pos));
234
+ setViewPage(next);
235
+ if (next !== pageRef.current) {
236
+ pageRef.current = next;
237
+ setPanelPage(next);
238
+ }
239
+ }, [w, circular, base, list.pages, setPanelPage]);
205
240
 
206
- const onStripScroll = (event: UIEvent<HTMLDivElement>) => {
207
- const el = event.currentTarget;
208
- if (w <= 0) return;
209
- const next = Math.max(
210
- 0,
211
- Math.min(list.pages - 1, Math.round(el.scrollLeft / w)),
212
- );
213
- setScrolling(true);
241
+ const onStripScroll = () => {
242
+ const el = stripRef.current;
243
+ if (!el || w <= 0) return;
244
+ dismissOpenTooltips();
245
+ if (performance.now() < suppressScroll.current) return;
246
+ if (drag.current) setScrolling(true);
214
247
  window.clearTimeout(idle.current);
215
- idle.current = window.setTimeout(() => {
216
- setScrolling(false);
217
- if (next !== pageRef.current) {
218
- fromScroll.current = true;
219
- setPanelPage(next);
220
- }
221
- setStartRaw(pageRef.current - (PAGE_WINDOW >> 1));
222
- }, 160);
248
+ idle.current = window.setTimeout(endScroll, 160);
249
+ const pos = Math.round(el.scrollLeft / w);
250
+ setViewPage(
251
+ circular
252
+ ? (((base + pos) % list.pages) + list.pages) % list.pages
253
+ : Math.max(0, Math.min(list.pages - 1, pos)),
254
+ );
223
255
  };
224
256
 
225
257
  const tabOptions = usePanelTabs(dIndex, dNames, dLang);
@@ -248,25 +280,47 @@ export const ItemPanel = memo(function ItemPanel({
248
280
  <div
249
281
  ref={stripRef}
250
282
  onScroll={onStripScroll}
283
+ onPointerDown={() => {
284
+ drag.current = true;
285
+ }}
251
286
  onWheel={(event) => {
252
- const el = stripRef.current;
253
- if (!el || w <= 0) return;
254
- el.scrollBy({
255
- left: Math.sign(event.deltaY) * w,
256
- behavior: 'smooth',
257
- });
287
+ if (w <= 0) return;
288
+ const delta =
289
+ Math.abs(event.deltaX) > Math.abs(event.deltaY)
290
+ ? event.deltaX
291
+ : event.deltaY;
292
+ const dir = Math.sign(delta);
293
+ if (!dir) return;
294
+ dismissOpenTooltips();
295
+ const now = performance.now();
296
+ if (now - lastWheelAt.current < 120) {
297
+ setFlying(true);
298
+ window.clearTimeout(flyTimer.current);
299
+ flyTimer.current = window.setTimeout(
300
+ () => setFlying(false),
301
+ 140,
302
+ );
303
+ }
304
+ lastWheelAt.current = now;
305
+ selectPage(pageRef.current + dir);
258
306
  }}
259
- className="flex h-full snap-x snap-mandatory overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
307
+ className={cn(
308
+ 'flex h-full snap-x snap-proximity overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden',
309
+ (scrolling || flying) && '[&>*]:pointer-events-none',
310
+ )}
260
311
  >
261
- <div
262
- aria-hidden
263
- className="h-full shrink-0"
264
- style={{ width: start * w }}
265
- />
266
312
  {windowPages.map((pageIndex, i) => (
267
313
  <div
268
314
  key={pageIndex}
269
315
  className="h-full w-full shrink-0 snap-center"
316
+ style={
317
+ pageIndex === list.page
318
+ ? undefined
319
+ : {
320
+ contentVisibility: 'auto',
321
+ containIntrinsicSize: `${w}px ${h}px`,
322
+ }
323
+ }
270
324
  >
271
325
  <ItemPanelGrid
272
326
  cells={windowCells[i]}
@@ -282,18 +336,13 @@ export const ItemPanel = memo(function ItemPanel({
282
336
  onHover={onHover}
283
337
  onToggleGroup={onToggleGroup}
284
338
  draggableStacks={isCalc}
285
- tooltip={!scrolling}
339
+ eager={pageIndex === viewPage}
340
+ frozen={
341
+ flying || (scrolling && pageIndex !== viewPage)
342
+ }
286
343
  />
287
344
  </div>
288
345
  ))}
289
- <div
290
- aria-hidden
291
- className="h-full shrink-0"
292
- style={{
293
- width:
294
- Math.max(0, list.pages - start - windowPages.length) * w,
295
- }}
296
- />
297
346
  </div>
298
347
  );
299
348
  }
@@ -313,19 +362,20 @@ export const ItemPanel = memo(function ItemPanel({
313
362
  />
314
363
  )}
315
364
  <Pager
316
- page={list.page}
365
+ loop
366
+ page={viewPage}
317
367
  pages={list.pages}
318
- to={list.to}
368
+ to={Math.min(list.total, (viewPage + 1) * pageSize)}
319
369
  total={list.total}
320
370
  label={t('{page}/{pages}', { note: 'recipe.page_of' })}
321
- onPage={setPanelPage}
371
+ onPage={selectPage}
322
372
  leading={
323
373
  <FavoriteButton
324
374
  variant="outline"
325
375
  active={mode === 'fav'}
326
376
  label={t('Favorites', { note: 'recipe.favorites' })}
327
377
  onToggle={() => {
328
- setPanelPage(0);
378
+ selectPage(0);
329
379
  setMode(mode === 'fav' ? 'all' : 'fav');
330
380
  }}
331
381
  className="size-9 [&_svg]:size-4.5"
@@ -342,7 +392,7 @@ export const ItemPanel = memo(function ItemPanel({
342
392
  params={nav}
343
393
  query={query}
344
394
  onQuery={(next) => {
345
- setPanelPage(0);
395
+ selectPage(0);
346
396
  setQuery(next);
347
397
  }}
348
398
  placeholder={t('Search items', { note: 'recipe.search' })}
@@ -27,7 +27,6 @@ function PanelChip({
27
27
  names,
28
28
  lang,
29
29
  favIds,
30
- tooltip,
31
30
  }: {
32
31
  id: string;
33
32
  size: EntrySize;
@@ -37,13 +36,11 @@ function PanelChip({
37
36
  names: Record<string, Record<string, string>>;
38
37
  lang: Lang;
39
38
  favIds?: ReadonlySet<string>;
40
- tooltip?: boolean;
41
39
  }) {
42
40
  return (
43
41
  <Entry
44
42
  id={id}
45
43
  kind={kind}
46
- tooltip={tooltip === false ? false : undefined}
47
44
  name={recipeItemName(names, lang, id)}
48
45
  size={size}
49
46
  variant="chip"
@@ -71,7 +68,6 @@ export const PanelCell = memo(function PanelCell({
71
68
  favIds,
72
69
  expandLabel,
73
70
  draggableStacks,
74
- tooltip,
75
71
  onPress,
76
72
  onHover,
77
73
  onToggleGroup,
@@ -84,7 +80,6 @@ export const PanelCell = memo(function PanelCell({
84
80
  favIds?: ReadonlySet<string>;
85
81
  expandLabel: string;
86
82
  draggableStacks?: boolean;
87
- tooltip?: boolean;
88
83
  onPress: (id: string, ref?: 'item' | 'fluid') => void;
89
84
  onHover?: (target: FavoriteHoverTarget | undefined) => void;
90
85
  onToggleGroup?: (id: string) => void;
@@ -173,7 +168,6 @@ export const PanelCell = memo(function PanelCell({
173
168
  names={names}
174
169
  lang={lang}
175
170
  favIds={favIds}
176
- tooltip={tooltip}
177
171
  />
178
172
  </button>
179
173
  </CopyIdMenu>
@@ -27,7 +27,8 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
27
27
  onHover,
28
28
  onToggleGroup,
29
29
  draggableStacks,
30
- tooltip,
30
+ eager,
31
+ frozen,
31
32
  }: {
32
33
  cells: ItemPanelCell[];
33
34
 
@@ -43,12 +44,17 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
43
44
  onHover?: (target: FavoriteHoverTarget | undefined) => void;
44
45
  onToggleGroup?: (id: string) => void;
45
46
  draggableStacks?: boolean;
46
- tooltip?: boolean;
47
+ eager?: boolean;
48
+ frozen?: boolean;
47
49
  }) {
48
50
  const t = useTranslations();
49
51
  const expandLabel = t('Expand', { note: 'recipe.expand' });
50
- const limit = useMountLimit(cells.length, resetKey);
51
- const shown = limit >= cells.length ? cells : cells.slice(0, limit);
52
+ const limit = useMountLimit(cells.length, resetKey, eager);
53
+ const shown = frozen
54
+ ? []
55
+ : limit >= cells.length
56
+ ? cells
57
+ : cells.slice(0, limit);
52
58
  const { gridRef, outlines } = useGroupOutlines(shown, cols, rows);
53
59
 
54
60
  return (
@@ -77,7 +83,6 @@ export const ItemPanelGrid = memo(function ItemPanelGrid({
77
83
  favIds={favIds}
78
84
  expandLabel={expandLabel}
79
85
  draggableStacks={draggableStacks}
80
- tooltip={tooltip}
81
86
  onPress={onPress}
82
87
  onHover={onHover}
83
88
  onToggleGroup={onToggleGroup}
@@ -54,6 +54,7 @@ export function ItemTagGroups({
54
54
  id: tagPseudoId(id, tagKind),
55
55
  search: query || undefined,
56
56
  tab: nav.tab,
57
+ version: nav.version,
57
58
  })}
58
59
  variant="chip"
59
60
  size="sm"
@@ -70,6 +71,7 @@ export function ItemTagGroups({
70
71
  recipeHref(dataset, resolved, {
71
72
  type: 'emi:tag',
72
73
  search,
74
+ version: nav.version,
73
75
  }),
74
76
  );
75
77
  }}