ziko 0.0.20 → 0.0.22

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.20",
3
+ "version": "0.0.22",
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,20 +1,30 @@
1
- export const Fixed={
2
- cos:x=>+Math.cos(x).toFixed(15),
3
- sin:x=>+Math.sin(x).toFixed(15),
4
- tan:x=>+Math.tan(x).toFixed(31),
5
- sinc:x=>+Math.sin(Math.PI*x)/(Math.PI*x),
6
- sec:x=>+1/Math.cos(x).toFixed(15),
7
- csc:x=>+1/Math.sin(x).toFixed(15),
8
- cot:x=>+1/Math.tan(x).toFixed(15),
9
- acos:x=>+Math.acos(x).toFixed(15),
10
- asin:x=>+Math.asin(x).toFixed(15),
11
- atan:x=>+Math.atan(x).toFixed(15),
12
- acot:x=>+Math.PI/2-Math.atan(x).toFixed(15),
13
- cosh:x=>+Math.cosh(x).toFixed(15),
14
- sinh:x=>+Math.sinh(x).toFixed(15),
15
- tanh:x=>+Math.tanh(x).toFixed(15),
16
- coth:n=>+(1/2*Math.log((1+n)/(1-n))).toFixed(15),
17
- acosh:x=>+Math.acosh(x).toFixed(15),
18
- asinh:x=>+Math.asinh(x).toFixed(15),
19
- atanh:x=>+Math.atanh(x).toFixed(15),
20
- }
1
+ const {PI, cos, sin, tan, acos, asin, atan, cosh, sinh, tanh, acosh, asinh, atanh, log} = Math
2
+ export let Fixed={
3
+ cos,
4
+ sin,
5
+ tan,
6
+ sinc: x => sin(PI*x)/(PI*x),
7
+ sec: x => 1/cos(x),
8
+ csc: x => 1/sin(x),
9
+ cot: x => 1/tan(x),
10
+ acos,
11
+ asin,
12
+ atan,
13
+ acot: x => PI/2-atan(x),
14
+ cosh,
15
+ sinh,
16
+ tanh,
17
+ coth: n => (1/2*log((1+n)/(1-n))),
18
+ acosh,
19
+ asinh,
20
+ atanh,
21
+ }
22
+
23
+ Fixed = new Proxy(Fixed, {
24
+ get(target, prop) {
25
+ if(prop in target){
26
+ return x => + target[prop](x).toFixed(15);
27
+ }
28
+ return undefined;
29
+ }
30
+ })
@@ -159,4 +159,5 @@ export{
159
159
  gamma,
160
160
  bessel,
161
161
  beta
162
- };
162
+ };
163
+
package/src/math/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as __Const__ from "./const.js"
2
- import * as __Functions__ from "./functions"
2
+ import * as __Functions__ from "./functions/index.js"
3
3
  // import * as __Signal__ from "./const.js"
4
4
  import * as __Random__ from "./random"
5
5
  //import { Derivation } from "./Numeric";
@@ -19,7 +19,7 @@ const Math = {
19
19
  ...__Calculus__,
20
20
  }
21
21
  export * from "./const.js"
22
- export * from "./functions"
22
+ export * from "./functions/index.js"
23
23
  export * from "./complex"
24
24
  export * from "./matrix"
25
25
  export * from "./discret"
@@ -42,8 +42,9 @@ const mapfun=(fun,...X)=>{
42
42
  default : return fun(x)
43
43
  }
44
44
  }
45
- else if(x instanceof Object)return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
46
-
45
+ else if(x instanceof Object){
46
+ return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
47
+ }
47
48
  });
48
49
  return Y.length==1?Y[0]:Y;
49
50
  }
@@ -5,160 +5,119 @@ class ZikoUIContainerElement extends ZikoUIElement {
5
5
  super(element, name);
6
6
  this.items = [];
7
7
  }
8
- maintain() {
9
- for (let i = 0; i < this.items.length; i++)
10
- Object.assign(this, { [[i]]: this.items[i] });
11
- this.length = this.items.length;
12
- return this;
13
- }
14
- at(index) {
15
- return this.items.at(index);
16
- }
17
- #addItem(adder, pusher, ...ele) {
18
- if (this.cache.isFrozzen) {
19
- console.warn("You can't append new item to frozzen element");
20
- return this;
21
- }
22
- for (let i = 0; i < ele.length; i++) {
23
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
24
- if (ele[i] instanceof ZikoUIElement) {
25
- ele[i].cache.parent = this;
26
- this.element[adder](ele[i].element);
27
- ele[i].target = this.element;
28
- this.items[pusher](ele[i]);
29
- } else if (ele[i] instanceof Object) {
30
- if (ele[i]?.style) this.style(ele[i]?.style);
31
- if (ele[i]?.attr) {
32
- Object.entries(ele[i].attr).forEach((n) =>
33
- this.setAttr("" + n[0], n[1]),
34
- );
35
- }
36
- }
37
- }
38
- this.maintain();
39
- return this;
40
- }
41
- append(...ele) {
42
- this.#addItem("append", "push", ...ele);
43
- return this;
44
- }
45
- prepend(...ele) {
46
- this.#addItem("prepend", "unshift", ...ele);
47
- return this;
48
- }
49
- // append(...ele) {
50
- // if(this.cache.isFrozzen){
51
- // console.warn("You can't append new item to frozzen element");
52
- // return this;
53
- // }
54
- // for (let i = 0; i < ele.length; i++){
55
- // if(["number","string"].includes(typeof ele[i]))ele[i]=text(ele[i]);
56
- // if (ele[i] instanceof ZikoUIElement) {
57
- // ele[i].cache.parent=this;
58
- // this.element?.appendChild(ele[i].element);
59
- // ele[i].target = this.element;
60
- // this.items.push(ele[i]);
61
- // } else if (ele[i] instanceof Object) {
62
- // if (ele[i]?.style) this.style(ele[i]?.style);
63
- // if (ele[i]?.attr) {
64
- // Object.entries(ele[i].attr).forEach((n) =>
65
- // this.setAttr("" + n[0], n[1]),
66
- // );
67
- // }
8
+ // maintain() {
9
+ // for (let i = 0; i < this.items.length; i++)
10
+ // Object.assign(this, { [[i]]: this.items[i] });
11
+ // this.length = this.items.length;
12
+ // return this;
13
+ // }
14
+ // at(index) {
15
+ // return this.items.at(index);
16
+ // }
17
+ // #addItem(adder, pusher, ...ele) {
18
+ // if (this.cache.isFrozzen) {
19
+ // console.warn("You can't append new item to frozzen element");
20
+ // return this;
21
+ // }
22
+ // for (let i = 0; i < ele.length; i++) {
23
+ // if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
24
+ // if (ele[i] instanceof ZikoUIElement) {
25
+ // ele[i].cache.parent = this;
26
+ // this.element[adder](ele[i].element);
27
+ // ele[i].target = this.element;
28
+ // this.items[pusher](ele[i]);
29
+ // } else if (ele[i] instanceof Object) {
30
+ // if (ele[i]?.style) this.style(ele[i]?.style);
31
+ // if (ele[i]?.attr) {
32
+ // Object.entries(ele[i].attr).forEach((n) =>
33
+ // this.setAttr("" + n[0], n[1]),
34
+ // );
68
35
  // }
69
36
  // }
70
- // this.maintain();
71
- // return this;
72
37
  // }
73
- insertAt(index, ...ele) {
74
- if (index >= this.element.children.length) this.append(...ele);
75
- else
76
- for (let i = 0; i < ele.length; i++) {
77
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
78
- this.element?.insertBefore(ele[i].element, this.items[index].element);
79
- this.items.splice(index, 0, ele[i]);
80
- }
81
- return this;
82
- }
38
+ // this.maintain();
39
+ // return this;
40
+ // }
41
+ // append(...ele) {
42
+ // this.#addItem("append", "push", ...ele);
43
+ // return this;
44
+ // }
45
+ // prepend(...ele) {
46
+ // this.#addItem("prepend", "unshift", ...ele);
47
+ // return this;
48
+ // }
49
+ // insertAt(index, ...ele) {
50
+ // if (index >= this.element.children.length) this.append(...ele);
51
+ // else
52
+ // for (let i = 0; i < ele.length; i++) {
53
+ // if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
54
+ // this.element?.insertBefore(ele[i].element, this.items[index].element);
55
+ // this.items.splice(index, 0, ele[i]);
56
+ // }
57
+ // return this;
58
+ // }
83
59
  // remove(...ele) {
84
- // if(ele.length==0){
85
- // if(this.cache.parent)this.cache.parent.remove(this);
86
- // else if(this.target.children.length && [...this.target.children].includes(this.element)) this.target.removeChild(this.element);
87
- // }
88
- // else {
89
- // const remove = (ele) => {
90
- // if(typeof ele === "number") ele=this.items[ele];
91
- // if(ele instanceof ZikoUIElement)this.element?.removeChild(ele.element);
92
- // this.items=this.items.filter(n=>n!==ele);
93
- // };
94
- // for (let i = 0; i < ele.length; i++) remove(ele[i]);
95
- // for (let i = 0; i < this.items.length; i++)Object.assign(this, { [[i]]: this.items[i] });
96
- // // Remove from item
97
- // }
60
+ // const remove = (ele) => {
61
+ // if (typeof ele === "number") ele = this.items[ele];
62
+ // if (ele instanceof ZikoUIElement) this.element?.removeChild(ele.element);
63
+ // this.items = this.items.filter((n) => n !== ele);
64
+ // };
65
+ // for (let i = 0; i < ele.length; i++) remove(ele[i]);
66
+ // for (let i = 0; i < this.items.length; i++)
67
+ // Object.assign(this, { [[i]]: this.items[i] });
68
+ // // Remove from item
69
+ // return this;
70
+ // }
71
+ // forEach(callback) {
72
+ // this.items.forEach(callback);
73
+ // return this;
74
+ // }
75
+ // map(callback) {
76
+ // return this.items.map(callback);
77
+ // }
78
+ // find(condition) {
79
+ // return this.items.filter(condition);
80
+ // }
81
+ // filter(condition_callback, if_callback = () => {}, else_callback = () => {}) {
82
+ // const FilterItems = this.items.filter(condition_callback);
83
+ // FilterItems.forEach(if_callback);
84
+ // this.items
85
+ // .filter((item) => !FilterItems.includes(item))
86
+ // .forEach(else_callback);
87
+ // return this;
88
+ // }
89
+ // filterByTextContent(text, exactMatch = false) {
90
+ // this.items.forEach((n) => n.render());
91
+ // this.filter(
92
+ // (n) => !(exactMatch ? n.text === text : n.text.includes(text)),
93
+ // (e) => e.unrender(),
94
+ // );
95
+ // // this.items.filter(n=>{
96
+ // // const content=n.element.textContent;
97
+ // // return !(exactMatch?content===text:content.includes(text))
98
+ // // }).map(n=>n.unrender());
99
+ // // return this;
100
+ // }
101
+ // filterByClass(value) {
102
+ // this.items.map((n) => n.render());
103
+ // this.items
104
+ // .filter((n) => !n.classes.includes(value))
105
+ // .map((n) => n.unrender());
106
+ // return this;
107
+ // }
108
+ // sortByTextContent(value, displays) {
109
+ // let item = this.children;
110
+ // item
111
+ // .filter((n) => !n.textContent.toLowerCase().includes(value.toLowerCase()))
112
+ // .map((n) => {
113
+ // n.style.display = "none";
114
+ // });
115
+ // item
116
+ // .filter((n) => n.textContent.toLowerCase().includes(value.toLowerCase()))
117
+ // .map((n, i) => (n.style.display = displays[i]));
118
+ // //return item.filter(n=>n.style.display!="none")
119
+ // item.filter((n) => n.style.display != "none");
98
120
  // return this;
99
121
  // }
100
- remove(...ele) {
101
- const remove = (ele) => {
102
- if (typeof ele === "number") ele = this.items[ele];
103
- if (ele instanceof ZikoUIElement) this.element?.removeChild(ele.element);
104
- this.items = this.items.filter((n) => n !== ele);
105
- };
106
- for (let i = 0; i < ele.length; i++) remove(ele[i]);
107
- for (let i = 0; i < this.items.length; i++)
108
- Object.assign(this, { [[i]]: this.items[i] });
109
- // Remove from item
110
- return this;
111
- }
112
- forEach(callback) {
113
- this.items.forEach(callback);
114
- return this;
115
- }
116
- map(callback) {
117
- return this.items.map(callback);
118
- }
119
- find(condition) {
120
- return this.items.filter(condition);
121
- }
122
- filter(condition_callback, if_callback = () => {}, else_callback = () => {}) {
123
- const FilterItems = this.items.filter(condition_callback);
124
- FilterItems.forEach(if_callback);
125
- this.items
126
- .filter((item) => !FilterItems.includes(item))
127
- .forEach(else_callback);
128
- return this;
129
- }
130
- filterByTextContent(text, exactMatch = false) {
131
- this.items.forEach((n) => n.render());
132
- this.filter(
133
- (n) => !(exactMatch ? n.text === text : n.text.includes(text)),
134
- (e) => e.unrender(),
135
- );
136
- // this.items.filter(n=>{
137
- // const content=n.element.textContent;
138
- // return !(exactMatch?content===text:content.includes(text))
139
- // }).map(n=>n.unrender());
140
- // return this;
141
- }
142
- filterByClass(value) {
143
- this.items.map((n) => n.render());
144
- this.items
145
- .filter((n) => !n.classes.includes(value))
146
- .map((n) => n.unrender());
147
- return this;
148
- }
149
- sortByTextContent(value, displays) {
150
- let item = this.children;
151
- item
152
- .filter((n) => !n.textContent.toLowerCase().includes(value.toLowerCase()))
153
- .map((n) => {
154
- n.style.display = "none";
155
- });
156
- item
157
- .filter((n) => n.textContent.toLowerCase().includes(value.toLowerCase()))
158
- .map((n, i) => (n.style.display = displays[i]));
159
- //return item.filter(n=>n.style.display!="none")
160
- item.filter((n) => n.style.display != "none");
161
- return this;
162
- }
163
122
  }
164
123
  export default ZikoUIContainerElement;
@@ -19,13 +19,18 @@ import {
19
19
  } from "../../../reactivity/index.js"
20
20
  import { Random } from "../../../math/index.js";
21
21
  import { Str } from "../../../data/index.js";
22
+ import { text } from "./text/text.js";
22
23
  class ZikoUIElement {
23
- constructor(element ,name="") {
24
+ constructor(element ,name="", el_type="html") {
24
25
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
25
26
  if(typeof element === "string") {
26
- element === "svg" ? element=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", "svg"): element = globalThis?.document?.createElement(element);
27
+ switch(el_type){
28
+ case "html" : element = globalThis?.document?.createElement(element); break;
29
+ case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
30
+ default : throw Error("Not supported")
31
+ }
27
32
  }
28
- if(element)this.element = element;
33
+ if(element)this.__ele__ = element;
29
34
  this.uuid=this.constructor.name+"-"+Random.string(10);
30
35
  this.cache = {
31
36
  name,
@@ -61,14 +66,17 @@ class ZikoUIElement {
61
66
  this.style({
62
67
  position: "relative",
63
68
  boxSizing:"border-box",
64
- // fontFamily:"verdana",
65
69
  margin:0,
66
70
  padding:0,
67
71
  });
72
+ this.items = [];
68
73
  this.size("auto", "auto");
69
74
  globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
70
75
  element && globalThis.__Ziko__.__Config__.default.render && this.render()
71
76
  }
77
+ get element(){
78
+ return this.__ele__
79
+ }
72
80
  get isZikoUIElement(){
73
81
  return true
74
82
  }
@@ -90,15 +98,6 @@ class ZikoUIElement {
90
98
  get isBody(){
91
99
  return this.element === globalThis?.document.body;
92
100
  }
93
- get __app__(){
94
- if(this.cache.isRoot)return this;
95
- let root=this.cache.parent;
96
- while(1){
97
- if(!root)return null;
98
- if(root.cache.isRoot)return root;
99
- root=root.parent;
100
- }
101
- }
102
101
  get parent(){
103
102
  return this.cache.parent;
104
103
  }
@@ -138,6 +137,120 @@ class ZikoUIElement {
138
137
  this.st.size(width,height);
139
138
  return this;
140
139
  }
140
+ maintain() {
141
+ for (let i = 0; i < this.items.length; i++)
142
+ Object.assign(this, { [[i]]: this.items[i] });
143
+ this.length = this.items.length;
144
+ return this;
145
+ }
146
+ at(index) {
147
+ return this.items.at(index);
148
+ }
149
+ #addItem(adder, pusher, ...ele) {
150
+ if (this.cache.isFrozzen) {
151
+ console.warn("You can't append new item to frozzen element");
152
+ return this;
153
+ }
154
+ for (let i = 0; i < ele.length; i++) {
155
+ if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
156
+ if (ele[i] instanceof ZikoUIElement) {
157
+ ele[i].cache.parent = this;
158
+ this.element[adder](ele[i].element);
159
+ ele[i].target = this.element;
160
+ this.items[pusher](ele[i]);
161
+ } else if (ele[i] instanceof Object) {
162
+ if (ele[i]?.style) this.style(ele[i]?.style);
163
+ if (ele[i]?.attr) {
164
+ Object.entries(ele[i].attr).forEach((n) =>
165
+ this.setAttr("" + n[0], n[1]),
166
+ );
167
+ }
168
+ }
169
+ }
170
+ this.maintain();
171
+ return this;
172
+ }
173
+ append(...ele) {
174
+ this.#addItem("append", "push", ...ele);
175
+ return this;
176
+ }
177
+ prepend(...ele) {
178
+ this.#addItem("prepend", "unshift", ...ele);
179
+ return this;
180
+ }
181
+ insertAt(index, ...ele) {
182
+ if (index >= this.element.children.length) this.append(...ele);
183
+ else
184
+ for (let i = 0; i < ele.length; i++) {
185
+ if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
186
+ this.element?.insertBefore(ele[i].element, this.items[index].element);
187
+ this.items.splice(index, 0, ele[i]);
188
+ }
189
+ return this;
190
+ }
191
+ remove(...ele) {
192
+ const remove = (ele) => {
193
+ if (typeof ele === "number") ele = this.items[ele];
194
+ if (ele instanceof ZikoUIElement) this.element?.removeChild(ele.element);
195
+ this.items = this.items.filter((n) => n !== ele);
196
+ };
197
+ for (let i = 0; i < ele.length; i++) remove(ele[i]);
198
+ for (let i = 0; i < this.items.length; i++)
199
+ Object.assign(this, { [[i]]: this.items[i] });
200
+ // Remove from item
201
+ return this;
202
+ }
203
+ forEach(callback) {
204
+ this.items.forEach(callback);
205
+ return this;
206
+ }
207
+ map(callback) {
208
+ return this.items.map(callback);
209
+ }
210
+ find(condition) {
211
+ return this.items.filter(condition);
212
+ }
213
+ filter(condition_callback, if_callback = () => {}, else_callback = () => {}) {
214
+ const FilterItems = this.items.filter(condition_callback);
215
+ FilterItems.forEach(if_callback);
216
+ this.items
217
+ .filter((item) => !FilterItems.includes(item))
218
+ .forEach(else_callback);
219
+ return this;
220
+ }
221
+ filterByTextContent(text, exactMatch = false) {
222
+ this.items.forEach((n) => n.render());
223
+ this.filter(
224
+ (n) => !(exactMatch ? n.text === text : n.text.includes(text)),
225
+ (e) => e.unrender(),
226
+ );
227
+ // this.items.filter(n=>{
228
+ // const content=n.element.textContent;
229
+ // return !(exactMatch?content===text:content.includes(text))
230
+ // }).map(n=>n.unrender());
231
+ // return this;
232
+ }
233
+ filterByClass(value) {
234
+ this.items.map((n) => n.render());
235
+ this.items
236
+ .filter((n) => !n.classes.includes(value))
237
+ .map((n) => n.unrender());
238
+ return this;
239
+ }
240
+ sortByTextContent(value, displays) {
241
+ let item = this.children;
242
+ item
243
+ .filter((n) => !n.textContent.toLowerCase().includes(value.toLowerCase()))
244
+ .map((n) => {
245
+ n.style.display = "none";
246
+ });
247
+ item
248
+ .filter((n) => n.textContent.toLowerCase().includes(value.toLowerCase()))
249
+ .map((n, i) => (n.style.display = displays[i]));
250
+ //return item.filter(n=>n.style.display!="none")
251
+ item.filter((n) => n.style.display != "none");
252
+ return this;
253
+ }
141
254
  get #SwitchedStyleRTL_LTR(){
142
255
  const CalculedStyle = globalThis.getComputedStyle(this.element);
143
256
  const SwitchedStyle = {}