ziko 1.4.0 → 1.6.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.
Files changed (34) hide show
  1. package/dist/ziko.cjs +396 -117
  2. package/dist/ziko.js +396 -117
  3. package/dist/ziko.min.js +2 -2
  4. package/dist/ziko.mjs +369 -118
  5. package/package.json +1 -1
  6. package/src/dom/components/for/index.js +17 -0
  7. package/src/dom/components/index.js +2 -1
  8. package/src/dom/components/swap/index.js +3 -3
  9. package/src/dom/constructors/UIElement.js +23 -4
  10. package/src/dom/constructors/UIElementCore.js +2 -1
  11. package/src/dom/constructors/mixins/dom.js +31 -22
  12. package/src/math/complex/index.d.ts +207 -30
  13. package/src/math/functions/arithmetic/index.d.ts +95 -0
  14. package/src/math/functions/conversions/index.d.ts +101 -0
  15. package/src/math/functions/index.d.ts +97 -90
  16. package/src/math/functions/logic/index.d.ts +50 -8
  17. package/src/math/functions/logic/index.js +1 -1
  18. package/src/math/functions/mapfun/index.d.ts +46 -80
  19. package/src/math/functions/mapfun/index.d.ts.txt +162 -0
  20. package/src/math/functions/signal/index.d.ts +146 -0
  21. package/src/math/functions/stats/index.js +33 -33
  22. package/src/math/functions/ufunc/index.d.ts +96 -0
  23. package/src/math/functions/utils/index.d.ts +118 -1
  24. package/src/math/index.d.ts +4 -0
  25. package/src/math/index.js +1 -16
  26. package/src/math/random/index.d.ts +162 -0
  27. package/src/math/random/index.js +4 -4
  28. package/src/math/stats/accum/index.d.ts +43 -0
  29. package/src/math/stats/average/index.d.ts +123 -0
  30. package/src/math/stats/index.d.ts +5 -0
  31. package/src/math/stats/percentile/index.d.ts +66 -0
  32. package/src/math/stats/rolling/index.d.ts +47 -0
  33. package/src/math/stats/variability/index.d.ts +93 -0
  34. package/src/math/index.d.ts.txt +0 -5
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Thu Jul 30 2026 20:50:03 GMT+0100 (UTC+01:00)
5
+ Date : Fri Jul 31 2026 17:26:32 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -54,122 +54,212 @@ const base2base = (value, fromBase, toBase) => {
54
54
  return dec.toString(toBase);
55
55
  };
56
56
 
57
- const arithmetic_helper=(op, x, y)=>{
58
- if(typeof x === 'number'){
59
- if(typeof y === 'number'){
60
- switch(op){
61
- case 'add' : return x + y;
62
- case 'sub' : return x - y;
63
- case 'mul' : return x * y;
64
- case 'div' : return x / y;
65
- case 'modulo' : return x % y;
66
- }
67
- }
68
- if(y?.isComplex?.()) x = new y.constructor(x, 0);
69
- if(y?.isMatrix?.()) x = y.constructor.nums(y.rows, y.cols, x);
70
- return x[op](y)
71
- }
72
- if(x?.isComplex?.()){
73
- if(typeof y === 'number' || y?.isComplex?.()) return x.clone()[op](y);
74
- if(y?.isMatrix?.()){
75
- x = y.constructor.nums(y.rows, y.cols, x);
76
- return x.clone()[op](y)
77
- }
78
- }
79
- if(x?.isMatrix?.()){
80
- return x.clone()[op](y)
81
- }
57
+ const percentile = (X, p) => {
58
+ if (X.length === 0)
59
+ return NaN;
60
+ let a = X.sort((x, y) => x - y);
61
+ let index = (p / 100) * (a.length - 1);
62
+ let i = Math.floor(index);
63
+ let f = index - i;
64
+ if (i === a.length - 1)
65
+ return a[i];
66
+ return a[i] * (1 - f) + a[i + 1] * f;
82
67
  };
83
- const add=(a,...b)=>{
84
- let res = a;
85
- for(let i=0; i<b.length; i++)
86
- res = arithmetic_helper('add', res, b[i]);
87
- return res;
68
+
69
+ const q1 = X => percentile(X, 25);
70
+ const median = X => percentile(X, 50);
71
+ const q3 = X => percentile(X, 75);
72
+
73
+ // Interquartile Range
74
+ const iqr = X => q3(X) - q1(X);
75
+
76
+ // Mean
77
+ const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
78
+ const geo_mean = (...x) => (x.reduce((a, b) => a * b)) ** (1/x.length);
79
+ // Quadratic Mean
80
+ const rms = (...x) => {
81
+ const n = x.length;
82
+ return (Math.hypot(...x)/n)**(1/n)
88
83
  };
89
- const sub=(a,...b)=>{
90
- let res = a;
91
- for(let i=0; i<b.length; i++)
92
- res = arithmetic_helper('sub', res, b[i]);
93
- return res;
84
+
85
+ const weighted_mean=(values, weights)=>{
86
+ let sum = 0, sw = 0;
87
+ for (let i = 0; i < values.length; i++) {
88
+ sum += values[i] * weights[i];
89
+ sw += weights[i];
90
+ }
91
+ return sum / sw;
94
92
  };
95
- const mul=(a,...b)=>{
96
- let res = a;
97
- for(let i=0; i<b.length; i++)
98
- res = arithmetic_helper('mul', res, b[i]);
99
- return res;
93
+
94
+ const harmonic_mean = (...x) => {
95
+ let s = 0, i = 0;
96
+ for(i=0; i<x.length; i++)
97
+ s += 1/x[i];
98
+ return x.length / s;
100
99
  };
101
- const div=(a,...b)=>{
102
- let res = a;
103
- for(let i=0; i<b.length; i++)
104
- res = arithmetic_helper('div', res, b[i]);
105
- return res;
100
+
101
+ const power_mean = (X, p) =>{
102
+ let s = 0, i = 0, l = X.length;
103
+ for(i=0; i < l; i++)
104
+ s+= X[i]**p;
105
+ return (s / l) ** (1 / p);
106
106
  };
107
- const modulo=(a,...b)=>{
108
- let res = a;
109
- for(let i=0; i<b.length; i++)
110
- res = arithmetic_helper('modulo', res, b[i]);
111
- return res;
112
- };
113
-
114
- const min = (...x) => Math.min(...x);
115
- const max = (...x) => Math.max(...x);
116
107
 
117
- const binomial = (n, k) =>{
118
- if(n !== Math.floor(n)) return TypeError('n must be an integer');
119
- if(k !== Math.floor(k)) return TypeError('k must be an integer');
120
- if (n < 0) return TypeError('n must be non-negative');
121
- if (k < 0 || n < 0 || k > n) return 0;
122
- if (k > n - k) k = n - k;
123
- let c = 1, i;
124
- for (i = 0; i < k; i++)
125
- c = c * (n - i) / (i + 1);
126
- return c;
108
+ const trimmed_mean = (X, k) =>{
109
+ let a = [...X].sort((a,b)=>a-b).slice(k, X.length - k);
110
+ return mean(...a);
127
111
  };
128
112
 
129
- const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
113
+ const winsorized_mean = (X, k) =>{
114
+ let a = [...X].sort((a,b)=>a-b);
115
+ let low = a[k], high = a[a.length - k - 1];
116
+ a = a.map(x => Math.max(low, Math.min(high, x)));
117
+ return mean(a);
118
+ };
119
+
120
+ const midrange = (x) =>{
121
+ let min = Math.min(...x);
122
+ let max = Math.max(...x);
123
+ return (min + max) / 2;
124
+ };
125
+
126
+ const midhinge = (...x) =>{
127
+ let a = x.sort((a,b)=>a-b);
128
+ let q1 = a[Math.floor((a.length - 1) * 0.25)];
129
+ let q3 = a[Math.floor((a.length - 1) * 0.75)];
130
+ return (q1 + q3) / 2;
131
+ };
130
132
 
133
+
134
+ const interquartile_mean = (...x) =>{
135
+ let a = x.sort((a,b)=>a-b);
136
+ let q1 = a[Math.floor((a.length - 1) * 0.25)];
137
+ let q3 = a[Math.floor((a.length - 1) * 0.75)];
138
+ let m = a.filter(x => x >= q1 && x <= q3);
139
+ return mean(m);
140
+ };
141
+
142
+
143
+ const contraharmonic_mean = (...x) =>{
144
+ let num = 0, den = 0, i, l = x.length;
145
+ for(i = 0; i < l; i++){
146
+ num += x[i]**2;
147
+ den += x[i];
148
+ }
149
+ return num / den;
150
+ };
151
+
152
+ // Population Variance
131
153
  const variance = (...x) => {
132
154
  const n = x.length;
133
155
  if (n === 0) return NaN;
134
156
  const x_mean = mean(...x);
135
157
  return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / n;
136
158
  };
137
-
138
159
  const std = (...x) => Math.sqrt(variance(...x));
139
160
 
140
- const accum_sum = (...x) => {
161
+ const sample_variance = (...x) => {
162
+ const n = x.length;
163
+ if (n < 2) return NaN;
164
+ const x_mean = mean(...x);
165
+ return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / (n - 1);
166
+ };
167
+ const sample_std = (...x) => Math.sqrt(sample_variance(...x));
168
+
169
+ const weighted_variance = (X, weights) => {
170
+ const n = X.length;
171
+ if (n === 0 || weights.length !== n) return NaN;
172
+ const sw = weights.reduce((sum, w) => sum + w, 0);
173
+ const mean = X.reduce((sum, x, i) => sum + x * weights[i], 0) / sw;
174
+ return X.reduce((sum, x, i) => sum + weights[i] * (x - mean) ** 2, 0) / sw;
175
+ };
176
+ const weighted_std = (X, weights) => Math.sqrt(weighted_variance(X, weights));
177
+
178
+ const rolling_variance = (X, windowSize) => {
179
+ if (windowSize < 1 || X.length < windowSize) return [];
141
180
  let result = [];
142
- let total = 0, i, n = x.length;
143
- for(i = 0; i < n ; i++){
144
- total = add(total, x[i]);
181
+ for (let i = 0; i <= X.length - windowSize; i++) {
182
+ const w = X.slice(i, i + windowSize);
183
+ result.push(sample_variance(w)); // usually sample variance for rolling
184
+ }
185
+ return result;
186
+ };
187
+ const rolling_std = (X, windowSize) => Math.sqrt(rolling_variance(X, windowSize));
188
+
189
+ // Simple Moving Average
190
+ const sma = (X, w) =>{
191
+ let r = [];
192
+ for (let i = 0; i <= X.length - w; i++) {
193
+ let s = 0;
194
+ for (let j = 0; j < w; j++) s += X[i + j];
195
+ r.push(s / w);
196
+ }
197
+ return r;
198
+ };
199
+
200
+ // exponential Moving Average
201
+ const ema = (X, alpha) =>{
202
+ let r = [], prev = X[0];
203
+ r.push(prev);
204
+ for (let i = 1; i < X.length; i++) {
205
+ prev = alpha * X[i] + (1 - alpha) * prev;
206
+ r.push(prev);
207
+ }
208
+ return r;
209
+ };
210
+
211
+ // weightedMovingAverage
212
+ const wma = (X, weights) =>{
213
+ let k = weights.length;
214
+ let sw = weights.reduce((a,b)=>a+b, 0);
215
+ let r = [];
216
+ for (let i = 0; i <= X.length - k; i++) {
217
+ let s = 0;
218
+ for (let j = 0; j < k; j++) s += X[i+j] * weights[j];
219
+ r.push(s / sw);
220
+ }
221
+ return r;
222
+ };
223
+
224
+ const accum_sum = (arr) => {
225
+ let result = [];
226
+ let total = 0;
227
+ for (let x of arr) {
228
+ total += x;
145
229
  result.push(total);
146
230
  }
147
231
  return result;
148
232
  };
149
233
 
150
- const accum_prod = (...x) => {
234
+ const accum_product = (arr) => {
151
235
  let result = [];
152
- let prod = 1, i, n = x.length;
153
- for(i = 0; i < n ; i++){
154
- prod = mul(prod, x[i]);
236
+ let prod = 1;
237
+ for (let x of arr) {
238
+ prod *= x;
155
239
  result.push(prod);
156
240
  }
157
241
  return result;
158
242
  };
159
243
 
160
- const percentile = (X, p) => {
161
- if (X.length === 0)
162
- return NaN;
163
- let a = [...X].sort((x, y) => x - y);
164
- let index = (p / 100) * (a.length - 1);
165
- let i = Math.floor(index);
166
- let f = index - i;
167
- if (i === a.length - 1)
168
- return a[i];
169
- return a[i] * (1 - f) + a[i + 1] * f;
244
+ const accum_max = (arr) => {
245
+ let result = [];
246
+ let m = -Infinity;
247
+ for (let x of arr) {
248
+ m = Math.max(m, x);
249
+ result.push(m);
250
+ }
251
+ return result;
170
252
  };
171
253
 
172
- const median = X => percentile(X, 50);
254
+ const accum_min = (arr) => {
255
+ let result = [];
256
+ let m = Infinity;
257
+ for (let x of arr) {
258
+ m = Math.min(m, x);
259
+ result.push(m);
260
+ }
261
+ return result;
262
+ };
173
263
 
174
264
  class Random {
175
265
  static int(a, b){
@@ -244,9 +334,9 @@ class Random {
244
334
  static get sample(){
245
335
  const R = this;
246
336
  return {
247
- int : (n,a,b) => Array.from({length:n}, () => R.int(a,b)),
248
- float : (n,a,b) => Array.from({length:n}, () => R.float(a,b)),
249
- char : (n,upper=false) => Array.from({length:n}, () => R.char(upper)),
337
+ int : (n, a, b) => Array.from({length:n}, () => R.int(a, b)),
338
+ float : (n, a, b) => Array.from({length:n}, () => R.float(a, b)),
339
+ char : (n, upper=false) => Array.from({length:n}, () => R.char(upper)),
250
340
  bool : n => Array.from({length:n}, () => R.bool()),
251
341
  bin : n => Array.from({length:n}, () => R.bin()),
252
342
  oct : n => Array.from({length:n}, () => R.oct()),
@@ -887,6 +977,63 @@ const sig = (...x) => mapfun$1(
887
977
  ...x
888
978
  );
889
979
 
980
+ const arithmetic_helper=(op, x, y)=>{
981
+ if(typeof x === 'number'){
982
+ if(typeof y === 'number'){
983
+ switch(op){
984
+ case 'add' : return x + y;
985
+ case 'sub' : return x - y;
986
+ case 'mul' : return x * y;
987
+ case 'div' : return x / y;
988
+ case 'modulo' : return x % y;
989
+ }
990
+ }
991
+ if(y?.isComplex?.()) x = new y.constructor(x, 0);
992
+ if(y?.isMatrix?.()) x = y.constructor.nums(y.rows, y.cols, x);
993
+ return x[op](y)
994
+ }
995
+ if(x?.isComplex?.()){
996
+ if(typeof y === 'number' || y?.isComplex?.()) return x.clone()[op](y);
997
+ if(y?.isMatrix?.()){
998
+ x = y.constructor.nums(y.rows, y.cols, x);
999
+ return x.clone()[op](y)
1000
+ }
1001
+ }
1002
+ if(x?.isMatrix?.()){
1003
+ return x.clone()[op](y)
1004
+ }
1005
+ };
1006
+ const add=(a,...b)=>{
1007
+ let res = a;
1008
+ for(let i=0; i<b.length; i++)
1009
+ res = arithmetic_helper('add', res, b[i]);
1010
+ return res;
1011
+ };
1012
+ const sub=(a,...b)=>{
1013
+ let res = a;
1014
+ for(let i=0; i<b.length; i++)
1015
+ res = arithmetic_helper('sub', res, b[i]);
1016
+ return res;
1017
+ };
1018
+ const mul=(a,...b)=>{
1019
+ let res = a;
1020
+ for(let i=0; i<b.length; i++)
1021
+ res = arithmetic_helper('mul', res, b[i]);
1022
+ return res;
1023
+ };
1024
+ const div=(a,...b)=>{
1025
+ let res = a;
1026
+ for(let i=0; i<b.length; i++)
1027
+ res = arithmetic_helper('div', res, b[i]);
1028
+ return res;
1029
+ };
1030
+ const modulo=(a,...b)=>{
1031
+ let res = a;
1032
+ for(let i=0; i<b.length; i++)
1033
+ res = arithmetic_helper('modulo', res, b[i]);
1034
+ return res;
1035
+ };
1036
+
890
1037
  const deg2rad = (...deg) => mapfun$1(x => x * Math.PI / 180, ...deg);
891
1038
  const rad2deg = (...rad) => mapfun$1(x => x / Math.PI * 180, ...rad);
892
1039
 
@@ -931,6 +1078,66 @@ const atan2 = (y, x, rad = true) => {
931
1078
  return rad ? phi : phi * 180 / Math.PI;
932
1079
  };
933
1080
 
1081
+ const min = (...x) => Math.min(...x);
1082
+ const max = (...x) => Math.max(...x);
1083
+
1084
+ const binomial = (n, k) =>{
1085
+ if(n !== Math.floor(n)) return TypeError('n must be an integer');
1086
+ if(k !== Math.floor(k)) return TypeError('k must be an integer');
1087
+ if (n < 0) return TypeError('n must be non-negative');
1088
+ if (k < 0 || n < 0 || k > n) return 0;
1089
+ if (k > n - k) k = n - k;
1090
+ let c = 1, i;
1091
+ for (i = 0; i < k; i++)
1092
+ c = c * (n - i) / (i + 1);
1093
+ return c;
1094
+ };
1095
+
1096
+ // export const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
1097
+
1098
+ // export const variance = (...x) => {
1099
+ // const n = x.length;
1100
+ // if (n === 0) return NaN;
1101
+ // const x_mean = mean(...x);
1102
+ // return x.reduce((sum, xi) => sum + (xi - x_mean) ** 2, 0) / n;
1103
+ // };
1104
+
1105
+ // export const std = (...x) => Math.sqrt(variance(...x));
1106
+
1107
+ // export const accum_sum = (...x) => {
1108
+ // let result = [];
1109
+ // let total = 0, i, n = x.length;
1110
+ // for(i = 0; i < n ; i++){
1111
+ // total = add(total, x[i])
1112
+ // result.push(total);
1113
+ // }
1114
+ // return result;
1115
+ // };
1116
+
1117
+ const accum_prod = (...x) => {
1118
+ let result = [];
1119
+ let prod = 1, i, n = x.length;
1120
+ for(i = 0; i < n ; i++){
1121
+ prod = mul(prod, x[i]);
1122
+ result.push(prod);
1123
+ }
1124
+ return result;
1125
+ };
1126
+
1127
+ // export const percentile = (X, p) => {
1128
+ // if (X.length === 0)
1129
+ // return NaN;
1130
+ // let a = [...X].sort((x, y) => x - y);
1131
+ // let index = (p / 100) * (a.length - 1);
1132
+ // let i = Math.floor(index);
1133
+ // let f = index - i;
1134
+ // if (i === a.length - 1)
1135
+ // return a[i];
1136
+ // return a[i] * (1 - f) + a[i + 1] * f;
1137
+ // }
1138
+
1139
+ // export const median = X => percentile(X, 50);
1140
+
934
1141
  const not = x => {
935
1142
  if(x.isComplex?.()) return new x.constructor(not(x.a), not(x.b))
936
1143
  if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, x.arr.flat(1).map(not))
@@ -2043,6 +2250,7 @@ class UIElementCore extends UINode{
2043
2250
  else this.target = element?.parentElement;
2044
2251
  Object.assign(this.cache, {
2045
2252
  name,
2253
+ itemsTarget : this,
2046
2254
  isInteractive : false,
2047
2255
  parent:null,
2048
2256
  isBody:false,
@@ -2079,7 +2287,7 @@ class UIElementCore extends UINode{
2079
2287
  get element(){
2080
2288
  return this.cache.element;
2081
2289
  }
2082
- [Symbol.iterator]() {
2290
+ [Symbol.iterator](){
2083
2291
  return this.items[Symbol.iterator]();
2084
2292
  }
2085
2293
  maintain() {
@@ -2305,12 +2513,6 @@ class ZikoUIText extends UINode {
2305
2513
  }
2306
2514
  const text = (...str) => new ZikoUIText(...str);
2307
2515
 
2308
- // import { isStateGetter } from "../../../hooks/use-state.js";
2309
- // import {
2310
- // is_camelcase,
2311
- // camel2hyphencase
2312
- // } from '../../../data/string/index.js';
2313
-
2314
2516
  function append(...ele) {
2315
2517
  __addItem__.call(this, "append", "push", ...ele);
2316
2518
  return this;
@@ -2320,19 +2522,30 @@ function prepend(...ele) {
2320
2522
  return this;
2321
2523
  }
2322
2524
  function insertAt(index, ...ele) {
2323
- if (index >= this.element.children.length) this.append(...ele);
2324
- else
2525
+ const target = this.itemsTarget;
2526
+
2527
+ if (index >= target.items.length) return this.append(...ele);
2528
+
2325
2529
  for (let i = 0; i < ele.length; i++) {
2326
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
2327
- this.element?.insertBefore(ele[i].element, this.items[index].element);
2328
- this.items.splice(index, 0, ele[i]);
2530
+ if (["number", "string"].includes(typeof ele[i]))
2531
+ ele[i] = text(ele[i]);
2532
+
2533
+ target.element?.insertBefore(
2534
+ ele[i].element,
2535
+ target.items[index].element
2536
+ );
2537
+
2538
+ target.items.splice(index, 0, ele[i]);
2329
2539
  }
2330
- return this;
2540
+
2541
+ target.maintain();
2542
+
2543
+ return this;
2331
2544
  }
2332
2545
  function remove(...ele) {
2333
2546
  const remove = (ele) => {
2334
2547
  if (typeof ele === "number") ele = this.items[ele];
2335
- if (ele?.isUIElement) this.element?.removeChild(ele.element);
2548
+ if (ele?.isUIElement) this.itemsTarget.element?.removeChild(ele.element);
2336
2549
  this.items = this.items.filter((n) => n !== ele);
2337
2550
  };
2338
2551
  for (let i = 0; i < ele.length; i++) remove(ele[i]);
@@ -2343,7 +2556,7 @@ function remove(...ele) {
2343
2556
  }
2344
2557
  function clear(){
2345
2558
  this?.items?.forEach(n=>n.unmount());
2346
- this.element.innerHTML = "";
2559
+ this.itemsTarget.element.innerHTML = '';
2347
2560
  return this;
2348
2561
  }
2349
2562
  function replaceElementWith(new_element){
@@ -2355,12 +2568,12 @@ function replaceElementWith(new_element){
2355
2568
  }
2356
2569
  function after(ui){
2357
2570
  if(ui?.isUIElement) ui=ui.element;
2358
- this.element?.after(ui);
2571
+ this.itemsTarget.element?.after(ui);
2359
2572
  return this;
2360
2573
  }
2361
2574
  function before(ui){
2362
2575
  if(ui?.isUIElement) ui=ui.element;
2363
- this.element?.before(ui);
2576
+ this.itemsTarget.element?.before(ui);
2364
2577
  return this;
2365
2578
  }
2366
2579
 
@@ -2368,6 +2581,9 @@ function before(ui){
2368
2581
 
2369
2582
 
2370
2583
  async function __addItem__(adder, pusher, ...ele) {
2584
+ const itemsTarget_el = this.itemsTarget.element;
2585
+ const itemsTarget = this.itemsTarget;
2586
+
2371
2587
  if (this.cache.isFrozzen) {
2372
2588
  console.warn("You can't append new item to frozzen element");
2373
2589
  return this;
@@ -2383,22 +2599,22 @@ async function __addItem__(adder, pusher, ...ele) {
2383
2599
  (newValue) => (ele[i].element.textContent = newValue),
2384
2600
  ele[i]
2385
2601
  );
2386
- // this.element.appendChild(textNode);
2602
+ // this.itemsTarget.element.appendChild(textNode);
2387
2603
  }
2388
2604
  }
2389
2605
  if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
2390
2606
  if (ele[i]?.isUINode) {
2391
2607
  ele[i].cache.parent = this;
2392
- this.element?.[adder](ele[i].element);
2393
- ele[i].target = this.element;
2394
- this.items[pusher](ele[i]);
2608
+ itemsTarget_el?.[adder](ele[i].element);
2609
+ ele[i].target = this.itemsTarget.element;
2610
+ itemsTarget.items[pusher](ele[i]);
2395
2611
  }
2396
2612
  else if(ele[i] instanceof Promise){
2397
2613
  const UIEle = await ele[i];
2398
2614
  UIEle.cache.parent = this;
2399
- this.element?.[adder](UIEle.element);
2400
- UIEle.target = this.element;
2401
- this.items[pusher](UIEle);
2615
+ itemsTarget_el?.[adder](UIEle.element);
2616
+ UIEle.target = this.itemsTarget.element;
2617
+ itemsTarget.items[pusher](UIEle);
2402
2618
  }
2403
2619
  else if (ele[i] instanceof Object) {
2404
2620
  if (ele[i]?.style) this.style(ele[i]?.style);
@@ -2889,7 +3105,14 @@ let UIElement$1 = class UIElement extends UIElementCore{
2889
3105
 
2890
3106
  if(element)this.init(element, name, type, render);
2891
3107
  }
2892
- on(event_name, callback, {details_setter, category = 'global', isCustom = false,preventDefault = false} = {}){
3108
+ on(event_name, callback, {details_setter, category = 'global', isCustom = false, preventDefault = false} = {}){
3109
+ if(event_name instanceof Array) event_name.forEach(
3110
+ event => this.on(
3111
+ event,
3112
+ callback,
3113
+ {details_setter, category, isCustom, preventDefault}
3114
+ )
3115
+ );
2893
3116
  if(category && !this.exp.events.hasOwnProperty(category)) this.exp.events[category] = new EventController(this, category);
2894
3117
  isCustom && this.exp.events[category].cache.customEvents.add(event_name);
2895
3118
  const EVENT = this.exp.events[category];
@@ -2903,10 +3126,22 @@ let UIElement$1 = class UIElement extends UIElementCore{
2903
3126
  }
2904
3127
  _off(event, category = 'global'){
2905
3128
  this.exp.events[category].removeListener(event);
3129
+ return this
2906
3130
  }
2907
3131
  get element(){
2908
3132
  return this.cache.element;
2909
3133
  }
3134
+ get itemsTarget(){
3135
+ return this.cache.itemsTarget;
3136
+ }
3137
+ get itemsTargetElement(){
3138
+ return this.itemsTarget.element;
3139
+ }
3140
+ setItemsTarget(parent){
3141
+ this.cache.itemsTarget = parent;
3142
+ this.items = parent.items;
3143
+ return this;
3144
+ }
2910
3145
  isInteractive(){
2911
3146
  return this.cache.isInteractive;
2912
3147
  }
@@ -3513,14 +3748,14 @@ class UISwap extends UIElement$1 {
3513
3748
  };
3514
3749
 
3515
3750
  this.append(...items);
3516
- this.#setup();
3751
+ this.render();
3517
3752
  }
3518
3753
  get activeItem(){
3519
3754
  return this.items[this.states.activeIndex]
3520
3755
  }
3521
- #setup() {
3756
+ render() {
3522
3757
  this.items.forEach((n, i) => {
3523
- // Store initial display style (fallback to empty string or default)
3758
+
3524
3759
  const initialDisplay = n.element?.style?.display || '';
3525
3760
  this.#DISPLAYS_MAP.set(n, initialDisplay);
3526
3761
 
@@ -3571,6 +3806,22 @@ class UIFragment extends UIElement$1{
3571
3806
 
3572
3807
  const Fragment = (...items) => new UIFragment(...items);
3573
3808
 
3809
+ class UIFor extends UIFragment{
3810
+ constructor({each, fallback, mapFn = () => {}} = {}){
3811
+ super();
3812
+ this.config = {
3813
+ each,
3814
+ fallback,
3815
+ mapFn
3816
+ };
3817
+ this.append(
3818
+ ...this.config.each.map((n,i) => this.config.mapFn(n, i))
3819
+ );
3820
+ }
3821
+ }
3822
+
3823
+ const For = ({each, fallback, mapFn} = {}) => new UIFor({each, fallback, mapFn});
3824
+
3574
3825
  const { PI, sqrt: sqrt$1, cos: cos$2, sin: sin$2, acos, pow } = Math;
3575
3826
 
3576
3827
  const linear = t => t;
@@ -4976,4 +5227,4 @@ if(globalThis?.document){
4976
5227
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
4977
5228
  }
4978
5229
 
4979
- export { App, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, Fragment, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, SVGWrapper, Scheduler, Suspense, Swap, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIFlex, UIFragment, UIHTMLWrapper, UINode, UISVGWrapper, UISwap, UISwitch, UIView, UseRoot, UseThread, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUISuspense, ZikoUIText, abs, accum_prod, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arc, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cbrt, ceil, clamp, clock, cloneUI, complex, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, exp$1 as exp, floor, fract, hypot, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isPrimitive, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, ln, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, min, modulo, mul, nand, nor, norm, normalize_css_value, nthr, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, percentile, pow$1 as pow, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, round, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trunc, useDerived, useEventEmitter, useIPC, useLocalStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, xnor, xor };
5230
+ export { App, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, For, Fragment, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, SVGWrapper, Scheduler, Suspense, Swap, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIFlex, UIFragment, UIHTMLWrapper, UINode, UISVGWrapper, UISwap, UISwitch, UIView, UseRoot, UseThread, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUISuspense, ZikoUIText, abs, accum_max, accum_min, accum_prod, accum_product, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arc, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cbrt, ceil, clamp, clock, cloneUI, complex, contraharmonic_mean, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, ema, exp$1 as exp, floor, fract, geo_mean, harmonic_mean, hypot, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, interquartile_mean, iqr, isPrimitive, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, ln, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, midhinge, midrange, min, modulo, mul, nand, nor, norm, normalize_css_value, not, nthr, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, percentile, pow$1 as pow, power_mean, q1, q3, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, rms, rolling_std, rolling_variance, round, sample_std, sample_variance, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sma, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trimmed_mean, trunc, useDerived, useEventEmitter, useIPC, useLocalStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, weighted_mean, weighted_std, weighted_variance, winsorized_mean, wma, xnor, xor };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "1.4.0",
3
+ "version": "1.6.0",
4
4
  "description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
5
5
  "keywords": [
6
6
  "front-end",