{"version":3,"file":"ResultsCount.js","names":["ResultsCount","a","setters","Component","default","Event","deepMerge","execute","constructor","element","options","arguments","length","dataModelId","templateName","total","initState","bindEvents","on","onSearchUpdated","data","isInsertMode","currentComponent","innerHTML","text","results","render","destroy","removeListener"],"sources":["components/search/ResultsCount.js"],"sourcesContent":["import Component from 'core/Component';\nimport { Event } from 'services/EventEmitter';\nimport { deepMerge } from 'toolbox/deepMerge';\n\n/**\n * This is a description of the ResultsCount constructor function.\n * @class\n * @classdesc This is a description of the ResultsCount class.\n * @extends Component\n */\nexport default class ResultsCount extends Component {\n /**\n * Constructor of the class that mainly merge the options of the components\n *\n * @param {HTMLElement} element HTMLElement of the component\n * @param {Object} options That belongs to the component\n */\n constructor(element, options = {}) {\n super(element, deepMerge({\n dataModelId: null,\n templateName: null,\n total: 0,\n }, options));\n }\n\n /**\n * Init the different state of the component\n * It helps to avoid heavy DOM manipulation\n */\n initState() {\n this.total = this.options.total || 0;\n }\n\n /**\n * Should contain only event listeners and nothing else\n * All the event handlers should be into a separated function. No usage of anonymous function\n */\n bindEvents() {\n Event.on('search.updated', this.onSearchUpdated, this);\n }\n\n /**\n * Search Updated event handler\n *\n * @param {Object} data Data due to refinement to be changed\n * @param {Boolean} isInsertMode Flag due to a insertion\n */\n onSearchUpdated(data, isInsertMode) {\n if (!data || isInsertMode || !this.options.dataModelId || !data[this.options.dataModelId]) {\n return;\n }\n const currentComponent = data[this.options.dataModelId];\n\n if (this.options.dataModelId === 'resultscount' && currentComponent.total !== this.total) {\n this.total = currentComponent.total;\n this.element.innerHTML = currentComponent.text.results;\n } else {\n this.render(currentComponent);\n }\n }\n\n /**\n * Destroy is called automatically after the component is being removed from the DOM\n * You must always destroy the listeners attached to an element to avoid any memory leaks\n */\n destroy() {\n Event.removeListener('search.updated', this.onSearchUpdated, this);\n }\n}\n"],"mappings":"+HAUqBA,CAAY,QAAAC,CAAA,oBAAAC,OAAA,WAAAD,CAAA,EAV1BE,CAAS,CAAAF,CAAA,CAA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