import React from 'react'; import { TEXT_COLORS, BG_COLORS, SPACING_PRESETS, RADIUS_PRESETS, } from '../../../constants/presets'; import { SectionLabel, ColorSwatchGrid, PresetButtonGrid, CollapsibleSection, ColorPickerField, labelStyle, inputStyle, sectionGap, useNodeProp, } from './shared'; import { ArrayItemFieldsEditor } from './ArrayItemFields'; /* ---------- SMART GENERIC PROPS EDITOR (Fallback) ---------- */ export const GenericPropsEditor: React.FC<{ selectedId: string; nodeProps: Record; typeName: string }> = ({ selectedId, nodeProps, typeName, }) => { const SKIP_PROPS = new Set(['style', 'children', 'cssId', 'cssClass']); const { setProp: setPropValue, setPropStyle: setStyleValue } = useNodeProp(selectedId); // Categorize all props const allProps = Object.entries(nodeProps).filter(([key]) => !SKIP_PROPS.has(key)); const colorProps = allProps.filter(([key, val]) => typeof val === 'string' && /color/i.test(key)); const boolProps = allProps.filter(([_, val]) => typeof val === 'boolean'); const numberProps = allProps.filter(([key, val]) => typeof val === 'number' && !/color/i.test(key)); const stringProps = allProps.filter(([key, val]) => typeof val === 'string' && !/color/i.test(key)); const arrayProps = allProps.filter(([_, val]) => Array.isArray(val)); const style = nodeProps.style || {}; return ( <> {/* String props */} {stringProps.length > 0 && ( {stringProps.map(([key, val]) => { const humanLabel = key.replace(/([A-Z])/g, ' $1').trim(); const isLong = String(val).length > 60 || key === 'description' || key === 'text' || key === 'content'; return (
{isLong ? (