);
}
/**
* defaultLayout + onLayoutChanged + a stable id · sizes persist across reloads.
* In v4 a bare id does NOT persist; you must seed defaultLayout and capture
* onLayoutChanged. Here the saved layout is held in state and echoed on screen.
*/
function PersistenceCard() {
// Layout is a map of panel id -> flexGrow value (relative, not %).
const [layout, setLayout] = React.useState({
"persisted-nav": 30,
"persisted-content": 70,
});
const total = Object.values(layout).reduce((sum, n) => sum + n, 0) || 1;
const ratio = [layout["persisted-nav"], layout["persisted-content"]]
.map((n) => `${Math.round(((n ?? 0) / total) * 100)}%`)
.join(" / ");
return (
永続化 · defaultLayout + onLayoutChanged
v4 では id 単体ではサイズは保存されない。defaultLayout で初期サイズを与え、onLayoutChanged
を localStorage 等に保存して復元する。現在の比率: {ratio}。
勘定科目
この比率は保存されます。
仕訳一覧
ハンドルを動かすと上の比率表示が即時に更新される。
);
}
/**
* disabled · read-only layout. Group disabled freezes all panels; an individual
* Separator can be disabled, and disableDoubleClick suppresses double-click reset.
*/
function DisabledCard() {
return (
無効化 · disabled / disableDoubleClick
ResizablePanelGroup に disabled
を渡すとレイアウトを固定(読み取り専用)にできる。Separator 単位の
disabled、ダブルクリックでのリセットを抑止する disableDoubleClick
もある。下の例はハンドルがグレーアウトし操作できない。