// --------------------------------------------------------------------------- // settings / ShortcutSettings.tsx — WAVE 52 · T19 (owner instruction 21, ruling R7, contract C5). // // Owner, verbatim: *"Under setting, we need to be able to toggle sheet's shortcuts. All the // shortcut available and can change the Letters for it."* // // ⭐⭐ RULING R7 — THE DELIBERATE DEVIATION. Instructions 20 and 21 conflict: Excel's own Alt+H // key tips (instruction 20, W52-T17) are NOT rebindable in the real product. This pane implements // instruction 21 anyway, as a STATED departure rather than a silent one — the disclosure line // below is not decoration, it is the ruling's own requirement. // // ⛔ CONTRACT C5 — EVERYTHING HERE IS A READER AND A WRITER OF `sheet/shortcuts.ts`'s OWN // localStorage store, and NOTHING ELSE. `matchShortcut`'s signature does not change and this file // never touches `SheetGrid.tsx` (a different lane's fence this wave) — the grid already reads the // SAME store fresh on every keydown, so a change made here takes effect the next time a key is // pressed in the sheet, with no reload and no server round trip: there is nothing on the wire for // a server to hold, this is a client-local preference exactly like a browser's own zoom level. // // ⛔ SELF-CONTAINED, LIKE ITS SIBLING PANES. Owns its own React state; no prop drilling, because // shortcuts are local preferences rather than server data (see `ManageDatabasePane` / `KeychainPane` // in `SettingsModal.tsx` for the pattern this follows). // --------------------------------------------------------------------------- import { useCallback, useState } from "react"; import { effectiveKeys, effectiveLetterFor, REBINDABLE_SHORTCUT_IDS, resetShortcutOverrides, setShortcutEnabled, setShortcutLetter, SHORTCUTS, } from "../sheet/shortcuts"; import type { ShortcutId } from "../sheet/shortcuts"; // The `.set-shortcut-*` row layout only; see that file's own header for why a component-owned // side-effect import is this repo's existing way to add a wave-52 rule without editing the shared // `index.css` chain or another lane's stylesheet. import "../styles/wave52/ribbon.css"; const REBINDABLE = new Set(REBINDABLE_SHORTCUT_IDS); export default function ShortcutSettings() { // ⚠ A BUMP COUNTER, NOT A COPY OF THE STORE. `effectiveKeys` / `effectiveLetterFor` read // `localStorage` fresh on every call, which is also exactly what `matchShortcut` does on every // keydown in the grid — so this component needs only a reason to RE-RENDER after a write, not a // mirror of the data it re-renders with. A copied `overrides` object would be a second place the // same fact could drift from the store the grid actually reads. const [, setVersion] = useState(0); const refresh = useCallback(() => setVersion((v) => v + 1), []); // The single-character draft per rebindable row, so typing does not write on every keystroke — // only on blur or Enter, matching the ticket's own "simplest, consistent with this file's plain // style" instruction. const [drafts, setDrafts] = useState>>({}); const [rowErrors, setRowErrors] = useState>>({}); const draftFor = (id: ShortcutId): string => drafts[id] ?? effectiveLetterFor(id); const commitLetter = (id: ShortcutId, raw: string) => { const trimmed = raw.trim(); const result = setShortcutLetter(id, trimmed === "" ? null : trimmed); if (result.ok) { setRowErrors((r) => ({ ...r, [id]: undefined })); setDrafts((d) => ({ ...d, [id]: undefined })); refresh(); } else { setRowErrors((r) => ({ ...r, [id]: result.reason })); } }; return (

Sheet shortcuts

Turn any sheet shortcut on or off, and change the letter behind the ones built on Ctrl plus a single letter. Rebinding your own shortcuts is a departure from Excel, which does not allow it.

    {SHORTCUTS.map((entry) => { const keys = effectiveKeys(entry.id); const disabled = keys === "Disabled"; const rebindable = REBINDABLE.has(entry.id); const error = rowErrors[entry.id]; return (
  • {entry.action} {entry.when}
    {keys} {rebindable ? ( ) : ( )} {error ?
    {error}
    : null}
  • ); })}
); }