ziko 0.38.0 → 0.38.1
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 +80 -109
- package/dist/ziko.js +80 -109
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +80 -109
- package/package.json +2 -1
- package/src/__helpers__/composition-dep/compose-class.js +46 -0
- package/src/__helpers__/register/index.js +6 -0
- package/src/__helpers__/register/register-to-class.js +16 -0
- package/src/__helpers__/register/register-to-instance.js +18 -0
- package/src/__ziko__/index.js +12 -11
- package/src/hooks/use-state.js +5 -0
- package/src/ui/__methods__/index.js +4 -0
- package/src/ui/constructors/ZikoUIElement.js +12 -23
- package/src/ui/tags/index.js +25 -15
- package/src/__helpers__/composition/compose-class.js +0 -28
- /package/src/__helpers__/{composition → composition-dep}/compose-instance.js +0 -0
- /package/src/__helpers__/{composition → composition-dep}/compose.js +0 -0
- /package/src/__helpers__/{composition → composition-dep}/index.js +0 -0
- /package/src/ui/constructors/{ZikoUIElementMethodesToBeMoved.js → ZikoUIElementMethodesToBeMoved-dep.js} +0 -0
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 : Sun Aug 17 2025 21:52:49 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
|
|
@@ -945,21 +945,6 @@ const preload=(url)=>{
|
|
|
945
945
|
}
|
|
946
946
|
};
|
|
947
947
|
|
|
948
|
-
async function fetchdom(url='https://github.com/zakarialaoui10'){
|
|
949
|
-
const data=await fetch(url);
|
|
950
|
-
const html=await data.text();
|
|
951
|
-
const dom= new DOMParser().parseFromString(html,'text/xml');
|
|
952
|
-
return dom.documentElement
|
|
953
|
-
}
|
|
954
|
-
function fetchdomSync(url='https://github.com/zakarialaoui10'){
|
|
955
|
-
const data=preload(url);
|
|
956
|
-
const dom= new DOMParser().parseFromString(data,'text/xml');
|
|
957
|
-
return dom.documentElement;
|
|
958
|
-
}
|
|
959
|
-
|
|
960
|
-
globalThis.fetchdom=fetchdom;
|
|
961
|
-
globalThis.fetchdomSync=fetchdomSync;
|
|
962
|
-
|
|
963
948
|
const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
|
|
964
949
|
const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
|
|
965
950
|
const csv2object = (csv, delimiter = ",") => {
|
|
@@ -1074,36 +1059,27 @@ class ZikoUINode {
|
|
|
1074
1059
|
|
|
1075
1060
|
globalThis.node = (node) => new ZikoUINode(node);
|
|
1076
1061
|
|
|
1077
|
-
function
|
|
1062
|
+
function register_to_class(target, ...mixins){
|
|
1063
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1064
|
+
}
|
|
1065
|
+
function _register_to_class_(target, mixin) {
|
|
1078
1066
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1079
|
-
|
|
1080
|
-
class Composed extends Class {
|
|
1081
|
-
constructor(...args) {
|
|
1082
|
-
super(...args);
|
|
1083
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1084
|
-
const desc = descriptors[key];
|
|
1085
|
-
|
|
1086
|
-
if (typeof desc.value === 'function') {
|
|
1087
|
-
this[key] = desc.value.bind(this);
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
1067
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1094
1068
|
const desc = descriptors[key];
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1069
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1070
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1071
|
+
} else if (typeof desc.value === 'function') {
|
|
1072
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1073
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1074
|
+
}
|
|
1100
1075
|
}
|
|
1101
1076
|
}
|
|
1102
|
-
|
|
1103
|
-
return Composed;
|
|
1104
1077
|
}
|
|
1105
1078
|
|
|
1106
|
-
function
|
|
1079
|
+
function register_to_instance(target, ...mixins){
|
|
1080
|
+
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1081
|
+
}
|
|
1082
|
+
function _register_to_instance_(instance, mixin) {
|
|
1107
1083
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1108
1084
|
|
|
1109
1085
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
@@ -1119,15 +1095,10 @@ function composeInstance(instance, mixin) {
|
|
|
1119
1095
|
}
|
|
1120
1096
|
}
|
|
1121
1097
|
|
|
1122
|
-
|
|
1123
|
-
if
|
|
1124
|
-
|
|
1125
|
-
}
|
|
1126
|
-
mixin.forEach(item =>composeInstance(target, item));
|
|
1127
|
-
} else {
|
|
1128
|
-
throw new TypeError("compose: target must be a class or instance");
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1098
|
+
const register = (target, ...mixins) => {
|
|
1099
|
+
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1100
|
+
else register_to_instance(target, ...mixins);
|
|
1101
|
+
};
|
|
1131
1102
|
|
|
1132
1103
|
class ZikoUIText extends ZikoUINode {
|
|
1133
1104
|
constructor(...value) {
|
|
@@ -1248,22 +1219,6 @@ function __addItem__(adder, pusher, ...ele) {
|
|
|
1248
1219
|
return this;
|
|
1249
1220
|
}
|
|
1250
1221
|
|
|
1251
|
-
const IndexingMethods = {
|
|
1252
|
-
at(index) {
|
|
1253
|
-
return this.items.at(index);
|
|
1254
|
-
},
|
|
1255
|
-
forEach(callback) {
|
|
1256
|
-
this.items.forEach(callback);
|
|
1257
|
-
return this;
|
|
1258
|
-
},
|
|
1259
|
-
map(callback) {
|
|
1260
|
-
return this.items.map(callback);
|
|
1261
|
-
},
|
|
1262
|
-
find(condition) {
|
|
1263
|
-
return this.items.filter(condition);
|
|
1264
|
-
},
|
|
1265
|
-
};
|
|
1266
|
-
|
|
1267
1222
|
const Events = {
|
|
1268
1223
|
'Click' : [
|
|
1269
1224
|
'Click',
|
|
@@ -1675,6 +1630,22 @@ Object.entries(Events).forEach(([name, eventList]) => {
|
|
|
1675
1630
|
});
|
|
1676
1631
|
});
|
|
1677
1632
|
|
|
1633
|
+
const IndexingMethods = {
|
|
1634
|
+
at(index) {
|
|
1635
|
+
return this.items.at(index);
|
|
1636
|
+
},
|
|
1637
|
+
forEach(callback) {
|
|
1638
|
+
this.items.forEach(callback);
|
|
1639
|
+
return this;
|
|
1640
|
+
},
|
|
1641
|
+
map(callback) {
|
|
1642
|
+
return this.items.map(callback);
|
|
1643
|
+
},
|
|
1644
|
+
find(condition) {
|
|
1645
|
+
return this.items.filter(condition);
|
|
1646
|
+
},
|
|
1647
|
+
};
|
|
1648
|
+
|
|
1678
1649
|
class ZikoUseStyle {
|
|
1679
1650
|
constructor(style = {}, use = style.hasOwnProperty("default")? "default" : Object.keys(style)[0], id = 0) {
|
|
1680
1651
|
this.id = "Ziko-Style-" + id;
|
|
@@ -3282,23 +3253,26 @@ const __CACHE__ = {
|
|
|
3282
3253
|
}
|
|
3283
3254
|
};
|
|
3284
3255
|
|
|
3285
|
-
|
|
3286
|
-
globalThis
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3256
|
+
function __init__global__(){
|
|
3257
|
+
if ( !globalThis?.__Ziko__ ){
|
|
3258
|
+
globalThis.__Ziko__ = {
|
|
3259
|
+
__UI__,
|
|
3260
|
+
__HYDRATION__,
|
|
3261
|
+
__HYDRATION_MAP__,
|
|
3262
|
+
__Config__,
|
|
3263
|
+
__CACHE__,
|
|
3264
|
+
};
|
|
3265
|
+
defineParamsGetter$1(__Ziko__);
|
|
3266
|
+
}
|
|
3294
3267
|
}
|
|
3295
3268
|
|
|
3269
|
+
__init__global__();
|
|
3296
3270
|
class ZikoUIElement extends ZikoUINode{
|
|
3297
|
-
constructor(element, name="", {
|
|
3271
|
+
constructor(element, name="", {type="html", useDefaultStyle=false}={}){
|
|
3298
3272
|
super();
|
|
3299
3273
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
3300
3274
|
if(typeof element === "string") {
|
|
3301
|
-
switch(
|
|
3275
|
+
switch(type){
|
|
3302
3276
|
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
3303
3277
|
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
3304
3278
|
default : throw Error("Not supported")
|
|
@@ -3307,18 +3281,7 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
3307
3281
|
else {
|
|
3308
3282
|
this.target = element.parentElement;
|
|
3309
3283
|
}
|
|
3310
|
-
|
|
3311
|
-
compose(
|
|
3312
|
-
this,
|
|
3313
|
-
DomMethods,
|
|
3314
|
-
IndexingMethods,
|
|
3315
|
-
EventsMethodes
|
|
3316
|
-
);
|
|
3317
|
-
// if(false){
|
|
3318
|
-
// import("../methods/tree.js").then(({ default: ExternalMethods }) => {
|
|
3319
|
-
// compose(this, ExternalMethods);
|
|
3320
|
-
// });
|
|
3321
|
-
// }
|
|
3284
|
+
register(this, DomMethods, IndexingMethods, EventsMethodes);
|
|
3322
3285
|
Object.assign(this.cache, {
|
|
3323
3286
|
name,
|
|
3324
3287
|
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
@@ -3386,10 +3349,6 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
3386
3349
|
isZikoUIElement(){
|
|
3387
3350
|
return true;
|
|
3388
3351
|
}
|
|
3389
|
-
register(){
|
|
3390
|
-
|
|
3391
|
-
return this;
|
|
3392
|
-
}
|
|
3393
3352
|
get st(){
|
|
3394
3353
|
return this.cache.style;
|
|
3395
3354
|
}
|
|
@@ -3706,27 +3665,40 @@ const SVGTags = [
|
|
|
3706
3665
|
"desc", "title", "metadata", "foreignObject"
|
|
3707
3666
|
];
|
|
3708
3667
|
|
|
3668
|
+
const isStateGetter = (arg) => {
|
|
3669
|
+
return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
|
|
3670
|
+
};
|
|
3671
|
+
|
|
3709
3672
|
const tags = new Proxy({}, {
|
|
3710
3673
|
get(target, prop) {
|
|
3711
3674
|
if (typeof prop !== 'string') return undefined;
|
|
3712
3675
|
let tag = prop.replaceAll("_","-").toLowerCase();
|
|
3676
|
+
let type ;
|
|
3677
|
+
if(HTMLTags.includes(tag)) type = 'html';
|
|
3678
|
+
if(SVGTags.includes(tag)) type = 'svg';
|
|
3713
3679
|
if(HTMLTags.includes(tag)) return (...args)=>{
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
//
|
|
3680
|
+
console.log(isStateGetter(args[0]));
|
|
3681
|
+
// if(typeof args[0] === 'function') {
|
|
3682
|
+
// console.log(args[0], args[0]?.() instanceof StateGetter)
|
|
3683
|
+
// globalThis.a = args[0]
|
|
3684
|
+
// console.log({t : a.constructor})
|
|
3685
|
+
// }
|
|
3686
|
+
if(
|
|
3687
|
+
['string', 'number'].includes(typeof args[0])
|
|
3688
|
+
|| args[0] instanceof ZikoUIElement
|
|
3689
|
+
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3690
|
+
) return new ZikoUIElement(tag, tag, {type}).append(...args);
|
|
3691
|
+
return new ZikoUIElement(tag).setAttr(args.shift()).append(...args)
|
|
3692
|
+
}
|
|
3693
|
+
// if(SVGTags.includes(tag)) return (...args) => new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3694
|
+
// return (...args)=>{
|
|
3695
|
+
// if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
|
|
3696
|
+
// let attributes = args.shift()
|
|
3697
|
+
// return new ZikoUIElement(tag).setAttr(attributes).append(...args)
|
|
3698
|
+
// }
|
|
3699
|
+
// return new ZikoUIElement(tag).append(...args);
|
|
3700
|
+
// }
|
|
3701
|
+
// // switch(tag){
|
|
3730
3702
|
// case "html" : globalThis?.document?.createElement("html")
|
|
3731
3703
|
// case "head" :
|
|
3732
3704
|
// case "style" :
|
|
@@ -5798,8 +5770,7 @@ class ZikoTimeAnimation{
|
|
|
5798
5770
|
const useAnimation=(callback,ease=Ease.Linear,step=50,config)=>new ZikoTimeAnimation(callback,ease=Ease.Linear,step=50,config);
|
|
5799
5771
|
|
|
5800
5772
|
const debounce=(fn,delay=1000)=>{
|
|
5801
|
-
|
|
5802
|
-
return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
|
|
5773
|
+
return (...args) => setTimeout(()=>fn(...args),delay);
|
|
5803
5774
|
};
|
|
5804
5775
|
const throttle=(fn,delay)=>{
|
|
5805
5776
|
let lastTime=0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.1",
|
|
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",
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
"./time": {},
|
|
61
61
|
"./components": {}
|
|
62
62
|
},
|
|
63
|
+
"sideEffects" : false,
|
|
63
64
|
"bin": {
|
|
64
65
|
"create-ziko-app": "starter/bin/index.js"
|
|
65
66
|
},
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export function composeClass(Class, mixin) {
|
|
2
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
3
|
+
|
|
4
|
+
class Composed extends Class {
|
|
5
|
+
constructor(...args) {
|
|
6
|
+
super(...args);
|
|
7
|
+
// ⚠️ Do NOT assign mixin functions to `this`
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Copy prototype properties (methods, getters/setters, non-functions)
|
|
12
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
13
|
+
const desc = descriptors[key];
|
|
14
|
+
|
|
15
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
16
|
+
Object.defineProperty(Composed.prototype, key, desc);
|
|
17
|
+
} else if (typeof desc.value === 'function') {
|
|
18
|
+
// Only add method if it does NOT already exist
|
|
19
|
+
if (!Composed.prototype.hasOwnProperty(key)) {
|
|
20
|
+
Object.defineProperty(Composed.prototype, key, desc);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Composed;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// // Usage
|
|
29
|
+
// class UIBase {
|
|
30
|
+
// log() { console.log('UIBase log'); }
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
// const mixin = {
|
|
34
|
+
// at() { return 0; },
|
|
35
|
+
// hello() { return 'hello'; }
|
|
36
|
+
// };
|
|
37
|
+
|
|
38
|
+
// const UIComposed = composeClass(UIBase, mixin);
|
|
39
|
+
|
|
40
|
+
// class UI2 extends UIComposed {
|
|
41
|
+
// at() { return 1; } // ✅ correctly overrides mixin
|
|
42
|
+
// }
|
|
43
|
+
|
|
44
|
+
// const ui = new UI2();
|
|
45
|
+
// console.log(ui.at()); // 1
|
|
46
|
+
// console.log(ui.hello()); // 'hello'
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { register_to_class } from "./register-to-class.js";
|
|
2
|
+
import { register_to_instance } from "./register-to-instance";
|
|
3
|
+
export const register = (target, ...mixins) => {
|
|
4
|
+
if(typeof target === 'function') register_to_class(target, ...mixins)
|
|
5
|
+
else register_to_instance(target, ...mixins)
|
|
6
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function register_to_class(target, ...mixins){
|
|
2
|
+
mixins.forEach(n => _register_to_class_(target, n))
|
|
3
|
+
}
|
|
4
|
+
function _register_to_class_(target, mixin) {
|
|
5
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
6
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
7
|
+
const desc = descriptors[key];
|
|
8
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
9
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
10
|
+
} else if (typeof desc.value === 'function') {
|
|
11
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
12
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export function register_to_instance(target, ...mixins){
|
|
2
|
+
mixins.forEach(n => _register_to_instance_(target, n))
|
|
3
|
+
}
|
|
4
|
+
function _register_to_instance_(instance, mixin) {
|
|
5
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
6
|
+
|
|
7
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
8
|
+
const desc = descriptors[key];
|
|
9
|
+
|
|
10
|
+
if ('get' in desc || 'set' in desc) {
|
|
11
|
+
Object.defineProperty(instance, key, desc);
|
|
12
|
+
} else if (typeof desc.value === 'function') {
|
|
13
|
+
instance[key] = desc.value.bind(instance);
|
|
14
|
+
} else {
|
|
15
|
+
instance[key] = desc.value;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
package/src/__ziko__/index.js
CHANGED
|
@@ -3,14 +3,15 @@ import { __UI__ } from './__ui__.js';
|
|
|
3
3
|
import { __Config__ } from './__config__.js';
|
|
4
4
|
import { __HYDRATION__, __HYDRATION_MAP__ } from './__hydration__.js';
|
|
5
5
|
import { __CACHE__ } from './__cache__.js';
|
|
6
|
-
|
|
7
|
-
if ( !globalThis?.__Ziko__ ){
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
6
|
+
export function __init__global__(){
|
|
7
|
+
if ( !globalThis?.__Ziko__ ){
|
|
8
|
+
globalThis.__Ziko__ = {
|
|
9
|
+
__UI__,
|
|
10
|
+
__HYDRATION__,
|
|
11
|
+
__HYDRATION_MAP__,
|
|
12
|
+
__Config__,
|
|
13
|
+
__CACHE__,
|
|
14
|
+
};
|
|
15
|
+
defineParamsGetter(__Ziko__)
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/hooks/use-state.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import ZikoUINode from "./ZikoUINode.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { register } from "../../__helpers__/register/index.js";
|
|
3
|
+
import {
|
|
4
|
+
DomMethods,
|
|
5
|
+
IndexingMethods,
|
|
6
|
+
EventsMethodes
|
|
7
|
+
} from "../__methods__/index.js";
|
|
6
8
|
import { ZikoUseStyle } from "../../reactivity/hooks/UI/useStyle.js";
|
|
7
9
|
import { ZikoUIElementStyle } from "./style/index.js";
|
|
10
|
+
|
|
8
11
|
import {
|
|
9
12
|
useCustomEvent,
|
|
10
13
|
useSwipeEvent,
|
|
@@ -15,13 +18,14 @@ import {
|
|
|
15
18
|
} from "../../reactivity/index.js"
|
|
16
19
|
import { Random } from "../../math/index.js";
|
|
17
20
|
import { Str } from "../../data/index.js";
|
|
18
|
-
import '../../__ziko__/index.js';
|
|
21
|
+
import {__init__global__} from '../../__ziko__/index.js';
|
|
22
|
+
__init__global__()
|
|
19
23
|
class ZikoUIElement extends ZikoUINode{
|
|
20
|
-
constructor(element, name="", {
|
|
24
|
+
constructor(element, name="", {type="html", useDefaultStyle=false}={}){
|
|
21
25
|
super()
|
|
22
26
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
23
27
|
if(typeof element === "string") {
|
|
24
|
-
switch(
|
|
28
|
+
switch(type){
|
|
25
29
|
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
26
30
|
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
27
31
|
default : throw Error("Not supported")
|
|
@@ -30,18 +34,7 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
30
34
|
else{
|
|
31
35
|
this.target = element.parentElement;
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
compose(
|
|
35
|
-
this,
|
|
36
|
-
DomMethods,
|
|
37
|
-
IndexingMethods,
|
|
38
|
-
EventsMethodes
|
|
39
|
-
)
|
|
40
|
-
// if(false){
|
|
41
|
-
// import("../methods/tree.js").then(({ default: ExternalMethods }) => {
|
|
42
|
-
// compose(this, ExternalMethods);
|
|
43
|
-
// });
|
|
44
|
-
// }
|
|
37
|
+
register(this, DomMethods, IndexingMethods, EventsMethodes);
|
|
45
38
|
Object.assign(this.cache, {
|
|
46
39
|
name,
|
|
47
40
|
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
@@ -109,10 +102,6 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
109
102
|
isZikoUIElement(){
|
|
110
103
|
return true;
|
|
111
104
|
}
|
|
112
|
-
register(){
|
|
113
|
-
|
|
114
|
-
return this;
|
|
115
|
-
}
|
|
116
105
|
get st(){
|
|
117
106
|
return this.cache.style;
|
|
118
107
|
}
|
package/src/ui/tags/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import ZikoUIElement from "../constructors/ZikoUIElement.js";
|
|
2
2
|
import { HTMLTags, SVGTags } from "./tags-list.js";
|
|
3
|
+
import { isStateGetter } from "../../hooks/use-state.js";
|
|
3
4
|
const _h=(tag, type, attributes, ...children)=>{
|
|
4
5
|
const { name, style, ...attrs } = attributes;
|
|
5
6
|
let element = new ZikoUIElement(tag, name, type);
|
|
@@ -15,23 +16,32 @@ const tags = new Proxy({}, {
|
|
|
15
16
|
get(target, prop) {
|
|
16
17
|
if (typeof prop !== 'string') return undefined;
|
|
17
18
|
let tag = prop.replaceAll("_","-").toLowerCase();
|
|
19
|
+
let type ;
|
|
20
|
+
if(HTMLTags.includes(tag)) type = 'html'
|
|
21
|
+
if(SVGTags.includes(tag)) type = 'svg'
|
|
18
22
|
if(HTMLTags.includes(tag)) return (...args)=>{
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
console.log(isStateGetter(args[0]))
|
|
24
|
+
// if(typeof args[0] === 'function') {
|
|
25
|
+
// console.log(args[0], args[0]?.() instanceof StateGetter)
|
|
26
|
+
// globalThis.a = args[0]
|
|
27
|
+
// console.log({t : a.constructor})
|
|
28
|
+
// }
|
|
29
|
+
if(
|
|
30
|
+
['string', 'number'].includes(typeof args[0])
|
|
31
|
+
|| args[0] instanceof ZikoUIElement
|
|
32
|
+
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
33
|
+
) return new ZikoUIElement(tag, tag, {type}).append(...args);
|
|
34
|
+
return new ZikoUIElement(tag).setAttr(args.shift()).append(...args)
|
|
25
35
|
}
|
|
26
|
-
if(SVGTags.includes(tag)) return (...args)=>new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
27
|
-
return (...args)=>{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
// switch(tag){
|
|
36
|
+
// if(SVGTags.includes(tag)) return (...args) => new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
37
|
+
// return (...args)=>{
|
|
38
|
+
// if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
|
|
39
|
+
// let attributes = args.shift()
|
|
40
|
+
// return new ZikoUIElement(tag).setAttr(attributes).append(...args)
|
|
41
|
+
// }
|
|
42
|
+
// return new ZikoUIElement(tag).append(...args);
|
|
43
|
+
// }
|
|
44
|
+
// // switch(tag){
|
|
35
45
|
// case "html" : globalThis?.document?.createElement("html")
|
|
36
46
|
// case "head" :
|
|
37
47
|
// case "style" :
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export function composeClass(Class, mixin) {
|
|
2
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
3
|
-
|
|
4
|
-
class Composed extends Class {
|
|
5
|
-
constructor(...args) {
|
|
6
|
-
super(...args);
|
|
7
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
8
|
-
const desc = descriptors[key];
|
|
9
|
-
|
|
10
|
-
if (typeof desc.value === 'function') {
|
|
11
|
-
this[key] = desc.value.bind(this);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
18
|
-
const desc = descriptors[key];
|
|
19
|
-
|
|
20
|
-
if ('get' in desc || 'set' in desc) {
|
|
21
|
-
Object.defineProperty(Composed.prototype, key, desc);
|
|
22
|
-
} else if (typeof desc.value !== 'function') {
|
|
23
|
-
Object.defineProperty(Composed.prototype, key, desc);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return Composed;
|
|
28
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|