ziko 0.37.0 → 0.38.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 +1160 -3365
- package/dist/ziko.js +6179 -8384
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +1153 -3251
- package/package.json +15 -13
- package/readme.md +79 -5
- package/src/__ziko__/__cache__.js +6 -0
- package/src/__ziko__/__config__.js +19 -0
- package/src/__ziko__/__hydration__.js +8 -0
- package/src/__ziko__/__ui__.js +22 -0
- package/src/__ziko__/index.js +16 -0
- package/src/__ziko__/params.js +40 -0
- package/src/app/globals.js +14 -0
- package/src/app/index.js +4 -4
- package/src/app/spa-file-based-routing.js +2 -2
- package/src/app/ziko-app.js +1 -1
- package/src/data/converter/svg.js +2 -2
- package/src/hooks/index.js +3 -0
- package/src/hooks/use-derived.js +61 -0
- package/src/hooks/use-reactive.js +7 -0
- package/src/hooks/use-state.js +47 -0
- package/src/index.js +1 -78
- package/src/math/complex/index.js +3 -0
- package/src/math/functions/index.js +23 -23
- package/src/math/functions/proxy.js +58 -0
- package/src/math/utils/mapfun.js +17 -21
- package/src/no-module.js +32 -0
- package/src/time/{animation.js → animation/index.js} +2 -2
- package/src/time/decorators/index.js +17 -0
- package/src/time/index.js +11 -12
- package/src/time/utils/index.js +0 -1
- package/src/ui/{methods → __methods__}/dom.js +15 -14
- package/src/ui/{utils → __utils__}/index.js +1 -1
- package/src/ui/constructors/{ziko-ui-element.js → ZikoUIElement.js} +9 -98
- package/src/ui/constructors/ZikoUIElementMethodesToBeMoved.js +96 -0
- package/src/ui/{style → constructors/style}/index.js +3 -3
- package/src/ui/{elements/flex → flex}/index.js +1 -1
- package/src/{graphics/canvas/index.js → ui/graphics/canvas.js} +4 -5
- package/src/ui/graphics/index.js +2 -0
- package/src/{graphics/svg/index.js → ui/graphics/svg.js} +1 -1
- package/src/ui/{elements/grid → grid}/index.js +1 -1
- package/src/ui/index.js +9 -40
- package/src/ui/{elements/misc/suspense.js → suspense/index.js} +1 -15
- package/src/ui/tags/index.js +3 -3
- package/src/ui/text/index.js +15 -0
- package/src/ui/{elements/misc/xml-wrapper.js → wrapper/index.js} +1 -1
- package/src/use/index.js +3 -7
- package/src/graphics/canvas/_canvas_offscreen +0 -0
- package/src/graphics/canvas/utils/color.js +0 -8
- package/src/graphics/canvas/utils/floodFill.js +0 -57
- package/src/graphics/index.js +0 -10
- package/src/time/utils/decorators.js +0 -17
- package/src/ui/elements/embaded/html.js +0 -20
- package/src/ui/elements/embaded/index.js +0 -3
- package/src/ui/elements/embaded/pdf.js +0 -17
- package/src/ui/elements/embaded/youtube.js +0 -24
- package/src/ui/elements/hydrate.js +0 -0
- package/src/ui/elements/index.js +0 -10
- package/src/ui/elements/io/Form/index.js +0 -42
- package/src/ui/elements/io/Form/index.js.txt +0 -104
- package/src/ui/elements/io/Inputs/__helpers__.js +0 -52
- package/src/ui/elements/io/Inputs/index.js +0 -12
- package/src/ui/elements/io/Inputs/input/index.js +0 -99
- package/src/ui/elements/io/Inputs/input-camera/index.js +0 -26
- package/src/ui/elements/io/Inputs/input-checkbox/index.js +0 -26
- package/src/ui/elements/io/Inputs/input-color/index.js +0 -16
- package/src/ui/elements/io/Inputs/input-date-time/index.js +0 -3
- package/src/ui/elements/io/Inputs/input-date-time/input-date-time.js +0 -14
- package/src/ui/elements/io/Inputs/input-date-time/input-date.js +0 -14
- package/src/ui/elements/io/Inputs/input-date-time/input-time.js +0 -14
- package/src/ui/elements/io/Inputs/input-email-password/index.js +0 -2
- package/src/ui/elements/io/Inputs/input-email-password/input-email.js +0 -15
- package/src/ui/elements/io/Inputs/input-email-password/input-password.js +0 -14
- package/src/ui/elements/io/Inputs/input-file/index.js +0 -1
- package/src/ui/elements/io/Inputs/input-file/input-file.js +0 -0
- package/src/ui/elements/io/Inputs/input-file/input-image.js +0 -43
- package/src/ui/elements/io/Inputs/input-number/index.js +0 -37
- package/src/ui/elements/io/Inputs/input-radio/index.js +0 -26
- package/src/ui/elements/io/Inputs/input-search/index.js +0 -45
- package/src/ui/elements/io/Inputs/input-slider/index.js +0 -34
- package/src/ui/elements/io/Select/index.js +0 -20
- package/src/ui/elements/io/Textarea/index.js +0 -18
- package/src/ui/elements/io/index.js +0 -4
- package/src/ui/elements/list/elements.js +0 -0
- package/src/ui/elements/list/index.js +0 -138
- package/src/ui/elements/media/Audio/index.js +0 -17
- package/src/ui/elements/media/Image/figure.js +0 -19
- package/src/ui/elements/media/Image/image.js +0 -37
- package/src/ui/elements/media/Image/index.js +0 -2
- package/src/ui/elements/media/Video/index.js +0 -27
- package/src/ui/elements/media/__ZikoUIDynamicMediaELement__.js +0 -47
- package/src/ui/elements/media/index.js +0 -3
- package/src/ui/elements/misc/hyperscript.js +0 -144
- package/src/ui/elements/misc/index.js +0 -101
- package/src/ui/elements/semantic/index.js +0 -42
- package/src/ui/elements/table/elements.js +0 -94
- package/src/ui/elements/table/index.js +0 -3
- package/src/ui/elements/table/table.js +0 -115
- package/src/ui/elements/table/utils.js +0 -12
- package/src/ui/elements/text/__ZikoUIText__.js +0 -70
- package/src/ui/elements/text/heading.js +0 -36
- package/src/ui/elements/text/index.js +0 -3
- package/src/ui/elements/text/p.js +0 -26
- package/src/ui/elements/text/pre.js +0 -0
- package/src/ui/elements/text/text.js +0 -81
- package/src/use/use-debounce.js +0 -4
- package/src/use/use-state.js +0 -22
- package/src/use/use-throttle.js +0 -9
- /package/src/reactivity/hooks/{Head → head}/_useCssText.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/index.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useFavIcon.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useHead.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useMeta.js +0 -0
- /package/src/reactivity/hooks/{Head → head}/useTitle.js +0 -0
- /package/src/time/{loop.js → loop/index.js} +0 -0
- /package/src/ui/{methods → __methods__}/events.js +0 -0
- /package/src/ui/{methods → __methods__}/indexing.js +0 -0
- /package/src/ui/{methods → __methods__}/observer.js +0 -0
- /package/src/ui/{methods → __methods__}/style.js +0 -0
- /package/src/ui/constructors/{ziko-ui-node.js → ZikoUINode.js} +0 -0
- /package/src/ui/tags/{tags.js → tags-list.js} +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
let {abs, sqrt, cos, sin, tan, exp, log, cosh, sinh, tanh} = Math;
|
|
2
|
+
// Math.abs = new Proxy(Math.abs, {
|
|
3
|
+
// apply(target, thisArg, args) {
|
|
4
|
+
// const x = args[0]
|
|
5
|
+
// if(typeof x === 'number') return target.apply(thisArg, args);
|
|
6
|
+
// if(x?.isComplex?.()){
|
|
7
|
+
// const {a, b, z, phi} = x
|
|
8
|
+
// const complex = (a, b) => new x.constructor(a, b)
|
|
9
|
+
// switch(target.name){
|
|
10
|
+
// case 'abs' : return a.z;
|
|
11
|
+
// case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
|
|
12
|
+
// }
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
// }
|
|
16
|
+
// });
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
for (const key of Object.getOwnPropertyNames(Math)) {
|
|
20
|
+
const fn = Math[key];
|
|
21
|
+
if (typeof fn === "function") {
|
|
22
|
+
Math[key] = new Proxy(fn, {
|
|
23
|
+
apply(target, thisArg, args) {
|
|
24
|
+
// console.log(target)
|
|
25
|
+
const x = args[0]
|
|
26
|
+
if(typeof x === 'number' || args.length === 0) return target.apply(thisArg, args);
|
|
27
|
+
if(x?.isComplex?.()){
|
|
28
|
+
const {a, b, z, phi} = x
|
|
29
|
+
const complex = (a, b) => new x.constructor(a, b);
|
|
30
|
+
switch(target.name){
|
|
31
|
+
case 'abs' : return x.z;
|
|
32
|
+
case 'sqrt' : return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2));
|
|
33
|
+
case 'log' : return complex(log(z), phi);
|
|
34
|
+
case 'exp' : return complex(exp(a)*cos(b),exp(a)*sin(b));
|
|
35
|
+
case 'cos' : return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
|
|
36
|
+
case 'sin' : return complex(sin(a)*cosh(b),cos(a)*sinh(b));
|
|
37
|
+
case 'tan' : {
|
|
38
|
+
const DEN = cos(2*a)+cosh(2*b);
|
|
39
|
+
return complex(sin(2*a) /DEN, sinh(2*b)/DEN);
|
|
40
|
+
}
|
|
41
|
+
case 'cosh' : return complex(cosh(a)*cos(b),sinh(a)*sin(b));
|
|
42
|
+
case 'sinh' : return complex(sinh(a)*cos(b),cosh(a)*sin(b));
|
|
43
|
+
case 'tanh' : {
|
|
44
|
+
const DEN=cosh(2*a)+cos(2*b);
|
|
45
|
+
return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
|
|
46
|
+
}
|
|
47
|
+
default : return target.apply(thisArg, args)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// if( x.isMatrix?.()){
|
|
51
|
+
// const {rows, cols, arr} = x
|
|
52
|
+
// // return new x.constructor(rows, cols, arr.flat(1).map(n=>));
|
|
53
|
+
// }
|
|
54
|
+
throw new TypeError(`Math.${key} expects only numbers`);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
package/src/math/utils/mapfun.js
CHANGED
|
@@ -1,36 +1,31 @@
|
|
|
1
|
-
/** @module Math */
|
|
2
1
|
import { Matrix } from "../matrix/index.js";
|
|
3
2
|
import { Complex , complex } from "../complex/index.js";
|
|
4
3
|
import {ln,e,cos,sin,sqrt,cosh,sinh} from "../functions/index.js";
|
|
5
4
|
import { Fixed } from "../functions/helper.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @param {function} fun
|
|
9
|
-
* @param {...any} X
|
|
10
|
-
* @returns {any|any[]}
|
|
11
|
-
*/
|
|
5
|
+
// To generalise
|
|
6
|
+
|
|
12
7
|
const mapfun=(fun,...X)=>{
|
|
13
8
|
const Y=X.map(x=>{
|
|
14
|
-
if(x===null)return fun(null);
|
|
15
|
-
if(["number","string","boolean","bigint","undefined"].includes(typeof x))return fun(x);
|
|
16
|
-
if(x instanceof Array)return x.map(n=>mapfun(fun,n));
|
|
17
|
-
if(ArrayBuffer.isView(x))return x.map(n=>fun(n));
|
|
18
|
-
if(x instanceof Set)return new Set(mapfun(fun,...[...x]));
|
|
19
|
-
if(x instanceof Map)return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
|
|
9
|
+
if(x===null) return fun(null);
|
|
10
|
+
if(["number","string","boolean","bigint","undefined"].includes(typeof x)) return fun(x);
|
|
11
|
+
if(x instanceof Array) return x.map(n=>mapfun(fun,n));
|
|
12
|
+
if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
|
|
13
|
+
if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
|
|
14
|
+
if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
|
|
20
15
|
if(x instanceof Matrix){
|
|
21
|
-
return new Matrix(x.rows,x.cols,mapfun(x.arr.flat(1)))
|
|
16
|
+
return new Matrix(x.rows,x.cols, mapfun(x.arr.flat(1)))
|
|
22
17
|
}
|
|
23
18
|
if(x instanceof Complex){
|
|
24
19
|
const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
|
|
25
20
|
switch(fun){
|
|
26
|
-
case Math.log:return complex(ln(z),phi); // Done
|
|
27
|
-
case Math.exp:return complex(e(a)*cos(b),e(a)*sin(b)); // Done
|
|
28
|
-
case Math.abs:return z; // Done
|
|
29
|
-
case Math.sqrt:return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
|
|
30
|
-
case Fixed.cos:return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
|
|
31
|
-
case Fixed.sin:return complex(sin(a)*cosh(b),cos(a)*sinh(b));
|
|
21
|
+
case Math.log: return complex(ln(z),phi); // Done
|
|
22
|
+
case Math.exp: return complex(e(a)*cos(b),e(a)*sin(b)); // Done
|
|
23
|
+
case Math.abs: return z; // Done
|
|
24
|
+
case Math.sqrt: return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
|
|
25
|
+
case Fixed.cos: return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
|
|
26
|
+
case Fixed.sin: return complex(sin(a)*cosh(b),cos(a)*sinh(b));
|
|
32
27
|
case Fixed.tan:{
|
|
33
|
-
const DEN=cos(2*a)+cosh(2*b);
|
|
28
|
+
const DEN = cos(2*a)+cosh(2*b);
|
|
34
29
|
return complex(sin(2*a)/DEN,sinh(2*b)/DEN);
|
|
35
30
|
}
|
|
36
31
|
case Fixed.cosh:return complex(cosh(a)*cos(b),sinh(a)*sin(b));
|
|
@@ -43,6 +38,7 @@ const mapfun=(fun,...X)=>{
|
|
|
43
38
|
}
|
|
44
39
|
}
|
|
45
40
|
else if(x instanceof Object){
|
|
41
|
+
return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
|
|
46
42
|
return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
|
|
47
43
|
}
|
|
48
44
|
});
|
package/src/no-module.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// import { __ExtractAll__,__RemoveAll__ } from "./__helpers__/index.js";
|
|
2
|
+
|
|
3
|
+
// [
|
|
4
|
+
// App,
|
|
5
|
+
// Math,
|
|
6
|
+
// UI,
|
|
7
|
+
// Time,
|
|
8
|
+
// Data,
|
|
9
|
+
// Reactivity,
|
|
10
|
+
// Graphics,
|
|
11
|
+
// ].forEach(n=>Object.assign(n,{
|
|
12
|
+
// ExtractAll:()=>__ExtractAll__(n),
|
|
13
|
+
// RemoveAll:()=>__RemoveAll__(n)
|
|
14
|
+
// }))
|
|
15
|
+
|
|
16
|
+
// function ExtractAll(){
|
|
17
|
+
// UI.ExtractAll();
|
|
18
|
+
// Math.ExtractAll();
|
|
19
|
+
// Time.ExtractAll();
|
|
20
|
+
// Reactivity.ExtractAll();
|
|
21
|
+
// Graphics.ExtractAll();
|
|
22
|
+
// Data.ExtractAll()
|
|
23
|
+
// return this;
|
|
24
|
+
// }
|
|
25
|
+
// function RemoveAll(){
|
|
26
|
+
// UI.RemoveAll();
|
|
27
|
+
// Math.RemoveAll();
|
|
28
|
+
// Time.RemoveAll();
|
|
29
|
+
// Reactivity.RemoveAll();
|
|
30
|
+
// Graphics.RemoveAll();
|
|
31
|
+
// Data.RemoveAll()
|
|
32
|
+
// }
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Ease } from "
|
|
2
|
-
import { map } from "
|
|
1
|
+
import { Ease } from "../utils";
|
|
2
|
+
import { map } from "../../math/utils"
|
|
3
3
|
class ZikoTimeAnimation{
|
|
4
4
|
constructor(callback,ease=Ease.Linear,step=50,{t=[0,null],start=true,duration=3000}={}){
|
|
5
5
|
this.cache={
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const debounce=(fn,delay=1000)=>{
|
|
2
|
+
let id;
|
|
3
|
+
return(...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
|
|
4
|
+
}
|
|
5
|
+
const throttle=(fn,delay)=>{
|
|
6
|
+
let lastTime=0;
|
|
7
|
+
return (...args) => {
|
|
8
|
+
const now = new Date().getTime()
|
|
9
|
+
if(now-lastTime < delay) return;
|
|
10
|
+
lastTime = now;
|
|
11
|
+
fn(...args);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export{
|
|
15
|
+
debounce,
|
|
16
|
+
throttle
|
|
17
|
+
}
|
package/src/time/index.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
|
|
5
|
-
import * as
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default Time
|
|
1
|
+
export * from './loop/index.js'
|
|
2
|
+
export * from './animation/index.js'
|
|
3
|
+
export * from './utils/index.js';
|
|
4
|
+
export * from './decorators/index.js';
|
|
5
|
+
// import * as Utils from './utils'
|
|
6
|
+
// const Time = {
|
|
7
|
+
// ...Loop,
|
|
8
|
+
// ...Animation,
|
|
9
|
+
// ...Utils
|
|
10
|
+
// }
|
|
11
|
+
// export default Time
|
package/src/time/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { text } from "../
|
|
1
|
+
import { text } from "../text/index.js";
|
|
2
2
|
export const DomMethods = {
|
|
3
3
|
append(...ele) {
|
|
4
4
|
__addItem__.call(this, "append", "push", ...ele);
|
|
@@ -75,24 +75,25 @@ function __addItem__(adder, pusher, ...ele) {
|
|
|
75
75
|
}
|
|
76
76
|
for (let i = 0; i < ele.length; i++) {
|
|
77
77
|
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
78
|
-
|
|
79
|
-
if (ele[i]
|
|
80
|
-
|
|
81
|
-
this.element[adder](ele[i].element);
|
|
82
|
-
ele[i].target = this.element;
|
|
83
|
-
this.items[pusher](ele[i]);
|
|
84
|
-
}
|
|
85
|
-
// Fix Items Latter
|
|
86
|
-
if( ele[i] instanceof Function){
|
|
87
|
-
const getter = ele[i]();
|
|
78
|
+
// Fix Items Latter
|
|
79
|
+
if (ele[i] instanceof Function) {
|
|
80
|
+
const getter = ele[i]();
|
|
88
81
|
if (getter.isStateGetter) {
|
|
89
|
-
|
|
90
|
-
this.element.appendChild(textNode);
|
|
82
|
+
ele[i] = text(getter.value);
|
|
91
83
|
getter._subscribe(
|
|
92
|
-
|
|
84
|
+
(newValue) => (ele[i].element.textContent = newValue),
|
|
85
|
+
ele[i]
|
|
93
86
|
);
|
|
87
|
+
// this.element.appendChild(textNode);
|
|
94
88
|
}
|
|
95
89
|
}
|
|
90
|
+
if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
|
|
91
|
+
if (ele[i]?.isZikoUINode) {
|
|
92
|
+
ele[i].cache.parent = this;
|
|
93
|
+
this.element?.[adder](ele[i].element);
|
|
94
|
+
ele[i].target = this.element;
|
|
95
|
+
this.items[pusher](ele[i]);
|
|
96
|
+
}
|
|
96
97
|
else if (ele[i] instanceof Object) {
|
|
97
98
|
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
98
99
|
if (ele[i]?.attr) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import ZikoUINode from "./
|
|
1
|
+
import ZikoUINode from "./ZikoUINode.js";
|
|
2
2
|
import { compose } from "../../__helpers__/index.js";
|
|
3
|
-
import { DomMethods } from "../
|
|
4
|
-
import { IndexingMethods } from "../
|
|
5
|
-
import { EventsMethodes } from "../
|
|
3
|
+
import { DomMethods } from "../__methods__/dom.js";
|
|
4
|
+
import { IndexingMethods } from "../__methods__/indexing.js";
|
|
5
|
+
import { EventsMethodes } from "../__methods__/events.js";
|
|
6
6
|
import { ZikoUseStyle } from "../../reactivity/hooks/UI/useStyle.js";
|
|
7
|
-
import { ZikoUIElementStyle } from "
|
|
7
|
+
import { ZikoUIElementStyle } from "./style/index.js";
|
|
8
8
|
import {
|
|
9
9
|
useCustomEvent,
|
|
10
10
|
useSwipeEvent,
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from "../../reactivity/index.js"
|
|
16
16
|
import { Random } from "../../math/index.js";
|
|
17
17
|
import { Str } from "../../data/index.js";
|
|
18
|
+
import '../../__ziko__/index.js';
|
|
18
19
|
class ZikoUIElement extends ZikoUINode{
|
|
19
20
|
constructor(element, name="", {el_type="html", useDefaultStyle=false}={}){
|
|
20
21
|
super()
|
|
@@ -105,7 +106,6 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
105
106
|
isInteractive(){
|
|
106
107
|
return this.cache.isInteractive;
|
|
107
108
|
}
|
|
108
|
-
// Remove get
|
|
109
109
|
isZikoUIElement(){
|
|
110
110
|
return true;
|
|
111
111
|
}
|
|
@@ -183,82 +183,6 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
183
183
|
});
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
-
filter(condition_callback, if_callback = () => {}, else_callback = () => {}) {
|
|
187
|
-
const FilterItems = this.items.filter(condition_callback);
|
|
188
|
-
FilterItems.forEach(if_callback);
|
|
189
|
-
this.items
|
|
190
|
-
.filter((item) => !FilterItems.includes(item))
|
|
191
|
-
.forEach(else_callback);
|
|
192
|
-
return this;
|
|
193
|
-
}
|
|
194
|
-
filterByTextContent(text, exactMatch = false) {
|
|
195
|
-
this.items.forEach((n) => n.render());
|
|
196
|
-
this.filter(
|
|
197
|
-
(n) => !(exactMatch ? n.text === text : n.text.includes(text)),
|
|
198
|
-
(e) => e.unrender(),
|
|
199
|
-
);
|
|
200
|
-
// this.items.filter(n=>{
|
|
201
|
-
// const content=n.element.textContent;
|
|
202
|
-
// return !(exactMatch?content===text:content.includes(text))
|
|
203
|
-
// }).map(n=>n.unrender());
|
|
204
|
-
// return this;
|
|
205
|
-
}
|
|
206
|
-
filterByClass(value) {
|
|
207
|
-
this.items.map((n) => n.render());
|
|
208
|
-
this.items
|
|
209
|
-
.filter((n) => !n.classes.includes(value))
|
|
210
|
-
.map((n) => n.unrender());
|
|
211
|
-
return this;
|
|
212
|
-
}
|
|
213
|
-
sortByTextContent(value, displays) {
|
|
214
|
-
let item = this.children;
|
|
215
|
-
item
|
|
216
|
-
.filter((n) => !n.textContent.toLowerCase().includes(value.toLowerCase()))
|
|
217
|
-
.map((n) => {
|
|
218
|
-
n.style.display = "none";
|
|
219
|
-
});
|
|
220
|
-
item
|
|
221
|
-
.filter((n) => n.textContent.toLowerCase().includes(value.toLowerCase()))
|
|
222
|
-
.map((n, i) => (n.style.display = displays[i]));
|
|
223
|
-
//return item.filter(n=>n.style.display!="none")
|
|
224
|
-
item.filter((n) => n.style.display != "none");
|
|
225
|
-
return this;
|
|
226
|
-
}
|
|
227
|
-
get #SwitchedStyleRTL_LTR(){
|
|
228
|
-
const CalculedStyle = globalThis.getComputedStyle(this.element);
|
|
229
|
-
const SwitchedStyle = {}
|
|
230
|
-
if(CalculedStyle.marginRight!=="0px")Object.assign(SwitchedStyle, {marginLeft: CalculedStyle.marginRight});
|
|
231
|
-
if(CalculedStyle.marginLeft!=="0px")Object.assign(SwitchedStyle, {marginRight: CalculedStyle.marginLeft});
|
|
232
|
-
if(CalculedStyle.paddingRight!=="0px")Object.assign(SwitchedStyle, {paddingLeft: CalculedStyle.paddingRight});
|
|
233
|
-
if(CalculedStyle.paddingLeft!=="0px")Object.assign(SwitchedStyle, {paddingRight: CalculedStyle.paddingLeft});
|
|
234
|
-
if(CalculedStyle.left!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.left});
|
|
235
|
-
if(CalculedStyle.right!=="0px")Object.assign(SwitchedStyle, {left: CalculedStyle.right});
|
|
236
|
-
if(CalculedStyle.textAlign === "right")Object.assign(SwitchedStyle, {textAlign: "left"});
|
|
237
|
-
if(CalculedStyle.textAlign === "left")Object.assign(SwitchedStyle, {textAlign: "right"});
|
|
238
|
-
if(CalculedStyle.float === "right")Object.assign(SwitchedStyle, {float: "left"});
|
|
239
|
-
if(CalculedStyle.float === "left")Object.assign(SwitchedStyle, {float: "right"});
|
|
240
|
-
if(CalculedStyle.borderRadiusLeft!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusRight});
|
|
241
|
-
if(CalculedStyle.borderRadiusRight!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusLeft});
|
|
242
|
-
if(["flex","inline-flex"].includes(CalculedStyle.display)){
|
|
243
|
-
if(CalculedStyle.justifyContent === "flex-end")Object.assign(SwitchedStyle, {justifyContent: "flex-start"});
|
|
244
|
-
if(CalculedStyle.justifyContent === "flex-start")Object.assign(SwitchedStyle, {justifyContent: "flex-end"});
|
|
245
|
-
}
|
|
246
|
-
return SwitchedStyle;
|
|
247
|
-
}
|
|
248
|
-
useRtl(switchAll = false){
|
|
249
|
-
switchAll ? this.style({
|
|
250
|
-
...this.#SwitchedStyleRTL_LTR,
|
|
251
|
-
direction : "rtl"
|
|
252
|
-
}) : this.style({direction : "rtl"});
|
|
253
|
-
return this;
|
|
254
|
-
}
|
|
255
|
-
useLtr(switchAll = false){
|
|
256
|
-
switchAll ? this.style({
|
|
257
|
-
...this.#SwitchedStyleRTL_LTR,
|
|
258
|
-
direction : "ltr"
|
|
259
|
-
}) : this.style({direction : "ltr"});
|
|
260
|
-
return this;
|
|
261
|
-
}
|
|
262
186
|
freeze(freeze){
|
|
263
187
|
this.cache.isFrozzen=freeze;
|
|
264
188
|
return this;
|
|
@@ -280,9 +204,9 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
280
204
|
}
|
|
281
205
|
// Attributes
|
|
282
206
|
#setAttr(name, value){
|
|
283
|
-
if(this.element
|
|
207
|
+
if(this.element?.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
|
|
284
208
|
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
285
|
-
this.element
|
|
209
|
+
this.element?.setAttribute(name, value)
|
|
286
210
|
Object.assign(this.cache.attributes, {[name]:value});
|
|
287
211
|
}
|
|
288
212
|
setAttr(name, value) {
|
|
@@ -380,19 +304,6 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
380
304
|
this.observer.intersection.start();
|
|
381
305
|
return this;
|
|
382
306
|
}
|
|
383
|
-
|
|
384
|
-
// if(!this.element.requestFullscreen){
|
|
385
|
-
// console.error("Fullscreen API is not supported in this browser.");
|
|
386
|
-
// return this;
|
|
387
|
-
// }
|
|
388
|
-
// if (set) this.element.requestFullscreen(e);
|
|
389
|
-
// else globalThis.document.exitFullscreen();
|
|
390
|
-
// return this;
|
|
391
|
-
// }
|
|
392
|
-
// toggleFullScreen(e) {
|
|
393
|
-
// if (!globalThis.document.fullscreenElement) this.element.requestFullscreen(e);
|
|
394
|
-
// else globalThis.document.exitFullscreen();
|
|
395
|
-
// return this;
|
|
396
|
-
// }
|
|
307
|
+
|
|
397
308
|
}
|
|
398
309
|
export default ZikoUIElement;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
class Ziko{
|
|
2
|
+
get #SwitchedStyleRTL_LTR(){
|
|
3
|
+
const CalculedStyle = globalThis.getComputedStyle(this.element);
|
|
4
|
+
const SwitchedStyle = {}
|
|
5
|
+
if(CalculedStyle.marginRight!=="0px")Object.assign(SwitchedStyle, {marginLeft: CalculedStyle.marginRight});
|
|
6
|
+
if(CalculedStyle.marginLeft!=="0px")Object.assign(SwitchedStyle, {marginRight: CalculedStyle.marginLeft});
|
|
7
|
+
if(CalculedStyle.paddingRight!=="0px")Object.assign(SwitchedStyle, {paddingLeft: CalculedStyle.paddingRight});
|
|
8
|
+
if(CalculedStyle.paddingLeft!=="0px")Object.assign(SwitchedStyle, {paddingRight: CalculedStyle.paddingLeft});
|
|
9
|
+
if(CalculedStyle.left!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.left});
|
|
10
|
+
if(CalculedStyle.right!=="0px")Object.assign(SwitchedStyle, {left: CalculedStyle.right});
|
|
11
|
+
if(CalculedStyle.textAlign === "right")Object.assign(SwitchedStyle, {textAlign: "left"});
|
|
12
|
+
if(CalculedStyle.textAlign === "left")Object.assign(SwitchedStyle, {textAlign: "right"});
|
|
13
|
+
if(CalculedStyle.float === "right")Object.assign(SwitchedStyle, {float: "left"});
|
|
14
|
+
if(CalculedStyle.float === "left")Object.assign(SwitchedStyle, {float: "right"});
|
|
15
|
+
if(CalculedStyle.borderRadiusLeft!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusRight});
|
|
16
|
+
if(CalculedStyle.borderRadiusRight!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusLeft});
|
|
17
|
+
if(["flex","inline-flex"].includes(CalculedStyle.display)){
|
|
18
|
+
if(CalculedStyle.justifyContent === "flex-end")Object.assign(SwitchedStyle, {justifyContent: "flex-start"});
|
|
19
|
+
if(CalculedStyle.justifyContent === "flex-start")Object.assign(SwitchedStyle, {justifyContent: "flex-end"});
|
|
20
|
+
}
|
|
21
|
+
return SwitchedStyle;
|
|
22
|
+
}
|
|
23
|
+
useRtl(switchAll = false){
|
|
24
|
+
switchAll ? this.style({
|
|
25
|
+
...this.#SwitchedStyleRTL_LTR,
|
|
26
|
+
direction : "rtl"
|
|
27
|
+
}) : this.style({direction : "rtl"});
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
useLtr(switchAll = false){
|
|
31
|
+
switchAll ? this.style({
|
|
32
|
+
...this.#SwitchedStyleRTL_LTR,
|
|
33
|
+
direction : "ltr"
|
|
34
|
+
}) : this.style({direction : "ltr"});
|
|
35
|
+
return this;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
filter(condition_callback, if_callback = () => {}, else_callback = () => {}) {
|
|
41
|
+
const FilterItems = this.items.filter(condition_callback);
|
|
42
|
+
FilterItems.forEach(if_callback);
|
|
43
|
+
this.items
|
|
44
|
+
.filter((item) => !FilterItems.includes(item))
|
|
45
|
+
.forEach(else_callback);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
filterByTextContent(text, exactMatch = false) {
|
|
49
|
+
this.items.forEach((n) => n.render());
|
|
50
|
+
this.filter(
|
|
51
|
+
(n) => !(exactMatch ? n.text === text : n.text.includes(text)),
|
|
52
|
+
(e) => e.unrender(),
|
|
53
|
+
);
|
|
54
|
+
// this.items.filter(n=>{
|
|
55
|
+
// const content=n.element.textContent;
|
|
56
|
+
// return !(exactMatch?content===text:content.includes(text))
|
|
57
|
+
// }).map(n=>n.unrender());
|
|
58
|
+
// return this;
|
|
59
|
+
}
|
|
60
|
+
filterByClass(value) {
|
|
61
|
+
this.items.map((n) => n.render());
|
|
62
|
+
this.items
|
|
63
|
+
.filter((n) => !n.classes.includes(value))
|
|
64
|
+
.map((n) => n.unrender());
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
sortByTextContent(value, displays) {
|
|
68
|
+
let item = this.children;
|
|
69
|
+
item
|
|
70
|
+
.filter((n) => !n.textContent.toLowerCase().includes(value.toLowerCase()))
|
|
71
|
+
.map((n) => {
|
|
72
|
+
n.style.display = "none";
|
|
73
|
+
});
|
|
74
|
+
item
|
|
75
|
+
.filter((n) => n.textContent.toLowerCase().includes(value.toLowerCase()))
|
|
76
|
+
.map((n, i) => (n.style.display = displays[i]));
|
|
77
|
+
//return item.filter(n=>n.style.display!="none")
|
|
78
|
+
item.filter((n) => n.style.display != "none");
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// setFullScreen(set = true, e) {
|
|
83
|
+
// if(!this.element.requestFullscreen){
|
|
84
|
+
// console.error("Fullscreen API is not supported in this browser.");
|
|
85
|
+
// return this;
|
|
86
|
+
// }
|
|
87
|
+
// if (set) this.element.requestFullscreen(e);
|
|
88
|
+
// else globalThis.document.exitFullscreen();
|
|
89
|
+
// return this;
|
|
90
|
+
// }
|
|
91
|
+
// toggleFullScreen(e) {
|
|
92
|
+
// if (!globalThis.document.fullscreenElement) this.element.requestFullscreen(e);
|
|
93
|
+
// else globalThis.document.exitFullscreen();
|
|
94
|
+
// return this;
|
|
95
|
+
// }
|
|
96
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { addSuffixeToNumber } from "
|
|
2
|
-
import { Matrix,cos,sin} from "
|
|
3
|
-
import { Str } from "
|
|
1
|
+
import { addSuffixeToNumber } from "../../__utils__/index.js";
|
|
2
|
+
import { Matrix,cos,sin} from "../../../math/index.js";
|
|
3
|
+
import { Str } from "../../../data/index.js";
|
|
4
4
|
class ZikoUIElementStyle{
|
|
5
5
|
constructor(defaultStyle={}){
|
|
6
6
|
this.target=null;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {Matrix} from "../../math/matrix/
|
|
3
|
-
// import { convolute } from "../../math/signal/conv.js";
|
|
1
|
+
import ZikoUIElement from "../constructors/ZikoUIElement.js";
|
|
2
|
+
import {Matrix} from "../../math/matrix/Matrix.js"
|
|
4
3
|
class ZikoUICanvas extends ZikoUIElement{
|
|
5
4
|
constructor(w,h){
|
|
6
5
|
super("canvas","canvas");
|
|
@@ -8,12 +7,12 @@ class ZikoUICanvas extends ZikoUIElement{
|
|
|
8
7
|
this.style({
|
|
9
8
|
border:"1px red solid",
|
|
10
9
|
})
|
|
11
|
-
this.transformMatrix=new Matrix([
|
|
10
|
+
this.transformMatrix = new Matrix([
|
|
12
11
|
[1,0,0],
|
|
13
12
|
[0,1,0],
|
|
14
13
|
[0,0,1]
|
|
15
14
|
])
|
|
16
|
-
this.axisMatrix=new Matrix([
|
|
15
|
+
this.axisMatrix = new Matrix([
|
|
17
16
|
[-10,-10],
|
|
18
17
|
[10,10]
|
|
19
18
|
])
|
package/src/ui/index.js
CHANGED
|
@@ -1,40 +1,9 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
10
|
-
export * from "./tags/index.js"
|
|
11
|
-
|
|
12
|
-
import * as Text from "./elements/text/index.js";
|
|
13
|
-
import * as List from "./elements/list/index.js";
|
|
14
|
-
import * as Io from "./elements/io/index.js";
|
|
15
|
-
import * as Media from "./elements/media/index.js";
|
|
16
|
-
import * as Table from "./elements/table/index.js";
|
|
17
|
-
import * as Semantic from "./elements/semantic/index.js";
|
|
18
|
-
import * as Misc from "./elements/misc/index.js";
|
|
19
|
-
import * as Flex from "./elements/flex/index.js";
|
|
20
|
-
import * as Grid from "./elements/grid/index.js";
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import ZikoUIElement from "./constructors/ziko-ui-element.js";
|
|
24
|
-
|
|
25
|
-
export{
|
|
26
|
-
ZikoUIElement
|
|
27
|
-
}
|
|
28
|
-
const UI = {
|
|
29
|
-
...Text,
|
|
30
|
-
...List,
|
|
31
|
-
...Io,
|
|
32
|
-
...Media,
|
|
33
|
-
...Table,
|
|
34
|
-
...Semantic,
|
|
35
|
-
...Misc,
|
|
36
|
-
...Flex,
|
|
37
|
-
...Grid,
|
|
38
|
-
ZikoUIElement,
|
|
39
|
-
}
|
|
40
|
-
export default UI;
|
|
1
|
+
export { default as ZikoUIElement } from "./constructors/ZikoUIElement.js"
|
|
2
|
+
export { default as ZikoUINode } from "./constructors/ZikoUINode.js"
|
|
3
|
+
export * from './tags/index.js';
|
|
4
|
+
export * from './text/index.js';
|
|
5
|
+
export * from './flex/index.js';
|
|
6
|
+
export * from './grid/index.js';
|
|
7
|
+
export * from './suspense/index.js';
|
|
8
|
+
export * from './wrapper/index.js';
|
|
9
|
+
export * from './graphics/index.js'
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import ZikoUIElement from "
|
|
2
|
-
// function loadComponent() {
|
|
3
|
-
// return new Promise((resolve) => {
|
|
4
|
-
// setTimeout(() => {
|
|
5
|
-
// resolve(p(1000))
|
|
6
|
-
// }, 500);
|
|
7
|
-
// });
|
|
8
|
-
// }
|
|
9
|
-
|
|
10
|
-
// Suspense(p("Loading ..."),()=>fetch('https://jsonplaceholder.typicode.com/todos/1')
|
|
11
|
-
// .then(response => response.json())
|
|
12
|
-
// .then(json => h2(json.title)))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import ZikoUIElement from "../constructors/ZikoUIElement";
|
|
16
2
|
class ZikoUISuspense extends ZikoUIElement{
|
|
17
3
|
constructor(fallback_ui, callback){
|
|
18
4
|
super("div", "suspense")
|
package/src/ui/tags/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import ZikoUIElement from "../constructors/
|
|
2
|
-
import { HTMLTags, SVGTags } from "./tags.js";
|
|
1
|
+
import ZikoUIElement from "../constructors/ZikoUIElement.js";
|
|
2
|
+
import { HTMLTags, SVGTags } from "./tags-list.js";
|
|
3
3
|
const _h=(tag, type, attributes, ...children)=>{
|
|
4
4
|
const { name, style, ...attrs } = attributes;
|
|
5
5
|
let element = new ZikoUIElement(tag, name, type);
|
|
@@ -18,7 +18,7 @@ const tags = new Proxy({}, {
|
|
|
18
18
|
if(HTMLTags.includes(tag)) return (...args)=>{
|
|
19
19
|
if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
|
|
20
20
|
let attributes = args.shift()
|
|
21
|
-
console.log(args)
|
|
21
|
+
// console.log(args)
|
|
22
22
|
return new ZikoUIElement(tag).setAttr(attributes).append(...args)
|
|
23
23
|
}
|
|
24
24
|
return new ZikoUIElement(tag).append(...args);
|