ziko 1.5.0 → 1.6.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.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Jul 31 2026 10:36:31 GMT+0100 (UTC+01:00)
5
+ Date : Fri Jul 31 2026 17:26:32 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
@@ -2252,6 +2252,7 @@ class UIElementCore extends UINode{
2252
2252
  else this.target = element?.parentElement;
2253
2253
  Object.assign(this.cache, {
2254
2254
  name,
2255
+ itemsTarget : this,
2255
2256
  isInteractive : false,
2256
2257
  parent:null,
2257
2258
  isBody:false,
@@ -2288,7 +2289,7 @@ class UIElementCore extends UINode{
2288
2289
  get element(){
2289
2290
  return this.cache.element;
2290
2291
  }
2291
- [Symbol.iterator]() {
2292
+ [Symbol.iterator](){
2292
2293
  return this.items[Symbol.iterator]();
2293
2294
  }
2294
2295
  maintain() {
@@ -2514,12 +2515,6 @@ class ZikoUIText extends UINode {
2514
2515
  }
2515
2516
  const text = (...str) => new ZikoUIText(...str);
2516
2517
 
2517
- // import { isStateGetter } from "../../../hooks/use-state.js";
2518
- // import {
2519
- // is_camelcase,
2520
- // camel2hyphencase
2521
- // } from '../../../data/string/index.js';
2522
-
2523
2518
  function append(...ele) {
2524
2519
  __addItem__.call(this, "append", "push", ...ele);
2525
2520
  return this;
@@ -2529,19 +2524,30 @@ function prepend(...ele) {
2529
2524
  return this;
2530
2525
  }
2531
2526
  function insertAt(index, ...ele) {
2532
- if (index >= this.element.children.length) this.append(...ele);
2533
- else
2527
+ const target = this.itemsTarget;
2528
+
2529
+ if (index >= target.items.length) return this.append(...ele);
2530
+
2534
2531
  for (let i = 0; i < ele.length; i++) {
2535
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
2536
- this.element?.insertBefore(ele[i].element, this.items[index].element);
2537
- this.items.splice(index, 0, ele[i]);
2532
+ if (["number", "string"].includes(typeof ele[i]))
2533
+ ele[i] = text(ele[i]);
2534
+
2535
+ target.element?.insertBefore(
2536
+ ele[i].element,
2537
+ target.items[index].element
2538
+ );
2539
+
2540
+ target.items.splice(index, 0, ele[i]);
2538
2541
  }
2539
- return this;
2542
+
2543
+ target.maintain();
2544
+
2545
+ return this;
2540
2546
  }
2541
2547
  function remove(...ele) {
2542
2548
  const remove = (ele) => {
2543
2549
  if (typeof ele === "number") ele = this.items[ele];
2544
- if (ele?.isUIElement) this.element?.removeChild(ele.element);
2550
+ if (ele?.isUIElement) this.itemsTarget.element?.removeChild(ele.element);
2545
2551
  this.items = this.items.filter((n) => n !== ele);
2546
2552
  };
2547
2553
  for (let i = 0; i < ele.length; i++) remove(ele[i]);
@@ -2552,7 +2558,7 @@ function remove(...ele) {
2552
2558
  }
2553
2559
  function clear(){
2554
2560
  this?.items?.forEach(n=>n.unmount());
2555
- this.element.innerHTML = "";
2561
+ this.itemsTarget.element.innerHTML = '';
2556
2562
  return this;
2557
2563
  }
2558
2564
  function replaceElementWith(new_element){
@@ -2564,12 +2570,12 @@ function replaceElementWith(new_element){
2564
2570
  }
2565
2571
  function after(ui){
2566
2572
  if(ui?.isUIElement) ui=ui.element;
2567
- this.element?.after(ui);
2573
+ this.itemsTarget.element?.after(ui);
2568
2574
  return this;
2569
2575
  }
2570
2576
  function before(ui){
2571
2577
  if(ui?.isUIElement) ui=ui.element;
2572
- this.element?.before(ui);
2578
+ this.itemsTarget.element?.before(ui);
2573
2579
  return this;
2574
2580
  }
2575
2581
 
@@ -2577,6 +2583,9 @@ function before(ui){
2577
2583
 
2578
2584
 
2579
2585
  async function __addItem__(adder, pusher, ...ele) {
2586
+ const itemsTarget_el = this.itemsTarget.element;
2587
+ const itemsTarget = this.itemsTarget;
2588
+
2580
2589
  if (this.cache.isFrozzen) {
2581
2590
  console.warn("You can't append new item to frozzen element");
2582
2591
  return this;
@@ -2592,22 +2601,22 @@ async function __addItem__(adder, pusher, ...ele) {
2592
2601
  (newValue) => (ele[i].element.textContent = newValue),
2593
2602
  ele[i]
2594
2603
  );
2595
- // this.element.appendChild(textNode);
2604
+ // this.itemsTarget.element.appendChild(textNode);
2596
2605
  }
2597
2606
  }
2598
2607
  if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
2599
2608
  if (ele[i]?.isUINode) {
2600
2609
  ele[i].cache.parent = this;
2601
- this.element?.[adder](ele[i].element);
2602
- ele[i].target = this.element;
2603
- this.items[pusher](ele[i]);
2610
+ itemsTarget_el?.[adder](ele[i].element);
2611
+ ele[i].target = this.itemsTarget.element;
2612
+ itemsTarget.items[pusher](ele[i]);
2604
2613
  }
2605
2614
  else if(ele[i] instanceof Promise){
2606
2615
  const UIEle = await ele[i];
2607
2616
  UIEle.cache.parent = this;
2608
- this.element?.[adder](UIEle.element);
2609
- UIEle.target = this.element;
2610
- this.items[pusher](UIEle);
2617
+ itemsTarget_el?.[adder](UIEle.element);
2618
+ UIEle.target = this.itemsTarget.element;
2619
+ itemsTarget.items[pusher](UIEle);
2611
2620
  }
2612
2621
  else if (ele[i] instanceof Object) {
2613
2622
  if (ele[i]?.style) this.style(ele[i]?.style);
@@ -3119,10 +3128,22 @@ let UIElement$1 = class UIElement extends UIElementCore{
3119
3128
  }
3120
3129
  _off(event, category = 'global'){
3121
3130
  this.exp.events[category].removeListener(event);
3131
+ return this
3122
3132
  }
3123
3133
  get element(){
3124
3134
  return this.cache.element;
3125
3135
  }
3136
+ get itemsTarget(){
3137
+ return this.cache.itemsTarget;
3138
+ }
3139
+ get itemsTargetElement(){
3140
+ return this.itemsTarget.element;
3141
+ }
3142
+ setItemsTarget(parent){
3143
+ this.cache.itemsTarget = parent;
3144
+ this.items = parent.items;
3145
+ return this;
3146
+ }
3126
3147
  isInteractive(){
3127
3148
  return this.cache.isInteractive;
3128
3149
  }
@@ -3729,14 +3750,14 @@ class UISwap extends UIElement$1 {
3729
3750
  };
3730
3751
 
3731
3752
  this.append(...items);
3732
- this.#setup();
3753
+ this.render();
3733
3754
  }
3734
3755
  get activeItem(){
3735
3756
  return this.items[this.states.activeIndex]
3736
3757
  }
3737
- #setup() {
3758
+ render() {
3738
3759
  this.items.forEach((n, i) => {
3739
- // Store initial display style (fallback to empty string or default)
3760
+
3740
3761
  const initialDisplay = n.element?.style?.display || '';
3741
3762
  this.#DISPLAYS_MAP.set(n, initialDisplay);
3742
3763
 
package/dist/ziko.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Jul 31 2026 10:36:31 GMT+0100 (UTC+01:00)
5
+ Date : Fri Jul 31 2026 17:26:32 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
@@ -2256,6 +2256,7 @@
2256
2256
  else this.target = element?.parentElement;
2257
2257
  Object.assign(this.cache, {
2258
2258
  name,
2259
+ itemsTarget : this,
2259
2260
  isInteractive : false,
2260
2261
  parent:null,
2261
2262
  isBody:false,
@@ -2292,7 +2293,7 @@
2292
2293
  get element(){
2293
2294
  return this.cache.element;
2294
2295
  }
2295
- [Symbol.iterator]() {
2296
+ [Symbol.iterator](){
2296
2297
  return this.items[Symbol.iterator]();
2297
2298
  }
2298
2299
  maintain() {
@@ -2518,12 +2519,6 @@
2518
2519
  }
2519
2520
  const text = (...str) => new ZikoUIText(...str);
2520
2521
 
2521
- // import { isStateGetter } from "../../../hooks/use-state.js";
2522
- // import {
2523
- // is_camelcase,
2524
- // camel2hyphencase
2525
- // } from '../../../data/string/index.js';
2526
-
2527
2522
  function append(...ele) {
2528
2523
  __addItem__.call(this, "append", "push", ...ele);
2529
2524
  return this;
@@ -2533,19 +2528,30 @@
2533
2528
  return this;
2534
2529
  }
2535
2530
  function insertAt(index, ...ele) {
2536
- if (index >= this.element.children.length) this.append(...ele);
2537
- else
2531
+ const target = this.itemsTarget;
2532
+
2533
+ if (index >= target.items.length) return this.append(...ele);
2534
+
2538
2535
  for (let i = 0; i < ele.length; i++) {
2539
- if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
2540
- this.element?.insertBefore(ele[i].element, this.items[index].element);
2541
- this.items.splice(index, 0, ele[i]);
2536
+ if (["number", "string"].includes(typeof ele[i]))
2537
+ ele[i] = text(ele[i]);
2538
+
2539
+ target.element?.insertBefore(
2540
+ ele[i].element,
2541
+ target.items[index].element
2542
+ );
2543
+
2544
+ target.items.splice(index, 0, ele[i]);
2542
2545
  }
2543
- return this;
2546
+
2547
+ target.maintain();
2548
+
2549
+ return this;
2544
2550
  }
2545
2551
  function remove(...ele) {
2546
2552
  const remove = (ele) => {
2547
2553
  if (typeof ele === "number") ele = this.items[ele];
2548
- if (ele?.isUIElement) this.element?.removeChild(ele.element);
2554
+ if (ele?.isUIElement) this.itemsTarget.element?.removeChild(ele.element);
2549
2555
  this.items = this.items.filter((n) => n !== ele);
2550
2556
  };
2551
2557
  for (let i = 0; i < ele.length; i++) remove(ele[i]);
@@ -2556,7 +2562,7 @@
2556
2562
  }
2557
2563
  function clear(){
2558
2564
  this?.items?.forEach(n=>n.unmount());
2559
- this.element.innerHTML = "";
2565
+ this.itemsTarget.element.innerHTML = '';
2560
2566
  return this;
2561
2567
  }
2562
2568
  function replaceElementWith(new_element){
@@ -2568,12 +2574,12 @@
2568
2574
  }
2569
2575
  function after(ui){
2570
2576
  if(ui?.isUIElement) ui=ui.element;
2571
- this.element?.after(ui);
2577
+ this.itemsTarget.element?.after(ui);
2572
2578
  return this;
2573
2579
  }
2574
2580
  function before(ui){
2575
2581
  if(ui?.isUIElement) ui=ui.element;
2576
- this.element?.before(ui);
2582
+ this.itemsTarget.element?.before(ui);
2577
2583
  return this;
2578
2584
  }
2579
2585
 
@@ -2581,6 +2587,9 @@
2581
2587
 
2582
2588
 
2583
2589
  async function __addItem__(adder, pusher, ...ele) {
2590
+ const itemsTarget_el = this.itemsTarget.element;
2591
+ const itemsTarget = this.itemsTarget;
2592
+
2584
2593
  if (this.cache.isFrozzen) {
2585
2594
  console.warn("You can't append new item to frozzen element");
2586
2595
  return this;
@@ -2596,22 +2605,22 @@
2596
2605
  (newValue) => (ele[i].element.textContent = newValue),
2597
2606
  ele[i]
2598
2607
  );
2599
- // this.element.appendChild(textNode);
2608
+ // this.itemsTarget.element.appendChild(textNode);
2600
2609
  }
2601
2610
  }
2602
2611
  if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
2603
2612
  if (ele[i]?.isUINode) {
2604
2613
  ele[i].cache.parent = this;
2605
- this.element?.[adder](ele[i].element);
2606
- ele[i].target = this.element;
2607
- this.items[pusher](ele[i]);
2614
+ itemsTarget_el?.[adder](ele[i].element);
2615
+ ele[i].target = this.itemsTarget.element;
2616
+ itemsTarget.items[pusher](ele[i]);
2608
2617
  }
2609
2618
  else if(ele[i] instanceof Promise){
2610
2619
  const UIEle = await ele[i];
2611
2620
  UIEle.cache.parent = this;
2612
- this.element?.[adder](UIEle.element);
2613
- UIEle.target = this.element;
2614
- this.items[pusher](UIEle);
2621
+ itemsTarget_el?.[adder](UIEle.element);
2622
+ UIEle.target = this.itemsTarget.element;
2623
+ itemsTarget.items[pusher](UIEle);
2615
2624
  }
2616
2625
  else if (ele[i] instanceof Object) {
2617
2626
  if (ele[i]?.style) this.style(ele[i]?.style);
@@ -3123,10 +3132,22 @@
3123
3132
  }
3124
3133
  _off(event, category = 'global'){
3125
3134
  this.exp.events[category].removeListener(event);
3135
+ return this
3126
3136
  }
3127
3137
  get element(){
3128
3138
  return this.cache.element;
3129
3139
  }
3140
+ get itemsTarget(){
3141
+ return this.cache.itemsTarget;
3142
+ }
3143
+ get itemsTargetElement(){
3144
+ return this.itemsTarget.element;
3145
+ }
3146
+ setItemsTarget(parent){
3147
+ this.cache.itemsTarget = parent;
3148
+ this.items = parent.items;
3149
+ return this;
3150
+ }
3130
3151
  isInteractive(){
3131
3152
  return this.cache.isInteractive;
3132
3153
  }
@@ -3733,14 +3754,14 @@
3733
3754
  };
3734
3755
 
3735
3756
  this.append(...items);
3736
- this.#setup();
3757
+ this.render();
3737
3758
  }
3738
3759
  get activeItem(){
3739
3760
  return this.items[this.states.activeIndex]
3740
3761
  }
3741
- #setup() {
3762
+ render() {
3742
3763
  this.items.forEach((n, i) => {
3743
- // Store initial display style (fallback to empty string or default)
3764
+
3744
3765
  const initialDisplay = n.element?.style?.display || '';
3745
3766
  this.#DISPLAYS_MAP.set(n, initialDisplay);
3746
3767