ziko 0.67.0 → 0.68.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 +347 -698
- package/dist/ziko.js +347 -698
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +337 -684
- package/package.json +1 -1
- package/src/events/controller/index.js +58 -0
- package/src/events/custom-events-registry/click-away.js +1 -0
- package/src/events/custom-events-registry/swipe.js +1 -1
- package/src/events/index.js +3 -3
- package/src/events/mixins/click.js +23 -0
- package/src/events/mixins/index.js +5 -0
- package/src/events/mixins/key.js +24 -0
- package/src/events/mixins/ptr.js +44 -0
- package/src/events/mixins/swipe.js +30 -0
- package/src/events/mixins/utils/index.js +17 -0
- package/src/events/mixins/view.js +24 -0
- package/src/{exp-events → events-dep}/custom-events-registry/click-away.js +0 -1
- package/src/events-dep/index.js +3 -0
- package/src/ui/constructors/UIElement.js +22 -10
- package/src/ui/constructors/mixins/attrs.js +19 -5
- package/src/ui/constructors/mixins/dom.js +53 -1
- package/src/ui/constructors/mixins/index.js +2 -3
- package/src/exp-events/controller/index.js +0 -41
- package/src/exp-events/details-setter/index.js +0 -4
- package/src/exp-events/details-setter/key.js +0 -14
- package/src/exp-events/details-setter/mouse.js +0 -35
- package/src/exp-events/details-setter/pointer.js +0 -35
- package/src/exp-events/details-setter/touch.js +0 -37
- package/src/exp-events/index.js +0 -1
- package/src/ui/constructors/mixins/events.js +0 -57
- package/src/ui/constructors/mixins/utils/index.js +0 -64
- /package/src/{events → events-dep}/binders/coordinates-based-event.js +0 -0
- /package/src/{events → events-dep}/binders/custom-event.js +0 -0
- /package/src/{events → events-dep}/binders/index.js +0 -0
- /package/src/{exp-events → events-dep}/custom-events-registry/index.js +0 -0
- /package/src/{exp-events → events-dep}/custom-events-registry/swipe.js +0 -0
- /package/src/{exp-events → events-dep}/custom-events-registry/view.js +0 -0
- /package/src/{events → events-dep}/customizers/normalise-coordinates.js +0 -0
- /package/src/{events → events-dep}/details-setter/index.js +0 -0
- /package/src/{events → events-dep}/details-setter/key.js +0 -0
- /package/src/{events → events-dep}/details-setter/mouse.js +0 -0
- /package/src/{events → events-dep}/details-setter/pointer.js +0 -0
- /package/src/{events → events-dep}/details-setter/touch.js +0 -0
- /package/src/{events → events-dep}/events-map/index.js +0 -0
- /package/src/{events → events-dep}/types/__Shared__.d.ts +0 -0
- /package/src/{events → events-dep}/types/clipboard.d.ts +0 -0
- /package/src/{events → events-dep}/types/focus.d.ts +0 -0
- /package/src/{events → events-dep}/types/pointer.d.ts +0 -0
- /package/src/{events → events-dep}/utils.js +0 -0
- /package/src/{events → events-dep}/ziko-event.js +0 -0
package/dist/ziko.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Wed Feb 25 2026 12:45:41 GMT+0000 (UTC)
|
|
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
|
|
@@ -2394,89 +2394,14 @@ const isStateGetter = (arg) => {
|
|
|
2394
2394
|
return typeof arg === 'function' && arg?.()?.isStateGetter?.();
|
|
2395
2395
|
};
|
|
2396
2396
|
|
|
2397
|
-
const camel2hyphencase
|
|
2397
|
+
const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
2398
2398
|
|
|
2399
|
-
const is_camelcase
|
|
2399
|
+
const is_camelcase = (text = '') =>{
|
|
2400
2400
|
if (text.length === 0) return false;
|
|
2401
2401
|
const camelCasePattern = /^[a-z][a-zA-Z0-9]*$/;
|
|
2402
2402
|
return camelCasePattern.test(text);
|
|
2403
2403
|
};
|
|
2404
2404
|
|
|
2405
|
-
class ZikoUIText extends UINode {
|
|
2406
|
-
constructor(...value) {
|
|
2407
|
-
super("span", "text", false, ...value);
|
|
2408
|
-
this.element = globalThis?.document?.createTextNode(...value);
|
|
2409
|
-
}
|
|
2410
|
-
isText(){
|
|
2411
|
-
return true
|
|
2412
|
-
}
|
|
2413
|
-
}
|
|
2414
|
-
const text = (...str) => new ZikoUIText(...str);
|
|
2415
|
-
|
|
2416
|
-
async function __addItem__(adder, pusher, ...ele) {
|
|
2417
|
-
if (this.cache.isFrozzen) {
|
|
2418
|
-
console.warn("You can't append new item to frozzen element");
|
|
2419
|
-
return this;
|
|
2420
|
-
}
|
|
2421
|
-
for (let i = 0; i < ele.length; i++) {
|
|
2422
|
-
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
2423
|
-
// Fix Items Latter
|
|
2424
|
-
if (ele[i] instanceof Function) {
|
|
2425
|
-
const getter = ele[i]();
|
|
2426
|
-
if (getter.isStateGetter) {
|
|
2427
|
-
ele[i] = text(getter.value);
|
|
2428
|
-
getter._subscribe(
|
|
2429
|
-
(newValue) => (ele[i].element.textContent = newValue),
|
|
2430
|
-
ele[i]
|
|
2431
|
-
);
|
|
2432
|
-
// this.element.appendChild(textNode);
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
|
|
2436
|
-
if (ele[i]?.isUINode) {
|
|
2437
|
-
ele[i].cache.parent = this;
|
|
2438
|
-
this.element?.[adder](ele[i].element);
|
|
2439
|
-
ele[i].target = this.element;
|
|
2440
|
-
this.items[pusher](ele[i]);
|
|
2441
|
-
}
|
|
2442
|
-
else if(ele[i] instanceof Promise){
|
|
2443
|
-
const UIEle = await ele[i];
|
|
2444
|
-
UIEle.cache.parent = this;
|
|
2445
|
-
this.element?.[adder](UIEle.element);
|
|
2446
|
-
UIEle.target = this.element;
|
|
2447
|
-
this.items[pusher](UIEle);
|
|
2448
|
-
}
|
|
2449
|
-
else if (ele[i] instanceof Object) {
|
|
2450
|
-
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
2451
|
-
if (ele[i]?.attr) {
|
|
2452
|
-
Object.entries(ele[i].attr).forEach((n) =>
|
|
2453
|
-
this.setAttr("" + n[0], n[1]),
|
|
2454
|
-
);
|
|
2455
|
-
}
|
|
2456
|
-
}
|
|
2457
|
-
}
|
|
2458
|
-
this.maintain();
|
|
2459
|
-
return this;
|
|
2460
|
-
}
|
|
2461
|
-
function _set_attrs_(name, value){
|
|
2462
|
-
if(globalThis.SVGAElement && this.element instanceof globalThis.SVGAElement) name = is_camelcase$1(name) ? camel2hyphencase$1(name) : name;
|
|
2463
|
-
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
2464
|
-
if(isStateGetter(value)){
|
|
2465
|
-
const getter = value();
|
|
2466
|
-
getter._subscribe(
|
|
2467
|
-
(newValue) => this.element?.setAttribute(name, newValue),
|
|
2468
|
-
this
|
|
2469
|
-
);
|
|
2470
|
-
}
|
|
2471
|
-
else this.element?.setAttribute(name, value);
|
|
2472
|
-
Object.assign(this.cache.attributes, {[name]:value});
|
|
2473
|
-
}
|
|
2474
|
-
|
|
2475
|
-
// import {
|
|
2476
|
-
// is_camelcase,
|
|
2477
|
-
// camel2hyphencase
|
|
2478
|
-
// } from '../../data/string/index.js'
|
|
2479
|
-
|
|
2480
2405
|
function setAttr(name, value) {
|
|
2481
2406
|
if(name instanceof Object){
|
|
2482
2407
|
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
@@ -2502,16 +2427,49 @@ function getAttr(name){
|
|
|
2502
2427
|
function setContentEditable(bool = true) {
|
|
2503
2428
|
this.setAttr("contenteditable", bool);
|
|
2504
2429
|
return this;
|
|
2430
|
+
}
|
|
2431
|
+
|
|
2432
|
+
|
|
2433
|
+
function _set_attrs_(name, value){
|
|
2434
|
+
if(globalThis.SVGAElement && this.element instanceof globalThis.SVGAElement) name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
2435
|
+
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
2436
|
+
if(isStateGetter(value)){
|
|
2437
|
+
const getter = value();
|
|
2438
|
+
getter._subscribe(
|
|
2439
|
+
(newValue) => this.element?.setAttribute(name, newValue),
|
|
2440
|
+
this
|
|
2441
|
+
);
|
|
2442
|
+
}
|
|
2443
|
+
else this.element?.setAttribute(name, value);
|
|
2444
|
+
Object.assign(this.cache.attributes, {[name]:value});
|
|
2505
2445
|
}
|
|
2506
2446
|
|
|
2507
2447
|
var AttrsMethods = /*#__PURE__*/Object.freeze({
|
|
2508
2448
|
__proto__: null,
|
|
2449
|
+
_set_attrs_: _set_attrs_,
|
|
2509
2450
|
getAttr: getAttr,
|
|
2510
2451
|
removeAttr: removeAttr,
|
|
2511
2452
|
setAttr: setAttr,
|
|
2512
2453
|
setContentEditable: setContentEditable
|
|
2513
2454
|
});
|
|
2514
2455
|
|
|
2456
|
+
class ZikoUIText extends UINode {
|
|
2457
|
+
constructor(...value) {
|
|
2458
|
+
super("span", "text", false, ...value);
|
|
2459
|
+
this.element = globalThis?.document?.createTextNode(...value);
|
|
2460
|
+
}
|
|
2461
|
+
isText(){
|
|
2462
|
+
return true
|
|
2463
|
+
}
|
|
2464
|
+
}
|
|
2465
|
+
const text = (...str) => new ZikoUIText(...str);
|
|
2466
|
+
|
|
2467
|
+
// import { isStateGetter } from "../../../hooks/use-state.js";
|
|
2468
|
+
// import {
|
|
2469
|
+
// is_camelcase,
|
|
2470
|
+
// camel2hyphencase
|
|
2471
|
+
// } from '../../../data/string/index.js';
|
|
2472
|
+
|
|
2515
2473
|
function append(...ele) {
|
|
2516
2474
|
__addItem__.call(this, "append", "push", ...ele);
|
|
2517
2475
|
return this;
|
|
@@ -2563,10 +2521,60 @@ function before(ui){
|
|
|
2563
2521
|
if(ui?.isUIElement) ui=ui.element;
|
|
2564
2522
|
this.element?.before(ui);
|
|
2565
2523
|
return this;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
|
|
2527
|
+
|
|
2528
|
+
|
|
2529
|
+
async function __addItem__(adder, pusher, ...ele) {
|
|
2530
|
+
if (this.cache.isFrozzen) {
|
|
2531
|
+
console.warn("You can't append new item to frozzen element");
|
|
2532
|
+
return this;
|
|
2533
|
+
}
|
|
2534
|
+
for (let i = 0; i < ele.length; i++) {
|
|
2535
|
+
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
2536
|
+
// Fix Items Latter
|
|
2537
|
+
if (ele[i] instanceof Function) {
|
|
2538
|
+
const getter = ele[i]();
|
|
2539
|
+
if (getter.isStateGetter) {
|
|
2540
|
+
ele[i] = text(getter.value);
|
|
2541
|
+
getter._subscribe(
|
|
2542
|
+
(newValue) => (ele[i].element.textContent = newValue),
|
|
2543
|
+
ele[i]
|
|
2544
|
+
);
|
|
2545
|
+
// this.element.appendChild(textNode);
|
|
2546
|
+
}
|
|
2547
|
+
}
|
|
2548
|
+
if (typeof globalThis?.Node === "function" && ele[i] instanceof globalThis?.Node) ele[i] = new this.constructor(ele[i]);
|
|
2549
|
+
if (ele[i]?.isUINode) {
|
|
2550
|
+
ele[i].cache.parent = this;
|
|
2551
|
+
this.element?.[adder](ele[i].element);
|
|
2552
|
+
ele[i].target = this.element;
|
|
2553
|
+
this.items[pusher](ele[i]);
|
|
2554
|
+
}
|
|
2555
|
+
else if(ele[i] instanceof Promise){
|
|
2556
|
+
const UIEle = await ele[i];
|
|
2557
|
+
UIEle.cache.parent = this;
|
|
2558
|
+
this.element?.[adder](UIEle.element);
|
|
2559
|
+
UIEle.target = this.element;
|
|
2560
|
+
this.items[pusher](UIEle);
|
|
2561
|
+
}
|
|
2562
|
+
else if (ele[i] instanceof Object) {
|
|
2563
|
+
if (ele[i]?.style) this.style(ele[i]?.style);
|
|
2564
|
+
if (ele[i]?.attr) {
|
|
2565
|
+
Object.entries(ele[i].attr).forEach((n) =>
|
|
2566
|
+
this.setAttr("" + n[0], n[1]),
|
|
2567
|
+
);
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
this.maintain();
|
|
2572
|
+
return this;
|
|
2566
2573
|
}
|
|
2567
2574
|
|
|
2568
2575
|
var DomMethods = /*#__PURE__*/Object.freeze({
|
|
2569
2576
|
__proto__: null,
|
|
2577
|
+
__addItem__: __addItem__,
|
|
2570
2578
|
after: after,
|
|
2571
2579
|
append: append,
|
|
2572
2580
|
before: before,
|
|
@@ -2577,355 +2585,127 @@ var DomMethods = /*#__PURE__*/Object.freeze({
|
|
|
2577
2585
|
replaceElementWith: replaceElementWith
|
|
2578
2586
|
});
|
|
2579
2587
|
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
'Click',
|
|
2583
|
-
'DblClick',
|
|
2584
|
-
'ClickAway'
|
|
2585
|
-
],
|
|
2586
|
-
'Ptr' : [
|
|
2587
|
-
'PtrMove',
|
|
2588
|
-
'PtrDown',
|
|
2589
|
-
'PtrUp',
|
|
2590
|
-
'PtrLeave',
|
|
2591
|
-
'PtrEnter',
|
|
2592
|
-
'PtrOut',
|
|
2593
|
-
'PtrCancel'
|
|
2594
|
-
],
|
|
2595
|
-
'Mouse' : [
|
|
2596
|
-
'MouseMove',
|
|
2597
|
-
'MouseDown',
|
|
2598
|
-
'MouseUp',
|
|
2599
|
-
'MouseEnter',
|
|
2600
|
-
'MouseLeave',
|
|
2601
|
-
'MouseOut'
|
|
2602
|
-
],
|
|
2603
|
-
// 'Touch' : [],
|
|
2604
|
-
'Key' : [
|
|
2605
|
-
'KeyDown',
|
|
2606
|
-
'KeyPress',
|
|
2607
|
-
'KeyUp'
|
|
2608
|
-
],
|
|
2609
|
-
'Clipboard':[
|
|
2610
|
-
'Copy',
|
|
2611
|
-
'Cut',
|
|
2612
|
-
'Paste'
|
|
2613
|
-
],
|
|
2614
|
-
'Focus':[
|
|
2615
|
-
'focus',
|
|
2616
|
-
'blur'
|
|
2617
|
-
],
|
|
2618
|
-
'Drag':[
|
|
2619
|
-
"Drag",
|
|
2620
|
-
"DragStart",
|
|
2621
|
-
"DragEnd",
|
|
2622
|
-
"Drop"
|
|
2623
|
-
],
|
|
2624
|
-
'Wheel': [
|
|
2625
|
-
'Wheel'
|
|
2626
|
-
],
|
|
2627
|
-
// 'Media':[
|
|
2628
|
-
|
|
2629
|
-
// ],
|
|
2630
|
-
// 'Hash':[
|
|
2631
|
-
// "HashChange"
|
|
2632
|
-
// ]
|
|
2633
|
-
|
|
2634
|
-
'View':[
|
|
2635
|
-
'EnterView',
|
|
2636
|
-
'ExitView',
|
|
2637
|
-
'ResizeView'
|
|
2638
|
-
],
|
|
2639
|
-
'Swipe':[
|
|
2640
|
-
'SwipeLeft',
|
|
2641
|
-
'SwipeUp',
|
|
2642
|
-
'SwipeRight',
|
|
2643
|
-
'SwipeDown'
|
|
2644
|
-
]
|
|
2645
|
-
};
|
|
2646
|
-
|
|
2647
|
-
function event_controller(e, event_name, details_setter, customizer) {
|
|
2648
|
-
this.cache.currentEvent = event_name;
|
|
2649
|
-
this.cache.event = e;
|
|
2650
|
-
|
|
2651
|
-
details_setter?.call(this);
|
|
2652
|
-
if (customizer?.hasOwnProperty('prototype')) customizer?.call(this);
|
|
2653
|
-
else customizer?.call(null, this);
|
|
2654
|
-
|
|
2655
|
-
if (this.cache.preventDefault[event_name]) e.preventDefault();
|
|
2656
|
-
if (this.cache.stopPropagation[event_name]) e.stopPropagation();
|
|
2657
|
-
if (this.cache.stopImmediatePropagation[event_name]) e.stopImmediatePropagation();
|
|
2658
|
-
|
|
2659
|
-
// Call the single callback if it exists
|
|
2660
|
-
this.cache.callbacks[event_name]?.(this);
|
|
2588
|
+
function at(index) {
|
|
2589
|
+
return this.items.at(index);
|
|
2661
2590
|
}
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
? Object.keys(this.cache.paused)
|
|
2666
|
-
: events;
|
|
2667
|
-
keys.forEach(key => {
|
|
2668
|
-
if (!this.cache.paused.hasOwnProperty(key)) return;
|
|
2669
|
-
this.targetElement?.[method](
|
|
2670
|
-
key,
|
|
2671
|
-
this.cache.__controllers__[key],
|
|
2672
|
-
this.cache.options[key]
|
|
2673
|
-
);
|
|
2674
|
-
this.cache.paused[key] = method === 'removeEventListener';
|
|
2675
|
-
});
|
|
2676
|
-
return this;
|
|
2591
|
+
function forEach(callback) {
|
|
2592
|
+
this.items.forEach(callback);
|
|
2593
|
+
return this;
|
|
2677
2594
|
}
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
class ZikoEvent {
|
|
2684
|
-
constructor(signature, target = null, Events = [], details_setter, customizer){
|
|
2685
|
-
this.target = target;
|
|
2686
|
-
this.cache = {
|
|
2687
|
-
signature,
|
|
2688
|
-
currentEvent : null,
|
|
2689
|
-
event: null,
|
|
2690
|
-
options : {},
|
|
2691
|
-
preventDefault : {},
|
|
2692
|
-
stopPropagation : {},
|
|
2693
|
-
stopImmediatePropagation : {},
|
|
2694
|
-
paused : {},
|
|
2695
|
-
callbacks : {},
|
|
2696
|
-
__controllers__:{}
|
|
2697
|
-
};
|
|
2698
|
-
if (Events) this._register_events(Events, details_setter, customizer);
|
|
2699
|
-
}
|
|
2700
|
-
_register_events(Events, details_setter, customizer, REGISTER_METHODES = true) {
|
|
2701
|
-
const events = Events?.map(n => getEvent(n));
|
|
2702
|
-
events?.forEach((event, i) => {
|
|
2703
|
-
this.cache.preventDefault[event] = false;
|
|
2704
|
-
this.cache.options[event] = {};
|
|
2705
|
-
this.cache.paused[event] = false;
|
|
2706
|
-
this.cache.__controllers__[event] = (e) =>
|
|
2707
|
-
event_controller.call(this, e, event, details_setter, customizer);
|
|
2708
|
-
if (REGISTER_METHODES) {
|
|
2709
|
-
this[`on${Events[i]}`] = (callback) =>
|
|
2710
|
-
this.__onEvent(event, this.cache.options[event], {}, callback);
|
|
2711
|
-
}
|
|
2712
|
-
});
|
|
2713
|
-
return this;
|
|
2714
|
-
}
|
|
2715
|
-
__onEvent(event, options, dispose, callback) {
|
|
2716
|
-
if (!callback) return this;
|
|
2717
|
-
this.cache.callbacks[event] = callback;
|
|
2718
|
-
this.__handle(event, this.cache.__controllers__[event], options, dispose);
|
|
2719
|
-
return this;
|
|
2720
|
-
}
|
|
2721
|
-
get targetElement(){
|
|
2722
|
-
return this.target?.element;
|
|
2723
|
-
}
|
|
2724
|
-
get isParent(){
|
|
2725
|
-
return this.target?.element === this.event?.srcElement;
|
|
2726
|
-
}
|
|
2727
|
-
get item(){
|
|
2728
|
-
return this.target.find(n => n.element == this.event?.srcElement)?.[0];
|
|
2729
|
-
}
|
|
2730
|
-
get currentEvent(){
|
|
2731
|
-
return this.cache.currentEvent;
|
|
2732
|
-
}
|
|
2733
|
-
get event(){
|
|
2734
|
-
return this.cache.event;
|
|
2735
|
-
}
|
|
2736
|
-
get detail(){
|
|
2737
|
-
return this.cache.event.detail
|
|
2738
|
-
}
|
|
2739
|
-
setTarget(UI){
|
|
2740
|
-
this.target = UI;
|
|
2741
|
-
return this;
|
|
2742
|
-
}
|
|
2743
|
-
__handle(event, handler, options){
|
|
2744
|
-
this.targetElement?.addEventListener(event, handler, options);
|
|
2745
|
-
return this;
|
|
2746
|
-
}
|
|
2747
|
-
#override(method, ...events) {
|
|
2748
|
-
const keys = events.length === 0 ? Object.keys(this.cache[method]) : events;
|
|
2749
|
-
keys.forEach(e => {
|
|
2750
|
-
if (this.cache[method].hasOwnProperty(e)) this.cache[method][e] = true;
|
|
2751
|
-
});
|
|
2752
|
-
return this;
|
|
2753
|
-
}
|
|
2754
|
-
preventDefault(...events) {
|
|
2755
|
-
return this.#override('preventDefault', ...events);
|
|
2756
|
-
}
|
|
2757
|
-
stopPropagation(...events) {
|
|
2758
|
-
return this.#override('stopPropagation', ...events);
|
|
2759
|
-
}
|
|
2760
|
-
stopImmediatePropagation(...events) {
|
|
2761
|
-
return this.#override('stopImmediatePropagation', ...events);
|
|
2762
|
-
}
|
|
2763
|
-
setEventOptions(event, options){
|
|
2764
|
-
const evt = getEvent(event);
|
|
2765
|
-
this.pause();
|
|
2766
|
-
Object.assign(this.cache.options[evt], options);
|
|
2767
|
-
this.resume();
|
|
2768
|
-
return this;
|
|
2769
|
-
}
|
|
2770
|
-
pause(...events) {
|
|
2771
|
-
return toggle_event_listener.call(this, 'removeEventListener', ...events)
|
|
2772
|
-
}
|
|
2773
|
-
resume(...events) {
|
|
2774
|
-
return toggle_event_listener.call(this, 'addEventListener', ...events);
|
|
2775
|
-
}
|
|
2776
|
-
dispose(){
|
|
2777
|
-
this.pause();
|
|
2778
|
-
this.target.events[this.cache.signature] = null;
|
|
2779
|
-
return this;
|
|
2780
|
-
}
|
|
2781
|
-
}
|
|
2782
|
-
|
|
2783
|
-
function key_details_setter(){
|
|
2784
|
-
switch(this.currentEvent){
|
|
2785
|
-
case "keydown" : {
|
|
2786
|
-
this.kd = this.event.key;
|
|
2787
|
-
} break;
|
|
2788
|
-
case "keypress" : {
|
|
2789
|
-
this.kp = this.event.key;
|
|
2790
|
-
} break;
|
|
2791
|
-
case "keyup" : {
|
|
2792
|
-
this.ku = this.event.key;
|
|
2793
|
-
} break;
|
|
2794
|
-
|
|
2795
|
-
}
|
|
2595
|
+
function map(callback) {
|
|
2596
|
+
return this.items.map(callback);
|
|
2597
|
+
}
|
|
2598
|
+
function find(condition) {
|
|
2599
|
+
return this.items.filter(condition);
|
|
2796
2600
|
}
|
|
2797
2601
|
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
const w = this.targetElement.clientWidth;
|
|
2806
|
-
const h = this.targetElement.clientHeight;
|
|
2807
|
-
x = +((x / w) * 2 - 1).toFixed(8);
|
|
2808
|
-
y = +((y / h) * -2 + 1).toFixed(8);
|
|
2809
|
-
}
|
|
2810
|
-
switch (this.currentEvent) {
|
|
2811
|
-
|
|
2812
|
-
case "pointerdown":
|
|
2813
|
-
this.dx = x;
|
|
2814
|
-
this.dy = y;
|
|
2815
|
-
this.isDown = true;
|
|
2816
|
-
break;
|
|
2817
|
-
|
|
2818
|
-
case "pointermove":
|
|
2819
|
-
this.mx = x;
|
|
2820
|
-
this.my = y;
|
|
2821
|
-
this.isMoving = true;
|
|
2822
|
-
break;
|
|
2823
|
-
|
|
2824
|
-
case "pointerup":
|
|
2825
|
-
this.ux = x;
|
|
2826
|
-
this.uy = y;
|
|
2827
|
-
this.isDown = false;
|
|
2828
|
-
this.isMoving = false;
|
|
2829
|
-
break;
|
|
2830
|
-
}
|
|
2831
|
-
}
|
|
2602
|
+
var IndexingMethods = /*#__PURE__*/Object.freeze({
|
|
2603
|
+
__proto__: null,
|
|
2604
|
+
at: at,
|
|
2605
|
+
find: find,
|
|
2606
|
+
forEach: forEach,
|
|
2607
|
+
map: map
|
|
2608
|
+
});
|
|
2832
2609
|
|
|
2833
|
-
function
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2610
|
+
function style$1(styles){
|
|
2611
|
+
if(!this.element?.style) return this;
|
|
2612
|
+
for(let key in styles){
|
|
2613
|
+
const value = styles[key];
|
|
2614
|
+
if(isStateGetter(value)){
|
|
2615
|
+
const getter = value();
|
|
2616
|
+
Object.assign(this.element.style, {[key] : getter.value});
|
|
2617
|
+
getter._subscribe(
|
|
2618
|
+
(newValue) => {
|
|
2619
|
+
console.log({newValue});
|
|
2620
|
+
Object.assign(this.element.style, {[key] : newValue});
|
|
2621
|
+
},
|
|
2622
|
+
// this
|
|
2623
|
+
);
|
|
2624
|
+
}
|
|
2625
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2844
2626
|
}
|
|
2627
|
+
return this;
|
|
2628
|
+
}
|
|
2629
|
+
function size(width, height){
|
|
2630
|
+
return this.style({width, height})
|
|
2631
|
+
}
|
|
2632
|
+
function hide(){
|
|
2845
2633
|
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
case "mousedown":
|
|
2849
|
-
this.dx = x;
|
|
2850
|
-
this.dy = y;
|
|
2851
|
-
this.isDown = true;
|
|
2852
|
-
break;
|
|
2853
|
-
|
|
2854
|
-
case "mousemove":
|
|
2855
|
-
this.mx = x;
|
|
2856
|
-
this.my = y;
|
|
2857
|
-
this.isMoving = true;
|
|
2858
|
-
break;
|
|
2634
|
+
}
|
|
2635
|
+
function show(){
|
|
2859
2636
|
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
this.isMoving = false;
|
|
2865
|
-
break;
|
|
2866
|
-
}
|
|
2637
|
+
}
|
|
2638
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2639
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2640
|
+
return this;
|
|
2867
2641
|
}
|
|
2868
2642
|
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
let y = touch.clientY - rect.top;
|
|
2878
|
-
|
|
2879
|
-
if(this.cache.useNormalisedCoordinates){
|
|
2880
|
-
const w = this.targetElement.clientWidth;
|
|
2881
|
-
const h = this.targetElement.clientHeight;
|
|
2882
|
-
x = +((x / w) * 2 - 1).toFixed(8);
|
|
2883
|
-
y = +((y / h) * -2 + 1).toFixed(8);
|
|
2884
|
-
}
|
|
2885
|
-
|
|
2886
|
-
switch (this.currentEvent) {
|
|
2887
|
-
case "touchstart":
|
|
2888
|
-
this.dx = x;
|
|
2889
|
-
this.dy = y;
|
|
2890
|
-
this.isDown = true;
|
|
2891
|
-
break;
|
|
2892
|
-
|
|
2893
|
-
case "touchmove":
|
|
2894
|
-
this.mx = x;
|
|
2895
|
-
this.my = y;
|
|
2896
|
-
this.isMoving = true;
|
|
2897
|
-
break;
|
|
2898
|
-
|
|
2899
|
-
case "touchend":
|
|
2900
|
-
this.ux = x;
|
|
2901
|
-
this.uy = y;
|
|
2902
|
-
this.isDown = false;
|
|
2903
|
-
break;
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2643
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2644
|
+
__proto__: null,
|
|
2645
|
+
animate: animate,
|
|
2646
|
+
hide: hide,
|
|
2647
|
+
show: show,
|
|
2648
|
+
size: size,
|
|
2649
|
+
style: style$1
|
|
2650
|
+
});
|
|
2906
2651
|
|
|
2907
|
-
class
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2652
|
+
class EventController {
|
|
2653
|
+
constructor(target, category){
|
|
2654
|
+
this.cache = {
|
|
2655
|
+
category,
|
|
2656
|
+
target,
|
|
2657
|
+
listeners : {},
|
|
2658
|
+
currentEvent : null,
|
|
2659
|
+
event : null,
|
|
2660
|
+
customEvents : new Set()
|
|
2661
|
+
};
|
|
2662
|
+
}
|
|
2663
|
+
get event(){
|
|
2664
|
+
return this.cache.event
|
|
2665
|
+
}
|
|
2666
|
+
get element(){
|
|
2667
|
+
return this.cache.target.element;
|
|
2668
|
+
}
|
|
2669
|
+
get currentEvent(){
|
|
2670
|
+
return this.cache.currentEvent;
|
|
2671
|
+
}
|
|
2672
|
+
addListener(event_name, callback, {preventDefault = false, paused = false} = {}){
|
|
2673
|
+
this.cache.listeners[event_name] = {
|
|
2674
|
+
callback : e =>{
|
|
2675
|
+
this.cache.event = e;
|
|
2676
|
+
if(this.cache.listeners[event_name].preventDefault) e.preventDefault();
|
|
2677
|
+
if(!this.cache.listeners[event_name].paused) {
|
|
2678
|
+
this.cache.currentEvent = event_name;
|
|
2679
|
+
callback.call(this, this);
|
|
2680
|
+
}
|
|
2681
|
+
},
|
|
2682
|
+
preventDefault,
|
|
2683
|
+
paused,
|
|
2684
|
+
};
|
|
2685
|
+
this.element.addEventListener(event_name, this.cache.listeners[event_name].callback);
|
|
2686
|
+
return this;
|
|
2687
|
+
}
|
|
2688
|
+
removeListener(event_name){
|
|
2689
|
+
this.element.removeEventListener(event_name, this.cache.listeners[event_name].callback);
|
|
2690
|
+
return this;
|
|
2691
|
+
}
|
|
2692
|
+
pause(event_name){
|
|
2693
|
+
this.cache.listeners[event_name].paused = true;
|
|
2694
|
+
return this;
|
|
2695
|
+
}
|
|
2696
|
+
resume(event_name){
|
|
2697
|
+
this.cache.listeners[event_name].paused = false;
|
|
2698
|
+
return this;
|
|
2699
|
+
}
|
|
2700
|
+
preventDefault(event_name){
|
|
2701
|
+
// if(!event_name)
|
|
2702
|
+
this.cache.listeners[event_name].preventDefault = true;
|
|
2703
|
+
return this;
|
|
2704
|
+
}
|
|
2705
|
+
useDefault(event_name){
|
|
2706
|
+
this.cache.listeners[event_name].preventDefault = false;
|
|
2707
|
+
return this;
|
|
2708
|
+
}
|
|
2929
2709
|
}
|
|
2930
2710
|
|
|
2931
2711
|
class ClickAwayEvent extends Event {
|
|
@@ -2937,6 +2717,7 @@ class ClickAwayEvent extends Event {
|
|
|
2937
2717
|
}
|
|
2938
2718
|
|
|
2939
2719
|
function register_click_away_event(element) {
|
|
2720
|
+
// console.log(element)
|
|
2940
2721
|
function handler(e) {
|
|
2941
2722
|
if (!element.contains(e.target)) {
|
|
2942
2723
|
const clickAwayEvent = new ClickAwayEvent(e, element);
|
|
@@ -2962,6 +2743,108 @@ function register_click_away_event(element) {
|
|
|
2962
2743
|
// // later, you can stop listening:
|
|
2963
2744
|
// // stop();
|
|
2964
2745
|
|
|
2746
|
+
const getCoordinates = (ctx, normalized = false) =>{
|
|
2747
|
+
const rect = ctx.element.getBoundingClientRect();
|
|
2748
|
+
const e = ctx.event;
|
|
2749
|
+
let x = (e?.clientX - rect.left) | 0;
|
|
2750
|
+
let y = (e?.clientY - rect.top) | 0;
|
|
2751
|
+
|
|
2752
|
+
if(normalized){
|
|
2753
|
+
const w = ctx.element.clientWidth;
|
|
2754
|
+
const h = ctx.element.clientHeight;
|
|
2755
|
+
x = +((x / w) * 2 - 1).toFixed(8);
|
|
2756
|
+
y = +((y / h) * -2 + 1).toFixed(8);
|
|
2757
|
+
}
|
|
2758
|
+
|
|
2759
|
+
return {x, y};
|
|
2760
|
+
};
|
|
2761
|
+
|
|
2762
|
+
const isCustomEventRegistred = (ctx, category, event_name) => ctx.exp.events?.[category]?.cache?.customEvents?.has(event_name);
|
|
2763
|
+
|
|
2764
|
+
const CATEGORY$3 = 'click';
|
|
2765
|
+
const ClickListeners = {
|
|
2766
|
+
onClick(callback){
|
|
2767
|
+
return this.on(
|
|
2768
|
+
'click', callback,
|
|
2769
|
+
{ category : CATEGORY$3 })
|
|
2770
|
+
},
|
|
2771
|
+
onDblClick(callback){
|
|
2772
|
+
return this.on(
|
|
2773
|
+
'dblclick', callback,
|
|
2774
|
+
{ category : CATEGORY$3})
|
|
2775
|
+
},
|
|
2776
|
+
onClickAway(callback){
|
|
2777
|
+
if(!isCustomEventRegistred(this, CATEGORY$3, 'clickaway')) register_click_away_event(this.element);
|
|
2778
|
+
return this.on(
|
|
2779
|
+
'clickaway', callback,
|
|
2780
|
+
{ category : CATEGORY$3, isCustom : true})
|
|
2781
|
+
},
|
|
2782
|
+
};
|
|
2783
|
+
|
|
2784
|
+
const CATEGORY$2 = 'ptr';
|
|
2785
|
+
const PtrListeners = {
|
|
2786
|
+
onPtrDown(callback, useNormalizedCoordinates = false){
|
|
2787
|
+
return this.on(
|
|
2788
|
+
'pointerdown', callback,
|
|
2789
|
+
{ category : CATEGORY$2, details_setter : (ctx)=> {
|
|
2790
|
+
const {x, y} = getCoordinates(ctx, useNormalizedCoordinates);
|
|
2791
|
+
ctx.dx = x;
|
|
2792
|
+
ctx.dy = y;
|
|
2793
|
+
ctx.isDown = true;
|
|
2794
|
+
ctx.isDragging = ctx.isMoving ?? false;
|
|
2795
|
+
}}
|
|
2796
|
+
)
|
|
2797
|
+
},
|
|
2798
|
+
onPtrMove(callback, useNormalizedCoordinates = false){
|
|
2799
|
+
return this.on(
|
|
2800
|
+
'pointermove', callback,
|
|
2801
|
+
{ category : CATEGORY$2, details_setter : (ctx)=> {
|
|
2802
|
+
const {x, y} = getCoordinates(ctx, useNormalizedCoordinates);
|
|
2803
|
+
ctx.mx = x;
|
|
2804
|
+
ctx.my = y;
|
|
2805
|
+
ctx.isMoving = true;
|
|
2806
|
+
ctx.isDragging = ctx.isDown ?? false;
|
|
2807
|
+
}}
|
|
2808
|
+
)
|
|
2809
|
+
},
|
|
2810
|
+
onPtrUp(callback, useNormalizedCoordinates = false){
|
|
2811
|
+
return this.on(
|
|
2812
|
+
'pointerup', callback,
|
|
2813
|
+
{ category : CATEGORY$2, details_setter : (ctx)=> {
|
|
2814
|
+
const {x, y} = getCoordinates(ctx, useNormalizedCoordinates);
|
|
2815
|
+
ctx.ux = x;
|
|
2816
|
+
ctx.uy = y;
|
|
2817
|
+
ctx.isDown = false;
|
|
2818
|
+
ctx.isMoving = false;
|
|
2819
|
+
ctx.isDragging = false;
|
|
2820
|
+
}}
|
|
2821
|
+
)
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
|
|
2825
|
+
const CATEGORY$1 = 'key';
|
|
2826
|
+
const KeyListeners = {
|
|
2827
|
+
onKeyDown(callback){
|
|
2828
|
+
return this.on(
|
|
2829
|
+
'keydown', callback,
|
|
2830
|
+
{ category : CATEGORY$1, details_setter : ctx=> { ctx.kd = ctx.event.key; }
|
|
2831
|
+
})
|
|
2832
|
+
},
|
|
2833
|
+
onKeyPress(callback){
|
|
2834
|
+
return this.on(
|
|
2835
|
+
'keypress', callback,
|
|
2836
|
+
{ category : CATEGORY$1, details_setter : ctx=> { ctx.kp = ctx.event.key; }
|
|
2837
|
+
})
|
|
2838
|
+
},
|
|
2839
|
+
onKeyUp(callback){
|
|
2840
|
+
return this.on(
|
|
2841
|
+
'keydown', callback,
|
|
2842
|
+
{ category : CATEGORY$1, details_setter : ctx=> { ctx.ku = ctx.event.key; }
|
|
2843
|
+
})
|
|
2844
|
+
},
|
|
2845
|
+
|
|
2846
|
+
};
|
|
2847
|
+
|
|
2965
2848
|
const debounce=(fn,delay=1000)=>{
|
|
2966
2849
|
let id;
|
|
2967
2850
|
return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
|
|
@@ -3045,6 +2928,28 @@ function register_view_event(
|
|
|
3045
2928
|
};
|
|
3046
2929
|
}
|
|
3047
2930
|
|
|
2931
|
+
const CATEGORY = 'view';
|
|
2932
|
+
const ViewListeners = {
|
|
2933
|
+
onEnterView(callback){
|
|
2934
|
+
if(!this.exp.events?.[CATEGORY]) register_view_event(this.element);
|
|
2935
|
+
return this.on(
|
|
2936
|
+
'enterview', callback,
|
|
2937
|
+
{ category : CATEGORY, isCustom : true})
|
|
2938
|
+
},
|
|
2939
|
+
onExitView(callback){
|
|
2940
|
+
if(!this.exp.events?.[CATEGORY]) register_view_event(this.element);
|
|
2941
|
+
return this.on(
|
|
2942
|
+
'exitview', callback,
|
|
2943
|
+
{ category : CATEGORY, isCustom : true})
|
|
2944
|
+
},
|
|
2945
|
+
onResizeView(callback){
|
|
2946
|
+
if(!this.exp.events?.[CATEGORY]) register_view_event(this.element);
|
|
2947
|
+
return this.on(
|
|
2948
|
+
'resizeview', callback,
|
|
2949
|
+
{ category : CATEGORY, isCustom : true})
|
|
2950
|
+
},
|
|
2951
|
+
};
|
|
2952
|
+
|
|
3048
2953
|
class SwipeEvent extends CustomEvent {
|
|
3049
2954
|
constructor(type, detail) {
|
|
3050
2955
|
super(type, {
|
|
@@ -3057,7 +2962,7 @@ class SwipeEvent extends CustomEvent {
|
|
|
3057
2962
|
|
|
3058
2963
|
function register_swipe_event(
|
|
3059
2964
|
element,
|
|
3060
|
-
threshold =
|
|
2965
|
+
threshold = 5,
|
|
3061
2966
|
restraint = 100,
|
|
3062
2967
|
allowedTime = 500
|
|
3063
2968
|
) {
|
|
@@ -3117,267 +3022,6 @@ function register_swipe_event(
|
|
|
3117
3022
|
};
|
|
3118
3023
|
}
|
|
3119
3024
|
|
|
3120
|
-
const bind_click_event = (target, customizer) => {
|
|
3121
|
-
register_click_away_event(target.element);
|
|
3122
|
-
return new ZikoEvent(
|
|
3123
|
-
'click',
|
|
3124
|
-
target,
|
|
3125
|
-
EventsMap.Click,
|
|
3126
|
-
null,
|
|
3127
|
-
customizer
|
|
3128
|
-
);
|
|
3129
|
-
};
|
|
3130
|
-
const bind_clipboard_event = (target, customizer) => new ZikoEvent(
|
|
3131
|
-
'clipboard',
|
|
3132
|
-
target,
|
|
3133
|
-
EventsMap.Clipboard,
|
|
3134
|
-
null,
|
|
3135
|
-
customizer
|
|
3136
|
-
);
|
|
3137
|
-
const bind_drag_event = (target, customizer) => new ZikoEvent(
|
|
3138
|
-
'drag',
|
|
3139
|
-
target,
|
|
3140
|
-
EventsMap.Drag,
|
|
3141
|
-
null,
|
|
3142
|
-
customizer
|
|
3143
|
-
);
|
|
3144
|
-
const bind_focus_event = (target, customizer) => new ZikoEvent(
|
|
3145
|
-
'focus',
|
|
3146
|
-
target,
|
|
3147
|
-
EventsMap.Focus,
|
|
3148
|
-
null,
|
|
3149
|
-
customizer
|
|
3150
|
-
);
|
|
3151
|
-
const bind_key_event = (target, customizer) => new ZikoEvent(
|
|
3152
|
-
'key',
|
|
3153
|
-
target,
|
|
3154
|
-
EventsMap.Key,
|
|
3155
|
-
key_details_setter,
|
|
3156
|
-
customizer
|
|
3157
|
-
);
|
|
3158
|
-
const bind_mouse_event = (target, customizer) => new CoordinatesBasedEvent(
|
|
3159
|
-
'mouse',
|
|
3160
|
-
target,
|
|
3161
|
-
EventsMap.Mouse,
|
|
3162
|
-
mouse_details_setter,
|
|
3163
|
-
customizer
|
|
3164
|
-
);
|
|
3165
|
-
const bind_pointer_event = (target, customizer) => new CoordinatesBasedEvent(
|
|
3166
|
-
'ptr',
|
|
3167
|
-
target,
|
|
3168
|
-
EventsMap.Ptr,
|
|
3169
|
-
ptr_details_setter,
|
|
3170
|
-
customizer
|
|
3171
|
-
);
|
|
3172
|
-
const bind_touch_event = (target, customizer) => new CoordinatesBasedEvent(
|
|
3173
|
-
'touch',
|
|
3174
|
-
target,
|
|
3175
|
-
EventsMap.Touch,
|
|
3176
|
-
touch_details_setter,
|
|
3177
|
-
customizer
|
|
3178
|
-
);
|
|
3179
|
-
const bind_wheel_event = (target, customizer) => new ZikoEvent(
|
|
3180
|
-
'wheel',
|
|
3181
|
-
target,
|
|
3182
|
-
EventsMap.Wheel,
|
|
3183
|
-
null,
|
|
3184
|
-
customizer
|
|
3185
|
-
);
|
|
3186
|
-
|
|
3187
|
-
const bind_view_event = (target, customizer) => {
|
|
3188
|
-
register_view_event(target.element);
|
|
3189
|
-
return new ZikoEvent(
|
|
3190
|
-
'view',
|
|
3191
|
-
target,
|
|
3192
|
-
EventsMap.View,
|
|
3193
|
-
null,
|
|
3194
|
-
customizer
|
|
3195
|
-
)
|
|
3196
|
-
};
|
|
3197
|
-
|
|
3198
|
-
const bind_swipe_event = (target, customizer) => {
|
|
3199
|
-
register_swipe_event(target.element);
|
|
3200
|
-
return new ZikoEvent(
|
|
3201
|
-
'swipe',
|
|
3202
|
-
target,
|
|
3203
|
-
EventsMap.Swipe,
|
|
3204
|
-
null,
|
|
3205
|
-
customizer
|
|
3206
|
-
)
|
|
3207
|
-
};
|
|
3208
|
-
|
|
3209
|
-
class ZikoCustomEvent extends ZikoEvent{
|
|
3210
|
-
constructor(target, events, customizer){
|
|
3211
|
-
super('custom', target, events, details_setter, customizer);
|
|
3212
|
-
}
|
|
3213
|
-
_register_events(events){
|
|
3214
|
-
super._register_events(events, null, null, false);
|
|
3215
|
-
return this;
|
|
3216
|
-
}
|
|
3217
|
-
emit(event_name, detail = {}){
|
|
3218
|
-
const event = new CustomEvent(event_name, {
|
|
3219
|
-
detail,
|
|
3220
|
-
bubbles: true,
|
|
3221
|
-
cancelable: true
|
|
3222
|
-
});
|
|
3223
|
-
this.targetElement.dispatchEvent(event);
|
|
3224
|
-
return this;
|
|
3225
|
-
}
|
|
3226
|
-
on(event_name, ...callbacks){
|
|
3227
|
-
if(!this.cache.options.hasOwnProperty(event_name)) this._register_events([event_name]);
|
|
3228
|
-
this.__onEvent(event_name, this.cache.options[event_name], {}, ...callbacks);
|
|
3229
|
-
return this;
|
|
3230
|
-
}
|
|
3231
|
-
}
|
|
3232
|
-
function details_setter(){
|
|
3233
|
-
|
|
3234
|
-
}
|
|
3235
|
-
const bind_custom_event = (target, events, customizer) => new ZikoCustomEvent(target, events, customizer);
|
|
3236
|
-
|
|
3237
|
-
const binderMap = {
|
|
3238
|
-
ptr: bind_pointer_event,
|
|
3239
|
-
mouse : bind_mouse_event,
|
|
3240
|
-
key: bind_key_event,
|
|
3241
|
-
click : bind_click_event,
|
|
3242
|
-
drag : bind_drag_event,
|
|
3243
|
-
clipboard : bind_clipboard_event,
|
|
3244
|
-
focus : bind_focus_event,
|
|
3245
|
-
wheel : bind_wheel_event,
|
|
3246
|
-
view : bind_view_event,
|
|
3247
|
-
swipe : bind_swipe_event
|
|
3248
|
-
};
|
|
3249
|
-
|
|
3250
|
-
const EventsMethodes = {
|
|
3251
|
-
on(event_name,...callbacks){
|
|
3252
|
-
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
3253
|
-
this.events.custom.on(event_name,...callbacks);
|
|
3254
|
-
return this;
|
|
3255
|
-
},
|
|
3256
|
-
emit(event_name,detail={}){
|
|
3257
|
-
if(!this.events.custom)this.events.custom = bind_custom_event(this);
|
|
3258
|
-
this.events.custom.emit(event_name,detail);
|
|
3259
|
-
return this;
|
|
3260
|
-
}
|
|
3261
|
-
};
|
|
3262
|
-
|
|
3263
|
-
Object.entries(EventsMap).forEach(([name, eventList]) => {
|
|
3264
|
-
const lname = name.toLowerCase();
|
|
3265
|
-
eventList.forEach(event => {
|
|
3266
|
-
const methodName = `on${event}`;
|
|
3267
|
-
EventsMethodes[methodName] = function (callbacks) {
|
|
3268
|
-
if (!this.events[lname]) this.events[lname] = binderMap[lname](this);
|
|
3269
|
-
this.events[lname][methodName](callbacks);
|
|
3270
|
-
return this;
|
|
3271
|
-
};
|
|
3272
|
-
});
|
|
3273
|
-
});
|
|
3274
|
-
|
|
3275
|
-
function at(index) {
|
|
3276
|
-
return this.items.at(index);
|
|
3277
|
-
}
|
|
3278
|
-
function forEach(callback) {
|
|
3279
|
-
this.items.forEach(callback);
|
|
3280
|
-
return this;
|
|
3281
|
-
}
|
|
3282
|
-
function map(callback) {
|
|
3283
|
-
return this.items.map(callback);
|
|
3284
|
-
}
|
|
3285
|
-
function find(condition) {
|
|
3286
|
-
return this.items.filter(condition);
|
|
3287
|
-
}
|
|
3288
|
-
|
|
3289
|
-
var IndexingMethods = /*#__PURE__*/Object.freeze({
|
|
3290
|
-
__proto__: null,
|
|
3291
|
-
at: at,
|
|
3292
|
-
find: find,
|
|
3293
|
-
forEach: forEach,
|
|
3294
|
-
map: map
|
|
3295
|
-
});
|
|
3296
|
-
|
|
3297
|
-
function style$1(styles){
|
|
3298
|
-
if(!this.element?.style) return this;
|
|
3299
|
-
for(let key in styles){
|
|
3300
|
-
const value = styles[key];
|
|
3301
|
-
if(isStateGetter(value)){
|
|
3302
|
-
const getter = value();
|
|
3303
|
-
Object.assign(this.element.style, {[key] : getter.value});
|
|
3304
|
-
getter._subscribe(
|
|
3305
|
-
(newValue) => {
|
|
3306
|
-
console.log({newValue});
|
|
3307
|
-
Object.assign(this.element.style, {[key] : newValue});
|
|
3308
|
-
},
|
|
3309
|
-
// this
|
|
3310
|
-
);
|
|
3311
|
-
}
|
|
3312
|
-
else Object.assign(this.element.style, {[key] : value});
|
|
3313
|
-
}
|
|
3314
|
-
return this;
|
|
3315
|
-
}
|
|
3316
|
-
function size(width, height){
|
|
3317
|
-
return this.style({width, height})
|
|
3318
|
-
}
|
|
3319
|
-
function hide(){
|
|
3320
|
-
|
|
3321
|
-
}
|
|
3322
|
-
function show(){
|
|
3323
|
-
|
|
3324
|
-
}
|
|
3325
|
-
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
3326
|
-
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
3327
|
-
return this;
|
|
3328
|
-
}
|
|
3329
|
-
|
|
3330
|
-
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
3331
|
-
__proto__: null,
|
|
3332
|
-
animate: animate,
|
|
3333
|
-
hide: hide,
|
|
3334
|
-
show: show,
|
|
3335
|
-
size: size,
|
|
3336
|
-
style: style$1
|
|
3337
|
-
});
|
|
3338
|
-
|
|
3339
|
-
class EventController {
|
|
3340
|
-
constructor(target, category){
|
|
3341
|
-
this.cache = {
|
|
3342
|
-
category,
|
|
3343
|
-
target,
|
|
3344
|
-
listeners : {},
|
|
3345
|
-
currentEvent : null
|
|
3346
|
-
};
|
|
3347
|
-
}
|
|
3348
|
-
get element(){
|
|
3349
|
-
return this.cache.target.element;
|
|
3350
|
-
}
|
|
3351
|
-
get currentEvent(){
|
|
3352
|
-
return this.cache.currentEvent;
|
|
3353
|
-
}
|
|
3354
|
-
addListener(event, callback){
|
|
3355
|
-
this.cache.listeners[event] = {
|
|
3356
|
-
paused : false,
|
|
3357
|
-
callback : ()=>{
|
|
3358
|
-
if(!this.cache.listeners[event].paused) {
|
|
3359
|
-
this.cache.currentEvent = event;
|
|
3360
|
-
callback.call(this, this);
|
|
3361
|
-
}
|
|
3362
|
-
},
|
|
3363
|
-
};
|
|
3364
|
-
this.element.addEventListener(event, this.cache.listeners[event].callback);
|
|
3365
|
-
return this;
|
|
3366
|
-
}
|
|
3367
|
-
removeListener(event){
|
|
3368
|
-
this.element.removeEventListener(event, this.cache.listeners[event].callback);
|
|
3369
|
-
return this;
|
|
3370
|
-
}
|
|
3371
|
-
pause(event){
|
|
3372
|
-
this.cache.listeners[event].paused = true;
|
|
3373
|
-
return this;
|
|
3374
|
-
}
|
|
3375
|
-
resume(event){
|
|
3376
|
-
this.cache.listeners[event].paused = false;
|
|
3377
|
-
return this;
|
|
3378
|
-
}
|
|
3379
|
-
}
|
|
3380
|
-
|
|
3381
3025
|
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3382
3026
|
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
3383
3027
|
super();
|
|
@@ -3392,17 +3036,26 @@ let UIElement$1 = class UIElement extends UIElementCore{
|
|
|
3392
3036
|
AttrsMethods,
|
|
3393
3037
|
DomMethods,
|
|
3394
3038
|
StyleMethods,
|
|
3395
|
-
IndexingMethods,
|
|
3396
|
-
|
|
3039
|
+
IndexingMethods,
|
|
3040
|
+
PtrListeners,
|
|
3041
|
+
ClickListeners,
|
|
3042
|
+
KeyListeners,
|
|
3043
|
+
ViewListeners,
|
|
3397
3044
|
);
|
|
3398
3045
|
|
|
3399
3046
|
if(element)this.init(element, name, type, render);
|
|
3400
3047
|
}
|
|
3401
|
-
|
|
3048
|
+
on(event_name, callback, {details_setter, category = 'global', isCustom = false,preventDefault = false} = {}){
|
|
3402
3049
|
if(category && !this.exp.events.hasOwnProperty(category)) this.exp.events[category] = new EventController(this, category);
|
|
3050
|
+
isCustom && this.exp.events[category].cache.customEvents.add(event_name);
|
|
3403
3051
|
const EVENT = this.exp.events[category];
|
|
3404
|
-
EVENT.addListener(
|
|
3405
|
-
|
|
3052
|
+
EVENT.addListener(event_name, (e)=>{
|
|
3053
|
+
if(details_setter) details_setter(EVENT);
|
|
3054
|
+
callback(e);
|
|
3055
|
+
},{
|
|
3056
|
+
preventDefault
|
|
3057
|
+
});
|
|
3058
|
+
return this;
|
|
3406
3059
|
}
|
|
3407
3060
|
_off(event, category = 'global'){
|
|
3408
3061
|
this.exp.events[category].removeListener(event);
|
|
@@ -5407,21 +5060,27 @@ if(globalThis?.document){
|
|
|
5407
5060
|
}
|
|
5408
5061
|
|
|
5409
5062
|
exports.App = App;
|
|
5063
|
+
exports.ClickAwayEvent = ClickAwayEvent;
|
|
5064
|
+
exports.ClickListeners = ClickListeners;
|
|
5410
5065
|
exports.Clock = Clock;
|
|
5411
5066
|
exports.CloneElement = CloneElement;
|
|
5412
5067
|
exports.Complex = Complex;
|
|
5413
5068
|
exports.E = E;
|
|
5414
5069
|
exports.EPSILON = EPSILON;
|
|
5070
|
+
exports.EventController = EventController;
|
|
5415
5071
|
exports.FileBasedRouting = FileBasedRouting;
|
|
5416
5072
|
exports.Flex = Flex;
|
|
5417
5073
|
exports.HTMLWrapper = HTMLWrapper;
|
|
5074
|
+
exports.KeyListeners = KeyListeners;
|
|
5418
5075
|
exports.Matrix = Matrix;
|
|
5419
5076
|
exports.PI = PI$1;
|
|
5077
|
+
exports.PtrListeners = PtrListeners;
|
|
5420
5078
|
exports.Random = Random;
|
|
5421
5079
|
exports.SPA = SPA;
|
|
5422
5080
|
exports.SVGWrapper = SVGWrapper;
|
|
5423
5081
|
exports.Scheduler = Scheduler;
|
|
5424
5082
|
exports.Suspense = Suspense;
|
|
5083
|
+
exports.SwipeEvent = SwipeEvent;
|
|
5425
5084
|
exports.Switch = Switch;
|
|
5426
5085
|
exports.Tick = Tick;
|
|
5427
5086
|
exports.TimeAnimation = TimeAnimation;
|
|
@@ -5438,8 +5097,9 @@ exports.UseRoot = UseRoot;
|
|
|
5438
5097
|
exports.UseThread = UseThread;
|
|
5439
5098
|
exports.Utils = Utils;
|
|
5440
5099
|
exports.View = View;
|
|
5100
|
+
exports.ViewEvent = ViewEvent;
|
|
5101
|
+
exports.ViewListeners = ViewListeners;
|
|
5441
5102
|
exports.ZikoApp = ZikoApp;
|
|
5442
|
-
exports.ZikoEvent = ZikoEvent;
|
|
5443
5103
|
exports.ZikoSPA = ZikoSPA;
|
|
5444
5104
|
exports.ZikoUISuspense = ZikoUISuspense;
|
|
5445
5105
|
exports.ZikoUIText = ZikoUIText;
|
|
@@ -5464,17 +5124,6 @@ exports.atan = atan;
|
|
|
5464
5124
|
exports.atan2 = atan2;
|
|
5465
5125
|
exports.atanh = atanh;
|
|
5466
5126
|
exports.back = back;
|
|
5467
|
-
exports.bind_click_event = bind_click_event;
|
|
5468
|
-
exports.bind_clipboard_event = bind_clipboard_event;
|
|
5469
|
-
exports.bind_drag_event = bind_drag_event;
|
|
5470
|
-
exports.bind_focus_event = bind_focus_event;
|
|
5471
|
-
exports.bind_key_event = bind_key_event;
|
|
5472
|
-
exports.bind_mouse_event = bind_mouse_event;
|
|
5473
|
-
exports.bind_pointer_event = bind_pointer_event;
|
|
5474
|
-
exports.bind_swipe_event = bind_swipe_event;
|
|
5475
|
-
exports.bind_touch_event = bind_touch_event;
|
|
5476
|
-
exports.bind_view_event = bind_view_event;
|
|
5477
|
-
exports.bind_wheel_event = bind_wheel_event;
|
|
5478
5127
|
exports.binomial = binomial;
|
|
5479
5128
|
exports.call_with_optional_props = call_with_optional_props;
|
|
5480
5129
|
exports.cartesianProduct = cartesianProduct;
|
|
@@ -5500,12 +5149,10 @@ exports.deg2rad = deg2rad;
|
|
|
5500
5149
|
exports.discret = discret;
|
|
5501
5150
|
exports.div = div;
|
|
5502
5151
|
exports.elastic = elastic;
|
|
5503
|
-
exports.event_controller = event_controller;
|
|
5504
5152
|
exports.exp = exp$1;
|
|
5505
5153
|
exports.floor = floor;
|
|
5506
5154
|
exports.fract = fract;
|
|
5507
5155
|
exports.geomspace = geomspace;
|
|
5508
|
-
exports.getEvent = getEvent;
|
|
5509
5156
|
exports.hypot = hypot;
|
|
5510
5157
|
exports.inRange = inRange;
|
|
5511
5158
|
exports.in_back = in_back;
|
|
@@ -5582,6 +5229,9 @@ exports.pgcd = pgcd;
|
|
|
5582
5229
|
exports.pow = pow$1;
|
|
5583
5230
|
exports.ppcm = ppcm;
|
|
5584
5231
|
exports.rad2deg = rad2deg;
|
|
5232
|
+
exports.register_click_away_event = register_click_away_event;
|
|
5233
|
+
exports.register_swipe_event = register_swipe_event;
|
|
5234
|
+
exports.register_view_event = register_view_event;
|
|
5585
5235
|
exports.remove_class = remove_class;
|
|
5586
5236
|
exports.round = round;
|
|
5587
5237
|
exports.script = script;
|
|
@@ -5610,7 +5260,6 @@ exports.tick = tick;
|
|
|
5610
5260
|
exports.timeTaken = timeTaken;
|
|
5611
5261
|
exports.time_memory_Taken = time_memory_Taken;
|
|
5612
5262
|
exports.timeout = timeout;
|
|
5613
|
-
exports.toggle_event_listener = toggle_event_listener;
|
|
5614
5263
|
exports.trunc = trunc;
|
|
5615
5264
|
exports.useDerived = useDerived;
|
|
5616
5265
|
exports.useEventEmitter = useEventEmitter;
|