Source: components/instant-search/instant-search-style/instant-search-style.js

/**
 * Instant search result style module
 * @module InsatantSearchStyle
 */

import Settings from "../../../helpers/settings";
import Utils from "../../../helpers/utils";
import InstantSearchResult from "./instant-search-result";
import InstantSearchResultStyle2 from "./instant-search-result-style2";
import InstantSearchMobile from "./instant-search-mobile";

/**
 * List of instant search style class
 * @type {Array}
 */
const Classes = {
	InstantSearchResult,
	InstantSearchResultStyle2,
	InstantSearchMobile
};

/**
 * Create a new style of Instant search result component
 * @param {String} id The element ID of search input
 * @param {Object} $element The jQuery object of search input element
 */
const instantSearchResult = (id, $element) => {
	const classDefault = 'InstantSearchResult';
	var style = Settings.getSettingValue('search.suggestionStyle');
	// Generate class name
	var className = classDefault + Utils.capitalize(style, true, true);
	if (!Classes[className] || !Classes[className].isActive()) {
		className = classDefault;
	}
	return new Classes[className](id, $element);
}

/**
 * Create a new style of Instant search compoment on mobile
 */
const instantSearchMobile = () => {
	const classDefault = 'InstantSearchMobile';
	var style = Settings.getSettingValue('search.suggestionMobileStyle');
	// Set style is empty if style setting is style1
	if (style == 'style1') style = '';
	// Generate class name
	var className = classDefault + Utils.capitalize(style, true, true);
	if (!Classes[className] || !Classes[className].isActive()) {
		className = classDefault;
	}
	return new Classes[className]();
}

const InstantSearchStyle = {
	instantSearchResult: instantSearchResult,
	instantSearchMobile: instantSearchMobile
}

export default InstantSearchStyle;