ziko 0.50.1 → 0.50.2

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.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Tue Dec 02 2025 16:28:22 GMT+0100 (UTC+01:00)
5
+ Date : Wed Dec 03 2025 10:48:15 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
@@ -943,16 +943,28 @@ const preload=(url)=>{
943
943
  }
944
944
  };
945
945
 
946
- async function fetchdom(url='https://github.com/zakarialaoui10'){
947
- const data=await fetch(url);
948
- const html=await data.text();
949
- const dom= new DOMParser().parseFromString(html,'text/xml');
950
- return dom.documentElement
946
+ async function fetchdom(url='https://github.com/zakarialaoui10') {
947
+ try {
948
+ const response = await fetch(url);
949
+ if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
950
+ const html = await response.text();
951
+ const dom = new DOMParser().parseFromString(html, 'text/html');
952
+ return dom.documentElement;
953
+ } catch (err) {
954
+ console.error('Failed to fetch DOM:', err);
955
+ throw err;
956
+ }
951
957
  }
952
- function fetchdomSync(url='https://github.com/zakarialaoui10'){
953
- const data=preload(url);
954
- const dom= new DOMParser().parseFromString(data,'text/xml');
955
- return dom.documentElement;
958
+
959
+ function fetchdomSync(url='https://github.com/zakarialaoui10') {
960
+ try {
961
+ const data = preload(url);
962
+ const dom = new DOMParser().parseFromString(data, 'text/html');
963
+ return dom.documentElement;
964
+ } catch (err) {
965
+ console.error('Failed to fetch DOM synchronously:', err);
966
+ throw err;
967
+ }
956
968
  }
957
969
 
958
970
  globalThis.fetchdom=fetchdom;
@@ -1211,6 +1223,67 @@ function _register_to_class_(target, mixin) {
1211
1223
  }
1212
1224
  }
1213
1225
 
1226
+ // export function mount(target = this.target) {
1227
+ // if(this.isBody) return ;
1228
+ // if(target?.isUIElement)target=target.element;
1229
+ // this.target=target;
1230
+ // this.target?.appendChild(this.element);
1231
+ // return this;
1232
+ // }
1233
+ // export function unmount(){
1234
+ // if(this.cache.parent)this.cache.parent.remove(this);
1235
+ // else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
1236
+ // return this;
1237
+ // }
1238
+
1239
+ // export function mountAfter(target = this.target, t = 1) {
1240
+ // setTimeout(() => this.mount(), t);
1241
+ // return this;
1242
+ // }
1243
+ // export function unmountAfter(t = 1) {
1244
+ // setTimeout(() => this.unmount(), t);
1245
+ // return this;
1246
+ // }
1247
+
1248
+ function mount(target = this.target, delay = 0) {
1249
+ if (delay > 0) {
1250
+ setTimeout(() => this.mount(target, 0), delay);
1251
+ return this;
1252
+ }
1253
+
1254
+ if (this.isBody) return this;
1255
+
1256
+ if (target?.isUIElement) target = target.element;
1257
+ this.target = target;
1258
+
1259
+ this.target?.appendChild(this.element);
1260
+ return this;
1261
+ }
1262
+
1263
+ function unmount(delay = 0) {
1264
+ if (delay > 0) {
1265
+ setTimeout(() => this.unmount(0), delay);
1266
+ return this;
1267
+ }
1268
+
1269
+ if (this.cache.parent) {
1270
+ this.cache.parent.remove(this);
1271
+ } else if (
1272
+ this.target?.children?.length &&
1273
+ [...this.target.children].includes(this.element)
1274
+ ) {
1275
+ this.target.removeChild(this.element);
1276
+ }
1277
+
1278
+ return this;
1279
+ }
1280
+
1281
+ var LifecycleMethods = /*#__PURE__*/Object.freeze({
1282
+ __proto__: null,
1283
+ mount: mount,
1284
+ unmount: unmount
1285
+ });
1286
+
1214
1287
  function parseQueryParams$1(queryString) {
1215
1288
  const params = {};
1216
1289
  queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
@@ -1699,18 +1772,6 @@ function clear(){
1699
1772
  this.element.innerHTML = "";
1700
1773
  return this;
1701
1774
  }
1702
- function mount(target = this.target) {
1703
- if(this.isBody)return ;
1704
- if(target?.isUIElement)target=target.element;
1705
- this.target=target;
1706
- this.target?.appendChild(this.element);
1707
- return this;
1708
- }
1709
- function unmount(){
1710
- if(this.cache.parent)this.cache.parent.remove(this);
1711
- else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
1712
- return this;
1713
- }
1714
1775
  function replaceElementWith(new_element){
1715
1776
  this.cache.element.replaceWith(new_element);
1716
1777
  this.cache.element = new_element;
@@ -1718,14 +1779,6 @@ function replaceElementWith(new_element){
1718
1779
  // To do : Dispose Events and States
1719
1780
  return this
1720
1781
  }
1721
- function renderAfter(t = 1) {
1722
- setTimeout(() => this.mount(), t);
1723
- return this;
1724
- }
1725
- function unrenderAfter(t = 1) {
1726
- setTimeout(() => this.unmount(), t);
1727
- return this;
1728
- }
1729
1782
  function after(ui){
1730
1783
  if(ui?.isUIElement) ui=ui.element;
1731
1784
  this.element?.after(ui);
@@ -1744,20 +1797,12 @@ var DomMethods = /*#__PURE__*/Object.freeze({
1744
1797
  before: before,
1745
1798
  clear: clear,
1746
1799
  insertAt: insertAt,
1747
- mount: mount,
1748
1800
  prepend: prepend,
1749
1801
  remove: remove,
1750
- renderAfter: renderAfter,
1751
- replaceElementWith: replaceElementWith,
1752
- unmount: unmount,
1753
- unrenderAfter: unrenderAfter
1802
+ replaceElementWith: replaceElementWith
1754
1803
  });
1755
1804
 
1756
1805
  const EventsMap = {
1757
- 'Custom' : [
1758
- 'emit',
1759
- 'on'
1760
- ],
1761
1806
  'Click' : [
1762
1807
  'Click',
1763
1808
  'DblClick',
@@ -1803,64 +1848,109 @@ const EventsMap = {
1803
1848
  ],
1804
1849
  'Wheel': [
1805
1850
  'Wheel'
1806
- ]
1851
+ ],
1807
1852
  // 'Media':[
1808
1853
 
1809
1854
  // ],
1810
1855
  // 'Hash':[
1811
1856
  // "HashChange"
1812
1857
  // ]
1858
+
1859
+ 'View':[
1860
+ 'EnterView',
1861
+ 'ExitView',
1862
+ 'ResizeView'
1863
+ ],
1864
+ 'Swipe':[
1865
+ 'SwipeLeft',
1866
+ 'SwipeUp',
1867
+ 'SwipeRight',
1868
+ 'SwipeDown'
1869
+ ]
1813
1870
  };
1814
1871
 
1872
+ function event_controller(e, event_name, details_setter, customizer) {
1873
+ this.cache.currentEvent = event_name;
1874
+ this.cache.event = e;
1875
+
1876
+ details_setter?.call(this);
1877
+ if (customizer?.hasOwnProperty('prototype')) customizer?.call(this);
1878
+ else customizer?.call(null, this);
1879
+
1880
+ if (this.cache.preventDefault[event_name]) e.preventDefault();
1881
+ if (this.cache.stopPropagation[event_name]) e.stopPropagation();
1882
+ if (this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
1883
+
1884
+ // Call the single callback if it exists
1885
+ this.cache.callbacks[event_name]?.(this);
1886
+ }
1887
+
1888
+ function toggle_event_listener(method, ...events) {
1889
+ const keys = events.length === 0
1890
+ ? Object.keys(this.cache.paused)
1891
+ : events;
1892
+ keys.forEach(key => {
1893
+ if (!this.cache.paused.hasOwnProperty(key)) return;
1894
+ this.targetElement?.[method](
1895
+ key,
1896
+ this.cache.__controllers__[key],
1897
+ this.cache.options[key]
1898
+ );
1899
+ this.cache.paused[key] = method === 'removeEventListener';
1900
+ });
1901
+ return this;
1902
+ }
1815
1903
  const getEvent=(event = "")=>{
1816
1904
  if(event.startsWith("Ptr"))return `pointer${event.split("Ptr")[1].toLowerCase()}`;
1817
1905
  return event.toLowerCase()
1818
1906
  };
1819
1907
 
1820
1908
  class ZikoEvent {
1821
- constructor(target = null, Events = [], details_setter, customizer){
1909
+ constructor(signature, target = null, Events = [], details_setter, customizer){
1822
1910
  this.target = target;
1823
1911
  this.cache = {
1912
+ signature,
1824
1913
  currentEvent : null,
1825
1914
  event: null,
1826
1915
  options : {},
1827
1916
  preventDefault : {},
1828
1917
  stopPropagation : {},
1829
1918
  stopImmediatePropagation : {},
1830
- event_flow : {},
1831
1919
  paused : {},
1832
- stream : {
1833
- enabled : {},
1834
- clear : {},
1835
- history : {}
1836
- },
1837
1920
  callbacks : {},
1838
1921
  __controllers__:{}
1839
1922
  };
1840
- if(Events)this._register_events(Events, details_setter, customizer);
1841
- }
1842
- _register_events(Events, details_setter, customizer, REGISTER_METHODES = true){
1843
- const events = Events?.map(n=>getEvent(n));
1844
- events?.forEach((event,i)=>{
1845
- Object.assign(this.cache.preventDefault, {[event] : false});
1846
- Object.assign(this.cache.options, {[event] : {}});
1847
- Object.assign(this.cache.paused, {[event] : false});
1848
- Object.assign(this.cache.stream.enabled, {[event] : false});
1849
- Object.assign(this.cache.stream.clear, {[event] : false});
1850
- Object.assign(this.cache.stream.history, {[event] : []});
1851
- Object.assign(this.cache.__controllers__, {[event] : e=>event_controller.call(this, e, event, details_setter, customizer)});
1852
- if(REGISTER_METHODES)Object.assign(this, { [`on${Events[i]}`] : (...callbacks)=> this.__onEvent(event, this.cache.options[event], {}, ...callbacks)});
1923
+ if (Events) this._register_events(Events, details_setter, customizer);
1924
+ }
1925
+ _register_events(Events, details_setter, customizer, REGISTER_METHODES = true) {
1926
+ const events = Events?.map(n => getEvent(n));
1927
+ events?.forEach((event, i) => {
1928
+ this.cache.preventDefault[event] = false;
1929
+ this.cache.options[event] = {};
1930
+ this.cache.paused[event] = false;
1931
+ this.cache.__controllers__[event] = (e) =>
1932
+ event_controller.call(this, e, event, details_setter, customizer);
1933
+ if (REGISTER_METHODES) {
1934
+ this[`on${Events[i]}`] = (callback) =>
1935
+ this.__onEvent(event, this.cache.options[event], {}, callback);
1936
+ }
1853
1937
  });
1854
1938
  return this;
1855
1939
  }
1940
+ __onEvent(event, options, dispose, callback) {
1941
+ if (!callback) return this;
1942
+ this.cache.callbacks[event] = callback;
1943
+ this.__handle(event, this.cache.__controllers__[event], options, dispose);
1944
+ return this;
1945
+ }
1856
1946
  get targetElement(){
1857
1947
  return this.target?.element;
1858
1948
  }
1859
1949
  get isParent(){
1860
- return this.target?.element === this.event.srcElement;
1950
+ return this.target?.element === this.event?.srcElement;
1861
1951
  }
1862
1952
  get item(){
1863
- return this.target.find(n=>n.element == this.event?.srcElement)?.[0];
1953
+ return this.target.find(n => n.element == this.event?.srcElement)?.[0];
1864
1954
  }
1865
1955
  get currentEvent(){
1866
1956
  return this.cache.currentEvent;
@@ -1868,114 +1958,51 @@ class ZikoEvent {
1868
1958
  get event(){
1869
1959
  return this.cache.event;
1870
1960
  }
1961
+ get detail(){
1962
+ return this.cache.event.detail
1963
+ }
1871
1964
  setTarget(UI){
1872
- this.target=UI;
1965
+ this.target = UI;
1873
1966
  return this;
1874
1967
  }
1875
- __handle(event, handler, options, dispose){
1968
+ __handle(event, handler, options){
1876
1969
  this.targetElement?.addEventListener(event, handler, options);
1877
1970
  return this;
1878
1971
  }
1879
- __onEvent(event, options, dispose, ...callbacks){
1880
- if(callbacks.length===0){
1881
- console.log("00");
1882
- if(this.cache.callbacks[event]){
1883
- console.log("Call");
1884
- // this.cache.callbacks.map(n=>e=>n.call(this,e));
1885
- this.cache.callbacks[event].map(n=>e=>n.call(this,e));
1886
- }
1887
- else {
1888
- return this;
1889
- }
1890
- }
1891
- else this.cache.callbacks[event] = callbacks.map(n=>e=>n.call(this,e));
1892
- this.__handle(event, this.cache.__controllers__[event],options, dispose);
1893
- return this;
1894
- }
1895
- #override(methode, overrides, defaultValue){
1896
- if(defaultValue === "default") Object.assign(this.cache[methode], {...this.cache[methode], ...overrides});
1897
- const all = defaultValue === "default"
1898
- ? this.cache[methode]
1899
- : Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]));
1900
- Object.assign(this.cache[methode], {...all,...overrides});
1901
- return this
1902
- }
1903
- preventDefault(overrides = {}, defaultValue = "default"){
1904
- this.#override("preventDefault", overrides, defaultValue);
1905
- // const all=Object.fromEntries(Object.keys(this.cache.preventDefault).map(n=>[n,defaultValue]))
1906
- // Object.assign(this.cache.preventDefault, {...all,...overrides});
1972
+ #override(method, ...events) {
1973
+ const keys = events.length === 0 ? Object.keys(this.cache[method]) : events;
1974
+ keys.forEach(e => {
1975
+ if (this.cache[method].hasOwnProperty(e)) this.cache[method][e] = true;
1976
+ });
1907
1977
  return this;
1908
1978
  }
1909
- stopPropagation(overrides = {}, defaultValue = "default"){
1910
- this.#override("stopPropagation", overrides, defaultValue);
1911
- return this;
1979
+ preventDefault(...events) {
1980
+ return this.#override('preventDefault', ...events);
1912
1981
  }
1913
- stopImmediatePropagation(overrides = {}, defaultValue = "default"){
1914
- this.#override("stopImmediatePropagation", overrides, defaultValue);
1915
- return this;
1982
+ stopPropagation(...events) {
1983
+ return this.#override('stopPropagation', ...events);
1984
+ }
1985
+ stopImmediatePropagation(...events) {
1986
+ return this.#override('stopImmediatePropagation', ...events);
1916
1987
  }
1917
1988
  setEventOptions(event, options){
1918
- this.pause({[event] : true, }, "default");
1919
- Object.assign(this.cache.options[getEvent(event)], options);
1920
- this.resume({[event] : true, }, "default");
1989
+ const evt = getEvent(event);
1990
+ this.pause();
1991
+ Object.assign(this.cache.options[evt], options);
1992
+ this.resume();
1921
1993
  return this;
1922
1994
  }
1923
- pause(overrides = {}, defaultValue = "default"){
1924
- const all = defaultValue === "default"
1925
- ? this.cache.stream.enabled
1926
- : Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
1927
- overrides={...all,...overrides};
1928
- for(let key in overrides){
1929
- if(overrides[key]){
1930
- this.targetElement?.removeEventListener(key, this.cache.__controllers__[key], this.cache.options[key]);
1931
- this.cache.paused[key]=true;
1932
- }
1933
- }
1934
- return this;
1995
+ pause(...events) {
1996
+ return toggle_event_listener.call(this, 'removeEventListener', ...events)
1935
1997
  }
1936
- resume(overrides = {}, defaultValue = "default"){
1937
- const all = defaultValue === "default"
1938
- ? this.cache.stream.enabled
1939
- : Object.entries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
1940
- overrides={...all,...overrides};
1941
- for(let key in overrides){
1942
- if(overrides[key]){
1943
- this.targetElement?.addEventListener(key,this.cache.__controllers__[key], this.cache.options[key]);
1944
- this.cache.paused[key]=false;
1945
- }
1946
- }
1947
- return this;
1948
- }
1949
- stream(overrides = {}, defaultValue = "default"){
1950
- this.cache.stream.t0=Date.now();
1951
- const all=Object.fromEntries(Object.keys(this.cache.stream.enabled).map(n=>[n,defaultValue]));
1952
- overrides={...all,...overrides};
1953
- Object.assign(this.cache.stream.enabled,overrides);
1954
- return this;
1955
- }
1956
- clear(){
1957
- return this;
1998
+ resume(...events) {
1999
+ return toggle_event_listener.call(this, 'addEventListener', ...events);
1958
2000
  }
1959
- dispose(overrides = {}, defaultValue = "default"){
1960
- this.pause(overrides, defaultValue);
1961
-
2001
+ dispose(){
2002
+ this.pause();
2003
+ this.target.events[this.cache.signature] = null;
1962
2004
  return this;
1963
2005
  }
1964
- }
1965
-
1966
- function event_controller(e, event_name, details_setter, customizer, push_object){
1967
- this.cache.currentEvent = event_name;
1968
- this.cache.event = e;
1969
- details_setter?.call(this);
1970
- customizer?.hasOwnProperty("prototype") ? customizer?.call(this) : customizer?.call(null, this);
1971
- // if(customizer?.hasOwnProperty("prototype")) customizer?.call(this)
1972
- // else customizer?.call(null, this)
1973
- if(this.cache.preventDefault[event_name]) e.preventDefault();
1974
- if(this.cache.stopPropagation[event_name]) e.stopPropagation();
1975
- if(this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
1976
-
1977
- if(this.cache.stream.enabled[event_name]&&push_object)this.cache.stream.history[event_name].push(push_object);
1978
- this.cache.callbacks[event_name]?.map(n=>n(this));
1979
2006
  }
1980
2007
 
1981
2008
  function key_details_setter(){
@@ -2062,9 +2089,165 @@ function register_click_away_event(element) {
2062
2089
  // // later, you can stop listening:
2063
2090
  // // stop();
2064
2091
 
2092
+ const debounce=(fn,delay=1000)=>{
2093
+ let id;
2094
+ return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
2095
+ };
2096
+ const throttle=(fn,delay)=>{
2097
+ let lastTime=0;
2098
+ return (...args) => {
2099
+ const now = new Date().getTime();
2100
+ if(now-lastTime < delay) return;
2101
+ lastTime = now;
2102
+ fn(...args);
2103
+ }
2104
+ };
2105
+
2106
+ class ViewEvent extends CustomEvent {
2107
+ constructor(type, detail, { bubbles = true, cancelable = true } = {}) {
2108
+ super(type, { detail, bubbles, cancelable });
2109
+ }
2110
+ }
2111
+
2112
+ function register_view_event(
2113
+ element,
2114
+ {
2115
+ intersection = true,
2116
+ resize = true,
2117
+ threshold = 0,
2118
+ throttleResize = 100,
2119
+ throttleEnterExit = 0
2120
+ } = {}
2121
+ ) {
2122
+ let intersectionObserver, resizeObserver;
2123
+ const resizeCallback = entries => {
2124
+ for (let entry of entries) {
2125
+ const { width, height } = entry.contentRect;
2126
+
2127
+ element.dispatchEvent(
2128
+ new ViewEvent("resizeview", {
2129
+ width,
2130
+ height,
2131
+ entry
2132
+ })
2133
+ );
2134
+ }
2135
+ };
2136
+
2137
+ const throttledResize = throttleResize > 0
2138
+ ? throttle(resizeCallback, throttleResize)
2139
+ : resizeCallback;
2140
+
2141
+ const intersectionCallback = entries => {
2142
+ for (let entry of entries) {
2143
+ const type = entry.isIntersecting ? "enterview" : "exitview";
2144
+ element.dispatchEvent(new ViewEvent(type, entry));
2145
+ }
2146
+ };
2147
+
2148
+ const throttledIntersections = throttleEnterExit > 0
2149
+ ? throttle(intersectionCallback, throttleEnterExit)
2150
+ : intersectionCallback;
2151
+
2152
+ if (intersection) {
2153
+ intersectionObserver = new IntersectionObserver(throttledIntersections, { threshold });
2154
+ intersectionObserver.observe(element);
2155
+ }
2156
+
2157
+ if (resize) {
2158
+ resizeObserver = new ResizeObserver(throttledResize);
2159
+ resizeObserver.observe(element);
2160
+ }
2161
+
2162
+ // ---- UNREGISTER ----
2163
+ return () => {
2164
+ if (intersectionObserver) {
2165
+ intersectionObserver.unobserve(element);
2166
+ intersectionObserver.disconnect();
2167
+ }
2168
+ if (resizeObserver) {
2169
+ resizeObserver.unobserve(element);
2170
+ resizeObserver.disconnect();
2171
+ }
2172
+ };
2173
+ }
2174
+
2175
+ class SwipeEvent extends CustomEvent {
2176
+ constructor(type, detail) {
2177
+ super(type, {
2178
+ detail,
2179
+ bubbles: true,
2180
+ cancelable: true
2181
+ });
2182
+ }
2183
+ }
2184
+
2185
+ function register_swipe_event(
2186
+ element,
2187
+ threshold = 50,
2188
+ restraint = 100,
2189
+ allowedTime = 500
2190
+ ) {
2191
+ let startX = 0,
2192
+ startY = 0,
2193
+ startTime = 0,
2194
+ isPointerDown = false;
2195
+
2196
+ function onPointerDown(e) {
2197
+ startX = e.clientX;
2198
+ startY = e.clientY;
2199
+ startTime = performance.now();
2200
+ isPointerDown = true;
2201
+ }
2202
+
2203
+ function onPointerUp(e) {
2204
+ if (!isPointerDown) return;
2205
+ isPointerDown = false;
2206
+
2207
+ const distX = e.clientX - startX;
2208
+ const distY = e.clientY - startY;
2209
+ const elapsed = performance.now() - startTime;
2210
+
2211
+ let direction = null;
2212
+ let eventName = null;
2213
+
2214
+ if (elapsed <= allowedTime) {
2215
+ if (Math.abs(distX) >= threshold && Math.abs(distY) <= restraint) {
2216
+ direction = distX < 0 ? "left" : "right";
2217
+ eventName = "swipe" + direction;
2218
+ }
2219
+ else if (Math.abs(distY) >= threshold && Math.abs(distX) <= restraint) {
2220
+ direction = distY < 0 ? "up" : "down";
2221
+ eventName = "swipe" + direction;
2222
+ }
2223
+ }
2224
+
2225
+ // Emit event
2226
+ if (eventName) {
2227
+ element.dispatchEvent(
2228
+ new SwipeEvent(eventName, {
2229
+ direction,
2230
+ distX,
2231
+ distY,
2232
+ originalEvent: e
2233
+ })
2234
+ );
2235
+ }
2236
+ }
2237
+
2238
+ element.addEventListener("pointerdown", onPointerDown, { passive: true });
2239
+ element.addEventListener("pointerup", onPointerUp, { passive: true });
2240
+
2241
+ return () => {
2242
+ element.removeEventListener("pointerdown", onPointerDown);
2243
+ element.removeEventListener("pointerup", onPointerUp);
2244
+ };
2245
+ }
2246
+
2065
2247
  const bind_click_event = (target, customizer) => {
2066
2248
  register_click_away_event(target.element);
2067
2249
  return new ZikoEvent(
2250
+ 'click',
2068
2251
  target,
2069
2252
  EventsMap.Click,
2070
2253
  null,
@@ -2072,64 +2255,87 @@ const bind_click_event = (target, customizer) => {
2072
2255
  );
2073
2256
  };
2074
2257
  const bind_clipboard_event = (target, customizer) => new ZikoEvent(
2258
+ 'clipboard',
2075
2259
  target,
2076
2260
  EventsMap.Clipboard,
2077
2261
  null,
2078
2262
  customizer
2079
2263
  );
2080
2264
  const bind_drag_event = (target, customizer) => new ZikoEvent(
2265
+ 'drag',
2081
2266
  target,
2082
2267
  EventsMap.Drag,
2083
2268
  null,
2084
2269
  customizer
2085
2270
  );
2086
2271
  const bind_focus_event = (target, customizer) => new ZikoEvent(
2272
+ 'focus',
2087
2273
  target,
2088
2274
  EventsMap.Focus,
2089
2275
  null,
2090
2276
  customizer
2091
2277
  );
2092
2278
  const bind_key_event = (target, customizer) => new ZikoEvent(
2279
+ 'key',
2093
2280
  target,
2094
2281
  EventsMap.Key,
2095
2282
  key_details_setter,
2096
2283
  customizer
2097
2284
  );
2098
2285
  const bind_mouse_event = (target, customizer) => new ZikoEvent(
2286
+ 'mouse',
2099
2287
  target,
2100
2288
  EventsMap.Mouse,
2101
2289
  null,
2102
2290
  customizer
2103
2291
  );
2104
2292
  const bind_pointer_event = (target, customizer) => new ZikoEvent(
2293
+ 'ptr',
2105
2294
  target,
2106
2295
  EventsMap.Ptr,
2107
2296
  ptr_details_setter,
2108
2297
  customizer
2109
2298
  );
2110
2299
  const bind_touch_event = (target, customizer) => new ZikoEvent(
2300
+ 'touch',
2111
2301
  target,
2112
2302
  EventsMap.Touch,
2113
2303
  null,
2114
2304
  customizer
2115
2305
  );
2116
2306
  const bind_wheel_event = (target, customizer) => new ZikoEvent(
2307
+ 'wheel',
2117
2308
  target,
2118
2309
  EventsMap.Wheel,
2119
2310
  null,
2120
2311
  customizer
2121
2312
  );
2122
2313
 
2314
+ const bind_view_event = (target, customizer) => {
2315
+ register_view_event(target.element);
2316
+ return new ZikoEvent(
2317
+ 'view',
2318
+ target,
2319
+ EventsMap.View,
2320
+ null,
2321
+ customizer
2322
+ )
2323
+ };
2123
2324
 
2124
- // function details_setter(){
2125
- // if(this.currentEvent==="click") this.dx = 0
2126
- // else this.dx = 1
2127
- // // console.log(this.currentEvent)
2128
- // }
2325
+ const bind_swipe_event = (target, customizer) => {
2326
+ register_swipe_event(target.element);
2327
+ return new ZikoEvent(
2328
+ 'swipe',
2329
+ target,
2330
+ EventsMap.Swipe,
2331
+ null,
2332
+ customizer
2333
+ )
2334
+ };
2129
2335
 
2130
2336
  class ZikoCustomEvent extends ZikoEvent{
2131
2337
  constructor(target, events, customizer){
2132
- super(target, events, details_setter, customizer);
2338
+ super('custom', target, events, details_setter, customizer);
2133
2339
  }
2134
2340
  _register_events(events){
2135
2341
  super._register_events(events, null, null, false);
@@ -2163,7 +2369,9 @@ const binderMap = {
2163
2369
  drag : bind_drag_event,
2164
2370
  clipboard : bind_clipboard_event,
2165
2371
  focus : bind_focus_event,
2166
- wheel : bind_wheel_event
2372
+ wheel : bind_wheel_event,
2373
+ view : bind_view_event,
2374
+ swipe : bind_swipe_event
2167
2375
  };
2168
2376
 
2169
2377
  const EventsMethodes = {
@@ -2183,9 +2391,9 @@ Object.entries(EventsMap).forEach(([name, eventList]) => {
2183
2391
  const lname = name.toLowerCase();
2184
2392
  eventList.forEach(event => {
2185
2393
  const methodName = `on${event}`;
2186
- EventsMethodes[methodName] = function (...callbacks) {
2394
+ EventsMethodes[methodName] = function (callbacks) {
2187
2395
  if (!this.events[lname]) this.events[lname] = binderMap[lname](this);
2188
- this.events[lname][methodName](...callbacks);
2396
+ this.events[lname][methodName](callbacks);
2189
2397
  return this;
2190
2398
  };
2191
2399
  });
@@ -2262,6 +2470,7 @@ let UIElement$1 = class UIElement extends UIElementCore{
2262
2470
  // console.log(this)
2263
2471
  register_to_class(
2264
2472
  this,
2473
+ LifecycleMethods,
2265
2474
  AttrsMethods,
2266
2475
  DomMethods,
2267
2476
  StyleMethods,
@@ -2391,32 +2600,12 @@ let UIElement$1 = class UIElement extends UIElementCore{
2391
2600
  // get id() {
2392
2601
  // return this.element.getAttribute("id");
2393
2602
  // }
2394
- // onSwipe(width_threshold, height_threshold,...callbacks){
2395
- // if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
2396
- // this.events.swipe.onSwipe(...callbacks);
2397
- // return this;
2398
- // }
2399
2603
  // To Fix
2400
2604
  // onKeysDown({keys=[],callback}={}){
2401
2605
  // if(!this.events.key)this.events.key = useKeyEvent(this);
2402
2606
  // this.events.key.handleSuccessifKeys({keys,callback});
2403
2607
  // return this;
2404
2608
  // }
2405
- // onSelect(...callbacks){
2406
- // if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
2407
- // this.events.clipboard.onSelect(...callbacks);
2408
- // return this;
2409
- // }
2410
- // on(event_name,...callbacks){
2411
- // if(!this.events.custom)this.events.custom = useCustomEvent(this);
2412
- // this.events.custom.on(event_name,...callbacks);
2413
- // return this;
2414
- // }
2415
- // emit(event_name,detail={}){
2416
- // if(!this.events.custom)this.events.custom = useCustomEvent(this);
2417
- // this.events.custom.emit(event_name,detail);
2418
- // return this;
2419
- // }
2420
2609
  // watchAttr(callback){
2421
2610
  // if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
2422
2611
  // return this;
@@ -2425,16 +2614,8 @@ let UIElement$1 = class UIElement extends UIElementCore{
2425
2614
  // if(!this.observer.children)this.observer.children = watchChildren(this,callback);
2426
2615
  // return this;
2427
2616
  // }
2428
- // watchSize(callback){
2429
- // if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
2430
- // this.observer.resize.start();
2431
- // return this;
2432
- // }
2433
- // watchIntersection(callback,config){
2434
- // if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
2435
- // this.observer.intersection.start();
2436
- // return this;
2437
- // }
2617
+ // watchSize(callback)Remplaced By on onViewResize
2618
+ // watchIntersection(callback,config) Remplaced By onViewEnter and onViewExit
2438
2619
 
2439
2620
  };
2440
2621
 
@@ -2733,7 +2914,6 @@ class ZikoUISuspense extends UIElement{
2733
2914
  const ui = await callback();
2734
2915
  fallback_ui.unmount();
2735
2916
  this.append(ui);
2736
- // console.log(content)
2737
2917
  }
2738
2918
  catch(error){
2739
2919
  console.log({error});
@@ -4364,20 +4544,6 @@ const Scheduler = (tasks, { repeat = null} = {}) => new TimeScheduler(tasks, { r
4364
4544
 
4365
4545
  const step_fps = (step_or_fps) => 1000 / step_or_fps;
4366
4546
 
4367
- const debounce=(fn,delay=1000)=>{
4368
- let id;
4369
- return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
4370
- };
4371
- const throttle=(fn,delay)=>{
4372
- let lastTime=0;
4373
- return (...args) => {
4374
- const now = new Date().getTime();
4375
- if(now-lastTime < delay) return;
4376
- lastTime = now;
4377
- fn(...args);
4378
- }
4379
- };
4380
-
4381
4547
  const sleep= ms => new Promise(res => setTimeout(res, ms));
4382
4548
  function timeout(ms, fn) {
4383
4549
  let id;
@@ -5152,4 +5318,4 @@ if(globalThis?.document){
5152
5318
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5153
5319
  }
5154
5320
 
5155
- export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_touch_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, e, elastic, fact, floor, geomspace, getEvent, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, zeros };
5321
+ export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_swipe_event, bind_touch_event, bind_view_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, e, elastic, event_controller, fact, floor, geomspace, getEvent, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, toggle_event_listener, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, zeros };