Comparing version 0.0.12 to 0.0.13
@@ -1,2 +0,2 @@ | ||
// [DOZ] Build version: 0.0.12 | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Doz",[],t):"object"==typeof exports?exports.Doz=t():e.Doz=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(e,t,r){"use strict";e.exports={ROOT:"__DOZ_GLOBAL_COMPONENTS__",TAG:{ROOT:"doz-root",EACH:"doz-each-root",VIEW:"doz-view",SUFFIX_ROOT:"-root"},REGEX:{IS_CUSTOM_TAG:/^\w+-[\w-]+$/,IS_CUSTOM_TAG_STRING:/<\w+-[\w-]+/,IS_BIND:/^d-bind$/,IS_REF:/^d-ref$/,IS_ALIAS:/^d:alias$/,IS_STORE:/^d:store$/,IS_COMPONENT_LISTENER:/^d:on-(\w+)$/,IS_LISTENER:/^on/,IS_ID_SELECTOR:/^#[\w-_:.]+$/,IS_PARENT_METHOD:/^parent.(.*)/,GET_LISTENER:/^this.(.*)\((.*)\)/,TRIM_QUOTES:/^["'](.*)["']$/},ATTR:{BIND:"d-bind",REF:"d-ref",ALIAS:"d:alias",STORE:"d:store",LISTENER:"d:on",CLASS:"d:class",STYLE:"d:style",ID:"d:id"}}},function(e,t,r){"use strict";function n(){return window[s]=window[s]||{components:{}},window[s].components}function o(e){var t=n(),r=e.tag.toUpperCase();if(t.hasOwnProperty(r))throw new Error("Component "+r+" already defined");t[r]=e}function i(){window[s]&&(window[s].components={})}function a(e){if("string"!=typeof e)throw new TypeError("tag must be a string");return e=e.toUpperCase(),n()[e]}var u=r(0),s=u.ROOT;e.exports={register:o,get:a,removeAll:i}},function(e,t,r){"use strict";function n(e){if("string"!=typeof e)return e;switch(e){case"undefined":return;case"null":return null;case"NaN":return NaN;case"Infinity":return 1/0;case"true":return!0;case"false":return!1;default:try{return JSON.parse(e)}catch(e){}}var t=parseFloat(e);return!isNaN(t)&&isFinite(e)?0===e.toLowerCase().indexOf("0x")?parseInt(e,16):t:e}e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(var o in t)t.hasOwnProperty(o)&&-1===r.indexOf(o)&&(e.hasOwnProperty(o)&&void 0!==e[o]?"object"===i(e[o])&&n(e[o],t[o]):e[o]=t[o]);return e}function o(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0]=Object.assign({},t[0]),n.apply(this,t)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n,e.exports.copy=o},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof e)throw new TypeError("Tag must be a string");if(!p.IS_CUSTOM_TAG.test(e))throw new TypeError("Tag must contain a dash (-): my-component");var r={};r.tag=e,r.cfg=u.copy(t,{updateChildrenProps:!0,props:{},template:function(){return"<div></div>"}}),c(r)}function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e=u.copy(e,{isStatic:!1});var t=e.template,r=e.view._cache.get(t);if(r)return r;e.template="string"==typeof e.template?l.create(e.template):e.template;var n={},a=e.template,s=e.autoCmp||v.get(a.nodeName)||e.view._components[a.nodeName.toLowerCase()];if(s){var c=E(a),f=O(c),m=a.innerHTML.trim();a.innerHTML="";var h=i(s,{root:e.root,view:e.view,props:c,dProps:f,parentCmp:e.parentCmp,isStatic:e.isStatic});if(void 0===h)return;if(a.parentNode.removeChild(a),h.render(),h._rootElement.dataset.root="true",y.callRender(h),n[f.alias?f.alias:0]=h,m){var b=l.create("<"+d.ROOT+">"+m+"</"+d.ROOT+">");e.isStatic&&h._rootElement.firstChild?h._rootElement.firstChild.appendChild(b):h._rootElement.appendChild(b)}h._rootElement.querySelectorAll("*").forEach(function(t){if(p.IS_CUSTOM_TAG.test(t.nodeName)&&t.nodeName.toLowerCase()!==d.ROOT){var r=t.outerHTML;if(!r)return;var n=document.createElement(t.nodeName);t.parentNode.replaceChild(n,t);var i=o({root:n,template:r,view:e.view,parentCmp:h,isStatic:e.isStatic});Object.keys(i).forEach(function(e){if(void 0!==i[e]){var t=e;void 0!==h.children[t]&&"number"==typeof S(t)&&t++,h.children[t]=i[e]}})}}),e.view._cache.set(t,h)}return n}function i(e,t){var r=u.copy(t.props,"function"==typeof e.cfg.props?e.cfg.props():e.cfg.props),n=Object.defineProperties({},{_isCreated:{value:!1,writable:!0},_prevTpl:{value:null,writable:!0},_prev:{value:null,writable:!0},_prevProps:{value:null,writable:!0},_rootElement:{value:null,writable:!0},_boundElements:{value:{},writable:!0},_callback:{value:t.dProps.callback,writable:!0},_cache:{value:new Map},_isStatic:{value:t.isStatic},_publicProps:{value:Object.assign({},t.props)},view:{value:t.view,enumerable:!0},parent:{value:t.parentCmp,enumerable:!0},ref:{value:{},writable:!0,enumerable:!0},children:{value:{},writable:!0,enumerable:!0},tag:{value:e.tag,enumerable:!0},emit:{value:function(e){if(this._callback&&void 0!==this._callback[e]&&void 0!==this.parent[this._callback[e]]&&"function"==typeof this.parent[this._callback[e]]){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.parent[this._callback[e]].apply(this.parent,r)}},enumerable:!0},each:{value:function(e,t){var r=this;if(Array.isArray(e))return e.map(t).map(function(e){e=e.trim();var t=e.match(p.IS_CUSTOM_TAG_STRING);if(t){var n=e,i=r._cache.get(n);if(void 0!==i)e=i;else{var a=void 0;if(0===t.index){var u=l.create(e);e=u.outerHTML,a=o({root:document.createElement(d.ROOT),template:e,view:r.view,parentCmp:r,isStatic:!0})}else{var s={tag:d.EACH,cfg:{props:{},template:function(){return e}}};a=o({root:document.createElement(d.ROOT),template:"<"+d.EACH+"></"+d.EACH+">",view:r.view,parentCmp:r,isStatic:!0,autoCmp:s})}e=a[0]._rootElement.innerHTML,a[0].destroy(),r._cache.set(n,e)}}return e}).join("").trim()},enumerable:!0},getStore:{value:function(e){return this.view.getStore(e)},enumerable:!0},getComponentById:{value:function(e){return this.view.getComponentById(e)},enumerable:!0},action:{value:t.view.action,enumerable:!0},render:{value:function(){var e=this.tag?this.tag+d.SUFFIX_ROOT:d.ROOT,r=this.template().trim(),n=l.create("<"+e+">"+r+"</"+e+">"),o=b(n),i=g(t.root,o,this._prev,0,this);!this._rootElement&&i&&(this._rootElement=i),this._prev=o},enumerable:!0},mount:{value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._rootElement;return"string"==typeof t.selector&&(r=r.querySelector(t.selector)),this.view.mount(e,r,this)},enumerable:!0},destroy:{value:function(){this._rootElement&&!1!==y.callBeforeDestroy(this)&&(this._rootElement.parentNode.removeChild(this._rootElement),y.callDestroy(this))},enumerable:!0}});if(a(n,e.cfg,t.dProps),!1!==y.callBeforeCreate(n))return m.create(n,r),_.create(n),w.create(n),y.callCreate(n),n._isCreated=!0,n}function a(e,t,r){Object.assign(e,t),r.store&&(e.store=r.store),r.id&&(e.id=r.id)}var u=r(3),s=r(1),c=s.register,l=r(5),f=r(0),p=f.REGEX,d=f.TAG,v=r(1),m=r(13),y=r(6),h=r(7),b=h.transform,E=h.serializeProps,g=r(8).updateElement,S=r(2),_=r(18),w=r(19),T=r(20),O=T.extract;e.exports={component:n,getInstances:o}},function(e,t,r){"use strict";var n=/\n/g,o=/\s+/g,i={create:function(e){var t=void 0;e=e.replace(n," "),e=e.replace(o," ");var r=document.createElement("div");if(r.innerHTML=e,t=r.firstChild,!this.isValidNode(t))throw new Error("Element not valid");return t},isValidNode:function(e){return e&&"nodeType"in e},getAllNodes:function(e){function t(e){for(;e;)r.push(e),e.hasChildNodes()&&t(e.firstChild),e=e.nextSibling}var r=[];return t(e),r}};e.exports=i},function(e,t,r){"use strict";function n(e){if("function"==typeof e.onBeforeCreate)return e.onBeforeCreate.call(e)}function o(e){"function"==typeof e.onCreate&&e.onCreate.call(e)}function i(e){"function"==typeof e.onRender&&e.onRender.call(e)}function a(e){if("function"==typeof e.onBeforeUpdate)return e.onBeforeUpdate.call(e,Object.assign({},e.props))}function u(e){"function"==typeof e.onUpdate&&e.onUpdate.call(e)}function s(e){if("function"==typeof e.onBeforeDestroy)return e.onBeforeDestroy.call(e)}function c(e){"function"==typeof e.onDestroy&&(e.onDestroy.call(e),e=null)}e.exports={callBeforeCreate:n,callCreate:o,callRender:i,callBeforeUpdate:a,callUpdate:u,callBeforeDestroy:s,callDestroy:c}},function(e,t,r){"use strict";function n(e){for(var t={},r=Array.from(e.attributes),n=r.length-1;n>=0;--n){var o=r[n],a=o.name.match(u.IS_COMPONENT_LISTENER);a?(void 0===t[s.LISTENER]&&(t[s.LISTENER]={}),t[s.LISTENER][a[1]]=o.nodeValue,delete t[o.name]):t[o.name]=""===o.nodeValue||i(o.nodeValue)}return t}function o(e){function t(e,o){for(;e;){var i=void 0;3===e.nodeType?i=e.nodeValue:(i={},i.type=e.nodeName.toLowerCase(),i.children=[],i.props=n(e)),Object.keys(r).length||(r=i),o&&o.children&&o.children.push(i),e.hasChildNodes()&&t(e.firstChild,i),e=e.nextSibling}}var r={};return t(e,r),r}var i=r(2),a=r(0),u=a.REGEX,s=a.ATTR;e.exports={transform:o,serializeProps:n}},function(e,t,r){"use strict";var n=r(15);e.exports={updateElement:n.update}},function(e,t,r){"use strict";e.exports=r(10)},function(e,t,r){"use strict";e.exports=r(11),e.exports.component=r(4).component,e.exports.collection=r(1),e.exports.update=r(8).updateElement,e.exports.transform=r(7).transform,e.exports.html=r(5)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(3),u=r(12),s=r(4),c=r(0),l=c.TAG,f=c.REGEX,p=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e);var i="<"+l.VIEW+"></"+l.VIEW+">";if(f.IS_ID_SELECTOR.test(r.root)&&(r.root=document.getElementById(r.root.substring(1))),f.IS_ID_SELECTOR.test(r.template)&&(r.template=document.getElementById(r.template.substring(1)),r.template=r.template.innerHTML),!(r.root instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid ID selector like #example-root");if(!(r.template instanceof HTMLElement||"string"==typeof r.template||"function"==typeof r.template))throw new TypeError("template must be a string or an HTMLElement or a function or an valid ID selector like #example-template");this.cfg=a(r,{components:[],actions:{}}),Object.defineProperties(this,{_components:{value:{},writable:!0},_usedComponents:{value:{},writable:!0},_stores:{value:{},writable:!0},_cache:{value:new Map},_ids:{value:{},writable:!0},action:{value:u(this.cfg.actions,this),enumerable:!0},mount:{value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._usedComponents[0];if("string"==typeof t&&(t=document.querySelector(t)),!((t=t||r._rootElement)instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid selector like #example-root");var n={tag:l.ROOT,cfg:{props:{},template:function(){return e}}};return s.getInstances({root:t,template:"<"+l.ROOT+"></"+l.ROOT+">",view:this,parentCmp:r,isStatic:!1,autoCmp:n})[0]},enumerable:!0}}),this.cfg.components.forEach(function(e){"object"===(void 0===e?"undefined":o(e))&&"string"==typeof e.tag&&"object"===o(e.cfg)&&(t._components[e.tag]=e)}),this._components[l.VIEW]={tag:l.VIEW,cfg:{props:r.props||{},template:function(){return"function"==typeof r.template?r.template():r.template}}},this._usedComponents=s.getInstances({root:this.cfg.root,template:i,view:this})||[]}return i(e,[{key:"getComponent",value:function(e){return this._usedComponents[0]?this._usedComponents[0].children[e]:void 0}},{key:"getComponentById",value:function(e){return this._ids[e]}},{key:"getStore",value:function(e){return this._stores[e]}}]),e}();e.exports=p},function(e,t,r){"use strict";function n(e,t){if("object"!==(void 0===e?"undefined":o(e)))throw new TypeError("expected an object");for(var r=Object.assign({},e),i=Object.keys(e),a=i.length-1;a>=0;--a){var u=r[i[a]];"function"==typeof u?r[i[a]]=u.bind(t):"object"===(void 0===u?"undefined":o(u))&&(r[i[a]]=n(u,t))}return r}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n},function(e,t,r){"use strict";function n(e){return void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout(e)}function o(e,t){if(e.updateChildrenProps){Object.keys(e.children).forEach(function(r){t.forEach(function(t){e.children[r]._publicProps.hasOwnProperty(t.currentPath)&&e.children[r].props.hasOwnProperty(t.currentPath)&&(e.children[r].props[t.currentPath]=t.newValue)})})}}function i(e,t){t.forEach(function(t){e._boundElements.hasOwnProperty(t.property)&&e._boundElements[t.property].forEach(function(e){e.value=t.newValue})})}function a(e,t){e.props=u.create(t,!0,function(t){e.render(),i(e,t),e._isCreated&&n(function(){o(e,t),s.callUpdate(e)})}),u.beforeChange(e.props,function(){if(!1===s.callBeforeUpdate(e))return!1})}var u=r(14),s=r(6);e.exports={create:a}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){var e=[],t=[],r=[],o=[],i=null,a=null,u=function(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e||self)},s=function s(c,l,f,p){var d=f||null,v=p||"",m=[],y=function(e,t){return e instanceof Array?""!==v?v:t:""!==v?v+"."+t:t},h=function(e){if(!0!==d.paused)if(!0===l)setTimeout(function(){if(e===m.length){for(var t=0;t<d.observers.length;t++)d.observers[t](m);m=[]}},10);else{for(var t=0;t<d.observers.length;t++)d.observers[t](m);m=[]}},b={get:function(e,n){if("__isProxy"===n)return!0;if("__getTarget"===n)return e;if("__getParent"===n)return function(t){if(void 0===t)var t=1;var r=y(e,"__getParent").split(".");return r.splice(-(t+1),t+1),u(d.proxy,r.join("."))};var a=e[n];if(o.push(d),null===i){i=d;var c=t.indexOf(e),f=r[c],p=f.length;if(p>1)for(;p--;)-1===o.indexOf(f[p].observable)&&f[p].proxy[n];i=null,o=[]}if(a instanceof Object&&null!==a&&e.hasOwnProperty(n)&&void 0===a.__isProxy){var c=t.indexOf(a);if(c>-1)for(var m=r[c],p=m.length;p--;)if(m[p].observable===d)return m[p].proxy;return s(a,l,d,""!==v?v+"."+n:n)}return a},deleteProperty:function(e,n){var o=!0;a===E&&(o=!1,a=null);var i=Object.assign({},e),u=y(e,n);if(m.push({type:"delete",target:e,property:n,newValue:null,previousValue:i[n],currentPath:u,proxy:E}),"function"==typeof d.beforeChange){if(!1===d.beforeChange(m))return!1}if(!0===o){var s=t.indexOf(e);if(s>-1)for(var c=r[s].length;c--;)r[s][c].proxy!==E&&(a=r[s][c].proxy,delete r[s][c].proxy[n]);delete e[n]}return h(m.length),!0},set:function(e,o,i,u){var s=!0;a===E&&(s=!1,a=null);var c=e[o];if(c!==i||!1===s){var l=void 0===c?"undefined":n(c),f=y(e,o),p="update";if("undefined"===l&&(p="add"),m.push({type:p,target:e,property:o,newValue:i,previousValue:u[o],currentPath:f,proxy:E}),"function"==typeof d.beforeChange){if(!1===d.beforeChange(m))return!1}if(!0===s){var v=t.indexOf(e);if(v>-1)for(var b=r[v],g=b.length;g--;)b[g].proxy!==E&&(a=b[g].proxy,b[g].proxy[o]=i);setTimeout(function(){l instanceof Object&&function e(n){for(var o in n){var i=n[o];i instanceof Object&&null!==i&&e(i)}var a=t.indexOf(n);if(a>-1){for(var u=r[a],s=u.length;s--;)if(d===u[s].observable){u.splice(s,1);break}0==u.length&&(r.splice(a,1),t.splice(a,1))}}(c)},1e4),e[o]=i}h(m.length)}return!0}},E=new Proxy(c,b);null===d&&(d={target:c,domDelay:l,proxy:E,observers:[],paused:!1,path:v},e.push(d));var g={target:c,proxy:E,observable:d},S=t.indexOf(c);return S>-1?r[S].push(g):(t.push(c),r.push([g])),E};return{create:function(e,t,r){if(!0===e.__isProxy)var e=e.__getTarget;var n=s(e,t);return"function"==typeof r&&this.observe(n,r),n},observe:function(t,r){for(var n=e.length;n--;)if(e[n].proxy===t){e[n].observers.push(r);break}},pause:function(t){for(var r=e.length,n=!1;r--;)if(e[r].proxy===t){e[r].paused=!0,n=!0;break}if(0==n)throw new Error("ObseravableSlim could not pause observable -- matching proxy not found.")},resume:function(t){for(var r=e.length,n=!1;r--;)if(e[r].proxy===t){e[r].paused=!1,n=!0;break}if(0==n)throw new Error("ObseravableSlim could not resume observable -- matching proxy not found.")},remove:function(n){for(var o=null,i=!1,a=e.length;a--;)if(e[a].proxy===n){o=e[a],i=!0;break}for(var u=r.length;u--;)for(var s=r[u].length;s--;)r[u][s].observable===o&&(r[u].splice(s,1),0==r[u].length&&(r.splice(u,1),t.splice(u,1)));!0===i&&e.splice(a,1)},beforeChange:function(t,r){if("function"!=typeof r)throw new Error("Callback function is required");for(var n=e.length,o=!1;n--;)if(e[n].proxy===t){e[n].beforeChange=r,o=!0;break}if(0==o)throw new Error("ObseravableSlim -- matching proxy not found.")}}}();try{e.exports=o}catch(e){}},function(e,t,r){"use strict";function n(e,t){return(void 0===e?"undefined":u(e))!==(void 0===t?"undefined":u(t))||"string"==typeof e&&e!==t||e.type!==t.type||e.props&&e.props.forceupdate}function o(e,t){if(void 0!==e){if("string"==typeof e)return document.createTextNode(e);var r=document.createElement(e.type);return c(r,e.props,t),e.children.map(function(e){return o(e,t)}).forEach(r.appendChild.bind(r)),r}}function i(e,t,r){var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments[4];if(!r){var c=o(t,s);return e.appendChild(c),c}if(t){if(n(t,r)){var p=o(t,s);return e.replaceChild(p,e.childNodes[u]),p}if(t.type){l(e.childNodes[u],t.props,r.props,s);for(var d=t.children.length,v=r.children.length,m=0;m<d||m<v;m++)i(e.childNodes[u],t.children[m],r.children[m],m,s);a()}}else e.childNodes[u]&&f.push(e.childNodes[u])}function a(){for(var e=f.length;e--;)f[e].parentNode.removeChild(f[e]),f.splice(e,1)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(16),c=s.attach,l=s.updateAttributes,f=[];e.exports={create:o,update:i}},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function o(e){return w.IS_LISTENER.test(e)}function i(e){return e===T.BIND}function a(e){return e===T.REF}function u(e){return-1!==["INPUT","TEXTAREA"].indexOf(e.nodeName)}function s(e,t,r,n){if(p(t));else if("className"===t)e.setAttribute("class",r);else if("boolean"==typeof r)d(e,t,r);else if("object"===(void 0===r?"undefined":S(r)))try{e.setAttribute(t,JSON.stringify(r))}catch(e){}else e.setAttribute(t,r)}function c(e,t,r){p(t)||("className"===t?e.removeAttribute("class"):"boolean"==typeof r?v(e,t):e.removeAttribute(t))}function l(e,t,r,n){r?n&&r===n||s(e,t,r):c(e,t,n)}function f(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=(arguments[3],Object.assign({},t,r));Object.keys(n).forEach(function(n){l(e,n,t[n],r[n])})}function p(e){return o(e)||i(e)||a(e)||"forceupdate"===e}function d(e,t,r){r?(e.setAttribute(t,r),e[t]=!0):e[t]=!1}function v(e,t){e.removeAttribute(t),e[t]=!1}function m(e){return e.slice(2).toLowerCase()}function y(e){return e.replace(w.TRIM_QUOTES,"$1")}function h(e,t,r,i){if(o(t)){var a=r.match(w.GET_LISTENER);if(i._isStatic&&(e.dataset[t]=r),a){var u=null,s=a[1],c=a[2];c&&(u=c.split(",").map(function(e){return e=e.trim(),"this"===e?i:O(y(e))}));var l=s.match(w.IS_PARENT_METHOD);l&&(s=l[1],i=i.parent);var f=x(s,i);void 0!==f&&(r=u?f.bind.apply(f,[i].concat(n(u))):f.bind(i))}"function"==typeof r&&e.addEventListener(m(t),r)}}function b(e,t,r,n){i(t)&&u(e)&&void 0!==n.props[r]&&(["compositionstart","compositionend","input","change"].forEach(function(t){e.addEventListener(t,function(){n.props[r]=this.value})}),n._boundElements.hasOwnProperty(r)?n._boundElements[r].push(e):n._boundElements[r]=[e])}function E(e,t,r,n){a(t)&&(n.ref[r]=e)}function g(e,t,r){Object.keys(t).forEach(function(n){s(e,n,t[n],r),h(e,n,t[n],r),b(e,n,t[n],r),E(e,n,t[n],r)});for(var n in e.dataset)e.dataset.hasOwnProperty(n)&&w.IS_LISTENER.test(n)&&h(e,n,e.dataset[n],r)}var S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_=r(0),w=_.REGEX,T=_.ATTR,O=r(2),x=r(17);e.exports={attach:g,updateAttributes:f}},function(e,t,r){"use strict";function n(e,t){return e.split(".").reduce(function(e,t){return e?e[t]:void 0},t)}function o(e,t){return-1!==e.indexOf(".")&&(e=e.split("."),e.pop(),e=e.join(".")),n(e,t)}e.exports=n,e.exports.getLast=o},function(e,t,r){"use strict";function n(e){if("string"==typeof e.store){if(void 0!==e.view._stores[e.store])throw new Error("Store already defined: "+e.store);e.view._stores[e.store]=e.props}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){if("string"==typeof e.id){if(void 0!==e.view._ids[e.id])throw new Error("ID already defined: "+e.id);e.view._ids[e.id]=e}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){var t={};return void 0!==e[i.ALIAS]&&(t.alias=e[i.ALIAS],delete e[i.ALIAS]),void 0!==e[i.STORE]&&(t.store=e[i.STORE],delete e[i.STORE]),void 0!==e[i.LISTENER]&&(t.callback=e[i.LISTENER],delete e[i.LISTENER]),void 0!==e[i.CLASS]&&(t.class=e[i.CLASS],delete e[i.CLASS]),void 0!==e[i.ID]&&(t.id=e[i.ID],delete e[i.ID]),t}var o=r(0),i=o.ATTR;e.exports={extract:n}}])}); | ||
// [DOZ] Build version: 0.0.13 | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("Doz",[],t):"object"==typeof exports?exports.Doz=t():e.Doz=t()}("undefined"!=typeof self?self:this,function(){return function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:n})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=9)}([function(e,t,r){"use strict";e.exports={ROOT:"__DOZ_GLOBAL_COMPONENTS__",TAG:{ROOT:"doz-root",EACH:"doz-each-root",VIEW:"doz-view",SUFFIX_ROOT:"-root"},REGEX:{IS_CUSTOM_TAG:/^\w+-[\w-]+$/,IS_CUSTOM_TAG_STRING:/<\w+-[\w-]+/,IS_BIND:/^d-bind$/,IS_REF:/^d-ref$/,IS_ALIAS:/^d:alias$/,IS_STORE:/^d:store$/,IS_COMPONENT_LISTENER:/^d:on-(\w+)$/,IS_LISTENER:/^on/,IS_ID_SELECTOR:/^#[\w-_:.]+$/,IS_PARENT_METHOD:/^parent.(.*)/,GET_LISTENER:/^this.(.*)\((.*)\)/,TRIM_QUOTES:/^["'](.*)["']$/},ATTR:{BIND:"d-bind",REF:"d-ref",ALIAS:"d:alias",STORE:"d:store",LISTENER:"d:on",CLASS:"d:class",STYLE:"d:style",ID:"d:id"}}},function(e,t,r){"use strict";function n(){return window[s]=window[s]||{components:{}},window[s].components}function o(e){var t=n(),r=e.tag.toUpperCase();if(t.hasOwnProperty(r))throw new Error("Component "+r+" already defined");t[r]=e}function i(){window[s]&&(window[s].components={})}function a(e){if("string"!=typeof e)throw new TypeError("tag must be a string");return e=e.toUpperCase(),n()[e]}var u=r(0),s=u.ROOT;e.exports={register:o,get:a,removeAll:i}},function(e,t,r){"use strict";function n(e){if("string"!=typeof e)return e;switch(e){case"undefined":return;case"null":return null;case"NaN":return NaN;case"Infinity":return 1/0;case"true":return!0;case"false":return!1;default:try{return JSON.parse(e)}catch(e){}}var t=parseFloat(e);return!isNaN(t)&&isFinite(e)?0===e.toLowerCase().indexOf("0x")?parseInt(e,16):t:e}e.exports=n},function(e,t,r){"use strict";function n(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];for(var o in t)t.hasOwnProperty(o)&&-1===r.indexOf(o)&&(e.hasOwnProperty(o)&&void 0!==e[o]?"object"===i(e[o])&&n(e[o],t[o]):e[o]=t[o]);return e}function o(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return t[0]=Object.assign({},t[0]),n.apply(this,t)}var i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n,e.exports.copy=o},function(e,t,r){"use strict";function n(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if("string"!=typeof e)throw new TypeError("Tag must be a string");if(!p.IS_CUSTOM_TAG.test(e))throw new TypeError("Tag must contain a dash (-): my-component");var r={};r.tag=e,r.cfg=u.copy(t,{updateChildrenProps:!0,props:{},template:function(){return"<div></div>"}}),c(r)}function o(){function e(o){for(var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};o;){var u=t.autoCmp||v.get(o.nodeName)||t.view._components[o.nodeName.toLowerCase()];if(u){var s=g(o),c=T(s),l=i(u,{root:o,view:t.view,props:s,dProps:c,parentCmp:a.cmp,isStatic:t.isStatic});if(!l)continue;if(l.render(),Object.keys(r).length||(r[0]=l),o.insertBefore(l._rootElement,o.firstChild),y.callRender(l),n=l,a.cmp){var f=Object.keys(a.cmp.children).length;a.cmp.children[l.alias?l.alias:f++]=l}t.autoCmp=null}o.hasChildNodes()&&e(o.firstChild,{cmp:n}),o=o.nextSibling}}var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};t.template="string"==typeof t.template?l.create(t.template):t.template,t.root.appendChild(t.template);var r={},n=void 0;return e(t.template),r}function i(e,t){var r=u.copy(t.props,"function"==typeof e.cfg.props?e.cfg.props():e.cfg.props),n=Object.defineProperties({},{_isCreated:{value:!1,writable:!0},_prevTpl:{value:null,writable:!0},_prev:{value:null,writable:!0},_prevProps:{value:null,writable:!0},_rootElement:{value:null,writable:!0},_boundElements:{value:{},writable:!0},_callback:{value:t.dProps.callback,writable:!0},_cache:{value:new Map},_isStatic:{value:t.isStatic},_publicProps:{value:Object.assign({},t.props)},view:{value:t.view,enumerable:!0},parent:{value:t.parentCmp,enumerable:!0},ref:{value:{},writable:!0,enumerable:!0},children:{value:{},writable:!0,enumerable:!0},tag:{value:e.tag,enumerable:!0},emit:{value:function(e){if(this._callback&&void 0!==this._callback[e]&&void 0!==this.parent[this._callback[e]]&&"function"==typeof this.parent[this._callback[e]]){for(var t=arguments.length,r=Array(t>1?t-1:0),n=1;n<t;n++)r[n-1]=arguments[n];this.parent[this._callback[e]].apply(this.parent,r)}},enumerable:!0},each:{value:function(e,t){var r=this;if(Array.isArray(e))return e.map(t).map(function(e){e=e.trim();var t=e.match(p.IS_CUSTOM_TAG_STRING);if(t){var n=e,i=r._cache.get(n);if(void 0!==i)e=i;else{var a=void 0;if(0===t.index){var u=l.create(e);e=u.outerHTML,a=o({root:document.createElement(d.ROOT),template:e,view:r.view,parentCmp:r,isStatic:!0})}else{var s={tag:d.EACH,cfg:{props:{},template:function(){return e}}};a=o({root:document.createElement(d.ROOT),template:"<"+d.EACH+"></"+d.EACH+">",view:r.view,parentCmp:r,isStatic:!0,autoCmp:s})}e=a[0]._rootElement.innerHTML,a[0].destroy(),r._cache.set(n,e)}}return e}).join("").trim()},enumerable:!0},getStore:{value:function(e){return this.view.getStore(e)},enumerable:!0},getComponentById:{value:function(e){return this.view.getComponentById(e)},enumerable:!0},action:{value:t.view.action,enumerable:!0},render:{value:function(){var e=this.tag?this.tag+d.SUFFIX_ROOT:d.ROOT,r=this.template().trim(),n=l.create("<"+e+">"+r+"</"+e+">"),o=b(n),i=E(t.root,o,this._prev,0,this);!this._rootElement&&i&&(this._rootElement=i),this._prev=o},enumerable:!0},mount:{value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this._rootElement;return"string"==typeof t.selector&&(r=r.querySelector(t.selector)),this.view.mount(e,r,this)},enumerable:!0},destroy:{value:function(){this._rootElement&&!1!==y.callBeforeDestroy(this)&&(this._rootElement.parentNode.removeChild(this._rootElement),y.callDestroy(this))},enumerable:!0}});if(a(n,e.cfg,t.dProps),!1!==y.callBeforeCreate(n))return m.create(n,r),S.create(n),_.create(n),y.callCreate(n),n._isCreated=!0,n}function a(e,t,r){Object.assign(e,t,r)}var u=r(3),s=r(1),c=s.register,l=r(5),f=r(0),p=f.REGEX,d=f.TAG,v=r(1),m=r(13),y=r(6),h=r(7),b=h.transform,g=h.serializeProps,E=r(8).updateElement,S=(r(2),r(18)),_=r(19),w=r(20),T=w.extract;e.exports={component:n,getInstances:o}},function(e,t,r){"use strict";var n=/\n/g,o=/\s+/g,i={create:function(e){var t=void 0;e=e.replace(n," "),e=e.replace(o," ");var r=document.createElement("div");if(r.innerHTML=e,t=r.firstChild,!this.isValidNode(t))throw new Error("Element not valid");return t},isValidNode:function(e){return e&&"nodeType"in e},getAllNodes:function(e){function t(e){for(;e;)r.push(e),e.hasChildNodes()&&t(e.firstChild),e=e.nextSibling}var r=[];return t(e),r}};e.exports=i},function(e,t,r){"use strict";function n(e){if("function"==typeof e.onBeforeCreate)return e.onBeforeCreate.call(e)}function o(e){"function"==typeof e.onCreate&&e.onCreate.call(e)}function i(e){"function"==typeof e.onRender&&e.onRender.call(e)}function a(e){if("function"==typeof e.onBeforeUpdate)return e.onBeforeUpdate.call(e,Object.assign({},e.props))}function u(e){"function"==typeof e.onUpdate&&e.onUpdate.call(e)}function s(e){if("function"==typeof e.onBeforeDestroy)return e.onBeforeDestroy.call(e)}function c(e){"function"==typeof e.onDestroy&&(e.onDestroy.call(e),e=null)}e.exports={callBeforeCreate:n,callCreate:o,callRender:i,callBeforeUpdate:a,callUpdate:u,callBeforeDestroy:s,callDestroy:c}},function(e,t,r){"use strict";function n(e){var t={};if(e.attributes)for(var r=Array.from(e.attributes),n=r.length-1;n>=0;--n){var o=r[n],a=o.name.match(u.IS_COMPONENT_LISTENER);a?(void 0===t[s.LISTENER]&&(t[s.LISTENER]={}),t[s.LISTENER][a[1]]=o.nodeValue,delete t[o.name]):t[o.name]=""===o.nodeValue||i(o.nodeValue)}return t}function o(e){function t(e,o){for(;e;){var i=void 0;3===e.nodeType?i=e.nodeValue:(i={},i.type=e.nodeName.toLowerCase(),i.children=[],i.props=n(e)),Object.keys(r).length||(r=i),o&&o.children&&o.children.push(i),e.hasChildNodes()&&t(e.firstChild,i),e=e.nextSibling}}var r={};return t(e,r),r}var i=r(2),a=r(0),u=a.REGEX,s=a.ATTR;e.exports={transform:o,serializeProps:n}},function(e,t,r){"use strict";var n=r(15);e.exports={updateElement:n.update}},function(e,t,r){"use strict";e.exports=r(10)},function(e,t,r){"use strict";e.exports=r(11),e.exports.component=r(4).component,e.exports.collection=r(1),e.exports.update=r(8).updateElement,e.exports.transform=r(7).transform,e.exports.html=r(5)},function(e,t,r){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=function(){function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}}(),a=r(3),u=r(12),s=r(4),c=r(0),l=c.TAG,f=c.REGEX,p=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};n(this,e);var i="<"+l.VIEW+"></"+l.VIEW+">";if(f.IS_ID_SELECTOR.test(r.root)&&(r.root=document.getElementById(r.root.substring(1))),f.IS_ID_SELECTOR.test(r.template)&&(r.template=document.getElementById(r.template.substring(1)),r.template=r.template.innerHTML),!(r.root instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid ID selector like #example-root");if(!(r.template instanceof HTMLElement||"string"==typeof r.template||"function"==typeof r.template))throw new TypeError("template must be a string or an HTMLElement or a function or an valid ID selector like #example-template");this.cfg=a(r,{components:[],actions:{}}),Object.defineProperties(this,{_components:{value:{},writable:!0},_usedComponents:{value:{},writable:!0},_stores:{value:{},writable:!0},_cache:{value:new Map},_ids:{value:{},writable:!0},action:{value:u(this.cfg.actions,this),enumerable:!0},mount:{value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this._usedComponents[0];if("string"==typeof t&&(t=document.querySelector(t)),!((t=t||r._rootElement)instanceof HTMLElement))throw new TypeError("root must be an HTMLElement or an valid selector like #example-root");var n={tag:l.ROOT,cfg:{props:{},template:function(){return e}}};return s.getInstances({root:t,template:"<"+l.ROOT+"></"+l.ROOT+">",view:this,parentCmp:r,isStatic:!1,autoCmp:n,mount:!0})[0]},enumerable:!0}}),this.cfg.components.forEach(function(e){"object"===(void 0===e?"undefined":o(e))&&"string"==typeof e.tag&&"object"===o(e.cfg)&&(t._components[e.tag]=e)}),this._components[l.VIEW]={tag:l.VIEW,cfg:{props:r.props||{},template:function(){return"function"==typeof r.template?r.template():r.template}}},this._usedComponents=s.getInstances({root:this.cfg.root,template:i,view:this})||[]}return i(e,[{key:"getComponent",value:function(e){return this._usedComponents[0]?this._usedComponents[0].children[e]:void 0}},{key:"getComponentById",value:function(e){return this._ids[e]}},{key:"getStore",value:function(e){return this._stores[e]}}]),e}();e.exports=p},function(e,t,r){"use strict";function n(e,t){if("object"!==(void 0===e?"undefined":o(e)))throw new TypeError("expected an object");for(var r=Object.assign({},e),i=Object.keys(e),a=i.length-1;a>=0;--a){var u=r[i[a]];"function"==typeof u?r[i[a]]=u.bind(t):"object"===(void 0===u?"undefined":o(u))&&(r[i[a]]=n(u,t))}return r}var o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};e.exports=n},function(e,t,r){"use strict";function n(e){return void 0!==window.requestAnimationFrame?window.requestAnimationFrame(e):window.setTimeout(e)}function o(e,t){if(e.updateChildrenProps){Object.keys(e.children).forEach(function(r){t.forEach(function(t){e.children[r]._publicProps.hasOwnProperty(t.currentPath)&&e.children[r].props.hasOwnProperty(t.currentPath)&&(e.children[r].props[t.currentPath]=t.newValue)})})}}function i(e,t){t.forEach(function(t){e._boundElements.hasOwnProperty(t.property)&&e._boundElements[t.property].forEach(function(e){e.value=t.newValue})})}function a(e,t){e.props=u.create(t,!0,function(t){e.render(),i(e,t),e._isCreated&&n(function(){o(e,t),s.callUpdate(e)})}),u.beforeChange(e.props,function(){if(!1===s.callBeforeUpdate(e))return!1})}var u=r(14),s=r(6);e.exports={create:a}},function(e,t,r){"use strict";var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(){var e=[],t=[],r=[],o=[],i=null,a=null,u=function(e,t){return t.split(".").reduce(function(e,t){return e?e[t]:void 0},e||self)},s=function s(c,l,f,p){var d=f||null,v=p||"",m=[],y=function(e,t){return e instanceof Array?""!==v?v:t:""!==v?v+"."+t:t},h=function(e){if(!0!==d.paused)if(!0===l)setTimeout(function(){if(e===m.length){for(var t=0;t<d.observers.length;t++)d.observers[t](m);m=[]}},10);else{for(var t=0;t<d.observers.length;t++)d.observers[t](m);m=[]}},b={get:function(e,n){if("__isProxy"===n)return!0;if("__getTarget"===n)return e;if("__getParent"===n)return function(t){if(void 0===t)var t=1;var r=y(e,"__getParent").split(".");return r.splice(-(t+1),t+1),u(d.proxy,r.join("."))};var a=e[n];if(o.push(d),null===i){i=d;var c=t.indexOf(e),f=r[c],p=f.length;if(p>1)for(;p--;)-1===o.indexOf(f[p].observable)&&f[p].proxy[n];i=null,o=[]}if(a instanceof Object&&null!==a&&e.hasOwnProperty(n)&&void 0===a.__isProxy){var c=t.indexOf(a);if(c>-1)for(var m=r[c],p=m.length;p--;)if(m[p].observable===d)return m[p].proxy;return s(a,l,d,""!==v?v+"."+n:n)}return a},deleteProperty:function(e,n){var o=!0;a===g&&(o=!1,a=null);var i=Object.assign({},e),u=y(e,n);if(m.push({type:"delete",target:e,property:n,newValue:null,previousValue:i[n],currentPath:u,proxy:g}),"function"==typeof d.beforeChange){if(!1===d.beforeChange(m))return!1}if(!0===o){var s=t.indexOf(e);if(s>-1)for(var c=r[s].length;c--;)r[s][c].proxy!==g&&(a=r[s][c].proxy,delete r[s][c].proxy[n]);delete e[n]}return h(m.length),!0},set:function(e,o,i,u){var s=!0;a===g&&(s=!1,a=null);var c=e[o];if(c!==i||!1===s){var l=void 0===c?"undefined":n(c),f=y(e,o),p="update";if("undefined"===l&&(p="add"),m.push({type:p,target:e,property:o,newValue:i,previousValue:u[o],currentPath:f,proxy:g}),"function"==typeof d.beforeChange){if(!1===d.beforeChange(m))return!1}if(!0===s){var v=t.indexOf(e);if(v>-1)for(var b=r[v],E=b.length;E--;)b[E].proxy!==g&&(a=b[E].proxy,b[E].proxy[o]=i);setTimeout(function(){l instanceof Object&&function e(n){for(var o in n){var i=n[o];i instanceof Object&&null!==i&&e(i)}var a=t.indexOf(n);if(a>-1){for(var u=r[a],s=u.length;s--;)if(d===u[s].observable){u.splice(s,1);break}0==u.length&&(r.splice(a,1),t.splice(a,1))}}(c)},1e4),e[o]=i}h(m.length)}return!0}},g=new Proxy(c,b);null===d&&(d={target:c,domDelay:l,proxy:g,observers:[],paused:!1,path:v},e.push(d));var E={target:c,proxy:g,observable:d},S=t.indexOf(c);return S>-1?r[S].push(E):(t.push(c),r.push([E])),g};return{create:function(e,t,r){if(!0===e.__isProxy)var e=e.__getTarget;var n=s(e,t);return"function"==typeof r&&this.observe(n,r),n},observe:function(t,r){for(var n=e.length;n--;)if(e[n].proxy===t){e[n].observers.push(r);break}},pause:function(t){for(var r=e.length,n=!1;r--;)if(e[r].proxy===t){e[r].paused=!0,n=!0;break}if(0==n)throw new Error("ObseravableSlim could not pause observable -- matching proxy not found.")},resume:function(t){for(var r=e.length,n=!1;r--;)if(e[r].proxy===t){e[r].paused=!1,n=!0;break}if(0==n)throw new Error("ObseravableSlim could not resume observable -- matching proxy not found.")},remove:function(n){for(var o=null,i=!1,a=e.length;a--;)if(e[a].proxy===n){o=e[a],i=!0;break}for(var u=r.length;u--;)for(var s=r[u].length;s--;)r[u][s].observable===o&&(r[u].splice(s,1),0==r[u].length&&(r.splice(u,1),t.splice(u,1)));!0===i&&e.splice(a,1)},beforeChange:function(t,r){if("function"!=typeof r)throw new Error("Callback function is required");for(var n=e.length,o=!1;n--;)if(e[n].proxy===t){e[n].beforeChange=r,o=!0;break}if(0==o)throw new Error("ObseravableSlim -- matching proxy not found.")}}}();try{e.exports=o}catch(e){}},function(e,t,r){"use strict";function n(e,t){return(void 0===e?"undefined":u(e))!==(void 0===t?"undefined":u(t))||"string"==typeof e&&e!==t||e.type!==t.type||e.props&&e.props.forceupdate}function o(e,t){if(void 0!==e){if("string"==typeof e)return document.createTextNode(e);var r=document.createElement(e.type);return c(r,e.props,t),e.children.map(function(e){return o(e,t)}).forEach(r.appendChild.bind(r)),r}}function i(e,t,r){var u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,s=arguments[4];if(!r){var c=o(t,s);return e.appendChild(c),c}if(t){if(n(t,r)){var p=o(t,s);return e.replaceChild(p,e.childNodes[u]),p}if(t.type){l(e.childNodes[u],t.props,r.props,s);for(var d=t.children.length,v=r.children.length,m=0;m<d||m<v;m++)i(e.childNodes[u],t.children[m],r.children[m],m,s);a()}}else e.childNodes[u]&&f.push(e.childNodes[u])}function a(){for(var e=f.length;e--;)f[e].parentNode.removeChild(f[e]),f.splice(e,1)}var u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s=r(16),c=s.attach,l=s.updateAttributes,f=[];e.exports={create:o,update:i}},function(e,t,r){"use strict";function n(e){if(Array.isArray(e)){for(var t=0,r=Array(e.length);t<e.length;t++)r[t]=e[t];return r}return Array.from(e)}function o(e){return w.IS_LISTENER.test(e)}function i(e){return e===T.BIND}function a(e){return e===T.REF}function u(e){return-1!==["INPUT","TEXTAREA"].indexOf(e.nodeName)}function s(e,t,r,n){if(p(t));else if("className"===t)e.setAttribute("class",r);else if("boolean"==typeof r)d(e,t,r);else if("object"===(void 0===r?"undefined":S(r)))try{e.setAttribute(t,JSON.stringify(r))}catch(e){}else e.setAttribute(t,r)}function c(e,t,r){p(t)||("className"===t?e.removeAttribute("class"):"boolean"==typeof r?v(e,t):e.removeAttribute(t))}function l(e,t,r,n){r?n&&r===n||s(e,t,r):c(e,t,n)}function f(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=(arguments[3],Object.assign({},t,r));Object.keys(n).forEach(function(n){l(e,n,t[n],r[n])})}function p(e){return o(e)||i(e)||a(e)||"forceupdate"===e}function d(e,t,r){r?(e.setAttribute(t,r),e[t]=!0):e[t]=!1}function v(e,t){e.removeAttribute(t),e[t]=!1}function m(e){return e.slice(2).toLowerCase()}function y(e){return e.replace(w.TRIM_QUOTES,"$1")}function h(e,t,r,i){if(o(t)){var a=r.match(w.GET_LISTENER);if(i._isStatic&&(e.dataset[t]=r),a){var u=null,s=a[1],c=a[2];c&&(u=c.split(",").map(function(e){return e=e.trim(),"this"===e?i:O(y(e))}));var l=s.match(w.IS_PARENT_METHOD);l&&(s=l[1],i=i.parent);var f=x(s,i);void 0!==f&&(r=u?f.bind.apply(f,[i].concat(n(u))):f.bind(i))}"function"==typeof r&&e.addEventListener(m(t),r)}}function b(e,t,r,n){i(t)&&u(e)&&void 0!==n.props[r]&&(["compositionstart","compositionend","input","change"].forEach(function(t){e.addEventListener(t,function(){n.props[r]=this.value})}),n._boundElements.hasOwnProperty(r)?n._boundElements[r].push(e):n._boundElements[r]=[e])}function g(e,t,r,n){a(t)&&(n.ref[r]=e)}function E(e,t,r){Object.keys(t).forEach(function(n){s(e,n,t[n],r),h(e,n,t[n],r),b(e,n,t[n],r),g(e,n,t[n],r)});for(var n in e.dataset)e.dataset.hasOwnProperty(n)&&w.IS_LISTENER.test(n)&&h(e,n,e.dataset[n],r)}var S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_=r(0),w=_.REGEX,T=_.ATTR,O=r(2),x=r(17);e.exports={attach:E,updateAttributes:f}},function(e,t,r){"use strict";function n(e,t){return e.split(".").reduce(function(e,t){return e?e[t]:void 0},t)}function o(e,t){return-1!==e.indexOf(".")&&(e=e.split("."),e.pop(),e=e.join(".")),n(e,t)}e.exports=n,e.exports.getLast=o},function(e,t,r){"use strict";function n(e){if("string"==typeof e.store){if(void 0!==e.view._stores[e.store])throw new Error("Store already defined: "+e.store);e.view._stores[e.store]=e.props}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){if("string"==typeof e.id){if(void 0!==e.view._ids[e.id])throw new Error("ID already defined: "+e.id);e.view._ids[e.id]=e}}e.exports={create:n}},function(e,t,r){"use strict";function n(e){var t={};return void 0!==e[i.ALIAS]&&(t.alias=e[i.ALIAS],delete e[i.ALIAS]),void 0!==e[i.STORE]&&(t.store=e[i.STORE],delete e[i.STORE]),void 0!==e[i.LISTENER]&&(t.callback=e[i.LISTENER],delete e[i.LISTENER]),void 0!==e[i.CLASS]&&(t.class=e[i.CLASS],delete e[i.CLASS]),void 0!==e[i.ID]&&(t.id=e[i.ID],delete e[i.ID]),t}var o=r(0),i=o.ATTR;e.exports={extract:n}}])}); |
{ | ||
"name": "doz", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"description": "A JavaScript framework for building UI, almost like writing in VanillaJS.", | ||
@@ -5,0 +5,0 @@ "main": "dist/doz.js", |
@@ -27,2 +27,4 @@ <div align="center"> | ||
#### Component definition | ||
```javascript | ||
@@ -45,3 +47,7 @@ Doz.component('button-counter', { | ||
}); | ||
``` | ||
#### Make a view with the component defined above | ||
```javascript | ||
new Doz({ | ||
@@ -48,0 +54,0 @@ root: '#app', |
@@ -42,17 +42,2 @@ const extend = require('../utils/extend'); | ||
cfg = extend.copy(cfg, { | ||
isStatic: false | ||
}); | ||
/*console.log('________________'); | ||
console.log(' '); | ||
console.log('TEMPLATE ->', cfg.template);*/ | ||
const originTpl = cfg.template; | ||
let cached = cfg.view._cache.get(originTpl); | ||
if (cached) { | ||
return cached; | ||
} | ||
cfg.template = typeof cfg.template === 'string' | ||
@@ -62,95 +47,62 @@ ? html.create(cfg.template) | ||
let components = {}; | ||
let index = 0; | ||
cfg.root.appendChild(cfg.template); | ||
let child = cfg.template; | ||
let component = {}; | ||
let parentElement; | ||
const cmp = cfg.autoCmp || collection.get(child.nodeName) || cfg.view._components[child.nodeName.toLowerCase()]; | ||
function walk(child, parent = {}) { | ||
while (child) { | ||
if (cmp) { | ||
let alias = index; | ||
const props = serializeProps(child); | ||
const dProps = extract(props); | ||
const inner = child.innerHTML.trim(); | ||
child.innerHTML = ''; | ||
const cmp = cfg.autoCmp || collection.get(child.nodeName) || cfg.view._components[child.nodeName.toLowerCase()]; | ||
const newElement = createInstance(cmp, { | ||
root: cfg.root, | ||
view: cfg.view, | ||
props, | ||
dProps, | ||
parentCmp: cfg.parentCmp, | ||
isStatic: cfg.isStatic | ||
}); | ||
if (cmp) { | ||
if (newElement === undefined) return; | ||
const props = serializeProps(child); | ||
const dProps = extract(props); | ||
//console.log(child.parentNode); | ||
// Remove old | ||
child.parentNode.removeChild(child); | ||
//console.log(child.parentNode); | ||
newElement.render(); | ||
newElement._rootElement.dataset.root = 'true'; | ||
events.callRender(newElement); | ||
components[dProps.alias ? dProps.alias : alias] = newElement; | ||
//console.log('INNER BEFORE ->', inner); | ||
const newElement = createInstance(cmp, { | ||
root: child, | ||
view: cfg.view, | ||
props, | ||
dProps, | ||
parentCmp: parent.cmp, | ||
isStatic: cfg.isStatic | ||
}); | ||
if (inner) { | ||
const innerEl = html.create(`<${TAG.ROOT}>${inner}</${TAG.ROOT}>`); | ||
//const innerEl = html.create(`${inner}`); | ||
if (cfg.isStatic && newElement._rootElement.firstChild) { | ||
newElement._rootElement.firstChild.appendChild(innerEl); | ||
} else { | ||
newElement._rootElement.appendChild(innerEl); | ||
} | ||
} | ||
if (!newElement) { | ||
continue; | ||
} | ||
const nested = newElement._rootElement.querySelectorAll('*'); | ||
//const nested = Array.from(newElement._rootElement.children); | ||
//console.log('NESTED ->', nested); | ||
/*console.log('COUNT NESTED ->', nested.length); | ||
nested.forEach(item => console.log('............ ->', item.nodeName)); | ||
console.log('OUTER AFTER ->', newElement._rootElement.outerHTML); | ||
console.log('INNER AFTER ->', newElement._rootElement.innerHTML);*/ | ||
newElement.render(); | ||
nested.forEach(item => { | ||
//const item = innerEl; | ||
if (REGEX.IS_CUSTOM_TAG.test(item.nodeName) && item.nodeName.toLowerCase() !== TAG.ROOT /*&& item.parentNode.nodeName === TAG.ROOT*/) { | ||
if (!Object.keys(component).length) { | ||
component[0] = newElement; | ||
} | ||
/* | ||
console.log('PARENT NODE ->', item.parentNode.nodeName); | ||
console.log('PARENTCMP ->', cfg.parentCmp ? cfg.parentCmp._rootElement.innerHTML : null); | ||
console.log('PREV TEMPLATE ->', cfg.prevTemplate); | ||
console.log('PARENT EQ ->', item.outerHTML === originTpl); | ||
console.log('NODENAME ->', item.nodeName); | ||
console.log('ORIG TEMPLATE ->', originTpl); | ||
console.log('N-OU TEMPLATE ->', item.outerHTML); | ||
*/ | ||
child.insertBefore(newElement._rootElement, child.firstChild); | ||
const template = item.outerHTML; | ||
if (!template) return; | ||
const rootElement = document.createElement(item.nodeName); | ||
item.parentNode.replaceChild(rootElement, item); | ||
const cmps = getInstances({ | ||
root: rootElement, | ||
template: template, | ||
view: cfg.view, | ||
parentCmp: newElement, | ||
isStatic: cfg.isStatic | ||
}); | ||
events.callRender(newElement); | ||
Object.keys(cmps).forEach(i => { | ||
if (cmps[i] === undefined) return; | ||
let n = i; | ||
if (newElement.children[n] !== undefined && typeof castStringTo(n) === 'number') { | ||
n++ | ||
} | ||
newElement.children[n] = cmps[i] | ||
}) | ||
parentElement = newElement; | ||
if (parent.cmp) { | ||
let n = Object.keys(parent.cmp.children).length; | ||
parent.cmp.children[newElement.alias ? newElement.alias : n++] = newElement; | ||
} | ||
cfg.autoCmp = null; | ||
} | ||
}); | ||
cfg.view._cache.set(originTpl, newElement); | ||
if (child.hasChildNodes()) { | ||
walk(child.firstChild, {cmp: parentElement}) | ||
} | ||
child = child.nextSibling; | ||
} | ||
} | ||
return components; | ||
walk(cfg.template); | ||
return component; | ||
} | ||
@@ -346,3 +298,2 @@ | ||
// Assign cfg to instance | ||
@@ -370,10 +321,3 @@ extendInstance(instance, cmp.cfg, cfg.dProps); | ||
function extendInstance(instance, cfg, dProps) { | ||
Object.assign(instance, cfg); | ||
// Overwrite store name with that passed though props | ||
if (dProps.store) | ||
instance.store = dProps.store; | ||
// Overwrite id with that passed though props | ||
if (dProps.id) | ||
instance.id = dProps.id; | ||
Object.assign(instance, cfg, dProps); | ||
} | ||
@@ -380,0 +324,0 @@ |
@@ -70,2 +70,3 @@ const extend = require('./utils/extend'); | ||
//console.log('ROOT', root.innerHTML); | ||
const autoCmp = { | ||
@@ -80,3 +81,2 @@ tag: TAG.ROOT, | ||
}; | ||
return component.getInstances({ | ||
@@ -88,3 +88,4 @@ root, | ||
isStatic: false, | ||
autoCmp | ||
autoCmp, | ||
mount: true | ||
})[0]; | ||
@@ -91,0 +92,0 @@ }, |
@@ -6,19 +6,18 @@ const castStringTo = require('../utils/cast-string-to'); | ||
const props = {}; | ||
const attributes = Array.from(node.attributes); | ||
//if (node.attributes.length) { | ||
for (let j = attributes.length - 1; j >= 0; --j) { | ||
let attr = attributes[j]; | ||
//Array.from(node.attributes).forEach(attr => { | ||
let isComponentListener = attr.name.match(REGEX.IS_COMPONENT_LISTENER); | ||
if (isComponentListener) { | ||
if (props[ATTR.LISTENER] === undefined) | ||
props[ATTR.LISTENER] = {}; | ||
props[ATTR.LISTENER][isComponentListener[1]] = attr.nodeValue; | ||
delete props[attr.name]; | ||
} else { | ||
props[attr.name] = attr.nodeValue === '' ? true : castStringTo(attr.nodeValue); | ||
if (node.attributes) { | ||
const attributes = Array.from(node.attributes); | ||
for (let j = attributes.length - 1; j >= 0; --j) { | ||
let attr = attributes[j]; | ||
//Array.from(node.attributes).forEach(attr => { | ||
let isComponentListener = attr.name.match(REGEX.IS_COMPONENT_LISTENER); | ||
if (isComponentListener) { | ||
if (props[ATTR.LISTENER] === undefined) | ||
props[ATTR.LISTENER] = {}; | ||
props[ATTR.LISTENER][isComponentListener[1]] = attr.nodeValue; | ||
delete props[attr.name]; | ||
} else { | ||
props[attr.name] = attr.nodeValue === '' ? true : castStringTo(attr.nodeValue); | ||
} | ||
} | ||
//}); | ||
} | ||
return props; | ||
@@ -25,0 +24,0 @@ } |
Sorry, the diff of this file is too big to display
62
163483
3207