ziko 0.45.2 → 0.45.4

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 : Mon Sep 01 2025 13:22:11 GMT+0100 (UTC+01:00)
5
+ Date : Thu Sep 04 2025 20:47:52 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
@@ -1207,11 +1207,11 @@ class UIElementCore extends UINode{
1207
1207
  switch(type){
1208
1208
  case "html" : {
1209
1209
  element = globalThis?.document?.createElement(element);
1210
- console.log('1');
1210
+ // console.log('1')
1211
1211
  } break;
1212
1212
  case "svg" : {
1213
1213
  element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
1214
- console.log('2');
1214
+ // console.log('2')
1215
1215
  } break;
1216
1216
  default : throw Error("Not supported")
1217
1217
  }
@@ -1673,6 +1673,13 @@ function unrender(){
1673
1673
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
1674
1674
  return this;
1675
1675
  }
1676
+ function replaceElementWith(new_element){
1677
+ this.cache.element.replaceWith(new_element);
1678
+ this.cache.element = new_element;
1679
+
1680
+ // To do : Dispose Events and States
1681
+ return this
1682
+ }
1676
1683
  function renderAfter(t = 1) {
1677
1684
  setTimeout(() => this.render(), t);
1678
1685
  return this;
@@ -1703,6 +1710,7 @@ var DomMethods = /*#__PURE__*/Object.freeze({
1703
1710
  remove: remove,
1704
1711
  render: render,
1705
1712
  renderAfter: renderAfter,
1713
+ replaceElementWith: replaceElementWith,
1706
1714
  unrender: unrender,
1707
1715
  unrenderAfter: unrenderAfter
1708
1716
  });
@@ -3124,7 +3132,7 @@ const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQ
3124
3132
  let UIElement$1 = class UIElement extends UIElementCore{
3125
3133
  constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
3126
3134
  super();
3127
- console.log({type});
3135
+ // console.log({type})
3128
3136
  // console.log(this)
3129
3137
  register_to_class(
3130
3138
  this,
@@ -3134,7 +3142,7 @@ let UIElement$1 = class UIElement extends UIElementCore{
3134
3142
  IndexingMethods,
3135
3143
  EventsMethodes
3136
3144
  );
3137
- this.init(element, name, type, render);
3145
+ if(element)this.init(element, name, type, render);
3138
3146
  }
3139
3147
  get element(){
3140
3148
  return this.cache.element;
@@ -3424,13 +3432,13 @@ const tags = new Proxy({}, {
3424
3432
  let type ;
3425
3433
  if(HTMLTags.includes(tag)) type = 'html';
3426
3434
  if(SVGTags.includes(tag)) type = 'svg';
3427
- console.log(type);
3435
+ // console.log(type)
3428
3436
  return (...args)=>{
3429
3437
  // Fix undefined
3430
3438
  // console.log(isStateGetter(args[0]))
3431
3439
  // console.log(!!args)
3432
3440
  if(args.length === 0) {
3433
- console.log('length 0');
3441
+ // console.log('length 0')
3434
3442
  return new UIElement$1({element : tag, name : tag, type})
3435
3443
  }
3436
3444
  if(
@@ -3698,6 +3706,38 @@ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
3698
3706
  );
3699
3707
  }
3700
3708
 
3709
+ class UISwitch extends UIElement$1{
3710
+ constructor(key, cases){
3711
+ super();
3712
+ this.key = key;
3713
+ this.cases = cases;
3714
+ this.init();
3715
+ }
3716
+ init(){
3717
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender());
3718
+ super.init(this.current.element);
3719
+ }
3720
+ get current(){
3721
+ const matched = Object.keys(this.cases).find(n => n == this.key) ?? 'default';
3722
+ return this.cases[matched]
3723
+ }
3724
+ updateKey(key){
3725
+ this.key = key;
3726
+ this.replaceElementWith(this.current.element);
3727
+ // this.cache.element.replaceWith(this.current.element)
3728
+ // this.cache.element = this.current.element;
3729
+ return this;
3730
+ }
3731
+
3732
+ }
3733
+
3734
+ const Switch=({key, cases})=> new UISwitch(key, cases);
3735
+
3736
+ // export const Switch=({key, cases}) => {
3737
+ // const matched = Object.keys(cases).find(n => n == key) ?? 'default';
3738
+ // return this.cases[matched]()
3739
+ // }
3740
+
3701
3741
  const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
3702
3742
  const svg2ascii=svg=>btoa(svg2str(svg));
3703
3743
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
@@ -5892,4 +5932,4 @@ if(globalThis?.document){
5892
5932
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5893
5933
  }
5894
5934
 
5895
- export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_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, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, 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_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
5935
+ export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_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, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, 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_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, 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.45.2",
3
+ "version": "0.45.4",
4
4
  "description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
5
5
  "keywords": [
6
6
  "front-end",
@@ -47,6 +47,13 @@ export function unrender(){
47
47
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
48
48
  return this;
49
49
  }
50
+ export function replaceElementWith(new_element){
51
+ this.cache.element.replaceWith(new_element)
52
+ this.cache.element = new_element;
53
+
54
+ // To do : Dispose Events and States
55
+ return this
56
+ }
50
57
  export function renderAfter(t = 1) {
51
58
  setTimeout(() => this.render(), t);
52
59
  return this;
@@ -18,7 +18,7 @@ import {
18
18
  class UIElement extends UIElementCore{
19
19
  constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
20
20
  super()
21
- console.log({type})
21
+ // console.log({type})
22
22
  // console.log(this)
23
23
  register_to_class(
24
24
  this,
@@ -28,7 +28,7 @@ class UIElement extends UIElementCore{
28
28
  IndexingMethods,
29
29
  EventsMethodes
30
30
  );
31
- this.init(element, name, type, render)
31
+ if(element)this.init(element, name, type, render)
32
32
  }
33
33
  get element(){
34
34
  return this.cache.element;
@@ -11,11 +11,11 @@ class UIElementCore extends UINode{
11
11
  switch(type){
12
12
  case "html" : {
13
13
  element = globalThis?.document?.createElement(element);
14
- console.log('1')
14
+ // console.log('1')
15
15
  }; break;
16
16
  case "svg" : {
17
17
  element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
18
- console.log('2')
18
+ // console.log('2')
19
19
  }; break;
20
20
  default : throw Error("Not supported")
21
21
  }
package/src/ui/index.js CHANGED
@@ -7,4 +7,5 @@ export * from './flex/index.js';
7
7
  export * from './suspense/index.js';
8
8
  export * from './wrappers/index.js';
9
9
  // export * from './graphics/index.js'
10
- export * from './web-component/index.js'
10
+ export * from './web-component/index.js'
11
+ export * from './logic/index.js'
@@ -0,0 +1 @@
1
+ export * from './switch/index.js'
@@ -0,0 +1,38 @@
1
+ import { UIElement } from "../../constructors/UIElement.js";
2
+
3
+ class UISwitch extends UIElement{
4
+ constructor(key, cases){
5
+ super()
6
+ this.key = key;
7
+ this.cases = cases;
8
+ this.init()
9
+ }
10
+ init(){
11
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender())
12
+ super.init(this.current.element)
13
+ }
14
+ get current(){
15
+ const matched = Object.keys(this.cases).find(n => n == this.key) ?? 'default'
16
+ return this.cases[matched]
17
+ }
18
+ updateKey(key){
19
+ this.key = key;
20
+ this.replaceElementWith(this.current.element)
21
+ // this.cache.element.replaceWith(this.current.element)
22
+ // this.cache.element = this.current.element;
23
+ return this;
24
+ }
25
+
26
+ }
27
+
28
+ const Switch=({key, cases})=> new UISwitch(key, cases)
29
+
30
+ export{
31
+ UISwitch,
32
+ Switch
33
+ }
34
+
35
+ // export const Switch=({key, cases}) => {
36
+ // const matched = Object.keys(cases).find(n => n == key) ?? 'default';
37
+ // return this.cases[matched]()
38
+ // }
@@ -19,13 +19,13 @@ const tags = new Proxy({}, {
19
19
  let type ;
20
20
  if(HTMLTags.includes(tag)) type = 'html'
21
21
  if(SVGTags.includes(tag)) type = 'svg'
22
- console.log(type)
22
+ // console.log(type)
23
23
  return (...args)=>{
24
24
  // Fix undefined
25
25
  // console.log(isStateGetter(args[0]))
26
26
  // console.log(!!args)
27
27
  if(args.length === 0) {
28
- console.log('length 0')
28
+ // console.log('length 0')
29
29
  return new UIElement({element : tag, name : tag, type})
30
30
  }
31
31
  if(