ziko 0.48.2 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Nov 21 2025 22:08:16 GMT+0100 (UTC+01:00)
5
+ Date : Sat Nov 22 2025 13:34:29 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
@@ -1338,7 +1338,7 @@ class UIElementCore extends UINode{
1338
1338
  // // UI.append(...items);
1339
1339
  // // }
1340
1340
  // // else UI.element=this.element.cloneNode(true);
1341
- // // return UI.render(render);
1341
+ // // return UI.mount(render);
1342
1342
  // }
1343
1343
 
1344
1344
  // freeze(freeze){
@@ -1348,9 +1348,9 @@ class UIElementCore extends UINode{
1348
1348
  // setTarget(tg) {
1349
1349
  // if(this.isBody) return ;
1350
1350
  // if (tg?.isUIElement) tg = tg.element;
1351
- // this.unrender();
1351
+ // this.unmount();
1352
1352
  // this.target = tg;
1353
- // this.render();
1353
+ // this.mount();
1354
1354
  // return this;
1355
1355
  // }
1356
1356
  // describe(label){
@@ -1656,18 +1656,18 @@ function remove(...ele) {
1656
1656
  return this;
1657
1657
  }
1658
1658
  function clear(){
1659
- this?.items?.forEach(n=>n.unrender());
1659
+ this?.items?.forEach(n=>n.unmount());
1660
1660
  this.element.innerHTML = "";
1661
1661
  return this;
1662
1662
  }
1663
- function render(target = this.target) {
1663
+ function mount(target = this.target) {
1664
1664
  if(this.isBody)return ;
1665
1665
  if(target?.isUIElement)target=target.element;
1666
1666
  this.target=target;
1667
1667
  this.target?.appendChild(this.element);
1668
1668
  return this;
1669
1669
  }
1670
- function unrender(){
1670
+ function unmount(){
1671
1671
  if(this.cache.parent)this.cache.parent.remove(this);
1672
1672
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
1673
1673
  return this;
@@ -1680,11 +1680,11 @@ function replaceElementWith(new_element){
1680
1680
  return this
1681
1681
  }
1682
1682
  function renderAfter(t = 1) {
1683
- setTimeout(() => this.render(), t);
1683
+ setTimeout(() => this.mount(), t);
1684
1684
  return this;
1685
1685
  }
1686
1686
  function unrenderAfter(t = 1) {
1687
- setTimeout(() => this.unrender(), t);
1687
+ setTimeout(() => this.unmount(), t);
1688
1688
  return this;
1689
1689
  }
1690
1690
  function after(ui){
@@ -1705,12 +1705,12 @@ var DomMethods = /*#__PURE__*/Object.freeze({
1705
1705
  before: before,
1706
1706
  clear: clear,
1707
1707
  insertAt: insertAt,
1708
+ mount: mount,
1708
1709
  prepend: prepend,
1709
1710
  remove: remove,
1710
- render: render,
1711
1711
  renderAfter: renderAfter,
1712
1712
  replaceElementWith: replaceElementWith,
1713
- unrender: unrender,
1713
+ unmount: unmount,
1714
1714
  unrenderAfter: unrenderAfter
1715
1715
  });
1716
1716
 
@@ -2415,7 +2415,7 @@ let UIElement$1 = class UIElement extends UIElementCore{
2415
2415
  // // UI.append(...items);
2416
2416
  // // }
2417
2417
  // // else UI.element=this.element.cloneNode(true);
2418
- // // return UI.render(render);
2418
+ // // return UI.mount(render);
2419
2419
  // }
2420
2420
  // [Symbol.iterator]() {
2421
2421
  // return this.items[Symbol.iterator]();
@@ -2437,9 +2437,9 @@ let UIElement$1 = class UIElement extends UIElementCore{
2437
2437
  // setTarget(tg) {
2438
2438
  // if(this.isBody) return ;
2439
2439
  // if (tg?.isUIElement) tg = tg.element;
2440
- // this.unrender();
2440
+ // this.unmount();
2441
2441
  // this.target = tg;
2442
- // this.render();
2442
+ // this.mount();
2443
2443
  // return this;
2444
2444
  // }
2445
2445
  // describe(label){
@@ -2702,7 +2702,7 @@ class ZikoUIFlex extends UIElement$1 {
2702
2702
  if (typeof h == "number") h += "%";
2703
2703
  this.style({ width: w, height: h });
2704
2704
  this.style({ display: "flex" });
2705
- // this.render();
2705
+ // this.mount();
2706
2706
  }
2707
2707
  get isFlex(){
2708
2708
  return true;
@@ -2810,7 +2810,7 @@ class ZikoUISuspense extends UIElement{
2810
2810
  (async ()=>{
2811
2811
  try{
2812
2812
  const ui = await callback();
2813
- fallback_ui.unrender();
2813
+ fallback_ui.unmount();
2814
2814
  this.append(ui);
2815
2815
  // console.log(content)
2816
2816
  }
@@ -2912,19 +2912,19 @@ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
2912
2912
  }
2913
2913
 
2914
2914
  connectedCallback() {
2915
- this.render();
2915
+ this.mount();
2916
2916
  }
2917
2917
 
2918
- render() {
2918
+ mount() {
2919
2919
  this.shadowRoot.innerHTML = '';
2920
- this.UIElement = UIElement(this.props).render(this.shadowRoot);
2920
+ this.UIElement = UIElement(this.props).mount(this.shadowRoot);
2921
2921
  }
2922
2922
 
2923
2923
  attributeChangedCallback(name, _, newValue) {
2924
2924
  Object.assign(this.props, {
2925
2925
  [name]: this.mask[name].type(newValue)
2926
2926
  });
2927
- this.render();
2927
+ this.mount();
2928
2928
  }
2929
2929
  }
2930
2930
  );
@@ -2938,7 +2938,7 @@ class UISwitch extends UIElement$1{
2938
2938
  this.init();
2939
2939
  }
2940
2940
  init(){
2941
- Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender());
2941
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unmount());
2942
2942
  super.init(this.current.element);
2943
2943
  }
2944
2944
  get current(){
@@ -2965,7 +2965,7 @@ const Switch=({key, cases})=> new UISwitch(key, cases);
2965
2965
  const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
2966
2966
  const svg2ascii=svg=>btoa(svg2str(svg));
2967
2967
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
2968
- const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).render(render);
2968
+ const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).mount(render);
2969
2969
 
2970
2970
  // const obj2str=(object)=>{
2971
2971
  // const recursiveToString = (obj) => {
@@ -4855,7 +4855,7 @@ class ZikoApp {
4855
4855
  this.head && this.setHead(this.head);
4856
4856
  this.wrapper && this.setWrapper(this.wrapper);
4857
4857
  this.target && this.setTarget(this.target);
4858
- if(this.wrapper && this.target)this.wrapper.render(this.target);
4858
+ if(this.wrapper && this.target)this.wrapper.mount(this.target);
4859
4859
  }
4860
4860
  setTarget(target){
4861
4861
  if(target instanceof HTMLElement) this.target = target;
@@ -4931,16 +4931,16 @@ class ZikoSPA extends ZikoApp{
4931
4931
  ...Object.entries(routes)
4932
4932
  ]);
4933
4933
  this.clear();
4934
- globalThis.onpopstate = this.render(location.pathname);
4934
+ globalThis.onpopstate = this.mount(location.pathname);
4935
4935
  }
4936
4936
  clear(){
4937
4937
  [...this.routes].forEach(n=>{
4938
- !isDynamic(n[0]) && n[1]?.isUIElement && n[1].unrender();
4938
+ !isDynamic(n[0]) && n[1]?.isUIElement && n[1].unmount();
4939
4939
  });
4940
4940
  // this.wrapper.clear();
4941
4941
  return this;
4942
4942
  }
4943
- render(path){
4943
+ mount(path){
4944
4944
  const [mask, callback] = [...this.routes].find(route=>routesMatcher(route[0],path));
4945
4945
  let element ;
4946
4946
  if(isDynamic(mask)){
@@ -4948,13 +4948,13 @@ class ZikoSPA extends ZikoApp{
4948
4948
  element = callback.call(this,params);
4949
4949
  }
4950
4950
  else {
4951
- callback?.isUIElement && callback.render(this.wrapper);
4951
+ callback?.isUIElement && callback.mount(this.wrapper);
4952
4952
  if(typeof callback === "function") element = callback();
4953
4953
  }
4954
- if(element?.isUIElement) element.render(this.wrapper);
4955
- // if(element?.isZikoApp) element.render(this.wrapper);
4954
+ if(element?.isUIElement) element.mount(this.wrapper);
4955
+ // if(element?.isZikoApp) element.mount(this.wrapper);
4956
4956
  if(element instanceof Promise){
4957
- element.then(e=>e.render(this.wrapper));
4957
+ element.then(e=>e.mount(this.wrapper));
4958
4958
  }
4959
4959
  globalThis.history.pushState({}, "", path);
4960
4960
  return this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "0.48.2",
3
+ "version": "0.49.1",
4
4
  "description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
5
5
  "keywords": [
6
6
  "front-end",
package/src/app/spa.js CHANGED
@@ -9,16 +9,16 @@ class ZikoSPA extends ZikoApp{
9
9
  ...Object.entries(routes)
10
10
  ]);
11
11
  this.clear();
12
- globalThis.onpopstate = this.render(location.pathname);
12
+ globalThis.onpopstate = this.mount(location.pathname);
13
13
  }
14
14
  clear(){
15
15
  [...this.routes].forEach(n=>{
16
- !isDynamic(n[0]) && n[1]?.isUIElement && n[1].unrender()
16
+ !isDynamic(n[0]) && n[1]?.isUIElement && n[1].unmount()
17
17
  })
18
18
  // this.wrapper.clear();
19
19
  return this;
20
20
  }
21
- render(path){
21
+ mount(path){
22
22
  const [mask, callback] = [...this.routes].find(route=>routesMatcher(route[0],path));
23
23
  let element ;
24
24
  if(isDynamic(mask)){
@@ -26,13 +26,13 @@ class ZikoSPA extends ZikoApp{
26
26
  element = callback.call(this,params)
27
27
  }
28
28
  else {
29
- callback?.isUIElement && callback.render(this.wrapper);
29
+ callback?.isUIElement && callback.mount(this.wrapper);
30
30
  if(typeof callback === "function") element = callback();
31
31
  }
32
- if(element?.isUIElement) element.render(this.wrapper);
33
- // if(element?.isZikoApp) element.render(this.wrapper);
32
+ if(element?.isUIElement) element.mount(this.wrapper);
33
+ // if(element?.isZikoApp) element.mount(this.wrapper);
34
34
  if(element instanceof Promise){
35
- element.then(e=>e.render(this.wrapper))
35
+ element.then(e=>e.mount(this.wrapper))
36
36
  }
37
37
  globalThis.history.pushState({}, "", path);
38
38
  return this;
@@ -13,7 +13,7 @@ class ZikoApp {
13
13
  this.head && this.setHead(this.head);
14
14
  this.wrapper && this.setWrapper(this.wrapper);
15
15
  this.target && this.setTarget(this.target);
16
- if(this.wrapper && this.target)this.wrapper.render(this.target);
16
+ if(this.wrapper && this.target)this.wrapper.mount(this.target);
17
17
  }
18
18
  setTarget(target){
19
19
  if(target instanceof HTMLElement) this.target = target;
@@ -2,7 +2,7 @@ import { tags } from "../../ui"
2
2
  const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
3
3
  const svg2ascii=svg=>btoa(svg2str(svg));
4
4
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
5
- const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).render(render);
5
+ const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).mount(render);
6
6
  export{
7
7
  svg2str,
8
8
  svg2ascii,
@@ -31,18 +31,18 @@ export function remove(...ele) {
31
31
  return this;
32
32
  }
33
33
  export function clear(){
34
- this?.items?.forEach(n=>n.unrender());
34
+ this?.items?.forEach(n=>n.unmount());
35
35
  this.element.innerHTML = "";
36
36
  return this;
37
37
  }
38
- export function render(target = this.target) {
38
+ export function mount(target = this.target) {
39
39
  if(this.isBody)return ;
40
40
  if(target?.isUIElement)target=target.element;
41
41
  this.target=target;
42
42
  this.target?.appendChild(this.element);
43
43
  return this;
44
44
  }
45
- export function unrender(){
45
+ export function unmount(){
46
46
  if(this.cache.parent)this.cache.parent.remove(this);
47
47
  else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
48
48
  return this;
@@ -55,11 +55,11 @@ export function replaceElementWith(new_element){
55
55
  return this
56
56
  }
57
57
  export function renderAfter(t = 1) {
58
- setTimeout(() => this.render(), t);
58
+ setTimeout(() => this.mount(), t);
59
59
  return this;
60
60
  }
61
61
  export function unrenderAfter(t = 1) {
62
- setTimeout(() => this.unrender(), t);
62
+ setTimeout(() => this.unmount(), t);
63
63
  return this;
64
64
  }
65
65
  export function after(ui){
@@ -94,7 +94,7 @@ class UIElement extends UIElementCore{
94
94
  // // UI.append(...items);
95
95
  // // }
96
96
  // // else UI.element=this.element.cloneNode(true);
97
- // // return UI.render(render);
97
+ // // return UI.mount(render);
98
98
  // }
99
99
  // [Symbol.iterator]() {
100
100
  // return this.items[Symbol.iterator]();
@@ -116,9 +116,9 @@ class UIElement extends UIElementCore{
116
116
  // setTarget(tg) {
117
117
  // if(this.isBody) return ;
118
118
  // if (tg?.isUIElement) tg = tg.element;
119
- // this.unrender();
119
+ // this.unmount();
120
120
  // this.target = tg;
121
- // this.render();
121
+ // this.mount();
122
122
  // return this;
123
123
  // }
124
124
  // describe(label){
@@ -133,7 +133,7 @@ class UIElementCore extends UINode{
133
133
  // // UI.append(...items);
134
134
  // // }
135
135
  // // else UI.element=this.element.cloneNode(true);
136
- // // return UI.render(render);
136
+ // // return UI.mount(render);
137
137
  // }
138
138
 
139
139
  // freeze(freeze){
@@ -143,9 +143,9 @@ class UIElementCore extends UINode{
143
143
  // setTarget(tg) {
144
144
  // if(this.isBody) return ;
145
145
  // if (tg?.isUIElement) tg = tg.element;
146
- // this.unrender();
146
+ // this.unmount();
147
147
  // this.target = tg;
148
- // this.render();
148
+ // this.mount();
149
149
  // return this;
150
150
  // }
151
151
  // describe(label){
@@ -46,22 +46,22 @@ get #SwitchedStyleRTL_LTR(){
46
46
  return this;
47
47
  }
48
48
  filterByTextContent(text, exactMatch = false) {
49
- this.items.forEach((n) => n.render());
49
+ this.items.forEach((n) => n.mount());
50
50
  this.filter(
51
51
  (n) => !(exactMatch ? n.text === text : n.text.includes(text)),
52
- (e) => e.unrender(),
52
+ (e) => e.unmount(),
53
53
  );
54
54
  // this.items.filter(n=>{
55
55
  // const content=n.element.textContent;
56
56
  // return !(exactMatch?content===text:content.includes(text))
57
- // }).map(n=>n.unrender());
57
+ // }).map(n=>n.unmount());
58
58
  // return this;
59
59
  }
60
60
  filterByClass(value) {
61
- this.items.map((n) => n.render());
61
+ this.items.map((n) => n.mount());
62
62
  this.items
63
63
  .filter((n) => !n.classes.includes(value))
64
- .map((n) => n.unrender());
64
+ .map((n) => n.unmount());
65
65
  return this;
66
66
  }
67
67
  sortByTextContent(value, displays) {
@@ -7,7 +7,7 @@ class ZikoUIFlex extends UIElement {
7
7
  if (typeof h == "number") h += "%";
8
8
  this.style({ width: w, height: h });
9
9
  this.style({ display: "flex" });
10
- // this.render();
10
+ // this.mount();
11
11
  }
12
12
  get isFlex(){
13
13
  return true;
@@ -7,7 +7,7 @@ class ZikoUIGrid extends UIElement {
7
7
  if (typeof h == "number") h += "%";
8
8
  this.style({ border: "1px solid black", width: w, height: h });
9
9
  this.style({ display: "grid" });
10
- // this.render();
10
+ // this.mount();
11
11
  }
12
12
  get isGird(){
13
13
  return true;
@@ -8,7 +8,7 @@ class UISwitch extends UIElement{
8
8
  this.init()
9
9
  }
10
10
  init(){
11
- Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender())
11
+ Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unmount())
12
12
  super.init(this.current.element)
13
13
  }
14
14
  get current(){
@@ -10,7 +10,7 @@ class ZikoUISuspense extends UIElement{
10
10
  (async ()=>{
11
11
  try{
12
12
  const ui = await callback()
13
- fallback_ui.unrender()
13
+ fallback_ui.unmount()
14
14
  this.append(ui)
15
15
  // console.log(content)
16
16
  }
@@ -1,7 +1,7 @@
1
1
  export function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
2
2
  if (globalThis.customElements?.get(name)) {
3
3
  console.warn(`Custom element "${name}" is already defined`);
4
- return; // skip redefinition
4
+ return;
5
5
  }
6
6
  if(name.search('-') === -1){
7
7
  console.warn(`"${name}" is not a valid custom element name`);
@@ -30,7 +30,9 @@ export function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
30
30
 
31
31
  render() {
32
32
  this.shadowRoot.innerHTML = '';
33
- this.UIElement = UIElement(this.props).render(this.shadowRoot);
33
+ const item = UIElement(this.props);
34
+ if(item instanceof Array) item.forEach(n => n.mount(this.shadowRoot))
35
+ else item.mount(this.shadowRoot)
34
36
  }
35
37
 
36
38
  attributeChangedCallback(name, _, newValue) {