@terrafirmagreg-team/recipe 0.0.0-stage → 0.1.0
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 +62 -3
- package/src/components/button-copy.tsx +42 -0
- package/src/components/cards/card/index.tsx +212 -0
- package/src/components/cards/card/model.ts +64 -0
- package/src/components/cards/card/scene.tsx +105 -0
- package/src/components/cards/card/strip.tsx +196 -0
- package/src/components/cards/card/text.tsx +45 -0
- package/src/components/cards/card/tips.tsx +62 -0
- package/src/components/cards/default-item.tsx +43 -0
- package/src/components/cards/fit-card.tsx +26 -0
- package/src/components/cards/glare-filter.tsx +28 -0
- package/src/components/cards/paged-card.tsx +221 -0
- package/src/components/cards/slot-hitbox.tsx +211 -0
- package/src/components/cards/strip-card/buttons.tsx +101 -0
- package/src/components/cards/strip-card/index.tsx +212 -0
- package/src/components/cards/strip-card/member-cell.tsx +165 -0
- package/src/components/cards/strip-card/sprite.tsx +35 -0
- package/src/components/mdx/recipe.tsx +111 -0
- package/src/components/tool-list.tsx +48 -0
- package/src/components/views/alloy/index.tsx +105 -0
- package/src/components/views/alloy/list.tsx +84 -0
- package/src/components/views/alloy/mix/index.tsx +34 -0
- package/src/components/views/alloy/mix/ratio.tsx +93 -0
- package/src/components/views/alloy/mix/rows.tsx +146 -0
- package/src/components/views/alloy/mix/status.tsx +121 -0
- package/src/components/views/alloy/mix/total.tsx +131 -0
- package/src/components/views/alloy/range-bar.tsx +64 -0
- package/src/components/views/alloy/stack-bar.tsx +86 -0
- package/src/components/views/browser/axis-switcher.tsx +53 -0
- package/src/components/views/browser/card-grid.tsx +274 -0
- package/src/components/views/browser/favorite-button.tsx +45 -0
- package/src/components/views/browser/frame.tsx +111 -0
- package/src/components/views/browser/index.tsx +96 -0
- package/src/components/views/browser/item-panel/index.tsx +227 -0
- package/src/components/views/browser/item-panel/skeleton.tsx +25 -0
- package/src/components/views/browser/item-panel-grid/cell.tsx +176 -0
- package/src/components/views/browser/item-panel-grid/favorite-cell.tsx +127 -0
- package/src/components/views/browser/item-panel-grid/index.tsx +103 -0
- package/src/components/views/browser/item-view/index.tsx +191 -0
- package/src/components/views/browser/item-view/tags.tsx +83 -0
- package/src/components/views/browser/item-view-header.tsx +130 -0
- package/src/components/views/browser/pane-tabs.tsx +60 -0
- package/src/components/views/browser/place-header.tsx +71 -0
- package/src/components/views/browser/query-controls.tsx +103 -0
- package/src/components/views/browser/recipe-item-header.tsx +59 -0
- package/src/components/views/browser/settings.tsx +51 -0
- package/src/components/views/browser/toolbar.tsx +53 -0
- package/src/components/views/browser/type-tabs.tsx +69 -0
- package/src/components/views/browser/type-view.tsx +189 -0
- package/src/components/views/browser/workstation-rail.tsx +42 -0
- package/src/components/views/calc/calculator/actions.tsx +57 -0
- package/src/components/views/calc/calculator/help.tsx +148 -0
- package/src/components/views/calc/calculator/index.tsx +220 -0
- package/src/components/views/calc/dot-overlay.tsx +79 -0
- package/src/components/views/calc/edge.tsx +50 -0
- package/src/components/views/calc/flow/index.tsx +267 -0
- package/src/components/views/calc/flow/picker-dialogs.tsx +68 -0
- package/src/components/views/calc/flow/toolbar.tsx +72 -0
- package/src/components/views/calc/flow/view-menu.tsx +221 -0
- package/src/components/views/calc/member-picker.tsx +118 -0
- package/src/components/views/calc/node-card/actions.tsx +168 -0
- package/src/components/views/calc/node-card/badges.tsx +77 -0
- package/src/components/views/calc/node-card/chips.tsx +219 -0
- package/src/components/views/calc/node-card/far.tsx +175 -0
- package/src/components/views/calc/node-card/full.tsx +282 -0
- package/src/components/views/calc/node-card/index.tsx +26 -0
- package/src/components/views/calc/node-card/menu.tsx +211 -0
- package/src/components/views/calc/recipe-picker/body.tsx +204 -0
- package/src/components/views/calc/recipe-picker/footer.tsx +129 -0
- package/src/components/views/calc/recipe-picker/index.tsx +47 -0
- package/src/components/views/calc/sidebar.tsx +162 -0
- package/src/components/views/calc/target.tsx +271 -0
- package/src/components/views/calc/trees/icon-picker.tsx +96 -0
- package/src/components/views/calc/trees/index.tsx +133 -0
- package/src/components/views/calc/trees/label.tsx +65 -0
- package/src/components/views/calc/trees/rows.tsx +139 -0
- package/src/components/views/forge/gui.tsx +130 -0
- package/src/components/views/forge/index.tsx +105 -0
- package/src/components/views/forge/list.tsx +112 -0
- package/src/components/views/forge/workbench/controls.tsx +96 -0
- package/src/components/views/forge/workbench/index.tsx +84 -0
- package/src/components/views/forge/workbench/panel.tsx +227 -0
- package/src/components/views/forge/workbench/ruler.tsx +132 -0
- package/src/components/views/forge/workbench/status.tsx +54 -0
- package/src/components/views/forge/workbench/tape.tsx +69 -0
- package/src/hooks/alloy/use-fluid-colors.ts +122 -0
- package/src/hooks/alloy/use-mix-state.ts +239 -0
- package/src/hooks/calc/flow/engage.ts +89 -0
- package/src/hooks/calc/flow/handlers.ts +115 -0
- package/src/hooks/calc/flow/layout.ts +149 -0
- package/src/hooks/calc/flow/mount.ts +96 -0
- package/src/hooks/calc/flow/nodes.ts +251 -0
- package/src/hooks/calc/flow/pickers.ts +50 -0
- package/src/hooks/calc/flow/props.ts +40 -0
- package/src/hooks/calc/flow/viewport.ts +154 -0
- package/src/hooks/calc/flow/window.ts +86 -0
- package/src/hooks/calc/use-actions.ts +376 -0
- package/src/hooks/calc/use-amounts.ts +101 -0
- package/src/hooks/calc/use-calc-fill.ts +91 -0
- package/src/hooks/calc/use-data.ts +289 -0
- package/src/hooks/calc/use-defaults.ts +38 -0
- package/src/hooks/calc/use-density.ts +28 -0
- package/src/hooks/calc/use-derived.ts +258 -0
- package/src/hooks/calc/use-direction.ts +23 -0
- package/src/hooks/calc/use-edge-style.ts +40 -0
- package/src/hooks/calc/use-far-mode.ts +36 -0
- package/src/hooks/calc/use-fill.ts +213 -0
- package/src/hooks/calc/use-focus.ts +30 -0
- package/src/hooks/calc/use-maps.ts +75 -0
- package/src/hooks/calc/use-reset.ts +14 -0
- package/src/hooks/calc/use-resolver.ts +234 -0
- package/src/hooks/calc/use-session.ts +12 -0
- package/src/hooks/calc/use-share.ts +61 -0
- package/src/hooks/calc/use-storage.ts +125 -0
- package/src/hooks/calc/use-tier.ts +12 -0
- package/src/hooks/calc/use-view-mode.ts +23 -0
- package/src/hooks/calc/use-worker.ts +269 -0
- package/src/hooks/forge/use-anvil-gui.ts +14 -0
- package/src/hooks/forge/use-forge-state.ts +134 -0
- package/src/hooks/forge/use-ruler.ts +99 -0
- package/src/hooks/use-add-to-calc.ts +47 -0
- package/src/hooks/use-favorite-hotkey.ts +38 -0
- package/src/hooks/use-favorites.ts +134 -0
- package/src/hooks/use-group-outlines.ts +64 -0
- package/src/hooks/use-hide-unused.ts +11 -0
- package/src/hooks/use-index.ts +68 -0
- package/src/hooks/use-item-feeds.ts +44 -0
- package/src/hooks/use-item-pane.ts +104 -0
- package/src/hooks/use-item-press.ts +85 -0
- package/src/hooks/use-item-tag-groups.ts +52 -0
- package/src/hooks/use-item-tooltips.ts +16 -0
- package/src/hooks/use-left-sidebar-tree.ts +26 -0
- package/src/hooks/use-mod-names.ts +15 -0
- package/src/hooks/use-mount-limit.ts +21 -0
- package/src/hooks/use-panel-cells.ts +115 -0
- package/src/hooks/use-panel-page.ts +51 -0
- package/src/hooks/use-panel-tabs.ts +42 -0
- package/src/hooks/use-query.ts +184 -0
- package/src/hooks/use-session.ts +84 -0
- package/src/hooks/use-sidebar-group.ts +20 -0
- package/src/hooks/use-tag-members.ts +14 -0
- package/src/hooks/use-tool-recipes.ts +25 -0
- package/src/hooks/use-type-filter.ts +72 -0
- package/src/lib/alloy/alloy.test.ts +186 -0
- package/src/lib/alloy/mix.ts +209 -0
- package/src/lib/alloy/parse.ts +36 -0
- package/src/lib/calc/defaults.ts +45 -0
- package/src/lib/calc/flow.ts +279 -0
- package/src/lib/calc/focus.ts +14 -0
- package/src/lib/calc/meta.ts +15 -0
- package/src/lib/calc/pack.ts +184 -0
- package/src/lib/calc/resolve.ts +230 -0
- package/src/lib/calc/route/buckets.ts +48 -0
- package/src/lib/calc/route/geometry.ts +62 -0
- package/src/lib/calc/route/index.ts +2 -0
- package/src/lib/calc/route/polyline.ts +103 -0
- package/src/lib/calc/route/router.ts +270 -0
- package/src/lib/calc/storage/entry.ts +89 -0
- package/src/lib/calc/storage/index.ts +18 -0
- package/src/lib/calc/storage/keys.ts +42 -0
- package/src/lib/calc/storage/store.ts +223 -0
- package/src/lib/calc/tree/build.ts +196 -0
- package/src/lib/calc/tree/context.ts +42 -0
- package/src/lib/calc/tree/goal.ts +64 -0
- package/src/lib/calc/tree/ideal.ts +36 -0
- package/src/lib/calc/tree/index.ts +18 -0
- package/src/lib/calc/tree/materials.ts +28 -0
- package/src/lib/calc/tree/pick.ts +68 -0
- package/src/lib/calc/tree/recipe.ts +103 -0
- package/src/lib/calc/tree/share.ts +198 -0
- package/src/lib/calc/tree/tree.test.ts +169 -0
- package/src/lib/calc/worker/api.ts +33 -0
- package/src/lib/calc/worker/fetch.ts +65 -0
- package/src/lib/calc/worker/fill.ts +123 -0
- package/src/lib/calc/worker/flush.ts +52 -0
- package/src/lib/calc/worker/index.ts +8 -0
- package/src/lib/calc/worker/protocol.ts +32 -0
- package/src/lib/calc/worker/resolve.ts +101 -0
- package/src/lib/calc/worker/state.ts +49 -0
- package/src/lib/client/recipe-categories.ts +96 -0
- package/src/lib/client/recipe.ts +83 -0
- package/src/lib/client-index/cache.ts +13 -0
- package/src/lib/client-index/catalog.ts +85 -0
- package/src/lib/client-index/chrome.ts +180 -0
- package/src/lib/client-index/index.ts +19 -0
- package/src/lib/client-index/registry.ts +110 -0
- package/src/lib/client-index/rows.ts +254 -0
- package/src/lib/client-index/tooltips.ts +80 -0
- package/src/lib/config.ts +17 -0
- package/src/lib/data/category/dto.ts +24 -0
- package/src/lib/data/category/load.ts +46 -0
- package/src/lib/data/category/parse.ts +70 -0
- package/src/lib/data/dto.ts +151 -0
- package/src/lib/data/grid.ts +39 -0
- package/src/lib/data/parse/entry.ts +84 -0
- package/src/lib/data/parse/index.ts +2 -0
- package/src/lib/data/parse/layout.ts +135 -0
- package/src/lib/data/parse/slots.ts +84 -0
- package/src/lib/data/parse/widgets.ts +80 -0
- package/src/lib/data/scene.ts +103 -0
- package/src/lib/data/slot-io.ts +43 -0
- package/src/lib/dump.ts +5 -0
- package/src/lib/favorite-hover.ts +12 -0
- package/src/lib/fluid-outputs.ts +72 -0
- package/src/lib/forge/actions.ts +58 -0
- package/src/lib/forge/data.ts +50 -0
- package/src/lib/forge/forge.test.ts +123 -0
- package/src/lib/forge/solve.ts +79 -0
- package/src/lib/group.ts +22 -0
- package/src/lib/index-store.ts +64 -0
- package/src/lib/links.ts +125 -0
- package/src/lib/lookup.ts +117 -0
- package/src/lib/panel-outline.ts +85 -0
- package/src/lib/panel.ts +104 -0
- package/src/lib/preview.ts +28 -0
- package/src/lib/recipe-slots.ts +7 -0
- package/src/lib/search.ts +138 -0
- package/src/lib/sidebar.ts +46 -0
- package/src/lib/tree.ts +90 -0
- package/src/lib/used-items.ts +24 -0
- package/src/locales/en_us.json +228 -0
- package/src/locales/ru_ru.json +228 -0
- package/src/locales.ts +5 -0
- package/src/types/alloy.ts +19 -0
- package/src/types/calc.ts +95 -0
- package/src/types/forge.ts +20 -0
- package/src/types/index.ts +134 -0
- package/styles/calc.css +47 -0
- package/styles/strip.css +7 -0
- package/styles.css +2 -0
- package/README.md +0 -3
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import type { ReactNode } from 'react';
|
|
5
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
6
|
+
import { QueryPager } from '@terrafirmagreg-team/recipe/components/views/browser/query-controls';
|
|
7
|
+
import { Pager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
8
|
+
import { RecipeToolbar } from '@terrafirmagreg-team/recipe/components/views/browser/toolbar';
|
|
9
|
+
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
10
|
+
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
11
|
+
import type { RecipeSession } from '@terrafirmagreg-team/recipe/types';
|
|
12
|
+
|
|
13
|
+
type FeedList = {
|
|
14
|
+
page: number;
|
|
15
|
+
pages: number;
|
|
16
|
+
from?: number;
|
|
17
|
+
to: number;
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function RecipeFrame({
|
|
22
|
+
session,
|
|
23
|
+
header,
|
|
24
|
+
list,
|
|
25
|
+
strip,
|
|
26
|
+
rail,
|
|
27
|
+
back,
|
|
28
|
+
onPageChange,
|
|
29
|
+
children,
|
|
30
|
+
}: {
|
|
31
|
+
session: RecipeSession;
|
|
32
|
+
header: ReactNode;
|
|
33
|
+
list?: FeedList;
|
|
34
|
+
strip?: ReactNode;
|
|
35
|
+
rail?: ReactNode;
|
|
36
|
+
back?: { href: string; label: string };
|
|
37
|
+
onPageChange?: (page: number) => void;
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
}) {
|
|
40
|
+
const t = useTranslations();
|
|
41
|
+
const goPage = (dir: number) => {
|
|
42
|
+
if (!list || list.pages <= 1) return;
|
|
43
|
+
const next = (list.page + dir + list.pages) % list.pages;
|
|
44
|
+
if (onPageChange) {
|
|
45
|
+
onPageChange(next);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
replaceUrlState(
|
|
49
|
+
recipeHref(session.dataset, session.lang, {
|
|
50
|
+
...session.nav,
|
|
51
|
+
id: undefined,
|
|
52
|
+
rpage: next > 0 ? next + 1 : undefined,
|
|
53
|
+
}),
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
return (
|
|
57
|
+
<div className="flex h-full min-h-0 flex-1 flex-col">
|
|
58
|
+
{strip ? (
|
|
59
|
+
<div className="flex items-center gap-2">
|
|
60
|
+
<div className="min-w-0 flex-1">{strip}</div>
|
|
61
|
+
</div>
|
|
62
|
+
) : null}
|
|
63
|
+
<div className="flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border pb-2 pt-2">
|
|
64
|
+
{back ? (
|
|
65
|
+
<Link
|
|
66
|
+
href={back.href}
|
|
67
|
+
className="shrink-0 text-xs text-muted-foreground hover:text-foreground"
|
|
68
|
+
>
|
|
69
|
+
← {back.label}
|
|
70
|
+
</Link>
|
|
71
|
+
) : null}
|
|
72
|
+
<div className="min-w-0 flex-1">{header}</div>
|
|
73
|
+
<div className="ms-auto flex items-center gap-2">
|
|
74
|
+
<RecipeToolbar session={session} />
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
{list ? (
|
|
78
|
+
onPageChange ? (
|
|
79
|
+
<Pager
|
|
80
|
+
page={list.page}
|
|
81
|
+
pages={list.pages}
|
|
82
|
+
to={list.to}
|
|
83
|
+
total={list.total}
|
|
84
|
+
label={t('recipe.page_of')}
|
|
85
|
+
className="pt-2"
|
|
86
|
+
onPage={onPageChange}
|
|
87
|
+
/>
|
|
88
|
+
) : (
|
|
89
|
+
<QueryPager
|
|
90
|
+
dataset={session.dataset}
|
|
91
|
+
lang={session.lang}
|
|
92
|
+
params={{ ...session.nav, id: undefined }}
|
|
93
|
+
query={session.query}
|
|
94
|
+
list={list}
|
|
95
|
+
label={t('recipe.page_of')}
|
|
96
|
+
className="pt-2"
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
) : null}
|
|
100
|
+
<div className="flex min-h-0 flex-1 gap-2 overflow-hidden pt-2">
|
|
101
|
+
{rail}
|
|
102
|
+
<div
|
|
103
|
+
onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
|
|
104
|
+
className="flex min-w-0 flex-1 flex-col"
|
|
105
|
+
>
|
|
106
|
+
{children}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useDocumentTitle } from '@terrafirmagreg-team/ui/hooks/use-document-title';
|
|
4
|
+
import { useRecipeSession } from '@terrafirmagreg-team/recipe/hooks/use-session';
|
|
5
|
+
import { recipeConfig } from '@terrafirmagreg-team/recipe/lib/config';
|
|
6
|
+
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
7
|
+
import { ItemPanel } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel';
|
|
8
|
+
import { RecipeGlareFilter } from '@terrafirmagreg-team/recipe/components/cards/glare-filter';
|
|
9
|
+
import { RightSidebarPortal } from '@terrafirmagreg-team/ui/components/layouts/right-sidebar';
|
|
10
|
+
import { TypeView } from '@terrafirmagreg-team/recipe/components/views/browser/type-view';
|
|
11
|
+
import { ItemView } from '@terrafirmagreg-team/recipe/components/views/browser/item-view';
|
|
12
|
+
import { Calculator } from '@terrafirmagreg-team/recipe/components/views/calc/calculator';
|
|
13
|
+
import { ForgeCalculator } from '@terrafirmagreg-team/recipe/components/views/forge';
|
|
14
|
+
import { AlloyCalculator } from '@terrafirmagreg-team/recipe/components/views/alloy';
|
|
15
|
+
import { RecipeFrame } from '@terrafirmagreg-team/recipe/components/views/browser/frame';
|
|
16
|
+
import { RecipeTypeTabs } from '@terrafirmagreg-team/recipe/components/views/browser/type-tabs';
|
|
17
|
+
import { ItemRow } from '@terrafirmagreg-team/ui/components/blocks/list/row';
|
|
18
|
+
import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
|
|
19
|
+
import { EntryProvider } from '@terrafirmagreg-team/game/hooks/use-entry-context';
|
|
20
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
21
|
+
import type { RecipePageData } from '@terrafirmagreg-team/recipe/types';
|
|
22
|
+
|
|
23
|
+
export function RecipeBrowser({ page }: { page: RecipePageData }) {
|
|
24
|
+
const session = useRecipeSession(page);
|
|
25
|
+
const { dataset, lang, item, fluid, names } = session;
|
|
26
|
+
const focusId = item ?? fluid;
|
|
27
|
+
|
|
28
|
+
const focusTitle = focusId
|
|
29
|
+
? recipeItemName(names, lang, focusId)
|
|
30
|
+
: (session.recipeId ?? '');
|
|
31
|
+
useDocumentTitle(`${focusTitle || page.title} | ${recipeConfig().appName}`);
|
|
32
|
+
|
|
33
|
+
const isCalc = session.place?.kind === 'calc';
|
|
34
|
+
|
|
35
|
+
let main;
|
|
36
|
+
if (focusId) {
|
|
37
|
+
main = <ItemView session={session} />;
|
|
38
|
+
} else if (isCalc) {
|
|
39
|
+
main = <Calculator session={session} />;
|
|
40
|
+
} else if (session.place?.kind === 'forge') {
|
|
41
|
+
main = <ForgeCalculator session={session} />;
|
|
42
|
+
} else if (session.place?.kind === 'alloy') {
|
|
43
|
+
main = <AlloyCalculator session={session} />;
|
|
44
|
+
} else if (session.place?.kind === 'type') {
|
|
45
|
+
main = <TypeView session={session} />;
|
|
46
|
+
} else {
|
|
47
|
+
main = (
|
|
48
|
+
<RecipeFrame
|
|
49
|
+
session={session}
|
|
50
|
+
strip={<RecipeTypeTabs session={session} ids={[]} />}
|
|
51
|
+
header={<ItemRow layout="header" title={page.title} />}
|
|
52
|
+
>
|
|
53
|
+
<div className="flex min-h-0 flex-1 flex-col items-center justify-start gap-2 pt-2">
|
|
54
|
+
{Array.from({ length: 6 }, (_, i) => (
|
|
55
|
+
<Skeleton
|
|
56
|
+
key={i}
|
|
57
|
+
className="h-24 rounded-md"
|
|
58
|
+
style={{ width: 240 + (i % 3) * 70 }}
|
|
59
|
+
/>
|
|
60
|
+
))}
|
|
61
|
+
</div>
|
|
62
|
+
</RecipeFrame>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<EntryProvider dataset={dataset} lang={lang} langMap={session.langMap}>
|
|
68
|
+
<RecipeGlareFilter />
|
|
69
|
+
<div
|
|
70
|
+
className={cn(
|
|
71
|
+
'viewport-shell recipe-viewport not-prose flex w-full flex-col gap-3',
|
|
72
|
+
isCalc && 'calc-viewport',
|
|
73
|
+
)}
|
|
74
|
+
>
|
|
75
|
+
<div className="flex min-h-0 flex-1 gap-4">
|
|
76
|
+
<main className="flex min-w-0 flex-1 flex-col">{main}</main>
|
|
77
|
+
</div>
|
|
78
|
+
<RightSidebarPortal>
|
|
79
|
+
<ItemPanel
|
|
80
|
+
dataset={dataset}
|
|
81
|
+
lang={lang}
|
|
82
|
+
index={session.index}
|
|
83
|
+
indexLoading={session.indexLoading}
|
|
84
|
+
names={names}
|
|
85
|
+
tab={session.tab}
|
|
86
|
+
query={session.query}
|
|
87
|
+
setQuery={session.setQuery}
|
|
88
|
+
isCalc={isCalc}
|
|
89
|
+
nav={session.nav}
|
|
90
|
+
className="hidden h-full w-90 lg:flex"
|
|
91
|
+
/>
|
|
92
|
+
</RightSidebarPortal>
|
|
93
|
+
</div>
|
|
94
|
+
</EntryProvider>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
memo,
|
|
5
|
+
useCallback,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from 'react';
|
|
10
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
11
|
+
import { useFavorites } from '@terrafirmagreg-team/recipe/hooks/use-favorites';
|
|
12
|
+
import { useFavoriteHotkey } from '@terrafirmagreg-team/recipe/hooks/use-favorite-hotkey';
|
|
13
|
+
import { useHideUnused } from '@terrafirmagreg-team/recipe/hooks/use-hide-unused';
|
|
14
|
+
import { usePagedList } from '@terrafirmagreg-team/ui/hooks/page/use-paged-list';
|
|
15
|
+
import { useSwipe } from '@terrafirmagreg-team/ui/hooks/use-swipe';
|
|
16
|
+
import { useElementSize } from '@terrafirmagreg-team/ui/hooks/use-element-size';
|
|
17
|
+
import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty-state';
|
|
18
|
+
import { type ItemPanelMode } from '@terrafirmagreg-team/recipe/lib/panel';
|
|
19
|
+
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
20
|
+
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
21
|
+
import { favoriteHover } from '@terrafirmagreg-team/recipe/lib/favorite-hover';
|
|
22
|
+
import { IconTabs } from '@terrafirmagreg-team/game/components/entry/icon/tabs';
|
|
23
|
+
import { FavoriteButton } from '@terrafirmagreg-team/recipe/components/views/browser/favorite-button';
|
|
24
|
+
import { ItemPanelGrid } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid';
|
|
25
|
+
import { RecipeSettings } from '@terrafirmagreg-team/recipe/components/views/browser/settings';
|
|
26
|
+
import { QuerySearch } from '@terrafirmagreg-team/recipe/components/views/browser/query-controls';
|
|
27
|
+
import { Pager } from '@terrafirmagreg-team/ui/components/blocks/page/pager';
|
|
28
|
+
import { usePanelPage } from '@terrafirmagreg-team/recipe/hooks/use-panel-page';
|
|
29
|
+
import { useItemPress } from '@terrafirmagreg-team/recipe/hooks/use-item-press';
|
|
30
|
+
import { usePanelCells } from '@terrafirmagreg-team/recipe/hooks/use-panel-cells';
|
|
31
|
+
import { usePanelTabs } from '@terrafirmagreg-team/recipe/hooks/use-panel-tabs';
|
|
32
|
+
import { PanelSkeleton } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel/skeleton';
|
|
33
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
34
|
+
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
35
|
+
import type {
|
|
36
|
+
RecipeCompactIndex,
|
|
37
|
+
RecipeHrefOpts,
|
|
38
|
+
} from '@terrafirmagreg-team/recipe/types';
|
|
39
|
+
|
|
40
|
+
const CELL = 40;
|
|
41
|
+
const PANEL_COLS = 10;
|
|
42
|
+
|
|
43
|
+
export const ItemPanel = memo(function ItemPanel({
|
|
44
|
+
dataset,
|
|
45
|
+
lang,
|
|
46
|
+
index,
|
|
47
|
+
indexLoading,
|
|
48
|
+
names,
|
|
49
|
+
tab,
|
|
50
|
+
query,
|
|
51
|
+
setQuery,
|
|
52
|
+
isCalc,
|
|
53
|
+
nav,
|
|
54
|
+
className,
|
|
55
|
+
}: {
|
|
56
|
+
dataset: string;
|
|
57
|
+
lang: Lang;
|
|
58
|
+
index: RecipeCompactIndex | null;
|
|
59
|
+
indexLoading: boolean;
|
|
60
|
+
names: Record<string, Record<string, string>>;
|
|
61
|
+
tab?: string;
|
|
62
|
+
query: string;
|
|
63
|
+
setQuery: (query: string) => void;
|
|
64
|
+
isCalc: boolean;
|
|
65
|
+
nav: RecipeHrefOpts;
|
|
66
|
+
className?: string;
|
|
67
|
+
}) {
|
|
68
|
+
const t = useTranslations();
|
|
69
|
+
const favorites = useFavorites();
|
|
70
|
+
const { hideUnused } = useHideUnused();
|
|
71
|
+
const [mode, setMode] = useState<ItemPanelMode>('all');
|
|
72
|
+
const boxRef = useRef<HTMLDivElement | null>(null);
|
|
73
|
+
useFavoriteHotkey();
|
|
74
|
+
const { w, h } = useElementSize(boxRef);
|
|
75
|
+
const cols = Math.min(PANEL_COLS, Math.max(1, Math.floor((w + 4) / CELL)));
|
|
76
|
+
const rows = Math.max(1, Math.floor((h + 4) / CELL));
|
|
77
|
+
const pageSize = cols * rows;
|
|
78
|
+
const measured = w > 0 && h > 0;
|
|
79
|
+
|
|
80
|
+
const [expandedGroups, setExpandedGroups] = useState<ReadonlySet<string>>(
|
|
81
|
+
new Set(),
|
|
82
|
+
);
|
|
83
|
+
const { cells, filtered, favoriteIds, dIndex, dNames, dLang } =
|
|
84
|
+
usePanelCells({
|
|
85
|
+
dataset,
|
|
86
|
+
index,
|
|
87
|
+
names,
|
|
88
|
+
lang,
|
|
89
|
+
mode,
|
|
90
|
+
query,
|
|
91
|
+
tab,
|
|
92
|
+
hideUnused,
|
|
93
|
+
favorites,
|
|
94
|
+
expandedGroups,
|
|
95
|
+
});
|
|
96
|
+
const favIds = useMemo(() => new Set(favoriteIds), [favoriteIds]);
|
|
97
|
+
const { page: panelPage, setPage: setPanelPage } = usePanelPage(dataset);
|
|
98
|
+
const list = usePagedList(cells, panelPage, pageSize);
|
|
99
|
+
|
|
100
|
+
const gridResetKey = useMemo(
|
|
101
|
+
() => [mode, filtered, favorites.entries],
|
|
102
|
+
[mode, filtered, favorites.entries],
|
|
103
|
+
);
|
|
104
|
+
const onToggleGroup = useCallback((groupId: string) => {
|
|
105
|
+
setExpandedGroups((prev) => {
|
|
106
|
+
const next = new Set(prev);
|
|
107
|
+
if (next.has(groupId)) next.delete(groupId);
|
|
108
|
+
else next.add(groupId);
|
|
109
|
+
return next;
|
|
110
|
+
});
|
|
111
|
+
}, []);
|
|
112
|
+
|
|
113
|
+
const onPress = useItemPress({ dataset, lang, nav, isCalc });
|
|
114
|
+
|
|
115
|
+
const setTab = (next: string) => {
|
|
116
|
+
setPanelPage(0);
|
|
117
|
+
replaceUrlState(
|
|
118
|
+
recipeHref(dataset, lang, {
|
|
119
|
+
...nav,
|
|
120
|
+
tab: next || undefined,
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const goPage = (dir: number) => {
|
|
126
|
+
if (list.pages <= 1) return;
|
|
127
|
+
setPanelPage((list.page + dir + list.pages) % list.pages);
|
|
128
|
+
};
|
|
129
|
+
const swipe = useSwipe(goPage);
|
|
130
|
+
|
|
131
|
+
const tabOptions = usePanelTabs(dIndex, dNames, dLang);
|
|
132
|
+
|
|
133
|
+
let body;
|
|
134
|
+
const indexEmpty = !index?.items.length;
|
|
135
|
+
if (!measured || (indexLoading && indexEmpty)) {
|
|
136
|
+
body =
|
|
137
|
+
indexLoading && indexEmpty ? (
|
|
138
|
+
<PanelSkeleton cols={cols} rows={rows} />
|
|
139
|
+
) : null;
|
|
140
|
+
} else if (!list.shown.length) {
|
|
141
|
+
body = (
|
|
142
|
+
<EmptyState variant="empty">
|
|
143
|
+
{mode === 'fav'
|
|
144
|
+
? t('recipe.favorites_empty')
|
|
145
|
+
: hideUnused && !query.trim()
|
|
146
|
+
? t('recipe.hide_unused_empty')
|
|
147
|
+
: t('recipe.empty_items')}
|
|
148
|
+
</EmptyState>
|
|
149
|
+
);
|
|
150
|
+
} else {
|
|
151
|
+
body = (
|
|
152
|
+
<ItemPanelGrid
|
|
153
|
+
cells={list.shown}
|
|
154
|
+
resetKey={gridResetKey}
|
|
155
|
+
dataset={dataset}
|
|
156
|
+
lang={dLang}
|
|
157
|
+
names={dNames}
|
|
158
|
+
nav={nav}
|
|
159
|
+
cols={cols}
|
|
160
|
+
rows={rows}
|
|
161
|
+
favIds={favIds}
|
|
162
|
+
onPress={onPress}
|
|
163
|
+
onHover={(target) => {
|
|
164
|
+
favoriteHover.base = target;
|
|
165
|
+
}}
|
|
166
|
+
onToggleGroup={onToggleGroup}
|
|
167
|
+
draggableStacks={isCalc}
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div className={cn('not-prose flex min-h-0 flex-col gap-2', className)}>
|
|
174
|
+
<IconTabs
|
|
175
|
+
value={mode === 'fav' ? 'fav' : (tab ?? '')}
|
|
176
|
+
options={tabOptions}
|
|
177
|
+
onChange={(id) => {
|
|
178
|
+
setMode('all');
|
|
179
|
+
setTab(id);
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
<Pager
|
|
183
|
+
page={list.page}
|
|
184
|
+
pages={list.pages}
|
|
185
|
+
to={list.to}
|
|
186
|
+
total={list.total}
|
|
187
|
+
label={t('recipe.page_of')}
|
|
188
|
+
onPage={setPanelPage}
|
|
189
|
+
leading={
|
|
190
|
+
<FavoriteButton
|
|
191
|
+
variant="outline"
|
|
192
|
+
active={mode === 'fav'}
|
|
193
|
+
label={t('recipe.favorites')}
|
|
194
|
+
onToggle={() => {
|
|
195
|
+
setPanelPage(0);
|
|
196
|
+
setMode(mode === 'fav' ? 'all' : 'fav');
|
|
197
|
+
}}
|
|
198
|
+
className="size-9 [&_svg]:size-4.5"
|
|
199
|
+
/>
|
|
200
|
+
}
|
|
201
|
+
/>
|
|
202
|
+
<div
|
|
203
|
+
ref={boxRef}
|
|
204
|
+
{...swipe}
|
|
205
|
+
onWheel={(event) => goPage(event.deltaY > 0 ? 1 : -1)}
|
|
206
|
+
className="min-h-0 flex-1"
|
|
207
|
+
>
|
|
208
|
+
{body}
|
|
209
|
+
</div>
|
|
210
|
+
<div className="mx-auto flex w-full max-w-md items-center gap-2">
|
|
211
|
+
<RecipeSettings />
|
|
212
|
+
<QuerySearch
|
|
213
|
+
dataset={dataset}
|
|
214
|
+
lang={lang}
|
|
215
|
+
params={nav}
|
|
216
|
+
query={query}
|
|
217
|
+
onQuery={(next) => {
|
|
218
|
+
setPanelPage(0);
|
|
219
|
+
setQuery(next);
|
|
220
|
+
}}
|
|
221
|
+
placeholder={t('recipe.search')}
|
|
222
|
+
className="w-full"
|
|
223
|
+
/>
|
|
224
|
+
</div>
|
|
225
|
+
</div>
|
|
226
|
+
);
|
|
227
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
|
|
4
|
+
|
|
5
|
+
export function PanelSkeleton({ cols, rows }: { cols: number; rows: number }) {
|
|
6
|
+
return (
|
|
7
|
+
<ul
|
|
8
|
+
aria-hidden
|
|
9
|
+
className="grid h-full w-full place-content-center gap-1"
|
|
10
|
+
style={{
|
|
11
|
+
gridTemplateColumns: `repeat(${Math.max(1, cols)}, 36px)`,
|
|
12
|
+
gridTemplateRows: `repeat(${Math.max(1, rows)}, 36px)`,
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
{Array.from({ length: Math.max(1, cols) * Math.max(1, rows) }, (_, i) => (
|
|
16
|
+
<li
|
|
17
|
+
key={i}
|
|
18
|
+
className="flex min-h-0 min-w-0 items-center justify-center"
|
|
19
|
+
>
|
|
20
|
+
<Skeleton className="size-9 rounded-sm" />
|
|
21
|
+
</li>
|
|
22
|
+
))}
|
|
23
|
+
</ul>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
import { Minus, Plus, Star } from 'lucide-react';
|
|
5
|
+
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
6
|
+
import { EntryGroup } from '@terrafirmagreg-team/game/components/entry/group';
|
|
7
|
+
import { CopyIdMenu } from '@terrafirmagreg-team/game/components/entry/copy-id-menu';
|
|
8
|
+
import { parseStackId } from '@terrafirmagreg-team/game/lib/dump/contract/ref';
|
|
9
|
+
import { formatNbt } from '@terrafirmagreg-team/game/lib/snbt';
|
|
10
|
+
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
11
|
+
import { Badge } from '@terrafirmagreg-team/ui/components/ui/badge';
|
|
12
|
+
import { Hint } from '@terrafirmagreg-team/ui/components/blocks/tooltip/hint';
|
|
13
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
14
|
+
import { RecipeFavoriteCell } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid/favorite-cell';
|
|
15
|
+
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
16
|
+
import type { EntrySize } from '@terrafirmagreg-team/game/types/entry';
|
|
17
|
+
import type { FavoriteHoverTarget } from '@terrafirmagreg-team/recipe/lib/favorite-hover';
|
|
18
|
+
import type { ItemPanelCell, RecipeHrefOpts } from '@terrafirmagreg-team/recipe/types';
|
|
19
|
+
|
|
20
|
+
function PanelChip({
|
|
21
|
+
id,
|
|
22
|
+
size,
|
|
23
|
+
className,
|
|
24
|
+
badge,
|
|
25
|
+
kind = 'item',
|
|
26
|
+
names,
|
|
27
|
+
lang,
|
|
28
|
+
favIds,
|
|
29
|
+
}: {
|
|
30
|
+
id: string;
|
|
31
|
+
size: EntrySize;
|
|
32
|
+
className?: string;
|
|
33
|
+
badge?: { node: ReactNode; className?: string };
|
|
34
|
+
kind?: 'item' | 'fluid';
|
|
35
|
+
names: Record<string, Record<string, string>>;
|
|
36
|
+
lang: Lang;
|
|
37
|
+
favIds?: ReadonlySet<string>;
|
|
38
|
+
}) {
|
|
39
|
+
return (
|
|
40
|
+
<Entry
|
|
41
|
+
id={id}
|
|
42
|
+
kind={kind}
|
|
43
|
+
name={recipeItemName(names, lang, id)}
|
|
44
|
+
size={size}
|
|
45
|
+
variant="chip"
|
|
46
|
+
href={false}
|
|
47
|
+
className={cn('block', className)}
|
|
48
|
+
badge={
|
|
49
|
+
badge?.node ??
|
|
50
|
+
(favIds?.has(id) ? (
|
|
51
|
+
<Star className="size-2.5 fill-amber-500 text-amber-500" />
|
|
52
|
+
) : undefined)
|
|
53
|
+
}
|
|
54
|
+
badgeClassName={
|
|
55
|
+
badge?.className ?? '-left-0.5 -top-0.5 right-auto bottom-auto'
|
|
56
|
+
}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function PanelCell({
|
|
62
|
+
cell,
|
|
63
|
+
dataset,
|
|
64
|
+
lang,
|
|
65
|
+
names,
|
|
66
|
+
nav,
|
|
67
|
+
favIds,
|
|
68
|
+
expandLabel,
|
|
69
|
+
draggableStacks,
|
|
70
|
+
onPress,
|
|
71
|
+
onHover,
|
|
72
|
+
onToggleGroup,
|
|
73
|
+
}: {
|
|
74
|
+
cell: ItemPanelCell;
|
|
75
|
+
dataset: string;
|
|
76
|
+
lang: Lang;
|
|
77
|
+
names: Record<string, Record<string, string>>;
|
|
78
|
+
nav: RecipeHrefOpts;
|
|
79
|
+
favIds?: ReadonlySet<string>;
|
|
80
|
+
expandLabel: string;
|
|
81
|
+
draggableStacks?: boolean;
|
|
82
|
+
onPress: (id: string, ref?: 'item' | 'fluid') => void;
|
|
83
|
+
onHover?: (target: FavoriteHoverTarget | undefined) => void;
|
|
84
|
+
onToggleGroup?: (id: string) => void;
|
|
85
|
+
}) {
|
|
86
|
+
const stack = cell.kind === 'stack' ? cell.id : undefined;
|
|
87
|
+
const parsed = stack ? parseStackId(stack) : undefined;
|
|
88
|
+
const nbt = parsed ? formatNbt(parsed.nbt) : undefined;
|
|
89
|
+
const hover: FavoriteHoverTarget | undefined =
|
|
90
|
+
cell.kind === 'stack'
|
|
91
|
+
? {
|
|
92
|
+
kind: 'stack',
|
|
93
|
+
id: cell.id,
|
|
94
|
+
...(cell.ref ? { ref: cell.ref } : {}),
|
|
95
|
+
}
|
|
96
|
+
: cell.kind === 'recipe'
|
|
97
|
+
? {
|
|
98
|
+
kind: 'recipe',
|
|
99
|
+
id: cell.fav.id,
|
|
100
|
+
type: cell.fav.type,
|
|
101
|
+
...(cell.fav.icon ? { icon: cell.fav.icon } : {}),
|
|
102
|
+
}
|
|
103
|
+
: undefined;
|
|
104
|
+
return (
|
|
105
|
+
<li
|
|
106
|
+
className="flex min-h-0 min-w-0 items-center justify-center"
|
|
107
|
+
onMouseEnter={() => onHover?.(hover)}
|
|
108
|
+
onMouseLeave={() => onHover?.(undefined)}
|
|
109
|
+
>
|
|
110
|
+
{cell.kind === 'recipe' ? (
|
|
111
|
+
<RecipeFavoriteCell
|
|
112
|
+
dataset={dataset}
|
|
113
|
+
lang={lang}
|
|
114
|
+
names={names}
|
|
115
|
+
nav={nav}
|
|
116
|
+
fav={cell.fav}
|
|
117
|
+
/>
|
|
118
|
+
) : cell.kind === 'group' ? (
|
|
119
|
+
<Hint label={cell.expanded ? undefined : expandLabel}>
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
aria-label={cell.label}
|
|
123
|
+
aria-pressed={cell.expanded}
|
|
124
|
+
onClick={() => onToggleGroup?.(cell.id)}
|
|
125
|
+
className="block rounded-sm"
|
|
126
|
+
>
|
|
127
|
+
<span className="relative flex size-9 items-center justify-center">
|
|
128
|
+
<EntryGroup members={cell.members} size="lg" />
|
|
129
|
+
<Badge className="absolute -right-0.5 -bottom-0.5 z-10 h-auto rounded-sm px-0.5 py-0 leading-tight">
|
|
130
|
+
{cell.expanded ? (
|
|
131
|
+
<Minus className="size-3" />
|
|
132
|
+
) : (
|
|
133
|
+
<Plus className="size-3" />
|
|
134
|
+
)}
|
|
135
|
+
</Badge>
|
|
136
|
+
</span>
|
|
137
|
+
</button>
|
|
138
|
+
</Hint>
|
|
139
|
+
) : (
|
|
140
|
+
<CopyIdMenu id={parsed?.id ?? cell.id} nbt={nbt}>
|
|
141
|
+
<button
|
|
142
|
+
type="button"
|
|
143
|
+
onClick={() => onPress(cell.id, cell.ref)}
|
|
144
|
+
aria-label={recipeItemName(names, lang, cell.id)}
|
|
145
|
+
className={cn('block rounded-sm', draggableStacks && 'cursor-grab')}
|
|
146
|
+
draggable={draggableStacks || undefined}
|
|
147
|
+
onDragStart={
|
|
148
|
+
draggableStacks
|
|
149
|
+
? (event) => {
|
|
150
|
+
event.dataTransfer.setData(
|
|
151
|
+
'application/x-tfg-calc',
|
|
152
|
+
JSON.stringify({
|
|
153
|
+
id: cell.id,
|
|
154
|
+
kind: cell.ref === 'fluid' ? 'fluid' : 'item',
|
|
155
|
+
}),
|
|
156
|
+
);
|
|
157
|
+
event.dataTransfer.effectAllowed = 'copy';
|
|
158
|
+
}
|
|
159
|
+
: undefined
|
|
160
|
+
}
|
|
161
|
+
>
|
|
162
|
+
<PanelChip
|
|
163
|
+
id={cell.id}
|
|
164
|
+
size="lg"
|
|
165
|
+
className="size-9"
|
|
166
|
+
kind={cell.ref === 'fluid' ? 'fluid' : 'item'}
|
|
167
|
+
names={names}
|
|
168
|
+
lang={lang}
|
|
169
|
+
favIds={favIds}
|
|
170
|
+
/>
|
|
171
|
+
</button>
|
|
172
|
+
</CopyIdMenu>
|
|
173
|
+
)}
|
|
174
|
+
</li>
|
|
175
|
+
);
|
|
176
|
+
}
|