@terrafirmagreg-team/recipe 1.2.26 → 1.2.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@terrafirmagreg-team/recipe",
3
- "version": "1.2.26",
3
+ "version": "1.2.27",
4
4
  "type": "module",
5
5
  "description": "Recipe viewer and calculator",
6
6
  "license": "LGPL-3.0-only",
@@ -24,14 +24,14 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@terrafirmagreg-team/data": "^1.2.13",
27
- "@terrafirmagreg-team/dump": "^1.2.19",
28
- "@terrafirmagreg-team/game": "^1.2.10",
27
+ "@terrafirmagreg-team/dump": "^1.2.20",
28
+ "@terrafirmagreg-team/game": "^1.2.11",
29
29
  "@terrafirmagreg-team/kit": "^1.2.28",
30
30
  "@terrafirmagreg-team/mdx": "^1.2.12",
31
31
  "@terrafirmagreg-team/preview": "^1.2.7",
32
32
  "@terrafirmagreg-team/sites": "^1.2.4",
33
- "@terrafirmagreg-team/translate": "^1.2.12",
34
- "@terrafirmagreg-team/ui": "^1.2.18",
33
+ "@terrafirmagreg-team/translate": "^1.2.13",
34
+ "@terrafirmagreg-team/ui": "^1.2.19",
35
35
  "@types/pathfinding": "^0.1.0",
36
36
  "comlink": "^4.4.2",
37
37
  "fflate": "0.8.3",
@@ -13,9 +13,7 @@ import {
13
13
  import { useRecipeSession } from '@terrafirmagreg-team/recipe/hooks/use-session';
14
14
  import { recipeConfig } from '@terrafirmagreg-team/recipe/lib/config';
15
15
  import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
16
- import { ItemPanel } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel';
17
16
  import { RecipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
18
- import { RightSidebarPortal } from '@terrafirmagreg-team/ui/components/layouts/right-sidebar';
19
17
  import { TypeView } from '@terrafirmagreg-team/recipe/components/views/browser/type-view';
20
18
  import { ItemView } from '@terrafirmagreg-team/recipe/components/views/browser/item-view';
21
19
  import { Calculator } from '@terrafirmagreg-team/recipe/components/views/calc/calculator';
@@ -147,21 +145,6 @@ export function RecipeBrowser({
147
145
  ) : null}
148
146
  </main>
149
147
  </div>
150
- <RightSidebarPortal>
151
- <ItemPanel
152
- dataset={dataset}
153
- lang={lang}
154
- index={session.index}
155
- indexLoading={session.indexLoading}
156
- names={names}
157
- tab={session.tab}
158
- query={session.query}
159
- setQuery={session.setQuery}
160
- isCalc={isCalc}
161
- nav={session.nav}
162
- className="hidden h-full w-90 lg:flex"
163
- />
164
- </RightSidebarPortal>
165
148
  </div>
166
149
  </EntryProvider>
167
150
  );
@@ -22,7 +22,10 @@ import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty
22
22
  import { type ItemPanelMode } from '@terrafirmagreg-team/recipe/lib/browser/panel';
23
23
  import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
24
24
  import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
25
- import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
25
+ import {
26
+ favoriteHover,
27
+ type FavoriteHoverTarget,
28
+ } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
26
29
  import { IconPager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
27
30
  import { FavoriteButton } from '@terrafirmagreg-team/recipe/components/views/browser/favorite-button';
28
31
  import { ItemPanelGrid } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid';
@@ -125,6 +128,27 @@ export const ItemPanel = memo(function ItemPanel({
125
128
  const resolved = useResolvedLang();
126
129
  const onPress = useItemPress({ dataset, nav, isCalc });
127
130
 
131
+ const {
132
+ tab: navTab,
133
+ search: navSearch,
134
+ tool: navTool,
135
+ unit: navUnit,
136
+ mix: navMix,
137
+ } = nav;
138
+ const cellNav = useMemo<RecipeHrefOpts>(
139
+ () => ({
140
+ tab: navTab,
141
+ search: navSearch,
142
+ tool: navTool,
143
+ unit: navUnit,
144
+ mix: navMix,
145
+ }),
146
+ [navTab, navSearch, navTool, navUnit, navMix],
147
+ );
148
+ const onHover = useCallback((target: FavoriteHoverTarget | undefined) => {
149
+ favoriteHover.base = target;
150
+ }, []);
151
+
128
152
  const setTab = (next: string) => {
129
153
  setPanelPage(0);
130
154
  replaceUrlState(
@@ -148,6 +172,11 @@ export const ItemPanel = memo(function ItemPanel({
148
172
  for (let i = start; i < end; i++) out.push(i);
149
173
  return out;
150
174
  }, [start, list.pages]);
175
+ const windowCells = useMemo(
176
+ () =>
177
+ windowPages.map((p) => cells.slice(p * pageSize, (p + 1) * pageSize)),
178
+ [cells, windowPages, pageSize],
179
+ );
151
180
 
152
181
  useEffect(() => {
153
182
  if (list.page < start || list.page > start + PAGE_WINDOW - 1) {
@@ -230,28 +259,23 @@ export const ItemPanel = memo(function ItemPanel({
230
259
  className="h-full shrink-0"
231
260
  style={{ width: start * w }}
232
261
  />
233
- {windowPages.map((pageIndex) => (
262
+ {windowPages.map((pageIndex, i) => (
234
263
  <div
235
264
  key={pageIndex}
236
265
  className="h-full w-full shrink-0 snap-center"
237
266
  >
238
267
  <ItemPanelGrid
239
- cells={cells.slice(
240
- pageIndex * pageSize,
241
- (pageIndex + 1) * pageSize,
242
- )}
268
+ cells={windowCells[i]}
243
269
  resetKey={gridResetKey}
244
270
  dataset={dataset}
245
271
  lang={dLang}
246
272
  names={dNames}
247
- nav={nav}
273
+ nav={cellNav}
248
274
  cols={cols}
249
275
  rows={rows}
250
276
  favIds={favIds}
251
277
  onPress={onPress}
252
- onHover={(target) => {
253
- favoriteHover.base = target;
254
- }}
278
+ onHover={onHover}
255
279
  onToggleGroup={onToggleGroup}
256
280
  draggableStacks={isCalc}
257
281
  />
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
3
3
 
4
- import type { ReactNode } from 'react';
4
+ import { memo, type ReactNode } from 'react';
5
5
  import { Minus, Plus, Star } from 'lucide-react';
6
6
  import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
7
7
  import { EntryGroup } from '@terrafirmagreg-team/game/components/entry/group';
@@ -59,7 +59,7 @@ function PanelChip({
59
59
  );
60
60
  }
61
61
 
62
- export function PanelCell({
62
+ export const PanelCell = memo(function PanelCell({
63
63
  cell,
64
64
  dataset,
65
65
  lang,
@@ -174,5 +174,5 @@ export function PanelCell({
174
174
  )}
175
175
  </li>
176
176
  );
177
- }
177
+ });
178
178
 
@@ -1,10 +1,57 @@
1
1
  'use client';
2
- import { useEffect } from 'react';
3
- import type { TreeFeatureProps } from '@terrafirmagreg-team/kit/types';
2
+ import { useEffect, useMemo } from 'react';
3
+ import type {
4
+ SectionRightPanelProps,
5
+ TreeFeatureProps,
6
+ } from '@terrafirmagreg-team/kit/types';
7
+ import { ItemPanel } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel';
8
+ import { useRecipeSession } from '@terrafirmagreg-team/recipe/hooks/use-session';
4
9
  import { useRecipeLeftSidebarTree } from '@terrafirmagreg-team/recipe/hooks/use-left-sidebar-tree';
10
+ import { EntryProvider } from '@terrafirmagreg-team/game/hooks/use-entry-context';
11
+ import type { RecipePageData } from '@terrafirmagreg-team/recipe/types';
5
12
 
6
13
  export function RecipeTreeFeature({ input, dataset, onTree }: TreeFeatureProps) {
7
14
  const tree = useRecipeLeftSidebarTree(input, dataset);
8
15
  useEffect(() => onTree({ input, tree }), [input, tree, onTree]);
9
16
  return null;
10
17
  }
18
+
19
+ export function RecipePanelFeature({
20
+ dataset,
21
+ title,
22
+ versions,
23
+ lang,
24
+ }: SectionRightPanelProps) {
25
+ const page = useMemo<RecipePageData>(
26
+ () => ({
27
+ title: title ?? dataset?.id ?? '',
28
+ dataset: dataset ?? { id: '' },
29
+ lang,
30
+ versions,
31
+ }),
32
+ [dataset, title, lang, versions],
33
+ );
34
+ const session = useRecipeSession(page);
35
+ if (!dataset?.id) return null;
36
+ return (
37
+ <EntryProvider
38
+ dataset={session.dataset}
39
+ lang={lang}
40
+ langMap={session.langMap}
41
+ >
42
+ <ItemPanel
43
+ dataset={session.dataset}
44
+ lang={lang}
45
+ index={session.index}
46
+ indexLoading={session.indexLoading}
47
+ names={session.names}
48
+ tab={session.tab}
49
+ query={session.query}
50
+ setQuery={session.setQuery}
51
+ isCalc={session.place?.kind === 'calc'}
52
+ nav={session.nav}
53
+ className="hidden h-full w-90 lg:flex"
54
+ />
55
+ </EntryProvider>
56
+ );
57
+ }
@@ -20,8 +20,11 @@ import type {
20
20
  FavoriteEntry,
21
21
  ItemPanelCell,
22
22
  RecipeCompactIndex,
23
+ UsedItems,
23
24
  } from '@terrafirmagreg-team/recipe/types';
24
25
 
26
+ const UNUSED: UsedItems = { ids: new Set(), bases: new Set() };
27
+
25
28
  export function usePanelCells({
26
29
  dataset,
27
30
  index,
@@ -62,7 +65,11 @@ export function usePanelCells({
62
65
  [dIndex, mode, favoriteIds, tab],
63
66
  );
64
67
 
65
- const used = useMemo(() => recipeUsedItems(dIndex), [dIndex]);
68
+ const used = useMemo(
69
+ () =>
70
+ mode === 'all' && hideUnused ? recipeUsedItems(dIndex) : UNUSED,
71
+ [dIndex, mode, hideUnused],
72
+ );
66
73
  const tooltips = useItemTooltips(dataset, dLang, query.includes('$'));
67
74
  const tagMembers = useTagMembers(dataset, query.includes('#'));
68
75
  const filtered = useMemo(() => {
@@ -43,16 +43,31 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
43
43
  [langRaw, names, lang],
44
44
  );
45
45
  const used = useMemo(() => recipeUsedItems(index), [index]);
46
- const nav: RecipeHrefOpts = {
47
- ...placeOpts,
48
- tab: query.tab,
49
- item: query.item,
50
- fluid: query.fluid,
51
- id: query.recipeId,
52
- relation: query.relation,
53
- search: query.query || undefined,
54
- rpage: query.rpage + 1,
55
- };
46
+ const { type: navType, tool: navTool } = placeOpts;
47
+ const nav = useMemo<RecipeHrefOpts>(
48
+ () => ({
49
+ ...(navType ? { type: navType } : {}),
50
+ ...(navTool ? { tool: navTool } : {}),
51
+ tab: query.tab,
52
+ item: query.item,
53
+ fluid: query.fluid,
54
+ id: query.recipeId,
55
+ relation: query.relation,
56
+ search: query.query || undefined,
57
+ rpage: query.rpage + 1,
58
+ }),
59
+ [
60
+ navType,
61
+ navTool,
62
+ query.tab,
63
+ query.item,
64
+ query.fluid,
65
+ query.recipeId,
66
+ query.relation,
67
+ query.query,
68
+ query.rpage,
69
+ ],
70
+ );
56
71
 
57
72
  const firstType = useMemo(() => {
58
73
  const counts = index?.typeCounts;
@@ -72,7 +87,7 @@ export function useRecipeSession(page: RecipePageData): RecipeSession {
72
87
  replaceUrlState(
73
88
  recipeHref(dataset, resolved, { ...nav, type: firstType }),
74
89
  );
75
- // eslint-disable-next-line react-hooks/exhaustive-deps -- nav rebuilds per render
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- nav tracks URL state; effect must run only on bare-index transitions
76
91
  }, [bareIndex, firstType, dataset, resolved]);
77
92
 
78
93
  return {
@@ -1,5 +1,5 @@
1
1
  import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
2
- import { clientRegistryNsEntries } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
2
+ import { clientRegistryUsesEntries } from '@terrafirmagreg-team/dump/lib/dump/client/dump';
3
3
  import { loadClientTagMembers } from '@terrafirmagreg-team/dump/lib/dump/client/tags';
4
4
  import {
5
5
  asRecord,
@@ -30,7 +30,7 @@ const registrySliceCache = createDatasetCache(
30
30
  ns: string,
31
31
  ): Promise<Record<string, Record<string, unknown>>> => {
32
32
  const field = registryField(kind);
33
- const raw = await clientRegistryNsEntries(dataset, field, ns, 'high');
33
+ const raw = await clientRegistryUsesEntries(dataset, field, ns, 'high');
34
34
  const map = asRecord(raw);
35
35
  return map ? resolveEdgeRows(map) : {};
36
36
  },
package/src/lib/routes.ts CHANGED
@@ -1,6 +1,9 @@
1
1
  import { createSectionRoutes } from '@terrafirmagreg-team/kit/components/views/routes';
2
2
  import { ogDeepLink } from '@terrafirmagreg-team/preview/server';
3
- import { RecipeTreeFeature } from '@terrafirmagreg-team/recipe/components/views/layout';
3
+ import {
4
+ RecipePanelFeature,
5
+ RecipeTreeFeature,
6
+ } from '@terrafirmagreg-team/recipe/components/views/layout';
4
7
  import { RecipeAxisSwitcher } from '@terrafirmagreg-team/recipe/components/views/browser/axis-switcher';
5
8
  import { recipeLanding } from '@terrafirmagreg-team/recipe/components/views/landing';
6
9
  import { recipeTrees } from '@terrafirmagreg-team/recipe/components/tree';
@@ -15,6 +18,7 @@ export function recipeRoutes() {
15
18
  layout: {
16
19
  treeFeature: RecipeTreeFeature,
17
20
  sidebar: { feature: RecipeAxisSwitcher },
21
+ rightPanel: RecipePanelFeature,
18
22
  },
19
23
  landing: recipeLanding,
20
24
  deepLink: ogDeepLink('recipe'),