ziko 0.0.31 → 0.32.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "0.0.31",
3
+ "version": "0.32.0",
4
4
  "description": "a versatile javaScript framework offering a rich set of UI components, advanced mathematical utilities, reactivity, animations, client side routing and graphics capabilities",
5
5
  "keywords": [
6
6
  "front-end",
@@ -1,18 +1,46 @@
1
1
  import ZikoUIElement from "../elements/ZikoUIElement.js";
2
+ import { HTMLTags, SVGTags } from "./tags.js";
3
+ const _h=(tag, type, attributes, ...children)=>{
4
+ const { name, style, ...attrs } = attributes;
5
+ let element = new ZikoUIElement(tag, name, type);
6
+ style && element.style(style);
7
+ attrs && element.setAttr(attrs);
8
+ children && element.append(...children);
9
+ return element;
10
+ }
11
+ const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
12
+ const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
13
+
2
14
  const tags = new Proxy({}, {
3
15
  get(target, prop) {
4
16
  if (typeof prop !== 'string') return undefined;
5
17
  let tag = prop.replaceAll("_","-").toLowerCase();
6
- switch(tag){
7
- case "html" : globalThis?.document?.createElement("html")
8
- case "head" :
9
- case "style" :
10
- case "link" :
11
- case "meta" :
12
- case "srcipt":
13
- case "body" : return null; break;
14
- default : return new ZikoUIElement(tag);
18
+ if(HTMLTags.includes(tag)) return (...args)=>{
19
+ if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
20
+ let attributes = args.shift()
21
+ console.log(args)
22
+ return new ZikoUIElement(tag).setAttr(attributes).append(...args)
23
+ }
24
+ return new ZikoUIElement(tag).append(...args);
25
+ }
26
+ if(SVGTags.includes(tag)) return (...args)=>new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
27
+ return (...args)=>{
28
+ if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
29
+ let attributes = args.shift()
30
+ return new ZikoUIElement(tag).setAttr(attributes).append(...args)
31
+ }
32
+ return new ZikoUIElement(tag).append(...args);
15
33
  }
34
+ // switch(tag){
35
+ // case "html" : globalThis?.document?.createElement("html")
36
+ // case "head" :
37
+ // case "style" :
38
+ // case "link" :
39
+ // case "meta" :
40
+ // case "srcipt":
41
+ // case "body" : return null; break;
42
+ // default : return new ZikoUIElement(tag);
43
+ // }
16
44
  }
17
45
  });
18
46
 
@@ -0,0 +1,126 @@
1
+ const HTMLTags = [
2
+ 'a',
3
+ 'abb',
4
+ 'address',
5
+ 'area',
6
+ 'article',
7
+ 'aside',
8
+ 'audio',
9
+ 'b',
10
+ 'base',
11
+ 'bdi',
12
+ 'bdo',
13
+ 'blockquote',
14
+ 'br',
15
+ 'button',
16
+ 'canvas',
17
+ 'caption',
18
+ 'cite',
19
+ 'code',
20
+ 'col',
21
+ 'colgroup',
22
+ 'data',
23
+ 'datalist',
24
+ 'dd',
25
+ 'del',
26
+ 'details',
27
+ 'dfn',
28
+ 'dialog',
29
+ 'div',
30
+ 'dl',
31
+ 'dt',
32
+ 'em',
33
+ 'embed',
34
+ 'fieldset',
35
+ 'figcaption',
36
+ 'figure',
37
+ 'footer',
38
+ 'form',
39
+ 'h1',
40
+ 'h2',
41
+ 'h3',
42
+ 'h4',
43
+ 'h5',
44
+ 'h6',
45
+ 'header',
46
+ 'hgroup',
47
+ 'hr',
48
+ 'i',
49
+ 'iframe',
50
+ 'img',
51
+ 'ipnut',
52
+ 'ins',
53
+ 'kbd',
54
+ 'label',
55
+ 'legend',
56
+ 'li',
57
+ 'main',
58
+ 'map',
59
+ 'mark',
60
+ 'menu',
61
+ 'meter',
62
+ 'nav',
63
+ 'object',
64
+ 'ol',
65
+ 'optgroup',
66
+ 'option',
67
+ 'output',
68
+ 'p',
69
+ 'param',
70
+ 'picture',
71
+ 'pre',
72
+ 'progress',
73
+ 'q',
74
+ 'rp',
75
+ 'rt',
76
+ 'ruby',
77
+ 's',
78
+ 'samp',
79
+ 'search',
80
+ 'section',
81
+ 'select',
82
+ 'small',
83
+ 'source',
84
+ 'span',
85
+ 'strong',
86
+ 'sub',
87
+ 'summary',
88
+ 'sup',
89
+ 'svg',
90
+ 'table',
91
+ 'tbody',
92
+ 'td',
93
+ 'template',
94
+ 'textarea',
95
+ 'tfoot',
96
+ 'th',
97
+ 'thead',
98
+ 'time',
99
+ 'title',
100
+ 'tr',
101
+ 'track',
102
+ 'u',
103
+ 'ul',
104
+ 'var',
105
+ 'video',
106
+ 'wbr'
107
+ ];
108
+
109
+ const SVGTags = [
110
+ "svg", "g", "defs", "symbol", "use", "image", "switch",
111
+ "rect", "circle", "ellipse", "line", "polyline", "polygon", "path",
112
+ "text", "tspan", "textPath", "altGlyph", "altGlyphDef", "altGlyphItem", "glyph", "glyphRef",
113
+ "linearGradient", "radialGradient", "pattern", "solidColor",
114
+ "filter", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix",
115
+ "feDiffuseLighting", "feDisplacementMap", "feDropShadow", "feFlood", "feFuncA", "feFuncR", "feFuncG", "feFuncB",
116
+ "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "feSpecularLighting",
117
+ "feTile", "feTurbulence",
118
+ "animate", "animateMotion", "animateTransform", "set",
119
+ "script",
120
+ "desc", "title", "metadata", "foreignObject"
121
+ ];
122
+
123
+ export{
124
+ HTMLTags,
125
+ SVGTags
126
+ }
File without changes