@terrafirmagreg-team/recipe 1.2.42 → 1.2.44
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 +6 -5
- package/src/components/cards/calc-add-item.tsx +2 -1
- package/src/components/views/browser/frame.tsx +46 -42
- package/src/components/views/browser/query-controls.tsx +6 -1
- package/src/components/views/browser/type-tabs.tsx +5 -0
- package/src/components/views/browser/type-view.tsx +22 -39
- package/src/components/views/calc/calculator/help.tsx +6 -6
- package/src/components/views/calc/calculator/index.tsx +29 -6
- package/src/components/views/calc/edge.tsx +197 -113
- package/src/components/views/calc/flow/index.tsx +120 -39
- package/src/components/views/calc/flow/notes.tsx +282 -0
- package/src/components/views/calc/flow/toolbar.tsx +46 -1
- package/src/components/views/calc/flow/view-menu.tsx +11 -0
- package/src/components/views/calc/material-picker.tsx +112 -0
- package/src/components/views/calc/node-card/actions.tsx +1 -1
- package/src/components/views/calc/node-card/badges.tsx +3 -3
- package/src/components/views/calc/node-card/far.tsx +1 -1
- package/src/components/views/calc/node-card/full.tsx +14 -3
- package/src/components/views/calc/node-card/menu.tsx +0 -17
- package/src/components/views/calc/node-card/port-cells.tsx +4 -4
- package/src/components/views/calc/node-card/ports.tsx +6 -1
- package/src/components/views/calc/recipe-picker/body.tsx +22 -32
- package/src/components/views/calc/recipe-picker/footer.tsx +1 -28
- package/src/hooks/calc/flow/use-handlers.ts +21 -14
- package/src/hooks/calc/flow/use-layout.ts +7 -7
- package/src/hooks/calc/flow/use-shift-held.ts +25 -0
- package/src/hooks/calc/use-actions.ts +126 -61
- package/src/hooks/calc/use-amounts.ts +8 -5
- package/src/hooks/calc/use-data.ts +11 -8
- package/src/hooks/calc/use-history.ts +98 -0
- package/src/hooks/calc/use-pipe-edit.ts +21 -0
- package/src/hooks/calc/use-snap.ts +17 -0
- package/src/hooks/calc/use-storage.ts +2 -1
- package/src/hooks/use-add-to-calc.ts +2 -1
- package/src/hooks/use-item-press.ts +4 -2
- package/src/hooks/use-query.ts +22 -1
- package/src/hooks/use-session.ts +2 -0
- package/src/lib/browser/row-search.test.ts +55 -0
- package/src/lib/browser/row-search.ts +24 -0
- package/src/lib/calc/flow.ts +31 -26
- package/src/lib/calc/member.test.ts +5 -5
- package/src/lib/calc/pack.ts +6 -6
- package/src/lib/calc/{wire.test.ts → pipe.test.ts} +5 -5
- package/src/lib/calc/{wire.ts → pipe.ts} +9 -9
- package/src/lib/calc/route/index.ts +1 -0
- package/src/lib/calc/scheme.test.ts +7 -7
- package/src/lib/calc/scheme.ts +16 -15
- package/src/lib/calc/storage/entry.test.ts +66 -0
- package/src/lib/calc/storage/entry.ts +29 -7
- package/src/lib/calc/storage/store.ts +3 -1
- package/src/lib/calc/tree/share.test.ts +102 -0
- package/src/lib/calc/tree/share.ts +43 -13
- package/src/lib/links.ts +3 -0
- package/src/types/calc-flow-props.ts +13 -2
- package/src/types/calc.ts +23 -3
- package/src/types/index.ts +3 -0
- package/styles/calc.css +65 -39
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@terrafirmagreg-team/recipe",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.44",
|
|
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.33",
|
|
35
35
|
"@types/pathfinding": "^0.1.0",
|
|
36
36
|
"comlink": "^4.4.2",
|
|
37
37
|
"fflate": "0.8.3",
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"fumadocs-core": ">=16",
|
|
44
44
|
"next": ">=15",
|
|
45
|
-
"react": ">=19"
|
|
45
|
+
"react": ">=19",
|
|
46
|
+
"react-dom": ">=19"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@types/node": "^26.6.6",
|
|
@@ -1,15 +1,18 @@
|
|
|
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 {
|
|
7
|
+
import { useElementSize } from '@terrafirmagreg-team/ui/hooks/use-element-size';
|
|
8
|
+
import {
|
|
9
|
+
QueryPager,
|
|
10
|
+
QuerySearch,
|
|
11
|
+
} from '@terrafirmagreg-team/recipe/components/views/browser/query-controls';
|
|
8
12
|
import { Pager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
9
13
|
import { RecipeToolbar } from '@terrafirmagreg-team/recipe/components/views/browser/toolbar';
|
|
10
14
|
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
11
15
|
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
12
|
-
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
13
16
|
import type { RecipeSession } from '@terrafirmagreg-team/recipe/types';
|
|
14
17
|
|
|
15
18
|
type FeedList = {
|
|
@@ -27,9 +30,8 @@ export function RecipeFrame({
|
|
|
27
30
|
strip,
|
|
28
31
|
rail,
|
|
29
32
|
back,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
onNavWheel,
|
|
33
|
+
search,
|
|
34
|
+
searchPersist = true,
|
|
33
35
|
onPageChange,
|
|
34
36
|
children,
|
|
35
37
|
}: {
|
|
@@ -39,29 +41,35 @@ export function RecipeFrame({
|
|
|
39
41
|
strip?: ReactNode;
|
|
40
42
|
rail?: ReactNode;
|
|
41
43
|
back?: { href: string; label: string };
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
onNavWheel?: (dir: -1 | 1) => void;
|
|
44
|
+
search?: boolean;
|
|
45
|
+
searchPersist?: boolean;
|
|
45
46
|
onPageChange?: (page: number) => void;
|
|
46
47
|
children: ReactNode;
|
|
47
48
|
}) {
|
|
48
49
|
const t = useTranslations();
|
|
49
50
|
const resolved = useResolvedLang();
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
const railBoxRef = useRef<HTMLDivElement | null>(null);
|
|
52
|
+
const railSize = useElementSize(railBoxRef);
|
|
53
|
+
const setPage = (next: number) => {
|
|
54
|
+
if (!list) return;
|
|
55
|
+
const clamped = Math.min(list.pages - 1, Math.max(0, next));
|
|
56
|
+
if (clamped === list.page) return;
|
|
53
57
|
if (onPageChange) {
|
|
54
|
-
onPageChange(
|
|
58
|
+
onPageChange(clamped);
|
|
55
59
|
return;
|
|
56
60
|
}
|
|
57
61
|
replaceUrlState(
|
|
58
62
|
recipeHref(session.dataset, resolved, {
|
|
59
63
|
...session.nav,
|
|
60
64
|
id: undefined,
|
|
61
|
-
rpage:
|
|
65
|
+
rpage: clamped > 0 ? clamped + 1 : undefined,
|
|
62
66
|
}),
|
|
63
67
|
);
|
|
64
68
|
};
|
|
69
|
+
const goPage = (dir: number) => {
|
|
70
|
+
if (!list || list.pages <= 1) return;
|
|
71
|
+
setPage((list.page + dir + list.pages) % list.pages);
|
|
72
|
+
};
|
|
65
73
|
const onPagerWheel = (event: { deltaY: number }) =>
|
|
66
74
|
goPage(event.deltaY > 0 ? 1 : -1);
|
|
67
75
|
return (
|
|
@@ -71,14 +79,7 @@ export function RecipeFrame({
|
|
|
71
79
|
<div className="min-w-0 flex-1">{strip}</div>
|
|
72
80
|
</div>
|
|
73
81
|
) : 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
|
-
>
|
|
82
|
+
<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
83
|
<div className="flex min-w-0 justify-start">
|
|
83
84
|
{back ? (
|
|
84
85
|
<Link
|
|
@@ -89,28 +90,13 @@ export function RecipeFrame({
|
|
|
89
90
|
</Link>
|
|
90
91
|
) : null}
|
|
91
92
|
</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
|
-
)}
|
|
93
|
+
<div className="min-w-0 max-w-full">{header}</div>
|
|
108
94
|
<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
95
|
<RecipeToolbar session={session} />
|
|
110
96
|
</div>
|
|
111
97
|
</div>
|
|
112
98
|
{list ? (
|
|
113
|
-
<div onWheel={onPagerWheel} className="mx-auto w-full sm:max-w-90">
|
|
99
|
+
<div onWheel={onPagerWheel} className="mx-auto w-full pt-2 sm:max-w-90">
|
|
114
100
|
{onPageChange ? (
|
|
115
101
|
<Pager
|
|
116
102
|
layout="spread"
|
|
@@ -119,7 +105,6 @@ export function RecipeFrame({
|
|
|
119
105
|
to={list.to}
|
|
120
106
|
total={list.total}
|
|
121
107
|
label={t('{page}/{pages}', { note: 'recipe.page_of' })}
|
|
122
|
-
className="pt-2"
|
|
123
108
|
onPage={onPageChange}
|
|
124
109
|
/>
|
|
125
110
|
) : (
|
|
@@ -129,22 +114,41 @@ export function RecipeFrame({
|
|
|
129
114
|
query={session.query}
|
|
130
115
|
list={list}
|
|
131
116
|
label={t('{page}/{pages}', { note: 'recipe.page_of' })}
|
|
132
|
-
className="pt-2"
|
|
133
117
|
/>
|
|
134
118
|
)}
|
|
135
119
|
</div>
|
|
136
120
|
) : null}
|
|
137
121
|
<div className="relative flex min-h-0 flex-1 overflow-hidden pt-2">
|
|
138
122
|
{rail ? (
|
|
139
|
-
<div className="z-10 flex shrink-0 flex-col">
|
|
123
|
+
<div ref={railBoxRef} className="z-10 flex shrink-0 flex-col">
|
|
124
|
+
{rail}
|
|
125
|
+
</div>
|
|
140
126
|
) : null}
|
|
141
127
|
<div
|
|
142
128
|
onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
|
|
143
129
|
className="flex min-w-0 flex-1 flex-col"
|
|
130
|
+
style={rail ? { paddingInlineEnd: railSize.w } : undefined}
|
|
144
131
|
>
|
|
145
132
|
{children}
|
|
146
133
|
</div>
|
|
147
134
|
</div>
|
|
135
|
+
{search ? (
|
|
136
|
+
<div className="flex shrink-0 justify-center pb-1 pt-1.5">
|
|
137
|
+
<div className="w-56 sm:w-72">
|
|
138
|
+
<QuerySearch
|
|
139
|
+
dataset={session.dataset}
|
|
140
|
+
param="rsearch"
|
|
141
|
+
params={{ ...session.nav, id: undefined, rpage: undefined }}
|
|
142
|
+
query={session.rquery}
|
|
143
|
+
onQuery={session.setRquery}
|
|
144
|
+
persist={searchPersist}
|
|
145
|
+
placeholder={t('Search materials', {
|
|
146
|
+
note: 'recipe.search_materials',
|
|
147
|
+
})}
|
|
148
|
+
/>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
) : null}
|
|
148
152
|
</div>
|
|
149
153
|
);
|
|
150
154
|
}
|
|
@@ -23,15 +23,19 @@ type QueryNav = {
|
|
|
23
23
|
export function QuerySearch({
|
|
24
24
|
dataset,
|
|
25
25
|
params,
|
|
26
|
+
param = 'search',
|
|
26
27
|
query,
|
|
27
28
|
onQuery,
|
|
28
29
|
placeholder,
|
|
29
30
|
className,
|
|
31
|
+
persist = true,
|
|
30
32
|
}: QueryNav & {
|
|
33
|
+
param?: 'search' | 'rsearch';
|
|
31
34
|
query: string;
|
|
32
35
|
onQuery: (query: string) => void;
|
|
33
36
|
placeholder?: string;
|
|
34
37
|
className?: string;
|
|
38
|
+
persist?: boolean;
|
|
35
39
|
}) {
|
|
36
40
|
const resolved = useResolvedLang();
|
|
37
41
|
return (
|
|
@@ -46,10 +50,11 @@ export function QuerySearch({
|
|
|
46
50
|
onChange={(event) => {
|
|
47
51
|
const next = event.target.value;
|
|
48
52
|
onQuery(next);
|
|
53
|
+
if (!persist) return;
|
|
49
54
|
replaceUrlState(
|
|
50
55
|
recipeHref(dataset, resolved, {
|
|
51
56
|
...params,
|
|
52
|
-
|
|
57
|
+
[param]: next || undefined,
|
|
53
58
|
}),
|
|
54
59
|
);
|
|
55
60
|
}}
|
|
@@ -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';
|
|
@@ -15,8 +14,13 @@ import { useFitPages } from '@terrafirmagreg-team/ui/hooks/page/use-fit-pages';
|
|
|
15
14
|
import {
|
|
16
15
|
loadTypeRows,
|
|
17
16
|
nonEmptyCategoryIds,
|
|
17
|
+
recipeItemName,
|
|
18
18
|
resolveRecipeRows,
|
|
19
19
|
} from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
20
|
+
import {
|
|
21
|
+
rowMatchesTerms,
|
|
22
|
+
rowSearchTerms,
|
|
23
|
+
} from '@terrafirmagreg-team/recipe/lib/browser/row-search';
|
|
20
24
|
import { RECIPE_ALL_TYPE, recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
21
25
|
import { RecipeTypeTabs } from '@terrafirmagreg-team/recipe/components/views/browser/type-tabs';
|
|
22
26
|
import { WorkstationRail } from '@terrafirmagreg-team/recipe/components/views/browser/workstation-rail';
|
|
@@ -72,12 +76,25 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
72
76
|
[dataset, index, recipeId, rows, focusIndex],
|
|
73
77
|
);
|
|
74
78
|
const solo = recipeId != null && session.solo === '1';
|
|
79
|
+
const terms = rowSearchTerms(session.rquery);
|
|
80
|
+
const filteredRows = terms.length
|
|
81
|
+
? allRows.filter((row) =>
|
|
82
|
+
rowMatchesTerms(row, terms, (id) =>
|
|
83
|
+
recipeItemName(session.names, session.lang, id),
|
|
84
|
+
),
|
|
85
|
+
)
|
|
86
|
+
: allRows;
|
|
75
87
|
const feedRows = solo
|
|
76
88
|
? focusIndex >= 0
|
|
77
89
|
? [allRows[focusIndex]]
|
|
78
90
|
: (focusRes.value ?? EMPTY_ROWS)
|
|
79
|
-
:
|
|
80
|
-
const feedFocus =
|
|
91
|
+
: filteredRows;
|
|
92
|
+
const feedFocus =
|
|
93
|
+
solo && focusIndex >= 0
|
|
94
|
+
? 0
|
|
95
|
+
: recipeId
|
|
96
|
+
? filteredRows.findIndex((row) => row.id === recipeId)
|
|
97
|
+
: -1;
|
|
81
98
|
useEffect(() => {
|
|
82
99
|
if (!recipeId || !index || rows === undefined || focusIndex >= 0) return;
|
|
83
100
|
if (focusRes.pending) return;
|
|
@@ -103,22 +120,6 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
103
120
|
!grid,
|
|
104
121
|
);
|
|
105
122
|
|
|
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
123
|
const onSwipe = (dir: -1 | 1) => {
|
|
123
124
|
if (recipeId) {
|
|
124
125
|
const next = focusIndex + dir;
|
|
@@ -163,6 +164,7 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
163
164
|
<RecipeFrame
|
|
164
165
|
session={session}
|
|
165
166
|
list={list}
|
|
167
|
+
search
|
|
166
168
|
strip={
|
|
167
169
|
<RecipeTypeTabs
|
|
168
170
|
session={session}
|
|
@@ -182,27 +184,8 @@ export function TypeView({ session }: { session: RecipeSession }) {
|
|
|
182
184
|
}}
|
|
183
185
|
/>
|
|
184
186
|
}
|
|
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
187
|
header={
|
|
205
|
-
<div className="
|
|
188
|
+
<div className="mx-auto w-full max-w-90">
|
|
206
189
|
<PlaceHeader
|
|
207
190
|
session={session}
|
|
208
191
|
overline={t('Categories', { note: 'recipe.axis_type' })}
|
|
@@ -78,19 +78,19 @@ export function CalcHelp() {
|
|
|
78
78
|
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
79
79
|
<span className="size-3.5 rounded-sm border border-emerald-500" />
|
|
80
80
|
</span>
|
|
81
|
-
{t('Input port: click to pick a supplier or drag a
|
|
81
|
+
{t('Input port: click to pick a supplier or drag a pipe', { note: 'recipe.calc.help.port_in' })}
|
|
82
82
|
</li>
|
|
83
83
|
<li className="flex items-center gap-2">
|
|
84
84
|
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
85
85
|
<span className="size-3.5 rounded-sm border border-red-400" />
|
|
86
86
|
</span>
|
|
87
|
-
{t('Output port: click to pick a recipe or drag a
|
|
87
|
+
{t('Output port: click to pick a recipe or drag a pipe', { note: 'recipe.calc.help.port_out' })}
|
|
88
88
|
</li>
|
|
89
89
|
<li className="flex items-center gap-2">
|
|
90
90
|
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
91
91
|
<span className="size-3.5 rounded-sm border border-dotted border-emerald-500" />
|
|
92
92
|
</span>
|
|
93
|
-
{t('Catalyst: needed but not consumed;
|
|
93
|
+
{t('Catalyst: needed but not consumed; pipe it or click to pick a supplier', { note: 'recipe.calc.help.port_cat' })}
|
|
94
94
|
</li>
|
|
95
95
|
<li className="flex items-center gap-2">
|
|
96
96
|
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
@@ -127,7 +127,7 @@ export function CalcHelp() {
|
|
|
127
127
|
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
128
128
|
<span className="h-0 w-4 border-t border-dashed border-primary/70" />
|
|
129
129
|
</span>
|
|
130
|
-
{t('Drag port to port to link; drag a
|
|
130
|
+
{t('Drag port to port to link; drag a pipe end to retarget', { note: 'recipe.calc.help.edge_link' })}
|
|
131
131
|
</li>
|
|
132
132
|
<li className="flex items-center gap-2">
|
|
133
133
|
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
@@ -135,13 +135,13 @@ export function CalcHelp() {
|
|
|
135
135
|
16
|
|
136
136
|
</span>
|
|
137
137
|
</span>
|
|
138
|
-
{t('Flow on a
|
|
138
|
+
{t('Flow on a pipe - shows on hover; click to cap the amount', { note: 'recipe.calc.help.edge_flow' })}
|
|
139
139
|
</li>
|
|
140
140
|
<li className="flex items-center gap-2">
|
|
141
141
|
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
142
142
|
<Scissors className="size-3.5 text-muted-foreground" />
|
|
143
143
|
</span>
|
|
144
|
-
{t('Shift +
|
|
144
|
+
{t('Shift + click a pipe to disconnect it', { note: 'recipe.calc.help.edge_cut' })}
|
|
145
145
|
</li>
|
|
146
146
|
</ul>
|
|
147
147
|
</section>
|
|
@@ -17,6 +17,8 @@ import { useCalcData } from '@terrafirmagreg-team/recipe/hooks/calc/use-data';
|
|
|
17
17
|
import { useCalcViewMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-view-mode';
|
|
18
18
|
import { useCalcFarMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-far-mode';
|
|
19
19
|
import { useCalcRecipeIdsMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-recipe-ids';
|
|
20
|
+
import { useCalcSnap } from '@terrafirmagreg-team/recipe/hooks/calc/use-snap';
|
|
21
|
+
import { useCalcHistory } from '@terrafirmagreg-team/recipe/hooks/calc/use-history';
|
|
20
22
|
|
|
21
23
|
export function Calculator({ session }: { session: RecipeSession }) {
|
|
22
24
|
const t = useTranslations();
|
|
@@ -24,10 +26,12 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
24
26
|
const [mode, setMode] = useCalcViewMode();
|
|
25
27
|
const [farCards, setFarCards] = useCalcFarMode();
|
|
26
28
|
const [recipeIds, setRecipeIds] = useCalcRecipeIdsMode();
|
|
29
|
+
const [snap, setSnap] = useCalcSnap();
|
|
27
30
|
const {
|
|
28
31
|
cards,
|
|
29
|
-
|
|
32
|
+
pipes,
|
|
30
33
|
tagSelections,
|
|
34
|
+
notes,
|
|
31
35
|
tabs,
|
|
32
36
|
activeTabId,
|
|
33
37
|
history,
|
|
@@ -52,6 +56,17 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
52
56
|
settled,
|
|
53
57
|
shareFailed,
|
|
54
58
|
} = useCalcData(session);
|
|
59
|
+
const {
|
|
60
|
+
write: persistTracked,
|
|
61
|
+
undo,
|
|
62
|
+
redo,
|
|
63
|
+
canUndo,
|
|
64
|
+
canRedo,
|
|
65
|
+
} = useCalcHistory(
|
|
66
|
+
{ cards, pipes, tagSelections, notes },
|
|
67
|
+
persist,
|
|
68
|
+
activeTabId ?? undefined,
|
|
69
|
+
);
|
|
55
70
|
const deferredNodes = useDeferredValue(nodes);
|
|
56
71
|
const deferredFlows = useDeferredValue(flows);
|
|
57
72
|
const deferredLangMap = useDeferredValue(session.langMap);
|
|
@@ -61,10 +76,11 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
61
76
|
const { displayCards, pendingCrafts, flushAmounts, onCrafts } =
|
|
62
77
|
useCalcAmounts({
|
|
63
78
|
cards,
|
|
64
|
-
|
|
79
|
+
pipes,
|
|
65
80
|
tagSelections,
|
|
81
|
+
notes,
|
|
66
82
|
resolved: deferredNodes,
|
|
67
|
-
persist,
|
|
83
|
+
persist: persistTracked,
|
|
68
84
|
});
|
|
69
85
|
const {
|
|
70
86
|
shared,
|
|
@@ -73,15 +89,17 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
73
89
|
onShare,
|
|
74
90
|
flowData,
|
|
75
91
|
onMoveCards,
|
|
92
|
+
onAddNote,
|
|
76
93
|
onClear,
|
|
77
94
|
} = useCalcActions({
|
|
78
95
|
dataset,
|
|
79
96
|
lang,
|
|
80
97
|
linkVersion: session.nav.version,
|
|
81
98
|
cards: displayCards,
|
|
82
|
-
|
|
99
|
+
pipes,
|
|
83
100
|
tagSelections,
|
|
84
|
-
|
|
101
|
+
notes,
|
|
102
|
+
persist: persistTracked,
|
|
85
103
|
recipeDefaults,
|
|
86
104
|
setRecipeDefault,
|
|
87
105
|
recipeBody,
|
|
@@ -143,7 +161,7 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
143
161
|
</LeftSidebarPortal>
|
|
144
162
|
<CalcFlow
|
|
145
163
|
nodes={deferredNodes}
|
|
146
|
-
|
|
164
|
+
pipes={pipes}
|
|
147
165
|
flows={deferredFlows}
|
|
148
166
|
cards={displayCards}
|
|
149
167
|
dataset={dataset}
|
|
@@ -155,6 +173,11 @@ export function Calculator({ session }: { session: RecipeSession }) {
|
|
|
155
173
|
onFarCardsChange={setFarCards}
|
|
156
174
|
recipeIds={recipeIds}
|
|
157
175
|
onRecipeIdsChange={setRecipeIds}
|
|
176
|
+
snap={snap}
|
|
177
|
+
onSnapChange={setSnap}
|
|
178
|
+
notes={notes}
|
|
179
|
+
onAddNote={onAddNote}
|
|
180
|
+
history={{ canUndo, canRedo, onUndo: undo, onRedo: redo }}
|
|
158
181
|
treeReady={settled}
|
|
159
182
|
resetGen={resetGen}
|
|
160
183
|
canvasId={activeTabId ?? undefined}
|