import { buildInsetClipPathSides, buildInsetClipPathValue, formatNumericValue, formatPxMetricValue, getClipPathInsetPx, inferClipPathPreset, parseInsetClipPathSides, parsePxMetricValue, type ClipPathInsetSides, } from "./propertyPanelHelpers"; import { FlatSlider } from "./propertyPanelFlatPrimitives"; import { MetricField } from "./propertyPanelPrimitives"; /* ------------------------------------------------------------------ */ /* Flat Mask inset — uniform slider + per-side fields */ /* (split out of propertyPanelFlatStyleSections.tsx to stay under the */ /* 600-line file-size gate) */ /* ------------------------------------------------------------------ */ export function FlatMaskInsetRows({ clipPathValue, radiusValue, disabled, onSetStyle, }: { clipPathValue: string; radiusValue: number; disabled: boolean; onSetStyle: (prop: string, value: string) => void | Promise; }) { const clipPathPreset = inferClipPathPreset(clipPathValue); const parsedClipInsets = parseInsetClipPathSides(clipPathValue); const clipInsetValue = getClipPathInsetPx(clipPathValue); const clipInsetSides = parsedClipInsets ?? { top: clipInsetValue, right: clipInsetValue, bottom: clipInsetValue, left: clipInsetValue, radius: radiusValue, }; const showClipInsetSides = clipPathPreset === "inset" || parsedClipInsets != null; const commitClipInsetSide = (side: keyof ClipPathInsetSides, nextValue: string) => { const next = parsePxMetricValue(nextValue); if (next == null) return; const sides: ClipPathInsetSides = { top: clipInsetSides.top, right: clipInsetSides.right, bottom: clipInsetSides.bottom, left: clipInsetSides.left, }; sides[side] = next; void onSetStyle("clip-path", buildInsetClipPathSides(sides, clipInsetSides.radius)); }; return ( <> 0 ? "explicitCustom" : "default"} displayValue={`${formatNumericValue(clipInsetValue)}px`} disabled={disabled} onCommit={(next) => void onSetStyle("clip-path", buildInsetClipPathValue(next, radiusValue)) } /> {showClipInsetSides && (
commitClipInsetSide("top", next)} /> commitClipInsetSide("right", next)} /> commitClipInsetSide("bottom", next)} /> commitClipInsetSide("left", next)} />
)} ); }