ziko 0.0.26 → 0.0.27
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 +217 -5
- package/dist/ziko.mjs +215 -6
- package/package.json +1 -1
- package/src/app/globals.js +30 -2
- package/src/index.js +2 -1
- package/src/math/index.js +1 -0
- package/src/reactivity/events/ZikoEvent.js +1 -0
- package/src/reactivity/events-exp/__Events__.js +47 -0
- package/src/reactivity/events-exp/__ZikoEvent__.js +160 -0
- package/src/reactivity/events-exp/click.js +19 -0
- package/src/reactivity/events-exp/index.js +5 -0
- package/src/reactivity/events-exp/key.js +27 -0
- package/src/reactivity/events-exp/pointer.js +48 -0
- package/src/reactivity/events-exp/utils.js +7 -0
- package/src/reactivity/index.js +3 -0
- package/src/ui/elements/ZikoUIElement.js +5 -2
- package/src/ui/elements/misc/index.js +0 -1
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 : Thu Jul 10 2025 11:49:56 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
|
|
@@ -1013,6 +1013,11 @@
|
|
|
1013
1013
|
}
|
|
1014
1014
|
}
|
|
1015
1015
|
|
|
1016
|
+
var __Random__ = /*#__PURE__*/Object.freeze({
|
|
1017
|
+
__proto__: null,
|
|
1018
|
+
Random: Random
|
|
1019
|
+
});
|
|
1020
|
+
|
|
1016
1021
|
const luDecomposition=matrix=>{
|
|
1017
1022
|
if(matrix instanceof Matrix)matrix=matrix.arr;
|
|
1018
1023
|
const n = matrix.length;
|
|
@@ -1808,6 +1813,7 @@
|
|
|
1808
1813
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
1809
1814
|
this.event=e;
|
|
1810
1815
|
if(this.cache.preventDefault[EVENT])e.preventDefault();
|
|
1816
|
+
console.log({setter});
|
|
1811
1817
|
if(setter)setter();
|
|
1812
1818
|
if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
|
|
1813
1819
|
this.cache.callbacks[EVENT].map(n=>n(this));
|
|
@@ -4608,10 +4614,181 @@
|
|
|
4608
4614
|
useType: useType
|
|
4609
4615
|
});
|
|
4610
4616
|
|
|
4617
|
+
const getEvent=(event = "")=>{
|
|
4618
|
+
if(event.startsWith("Ptr"))return `pointer${event.split("Ptr")[1].toLowerCase()}`;
|
|
4619
|
+
return event.toLowerCase()
|
|
4620
|
+
};
|
|
4621
|
+
|
|
4622
|
+
function event_controller(e, event_name, details_setter, customizer, push_object){
|
|
4623
|
+
this.cache.currentEvent = event_name;
|
|
4624
|
+
this.cache.event = e;
|
|
4625
|
+
details_setter?.call(this);
|
|
4626
|
+
if(customizer?.hasOwnProperty("prototype"))customizer?.call(this);
|
|
4627
|
+
else customizer?.call(null, this);
|
|
4628
|
+
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
4629
|
+
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
4630
|
+
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
4631
|
+
|
|
4632
|
+
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
4633
|
+
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
4634
|
+
}
|
|
4635
|
+
class __ZikoEvent__ {
|
|
4636
|
+
constructor(target = null, Events = [], details_setter, customizer){
|
|
4637
|
+
this.target = target;
|
|
4638
|
+
this.cache = {
|
|
4639
|
+
currentEvent : null,
|
|
4640
|
+
event: null,
|
|
4641
|
+
options : {},
|
|
4642
|
+
preventDefault : {},
|
|
4643
|
+
stopPropagation : {},
|
|
4644
|
+
stopImmediatePropagation : {},
|
|
4645
|
+
event_flow : {},
|
|
4646
|
+
paused : {},
|
|
4647
|
+
stream : {
|
|
4648
|
+
enabled : {},
|
|
4649
|
+
clear : {},
|
|
4650
|
+
history : {}
|
|
4651
|
+
},
|
|
4652
|
+
callbacks : {},
|
|
4653
|
+
__controllers__:{}
|
|
4654
|
+
};
|
|
4655
|
+
const events = Events.map(n=>getEvent(n));
|
|
4656
|
+
events.forEach((event,i)=>{
|
|
4657
|
+
Object.assign(this.cache.preventDefault, {[event] : false});
|
|
4658
|
+
Object.assign(this.cache.options, {[event] : {}});
|
|
4659
|
+
Object.assign(this.cache.paused, {[event] : false});
|
|
4660
|
+
Object.assign(this.cache.stream.enabled, {[event] : false});
|
|
4661
|
+
Object.assign(this.cache.stream.clear, {[event] : false});
|
|
4662
|
+
Object.assign(this.cache.stream.history, {[event] : []});
|
|
4663
|
+
Object.assign(this.cache.__controllers__, {[event] : e=>event_controller.call(this, e, event, details_setter, customizer)});
|
|
4664
|
+
Object.assign(this, { [`on${Events[i]}`] : (...callbacks)=> this.__onEvent(event, this.cache.options[event], {}, ...callbacks)});
|
|
4665
|
+
});
|
|
4666
|
+
}
|
|
4667
|
+
get targetElement(){
|
|
4668
|
+
return this.target?.element;
|
|
4669
|
+
}
|
|
4670
|
+
get isParent(){
|
|
4671
|
+
return this.target?.element === this.event.srcElement;
|
|
4672
|
+
}
|
|
4673
|
+
get item(){
|
|
4674
|
+
return this.target.find(n=>n.element == this.event?.srcElement)?.[0];
|
|
4675
|
+
}
|
|
4676
|
+
get currentEvent(){
|
|
4677
|
+
return this.cache.currentEvent;
|
|
4678
|
+
}
|
|
4679
|
+
get event(){
|
|
4680
|
+
return this.cache.event;
|
|
4681
|
+
}
|
|
4682
|
+
setTarget(UI){
|
|
4683
|
+
this.target=UI;
|
|
4684
|
+
return this;
|
|
4685
|
+
}
|
|
4686
|
+
__handle(event, handler, options, dispose){
|
|
4687
|
+
this.targetElement?.addEventListener(event, handler, options);
|
|
4688
|
+
return this;
|
|
4689
|
+
}
|
|
4690
|
+
__onEvent(event, options, dispose, ...callbacks){
|
|
4691
|
+
if(callbacks.length===0){
|
|
4692
|
+
console.log("00");
|
|
4693
|
+
if(this.cache.callbacks[event]){
|
|
4694
|
+
console.log("Call");
|
|
4695
|
+
// this.cache.callbacks.map(n=>e=>n.call(this,e));
|
|
4696
|
+
this.cache.callbacks[event].map(n=>e=>n.call(this,e));
|
|
4697
|
+
}
|
|
4698
|
+
else {
|
|
4699
|
+
return this;
|
|
4700
|
+
}
|
|
4701
|
+
}
|
|
4702
|
+
else this.cache.callbacks[event] = callbacks.map(n=>e=>n.call(this,e));
|
|
4703
|
+
this.__handle(event, this.cache.__controllers__[event],options, dispose);
|
|
4704
|
+
return this;
|
|
4705
|
+
}
|
|
4706
|
+
#override(methode, overrides, defaultValue){
|
|
4707
|
+
if(defaultValue === "default") Object.assign(this.cache[methode], {...this.cache[methode], ...overrides});
|
|
4708
|
+
const all = defaultValue === "default"
|
|
4709
|
+
? this.cache[methode]
|
|
4710
|
+
: Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]));
|
|
4711
|
+
Object.assign(this.cache[methode], {...all,...overrides});
|
|
4712
|
+
return this
|
|
4713
|
+
}
|
|
4714
|
+
preventDefault(overrides = {}, defaultValue = "default"){
|
|
4715
|
+
this.#override("preventDefault", overrides, defaultValue);
|
|
4716
|
+
// const all=Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]))
|
|
4717
|
+
// Object.assign(this.cache.preventDefault, {...all,...overrides});
|
|
4718
|
+
return this;
|
|
4719
|
+
}
|
|
4720
|
+
stopPropagation(overrides = {}, defaultValue = "default"){
|
|
4721
|
+
this.#override("stopPropagation", overrides, defaultValue);
|
|
4722
|
+
return this;
|
|
4723
|
+
}
|
|
4724
|
+
stopImmediatePropagation(overrides = {}, defaultValue = "default"){
|
|
4725
|
+
this.#override("stopImmediatePropagation", overrides, defaultValue);
|
|
4726
|
+
return this;
|
|
4727
|
+
}
|
|
4728
|
+
setEventOptions(event, options){
|
|
4729
|
+
this.pause({[event] : true, }, "default");
|
|
4730
|
+
Object.assign(this.cache.options[getEvent(event)], options);
|
|
4731
|
+
this.resume({[event] : true, }, "default");
|
|
4732
|
+
return this;
|
|
4733
|
+
}
|
|
4734
|
+
pause(overrides = {}, defaultValue = "default"){
|
|
4735
|
+
const all = defaultValue === "default"
|
|
4736
|
+
? this.cache.stream.enabled
|
|
4737
|
+
: Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
4738
|
+
overrides={...all,...overrides};
|
|
4739
|
+
for(let key in overrides){
|
|
4740
|
+
if(overrides[key]){
|
|
4741
|
+
this.targetElement?.removeEventListener(key, this.cache.__controllers__[key], this.cache.options[key]);
|
|
4742
|
+
this.cache.paused[key]=true;
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
return this;
|
|
4746
|
+
}
|
|
4747
|
+
resume(overrides = {}, defaultValue = "default"){
|
|
4748
|
+
const all = defaultValue === "default"
|
|
4749
|
+
? this.cache.stream.enabled
|
|
4750
|
+
: Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
4751
|
+
overrides={...all,...overrides};
|
|
4752
|
+
for(let key in overrides){
|
|
4753
|
+
if(overrides[key]){
|
|
4754
|
+
this.targetElement?.addEventListener(key,this.cache.__controllers__[key], this.cache.options[key]);
|
|
4755
|
+
this.cache.paused[key]=false;
|
|
4756
|
+
}
|
|
4757
|
+
}
|
|
4758
|
+
return this;
|
|
4759
|
+
}
|
|
4760
|
+
stream(overrides = {}, defaultValue = "default"){
|
|
4761
|
+
this.cache.stream.t0=Date.now();
|
|
4762
|
+
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
4763
|
+
overrides={...all,...overrides};
|
|
4764
|
+
Object.assign(this.cache.stream.enabled,overrides);
|
|
4765
|
+
return this;
|
|
4766
|
+
}
|
|
4767
|
+
clear(){
|
|
4768
|
+
|
|
4769
|
+
}
|
|
4770
|
+
dispose(overrides = {}, defaultValue = "default"){
|
|
4771
|
+
this.pause(overrides, defaultValue);
|
|
4772
|
+
|
|
4773
|
+
return this;
|
|
4774
|
+
}
|
|
4775
|
+
}
|
|
4776
|
+
|
|
4777
|
+
// export * from "./click.js";
|
|
4778
|
+
// export * from "./key.js";
|
|
4779
|
+
// export * from "./pointer.js"
|
|
4780
|
+
|
|
4781
|
+
var EventsExp = /*#__PURE__*/Object.freeze({
|
|
4782
|
+
__proto__: null,
|
|
4783
|
+
__ZikoEvent__: __ZikoEvent__,
|
|
4784
|
+
getEvent: getEvent
|
|
4785
|
+
});
|
|
4786
|
+
|
|
4611
4787
|
const Reactivity={
|
|
4612
4788
|
...Events,
|
|
4613
4789
|
...Observer,
|
|
4614
4790
|
...Hooks,
|
|
4791
|
+
...EventsExp,
|
|
4615
4792
|
};
|
|
4616
4793
|
|
|
4617
4794
|
class ZikoUIElement {
|
|
@@ -4659,6 +4836,7 @@
|
|
|
4659
4836
|
intersection:null
|
|
4660
4837
|
};
|
|
4661
4838
|
this.uuid = `${this.cache.name}-${Random.string(16)}`;
|
|
4839
|
+
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
4662
4840
|
this.cache.style.linkTo(this);
|
|
4663
4841
|
useDefaultStyle && this.style({
|
|
4664
4842
|
position: "relative",
|
|
@@ -4671,7 +4849,7 @@
|
|
|
4671
4849
|
this.items = [];
|
|
4672
4850
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
4673
4851
|
element && globalThis.__Ziko__.__Config__.default.render && this.render();
|
|
4674
|
-
this.setAttr("data-
|
|
4852
|
+
this.setAttr("data-ui-index", this.ui_index);
|
|
4675
4853
|
if(globalThis.__Ziko__.__Config__.renderingMode !== "spa" && !globalThis.__Ziko__.__Config__.isSSC) {
|
|
4676
4854
|
globalThis.__Ziko__.__HYDRATION_MAP__.set(this.uuid, ()=>this);
|
|
4677
4855
|
}
|
|
@@ -4755,12 +4933,14 @@
|
|
|
4755
4933
|
}
|
|
4756
4934
|
for (let i = 0; i < ele.length; i++) {
|
|
4757
4935
|
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
4936
|
+
if(ele[i] instanceof Node) ele[i] = new ZikoUIElement(ele[i]);
|
|
4758
4937
|
if (ele[i]?.isZikoUIElement) {
|
|
4759
4938
|
ele[i].cache.parent = this;
|
|
4760
4939
|
this.element[adder](ele[i].element);
|
|
4761
4940
|
ele[i].target = this.element;
|
|
4762
4941
|
this.items[pusher](ele[i]);
|
|
4763
|
-
}
|
|
4942
|
+
}
|
|
4943
|
+
else if (ele[i] instanceof Object) {
|
|
4764
4944
|
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
4765
4945
|
if (ele[i]?.attr) {
|
|
4766
4946
|
Object.entries(ele[i].attr).forEach((n) =>
|
|
@@ -6057,7 +6237,6 @@
|
|
|
6057
6237
|
class ZikoUIBtn extends ZikoUIElement {
|
|
6058
6238
|
constructor(value = "button") {
|
|
6059
6239
|
super("button","btn");
|
|
6060
|
-
this.element = document?.createElement("button");
|
|
6061
6240
|
this.setValue(value);
|
|
6062
6241
|
this.st.cursor("pointer");
|
|
6063
6242
|
globalThis.__Ziko__.__Config__.default.render && this.render();
|
|
@@ -8466,6 +8645,7 @@
|
|
|
8466
8645
|
...__Functions__,
|
|
8467
8646
|
...__Complex__,
|
|
8468
8647
|
...__Matrix__,
|
|
8648
|
+
...__Random__,
|
|
8469
8649
|
...__Utils__,
|
|
8470
8650
|
...__Discrect__,
|
|
8471
8651
|
// ...__Signal__,
|
|
@@ -9101,7 +9281,28 @@
|
|
|
9101
9281
|
});
|
|
9102
9282
|
}
|
|
9103
9283
|
|
|
9104
|
-
const __UI__={
|
|
9284
|
+
const __UI__={
|
|
9285
|
+
__all__(){
|
|
9286
|
+
return Object.values(this)
|
|
9287
|
+
.filter(Array.isArray)
|
|
9288
|
+
.flat();
|
|
9289
|
+
},
|
|
9290
|
+
querySelectorAll(){
|
|
9291
|
+
return this.__all__().filter(n=>n)
|
|
9292
|
+
},
|
|
9293
|
+
getElementByIndex(index){
|
|
9294
|
+
return this.__all__().find(n=>n.ui_index===index);
|
|
9295
|
+
},
|
|
9296
|
+
getElementById(id){
|
|
9297
|
+
return null;
|
|
9298
|
+
},
|
|
9299
|
+
getElementsByClass(){
|
|
9300
|
+
|
|
9301
|
+
},
|
|
9302
|
+
getElementsByTagName(){
|
|
9303
|
+
|
|
9304
|
+
}
|
|
9305
|
+
};
|
|
9105
9306
|
const __HYDRATION_MAP__ = new Map();
|
|
9106
9307
|
const __Config__={
|
|
9107
9308
|
default:{
|
|
@@ -9119,10 +9320,17 @@
|
|
|
9119
9320
|
init:()=>document.documentElement.setAttribute("data-engine","zikojs"),
|
|
9120
9321
|
renderingMode :"spa",
|
|
9121
9322
|
isSSC : false,
|
|
9323
|
+
};
|
|
9324
|
+
const __CACHE__ = {
|
|
9325
|
+
ui_index : 0,
|
|
9326
|
+
get_ui_index:function(){
|
|
9327
|
+
return this.ui_index ++
|
|
9328
|
+
}
|
|
9122
9329
|
};
|
|
9123
9330
|
|
|
9124
9331
|
var Global = /*#__PURE__*/Object.freeze({
|
|
9125
9332
|
__proto__: null,
|
|
9333
|
+
__CACHE__: __CACHE__,
|
|
9126
9334
|
__Config__: __Config__,
|
|
9127
9335
|
__HYDRATION_MAP__: __HYDRATION_MAP__,
|
|
9128
9336
|
__UI__: __UI__
|
|
@@ -9226,6 +9434,7 @@
|
|
|
9226
9434
|
__UI__,
|
|
9227
9435
|
__HYDRATION_MAP__,
|
|
9228
9436
|
__Config__,
|
|
9437
|
+
__CACHE__,
|
|
9229
9438
|
ExtractAll,
|
|
9230
9439
|
RemoveAll
|
|
9231
9440
|
};
|
|
@@ -9363,9 +9572,11 @@
|
|
|
9363
9572
|
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
9364
9573
|
exports.ZikoUseRoot = ZikoUseRoot;
|
|
9365
9574
|
exports.ZikoUseStyle = ZikoUseStyle;
|
|
9575
|
+
exports.__CACHE__ = __CACHE__;
|
|
9366
9576
|
exports.__Config__ = __Config__;
|
|
9367
9577
|
exports.__HYDRATION_MAP__ = __HYDRATION_MAP__;
|
|
9368
9578
|
exports.__UI__ = __UI__;
|
|
9579
|
+
exports.__ZikoEvent__ = __ZikoEvent__;
|
|
9369
9580
|
exports.abbrText = abbrText;
|
|
9370
9581
|
exports.abs = abs;
|
|
9371
9582
|
exports.accum = accum;
|
|
@@ -9419,6 +9630,7 @@
|
|
|
9419
9630
|
exports.floor = floor;
|
|
9420
9631
|
exports.gamma = gamma;
|
|
9421
9632
|
exports.geomspace = geomspace;
|
|
9633
|
+
exports.getEvent = getEvent;
|
|
9422
9634
|
exports.h = h;
|
|
9423
9635
|
exports.h1 = h1;
|
|
9424
9636
|
exports.h2 = h2;
|
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 : Thu Jul 10 2025 11:49:56 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
|
|
@@ -1007,6 +1007,11 @@ class Random {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
}
|
|
1009
1009
|
|
|
1010
|
+
var __Random__ = /*#__PURE__*/Object.freeze({
|
|
1011
|
+
__proto__: null,
|
|
1012
|
+
Random: Random
|
|
1013
|
+
});
|
|
1014
|
+
|
|
1010
1015
|
const luDecomposition=matrix=>{
|
|
1011
1016
|
if(matrix instanceof Matrix)matrix=matrix.arr;
|
|
1012
1017
|
const n = matrix.length;
|
|
@@ -1802,6 +1807,7 @@ class ZikoUIElementStyle{
|
|
|
1802
1807
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
1803
1808
|
this.event=e;
|
|
1804
1809
|
if(this.cache.preventDefault[EVENT])e.preventDefault();
|
|
1810
|
+
console.log({setter});
|
|
1805
1811
|
if(setter)setter();
|
|
1806
1812
|
if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
|
|
1807
1813
|
this.cache.callbacks[EVENT].map(n=>n(this));
|
|
@@ -4602,10 +4608,181 @@ var Hooks = /*#__PURE__*/Object.freeze({
|
|
|
4602
4608
|
useType: useType
|
|
4603
4609
|
});
|
|
4604
4610
|
|
|
4611
|
+
const getEvent=(event = "")=>{
|
|
4612
|
+
if(event.startsWith("Ptr"))return `pointer${event.split("Ptr")[1].toLowerCase()}`;
|
|
4613
|
+
return event.toLowerCase()
|
|
4614
|
+
};
|
|
4615
|
+
|
|
4616
|
+
function event_controller(e, event_name, details_setter, customizer, push_object){
|
|
4617
|
+
this.cache.currentEvent = event_name;
|
|
4618
|
+
this.cache.event = e;
|
|
4619
|
+
details_setter?.call(this);
|
|
4620
|
+
if(customizer?.hasOwnProperty("prototype"))customizer?.call(this);
|
|
4621
|
+
else customizer?.call(null, this);
|
|
4622
|
+
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
4623
|
+
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
4624
|
+
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
4625
|
+
|
|
4626
|
+
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
4627
|
+
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
4628
|
+
}
|
|
4629
|
+
class __ZikoEvent__ {
|
|
4630
|
+
constructor(target = null, Events = [], details_setter, customizer){
|
|
4631
|
+
this.target = target;
|
|
4632
|
+
this.cache = {
|
|
4633
|
+
currentEvent : null,
|
|
4634
|
+
event: null,
|
|
4635
|
+
options : {},
|
|
4636
|
+
preventDefault : {},
|
|
4637
|
+
stopPropagation : {},
|
|
4638
|
+
stopImmediatePropagation : {},
|
|
4639
|
+
event_flow : {},
|
|
4640
|
+
paused : {},
|
|
4641
|
+
stream : {
|
|
4642
|
+
enabled : {},
|
|
4643
|
+
clear : {},
|
|
4644
|
+
history : {}
|
|
4645
|
+
},
|
|
4646
|
+
callbacks : {},
|
|
4647
|
+
__controllers__:{}
|
|
4648
|
+
};
|
|
4649
|
+
const events = Events.map(n=>getEvent(n));
|
|
4650
|
+
events.forEach((event,i)=>{
|
|
4651
|
+
Object.assign(this.cache.preventDefault, {[event] : false});
|
|
4652
|
+
Object.assign(this.cache.options, {[event] : {}});
|
|
4653
|
+
Object.assign(this.cache.paused, {[event] : false});
|
|
4654
|
+
Object.assign(this.cache.stream.enabled, {[event] : false});
|
|
4655
|
+
Object.assign(this.cache.stream.clear, {[event] : false});
|
|
4656
|
+
Object.assign(this.cache.stream.history, {[event] : []});
|
|
4657
|
+
Object.assign(this.cache.__controllers__, {[event] : e=>event_controller.call(this, e, event, details_setter, customizer)});
|
|
4658
|
+
Object.assign(this, { [`on${Events[i]}`] : (...callbacks)=> this.__onEvent(event, this.cache.options[event], {}, ...callbacks)});
|
|
4659
|
+
});
|
|
4660
|
+
}
|
|
4661
|
+
get targetElement(){
|
|
4662
|
+
return this.target?.element;
|
|
4663
|
+
}
|
|
4664
|
+
get isParent(){
|
|
4665
|
+
return this.target?.element === this.event.srcElement;
|
|
4666
|
+
}
|
|
4667
|
+
get item(){
|
|
4668
|
+
return this.target.find(n=>n.element == this.event?.srcElement)?.[0];
|
|
4669
|
+
}
|
|
4670
|
+
get currentEvent(){
|
|
4671
|
+
return this.cache.currentEvent;
|
|
4672
|
+
}
|
|
4673
|
+
get event(){
|
|
4674
|
+
return this.cache.event;
|
|
4675
|
+
}
|
|
4676
|
+
setTarget(UI){
|
|
4677
|
+
this.target=UI;
|
|
4678
|
+
return this;
|
|
4679
|
+
}
|
|
4680
|
+
__handle(event, handler, options, dispose){
|
|
4681
|
+
this.targetElement?.addEventListener(event, handler, options);
|
|
4682
|
+
return this;
|
|
4683
|
+
}
|
|
4684
|
+
__onEvent(event, options, dispose, ...callbacks){
|
|
4685
|
+
if(callbacks.length===0){
|
|
4686
|
+
console.log("00");
|
|
4687
|
+
if(this.cache.callbacks[event]){
|
|
4688
|
+
console.log("Call");
|
|
4689
|
+
// this.cache.callbacks.map(n=>e=>n.call(this,e));
|
|
4690
|
+
this.cache.callbacks[event].map(n=>e=>n.call(this,e));
|
|
4691
|
+
}
|
|
4692
|
+
else {
|
|
4693
|
+
return this;
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
else this.cache.callbacks[event] = callbacks.map(n=>e=>n.call(this,e));
|
|
4697
|
+
this.__handle(event, this.cache.__controllers__[event],options, dispose);
|
|
4698
|
+
return this;
|
|
4699
|
+
}
|
|
4700
|
+
#override(methode, overrides, defaultValue){
|
|
4701
|
+
if(defaultValue === "default") Object.assign(this.cache[methode], {...this.cache[methode], ...overrides});
|
|
4702
|
+
const all = defaultValue === "default"
|
|
4703
|
+
? this.cache[methode]
|
|
4704
|
+
: Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]));
|
|
4705
|
+
Object.assign(this.cache[methode], {...all,...overrides});
|
|
4706
|
+
return this
|
|
4707
|
+
}
|
|
4708
|
+
preventDefault(overrides = {}, defaultValue = "default"){
|
|
4709
|
+
this.#override("preventDefault", overrides, defaultValue);
|
|
4710
|
+
// const all=Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]))
|
|
4711
|
+
// Object.assign(this.cache.preventDefault, {...all,...overrides});
|
|
4712
|
+
return this;
|
|
4713
|
+
}
|
|
4714
|
+
stopPropagation(overrides = {}, defaultValue = "default"){
|
|
4715
|
+
this.#override("stopPropagation", overrides, defaultValue);
|
|
4716
|
+
return this;
|
|
4717
|
+
}
|
|
4718
|
+
stopImmediatePropagation(overrides = {}, defaultValue = "default"){
|
|
4719
|
+
this.#override("stopImmediatePropagation", overrides, defaultValue);
|
|
4720
|
+
return this;
|
|
4721
|
+
}
|
|
4722
|
+
setEventOptions(event, options){
|
|
4723
|
+
this.pause({[event] : true, }, "default");
|
|
4724
|
+
Object.assign(this.cache.options[getEvent(event)], options);
|
|
4725
|
+
this.resume({[event] : true, }, "default");
|
|
4726
|
+
return this;
|
|
4727
|
+
}
|
|
4728
|
+
pause(overrides = {}, defaultValue = "default"){
|
|
4729
|
+
const all = defaultValue === "default"
|
|
4730
|
+
? this.cache.stream.enabled
|
|
4731
|
+
: Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
4732
|
+
overrides={...all,...overrides};
|
|
4733
|
+
for(let key in overrides){
|
|
4734
|
+
if(overrides[key]){
|
|
4735
|
+
this.targetElement?.removeEventListener(key, this.cache.__controllers__[key], this.cache.options[key]);
|
|
4736
|
+
this.cache.paused[key]=true;
|
|
4737
|
+
}
|
|
4738
|
+
}
|
|
4739
|
+
return this;
|
|
4740
|
+
}
|
|
4741
|
+
resume(overrides = {}, defaultValue = "default"){
|
|
4742
|
+
const all = defaultValue === "default"
|
|
4743
|
+
? this.cache.stream.enabled
|
|
4744
|
+
: Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
4745
|
+
overrides={...all,...overrides};
|
|
4746
|
+
for(let key in overrides){
|
|
4747
|
+
if(overrides[key]){
|
|
4748
|
+
this.targetElement?.addEventListener(key,this.cache.__controllers__[key], this.cache.options[key]);
|
|
4749
|
+
this.cache.paused[key]=false;
|
|
4750
|
+
}
|
|
4751
|
+
}
|
|
4752
|
+
return this;
|
|
4753
|
+
}
|
|
4754
|
+
stream(overrides = {}, defaultValue = "default"){
|
|
4755
|
+
this.cache.stream.t0=Date.now();
|
|
4756
|
+
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
4757
|
+
overrides={...all,...overrides};
|
|
4758
|
+
Object.assign(this.cache.stream.enabled,overrides);
|
|
4759
|
+
return this;
|
|
4760
|
+
}
|
|
4761
|
+
clear(){
|
|
4762
|
+
|
|
4763
|
+
}
|
|
4764
|
+
dispose(overrides = {}, defaultValue = "default"){
|
|
4765
|
+
this.pause(overrides, defaultValue);
|
|
4766
|
+
|
|
4767
|
+
return this;
|
|
4768
|
+
}
|
|
4769
|
+
}
|
|
4770
|
+
|
|
4771
|
+
// export * from "./click.js";
|
|
4772
|
+
// export * from "./key.js";
|
|
4773
|
+
// export * from "./pointer.js"
|
|
4774
|
+
|
|
4775
|
+
var EventsExp = /*#__PURE__*/Object.freeze({
|
|
4776
|
+
__proto__: null,
|
|
4777
|
+
__ZikoEvent__: __ZikoEvent__,
|
|
4778
|
+
getEvent: getEvent
|
|
4779
|
+
});
|
|
4780
|
+
|
|
4605
4781
|
const Reactivity={
|
|
4606
4782
|
...Events,
|
|
4607
4783
|
...Observer,
|
|
4608
4784
|
...Hooks,
|
|
4785
|
+
...EventsExp,
|
|
4609
4786
|
};
|
|
4610
4787
|
|
|
4611
4788
|
class ZikoUIElement {
|
|
@@ -4653,6 +4830,7 @@ class ZikoUIElement {
|
|
|
4653
4830
|
intersection:null
|
|
4654
4831
|
};
|
|
4655
4832
|
this.uuid = `${this.cache.name}-${Random.string(16)}`;
|
|
4833
|
+
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
4656
4834
|
this.cache.style.linkTo(this);
|
|
4657
4835
|
useDefaultStyle && this.style({
|
|
4658
4836
|
position: "relative",
|
|
@@ -4665,7 +4843,7 @@ class ZikoUIElement {
|
|
|
4665
4843
|
this.items = [];
|
|
4666
4844
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
4667
4845
|
element && globalThis.__Ziko__.__Config__.default.render && this.render();
|
|
4668
|
-
this.setAttr("data-
|
|
4846
|
+
this.setAttr("data-ui-index", this.ui_index);
|
|
4669
4847
|
if(globalThis.__Ziko__.__Config__.renderingMode !== "spa" && !globalThis.__Ziko__.__Config__.isSSC) {
|
|
4670
4848
|
globalThis.__Ziko__.__HYDRATION_MAP__.set(this.uuid, ()=>this);
|
|
4671
4849
|
}
|
|
@@ -4749,12 +4927,14 @@ class ZikoUIElement {
|
|
|
4749
4927
|
}
|
|
4750
4928
|
for (let i = 0; i < ele.length; i++) {
|
|
4751
4929
|
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
4930
|
+
if(ele[i] instanceof Node) ele[i] = new ZikoUIElement(ele[i]);
|
|
4752
4931
|
if (ele[i]?.isZikoUIElement) {
|
|
4753
4932
|
ele[i].cache.parent = this;
|
|
4754
4933
|
this.element[adder](ele[i].element);
|
|
4755
4934
|
ele[i].target = this.element;
|
|
4756
4935
|
this.items[pusher](ele[i]);
|
|
4757
|
-
}
|
|
4936
|
+
}
|
|
4937
|
+
else if (ele[i] instanceof Object) {
|
|
4758
4938
|
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
4759
4939
|
if (ele[i]?.attr) {
|
|
4760
4940
|
Object.entries(ele[i].attr).forEach((n) =>
|
|
@@ -6051,7 +6231,6 @@ class ZikoUIHtmlTag extends ZikoUIElement {
|
|
|
6051
6231
|
class ZikoUIBtn extends ZikoUIElement {
|
|
6052
6232
|
constructor(value = "button") {
|
|
6053
6233
|
super("button","btn");
|
|
6054
|
-
this.element = document?.createElement("button");
|
|
6055
6234
|
this.setValue(value);
|
|
6056
6235
|
this.st.cursor("pointer");
|
|
6057
6236
|
globalThis.__Ziko__.__Config__.default.render && this.render();
|
|
@@ -8460,6 +8639,7 @@ const Math$1 = {
|
|
|
8460
8639
|
...__Functions__,
|
|
8461
8640
|
...__Complex__,
|
|
8462
8641
|
...__Matrix__,
|
|
8642
|
+
...__Random__,
|
|
8463
8643
|
...__Utils__,
|
|
8464
8644
|
...__Discrect__,
|
|
8465
8645
|
// ...__Signal__,
|
|
@@ -9095,7 +9275,28 @@ function defineParamsGetter(target ){
|
|
|
9095
9275
|
});
|
|
9096
9276
|
}
|
|
9097
9277
|
|
|
9098
|
-
const __UI__={
|
|
9278
|
+
const __UI__={
|
|
9279
|
+
__all__(){
|
|
9280
|
+
return Object.values(this)
|
|
9281
|
+
.filter(Array.isArray)
|
|
9282
|
+
.flat();
|
|
9283
|
+
},
|
|
9284
|
+
querySelectorAll(){
|
|
9285
|
+
return this.__all__().filter(n=>n)
|
|
9286
|
+
},
|
|
9287
|
+
getElementByIndex(index){
|
|
9288
|
+
return this.__all__().find(n=>n.ui_index===index);
|
|
9289
|
+
},
|
|
9290
|
+
getElementById(id){
|
|
9291
|
+
return null;
|
|
9292
|
+
},
|
|
9293
|
+
getElementsByClass(){
|
|
9294
|
+
|
|
9295
|
+
},
|
|
9296
|
+
getElementsByTagName(){
|
|
9297
|
+
|
|
9298
|
+
}
|
|
9299
|
+
};
|
|
9099
9300
|
const __HYDRATION_MAP__ = new Map();
|
|
9100
9301
|
const __Config__={
|
|
9101
9302
|
default:{
|
|
@@ -9113,10 +9314,17 @@ const __Config__={
|
|
|
9113
9314
|
init:()=>document.documentElement.setAttribute("data-engine","zikojs"),
|
|
9114
9315
|
renderingMode :"spa",
|
|
9115
9316
|
isSSC : false,
|
|
9317
|
+
};
|
|
9318
|
+
const __CACHE__ = {
|
|
9319
|
+
ui_index : 0,
|
|
9320
|
+
get_ui_index:function(){
|
|
9321
|
+
return this.ui_index ++
|
|
9322
|
+
}
|
|
9116
9323
|
};
|
|
9117
9324
|
|
|
9118
9325
|
var Global = /*#__PURE__*/Object.freeze({
|
|
9119
9326
|
__proto__: null,
|
|
9327
|
+
__CACHE__: __CACHE__,
|
|
9120
9328
|
__Config__: __Config__,
|
|
9121
9329
|
__HYDRATION_MAP__: __HYDRATION_MAP__,
|
|
9122
9330
|
__UI__: __UI__
|
|
@@ -9220,6 +9428,7 @@ if ( globalThis.__Ziko__ ) {
|
|
|
9220
9428
|
__UI__,
|
|
9221
9429
|
__HYDRATION_MAP__,
|
|
9222
9430
|
__Config__,
|
|
9431
|
+
__CACHE__,
|
|
9223
9432
|
ExtractAll,
|
|
9224
9433
|
RemoveAll
|
|
9225
9434
|
};
|
|
@@ -9253,4 +9462,4 @@ function RemoveAll(){
|
|
|
9253
9462
|
Data.RemoveAll();
|
|
9254
9463
|
}
|
|
9255
9464
|
|
|
9256
|
-
export { App$1 as App, Article, Aside, Base, Canvas, Combinaison, Complex, E, EPSILON, Ease, FileBasedRouting, Flex, Footer, Form, Grid$1 as Grid, HTMLWrapper, Header, LinearSystem, Logic$1 as Logic, Main, Matrix, Nav, PI$1 as PI, Permutation, Random, SPA, SVGWrapper, Section, Str, Suspense, Svg, Table$1 as Table, Utils$1 as Utils, ZikoApp, ZikoCustomEvent, ZikoEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventHash, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventWheel, ZikoHead$1 as ZikoHead, ZikoJsonStyleSheet, ZikoMutationObserver, ZikoSPA, ZikoUIAbbrText, ZikoUIArticle, ZikoUIAside, ZikoUIAudio, ZikoUIBlockQuote, ZikoUIBr, ZikoUICanvas, ZikoUICodeText, ZikoUIDefintion, ZikoUIElement, ZikoUIFigure, ZikoUIFlex, ZikoUIFooter, ZikoUIForm, ZikoUIGrid, ZikoUIHTMLWrapper, ZikoUIHeader, ZikoUIHeading, ZikoUIHr, ZikoUIHtmlTag, ZikoUIImage, ZikoUIInput, ZikoUIInputCheckbox, ZikoUIInputColor, ZikoUIInputDatalist$1 as ZikoUIInputDatalist, ZikoUIInputDate, ZikoUIInputDateTime, ZikoUIInputEmail, ZikoUIInputImage, ZikoUIInputNumber, ZikoUIInputOption, ZikoUIInputPassword, ZikoUIInputRadio, ZikoUIInputSearch, ZikoUIInputSlider$1 as ZikoUIInputSlider, ZikoUIInputTime, ZikoUILabel, ZikoUILink, ZikoUIMain, ZikoUINav, ZikoUIParagraphe, ZikoUIQuote, ZikoUISVGWrapper, ZikoUISection, ZikoUISelect, ZikoUISubText, ZikoUISupText, ZikoUISuspense, ZikoUISvg, ZikoUIText, ZikoUITextArea, ZikoUIVideo, ZikoUIXMLWrapper, ZikoUseRoot, ZikoUseStyle, __Config__, __HYDRATION_MAP__, __UI__, abbrText, abs, accum, acos, acosh, acot, add, arange, arr2str, asin, asinh, atan, atan2, atanh, audio, bessel, beta, blockQuote, br, brs, btn, cartesianProduct, ceil, checkbox, choleskyDecomposition, clamp, codeText, combinaison, complex, cos, cosh, cot, coth, count, countWords, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, datalist, Ziko as default, defineParamsGetter, deg2rad, dfnText, div, e, fact, figure, floor, gamma, geomspace, h, h1, h2, h3, h4, h5, h6, hTags, hr, hrs, html, hypot, image, inRange, input, inputCamera, inputColor, inputDate, inputDateTime, inputEmail, inputImage, inputNumber, inputPassword, inputTime, isApproximatlyEqual, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, jsonStyleSheet, lerp, li, link, linspace, ln, logspace, luDecomposition, map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ol, ones, p, pgcd, pow, powerSet, ppcm, preload, prod, qrDecomposition, quote, rad2deg, radio, removeExtraSpace, round, s, sTags, search, sec, select, sig, sign, sin, sinc, sinh, slider, sqrt, sqrtn, str, sub, subSet, subText, sum, supText, svg2ascii, svg2img, svg2imgUrl, svg2str, tan, tanh, text, textarea, timeTaken, time_memory_Taken, ul, useAnimation, useChannel$1 as useChannel, useClickEvent, useClipboardEvent, useCustomEvent, useDebounce, useDragEvent, useDropEvent, useEventEmitter, useFavIcon$1 as useFavIcon, useFocusEvent, useFps, useHashEvent, useHead$1 as useHead, useInputEvent, useKeyEvent, useLocaleStorage, useMediaQuery, useMeta$1 as useMeta, useMouseEvent, usePointerEvent, useRoot, useRootValue, useSessionStorage, useStyle, useSuccesifKeys, useSwipeEvent, useThread, useThrottle, useTimeLoop, useTitle$1 as useTitle, useType, useWheelEvent, video, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
|
|
9465
|
+
export { App$1 as App, Article, Aside, Base, Canvas, Combinaison, Complex, E, EPSILON, Ease, FileBasedRouting, Flex, Footer, Form, Grid$1 as Grid, HTMLWrapper, Header, LinearSystem, Logic$1 as Logic, Main, Matrix, Nav, PI$1 as PI, Permutation, Random, SPA, SVGWrapper, Section, Str, Suspense, Svg, Table$1 as Table, Utils$1 as Utils, ZikoApp, ZikoCustomEvent, ZikoEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventHash, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventWheel, ZikoHead$1 as ZikoHead, ZikoJsonStyleSheet, ZikoMutationObserver, ZikoSPA, ZikoUIAbbrText, ZikoUIArticle, ZikoUIAside, ZikoUIAudio, ZikoUIBlockQuote, ZikoUIBr, ZikoUICanvas, ZikoUICodeText, ZikoUIDefintion, ZikoUIElement, ZikoUIFigure, ZikoUIFlex, ZikoUIFooter, ZikoUIForm, ZikoUIGrid, ZikoUIHTMLWrapper, ZikoUIHeader, ZikoUIHeading, ZikoUIHr, ZikoUIHtmlTag, ZikoUIImage, ZikoUIInput, ZikoUIInputCheckbox, ZikoUIInputColor, ZikoUIInputDatalist$1 as ZikoUIInputDatalist, ZikoUIInputDate, ZikoUIInputDateTime, ZikoUIInputEmail, ZikoUIInputImage, ZikoUIInputNumber, ZikoUIInputOption, ZikoUIInputPassword, ZikoUIInputRadio, ZikoUIInputSearch, ZikoUIInputSlider$1 as ZikoUIInputSlider, ZikoUIInputTime, ZikoUILabel, ZikoUILink, ZikoUIMain, ZikoUINav, ZikoUIParagraphe, ZikoUIQuote, ZikoUISVGWrapper, ZikoUISection, ZikoUISelect, ZikoUISubText, ZikoUISupText, ZikoUISuspense, ZikoUISvg, ZikoUIText, ZikoUITextArea, ZikoUIVideo, ZikoUIXMLWrapper, ZikoUseRoot, ZikoUseStyle, __CACHE__, __Config__, __HYDRATION_MAP__, __UI__, __ZikoEvent__, abbrText, abs, accum, acos, acosh, acot, add, arange, arr2str, asin, asinh, atan, atan2, atanh, audio, bessel, beta, blockQuote, br, brs, btn, cartesianProduct, ceil, checkbox, choleskyDecomposition, clamp, codeText, combinaison, complex, cos, cosh, cot, coth, count, countWords, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, datalist, Ziko as default, defineParamsGetter, deg2rad, dfnText, div, e, fact, figure, floor, gamma, geomspace, getEvent, h, h1, h2, h3, h4, h5, h6, hTags, hr, hrs, html, hypot, image, inRange, input, inputCamera, inputColor, inputDate, inputDateTime, inputEmail, inputImage, inputNumber, inputPassword, inputTime, isApproximatlyEqual, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, jsonStyleSheet, lerp, li, link, linspace, ln, logspace, luDecomposition, map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ol, ones, p, pgcd, pow, powerSet, ppcm, preload, prod, qrDecomposition, quote, rad2deg, radio, removeExtraSpace, round, s, sTags, search, sec, select, sig, sign, sin, sinc, sinh, slider, sqrt, sqrtn, str, sub, subSet, subText, sum, supText, svg2ascii, svg2img, svg2imgUrl, svg2str, tan, tanh, text, textarea, timeTaken, time_memory_Taken, ul, useAnimation, useChannel$1 as useChannel, useClickEvent, useClipboardEvent, useCustomEvent, useDebounce, useDragEvent, useDropEvent, useEventEmitter, useFavIcon$1 as useFavIcon, useFocusEvent, useFps, useHashEvent, useHead$1 as useHead, useInputEvent, useKeyEvent, useLocaleStorage, useMediaQuery, useMeta$1 as useMeta, useMouseEvent, usePointerEvent, useRoot, useRootValue, useSessionStorage, useStyle, useSuccesifKeys, useSwipeEvent, useThread, useThrottle, useTimeLoop, useTitle$1 as useTitle, useType, useWheelEvent, video, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
4
4
|
"description": "a versatile javaScript framework offering a rich set of UI components, advanced mathematical utilities, reactivity, animations, client side routing and graphics capabilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"front-end",
|
package/src/app/globals.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
const __UI__={
|
|
1
|
+
const __UI__={
|
|
2
|
+
__all__(){
|
|
3
|
+
return Object.values(this)
|
|
4
|
+
.filter(Array.isArray)
|
|
5
|
+
.flat();
|
|
6
|
+
},
|
|
7
|
+
querySelectorAll(){
|
|
8
|
+
return this.__all__().filter(n=>n)
|
|
9
|
+
},
|
|
10
|
+
getElementByIndex(index){
|
|
11
|
+
return this.__all__().find(n=>n.ui_index===index);
|
|
12
|
+
},
|
|
13
|
+
getElementById(id){
|
|
14
|
+
return null;
|
|
15
|
+
},
|
|
16
|
+
getElementsByClass(){
|
|
17
|
+
|
|
18
|
+
},
|
|
19
|
+
getElementsByTagName(){
|
|
20
|
+
|
|
21
|
+
}
|
|
22
|
+
}
|
|
2
23
|
const __HYDRATION_MAP__ = new Map()
|
|
3
24
|
const __Config__={
|
|
4
25
|
default:{
|
|
@@ -17,8 +38,15 @@ const __Config__={
|
|
|
17
38
|
renderingMode :"spa",
|
|
18
39
|
isSSC : false,
|
|
19
40
|
}
|
|
41
|
+
const __CACHE__ = {
|
|
42
|
+
ui_index : 0,
|
|
43
|
+
get_ui_index:function(){
|
|
44
|
+
return this.ui_index ++
|
|
45
|
+
}
|
|
46
|
+
}
|
|
20
47
|
export {
|
|
21
48
|
__UI__,
|
|
22
49
|
__HYDRATION_MAP__,
|
|
23
|
-
__Config__
|
|
50
|
+
__Config__,
|
|
51
|
+
__CACHE__
|
|
24
52
|
}
|
package/src/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import Time from "./time";
|
|
|
5
5
|
import Data from "./data";
|
|
6
6
|
import Reactivity from "./reactivity";
|
|
7
7
|
import Graphics from "./graphics";
|
|
8
|
-
import App,{__UI__,__HYDRATION_MAP__, __Config__, defineParamsGetter} from "./app";
|
|
8
|
+
import App,{__UI__,__HYDRATION_MAP__, __Config__, __CACHE__, defineParamsGetter} from "./app";
|
|
9
9
|
|
|
10
10
|
export * from "./math";
|
|
11
11
|
export * from "./ui";
|
|
@@ -47,6 +47,7 @@ if ( globalThis.__Ziko__ ) {
|
|
|
47
47
|
__UI__,
|
|
48
48
|
__HYDRATION_MAP__,
|
|
49
49
|
__Config__,
|
|
50
|
+
__CACHE__,
|
|
50
51
|
ExtractAll,
|
|
51
52
|
RemoveAll
|
|
52
53
|
};
|
package/src/math/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
2
2
|
this.event=e
|
|
3
3
|
if(this.cache.preventDefault[EVENT])e.preventDefault();
|
|
4
|
+
console.log({setter})
|
|
4
5
|
if(setter)setter();
|
|
5
6
|
if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
|
|
6
7
|
this.cache.callbacks[EVENT].map(n=>n(this));
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const Events = {
|
|
2
|
+
'Click' : [
|
|
3
|
+
'Click',
|
|
4
|
+
'DblClick'
|
|
5
|
+
],
|
|
6
|
+
'Pointer' : [
|
|
7
|
+
'PtrMove',
|
|
8
|
+
'PtrDown',
|
|
9
|
+
'PtrUp',
|
|
10
|
+
'PtrLeave',
|
|
11
|
+
'PtrEnter',
|
|
12
|
+
'PtrOut',
|
|
13
|
+
'PtrCancel'
|
|
14
|
+
],
|
|
15
|
+
'Mouse' : [],
|
|
16
|
+
'Touch' : [],
|
|
17
|
+
'Key' : [
|
|
18
|
+
'KeyDown',
|
|
19
|
+
'KeyPress',
|
|
20
|
+
'KeyUp'
|
|
21
|
+
],
|
|
22
|
+
'Clipboard':[
|
|
23
|
+
'Copy',
|
|
24
|
+
'Cut',
|
|
25
|
+
'Paste'
|
|
26
|
+
],
|
|
27
|
+
'Focus':[
|
|
28
|
+
'focus',
|
|
29
|
+
'blur'
|
|
30
|
+
],
|
|
31
|
+
'Drag':[
|
|
32
|
+
"Drag",
|
|
33
|
+
"DragStart",
|
|
34
|
+
"DragEnd",
|
|
35
|
+
"Drop"
|
|
36
|
+
],
|
|
37
|
+
'Media':[
|
|
38
|
+
|
|
39
|
+
],
|
|
40
|
+
'Hash':[
|
|
41
|
+
"HashChange"
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export {
|
|
46
|
+
Events
|
|
47
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { getEvent } from "./utils.js"
|
|
2
|
+
function event_controller(e, event_name, details_setter, customizer, push_object){
|
|
3
|
+
this.cache.currentEvent = event_name;
|
|
4
|
+
this.cache.event = e;
|
|
5
|
+
details_setter?.call(this);
|
|
6
|
+
if(customizer?.hasOwnProperty("prototype"))customizer?.call(this)
|
|
7
|
+
else customizer?.call(null, this)
|
|
8
|
+
if(this.cache.preventDefault[event_name]) e.preventDefault();
|
|
9
|
+
if(this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
10
|
+
if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
11
|
+
|
|
12
|
+
if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
|
|
13
|
+
this.cache.callbacks[event_name]?.map(n=>n(this));
|
|
14
|
+
}
|
|
15
|
+
class __ZikoEvent__ {
|
|
16
|
+
constructor(target = null, Events = [], details_setter, customizer){
|
|
17
|
+
this.target = target;
|
|
18
|
+
this.cache = {
|
|
19
|
+
currentEvent : null,
|
|
20
|
+
event: null,
|
|
21
|
+
options : {},
|
|
22
|
+
preventDefault : {},
|
|
23
|
+
stopPropagation : {},
|
|
24
|
+
stopImmediatePropagation : {},
|
|
25
|
+
event_flow : {},
|
|
26
|
+
paused : {},
|
|
27
|
+
stream : {
|
|
28
|
+
enabled : {},
|
|
29
|
+
clear : {},
|
|
30
|
+
history : {}
|
|
31
|
+
},
|
|
32
|
+
callbacks : {},
|
|
33
|
+
__controllers__:{}
|
|
34
|
+
}
|
|
35
|
+
const events = Events.map(n=>getEvent(n))
|
|
36
|
+
events.forEach((event,i)=>{
|
|
37
|
+
Object.assign(this.cache.preventDefault, {[event] : false});
|
|
38
|
+
Object.assign(this.cache.options, {[event] : {}});
|
|
39
|
+
Object.assign(this.cache.paused, {[event] : false});
|
|
40
|
+
Object.assign(this.cache.stream.enabled, {[event] : false});
|
|
41
|
+
Object.assign(this.cache.stream.clear, {[event] : false});
|
|
42
|
+
Object.assign(this.cache.stream.history, {[event] : []});
|
|
43
|
+
Object.assign(this.cache.__controllers__, {[event] : e=>event_controller.call(this, e, event, details_setter, customizer)});
|
|
44
|
+
Object.assign(this, { [`on${Events[i]}`] : (...callbacks)=> this.__onEvent(event, this.cache.options[event], {}, ...callbacks)})
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
get targetElement(){
|
|
48
|
+
return this.target?.element;
|
|
49
|
+
}
|
|
50
|
+
get isParent(){
|
|
51
|
+
return this.target?.element === this.event.srcElement;
|
|
52
|
+
}
|
|
53
|
+
get item(){
|
|
54
|
+
return this.target.find(n=>n.element == this.event?.srcElement)?.[0];
|
|
55
|
+
}
|
|
56
|
+
get currentEvent(){
|
|
57
|
+
return this.cache.currentEvent;
|
|
58
|
+
}
|
|
59
|
+
get event(){
|
|
60
|
+
return this.cache.event;
|
|
61
|
+
}
|
|
62
|
+
setTarget(UI){
|
|
63
|
+
this.target=UI;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
__handle(event, handler, options, dispose){
|
|
67
|
+
this.targetElement?.addEventListener(event, handler, options);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
__onEvent(event, options, dispose, ...callbacks){
|
|
71
|
+
if(callbacks.length===0){
|
|
72
|
+
console.log("00")
|
|
73
|
+
if(this.cache.callbacks[event]){
|
|
74
|
+
console.log("Call")
|
|
75
|
+
// this.cache.callbacks.map(n=>e=>n.call(this,e));
|
|
76
|
+
this.cache.callbacks[event].map(n=>e=>n.call(this,e))
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else this.cache.callbacks[event] = callbacks.map(n=>e=>n.call(this,e));
|
|
83
|
+
this.__handle(event, this.cache.__controllers__[event],options, dispose)
|
|
84
|
+
return this;
|
|
85
|
+
}
|
|
86
|
+
#override(methode, overrides, defaultValue){
|
|
87
|
+
if(defaultValue === "default") Object.assign(this.cache[methode], {...this.cache[methode], ...overrides});
|
|
88
|
+
const all = defaultValue === "default"
|
|
89
|
+
? this.cache[methode]
|
|
90
|
+
: Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]))
|
|
91
|
+
Object.assign(this.cache[methode], {...all,...overrides});
|
|
92
|
+
return this
|
|
93
|
+
}
|
|
94
|
+
preventDefault(overrides = {}, defaultValue = "default"){
|
|
95
|
+
this.#override("preventDefault", overrides, defaultValue);
|
|
96
|
+
// const all=Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]))
|
|
97
|
+
// Object.assign(this.cache.preventDefault, {...all,...overrides});
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
stopPropagation(overrides = {}, defaultValue = "default"){
|
|
101
|
+
this.#override("stopPropagation", overrides, defaultValue);
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
stopImmediatePropagation(overrides = {}, defaultValue = "default"){
|
|
105
|
+
this.#override("stopImmediatePropagation", overrides, defaultValue);
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
setEventOptions(event, options){
|
|
109
|
+
this.pause({[event] : true, }, "default");
|
|
110
|
+
Object.assign(this.cache.options[getEvent(event)], options);
|
|
111
|
+
this.resume({[event] : true, }, "default");
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
pause(overrides = {}, defaultValue = "default"){
|
|
115
|
+
const all = defaultValue === "default"
|
|
116
|
+
? this.cache.stream.enabled
|
|
117
|
+
: Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
118
|
+
overrides={...all,...overrides};
|
|
119
|
+
for(let key in overrides){
|
|
120
|
+
if(overrides[key]){
|
|
121
|
+
this.targetElement?.removeEventListener(key, this.cache.__controllers__[key], this.cache.options[key]);
|
|
122
|
+
this.cache.paused[key]=true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return this;
|
|
126
|
+
}
|
|
127
|
+
resume(overrides = {}, defaultValue = "default"){
|
|
128
|
+
const all = defaultValue === "default"
|
|
129
|
+
? this.cache.stream.enabled
|
|
130
|
+
: Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
|
|
131
|
+
overrides={...all,...overrides};
|
|
132
|
+
for(let key in overrides){
|
|
133
|
+
if(overrides[key]){
|
|
134
|
+
this.targetElement?.addEventListener(key,this.cache.__controllers__[key], this.cache.options[key]);
|
|
135
|
+
this.cache.paused[key]=false;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return this;
|
|
139
|
+
}
|
|
140
|
+
stream(overrides = {}, defaultValue = "default"){
|
|
141
|
+
this.cache.stream.t0=Date.now();
|
|
142
|
+
const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]))
|
|
143
|
+
overrides={...all,...overrides}
|
|
144
|
+
Object.assign(this.cache.stream.enabled,overrides);
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
clear(){
|
|
148
|
+
|
|
149
|
+
}
|
|
150
|
+
dispose(overrides = {}, defaultValue = "default"){
|
|
151
|
+
this.pause(overrides, defaultValue);
|
|
152
|
+
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export {
|
|
158
|
+
__ZikoEvent__,
|
|
159
|
+
getEvent
|
|
160
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { __ZikoEvent__ } from "./__ZikoEvent__.js";
|
|
2
|
+
import { Events } from "./__Events__.js";
|
|
3
|
+
class ZikoEventClick extends __ZikoEvent__{
|
|
4
|
+
constructor(target, customizer){
|
|
5
|
+
super(target, Events.Click, details_setter, customizer)
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function details_setter(){
|
|
9
|
+
if(this.currentEvent==="click") this.dx = 0
|
|
10
|
+
else this.dx = 1
|
|
11
|
+
// console.log(this.currentEvent)
|
|
12
|
+
}
|
|
13
|
+
const __useClickEvent = (target, customizer) => new ZikoEventClick(target, customizer)
|
|
14
|
+
|
|
15
|
+
globalThis.expClick = __useClickEvent
|
|
16
|
+
export{
|
|
17
|
+
__useClickEvent,
|
|
18
|
+
ZikoEventClick
|
|
19
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __ZikoEvent__ } from "./__ZikoEvent__.js";
|
|
2
|
+
import { Events } from "./__Events__.js";
|
|
3
|
+
class ZikoEventKey extends __ZikoEvent__{
|
|
4
|
+
constructor(target, customizer){
|
|
5
|
+
super(target, Events.Key, details_setter, customizer)
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function details_setter(){
|
|
9
|
+
switch(this.currentEvent){
|
|
10
|
+
case "keydown" : {
|
|
11
|
+
this.kd = this.event.key
|
|
12
|
+
}; break;
|
|
13
|
+
case "keypress" : {
|
|
14
|
+
this.kp = this.event.key
|
|
15
|
+
}; break;
|
|
16
|
+
case "keyup" : {
|
|
17
|
+
this.ku = this.event.key
|
|
18
|
+
}; break;
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const __useKeyEvent = (target, customizer) => new ZikoEventKey(target, customizer)
|
|
23
|
+
|
|
24
|
+
export{
|
|
25
|
+
__useKeyEvent,
|
|
26
|
+
ZikoEventKey
|
|
27
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { __ZikoEvent__ } from "./__ZikoEvent__.js";
|
|
2
|
+
import { Events } from "./__Events__.js";
|
|
3
|
+
class ZikoEventPointer extends __ZikoEvent__{
|
|
4
|
+
constructor(target, customizer){
|
|
5
|
+
super(target, Events.Pointer, details_setter, customizer);
|
|
6
|
+
this.isDown = false;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function details_setter(){
|
|
10
|
+
switch(this.currentEvent){
|
|
11
|
+
case "pointerdown" : {
|
|
12
|
+
this.dx = parseInt(this.event.offsetX);
|
|
13
|
+
this.dy = parseInt(this.event.offsetY);
|
|
14
|
+
this.isDown = true
|
|
15
|
+
}; break;
|
|
16
|
+
case "pointermove" : {
|
|
17
|
+
this.mx = parseInt(this.event.offsetX);
|
|
18
|
+
this.my = parseInt(this.event.offsetY);
|
|
19
|
+
this.isMove = true
|
|
20
|
+
}; break;
|
|
21
|
+
case "pointerup" : {
|
|
22
|
+
this.ux = parseInt(this.event.offsetX);
|
|
23
|
+
this.uy = parseInt(this.event.offsetY);
|
|
24
|
+
this.isDown = false;
|
|
25
|
+
console.log(this.target.width)
|
|
26
|
+
const delta_x=(this.ux-this.dx)/this.target.width;
|
|
27
|
+
const delta_y=(this.dy-this.uy)/this.target.height;
|
|
28
|
+
const HORIZONTAL_SWIPPE=(delta_x<0)?"left":(delta_x>0)?"right":"none";
|
|
29
|
+
const VERTICAL_SWIPPE=(delta_y<0)?"bottom":(delta_y>0)?"top":"none";
|
|
30
|
+
this.swippe={
|
|
31
|
+
h:HORIZONTAL_SWIPPE,
|
|
32
|
+
v:VERTICAL_SWIPPE,
|
|
33
|
+
delta_x,
|
|
34
|
+
delta_y
|
|
35
|
+
}
|
|
36
|
+
}; break;
|
|
37
|
+
}
|
|
38
|
+
// if(this.currentEvent==="click") this.dx = 0
|
|
39
|
+
// else this.dx = 1
|
|
40
|
+
// console.log(this.currentEvent)
|
|
41
|
+
}
|
|
42
|
+
const __usePointerEvent = (target, customizer) => new ZikoEventPointer(target, customizer)
|
|
43
|
+
|
|
44
|
+
globalThis.expPointer = __usePointerEvent
|
|
45
|
+
export{
|
|
46
|
+
__usePointerEvent,
|
|
47
|
+
ZikoEventPointer
|
|
48
|
+
}
|
package/src/reactivity/index.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import * as Events from "./events";
|
|
2
2
|
import * as Observer from "./observer"
|
|
3
3
|
import * as Hooks from "./hooks"
|
|
4
|
+
import * as EventsExp from "./events-exp"
|
|
4
5
|
const Reactivity={
|
|
5
6
|
...Events,
|
|
6
7
|
...Observer,
|
|
7
8
|
...Hooks,
|
|
9
|
+
...EventsExp,
|
|
8
10
|
}
|
|
9
11
|
export * from "./events";
|
|
10
12
|
export * from "./observer";
|
|
11
13
|
export * from "./hooks";
|
|
14
|
+
export * from "./events-exp";
|
|
12
15
|
export default Reactivity;
|
|
@@ -65,6 +65,7 @@ class ZikoUIElement {
|
|
|
65
65
|
intersection:null
|
|
66
66
|
}
|
|
67
67
|
this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
68
|
+
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index()
|
|
68
69
|
this.cache.style.linkTo(this);
|
|
69
70
|
useDefaultStyle && this.style({
|
|
70
71
|
position: "relative",
|
|
@@ -77,7 +78,7 @@ class ZikoUIElement {
|
|
|
77
78
|
this.items = [];
|
|
78
79
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
79
80
|
element && globalThis.__Ziko__.__Config__.default.render && this.render()
|
|
80
|
-
this.setAttr("data-
|
|
81
|
+
this.setAttr("data-ui-index", this.ui_index);
|
|
81
82
|
if(globalThis.__Ziko__.__Config__.renderingMode !== "spa" && !globalThis.__Ziko__.__Config__.isSSC) {
|
|
82
83
|
globalThis.__Ziko__.__HYDRATION_MAP__.set(this.uuid, ()=>this)
|
|
83
84
|
}
|
|
@@ -161,12 +162,14 @@ class ZikoUIElement {
|
|
|
161
162
|
}
|
|
162
163
|
for (let i = 0; i < ele.length; i++) {
|
|
163
164
|
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
165
|
+
if(ele[i] instanceof Node) ele[i] = new ZikoUIElement(ele[i]);
|
|
164
166
|
if (ele[i]?.isZikoUIElement) {
|
|
165
167
|
ele[i].cache.parent = this;
|
|
166
168
|
this.element[adder](ele[i].element);
|
|
167
169
|
ele[i].target = this.element;
|
|
168
170
|
this.items[pusher](ele[i]);
|
|
169
|
-
}
|
|
171
|
+
}
|
|
172
|
+
else if (ele[i] instanceof Object) {
|
|
170
173
|
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
171
174
|
if (ele[i]?.attr) {
|
|
172
175
|
Object.entries(ele[i].attr).forEach((n) =>
|
|
@@ -7,7 +7,6 @@ class ZikoUIHtmlTag extends ZikoUIElement {
|
|
|
7
7
|
class ZikoUIBtn extends ZikoUIElement {
|
|
8
8
|
constructor(value = "button") {
|
|
9
9
|
super("button","btn");
|
|
10
|
-
this.element = document?.createElement("button");
|
|
11
10
|
this.setValue(value);
|
|
12
11
|
this.st.cursor("pointer");
|
|
13
12
|
globalThis.__Ziko__.__Config__.default.render && this.render();
|