import React from 'react'; import { ScrollArea } from '../../ui/scroll-area'; import type { ElementType } from '../../../types/labelTemplate'; /** 左侧标签库:四类分组(与产品图一致);打印时输入项可带 config 以正确显示为 input */ const ELEMENT_CATEGORIES: { title: string; subtitle?: string; items: { label: string; type: ElementType; config?: Record }[]; }[] = [ { title: '模版信息', items: [ { label: 'Text', type: 'TEXT_STATIC' }, { label: 'QR Code', type: 'QRCODE' }, { label: 'Barcode', type: 'BARCODE' }, { label: 'Blank Space', type: 'BLANK' }, { label: 'Price', type: 'TEXT_PRICE' }, { label: 'Image', type: 'IMAGE' }, { label: 'Logo', type: 'IMAGE' }, ], }, { title: '标签信息', items: [ { label: 'Label Name', type: 'TEXT_PRODUCT' }, { label: 'Text', type: 'TEXT_STATIC' }, { label: 'QR Code', type: 'QRCODE' }, { label: 'Barcode', type: 'BARCODE' }, { label: 'Nutrition Facts', type: 'NUTRITION' }, { label: 'Price', type: 'TEXT_PRICE' }, { label: 'Duration Date', type: 'DATE' }, { label: 'Duration Time', type: 'TIME' }, { label: 'Duration', type: 'DURATION' }, { label: 'Image', type: 'IMAGE' }, { label: 'Label Type', type: 'TEXT_STATIC' }, { label: 'How-to', type: 'TEXT_STATIC' }, { label: 'Expiration Alert', type: 'TEXT_STATIC' }, ], }, { title: '自动生成', items: [ { label: 'Company', type: 'TEXT_STATIC' }, { label: 'Employee', type: 'TEXT_STATIC' }, { label: 'Current Date', type: 'DATE' }, { label: 'Current Time', type: 'TIME' }, { label: 'Label ID', type: 'TEXT_STATIC' }, ], }, { title: '打印时输入', subtitle: '点击添加到画布', items: [ { label: 'Text', type: 'TEXT_STATIC', config: { inputType: 'text' } }, { label: 'Weight', type: 'WEIGHT' }, { label: 'Number', type: 'TEXT_STATIC', config: { inputType: 'number', text: '0' } }, { label: 'Date & Time', type: 'DATE', config: { inputType: 'datetime' } }, { label: 'Multiple Options', type: 'TEXT_STATIC', config: { inputType: 'options' } }, ], }, ]; interface ElementsPanelProps { onAddElement: (type: ElementType, configOverride?: Partial>) => void; } export function ElementsPanel({ onAddElement }: ElementsPanelProps) { return (
Elements
{ELEMENT_CATEGORIES.map((cat) => (
{cat.title}
{cat.subtitle && (
{cat.subtitle}
)}
{cat.items.map((item, i) => ( ))}
))}
); }