@terrafirmagreg-team/recipe 1.2.24 → 1.2.26

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.24",
3
+ "version": "1.2.26",
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.11",
27
- "@terrafirmagreg-team/dump": "^1.2.18",
26
+ "@terrafirmagreg-team/data": "^1.2.13",
27
+ "@terrafirmagreg-team/dump": "^1.2.19",
28
28
  "@terrafirmagreg-team/game": "^1.2.10",
29
- "@terrafirmagreg-team/kit": "^1.2.26",
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
33
  "@terrafirmagreg-team/translate": "^1.2.12",
34
- "@terrafirmagreg-team/ui": "^1.2.17",
34
+ "@terrafirmagreg-team/ui": "^1.2.18",
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,10 +8,13 @@ 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';
14
- import { texturePublicUrl } from '@terrafirmagreg-team/dump/lib/dump/assets/urls';
15
18
  import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/browser/favorite-hover';
16
19
  import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
17
20
  import type { ReferenceKind } from '@terrafirmagreg-team/dump/lib/dump/contract/ref';
@@ -115,11 +118,6 @@ export function SlotHitbox({
115
118
  ? widget.tagKind
116
119
  : undefined
117
120
  : widgetRefKind(widget);
118
- const chanceUrl =
119
- dataset && (alternatives?.length ?? 0) > 1
120
- ? texturePublicUrl(dataset, 'emi:textures/gui/widgets.png')
121
- : undefined;
122
- const chance = widget.w >= 26 ? { u: 19, v: 27 } : { u: 1, v: 19 };
123
121
  const icon = (
124
122
  <span className="pointer-events-none flex size-full items-center justify-center">
125
123
  {alternatives && alternatives.length > 1 ? (
@@ -127,19 +125,7 @@ export function SlotHitbox({
127
125
  aria-hidden
128
126
  className="absolute bg-mc-inset"
129
127
  style={{ inset: scale }}
130
- >
131
- {chanceUrl ? (
132
- <span
133
- className="absolute inset-0 block"
134
- style={{
135
- backgroundImage: `url(${chanceUrl})`,
136
- backgroundSize: `${256 * scale}px ${256 * scale}px`,
137
- backgroundPosition: `-${chance.u * scale}px -${chance.v * scale}px`,
138
- imageRendering: 'pixelated',
139
- }}
140
- />
141
- ) : null}
142
- </span>
128
+ />
143
129
  ) : null}
144
130
  <EntryIcon
145
131
  id={iconId}
@@ -156,6 +142,32 @@ export function SlotHitbox({
156
142
  width: widget.w * scale,
157
143
  height: widget.h * scale,
158
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;
159
171
  if (!interactive) {
160
172
 
161
173
  if (tooltipLevel === 'none') {
@@ -166,6 +178,7 @@ export function SlotHitbox({
166
178
  style={pos}
167
179
  >
168
180
  {icon}
181
+ {badge}
169
182
  </span>
170
183
  );
171
184
  }
@@ -178,6 +191,7 @@ export function SlotHitbox({
178
191
  lang={lang}
179
192
  langMap={langMap}
180
193
  level={tooltipLevel}
194
+ subheader={amountLine}
181
195
  >
182
196
  <span
183
197
  {...hover}
@@ -186,6 +200,7 @@ export function SlotHitbox({
186
200
  style={pos}
187
201
  >
188
202
  {icon}
203
+ {badge}
189
204
  </span>
190
205
  </EntryTooltip>
191
206
  );
@@ -199,10 +214,11 @@ export function SlotHitbox({
199
214
  lang={lang}
200
215
  langMap={langMap}
201
216
  level={tooltipLevel}
217
+ subheader={amountLine}
202
218
  >
203
219
  <span
204
220
  {...hover}
205
- className="absolute block"
221
+ className="absolute block cursor-pointer"
206
222
  style={pos}
207
223
  aria-label={name}
208
224
  >
@@ -220,9 +236,13 @@ export function SlotHitbox({
220
236
  className="absolute inset-0 block"
221
237
  >
222
238
  {icon}
239
+ {badge}
223
240
  </Link>
224
241
  ) : (
225
- <span className="absolute inset-0 block">{icon}</span>
242
+ <span className="absolute inset-0 block">
243
+ {icon}
244
+ {badge}
245
+ </span>
226
246
  )}
227
247
  </span>
228
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
@@ -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,7 +17,6 @@ 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';
@@ -48,6 +50,7 @@ import type {
48
50
 
49
51
  const CELL = 40;
50
52
  const PANEL_COLS = 10;
53
+ const PAGE_WINDOW = 5;
51
54
 
52
55
  export const ItemPanel = memo(function ItemPanel({
53
56
  dataset,
@@ -132,11 +135,59 @@ export const ItemPanel = memo(function ItemPanel({
132
135
  );
133
136
  };
134
137
 
135
- const goPage = (dir: number) => {
136
- if (list.pages <= 1) return;
137
- setPanelPage((list.page + dir + list.pages) % list.pages);
138
+ const stripRef = useRef<HTMLDivElement | null>(null);
139
+ const fromScroll = useRef(false);
140
+ const pageRef = useRef(list.page);
141
+ pageRef.current = list.page;
142
+ const [startRaw, setStartRaw] = useState(list.page - (PAGE_WINDOW >> 1));
143
+ const maxStart = Math.max(0, list.pages - PAGE_WINDOW);
144
+ const start = Math.max(0, Math.min(startRaw, maxStart));
145
+ const windowPages = useMemo(() => {
146
+ const end = Math.min(list.pages, start + PAGE_WINDOW);
147
+ const out: number[] = [];
148
+ for (let i = start; i < end; i++) out.push(i);
149
+ return out;
150
+ }, [start, list.pages]);
151
+
152
+ useEffect(() => {
153
+ if (list.page < start || list.page > start + PAGE_WINDOW - 1) {
154
+ setStartRaw(list.page - (PAGE_WINDOW >> 1));
155
+ }
156
+ }, [list.page, start]);
157
+
158
+ useLayoutEffect(() => {
159
+ const el = stripRef.current;
160
+ if (!el || w <= 0) return;
161
+ const target = list.page * w;
162
+ if (Math.abs(el.scrollLeft - target) > 2) {
163
+ el.scrollTo({
164
+ left: target,
165
+ behavior: fromScroll.current ? 'instant' : 'smooth',
166
+ });
167
+ }
168
+ fromScroll.current = false;
169
+ }, [list.page, start, w]);
170
+
171
+ const idle = useRef<number | undefined>(undefined);
172
+ useEffect(() => () => window.clearTimeout(idle.current), []);
173
+
174
+ const onStripScroll = (event: UIEvent<HTMLDivElement>) => {
175
+ const el = event.currentTarget;
176
+ if (w <= 0) return;
177
+ const next = Math.max(
178
+ 0,
179
+ Math.min(list.pages - 1, Math.round(el.scrollLeft / w)),
180
+ );
181
+ if (next !== pageRef.current) {
182
+ fromScroll.current = true;
183
+ setPanelPage(next);
184
+ }
185
+ window.clearTimeout(idle.current);
186
+ idle.current = window.setTimeout(
187
+ () => setStartRaw(pageRef.current - (PAGE_WINDOW >> 1)),
188
+ 160,
189
+ );
138
190
  };
139
- const swipe = useSwipe(goPage);
140
191
 
141
192
  const tabOptions = usePanelTabs(dIndex, dNames, dLang);
142
193
 
@@ -161,23 +212,60 @@ export const ItemPanel = memo(function ItemPanel({
161
212
  );
162
213
  } else {
163
214
  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;
215
+ <div
216
+ ref={stripRef}
217
+ onScroll={onStripScroll}
218
+ onWheel={(event) => {
219
+ const el = stripRef.current;
220
+ if (!el || w <= 0) return;
221
+ el.scrollBy({
222
+ left: Math.sign(event.deltaY) * w,
223
+ behavior: 'smooth',
224
+ });
177
225
  }}
178
- onToggleGroup={onToggleGroup}
179
- draggableStacks={isCalc}
180
- />
226
+ className="flex h-full snap-x snap-mandatory overflow-x-auto overscroll-x-contain [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
227
+ >
228
+ <div
229
+ aria-hidden
230
+ className="h-full shrink-0"
231
+ style={{ width: start * w }}
232
+ />
233
+ {windowPages.map((pageIndex) => (
234
+ <div
235
+ key={pageIndex}
236
+ className="h-full w-full shrink-0 snap-center"
237
+ >
238
+ <ItemPanelGrid
239
+ cells={cells.slice(
240
+ pageIndex * pageSize,
241
+ (pageIndex + 1) * pageSize,
242
+ )}
243
+ resetKey={gridResetKey}
244
+ dataset={dataset}
245
+ lang={dLang}
246
+ names={dNames}
247
+ nav={nav}
248
+ cols={cols}
249
+ rows={rows}
250
+ favIds={favIds}
251
+ onPress={onPress}
252
+ onHover={(target) => {
253
+ favoriteHover.base = target;
254
+ }}
255
+ onToggleGroup={onToggleGroup}
256
+ draggableStacks={isCalc}
257
+ />
258
+ </div>
259
+ ))}
260
+ <div
261
+ aria-hidden
262
+ className="h-full shrink-0"
263
+ style={{
264
+ width:
265
+ Math.max(0, list.pages - start - windowPages.length) * w,
266
+ }}
267
+ />
268
+ </div>
181
269
  );
182
270
  }
183
271
 
@@ -215,12 +303,7 @@ export const ItemPanel = memo(function ItemPanel({
215
303
  />
216
304
  }
217
305
  />
218
- <div
219
- ref={boxRef}
220
- {...swipe}
221
- onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
222
- className="min-h-0 flex-1"
223
- >
306
+ <div ref={boxRef} className="min-h-0 flex-1 overflow-hidden">
224
307
  {body}
225
308
  </div>
226
309
  <div className="mx-auto flex w-full max-w-md items-center gap-2">
@@ -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
+