ziko 0.32.0 → 0.34.0
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 +2440 -3447
- package/dist/ziko.js +8192 -9199
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +2423 -3424
- package/package.json +4 -6
- package/src/__helpers__/composition/compose-class.js +28 -0
- package/src/__helpers__/composition/compose-instance.js +15 -0
- package/src/__helpers__/composition/compose.js +11 -0
- package/src/__helpers__/composition/index.js +3 -0
- package/src/__helpers__/index.js +4 -2
- package/src/app/index.js +0 -3
- package/src/events/__Events__.js +18 -8
- package/src/events/pointer.js +1 -1
- package/src/index.js +9 -3
- package/src/math/functions/index.js +6 -9
- package/src/math/index.js +0 -7
- package/src/math/matrix/Matrix.js +1 -50
- package/src/math/matrix/index.js +1 -3
- package/src/math/signal/index.js +1 -110
- package/src/math/statistics/index.js +2 -2
- package/src/reactivity/events/index.js +8 -8
- package/src/reactivity/hooks/Head/useFavIcon.js +2 -2
- package/src/reactivity/hooks/Head/useTitle.js +1 -1
- package/src/reactivity/hooks/index.js +3 -3
- package/src/ui/elements/ZikoUIElement.js +45 -285
- package/src/ui/elements/semantic/index.js +33 -73
- package/src/ui/methods/dom.js +99 -0
- package/src/ui/methods/events.js +39 -0
- package/src/ui/methods/indexing.js +15 -0
- package/src/use/decorators/index.js +2 -0
- package/src/use/decorators/use-debounce.js +4 -0
- package/src/use/decorators/use-throttle.js +9 -0
- package/src/use/index.js +3 -0
- package/src/use/interactions/index.js +3 -0
- package/src/{reactivity/hooks/Interactions/useChannel.js → use/interactions/use-channel.js} +8 -8
- package/src/{reactivity/hooks/Storage/useStorage.js → use/storage/index.js} +2 -2
- package/src/app/json-style-sheet.js +0 -64
- package/src/math/calculus/derivation/index.js +0 -7
- package/src/math/calculus/index.js +0 -2
- package/src/math/calculus/special-functions/bessel.js +0 -31
- package/src/math/calculus/special-functions/beta.js +0 -38
- package/src/math/calculus/special-functions/gamma.js +0 -30
- package/src/math/calculus/special-functions/index.js +0 -4
- package/src/math/matrix/Decomposition.js +0 -90
- package/src/math/matrix/LinearSystem.js +0 -10
- package/src/math/signal/__np.py.txt +0 -40
- package/src/math/signal/conv.js +0 -175
- package/src/math/signal/fft.js +0 -55
- package/src/math/signal/filter.js +0 -39
- package/src/reactivity/events/Pointer.js +0 -232
- package/src/reactivity/events/click.js +0 -102
- package/src/reactivity/events/clipboard.js +0 -88
- package/src/reactivity/events/drag.js +0 -137
- package/src/reactivity/events/focus.js +0 -59
- package/src/reactivity/events/key.js +0 -102
- package/src/reactivity/events/wheel.js +0 -47
- package/src/reactivity/hooks/Decorators/index.js +0 -6
- package/src/reactivity/hooks/Decorators/time.js +0 -17
- package/src/reactivity/hooks/Decorators/type.js +0 -88
- package/src/reactivity/hooks/Interactions/_useBluetooth.js +0 -48
- package/src/reactivity/hooks/Interactions/index.js +0 -4
- package/src/reactivity/hooks/Sensors ( To Be Moved )/index.js +0 -2
- package/src/reactivity/hooks/Sensors ( To Be Moved )/useBattery.js +0 -36
- package/src/reactivity/hooks/Sensors ( To Be Moved )/useGeolocation.js +0 -17
- package/src/reactivity/hooks/Storage/index.js +0 -1
- /package/src/events/{index.d.ts → index.d.ts.txt} +0 -0
- /package/src/math/statistics/{Functions → functions}/index.js +0 -0
- /package/src/{math/numeric/index.js → ui/methods/observer.js} +0 -0
- /package/src/{reactivity/hooks/Interactions/useUsb.js → ui/methods/style.js} +0 -0
- /package/src/{reactivity/hooks/Sensors ( To Be Moved )/useCamera.js → use/app/index.js} +0 -0
- /package/src/{reactivity/hooks/Sensors ( To Be Moved )/useMicro.js → use/app/use-favicon.js} +0 -0
- /package/src/{reactivity/hooks/Sensors ( To Be Moved )/useOrientation.js → use/app/use-link.js} +0 -0
- /package/src/{reactivity/hooks/Storage/useCookie.js → use/app/use-meta.js} +0 -0
- /package/src/{reactivity/hooks/Storage/useIndexedDb.js → use/app/use-title.js} +0 -0
- /package/src/{reactivity/hooks/Interactions/useEventEmmiter.js → use/interactions/use-event-emmiter.js} +0 -0
- /package/src/{reactivity/hooks/Interactions/useThread.js → use/interactions/use-thread.js} +0 -0
|
@@ -1,15 +1,10 @@
|
|
|
1
|
+
import { compose } from "../../__helpers__/index.js";
|
|
2
|
+
import { DomMethods } from "../methods/dom.js";
|
|
3
|
+
import { IndexingMethods } from "../methods/indexing.js";
|
|
4
|
+
import { EventsMethodes } from "../methods/events.js";
|
|
1
5
|
import { ZikoUseStyle } from "../../reactivity/hooks/UI/useStyle.js";
|
|
2
6
|
import { ZikoUIElementStyle } from "../style/index.js";
|
|
3
7
|
import {
|
|
4
|
-
usePointerEvent,
|
|
5
|
-
useMouseEvent,
|
|
6
|
-
useWheelEvent,
|
|
7
|
-
useKeyEvent,
|
|
8
|
-
useDragEvent ,
|
|
9
|
-
useDropEvent,
|
|
10
|
-
useClickEvent ,
|
|
11
|
-
useClipboardEvent ,
|
|
12
|
-
useFocusEvent,
|
|
13
8
|
useCustomEvent,
|
|
14
9
|
useSwipeEvent,
|
|
15
10
|
watchIntersection,
|
|
@@ -19,7 +14,6 @@ import {
|
|
|
19
14
|
} from "../../reactivity/index.js"
|
|
20
15
|
import { Random } from "../../math/index.js";
|
|
21
16
|
import { Str } from "../../data/index.js";
|
|
22
|
-
import { text } from "./text/text.js";
|
|
23
17
|
class ZikoUIElement {
|
|
24
18
|
constructor(element, name="", {el_type="html", useDefaultStyle=false}={}){
|
|
25
19
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
@@ -34,6 +28,17 @@ class ZikoUIElement {
|
|
|
34
28
|
this.target = element.parentElement;
|
|
35
29
|
}
|
|
36
30
|
if(element)this.__ele__ = element;
|
|
31
|
+
compose(
|
|
32
|
+
this,
|
|
33
|
+
DomMethods,
|
|
34
|
+
IndexingMethods,
|
|
35
|
+
EventsMethodes
|
|
36
|
+
)
|
|
37
|
+
// if(false){
|
|
38
|
+
// import("../methods/tree.js").then(({ default: ExternalMethods }) => {
|
|
39
|
+
// compose(this, ExternalMethods);
|
|
40
|
+
// });
|
|
41
|
+
// }
|
|
37
42
|
this.cache = {
|
|
38
43
|
name,
|
|
39
44
|
parent:null,
|
|
@@ -77,7 +82,7 @@ class ZikoUIElement {
|
|
|
77
82
|
});
|
|
78
83
|
this.items = [];
|
|
79
84
|
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
80
|
-
element && globalThis.__Ziko__.__Config__.default.render && this
|
|
85
|
+
element && globalThis.__Ziko__.__Config__.default.render && this?.render?.()
|
|
81
86
|
if(
|
|
82
87
|
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
83
88
|
// &&
|
|
@@ -99,6 +104,10 @@ class ZikoUIElement {
|
|
|
99
104
|
get isZikoUIElement(){
|
|
100
105
|
return true;
|
|
101
106
|
}
|
|
107
|
+
register(){
|
|
108
|
+
|
|
109
|
+
return this;
|
|
110
|
+
}
|
|
102
111
|
get st(){
|
|
103
112
|
return this.cache.style;
|
|
104
113
|
}
|
|
@@ -162,75 +171,6 @@ class ZikoUIElement {
|
|
|
162
171
|
this.length = this.items.length;
|
|
163
172
|
return this;
|
|
164
173
|
}
|
|
165
|
-
at(index) {
|
|
166
|
-
return this.items.at(index);
|
|
167
|
-
}
|
|
168
|
-
#addItem(adder, pusher, ...ele) {
|
|
169
|
-
if (this.cache.isFrozzen) {
|
|
170
|
-
console.warn("You can't append new item to frozzen element");
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
for (let i = 0; i < ele.length; i++) {
|
|
174
|
-
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
175
|
-
if(ele[i] instanceof Node) ele[i] = new ZikoUIElement(ele[i]);
|
|
176
|
-
if (ele[i]?.isZikoUIElement) {
|
|
177
|
-
ele[i].cache.parent = this;
|
|
178
|
-
this.element[adder](ele[i].element);
|
|
179
|
-
ele[i].target = this.element;
|
|
180
|
-
this.items[pusher](ele[i]);
|
|
181
|
-
}
|
|
182
|
-
else if (ele[i] instanceof Object) {
|
|
183
|
-
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
184
|
-
if (ele[i]?.attr) {
|
|
185
|
-
Object.entries(ele[i].attr).forEach((n) =>
|
|
186
|
-
this.setAttr("" + n[0], n[1]),
|
|
187
|
-
);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
this.maintain();
|
|
192
|
-
return this;
|
|
193
|
-
}
|
|
194
|
-
append(...ele) {
|
|
195
|
-
this.#addItem("append", "push", ...ele);
|
|
196
|
-
return this;
|
|
197
|
-
}
|
|
198
|
-
prepend(...ele) {
|
|
199
|
-
this.#addItem("prepend", "unshift", ...ele);
|
|
200
|
-
return this;
|
|
201
|
-
}
|
|
202
|
-
insertAt(index, ...ele) {
|
|
203
|
-
if (index >= this.element.children.length) this.append(...ele);
|
|
204
|
-
else
|
|
205
|
-
for (let i = 0; i < ele.length; i++) {
|
|
206
|
-
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
207
|
-
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
208
|
-
this.items.splice(index, 0, ele[i]);
|
|
209
|
-
}
|
|
210
|
-
return this;
|
|
211
|
-
}
|
|
212
|
-
remove(...ele) {
|
|
213
|
-
const remove = (ele) => {
|
|
214
|
-
if (typeof ele === "number") ele = this.items[ele];
|
|
215
|
-
if (ele?.isZikoUIElement) this.element?.removeChild(ele.element);
|
|
216
|
-
this.items = this.items.filter((n) => n !== ele);
|
|
217
|
-
};
|
|
218
|
-
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
219
|
-
for (let i = 0; i < this.items.length; i++)
|
|
220
|
-
Object.assign(this, { [[i]]: this.items[i] });
|
|
221
|
-
// Remove from item
|
|
222
|
-
return this;
|
|
223
|
-
}
|
|
224
|
-
forEach(callback) {
|
|
225
|
-
this.items.forEach(callback);
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
map(callback) {
|
|
229
|
-
return this.items.map(callback);
|
|
230
|
-
}
|
|
231
|
-
find(condition) {
|
|
232
|
-
return this.items.filter(condition);
|
|
233
|
-
}
|
|
234
174
|
filter(condition_callback, if_callback = () => {}, else_callback = () => {}) {
|
|
235
175
|
const FilterItems = this.items.filter(condition_callback);
|
|
236
176
|
FilterItems.forEach(if_callback);
|
|
@@ -322,41 +262,6 @@ class ZikoUIElement {
|
|
|
322
262
|
describe(label){
|
|
323
263
|
if(label)this.setAttr("aria-label",label)
|
|
324
264
|
}
|
|
325
|
-
clear(){
|
|
326
|
-
this?.items?.forEach(n=>n.unrender());
|
|
327
|
-
this.element.innerHTML = "";
|
|
328
|
-
return this;
|
|
329
|
-
}
|
|
330
|
-
render(target = this.target) {
|
|
331
|
-
if(this.isBody)return ;
|
|
332
|
-
if(target?.isZikoUIElement)target=target.element;
|
|
333
|
-
this.target=target;
|
|
334
|
-
this.target?.appendChild(this.element);
|
|
335
|
-
return this;
|
|
336
|
-
}
|
|
337
|
-
unrender(){
|
|
338
|
-
if(this.cache.parent)this.cache.parent.remove(this);
|
|
339
|
-
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
340
|
-
return this;
|
|
341
|
-
}
|
|
342
|
-
renderAfter(t = 1) {
|
|
343
|
-
setTimeout(() => this.render(), t);
|
|
344
|
-
return this;
|
|
345
|
-
}
|
|
346
|
-
unrenderAfter(t = 1) {
|
|
347
|
-
setTimeout(() => this.unrender(), t);
|
|
348
|
-
return this;
|
|
349
|
-
}
|
|
350
|
-
after(ui){
|
|
351
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
352
|
-
this.element?.after(ui)
|
|
353
|
-
return this;
|
|
354
|
-
}
|
|
355
|
-
before(ui){
|
|
356
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
357
|
-
this.element?.before(ui)
|
|
358
|
-
return this;
|
|
359
|
-
}
|
|
360
265
|
animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
361
266
|
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
362
267
|
return this;
|
|
@@ -419,161 +324,22 @@ class ZikoUIElement {
|
|
|
419
324
|
get id() {
|
|
420
325
|
return this.element.getAttribute("id");
|
|
421
326
|
}
|
|
422
|
-
onPtrMove(...callbacks){
|
|
423
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
424
|
-
this.events.ptr.onMove(...callbacks);
|
|
425
|
-
return this;
|
|
426
|
-
}
|
|
427
|
-
onPtrDown(...callbacks){
|
|
428
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
429
|
-
this.events.ptr.onDown(...callbacks);
|
|
430
|
-
return this;
|
|
431
|
-
}
|
|
432
|
-
onPtrUp(...callbacks){
|
|
433
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
434
|
-
this.events.ptr.onUp(...callbacks);
|
|
435
|
-
return this;
|
|
436
|
-
}
|
|
437
|
-
onPtrEnter(...callbacks){
|
|
438
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
439
|
-
this.events.ptr.onEnter(...callbacks);
|
|
440
|
-
return this;
|
|
441
|
-
}
|
|
442
|
-
onPtrLeave(...callbacks){
|
|
443
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
444
|
-
this.events.ptr.onLeave(...callbacks);
|
|
445
|
-
return this;
|
|
446
|
-
}
|
|
447
|
-
onPtrOut(...callbacks){
|
|
448
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
449
|
-
this.events.ptr.onOut(...callbacks);
|
|
450
|
-
return this;
|
|
451
|
-
}
|
|
452
|
-
onPtrCancel(...callbacks){
|
|
453
|
-
if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
|
|
454
|
-
this.events.ptr.onCancel(...callbacks);
|
|
455
|
-
return this;
|
|
456
|
-
}
|
|
457
327
|
onSwipe(width_threshold, height_threshold,...callbacks){
|
|
458
328
|
if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
459
329
|
this.events.swipe.onSwipe(...callbacks);
|
|
460
330
|
return this;
|
|
461
331
|
}
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
474
|
-
this.events.mouse.onUp(...callbacks);
|
|
475
|
-
return this;
|
|
476
|
-
}
|
|
477
|
-
onMouseEnter(...callbacks){
|
|
478
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
479
|
-
this.events.mouse.onEnter(...callbacks);
|
|
480
|
-
return this;
|
|
481
|
-
}
|
|
482
|
-
onMouseLeave(...callbacks){
|
|
483
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
484
|
-
this.events.mouse.onLeave(...callbacks);
|
|
485
|
-
return this;
|
|
486
|
-
}
|
|
487
|
-
onMouseOut(...callbacks){
|
|
488
|
-
if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
|
|
489
|
-
this.events.mouse.onOut(...callbacks);
|
|
490
|
-
return this;
|
|
491
|
-
}
|
|
492
|
-
onWheel(...callbacks){
|
|
493
|
-
if(!this.events.wheel)this.events.wheel = useWheelEvent(this);
|
|
494
|
-
this.events.wheel.onWheel(...callbacks);
|
|
495
|
-
return this;
|
|
496
|
-
}
|
|
497
|
-
onKeyDown(...callbacks){
|
|
498
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
499
|
-
this.events.key.onDown(...callbacks);
|
|
500
|
-
return this;
|
|
501
|
-
}
|
|
502
|
-
onKeyPress(...callbacks){
|
|
503
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
504
|
-
this.events.key.onPress(...callbacks);
|
|
505
|
-
return this;
|
|
506
|
-
}
|
|
507
|
-
onKeyUp(...callbacks){
|
|
508
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
509
|
-
this.events.key.onUp(...callbacks);
|
|
510
|
-
return this;
|
|
511
|
-
}
|
|
512
|
-
onKeysDown({keys=[],callback}={}){
|
|
513
|
-
if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
514
|
-
this.events.key.handleSuccessifKeys({keys,callback});
|
|
515
|
-
return this;
|
|
516
|
-
}
|
|
517
|
-
onDragStart(...callbacks){
|
|
518
|
-
if(!this.events.drag)this.events.drag = useDragEvent(this);
|
|
519
|
-
this.events.drag.onStart(...callbacks);
|
|
520
|
-
return this;
|
|
521
|
-
}
|
|
522
|
-
onDrag(...callbacks){
|
|
523
|
-
if(!this.events.drag)this.events.drag = useDragEvent(this);
|
|
524
|
-
this.events.drag.onDrag(...callbacks);
|
|
525
|
-
return this;
|
|
526
|
-
}
|
|
527
|
-
onDragEnd(...callbacks){
|
|
528
|
-
if(!this.events.drag)this.events.drag = useDragEvent(this);
|
|
529
|
-
this.events.drag.onEnd(...callbacks);
|
|
530
|
-
return this;
|
|
531
|
-
}
|
|
532
|
-
onDrop(...callbacks){
|
|
533
|
-
if(!this.events.drop)this.events.drop = useDropEvent(this);
|
|
534
|
-
this.events.drop.onDrop(...callbacks);
|
|
535
|
-
return this;
|
|
536
|
-
}
|
|
537
|
-
onClick(...callbacks){
|
|
538
|
-
if(!this.events.click)this.events.click = useClickEvent(this);
|
|
539
|
-
this.events.click.onClick(...callbacks);
|
|
540
|
-
return this;
|
|
541
|
-
}
|
|
542
|
-
onDbClick(...callbacks){
|
|
543
|
-
if(!this.events.click)this.events.click = useClickEvent(this);
|
|
544
|
-
this.events.click.onDbClick(...callbacks);
|
|
545
|
-
return this;
|
|
546
|
-
}
|
|
547
|
-
onCopy(...callbacks){
|
|
548
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
549
|
-
this.events.clipboard.onCopy(...callbacks);
|
|
550
|
-
return this;
|
|
551
|
-
}
|
|
552
|
-
onCut(...callbacks){
|
|
553
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
554
|
-
this.events.clipboard.onCut(...callbacks);
|
|
555
|
-
return this;
|
|
556
|
-
}
|
|
557
|
-
onPaste(...callbacks){
|
|
558
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
559
|
-
this.events.clipboard.onPaste(...callbacks);
|
|
560
|
-
return this;
|
|
561
|
-
}
|
|
562
|
-
onSelect(...callbacks){
|
|
563
|
-
if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
564
|
-
this.events.clipboard.onSelect(...callbacks);
|
|
565
|
-
return this;
|
|
566
|
-
}
|
|
567
|
-
onFocus(...callbacks){
|
|
568
|
-
if(!this.events.focus)this.events.focus = useFocusEvent(this);
|
|
569
|
-
this.events.focus.onFocus(...callbacks);
|
|
570
|
-
return this;
|
|
571
|
-
}
|
|
572
|
-
onBlur(...callbacks){
|
|
573
|
-
if(!this.events.focus)this.events.focus = useFocusEvent(this);
|
|
574
|
-
this.events.focus.onFocus(...callbacks);
|
|
575
|
-
return this;
|
|
576
|
-
}
|
|
332
|
+
// To Fix
|
|
333
|
+
// onKeysDown({keys=[],callback}={}){
|
|
334
|
+
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
335
|
+
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
336
|
+
// return this;
|
|
337
|
+
// }
|
|
338
|
+
// onSelect(...callbacks){
|
|
339
|
+
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
340
|
+
// this.events.clipboard.onSelect(...callbacks);
|
|
341
|
+
// return this;
|
|
342
|
+
// }
|
|
577
343
|
on(event_name,...callbacks){
|
|
578
344
|
if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
579
345
|
this.events.custom.on(event_name,...callbacks);
|
|
@@ -602,25 +368,19 @@ class ZikoUIElement {
|
|
|
602
368
|
this.observer.intersection.start();
|
|
603
369
|
return this;
|
|
604
370
|
}
|
|
605
|
-
setFullScreen(set = true, e) {
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
toggleFullScreen(e) {
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
}
|
|
619
|
-
toPdf(){
|
|
620
|
-
if(__ZikoPdf__){
|
|
621
|
-
|
|
622
|
-
}
|
|
623
|
-
return this;
|
|
624
|
-
}
|
|
371
|
+
// setFullScreen(set = true, e) {
|
|
372
|
+
// if(!this.element.requestFullscreen){
|
|
373
|
+
// console.error("Fullscreen API is not supported in this browser.");
|
|
374
|
+
// return this;
|
|
375
|
+
// }
|
|
376
|
+
// if (set) this.element.requestFullscreen(e);
|
|
377
|
+
// else globalThis.document.exitFullscreen();
|
|
378
|
+
// return this;
|
|
379
|
+
// }
|
|
380
|
+
// toggleFullScreen(e) {
|
|
381
|
+
// if (!globalThis.document.fullscreenElement) this.element.requestFullscreen(e);
|
|
382
|
+
// else globalThis.document.exitFullscreen();
|
|
383
|
+
// return this;
|
|
384
|
+
// }
|
|
625
385
|
}
|
|
626
386
|
export default ZikoUIElement;
|
|
@@ -1,82 +1,42 @@
|
|
|
1
|
-
import ZikoUIElement from "../ZikoUIElement";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class
|
|
11
|
-
constructor(){
|
|
12
|
-
super(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
class ZikoUISection extends ZikoUIElement{
|
|
27
|
-
constructor(){
|
|
28
|
-
super("section","Section");
|
|
29
|
-
this.style({position:"relative"})
|
|
30
|
-
}
|
|
31
|
-
get isSection(){
|
|
32
|
-
return true
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
class ZikoUIArticle extends ZikoUIElement{
|
|
36
|
-
constructor(){
|
|
37
|
-
super("article","Article");
|
|
38
|
-
}
|
|
39
|
-
get isArticle(){
|
|
40
|
-
return true
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
class ZikoUIAside extends ZikoUIElement{
|
|
44
|
-
constructor(){
|
|
45
|
-
super("aside","Aside");
|
|
46
|
-
}
|
|
47
|
-
get isAside(){
|
|
48
|
-
return true
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
class ZikoUIFooter extends ZikoUIElement{
|
|
52
|
-
constructor(){
|
|
53
|
-
super("footer","Footer");
|
|
54
|
-
this.element=document?.createElement("footer");
|
|
55
|
-
}
|
|
56
|
-
get isFooter(){
|
|
57
|
-
return true
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
const Section = (...ZikoUIElement) => new ZikoUISection().append(...ZikoUIElement);
|
|
61
|
-
const Article = (...ZikoUIElement) => new ZikoUIArticle().append(...ZikoUIElement);
|
|
62
|
-
const Main = (...ZikoUIElement) => new ZikoUIMain().append(...ZikoUIElement);
|
|
63
|
-
const Header = (...ZikoUIElement) => new ZikoUIHeader().append(...ZikoUIElement);
|
|
64
|
-
const Footer = (...ZikoUIElement) => new ZikoUIFooter().append(...ZikoUIElement);
|
|
65
|
-
const Nav = (...ZikoUIElement) => new ZikoUINav().append(...ZikoUIElement);
|
|
66
|
-
const Aside = (...ZikoUIElement) => new ZikoUIAside().append(...ZikoUIElement);
|
|
67
|
-
export{
|
|
68
|
-
Header,
|
|
1
|
+
import ZikoUIElement from "../ZikoUIElement.js";
|
|
2
|
+
const elements = ['Main', 'Header', 'Nav', 'Section', 'Article', 'Aside', 'Footer']
|
|
3
|
+
|
|
4
|
+
// Storage for Classes and component functions
|
|
5
|
+
const Classes = {};
|
|
6
|
+
const Components = {};
|
|
7
|
+
|
|
8
|
+
// Auto-generate Classes and factory functions
|
|
9
|
+
for (let i=0; i<elements.length; i++) {
|
|
10
|
+
Classes[`ZikoUI${elements[i]}`] = class extends ZikoUIElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(elements[i].toLowerCase());
|
|
13
|
+
this.style({ position: "relative" });
|
|
14
|
+
}
|
|
15
|
+
get [`is${elements[i]}`]() {
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
Components[elements[i]] = (...children) =>
|
|
21
|
+
new Classes[`ZikoUI${elements[i]}`]().append(...children);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const {
|
|
69
25
|
Main,
|
|
26
|
+
Header,
|
|
27
|
+
Nav,
|
|
70
28
|
Section,
|
|
71
29
|
Article,
|
|
72
30
|
Aside,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
31
|
+
Footer
|
|
32
|
+
} = Components;
|
|
33
|
+
|
|
34
|
+
export const {
|
|
76
35
|
ZikoUIMain,
|
|
36
|
+
ZikoUIHeader,
|
|
37
|
+
ZikoUINav,
|
|
77
38
|
ZikoUISection,
|
|
78
39
|
ZikoUIArticle,
|
|
79
40
|
ZikoUIAside,
|
|
80
|
-
ZikoUINav,
|
|
81
41
|
ZikoUIFooter
|
|
82
|
-
}
|
|
42
|
+
} = Classes;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { text } from "../elements/text/text.js";
|
|
2
|
+
export const DomMethods = {
|
|
3
|
+
append(...ele) {
|
|
4
|
+
__addItem__.call(this, "append", "push", ...ele);
|
|
5
|
+
return this;
|
|
6
|
+
},
|
|
7
|
+
prepend(...ele) {
|
|
8
|
+
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
9
|
+
return this;
|
|
10
|
+
},
|
|
11
|
+
insertAt(index, ...ele) {
|
|
12
|
+
if (index >= this.element.children.length) this.append(...ele);
|
|
13
|
+
else
|
|
14
|
+
for (let i = 0; i < ele.length; i++) {
|
|
15
|
+
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
16
|
+
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
17
|
+
this.items.splice(index, 0, ele[i]);
|
|
18
|
+
}
|
|
19
|
+
return this;
|
|
20
|
+
},
|
|
21
|
+
remove(...ele) {
|
|
22
|
+
const remove = (ele) => {
|
|
23
|
+
if (typeof ele === "number") ele = this.items[ele];
|
|
24
|
+
if (ele?.isZikoUIElement) this.element?.removeChild(ele.element);
|
|
25
|
+
this.items = this.items.filter((n) => n !== ele);
|
|
26
|
+
};
|
|
27
|
+
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
28
|
+
for (let i = 0; i < this.items.length; i++)
|
|
29
|
+
Object.assign(this, { [[i]]: this.items[i] });
|
|
30
|
+
// Remove from item
|
|
31
|
+
return this;
|
|
32
|
+
},
|
|
33
|
+
clear(){
|
|
34
|
+
this?.items?.forEach(n=>n.unrender());
|
|
35
|
+
this.element.innerHTML = "";
|
|
36
|
+
return this;
|
|
37
|
+
},
|
|
38
|
+
render(target = this.target) {
|
|
39
|
+
if(this.isBody)return ;
|
|
40
|
+
if(target?.isZikoUIElement)target=target.element;
|
|
41
|
+
this.target=target;
|
|
42
|
+
this.target?.appendChild(this.element);
|
|
43
|
+
return this;
|
|
44
|
+
},
|
|
45
|
+
unrender(){
|
|
46
|
+
if(this.cache.parent)this.cache.parent.remove(this);
|
|
47
|
+
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
48
|
+
return this;
|
|
49
|
+
},
|
|
50
|
+
renderAfter(t = 1) {
|
|
51
|
+
setTimeout(() => this.render(), t);
|
|
52
|
+
return this;
|
|
53
|
+
},
|
|
54
|
+
unrenderAfter(t = 1) {
|
|
55
|
+
setTimeout(() => this.unrender(), t);
|
|
56
|
+
return this;
|
|
57
|
+
},
|
|
58
|
+
after(ui){
|
|
59
|
+
if(ui?.isZikoUIElement) ui=ui.element;
|
|
60
|
+
this.element?.after(ui)
|
|
61
|
+
return this;
|
|
62
|
+
},
|
|
63
|
+
before(ui){
|
|
64
|
+
if(ui?.isZikoUIElement) ui=ui.element;
|
|
65
|
+
this.element?.before(ui)
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
function __addItem__(adder, pusher, ...ele) {
|
|
72
|
+
if (this.cache.isFrozzen) {
|
|
73
|
+
console.warn("You can't append new item to frozzen element");
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
for (let i = 0; i < ele.length; i++) {
|
|
77
|
+
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
78
|
+
if (
|
|
79
|
+
typeof globalThis?.Node === "function" &&
|
|
80
|
+
ele[i] instanceof globalThis?.Node
|
|
81
|
+
)
|
|
82
|
+
ele[i] = new this.constructor(ele[i]);
|
|
83
|
+
if (ele[i]?.isZikoUIElement) {
|
|
84
|
+
ele[i].cache.parent = this;
|
|
85
|
+
this.element[adder](ele[i].element);
|
|
86
|
+
ele[i].target = this.element;
|
|
87
|
+
this.items[pusher](ele[i]);
|
|
88
|
+
} else if (ele[i] instanceof Object) {
|
|
89
|
+
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
90
|
+
if (ele[i]?.attr) {
|
|
91
|
+
Object.entries(ele[i].attr).forEach((n) =>
|
|
92
|
+
this.setAttr("" + n[0], n[1]),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
this.maintain();
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Events } from "../../events/__Events__";
|
|
2
|
+
import {
|
|
3
|
+
bindPointerEvent,
|
|
4
|
+
bindMouseEvent,
|
|
5
|
+
bindKeyEvent,
|
|
6
|
+
bindClickEvent,
|
|
7
|
+
bindDragEvent,
|
|
8
|
+
bindClipboardEvent,
|
|
9
|
+
bindFocusEvent,
|
|
10
|
+
bindWheelEvent
|
|
11
|
+
} from "../../events/index.js";
|
|
12
|
+
|
|
13
|
+
const binderMap = {
|
|
14
|
+
ptr: bindPointerEvent,
|
|
15
|
+
mouse : bindMouseEvent,
|
|
16
|
+
key: bindKeyEvent,
|
|
17
|
+
click : bindClickEvent,
|
|
18
|
+
drag : bindDragEvent,
|
|
19
|
+
clipboard : bindClipboardEvent,
|
|
20
|
+
focus : bindFocusEvent,
|
|
21
|
+
wheel : bindWheelEvent
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const EventsMethodes = {};
|
|
25
|
+
|
|
26
|
+
Object.entries(Events).forEach(([name, eventList]) => {
|
|
27
|
+
eventList.forEach(event => {
|
|
28
|
+
const methodName = `on${event}`;
|
|
29
|
+
EventsMethodes[methodName] = function (...callbacks) {
|
|
30
|
+
if (!this.events[name]) this.events[name] = binderMap[name.toLowerCase()](this);
|
|
31
|
+
this.events[name][methodName](...callbacks);
|
|
32
|
+
return this;
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
export {EventsMethodes}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const IndexingMethods = {
|
|
2
|
+
at(index) {
|
|
3
|
+
return this.items.at(index);
|
|
4
|
+
},
|
|
5
|
+
forEach(callback) {
|
|
6
|
+
this.items.forEach(callback);
|
|
7
|
+
return this;
|
|
8
|
+
},
|
|
9
|
+
map(callback) {
|
|
10
|
+
return this.items.map(callback);
|
|
11
|
+
},
|
|
12
|
+
find(condition) {
|
|
13
|
+
return this.items.filter(condition);
|
|
14
|
+
},
|
|
15
|
+
};
|
package/src/use/index.js
ADDED