import { Show, For } from 'solid-js'; import type { CardData, LayerConfig } from './types'; import { FieldEditor, PropertyForm } from './FieldEditor'; import type { FieldSchema } from './hooks/types'; export interface DataEditorPanelProps { cards: CardData[]; activeTab: number; updateCardData: (key: string, value: string) => void; } export interface PropertiesEditorPanelProps { localSize: string; localGrid: string; localBleed: string; localPadding: string; layerConfigs: LayerConfig[]; editingLayer: string | null; onSizeChange: (value: string) => void; onGridChange: (value: string) => void; onBleedChange: (value: string) => void; onPaddingChange: (value: string) => void; onToggleLayerVisible: (prop: string) => void; onStartEditingLayer: (prop: string) => void; onCopyCode: () => void; } /** * 为 CardData 创建 Schema */ function createCardDataSchema(keys: string[]): FieldSchema[] { return keys.map((key) => ({ key, label: key.charAt(0).toUpperCase() + key.slice(1), type: 'text', rows: 3 })); } /** * 左侧:CSV 数据编辑面板 * 使用通用 FieldEditor 组件渲染 */ export function DataEditorPanel(props: DataEditorPanelProps) { const currentCard = () => props.cards[props.activeTab] || {}; const fieldKeys = () => Object.keys(currentCard()); const schema = () => ({ fields: createCardDataSchema(fieldKeys()) }); const handleChange = (key: string, value: string | number | boolean) => { props.updateCardData(key, String(value)); }; return (