ziko 1.3.0 → 1.5.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/dist/ziko.cjs +362 -90
- package/dist/ziko.js +362 -90
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +333 -91
- package/package.json +1 -1
- package/src/dom/components/for/index.js +17 -0
- package/src/dom/components/fragment/index.d.ts +36 -0
- package/src/dom/components/fragment/index.js +13 -0
- package/src/dom/components/index.js +3 -1
- package/src/dom/constructors/UIElement.js +8 -1
- package/src/math/complex/index.d.ts +207 -30
- package/src/math/functions/arithmetic/index.d.ts +95 -0
- package/src/math/functions/conversions/index.d.ts +101 -0
- package/src/math/functions/index.d.ts +97 -90
- package/src/math/functions/logic/index.d.ts +50 -8
- package/src/math/functions/logic/index.js +1 -1
- package/src/math/functions/mapfun/index.d.ts +46 -80
- package/src/math/functions/mapfun/index.d.ts.txt +162 -0
- package/src/math/functions/signal/index.d.ts +146 -0
- package/src/math/functions/stats/index.js +33 -33
- package/src/math/functions/ufunc/index.d.ts +96 -0
- package/src/math/functions/utils/index.d.ts +118 -1
- package/src/math/index.d.ts +4 -0
- package/src/math/index.js +1 -16
- package/src/math/random/index.d.ts +162 -0
- package/src/math/random/index.js +4 -4
- package/src/math/stats/accum/index.d.ts +43 -0
- package/src/math/stats/average/index.d.ts +123 -0
- package/src/math/stats/index.d.ts +5 -0
- package/src/math/stats/percentile/index.d.ts +66 -0
- package/src/math/stats/rolling/index.d.ts +47 -0
- package/src/math/stats/variability/index.d.ts +93 -0
- 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 :
|
|
5
|
+
Date : Fri Jul 31 2026 10:36:31 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
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
108
|
+
const trimmed_mean = (X, k) =>{
|
|
109
|
+
let a = [...X].sort((a,b)=>a-b).slice(k, X.length - k);
|
|
110
|
+
return mean(...a);
|
|
111
|
+
};
|
|
112
|
+
|
|
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
|
+
};
|
|
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);
|
|
127
140
|
};
|
|
128
141
|
|
|
129
|
-
const mean = (...x) => x.reduce((a, b) => a + b) / x.length;
|
|
130
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
|
|
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
|
|
143
|
-
|
|
144
|
-
|
|
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
|
|
234
|
+
const accum_product = (arr) => {
|
|
151
235
|
let result = [];
|
|
152
|
-
let prod = 1
|
|
153
|
-
for(
|
|
154
|
-
prod
|
|
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
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
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))
|
|
@@ -2889,7 +3096,14 @@ let UIElement$1 = class UIElement extends UIElementCore{
|
|
|
2889
3096
|
|
|
2890
3097
|
if(element)this.init(element, name, type, render);
|
|
2891
3098
|
}
|
|
2892
|
-
on(event_name, callback, {details_setter, category = 'global', isCustom = false,preventDefault = false} = {}){
|
|
3099
|
+
on(event_name, callback, {details_setter, category = 'global', isCustom = false, preventDefault = false} = {}){
|
|
3100
|
+
if(event_name instanceof Array) event_name.forEach(
|
|
3101
|
+
event => this.on(
|
|
3102
|
+
event,
|
|
3103
|
+
callback,
|
|
3104
|
+
{details_setter, category, isCustom, preventDefault}
|
|
3105
|
+
)
|
|
3106
|
+
);
|
|
2893
3107
|
if(category && !this.exp.events.hasOwnProperty(category)) this.exp.events[category] = new EventController(this, category);
|
|
2894
3108
|
isCustom && this.exp.events[category].cache.customEvents.add(event_name);
|
|
2895
3109
|
const EVENT = this.exp.events[category];
|
|
@@ -3559,6 +3773,34 @@ class UISwap extends UIElement$1 {
|
|
|
3559
3773
|
|
|
3560
3774
|
const Swap = call_with_optional_props(UISwap);
|
|
3561
3775
|
|
|
3776
|
+
class UIFragment extends UIElement$1{
|
|
3777
|
+
constructor(...items){
|
|
3778
|
+
super({ element : document.createDocumentFragment()});
|
|
3779
|
+
this.append(...items);
|
|
3780
|
+
}
|
|
3781
|
+
isFragment(){
|
|
3782
|
+
return true
|
|
3783
|
+
}
|
|
3784
|
+
}
|
|
3785
|
+
|
|
3786
|
+
const Fragment = (...items) => new UIFragment(...items);
|
|
3787
|
+
|
|
3788
|
+
class UIFor extends UIFragment{
|
|
3789
|
+
constructor({each, fallback, mapFn = () => {}} = {}){
|
|
3790
|
+
super();
|
|
3791
|
+
this.config = {
|
|
3792
|
+
each,
|
|
3793
|
+
fallback,
|
|
3794
|
+
mapFn
|
|
3795
|
+
};
|
|
3796
|
+
this.append(
|
|
3797
|
+
...this.config.each.map((n,i) => this.config.mapFn(n, i))
|
|
3798
|
+
);
|
|
3799
|
+
}
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3802
|
+
const For = ({each, fallback, mapFn} = {}) => new UIFor({each, fallback, mapFn});
|
|
3803
|
+
|
|
3562
3804
|
const { PI, sqrt: sqrt$1, cos: cos$2, sin: sin$2, acos, pow } = Math;
|
|
3563
3805
|
|
|
3564
3806
|
const linear = t => t;
|
|
@@ -4964,4 +5206,4 @@ if(globalThis?.document){
|
|
|
4964
5206
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
4965
5207
|
}
|
|
4966
5208
|
|
|
4967
|
-
export { App, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, 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, 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 };
|
|
5209
|
+
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.
|
|
3
|
+
"version": "1.5.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",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Fragment, UIFragment } from "../fragment/index.js";
|
|
2
|
+
|
|
3
|
+
class UIFor extends UIFragment{
|
|
4
|
+
constructor({each, fallback, mapFn = () => {}} = {}){
|
|
5
|
+
super()
|
|
6
|
+
this.config = {
|
|
7
|
+
each,
|
|
8
|
+
fallback,
|
|
9
|
+
mapFn
|
|
10
|
+
}
|
|
11
|
+
this.append(
|
|
12
|
+
...this.config.each.map((n,i) => this.config.mapFn(n, i))
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const For = ({each, fallback, mapFn} = {}) => new UIFor({each, fallback, mapFn})
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { UIElement } from "../../constructors/UIElement.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A zero-DOM container primitive that wraps child items using a DocumentFragment.
|
|
5
|
+
*/
|
|
6
|
+
export class UIFragment extends UIElement {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new UIFragment instance.
|
|
9
|
+
*
|
|
10
|
+
* @param items Initial UI elements or primitives to group within the fragment.
|
|
11
|
+
*/
|
|
12
|
+
constructor(...items: UIElement[]);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Identifies whether the element instance is a UIFragment.
|
|
16
|
+
*
|
|
17
|
+
* @returns Always returns true.
|
|
18
|
+
*/
|
|
19
|
+
isFragment(): true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Factory function to create a new `UIFragment` instance.
|
|
24
|
+
*
|
|
25
|
+
* @param items Child elements or primitives to include in the fragment.
|
|
26
|
+
* @returns A new UIFragment instance.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const group = Fragment(p("Item 1"), p("Item 2"));
|
|
31
|
+
* if (group.isFragment()) {
|
|
32
|
+
* // Unpack or handle fragment logic
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export function Fragment(...items: UIElement[]): UIFragment;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { UIElement } from "../../constructors/UIElement.js";
|
|
2
|
+
|
|
3
|
+
export class UIFragment extends UIElement{
|
|
4
|
+
constructor(...items){
|
|
5
|
+
super({ element : document.createDocumentFragment()})
|
|
6
|
+
this.append(...items);
|
|
7
|
+
}
|
|
8
|
+
isFragment(){
|
|
9
|
+
return true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Fragment = (...items) => new UIFragment(...items)
|
|
@@ -38,7 +38,14 @@ class UIElement extends UIElementCore{
|
|
|
38
38
|
|
|
39
39
|
if(element)this.init(element, name, type, render)
|
|
40
40
|
}
|
|
41
|
-
on(event_name, callback, {details_setter, category = 'global', isCustom = false,preventDefault = false} = {}){
|
|
41
|
+
on(event_name, callback, {details_setter, category = 'global', isCustom = false, preventDefault = false} = {}){
|
|
42
|
+
if(event_name instanceof Array) event_name.forEach(
|
|
43
|
+
event => this.on(
|
|
44
|
+
event,
|
|
45
|
+
callback,
|
|
46
|
+
{details_setter, category, isCustom, preventDefault}
|
|
47
|
+
)
|
|
48
|
+
)
|
|
42
49
|
if(category && !this.exp.events.hasOwnProperty(category)) this.exp.events[category] = new EventController(this, category);
|
|
43
50
|
isCustom && this.exp.events[category].cache.customEvents.add(event_name)
|
|
44
51
|
const EVENT = this.exp.events[category];
|