{"version":3,"sources":["webpack:///./LeLab.Web/src/barba/page-component.js"],"names":["PageComponent","constructor","s","c","this","selector","class","record","afterLeave","bind","beforeEnter","PageHooks","data","current","i","length","container","contains","__node__","destroy","console","warn","splice","next","node","querySelectorAll","classInstance","push"],"mappings":"yFAAA,WA+DeA,IA7Cf,MAEIC,YAAYC,EAAGC,GACXC,KAAKC,SAAWH,EAChBE,KAAKE,MAAQH,EACbC,KAAKG,OAAS,GAEd,MAAMC,EAAaJ,KAAKI,WAAWC,KAAKL,MAClCM,EAAcN,KAAKM,YAAYD,KAAKL,MAE1C,IAAI,cAAcO,IACdH,WAAWI,GACPJ,EAAWI,GAEfF,YAAYE,GACRF,EAAYE,KAKxBJ,YAAW,QAAEK,IACT,IAAK,IAAIC,EAAIV,KAAKG,OAAOQ,OAAS,EAAGD,GAAK,EAAGA,IACrCD,EAAQG,UAAUC,SAASb,KAAKG,OAAOO,GAAGI,YACtCd,KAAKG,OAAOO,GAAGK,SAA6C,mBAA3Bf,KAAKG,OAAOO,GAAGK,QAChDf,KAAKG,OAAOO,GAAGK,UAEfC,QAAQC,KAAK,yCAA0CjB,KAAKG,OAAOO,IAEvEV,KAAKG,OAAOO,GAAK,KACjBV,KAAKG,OAAOe,OAAOR,EAAG,IAKlCJ,aAAY,KAAEa,IACV,IAAK,IAAIC,KAAQD,EAAKP,UAAUS,iBAAiBrB,KAAKC,UAAW,CAC7D,IAAIqB,EAAgB,IAAItB,KAAKE,MAAM,CAAEU,UAAWO,EAAKP,UAAWQ,SAChEE,EAAcR,SAAWM,EACzBpB,KAAKG,OAAOoB,KAAKD","file":"page-component.1d130c45.js","sourcesContent":["/**\r\n * This class \"PageComponent\" is an abstraction of \"PageHooks\"\r\n * for page component contruction / destruction.\r\n * \r\n * =============================================================\r\n * \r\n * new PageComponent(\r\n * \".my-component-selector\",\r\n * class MyComponentClass {\r\n * construct({ container, node }) {}\r\n * destroy() {}\r\n * }\r\n * }\r\n * \r\n */\r\n\r\nimport { PageHooks } from \"barba\"\r\n\r\nclass PageComponent {\r\n\r\n constructor(s, c) {\r\n this.selector = s\r\n this.class = c\r\n this.record = []\r\n\r\n const afterLeave = this.afterLeave.bind(this)\r\n const beforeEnter = this.beforeEnter.bind(this)\r\n\r\n new class extends PageHooks {\r\n afterLeave(data) {\r\n afterLeave(data)\r\n }\r\n beforeEnter(data) {\r\n beforeEnter(data)\r\n }\r\n }\r\n }\r\n\r\n afterLeave({ current }) {\r\n for (let i = this.record.length - 1; i >= 0; i--) {\r\n if (current.container.contains(this.record[i].__node__)) {\r\n if (this.record[i].destroy && typeof this.record[i].destroy === 'function') {\r\n this.record[i].destroy()\r\n } else {\r\n console.warn(\"Class is missing a 'destroy()' method.\", this.record[i])\r\n }\r\n this.record[i] = null\r\n this.record.splice(i, 1)\r\n }\r\n }\r\n }\r\n\r\n beforeEnter({ next }) {\r\n for (let node of next.container.querySelectorAll(this.selector)) {\r\n let classInstance = new this.class({ container: next.container, node })\r\n classInstance.__node__ = node\r\n this.record.push(classInstance)\r\n }\r\n }\r\n\r\n}\r\n\r\nexport { PageComponent }\r\nexport default PageComponent"],"sourceRoot":""}