import $ from 'domtastic';
import ToggleComponent from '../_helpers/toggleComponent';

export default class Modal extends ToggleComponent {
  constructor(element, customOptions) {
    const $modal = $(element);

    let options = {
      dataAttrBase: 'data-sui-o-modal',
      focusRecoverEnabled: true,
    };

    // Merge custom options
    if (customOptions) {
      options = $.extend({}, options, customOptions);
    }

    super($modal, options);
  }

  _isClickOutside(target) {
    return !$.contains(this.$component[0], target);
  }
}
