"use client"; import { ChevronDown, ChevronUp, LockKeyhole, LockKeyholeOpen, Split, Image as ImageIcon, ArrowUpToLine, MoveRight, MoveUp, Layers, Scissors } from "lucide-react"; import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type Dispatch, type SetStateAction } from "react"; import { ToolbarHideSelectedIcon } from "@/components/icons"; import { calculateSmartPlacementPoint, calculateTopSurfaceElevation } from "@/lib/smartPlacement"; import { DEFAULT_GEAR_HELIX_ANGLE, DEFAULT_GEAR_HELIX_QUALITY, DEFAULT_GEAR_TEETH, DEFAULT_GEAR_TOOTH_SIZE, MAX_GEAR_HELIX_ANGLE, MAX_GEAR_HELIX_QUALITY, MIN_GEAR_HELIX_ANGLE, MIN_GEAR_HELIX_QUALITY, gearCenterHoleLimits, normalizeGearHelixAngle, normalizeGearHelixQuality, normalizeGearCenterHoleSize, normalizeGearToothSize, normalizeGearToothWidth, normalizeGearType, gearToothPitch, } from "@/lib/gearGeometry"; import { displayStepFromMillimeters, displayToMillimeters, formatMeasurementNumber, lengthDisplayUnit, millimetersToDisplay, parseMeasurementInput } from "@/lib/measurementUnits"; import { resizedShapeSize, shapeDepth, shapeHasTaper, shapeOverallFootprintDimensions, shapeTaperDimensions, shapeWidth } from "@/lib/workplaneShapes"; import { normalizeSketchRevolveSettings } from "@/lib/sketchRevolve"; import { MAX_HIGH_RESOLUTION_SIDES } from "@/lib/workplaneSettings"; import { ARCHITECTURAL_TEXTURES, getTextureDefinition } from "@/lib/architecturalTextures"; import type { GearType, GridSize, MeasurementAccuracy, WorkplaneShape, WorkplaneWorkspaceSettings } from "@/types/sketchforge"; const GRID_SIZES: GridSize[] = ["Off", "0.1 mm", "0.25 mm", "0.5 mm", "1.0 mm", "2.0 mm", "5.0 mm", "Brick"]; const MIN_SHAPE_SIZE = 0.01; const SOLID_COLORS = [ "#d41721", "#ff4b4b", "#ff7a1a", "#d97813", "#f6a21a", "#f2cf10", "#f7e65a", "#a8d642", "#33983d", "#1fb66d", "#18b99a", "#0098c7", "#49c7ef", "#3b82f6", "#294c93", "#5b5ce2", "#6e2786", "#9b3bd2", "#c9009a", "#f062b6", "#8a5a2b", "#b98254", "#f2caa0", "#ffffff", "#cfd8df", "#8a98a6", "#4b5563", "#111111", ]; const TEXT_FONT_OPTIONS = ["Multilanguage", "Sans", "Serif", "Script", "Monospace", "Rounded", "Stencil"]; const GEAR_TYPE_OPTIONS: Array<{ value: GearType; label: string }> = [ { value: "spur", label: "Düz Dişli" }, { value: "helical", label: "Helisel Dişli" }, { value: "bevel", label: "Konik Dişli" }, ]; const PROPERTY_LABELS_TR: Record = { "Length": "Uzunluk (Boy)", "Width": "Genişlik (En)", "Height": "Yükseklik", "Sides": "Kenar Sayısı", "Steps": "Adım Sayısı", "Top Radius": "Üst Yarıçap", "Base Radius": "Taban Yarıçapı", "Thickness": "Et Kalınlığı", "Teeth": "Diş Sayısı", "Tooth Size": "Diş Boyutu", "Tooth Width": "Diş Genişliği", "Center Hole": "Merkez Delik", "Helix Angle": "Helis Açısı", "Quality": "Kalite", "Text": "Metin", "Font": "Yazı Tipi", "Bevel": "Pah (Bevel)", "Segments": "Segment", "Start Angle": "Başlangıç Açısı", "Sweep": "Dönüş Açısı", "Top Length": "Üst Uzunluk", "Top Width": "Üst Genişlik", "Bottom Length": "Alt Uzunluk", "Bottom Width": "Alt Genişlik", }; function displayPropertyLabel(label: string) { return PROPERTY_LABELS_TR[label] ?? label; } type RangePropertyConfig = { type?: "range"; label: string; value: number; min: number; max: number; step?: number; onChange: (value: number) => void; }; type TextPropertyConfig = { type: "text"; label: string; value: string; onChange: (value: string) => void; }; type SelectPropertyConfig = { type: "select"; label: string; value: string; options: string[]; onChange: (value: string) => void; }; type ShapePropertyConfig = RangePropertyConfig | TextPropertyConfig | SelectPropertyConfig; export type ShapeInspectorUpdateOptions = { resizeAxis?: "width" | "depth" | "height" }; type ShapeInspectorUpdate = (patch: Partial, options?: ShapeInspectorUpdateOptions) => void; function clamp(value: number, min: number, max: number) { return Math.min(max, Math.max(min, value)); } function formatPropertyNumber(value: number, accuracy: MeasurementAccuracy, step: number) { if (step >= 1) return String(Math.round(value)); return formatMeasurementNumber(value, accuracy, step); } function propertyUsesLengthUnit(label: string) { return ["Radius", "Length", "Width", "Height", "Bevel", "Top Radius", "Base Radius", "Thickness", "Tooth Size", "Tooth Width", "Center Hole", "Top Length", "Top Width", "Bottom Length", "Bottom Width"].includes(label); } function getShapePropertiesWithAppLimits(shape: WorkplaneShape, onUpdate: ShapeInspectorUpdate, textWidthMax = 260): ShapePropertyConfig[] { const baseWidth = shapeWidth(shape); const baseDepth = shapeDepth(shape); const footprint = shapeOverallFootprintDimensions(shape); const width = footprint.width; const depth = footprint.depth; const taper = shapeTaperDimensions(shape); const widthPatch = (value: number): Partial => { if (!shapeHasTaper(shape)) { return { width: value, size: resizedShapeSize(value, baseDepth) }; } const scale = value / Math.max(MIN_SHAPE_SIZE, width); const nextBaseWidth = Math.max(MIN_SHAPE_SIZE, baseWidth * scale); return { width: nextBaseWidth, size: resizedShapeSize(nextBaseWidth, baseDepth), taperTopWidth: Math.max(MIN_SHAPE_SIZE, taper.topWidth * scale), taperBottomWidth: Math.max(MIN_SHAPE_SIZE, taper.bottomWidth * scale), }; }; const depthPatch = (value: number): Partial => { if (!shapeHasTaper(shape)) { return { depth: value, size: resizedShapeSize(baseWidth, value) }; } const scale = value / Math.max(MIN_SHAPE_SIZE, depth); const nextBaseDepth = Math.max(MIN_SHAPE_SIZE, baseDepth * scale); return { depth: nextBaseDepth, size: resizedShapeSize(baseWidth, nextBaseDepth), taperTopDepth: Math.max(MIN_SHAPE_SIZE, taper.topDepth * scale), taperBottomDepth: Math.max(MIN_SHAPE_SIZE, taper.bottomDepth * scale), }; }; const setWidth = (value: number) => onUpdate(widthPatch(value), { resizeAxis: "width" }); const setDepth = (value: number) => onUpdate(depthPatch(value), { resizeAxis: "depth" }); const setConeWidth = (value: number) => { const patch = widthPatch(value); patch.baseRadius = Math.max(MIN_SHAPE_SIZE, (patch.width ?? baseWidth) / 2); onUpdate(patch, { resizeAxis: "width" }); }; const setBaseRadius = (value: number) => { const diameter = value * 2; onUpdate({ baseRadius: value, width: diameter, size: resizedShapeSize(diameter, baseDepth) }, { resizeAxis: "width" }); }; const setHeight = (height: number) => onUpdate({ height }, { resizeAxis: "height" }); if (shape.sketchOperation === "revolve" || shape.sketchRevolve) { const settings = normalizeSketchRevolveSettings(shape.sketchRevolve); const updateRevolve = (patch: Partial) => onUpdate({ sketchRevolve: normalizeSketchRevolveSettings({ ...settings, ...patch }) }); return [ { label: "Start Angle", value: settings.startAngle, min: 0, max: 359, step: 1, onChange: (startAngle) => updateRevolve({ startAngle }) }, { label: "Sweep", value: settings.sweepAngle, min: -360, max: 360, step: 1, onChange: (sweepAngle) => updateRevolve({ sweepAngle }) }, { label: "Sides", value: settings.sides, min: 3, max: MAX_HIGH_RESOLUTION_SIDES, step: 1, onChange: (sides) => updateRevolve({ sides }) }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "box") { return [ { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "cylinder") { return [ { label: "Sides", value: shape.sides ?? 96, min: 3, max: MAX_HIGH_RESOLUTION_SIDES, step: 1, onChange: (sides) => onUpdate({ sides: Math.round(sides) }) }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "sphere") { return [ { label: "Steps", value: shape.steps ?? 24, min: 6, max: 64, step: 1, onChange: (steps) => onUpdate({ steps: Math.round(steps) }) }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "halfSphere") { return [ { label: "Steps", value: shape.steps ?? 32, min: 6, max: 64, step: 1, onChange: (steps) => onUpdate({ steps: Math.round(steps) }) }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "cone") { return [ { label: "Top Radius", value: shape.topRadius ?? 0, min: 0, max: 40, onChange: (topRadius) => onUpdate({ topRadius }) }, { label: "Base Radius", value: shape.baseRadius ?? baseWidth / 2, min: MIN_SHAPE_SIZE, max: 80, onChange: setBaseRadius }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setConeWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, { label: "Sides", value: shape.sides ?? 96, min: 3, max: MAX_HIGH_RESOLUTION_SIDES, step: 1, onChange: (sides) => onUpdate({ sides: Math.round(sides) }) }, ]; } if (shape.kind === "pyramid") { return [ { label: "Sides", value: shape.sides ?? 4, min: 3, max: 24, step: 1, onChange: (sides) => onUpdate({ sides: Math.round(sides) }) }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "roundRoof") { return [ { label: "Sides", value: shape.sides ?? 64, min: 4, max: MAX_HIGH_RESOLUTION_SIDES, step: 1, onChange: (sides) => onUpdate({ sides: Math.round(sides) }) }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "tube" || shape.kind === "ring") { return [ { label: "Thickness", value: shape.bevel ?? 4, min: 0.5, max: 20, onChange: (bevel) => onUpdate({ bevel }) }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } if (shape.kind === "gear") { const setGearWidth = (value: number) => { const toothSize = normalizeGearToothSize(shape.toothSize, value, depth); const toothWidth = normalizeGearToothWidth(shape.toothWidth, value, depth, shape.teeth); const centerHoleSize = normalizeGearCenterHoleSize(shape.centerHoleSize, value, depth, toothSize); onUpdate({ width: value, size: resizedShapeSize(value, depth), toothSize, toothWidth, centerHoleSize }, { resizeAxis: "width" }); }; const setGearDepth = (value: number) => { const toothSize = normalizeGearToothSize(shape.toothSize, width, value); const toothWidth = normalizeGearToothWidth(shape.toothWidth, width, value, shape.teeth); const centerHoleSize = normalizeGearCenterHoleSize(shape.centerHoleSize, width, value, toothSize); onUpdate({ depth: value, size: resizedShapeSize(width, value), toothSize, toothWidth, centerHoleSize }, { resizeAxis: "depth" }); }; const teeth = shape.teeth ?? DEFAULT_GEAR_TEETH; const toothPitch = gearToothPitch(width, depth, teeth); const toothSize = normalizeGearToothSize(shape.toothSize ?? DEFAULT_GEAR_TOOTH_SIZE, width, depth); const centerHoleLimits = gearCenterHoleLimits(width, depth, toothSize); const properties: ShapePropertyConfig[] = [ { label: "Teeth", value: teeth, min: 6, max: 64, step: 1, onChange: (value) => { const nextTeeth = Math.round(value); onUpdate({ teeth: nextTeeth, toothWidth: normalizeGearToothWidth(shape.toothWidth, width, depth, nextTeeth), }); }, }, { label: "Tooth Size", value: toothSize, min: 0.2, max: Math.max(0.2, Math.min(width, depth) * 0.22), step: 0.1, onChange: (nextToothSize) => onUpdate({ toothSize: nextToothSize, centerHoleSize: normalizeGearCenterHoleSize(shape.centerHoleSize, width, depth, nextToothSize), }), }, { label: "Tooth Width", value: normalizeGearToothWidth(shape.toothWidth, width, depth, teeth), min: toothPitch * 0.12, max: toothPitch * 0.82, step: 0.1, onChange: (toothWidth) => onUpdate({ toothWidth }), }, ]; if (normalizeGearType(shape.gearType) === "helical") { properties.push({ label: "Helix Angle", value: normalizeGearHelixAngle(shape.helixAngle ?? DEFAULT_GEAR_HELIX_ANGLE), min: MIN_GEAR_HELIX_ANGLE, max: MAX_GEAR_HELIX_ANGLE, step: 1, onChange: (helixAngle) => onUpdate({ helixAngle }), }); properties.push({ label: "Quality", value: normalizeGearHelixQuality(shape.helixQuality ?? DEFAULT_GEAR_HELIX_QUALITY), min: MIN_GEAR_HELIX_QUALITY, max: MAX_GEAR_HELIX_QUALITY, step: 1, onChange: (helixQuality) => onUpdate({ helixQuality: Math.round(helixQuality) }), }); } properties.push( { label: "Center Hole", value: normalizeGearCenterHoleSize(shape.centerHoleSize, width, depth, toothSize), min: centerHoleLimits.min, max: centerHoleLimits.max, step: 0.1, onChange: (centerHoleSize) => onUpdate({ centerHoleSize }), }, { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setGearDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setGearWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ); return properties; } if (shape.kind === "text") { return [ { type: "text", label: "Text", value: shape.text ?? "TEXT", onChange: (text) => { const nextText = text.slice(0, 24) || " "; const nextWidth = clamp(Math.max(Math.min(46, textWidthMax), nextText.length * 19), MIN_SHAPE_SIZE, textWidthMax); onUpdate({ text: nextText, width: nextWidth, size: nextWidth }); }, }, { type: "select", label: "Font", value: shape.font ?? "Multilanguage", options: TEXT_FONT_OPTIONS, onChange: (font) => onUpdate({ font }) }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 40, onChange: setHeight }, { label: "Bevel", value: shape.bevel ?? 0, min: 0, max: 8, onChange: (bevel) => onUpdate({ bevel }) }, { label: "Segments", value: shape.segments ?? 0, min: 0, max: 24, step: 1, onChange: (segments) => onUpdate({ segments: Math.round(segments) }) }, ]; } return [ { label: "Length", value: depth, min: MIN_SHAPE_SIZE, max: 160, onChange: setDepth }, { label: "Width", value: width, min: MIN_SHAPE_SIZE, max: 160, onChange: setWidth }, { label: "Height", value: shape.height, min: MIN_SHAPE_SIZE, max: 160, onChange: setHeight }, ]; } function getShapeProperties(shape: WorkplaneShape, onUpdate: ShapeInspectorUpdate, workspace: WorkplaneWorkspaceSettings): ShapePropertyConfig[] { const customLimit = workspace.shapeCustomizations[shape.kind]?.maxDimension; const properties = getShapePropertiesWithAppLimits(shape, onUpdate, customLimit ?? 260); if (customLimit === undefined) return properties; return properties.map((property) => { if (property.type === "text" || property.type === "select") return property; if (["Length", "Width", "Height"].includes(property.label)) return { ...property, max: customLimit }; if (["Top Radius", "Base Radius"].includes(property.label)) return { ...property, max: customLimit / 2 }; return property; }); } export function ShapeInspector({ shape, snap, snapOpen, workspace, onUpdate, onSnapChange, onSnapOpenChange, onEditSketch, canSeparateParts = false, onSeparateParts, onInteractionActiveChange, allShapes, onSelectShape, }: { shape: WorkplaneShape; snap: GridSize; snapOpen: boolean; workspace: WorkplaneWorkspaceSettings; onUpdate: ShapeInspectorUpdate; onSnapChange: Dispatch>; onSnapOpenChange: Dispatch>; onEditSketch?: () => void; canSeparateParts?: boolean; onSeparateParts?: () => void; onInteractionActiveChange?: (active: boolean) => void; allShapes?: WorkplaneShape[]; onSelectShape?: (id: string) => void; }) { const solidColor = shape.color; const locked = Boolean(shape.locked); const properties = getShapeProperties(shape, onUpdate, workspace); const gearType = shape.kind === "gear" ? normalizeGearType(shape.gearType) : null; const primaryProperties = shape.kind === "gear" ? properties.filter((property) => ["Center Hole", "Length", "Width", "Height"].includes(property.label)) : properties; const gearTeethProperties = shape.kind === "gear" ? properties.filter((property) => ["Teeth", "Tooth Size", "Tooth Width"].includes(property.label)) : []; const gearHelixProperties = shape.kind === "gear" ? properties.filter((property) => ["Helix Angle", "Quality"].includes(property.label)) : []; const taper = shapeTaperDimensions(shape); const taperDimensionMax = workspace.shapeCustomizations[shape.kind]?.maxDimension ?? 480; const taperProperties: ShapePropertyConfig[] = shape.kind === "gear" ? [] : [ { label: "Top Length", value: taper.topDepth, min: MIN_SHAPE_SIZE, max: taperDimensionMax, onChange: (taperTopDepth) => onUpdate({ taperTopDepth, taperTopWidth: taper.topWidth, taperTopScale: undefined }), }, { label: "Top Width", value: taper.topWidth, min: MIN_SHAPE_SIZE, max: taperDimensionMax, onChange: (taperTopWidth) => onUpdate({ taperTopWidth, taperTopDepth: taper.topDepth, taperTopScale: undefined }), }, { label: "Bottom Length", value: taper.bottomDepth, min: MIN_SHAPE_SIZE, max: taperDimensionMax, onChange: (taperBottomDepth) => onUpdate({ taperBottomDepth, taperBottomWidth: taper.bottomWidth, taperBottomScale: undefined }), }, { label: "Bottom Width", value: taper.bottomWidth, min: MIN_SHAPE_SIZE, max: taperDimensionMax, onChange: (taperBottomWidth) => onUpdate({ taperBottomWidth, taperBottomDepth: taper.bottomDepth, taperBottomScale: undefined }), }, ]; const isSketchRevolve = shape.sketchOperation === "revolve" || Boolean(shape.sketchRevolve); const inspectorRef = useRef(null); const [propertiesOpen, setPropertiesOpen] = useState(true); const [taperOpen, setTaperOpen] = useState(false); const [gearTeethOpen, setGearTeethOpen] = useState(true); const [gearHelixOpen, setGearHelixOpen] = useState(true); const [colorOpen, setColorOpen] = useState(false); const [minimized, setMinimized] = useState(false); const customColorInputRef = useRef(null); useEffect(() => () => onInteractionActiveChange?.(false), [onInteractionActiveChange]); useEffect(() => { const input = customColorInputRef.current; if (!colorOpen || !input) { return; } // React's color-input onChange follows the native input event and fires for // every movement in the picker. Commit only the native change event, which // fires after the user finishes choosing, so dragging stays responsive. const commitCustomColor = () => { onUpdate({ color: input.value, hole: false }); }; input.addEventListener("change", commitCustomColor); return () => input.removeEventListener("change", commitCustomColor); }, [colorOpen, onUpdate]); useLayoutEffect(() => { inspectorRef.current?.scrollTo({ top: 0, left: 0 }); }, [isSketchRevolve, shape.id]); return ( ); } function ShapePropertyRows({ properties, workspace, disabled, onInteractionActiveChange, }: { properties: ShapePropertyConfig[]; workspace: WorkplaneWorkspaceSettings; disabled?: boolean; onInteractionActiveChange?: (active: boolean) => void; }) { return properties.map((property) => { if (property.type === "text") { return ; } if (property.type === "select") { return ; } return ; }); } export function SnapGridControl({ snap, snapOpen, onSnapChange, onSnapOpenChange, }: { snap: GridSize; snapOpen: boolean; onSnapChange: Dispatch>; onSnapOpenChange: Dispatch>; }) { return (
Izgara Yakalama (Snap) {snapOpen ? (
{GRID_SIZES.map((size) => ( ))}
) : null}
); } function RangeProperty({ label, value, min, max, step = 0.01, workspace, disabled, onChange, onInteractionActiveChange, }: RangePropertyConfig & { workspace: WorkplaneWorkspaceSettings; disabled?: boolean; onInteractionActiveChange?: (active: boolean) => void }) { const allowsAboveSliderMax = label === "Length" || label === "Width" || label === "Height" || label.endsWith(" Length") || label.endsWith(" Width"); const isLength = propertyUsesLengthUnit(label); const accuracy = workspace.accuracy; const actualValue = Math.max(min, Number.isFinite(value) ? value : min); const controlValue = isLength ? millimetersToDisplay(actualValue, workspace) : actualValue; const controlMin = isLength ? millimetersToDisplay(min, workspace) : min; const controlMax = isLength ? millimetersToDisplay(max, workspace) : max; const controlStep = isLength ? displayStepFromMillimeters(step, workspace) : step; const sliderValue = clamp(controlValue, controlMin, controlMax); const position = ((sliderValue - controlMin) / Math.max(Number.EPSILON, controlMax - controlMin)) * 100; const [editing, setEditing] = useState(false); const [draft, setDraft] = useState(formatPropertyNumber(controlValue, accuracy, controlStep)); const unit = isLength ? lengthDisplayUnit(workspace).label : null; const toModelValue = (nextValue: number) => isLength ? displayToMillimeters(nextValue, workspace) : nextValue; const commitDraft = () => { const next = parseMeasurementInput(draft); const finiteNext = Number.isFinite(next) ? next : controlValue; const nextModelValue = toModelValue(finiteNext); onChange(allowsAboveSliderMax ? Math.max(min, nextModelValue) : clamp(nextModelValue, min, max)); setEditing(false); onInteractionActiveChange?.(false); }; const handleSliderChange = (nextValue: number) => { const next = clamp(Number.isFinite(nextValue) ? nextValue : controlMin, controlMin, controlMax); onChange(clamp(toModelValue(next), min, max)); setDraft(formatPropertyNumber(next, accuracy, controlStep)); }; return ( ); } function TextProperty({ label, value, disabled, onChange, onInteractionActiveChange }: TextPropertyConfig & { disabled?: boolean; onInteractionActiveChange?: (active: boolean) => void }) { return ( ); } function SelectProperty({ label, value, options, disabled, onChange }: SelectPropertyConfig & { disabled?: boolean }) { return ( ); } function GearTypePreview({ type }: { type: GearType }) { return ; } function GearTypeSelector({ value, disabled, onChange }: { value: GearType; disabled?: boolean; onChange: (value: GearType) => void }) { return (
Dişli Türü
{GEAR_TYPE_OPTIONS.map((option) => ( ))}
); }