import { OjSwipeActionsBase } from './OjSwipeActionsBase';
import { executeWithModules } from '../../lib/oj-module-proxy';

/**
 * The component WebElement for [oj-swipe-actions](../../jsdocs/oj.ojSwipeActions.html).
 * Do not instantiate this class directly, instead, use
 * [ojSwipeActions](../functions/elements.ojSwipeActions-1.html).
 */
export class OjSwipeActions extends OjSwipeActionsBase {
  /**
   * Performs the specified action.
   *
   * @param {string} value The value of the oj-option associated with the action to perform.
   */
  async doAction(value: string) {
    return executeWithModules<void>(
      this.getDriver(),
      ['CustomElementUtils'],
      [this, value],
      `
      (({ getElementBridge }, elem, action) => {
        var bridge = getElementBridge(elem);
        return bridge._WIDGET_INSTANCE._doAction(action);
      })
      `
    );
  }
}
