ziko 0.0.16 → 0.0.18

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.
Files changed (61) hide show
  1. package/dist/ziko.cjs +479 -1901
  2. package/dist/ziko.js +7648 -8185
  3. package/dist/ziko.min.js +2 -2
  4. package/dist/ziko.mjs +7614 -8182
  5. package/package.json +1 -1
  6. package/readme.md +137 -0
  7. package/src/app/spa-file-based-routing.js +0 -1
  8. package/src/data/datatypes/color.js +11 -0
  9. package/src/graphics/canvas/canvas.js +13 -26
  10. package/src/graphics/canvas/elements/{Basic → basic}/arc.js +1 -1
  11. package/src/graphics/canvas/elements/{Basic → basic}/line.js +1 -1
  12. package/src/graphics/canvas/elements/{Basic → basic}/points.js +1 -1
  13. package/src/graphics/canvas/elements/{Basic → basic}/rect.js +1 -1
  14. package/src/graphics/canvas/elements/index.js +4 -4
  15. package/src/graphics/canvas/index.js +2 -15
  16. package/src/graphics/index.js +9 -68
  17. package/src/graphics/svg/{Elements/Basic → elements/basic}/circle.js +5 -2
  18. package/src/graphics/svg/{Elements/Basic → elements/basic}/ellipse.js +5 -2
  19. package/src/graphics/svg/{Elements/Basic/foreignObject.js → elements/basic/foreign-object.js} +7 -4
  20. package/src/graphics/svg/{Elements/Basic → elements/basic}/groupe.js +5 -2
  21. package/src/graphics/svg/{Elements/Basic → elements/basic}/image.js +5 -2
  22. package/src/graphics/svg/elements/basic/index.js +11 -0
  23. package/src/graphics/svg/{Elements/Basic → elements/basic}/line.js +5 -2
  24. package/src/graphics/svg/{Elements/Basic → elements/basic}/link.js +5 -2
  25. package/src/graphics/svg/{Elements/Basic → elements/basic}/path.js +5 -2
  26. package/src/graphics/svg/{Elements/Basic → elements/basic}/polygon.js +1 -1
  27. package/src/graphics/svg/{Elements/Basic → elements/basic}/polyline.js +4 -1
  28. package/src/graphics/svg/{Elements/Basic → elements/basic}/rect.js +5 -2
  29. package/src/graphics/svg/{Elements/Basic → elements/basic}/text.js +5 -2
  30. package/src/graphics/svg/{Elements/Derived → elements/derived}/grid.js +1 -1
  31. package/src/graphics/svg/elements/derived/index.js +1 -0
  32. package/src/graphics/svg/elements/index.js +2 -0
  33. package/src/graphics/svg/{Elements/ZikoSvgElement.js → elements/ziko-svg-element.js} +5 -3
  34. package/src/graphics/svg/index.js +1 -1
  35. package/src/graphics/svg/svg.js +19 -65
  36. package/src/index.js +2 -1
  37. package/src/reactivity/events/index.js +12 -63
  38. package/src/reactivity/hooks/index.js +8 -91
  39. package/src/reactivity/hooks/ui/index.js +2 -1
  40. package/src/reactivity/hooks/ui/useRoot.js +39 -0
  41. package/src/reactivity/index.js +2 -2
  42. package/src/ui/elements/primitives/ZikoUIContainerElement.js +155 -118
  43. package/src/ui/elements/primitives/ZikoUIElement.js +3 -3
  44. package/src/ui/elements/primitives/misc/xml-wrapper.js +3 -2
  45. package/src/ui/index.js +10 -1
  46. package/README.md +0 -246
  47. package/src/graphics/canvas/elements/Groupe.js +0 -0
  48. package/src/graphics/canvas/elements/grid.js +0 -0
  49. package/src/graphics/canvas/filter/index.js +0 -0
  50. package/src/graphics/canvas/paint/index.js +0 -0
  51. package/src/graphics/svg/Elements/index.js +0 -14
  52. /package/src/graphics/canvas/elements/{Basic → basic}/image.js +0 -0
  53. /package/src/graphics/canvas/elements/{Basic → basic}/path.js +0 -0
  54. /package/src/graphics/canvas/elements/{Basic → basic}/polygon.js +0 -0
  55. /package/src/graphics/canvas/elements/{Basic → basic}/polyline.js +0 -0
  56. /package/src/graphics/canvas/elements/{Basic → basic}/text.js +0 -0
  57. /package/src/graphics/canvas/elements/{Chart → chart}/histogram.js +0 -0
  58. /package/src/graphics/canvas/elements/{Chart → chart}/plot.js +0 -0
  59. /package/src/graphics/canvas/elements/{Chart → chart}/scatter.js +0 -0
  60. /package/src/graphics/canvas/elements/{Chart → chart}/stem.js +0 -0
  61. /package/src/graphics/canvas/elements/{Element.js → element.js} +0 -0
@@ -8,11 +8,12 @@ class ZikoUIXMLWrapper extends ZikoUIElement{
8
8
  function html2dom(htmlString) {
9
9
  const parser = new DOMParser();
10
10
  const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
11
+ doc.body.firstChild.style.display = "contents"
11
12
  return doc.body.firstChild;
12
13
  }
13
14
  function svg2dom(svgString) {
14
15
  const parser = new DOMParser();
15
- const doc = parser.parseFromString(svgString, 'image/svg+xml');
16
+ const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
16
17
  return doc.documentElement; // SVG elements are usually at the root
17
18
  }
18
19
  class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
@@ -26,7 +27,7 @@ class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
26
27
  }
27
28
  }
28
29
  const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
29
- const SVGWrapper = (SVGContent) => new ZikoUIHTMLWrapper(SVGContent);
30
+ const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
30
31
 
31
32
  export{
32
33
  ZikoUIXMLWrapper,
package/src/ui/index.js CHANGED
@@ -16,6 +16,13 @@ import * as Semantic from "./elements/primitives/semantic";
16
16
  import * as Misc from "./elements/primitives/misc";
17
17
  import * as Derived from "./elements/derived";
18
18
 
19
+ import ZikoUIElement from "./elements/primitives/ZikoUIElement";
20
+ import ZikoUIContainerElement from "./elements/primitives/ZikoUIContainerElement";
21
+
22
+ export{
23
+ ZikoUIContainerElement,
24
+ ZikoUIElement
25
+ }
19
26
  const UI = {
20
27
  ...Text,
21
28
  ...List,
@@ -24,6 +31,8 @@ const UI = {
24
31
  ...Table,
25
32
  ...Semantic,
26
33
  ...Misc,
27
- ...Derived
34
+ ...Derived,
35
+ ZikoUIElement,
36
+ ZikoUIContainerElement
28
37
  }
29
38
  export default UI;
package/README.md DELETED
@@ -1,246 +0,0 @@
1
- <img src="docs/assets/zikojs.png" width="200" align="right" alt="zikojs logo">
2
-
3
- *💡 **Zikojs** a versatile JavaScript library offering a rich set of UI components, advanced mathematical utilities,Reactivity,animations,client side routing and graphics capabilities*
4
-
5
- <br>
6
-
7
- # Install
8
- ```bash
9
- npm install ziko
10
- ```
11
- # ⚡ Get started
12
- ## Node
13
- ```bash
14
- npx create-ziko-app [My_App]
15
- ```
16
- ```
17
- cd [My_App]
18
- npm run dev
19
- ```
20
- ## Browser
21
- ```html
22
- <!DOCTYPE html>
23
- <html lang="en">
24
- <head>
25
- <meta charset="UTF-8">
26
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
27
- <title>zikojs</title>
28
- </head>
29
- <body>
30
- <script src="https://cdn.jsdelivr.net/npm/ziko@latest/dist/ziko.js"></script>
31
- <script>
32
- Ziko.ExtractAll()
33
- const hello = p("Hello World").style({
34
- color: "gold",
35
- fontSize: "30px",
36
- fontWeight: "bold"
37
- })
38
- .onPtrEnter(e=>e.target.st.color(Random.color()))
39
- .onPtrLeave(e=>e.target.st.color("gold"))
40
- Ziko.App(
41
- hello
42
- ).style({
43
- width: "100vw",
44
- height: "100vh",
45
- background: "darkblue"
46
- }).vertical(0, "space-around")
47
-
48
- </script>
49
- </body>
50
- </html>
51
- ```
52
- ## Documentation
53
- ## 🎬 Demos
54
- - ### [ Windows entanglement using zikojs and ziko-three ](https://www.linkedin.com/feed/update/urn:li:activity:7144023650394918913/)
55
-
56
- ## 📃 [wiki](https://github.com/zakarialaoui10/ziko.js/wiki)
57
-
58
- ## 💡 [Features]()
59
- ### 🔰 No Template Engines :
60
-
61
- zikojs UI module adopts a distinctive approach to building and updating user interfaces.
62
- It doesn't rely on predefined markup templates. Instead, it leverages a hyperscript-like syntax to dynamically create and update user interfaces.
63
-
64
- <details>
65
- <summary> See More </summary>
66
-
67
- For instance, consider the following JavaScript code using zikojs:
68
- ```js
69
- para=p(
70
- text("hello"),
71
- text("world")
72
- )
73
- .style({
74
- color:"darkblue"
75
- })
76
- .forEach(n=>n.onPtrEnter(e=>{
77
- console.log(e.target.text)
78
- }));
79
- ```
80
- `p(...)` - This line creates a paragraph element (&lt;p&gt;) using zikojs. Inside the p() function, we pass in two text() function calls, which create text nodes containing "hello" and "world" respectively. These will be the contents of the paragraph.
81
-
82
- `.style({...})` - This method sets the style of the paragraph element. In this case, it sets the color to "darkblue".
83
-
84
- `.forEach(...)` - This method iterates over the two items of the paragraph element. Inside the callback function, it sets up an event listener for the "pointerenter" event on each child element. When the pointer enters any child element, it logs the text content of that element to the console.
85
-
86
- >[!TIP]
87
- To acces the para items you can use Array like syntaxe , `para[index]` or `para.at(index)` (index can positive or negative integer)
88
-
89
- This code snippet produces the equivalent HTML structure:
90
- ```html
91
- <p style="color:darkblue">
92
- <span>hello</span>
93
- <span>world</span>
94
- </p>
95
- <script>
96
- para=document.querySelector(p);
97
- [...a.children].forEach(
98
- n=>n.addEventListener("pointerenter",e=>{
99
- console.log(e.target.textContent)
100
- }))
101
- </script>
102
- ```
103
- In summary, zikojs UI module enables dynamic creation and manipulation of user interfaces without relying on static markup templates, offering flexibility and control over UI elements.
104
-
105
- </details>
106
-
107
-
108
-
109
- ### 🔰 Flexible Integration with Popular Frameworks/Libraries
110
-
111
- You can integrate it inside other frameworks/libraries like React , Vue , Svelte ... To do so, all you need to do is install the [ziko-wrapper](https://www.npmjs.com/package/ziko-wrapper) package.
112
-
113
- ### 🔰 Extensive Add-On Ecosystem
114
-
115
- |Addon|Purpose|Dependecy|Links|
116
- |-|-|-|-|
117
- |ziko-gl|-|`Three.js`|[NPM](https://www.npmjs.com/package/zikogl) [GITHUB](https://github.com/zakarialaoui10/zikogl/)|
118
- |ziko-chart|-|`Chart.js`<br>`D3.js`|[NPM](https://www.npmjs.com/package/ziko-chart) [GITHUB](https://github.com/zakarialaoui10/ziko-chart/)|
119
- |ziko-xls|-|`Xls.js`<br>`Hansontable.js`<br>|[NPM](https://www.npmjs.com/package/ziko-xls) [GITHUB](https://github.com/zakarialaoui10/ziko-xls/)|
120
- |ziko-pdf|-|`jsPdf.js`<br>`Pdf.js`<br>|[NPM](https://www.npmjs.com/package/ziko-pdf) [GITHUB](https://github.com/zakarialaoui10/ziko-pdf/)|
121
- |ziko-lottie|render Lottie file within zikojs app|`Lottie-web`|[NPM](https://www.npmjs.com/package/ziko-lottie) [GITHUB](https://github.com/zakarialaoui10/ziko-lottie/)|
122
- ### 🔰 The capability to function in both browser-based and Node.js environments
123
- ### 🔰 Methodes Extracting
124
-
125
- <details>
126
- <summary>
127
- See More
128
- </summary>
129
-
130
- ```js
131
- Ziko.ExtractAll()
132
- // if you want to extract only UI methodes you can use Ziko.UI.Extractll()
133
- ```
134
- 🏷️ This method simplifies syntax by extracting all UI, Math, Time, Graphics, and other methods within the Ziko framework. Instead of writing specific namespace prefixes like `Ziko.UI.text("Hi")` , `Ziko.Math.complex(1,2)` , `Ziko.Math.matrix([[1,2],[2,3]])`, you can directly use simplified syntax such as `text("Hi")` , `complex(1,1)` and `matrix([[1,2],[2,3]])`.
135
-
136
- ⚠️ Be careful with this method because it will overwrite any existing global or local variables and functions with the same names as the extracted methods.
137
- </details>
138
-
139
- ### 🔰 Mathematical Utilities & Tips
140
- ### 🔰 Rich UI elements
141
- ### 🔰 Methodes Chaining
142
- It allows multiple methods to be called sequentially on an object, enhancing code readability and conciseness.
143
- <details>
144
- <summary> See More </summary>
145
- </details>
146
-
147
- ### 🔰 Events Handling
148
-
149
- <details>
150
- <summary>
151
- See More
152
- </summary>
153
-
154
- Example of creating simple Paint sketch using canvas and pointer events :
155
- ```js
156
- Scene=Canvas().size("500px","500px")
157
- Scene.onPtrDown(e=>{
158
- e.target.ctx.beginPath()
159
- e.target.ctx.moveTo(
160
- map(e.dx,0,e.target.element.offsetWidth,e.target.Xmin,e.target.Xmax),
161
- map(e.dy,0,e.target.element.offseHeight,e.target.Ymin,e.target.Ymax)
162
- )
163
- })
164
- Scene.onPtrMove(e=>{
165
- if(e.isDown){
166
- const x=map(e.mx,0,e.target.element.offsetWidth,e.target.axisMatrix[0][0],e.target.axisMatrix[1][0])
167
- const y=map(e.my,0,e.target.element.offsetHeight,e.target.axisMatrix[1][1],e.target.axisMatrix[0][1])
168
- e.target.append(canvasCircle(x,y,1).color({fill:"#5555AA"}).fill())
169
- }})
170
-
171
- Scene.onPtrUp(()=>{})
172
- ```
173
- </details>
174
-
175
- ### 🔰 Functions decorators
176
-
177
- ```js
178
- const inp=input().onKeyDown(throttle(e=>console.log(e.kd),1000));
179
- ```
180
-
181
- ### 🔰 Reactivity
182
- ### 🔰 Routing for Single Page Applications (SPA)
183
-
184
- Zikojs has a built-in Single page application router based on history browser api
185
-
186
- <details>
187
- <summary>
188
- <strong> See More </strong>
189
- </summary>
190
-
191
- ```js
192
- const main= Ziko.App()
193
- const p1=Section()
194
- const p2=Section()
195
- S=Ziko.SPA(
196
- main,{
197
- "/page1":p1,
198
- "/page2":p2
199
- })
200
- // You can use regex to define routes
201
- S.get(
202
- pattern,
203
- path=>handler(path)
204
- )
205
- ```
206
-
207
- ***⚠️ Ensure that your server serves only the index page for all incoming requests.***
208
-
209
- ***💡 Example using expressjs :***
210
-
211
- ```js
212
- app.get('*', (req , res) => {
213
- res.sendFile(path.join(__dirname, 'public', 'index.html'));
214
- });
215
- ```
216
- </details>
217
-
218
-
219
- ### 🔰 Multithreading supports
220
-
221
- ```js
222
- useThread(() => {
223
- s = 0;
224
- for (i = 0; i < 10000000000; i++) s += i;
225
- return s;
226
- }, console.log);
227
- ```
228
-
229
- ### 🔰 Responsive Design based on Flex element and resize observer
230
- ### 🔰 Loop and animations support
231
-
232
- ## ⭐️ Show your support <a name="support"></a>
233
-
234
- If you appreciate the library, kindly demonstrate your support by giving it a star!<br>
235
- [![Star](https://img.shields.io/github/stars/zakarialaoui10/ziko.js?style=social)](https://github.com/zakarialaoui10/ziko.js)
236
- <!--## Financial support-->
237
- # License
238
- This projet is licensed under the terms of MIT License
239
- <img src="https://img.shields.io/github/license/zakarialaoui10/zikojs?color=rgb%2820%2C21%2C169%29" width="100" align="right">
240
-
241
-
242
-
243
-
244
-
245
-
246
-
File without changes
File without changes
File without changes
File without changes
@@ -1,14 +0,0 @@
1
- export { svgRect } from "./Basic/rect.js";
2
- export { svgCircle } from "./Basic/circle.js";
3
- export { svgEllipse } from "./Basic/ellipse.js";
4
- export { svgLine } from "./Basic/line.js";
5
- export { svgPolyLine } from "./Basic/polyline.js";
6
- export { svgPath } from "./Basic/path.js";
7
- export { svgPolygon } from "./Basic/polygon.js";
8
- export { svgText } from "./Basic/text.js";
9
- export { svgImage } from "./Basic/image.js";
10
- export { svgObject } from "./Basic/foreignObject.js";
11
- export { svgGroupe } from "./Basic/groupe.js";
12
- export { svgLink } from "./Basic/link.js";
13
-
14
- export { svgGrid } from "./Derived/grid.js";