@terrafirmagreg-team/recipe 1.2.25 → 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.25",
3
+ "version": "1.2.27",
4
4
  "type": "module",
5
5
  "description": "Recipe viewer and calculator",
6
6
  "license": "LGPL-3.0-only",
@@ -23,15 +23,15 @@
23
23
  "./styles.css": "./styles.css"
24
24
  },
25
25
  "dependencies": {
26
- "@terrafirmagreg-team/data": "^1.2.12",
27
- "@terrafirmagreg-team/dump": "^1.2.19",
28
- "@terrafirmagreg-team/game": "^1.2.10",
29
- "@terrafirmagreg-team/kit": "^1.2.27",
26
+ "@terrafirmagreg-team/data": "^1.2.13",
27
+ "@terrafirmagreg-team/dump": "^1.2.20",
28
+ "@terrafirmagreg-team/game": "^1.2.11",
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",
@@ -6,6 +6,8 @@ import { recipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/
6
6
  import {
7
7
  cardStripGeo,
8
8
  countCoveredText,
9
+ slotCoveredLabel,
10
+ slotOverlay,
9
11
  textInStrip,
10
12
  } from '@terrafirmagreg-team/recipe/lib/cards/model';
11
13
  import { CardText } from '@terrafirmagreg-team/recipe/components/cards/card/text';
@@ -184,8 +186,17 @@ export function RecipeCard({
184
186
  />
185
187
  ) : null}
186
188
  {inView
187
- ? textWidgets.map((widget, index) =>
188
- textInStrip(widget, strip) ? null : (
189
+ ? textWidgets.map((widget, index) => {
190
+ if (textInStrip(widget, strip) || countCoveredText(widget, slots)) {
191
+ return null;
192
+ }
193
+ const labelSlot = slotCoveredLabel(widget, slots);
194
+ const overlaySlot = labelSlot ?? slotOverlay(widget, slots);
195
+ const micro =
196
+ overlaySlot && widget.h <= 6
197
+ ? (Math.min(overlaySlot.w, overlaySlot.h) / 16) * 4 * scale
198
+ : undefined;
199
+ return (
189
200
  <CardText
190
201
  key={`${widget.x}:${widget.y}:${index}`}
191
202
  widget={widget}
@@ -193,9 +204,19 @@ export function RecipeCard({
193
204
  offY={margin}
194
205
  scale={scale}
195
206
  langMap={langMap}
207
+ size={micro}
208
+ {...(labelSlot
209
+ ? {
210
+ anchor: {
211
+ x: labelSlot.x,
212
+ y: labelSlot.y,
213
+ w: labelSlot.w,
214
+ },
215
+ }
216
+ : {})}
196
217
  />
197
- ),
198
- )
218
+ );
219
+ })
199
220
  : null}
200
221
  </div>
201
222
  );
@@ -5,8 +5,11 @@ import { Fragment, useRef, useState } from 'react';
5
5
  import { SlotHitbox } from '@terrafirmagreg-team/recipe/components/cards/slot-hitbox';
6
6
  import { CardText } from '@terrafirmagreg-team/recipe/components/cards/card/text';
7
7
  import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
8
- import { formatCount } from '@terrafirmagreg-team/ui/lib/utils/format';
9
8
  import type { CardStripGeo } from '@terrafirmagreg-team/recipe/lib/cards/model';
9
+ import {
10
+ slotCoveredLabel,
11
+ slotOverlay,
12
+ } from '@terrafirmagreg-team/recipe/lib/cards/model';
10
13
  import type { EntryTooltipLevel } from '@terrafirmagreg-team/game/components/entry/tooltip';
11
14
  import type { RecipeTextWidget } from '@terrafirmagreg-team/recipe/lib/data/dto';
12
15
  import type { RecipeHrefOpts } from '@terrafirmagreg-team/recipe/types';
@@ -126,33 +129,34 @@ export function CardStrip({
126
129
  interactive={interactive}
127
130
  tooltipLevel={tooltipLevel}
128
131
  />
129
- {widget.count !== undefined && widget.count > 1 ? (
130
- <span
131
- aria-hidden
132
- className="font-mc pointer-events-none absolute leading-none text-white"
133
- style={{
134
- left: widget.x * scale,
135
- top: (widget.y + widget.h - 8) * scale,
136
- width: widget.w * scale,
137
- paddingRight: scale,
138
- fontSize: 7 * scale,
139
- textAlign: 'right',
140
- textShadow: `${scale}px ${scale}px 0 var(--color-mc-arrow)`,
141
- }}
142
- >
143
- {formatCount(widget.count)}
144
- </span>
145
- ) : null}
146
132
  </Fragment>
147
133
  ))}
148
- {texts.map((widget, index) => (
149
- <CardText
150
- key={`${widget.x}:${widget.y}:${index}`}
151
- widget={widget}
152
- scale={scale}
153
- langMap={langMap}
154
- />
155
- ))}
134
+ {texts.map((widget, index) => {
135
+ const labelSlot = slotCoveredLabel(widget, geo.slots);
136
+ const overlaySlot = labelSlot ?? slotOverlay(widget, geo.slots);
137
+ const micro =
138
+ overlaySlot && widget.h <= 6
139
+ ? (Math.min(overlaySlot.w, overlaySlot.h) / 16) * 4 * scale
140
+ : undefined;
141
+ return (
142
+ <CardText
143
+ key={`${widget.x}:${widget.y}:${index}`}
144
+ widget={widget}
145
+ scale={scale}
146
+ langMap={langMap}
147
+ size={micro}
148
+ {...(labelSlot
149
+ ? {
150
+ anchor: {
151
+ x: labelSlot.x,
152
+ y: labelSlot.y,
153
+ w: labelSlot.w,
154
+ },
155
+ }
156
+ : {})}
157
+ />
158
+ );
159
+ })}
156
160
  </div>
157
161
  </div>
158
162
  <div
@@ -10,12 +10,16 @@ export function CardText({
10
10
  offY = 0,
11
11
  scale,
12
12
  langMap,
13
+ anchor,
14
+ size,
13
15
  }: {
14
16
  widget: RecipeTextWidget;
15
17
  offX?: number;
16
18
  offY?: number;
17
19
  scale: number;
18
20
  langMap?: Record<string, string>;
21
+ anchor?: { x: number; y: number; w: number };
22
+ size?: number;
19
23
  }) {
20
24
  const content = widget.component
21
25
  ? dumpTextString(langMap ?? {}, widget.component) || widget.text
@@ -28,9 +32,18 @@ export function CardText({
28
32
  <span
29
33
  className="font-mc pointer-events-none absolute leading-none whitespace-pre"
30
34
  style={{
31
- left: (widget.x + offX) * scale,
32
- top: (widget.y + offY) * scale,
33
- fontSize: Math.max(6, (widget.h - 1 || 8) * scale),
35
+ ...(anchor
36
+ ? {
37
+ left: (anchor.x + offX) * scale,
38
+ top: (anchor.y + offY) * scale,
39
+ width: anchor.w * scale,
40
+ textAlign: 'right' as const,
41
+ }
42
+ : {
43
+ left: (widget.x + offX) * scale,
44
+ top: (widget.y + offY) * scale,
45
+ }),
46
+ fontSize: size ?? 8 * scale,
34
47
  color: `#${rgb.toString(16).padStart(6, '0')}`,
35
48
  ...(shadowed
36
49
  ? {
@@ -326,7 +326,7 @@ export function ScrollCard(props: Props) {
326
326
  style={{
327
327
  left: horizontal ? shifted : x,
328
328
  top: horizontal ? y : shifted,
329
- fontSize: Math.max(6, (el.h - 1 || 8) * scale),
329
+ fontSize: 8 * scale,
330
330
  color: `#${rgb.toString(16).padStart(6, '0')}`,
331
331
  textShadow: `${scale}px ${scale}px 0 #${shadowRgb.toString(16).padStart(6, '0')}`,
332
332
  }}
@@ -414,7 +414,7 @@ export function ScrollCard(props: Props) {
414
414
  {el.label ? (
415
415
  <span
416
416
  className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white [text-shadow:1px_1px_0_var(--color-mc-arrow)]"
417
- style={{ fontSize: (el.w * scale) / 4 }}
417
+ style={{ fontSize: (el.w / 16) * 7 * scale }}
418
418
  >
419
419
  {el.label}
420
420
  </span>
@@ -8,6 +8,10 @@ import {
8
8
  type EntryTooltipLevel,
9
9
  } from '@terrafirmagreg-team/game/components/entry/tooltip';
10
10
  import { useCycleIndex } from '@terrafirmagreg-team/ui/hooks/use-cycle-index';
11
+ import {
12
+ formatCount,
13
+ formatFluidAmount,
14
+ } from '@terrafirmagreg-team/ui/lib/utils/format';
11
15
  import { stackDisplayName } from '@terrafirmagreg-team/game/lib/entry/display';
12
16
  import { entryHref } from '@terrafirmagreg-team/game/lib/entry/href';
13
17
  import { loadStackDisplay } from '@terrafirmagreg-team/game/lib/entry/tooltip';
@@ -138,6 +142,32 @@ export function SlotHitbox({
138
142
  width: widget.w * scale,
139
143
  height: widget.h * scale,
140
144
  };
145
+ const badge =
146
+ widget.count !== undefined && widget.count > 1 ? (
147
+ <span
148
+ aria-hidden
149
+ className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white"
150
+ style={{
151
+ paddingRight: scale,
152
+ paddingBottom: scale,
153
+ fontSize:
154
+ (Math.min(widget.w, widget.h) / 16) *
155
+ (widget.kind === 'fluid' ? 4 : 7) *
156
+ scale,
157
+ textShadow: `${scale}px ${scale}px 0 var(--color-mc-arrow)`,
158
+ }}
159
+ >
160
+ {widget.kind === 'fluid'
161
+ ? formatFluidAmount(widget.count)
162
+ : formatCount(widget.count, 1_000)}
163
+ </span>
164
+ ) : null;
165
+ const amountLine =
166
+ widget.kind === 'fluid' && widget.count !== undefined ? (
167
+ <p className="text-muted-foreground">
168
+ {widget.count.toLocaleString('en-US')} mB
169
+ </p>
170
+ ) : undefined;
141
171
  if (!interactive) {
142
172
 
143
173
  if (tooltipLevel === 'none') {
@@ -148,6 +178,7 @@ export function SlotHitbox({
148
178
  style={pos}
149
179
  >
150
180
  {icon}
181
+ {badge}
151
182
  </span>
152
183
  );
153
184
  }
@@ -160,6 +191,7 @@ export function SlotHitbox({
160
191
  lang={lang}
161
192
  langMap={langMap}
162
193
  level={tooltipLevel}
194
+ subheader={amountLine}
163
195
  >
164
196
  <span
165
197
  {...hover}
@@ -168,6 +200,7 @@ export function SlotHitbox({
168
200
  style={pos}
169
201
  >
170
202
  {icon}
203
+ {badge}
171
204
  </span>
172
205
  </EntryTooltip>
173
206
  );
@@ -181,10 +214,11 @@ export function SlotHitbox({
181
214
  lang={lang}
182
215
  langMap={langMap}
183
216
  level={tooltipLevel}
217
+ subheader={amountLine}
184
218
  >
185
219
  <span
186
220
  {...hover}
187
- className="absolute block"
221
+ className="absolute block cursor-pointer"
188
222
  style={pos}
189
223
  aria-label={name}
190
224
  >
@@ -202,9 +236,13 @@ export function SlotHitbox({
202
236
  className="absolute inset-0 block"
203
237
  >
204
238
  {icon}
239
+ {badge}
205
240
  </Link>
206
241
  ) : (
207
- <span className="absolute inset-0 block">{icon}</span>
242
+ <span className="absolute inset-0 block">
243
+ {icon}
244
+ {badge}
245
+ </span>
208
246
  )}
209
247
  </span>
210
248
  </EntryTooltip>
@@ -13,6 +13,10 @@ import { entryHref } from '@terrafirmagreg-team/game/lib/entry/href';
13
13
  import { loadStackDisplay } from '@terrafirmagreg-team/game/lib/entry/tooltip';
14
14
  import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
15
15
  import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
16
+ import {
17
+ formatCount,
18
+ formatFluidAmount,
19
+ } from '@terrafirmagreg-team/ui/lib/utils/format';
16
20
  import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
17
21
  import type { RecipeGridMember } from '@terrafirmagreg-team/recipe/lib/data/dto';
18
22
  import type { RecipeHrefOpts } from '@terrafirmagreg-team/recipe/types';
@@ -77,7 +81,11 @@ export function StripCardMember({
77
81
  stackRes.value.display === undefined;
78
82
  const badges: string[] = [];
79
83
  if (member.amount !== undefined && member.amount > 1) {
80
- badges.push(`×${member.amount}`);
84
+ badges.push(
85
+ kind === 'fluid'
86
+ ? formatFluidAmount(member.amount)
87
+ : `×${formatCount(member.amount, 1_000)}`,
88
+ );
81
89
  }
82
90
  if (member.chance !== undefined && member.chance < 1) {
83
91
  const percent = member.chance <= 1 ? member.chance * 100 : member.chance;
@@ -102,13 +110,19 @@ export function StripCardMember({
102
110
  {badges.length > 0 && (
103
111
  <span
104
112
  className="font-mc pointer-events-none absolute right-0 bottom-0 leading-none text-white [text-shadow:1px_1px_0_var(--color-mc-arrow)]"
105
- style={{ fontSize: pitch / 4 }}
113
+ style={{ fontSize: (pitch / 16) * (kind === 'fluid' ? 4 : 7) }}
106
114
  >
107
115
  {badges.join(' ')}
108
116
  </span>
109
117
  )}
110
118
  </>
111
119
  );
120
+ const subheader =
121
+ kind === 'fluid' && member.amount !== undefined ? (
122
+ <p className="text-muted-foreground">
123
+ {member.amount.toLocaleString('en-US')} mB
124
+ </p>
125
+ ) : undefined;
112
126
  const footer = tooltipLines?.length ? (
113
127
  <>
114
128
  {tooltipLines.map((line, index) => (
@@ -144,6 +158,7 @@ export function StripCardMember({
144
158
  lang={lang}
145
159
  langMap={langMap}
146
160
  level={tooltipLevel}
161
+ subheader={subheader}
147
162
  footer={footer}
148
163
  >
149
164
  <span
@@ -166,11 +181,12 @@ export function StripCardMember({
166
181
  lang={lang}
167
182
  langMap={langMap}
168
183
  level={tooltipLevel}
184
+ subheader={subheader}
169
185
  footer={footer}
170
186
  >
171
187
  <span
172
188
  {...hover}
173
- className="absolute block"
189
+ className="absolute block cursor-pointer"
174
190
  style={faceStyle}
175
191
  aria-label={name}
176
192
  >
@@ -112,7 +112,7 @@ function RecipeGridCard({
112
112
  return (
113
113
  <CopyIdMenu
114
114
  id={row.id}
115
- label="recipe.copy_recipe_id"
115
+ label={t('Copy recipe id', { note: 'recipe.copy_recipe_id' })}
116
116
  extra={
117
117
  <>
118
118
  <RecipeDefaultMenuItem
@@ -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
  );
@@ -4,9 +4,12 @@ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
4
4
  import {
5
5
  memo,
6
6
  useCallback,
7
+ useEffect,
8
+ useLayoutEffect,
7
9
  useMemo,
8
10
  useRef,
9
11
  useState,
12
+ type UIEvent,
10
13
  } from 'react';
11
14
  import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
12
15
  import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
@@ -14,13 +17,15 @@ import { useFavorites } from '@terrafirmagreg-team/recipe/hooks/use-favorites';
14
17
  import { useFavoriteHotkey } from '@terrafirmagreg-team/recipe/hooks/use-favorite-hotkey';
15
18
  import { useHideUnused } from '@terrafirmagreg-team/recipe/hooks/use-hide-unused';
16
19
  import { usePagedList } from '@terrafirmagreg-team/ui/hooks/page/use-paged-list';
17
- import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
18
20
  import { useElementSize } from '@terrafirmagreg-team/ui/hooks/use-element-size';
19
21
  import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty-state';
20
22
  import { type ItemPanelMode } from '@terrafirmagreg-team/recipe/lib/browser/panel';
21
23
  import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
22
24
  import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
23
- 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';
24
29
  import { IconPager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
25
30
  import { FavoriteButton } from '@terrafirmagreg-team/recipe/components/views/browser/favorite-button';
26
31
  import { ItemPanelGrid } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid';
@@ -48,6 +53,7 @@ import type {
48
53
 
49
54
  const CELL = 40;
50
55
  const PANEL_COLS = 10;
56
+ const PAGE_WINDOW = 5;
51
57
 
52
58
  export const ItemPanel = memo(function ItemPanel({
53
59
  dataset,
@@ -122,6 +128,27 @@ export const ItemPanel = memo(function ItemPanel({
122
128
  const resolved = useResolvedLang();
123
129
  const onPress = useItemPress({ dataset, nav, isCalc });
124
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
+
125
152
  const setTab = (next: string) => {
126
153
  setPanelPage(0);
127
154
  replaceUrlState(
@@ -132,11 +159,64 @@ export const ItemPanel = memo(function ItemPanel({
132
159
  );
133
160
  };
134
161
 
135
- const goPage = (dir: number) => {
136
- if (list.pages <= 1) return;
137
- setPanelPage((list.page + dir + list.pages) % list.pages);
162
+ const stripRef = useRef<HTMLDivElement | null>(null);
163
+ const fromScroll = useRef(false);
164
+ const pageRef = useRef(list.page);
165
+ pageRef.current = list.page;
166
+ const [startRaw, setStartRaw] = useState(list.page - (PAGE_WINDOW >> 1));
167
+ const maxStart = Math.max(0, list.pages - PAGE_WINDOW);
168
+ const start = Math.max(0, Math.min(startRaw, maxStart));
169
+ const windowPages = useMemo(() => {
170
+ const end = Math.min(list.pages, start + PAGE_WINDOW);
171
+ const out: number[] = [];
172
+ for (let i = start; i < end; i++) out.push(i);
173
+ return out;
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
+ );
180
+
181
+ useEffect(() => {
182
+ if (list.page < start || list.page > start + PAGE_WINDOW - 1) {
183
+ setStartRaw(list.page - (PAGE_WINDOW >> 1));
184
+ }
185
+ }, [list.page, start]);
186
+
187
+ useLayoutEffect(() => {
188
+ const el = stripRef.current;
189
+ if (!el || w <= 0) return;
190
+ const target = list.page * w;
191
+ if (Math.abs(el.scrollLeft - target) > 2) {
192
+ el.scrollTo({
193
+ left: target,
194
+ behavior: fromScroll.current ? 'instant' : 'smooth',
195
+ });
196
+ }
197
+ fromScroll.current = false;
198
+ }, [list.page, start, w]);
199
+
200
+ const idle = useRef<number | undefined>(undefined);
201
+ useEffect(() => () => window.clearTimeout(idle.current), []);
202
+
203
+ const onStripScroll = (event: UIEvent<HTMLDivElement>) => {
204
+ const el = event.currentTarget;
205
+ if (w <= 0) return;
206
+ const next = Math.max(
207
+ 0,
208
+ Math.min(list.pages - 1, Math.round(el.scrollLeft / w)),
209
+ );
210
+ if (next !== pageRef.current) {
211
+ fromScroll.current = true;
212
+ setPanelPage(next);
213
+ }
214
+ window.clearTimeout(idle.current);
215
+ idle.current = window.setTimeout(
216
+ () => setStartRaw(pageRef.current - (PAGE_WINDOW >> 1)),
217
+ 160,
218
+ );
138
219
  };
139
- const swipe = useSwipe(goPage);
140
220
 
141
221
  const tabOptions = usePanelTabs(dIndex, dNames, dLang);
142
222
 
@@ -161,23 +241,55 @@ export const ItemPanel = memo(function ItemPanel({
161
241
  );
162
242
  } else {
163
243
  body = (
164
- <ItemPanelGrid
165
- cells={list.shown}
166
- resetKey={gridResetKey}
167
- dataset={dataset}
168
- lang={dLang}
169
- names={dNames}
170
- nav={nav}
171
- cols={cols}
172
- rows={rows}
173
- favIds={favIds}
174
- onPress={onPress}
175
- onHover={(target) => {
176
- favoriteHover.base = target;
244
+ <div
245
+ ref={stripRef}
246
+ onScroll={onStripScroll}
247
+ onWheel={(event) => {
248
+ const el = stripRef.current;
249
+ if (!el || w <= 0) return;
250
+ el.scrollBy({
251
+ left: Math.sign(event.deltaY) * w,
252
+ behavior: 'smooth',
253
+ });
177
254
  }}
178
- onToggleGroup={onToggleGroup}
179
- draggableStacks={isCalc}
180
- />
255
+ className="flex h-full snap-x snap-mandatory overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
256
+ >
257
+ <div
258
+ aria-hidden
259
+ className="h-full shrink-0"
260
+ style={{ width: start * w }}
261
+ />
262
+ {windowPages.map((pageIndex, i) => (
263
+ <div
264
+ key={pageIndex}
265
+ className="h-full w-full shrink-0 snap-center"
266
+ >
267
+ <ItemPanelGrid
268
+ cells={windowCells[i]}
269
+ resetKey={gridResetKey}
270
+ dataset={dataset}
271
+ lang={dLang}
272
+ names={dNames}
273
+ nav={cellNav}
274
+ cols={cols}
275
+ rows={rows}
276
+ favIds={favIds}
277
+ onPress={onPress}
278
+ onHover={onHover}
279
+ onToggleGroup={onToggleGroup}
280
+ draggableStacks={isCalc}
281
+ />
282
+ </div>
283
+ ))}
284
+ <div
285
+ aria-hidden
286
+ className="h-full shrink-0"
287
+ style={{
288
+ width:
289
+ Math.max(0, list.pages - start - windowPages.length) * w,
290
+ }}
291
+ />
292
+ </div>
181
293
  );
182
294
  }
183
295
 
@@ -215,12 +327,7 @@ export const ItemPanel = memo(function ItemPanel({
215
327
  />
216
328
  }
217
329
  />
218
- <div
219
- ref={boxRef}
220
- {...swipe}
221
- onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
222
- className="min-h-0 flex-1"
223
- >
330
+ <div ref={boxRef} className="min-h-0 flex-1 overflow-hidden">
224
331
  {body}
225
332
  </div>
226
333
  <div className="mx-auto flex w-full max-w-md items-center gap-2">
@@ -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 {
@@ -38,14 +38,41 @@ export function cardStripGeo(
38
38
  return { slots: stripSlots, top, bottom, right, overflow, patchBottom, barTop };
39
39
  }
40
40
 
41
+ const COUNT_TEXT = /^x?(\d[\d\s.,]*)?\s*(mB|k|B|L|M)?$/i;
42
+
43
+ export function slotOverlay(
44
+ widget: RecipeTextWidget,
45
+ slots: RecipeSlotWidget[],
46
+ ): RecipeSlotWidget | undefined {
47
+ return slots.find(
48
+ (slot) => widget.x + widget.w > slot.x && widget.x < slot.x + slot.w,
49
+ );
50
+ }
51
+
41
52
  export function countCoveredText(
42
53
  widget: RecipeTextWidget,
43
- stripSlots: RecipeSlotWidget[],
54
+ slots: RecipeSlotWidget[],
44
55
  ): boolean {
45
- return stripSlots.some(
56
+ const match = widget.text
57
+ .replace(/§./g, '')
58
+ .trim()
59
+ .match(COUNT_TEXT);
60
+ if (!match?.[1]) return false;
61
+ const num = parseFloat(match[1].replace(/\s/g, '').replace(',', '.'));
62
+ if (!Number.isFinite(num)) return false;
63
+ const unit = (match[2] ?? '').toLowerCase();
64
+ const scales =
65
+ unit === 'b' || unit === 'l'
66
+ ? [1000, 1e9]
67
+ : unit === 'k'
68
+ ? [1000]
69
+ : unit === 'm'
70
+ ? [1e6]
71
+ : [1];
72
+ return slots.some(
46
73
  (slot) =>
47
74
  slot.count !== undefined &&
48
- String(slot.count) === widget.text &&
75
+ scales.some((scale) => Math.round(num * scale) === slot.count) &&
49
76
  widget.x + widget.w > slot.x &&
50
77
  widget.x < slot.x + slot.w,
51
78
  );
@@ -63,3 +90,11 @@ export function textInStrip(
63
90
  );
64
91
  }
65
92
 
93
+ export function slotCoveredLabel(
94
+ widget: RecipeTextWidget,
95
+ slots: RecipeSlotWidget[],
96
+ ): RecipeSlotWidget | undefined {
97
+ if (widget.text.replace(/§./g, '').trim() !== 'NC') return undefined;
98
+ return slotOverlay(widget, slots);
99
+ }
100
+
@@ -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'),