{"version":3,"sources":["webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/text-html-rxjs/client/js/button/index.js","webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/text-html-rxjs/client/js/store/actions.js","webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/text-html-rxjs/client/js/store/reducer.js","webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/text-html-rxjs/client/js/index.js","webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/text-html-rxjs/client/js/config.js","webpack:///./node_modules/@bluekiri/alexandria-contrib-components/components/text-html-rxjs/client/js/prototype.js"],"names":["html","toNode","addData","addStyle","randomId","types","actions","ButtonTemplate","Button","module","exports","addButton","instance","inst","config","hasCollapse","node","viewMoreLabel","literals","template","content","icon","less","type","toggleMore","css","button","createButton","hooks","wrapper","parentNode","appendChild","selector","dataset","toggleViewMore","store","dispatch","reactions","subscribe","state","action","TOGGLE_VIEW_MORE","collapsed","select","setContent","setIcon","classList","add","more","viewLessLabel","remove","subscriptions","events","click$","DESTROY","destroy","initialState","reducer","elementExist","prototype","configuration","Object","create","element","document","querySelector","result","JSON","parse","init","component","start","min","Store","this","panel","keys","forEach","key","unsubscribe","removeChild","setupStore","setupActions","setupReactions"],"mappings":";iFAKA,MAAM,KAAEA,GAAS,EAAQ,SACnB,OAAEC,GAAW,EAAQ,SACrB,QAAEC,EAAO,SAAEC,EAAQ,SAAEC,GAAa,EAAQ,SAE1C,MAAEC,EAAK,QAAEC,GAAY,EAAQ,QAE7BC,EAAiB,EAAQ,QACzBC,EAAS,EAAQ,QAkGvBC,EAAOC,QAAU,CACbC,UA/DJ,SAAmBC,GACf,MAAMC,EAAOD,GAGP,OAAEE,GAAWF,GAEb,YAAEG,GAAgBD,EAExB,IAAKC,EAAa,OAGlB,MAAMC,EA5CV,SAAsBJ,GAElB,MAAM,OAAEE,GAAWF,GAGb,cAAEK,GAAkBH,EAAOI,SAG3BC,EAAWnB,EACbO,EACIJ,EACID,EACI,CACIkB,Q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vC,QAETuC,KAAKvC,MAAQ,IAAIsC,EAAM,CACnBE,MAAOlB,KAHYiB,MAS3B,eACI,OAAIA,KAAKpE,UAEToE,KAAKpE,QAAU,CACXiD,QAAS,IAAMmB,KAAKvC,MAAMC,SAAS9B,EAAQiD,aAHtBmB,MAS7B,iBACI,OAAIA,KAAKrC,YAETqC,KAAKrC,UAAY,CACbkB,QAASmB,KAAKvC,MAAMG,UAAU,CAACC,EAAOC,KAC9BA,EAAOjB,OAASlB,EAAMiD,UAG1B,IAAIO,OAAOe,KAAKF,KAAKrC,YAAYwC,QAAQC,GAAOJ,KAAKrC,UAAUyC,GAAKC,eAGpEL,KAAKX,QAAQjC,WAAWkD,YAAYN,KAAKX,SAGzC,IAAIF,OAAOe,KAAKF,OAAOG,QAAQC,UAAcJ,KAAKI,SAb/BJ,MAoB/B,QACI,IAAKA,KAAK5D,OAAOyD,MAAO,OAAOG,KAG/B,MAAM,UAAEhC,EAAS,YAAE3B,GAAgB2D,KAAK5D,OAOxC,OALI4B,GAAa3B,GACb2D,KAAKpE,QAAQ4B,iBAIVwC,MAGX,OACI,OAAKA,KAAK5D,OAAOuD,MAGjBK,KAAKO,aAGLP,KAAKQ,eAGLR,KAAKS,iBAGLxE,EAAU+D,MAGVA,KAAKH,QAEEG,MAjBuBA,OAsBtCjE,EAAOC,QAAUiD","file":"text-html-rxjs.7585f2905ca47cfd7eec.bundle.js","sourcesContent":["/* ==========================================================================\n TextHtmlRxjs > Client > Button\n ========================================================================== */\n\n/* Modules */\nconst { html } = require('common-tags');\nconst { toNode } = require('@bluekiri/alexandria/helpers/domHelpers');\nconst { addData, addStyle, randomId } = require('@bluekiri/alexandria/helpers/dataHelpers');\n\nconst { types, actions } = require('../store/actions');\n\nconst ButtonTemplate = require('../../../../button-rxjs/template');\nconst Button = require('../../../../button-rxjs/client/js');\n\n/* Create button */\nfunction createButton(instance) {\n /* Data */\n const { config } = instance;\n\n /* Literals */\n const { viewMoreLabel } = config.literals;\n\n /* Template */\n const template = html(\n ButtonTemplate(\n addStyle(\n addData(\n {\n content: viewMoreLabel,\n icon: config.icon.less\n },\n {\n type: randomId(randomId(config.type.toggleMore))\n }\n ),\n [config.css.button]\n )\n )\n );\n\n /* Button */\n const button = toNode(template)[0];\n\n /* Return */\n return button;\n}\n\n/* Add button */\nfunction addButton(instance) {\n const inst = instance;\n\n /* Data */\n const { config } = instance;\n\n const { hasCollapse } = config;\n\n if (!hasCollapse) return;\n\n /* Prepare node */\n const node = createButton(instance);\n\n /* Append as sibling to the wrapper */\n inst.hooks.wrapper.parentNode.appendChild(node, inst.hooks.wrapper);\n\n /* Init button */\n inst.toggleMore = Button(`${instance.selector} [data-component=\"ButtonRxjs\"][data-type=\"${node.dataset.type}\"]`, {\n ...config.button\n });\n\n /**\n * Update actions, reactions, subscriptions\n */\n inst.actions = {\n ...inst.actions,\n toggleViewMore: () => instance.store.dispatch(actions.toggleViewMore())\n };\n\n inst.reactions = {\n ...inst.reactions,\n toggleViewMore: instance.store.subscribe((state, action) => {\n if (action.type !== types.TOGGLE_VIEW_MORE) return;\n\n /* Data */\n const { collapsed } = instance.store.select('panel');\n const { icon, literals, css } = instance.config;\n\n if (collapsed) {\n /* Update content to the button */\n instance.toggleMore.actions.setContent(literals.viewMoreLabel);\n instance.toggleMore.actions.setIcon(icon.less);\n instance.hooks.wrapper.classList.add(css.more);\n } else {\n /* Update content to the button */\n instance.toggleMore.actions.setContent(literals.viewLessLabel);\n instance.toggleMore.actions.setIcon(icon.more);\n instance.hooks.wrapper.classList.remove(css.more);\n }\n })\n };\n\n inst.subscriptions = {\n ...inst.subscriptions,\n toggleMore: instance.toggleMore.events.click$.subscribe(() => {\n /* Dispatch action */\n instance.actions.toggleViewMore();\n })\n };\n}\n\n/* Exports */\nmodule.exports = {\n addButton\n};\n","/* ==========================================================================\n TextHtmlRxjs > Client > Store > Actions\n ========================================================================== */\n\n/* Types */\nconst DESTROY = 'TEXT_HTML_RXJS::DESTROY';\n\nconst TOGGLE_VIEW_MORE = 'TEXT_HTML_RXJS::TOGGLE_VIEW_MORE';\n\n/* Actions */\nconst destroy = () => ({ type: DESTROY });\n\nconst toggleViewMore = () => ({ type: TOGGLE_VIEW_MORE });\n\n/* Exports */\nmodule.exports = {\n types: {\n DESTROY,\n TOGGLE_VIEW_MORE\n },\n actions: {\n destroy,\n toggleViewMore\n }\n};\n","/* ==========================================================================\n TextHtmlRxjs > Client > Store > Reducer\n ========================================================================== */\n\n/* Modules */\nconst { types } = require('./actions');\n\n/* Initial state */\nconst initialState = {\n collapsed: false\n};\n\n/* Reducer */\nfunction reducer(state = initialState, action) {\n switch (action.type) {\n case types.DESTROY:\n return state;\n case types.TOGGLE_VIEW_MORE:\n return {\n ...state,\n collapsed: !state.collapsed\n };\n default:\n return state;\n }\n}\n\n/* Exports */\nmodule.exports = {\n reducer\n};\n","/* ==========================================================================\n TextHtmlRxjs > Client\n ========================================================================== */\n\n/* Import modules */\nconst { elementExist } = require('@bluekiri/alexandria/helpers/domHelpers');\n\nconst prototype = require('./prototype');\nconst config = require('./config');\n\n/**\n * TextHtmlRxjs component\n * @param {selector} String selector for the component in the client side.\n */\nmodule.exports = function TextHtmlRxjs(selector = '[data-component=TextHtmlRxjs]', configuration = {}) {\n if (elementExist(selector)) {\n /* Instance */\n const instance = Object.create(prototype);\n\n /* Selector */\n instance.selector = selector;\n\n /* Element */\n instance.element = document.querySelector(selector);\n\n /* Hooks */\n instance.hooks = {\n wrapper: instance.element.querySelector('[data-spacer]')\n };\n\n /* Config */\n instance.config = {\n ...config(),\n ...configuration,\n ...(function getConfig() {\n if (!instance.element.dataset.config) return '';\n\n const result = JSON.parse(instance.element.dataset.config);\n instance.element.dataset.config = '';\n\n return result;\n })()\n };\n\n /* Init */\n instance.init();\n\n /* Return */\n return instance;\n }\n};\n","/* ==========================================================================\n TextHtmlRxjs > Client > Config\n ========================================================================== */\n\n/* Config */\nconst config = {\n component: 'TextHtmlRxjs',\n init: true,\n start: true,\n min: 216,\n css: {\n button: 'text-html-rxjs__button',\n more: 'has-more'\n },\n icon: {\n more: 'angle-up',\n less: 'angle-down'\n },\n type: {\n toggleMore: 'panel-toggle-more'\n }\n};\n\nmodule.exports = () => config;\n","/* ==========================================================================\n TextHtmlRxjs > Client > Prototype\n ========================================================================== */\n\n/* Modules */\nconst { Store } = require('@bluekiri/alexandria/helpers/state');\n\nconst { actions, types } = require('./store/actions');\nconst { reducer } = require('./store/reducer');\n\nconst { addButton } = require('./button');\n\n/* Prototype */\nconst prototype = {\n /* Setup store */\n setupStore() {\n if (this.store) return this;\n\n this.store = new Store({\n panel: reducer\n });\n\n return this;\n },\n /* Setup actions */\n setupActions() {\n if (this.actions) return this;\n\n this.actions = {\n destroy: () => this.store.dispatch(actions.destroy())\n };\n\n return this;\n },\n /* Setup reactions */\n setupReactions() {\n if (this.reactions) return this;\n\n this.reactions = {\n destroy: this.store.subscribe((state, action) => {\n if (action.type !== types.DESTROY) return;\n\n /* Unsubscribe */\n [...Object.keys(this.reactions)].forEach(key => this.reactions[key].unsubscribe());\n\n /* Remove from DOM */\n this.element.parentNode.removeChild(this.element);\n\n /* Clean references */\n [...Object.keys(this)].forEach(key => delete this[key]);\n })\n };\n\n return this;\n },\n /* Start */\n start() {\n if (!this.config.start) return this;\n\n /* Collapsed */\n const { collapsed, hasCollapse } = this.config;\n\n if (collapsed && hasCollapse) {\n this.actions.toggleViewMore();\n }\n\n /* Data */\n return this;\n },\n /* Init */\n init() {\n if (!this.config.init) return this;\n\n /* Setup store */\n this.setupStore();\n\n /* Setup actions */\n this.setupActions();\n\n /* Setup reactions */\n this.setupReactions();\n\n /* Init collapse */\n addButton(this);\n\n /* Start */\n this.start();\n\n return this;\n }\n};\n\n/* Exports */\nmodule.exports = prototype;\n"],"sourceRoot":""}