import { Component, Input, Output, EventEmitter } from '@angular/core';
import { ComponentProperty } from '../chart-config-manager.component';

@Component({
  selector: 'app-component-property-form',
  templateUrl: './component-property-form.component.html',
  styleUrls: ['./component-property-form.component.scss']
})
export class ComponentPropertyFormComponent {
  @Input() componentProperty: Partial<ComponentProperty> = {};
  @Input() isEdit = false;
  @Output() save = new EventEmitter<Partial<ComponentProperty>>();
  @Output() cancel = new EventEmitter<void>();

  propertyTypes = [
    'string',
    'number',
    'boolean',
    'array',
    'object',
    'function'
  ];

  onSubmit(): void {
    this.save.emit(this.componentProperty);
  }

  onCancel(): void {
    this.cancel.emit();
  }
}