@alexgyver/component 1.3.6 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Component.js +9 -7
- package/Component.min.js +1 -1
- package/package.json +1 -1
package/Component.js
CHANGED
|
@@ -74,29 +74,31 @@ export class EL {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
for (const [key, val] of Object.entries(data)) {
|
|
77
|
-
if (!val) continue;
|
|
78
77
|
switch (key) {
|
|
78
|
+
case 'text': el.textContent = (val == null) ? '' : (val + ''); continue;
|
|
79
|
+
case 'html': el.innerHTML = (val == null) ? '' : (val + ''); continue;
|
|
79
80
|
case 'tag':
|
|
80
81
|
case 'context':
|
|
81
82
|
case 'get':
|
|
82
83
|
case 'also':
|
|
83
84
|
continue;
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
}
|
|
86
|
+
if (!val) continue;
|
|
87
|
+
switch (key) {
|
|
86
88
|
case 'class': (Array.isArray(val) ? val : val.split(' ')).map(c => c && el.classList.add(c)); break;
|
|
87
89
|
case 'push': val.push(el); break;
|
|
88
90
|
case 'var': if (ctx) ctx['$' + val] = el; break;
|
|
89
91
|
case 'events': for (let ev in val) el.addEventListener(ev, val[ev].bind(ctx)); break;
|
|
90
|
-
case 'parent':
|
|
92
|
+
case 'parent': val.appendChild(el); break;
|
|
91
93
|
case 'attrs': for (let attr in val) el.setAttribute(attr, val[attr]); break;
|
|
92
94
|
case 'props': for (let prop in val) el[prop] = val[prop]; break;
|
|
93
95
|
case 'child_r': EL.clear(el); // fall
|
|
94
96
|
case 'child': addChild(val); break;
|
|
95
97
|
case 'children_r': EL.clear(el); // fall
|
|
96
|
-
case 'children': for (
|
|
98
|
+
case 'children': for (let obj of val) addChild(obj); break;
|
|
97
99
|
case 'style':
|
|
98
|
-
if (typeof val === 'string') el.style.cssText +=
|
|
99
|
-
else for (let st in val) el.style[st] = val[st];
|
|
100
|
+
if (typeof val === 'string') el.style.cssText += val + ';';
|
|
101
|
+
else for (let st in val) if (val[st]) el.style[st] = val[st];
|
|
100
102
|
break;
|
|
101
103
|
default: el[key] = val; break;
|
|
102
104
|
}
|
package/Component.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e={d:(t,a)=>{for(var c in a)e.o(a,c)&&!e.o(t,c)&&Object.defineProperty(t,c,{enumerable:!0,get:a[c]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{EL:()=>a,LV:()=>r,cj:()=>s,t4:()=>n,uA:()=>c});class a{static ctx;constructor(e,t={},c=!1){a.ctx=this,this.$root=a.make(e,t,c)}static make(e,t={},c=!1){return e&&"object"==typeof t?t instanceof Node?t:("svg"==e&&(c=!0),a.config(c?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e),t,c)):null}static config(e,t,c=!1){if(Array.isArray(e))return e.forEach((e=>a.config(e,t,c))),null;if(!(e instanceof Node)||"object"!=typeof t)return e;let n=t.context;a.ctx=null===n?null:n||a.ctx,n=a.ctx;let s=t=>{if(t)if(t instanceof Node)e.appendChild(t);else if(t instanceof a)e.appendChild(t.$root);else if("string"==typeof t)e.innerHTML+=t;else if("object"==typeof t){let n=a.make(t.tag??"div",t,c||"svg"==t.tag);n&&e.appendChild(n)}};for(const[
|
|
1
|
+
var e={d:(t,a)=>{for(var c in a)e.o(a,c)&&!e.o(t,c)&&Object.defineProperty(t,c,{enumerable:!0,get:a[c]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)},t={};e.d(t,{EL:()=>a,LV:()=>r,cj:()=>s,t4:()=>n,uA:()=>c});class a{static ctx;constructor(e,t={},c=!1){a.ctx=this,this.$root=a.make(e,t,c)}static make(e,t={},c=!1){return e&&"object"==typeof t?t instanceof Node?t:("svg"==e&&(c=!0),a.config(c?document.createElementNS("http://www.w3.org/2000/svg",e):document.createElement(e),t,c)):null}static config(e,t,c=!1){if(Array.isArray(e))return e.forEach((e=>a.config(e,t,c))),null;if(!(e instanceof Node)||"object"!=typeof t)return e;let n=t.context;a.ctx=null===n?null:n||a.ctx,n=a.ctx;let s=t=>{if(t)if(t instanceof Node)e.appendChild(t);else if(t instanceof a)e.appendChild(t.$root);else if("string"==typeof t)e.innerHTML+=t;else if("object"==typeof t){let n=a.make(t.tag??"div",t,c||"svg"==t.tag);n&&e.appendChild(n)}};for(const[c,r]of Object.entries(t)){switch(c){case"text":e.textContent=null==r?"":r+"";continue;case"html":e.innerHTML=null==r?"":r+"";continue;case"tag":case"context":case"get":case"also":continue}if(r)switch(c){case"class":(Array.isArray(r)?r:r.split(" ")).map((t=>t&&e.classList.add(t)));break;case"push":r.push(e);break;case"var":n&&(n["$"+r]=e);break;case"events":for(let t in r)e.addEventListener(t,r[t].bind(n));break;case"parent":r.appendChild(e);break;case"attrs":for(let t in r)e.setAttribute(t,r[t]);break;case"props":for(let t in r)e[t]=r[t];break;case"child_r":a.clear(e);case"child":s(r);break;case"children_r":a.clear(e);case"children":for(let e of r)s(e);break;case"style":if("string"==typeof r)e.style.cssText+=r+";";else for(let t in r)r[t]&&(e.style[t]=r[t]);break;default:e[c]=r}}return t.also&&n&&t.also.call(n,e),e}static clear(e){for(;e.firstChild;)e.removeChild(e.lastChild)}static makeArray(e,t=!1){return e&&Array.isArray(e)?e.map((e=>a.make(e.tag,e,t))):[]}static makeShadow(e,t={},c=null){if(!e||"object"!=typeof t)return null;let n=e instanceof Node?e:document.createElement(e);return n.attachShadow({mode:"open"}),a.config(n.shadowRoot,{context:t.context,children:[{tag:"style",textContent:c??""},t.child??{},...t.children??[]]}),delete t.children,delete t.child,a.config(n,t),n}}const c=a;class n{static make=(e,t)=>a.make(e,t,!0);static config=(e,t)=>a.config(e,t,!0);static makeArray=e=>a.makeArray(e,!0);static svg=(e={},t={})=>n._make("svg",e,t);static rect=(e,t,a,c,s,r,l={},o={})=>n._make("rect",{...l,x:e,y:t,width:a,height:c,rx:s,ry:r},o);static circle=(e,t,a,c={},s={})=>n._make("circle",{...c,cx:e,cy:t,r:a},s);static line=(e,t,a,c,s={},r={})=>n._make("line",{...s,x1:e,y1:t,x2:a,y2:c},r);static polyline=(e,t={},a={})=>n._make("polyline",{...t,points:e},a);static polygon=(e,t={},a={})=>n._make("polygon",{...t,points:e},a);static path=(e,t={},a={})=>n._make("path",{...t,d:e},a);static text=(e,t,a,c={},s={})=>n._make("text",{...c,x:t,y:a},{...s,text:e});static _make=(e,t={},a={})=>n.make(e,{attrs:{...t},...a})}class s{static addStyle(e,t,a=!1){if(e&&t&&("object"==typeof t&&(t=t.constructor.name),!s.#e.has(t)&&!s.#t.has(t)))if(a){let a=document.createElement("style");document.head.appendChild(a),a.textContent=e,s.#t.set(t,a)}else s.#a||(s.#a=document.head.appendChild(document.createElement("style"))),s.#a.textContent+=e+"\r\n",s.#e.add(t)}static removeStyle(e){"object"==typeof e&&(e=e.constructor.name),s.#t.has(e)&&(s.#t.get(e).remove(),s.#t.delete(e))}static#a=null;static#e=new Set;static#t=new Map}class r extends a{constructor(e,t={},a=null,c=null,n=!1){super(e,t),s.addStyle(a,c,n)}static make(e,t={},c=null,n=null,r=!1){return s.addStyle(c,n,r),a.make(e,t)}}const l=t.uA,o=t.EL,i=t.t4,d=t.cj,h=t.LV;export{l as Component,o as EL,i as SVG,d as Sheet,h as StyledComponent};
|