@terrafirmagreg-team/recipe 0.1.0 → 1.2.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.
Files changed (240) hide show
  1. package/package.json +16 -16
  2. package/src/components/button-copy.tsx +1 -0
  3. package/src/components/cards/card/index.tsx +5 -3
  4. package/src/components/cards/card/scene.tsx +4 -2
  5. package/src/components/cards/card/strip.tsx +4 -2
  6. package/src/components/cards/card/text.tsx +2 -1
  7. package/src/components/cards/card/tips.tsx +1 -0
  8. package/src/components/cards/default-item.tsx +6 -2
  9. package/src/components/cards/glare-filter.tsx +1 -0
  10. package/src/components/cards/paged-card.tsx +1 -0
  11. package/src/components/cards/slot-hitbox.tsx +4 -2
  12. package/src/components/cards/strip-card/buttons.tsx +7 -2
  13. package/src/components/cards/strip-card/index.tsx +3 -1
  14. package/src/components/cards/strip-card/member-cell.tsx +4 -2
  15. package/src/components/cards/strip-card/sprite.tsx +1 -0
  16. package/src/components/embed-card.tsx +44 -0
  17. package/src/components/mdx/recipe.tsx +34 -16
  18. package/src/components/tool-list.tsx +1 -0
  19. package/src/{lib/tree.ts → components/tree.tsx} +20 -12
  20. package/src/components/views/alloy/index.tsx +14 -7
  21. package/src/components/views/alloy/list.tsx +3 -2
  22. package/src/components/views/alloy/mix/index.tsx +1 -0
  23. package/src/components/views/alloy/mix/ratio.tsx +7 -6
  24. package/src/components/views/alloy/mix/rows.tsx +6 -7
  25. package/src/components/views/alloy/mix/status.tsx +8 -7
  26. package/src/components/views/alloy/mix/total.tsx +13 -12
  27. package/src/components/views/alloy/range-bar.tsx +2 -1
  28. package/src/components/views/alloy/stack-bar.tsx +4 -2
  29. package/src/components/views/browser/axis-switcher.tsx +13 -12
  30. package/src/components/views/browser/card-grid.tsx +2 -1
  31. package/src/components/views/browser/favorite-button.tsx +2 -1
  32. package/src/components/views/browser/frame.tsx +3 -2
  33. package/src/components/views/browser/index.tsx +20 -2
  34. package/src/components/views/browser/item-panel/index.tsx +11 -9
  35. package/src/components/views/browser/item-panel/skeleton.tsx +1 -0
  36. package/src/components/views/browser/item-panel-grid/cell.tsx +5 -3
  37. package/src/components/views/browser/item-panel-grid/favorite-cell.tsx +4 -2
  38. package/src/components/views/browser/item-panel-grid/index.tsx +4 -2
  39. package/src/components/views/browser/item-view/index.tsx +7 -12
  40. package/src/components/views/browser/item-view/tags.tsx +7 -5
  41. package/src/components/views/browser/item-view-header.tsx +10 -9
  42. package/src/components/views/browser/pane-tabs.tsx +1 -0
  43. package/src/components/views/browser/place-header.tsx +4 -3
  44. package/src/components/views/browser/query-controls.tsx +3 -1
  45. package/src/components/views/browser/recipe-item-header.tsx +5 -4
  46. package/src/components/views/browser/settings.tsx +4 -3
  47. package/src/components/views/browser/toolbar.tsx +3 -2
  48. package/src/components/views/browser/type-tabs.tsx +5 -3
  49. package/src/components/views/browser/type-view.tsx +7 -12
  50. package/src/components/views/browser/workstation-rail.tsx +4 -3
  51. package/src/components/views/calc/calculator/actions.tsx +4 -14
  52. package/src/components/views/calc/calculator/help.tsx +69 -28
  53. package/src/components/views/calc/calculator/index.tsx +34 -82
  54. package/src/components/views/calc/dot-overlay.tsx +1 -0
  55. package/src/components/views/calc/edge.tsx +134 -32
  56. package/src/components/views/calc/flow/index.tsx +92 -54
  57. package/src/components/views/calc/flow/picker-dialogs.tsx +84 -6
  58. package/src/components/views/calc/flow/toolbar.tsx +9 -21
  59. package/src/components/views/calc/flow/view-menu.tsx +16 -120
  60. package/src/components/views/calc/member-picker.tsx +8 -6
  61. package/src/components/views/calc/node-card/actions.tsx +28 -106
  62. package/src/components/views/calc/node-card/badges.tsx +10 -28
  63. package/src/components/views/calc/node-card/chips.tsx +8 -40
  64. package/src/components/views/calc/node-card/far.tsx +13 -65
  65. package/src/components/views/calc/node-card/full.tsx +133 -83
  66. package/src/components/views/calc/node-card/index.tsx +1 -0
  67. package/src/components/views/calc/node-card/menu.tsx +93 -22
  68. package/src/components/views/calc/node-card/port-cells.tsx +186 -0
  69. package/src/components/views/calc/node-card/port-rails.tsx +251 -0
  70. package/src/components/views/calc/node-card/ports.tsx +86 -0
  71. package/src/components/views/calc/recipe-picker/body.tsx +17 -14
  72. package/src/components/views/calc/recipe-picker/footer.tsx +5 -3
  73. package/src/components/views/calc/recipe-picker/index.tsx +5 -0
  74. package/src/components/views/calc/sidebar.tsx +19 -10
  75. package/src/components/views/calc/trees/icon-picker.tsx +3 -2
  76. package/src/components/views/calc/trees/index.tsx +5 -4
  77. package/src/components/views/calc/trees/label.tsx +6 -4
  78. package/src/components/views/calc/trees/rows.tsx +6 -5
  79. package/src/components/views/forge/gui.tsx +2 -1
  80. package/src/components/views/forge/index.tsx +14 -7
  81. package/src/components/views/forge/list.tsx +3 -2
  82. package/src/components/views/forge/workbench/controls.tsx +13 -6
  83. package/src/components/views/forge/workbench/index.tsx +3 -2
  84. package/src/components/views/forge/workbench/panel.tsx +1 -0
  85. package/src/components/views/forge/workbench/ruler.tsx +5 -4
  86. package/src/components/views/forge/workbench/status.tsx +6 -5
  87. package/src/components/views/forge/workbench/tape.tsx +5 -4
  88. package/src/hooks/alloy/use-fluid-colors.ts +12 -9
  89. package/src/hooks/alloy/use-mix-state.ts +3 -2
  90. package/src/hooks/calc/flow/use-engage.ts +129 -0
  91. package/src/hooks/calc/flow/use-handlers.ts +192 -0
  92. package/src/hooks/calc/flow/use-layout.ts +105 -0
  93. package/src/hooks/calc/flow/{mount.ts → use-mount.ts} +1 -0
  94. package/src/hooks/calc/flow/{nodes.ts → use-nodes.ts} +46 -37
  95. package/src/hooks/calc/flow/use-pickers.ts +57 -0
  96. package/src/hooks/calc/flow/{viewport.ts → use-viewport.ts} +13 -26
  97. package/src/hooks/calc/flow/{window.ts → use-window.ts} +1 -0
  98. package/src/hooks/calc/use-actions.ts +208 -229
  99. package/src/hooks/calc/use-amounts.ts +23 -60
  100. package/src/hooks/calc/use-data.ts +106 -192
  101. package/src/hooks/calc/use-defaults.ts +4 -2
  102. package/src/hooks/calc/use-far-mode.ts +1 -0
  103. package/src/hooks/calc/use-focus.ts +8 -7
  104. package/src/hooks/calc/use-maps.ts +1 -0
  105. package/src/hooks/calc/use-reset.ts +1 -0
  106. package/src/hooks/calc/use-resolver.ts +32 -196
  107. package/src/hooks/calc/use-session.ts +1 -0
  108. package/src/hooks/calc/use-share.ts +5 -2
  109. package/src/hooks/calc/use-storage.ts +5 -4
  110. package/src/hooks/calc/use-tier.ts +1 -0
  111. package/src/hooks/calc/use-view-mode.ts +1 -0
  112. package/src/hooks/calc/use-worker.ts +56 -121
  113. package/src/hooks/forge/use-anvil-gui.ts +4 -2
  114. package/src/hooks/forge/use-forge-state.ts +1 -0
  115. package/src/hooks/forge/use-ruler.ts +1 -0
  116. package/src/hooks/use-add-to-calc.ts +23 -19
  117. package/src/hooks/use-categories-by-id.ts +18 -0
  118. package/src/hooks/use-favorite-hotkey.ts +1 -0
  119. package/src/hooks/use-favorites.ts +1 -0
  120. package/src/hooks/use-group-outlines.ts +1 -0
  121. package/src/hooks/use-hide-unused.ts +2 -1
  122. package/src/hooks/use-index.ts +6 -2
  123. package/src/hooks/use-item-feeds.ts +3 -1
  124. package/src/hooks/use-item-pane.ts +6 -4
  125. package/src/hooks/use-item-press.ts +27 -23
  126. package/src/hooks/use-item-tag-groups.ts +4 -2
  127. package/src/hooks/use-item-tooltips.ts +3 -1
  128. package/src/hooks/use-left-sidebar-tree.ts +11 -3
  129. package/src/hooks/use-mod-names.ts +4 -2
  130. package/src/hooks/use-mount-limit.ts +1 -0
  131. package/src/hooks/use-panel-cells.ts +3 -1
  132. package/src/hooks/use-panel-page.ts +9 -6
  133. package/src/hooks/use-panel-tabs.ts +2 -1
  134. package/src/hooks/use-query.ts +8 -6
  135. package/src/hooks/use-session.ts +6 -2
  136. package/src/hooks/use-sidebar-group.ts +3 -7
  137. package/src/hooks/use-tag-members.ts +3 -1
  138. package/src/hooks/use-tool-recipes.ts +1 -0
  139. package/src/hooks/use-type-filter.ts +1 -0
  140. package/src/lib/alloy/mix.ts +1 -0
  141. package/src/lib/alloy/parse.ts +1 -0
  142. package/src/lib/calc/defaults.ts +6 -4
  143. package/src/lib/calc/flow.ts +143 -107
  144. package/src/lib/calc/focus.ts +1 -0
  145. package/src/lib/calc/meta.ts +3 -1
  146. package/src/lib/calc/pack.ts +47 -154
  147. package/src/lib/calc/ports.ts +43 -0
  148. package/src/lib/calc/resolve.ts +6 -38
  149. package/src/lib/calc/route/buckets.ts +1 -0
  150. package/src/lib/calc/route/geometry.ts +13 -24
  151. package/src/lib/calc/route/index.ts +1 -0
  152. package/src/lib/calc/route/polyline.ts +3 -3
  153. package/src/lib/calc/route/router.ts +181 -57
  154. package/src/lib/calc/scheme.ts +226 -0
  155. package/src/lib/calc/storage/entry.ts +27 -19
  156. package/src/lib/calc/storage/index.ts +2 -0
  157. package/src/lib/calc/storage/keys.ts +4 -8
  158. package/src/lib/calc/storage/store.ts +11 -36
  159. package/src/lib/calc/tree/index.ts +2 -16
  160. package/src/lib/calc/tree/materials.ts +1 -0
  161. package/src/lib/calc/tree/recipe.ts +1 -0
  162. package/src/lib/calc/tree/share.ts +86 -149
  163. package/src/lib/calc/worker/api.ts +3 -11
  164. package/src/lib/calc/worker/fetch.ts +1 -0
  165. package/src/lib/calc/worker/flush.ts +7 -20
  166. package/src/lib/calc/worker/index.ts +1 -1
  167. package/src/lib/calc/worker/protocol.ts +16 -13
  168. package/src/lib/calc/worker/resolve.ts +32 -84
  169. package/src/lib/calc/worker/state.ts +5 -6
  170. package/src/{components/cards/card/model.ts → lib/card-model.ts} +1 -0
  171. package/src/lib/client/recipe-categories.ts +11 -93
  172. package/src/lib/client/recipe.ts +13 -11
  173. package/src/lib/client-index/catalog.ts +33 -27
  174. package/src/lib/client-index/chrome.ts +30 -30
  175. package/src/lib/client-index/index.ts +1 -0
  176. package/src/lib/client-index/registry.ts +70 -59
  177. package/src/lib/client-index/rows.ts +63 -57
  178. package/src/lib/client-index/tooltips.ts +28 -34
  179. package/src/lib/config.ts +2 -1
  180. package/src/lib/data/category/dto.ts +4 -3
  181. package/src/lib/data/category/load.ts +9 -8
  182. package/src/lib/data/category/parse.ts +4 -3
  183. package/src/lib/data/dto.ts +4 -3
  184. package/src/lib/data/grid.ts +2 -1
  185. package/src/lib/data/parse/entry.ts +3 -2
  186. package/src/lib/data/parse/index.ts +1 -0
  187. package/src/lib/data/parse/layout.ts +5 -2
  188. package/src/lib/data/parse/slots.ts +3 -2
  189. package/src/lib/data/parse/widgets.ts +3 -2
  190. package/src/lib/data/scene.ts +1 -1
  191. package/src/lib/data/slot-io.ts +1 -0
  192. package/src/lib/dump.ts +4 -3
  193. package/src/lib/embed.ts +22 -0
  194. package/src/lib/favorite-hover.ts +1 -0
  195. package/src/lib/fluid-outputs.ts +10 -12
  196. package/src/lib/forge/actions.ts +2 -1
  197. package/src/lib/forge/data.ts +2 -1
  198. package/src/lib/forge/solve.ts +1 -0
  199. package/src/lib/group.ts +1 -0
  200. package/src/lib/index-store.ts +15 -9
  201. package/src/lib/links.ts +15 -9
  202. package/src/lib/lookup.ts +10 -8
  203. package/src/lib/panel-outline.ts +1 -0
  204. package/src/lib/panel.ts +3 -2
  205. package/src/lib/preview.ts +12 -8
  206. package/src/lib/recipe-slots.ts +1 -0
  207. package/src/lib/search.ts +1 -0
  208. package/src/lib/sidebar.ts +1 -0
  209. package/src/lib/used-items.ts +1 -0
  210. package/src/locales/en_us.json +170 -226
  211. package/src/locales/ru_ru.json +170 -226
  212. package/src/locales.ts +1 -0
  213. package/src/types/alloy.ts +1 -0
  214. package/src/{hooks/calc/flow/props.ts → types/calc-flow-props.ts} +18 -14
  215. package/src/types/calc.ts +41 -44
  216. package/src/types/forge.ts +1 -0
  217. package/src/types/index.ts +4 -2
  218. package/styles/calc.css +308 -47
  219. package/src/components/cards/fit-card.tsx +0 -26
  220. package/src/components/views/calc/target.tsx +0 -271
  221. package/src/hooks/calc/flow/engage.ts +0 -89
  222. package/src/hooks/calc/flow/handlers.ts +0 -115
  223. package/src/hooks/calc/flow/layout.ts +0 -149
  224. package/src/hooks/calc/flow/pickers.ts +0 -50
  225. package/src/hooks/calc/use-calc-fill.ts +0 -91
  226. package/src/hooks/calc/use-density.ts +0 -28
  227. package/src/hooks/calc/use-derived.ts +0 -258
  228. package/src/hooks/calc/use-direction.ts +0 -23
  229. package/src/hooks/calc/use-edge-style.ts +0 -40
  230. package/src/hooks/calc/use-fill.ts +0 -213
  231. package/src/lib/alloy/alloy.test.ts +0 -186
  232. package/src/lib/calc/tree/build.ts +0 -196
  233. package/src/lib/calc/tree/context.ts +0 -42
  234. package/src/lib/calc/tree/goal.ts +0 -64
  235. package/src/lib/calc/tree/ideal.ts +0 -36
  236. package/src/lib/calc/tree/pick.ts +0 -68
  237. package/src/lib/calc/tree/tree.test.ts +0 -169
  238. package/src/lib/calc/worker/fill.ts +0 -123
  239. package/src/lib/client-index/cache.ts +0 -13
  240. package/src/lib/forge/forge.test.ts +0 -123
@@ -1,6 +1,7 @@
1
+ import type { DatasetRef } from '@terrafirmagreg-team/sites/location';
1
2
  import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
2
3
  import type { DatasetLanding } from '@terrafirmagreg-team/kit/types';
3
- import type { DumpCreativeTab } from '@terrafirmagreg-team/game/lib/dump/data/tab/dto';
4
+ import type { DumpCreativeTab } from '@terrafirmagreg-team/dump/lib/dump/data/tab/dto';
4
5
  import type { DumpRecipeCategory } from '@terrafirmagreg-team/recipe/lib/data/category/dto';
5
6
  import type { Recipe } from '@terrafirmagreg-team/recipe/lib/data/dto';
6
7
 
@@ -108,7 +109,7 @@ export type CategoryGroup = { category: string; rows: RecipeCompactRow[] };
108
109
 
109
110
  export type RecipeSession = {
110
111
  page: RecipePageData;
111
- dataset: string;
112
+ dataset: DatasetRef;
112
113
  lang: Lang;
113
114
  place?: RecipePlace;
114
115
  placeOpts: Pick<RecipeHrefOpts, 'type' | 'tool'>;
@@ -132,3 +133,4 @@ export type RecipeSession = {
132
133
  langMap: Record<string, string>;
133
134
  used: UsedItems;
134
135
  };
136
+
package/styles/calc.css CHANGED
@@ -1,47 +1,308 @@
1
- .calc-edge--catalyst {
2
- opacity: 0.4;
3
- }
4
-
5
- .calc-edge--circuit .chevron-edge__base {
6
- stroke: color-mix(
7
- in oklab,
8
- var(--color-primary) 45%,
9
- var(--color-muted-foreground)
10
- );
11
- }
12
-
13
- .calc-flow .react-flow__node:not(.dragging) {
14
- transition: transform 240ms ease;
15
- }
16
-
17
- .calc-flow .react-flow__node-calcMaterial[style*='--calc-delay'] {
18
- animation: calc-node-in 200ms ease-out both;
19
- animation-delay: var(--calc-delay, 0ms);
20
- }
21
-
22
- .calc-flow
23
- .react-flow__node-calcMaterial[style*='--calc-delay']
24
- [data-calc-card] {
25
- animation: calc-card-in 200ms ease-out both;
26
- animation-delay: var(--calc-delay, 0ms);
27
- }
28
-
29
- @keyframes calc-node-in {
30
- from {
31
- opacity: 0;
32
- }
33
- }
34
-
35
- @keyframes calc-card-in {
36
- from {
37
- transform: translateY(6px) scale(0.92);
38
- }
39
- }
40
-
41
- .react-flow__node.calc-node--focus [data-calc-card] {
42
- box-shadow: 0 0 0 2px var(--color-primary);
43
- }
44
-
45
- .calc-flow--dots .react-flow__edges {
46
- display: none;
47
- }
1
+ .calc-edge--link .chevron-edge__base {
2
+ stroke-dasharray: 5 4;
3
+ stroke: color-mix(
4
+ in oklab,
5
+ var(--color-primary) 65%,
6
+ var(--color-muted-foreground)
7
+ );
8
+ }
9
+
10
+ .calc-flow .react-flow__node {
11
+ cursor: default;
12
+ }
13
+
14
+ .calc-flow .react-flow__node.dragging {
15
+ cursor: grabbing;
16
+ }
17
+
18
+ .calc-rail {
19
+ position: absolute;
20
+ top: 2px;
21
+ bottom: 2px;
22
+ z-index: 25;
23
+ display: flex;
24
+ flex-direction: column;
25
+ flex-wrap: nowrap;
26
+ justify-content: center;
27
+ gap: 2px;
28
+ overflow: hidden;
29
+ width: 20px;
30
+ pointer-events: none;
31
+ }
32
+
33
+ .calc-rail .calc-port {
34
+ pointer-events: auto;
35
+ }
36
+
37
+ .calc-rail--in {
38
+ right: calc(100% - 10px);
39
+ align-items: flex-start;
40
+ }
41
+
42
+ .calc-rail--out {
43
+ left: calc(100% - 10px);
44
+ align-items: flex-end;
45
+ }
46
+
47
+ .calc-port {
48
+ position: absolute;
49
+ display: grid;
50
+ width: 20px;
51
+ height: 20px;
52
+ place-items: center;
53
+ border-radius: 3px;
54
+ border: 1px solid;
55
+ background: var(--color-card);
56
+ padding: 0;
57
+ z-index: 25;
58
+ cursor: default;
59
+ }
60
+
61
+ .calc-rail .calc-port {
62
+ position: relative;
63
+ flex: none;
64
+ inset: auto;
65
+ transform: none;
66
+ }
67
+
68
+ .calc-port--ghost {
69
+ opacity: 0;
70
+ pointer-events: none;
71
+ border-color: transparent;
72
+ background: transparent;
73
+ }
74
+
75
+ .calc-port-inner {
76
+ position: relative;
77
+ display: grid;
78
+ place-items: center;
79
+ }
80
+
81
+ .calc-port.connectionindicator {
82
+ cursor: default;
83
+ }
84
+
85
+ .calc-port--in.connectionindicator {
86
+ cursor: pointer;
87
+ }
88
+
89
+ .calc-port--out.connectionindicator {
90
+ cursor: pointer;
91
+ }
92
+
93
+ .calc-port--out {
94
+ border-color: var(--color-red-400, #f87171);
95
+ background: color-mix(in oklab, var(--color-red-400, #f87171) 14%, var(--color-card));
96
+ cursor: pointer;
97
+ }
98
+
99
+ .calc-port--out:hover,
100
+ .calc-port--out.connectablestart {
101
+ background: color-mix(in oklab, var(--color-red-400, #f87171) 30%, var(--color-card));
102
+ }
103
+
104
+ .calc-port--over {
105
+ border-color: var(--color-red-500, #ef4444);
106
+ box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--color-red-500, #ef4444) 55%, transparent);
107
+ }
108
+
109
+ .calc-port--in {
110
+ border-color: var(--color-emerald-500, #10b981);
111
+ background: color-mix(in oklab, var(--color-emerald-500, #10b981) 10%, var(--color-card));
112
+ cursor: pointer;
113
+ }
114
+
115
+ .calc-port--in:hover,
116
+ .calc-port--in.connectableend:hover {
117
+ background: color-mix(in oklab, var(--color-emerald-500, #10b981) 28%, var(--color-card));
118
+ }
119
+
120
+ .calc-port--open {
121
+ border-style: dashed;
122
+ }
123
+
124
+ .calc-port--open .calc-port-inner {
125
+ opacity: 0.55;
126
+ }
127
+
128
+ .calc-port--partial {
129
+ border-color: var(--color-amber-400, #fbbf24);
130
+ background: color-mix(in oklab, var(--color-amber-400, #fbbf24) 12%, var(--color-card));
131
+ }
132
+
133
+ .calc-port--full {
134
+ border-color: var(--color-emerald-500, #10b981);
135
+ background: color-mix(in oklab, var(--color-emerald-500, #10b981) 16%, var(--color-card));
136
+ }
137
+
138
+ .calc-port--cat {
139
+ border-style: dotted;
140
+ }
141
+
142
+ .calc-port--more {
143
+ display: flex;
144
+ flex-direction: column;
145
+ align-items: center;
146
+ justify-content: center;
147
+ gap: 0;
148
+ height: 20px;
149
+ border: 1px dashed color-mix(in oklab, var(--color-muted-foreground) 45%, transparent);
150
+ background: var(--color-card);
151
+ color: var(--color-muted-foreground);
152
+ font-size: 7px;
153
+ line-height: 1;
154
+ cursor: pointer;
155
+ }
156
+
157
+ .calc-port--more:hover {
158
+ color: var(--color-foreground);
159
+ border-color: var(--color-muted-foreground);
160
+ }
161
+
162
+ .calc-port-count {
163
+ position: absolute;
164
+ left: 50%;
165
+ bottom: 0;
166
+ transform: translateX(-50%);
167
+ z-index: 1;
168
+ pointer-events: none;
169
+ white-space: nowrap;
170
+ font-size: 8px;
171
+ font-weight: 600;
172
+ line-height: 1;
173
+ padding-bottom: 0.5px;
174
+ color: var(--color-foreground);
175
+ text-shadow:
176
+ 0 0 2px var(--color-card),
177
+ 0 1px 1px var(--color-card),
178
+ 1px 0 1px var(--color-card),
179
+ -1px 0 1px var(--color-card),
180
+ 0 -1px 1px var(--color-card);
181
+ }
182
+
183
+ .calc-port-count[data-len='l'] {
184
+ font-size: 7px;
185
+ }
186
+
187
+ .calc-port-count[data-len='xl'] {
188
+ font-size: 6px;
189
+ }
190
+
191
+ .calc-edge--wire.selected .chevron-edge__base,
192
+ .react-flow__edge.selected .chevron-edge__base {
193
+ stroke: var(--color-primary);
194
+ }
195
+
196
+ .calc-flow .react-flow__node:not(.dragging) {
197
+ transition: transform 240ms ease;
198
+ }
199
+
200
+ .calc-flow .react-flow__node-calcMaterial[style*='--calc-delay'] {
201
+ animation: calc-node-in 200ms ease-out both;
202
+ animation-delay: var(--calc-delay, 0ms);
203
+ }
204
+
205
+ .calc-flow
206
+ .react-flow__node-calcMaterial[style*='--calc-delay']
207
+ [data-calc-card] {
208
+ animation: calc-card-in 200ms ease-out both;
209
+ animation-delay: var(--calc-delay, 0ms);
210
+ }
211
+
212
+ @keyframes calc-node-in {
213
+ from {
214
+ opacity: 0;
215
+ }
216
+ }
217
+
218
+ @keyframes calc-card-in {
219
+ from {
220
+ transform: translateY(6px) scale(0.92);
221
+ }
222
+ }
223
+
224
+ .react-flow__node.calc-node--focus [data-calc-card] {
225
+ box-shadow: 0 0 0 2px var(--color-primary);
226
+ }
227
+
228
+ .calc-flow--dots .react-flow__edges {
229
+ display: none;
230
+ }
231
+
232
+ .calc-edge-label {
233
+ display: inline-flex;
234
+ align-items: center;
235
+ gap: 2px;
236
+ border-radius: 4px;
237
+ border: 1px solid var(--color-border);
238
+ background: var(--color-card);
239
+ padding: 1px 4px;
240
+ font-size: 9px;
241
+ line-height: 1.3;
242
+ color: var(--color-muted-foreground);
243
+ cursor: pointer;
244
+ pointer-events: all;
245
+ }
246
+
247
+ .calc-edge-label > span:first-child {
248
+ line-height: 0;
249
+ }
250
+
251
+ .calc-edge-label:hover {
252
+ color: var(--color-foreground);
253
+ border-color: var(--color-muted-foreground);
254
+ }
255
+
256
+ .calc-edge-label__name {
257
+ max-width: 90px;
258
+ overflow: hidden;
259
+ text-overflow: ellipsis;
260
+ white-space: nowrap;
261
+ color: var(--color-foreground);
262
+ }
263
+
264
+ .calc-edge-label__cut {
265
+ display: none;
266
+ color: var(--color-red-500, #ef4444);
267
+ font-size: 11px;
268
+ font-weight: 600;
269
+ line-height: 1;
270
+ }
271
+
272
+ .calc-edge-label__input {
273
+ width: 56px;
274
+ border-radius: 4px;
275
+ border: 1px solid var(--color-primary);
276
+ background: var(--color-card);
277
+ padding: 1px 4px;
278
+ font-size: 10px;
279
+ outline: none;
280
+ }
281
+
282
+ .calc-flow--shift .react-flow__edge {
283
+ cursor: pointer;
284
+ }
285
+
286
+ .calc-flow--shift
287
+ .react-flow__edge:hover
288
+ .calc-edge-label
289
+ .calc-edge-label__amount {
290
+ display: none;
291
+ }
292
+
293
+ .calc-flow--shift .react-flow__edge:hover .calc-edge-label .calc-edge-label__cut {
294
+ display: inline;
295
+ }
296
+
297
+ .calc-flow--shift .react-flow__edge:hover .chevron-edge__base {
298
+ stroke: var(--color-red-500, #ef4444);
299
+ }
300
+
301
+ .react-flow__node.calc-node--dim {
302
+ opacity: 0.35;
303
+ transition: opacity 160ms ease;
304
+ }
305
+
306
+ .react-flow__node.calc-node--chain [data-calc-card] {
307
+ box-shadow: 0 0 0 1.5px color-mix(in oklab, var(--color-primary) 65%, transparent);
308
+ }
@@ -1,26 +0,0 @@
1
- 'use client';
2
-
3
- import { useRef, type ReactNode } from 'react';
4
- import { useElementSize } from '@terrafirmagreg-team/ui/hooks/use-element-size';
5
-
6
- export function FitCard({
7
- w,
8
- children,
9
- }: {
10
- w: number;
11
- children: ReactNode;
12
- }) {
13
- const ref = useRef<HTMLDivElement>(null);
14
- const { w: avail } = useElementSize(ref);
15
- const fit = w > 0 && avail > 0 ? Math.min(1, avail / w) : 1;
16
- return (
17
- <div ref={ref} className="w-full">
18
- <div
19
- className="mx-auto w-fit"
20
- style={fit < 1 ? { zoom: fit } : undefined}
21
- >
22
- {children}
23
- </div>
24
- </div>
25
- );
26
- }
@@ -1,271 +0,0 @@
1
- 'use client';
2
-
3
- import { useState, type ReactNode } from 'react';
4
- import {
5
- ChevronDown,
6
- Crosshair,
7
- Minus,
8
- Package,
9
- Plus,
10
- Trash2,
11
- X,
12
- Zap,
13
- } from 'lucide-react';
14
- import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
15
- import { useSidebar } from '@terrafirmagreg-team/ui/hooks/sidebar';
16
- import { IconButton } from '@terrafirmagreg-team/ui/components/blocks/button/icon-button';
17
- import { Input } from '@terrafirmagreg-team/ui/components/ui/input';
18
- import { Badge } from '@terrafirmagreg-team/ui/components/ui/badge';
19
- import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
20
- import { formatCount } from '@terrafirmagreg-team/ui/lib/utils/format';
21
- import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
22
- import type {
23
- CalcMaterial,
24
- CalculatorTarget,
25
- } from '@terrafirmagreg-team/recipe/types/calc';
26
- import type { IconItem } from '@terrafirmagreg-team/recipe/lib/calc/meta';
27
- import { IconPicker } from '@terrafirmagreg-team/recipe/components/views/calc/trees/icon-picker';
28
-
29
- const clamp = (value: number) => Math.max(1, Math.round(value) || 1);
30
-
31
- function AmountRow({
32
- row,
33
- dataset,
34
- lang,
35
- langMap,
36
- onAmount,
37
- onRemove,
38
- onFocus,
39
- trailing,
40
- }: {
41
- row: CalcMaterial;
42
- dataset: string;
43
- lang: string;
44
- langMap?: Record<string, string>;
45
- onAmount: (amount: number) => void;
46
- onRemove?: () => void;
47
- onFocus?: (id: string) => void;
48
- trailing?: ReactNode;
49
- }) {
50
- const t = useTranslations();
51
- return (
52
- <div className="group flex items-center gap-1 rounded-md px-1 py-0.5 hover:bg-accent/50">
53
- <button
54
- type="button"
55
- className="flex min-w-0 flex-1 items-center text-start"
56
- onClick={() => onFocus?.(row.id)}
57
- >
58
- <Entry
59
- id={row.id}
60
- kind={row.kind}
61
- dataset={dataset}
62
- lang={lang}
63
- langMap={langMap}
64
- size="sm"
65
- labeled
66
- href={false}
67
- tooltip="adaptive"
68
- className="min-w-0 flex-1 justify-start truncate"
69
- />
70
- </button>
71
- <span className="flex shrink-0 items-center">
72
- {trailing}
73
- <IconButton
74
- variant="ghost"
75
- size="icon-xs"
76
- tooltip={false}
77
- label="-"
78
- className="size-5"
79
- onClick={() => onAmount(clamp(row.amount - 1))}
80
- >
81
- <Minus className="size-3" />
82
- </IconButton>
83
- <Input
84
- type="number"
85
- min={1}
86
- value={row.amount}
87
- onChange={(event) =>
88
- onAmount(clamp(Number(event.target.value)))
89
- }
90
- onWheel={(event) => {
91
- if (document.activeElement !== event.currentTarget) return;
92
- event.preventDefault();
93
- onAmount(clamp(row.amount + (event.deltaY < 0 ? 1 : -1)));
94
- }}
95
- className="h-6 w-11 border-0 bg-transparent px-0.5 py-0 text-center text-xs shadow-none [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none"
96
- />
97
- <IconButton
98
- variant="ghost"
99
- size="icon-xs"
100
- tooltip={false}
101
- label="+"
102
- className="size-5"
103
- onClick={() => onAmount(clamp(row.amount + 1))}
104
- >
105
- <Plus className="size-3" />
106
- </IconButton>
107
- {onRemove ? (
108
- <IconButton
109
- variant="ghost"
110
- size="icon-xs"
111
- tooltip={false}
112
- label={t('recipe.calc.remove.title')}
113
- className="size-5 opacity-0 transition-opacity group-hover:opacity-100"
114
- onClick={onRemove}
115
- >
116
- <X className="size-3" />
117
- </IconButton>
118
- ) : null}
119
- </span>
120
- </div>
121
- );
122
- }
123
-
124
- export function CalcTarget({
125
- dataset,
126
- lang,
127
- langMap,
128
- target,
129
- inventory,
130
- iconItems,
131
- ideal,
132
- onAmount,
133
- onStockAmount,
134
- onRemoveTarget,
135
- onRemoveStock,
136
- onAddStock,
137
- onApplyIdeal,
138
- onClear,
139
- onFocus,
140
- }: {
141
- dataset: string;
142
- lang: string;
143
- langMap?: Record<string, string>;
144
- target: CalculatorTarget | null;
145
- inventory: CalcMaterial[];
146
- iconItems?: IconItem[];
147
- ideal: number;
148
- onAmount: (amount: number) => void;
149
- onStockAmount: (index: number, amount: number) => void;
150
- onRemoveTarget: () => void;
151
- onRemoveStock: (index: number) => void;
152
- onAddStock: (materialId: string, kind: CalcMaterial['kind']) => void;
153
- onApplyIdeal: () => void;
154
- onClear?: () => void;
155
- onFocus?: (id: string) => void;
156
- }) {
157
- const t = useTranslations();
158
- const { collapsed } = useSidebar();
159
- const [open, setOpen] = useState(true);
160
- if (!target && !inventory.length) return null;
161
- const showIdeal = Number.isFinite(ideal) && ideal > 1;
162
- return (
163
- <div
164
- className="nodrag absolute left-2 top-2 z-10 flex w-60 flex-col items-start gap-1 max-md:top-12"
165
- style={
166
- collapsed
167
- ? { top: 'calc(var(--header-height) + 2.5rem)' }
168
- : undefined
169
- }
170
- >
171
- <Badge variant="secondary" className="h-4 rounded-sm px-1 text-[9px]">
172
- {t('recipe.calc.experimental')}
173
- </Badge>
174
- <div className="w-60 overflow-hidden rounded-md border bg-card">
175
- <div className="flex items-center gap-1 border-b border-border/60 px-2 py-1">
176
- <Crosshair className="size-3.5 shrink-0 text-muted-foreground" />
177
- <span className="min-w-0 flex-1 truncate text-[10px] font-medium uppercase tracking-wide text-muted-foreground">
178
- {t('recipe.calc.goal')}
179
- </span>
180
- {onClear ? (
181
- <IconButton
182
- variant="ghost"
183
- size="icon-xs"
184
- tooltip={false}
185
- label={t('recipe.calc.clear.title')}
186
- className="size-5"
187
- onClick={onClear}
188
- >
189
- <Trash2 className="size-3" />
190
- </IconButton>
191
- ) : null}
192
- <IconButton
193
- variant="ghost"
194
- size="icon-xs"
195
- tooltip={false}
196
- label={t('recipe.calc.collapse')}
197
- className={cn('size-5', !open && '-rotate-180')}
198
- onClick={() => setOpen((prev) => !prev)}
199
- >
200
- <ChevronDown className="size-3" />
201
- </IconButton>
202
- </div>
203
- {open ? (
204
- <div className="max-h-56 overflow-y-auto p-1">
205
- {target ? (
206
- <AmountRow
207
- row={target}
208
- dataset={dataset}
209
- lang={lang}
210
- langMap={langMap}
211
- onAmount={onAmount}
212
- onRemove={onRemoveTarget}
213
- onFocus={onFocus}
214
- trailing={
215
- showIdeal ? (
216
- <IconButton
217
- variant="ghost"
218
- size="icon-xs"
219
- tooltip={false}
220
- label={t('recipe.calc.ideal', {
221
- variables: { count: formatCount(ideal) },
222
- })}
223
- className="size-5 text-primary"
224
- onClick={onApplyIdeal}
225
- >
226
- <Zap className="size-3" />
227
- </IconButton>
228
- ) : undefined
229
- }
230
- />
231
- ) : null}
232
- {target || inventory.length ? (
233
- <>
234
- <div className="mt-1 flex items-center gap-1 border-t border-border/60 px-2 pt-1.5 pb-0.5">
235
- <Package className="size-3 shrink-0 text-muted-foreground" />
236
- <span className="min-w-0 flex-1 truncate text-[10px] font-medium uppercase tracking-wide text-muted-foreground">
237
- {t('recipe.calc.stock')}
238
- </span>
239
- <span className="shrink-0 tabular-nums text-[10px] text-muted-foreground/70">
240
- {inventory.length}
241
- </span>
242
- {iconItems?.length ? (
243
- <IconPicker
244
- items={iconItems}
245
- meta={{ dataset, lang, langMap }}
246
- onPick={(item) => onAddStock(item.id, item.kind)}
247
- label={t('recipe.calc.add.stock')}
248
- icon={<Plus className="size-3" />}
249
- alwaysVisible
250
- />
251
- ) : null}
252
- </div>
253
- {inventory.map((row, index) => (
254
- <AmountRow
255
- key={`${row.kind}:${row.id}`}
256
- row={row}
257
- dataset={dataset}
258
- lang={lang}
259
- langMap={langMap}
260
- onAmount={(amount) => onStockAmount(index, amount)}
261
- onRemove={() => onRemoveStock(index)}
262
- />
263
- ))}
264
- </>
265
- ) : null}
266
- </div>
267
- ) : null}
268
- </div>
269
- </div>
270
- );
271
- }