import { bindable, bindingMode, customElement, noView, processContent, autoinject, ViewCompiler, ViewResources } from "aurelia-framework";
import { BindingEngine, Parser } from 'aurelia-binding';
import { CommonColumn } from "./common-column";

@customElement("ui-column")
@processContent(false)
@noView()
@autoinject()
export class UIColumn extends CommonColumn {
  //header
  @bindable({ defaultBindingMode: bindingMode.oneTime })
  public width?: number | string | 'fit-content' = 1;

  //cell
  @bindable({ defaultBindingMode: bindingMode.oneTime })
  public type: "text" | "number" | "drag" | "checkbox" | "counter" | "action" /*| "date" | "time" | "datetime" | "currency" | "url"*/ = "text";
  @bindable
  public colspan: number = 1;


  constructor(element: Element, parser: Parser, viewCompiler: ViewCompiler, viewResources: ViewResources, bindingEngine: BindingEngine) {
    super(element, parser, viewCompiler, viewResources, bindingEngine);
  }

  public bind() {
    if (this.type == "number") {
      this.cellAlign = "end";
    }
  }
}
