-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
1 lines (1 loc) · 8.2 KB
/
index.js
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.$=e():t.$=e()}(window,(function(){return function(t){var e={};function n(o){if(e[o])return e[o].exports;var r=e[o]={i:o,l:!1,exports:{}};return t[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,o){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(o,r,function(e){return t[e]}.bind(null,r));return o},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";function o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){if(!(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)))return;var n=[],o=!0,r=!1,i=void 0;try{for(var c,u=t[Symbol.iterator]();!(o=(c=u.next()).done)&&(n.push(c.value),!e||n.length!==e);o=!0);}catch(t){r=!0,i=t}finally{try{o||null==u.return||u.return()}finally{if(r)throw i}}return n}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function r(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function i(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function c(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function u(t){var e="function"==typeof Map?new Map:void 0;return(u=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,o)}function o(){return l(t,arguments,f(this).constructor)}return o.prototype=Object.create(t.prototype,{constructor:{value:o,enumerable:!1,writable:!0,configurable:!0}}),s(o,t)})(t)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function l(t,e,n){return(l=a()?Reflect.construct:function(t,e,n){var o=[null];o.push.apply(o,e);var r=new(Function.bind.apply(t,o));return n&&s(r,n.prototype),r}).apply(null,arguments)}function s(t,e){return(s=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function d(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function p(t){return(p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}n.r(e),n.d(e,"html",(function(){return y})),n.d(e,"init",(function(){return v})),n.d(e,"Shadow",(function(){return g})),n.d(e,"createShadowElement",(function(){return x}));var h=document.createRange(),y=Range.prototype.createContextualFragment.bind(h),v=function(t,e,n){var o={};(o=void 0!==n?n.querySelector(t):document.querySelector(t)).attachShadow({mode:"open"}),o.shadowRoot.appendChild(e)},b=function(t,e,n,o){e["".concat(t)]=function(t){void 0!==p(o)&&"true"===o.defaultAction&&t.preventDefault(),n(t,o)}};function m(t,e){w(e.ctx,e.path,e.location)}function w(t,e,n){if(void 0!==e)return(e=e.substr(1))===n?(t._render(),!0):(t._shadowRoot.innerHTML="",!1)}var g;!function(t){!function(t){var e=function(){function t(){}return t.prototype.clone=function(t,e){return function(n){function i(){var n,c,u;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),c=this,u=f(i).call(this),n=!u||"object"!==p(u)&&"function"!=typeof u?r(c):u,d(r(n),"setPassedAttribute",(function(t){var e=Array.from(t.attributes),i=new Map;e.map((function(t){i.set("".concat(t.nodeName),"".concat(t.nodeValue))}),"");var c=n._shadowRoot.getElementById(i.get("id")),u=!0,a=!1,l=void 0;try{for(var s,f=i.entries()[Symbol.iterator]();!(u=(s=f.next()).done);u=!0){var d=o(s.value,2),p=d[0],h=d[1];p.startsWith("@")&&(p=p.substr(1),b("".concat(p),c,n.methods["".concat(h)],{defaultAction:i.get("default"),ctx:r(n),bound:i.get("bind")}))}}catch(t){a=!0,l=t}finally{try{u||null==f.return||f.return()}finally{if(a)throw l}}})),d(r(n),"recursivelyCheckForNodes",(function(t,e){if(t.hasChildNodes())for(var o=0;o<t.childNodes.length;o++)n.nestedNodes["".concat(e)].push(t),n.recursivelyCheckForNodes(t.childNodes[o],e);else n.nestedNodes["".concat(e)].push(t)})),n.state=t.state,n.methods=t.methods,n.actions=t.actions,n.provider=e,n.nestedNodes={attrNodes:[]},n.renderTemplate=document.createElement("template"),n._shadowRoot=n.attachShadow({mode:"open"}),n.localWindow=window,n.path=n.getAttribute("path"),n.type=n.getAttribute("type");var a={ctx:r(n),path:n.path,location:n.localWindow.location.hash};return void 0!==n.type&&"router"===n.type?w(r(n),n.path,n.localWindow.location.hash):n._render(),function(t,e,n,o){e["".concat(t)]=function(t){o.location=e.location.hash,n(t,o)}}("onpopstate",n.localWindow,m,a),n}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(i,n),c(i,[{key:"connectedCallback",value:function(){var e,n;e=this,void 0!==(n=t.lifecycle.onMount)?n(e):console.log("Onmount function is undefined")}}]),c(i,[{key:"setState",value:function(t){for(var e in t)t.hasOwnProperty(e)&&(this.state[e]=t[e]);for(var n=0;n<this._shadowRoot.childNodes.length;)this._shadowRoot.removeChild(this.shadowRoot.childNodes[n]),n=1;this._render()}},{key:"clean",value:function(t){for(var e,n=0;n<t.childNodes.length;)8===t.childNodes[n].nodeType||3===t.childNodes[n].nodeType&&(e=t.childNodes[n],!/[^\t\n\r ]/.test(e.textContent))?t.removeChild(t.childNodes[n]):1===t.childNodes[n].nodeType&&this.clean(t.childNodes[n]),n+=1;return t}},{key:"_render",value:function(){var e=t.template(this),n=document.createElement("div");n.appendChild(e),this.renderTemplate.innerHTML=n.innerHTML,n.innerHTML="";var o=this.clean(this.renderTemplate.content.cloneNode(!0));n.appendChild(o),this._shadowRoot.appendChild(n.cloneNode(!0)),this._handleAttributes(this._shadowRoot.childNodes[0].childNodes)}},{key:"_handleAttributes",value:function(t){var e=!0,n=!1,o=void 0;try{for(var r,i=t[Symbol.iterator]();!(e=(r=i.next()).done);e=!0){var c=r.value;this.recursivelyCheckForNodes(c,"attrNodes")}}catch(t){n=!0,o=t}finally{try{e||null==i.return||i.return()}finally{if(n)throw o}}var u=this.nestedNodes.attrNodes.filter((function(t){return void 0!==t.id&&""!==t.id}));this.nestedNodes.attrNodes=[],u.forEach(this.setPassedAttribute)}}]),i}(u(HTMLElement))},t}();t.BaseElement=e;var n=function(){function t(){this.providers={}}return t.prototype.addNewContext=function(t,e){this.providers.hasOwnProperty(t)||(this.providers["".concat(t)]={});var n=this.providers["".concat(t)];n.data=e,n.subs=[];var o={get:function(t,e,o){return n.subs.forEach((function(n){"get"===n.listenOn&&n.f(e,t[e])})),Reflect.get(t,e,o)},set:function(t,e,o,r){var i=Reflect.set(t,e,o);return n.subs.forEach((function(n){"set"===n.listenOn&&n.f(e,t[e])})),i}};return n.proxyObject=new Proxy(n.data,o),n},t.prototype.subToContext=function(t,e){if(this.providers["".concat(t)])return this.providers["".concat(t)].subs.push(e),this;throw new Error("Provider does not exist")},t}();t.ContextProvider=new n}(t.Base||(t.Base={}))}(g||(g={}));var N=g.Base.ContextProvider,x=function(t){return new g.Base.BaseElement.prototype.clone(t,N)}}])}));