"use client"; import { useEffect, useRef } from "react"; import { cn } from "@/lib/utils"; import { PhoneOnly } from "./phone"; import { SheetHead, closeSheet, useSheetFrame, useSheetOpen } from "./Sheet"; // --------------------------------------------------------------------------- // The page's actions and its one-line status (AppHeader's `actions` and // `note`), in ONE element that is two things: // - the desk: the row at the right of the head, exactly as it was; // - a phone: the ⋯ sheet, opened from the place bar (PlaceBar.tsx) -- the // head's controls leave the top of the screen, where the thumb is not. // One element, not a copy per layout, so a control is never on the page twice // (a spec's selector, a client component's request, a menu's state). // // `phone` is what only the sheet carries (a piece's policy chip, which the desk // keeps in its stage row): rendered on a phone only (components/shell/phone.tsx). // A lifecycle change closes the sheet, so the Undo bar it raises is in view. // --------------------------------------------------------------------------- export const PAGE_SHEET = "page"; export default function PageActions({ phone, className, children }: { phone?: React.ReactNode; className?: string; children: React.ReactNode }) { const open = useSheetOpen(PAGE_SHEET); const panel = useRef(null); const close = () => closeSheet(PAGE_SHEET); useSheetFrame(open, close, panel); useEffect(() => { if (!open) return; const changed = () => closeSheet(PAGE_SHEET); window.addEventListener("umtool:lifecycle", changed); return () => window.removeEventListener("umtool:lifecycle", changed); }, [open]); return ( <> {open &&