ziko 0.0.27 → 0.0.29

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 CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Thu Feb 13 2025 17:40:20 GMT+0100 (UTC+01:00)
5
+ Date : Fri Jul 25 2025 11:35:58 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
@@ -1011,6 +1011,11 @@ class Random {
1011
1011
  }
1012
1012
  }
1013
1013
 
1014
+ var __Random__ = /*#__PURE__*/Object.freeze({
1015
+ __proto__: null,
1016
+ Random: Random
1017
+ });
1018
+
1014
1019
  const luDecomposition=matrix=>{
1015
1020
  if(matrix instanceof Matrix)matrix=matrix.arr;
1016
1021
  const n = matrix.length;
@@ -1806,6 +1811,7 @@ class ZikoUIElementStyle{
1806
1811
  function EVENT_CONTROLLER(e,EVENT,setter,push_object){
1807
1812
  this.event=e;
1808
1813
  if(this.cache.preventDefault[EVENT])e.preventDefault();
1814
+ console.log({setter});
1809
1815
  if(setter)setter();
1810
1816
  if(this.cache.stream.enabled[EVENT]&&push_object)this.cache.stream.history[EVENT].push(push_object);
1811
1817
  this.cache.callbacks[EVENT].map(n=>n(this));
@@ -4606,10 +4612,181 @@ var Hooks = /*#__PURE__*/Object.freeze({
4606
4612
  useType: useType
4607
4613
  });
4608
4614
 
4615
+ const getEvent=(event = "")=>{
4616
+ if(event.startsWith("Ptr"))return `pointer${event.split("Ptr")[1].toLowerCase()}`;
4617
+ return event.toLowerCase()
4618
+ };
4619
+
4620
+ function event_controller(e, event_name, details_setter, customizer, push_object){
4621
+ this.cache.currentEvent = event_name;
4622
+ this.cache.event = e;
4623
+ details_setter?.call(this);
4624
+ if(customizer?.hasOwnProperty("prototype"))customizer?.call(this);
4625
+ else customizer?.call(null, this);
4626
+ if(this.cache.preventDefault[event_name]) e.preventDefault();
4627
+ if(this.cache.stopPropagation[event_name]) e.stopPropagation();
4628
+ if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
4629
+
4630
+ if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
4631
+ this.cache.callbacks[event_name]?.map(n=>n(this));
4632
+ }
4633
+ class __ZikoEvent__ {
4634
+ constructor(target = null, Events = [], details_setter, customizer){
4635
+ this.target = target;
4636
+ this.cache = {
4637
+ currentEvent : null,
4638
+ event: null,
4639
+ options : {},
4640
+ preventDefault : {},
4641
+ stopPropagation : {},
4642
+ stopImmediatePropagation : {},
4643
+ event_flow : {},
4644
+ paused : {},
4645
+ stream : {
4646
+ enabled : {},
4647
+ clear : {},
4648
+ history : {}
4649
+ },
4650
+ callbacks : {},
4651
+ __controllers__:{}
4652
+ };
4653
+ const events = Events.map(n=>getEvent(n));
4654
+ events.forEach((event,i)=>{
4655
+ Object.assign(this.cache.preventDefault, {[event] : false});
4656
+ Object.assign(this.cache.options, {[event] : {}});
4657
+ Object.assign(this.cache.paused, {[event] : false});
4658
+ Object.assign(this.cache.stream.enabled, {[event] : false});
4659
+ Object.assign(this.cache.stream.clear, {[event] : false});
4660
+ Object.assign(this.cache.stream.history, {[event] : []});
4661
+ Object.assign(this.cache.__controllers__, {[event] : e=>event_controller.call(this, e, event, details_setter, customizer)});
4662
+ Object.assign(this, { [`on${Events[i]}`] : (...callbacks)=> this.__onEvent(event, this.cache.options[event], {}, ...callbacks)});
4663
+ });
4664
+ }
4665
+ get targetElement(){
4666
+ return this.target?.element;
4667
+ }
4668
+ get isParent(){
4669
+ return this.target?.element === this.event.srcElement;
4670
+ }
4671
+ get item(){
4672
+ return this.target.find(n=>n.element == this.event?.srcElement)?.[0];
4673
+ }
4674
+ get currentEvent(){
4675
+ return this.cache.currentEvent;
4676
+ }
4677
+ get event(){
4678
+ return this.cache.event;
4679
+ }
4680
+ setTarget(UI){
4681
+ this.target=UI;
4682
+ return this;
4683
+ }
4684
+ __handle(event, handler, options, dispose){
4685
+ this.targetElement?.addEventListener(event, handler, options);
4686
+ return this;
4687
+ }
4688
+ __onEvent(event, options, dispose, ...callbacks){
4689
+ if(callbacks.length===0){
4690
+ console.log("00");
4691
+ if(this.cache.callbacks[event]){
4692
+ console.log("Call");
4693
+ // this.cache.callbacks.map(n=>e=>n.call(this,e));
4694
+ this.cache.callbacks[event].map(n=>e=>n.call(this,e));
4695
+ }
4696
+ else {
4697
+ return this;
4698
+ }
4699
+ }
4700
+ else this.cache.callbacks[event] = callbacks.map(n=>e=>n.call(this,e));
4701
+ this.__handle(event, this.cache.__controllers__[event],options, dispose);
4702
+ return this;
4703
+ }
4704
+ #override(methode, overrides, defaultValue){
4705
+ if(defaultValue === "default") Object.assign(this.cache[methode], {...this.cache[methode], ...overrides});
4706
+ const all = defaultValue === "default"
4707
+ ? this.cache[methode]
4708
+ : Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]));
4709
+ Object.assign(this.cache[methode], {...all,...overrides});
4710
+ return this
4711
+ }
4712
+ preventDefault(overrides = {}, defaultValue = "default"){
4713
+ this.#override("preventDefault", overrides, defaultValue);
4714
+ // const all=Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]))
4715
+ // Object.assign(this.cache.preventDefault, {...all,...overrides});
4716
+ return this;
4717
+ }
4718
+ stopPropagation(overrides = {}, defaultValue = "default"){
4719
+ this.#override("stopPropagation", overrides, defaultValue);
4720
+ return this;
4721
+ }
4722
+ stopImmediatePropagation(overrides = {}, defaultValue = "default"){
4723
+ this.#override("stopImmediatePropagation", overrides, defaultValue);
4724
+ return this;
4725
+ }
4726
+ setEventOptions(event, options){
4727
+ this.pause({[event] : true, }, "default");
4728
+ Object.assign(this.cache.options[getEvent(event)], options);
4729
+ this.resume({[event] : true, }, "default");
4730
+ return this;
4731
+ }
4732
+ pause(overrides = {}, defaultValue = "default"){
4733
+ const all = defaultValue === "default"
4734
+ ? this.cache.stream.enabled
4735
+ : Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
4736
+ overrides={...all,...overrides};
4737
+ for(let key in overrides){
4738
+ if(overrides[key]){
4739
+ this.targetElement?.removeEventListener(key, this.cache.__controllers__[key], this.cache.options[key]);
4740
+ this.cache.paused[key]=true;
4741
+ }
4742
+ }
4743
+ return this;
4744
+ }
4745
+ resume(overrides = {}, defaultValue = "default"){
4746
+ const all = defaultValue === "default"
4747
+ ? this.cache.stream.enabled
4748
+ : Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
4749
+ overrides={...all,...overrides};
4750
+ for(let key in overrides){
4751
+ if(overrides[key]){
4752
+ this.targetElement?.addEventListener(key,this.cache.__controllers__[key], this.cache.options[key]);
4753
+ this.cache.paused[key]=false;
4754
+ }
4755
+ }
4756
+ return this;
4757
+ }
4758
+ stream(overrides = {}, defaultValue = "default"){
4759
+ this.cache.stream.t0=Date.now();
4760
+ const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
4761
+ overrides={...all,...overrides};
4762
+ Object.assign(this.cache.stream.enabled,overrides);
4763
+ return this;
4764
+ }
4765
+ clear(){
4766
+
4767
+ }
4768
+ dispose(overrides = {}, defaultValue = "default"){
4769
+ this.pause(overrides, defaultValue);
4770
+
4771
+ return this;
4772
+ }
4773
+ }
4774
+
4775
+ // export * from "./click.js";
4776
+ // export * from "./key.js";
4777
+ // export * from "./pointer.js"
4778
+
4779
+ var EventsExp = /*#__PURE__*/Object.freeze({
4780
+ __proto__: null,
4781
+ __ZikoEvent__: __ZikoEvent__,
4782
+ getEvent: getEvent
4783
+ });
4784
+
4609
4785
  const Reactivity={
4610
4786
  ...Events,
4611
4787
  ...Observer,
4612
4788
  ...Hooks,
4789
+ ...EventsExp,
4613
4790
  };
4614
4791
 
4615
4792
  class ZikoUIElement {
@@ -4657,6 +4834,7 @@ class ZikoUIElement {
4657
4834
  intersection:null
4658
4835
  };
4659
4836
  this.uuid = `${this.cache.name}-${Random.string(16)}`;
4837
+ this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
4660
4838
  this.cache.style.linkTo(this);
4661
4839
  useDefaultStyle && this.style({
4662
4840
  position: "relative",
@@ -4669,7 +4847,7 @@ class ZikoUIElement {
4669
4847
  this.items = [];
4670
4848
  globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
4671
4849
  element && globalThis.__Ziko__.__Config__.default.render && this.render();
4672
- this.setAttr("data-ref", this.uuid);
4850
+ this.setAttr("data-ui-index", this.ui_index);
4673
4851
  if(globalThis.__Ziko__.__Config__.renderingMode !== "spa" && !globalThis.__Ziko__.__Config__.isSSC) {
4674
4852
  globalThis.__Ziko__.__HYDRATION_MAP__.set(this.uuid, ()=>this);
4675
4853
  }
@@ -4753,12 +4931,14 @@ class ZikoUIElement {
4753
4931
  }
4754
4932
  for (let i = 0; i < ele.length; i++) {
4755
4933
  if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
4934
+ if(ele[i] instanceof Node) ele[i] = new ZikoUIElement(ele[i]);
4756
4935
  if (ele[i]?.isZikoUIElement) {
4757
4936
  ele[i].cache.parent = this;
4758
4937
  this.element[adder](ele[i].element);
4759
4938
  ele[i].target = this.element;
4760
4939
  this.items[pusher](ele[i]);
4761
- } else if (ele[i] instanceof Object) {
4940
+ }
4941
+ else if (ele[i] instanceof Object) {
4762
4942
  if (ele[i]?.style) this.style(ele[i]?.style);
4763
4943
  if (ele[i]?.attr) {
4764
4944
  Object.entries(ele[i].attr).forEach((n) =>
@@ -5237,9 +5417,9 @@ class __ZikoUIText__ extends ZikoUIElement {
5237
5417
 
5238
5418
  if(this.cache.lineBreak)this.element?.appendChild(globalThis.document?.createElement("br"));
5239
5419
  });
5240
- if(this.element?.innerHTML){
5241
- this.element.innerHTML = this.element.innerHTML.replace(/\n/g, '<br>').replace(/(?<!<[^>]+) /g, '&nbsp;');
5242
- }
5420
+ // if(this.element?.innerHTML){
5421
+ // this.element.innerHTML = this.element.innerHTML.replace(/\n/g, '<br>').replace(/(?<!<[^>]+) /g, '&nbsp;');
5422
+ // }
5243
5423
  return this
5244
5424
  }
5245
5425
  setValue(...value) {
@@ -5844,15 +6024,19 @@ class ZikoUIXMLWrapper extends ZikoUIElement{
5844
6024
  }
5845
6025
  }
5846
6026
  function html2dom(htmlString) {
5847
- const parser = new DOMParser();
5848
- const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
5849
- doc.body.firstChild.style.display = "contents";
5850
- return doc.body.firstChild;
6027
+ if(globalThis?.DOMParser){
6028
+ const parser = new DOMParser();
6029
+ const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
6030
+ doc.body.firstChild.style.display = "contents";
6031
+ return doc.body.firstChild;
6032
+ }
5851
6033
  }
5852
6034
  function svg2dom(svgString) {
5853
- const parser = new DOMParser();
5854
- const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
5855
- return doc.documentElement; // SVG elements are usually at the root
6035
+ if(globalThis?.DOMParser){
6036
+ const parser = new DOMParser();
6037
+ const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
6038
+ return doc.documentElement; // SVG elements are usually at the root
6039
+ }
5856
6040
  }
5857
6041
  class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
5858
6042
  constructor(HTMLContent){
@@ -6055,7 +6239,6 @@ class ZikoUIHtmlTag extends ZikoUIElement {
6055
6239
  class ZikoUIBtn extends ZikoUIElement {
6056
6240
  constructor(value = "button") {
6057
6241
  super("button","btn");
6058
- this.element = document?.createElement("button");
6059
6242
  this.setValue(value);
6060
6243
  this.st.cursor("pointer");
6061
6244
  globalThis.__Ziko__.__Config__.default.render && this.render();
@@ -8464,6 +8647,7 @@ const Math$1 = {
8464
8647
  ...__Functions__,
8465
8648
  ...__Complex__,
8466
8649
  ...__Matrix__,
8650
+ ...__Random__,
8467
8651
  ...__Utils__,
8468
8652
  ...__Discrect__,
8469
8653
  // ...__Signal__,
@@ -9099,7 +9283,28 @@ function defineParamsGetter(target ){
9099
9283
  });
9100
9284
  }
9101
9285
 
9102
- const __UI__={};
9286
+ const __UI__={
9287
+ __all__(){
9288
+ return Object.values(this)
9289
+ .filter(Array.isArray)
9290
+ .flat();
9291
+ },
9292
+ querySelectorAll(){
9293
+ return this.__all__().filter(n=>n)
9294
+ },
9295
+ getElementByIndex(index){
9296
+ return this.__all__().find(n=>n.ui_index===index);
9297
+ },
9298
+ getElementById(id){
9299
+ return null;
9300
+ },
9301
+ getElementsByClass(){
9302
+
9303
+ },
9304
+ getElementsByTagName(){
9305
+
9306
+ }
9307
+ };
9103
9308
  const __HYDRATION_MAP__ = new Map();
9104
9309
  const __Config__={
9105
9310
  default:{
@@ -9117,10 +9322,17 @@ const __Config__={
9117
9322
  init:()=>document.documentElement.setAttribute("data-engine","zikojs"),
9118
9323
  renderingMode :"spa",
9119
9324
  isSSC : false,
9325
+ };
9326
+ const __CACHE__ = {
9327
+ ui_index : 0,
9328
+ get_ui_index:function(){
9329
+ return this.ui_index ++
9330
+ }
9120
9331
  };
9121
9332
 
9122
9333
  var Global = /*#__PURE__*/Object.freeze({
9123
9334
  __proto__: null,
9335
+ __CACHE__: __CACHE__,
9124
9336
  __Config__: __Config__,
9125
9337
  __HYDRATION_MAP__: __HYDRATION_MAP__,
9126
9338
  __UI__: __UI__
@@ -9224,6 +9436,7 @@ if ( globalThis.__Ziko__ ) {
9224
9436
  __UI__,
9225
9437
  __HYDRATION_MAP__,
9226
9438
  __Config__,
9439
+ __CACHE__,
9227
9440
  ExtractAll,
9228
9441
  RemoveAll
9229
9442
  };
@@ -9361,9 +9574,11 @@ exports.ZikoUIVideo = ZikoUIVideo;
9361
9574
  exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
9362
9575
  exports.ZikoUseRoot = ZikoUseRoot;
9363
9576
  exports.ZikoUseStyle = ZikoUseStyle;
9577
+ exports.__CACHE__ = __CACHE__;
9364
9578
  exports.__Config__ = __Config__;
9365
9579
  exports.__HYDRATION_MAP__ = __HYDRATION_MAP__;
9366
9580
  exports.__UI__ = __UI__;
9581
+ exports.__ZikoEvent__ = __ZikoEvent__;
9367
9582
  exports.abbrText = abbrText;
9368
9583
  exports.abs = abs;
9369
9584
  exports.accum = accum;
@@ -9417,6 +9632,7 @@ exports.figure = figure;
9417
9632
  exports.floor = floor;
9418
9633
  exports.gamma = gamma;
9419
9634
  exports.geomspace = geomspace;
9635
+ exports.getEvent = getEvent;
9420
9636
  exports.h = h;
9421
9637
  exports.h1 = h1;
9422
9638
  exports.h2 = h2;
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Thu Jul 10 2025 11:49:56 GMT+0100 (UTC+01:00)
5
+ Date : Fri Jul 25 2025 11:35:58 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
@@ -6026,15 +6026,19 @@
6026
6026
  }
6027
6027
  }
6028
6028
  function html2dom(htmlString) {
6029
- const parser = new DOMParser();
6030
- const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
6031
- doc.body.firstChild.style.display = "contents";
6032
- return doc.body.firstChild;
6029
+ if(globalThis?.DOMParser){
6030
+ const parser = new DOMParser();
6031
+ const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
6032
+ doc.body.firstChild.style.display = "contents";
6033
+ return doc.body.firstChild;
6034
+ }
6033
6035
  }
6034
6036
  function svg2dom(svgString) {
6035
- const parser = new DOMParser();
6036
- const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
6037
- return doc.documentElement; // SVG elements are usually at the root
6037
+ if(globalThis?.DOMParser){
6038
+ const parser = new DOMParser();
6039
+ const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
6040
+ return doc.documentElement; // SVG elements are usually at the root
6041
+ }
6038
6042
  }
6039
6043
  class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
6040
6044
  constructor(HTMLContent){