import { h } from '@stencil/core';
export const SHORTCUT_SEARCH_FIELD = "ctrl+f";
export const SEARCH_FIELD_FULL_WIDTH = 240;
const SEARCH_FIELD_MARGIN_BOTTOM = "0px";
const SEARCH_FIELD_WIDTH = String(SEARCH_FIELD_FULL_WIDTH - 30) + "px";
export const buildFieldSearch = (action, optionLoader, onSelectField) => {
  return h("ez-search", { class: 'ez-padding--small ez-margin--none', style: {
      "--ez-text-input__margin-bottom": SEARCH_FIELD_MARGIN_BOTTOM,
      "--ez-search--width": SEARCH_FIELD_WIDTH
    }, canShowError: false, showSelectedValue: false, showOptionValue: false, suppressEmptyOption: true, label: action.label, value: null, optionLoader: optionLoader, onEzChange: (evt) => onSelectField(evt.detail), ignoreLimitCharsToSearch: true });
};
export const openFieldSearch = async (splitButton, field) => {
  if (!splitButton) {
    return;
  }
  const isOpen = await splitButton.isOpenedDropdown();
  if (isOpen) {
    await focusOnFieldSerch(field);
    return;
  }
  await splitButton.toggleDropdown();
};
export const focusOnFieldSerch = async (field) => {
  requestAnimationFrame(async () => {
    if (field) {
      const realElement = field['$elm$'];
      if (!realElement)
        return;
      realElement.value = null;
      await realElement.setFocus();
    }
  });
};
