@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,148 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ArrowUp,
|
|
5
|
+
ChevronsUpDown,
|
|
6
|
+
Eye,
|
|
7
|
+
Info,
|
|
8
|
+
Move,
|
|
9
|
+
Settings2,
|
|
10
|
+
SquareMousePointer,
|
|
11
|
+
} from 'lucide-react';
|
|
12
|
+
import { IconButton } from '@terrafirmagreg-team/ui/components/blocks/button/icon-button';
|
|
13
|
+
import {
|
|
14
|
+
Popover,
|
|
15
|
+
PopoverContent,
|
|
16
|
+
PopoverTrigger,
|
|
17
|
+
} from '@terrafirmagreg-team/ui/components/ui/popover';
|
|
18
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
19
|
+
|
|
20
|
+
export function CalcHelp() {
|
|
21
|
+
const t = useTranslations();
|
|
22
|
+
return (
|
|
23
|
+
<Popover>
|
|
24
|
+
<PopoverTrigger
|
|
25
|
+
render={<IconButton overlay label={t('recipe.calc.help.title')} />}
|
|
26
|
+
>
|
|
27
|
+
<Info className="size-3.5" />
|
|
28
|
+
</PopoverTrigger>
|
|
29
|
+
<PopoverContent side="bottom" align="end" className="w-80 space-y-3 p-3">
|
|
30
|
+
<section className="space-y-1.5">
|
|
31
|
+
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70">
|
|
32
|
+
{t('recipe.calc.help.sec_nodes')}
|
|
33
|
+
</h4>
|
|
34
|
+
<ul className="space-y-1.5 text-xs text-muted-foreground">
|
|
35
|
+
<li className="flex items-center gap-2">
|
|
36
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
37
|
+
<span className="size-4 rounded border border-primary/60" />
|
|
38
|
+
</span>
|
|
39
|
+
{t('recipe.calc.help.recipe')}
|
|
40
|
+
</li>
|
|
41
|
+
<li className="flex items-center gap-2">
|
|
42
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
43
|
+
<span className="size-4 rounded border border-dashed border-muted-foreground/50" />
|
|
44
|
+
</span>
|
|
45
|
+
{t('recipe.calc.help.catalyst')}
|
|
46
|
+
</li>
|
|
47
|
+
<li className="flex items-center gap-2">
|
|
48
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
49
|
+
<span className="size-4 rounded border border-red-500/70" />
|
|
50
|
+
</span>
|
|
51
|
+
{t('recipe.calc.help.cycle')}
|
|
52
|
+
</li>
|
|
53
|
+
<li className="flex items-center gap-2">
|
|
54
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
55
|
+
<span className="size-3.5 rounded ring-2 ring-primary/70" />
|
|
56
|
+
</span>
|
|
57
|
+
{t('recipe.calc.help.focus')}
|
|
58
|
+
</li>
|
|
59
|
+
<li className="flex items-center gap-2">
|
|
60
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
61
|
+
<span className="rounded border border-emerald-500/40 px-0.5 text-[10px] font-medium leading-3 text-emerald-500">
|
|
62
|
+
+N
|
|
63
|
+
</span>
|
|
64
|
+
</span>
|
|
65
|
+
{t('recipe.calc.help.satisfied')}
|
|
66
|
+
</li>
|
|
67
|
+
<li className="flex items-center gap-2">
|
|
68
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
69
|
+
<span className="rounded border border-border bg-background px-0.5 text-[10px] leading-3">
|
|
70
|
+
S
|
|
71
|
+
</span>
|
|
72
|
+
</span>
|
|
73
|
+
{t('recipe.calc.help.source')}
|
|
74
|
+
</li>
|
|
75
|
+
</ul>
|
|
76
|
+
</section>
|
|
77
|
+
<section className="space-y-1.5">
|
|
78
|
+
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70">
|
|
79
|
+
{t('recipe.calc.help.sec_edges')}
|
|
80
|
+
</h4>
|
|
81
|
+
<ul className="space-y-1.5 text-xs text-muted-foreground">
|
|
82
|
+
<li className="flex items-center gap-2">
|
|
83
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
84
|
+
<ArrowUp className="size-3.5 text-muted-foreground" />
|
|
85
|
+
</span>
|
|
86
|
+
{t('recipe.calc.help.edges')}
|
|
87
|
+
</li>
|
|
88
|
+
<li className="flex items-center gap-2">
|
|
89
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
90
|
+
<span className="h-0.5 w-4 rounded bg-teal-500" />
|
|
91
|
+
</span>
|
|
92
|
+
{t('recipe.calc.help.edge_out')}
|
|
93
|
+
</li>
|
|
94
|
+
<li className="flex items-center gap-2">
|
|
95
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
96
|
+
<span className="h-0.5 w-4 rounded bg-yellow-500" />
|
|
97
|
+
</span>
|
|
98
|
+
{t('recipe.calc.help.edge_in')}
|
|
99
|
+
</li>
|
|
100
|
+
<li className="flex items-center gap-2">
|
|
101
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
102
|
+
<span className="h-0 w-4 border-t border-dashed border-muted-foreground/60" />
|
|
103
|
+
</span>
|
|
104
|
+
{t('recipe.calc.help.edge_catalyst')}
|
|
105
|
+
</li>
|
|
106
|
+
</ul>
|
|
107
|
+
</section>
|
|
108
|
+
<section className="space-y-1.5">
|
|
109
|
+
<h4 className="text-[10px] font-semibold uppercase tracking-wider text-muted-foreground/70">
|
|
110
|
+
{t('recipe.calc.help.sec_actions')}
|
|
111
|
+
</h4>
|
|
112
|
+
<ul className="space-y-1.5 text-xs text-muted-foreground">
|
|
113
|
+
<li className="flex items-center gap-2">
|
|
114
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
115
|
+
<ChevronsUpDown className="size-3.5 text-muted-foreground" />
|
|
116
|
+
</span>
|
|
117
|
+
{t('recipe.calc.help.chip')}
|
|
118
|
+
</li>
|
|
119
|
+
<li className="flex items-center gap-2">
|
|
120
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
121
|
+
<Eye className="size-3.5 text-muted-foreground" />
|
|
122
|
+
</span>
|
|
123
|
+
{t('recipe.calc.help.hover')}
|
|
124
|
+
</li>
|
|
125
|
+
<li className="flex items-center gap-2">
|
|
126
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
127
|
+
<SquareMousePointer className="size-3.5 text-muted-foreground" />
|
|
128
|
+
</span>
|
|
129
|
+
{t('recipe.calc.help.ctx')}
|
|
130
|
+
</li>
|
|
131
|
+
<li className="flex items-center gap-2">
|
|
132
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
133
|
+
<Settings2 className="size-3.5 text-muted-foreground" />
|
|
134
|
+
</span>
|
|
135
|
+
{t('recipe.calc.help.modes')}
|
|
136
|
+
</li>
|
|
137
|
+
<li className="flex items-center gap-2">
|
|
138
|
+
<span className="flex w-5 shrink-0 items-center justify-center">
|
|
139
|
+
<Move className="size-3.5 text-muted-foreground" />
|
|
140
|
+
</span>
|
|
141
|
+
{t('recipe.calc.help.nav')}
|
|
142
|
+
</li>
|
|
143
|
+
</ul>
|
|
144
|
+
</section>
|
|
145
|
+
</PopoverContent>
|
|
146
|
+
</Popover>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useDeferredValue, useMemo } from 'react';
|
|
4
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
5
|
+
import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty-state';
|
|
6
|
+
import { LeftSidebarPortal } from '@terrafirmagreg-team/ui/components/layouts/left-sidebar';
|
|
7
|
+
import { CalcFlow } from '@terrafirmagreg-team/recipe/components/views/calc/flow';
|
|
8
|
+
import { CalcSidebar } from '@terrafirmagreg-team/recipe/components/views/calc/sidebar';
|
|
9
|
+
import { CalcTarget } from '@terrafirmagreg-team/recipe/components/views/calc/target';
|
|
10
|
+
import { CalcHistoryList } from '@terrafirmagreg-team/recipe/components/views/calc/trees';
|
|
11
|
+
import { CalcActions } from '@terrafirmagreg-team/recipe/components/views/calc/calculator/actions';
|
|
12
|
+
import { useCalcFocus } from '@terrafirmagreg-team/recipe/hooks/calc/use-focus';
|
|
13
|
+
import { useCalcReset } from '@terrafirmagreg-team/recipe/hooks/calc/use-reset';
|
|
14
|
+
import { useCalcAmounts } from '@terrafirmagreg-team/recipe/hooks/calc/use-amounts';
|
|
15
|
+
import { useCalcFill } from '@terrafirmagreg-team/recipe/hooks/calc/use-calc-fill';
|
|
16
|
+
import { useCalcActions } from '@terrafirmagreg-team/recipe/hooks/calc/use-actions';
|
|
17
|
+
import type { RecipeSession } from '@terrafirmagreg-team/recipe/types';
|
|
18
|
+
import { useCalcData } from '@terrafirmagreg-team/recipe/hooks/calc/use-data';
|
|
19
|
+
import { useCalcViewMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-view-mode';
|
|
20
|
+
import { useCalcDirection } from '@terrafirmagreg-team/recipe/hooks/calc/use-direction';
|
|
21
|
+
import { useCalcEdgeStyle } from '@terrafirmagreg-team/recipe/hooks/calc/use-edge-style';
|
|
22
|
+
import { useCalcFarMode } from '@terrafirmagreg-team/recipe/hooks/calc/use-far-mode';
|
|
23
|
+
import { useCalcDensity } from '@terrafirmagreg-team/recipe/hooks/calc/use-density';
|
|
24
|
+
|
|
25
|
+
export function Calculator({ session }: { session: RecipeSession }) {
|
|
26
|
+
const t = useTranslations();
|
|
27
|
+
const { dataset, lang } = session;
|
|
28
|
+
const [mode, setMode] = useCalcViewMode();
|
|
29
|
+
const [direction, setDirection] = useCalcDirection();
|
|
30
|
+
const [edgeStyle, setEdgeStyle] = useCalcEdgeStyle();
|
|
31
|
+
const [farCards, setFarCards] = useCalcFarMode();
|
|
32
|
+
const [density, setDensity] = useCalcDensity();
|
|
33
|
+
const {
|
|
34
|
+
target,
|
|
35
|
+
inventory,
|
|
36
|
+
selections,
|
|
37
|
+
tagSelections,
|
|
38
|
+
collapsed,
|
|
39
|
+
auto,
|
|
40
|
+
tabs,
|
|
41
|
+
activeTabId,
|
|
42
|
+
history,
|
|
43
|
+
openTab,
|
|
44
|
+
openEntry,
|
|
45
|
+
closeTab,
|
|
46
|
+
newTab,
|
|
47
|
+
renameTab,
|
|
48
|
+
setTabIcon,
|
|
49
|
+
removeHistory,
|
|
50
|
+
recipeDefaults,
|
|
51
|
+
setRecipeDefault,
|
|
52
|
+
goals,
|
|
53
|
+
summary,
|
|
54
|
+
ideal,
|
|
55
|
+
persist,
|
|
56
|
+
fillTree,
|
|
57
|
+
encodeShare,
|
|
58
|
+
recipeBody,
|
|
59
|
+
settled,
|
|
60
|
+
} = useCalcData(session);
|
|
61
|
+
const deferredGoals = useDeferredValue(goals);
|
|
62
|
+
const deferredLangMap = useDeferredValue(session.langMap);
|
|
63
|
+
const { focusNodeRef, onFocusNode, focusNodeId, setFocusNodeId } =
|
|
64
|
+
useCalcFocus(target);
|
|
65
|
+
const { resetGen, setResetGen } = useCalcReset(activeTabId);
|
|
66
|
+
const {
|
|
67
|
+
displayTarget,
|
|
68
|
+
displayInventory,
|
|
69
|
+
flushAmounts,
|
|
70
|
+
onAmount,
|
|
71
|
+
onStockAmount,
|
|
72
|
+
} = useCalcAmounts({
|
|
73
|
+
target,
|
|
74
|
+
inventory,
|
|
75
|
+
persist,
|
|
76
|
+
selections,
|
|
77
|
+
tagSelections,
|
|
78
|
+
collapsed,
|
|
79
|
+
auto,
|
|
80
|
+
});
|
|
81
|
+
const { onFillNode, onAutoBuild } = useCalcFill({
|
|
82
|
+
dataset,
|
|
83
|
+
hasTarget: !!target,
|
|
84
|
+
fillTree,
|
|
85
|
+
setResetGen,
|
|
86
|
+
});
|
|
87
|
+
const {
|
|
88
|
+
shared,
|
|
89
|
+
onShare,
|
|
90
|
+
flowData,
|
|
91
|
+
onAddStock,
|
|
92
|
+
onRemoveStock,
|
|
93
|
+
onApplyIdeal,
|
|
94
|
+
onRemoveTarget,
|
|
95
|
+
onClear,
|
|
96
|
+
} = useCalcActions({
|
|
97
|
+
dataset,
|
|
98
|
+
lang,
|
|
99
|
+
selections,
|
|
100
|
+
tagSelections,
|
|
101
|
+
collapsed,
|
|
102
|
+
auto,
|
|
103
|
+
goal: goals[0] ?? null,
|
|
104
|
+
ideal,
|
|
105
|
+
persist,
|
|
106
|
+
recipeDefaults,
|
|
107
|
+
setRecipeDefault,
|
|
108
|
+
recipeBody,
|
|
109
|
+
encodeShare,
|
|
110
|
+
flushAmounts,
|
|
111
|
+
setFocusNodeId,
|
|
112
|
+
onFillNode,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const iconItems = useMemo(
|
|
116
|
+
() => [
|
|
117
|
+
...(session.index?.items ?? []).map(
|
|
118
|
+
(id) => ({ id, kind: 'item' as const }),
|
|
119
|
+
),
|
|
120
|
+
...(session.index?.fluids ?? []).map(
|
|
121
|
+
(id) => ({ id, kind: 'fluid' as const }),
|
|
122
|
+
),
|
|
123
|
+
],
|
|
124
|
+
[session.index],
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
<>
|
|
129
|
+
<LeftSidebarPortal>
|
|
130
|
+
<CalcSidebar
|
|
131
|
+
dataset={dataset}
|
|
132
|
+
lang={lang}
|
|
133
|
+
langMap={deferredLangMap}
|
|
134
|
+
summary={summary}
|
|
135
|
+
target={displayTarget}
|
|
136
|
+
onFocus={onFocusNode}
|
|
137
|
+
trees={{
|
|
138
|
+
tabs,
|
|
139
|
+
activeId: activeTabId,
|
|
140
|
+
history,
|
|
141
|
+
iconItems,
|
|
142
|
+
onOpen: openTab,
|
|
143
|
+
onOpenEntry: openEntry,
|
|
144
|
+
onClose: closeTab,
|
|
145
|
+
onRename: renameTab,
|
|
146
|
+
onSetIcon: setTabIcon,
|
|
147
|
+
onNew: newTab,
|
|
148
|
+
onRemoveHistory: removeHistory,
|
|
149
|
+
}}
|
|
150
|
+
/>
|
|
151
|
+
</LeftSidebarPortal>
|
|
152
|
+
<CalcFlow
|
|
153
|
+
goals={deferredGoals}
|
|
154
|
+
dataset={dataset}
|
|
155
|
+
session={session}
|
|
156
|
+
data={flowData}
|
|
157
|
+
mode={mode}
|
|
158
|
+
onModeChange={setMode}
|
|
159
|
+
direction={direction}
|
|
160
|
+
onDirectionChange={setDirection}
|
|
161
|
+
edgeStyle={edgeStyle}
|
|
162
|
+
onEdgeStyleChange={setEdgeStyle}
|
|
163
|
+
farCards={farCards}
|
|
164
|
+
onFarCardsChange={setFarCards}
|
|
165
|
+
density={density}
|
|
166
|
+
onDensityChange={setDensity}
|
|
167
|
+
|
|
168
|
+
treeReady={settled && goals === deferredGoals}
|
|
169
|
+
resetGen={resetGen}
|
|
170
|
+
canvasId={activeTabId ?? undefined}
|
|
171
|
+
actions={
|
|
172
|
+
<CalcActions
|
|
173
|
+
session={session}
|
|
174
|
+
shared={shared}
|
|
175
|
+
onShare={onShare}
|
|
176
|
+
hasTargets={!!target}
|
|
177
|
+
onAutoBuild={onAutoBuild}
|
|
178
|
+
onClear={onClear}
|
|
179
|
+
/>
|
|
180
|
+
}
|
|
181
|
+
panel={
|
|
182
|
+
<CalcTarget
|
|
183
|
+
dataset={dataset}
|
|
184
|
+
lang={lang}
|
|
185
|
+
langMap={deferredLangMap}
|
|
186
|
+
target={displayTarget}
|
|
187
|
+
inventory={displayInventory}
|
|
188
|
+
iconItems={iconItems}
|
|
189
|
+
ideal={ideal}
|
|
190
|
+
onAmount={onAmount}
|
|
191
|
+
onStockAmount={onStockAmount}
|
|
192
|
+
onRemoveTarget={onRemoveTarget}
|
|
193
|
+
onRemoveStock={onRemoveStock}
|
|
194
|
+
onAddStock={onAddStock}
|
|
195
|
+
onApplyIdeal={onApplyIdeal}
|
|
196
|
+
onClear={onClear}
|
|
197
|
+
onFocus={onFocusNode}
|
|
198
|
+
/>
|
|
199
|
+
}
|
|
200
|
+
focusRef={focusNodeRef}
|
|
201
|
+
focusNodeId={focusNodeId}
|
|
202
|
+
onFocusedNode={() => setFocusNodeId(null)}
|
|
203
|
+
empty={
|
|
204
|
+
<div className="absolute inset-0 z-10 grid place-items-center overflow-auto p-4">
|
|
205
|
+
<div className="flex flex-col items-center gap-4">
|
|
206
|
+
<EmptyState variant="empty">
|
|
207
|
+
{t('recipe.calc.empty')}
|
|
208
|
+
</EmptyState>
|
|
209
|
+
<CalcHistoryList
|
|
210
|
+
history={history}
|
|
211
|
+
onOpen={openEntry}
|
|
212
|
+
meta={{ dataset, lang, langMap: session.langMap }}
|
|
213
|
+
/>
|
|
214
|
+
</div>
|
|
215
|
+
</div>
|
|
216
|
+
}
|
|
217
|
+
/>
|
|
218
|
+
</>
|
|
219
|
+
);
|
|
220
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { memo, useEffect, useRef } from 'react';
|
|
4
|
+
import { useStore } from '@terrafirmagreg-team/ui/lib/canvas/xyflow';
|
|
5
|
+
import {
|
|
6
|
+
CALC_NODE_H,
|
|
7
|
+
CALC_NODE_W,
|
|
8
|
+
type AnyCalcFlowNode,
|
|
9
|
+
} from '@terrafirmagreg-team/recipe/lib/calc/flow';
|
|
10
|
+
|
|
11
|
+
const cssVar = (name: string, fallback: string) =>
|
|
12
|
+
getComputedStyle(document.documentElement)
|
|
13
|
+
.getPropertyValue(name)
|
|
14
|
+
.trim() || fallback;
|
|
15
|
+
|
|
16
|
+
export const CalcDotOverlay = memo(function CalcDotOverlay({
|
|
17
|
+
nodes,
|
|
18
|
+
focusId,
|
|
19
|
+
}: {
|
|
20
|
+
nodes: AnyCalcFlowNode[];
|
|
21
|
+
focusId: string | null;
|
|
22
|
+
}) {
|
|
23
|
+
const canvasRef = useRef<HTMLCanvasElement>(null);
|
|
24
|
+
const tx = useStore((s) => s.transform[0]);
|
|
25
|
+
const ty = useStore((s) => s.transform[1]);
|
|
26
|
+
const zoom = useStore((s) => s.transform[2]);
|
|
27
|
+
const w = useStore((s) => s.width);
|
|
28
|
+
const h = useStore((s) => s.height);
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const canvas = canvasRef.current;
|
|
32
|
+
if (!canvas || !w || !h || !zoom) return;
|
|
33
|
+
const dpr = window.devicePixelRatio || 1;
|
|
34
|
+
const pw = Math.round(w * dpr);
|
|
35
|
+
const ph = Math.round(h * dpr);
|
|
36
|
+
if (canvas.width !== pw || canvas.height !== ph) {
|
|
37
|
+
canvas.width = pw;
|
|
38
|
+
canvas.height = ph;
|
|
39
|
+
}
|
|
40
|
+
const ctx = canvas.getContext('2d');
|
|
41
|
+
if (!ctx) return;
|
|
42
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
43
|
+
ctx.clearRect(0, 0, w, h);
|
|
44
|
+
const card = cssVar('--color-card', '#17171a');
|
|
45
|
+
const border = cssVar('--color-border', '#3f3f46');
|
|
46
|
+
const primary = cssVar('--color-primary', '#00c8c8');
|
|
47
|
+
const danger = cssVar('--color-red-500', '#ef4444');
|
|
48
|
+
ctx.lineWidth = 1;
|
|
49
|
+
for (const node of nodes) {
|
|
50
|
+
const nw = node.width ?? CALC_NODE_W;
|
|
51
|
+
const nh = node.height ?? CALC_NODE_H;
|
|
52
|
+
const x = (node.position.x - nw / 2) * zoom + tx;
|
|
53
|
+
const y = (node.position.y - nh / 2) * zoom + ty;
|
|
54
|
+
const rw = nw * zoom;
|
|
55
|
+
const rh = nh * zoom;
|
|
56
|
+
if (x + rw < 0 || x > w || y + rh < 0 || y > h) continue;
|
|
57
|
+
const { node: calc } = node.data;
|
|
58
|
+
const stroke =
|
|
59
|
+
node.id === focusId || calc.recipe
|
|
60
|
+
? primary
|
|
61
|
+
: calc.cycle
|
|
62
|
+
? danger
|
|
63
|
+
: border;
|
|
64
|
+
ctx.fillStyle = card;
|
|
65
|
+
ctx.fillRect(x, y, rw, rh);
|
|
66
|
+
ctx.strokeStyle = stroke;
|
|
67
|
+
ctx.strokeRect(x + 0.5, y + 0.5, Math.max(rw - 1, 0), Math.max(rh - 1, 0));
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<canvas
|
|
73
|
+
ref={canvasRef}
|
|
74
|
+
aria-hidden
|
|
75
|
+
className="pointer-events-none absolute inset-0 z-10"
|
|
76
|
+
style={{ width: w, height: h }}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { createChevronEdge } from '@terrafirmagreg-team/ui/components/blocks/canvas/chevron-edge';
|
|
4
|
+
import {
|
|
5
|
+
getBezierPath,
|
|
6
|
+
getSmoothStepPath,
|
|
7
|
+
} from '@terrafirmagreg-team/ui/lib/canvas/xyflow';
|
|
8
|
+
import {
|
|
9
|
+
chamferedPolylinePath,
|
|
10
|
+
svgPathToPoints,
|
|
11
|
+
} from '@terrafirmagreg-team/ui/lib/canvas/edge';
|
|
12
|
+
import type { FlowPoint } from '@terrafirmagreg-team/ui/types/canvas';
|
|
13
|
+
import type { CalcEdgeStyle } from '@terrafirmagreg-team/recipe/lib/calc/flow';
|
|
14
|
+
|
|
15
|
+
export const CalcEdge = createChevronEdge({
|
|
16
|
+
resolvePath: (ctx) => {
|
|
17
|
+
const route = (ctx.data?.route as CalcEdgeStyle | undefined) ?? 'default';
|
|
18
|
+
if (route === 'circuit') {
|
|
19
|
+
const points = ctx.data?.points;
|
|
20
|
+
if (Array.isArray(points) && points.length >= 2) {
|
|
21
|
+
|
|
22
|
+
return svgPathToPoints(chamferedPolylinePath(points as FlowPoint[]));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const anchors = {
|
|
26
|
+
sourceX: ctx.sourceX,
|
|
27
|
+
sourceY: ctx.sourceY,
|
|
28
|
+
sourcePosition: ctx.sourcePosition,
|
|
29
|
+
targetX: ctx.targetX,
|
|
30
|
+
targetY: ctx.targetY,
|
|
31
|
+
targetPosition: ctx.targetPosition,
|
|
32
|
+
};
|
|
33
|
+
if (route === 'straight') {
|
|
34
|
+
return [
|
|
35
|
+
{ x: ctx.sourceX, y: ctx.sourceY },
|
|
36
|
+
{ x: ctx.targetX, y: ctx.targetY },
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
if (route === 'default') {
|
|
40
|
+
return svgPathToPoints(getBezierPath(anchors)[0]);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return svgPathToPoints(
|
|
44
|
+
getSmoothStepPath({
|
|
45
|
+
...anchors,
|
|
46
|
+
borderRadius: route === 'smoothstep' ? 10 : 0,
|
|
47
|
+
})[0],
|
|
48
|
+
);
|
|
49
|
+
},
|
|
50
|
+
});
|