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