Extract toolbox planner helpers

This commit is contained in:
Shinuwa 2026-08-14 09:25:14 +02:00
parent c312b9ed91
commit 348f6f278b
5 changed files with 826 additions and 783 deletions

View file

@ -6,70 +6,19 @@ import { Tooltip } from "../../../components/Tooltip.jsx";
import { applyGroupedReorderOperation, moveItem, useGroupedReorder } from "../../../hooks/useGroupedReorder.js";
import { useInlineEdit } from "../../../hooks/useInlineEdit.js";
import { TextExchangeActions } from "./TextExchangeActions.jsx";
const SOCKET_SHAPES = ["ball", "jewel"];
const SOCKET_COLORS = ["red", "orange", "amber", "yellow", "lime", "green", "teal", "cyan", "blue", "indigo", "violet", "purple", "pink", "rose", "white", "gray", "black"];
const SOCKET_COLOR_VALUES = {
red: "#ef4444",
orange: "#f97316",
amber: "#f59e0b",
yellow: "var(--color-accent-gold)",
lime: "#84cc16",
green: "#22c55e",
teal: "#14b8a6",
cyan: "var(--color-accent-cyan)",
blue: "#3b82f6",
indigo: "var(--color-accent-indigo)",
violet: "#7c3aed",
purple: "var(--color-primary)",
pink: "var(--color-accent-pink)",
rose: "#f43f5e",
white: "#f8fafc",
gray: "#64748b",
black: "#020617"
};
const EQUIPMENT_ICONS = [
{ icon: "helmet", label: "Casque" },
{ icon: "chest-armor", label: "Chest" },
{ icon: "glove", label: "Gants" },
{ icon: "boot", label: "Bottes" },
{ icon: "necklace", label: "Collier" },
{ icon: "earring", label: "Earring" },
{ icon: "ring", label: "Anneau" },
{ icon: "sword", label: "Épée" },
{ icon: "gun", label: "Gun" },
{ icon: "shield", label: "Bouclier" }
];
const TRAIT_ICONS = ["sword", "shield"];
const DETAIL_TABS = ["stats", "sockets", "craft"];
function getCharacteristicCategories(equipment) {
const categories = equipment.characteristics.map((trait) => trait.category).filter(Boolean);
return [
...equipment.categoryOrder.filter((category) => categories.includes(category)),
...categories.filter((category, index) => categories.indexOf(category) === index && !equipment.categoryOrder.includes(category))
];
}
function setItemCategory(item, category) {
const nextItem = { ...item };
if (category) nextItem.category = category;
else delete nextItem.category;
return nextItem;
}
function formatValue(value) {
if (typeof value === "number") return Number.isInteger(value) ? String(value) : String(Math.round(value * 1000) / 1000);
return String(value || "");
}
function createLocalId(prefix) {
return globalThis.crypto?.randomUUID?.() || `${prefix}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
}
function getSocketItemName(equipment, socketItemId) {
return equipment.socketItems.find((socketItem) => socketItem.id === socketItemId)?.name || "";
}
import {
DETAIL_TABS,
EQUIPMENT_ICONS,
SOCKET_COLORS,
SOCKET_COLOR_VALUES,
SOCKET_SHAPES,
TRAIT_ICONS,
createLocalId,
formatValue,
getCharacteristicCategories,
getSocketItemName,
setItemCategory
} from "./equipmentPlannerOptions.js";
function SocketShapeIcon({ shape, color = "gray", className = "" }) {
return (