@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,127 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import Link from 'next/link';
|
|
4
|
+
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
5
|
+
import { EntryTooltip } from '@terrafirmagreg-team/game/components/entry/tooltip';
|
|
6
|
+
import { tooltipLoadKind } from '@terrafirmagreg-team/game/lib/entry/entry';
|
|
7
|
+
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
8
|
+
import {
|
|
9
|
+
recipeCardImageUrl,
|
|
10
|
+
recipeHref,
|
|
11
|
+
} from '@terrafirmagreg-team/recipe/lib/links';
|
|
12
|
+
import {
|
|
13
|
+
Tooltip,
|
|
14
|
+
TooltipContent,
|
|
15
|
+
TooltipTrigger,
|
|
16
|
+
} from '@terrafirmagreg-team/ui/components/ui/tooltip';
|
|
17
|
+
import { Badge } from '@terrafirmagreg-team/ui/components/ui/badge';
|
|
18
|
+
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
19
|
+
import type { ReferenceKind } from '@terrafirmagreg-team/game/lib/dump/contract/ref';
|
|
20
|
+
import type { RecipeFavorite, RecipeHrefOpts } from '@terrafirmagreg-team/recipe/types';
|
|
21
|
+
|
|
22
|
+
const TAG_SEGMENT_KIND: Record<string, ReferenceKind> = {
|
|
23
|
+
item: 'itemTag',
|
|
24
|
+
block: 'blockTag',
|
|
25
|
+
fluid: 'fluidTag',
|
|
26
|
+
entity_type: 'entityTag',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
function favoriteIconKind(fav: RecipeFavorite): ReferenceKind {
|
|
30
|
+
if (fav.icon?.startsWith('#')) {
|
|
31
|
+
return TAG_SEGMENT_KIND[fav.id.split('/')[1] ?? ''] ?? 'itemTag';
|
|
32
|
+
}
|
|
33
|
+
return 'item';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function RecipeFavoriteCell({
|
|
37
|
+
dataset,
|
|
38
|
+
lang,
|
|
39
|
+
names,
|
|
40
|
+
nav,
|
|
41
|
+
fav,
|
|
42
|
+
}: {
|
|
43
|
+
dataset: string;
|
|
44
|
+
lang: Lang;
|
|
45
|
+
names: Record<string, Record<string, string>>;
|
|
46
|
+
nav: RecipeHrefOpts;
|
|
47
|
+
fav: RecipeFavorite;
|
|
48
|
+
}) {
|
|
49
|
+
const src = recipeCardImageUrl(dataset, fav.id);
|
|
50
|
+
const iconKind = favoriteIconKind(fav);
|
|
51
|
+
const itemName = fav.icon ? recipeItemName(names, lang, fav.icon) : fav.id;
|
|
52
|
+
const href = recipeHref(dataset, lang, {
|
|
53
|
+
...nav,
|
|
54
|
+
type: fav.type,
|
|
55
|
+
id: fav.id,
|
|
56
|
+
item: undefined,
|
|
57
|
+
fluid: undefined,
|
|
58
|
+
relation: undefined,
|
|
59
|
+
rpage: undefined,
|
|
60
|
+
});
|
|
61
|
+
const cardImg = src ? (
|
|
62
|
+
// eslint-disable-next-line @next/next/no-img-element -- dump asset
|
|
63
|
+
<img
|
|
64
|
+
src={src}
|
|
65
|
+
alt={fav.id}
|
|
66
|
+
loading="lazy"
|
|
67
|
+
decoding="async"
|
|
68
|
+
className="max-h-24 rounded-sm"
|
|
69
|
+
/>
|
|
70
|
+
) : null;
|
|
71
|
+
const link = (
|
|
72
|
+
<Link href={href} aria-label={itemName} className="block rounded-sm">
|
|
73
|
+
{fav.icon ? (
|
|
74
|
+
<Entry
|
|
75
|
+
id={fav.icon}
|
|
76
|
+
kind={iconKind}
|
|
77
|
+
name={itemName}
|
|
78
|
+
size="lg"
|
|
79
|
+
variant="chip"
|
|
80
|
+
href={false}
|
|
81
|
+
tooltip={false}
|
|
82
|
+
badge={
|
|
83
|
+
<Badge className="h-auto rounded-sm px-0.5 py-0 text-3xs leading-tight">
|
|
84
|
+
R
|
|
85
|
+
</Badge>
|
|
86
|
+
}
|
|
87
|
+
/>
|
|
88
|
+
) : src ? (
|
|
89
|
+
// eslint-disable-next-line @next/next/no-img-element -- dump asset
|
|
90
|
+
<img
|
|
91
|
+
src={src}
|
|
92
|
+
alt={fav.id}
|
|
93
|
+
className="h-9 rounded-sm"
|
|
94
|
+
loading="lazy"
|
|
95
|
+
decoding="async"
|
|
96
|
+
/>
|
|
97
|
+
) : (
|
|
98
|
+
<span className="block max-w-9 truncate rounded-sm bg-muted px-1 text-2xs">
|
|
99
|
+
{fav.id}
|
|
100
|
+
</span>
|
|
101
|
+
)}
|
|
102
|
+
</Link>
|
|
103
|
+
);
|
|
104
|
+
if (fav.icon) {
|
|
105
|
+
return (
|
|
106
|
+
<EntryTooltip
|
|
107
|
+
dataset={dataset}
|
|
108
|
+
id={fav.icon.replace(/^#+/, '')}
|
|
109
|
+
name={itemName}
|
|
110
|
+
kind={tooltipLoadKind(iconKind)}
|
|
111
|
+
lang={lang}
|
|
112
|
+
footer={cardImg}
|
|
113
|
+
>
|
|
114
|
+
{link}
|
|
115
|
+
</EntryTooltip>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
return (
|
|
119
|
+
<Tooltip>
|
|
120
|
+
<TooltipTrigger render={link} delay={150} closeDelay={100} />
|
|
121
|
+
<TooltipContent className="flex-col items-start gap-1.5 p-2.5">
|
|
122
|
+
<p className="text-sm font-medium">{itemName}</p>
|
|
123
|
+
{cardImg}
|
|
124
|
+
</TooltipContent>
|
|
125
|
+
</Tooltip>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { memo } from 'react';
|
|
4
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
5
|
+
import { PanelCell } from '@terrafirmagreg-team/recipe/components/views/browser/item-panel-grid/cell';
|
|
6
|
+
import { useMountLimit } from '@terrafirmagreg-team/recipe/hooks/use-mount-limit';
|
|
7
|
+
import { useGroupOutlines } from '@terrafirmagreg-team/recipe/hooks/use-group-outlines';
|
|
8
|
+
import { Skeleton } from '@terrafirmagreg-team/ui/components/ui/skeleton';
|
|
9
|
+
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
10
|
+
import type { FavoriteHoverTarget } from '@terrafirmagreg-team/recipe/lib/favorite-hover';
|
|
11
|
+
import type { ItemPanelCell, RecipeHrefOpts } from '@terrafirmagreg-team/recipe/types';
|
|
12
|
+
|
|
13
|
+
const CELL = 36;
|
|
14
|
+
|
|
15
|
+
export const ItemPanelGrid = memo(function ItemPanelGrid({
|
|
16
|
+
cells,
|
|
17
|
+
resetKey,
|
|
18
|
+
dataset,
|
|
19
|
+
lang,
|
|
20
|
+
names,
|
|
21
|
+
nav,
|
|
22
|
+
cols,
|
|
23
|
+
rows,
|
|
24
|
+
favIds,
|
|
25
|
+
onPress,
|
|
26
|
+
onHover,
|
|
27
|
+
onToggleGroup,
|
|
28
|
+
draggableStacks,
|
|
29
|
+
}: {
|
|
30
|
+
cells: ItemPanelCell[];
|
|
31
|
+
|
|
32
|
+
resetKey: unknown;
|
|
33
|
+
dataset: string;
|
|
34
|
+
lang: Lang;
|
|
35
|
+
names: Record<string, Record<string, string>>;
|
|
36
|
+
nav: RecipeHrefOpts;
|
|
37
|
+
cols: number;
|
|
38
|
+
rows: number;
|
|
39
|
+
favIds?: ReadonlySet<string>;
|
|
40
|
+
onPress: (id: string, ref?: 'item' | 'fluid') => void;
|
|
41
|
+
onHover?: (target: FavoriteHoverTarget | undefined) => void;
|
|
42
|
+
onToggleGroup?: (id: string) => void;
|
|
43
|
+
draggableStacks?: boolean;
|
|
44
|
+
}) {
|
|
45
|
+
const t = useTranslations();
|
|
46
|
+
const expandLabel = t('recipe.expand');
|
|
47
|
+
const limit = useMountLimit(cells.length, resetKey);
|
|
48
|
+
const shown = limit >= cells.length ? cells : cells.slice(0, limit);
|
|
49
|
+
const { gridRef, outlines } = useGroupOutlines(shown, cols, rows);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ul
|
|
53
|
+
ref={gridRef}
|
|
54
|
+
className="relative grid h-full w-full place-content-center gap-1"
|
|
55
|
+
style={{
|
|
56
|
+
gridTemplateColumns: `repeat(${cols}, ${CELL}px)`,
|
|
57
|
+
gridTemplateRows: `repeat(${rows}, ${CELL}px)`,
|
|
58
|
+
}}
|
|
59
|
+
>
|
|
60
|
+
{shown.map((cell) => (
|
|
61
|
+
<PanelCell
|
|
62
|
+
key={cell.kind === 'recipe' ? `R:${cell.fav.id}` : cell.id}
|
|
63
|
+
cell={cell}
|
|
64
|
+
dataset={dataset}
|
|
65
|
+
lang={lang}
|
|
66
|
+
names={names}
|
|
67
|
+
nav={nav}
|
|
68
|
+
favIds={favIds}
|
|
69
|
+
expandLabel={expandLabel}
|
|
70
|
+
draggableStacks={draggableStacks}
|
|
71
|
+
onPress={onPress}
|
|
72
|
+
onHover={onHover}
|
|
73
|
+
onToggleGroup={onToggleGroup}
|
|
74
|
+
/>
|
|
75
|
+
))}
|
|
76
|
+
{Array.from({ length: cells.length - shown.length }, (_, i) => (
|
|
77
|
+
<li
|
|
78
|
+
key={`skel-${i}`}
|
|
79
|
+
aria-hidden
|
|
80
|
+
className="flex min-h-0 min-w-0 items-center justify-center"
|
|
81
|
+
>
|
|
82
|
+
<Skeleton className="size-9 rounded-sm" />
|
|
83
|
+
</li>
|
|
84
|
+
))}
|
|
85
|
+
<svg
|
|
86
|
+
aria-hidden
|
|
87
|
+
className="pointer-events-none absolute inset-0 h-full w-full overflow-visible"
|
|
88
|
+
>
|
|
89
|
+
{outlines.map((outline) => (
|
|
90
|
+
<path
|
|
91
|
+
key={outline.groupId + outline.d}
|
|
92
|
+
d={outline.d}
|
|
93
|
+
fill="none"
|
|
94
|
+
stroke="var(--color-foreground)"
|
|
95
|
+
strokeOpacity={0.4}
|
|
96
|
+
strokeWidth={1.5}
|
|
97
|
+
strokeLinejoin="round"
|
|
98
|
+
/>
|
|
99
|
+
))}
|
|
100
|
+
</svg>
|
|
101
|
+
</ul>
|
|
102
|
+
);
|
|
103
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useMemo, useRef } from 'react';
|
|
4
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
5
|
+
import { RecipeFrame } from '@terrafirmagreg-team/recipe/components/views/browser/frame';
|
|
6
|
+
import { ItemViewHeader } from '@terrafirmagreg-team/recipe/components/views/browser/item-view-header';
|
|
7
|
+
import {
|
|
8
|
+
RecipeCardGrid,
|
|
9
|
+
recipeCardDim,
|
|
10
|
+
} from '@terrafirmagreg-team/recipe/components/views/browser/card-grid';
|
|
11
|
+
import { RecipeTypeTabs } from '@terrafirmagreg-team/recipe/components/views/browser/type-tabs';
|
|
12
|
+
import { WorkstationRail } from '@terrafirmagreg-team/recipe/components/views/browser/workstation-rail';
|
|
13
|
+
import { PaneTabs } from '@terrafirmagreg-team/recipe/components/views/browser/pane-tabs';
|
|
14
|
+
import { useFitPages } from '@terrafirmagreg-team/ui/hooks/page/use-fit-pages';
|
|
15
|
+
import { useTypeFilter } from '@terrafirmagreg-team/recipe/hooks/use-type-filter';
|
|
16
|
+
import { useFavorites } from '@terrafirmagreg-team/recipe/hooks/use-favorites';
|
|
17
|
+
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
18
|
+
import {
|
|
19
|
+
EMPTY_ROWS,
|
|
20
|
+
useItemFeeds,
|
|
21
|
+
} from '@terrafirmagreg-team/recipe/hooks/use-item-feeds';
|
|
22
|
+
import { useItemTagGroups } from '@terrafirmagreg-team/recipe/hooks/use-item-tag-groups';
|
|
23
|
+
import { ItemTagGroups } from '@terrafirmagreg-team/recipe/components/views/browser/item-view/tags';
|
|
24
|
+
import { useItemPane } from '@terrafirmagreg-team/recipe/hooks/use-item-pane';
|
|
25
|
+
import { useAddToCalc } from '@terrafirmagreg-team/recipe/hooks/use-add-to-calc';
|
|
26
|
+
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
27
|
+
import { parseStackId, stackIdFromRef } from '@terrafirmagreg-team/game/lib/dump/contract/ref';
|
|
28
|
+
import type { TaggedReference } from '@terrafirmagreg-team/game/lib/dump/contract/ref';
|
|
29
|
+
import { customStackName } from '@terrafirmagreg-team/game/lib/dump/assets/lang/names';
|
|
30
|
+
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
31
|
+
import type {
|
|
32
|
+
RecipeCategory,
|
|
33
|
+
RecipeSession,
|
|
34
|
+
} from '@terrafirmagreg-team/recipe/types';
|
|
35
|
+
|
|
36
|
+
export function ItemView({ session }: { session: RecipeSession }) {
|
|
37
|
+
const t = useTranslations();
|
|
38
|
+
const {
|
|
39
|
+
dataset,
|
|
40
|
+
lang,
|
|
41
|
+
index,
|
|
42
|
+
indexLoading,
|
|
43
|
+
names,
|
|
44
|
+
nav,
|
|
45
|
+
rpage,
|
|
46
|
+
recipeId,
|
|
47
|
+
relation,
|
|
48
|
+
} = session;
|
|
49
|
+
const item = (session.item ?? session.fluid)!;
|
|
50
|
+
const kind = session.item ? 'item' : 'fluid';
|
|
51
|
+
const parsed = useMemo(() => parseStackId(item), [item]);
|
|
52
|
+
const favorites = useFavorites();
|
|
53
|
+
const name =
|
|
54
|
+
customStackName(session.langMap, item) ??
|
|
55
|
+
recipeItemName(names, lang, item);
|
|
56
|
+
|
|
57
|
+
const boxRef = useRef<HTMLDivElement | null>(null);
|
|
58
|
+
|
|
59
|
+
const categoriesById = useMemo(
|
|
60
|
+
() =>
|
|
61
|
+
new Map<string, RecipeCategory>(
|
|
62
|
+
(index?.categories ?? []).map((row) => [row.id, row]),
|
|
63
|
+
),
|
|
64
|
+
[index],
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const feeds = useItemFeeds({ dataset, index, indexLoading, item, kind });
|
|
68
|
+
const { recipes, uses } = feeds;
|
|
69
|
+
const tags = useItemTagGroups({ dataset, index, item, kind });
|
|
70
|
+
const pane = useItemPane({
|
|
71
|
+
dataset,
|
|
72
|
+
lang,
|
|
73
|
+
nav,
|
|
74
|
+
relation,
|
|
75
|
+
recipeId,
|
|
76
|
+
recipes,
|
|
77
|
+
uses,
|
|
78
|
+
tagCount: tags.ids.length,
|
|
79
|
+
feedsPending: feeds.pending,
|
|
80
|
+
});
|
|
81
|
+
const addToCalc = useAddToCalc(session);
|
|
82
|
+
|
|
83
|
+
const feedRows = (pane.pane === 'uses' ? uses : recipes) ?? EMPTY_ROWS;
|
|
84
|
+
const typeFilter = useTypeFilter(session, feedRows);
|
|
85
|
+
const railRefs = useMemo(() => {
|
|
86
|
+
const seen = new Set<string>();
|
|
87
|
+
const refs: TaggedReference[] = [];
|
|
88
|
+
for (const ref of
|
|
89
|
+
categoriesById.get(typeFilter.active)?.workstations ?? []) {
|
|
90
|
+
const key = stackIdFromRef(ref);
|
|
91
|
+
if (!seen.has(key)) {
|
|
92
|
+
seen.add(key);
|
|
93
|
+
refs.push(ref);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return refs;
|
|
97
|
+
}, [categoriesById, typeFilter.active]);
|
|
98
|
+
const focusIndex = recipeId
|
|
99
|
+
? typeFilter.rows.findIndex((row) => row.id === recipeId)
|
|
100
|
+
: -1;
|
|
101
|
+
const list = useFitPages(
|
|
102
|
+
boxRef,
|
|
103
|
+
typeFilter.rows,
|
|
104
|
+
(row, box) => {
|
|
105
|
+
const d = recipeCardDim(index, categoriesById, row);
|
|
106
|
+
return d.h > box.h ? { w: d.w, h: box.h } : d;
|
|
107
|
+
},
|
|
108
|
+
rpage,
|
|
109
|
+
8,
|
|
110
|
+
focusIndex >= 0 ? focusIndex : undefined,
|
|
111
|
+
true,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
const onSwipe = (dir: -1 | 1) => {
|
|
115
|
+
if (recipeId) {
|
|
116
|
+
const row = typeFilter.rows[focusIndex + dir];
|
|
117
|
+
if (focusIndex < 0 || !row) return;
|
|
118
|
+
replaceUrlState(
|
|
119
|
+
recipeHref(dataset, lang, { ...nav, id: row.id, rpage: undefined }),
|
|
120
|
+
);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
if (list.pages <= 1) return;
|
|
124
|
+
replaceUrlState(
|
|
125
|
+
recipeHref(dataset, lang, {
|
|
126
|
+
...nav,
|
|
127
|
+
rpage: (list.page + dir + list.pages) % list.pages,
|
|
128
|
+
}),
|
|
129
|
+
);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return (
|
|
133
|
+
<RecipeFrame
|
|
134
|
+
session={session}
|
|
135
|
+
list={pane.pane === 'tags' ? undefined : list}
|
|
136
|
+
strip={
|
|
137
|
+
<RecipeTypeTabs
|
|
138
|
+
session={session}
|
|
139
|
+
ids={pane.pane !== 'tags' ? typeFilter.ids : []}
|
|
140
|
+
value={typeFilter.active}
|
|
141
|
+
onChange={typeFilter.setActive}
|
|
142
|
+
/>
|
|
143
|
+
}
|
|
144
|
+
header={
|
|
145
|
+
<div className="flex flex-col gap-1.5">
|
|
146
|
+
<ItemViewHeader
|
|
147
|
+
item={item}
|
|
148
|
+
kind={kind}
|
|
149
|
+
name={name}
|
|
150
|
+
parsed={parsed}
|
|
151
|
+
favorite={favorites.isFavorite(item)}
|
|
152
|
+
onToggleFavorite={() => favorites.toggleItem(item)}
|
|
153
|
+
onAddToCalc={() => addToCalc(item, kind)}
|
|
154
|
+
/>
|
|
155
|
+
<PaneTabs
|
|
156
|
+
value={pane.pane}
|
|
157
|
+
options={pane.options}
|
|
158
|
+
onChange={pane.select}
|
|
159
|
+
/>
|
|
160
|
+
</div>
|
|
161
|
+
}
|
|
162
|
+
rail={
|
|
163
|
+
pane.pane !== 'tags' ? (
|
|
164
|
+
<WorkstationRail session={session} workstations={railRefs} />
|
|
165
|
+
) : undefined
|
|
166
|
+
}
|
|
167
|
+
>
|
|
168
|
+
{pane.pane === 'tags' ? (
|
|
169
|
+
<ItemTagGroups
|
|
170
|
+
groups={tags.groups}
|
|
171
|
+
dataset={dataset}
|
|
172
|
+
lang={lang}
|
|
173
|
+
names={names}
|
|
174
|
+
query={session.query}
|
|
175
|
+
nav={nav}
|
|
176
|
+
/>
|
|
177
|
+
) : (
|
|
178
|
+
<RecipeCardGrid
|
|
179
|
+
session={session}
|
|
180
|
+
rows={list.shown}
|
|
181
|
+
boxRef={boxRef}
|
|
182
|
+
maxH={list.box.h}
|
|
183
|
+
maxW={list.box.w}
|
|
184
|
+
loading={feeds.pending}
|
|
185
|
+
empty={t('recipe.empty_type')}
|
|
186
|
+
onSwipe={onSwipe}
|
|
187
|
+
/>
|
|
188
|
+
)}
|
|
189
|
+
</RecipeFrame>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
4
|
+
import { EmptyState } from '@terrafirmagreg-team/ui/components/blocks/page/empty-state';
|
|
5
|
+
import { LinkPreview } from '@terrafirmagreg-team/ui/components/blocks/link/link-preview';
|
|
6
|
+
import { recipeItemName } from '@terrafirmagreg-team/recipe/lib/client-index';
|
|
7
|
+
import { tagPseudoId } from '@terrafirmagreg-team/game/lib/dump/paths';
|
|
8
|
+
import { recipeHref } from '@terrafirmagreg-team/recipe/lib/links';
|
|
9
|
+
import { replaceUrlState } from '@terrafirmagreg-team/ui/lib/utils/history';
|
|
10
|
+
import type { Lang } from '@terrafirmagreg-team/translate/types/locale';
|
|
11
|
+
import type { RecipeHrefOpts } from '@terrafirmagreg-team/recipe/types';
|
|
12
|
+
|
|
13
|
+
export function ItemTagGroups({
|
|
14
|
+
groups,
|
|
15
|
+
dataset,
|
|
16
|
+
lang,
|
|
17
|
+
names,
|
|
18
|
+
query,
|
|
19
|
+
nav,
|
|
20
|
+
}: {
|
|
21
|
+
groups: [string, string[]][];
|
|
22
|
+
dataset: string;
|
|
23
|
+
lang: Lang;
|
|
24
|
+
names: Record<string, Record<string, string>>;
|
|
25
|
+
query: string;
|
|
26
|
+
nav: RecipeHrefOpts;
|
|
27
|
+
}) {
|
|
28
|
+
const t = useTranslations();
|
|
29
|
+
if (!groups.length) {
|
|
30
|
+
return <EmptyState variant="empty">{t('recipe.empty_tags')}</EmptyState>;
|
|
31
|
+
}
|
|
32
|
+
return (
|
|
33
|
+
<div className="flex flex-col gap-3 pt-1">
|
|
34
|
+
{groups.map(([tagKind, ids]) => (
|
|
35
|
+
<div key={tagKind} className="flex flex-col gap-1.5">
|
|
36
|
+
{groups.length > 1 && (
|
|
37
|
+
<p className="text-xs font-medium text-muted-foreground">
|
|
38
|
+
{tagKind === 'block'
|
|
39
|
+
? t('recipe.tags_block')
|
|
40
|
+
: t('recipe.tags_item')}
|
|
41
|
+
</p>
|
|
42
|
+
)}
|
|
43
|
+
<div className="flex flex-wrap gap-1">
|
|
44
|
+
{ids.map((id) => {
|
|
45
|
+
const bare = id.replace(/^#+/, '');
|
|
46
|
+
return (
|
|
47
|
+
<LinkPreview
|
|
48
|
+
key={`${tagKind}:${id}`}
|
|
49
|
+
href={recipeHref(dataset, lang, {
|
|
50
|
+
type: 'emi:tag',
|
|
51
|
+
id: tagPseudoId(id, tagKind),
|
|
52
|
+
search: query || undefined,
|
|
53
|
+
tab: nav.tab,
|
|
54
|
+
})}
|
|
55
|
+
variant="chip"
|
|
56
|
+
size="sm"
|
|
57
|
+
onClick={(event) => {
|
|
58
|
+
if (!event.shiftKey) return;
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
const token = `#${bare}`;
|
|
61
|
+
const text = query.trim();
|
|
62
|
+
const search =
|
|
63
|
+
!text || text.split(/\s+/).includes(token)
|
|
64
|
+
? text || token
|
|
65
|
+
: `${text} ${token}`;
|
|
66
|
+
replaceUrlState(
|
|
67
|
+
recipeHref(dataset, lang, {
|
|
68
|
+
type: 'emi:tag',
|
|
69
|
+
search,
|
|
70
|
+
}),
|
|
71
|
+
);
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
{recipeItemName(names, lang, id)}
|
|
75
|
+
</LinkPreview>
|
|
76
|
+
);
|
|
77
|
+
})}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
))}
|
|
81
|
+
</div>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Braces, Calculator, Check, Copy } from 'lucide-react';
|
|
4
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
5
|
+
import { useModifierKeys } from '@terrafirmagreg-team/ui/hooks/use-modifier-keys';
|
|
6
|
+
import { ItemRow } from '@terrafirmagreg-team/ui/components/blocks/list/row';
|
|
7
|
+
import { Entry } from '@terrafirmagreg-team/game/components/entry/entry';
|
|
8
|
+
import { CopyIdMenu } from '@terrafirmagreg-team/game/components/entry/copy-id-menu';
|
|
9
|
+
import { ButtonCopy } from '@terrafirmagreg-team/recipe/components/button-copy';
|
|
10
|
+
import { FavoriteButton } from '@terrafirmagreg-team/recipe/components/views/browser/favorite-button';
|
|
11
|
+
import { IconButton } from '@terrafirmagreg-team/ui/components/blocks/button/icon-button';
|
|
12
|
+
import {
|
|
13
|
+
Popover,
|
|
14
|
+
PopoverContent,
|
|
15
|
+
PopoverTitle,
|
|
16
|
+
PopoverTrigger,
|
|
17
|
+
} from '@terrafirmagreg-team/ui/components/ui/popover';
|
|
18
|
+
import { formatNbt, formatNbtPretty } from '@terrafirmagreg-team/game/lib/snbt';
|
|
19
|
+
import type { ParsedStackId } from '@terrafirmagreg-team/game/lib/dump/contract/ref';
|
|
20
|
+
import type { ReferenceKind } from '@terrafirmagreg-team/game/lib/dump/contract/ref';
|
|
21
|
+
|
|
22
|
+
export function ItemViewHeader({
|
|
23
|
+
item,
|
|
24
|
+
kind,
|
|
25
|
+
name,
|
|
26
|
+
parsed,
|
|
27
|
+
favorite,
|
|
28
|
+
onToggleFavorite,
|
|
29
|
+
onAddToCalc,
|
|
30
|
+
}: {
|
|
31
|
+
item: string;
|
|
32
|
+
kind: ReferenceKind;
|
|
33
|
+
name: string;
|
|
34
|
+
parsed: ParsedStackId;
|
|
35
|
+
favorite: boolean;
|
|
36
|
+
onToggleFavorite: () => void;
|
|
37
|
+
onAddToCalc?: () => void;
|
|
38
|
+
}) {
|
|
39
|
+
const t = useTranslations();
|
|
40
|
+
const held = useModifierKeys();
|
|
41
|
+
const nbt = formatNbt(parsed.nbt);
|
|
42
|
+
const pretty =
|
|
43
|
+
parsed.nbt !== undefined ? formatNbtPretty(parsed.nbt) : undefined;
|
|
44
|
+
const copyId = held.shift && nbt ? `${parsed.id}${nbt}` : parsed.id;
|
|
45
|
+
const copyTitle = held.shift ? t('recipe.copy_stack') : t('recipe.copy');
|
|
46
|
+
return (
|
|
47
|
+
<>
|
|
48
|
+
<ItemRow
|
|
49
|
+
layout="header"
|
|
50
|
+
media={
|
|
51
|
+
<CopyIdMenu id={parsed.id} nbt={nbt}>
|
|
52
|
+
<Entry
|
|
53
|
+
id={item}
|
|
54
|
+
kind={kind}
|
|
55
|
+
name={name}
|
|
56
|
+
size="lg"
|
|
57
|
+
variant="chip"
|
|
58
|
+
href={false}
|
|
59
|
+
/>
|
|
60
|
+
</CopyIdMenu>
|
|
61
|
+
}
|
|
62
|
+
title={name}
|
|
63
|
+
titleClassName="truncate"
|
|
64
|
+
code={
|
|
65
|
+
<span className="inline-flex max-w-full items-center gap-0.5">
|
|
66
|
+
<span className="truncate">{parsed.id}</span>
|
|
67
|
+
<ButtonCopy
|
|
68
|
+
value={copyId}
|
|
69
|
+
title={copyTitle}
|
|
70
|
+
aria-label={copyTitle}
|
|
71
|
+
copy={<Copy className="size-3" />}
|
|
72
|
+
copied={<Check className="size-3" />}
|
|
73
|
+
/>
|
|
74
|
+
</span>
|
|
75
|
+
}
|
|
76
|
+
trailing={
|
|
77
|
+
<span className="flex items-center gap-1">
|
|
78
|
+
{nbt && pretty ? (
|
|
79
|
+
<Popover>
|
|
80
|
+
<PopoverTrigger
|
|
81
|
+
render={
|
|
82
|
+
<IconButton
|
|
83
|
+
variant="ghost"
|
|
84
|
+
tooltip={false}
|
|
85
|
+
label={t('recipe.nbt')}
|
|
86
|
+
className="size-7 rounded-lg text-muted-foreground hover:text-foreground [&_svg]:size-3.5"
|
|
87
|
+
>
|
|
88
|
+
<Braces />
|
|
89
|
+
</IconButton>
|
|
90
|
+
}
|
|
91
|
+
/>
|
|
92
|
+
<PopoverContent
|
|
93
|
+
align="end"
|
|
94
|
+
className="w-96 max-w-[calc(100vw-2rem)]"
|
|
95
|
+
>
|
|
96
|
+
<div className="flex items-center justify-between">
|
|
97
|
+
<PopoverTitle className="text-xs font-medium tracking-wider text-muted-foreground uppercase">
|
|
98
|
+
{t('recipe.nbt')}
|
|
99
|
+
</PopoverTitle>
|
|
100
|
+
<ButtonCopy
|
|
101
|
+
value={nbt}
|
|
102
|
+
title={t('recipe.copy_nbt')}
|
|
103
|
+
aria-label={t('recipe.copy_nbt')}
|
|
104
|
+
copy={<Copy className="size-3" />}
|
|
105
|
+
copied={<Check className="size-3" />}
|
|
106
|
+
/>
|
|
107
|
+
</div>
|
|
108
|
+
<pre className="max-h-80 overflow-auto rounded-md bg-muted/50 p-2 text-2xs leading-snug break-all whitespace-pre-wrap">
|
|
109
|
+
{pretty}
|
|
110
|
+
</pre>
|
|
111
|
+
</PopoverContent>
|
|
112
|
+
</Popover>
|
|
113
|
+
) : null}
|
|
114
|
+
{onAddToCalc ? (
|
|
115
|
+
<IconButton
|
|
116
|
+
variant="ghost"
|
|
117
|
+
label={t('recipe.calc.add.title')}
|
|
118
|
+
className="size-7 rounded-lg text-muted-foreground hover:text-foreground [&_svg]:size-3.5"
|
|
119
|
+
onClick={onAddToCalc}
|
|
120
|
+
>
|
|
121
|
+
<Calculator />
|
|
122
|
+
</IconButton>
|
|
123
|
+
) : null}
|
|
124
|
+
<FavoriteButton active={favorite} onToggle={onToggleFavorite} />
|
|
125
|
+
</span>
|
|
126
|
+
}
|
|
127
|
+
/>
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import type { ReactNode } from 'react';
|
|
4
|
+
import {
|
|
5
|
+
Tooltip,
|
|
6
|
+
TooltipContent,
|
|
7
|
+
TooltipTrigger,
|
|
8
|
+
} from '@terrafirmagreg-team/ui/components/ui/tooltip';
|
|
9
|
+
import { Tabs, TabsList, TabsTrigger } from '@terrafirmagreg-team/ui/components/ui/tabs';
|
|
10
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
11
|
+
|
|
12
|
+
export type PaneTabOption<T extends string> = {
|
|
13
|
+
id: T;
|
|
14
|
+
label: string;
|
|
15
|
+
icon: ReactNode;
|
|
16
|
+
help?: string;
|
|
17
|
+
disabled?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function PaneTabs<T extends string>({
|
|
21
|
+
value,
|
|
22
|
+
options,
|
|
23
|
+
onChange,
|
|
24
|
+
className,
|
|
25
|
+
}: {
|
|
26
|
+
value: T;
|
|
27
|
+
options: PaneTabOption<T>[];
|
|
28
|
+
onChange: (id: T) => void;
|
|
29
|
+
className?: string;
|
|
30
|
+
}) {
|
|
31
|
+
return (
|
|
32
|
+
<Tabs
|
|
33
|
+
value={value}
|
|
34
|
+
onValueChange={(id) => onChange(id as T)}
|
|
35
|
+
className={cn('flex', className)}
|
|
36
|
+
>
|
|
37
|
+
<TabsList className="flex-wrap gap-1 bg-transparent p-0">
|
|
38
|
+
{options.map((option) => (
|
|
39
|
+
<Tooltip key={option.id}>
|
|
40
|
+
<TooltipTrigger
|
|
41
|
+
render={
|
|
42
|
+
<TabsTrigger
|
|
43
|
+
value={option.id}
|
|
44
|
+
disabled={option.disabled}
|
|
45
|
+
className="h-7 flex-none rounded-lg border border-border bg-background px-2.5 text-xs hover:bg-muted hover:text-foreground data-active:border-border data-active:bg-secondary data-active:text-secondary-foreground"
|
|
46
|
+
/>
|
|
47
|
+
}
|
|
48
|
+
>
|
|
49
|
+
{option.icon}
|
|
50
|
+
{option.label}
|
|
51
|
+
</TooltipTrigger>
|
|
52
|
+
{option.help ? (
|
|
53
|
+
<TooltipContent>{option.help}</TooltipContent>
|
|
54
|
+
) : null}
|
|
55
|
+
</Tooltip>
|
|
56
|
+
))}
|
|
57
|
+
</TabsList>
|
|
58
|
+
</Tabs>
|
|
59
|
+
);
|
|
60
|
+
}
|