// Rôle : rend les combos enregistrés, leurs catégories et les contrôles de réorganisation. import { Icon } from "../../../components/Icon.jsx"; import { ComboSequence, InlineTextInput } from "./CombosParts.jsx"; import { getComboCategory } from "./combosUtils.js"; export function CombosList({ entries, data, textContent, reorder, onComboUpdate, onComboEdit, onComboDelete, onCategoryToggle }) { const categoryCount = entries.filter((entry) => entry.type === "group").length; function renderCombo(combo) { const category = getComboCategory(combo); const comboClassName = [ "combo-card", "is-editing", reorder.isItemDragging(combo.id) ? "is-dragging" : "", reorder.isItemDropTarget(combo.id) ? "is-drop-target" : "", reorder.getDropPlacement("item", combo.id) === "after" ? "drop-after" : "" ].filter(Boolean).join(" "); return (
onComboUpdate(combo.id, (current) => ({ ...current, name: name || current.name }))} ariaLabel={textContent.comboNameLabel || "Nom"} />
); } function renderCategory(group, index, groupCount) { const category = group.category; const isCollapsed = data.collapsedCategories.includes(category); const isLastCategory = index === groupCount - 1; const categoryClassName = [ "combos-category checklist-section is-grouped", isCollapsed ? "is-collapsed" : "", reorder.isGroupDragging(category) ? "is-dragging" : "", reorder.isGroupDropTarget(category) ? "is-drop-target" : "", reorder.getDropPlacement("group", category) === "after" ? "drop-after" : "" ].filter(Boolean).join(" "); const showBoundaryDropZones = reorder.shouldShowGroupBoundaries(); const beforeDropZone = showBoundaryDropZones ? (
) : null; const afterDropZone = showBoundaryDropZones ? (
) : null; return [ beforeDropZone,

{category}

{group.combos.length}
{!isCollapsed && (
{group.combos.map((combo) => renderCombo(combo))}
)}
, showBoundaryDropZones && isLastCategory ? afterDropZone : null ]; } function getCategoryIndex(entryIndex) { return entries.slice(0, entryIndex + 1).filter((entry) => entry.type === "group").length - 1; } function renderEntry(entry, entryIndex) { if (entry.type !== "group") return renderCombo(entry.item); return renderCategory(entry.group, getCategoryIndex(entryIndex), categoryCount); } return (
{entries.map(renderEntry)}
); }