window.ConfigSection = { props: { section: String, label: String, fields: Object, modelValue: Object, }, emits: ['update:modelValue'], setup(props, { emit }) { const { computed } = Vue; const flatFields = computed(() => { const result = []; for (const [key, val] of Object.entries(props.fields)) { if (typeof val === 'object' && !Array.isArray(val)) continue; result.push({ key, val }); } return result; }); function updateField(key, newVal) { props.modelValue[key] = newVal; } function fieldType(val) { if (typeof val === 'boolean') return 'boolean'; if (typeof val === 'number') return 'number'; if (Array.isArray(val)) return 'array'; return 'string'; } function removeTag(key, index) { props.modelValue[key].splice(index, 1); } function addTag(key, val) { if (!val || !val.trim()) return; if (!Array.isArray(props.modelValue[key])) props.modelValue[key] = []; props.modelValue[key].push(val.trim()); } return { flatFields, updateField, fieldType, removeTag, addTag }; }, template: `
{{ item.key }}
{{ tag }}
` };