import React, { useEffect, useRef } from 'react'; import { useEditor } from '@craftjs/core'; import { CollapsibleSection, ArrayPropEditor, smallInputStyle } from './shared'; import { useLayerFocus } from '../../left/LayerFocusContext'; /* ---------- Shared array-item field editor ---------- Extracted from SectionTypePanel and GenericPropsEditor, which both had a near-byte-identical per-item field renderer for generic array props (features/items/plans/testimonials/etc.). Infers an input type per field: boolean -> checkbox, number -> number, /color/ -> color swatch, long string -> textarea, else text. Fields are derived from Object.keys(items[0]). Callers keep their own special-casing (e.g. SectionTypePanel routes key === 'features' to FeaturesEditor instead of using this component). */ export const ArrayItemFieldsEditor: React.FC<{ selectedId: string; propKey: string; items: any[] }> = ({ selectedId, propKey, items, }) => { const { actions } = useEditor(); const arrayItems = items; const sampleItem = arrayItems[0] || {}; const itemFields = typeof sampleItem === 'object' && sampleItem !== null ? Object.keys(sampleItem) : []; // Layers panel -> array editor "scroll to this item" hookup. The outer //