function showProperties(comp) {
const panel = document.getElementById('properties-content');
if (!comp) {panel.innerHTML = '
`;
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';
}