{"version":3,"file":"./modules/SmallExpander.xxxxxxxx.js","mappings":"8JAEA,MAAMA,EAAiB,gCAER,MAAMC,EAKjB,YAAOC,CAAMC,EAAmBH,GAC5BI,MAAMC,KAAKC,SAASC,iBAAiBJ,IAAWK,QAAQC,IAAuBA,EAAKC,QAAQC,oBAAmBC,SAASC,IACpH,IAAIZ,EAAcY,GAClBA,EAAQH,QAAQC,kBAAoB,MAAM,GAElD,CAEA,WAAAG,CAAmBD,EAAsBE,GAAtB,KAAAF,QAAAA,EACfG,KAAKD,SAAU,QAAWC,KAAKH,QAASI,OAAOC,OAAOF,KAAKG,oBAAqBJ,IAChFC,KAAKI,eAAkBJ,KAAKH,QAAQQ,cAAc,IAAIL,KAAKD,QAAQO,uBACnEN,KAAKO,aAAeP,KAAKH,QAAQQ,cAAc,IAAIL,KAAKD,QAAQQ,gBAEhEP,KAAKQ,4BACLR,KAAKS,iBACT,CAEU,yBAAAD,G,QACN,MAAME,GAAU,QAAU,2BAC1BA,EAAQC,MAAMC,SAAW,WACzBF,EAAQG,UAA6B,QAAjB,EAAAb,KAAKO,oBAAY,eAAEM,UAEvCH,GAAWV,KAAKH,QAAQiB,YAAYJ,IACnB,QAAjB,EAAAV,KAAKO,oBAAY,eAAEQ,eAAeL,aAAO,EAAPA,EAASK,gBAAef,KAAKI,eAAeO,MAAMK,QAAU,IAC9FN,EAAQO,QACZ,CAEU,eAAAR,GACNT,KAAKI,eAAec,iBAAiB,SAAS,IAAKlB,KAAKmB,WAC5D,CAEU,OAAAA,GACNnB,KAAKH,QAAQuB,UAAUC,IAAI,GAAGrB,KAAKD,QAAQuB,qBAC/C,CAEU,iBAAAnB,GACN,MAAO,CACHmB,SAAU,oBACVf,aAAc,0BACdD,oBAAqB,yBAE7B,EAkBArB,EAAcC,MAAMF,E,gDClExB,Q,SAA4B,O","sources":["webpack:///./modules/SmallExpander/SmallExpander.ts","webpack:///./modules/SmallExpander/index.ts"],"sourcesContent":["import { createDiv } from '../../helpers/DOMHelpers';\r\nimport { getOptions } from '../../helpers/helperFunctions';\r\nconst moduleSelector = '[data-module=\"SmallExpander\"]';\r\n\r\nexport default class SmallExpander {\r\n protected options: SmallExpanderOptions;\r\n protected expanderButton: HTMLElement;\r\n protected expanderText: HTMLElement;\r\n\r\n static setup(selector: string = moduleSelector): void {\r\n Array.from(document.querySelectorAll(selector)).filter((node: HTMLElement) => !node.dataset.moduleInitialized).forEach((element: HTMLElement) => {\r\n new SmallExpander(element);\r\n element.dataset.moduleInitialized = 'true';\r\n });\r\n }\r\n\r\n constructor(public element: HTMLElement, options?: SmallExpanderOptions) {\r\n this.options = getOptions(this.element, Object.assign(this.getDefaultOptions(), options));\r\n this.expanderButton = this.element.querySelector(`.${this.options.SmallExpanderButton}`);\r\n this.expanderText = this.element.querySelector(`.${this.options.expanderText}`);\r\n \r\n this.checkIfReadMoreNeedToShow();\r\n this.addEventHanlder();\r\n }\r\n\r\n protected checkIfReadMoreNeedToShow() {\r\n const fakeDiv = createDiv(\"nx-u-visibility--hidden\");\r\n fakeDiv.style.position = \"absolute\";\r\n fakeDiv.innerHTML = this.expanderText?.innerHTML;\r\n\r\n fakeDiv && this.element.appendChild(fakeDiv);\r\n this.expanderText?.clientHeight < fakeDiv?.clientHeight ? this.expanderButton.style.display = \"\" : \"\";\r\n fakeDiv.remove();\r\n }\r\n\r\n protected addEventHanlder(){\r\n this.expanderButton.addEventListener('click', ()=> this.showAll());\r\n }\r\n\r\n protected showAll() {\r\n this.element.classList.add(`${this.options.Selector}--show-all`);\r\n }\r\n \r\n protected getDefaultOptions(): SmallExpanderOptions {\r\n return {\r\n Selector: 'nx-small-expander',\r\n expanderText: \"nx-small-expander__text\",\r\n SmallExpanderButton: 'nx-small-expander__btn',\r\n };\r\n }\r\n}\r\n\r\n\r\n// Hot Module Replacement\r\nif (module.hot) {\r\n let nodesCache: HMRNodes[] = Array.from(document.querySelectorAll(moduleSelector)).map((element: Node) => ({ nodeToReplace: element, nodeOrigin: element.cloneNode(true) }));\r\n\r\n SmallExpander.setup(moduleSelector);\r\n\r\n module.hot.accept(() => {\r\n SmallExpander.setup(moduleSelector);\r\n });\r\n\r\n module.hot.dispose(() => {\r\n nodesCache.forEach(({ nodeToReplace, nodeOrigin }) => { nodeToReplace = nodeToReplace.parentElement.replaceChild(nodeOrigin.cloneNode(true), nodeToReplace) });\r\n });\r\n} else {\r\n SmallExpander.setup(moduleSelector);\r\n}","import SmallExpander from './SmallExpander';\r\nexport default SmallExpander;"],"names":["moduleSelector","SmallExpander","setup","selector","Array","from","document","querySelectorAll","filter","node","dataset","moduleInitialized","forEach","element","constructor","options","this","Object","assign","getDefaultOptions","expanderButton","querySelector","SmallExpanderButton","expanderText","checkIfReadMoreNeedToShow","addEventHanlder","fakeDiv","style","position","innerHTML","appendChild","clientHeight","display","remove","addEventListener","showAll","classList","add","Selector"],"sourceRoot":""}