import Handsontable from 'handsontable'

export class CustomAutocompleteEditor
  extends Handsontable.editors.AutocompleteEditor
{
  constructor(instance: Handsontable.Core) {
    super(instance)
  }

  createElements() {
    super.createElements()
  }

  // Listbox open
  // HOT 18's AutocompleteEditor.open() takes no arguments (was `event?: Event`).
  open(): void {
    super.open()

    if (this.isCellNumeric()) {
      this.htContainer.classList.add('numericListbox')
    } else {
      this.htContainer.classList.remove('numericListbox')
    }
  }

  isCellNumeric() {
    return this.cellProperties?.className?.includes('htNumeric')
  }
}
