ziko 2.0.0-beta.3 → 2.0.0-beta.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.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",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { text } from "../text/index.js";
|
|
2
2
|
import { isStateGetter } from "../../hooks/use-state.js";
|
|
3
3
|
export function append(...ele) {
|
|
4
|
-
|
|
4
|
+
__addItems__.call(this, "append", "push", ...ele);
|
|
5
5
|
return this;
|
|
6
6
|
}
|
|
7
7
|
export function prepend(...ele) {
|
|
8
|
-
this.
|
|
8
|
+
this.__addItems__.call(this, "prepend", "unshift", ...ele);
|
|
9
9
|
return this;
|
|
10
10
|
}
|
|
11
11
|
export function insertAt(index, ...ele) {
|
|
@@ -47,58 +47,46 @@ export function replaceElementWith(new_element){
|
|
|
47
47
|
return this
|
|
48
48
|
}
|
|
49
49
|
export function after(ui){
|
|
50
|
-
if(ui?.isUIElement) ui=ui.element;
|
|
50
|
+
if(ui?.isUIElement) ui = ui.element;
|
|
51
51
|
this.itemsTarget.element?.after(ui)
|
|
52
52
|
return this;
|
|
53
53
|
}
|
|
54
54
|
export function before(ui){
|
|
55
|
-
if(ui?.isUIElement) ui=ui.element;
|
|
55
|
+
if(ui?.isUIElement) ui = ui.element;
|
|
56
56
|
this.itemsTarget.element?.before(ui)
|
|
57
57
|
return this;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
|
|
60
|
+
export async function __addItem__(adder, pusher, item, referenceNode = null, index = null) {
|
|
61
|
+
const { element: itemsTargetEl, items } = this.itemsTarget;
|
|
62
|
+
if (["number", "string"].includes(typeof item)) item = text(item);
|
|
63
|
+
if (typeof item === "function" && isStateGetter(item)) {
|
|
64
|
+
const getter = item();
|
|
65
|
+
item = text(getter.value);
|
|
66
|
+
getter._subscribe(
|
|
67
|
+
(newValue) => { item.element.textContent = newValue; },
|
|
68
|
+
item
|
|
69
|
+
);
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
itemsTarget.items[pusher](ele[i]);
|
|
86
|
-
}
|
|
87
|
-
else if(ele[i] instanceof Promise){
|
|
88
|
-
const UIEle = await ele[i]
|
|
89
|
-
UIEle.cache.parent = this;
|
|
90
|
-
itemsTarget_el?.[adder](UIEle.element);
|
|
91
|
-
UIEle.target = this.itemsTarget.element;
|
|
92
|
-
itemsTarget.items[pusher](UIEle)
|
|
93
|
-
}
|
|
94
|
-
else if (ele[i] instanceof Object) {
|
|
95
|
-
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
96
|
-
if (ele[i]?.attr) {
|
|
97
|
-
Object.entries(ele[i].attr).forEach((n) =>
|
|
98
|
-
this.setAttr("" + n[0], n[1]),
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
71
|
+
if (typeof globalThis?.Node === "function" && item instanceof globalThis.Node)
|
|
72
|
+
item = new this.constructor(item);
|
|
73
|
+
if (item instanceof Promise) item = await item;
|
|
74
|
+
if (item?.isUINode) {
|
|
75
|
+
item.cache.parent = this;
|
|
76
|
+
item.target = itemsTargetEl;
|
|
77
|
+
if (adder === "insertBefore" && itemsTargetEl)
|
|
78
|
+
itemsTargetEl.insertBefore(item.element, referenceNode);
|
|
79
|
+
else if (typeof itemsTargetEl?.[adder] === "function")
|
|
80
|
+
itemsTargetEl[adder](item.element);
|
|
81
|
+
if (pusher === "splice" && index !== null) items.splice(index, 0, item);
|
|
82
|
+
else if (typeof items?.[pusher] === "function") items[pusher](item);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function __addItems__(adder, pusher, ...elements) {
|
|
88
|
+
for (const item of elements) {
|
|
89
|
+
await this.__addItem__(adder, pusher, item);
|
|
102
90
|
}
|
|
103
91
|
this.maintain();
|
|
104
92
|
return this;
|
|
@@ -3,12 +3,9 @@ export function mount(target = this.target, delay = 0) {
|
|
|
3
3
|
setTimeout(() => this.mount(target, 0), delay);
|
|
4
4
|
return this;
|
|
5
5
|
}
|
|
6
|
-
|
|
7
6
|
if (this.isBody) return this;
|
|
8
|
-
|
|
9
7
|
if (target?.isUIElement) target = target.element;
|
|
10
8
|
this.target = target;
|
|
11
|
-
|
|
12
9
|
this.target?.appendChild(this.element);
|
|
13
10
|
return this;
|
|
14
11
|
}
|
|
@@ -18,7 +15,6 @@ export function unmount(delay = 0) {
|
|
|
18
15
|
setTimeout(() => this.unmount(0), delay);
|
|
19
16
|
return this;
|
|
20
17
|
}
|
|
21
|
-
|
|
22
18
|
if (this.cache.parent) {
|
|
23
19
|
this.cache.parent.remove(this);
|
|
24
20
|
} else if (
|