function showProperties(comp) { const panel = document.getElementById('properties-content'); if (!comp) {panel.innerHTML = '
เลือกคอมโพเนนต์เพื่อแก้ไข
'; return;} const d = comp.data; let html = `

${getName(comp.type)}

`; switch (comp.type) { case 'heading': case 'text': case 'footer': html += `
`; break; case 'logo': html += `
`; break; case 'image': html += `
`; break; case 'divider': html += `
`; break; case 'spacer': html += `
`; break; case 'barcode': html += `
`; html += `
`; break; case 'promptpay': html += `
PromptPay ID ตั้งค่าที่ ข้อมูลร้าน
`; break; case 'payment-info': html += `
`; break; case 'box': html += `
${d.layout === 'flex' ? `
` : ''} ${d.layout === 'grid' ? `
` : ''}
`; break; default: html += `
ไม่มี properties
`; } html += `
`; panel.innerHTML = html; } function upd(id, key, val) { const comp = Pro.components.find(c => c.id === id); if (!comp) return; comp.data[key] = val; const el = document.getElementById(id); if (el) { const ctrl = el.querySelector('.component-controls')?.outerHTML || ''; el.innerHTML = ctrl + renderComponentContent(comp); } setTimeout(() => {renderBarcodes(); renderQRCodes(); bindInlineEditors();}, 20); } function getName(type) { return ({ heading: 'หัวข้อ', text: 'ข้อความ', logo: 'โลโก้', divider: 'เส้นแบ่ง', spacer: 'ช่องว่าง', 'store-info': 'ข้อมูลร้าน', 'receipt-info': 'ข้อมูลใบเสร็จ', 'items-table': 'ตารางรายการ', summary: 'สรุปยอด', 'payment-info': 'ชำระเงิน', barcode: 'Barcode', qrcode: 'QR Code', promptpay: 'PromptPay', footer: 'ข้อความท้าย', box: 'กล่อง' })[type] || type; } function toColor(c) { // Accept #rrggbb or names; fallback to #ddd const ctx = document.createElement('canvas').getContext('2d'); ctx.fillStyle = c; return ctx.fillStyle || '#dddddd'; }