import React from 'react'; import { MmInput } from './A4Inspector'; import { FONT_FAMILIES } from './fonts'; import { PAGE } from './units'; import '../ObjectInspector.css'; import './A4Inspector.css'; import './A4PageSetup.css'; /** * Page setup panel: orientation, the four margins in mm, and the defaults new * elements inherit. * * Margins are NOT cosmetic. A band's x/width are derived from the content area * (A4Canvas `contentWidthOf`), so changing a margin has to reflow every existing * band — otherwise a band keeps the width it was created with and silently * overhangs the new margin. `A4ReportEditor.handlePageSetupChange` owns that * reflow; this panel only reports the new setup. * * Margins use MmInput for the same reason every other mm field does: a * `type="number"` input discards the intermediate "1." and the decimal point * appears not to type. Font size is pt with a 0.5 step, matching the inspector. */ const MARGIN_FIELDS = [ { key: 'top', label: 'Top' }, { key: 'right', label: 'Right' }, { key: 'bottom', label: 'Bottom' }, { key: 'left', label: 'Left' } ]; const FONT_SIZES = [6, 7, 8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 48]; function A4PageSetup({ pageSetup, onChange, onClose }) { const setup = pageSetup || {}; const margins = setup.margins || {}; const orientation = setup.orientation === 'landscape' ? 'landscape' : 'portrait'; const size = PAGE.A4[orientation]; const handleMarginChange = (key, value) => { onChange({ ...setup, margins: { ...margins, [key]: value } }); }; return (
e.stopPropagation()}>

Page Setup

Page
A4 {orientation} — {size.w} × {size.h} mm
Margins (mm)
{MARGIN_FIELDS.map(({ key, label }) => ( handleMarginChange(key, v)} /> ))}
Bands span the content width, so changing a side margin resizes every band in the report.
Defaults for new elements
Applies to elements created from now on. Existing elements keep the font they were given.
); } export default A4PageSetup;