@appbaseio/vue-searchbox
Version:
Lightweight searchbox component for Vue
3,037 lines • 114 kB
JavaScript
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var _mergeJSXProps = _interopDefault(require('@vue/babel-helper-vue-jsx-merge-props'));
var VueTypes = _interopDefault(require('vue-types'));
var searchbase = require('@appbaseio/searchbase');
var computeScrollIntoView = _interopDefault(require('compute-scroll-into-view'));
var styled = require('@appbaseio/vue-emotion');
var styled__default = _interopDefault(styled);
var emotion = require('emotion');
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _objectWithoutPropertiesLoose(source, excluded) {
if (source == null) return {};
var target = {};
var sourceKeys = Object.keys(source);
var key, i;
for (i = 0; i < sourceKeys.length; i++) {
key = sourceKeys[i];
if (excluded.indexOf(key) >= 0) continue;
target[key] = source[key];
}
return target;
}
function _taggedTemplateLiteralLoose(strings, raw) {
if (!raw) {
raw = strings.slice(0);
}
strings.raw = raw;
return strings;
}
VueTypes.sensibleDefaults = false;
var DataField = VueTypes.shape({
field: VueTypes.string,
weight: VueTypes.number
});
var reactKeyType = VueTypes.oneOfType([VueTypes.string, VueTypes.arrayOf(VueTypes.string), VueTypes.object, VueTypes.arrayOf(VueTypes.object)]); // eslint-disable-next-line
var types = {
app: VueTypes.string.isRequired,
url: VueTypes.string.def('https://scalr.api.appbase.io'),
enableAppbase: VueTypes.bool.def(false),
enablePopularSuggestions: VueTypes.bool.def(false),
credentials: VueTypes.string.isRequired,
analytics: VueTypes.bool.def(false),
headers: VueTypes.object,
dataField: VueTypes.oneOfType([VueTypes.string, VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, DataField]))]),
// aggregationData can be used by listening to event `aggregations`
aggregationField: VueTypes.string,
aggregationSize: VueTypes.number,
nestedField: VueTypes.string,
size: VueTypes.number.def(10),
title: VueTypes.string,
defaultValue: VueTypes.string,
placeholder: VueTypes.string.def('Search'),
showIcon: VueTypes.bool.def(true),
iconPosition: VueTypes.oneOf(['left', 'right']).def('right'),
icon: VueTypes.any,
showClear: VueTypes.bool.def(false),
clearIcon: VueTypes.any,
autosuggest: VueTypes.bool.def(true),
strictSelection: VueTypes.bool.def(false),
defaultSuggestions: VueTypes.arrayOf(VueTypes.object),
debounce: VueTypes.number.def(0),
highlight: VueTypes.bool.def(false),
highlightField: VueTypes.oneOfType([VueTypes.string, VueTypes.arrayOf(VueTypes.string)]),
customHighlight: VueTypes.func,
queryFormat: VueTypes.oneOf(['and', 'or']).def('or'),
fuzziness: VueTypes.oneOf([0, 1, 2, 'AUTO']),
showVoiceSearch: VueTypes.bool.def(false),
searchOperators: VueTypes.bool.def(false),
render: VueTypes.func,
renderError: VueTypes.oneOfType([VueTypes.string, VueTypes.any]),
renderNoSuggestion: VueTypes.oneOfType([VueTypes.string, VueTypes.any]),
renderMic: VueTypes.func,
innerClass: VueTypes.object,
style: VueTypes.object,
defaultQuery: VueTypes.func,
beforeValueChange: VueTypes.func,
className: VueTypes.string.def(''),
loader: VueTypes.object,
autoFocus: VueTypes.bool.def(false),
currentURL: VueTypes.string.def(''),
searchTerm: VueTypes.string.def('search'),
URLParams: VueTypes.bool.def(false),
appbaseConfig: VueTypes.shape({
recordAnalytics: VueTypes.bool,
enableQueryRules: VueTypes.bool,
enableSearchRelevancy: VueTypes.bool,
customEvents: VueTypes.object,
userId: VueTypes.string,
useCache: VueTypes.bool,
enableTelemetry: VueTypes.bool
}),
showDistinctSuggestions: VueTypes.bool.def(true),
queryString: VueTypes.queryString,
queryTypes: VueTypes.oneOf(['search', 'term', 'geo', 'range', 'suggestion']),
reactType: VueTypes.shape({
and: reactKeyType,
or: reactKeyType,
not: reactKeyType
}),
sortType: VueTypes.oneOf(['asc', 'desc', 'count']),
sourceFields: VueTypes.arrayOf(VueTypes.string),
focusShortcuts: VueTypes.arrayOf(VueTypes.oneOfType([VueTypes.string, VueTypes.number])),
expandSuggestionsContainer: VueTypes.bool.def(true)
};
var getClassName = function getClassName(classMap, component) {
return classMap && classMap[component] || '';
};
/**
* To determine wether an element is a function
* @param {any} element
*/
var equals = function equals(a, b) {
if (a === b) return true;
if (!a || !b || typeof a !== 'object' && typeof b !== 'object') return a === b;
if (a === null || a === undefined || b === null || b === undefined) return false;
if (a.prototype !== b.prototype) return false;
var keys = Object.keys(a);
if (keys.length !== Object.keys(b).length) return false;
return keys.every(function (k) {
return equals(a[k], b[k]);
});
};
var debounce = function debounce(method, delay) {
clearTimeout(method._tId); // eslint-disable-next-line
method._tId = setTimeout(function () {
method();
}, delay);
};
/**
* Scroll node into view if necessary
* @param {HTMLElement} node the element that should scroll into view
* @param {HTMLElement} rootNode the root element of the component
*/
// eslint-disable-next-line
var scrollIntoView = function scrollIntoView(node, rootNode) {
if (node === null) {
return;
}
var actions = computeScrollIntoView(node, {
boundary: rootNode,
block: 'nearest',
scrollMode: 'if-needed'
});
actions.forEach(function (_ref2) {
var el = _ref2.el,
top = _ref2.top,
left = _ref2.left;
el.scrollTop = top;
el.scrollLeft = left;
});
}; // escapes regex for special characters: \ => \\, $ => \$
function escapeRegExp(string) {
return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
}
/**
* Extracts the render prop from props or slot and returns a valid JSX element
* @param {Object} data
* @param _ref
*/
var getComponent = function getComponent(data, _ref) {
if (data === void 0) {
data = {};
}
if (_ref === void 0) {
_ref = {};
}
var _ref3 = _ref.$scopedSlots || _ref.$props,
render = _ref3.render;
if (render) return render(data);
return null;
};
/**
* To determine whether a component has render prop or slot defined or not
* @returns {Boolean}
*/
var hasCustomRenderer = function hasCustomRenderer(_ref) {
if (_ref === void 0) {
_ref = {};
}
var _ref4 = _ref.$scopedSlots || _ref.$props,
render = _ref4.render;
return Boolean(render);
};
function isEqual(x, y) {
if (x === y) return true;
if (!(x instanceof Object) || !(y instanceof Object)) return false;
if (x.constructor !== y.constructor) return false;
/* eslint-disable */
for (var p in x) {
if (!x.hasOwnProperty(p)) continue;
if (!y.hasOwnProperty(p)) return false;
if (x[p] === y[p]) continue;
if (typeof x[p] !== 'object') return false;
if (!isEqual(x[p], y[p])) return false;
}
for (var _p in y) {
if (y.hasOwnProperty(_p) && !x.hasOwnProperty(_p)) return false;
}
/* eslint-enable */
return true;
}
var checkValidValue = function checkValidValue(value) {
if (value) {
if (Array.isArray(value) && !value.length) return false;
return true;
}
return false;
};
/**
* To get the camel case string from kebab case
* @returns {string}
*/
var getCamelCase = function getCamelCase(str) {
if (str === void 0) {
str = '';
}
var arr = str.split('-');
var capital = arr.map(function (item, index) {
return index ? item.charAt(0).toUpperCase() + item.slice(1).toLowerCase() : item;
}); // ^-- change here.
var capitalString = capital.join('');
return capitalString || '';
};
var isEmpty = function isEmpty(val) {
return !(val && val.length && Object.keys(val).length);
};
function isNumeric(value) {
return /^-?\d+$/.test(value);
} // check if passed shortcut a key combination
function isHotkeyCombination(hotkey) {
return typeof hotkey === 'string' && hotkey.indexOf('+') !== -1;
} // parse focusshortcuts array for key combinations
function isHotkeyCombinationUsed(focusShortcuts) {
for (var index = 0; index < focusShortcuts.length; index += 1) {
if (isHotkeyCombination(focusShortcuts[index])) {
return true;
}
}
return false;
} // used for getting correct string char from keycode passed
// the below algebraic expression is used to get the correct ascii code out of the e.which || e.keycode returned value
// since the keyboards doesn't understand ascii but scan codes and they differ for certain keys such as '/'
// stackoverflow ref: https://stackoverflow.com/a/29811987/10822996
function getCharFromCharCode(passedCharCode) {
var which = passedCharCode;
var chrCode = which - 48 * Math.floor(which / 48);
return String.fromCharCode(which >= 96 ? chrCode : which);
} // used for parsing focusshortcuts for keycodes passed as string, eg: 'ctrl+/' is same as 'ctrl+47'
// returns focusShortcuts containing appropriate key charsas depicted on keyboards
function parseFocusShortcuts(focusShortcutsArray) {
if (isEmpty(focusShortcutsArray)) return [];
var parsedFocusShortcutsArray = [];
focusShortcutsArray.forEach(function (element) {
if (typeof element === 'string') {
if (isHotkeyCombination(element)) {
// splitting the combination into pieces
var splitCombination = element.split('+');
var parsedSplitCombination = []; // parsedCombination would have all the keycodes converted into chars
var parsedCombination = '';
for (var i = 0; i < splitCombination.length; i += 1) {
if (isNumeric(splitCombination[i])) {
parsedSplitCombination.push(getCharFromCharCode(+splitCombination[i]));
} else {
parsedSplitCombination.push(splitCombination[i]);
}
}
parsedCombination = parsedSplitCombination.join('+');
parsedFocusShortcutsArray.push(parsedCombination);
} else if (isNumeric(element)) {
parsedFocusShortcutsArray.push(getCharFromCharCode(+element));
} else {
// single char shortcut, eg: '/'
parsedFocusShortcutsArray.push(element);
}
} else {
// if not a string the the shortcut is assumed to be a keycode
parsedFocusShortcutsArray.push(getCharFromCharCode(element));
}
});
return parsedFocusShortcutsArray;
}
var MODIFIER_KEYS = ['shift', 'ctrl', 'alt', 'control', 'option', 'cmd', 'command']; // filter out modifierkeys such as ctrl, alt, command, shift from focusShortcuts prop
function extractModifierKeysFromFocusShortcuts(focusShortcutsArray) {
return focusShortcutsArray.filter(function (shortcutKey) {
return MODIFIER_KEYS.includes(shortcutKey);
});
}
function isModifierKeyUsed(focusShortcutsArray) {
return !!extractModifierKeysFromFocusShortcuts(focusShortcutsArray).length;
}
var queryTypes = {
Search: 'search',
Term: 'term',
Geo: 'geo',
Range: 'range',
Suggestion: 'suggestion'
};
var suggestionTypes = {
Popular: 'popular',
Index: 'index',
Recent: 'recent',
Promoted: 'promoted'
};
var URLParamsProvider = {
name: 'URLParamsProvider',
inject: ['searchbase'],
props: {
id: VueTypes.string.isRequired
},
mounted: function mounted() {
var _this = this;
var id = this.$props.id;
if (window) {
this.init();
window.addEventListener('popstate', function () {
var options = {
triggerCustomQuery: true,
triggerDefaultQuery: true,
stateChanges: true
};
_this.init();
var componentInstance = _this.getComponentInstance();
if (componentInstance) {
if (_this.params.has(id)) {
// Set component value
try {
var paramValue = JSON.parse(_this.params.get(id));
var category;
if (typeof paramValue === 'object' && paramValue.category) {
category = paramValue.category;
paramValue = paramValue.value;
componentInstance.setCategoryValue(category, {
triggerCustomQuery: false,
triggerDefaultQuery: false,
stateChanges: false
});
}
if (!isEqual(componentInstance.value, paramValue)) {
componentInstance.setValue(paramValue, _extends({}, options));
}
} catch (e) {
console.error(e); // Do not set value if JSON parsing fails.
}
} else if (componentInstance.value) {
// Remove inactive componentInstance
componentInstance.setValue(null, options);
}
}
});
var component = this.getComponentInstance();
if (component) {
component.subscribeToStateChanges(function (change) {
_this.init(); // this ensures the url params change are handled
// when the url changes, which enables us to
// make `onpopstate` event handler work with history.pushState updates
_this.checkForURLParamsChange(); // Set URLParams on value change
// Only set the valid values
if (checkValidValue(change.value.next)) {
// stringify the values
var valueParam = change.value.next;
if (component.categoryValue) {
valueParam = {
value: change.value.next,
category: component.categoryValue
};
}
_this.params.set(id, JSON.stringify(valueParam));
} else {
_this.params["delete"](id);
} // Update URLParam
_this.pushToHistory();
}, ['value']);
}
}
},
beforeDestroy: function beforeDestroy() {
var id = this.$props.id; // Remove param on unmount
this.params["delete"](id);
},
methods: {
getComponentInstance: function getComponentInstance() {
return this.searchbase.getComponent(this.$props.id);
},
init: function init() {
this.searchString = window.location.search;
this.params = new URLSearchParams(this.searchString);
},
checkForURLParamsChange: function checkForURLParamsChange() {
// we only compare the search string (window.location.search by default)
// to see if the route has changed (or) not. This handles the following usecase:
// search on homepage -> route changes -> search results page with same search query
if (window) {
var searchString = window.location.search;
if (searchString !== this.searchString) {
var event;
if (typeof Event === 'function') {
event = new Event('popstate');
} else {
// Correctly fire popstate event on IE11 to prevent app crash.
event = document.createEvent('Event');
event.initEvent('popstate', true, true);
}
window.dispatchEvent(event);
}
}
},
pushToHistory: function pushToHistory() {
var paramsSting = this.params.toString() ? "?" + this.params.toString() : '';
var base = window.location.href.split('?')[0];
var newURL = "" + base + paramsSting;
if (window.history.pushState) {
window.history.pushState({
path: newURL
}, '', newURL);
}
this.init();
}
},
render: function render() {
var h = arguments[0];
return this.$slots["default"] ? h("div", [this.$slots["default"]]) : null;
}
};
URLParamsProvider.install = function (Vue) {
Vue.component(URLParamsProvider.name, URLParamsProvider);
};
var SearchComponent = {
name: 'search-component',
inject: ['searchbase'],
props: {
index: VueTypes.string,
url: VueTypes.string,
credentials: VueTypes.string,
headers: VueTypes.object,
appbaseConfig: types.appbaseConfig,
transformRequest: VueTypes.func,
transformResponse: VueTypes.func,
beforeValueChange: VueTypes.func,
enablePopularSuggestions: VueTypes.bool,
enablePredictiveSuggestions: VueTypes.bool,
maxPopularSuggestions: VueTypes.number,
clearOnQueryChange: VueTypes.bool,
showDistinctSuggestions: types.showDistinctSuggestions,
URLParams: VueTypes.bool,
// RS API properties
id: VueTypes.string.isRequired,
value: VueTypes.any,
type: types.queryTypes,
react: types.reactType,
queryFormat: types.queryFormat,
dataField: types.dataField,
categoryField: VueTypes.string,
categoryValue: VueTypes.string,
nestedField: VueTypes.string,
from: VueTypes.number,
size: VueTypes.number,
sortBy: types.sortType,
aggregationField: VueTypes.string,
aggregationSize: VueTypes.number,
after: VueTypes.object,
includeNullValues: VueTypes.bool,
includeFields: types.sourceFields,
excludeFields: types.sourceFields,
fuzziness: types.fuzziness,
searchOperators: VueTypes.bool,
highlight: VueTypes.bool,
highlightField: VueTypes.string,
customHighlight: VueTypes.object,
interval: VueTypes.number,
aggregations: VueTypes.arrayOf(VueTypes.string),
missingLabel: VueTypes.string,
showMissing: VueTypes.bool,
defaultQuery: VueTypes.func,
customQuery: VueTypes.func,
enableSynonyms: VueTypes.bool,
selectAllLabel: VueTypes.string,
pagination: VueTypes.bool,
queryString: VueTypes.bool,
preserveResults: VueTypes.bool,
render: VueTypes.func,
distinctField: VueTypes.string,
distinctFieldConfig: VueTypes.object,
// subscribe on changes,
subscribeTo: VueTypes.arrayOf(VueTypes.string),
triggerQueryOnInit: VueTypes.bool.def(true),
recentSuggestionsConfig: VueTypes.object,
popularSuggestionsConfig: VueTypes.object,
maxPredictedWords: VueTypes.number,
urlField: VueTypes.string,
rankFeature: VueTypes.object,
enableRecentSearches: VueTypes.bool,
enableRecentSuggestions: VueTypes.bool,
applyStopwords: VueTypes.bool,
stopwords: VueTypes.arrayOf(VueTypes.string),
// meta info about instantiated component
componentName: VueTypes.oneOf(['SearchBox', 'SearchComponent']).def('SearchComponent'),
// mongodb specific
autocompleteField: types.dataField,
highlightConfig: VueTypes.object,
mongodb: VueTypes.object
},
data: function data() {
return {
searchState: {}
};
},
created: function created() {
var _this = this;
// clone the props for component it is needed because $options gets changed on time
var componentProps = this.$props;
if (this.$options && this.$options.propsData) {
componentProps = _extends({}, this.$options.propsData);
} // handle kebab case for props
var parsedProps = {};
Object.keys(componentProps).forEach(function (key) {
parsedProps[getCamelCase(key)] = componentProps[key];
});
this.rawProps = parsedProps;
var _this$rawProps = this.rawProps,
id = _this$rawProps.id,
index = _this$rawProps.index,
url = _this$rawProps.url,
credentials = _this$rawProps.credentials,
headers = _this$rawProps.headers,
appbaseConfig = _this$rawProps.appbaseConfig,
transformRequest = _this$rawProps.transformRequest,
transformResponse = _this$rawProps.transformResponse,
type = _this$rawProps.type,
react = _this$rawProps.react,
queryFormat = _this$rawProps.queryFormat,
dataField = _this$rawProps.dataField,
categoryField = _this$rawProps.categoryField,
categoryValue = _this$rawProps.categoryValue,
nestedField = _this$rawProps.nestedField,
from = _this$rawProps.from,
size = _this$rawProps.size,
sortBy = _this$rawProps.sortBy,
aggregationField = _this$rawProps.aggregationField,
aggregationSize = _this$rawProps.aggregationSize,
after = _this$rawProps.after,
includeNullValues = _this$rawProps.includeNullValues,
includeFields = _this$rawProps.includeFields,
excludeFields = _this$rawProps.excludeFields,
fuzziness = _this$rawProps.fuzziness,
searchOperators = _this$rawProps.searchOperators,
highlight = _this$rawProps.highlight,
highlightField = _this$rawProps.highlightField,
customHighlight = _this$rawProps.customHighlight,
interval = _this$rawProps.interval,
aggregations = _this$rawProps.aggregations,
missingLabel = _this$rawProps.missingLabel,
showMissing = _this$rawProps.showMissing,
defaultQuery = _this$rawProps.defaultQuery,
customQuery = _this$rawProps.customQuery,
enableSynonyms = _this$rawProps.enableSynonyms,
selectAllLabel = _this$rawProps.selectAllLabel,
pagination = _this$rawProps.pagination,
queryString = _this$rawProps.queryString,
enablePopularSuggestions = _this$rawProps.enablePopularSuggestions,
maxPopularSuggestions = _this$rawProps.maxPopularSuggestions,
enablePredictiveSuggestions = _this$rawProps.enablePredictiveSuggestions,
showDistinctSuggestions = _this$rawProps.showDistinctSuggestions,
subscribeTo = _this$rawProps.subscribeTo,
preserveResults = _this$rawProps.preserveResults,
clearOnQueryChange = _this$rawProps.clearOnQueryChange,
distinctField = _this$rawProps.distinctField,
distinctFieldConfig = _this$rawProps.distinctFieldConfig,
enableRecentSearches = _this$rawProps.enableRecentSearches,
enableRecentSuggestions = _this$rawProps.enableRecentSuggestions,
recentSuggestionsConfig = _this$rawProps.recentSuggestionsConfig,
popularSuggestionsConfig = _this$rawProps.popularSuggestionsConfig,
maxPredictedWords = _this$rawProps.maxPredictedWords,
urlField = _this$rawProps.urlField,
rankFeature = _this$rawProps.rankFeature,
applyStopwords = _this$rawProps.applyStopwords,
stopwords = _this$rawProps.stopwords,
mongodb = _this$rawProps.mongodb,
autocompleteField = _this$rawProps.autocompleteField,
highlightConfig = _this$rawProps.highlightConfig;
var _this$rawProps2 = this.rawProps,
value = _this$rawProps2.value,
category = _this$rawProps2.categoryValue;
if (window && window.location && window.location.search) {
var params = new URLSearchParams(window.location.search);
if (params.has(id)) {
try {
value = JSON.parse(params.get(id));
if (typeof value === 'object' && value.category) {
category = value.category;
value = value.value;
}
} catch (e) {
console.error(e); // Do not set value if JSON parsing fails.
}
}
}
var componentInstance = this.searchbase.register(id, {
index: index,
url: url,
credentials: credentials,
headers: headers,
appbaseConfig: appbaseConfig,
transformRequest: transformRequest,
transformResponse: transformResponse,
value: value,
type: type,
react: react,
queryFormat: queryFormat,
dataField: dataField,
categoryField: categoryField,
categoryValue: category || categoryValue,
nestedField: nestedField,
from: from,
size: size,
sortBy: sortBy,
aggregationField: aggregationField,
aggregationSize: aggregationSize,
after: after,
includeNullValues: includeNullValues,
includeFields: includeFields,
excludeFields: excludeFields,
fuzziness: fuzziness,
searchOperators: searchOperators,
highlight: highlight,
highlightField: highlightField,
customHighlight: customHighlight,
interval: interval,
aggregations: aggregations,
missingLabel: missingLabel,
showMissing: showMissing,
defaultQuery: defaultQuery,
customQuery: customQuery,
enableSynonyms: enableSynonyms,
selectAllLabel: selectAllLabel,
pagination: pagination,
queryString: queryString,
enablePopularSuggestions: enablePopularSuggestions,
maxPopularSuggestions: maxPopularSuggestions,
enablePredictiveSuggestions: enablePredictiveSuggestions,
showDistinctSuggestions: showDistinctSuggestions,
preserveResults: preserveResults,
clearOnQueryChange: clearOnQueryChange,
distinctField: distinctField,
distinctFieldConfig: distinctFieldConfig,
enableRecentSearches: enableRecentSearches,
enableRecentSuggestions: enableRecentSuggestions,
recentSuggestionsConfig: recentSuggestionsConfig,
popularSuggestionsConfig: popularSuggestionsConfig,
maxPredictedWords: maxPredictedWords,
urlField: urlField,
rankFeature: rankFeature,
applyStopwords: applyStopwords,
stopwords: stopwords,
componentName: this.$props.componentName,
mongodb: mongodb,
autocompleteField: autocompleteField,
highlightConfig: highlightConfig,
onValueChange: function onValueChange(prev, next) {
_this.$emit('value', {
prev: prev,
next: next
});
},
onResults: function onResults(prev, next) {
_this.$emit('results', {
prev: prev,
next: next
});
},
onAggregationData: function onAggregationData(prev, next) {
_this.$emit('aggregationData', {
prev: prev,
next: next
});
},
onError: function onError(prev, next) {
_this.$emit('error', {
prev: prev,
next: next
});
},
onRequestStatusChange: function onRequestStatusChange(prev, next) {
_this.$emit('requestStatus', {
prev: prev,
next: next
});
},
onQueryChange: function onQueryChange(prev, next) {
_this.$emit('query', {
prev: prev,
next: next
});
},
onMicStatusChange: function onMicStatusChange(prev, next) {
_this.$emit('micStatus', {
prev: prev,
next: next
});
},
libAlias: searchbase.LIBRARY_ALIAS.VUE_SEARCHBOX
});
Object.keys(componentInstance.mappedProps).forEach(function (key) {
_this.$set(_this.searchState, key, componentInstance.mappedProps[key]);
}); // Subscribe to state changes only when slot is defined
componentInstance.subscribeToStateChanges(function (change) {
Object.keys(change).forEach(function () {
_this.searchState = componentInstance.mappedProps;
});
}, subscribeTo);
if ((value || customQuery) && this.componentInstance) {
this.componentInstance.triggerCustomQuery();
}
},
mounted: function mounted() {
var triggerQueryOnInit = this.$props.triggerQueryOnInit;
var componentInstance = this.getComponentInstance();
if (triggerQueryOnInit) {
componentInstance.triggerDefaultQuery();
}
},
methods: {
getComponentInstance: function getComponentInstance() {
return this.searchbase.getComponent(this.$props.id);
}
},
render: function render() {
var h = arguments[0];
var _this$$props = this.$props,
id = _this$$props.id,
URLParams = _this$$props.URLParams;
if (this.$scopedSlots["default"]) {
var dom = this.$scopedSlots["default"];
if (URLParams) {
return h(URLParamsProvider, {
"attrs": {
"id": id
}
}, [dom(this.searchState)]);
}
return h("div", [dom(this.searchState)]);
}
return null;
}
};
SearchComponent.install = function (Vue) {
Vue.component(SearchComponent.name, SearchComponent);
};
var _templateObject;
var InputGroup = styled__default('div')(_templateObject || (_templateObject = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n height: 42px;\n width: 100%;\n\n .enter-button-wrapper{\n height: 100%;\n }\n"])));
InputGroup.defaultProps = {
className: 'input-group'
};
var _templateObject$1;
var InputWrapper = styled__default('div')(_templateObject$1 || (_templateObject$1 = _taggedTemplateLiteralLoose(["\n flex: 1;\n position: relative;\n"])));
var _templateObject$2;
var InputAddon = styled__default('div')(_templateObject$2 || (_templateObject$2 = _taggedTemplateLiteralLoose(["\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n background-color: #fafafa;\n border: 1px solid #ccc;\n border-radius: 2px;\n color: rgba(0, 0, 0, 0.85);\n font-size: 14px;\n font-weight: 400;\n padding: 2px 11px;\n position: relative;\n transition: all 0.3s;\n box-sizing: border-box;\n overflow: hidden;\n\n &:first-of-type {\n border-right: none;\n }\n &:last-of-type {\n border-left: none;\n }\n"])));
InputAddon.defaultProps = {
className: 'input-addon'
};
var _templateObject$3, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
var input = emotion.css(_templateObject$3 || (_templateObject$3 = _taggedTemplateLiteralLoose(["\n width: 100%;\n height: 42px;\n line-height: 42px;\n padding: 8px 12px;\n border: 1px solid #ccc;\n background-color: #fafafa;\n font-size: 0.9rem;\n outline: none;\n box-sizing: border-box;\n\n &:focus {\n background-color: #fff;\n }\n"])));
var Input = styled__default('input')(_templateObject2 || (_templateObject2 = _taggedTemplateLiteralLoose(["\n ", "\n\n ", ";\n\n ", ";\n\n ", ";\n ", ";\n\n ", ";\n\n ", ";\n ", ";\n ", ";\n"])), input, function (props) {
return props.showIcon && props.iconPosition === 'left' && emotion.css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteralLoose(["\n padding-left: 36px;\n "])));
}, function (props) {
return props.showIcon && props.iconPosition === 'right' && emotion.css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteralLoose(["\n padding-right: 36px;\n "])));
}, function (props) {
return (// for clear icon
props.showClear && emotion.css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteralLoose(["\n padding-right: 36px;\n "])))
);
}, function (props) {
return (// for voice search icon
props.showVoiceSearch && emotion.css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteralLoose(["\n padding-right: 36px;\n "])))
);
}, function (props) {
return (// for clear icon with search icon
props.showClear && props.showIcon && props.iconPosition === 'right' && emotion.css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteralLoose(["\n padding-right: 66px;\n "])))
);
}, function (props) {
return (// for voice search icon with search icon
props.showVoiceSearch && props.showIcon && props.iconPosition === 'right' && emotion.css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteralLoose(["\n padding-right: 66px;\n "])))
);
}, function (props) {
return (// for voice search icon with clear icon
props.showClear && props.showVoiceSearch && emotion.css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteralLoose(["\n padding-right: 66px;\n "])))
);
}, function (props) {
return (// for clear icon with search icon and voice search
props.showClear && props.showIcon && props.showVoiceSearch && props.iconPosition === 'right' && emotion.css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteralLoose(["\n padding-right: 90px;\n "])))
);
});
var DownShift = {
// eslint-disable-next-line
props: ['isOpen', 'inputValue', 'selectedItem', 'highlightedIndex', 'handleChange', 'itemToString', 'handleMouseup'],
data: function data() {
return {
isMouseDown: false,
internal_isOpen: false,
internal_inputValue: '',
internal_selectedItem: null,
internal_highlightedIndex: null
};
},
computed: {
mergedState: function mergedState() {
var _this = this;
return Object.keys(this.$props).reduce(function (state, key) {
var _extends2;
return _extends({}, state, (_extends2 = {}, _extends2[key] = _this.isControlledProp(key) ? _this.$props[key] : _this["internal_" + key], _extends2));
}, {});
},
internalItemCount: function internalItemCount() {
return this.items.length;
}
},
mounted: function mounted() {
window.addEventListener('mousedown', this.handleWindowMousedown);
window.addEventListener('mouseup', this.handleWindowMouseup);
},
beforeDestroy: function beforeDestroy() {
window.removeEventListener('mousedown', this.handleWindowMousedown);
window.removeEventListener('mouseup', this.handleWindowMouseup);
},
methods: {
handleWindowMousedown: function handleWindowMousedown() {
this.isMouseDown = true;
},
handleWindowMouseup: function handleWindowMouseup(event) {
this.isMouseDown = false;
if ((event.target === this.$refs.rootNode || !this.$refs.rootNode.contains(event.target)) && this.mergedState.isOpen) {
// TODO: handle on outer click here
if (!this.isMouseDown) {
this.reset();
if (this.$props.handleMouseup) {
this.$props.handleMouseup({
isOpen: false
});
}
}
}
},
keyDownArrowDown: function keyDownArrowDown(event) {
event.preventDefault();
var amount = event.shiftKey ? 5 : 1;
if (this.mergedState.isOpen) {
this.changeHighlightedIndex(amount);
} else {
this.setState({
isOpen: true
});
this.setHighlightedIndex();
}
},
keyDownArrowUp: function keyDownArrowUp(event) {
event.preventDefault();
var amount = event.shiftKey ? -5 : -1;
if (this.mergedState.isOpen) {
this.changeHighlightedIndex(amount);
} else {
this.setState({
isOpen: true
});
this.setHighlightedIndex();
}
},
keyDownEnter: function keyDownEnter(event) {
if (this.mergedState.isOpen) {
event.preventDefault();
this.selectHighlightedItem();
}
},
keyDownEscape: function keyDownEscape(event) {
event.preventDefault();
this.reset();
},
selectHighlightedItem: function selectHighlightedItem() {
return this.selectItemAtIndex(this.mergedState.highlightedIndex);
},
selectItemAtIndex: function selectItemAtIndex(itemIndex) {
var item = this.items[itemIndex];
if (item == null) {
return;
}
this.selectItem(item);
},
selectItem: function selectItem(item) {
if (this.$props.handleChange) {
this.$props.handleChange(item);
}
this.setState({
isOpen: false,
highlightedIndex: null,
selectedItem: item,
inputValue: this.isControlledProp('selectedItem') ? '' : item
});
},
changeHighlightedIndex: function changeHighlightedIndex(moveAmount) {
if (this.internalItemCount < 0) {
return;
}
var highlightedIndex = this.mergedState.highlightedIndex;
var baseIndex = highlightedIndex;
if (baseIndex === null) {
baseIndex = moveAmount > 0 ? -1 : this.internalItemCount + 1;
}
var newIndex = baseIndex + moveAmount;
if (newIndex < 0) {
newIndex = this.internalItemCount;
} else if (newIndex > this.internalItemCount) {
newIndex = 0;
}
this.setHighlightedIndex(newIndex);
},
setHighlightedIndex: function setHighlightedIndex(highlightedIndex) {
if (highlightedIndex === void 0) {
highlightedIndex = null;
}
this.setState({
highlightedIndex: highlightedIndex
});
var element = document.getElementById("Downshift" + highlightedIndex);
scrollIntoView(element, this.rootNode); // Implement scrollIntroView thingy
},
reset: function reset() {
var selectedItem = this.mergedState.selectedItem;
this.setState({
isOpen: false,
highlightedIndex: null,
inputValue: selectedItem
});
},
getItemProps: function getItemProps(_ref) {
var index = _ref.index,
item = _ref.item;
var newIndex = index;
if (index === undefined) {
if (this.$props.itemToString) {
this.items.push(this.$props.itemToString(item));
} else {
this.items.push(item);
}
newIndex = this.items.indexOf(item);
} else {
this.items[newIndex] = item;
}
return {
id: "Downshift" + newIndex
};
},
getItemEvents: function getItemEvents(_ref2) {
var index = _ref2.index,
item = _ref2.item;
var newIndex = index;
if (index === undefined) {
newIndex = this.items.indexOf(item);
}
var vm = this;
return {
mouseenter: function mouseenter() {
vm.setHighlightedIndex(newIndex);
},
click: function click(event) {
event.stopPropagation();
vm.selectItemAtIndex(newIndex);
}
};
},
getInputProps: function getInputProps(_ref3) {
var value = _ref3.value;
var inputValue = this.mergedState.inputValue;
if (value !== inputValue) {
this.setState({
inputValue: value
});
}
return {
value: inputValue
};
},
getButtonProps: function getButtonProps(_ref4) {
var _this2 = this;
var onClick = _ref4.onClick,
onKeyDown = _ref4.onKeyDown,
onKeyUp = _ref4.onKeyUp,
onBlur = _ref4.onBlur;
return {
click: function click(event) {
_this2.setState({
isOpen: true,
inputValue: event.target.value
});
if (onClick) {
onClick(event);
}
},
keydown: function keydown(event) {
if (event.key && _this2["keyDown" + event.key]) {
_this2["keyDown" + event.key].call(_this2, event);
}
if (onKeyDown) {
onKeyDown(event);
}
},
keyup: function keyup(event) {
if (onKeyUp) {
onKeyUp(event);
}
},
blur: function blur(event) {
if (onBlur) {
onBlur(event);
}
}
};
},
getInputEvents: function getInputEvents(_ref5) {
var _this3 = this;
var onInput = _ref5.onInput,
onBlur = _ref5.onBlur,
onFocus = _ref5.onFocus,
onKeyPress = _ref5.onKeyPress,
onKeyDown = _ref5.onKeyDown,
onKeyUp = _ref5.onKeyUp;
return {
input: function input(event) {
_this3.setState({
isOpen: true,
inputValue: event.target.value
});
if (onInput) {
onInput(event);
}
},
focus: function focus(event) {
if (onFocus) {
onFocus(event);
}
},
keydown: function keydown(event) {
if (event.key && _this3["keyDown" + event.key]) {
_this3["keyDown" + event.key].call(_this3, event);
}
if (onKeyDown) {
onKeyDown(event);
}
},
keypress: function keypress(event) {
if (onKeyPress) {
onKeyPress(event);
}
},
keyup: function keyup(event) {
if (onKeyUp) {
onKeyUp(event);
}
},
blur: function blur(event) {
if (onBlur) {
onBlur(event);
} // TODO: implement isMouseDown
// this.reset()
}
};
},
getHelpersAndState: function getHelpersAndState() {
var getItemProps = this.getItemProps,
getItemEvents = this.getItemEvents,
getInputProps = this.getInputProps,
getInputEvents = this.getInputEvents,
getButtonProps = this.getButtonProps;
return _extends({
getItemProps: getItemProps,
getItemEvents: getItemEvents,
getInputProps: getInputProps,
getInputEvents: getInputEvents,
getButtonProps: getButtonProps
}, this.mergedState);
},
isControlledProp: function isControlledProp(prop) {
return this.$props[prop] !== undefined;
},
setState: function setState(stateToSet) {
var _this4 = this;
// eslint-disable-next-line
Object.keys(stateToSet).map(function (key) {
// eslint-disable-next-line
_this4.isControlledProp(key) ? _this4.$emit(key + "Change", stateToSet[key]) : _this4["internal_" + key] = stateToSet[key];
});
this.$emit('stateChange', this.mergedState);
}
},
render: function render() {
var h = arguments[0];
this.items = [];
return h("div", {
"ref": "rootNode"
}, [this.$scopedSlots["default"] && this.$scopedSlots["default"](_extends({}, this.getHelpersAndState()))]);
}
};
var _templateObject$4, _templateObject2$1;
var suggestions = emotion.css(_templateObject$4 || (_templateObject$4 = _taggedTemplateLiteralLoose(["\n display: block;\n width: 100%;\n border: 1px solid #ccc;\n background-color: #fff;\n font-size: 0.9rem;\n z-index: 3;\n position: absolute;\n top: 41px;\n margin: 0;\n padding: 0;\n list-style: none;\n max-height: 405px;\n overflow-y: auto;\n box-sizing: border-box;\n\n &.small {\n top: 30px;\n }\n\n li {\n display: flex;\n justify-content: space-between;\n cursor: pointer;\n padding: 10px;\n user-select: none;\n\n .trim {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n position: relative;\n }\n\n &:hover,\n &:focus {\n background-color: #eee;\n }\n\n .highlight-class {\n font-weight: 600;\n padding: 0;\n background-color: transparent;\n color: inherit;\n }\n }\n"])));
var suggestionsContainer = emotion.css(_templateObject2$1 || (_templateObject2$1 = _taggedTemplateLiteralLoose(["\n position: relative;\n .cancel-icon {\n cursor: pointer;\n }\n .no-suggestions {\n border: 1px solid #ccc;\n border-top: 0;\n font-size: 0.9rem;\n padding: 10px;\n }\n"])));
var SuggestionItem = {
props: ['suggestion', 'currentValue'],
render: function render() {
var h = arguments[0];
var _this$$props = this.$props,
suggestion = _this$$props.suggestion,
_this$$props$currentV = _this$$props.currentValue,
currentValue = _this$$props$currentV === void 0 ? '' : _this$$props$currentV;
var label = suggestion.label,
value = suggestion.value;
var modSearchWords = currentValue.split(' ').map(function (word) {
return escapeRegExp(word);
});
var stringToReplace = suggestion._category ? "in " + suggestion._category : modSearchWords.join('|');
if (label) {
// label has highest precedence
if (typeof label === 'string') {
try {
return h("div", {
"class": "trim",
"domProps": {
"innerHTML": /<[a-z][\s\S]*>/i.test(suggestion.label) // contains any html from backend, eg: highlight
? label : label.replace(new RegExp(stringToReplace, 'ig'), function (matched) {
return "<mark class=\"highlight-class\">" + matched + "</mark>";
})
}
});
} catch (e) {
return label;
}
}
return label;
}
return value;
}
};
var _templateObject$5;
var Title = styled__default('h2')(_templateObject$5 || (_templateObject$5 = _taggedTemplateLiteralLoose(["\n margin: 0 0 8px;\n font-size: 1rem;\n color: #424242;\n"])));
var CancelSvg = {
functional: true,
render: function render(h) {
return h("svg", {
"attrs": {
"alt": "Clear",
"xmlns": "http://www.w3.org/2000/svg",
"height": "20px",
"viewBox": "0 0 24 24",
"width": "20px",
"fill": "#000000"
},
"class": "cancel-icon"
}, [h("title", ["Clear"]), h("path", {
"attrs": {
"d": "M0 0h24v24H0V0z",
"fill": "none"
}
}), h("path", {
"attrs": {
"d": "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"
}
})]);
}
};
var _templateObject$6;
var IconWrapper = styled__default('div')(_templateObject$6 || (_templateObject$6 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tmax-width: 23px;\n\twidth: max-content;\n\tcursor: pointer;\n\theight: 100%;min-width:20px;\n\n\tsvg.search-icon {\n\t\tfill: #0B6AFF;\n\t}\n\n\tsvg.cancel-icon {\n\t\tfill: #595959;\n\t}\n"])));
var _templateObject$7, _templateObject2$2, _templateObject3$1, _templateObject4$1;
var IconGroup = styled__default('div')(_templateObject$7 || (_templateObject$7 = _taggedTemplateLiteralLoose(["\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tgrid-gap: 6px;\n\tmargin: 0 10px;\n\theight: 100%;\n\n\t", ";\n\n\t", ";\n"])), function (_ref) {
var positionType = _ref.positionType;
if (positionType === 'absolute') {
return styled.css(_templateObject2$2 || (_templateObject2$2 = _taggedTemplateLiteralLoose(["\n\t\t\t\tposition: absolute;\n\t\t\t\ttop: 50%;\n\t\t\t\ttransform: translateY(-50%);\n\t\t\t"])));
}
return null;
}, function (_ref2) {
var groupPosition = _ref2.groupPosition;
return groupPosition === 'right' ? styled.css(_templateObject3$1 || (_templateObject3$1 = _taggedTemplateLiteralLoose(["\n\t\t\t\t\tright: 0;\n\t\t\t "]))) : styled.css(_templateObject4$1 || (_templateObject4$1 = _taggedTemplateLiteralLoose(["\n\t\t\t\t\tleft: 0;\n\t\t\t "])));
});
var SearchSvg = {
functional: true,
render: function render(h, data) {
if (data === void 0) {
data = {
props: {}
};
}
return h("svg", {
"attrs": {
"alt": "Search",
"height": "12",
"xmlns": "http://www.w3.org/2000/svg",
"viewBox": "0 0 15 15"
},
"class": "search-icon",
"style": _extends({
transform: 'scale(1.25)',
position: 'relative'
}, data.props.style ? data.props.style : {})
}, [h("title", ["Search"]), h("path", {
"attrs": {
"d": 'M6.02945,10.20327a4.17382,4.17382,0,1,1,4.17382-4.17382A4.15609,4.15609,0,0,1,6.02945,10.20327Zm9.69195,4.2199L10.8989,9.59979A5.88021,5.88021,0,0,0,12.058,6.02856,6.00467,6.00467,0,1,0,9.59979,10.8989l4.82338,4.82338a.89729.89729,0,0,0,1.29912,0,.89749.89749,0,0,0-.00087-1.29909Z'
}
})]);
}
};
var _templateObject$8;
styled.injectGlobal(_templateObject$8 || (_templateObject$8 = _taggedTemplateLiteralLoose(["\n\t@-webkit-keyframes kf_el_6WKby7wXqV_an_qqO-rxbNc {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t13.89% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_6WKby7wXqV_an_qqO-rxbNc {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t13.89% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_Wi-my975tM_an_XhXP1epXB {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t27.78% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_Wi-my975tM_an_XhXP1epXB {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t27.78% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_DkfFFTaFxy8_an_T2XxzvIaA {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t41.67% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_DkfFFTaFxy8_an_T2XxzvIaA {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t41.67% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_34IgwiMB5rf_an_TPom3H2LI {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t55.56% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_34IgwiMB5rf_an_TPom3H2LI {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t55.56% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_DeebuCsPTGA_an_aYTRBE7Na {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t69.44% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_DeebuCsPTGA_an_aYTRBE7Na {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t69.44% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_ZOjjrPTvyrv_an_l_BjBNzXw {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t83.33% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_ZOjjrPTvyrv_an_l_BjBNzXw {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t83.33% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@-webkit-keyframes kf_el_2FATegVmf0K_an_wLg4ofuFx {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t97.22% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t@keyframes kf_el_2FATegVmf0K_an_wLg4ofuFx {\n\t\t0% {\n\t\t\topacity: 0;\n\t\t}\n\t\t97.22% {\n\t\t\topacity: 1;\n\t\t}\n\t\t100% {\n\t\t\topacity: 1;\n\t\t}\n\t}\n\t#el_hiibMG0x- * {\n\t\t-webkit-animation-duration: 1.2s;\n\t\tanimation-duration: 1.2s;\n\t\t-webkit-animation-iteration-count: infinite;\n\t\tanimation-iteration-count: infinite;\n\t\t-webkit-animation-timing-function: cubic-bezier(0, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0, 0, 1, 1);\n\t}\n\t#el_QJeJ_2CDw5 {\n\t\tstroke: none;\n\t\tstroke-width: 1;\n\t\tfill: none;\n\t}\n\t#el_UYYCfubTRf {\n\t\t-webkit-transform: translate(163px, 123px);\n\t\ttransform: translate(163px, 123px);\n\t}\n\t#el_uzZNtK32Zi {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_EYKQ2N9Kgy {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_6SDP2LAgKC {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t}\n\t#el_-Vm65Ltfy7 {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_q04iZcSim4 {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_6WKby7wXqV {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_6WKby7wXqV_an_qqO-rxbNc;\n\t\tanimation-name: kf_el_6WKby7wXqV_an_qqO-rxbNc;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_9bggsfQOtU {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_NKxqi9eIym {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_Wi-my975tM {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_Wi-my975tM_an_XhXP1epXB;\n\t\tanimation-name: kf_el_Wi-my975tM_an_XhXP1epXB;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_zclQ34fvf7 {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_1OsvRT8HkeZ {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_DkfFFTaFxy8 {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_DkfFFTaFxy8_an_T2XxzvIaA;\n\t\tanimation-name: kf_el_DkfFFTaFxy8_an_T2XxzvIaA;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_aa9sjx4H0vA {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_tea114vWg0J {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_34IgwiMB5rf {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_34IgwiMB5rf_an_TPom3H2LI;\n\t\tanimation-name: kf_el_34IgwiMB5rf_an_TPom3H2LI;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_z5u6RAFhx7d {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_7nfuWmA5Uhy {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_DeebuCsPTGA {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_DeebuCsPTGA_an_aYTRBE7Na;\n\t\tanimation-name: kf_el_DeebuCsPTGA_an_aYTRBE7Na;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el__ZcqlS20zcw {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_8DnEQnD7VWV {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_ZOjjrPTvyrv {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_ZOjjrPTvyrv_an_l_BjBNzXw;\n\t\tanimation-name: kf_el_ZOjjrPTvyrv_an_l_BjBNzXw;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_FYYKCI_u24e {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_XZty4MnTp5Y {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_2FATegVmf0K {\n\t\t-webkit-transform: translate(37.846924px, 0px);\n\t\ttransform: translate(37.846924px, 0px);\n\t\t-webkit-animation-fill-mode: backwards;\n\t\tanimation-fill-mode: backwards;\n\t\topacity: 0;\n\t\t-webkit-animation-name: kf_el_2FATegVmf0K_an_wLg4ofuFx;\n\t\tanimation-name: kf_el_2FATegVmf0K_an_wLg4ofuFx;\n\t\t-webkit-animation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t\tanimation-timing-function: cubic-bezier(0.42, 0, 1, 1);\n\t}\n\t#el_RMT1KUfbdF8 {\n\t\tfill: #0B6AFF;\n\t}\n\t#el_RgLcovvFiO1 {\n\t\tfill: #d8d8d8;\n\t}\n"])));
var ListenSvg = {
name: 'ListenSvg',
props: ['className', 'handleMicClick'],
render: function render() {
var h = arguments[0];
return h("svg", {
"attrs": {
"viewBox": "0 0 480 480",
"xmlns": "http://www.w3.org/2000/svg",
"xmlnsXlink": "http://www.w3.org/1999/xlink",
"id": "el_hiibMG0x-",
"width": 28,
"height": 29,
"className": this.$props.className
},
"style": {
transform: 'scale(1.5)'
},
"on": {
"click": this.$props.handleMicClick
}
}, [h("defs", [h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-1"
}
}), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-3"
}
}), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-5"
}
}), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-7"
}
}), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-9"
}
}), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-11"
}
}), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-13"
}
}), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "path-15"
}
})]), h("g", {
"attrs": {
"id": "el_QJeJ_2CDw5",
"fillRule": "evenodd"
}
}, [h("g", {
"attrs": {
"id": "el_UYYCfubTRf"
}
}, [h("path", {
"attrs": {
"d": "M142.731204,111 C137.280427,111 132.719573,114.852 131.82965,120.095 C127.268796,145.24 104.464526,164.5 76.9881611,164.5 C49.5117965,164.5 26.7075263,145.24 22.1466723,120.095 C21.2567496,114.852 16.6958955,111 11.2451187,111 C4.45945784,111 -0.880078594,116.778 0.121084488,123.198 C5.57186127,155.298 32.2695435,180.443 65.8641269,185.044 L65.8641269,207.3 C65.8641269,213.185 70.8699423,218 76.9881611,218 C83.10638,218 88.1121954,213.185 88.1121954,207.3 L88.1121954,185.044 C121.706779,180.443 148.404461,155.298 153.855238,123.198 C154.967641,116.778 149.516864,111 142.731204,111 Z",
"id": "el_uzZNtK32Zi",
"fillRule": "nonzero"
},
"style": {
fill: '#0B6AFF'
}
}), h("path", {
"attrs": {
"d": "M76.9864699,147.789474 C98.090352,147.789474 115.126016,131.286316 115.126016,110.842105 L115.126016,36.9473684 C115.126016,16.5031579 98.090352,0 76.9864699,0 C55.8825877,0 38.8469239,16.5031579 38.8469239,36.9473684 L38.8469239,110.842105 C38.8469239,131.286316 55.8825877,147.789474 76.9864699,147.789474 Z",
"id": "el_EYKQ2N9Kgy",
"fillRule": "nonzero"
}
}), h("g", {
"attrs": {
"id": "el_6SDP2LAgKC"
}
}, [h("mask", {
"attrs": {
"id": "mask-2",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-1"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el_-Vm65Ltfy7",
"fillRule": "nonzero",
"mask": "url(#mask-2)"
}
}), h("rect", {
"attrs": {
"id": "el_q04iZcSim4",
"mask": "url(#mask-2)",
"x": "0.279",
"width": "77",
"height": "130"
}
})]), h("g", {
"attrs": {
"id": "el_6WKby7wXqV"
}
}, [h("mask", {
"attrs": {
"id": "mask-4",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-3"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el_9bggsfQOtU",
"fillRule": "nonzero",
"mask": "url(#mask-4)"
}
}), h("rect", {
"attrs": {
"id": "el_NKxqi9eIym",
"mask": "url(#mask-4)",
"x": "0.279",
"width": "77",
"height": "115"
}
})]), h("g", {
"attrs": {
"id": "el_Wi-my975tM"
}
}, [h("mask", {
"attrs": {
"id": "mask-6",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-5"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el_zclQ34fvf7",
"fillRule": "nonzero",
"mask": "url(#mask-6)"
}
}), h("rect", {
"attrs": {
"id": "el_1OsvRT8HkeZ",
"mask": "url(#mask-6)",
"x": "0.279",
"width": "77",
"height": "100"
}
})]), h("g", {
"attrs": {
"id": "el_DkfFFTaFxy8"
}
}, [h("mask", {
"attrs": {
"id": "mask-8",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-7"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el_aa9sjx4H0vA",
"fillRule": "nonzero",
"mask": "url(#mask-8)"
}
}), h("rect", {
"attrs": {
"id": "el_tea114vWg0J",
"mask": "url(#mask-8)",
"x": "0.279",
"width": "77",
"height": "85"
}
})]), h("g", {
"attrs": {
"id": "el_34IgwiMB5rf"
}
}, [h("mask", {
"attrs": {
"id": "mask-10",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-9"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el_z5u6RAFhx7d",
"fillRule": "nonzero",
"mask": "url(#mask-10)"
}
}), h("rect", {
"attrs": {
"id": "el_7nfuWmA5Uhy",
"mask": "url(#mask-10)",
"x": "0.279",
"width": "77",
"height": "70"
}
})]), h("g", {
"attrs": {
"id": "el_DeebuCsPTGA"
}
}, [h("mask", {
"attrs": {
"id": "mask-12",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-11"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el__ZcqlS20zcw",
"fillRule": "nonzero",
"mask": "url(#mask-12)"
}
}), h("rect", {
"attrs": {
"id": "el_8DnEQnD7VWV",
"mask": "url(#mask-12)",
"x": "0.279",
"width": "77",
"height": "55"
}
})]), h("g", {
"attrs": {
"id": "el_ZOjjrPTvyrv"
}
}, [h("mask", {
"attrs": {
"id": "mask-14",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-13"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el_FYYKCI_u24e",
"fillRule": "nonzero",
"mask": "url(#mask-14)"
}
}), h("rect", {
"attrs": {
"id": "el_XZty4MnTp5Y",
"mask": "url(#mask-14)",
"x": "0.279",
"width": "77",
"height": "40"
}
})]), h("g", {
"attrs": {
"id": "el_2FATegVmf0K"
}
}, [h("mask", {
"attrs": {
"id": "mask-16",
"fill": "#fff"
}
}, [h("use", {
"attrs": {
"xlink:href": "#path-15"
}
})]), h("path", {
"attrs": {
"d": "M38.779092,147.789474 C60.0824253,147.789474 77.279092,131.286316 77.279092,110.842105 L77.279092,36.9473684 C77.279092,16.5031579 60.0824253,0 38.779092,0 C17.4757586,0 0.279091964,16.5031579 0.279091964,36.9473684 L0.279091964,110.842105 C0.279091964,131.286316 17.4757586,147.789474 38.779092,147.789474 Z",
"id": "el_RMT1KUfbdF8",
"fillRule": "nonzero",
"mask": "url(#mask-16)"
}
}), h("rect", {
"attrs": {
"id": "el_RgLcovvFiO1",
"mask": "url(#mask-16)",
"x": "0.279",
"width": "77",
"height": "25"
}
})])])])]);
}
};
var _templateObject$9;
styled.injectGlobal(_templateObject$9 || (_templateObject$9 = _taggedTemplateLiteralLoose(["\n\t#el_X81iT9kZYo {\n\t\tstroke: none;\n\t\tstroke-width: 1;\n\t\tfill: none;\n\t}\n\t#el_gMpyalCphp {\n\t\t-webkit-transform: translate(163px, 131px);\n\t\ttransform: translate(163px, 131px);\n\t}\n\t#el_c7H-3u-D4l {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_qhFcdAAFwo {\n\t\tfill: #d8d8d8;\n\t}\n\t#el_M8X8g37WOI {\n\t\tstroke: #e83137;\n\t\tstroke-width: 21;\n\t}\n"])));
var MuteSvg = {
name: 'MuteSvg',
props: ['className', 'handleMicClick'],
render: function render() {
var h = arguments[0];
return h("svg", {
"style": {
transform: 'scale(1.5)'
},
"attrs": {
"viewBox": "0 0 480 480",
"xmlns": "http://www.w3.org/2000/svg",
"id": "el_D1rEpH2zj",
"width": 28,
"height": 28,
"className": this.$props.className
},
"on": {
"click": this.$props.handleMicClick
}
}, [h("g", {
"attrs": {
"id": "el_X81iT9kZYo",
"fillRule": "evenodd"
}
}, [h("g", {
"attrs": {
"id": "el_gMpyalCphp"
}
}, [h("path", {
"attrs": {
"d": "M142.731204,111 C137.280427,111 132.719573,114.852 131.82965,120.095 C127.268796,145.24 104.464526,164.5 76.9881611,164.5 C49.5117965,164.5 26.7075263,145.24 22.1466723,120.095 C21.2567496,114.852 16.6958955,111 11.2451187,111 C4.45945784,111 -0.880078594,116.778 0.121084488,123.198 C5.57186127,155.298 32.2695435,180.443 65.8641269,185.044 L65.8641269,207.3 C65.8641269,213.185 70.8699423,218 76.9881611,218 C83.10638,218 88.1121954,213.185 88.1121954,207.3 L88.1121954,185.044 C121.706779,180.443 148.404461,155.298 153.855238,123.198 C154.967641,116.778 149.516864,111 142.731204,111 Z",
"id": "el_c7H-3u-D4l",
"fillRule": "nonzero"
},
"style": {
fill: '#595959'
}
}), h("path", {
"attrs": {
"d": "M76.9864699,147.789474 C98.090352,147.789474 115.126016,131.286316 115.126016,110.842105 L115.126016,36.9473684 C115.126016,16.5031579 98.090352,-2.84217094e-14 76.9864699,-2.84217094e-14 C55.8825877,-2.84217094e-14 38.8469239,16.5031579 38.8469239,36.9473684 L38.8469239,110.842105 C38.8469239,131.286316 55.8825877,147.789474 76.9864699,147.789474 Z",
"id": "el_qhFcdAAFwo",
"fillRule": "nonzero"
},
"style": {
fill: '#595959'
}
}), h("path", {
"attrs": {
"d": "M11.5,206.5 L142.5,12.5",
"id": "el_M8X8g37WOI",
"strokeLinecap": "round",
"strokeLinejoin": "round"
}
})])])]);
}
};
var _templateObject$a;
styled.injectGlobal(_templateObject$a || (_templateObject$a = _taggedTemplateLiteralLoose(["\n\t#el_TvxDfTAtKp {\n\t\tstroke: none;\n\t\tstroke-width: 1;\n\t\tfill: none;\n\t}\n\t#el_D93PK3GbmJ {\n\t\t-webkit-transform: translate(163px, 131px);\n\t\ttransform: translate(163px, 131px);\n\t\tfill: #d8d8d8;\n\t}\n"])));
var MicSvg = {
name: 'MicSvg',
props: ['className', 'handleMicClick'],
render: function render() {
var h = arguments[0];
return h("svg", {
"attrs": {
"viewBox": "0 0 480 480",
"xmlns": "http://www.w3.org/2000/svg",
"id": "el_xS0FRzQjJ",
"width": 28,
"height": 28,
"className": this.$props.className
},
"style": {
transform: 'scale(1.5)'
},
"on": {
"click": this.$props.handleMicClick
}
}, [h("g", {
"attrs": {
"id": "el_TvxDfTAtKp",
"fillRule": "evenodd"
}
}, [h("g", {
"attrs": {
"id": "el_D93PK3GbmJ",
"fillRule": "nonzero"
},
"style": {
fill: '#595959'
}
}, [h("path", {
"attrs": {
"d": "M142.731204,111 C137.280427,111 132.719573,114.852 131.82965,120.095 C127.268796,145.24 104.464526,164.5 76.9881611,164.5 C49.5117965,164.5 26.7075263,145.24 22.1466723,120.095 C21.2567496,114.852 16.6958955,111 11.2451187,111 C4.45945784,111 -0.880078594,116.778 0.121084488,123.198 C5.57186127,155.298 32.2695435,180.443 65.8641269,185.044 L65.8641269,207.3 C65.8641269,213.185 70.8699423,218 76.9881611,218 C83.10638,218 88.1121954,213.185 88.1121954,207.3 L88.1121954,185.044 C121.706779,180.443 148.404461,155.298 153.855238,123.198 C154.967641,116.778 149.516864,111 142.731204,111 Z",
"id": "el_uly3EwA2O3"
}
}), h("path", {
"attrs": {
"d": "M76.9864699,147.789474 C98.090352,147.789474 115.126016,131.286316 115.126016,110.842105 L115.126016,36.9473684 C115.126016,16.5031579 98.090352,-2.84217094e-14 76.9864699,-2.84217094e-14 C55.8825877,-2.84217094e-14 38.8469239,16.5031579 38.8469239,36.9473684 L38.8469239,110.842105 C38.8469239,131.286316 55.8825877,147.789474 76.9864699,147.789474 Z",
"id": "el_tnDbR4ytu4"
}
})])])]);
}
};
var STATUS = {
inactive: 'INACTIVE',
stopped: 'STOPPED',
active: 'ACTIVE',
denied: 'DENIED'
};
var Icon = {
props: ['status', 'handleMicClick', 'className', 'applyClearStyle'],
render: function render() {
var h = arguments[0];
var _this$$props = this.$props,
status = _this$$props.status,
className = _this$$props.className,
handleMicClick = _this$$props.handleMicClick;
switch (status) {
case STATUS.active:
return h(ListenSvg, {
"attrs": {
"className": className,
"handleMicClick": handleMicClick
}
});
case STATUS.stopped:
case STATUS.denied:
return h(MuteSvg, {
"attrs": {
"className": className,
"handleMicClick": handleMicClick
}
});
default:
return h(MicSvg, {
"attrs": {
"className": className,
"handleMicClick": handleMicClick
}
});
} // switch (status) {
// case STATUS.active:
// url = "https://media.giphy.com/media/ZZr4lCvpuMP58PXzY1/giphy.gif";
// break;
// case STATUS.stopped:
// break;
// case STATUS.denied:
// url =
// "https://cdn3.iconfinder.com/data/icons/glypho-music-and-sound/64/microphone-off-512.png";
// break;
// default:
// url =
// "https://cdn3.iconfinder.com/data/icons/glypho-music-and-sound/64/microphone-512.png";
// }
// return (
// <img
// class={className}
// onClick={handleMicClick}
// src={url}
// style={{ width: "18px" }}
// />
// );
}
};
var Mic = {
props: ['iconPosition', 'handleMicClick', 'className', 'status', 'showIcon', 'applyClearStyle'],
render: function render() {
var h = arguments[0];
var _this$$props2 = this.$props,
className = _this$$props2.className,
handleMicClick = _this$$props2.handleMicClick,
status = _this$$props2.status;
return h(IconWrapper, [h(Icon, {
"attrs": {
"className": className,
"handleMicClick": handleMicClick,
"status": status
}
})]);
}
};
var SearchIcon = {
props: ['showIcon', 'icon'],
render: function render() {
var h = arguments[0];
var _this$$props = this.$props,
showIcon = _this$$props.showIcon,
icon = _this$$props.icon;
if (showIcon) {
return icon || h(SearchSvg);
}
return null;
}
};
var Icons = {
props: ['clearValue', 'iconPosition', 'showClear', 'clearIcon', 'currentValue', 'handleSearchIconClick', 'showIcon', 'icon', 'enableVoiceSearch', 'innerClass', 'getMicInstance', 'micStatus', 'handleMicClick'],
render: function render() {
var h = arguments[0];
var _this$$props2 = this.$props,
clearValue = _this$$props2.clearValue,
iconPosition = _this$$props2.iconPosition,
showClear = _this$$props2.showClear,
clearIcon = _this$$props2.clearIcon,
currentValue = _this$$props2.currentValue,
handleSearchIconClick = _this$$props2.handleSearchIconClick,
showIcon = _this$$props2.showIcon,
icon = _this$$props2.icon,
enableVoiceSearch = _this$$props2.enableVoiceSearch,
innerClass = _this$$props2.innerClass,
micStatus = _this$$props2.micStatus,
handleMicClick = _this$$props2.handleMicClick;
return h("div", [h(IconGroup, {
"attrs": {
"groupPosition": "right",
"positionType": "absolute"
}
}, [currentValue && showClear && h(IconWrapper, {
"on": {
"click": clearValue
},
"attrs": {
"showIcon": showIcon,
"isClearIcon": true
}
}, [clearIcon || h(CancelSvg)]), enableVoiceSearch && h(Mic, {
"attrs": {
"className": getClassName(innerClass, 'mic') || null,
"status": micStatus,
"handleMicClick": handleMicClick
}
}), iconPosition === 'right' && h(IconWrapper, {
"attrs": {
"showIcon": showIcon,
"iconPosition": iconPosition
},
"on": {
"click": handleSearchIconClick
}
}, [h(SearchIcon, {
"attrs": {
"showIcon": showIcon,
"icon": icon
}
})])]), h(IconGroup, {
"attrs": {
"groupPosition": "left",
"positionType": "absolute"
}
}, [iconPosition === 'left' && h(IconWrapper, {
"attrs": {
"showIcon": showIcon,
"iconPosition": iconPosition
},
"on": {
"click": handleSearchIconClick
}
}, [h(SearchIcon, {
"attrs": {
"showIcon": showIcon,
"icon": icon
}
})])])]);
}
};
// A map of causes leading to changes in components
var ENTER_PRESS = 'ENTER_PRESS';
var SUGGESTION_SELECT = 'SUGGESTION_SELECT';
var CLEAR_VALUE = 'CLEAR_VALUE';
var SEARCH_ICON_CLICK = 'SEARCH_ICON_CLICK';
var causes = {
ENTER_PRESS: ENTER_PRESS,
SUGGESTION_SELECT: SUGGESTION_SELECT,
CLEAR_VALUE: CLEAR_VALUE,
SEARCH_ICON_CLICK: SEARCH_ICON_CLICK
};
var CustomSvg = {
name: 'CustomSvg',
props: {
className: String,
icon: Function,
type: String
},
data: function data() {
return {
customIcon: this.$props.icon && typeof this.$props.icon === 'function' ? this.$props.icon() : null
};
},
render: function render() {
var h = arguments[0];
if (this.customIcon) {
return h("div", {
"class": this.$props.className
}, [this.customIcon]);
}
if (this.$props.type === 'recent-search-icon') {
return h("svg", {
"attrs": {
"xmlns": "http://www.w3.org/2000/svg",
"alt": "Recent Searches",
"height": "20",
"width": "20",
"viewBox": "0 0 24 24"
},
"style": {
fill: '#707070'
},
"class": this.$props.className
}, [h("path", {
"attrs": {
"d": "M0 0h24v24H0z",
"fill": "none"
}
}), h("path", {
"attrs": {
"d": "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z"
}
})]);
}
if (this.$props.type === 'promoted-search-icon') {
return h("svg", {
"attrs": {
"xmlns": "http://www.w3.org/2000/svg",
"width": "20",
"alt": "promoted search",
"height": "20",
"viewBox": "0 0 24 24"
},
"class": this.$props.className,
"style": {
fill: '#707070',
transform: 'scale(0.9) translateY(-2px)'
}
}, [h("path", {
"attrs": {
"d": "M12 .587l3.668 7.568 8.332 1.151-6.064 5.828 1.48 8.279-7.416-3.967-7.417 3.967 1.481-8.279-6.064-5.828 8.332-1.151z"
}
})]);
}
if (this.$props.type === 'popular-search-icon') {
return h("svg", {
"attrs": {
"xmlns": "http://www.w3.org/2000/svg",
"alt": "Popular Searches",
"height": "20",
"width": "20",
"viewBox": "0 0 24 24"
},
"style": {
fill: '#707070'
},
"class": this.$props.className
}, [h("path", {
"attrs": {
"d": "M0 0h24v24H0z",
"fill": "none"
}
}), h("path", {
"attrs": {
"d": "M16 6l2.29 2.29-4.88 4.88-4-4L2 16.59 3.41 18l6-6 4 4 6.3-6.29L22 12V6z"
}
})]);
}
return h(SearchSvg, _mergeJSXProps([{}, {
"props": {
style: {
position: 'relative',
fill: '#707070',
left: '3px',
marginRight: '8px'
}
}
}]));
}
};
var _templateObject$b;
var AutofillSvgIcon = styled__default('button')(_templateObject$b || (_templateObject$b = _taggedTemplateLiteralLoose(["\n display: flex;\n margin-left: auto;\n position: relative;\n right: -3px;\n border: none;\n outline: none;\n background: transparent;\n padding: 0;\n z-index: 111;\n\n svg {\n cursor: pointer;\n fill: #707070;\n height: 20px;\n }\n\n &:hover {\n svg {\n fill: #1c1a1a;\n }\n }\n"])));
var AutofillSvg = {
functional: true,
render: function render(h, props) {
var _props$data, _props$data$on;
return h(AutofillSvgIcon, {
"on": {
"click": (_props$data = props.data) == null ? void 0 : (_props$data$on = _props$data.on) == null ? void 0 : _props$data$on.click
}
}, [h("svg", {
"attrs": {
"viewBox": "0 0 24 24"
}
}, [h("path", {
"attrs": {
"d": "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"
}
})])]);
}
};
var _templateObject$c, _templateObject2$3;
var primary = function primary() {
return styled.css(_templateObject$c || (_templateObject$c = _taggedTemplateLiteralLoose(["\n background-color: #0b6aff;\n color: #fff;\n\n &:hover {\n background-color: #0b6aff;\n filter: brightness(0.9);\n }\n\n &:active {\n background-color: #0b6aff;\n filter: brightness(1.1);\n }\n"])));
};
var Button = styled__default('a')(_templateObject2$3 || (_templateObject2$3 = _taggedTemplateLiteralLoose(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n border-radius: 3px;\n border: 1px solid transparent;\n min-height: 30px;\n word-wrap: break-word;\n padding: 5px 12px;\n line-height: 1.2rem;\n background-color: #eee;\n color: #000;\n cursor: pointer;\n user-select: none;\n transition: all 0.3s ease;\n font-weight: 500;\n\n &:hover,\n &:focus {\n background-color: #ccc;\n }\n\n &:focus {\n outline: 0;\n border-color: rgba(#0b6aff, 0.6);\n box-shadow: 0 0 0 2px rgba(#0b6aff, 0.3);\n }\n\n ", ";\n\n &.enter-btn {\n border-top-left-radius: 0px;\n border-bottom-left-radius: 0px;\n }\n"])), function (props) {
return props.primary ? primary : null;
});
var _excluded = ["value", "isOpen", "category"];
var SearchBox = {
name: 'search-box',
inject: ['searchbase'],
props: {
// common props for search component and search box
index: VueTypes.string,
// search component props
url: VueTypes.string,
credentials: VueTypes.string,
headers: VueTypes.object,
appbaseConfig: types.appbaseConfig,
transformRequest: VueTypes.func,
transformResponse: VueTypes.func,
beforeValueChange: VueTypes.func,
enablePopularSuggestions: VueTypes.bool,
maxPopularSuggestions: VueTypes.number,
maxRecentSearches: VueTypes.number,
enablePredictiveSuggestions: VueTypes.bool,
enableRecentSearches: VueTypes.bool,
enableRecentSuggestions: VueTypes.bool,
clearOnQueryChange: VueTypes.bool,
showDistinctSuggestions: types.showDistinctSuggestions,
URLParams: VueTypes.bool,
// RS API properties
id: VueTypes.string.isRequired,
value: VueTypes.string.def(undefined),
type: types.queryTypes,
react: types.reactType,
queryFormat: types.queryFormat,
dataField: types.dataField,
categoryField: VueTypes.string,
categoryValue: VueTypes.string,
nestedField: VueTypes.string,
from: VueTypes.number,
size: VueTypes.number,
sortBy: types.sortType,
aggregationField: VueTypes.string,
aggregationSize: VueTypes.number,
after: VueTypes.object,
includeNullValues: VueTypes.bool,
includeFields: types.sourceFields,
excludeFields: types.sourceFields,
fuzziness: types.fuzziness,
searchOperators: VueTypes.bool,
highlight: VueTypes.bool,
highlightField: VueTypes.string,
customHighlight: VueTypes.object,
interval: VueTypes.number,
aggregations: VueTypes.arrayOf(VueTypes.string),
missingLabel: VueTypes.string,
showMissing: VueTypes.bool,
defaultQuery: VueTypes.func,
customQuery: VueTypes.func,
enableSynonyms: VueTypes.bool,
selectAllLabel: VueTypes.string,
pagination: VueTypes.bool,
queryString: VueTypes.bool,
distinctField: VueTypes.string,
distinctFieldConfig: VueTypes.object,
// subscribe on changes,
subscribeTo: VueTypes.arrayOf(VueTypes.string),
triggerQueryOnInit: VueTypes.bool.def(true),
// searchbox specific
title: types.title,
defaultValue: types.defaultValue,
placeholder: types.placeholder,
showIcon: types.showIcon,
iconPosition: types.iconPosition,
icon: types.icon,
showClear: types.showClear,
clearIcon: types.clearIcon,
autosuggest: types.autosuggest,
strictSelection: types.strictSelection,
defaultSuggestions: types.defaultSuggestions,
recentSearches: types.defaultSuggestions,
debounce: types.debounce,
showVoiceSearch: types.showVoiceSearch,
render: types.render,
renderError: types.renderError,
renderNoSuggestion: types.renderNoSuggestion,
renderMic: types.renderMic,
innerClass: types.innerClass,
className: types.className,
loader: types.loader,
autoFocus: types.autoFocus,
// Internal props from search component
loading: VueTypes.bool,
error: VueTypes.any,
micStatus: VueTypes.string,
instanceValue: VueTypes.string,
//
focusShortcuts: VueTypes.focusShortcuts,
addonBefore: VueTypes.any,
addonAfter: VueTypes.any,
expandSuggestionsContainer: types.expandSuggestionsContainer,
recentSuggestionsConfig: VueTypes.object,
popularSuggestionsConfig: VueTypes.object,
maxPredictedWords: VueTypes.number,
urlField: VueTypes.string,
rankFeature: VueTypes.object,
applyStopwords: VueTypes.bool,
stopwords: VueTypes.arrayOf(VueTypes.string),
mongodb: VueTypes.object,
autocompleteField: types.dataField,
highlightConfig: VueTypes.object,
enterButton: VueTypes.bool.def(false),
renderEnterButton: VueTypes.any
},
data: function data() {
this.state = {
isOpen: false
};
return _extends({}, this.state, {
hotkeys: undefined,
shouldUtilizeHotkeysLib: false
});
},
beforeMount: function beforeMount() {
var focusShortcuts = this.$props.focusShortcuts; // dynamically import hotkey-js
if (!isEmpty(focusShortcuts)) {
this.shouldUtilizeHotkeysLib = isHotkeyCombinationUsed(focusShortcuts) || isModifierKeyUsed(focusShortcuts);
if (this.shouldUtilizeHotkeysLib) {
try {
// eslint-disable-next-line
this.hotkeys = require('hotkeys-js')["default"];
} catch (error) {
// eslint-disable-next-line
console.warn('Warning(SearchBox): The `hotkeys-js` library seems to be missing, it is required when using key combinations( eg: `ctrl+a`) in focusShortcuts prop.');
}
}
}
},
mounted: function mounted() {
document.addEventListener('keydown', this.onKeyDown);
this.registerHotkeysListener();
if (this.aggregationField) {
console.warn('Warning(SearchBox): The `aggregationField` prop has been marked as deprecated, please use the `distinctField` prop instead.');
}
},
destroyed: function destroyed() {
document.removeEventListener('keydown', this.onKeyDown);
},
computed: {
hasCustomRenderer: function hasCustomRenderer$1() {
return hasCustomRenderer(this);
},
stats: function stats() {
var results = this.$props.results;
var total = results.numberOfResults;
var time = results.time,
hidden = results.hidden,
promotedData = results.promotedData;
var size = this.$props.size || 10;
return _extends({
numberOfResults: total
}, size > 0 ? {
numberOfPages: Math.ceil(total / size)
} : null, {
time: time,
hidden: hidden,
promoted: promotedData && promotedData.length
});
}
},
methods: {
getComponentInstance: function getComponentInstance() {
var id = this.$props.id;
return this.searchbase.getComponent(id);
},
getSuggestionsList: function getSuggestionsList() {
var _this$getComponentIns, _this$getComponentIns2;
var _this$$props = this.$props,
defaultSuggestions = _this$$props.defaultSuggestions,
instanceValue = _this$$props.instanceValue;
if (!instanceValue && defaultSuggestions) {
return defaultSuggestions;
}
var suggestions = this.getComponentInstance().mongodb ? this.getComponentInstance().suggestions : (_this$getComponentIns = this.getComponentInstance()) == null ? void 0 : (_this$getComponentIns2 = _this$getComponentIns.results) == null ? void 0 : _this$getComponentIns2.data;
return suggestions != null ? suggestions : [];
},
_applySetter: function _applySetter(prev, next, setterFunc) {
if (!equals(prev, next)) {
var component = this.getComponentInstance();
component[setterFunc](next);
}
},
triggerClickAnalytics: function triggerClickAnalytics(clickPosition, isSuggestion, value) {
if (isSuggestion === void 0) {
isSuggestion = true;
}
var component = this.getComponentInstance();
if (!component) return;
if (component && component.appbaseSettings && component.appbaseSettings.recordAnalytics) {
var _component$recordClic;
component.recordClick((_component$recordClic = {}, _component$recordClic[value] = clickPosition, _component$recordClic), isSuggestion);
}
},
onValueSelectedHandler: function onValueSelectedHandler(currentValue) {
if (currentValue === void 0) {
currentValue = this.$props.instanceValue;
}
for (var _len = arguments.length, cause = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
cause[_key - 1] = arguments[_key];
}
this.$emit.apply(this, ['valueSelected', currentValue].concat(cause));
},
onInputChange: function onInputChange(event) {
this.setValue({
value: event.target.value,
event: event
});
},
onSuggestionSelected: function onSuggestionSelected(suggestion) {
if (!suggestion) {
var componentInstance = this.getComponentInstance();
if (componentInstance) {
componentInstance.setCategoryValue('', {
triggerDefaultQuery: false,
triggerCustomQuery: false,
stateChanges: false
});
componentInstance.setValue('', {
triggerDefaultQuery: true,
triggerCustomQuery: true,
stateChanges: true
});
return;
}
}
if (suggestion.url // check valid url: https://stackoverflow.com/a/43467144/10822996
&& new RegExp('^(https?:\\/\\/)?' // protocol
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' // domain name
+ '((\\d{1,3}\\.){3}\\d{1,3}))' // OR ip (v4) address
+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' // port and path
+ '(\\?[;&a-z\\d%_.~+=-]*)?' // query string
+ '(\\#[-a-z\\d_]*)?$', 'i').test(suggestion.url)) {
window.open(suggestion.url);
return;
}
var suggestionValue = suggestion.value;
this.setValue({
value: suggestionValue,
isOpen: false,
triggerCustomQuery: true,
category: suggestion._category
});
this.triggerClickAnalytics(suggestion && suggestion._click_id, true, suggestion.source && suggestion.source._id);
this.onValueSelectedHandler(suggestion.value, causes.SUGGESTION_SELECT, suggestion.source);
},
onSelectArrowClick: function onSelectArrowClick(suggestion) {
this.setValue({
value: suggestion._category ? suggestion.label : suggestion.value,
isOpen: true,
triggerDefaultQuery: true
});
},
triggerDefaultQuery: function triggerDefaultQuery() {
var componentInstance = this.getComponentInstance();
if (componentInstance) {
componentInstance.triggerDefaultQuery();
}
},
triggerCustomQuery: function triggerCustomQuery() {
var componentInstance = this.getComponentInstance();
if (componentInstance) {
componentInstance.triggerCustomQuery();
}
},
isControlled: function isControlled() {
if (this.$props.value !== undefined && this.$listeners.change) {
return true;
}
return false;
},
setValue: function setValue(_ref) {
var value = _ref.value,
_ref$isOpen = _ref.isOpen,
isOpen = _ref$isOpen === void 0 ? true : _ref$isOpen,
_ref$category = _ref.category,
category = _ref$category === void 0 ? undefined : _ref$category,
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
var debounce$1 = this.$props.debounce;
this.isOpen = isOpen;
var componentInstance = this.getComponentInstance();
if (!value && this.autosuggest && rest.cause !== causes.CLEAR_VALUE) {
this.triggerDefaultQuery();
}
componentInstance.setCategoryValue(category, {
triggerDefaultQuery: false,
triggerCustomQuery: false
});
if (this.isControlled()) {
componentInstance.setValue(value, {
triggerDefaultQuery: false,
triggerCustomQuery: false
});
this.$emit('change', value, componentInstance, rest.event);
} else if (debounce$1 > 0) {
componentInstance.setValue(value, {
triggerDefaultQuery: rest.cause === causes.CLEAR_VALUE,
triggerCustomQuery: false,
stateChanges: true
});
if (this.autosuggest) {
// Clear results for empty query
if (!value) {
componentInstance.clearResults();
}
debounce(this.triggerDefaultQuery, debounce$1);
} else if (!this.enterButton) {
debounce(this.triggerCustomQuery, debounce$1);
}
if (rest.triggerCustomQuery) {
debounce(this.triggerCustomQuery, debounce$1);
}
} else {
componentInstance.setValue(value, {
triggerCustomQuery: rest.triggerCustomQuery,
triggerDefaultQuery: this.autosuggest,
stateChanges: true
});
if (!this.autosuggest && !this.enterButton) {
this.triggerCustomQuery();
}
}
},
handleFocus: function handleFocus(event) {
this.isOpen = true;
this.withTriggerQuery('focus', event);
},
handleStateChange: function handleStateChange(changes) {
var isOpen = changes.isOpen;
this.isOpen = isOpen;
},
handleKeyDown: function handleKeyDown(event, highlightedIndex) {
if (highlightedIndex === void 0) {
highlightedIndex = null;
}
// if a suggestion was selected, delegate the handling
// to suggestion handler
if (event.key === 'Enter') {
if (this.$props.autosuggest === false) {
this.enterButtonOnClick();
} else if (highlightedIndex === null) {
this.setValue({
value: event.target.value,
isOpen: false,
triggerCustomQuery: true
});
this.onValueSelectedHandler(event.target.value, causes.ENTER_PRESS);
}
}
this.withTriggerQuery('keyDown', event);
},
handleMicClick: function handleMicClick() {
var componentInstance = this.getComponentInstance();
componentInstance.onMicClick(null);
},
renderInputAddonBefore: function renderInputAddonBefore() {
var h = this.$createElement;
var addonBefore = this.$scopedSlots.addonBefore;
if (addonBefore) {
return h(InputAddon, [addonBefore()]);
}
return null;
},
renderInputAddonAfter: function renderInputAddonAfter() {
var h = this.$createElement;
var addonAfter = this.$scopedSlots.addonAfter;
if (addonAfter) {
return h(InputAddon, [addonAfter()]);
}
return null;
},
enterButtonOnClick: function enterButtonOnClick() {
this.isOpen = false;
this.triggerCustomQuery();
},
renderEnterButtonElement: function renderEnterButtonElement() {
var _this = this;
var h = this.$createElement;
var _this$$props2 = this.$props,
enterButton = _this$$props2.enterButton,
innerClass = _this$$props2.innerClass;
var renderEnterButton = this.$scopedSlots.renderEnterButton;
if (enterButton) {
var getEnterButtonMarkup = function getEnterButtonMarkup() {
if (renderEnterButton) {
return renderEnterButton(_this.enterButtonOnClick);
}
return h(Button, {
"class": "enter-btn " + getClassName(innerClass, 'enter-button'),
"attrs": {
"primary": true
},
"on": {
"click": _this.enterButtonOnClick
}
}, ["Search"]);
};
return h("div", {
"class": "enter-button-wrapper"
}, [getEnterButtonMarkup()]);
}
return null;
},
renderIcons: function renderIcons() {
var h = this.$createElement;
var _this$$props3 = this.$props,
iconPosition = _this$$props3.iconPosition,
showClear = _this$$props3.showClear,
clearIcon = _this$$props3.clearIcon,
innerClass = _this$$props3.innerClass,
showVoiceSearch = _this$$props3.showVoiceSearch,
icon = _this$$props3.icon,
showIcon = _this$$props3.showIcon;
var _this$$props4 = this.$props,
instanceValue = _this$$props4.instanceValue,
micStatus = _this$$props4.micStatus;
return h(Icons, {
"attrs": {
"clearValue": this.clearValue,
"iconPosition": iconPosition,
"showClear": showClear,
"clearIcon": clearIcon,
"currentValue": instanceValue,
"handleSearchIconClick": this.handleSearchIconClick,
"icon": icon,
"showIcon": showIcon,
"innerClass": innerClass,
"enableVoiceSearch": showVoiceSearch,
"micStatus": micStatus,
"handleMicClick": this.handleMicClick
}
});
},
renderNoSuggestionComponent: function renderNoSuggestionComponent() {
var h = this.$createElement;
var _this$$props5 = this.$props,
innerClass = _this$$props5.innerClass,
renderError = _this$$props5.renderError,
loading = _this$$props5.loading,
error = _this$$props5.error,
instanceValue = _this$$props5.instanceValue;
var isOpen = this.$data.isOpen;
var suggestionsList = this.getSuggestionsList();
var renderNoSuggestion = this.$scopedSlots.renderNoSuggestion || this.$props.renderNoSuggestion;
if (renderNoSuggestion && isOpen && !suggestionsList.length && !loading && instanceValue && !(renderError && error)) {
return h("div", {
"class": "no-suggestions " + getClassName(innerClass, 'noSuggestion')
}, [typeof renderNoSuggestion === 'function' ? renderNoSuggestion(instanceValue) : renderNoSuggestion]);
}
return null;
},
renderErrorComponent: function renderErrorComponent() {
var h = this.$createElement;
var _this$$props6 = this.$props,
innerClass = _this$$props6.innerClass,
error = _this$$props6.error,
loading = _this$$props6.loading,
instanceValue = _this$$props6.instanceValue;
var renderError = this.$scopedSlots.renderError || this.$props.renderError;
if (error && renderError && instanceValue && !loading) {
return h("div", {
"class": getClassName(innerClass, 'error')
}, [typeof renderError === 'function' ? renderError(error) : renderError]);
}
return null;
},
clearValue: function clearValue() {
this.setValue({
value: '',
isOpen: false,
triggerCustomQuery: true,
cause: causes.CLEAR_VALUE
});
this.onValueSelectedHandler(null, causes.CLEAR_VALUE);
},
handleSearchIconClick: function handleSearchIconClick() {
var instanceValue = this.$props.instanceValue;
if (instanceValue.trim()) {
this.setValue({
value: instanceValue,
isOpen: false,
triggerCustomQuery: true
});
this.onValueSelectedHandler(instanceValue, causes.SEARCH_ICON_CLICK);
}
},
getBackgroundColor: function getBackgroundColor(highlightedIndex, index) {
return highlightedIndex === index ? '#eee' : '#fff';
},
getComponent: function getComponent$1(downshiftProps) {
if (downshiftProps === void 0) {
downshiftProps = {};
}
var _this$$props7 = this.$props,
instanceValue = _this$$props7.instanceValue,
loading = _this$$props7.loading,
error = _this$$props7.error,
results = _this$$props7.results;
var suggestionsList = this.getSuggestionsList();
var data = {
loading: loading,
error: error,
value: instanceValue,
downshiftProps: downshiftProps,
data: suggestionsList,
promotedData: results.promotedData,
customData: results.customData,
resultStats: this.stats,
rawData: results.rawData,
triggerClickAnalytics: this.triggerClickAnalytics
};
return getComponent(data, this);
},
focusSearchBox: function focusSearchBox(event) {
var elt = event.target || event.srcElement;
var tagName = elt.tagName;
if (elt.isContentEditable || tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA') {
// already in an input
return;
}
this.$refs.searchInputField.focus();
},
onKeyDown: function onKeyDown(event) {
var _this$$props$focusSho = this.$props.focusShortcuts,
focusShortcuts = _this$$props$focusSho === void 0 ? ['/'] : _this$$props$focusSho;
if (isEmpty(focusShortcuts) || this.shouldUtilizeHotkeysLib && typeof this.hotkeys === 'function') {
return;
}
var shortcuts = focusShortcuts.map(function (key) {
if (typeof key === 'string') {
return isNumeric(key) ? parseInt(key, 10) : key.toUpperCase().charCodeAt(0);
}
return key;
}); // the below algebraic expression is used to get the correct ascii code out of the e.which || e.keycode returned value
// since the keyboards doesn't understand ascii but scan codes and they differ for certain keys such as '/'
// stackoverflow ref: https://stackoverflow.com/a/29811987/10822996
var which = event.which || event.keyCode;
var chrCode = which - 48 * Math.floor(which / 48);
if (shortcuts.indexOf(which >= 96 ? chrCode : which) === -1) {
// not the right shortcut
return;
}
this.focusSearchBox(event);
event.stopPropagation();
event.preventDefault();
},
withTriggerQuery: function withTriggerQuery(eventName, event) {
this.$emit(eventName, this.getComponentInstance(), event);
},
registerHotkeysListener: function registerHotkeysListener() {
var _this2 = this;
var focusShortcuts = this.$props.focusShortcuts;
if (!this.shouldUtilizeHotkeysLib || !(typeof this.hotkeys === 'function') || isEmpty(focusShortcuts)) {
return;
} // for single press keys (a-z, A-Z) &, hotkeys' combinations such as 'cmd+k', 'ctrl+shft+a', etc
this.hotkeys(parseFocusShortcuts(focusShortcuts).join(','),
/* eslint-disable no-shadow */
// eslint-disable-next-line no-unused-vars
function (event, handler) {
// Prevent the default refresh event under WINDOWS system
event.preventDefault();
_this2.focusSearchBox(event);
}); // if one of modifier keys are used, they are handled below
this.hotkeys('*', function (event) {
var modifierKeys = extractModifierKeysFromFocusShortcuts(focusShortcuts);
if (modifierKeys.length === 0) return;
for (var index = 0; index < modifierKeys.length; index += 1) {
var element = modifierKeys[index];
if (_this2.hotkeys[element]) {
_this2.focusSearchBox(event);
break;
}
}
});
}
},
render: function render() {
var _this3 = this;
var h = arguments[0];
var _this$$props8 = this.$props,
className = _this$$props8.className,
innerClass = _this$$props8.innerClass,
showIcon = _this$$props8.showIcon,
showClear = _this$$props8.showClear,
showVoiceSearch = _this$$props8.showVoiceSearch,
iconPosition = _this$$props8.iconPosition,
title = _this$$props8.title,
defaultSuggestions = _this$$props8.defaultSuggestions,
autosuggest = _this$$props8.autosuggest,
placeholder = _this$$props8.placeholder,
autoFocus = _this$$props8.autoFocus,
innerRef = _this$$props8.innerRef,
instanceValue = _this$$props8.instanceValue,
expandSuggestionsContainer = _this$$props8.expandSuggestionsContainer;
var _this$$scopedSlots = this.$scopedSlots,
recentSearchesIcon = _this$$scopedSlots.recentSearchesIcon,
popularSearchesIcon = _this$$scopedSlots.popularSearchesIcon;
var getIcon = function getIcon(iconType) {
switch (iconType) {
case suggestionTypes.Recent:
return recentSearchesIcon;
case suggestionTypes.Popular:
return popularSearchesIcon;
default:
return null;
}
};
var suggestionsList = this.getSuggestionsList();
var hasSuggestions = defaultSuggestions && defaultSuggestions.length || suggestionsList && suggestionsList.length;
return h("div", {
"class": className
}, [title && h(Title, {
"class": getClassName(innerClass, 'title') || ''
}, [title]), hasSuggestions && autosuggest ? h(DownShift, {
"attrs": {
"id": "searchbox-downshift",
"handleChange": this.onSuggestionSelected,
"handleMouseup": this.handleStateChange,
"isOpen": this.isOpen
},
"scopedSlots": {
"default": function _default(_ref2) {
var getInputEvents = _ref2.getInputEvents,
getInputProps = _ref2.getInputProps,
getItemProps = _ref2.getItemProps,
getItemEvents = _ref2.getItemEvents,
isOpen = _ref2.isOpen,
highlightedIndex = _ref2.highlightedIndex;
var renderSuggestionsContainer = function renderSuggestionsContainer() {
return h("div", [_this3.hasCustomRenderer && _this3.getComponent({
isOpen: isOpen,
getItemProps: getItemProps,
getItemEvents: getItemEvents,
highlightedIndex: highlightedIndex
}), _this3.renderErrorComponent(), !_this3.hasCustomRenderer && isOpen ? h("ul", {
"class": suggestions + " " + getClassName(innerClass, 'list')
}, [suggestionsList.map(function (item, index) {
return h("li", {
"domProps": _extends({}, getItemProps({
item: item
})),
"on": _extends({}, getItemEvents({
item: item
})),
"key": index + 1 + "-" + item.value,
"style": {
backgroundColor: _this3.getBackgroundColor(highlightedIndex, index),
justifyContent: 'flex-start',
alignItems: 'center'
}
}, [h("div", {
"style": {
padding: '0 10px 0 0',
display: 'flex'
}
}, [h(CustomSvg, {
"attrs": {
"iconId": index + 1 + "-" + item.value + "-icon",
"className": getClassName(innerClass, item._suggestion_type + "-search-icon") || null,
"icon": getIcon(item._suggestion_type),
"type": item._suggestion_type + "-search-icon"
}
})]), h(SuggestionItem, {
"attrs": {
"currentValue": instanceValue,
"suggestion": item
}
}), h(AutofillSvg, {
"on": {
"click": function click(e) {
e.stopPropagation();
_this3.onSelectArrowClick(item);
}
}
})]);
})]) : _this3.renderNoSuggestionComponent()]);
};
return h("div", {
"class": suggestionsContainer
}, [h(InputGroup, [_this3.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
"ref": "searchInputField",
"attrs": {
"showIcon": showIcon,
"showClear": showClear,
"showVoiceSearch": showVoiceSearch,
"iconPosition": iconPosition,
"placeholder": placeholder,
"currentValue": instanceValue,
"autoFocus": autoFocus
},
"class": getClassName(innerClass, 'input'),
"on": _extends({}, getInputEvents({
onInput: _this3.onInputChange,
onBlur: function onBlur(e) {
_this3.withTriggerQuery('blur', e);
},
onFocus: _this3.handleFocus,
onKeyPress: function onKeyPress(e) {
_this3.withTriggerQuery('key-press', e);
},
onKeyDown: function onKeyDown(e) {
return _this3.handleKeyDown(e, highlightedIndex);
},
onKeyUp: function onKeyUp(e) {
_this3.withTriggerQuery('key-up', e);
}
})),
"domProps": _extends({}, getInputProps({
value: instanceValue || ''
}))
}), _this3.renderIcons(), !expandSuggestionsContainer && renderSuggestionsContainer()]), _this3.renderInputAddonAfter(), _this3.renderEnterButtonElement()]), expandSuggestionsContainer && renderSuggestionsContainer()]);
}
}
}) : h("div", {
"class": suggestionsContainer
}, [h(InputGroup, [this.renderInputAddonBefore(), h(InputWrapper, [h(Input, {
"ref": "searchInputField",
"class": getClassName(innerClass, 'input') || '',
"attrs": {
"placeholder": placeholder,
"autoFocus": autoFocus,
"iconPosition": iconPosition,
"showIcon": showIcon,
"showClear": showClear,
"showVoiceSearch": showVoiceSearch,
"innerRef": innerRef
},
"on": _extends({}, {
blur: function blur(e) {
_this3.$emit('blur', e);
},
keypress: function keypress(e) {
_this3.$emit('keyPress', e);
},
input: this.onInputChange,
focus: function focus(e) {
_this3.$emit('focus', e);
},
keydown: this.handleKeyDown,
keyup: function keyup(e) {
_this3.$emit('keyUp', e);
}
}),
"domProps": _extends({}, {
autofocus: autoFocus,
value: instanceValue || ''
})
}), this.renderIcons()]), this.renderInputAddonAfter(), this.renderEnterButtonElement()])])]);
}
};
var SearchBoxWrapper = {
name: 'search-box-wrapper',
functional: true,
render: function render(h, context) {
return h(SearchComponent, _mergeJSXProps([{
"attrs": {
"componentName": "SearchBox",
"value": "",
"type": queryTypes.Suggestion,
"triggerQueryOnInit": !!context.props.enableRecentSearches || context.props.enableRecentSuggestions,
"clearOnQueryChange": true
}
}, {
on: context.listeners,
props: context.props,
scopedSlots: {
"default": function _default(_ref3) {
var loading = _ref3.loading,
error = _ref3.error,
micStatus = _ref3.micStatus,
results = _ref3.results,
value = _ref3.value;
return h(SearchBox, _mergeJSXProps([{
"attrs": {
"loading": loading,
"error": error,
"micStatus": micStatus,
"results": results,
"instanceValue": value
}
}, {
attrs: context.data.attrs,
on: context.listeners,
scopedSlots: context.scopedSlots,
slots: context.slots
}]));
}
}
}, {
"attrs": {
"subscribeTo": ['micStatus', 'error', 'requestPending', 'results', 'value']
}
}]));
}
};
SearchBoxWrapper.install = function (Vue) {
Vue.component(SearchBox.name, SearchBoxWrapper);
};
var SearchBase = {
name: 'search-base',
props: {
index: VueTypes.string,
url: types.url,
mongodb: VueTypes.object,
credentials: VueTypes.string,
headers: types.headers,
appbaseConfig: types.appbaseConfig,
transformRequest: VueTypes.func,
transformResponse: VueTypes.func
},
provide: function provide() {
var headers = _extends({}, this.$props.headers, !this.$props.mongodb ? {
'x-search-client': 'Searchbox Vue'
} : {});
this.searchbase = new searchbase.SearchBase({
index: this.$props.index,
url: this.$props.url,
credentials: this.$props.credentials,
mongodb: this.$props.mongodb,
headers: headers,
appbaseConfig: this.$props.appbaseConfig,
transformRequest: this.$props.transformRequest,
transformResponse: this.$props.transformResponse,
libAlias: searchbase.LIBRARY_ALIAS.VUE_SEARCHBOX
});
return {
searchbase: this.searchbase
};
},
render: function render() {
var h = arguments[0];
return h("div", [this.$slots["default"]]);
}
};
SearchBase.install = function (Vue) {
Vue.component(SearchBase.name, SearchBase);
};
var version = "1.8.1";
var components = [SearchBoxWrapper, SearchBase, SearchComponent];
var install = function install(Vue) {
components.map(function (component) {
Vue.use(component);
return null;
});
};
if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
}
var index = {
version: version,
install: install
};
exports.SearchBase = SearchBase;
exports.SearchBox = SearchBoxWrapper;
exports.SearchComponent = SearchComponent;
exports.default = index;
exports.install = install;
exports.version = version;