@terrafirmagreg-team/recipe 1.2.42 → 1.2.43
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 +4 -4
- package/src/components/views/browser/frame.tsx +10 -33
- package/src/components/views/browser/type-tabs.tsx +5 -0
- package/src/components/views/browser/type-view.tsx +1 -37
- package/src/components/views/calc/node-card/actions.tsx +1 -1
- package/src/components/views/calc/node-card/badges.tsx +1 -1
- package/src/components/views/calc/node-card/far.tsx +1 -1
- package/src/components/views/calc/node-card/full.tsx +1 -1
- package/src/components/views/calc/recipe-picker/body.tsx +1 -27
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.43",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Recipe viewer and calculator",
|
|
6
6
|
"license": "LGPL-3.0-only",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@terrafirmagreg-team/data": "^1.2.14",
|
|
27
27
|
"@terrafirmagreg-team/dump": "^1.2.25",
|
|
28
|
-
"@terrafirmagreg-team/game": "^1.2.
|
|
28
|
+
"@terrafirmagreg-team/game": "^1.2.18",
|
|
29
29
|
"@terrafirmagreg-team/kit": "^1.2.37",
|
|
30
30
|
"@terrafirmagreg-team/mdx": "^1.2.14",
|
|
31
31
|
"@terrafirmagreg-team/preview": "^1.2.12",
|
|
32
32
|
"@terrafirmagreg-team/sites": "^1.2.5",
|
|
33
|
-
"@terrafirmagreg-team/translate": "^1.2.
|
|
34
|
-
"@terrafirmagreg-team/ui": "^1.2.
|
|
33
|
+
"@terrafirmagreg-team/translate": "^1.2.17",
|
|
34
|
+
"@terrafirmagreg-team/ui": "^1.2.32",
|
|
35
35
|
"@types/pathfinding": "^0.1.0",
|
|
36
36
|
"comlink": "^4.4.2",
|
|
37
37
|
"fflate": "0.8.3",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import Link from 'next/link';
|
|
4
|
-
import type
|
|
4
|
+
import { useRef, type ReactNode } from 'react';
|
|
5
5
|
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
6
6
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
7
|
+
import { useElementSize } from '@terrafirmagreg-team/ui/hooks/use-element-size';
|
|
7
8
|
import { QueryPager } from '@terrafirmagreg-team/recipe/components/views/browser/query-controls';
|
|
8
9
|
import { Pager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
9
10
|
import { RecipeToolbar } from '@terrafirmagreg-team/recipe/components/views/browser/toolbar';
|
|
10
11
|
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
11
12
|
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
12
|
-
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
13
13
|
import type { RecipeSession } from '@terrafirmagreg-team/recipe/types';
|
|
14
14
|
|
|
15
15
|
type FeedList = {
|
|
@@ -27,9 +27,6 @@ export function RecipeFrame({
|
|
|
27
27
|
strip,
|
|
28
28
|
rail,
|
|
29
29
|
back,
|
|
30
|
-
navPrev,
|
|
31
|
-
navNext,
|
|
32
|
-
onNavWheel,
|
|
33
30
|
onPageChange,
|
|
34
31
|
children,
|
|
35
32
|
}: {
|
|
@@ -39,14 +36,13 @@ export function RecipeFrame({
|
|
|
39
36
|
strip?: ReactNode;
|
|
40
37
|
rail?: ReactNode;
|
|
41
38
|
back?: { href: string; label: string };
|
|
42
|
-
navPrev?: ReactNode;
|
|
43
|
-
navNext?: ReactNode;
|
|
44
|
-
onNavWheel?: (dir: -1 | 1) => void;
|
|
45
39
|
onPageChange?: (page: number) => void;
|
|
46
40
|
children: ReactNode;
|
|
47
41
|
}) {
|
|
48
42
|
const t = useTranslations();
|
|
49
43
|
const resolved = useResolvedLang();
|
|
44
|
+
const railBoxRef = useRef<HTMLDivElement | null>(null);
|
|
45
|
+
const railSize = useElementSize(railBoxRef);
|
|
50
46
|
const goPage = (dir: number) => {
|
|
51
47
|
if (!list || list.pages <= 1) return;
|
|
52
48
|
const next = (list.page + dir + list.pages) % list.pages;
|
|
@@ -71,14 +67,7 @@ export function RecipeFrame({
|
|
|
71
67
|
<div className="min-w-0 flex-1">{strip}</div>
|
|
72
68
|
</div>
|
|
73
69
|
) : null}
|
|
74
|
-
<div
|
|
75
|
-
className={cn(
|
|
76
|
-
'relative grid items-center gap-x-3 border-b border-border pb-2 pt-2 max-sm:pe-11',
|
|
77
|
-
navPrev || navNext
|
|
78
|
-
? 'grid-cols-[auto_minmax(0,1fr)_auto] sm:grid-cols-[minmax(0,1fr)_minmax(0,360px)_minmax(0,1fr)]'
|
|
79
|
-
: 'grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)]',
|
|
80
|
-
)}
|
|
81
|
-
>
|
|
70
|
+
<div className="relative grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] items-center gap-x-3 border-b border-border pb-2 pt-2 max-sm:pe-11">
|
|
82
71
|
<div className="flex min-w-0 justify-start">
|
|
83
72
|
{back ? (
|
|
84
73
|
<Link
|
|
@@ -89,22 +78,7 @@ export function RecipeFrame({
|
|
|
89
78
|
</Link>
|
|
90
79
|
) : null}
|
|
91
80
|
</div>
|
|
92
|
-
|
|
93
|
-
<div
|
|
94
|
-
onWheel={
|
|
95
|
-
onNavWheel
|
|
96
|
-
? (event) => onNavWheel(event.deltaY > 0 ? 1 : -1)
|
|
97
|
-
: undefined
|
|
98
|
-
}
|
|
99
|
-
className="flex w-full max-w-90 min-w-0 items-center gap-2"
|
|
100
|
-
>
|
|
101
|
-
{navPrev}
|
|
102
|
-
<div className="min-w-0 flex-1">{header}</div>
|
|
103
|
-
{navNext}
|
|
104
|
-
</div>
|
|
105
|
-
) : (
|
|
106
|
-
<div className="min-w-0 max-w-full">{header}</div>
|
|
107
|
-
)}
|
|
81
|
+
<div className="min-w-0 max-w-full">{header}</div>
|
|
108
82
|
<div className="flex min-w-0 items-center justify-self-end max-sm:absolute max-sm:end-1.5 max-sm:top-1/2 max-sm:-translate-y-1/2">
|
|
109
83
|
<RecipeToolbar session={session} />
|
|
110
84
|
</div>
|
|
@@ -136,11 +110,14 @@ export function RecipeFrame({
|
|
|
136
110
|
) : null}
|
|
137
111
|
<div className="relative flex min-h-0 flex-1 overflow-hidden pt-2">
|
|
138
112
|
{rail ? (
|
|
139
|
-
<div className="z-10 flex shrink-0 flex-col">
|
|
113
|
+
<div ref={railBoxRef} className="z-10 flex shrink-0 flex-col">
|
|
114
|
+
{rail}
|
|
115
|
+
</div>
|
|
140
116
|
) : null}
|
|
141
117
|
<div
|
|
142
118
|
onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
|
|
143
119
|
className="flex min-w-0 flex-1 flex-col"
|
|
120
|
+
style={rail ? { paddingInlineEnd: railSize.w } : undefined}
|
|
144
121
|
>
|
|
145
122
|
{children}
|
|
146
123
|
</div>
|
|
@@ -7,6 +7,7 @@ import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
|
7
7
|
import { creativeTabName } from '@terrafirmagreg-team/dump/lib/dump/assets/lang/names';
|
|
8
8
|
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
9
9
|
import { IconPager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
10
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
10
11
|
import type { RecipeCategory, RecipeSession } from '@terrafirmagreg-team/recipe/types';
|
|
11
12
|
|
|
12
13
|
function CategoryGlyph({
|
|
@@ -48,6 +49,7 @@ export function RecipeTypeTabs({
|
|
|
48
49
|
className?: string;
|
|
49
50
|
}) {
|
|
50
51
|
const { lang, names, index, dataset, langMap } = session;
|
|
52
|
+
const t = useTranslations();
|
|
51
53
|
|
|
52
54
|
const options = useMemo(() => {
|
|
53
55
|
const byId = new Map(
|
|
@@ -72,6 +74,9 @@ export function RecipeTypeTabs({
|
|
|
72
74
|
value={value}
|
|
73
75
|
options={options}
|
|
74
76
|
onChange={onChange ?? (() => {})}
|
|
77
|
+
step="option"
|
|
78
|
+
prevLabel={t('Previous category', { note: 'recipe.axis.prev' })}
|
|
79
|
+
nextLabel={t('Next category', { note: 'recipe.axis.next' })}
|
|
75
80
|
className={className}
|
|
76
81
|
/>
|
|
77
82
|
);
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useEffect, useRef } from 'react';
|
|
4
|
-
import { PagerArrow } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
5
4
|
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
6
5
|
import { useResolvedLang } from '@terrafirmagreg-team/translate/hooks/use-resolved-lang';
|
|
7
6
|
import { useAsyncResult } from '@terrafirmagreg-team/ui/hooks/use-async-value';
|
|
@@ -103,22 +102,6 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
103
102
|
!grid,
|
|
104
103
|
);
|
|
105
104
|
|
|
106
|
-
const goCategory = (dir: -1 | 1) => {
|
|
107
|
-
const cur = nonEmptyIds.indexOf(shown ?? '');
|
|
108
|
-
const next =
|
|
109
|
-
nonEmptyIds[(cur + dir + nonEmptyIds.length) % nonEmptyIds.length];
|
|
110
|
-
if (!next || next === shown) return;
|
|
111
|
-
replaceUrlState(
|
|
112
|
-
recipeHref(dataset, resolved, {
|
|
113
|
-
...nav,
|
|
114
|
-
type: next,
|
|
115
|
-
id: undefined,
|
|
116
|
-
solo: undefined,
|
|
117
|
-
rpage: undefined,
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
120
|
-
};
|
|
121
|
-
|
|
122
105
|
const onSwipe = (dir: -1 | 1) => {
|
|
123
106
|
if (recipeId) {
|
|
124
107
|
const next = focusIndex + dir;
|
|
@@ -182,27 +165,8 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
182
165
|
}}
|
|
183
166
|
/>
|
|
184
167
|
}
|
|
185
|
-
navPrev={
|
|
186
|
-
<PagerArrow
|
|
187
|
-
dir={-1}
|
|
188
|
-
label={t('Previous category', { note: 'recipe.axis.prev' })}
|
|
189
|
-
disabled={nonEmptyIds.length < 2}
|
|
190
|
-
className="max-sm:hidden"
|
|
191
|
-
onClick={() => goCategory(-1)}
|
|
192
|
-
/>
|
|
193
|
-
}
|
|
194
|
-
navNext={
|
|
195
|
-
<PagerArrow
|
|
196
|
-
dir={1}
|
|
197
|
-
label={t('Next category', { note: 'recipe.axis.next' })}
|
|
198
|
-
disabled={nonEmptyIds.length < 2}
|
|
199
|
-
className="max-sm:hidden"
|
|
200
|
-
onClick={() => goCategory(1)}
|
|
201
|
-
/>
|
|
202
|
-
}
|
|
203
|
-
onNavWheel={goCategory}
|
|
204
168
|
header={
|
|
205
|
-
<div className="
|
|
169
|
+
<div className="mx-auto w-full max-w-90">
|
|
206
170
|
<PlaceHeader
|
|
207
171
|
session={session}
|
|
208
172
|
overline={t('Categories', { note: 'recipe.axis_type' })}
|
|
@@ -29,7 +29,7 @@ export function NodeActions({
|
|
|
29
29
|
const canPick = node.recipe != null || node.availableRecipes.length > 0;
|
|
30
30
|
|
|
31
31
|
return (
|
|
32
|
-
<span className="pointer-events-auto absolute -top-2 right-3 z-30 flex gap-0.5">
|
|
32
|
+
<span className="pointer-events-auto absolute -top-2.5 right-3 z-30 flex gap-0.5">
|
|
33
33
|
{canPick ? (
|
|
34
34
|
<Hint label={t('Pick a recipe', { note: 'recipe.calc.pick.title' })} side="top">
|
|
35
35
|
<button
|
|
@@ -65,7 +65,7 @@ export function NodeBadges({
|
|
|
65
65
|
}
|
|
66
66
|
if (!chips.length) return null;
|
|
67
67
|
return (
|
|
68
|
-
<span className="pointer-events-auto absolute right-3 -bottom-
|
|
68
|
+
<span className="pointer-events-auto absolute right-3 -bottom-2 z-30 flex flex-col-reverse items-end gap-0.5">
|
|
69
69
|
{chips}
|
|
70
70
|
</span>
|
|
71
71
|
);
|
|
@@ -91,7 +91,7 @@ export function CalcFarCard({ data, selected }: NodeProps<CalcFlowNode>) {
|
|
|
91
91
|
event.stopPropagation();
|
|
92
92
|
onRequestPicker(node);
|
|
93
93
|
}}
|
|
94
|
-
className={cn(CORNER_BUTTON, 'absolute -top-2 right-1')}
|
|
94
|
+
className={cn(CORNER_BUTTON, 'absolute -top-2.5 right-1')}
|
|
95
95
|
>
|
|
96
96
|
<ListFilter className="size-2.5" />
|
|
97
97
|
</button>
|
|
@@ -411,7 +411,7 @@ export const CalcNodeCardFull = memo(function CalcNodeCardFull({
|
|
|
411
411
|
/>
|
|
412
412
|
{interactive ? <NodeActions data={data} nodeId={id} /> : null}
|
|
413
413
|
{showIds && body ? (
|
|
414
|
-
<span className="nodrag absolute -bottom-2 left-3 z-30 flex">
|
|
414
|
+
<span className="nodrag absolute -bottom-2.5 left-3 z-30 flex">
|
|
415
415
|
<span className="inline-flex max-w-full items-center gap-0.5 rounded-sm border border-border bg-background px-1 py-px shadow-sm">
|
|
416
416
|
<code className="truncate text-[8px] leading-tight text-muted-foreground">
|
|
417
417
|
{body.id}
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
DialogTitle,
|
|
12
12
|
} from '@terrafirmagreg-team/ui/components/ui/dialog';
|
|
13
13
|
import { Button } from '@terrafirmagreg-team/ui/components/ui/button';
|
|
14
|
-
import { PagerArrow } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
15
14
|
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
16
15
|
import { RecipeFrame } from '@terrafirmagreg-team/recipe/components/views/browser/frame';
|
|
17
16
|
import { RecipeCardGrid } from '@terrafirmagreg-team/recipe/components/views/browser/card-grid';
|
|
@@ -100,14 +99,6 @@ export function PickerBody({
|
|
|
100
99
|
setPinned(false);
|
|
101
100
|
setPage(next);
|
|
102
101
|
};
|
|
103
|
-
const goCategory = (dir: -1 | 1) => {
|
|
104
|
-
const cur = categories.indexOf(active ?? '');
|
|
105
|
-
const next =
|
|
106
|
-
categories[(cur + dir + categories.length) % categories.length];
|
|
107
|
-
if (!next || next === active) return;
|
|
108
|
-
setTab(next);
|
|
109
|
-
goPage(0);
|
|
110
|
-
};
|
|
111
102
|
const custom =
|
|
112
103
|
!!node.recipe &&
|
|
113
104
|
node.recipe.recipeId !== (defaultRecipeId ?? recipes[0]?.recipeId);
|
|
@@ -170,25 +161,8 @@ export function PickerBody({
|
|
|
170
161
|
}}
|
|
171
162
|
/>
|
|
172
163
|
}
|
|
173
|
-
navPrev={
|
|
174
|
-
<PagerArrow
|
|
175
|
-
dir={-1}
|
|
176
|
-
label={t('Previous category', { note: 'recipe.axis.prev' })}
|
|
177
|
-
disabled={categories.length < 2}
|
|
178
|
-
onClick={() => goCategory(-1)}
|
|
179
|
-
/>
|
|
180
|
-
}
|
|
181
|
-
navNext={
|
|
182
|
-
<PagerArrow
|
|
183
|
-
dir={1}
|
|
184
|
-
label={t('Next category', { note: 'recipe.axis.next' })}
|
|
185
|
-
disabled={categories.length < 2}
|
|
186
|
-
onClick={() => goCategory(1)}
|
|
187
|
-
/>
|
|
188
|
-
}
|
|
189
|
-
onNavWheel={goCategory}
|
|
190
164
|
header={
|
|
191
|
-
<div className="
|
|
165
|
+
<div className="mx-auto w-full max-w-90">
|
|
192
166
|
<PlaceHeader
|
|
193
167
|
session={frameSession}
|
|
194
168
|
overline={t('Categories', { note: 'recipe.axis_type' })}
|