/* ObsiGate — XLSX command bar builder (#154-A5). * * Pure string builder for the spreadsheet shell (sheet tabs + grouped action * buttons + status pills). Extracted from frontend/js/viewer.js so the markup * is testable and the viewer only wires behaviour. */ import { t } from '../i18n.js'; import { escapeHtml } from '../utils.js'; /** * @param {object} ctx * @param {Array<{name: string}>} ctx.sheets * @param {boolean} ctx.isCsv * @param {boolean} ctx.readOnly * @param {boolean} ctx.editable - not a CSV and not read-only * @returns {{ tabs: string, actionsHtml: string, statusBar: string }} */ export function buildCommandBar({ sheets, isCsv, readOnly, editable }) { // Sheet tabs are always rendered (even for a single sheet) so the strip reads // as a real affordance; an editable workbook gets an explicit “+” button. const tabs = isCsv ? "" : `
${sheets.map((s, i) => `` ).join("")}${editable ? `` : ""}
`; // Status pills make the viewer's limits visible up front. const statusPills = [ readOnly ? `${escapeHtml(t("xlsx.readonly_badge"))}` : "", !isCsv ? `${escapeHtml(t("xlsx.formulas_note"))}` : "", ].filter(Boolean).join(""); const statusBar = statusPills ? `
${statusPills}
` : ""; // Command groups, separated by thin rules. const actionGroups = []; if (!readOnly) { actionGroups.push(` `); actionGroups.push(` `); } if (editable) { actionGroups.push(` `); actionGroups.push(``); } actionGroups.push(` `); const actionsHtml = actionGroups.join(''); return { tabs, actionsHtml, statusBar }; }