ziko 0.42.0 → 0.42.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.js +56 -49
- package/dist/ziko.mjs +56 -49
- package/package.json +1 -1
- package/src/__ziko__/__cache__.js +3 -0
- package/src/__ziko__/__hydration__.js +4 -5
- package/src/__ziko__/__ui__.js +27 -21
- package/src/__ziko__/index.js +2 -2
- package/src/ui/__methods__/style.js +18 -18
- package/src/ui/constructors/UIElement.js +43 -26
package/dist/ziko.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date : Sun Aug 24 2025 12:
|
|
5
|
+
Date : Sun Aug 24 2025 12:52:45 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
|
|
@@ -1150,28 +1150,34 @@
|
|
|
1150
1150
|
});
|
|
1151
1151
|
}
|
|
1152
1152
|
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
.filter(Array.isArray)
|
|
1157
|
-
.flat();
|
|
1158
|
-
},
|
|
1159
|
-
querySelectorAll(){
|
|
1160
|
-
return this.__all__().filter(n=>n)
|
|
1161
|
-
},
|
|
1162
|
-
getElementByIndex(index){
|
|
1163
|
-
return this.__all__().find(n=>n.ui_index===index);
|
|
1164
|
-
},
|
|
1165
|
-
getElementById(id){
|
|
1166
|
-
return null;
|
|
1167
|
-
},
|
|
1168
|
-
getElementsByClass(){
|
|
1169
|
-
|
|
1170
|
-
},
|
|
1171
|
-
getElementsByTagName(){
|
|
1172
|
-
|
|
1153
|
+
class UIStore extends Array {
|
|
1154
|
+
constructor(...args) {
|
|
1155
|
+
super(...args);
|
|
1173
1156
|
}
|
|
1174
|
-
|
|
1157
|
+
getItemById(id) {
|
|
1158
|
+
return this.find(n => n.element.id === id);
|
|
1159
|
+
}
|
|
1160
|
+
getItemsByTagName(tag) {
|
|
1161
|
+
return this.filter(n => n.element.tagName.toLowerCase() === tag.toLowerCase());
|
|
1162
|
+
}
|
|
1163
|
+
getElementsByClassName(className) {
|
|
1164
|
+
return this.filter(n => n.element.classList?.contains(className));
|
|
1165
|
+
}
|
|
1166
|
+
querySelector(selector) {
|
|
1167
|
+
const el = globalThis?.document?.querySelector(selector);
|
|
1168
|
+
if (!el) return null;
|
|
1169
|
+
return this.find(ui => ui.element === el) || null;
|
|
1170
|
+
}
|
|
1171
|
+
querySelectorAll(selector) {
|
|
1172
|
+
const els = globalThis?.document?.querySelectorAll(selector);
|
|
1173
|
+
return Array.from(els)
|
|
1174
|
+
.map(el => this.find(ui => ui.element === el))
|
|
1175
|
+
.filter(Boolean);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// create the singleton
|
|
1180
|
+
const __UI__ = new UIStore();
|
|
1175
1181
|
|
|
1176
1182
|
const __Config__ = {
|
|
1177
1183
|
default:{
|
|
@@ -1194,10 +1200,10 @@
|
|
|
1194
1200
|
};
|
|
1195
1201
|
|
|
1196
1202
|
const __HYDRATION__ = {
|
|
1197
|
-
|
|
1203
|
+
store : new Map(),
|
|
1198
1204
|
index : 0,
|
|
1199
|
-
|
|
1200
|
-
|
|
1205
|
+
register: function(component){
|
|
1206
|
+
this.store.set(this.index++, component);
|
|
1201
1207
|
}
|
|
1202
1208
|
};
|
|
1203
1209
|
|
|
@@ -1205,6 +1211,9 @@
|
|
|
1205
1211
|
ui_index : 0,
|
|
1206
1212
|
get_ui_index:function(){
|
|
1207
1213
|
return this.ui_index ++
|
|
1214
|
+
},
|
|
1215
|
+
register_ui: function(UIElement){
|
|
1216
|
+
|
|
1208
1217
|
}
|
|
1209
1218
|
};
|
|
1210
1219
|
|
|
@@ -1227,7 +1236,6 @@
|
|
|
1227
1236
|
__UI__,
|
|
1228
1237
|
__HYDRATION__,
|
|
1229
1238
|
__State__,
|
|
1230
|
-
// __HYDRATION_MAP__,
|
|
1231
1239
|
__Config__,
|
|
1232
1240
|
__CACHE__,
|
|
1233
1241
|
};
|
|
@@ -2875,7 +2883,7 @@
|
|
|
2875
2883
|
|
|
2876
2884
|
__init__global__();
|
|
2877
2885
|
class UIElement extends UINode{
|
|
2878
|
-
constructor({element, name ='', type="html", useDefaultStyle=false}={}){
|
|
2886
|
+
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
|
|
2879
2887
|
super();
|
|
2880
2888
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
2881
2889
|
if(typeof element === "string") {
|
|
@@ -2926,8 +2934,8 @@
|
|
|
2926
2934
|
resize:null,
|
|
2927
2935
|
intersection:null
|
|
2928
2936
|
};
|
|
2929
|
-
if(element)Object.assign(this.cache,{element});
|
|
2930
|
-
this.uuid = `${this.cache.name}-${Random.string(16)}
|
|
2937
|
+
if(element) Object.assign(this.cache,{element});
|
|
2938
|
+
// this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
2931
2939
|
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
2932
2940
|
useDefaultStyle && this.style({
|
|
2933
2941
|
position: "relative",
|
|
@@ -2937,9 +2945,9 @@
|
|
|
2937
2945
|
width : "auto",
|
|
2938
2946
|
height : "auto"
|
|
2939
2947
|
});
|
|
2940
|
-
this.items =
|
|
2948
|
+
this.items = new UIStore();
|
|
2941
2949
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
2942
|
-
element &&
|
|
2950
|
+
element && render && this?.render?.();
|
|
2943
2951
|
if(
|
|
2944
2952
|
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
2945
2953
|
// &&
|
|
@@ -2948,9 +2956,9 @@
|
|
|
2948
2956
|
this.isInteractive()
|
|
2949
2957
|
){
|
|
2950
2958
|
this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
2951
|
-
globalThis.__Ziko__.__HYDRATION__.
|
|
2952
|
-
globalThis.__Ziko__.__HYDRATION__.increment();
|
|
2959
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
2953
2960
|
}
|
|
2961
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
2954
2962
|
}
|
|
2955
2963
|
get element(){
|
|
2956
2964
|
return this.cache.element;
|
|
@@ -3001,14 +3009,13 @@
|
|
|
3001
3009
|
return this.element.getBoundingClientRect().left;
|
|
3002
3010
|
}
|
|
3003
3011
|
clone(render=false) {
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
return UI.render(render);
|
|
3012
|
+
// UI.__proto__=this.__proto__;
|
|
3013
|
+
// if(this.items.length){
|
|
3014
|
+
// const items = [...this.items].map(n=>n.clone());
|
|
3015
|
+
// UI.append(...items);
|
|
3016
|
+
// }
|
|
3017
|
+
// else UI.element=this.element.cloneNode(true);
|
|
3018
|
+
// return UI.render(render);
|
|
3012
3019
|
}
|
|
3013
3020
|
[Symbol.iterator]() {
|
|
3014
3021
|
return this.items[Symbol.iterator]();
|
|
@@ -3027,14 +3034,14 @@
|
|
|
3027
3034
|
this.cache.isFrozzen=freeze;
|
|
3028
3035
|
return this;
|
|
3029
3036
|
}
|
|
3030
|
-
setTarget(tg) {
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
}
|
|
3037
|
+
// setTarget(tg) {
|
|
3038
|
+
// if(this.isBody) return ;
|
|
3039
|
+
// if (tg?.isZikoUIElement) tg = tg.element;
|
|
3040
|
+
// this.unrender();
|
|
3041
|
+
// this.target = tg;
|
|
3042
|
+
// this.render();
|
|
3043
|
+
// return this;
|
|
3044
|
+
// }
|
|
3038
3045
|
describe(label){
|
|
3039
3046
|
if(label)this.setAttr("aria-label",label);
|
|
3040
3047
|
}
|
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date : Sun Aug 24 2025 12:
|
|
5
|
+
Date : Sun Aug 24 2025 12:52:45 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
|
|
@@ -1144,28 +1144,34 @@ function defineParamsGetter$1(target ){
|
|
|
1144
1144
|
});
|
|
1145
1145
|
}
|
|
1146
1146
|
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
.filter(Array.isArray)
|
|
1151
|
-
.flat();
|
|
1152
|
-
},
|
|
1153
|
-
querySelectorAll(){
|
|
1154
|
-
return this.__all__().filter(n=>n)
|
|
1155
|
-
},
|
|
1156
|
-
getElementByIndex(index){
|
|
1157
|
-
return this.__all__().find(n=>n.ui_index===index);
|
|
1158
|
-
},
|
|
1159
|
-
getElementById(id){
|
|
1160
|
-
return null;
|
|
1161
|
-
},
|
|
1162
|
-
getElementsByClass(){
|
|
1163
|
-
|
|
1164
|
-
},
|
|
1165
|
-
getElementsByTagName(){
|
|
1166
|
-
|
|
1147
|
+
class UIStore extends Array {
|
|
1148
|
+
constructor(...args) {
|
|
1149
|
+
super(...args);
|
|
1167
1150
|
}
|
|
1168
|
-
|
|
1151
|
+
getItemById(id) {
|
|
1152
|
+
return this.find(n => n.element.id === id);
|
|
1153
|
+
}
|
|
1154
|
+
getItemsByTagName(tag) {
|
|
1155
|
+
return this.filter(n => n.element.tagName.toLowerCase() === tag.toLowerCase());
|
|
1156
|
+
}
|
|
1157
|
+
getElementsByClassName(className) {
|
|
1158
|
+
return this.filter(n => n.element.classList?.contains(className));
|
|
1159
|
+
}
|
|
1160
|
+
querySelector(selector) {
|
|
1161
|
+
const el = globalThis?.document?.querySelector(selector);
|
|
1162
|
+
if (!el) return null;
|
|
1163
|
+
return this.find(ui => ui.element === el) || null;
|
|
1164
|
+
}
|
|
1165
|
+
querySelectorAll(selector) {
|
|
1166
|
+
const els = globalThis?.document?.querySelectorAll(selector);
|
|
1167
|
+
return Array.from(els)
|
|
1168
|
+
.map(el => this.find(ui => ui.element === el))
|
|
1169
|
+
.filter(Boolean);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
// create the singleton
|
|
1174
|
+
const __UI__ = new UIStore();
|
|
1169
1175
|
|
|
1170
1176
|
const __Config__ = {
|
|
1171
1177
|
default:{
|
|
@@ -1188,10 +1194,10 @@ const __Config__ = {
|
|
|
1188
1194
|
};
|
|
1189
1195
|
|
|
1190
1196
|
const __HYDRATION__ = {
|
|
1191
|
-
|
|
1197
|
+
store : new Map(),
|
|
1192
1198
|
index : 0,
|
|
1193
|
-
|
|
1194
|
-
|
|
1199
|
+
register: function(component){
|
|
1200
|
+
this.store.set(this.index++, component);
|
|
1195
1201
|
}
|
|
1196
1202
|
};
|
|
1197
1203
|
|
|
@@ -1199,6 +1205,9 @@ const __CACHE__ = {
|
|
|
1199
1205
|
ui_index : 0,
|
|
1200
1206
|
get_ui_index:function(){
|
|
1201
1207
|
return this.ui_index ++
|
|
1208
|
+
},
|
|
1209
|
+
register_ui: function(UIElement){
|
|
1210
|
+
|
|
1202
1211
|
}
|
|
1203
1212
|
};
|
|
1204
1213
|
|
|
@@ -1221,7 +1230,6 @@ function __init__global__(){
|
|
|
1221
1230
|
__UI__,
|
|
1222
1231
|
__HYDRATION__,
|
|
1223
1232
|
__State__,
|
|
1224
|
-
// __HYDRATION_MAP__,
|
|
1225
1233
|
__Config__,
|
|
1226
1234
|
__CACHE__,
|
|
1227
1235
|
};
|
|
@@ -2869,7 +2877,7 @@ const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQ
|
|
|
2869
2877
|
|
|
2870
2878
|
__init__global__();
|
|
2871
2879
|
class UIElement extends UINode{
|
|
2872
|
-
constructor({element, name ='', type="html", useDefaultStyle=false}={}){
|
|
2880
|
+
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
|
|
2873
2881
|
super();
|
|
2874
2882
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
2875
2883
|
if(typeof element === "string") {
|
|
@@ -2920,8 +2928,8 @@ class UIElement extends UINode{
|
|
|
2920
2928
|
resize:null,
|
|
2921
2929
|
intersection:null
|
|
2922
2930
|
};
|
|
2923
|
-
if(element)Object.assign(this.cache,{element});
|
|
2924
|
-
this.uuid = `${this.cache.name}-${Random.string(16)}
|
|
2931
|
+
if(element) Object.assign(this.cache,{element});
|
|
2932
|
+
// this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
2925
2933
|
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
2926
2934
|
useDefaultStyle && this.style({
|
|
2927
2935
|
position: "relative",
|
|
@@ -2931,9 +2939,9 @@ class UIElement extends UINode{
|
|
|
2931
2939
|
width : "auto",
|
|
2932
2940
|
height : "auto"
|
|
2933
2941
|
});
|
|
2934
|
-
this.items =
|
|
2942
|
+
this.items = new UIStore();
|
|
2935
2943
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
2936
|
-
element &&
|
|
2944
|
+
element && render && this?.render?.();
|
|
2937
2945
|
if(
|
|
2938
2946
|
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
2939
2947
|
// &&
|
|
@@ -2942,9 +2950,9 @@ class UIElement extends UINode{
|
|
|
2942
2950
|
this.isInteractive()
|
|
2943
2951
|
){
|
|
2944
2952
|
this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
2945
|
-
globalThis.__Ziko__.__HYDRATION__.
|
|
2946
|
-
globalThis.__Ziko__.__HYDRATION__.increment();
|
|
2953
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
2947
2954
|
}
|
|
2955
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
2948
2956
|
}
|
|
2949
2957
|
get element(){
|
|
2950
2958
|
return this.cache.element;
|
|
@@ -2995,14 +3003,13 @@ class UIElement extends UINode{
|
|
|
2995
3003
|
return this.element.getBoundingClientRect().left;
|
|
2996
3004
|
}
|
|
2997
3005
|
clone(render=false) {
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
return UI.render(render);
|
|
3006
|
+
// UI.__proto__=this.__proto__;
|
|
3007
|
+
// if(this.items.length){
|
|
3008
|
+
// const items = [...this.items].map(n=>n.clone());
|
|
3009
|
+
// UI.append(...items);
|
|
3010
|
+
// }
|
|
3011
|
+
// else UI.element=this.element.cloneNode(true);
|
|
3012
|
+
// return UI.render(render);
|
|
3006
3013
|
}
|
|
3007
3014
|
[Symbol.iterator]() {
|
|
3008
3015
|
return this.items[Symbol.iterator]();
|
|
@@ -3021,14 +3028,14 @@ class UIElement extends UINode{
|
|
|
3021
3028
|
this.cache.isFrozzen=freeze;
|
|
3022
3029
|
return this;
|
|
3023
3030
|
}
|
|
3024
|
-
setTarget(tg) {
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
}
|
|
3031
|
+
// setTarget(tg) {
|
|
3032
|
+
// if(this.isBody) return ;
|
|
3033
|
+
// if (tg?.isZikoUIElement) tg = tg.element;
|
|
3034
|
+
// this.unrender();
|
|
3035
|
+
// this.target = tg;
|
|
3036
|
+
// this.render();
|
|
3037
|
+
// return this;
|
|
3038
|
+
// }
|
|
3032
3039
|
describe(label){
|
|
3033
3040
|
if(label)this.setAttr("aria-label",label);
|
|
3034
3041
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.42.
|
|
3
|
+
"version": "0.42.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",
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export const __HYDRATION__ = {
|
|
2
|
-
|
|
2
|
+
store : new Map(),
|
|
3
3
|
index : 0,
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
register: function(component){
|
|
5
|
+
this.store.set(this.index++, component)
|
|
6
6
|
}
|
|
7
|
-
}
|
|
8
|
-
export const __HYDRATION_MAP__ = new Map()
|
|
7
|
+
}
|
package/src/__ziko__/__ui__.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
getElementById(id){
|
|
14
|
-
return null;
|
|
15
|
-
},
|
|
16
|
-
getElementsByClass(){
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
getElementsByTagName(){
|
|
20
|
-
|
|
1
|
+
export class UIStore extends Array {
|
|
2
|
+
constructor(...args) {
|
|
3
|
+
super(...args);
|
|
4
|
+
}
|
|
5
|
+
getItemById(id) {
|
|
6
|
+
return this.find(n => n.element.id === id);
|
|
7
|
+
}
|
|
8
|
+
getItemsByTagName(tag) {
|
|
9
|
+
return this.filter(n => n.element.tagName.toLowerCase() === tag.toLowerCase());
|
|
10
|
+
}
|
|
11
|
+
getElementsByClassName(className) {
|
|
12
|
+
return this.filter(n => n.element.classList?.contains(className));
|
|
21
13
|
}
|
|
22
|
-
|
|
14
|
+
querySelector(selector) {
|
|
15
|
+
const el = globalThis?.document?.querySelector(selector);
|
|
16
|
+
if (!el) return null;
|
|
17
|
+
return this.find(ui => ui.element === el) || null;
|
|
18
|
+
}
|
|
19
|
+
querySelectorAll(selector) {
|
|
20
|
+
const els = globalThis?.document?.querySelectorAll(selector);
|
|
21
|
+
return Array.from(els)
|
|
22
|
+
.map(el => this.find(ui => ui.element === el))
|
|
23
|
+
.filter(Boolean);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// create the singleton
|
|
28
|
+
export const __UI__ = new UIStore();
|
package/src/__ziko__/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineParamsGetter } from './params.js';
|
|
2
2
|
import { __UI__ } from './__ui__.js';
|
|
3
3
|
import { __Config__ } from './__config__.js';
|
|
4
|
-
import { __HYDRATION__
|
|
4
|
+
import { __HYDRATION__ } from './__hydration__.js';
|
|
5
5
|
import { __CACHE__ } from './__cache__.js';
|
|
6
6
|
import { __State__ } from './__state__.js';
|
|
7
7
|
export function __init__global__(){
|
|
@@ -10,10 +10,10 @@ export function __init__global__(){
|
|
|
10
10
|
__UI__,
|
|
11
11
|
__HYDRATION__,
|
|
12
12
|
__State__,
|
|
13
|
-
// __HYDRATION_MAP__,
|
|
14
13
|
__Config__,
|
|
15
14
|
__CACHE__,
|
|
16
15
|
};
|
|
17
16
|
defineParamsGetter(__Ziko__)
|
|
18
17
|
}
|
|
19
18
|
}
|
|
19
|
+
export { UIStore } from './__ui__.js'
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { isStateGetter } from '../../hooks/use-state.js'
|
|
2
2
|
export const StyleMethods = {
|
|
3
|
-
style(styles){
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
3
|
+
// style(styles){
|
|
4
|
+
// for(let key in styles){
|
|
5
|
+
// const value = styles[key];
|
|
6
|
+
// if(isStateGetter(value)){
|
|
7
|
+
// const getter = value()
|
|
8
|
+
// Object.assign(this.element.style, {[key] : getter.value})
|
|
9
|
+
// getter._subscribe(
|
|
10
|
+
// (newValue) => {
|
|
11
|
+
// console.log({newValue})
|
|
12
|
+
// Object.assign(this.element.style, {[key] : newValue})
|
|
13
|
+
// },
|
|
14
|
+
// // this
|
|
15
|
+
// );
|
|
16
|
+
// }
|
|
17
|
+
// else Object.assign(this.element.style, {[key] : value})
|
|
18
|
+
// }
|
|
19
|
+
// return this;
|
|
20
|
+
// },
|
|
21
21
|
size(width, height){
|
|
22
22
|
return this.style({width, height})
|
|
23
23
|
},
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
EventsMethodes,
|
|
8
8
|
StyleMethods
|
|
9
9
|
} from "../__methods__/index.js";
|
|
10
|
-
|
|
10
|
+
import { isStateGetter } from "../../hooks/use-state.js";
|
|
11
11
|
import {
|
|
12
12
|
useCustomEvent,
|
|
13
13
|
useSwipeEvent,
|
|
@@ -16,11 +16,11 @@ import {
|
|
|
16
16
|
watchAttr,
|
|
17
17
|
watchChildren
|
|
18
18
|
} from "../../reactivity/index.js"
|
|
19
|
-
import { Random } from "../../math/index.js";
|
|
20
|
-
import {__init__global__} from '../../__ziko__/index.js';
|
|
19
|
+
// import { Random } from "../../math/index.js";
|
|
20
|
+
import {__init__global__, UIStore} from '../../__ziko__/index.js';
|
|
21
21
|
__init__global__()
|
|
22
22
|
class UIElement extends UINode{
|
|
23
|
-
constructor({element, name ='', type="html", useDefaultStyle=false}={}){
|
|
23
|
+
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
|
|
24
24
|
super()
|
|
25
25
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
26
26
|
if(typeof element === "string") {
|
|
@@ -71,8 +71,8 @@ class UIElement extends UINode{
|
|
|
71
71
|
resize:null,
|
|
72
72
|
intersection:null
|
|
73
73
|
}
|
|
74
|
-
if(element)Object.assign(this.cache,{element});
|
|
75
|
-
this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
74
|
+
if(element) Object.assign(this.cache,{element});
|
|
75
|
+
// this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
76
76
|
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
77
77
|
useDefaultStyle && this.style({
|
|
78
78
|
position: "relative",
|
|
@@ -82,9 +82,9 @@ class UIElement extends UINode{
|
|
|
82
82
|
width : "auto",
|
|
83
83
|
height : "auto"
|
|
84
84
|
});
|
|
85
|
-
this.items =
|
|
85
|
+
this.items = new UIStore();
|
|
86
86
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
87
|
-
element &&
|
|
87
|
+
element && render && this?.render?.()
|
|
88
88
|
if(
|
|
89
89
|
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
90
90
|
// &&
|
|
@@ -93,9 +93,9 @@ class UIElement extends UINode{
|
|
|
93
93
|
this.isInteractive()
|
|
94
94
|
){
|
|
95
95
|
this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
96
|
-
globalThis.__Ziko__.__HYDRATION__.
|
|
97
|
-
globalThis.__Ziko__.__HYDRATION__.increment()
|
|
96
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this)
|
|
98
97
|
}
|
|
98
|
+
globalThis.__Ziko__.__UI__.push(this)
|
|
99
99
|
}
|
|
100
100
|
get element(){
|
|
101
101
|
return this.cache.element;
|
|
@@ -106,6 +106,24 @@ class UIElement extends UINode{
|
|
|
106
106
|
isZikoUIElement(){
|
|
107
107
|
return true;
|
|
108
108
|
}
|
|
109
|
+
style(styles){
|
|
110
|
+
for(let key in styles){
|
|
111
|
+
const value = styles[key];
|
|
112
|
+
if(isStateGetter(value)){
|
|
113
|
+
const getter = value()
|
|
114
|
+
Object.assign(this.element.style, {[key] : getter.value})
|
|
115
|
+
getter._subscribe(
|
|
116
|
+
(newValue) => {
|
|
117
|
+
console.log({newValue})
|
|
118
|
+
Object.assign(this.element.style, {[key] : newValue})
|
|
119
|
+
},
|
|
120
|
+
// this
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
else Object.assign(this.element.style, {[key] : value})
|
|
124
|
+
}
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
109
127
|
get st(){
|
|
110
128
|
return this.cache.style;
|
|
111
129
|
}
|
|
@@ -146,14 +164,13 @@ class UIElement extends UINode{
|
|
|
146
164
|
return this.element.getBoundingClientRect().left;
|
|
147
165
|
}
|
|
148
166
|
clone(render=false) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return UI.render(render);
|
|
167
|
+
// UI.__proto__=this.__proto__;
|
|
168
|
+
// if(this.items.length){
|
|
169
|
+
// const items = [...this.items].map(n=>n.clone());
|
|
170
|
+
// UI.append(...items);
|
|
171
|
+
// }
|
|
172
|
+
// else UI.element=this.element.cloneNode(true);
|
|
173
|
+
// return UI.render(render);
|
|
157
174
|
}
|
|
158
175
|
[Symbol.iterator]() {
|
|
159
176
|
return this.items[Symbol.iterator]();
|
|
@@ -172,14 +189,14 @@ class UIElement extends UINode{
|
|
|
172
189
|
this.cache.isFrozzen=freeze;
|
|
173
190
|
return this;
|
|
174
191
|
}
|
|
175
|
-
setTarget(tg) {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
192
|
+
// setTarget(tg) {
|
|
193
|
+
// if(this.isBody) return ;
|
|
194
|
+
// if (tg?.isZikoUIElement) tg = tg.element;
|
|
195
|
+
// this.unrender();
|
|
196
|
+
// this.target = tg;
|
|
197
|
+
// this.render();
|
|
198
|
+
// return this;
|
|
199
|
+
// }
|
|
183
200
|
describe(label){
|
|
184
201
|
if(label)this.setAttr("aria-label",label)
|
|
185
202
|
}
|