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.cjs
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
|
|
@@ -947,21 +947,6 @@ const preload=(url)=>{
|
|
|
947
947
|
}
|
|
948
948
|
};
|
|
949
949
|
|
|
950
|
-
async function fetchdom(url='https://github.com/zakarialaoui10'){
|
|
951
|
-
const data=await fetch(url);
|
|
952
|
-
const html=await data.text();
|
|
953
|
-
const dom= new DOMParser().parseFromString(html,'text/xml');
|
|
954
|
-
return dom.documentElement
|
|
955
|
-
}
|
|
956
|
-
function fetchdomSync(url='https://github.com/zakarialaoui10'){
|
|
957
|
-
const data=preload(url);
|
|
958
|
-
const dom= new DOMParser().parseFromString(data,'text/xml');
|
|
959
|
-
return dom.documentElement;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
globalThis.fetchdom=fetchdom;
|
|
963
|
-
globalThis.fetchdomSync=fetchdomSync;
|
|
964
|
-
|
|
965
950
|
const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
|
|
966
951
|
const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
|
|
967
952
|
const csv2object = (csv, delimiter = ",") => {
|
|
@@ -1076,36 +1061,27 @@ class ZikoUINode {
|
|
|
1076
1061
|
|
|
1077
1062
|
globalThis.node = (node) => new ZikoUINode(node);
|
|
1078
1063
|
|
|
1079
|
-
function
|
|
1064
|
+
function register_to_class(target, ...mixins){
|
|
1065
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1066
|
+
}
|
|
1067
|
+
function _register_to_class_(target, mixin) {
|
|
1080
1068
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1081
|
-
|
|
1082
|
-
class Composed extends Class {
|
|
1083
|
-
constructor(...args) {
|
|
1084
|
-
super(...args);
|
|
1085
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1086
|
-
const desc = descriptors[key];
|
|
1087
|
-
|
|
1088
|
-
if (typeof desc.value === 'function') {
|
|
1089
|
-
this[key] = desc.value.bind(this);
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
1069
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1096
1070
|
const desc = descriptors[key];
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1071
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1072
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1073
|
+
} else if (typeof desc.value === 'function') {
|
|
1074
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1075
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1076
|
+
}
|
|
1102
1077
|
}
|
|
1103
1078
|
}
|
|
1104
|
-
|
|
1105
|
-
return Composed;
|
|
1106
1079
|
}
|
|
1107
1080
|
|
|
1108
|
-
function
|
|
1081
|
+
function register_to_instance(target, ...mixins){
|
|
1082
|
+
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1083
|
+
}
|
|
1084
|
+
function _register_to_instance_(instance, mixin) {
|
|
1109
1085
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1110
1086
|
|
|
1111
1087
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
@@ -1121,15 +1097,10 @@ function composeInstance(instance, mixin) {
|
|
|
1121
1097
|
}
|
|
1122
1098
|
}
|
|
1123
1099
|
|
|
1124
|
-
|
|
1125
|
-
if
|
|
1126
|
-
|
|
1127
|
-
}
|
|
1128
|
-
mixin.forEach(item =>composeInstance(target, item));
|
|
1129
|
-
} else {
|
|
1130
|
-
throw new TypeError("compose: target must be a class or instance");
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1100
|
+
const register = (target, ...mixins) => {
|
|
1101
|
+
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1102
|
+
else register_to_instance(target, ...mixins);
|
|
1103
|
+
};
|
|
1133
1104
|
|
|
1134
1105
|
class ZikoUIText extends ZikoUINode {
|
|
1135
1106
|
constructor(...value) {
|
|
@@ -1250,22 +1221,6 @@ function __addItem__(adder, pusher, ...ele) {
|
|
|
1250
1221
|
return this;
|
|
1251
1222
|
}
|
|
1252
1223
|
|
|
1253
|
-
const IndexingMethods = {
|
|
1254
|
-
at(index) {
|
|
1255
|
-
return this.items.at(index);
|
|
1256
|
-
},
|
|
1257
|
-
forEach(callback) {
|
|
1258
|
-
this.items.forEach(callback);
|
|
1259
|
-
return this;
|
|
1260
|
-
},
|
|
1261
|
-
map(callback) {
|
|
1262
|
-
return this.items.map(callback);
|
|
1263
|
-
},
|
|
1264
|
-
find(condition) {
|
|
1265
|
-
return this.items.filter(condition);
|
|
1266
|
-
},
|
|
1267
|
-
};
|
|
1268
|
-
|
|
1269
1224
|
const Events = {
|
|
1270
1225
|
'Click' : [
|
|
1271
1226
|
'Click',
|
|
@@ -1677,6 +1632,22 @@ Object.entries(Events).forEach(([name, eventList]) => {
|
|
|
1677
1632
|
});
|
|
1678
1633
|
});
|
|
1679
1634
|
|
|
1635
|
+
const IndexingMethods = {
|
|
1636
|
+
at(index) {
|
|
1637
|
+
return this.items.at(index);
|
|
1638
|
+
},
|
|
1639
|
+
forEach(callback) {
|
|
1640
|
+
this.items.forEach(callback);
|
|
1641
|
+
return this;
|
|
1642
|
+
},
|
|
1643
|
+
map(callback) {
|
|
1644
|
+
return this.items.map(callback);
|
|
1645
|
+
},
|
|
1646
|
+
find(condition) {
|
|
1647
|
+
return this.items.filter(condition);
|
|
1648
|
+
},
|
|
1649
|
+
};
|
|
1650
|
+
|
|
1680
1651
|
class ZikoUseStyle {
|
|
1681
1652
|
constructor(style = {}, use = style.hasOwnProperty("default")? "default" : Object.keys(style)[0], id = 0) {
|
|
1682
1653
|
this.id = "Ziko-Style-" + id;
|
|
@@ -3284,23 +3255,26 @@ const __CACHE__ = {
|
|
|
3284
3255
|
}
|
|
3285
3256
|
};
|
|
3286
3257
|
|
|
3287
|
-
|
|
3288
|
-
globalThis
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3258
|
+
function __init__global__(){
|
|
3259
|
+
if ( !globalThis?.__Ziko__ ){
|
|
3260
|
+
globalThis.__Ziko__ = {
|
|
3261
|
+
__UI__,
|
|
3262
|
+
__HYDRATION__,
|
|
3263
|
+
__HYDRATION_MAP__,
|
|
3264
|
+
__Config__,
|
|
3265
|
+
__CACHE__,
|
|
3266
|
+
};
|
|
3267
|
+
defineParamsGetter$1(__Ziko__);
|
|
3268
|
+
}
|
|
3296
3269
|
}
|
|
3297
3270
|
|
|
3271
|
+
__init__global__();
|
|
3298
3272
|
class ZikoUIElement extends ZikoUINode{
|
|
3299
|
-
constructor(element, name="", {
|
|
3273
|
+
constructor(element, name="", {type="html", useDefaultStyle=false}={}){
|
|
3300
3274
|
super();
|
|
3301
3275
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
3302
3276
|
if(typeof element === "string") {
|
|
3303
|
-
switch(
|
|
3277
|
+
switch(type){
|
|
3304
3278
|
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
3305
3279
|
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
3306
3280
|
default : throw Error("Not supported")
|
|
@@ -3309,18 +3283,7 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
3309
3283
|
else {
|
|
3310
3284
|
this.target = element.parentElement;
|
|
3311
3285
|
}
|
|
3312
|
-
|
|
3313
|
-
compose(
|
|
3314
|
-
this,
|
|
3315
|
-
DomMethods,
|
|
3316
|
-
IndexingMethods,
|
|
3317
|
-
EventsMethodes
|
|
3318
|
-
);
|
|
3319
|
-
// if(false){
|
|
3320
|
-
// import("../methods/tree.js").then(({ default: ExternalMethods }) => {
|
|
3321
|
-
// compose(this, ExternalMethods);
|
|
3322
|
-
// });
|
|
3323
|
-
// }
|
|
3286
|
+
register(this, DomMethods, IndexingMethods, EventsMethodes);
|
|
3324
3287
|
Object.assign(this.cache, {
|
|
3325
3288
|
name,
|
|
3326
3289
|
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
@@ -3388,10 +3351,6 @@ class ZikoUIElement extends ZikoUINode{
|
|
|
3388
3351
|
isZikoUIElement(){
|
|
3389
3352
|
return true;
|
|
3390
3353
|
}
|
|
3391
|
-
register(){
|
|
3392
|
-
|
|
3393
|
-
return this;
|
|
3394
|
-
}
|
|
3395
3354
|
get st(){
|
|
3396
3355
|
return this.cache.style;
|
|
3397
3356
|
}
|
|
@@ -3708,27 +3667,40 @@ const SVGTags = [
|
|
|
3708
3667
|
"desc", "title", "metadata", "foreignObject"
|
|
3709
3668
|
];
|
|
3710
3669
|
|
|
3670
|
+
const isStateGetter = (arg) => {
|
|
3671
|
+
return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
|
|
3672
|
+
};
|
|
3673
|
+
|
|
3711
3674
|
const tags = new Proxy({}, {
|
|
3712
3675
|
get(target, prop) {
|
|
3713
3676
|
if (typeof prop !== 'string') return undefined;
|
|
3714
3677
|
let tag = prop.replaceAll("_","-").toLowerCase();
|
|
3678
|
+
let type ;
|
|
3679
|
+
if(HTMLTags.includes(tag)) type = 'html';
|
|
3680
|
+
if(SVGTags.includes(tag)) type = 'svg';
|
|
3715
3681
|
if(HTMLTags.includes(tag)) return (...args)=>{
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
//
|
|
3682
|
+
console.log(isStateGetter(args[0]));
|
|
3683
|
+
// if(typeof args[0] === 'function') {
|
|
3684
|
+
// console.log(args[0], args[0]?.() instanceof StateGetter)
|
|
3685
|
+
// globalThis.a = args[0]
|
|
3686
|
+
// console.log({t : a.constructor})
|
|
3687
|
+
// }
|
|
3688
|
+
if(
|
|
3689
|
+
['string', 'number'].includes(typeof args[0])
|
|
3690
|
+
|| args[0] instanceof ZikoUIElement
|
|
3691
|
+
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3692
|
+
) return new ZikoUIElement(tag, tag, {type}).append(...args);
|
|
3693
|
+
return new ZikoUIElement(tag).setAttr(args.shift()).append(...args)
|
|
3694
|
+
}
|
|
3695
|
+
// if(SVGTags.includes(tag)) return (...args) => new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3696
|
+
// return (...args)=>{
|
|
3697
|
+
// if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
|
|
3698
|
+
// let attributes = args.shift()
|
|
3699
|
+
// return new ZikoUIElement(tag).setAttr(attributes).append(...args)
|
|
3700
|
+
// }
|
|
3701
|
+
// return new ZikoUIElement(tag).append(...args);
|
|
3702
|
+
// }
|
|
3703
|
+
// // switch(tag){
|
|
3732
3704
|
// case "html" : globalThis?.document?.createElement("html")
|
|
3733
3705
|
// case "head" :
|
|
3734
3706
|
// case "style" :
|
|
@@ -5800,8 +5772,7 @@ class ZikoTimeAnimation{
|
|
|
5800
5772
|
const useAnimation=(callback,ease=Ease.Linear,step=50,config)=>new ZikoTimeAnimation(callback,ease=Ease.Linear,step=50,config);
|
|
5801
5773
|
|
|
5802
5774
|
const debounce=(fn,delay=1000)=>{
|
|
5803
|
-
|
|
5804
|
-
return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
|
|
5775
|
+
return (...args) => setTimeout(()=>fn(...args),delay);
|
|
5805
5776
|
};
|
|
5806
5777
|
const throttle=(fn,delay)=>{
|
|
5807
5778
|
let lastTime=0;
|
package/dist/ziko.js
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
|
|
@@ -951,21 +951,6 @@
|
|
|
951
951
|
}
|
|
952
952
|
};
|
|
953
953
|
|
|
954
|
-
async function fetchdom(url='https://github.com/zakarialaoui10'){
|
|
955
|
-
const data=await fetch(url);
|
|
956
|
-
const html=await data.text();
|
|
957
|
-
const dom= new DOMParser().parseFromString(html,'text/xml');
|
|
958
|
-
return dom.documentElement
|
|
959
|
-
}
|
|
960
|
-
function fetchdomSync(url='https://github.com/zakarialaoui10'){
|
|
961
|
-
const data=preload(url);
|
|
962
|
-
const dom= new DOMParser().parseFromString(data,'text/xml');
|
|
963
|
-
return dom.documentElement;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
globalThis.fetchdom=fetchdom;
|
|
967
|
-
globalThis.fetchdomSync=fetchdomSync;
|
|
968
|
-
|
|
969
954
|
const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
|
|
970
955
|
const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
|
|
971
956
|
const csv2object = (csv, delimiter = ",") => {
|
|
@@ -1080,36 +1065,27 @@
|
|
|
1080
1065
|
|
|
1081
1066
|
globalThis.node = (node) => new ZikoUINode(node);
|
|
1082
1067
|
|
|
1083
|
-
function
|
|
1068
|
+
function register_to_class(target, ...mixins){
|
|
1069
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1070
|
+
}
|
|
1071
|
+
function _register_to_class_(target, mixin) {
|
|
1084
1072
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1085
|
-
|
|
1086
|
-
class Composed extends Class {
|
|
1087
|
-
constructor(...args) {
|
|
1088
|
-
super(...args);
|
|
1089
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1090
|
-
const desc = descriptors[key];
|
|
1091
|
-
|
|
1092
|
-
if (typeof desc.value === 'function') {
|
|
1093
|
-
this[key] = desc.value.bind(this);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
1073
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1100
1074
|
const desc = descriptors[key];
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1075
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1076
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1077
|
+
} else if (typeof desc.value === 'function') {
|
|
1078
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1079
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1080
|
+
}
|
|
1106
1081
|
}
|
|
1107
1082
|
}
|
|
1108
|
-
|
|
1109
|
-
return Composed;
|
|
1110
1083
|
}
|
|
1111
1084
|
|
|
1112
|
-
function
|
|
1085
|
+
function register_to_instance(target, ...mixins){
|
|
1086
|
+
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1087
|
+
}
|
|
1088
|
+
function _register_to_instance_(instance, mixin) {
|
|
1113
1089
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1114
1090
|
|
|
1115
1091
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
@@ -1125,15 +1101,10 @@
|
|
|
1125
1101
|
}
|
|
1126
1102
|
}
|
|
1127
1103
|
|
|
1128
|
-
|
|
1129
|
-
if
|
|
1130
|
-
|
|
1131
|
-
}
|
|
1132
|
-
mixin.forEach(item =>composeInstance(target, item));
|
|
1133
|
-
} else {
|
|
1134
|
-
throw new TypeError("compose: target must be a class or instance");
|
|
1135
|
-
}
|
|
1136
|
-
}
|
|
1104
|
+
const register = (target, ...mixins) => {
|
|
1105
|
+
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1106
|
+
else register_to_instance(target, ...mixins);
|
|
1107
|
+
};
|
|
1137
1108
|
|
|
1138
1109
|
class ZikoUIText extends ZikoUINode {
|
|
1139
1110
|
constructor(...value) {
|
|
@@ -1254,22 +1225,6 @@
|
|
|
1254
1225
|
return this;
|
|
1255
1226
|
}
|
|
1256
1227
|
|
|
1257
|
-
const IndexingMethods = {
|
|
1258
|
-
at(index) {
|
|
1259
|
-
return this.items.at(index);
|
|
1260
|
-
},
|
|
1261
|
-
forEach(callback) {
|
|
1262
|
-
this.items.forEach(callback);
|
|
1263
|
-
return this;
|
|
1264
|
-
},
|
|
1265
|
-
map(callback) {
|
|
1266
|
-
return this.items.map(callback);
|
|
1267
|
-
},
|
|
1268
|
-
find(condition) {
|
|
1269
|
-
return this.items.filter(condition);
|
|
1270
|
-
},
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
1228
|
const Events = {
|
|
1274
1229
|
'Click' : [
|
|
1275
1230
|
'Click',
|
|
@@ -1681,6 +1636,22 @@
|
|
|
1681
1636
|
});
|
|
1682
1637
|
});
|
|
1683
1638
|
|
|
1639
|
+
const IndexingMethods = {
|
|
1640
|
+
at(index) {
|
|
1641
|
+
return this.items.at(index);
|
|
1642
|
+
},
|
|
1643
|
+
forEach(callback) {
|
|
1644
|
+
this.items.forEach(callback);
|
|
1645
|
+
return this;
|
|
1646
|
+
},
|
|
1647
|
+
map(callback) {
|
|
1648
|
+
return this.items.map(callback);
|
|
1649
|
+
},
|
|
1650
|
+
find(condition) {
|
|
1651
|
+
return this.items.filter(condition);
|
|
1652
|
+
},
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1684
1655
|
class ZikoUseStyle {
|
|
1685
1656
|
constructor(style = {}, use = style.hasOwnProperty("default")? "default" : Object.keys(style)[0], id = 0) {
|
|
1686
1657
|
this.id = "Ziko-Style-" + id;
|
|
@@ -3288,23 +3259,26 @@
|
|
|
3288
3259
|
}
|
|
3289
3260
|
};
|
|
3290
3261
|
|
|
3291
|
-
|
|
3292
|
-
globalThis
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
3262
|
+
function __init__global__(){
|
|
3263
|
+
if ( !globalThis?.__Ziko__ ){
|
|
3264
|
+
globalThis.__Ziko__ = {
|
|
3265
|
+
__UI__,
|
|
3266
|
+
__HYDRATION__,
|
|
3267
|
+
__HYDRATION_MAP__,
|
|
3268
|
+
__Config__,
|
|
3269
|
+
__CACHE__,
|
|
3270
|
+
};
|
|
3271
|
+
defineParamsGetter$1(__Ziko__);
|
|
3272
|
+
}
|
|
3300
3273
|
}
|
|
3301
3274
|
|
|
3275
|
+
__init__global__();
|
|
3302
3276
|
class ZikoUIElement extends ZikoUINode{
|
|
3303
|
-
constructor(element, name="", {
|
|
3277
|
+
constructor(element, name="", {type="html", useDefaultStyle=false}={}){
|
|
3304
3278
|
super();
|
|
3305
3279
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
3306
3280
|
if(typeof element === "string") {
|
|
3307
|
-
switch(
|
|
3281
|
+
switch(type){
|
|
3308
3282
|
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
3309
3283
|
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
3310
3284
|
default : throw Error("Not supported")
|
|
@@ -3313,18 +3287,7 @@
|
|
|
3313
3287
|
else {
|
|
3314
3288
|
this.target = element.parentElement;
|
|
3315
3289
|
}
|
|
3316
|
-
|
|
3317
|
-
compose(
|
|
3318
|
-
this,
|
|
3319
|
-
DomMethods,
|
|
3320
|
-
IndexingMethods,
|
|
3321
|
-
EventsMethodes
|
|
3322
|
-
);
|
|
3323
|
-
// if(false){
|
|
3324
|
-
// import("../methods/tree.js").then(({ default: ExternalMethods }) => {
|
|
3325
|
-
// compose(this, ExternalMethods);
|
|
3326
|
-
// });
|
|
3327
|
-
// }
|
|
3290
|
+
register(this, DomMethods, IndexingMethods, EventsMethodes);
|
|
3328
3291
|
Object.assign(this.cache, {
|
|
3329
3292
|
name,
|
|
3330
3293
|
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
@@ -3392,10 +3355,6 @@
|
|
|
3392
3355
|
isZikoUIElement(){
|
|
3393
3356
|
return true;
|
|
3394
3357
|
}
|
|
3395
|
-
register(){
|
|
3396
|
-
|
|
3397
|
-
return this;
|
|
3398
|
-
}
|
|
3399
3358
|
get st(){
|
|
3400
3359
|
return this.cache.style;
|
|
3401
3360
|
}
|
|
@@ -3712,27 +3671,40 @@
|
|
|
3712
3671
|
"desc", "title", "metadata", "foreignObject"
|
|
3713
3672
|
];
|
|
3714
3673
|
|
|
3674
|
+
const isStateGetter = (arg) => {
|
|
3675
|
+
return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
|
|
3676
|
+
};
|
|
3677
|
+
|
|
3715
3678
|
const tags = new Proxy({}, {
|
|
3716
3679
|
get(target, prop) {
|
|
3717
3680
|
if (typeof prop !== 'string') return undefined;
|
|
3718
3681
|
let tag = prop.replaceAll("_","-").toLowerCase();
|
|
3682
|
+
let type ;
|
|
3683
|
+
if(HTMLTags.includes(tag)) type = 'html';
|
|
3684
|
+
if(SVGTags.includes(tag)) type = 'svg';
|
|
3719
3685
|
if(HTMLTags.includes(tag)) return (...args)=>{
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
//
|
|
3686
|
+
console.log(isStateGetter(args[0]));
|
|
3687
|
+
// if(typeof args[0] === 'function') {
|
|
3688
|
+
// console.log(args[0], args[0]?.() instanceof StateGetter)
|
|
3689
|
+
// globalThis.a = args[0]
|
|
3690
|
+
// console.log({t : a.constructor})
|
|
3691
|
+
// }
|
|
3692
|
+
if(
|
|
3693
|
+
['string', 'number'].includes(typeof args[0])
|
|
3694
|
+
|| args[0] instanceof ZikoUIElement
|
|
3695
|
+
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3696
|
+
) return new ZikoUIElement(tag, tag, {type}).append(...args);
|
|
3697
|
+
return new ZikoUIElement(tag).setAttr(args.shift()).append(...args)
|
|
3698
|
+
}
|
|
3699
|
+
// if(SVGTags.includes(tag)) return (...args) => new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3700
|
+
// return (...args)=>{
|
|
3701
|
+
// if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
|
|
3702
|
+
// let attributes = args.shift()
|
|
3703
|
+
// return new ZikoUIElement(tag).setAttr(attributes).append(...args)
|
|
3704
|
+
// }
|
|
3705
|
+
// return new ZikoUIElement(tag).append(...args);
|
|
3706
|
+
// }
|
|
3707
|
+
// // switch(tag){
|
|
3736
3708
|
// case "html" : globalThis?.document?.createElement("html")
|
|
3737
3709
|
// case "head" :
|
|
3738
3710
|
// case "style" :
|
|
@@ -5804,8 +5776,7 @@
|
|
|
5804
5776
|
const useAnimation=(callback,ease=Ease.Linear,step=50,config)=>new ZikoTimeAnimation(callback,ease=Ease.Linear,step=50,config);
|
|
5805
5777
|
|
|
5806
5778
|
const debounce=(fn,delay=1000)=>{
|
|
5807
|
-
|
|
5808
|
-
return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
|
|
5779
|
+
return (...args) => setTimeout(()=>fn(...args),delay);
|
|
5809
5780
|
};
|
|
5810
5781
|
const throttle=(fn,delay)=>{
|
|
5811
5782
|
let lastTime=0;
|