ziko 0.45.0 → 0.45.2
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.js +647 -696
- package/dist/ziko.mjs +636 -678
- package/package.json +1 -1
- package/src/__helpers__/register/index.js +3 -1
- package/src/__helpers__/register/register-to-instance.js +17 -5
- package/src/app/spa-file-based-routing.js +3 -2
- package/src/app/spa.js +3 -3
- package/src/app/ziko-app.js +1 -1
- package/src/events/__Events__.js +2 -1
- package/src/events/binders/click.js +20 -0
- package/src/events/binders/clipboard.js +16 -0
- package/src/events/{custom-event.js → binders/custom-event.js} +1 -1
- package/src/events/binders/drag.js +16 -0
- package/src/events/binders/focus.js +16 -0
- package/src/events/{hash.js → binders/hash.js} +2 -2
- package/src/events/binders/index.js +16 -0
- package/src/events/{key.js → binders/key.js} +4 -4
- package/src/events/binders/mouse.js +16 -0
- package/src/events/{pointer.js → binders/pointer.js} +4 -4
- package/src/events/{touch.js → binders/touch.js} +2 -2
- package/src/events/binders/wheel.js +16 -0
- package/src/events/custom-events/click-away.js +1 -0
- package/src/events/index.js +2 -16
- package/src/events/types/clipboard.d.ts +2 -2
- package/src/events/types/focus.d.ts +2 -2
- package/src/events/types/pointer.d.ts +2 -2
- package/src/hooks/use-state.js +2 -2
- package/src/lite.js +2 -0
- package/src/ui/__methods__/attrs.js +29 -45
- package/src/ui/__methods__/dom.js +65 -111
- package/src/ui/__methods__/events.js +17 -17
- package/src/ui/__methods__/index.js +10 -1
- package/src/ui/__methods__/indexing.js +14 -15
- package/src/ui/__methods__/style.js +28 -30
- package/src/ui/__methods__/utils/index.js +64 -0
- package/src/ui/constructors/UIElement-lite.js +10 -0
- package/src/ui/constructors/UIElement.js +89 -155
- package/src/ui/constructors/UIElementCore.js +235 -0
- package/src/ui/index.js +3 -3
- package/src/ui/suspense/index.js +1 -1
- package/src/ui/tags/index.js +9 -3
- package/src/ui/tags/tags-list.js +0 -1
- package/src/ui/wrappers/html/index.js +26 -0
- package/src/ui/wrappers/index.js +2 -0
- package/src/ui/wrappers/svg/index.js +46 -0
- package/src/events/click.js +0 -18
- package/src/events/clipboard.js +0 -16
- package/src/events/drag.js +0 -16
- package/src/events/focus.js +0 -16
- package/src/events/mouse.js +0 -16
- package/src/events/wheel.js +0 -16
- package/src/ui/__methods__/observer.js +0 -0
- package/src/ui/wrapper/index.js +0 -42
- /package/src/ui/constructors/{ZikoUIElementMethodesToBeMoved-dep.js → _m.js.txt} +0 -0
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Mon Sep 01 2025 13:22:11 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -249,17 +249,17 @@ const lerp=(value, min, max)=>{
|
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
-
const map=(value, a, b, c, d)=>{
|
|
252
|
+
const map$1=(value, a, b, c, d)=>{
|
|
253
253
|
if (typeof value === "number") return lerp(norm(value, a, b), c, d);
|
|
254
|
-
else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, map(value.arr.flat(1), a, b, c, d));
|
|
255
|
-
else if (value instanceof Complex) return new Complex(map(value.a, b, c, d), map(value.b, a, b, c, d));
|
|
254
|
+
else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, map$1(value.arr.flat(1), a, b, c, d));
|
|
255
|
+
else if (value instanceof Complex) return new Complex(map$1(value.a, b, c, d), map$1(value.b, a, b, c, d));
|
|
256
256
|
else if (value instanceof Array) {
|
|
257
257
|
if (value.every((n) => typeof (n === "number"))) {
|
|
258
|
-
return value.map((n) => map(n, a, b, c, d));
|
|
258
|
+
return value.map((n) => map$1(n, a, b, c, d));
|
|
259
259
|
} else {
|
|
260
260
|
let y = new Array(value.length);
|
|
261
261
|
for (let i = 0; i < value.length; i++) {
|
|
262
|
-
y[i] = map(value[i], a, b, c, d);
|
|
262
|
+
y[i] = map$1(value[i], a, b, c, d);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -532,7 +532,7 @@ const Utils={
|
|
|
532
532
|
nums,
|
|
533
533
|
norm,
|
|
534
534
|
lerp,
|
|
535
|
-
map,
|
|
535
|
+
map: map$1,
|
|
536
536
|
clamp,
|
|
537
537
|
arange,
|
|
538
538
|
linspace,
|
|
@@ -1074,47 +1074,6 @@ class UINode {
|
|
|
1074
1074
|
|
|
1075
1075
|
// globalThis.node = (node) => new UINode(node);
|
|
1076
1076
|
|
|
1077
|
-
function register_to_class(target, ...mixins){
|
|
1078
|
-
mixins.forEach(n => _register_to_class_(target, n));
|
|
1079
|
-
}
|
|
1080
|
-
function _register_to_class_(target, mixin) {
|
|
1081
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1082
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1083
|
-
const desc = descriptors[key];
|
|
1084
|
-
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1085
|
-
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1086
|
-
} else if (typeof desc.value === 'function') {
|
|
1087
|
-
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1088
|
-
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
function register_to_instance(target, ...mixins){
|
|
1095
|
-
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1096
|
-
}
|
|
1097
|
-
function _register_to_instance_(instance, mixin) {
|
|
1098
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1099
|
-
|
|
1100
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1101
|
-
const desc = descriptors[key];
|
|
1102
|
-
|
|
1103
|
-
if ('get' in desc || 'set' in desc) {
|
|
1104
|
-
Object.defineProperty(instance, key, desc);
|
|
1105
|
-
} else if (typeof desc.value === 'function') {
|
|
1106
|
-
instance[key] = desc.value.bind(instance);
|
|
1107
|
-
} else {
|
|
1108
|
-
instance[key] = desc.value;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
const register = (target, ...mixins) => {
|
|
1114
|
-
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1115
|
-
else register_to_instance(target, ...mixins);
|
|
1116
|
-
};
|
|
1117
|
-
|
|
1118
1077
|
function parseQueryParams$1(queryString) {
|
|
1119
1078
|
const params = {};
|
|
1120
1079
|
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
@@ -1237,11 +1196,261 @@ function __init__global__(){
|
|
|
1237
1196
|
}
|
|
1238
1197
|
}
|
|
1239
1198
|
|
|
1199
|
+
__init__global__();
|
|
1200
|
+
class UIElementCore extends UINode{
|
|
1201
|
+
constructor(){
|
|
1202
|
+
super();
|
|
1203
|
+
}
|
|
1204
|
+
init(element, name, type, render, isInteractive = [true, false][Math.floor(2*Math.random())]){
|
|
1205
|
+
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1206
|
+
if(typeof element === "string") {
|
|
1207
|
+
switch(type){
|
|
1208
|
+
case "html" : {
|
|
1209
|
+
element = globalThis?.document?.createElement(element);
|
|
1210
|
+
console.log('1');
|
|
1211
|
+
} break;
|
|
1212
|
+
case "svg" : {
|
|
1213
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1214
|
+
console.log('2');
|
|
1215
|
+
} break;
|
|
1216
|
+
default : throw Error("Not supported")
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
else this.target = element?.parentElement;
|
|
1220
|
+
Object.assign(this.cache, {
|
|
1221
|
+
name,
|
|
1222
|
+
isInteractive,
|
|
1223
|
+
parent:null,
|
|
1224
|
+
isBody:false,
|
|
1225
|
+
isRoot:false,
|
|
1226
|
+
isHidden: false,
|
|
1227
|
+
isFrozzen:false,
|
|
1228
|
+
legacyParent : null,
|
|
1229
|
+
attributes: {},
|
|
1230
|
+
filters: {},
|
|
1231
|
+
temp:{}
|
|
1232
|
+
});
|
|
1233
|
+
this.events = {
|
|
1234
|
+
ptr:null,
|
|
1235
|
+
mouse:null,
|
|
1236
|
+
wheel:null,
|
|
1237
|
+
key:null,
|
|
1238
|
+
drag:null,
|
|
1239
|
+
drop:null,
|
|
1240
|
+
click:null,
|
|
1241
|
+
clipboard:null,
|
|
1242
|
+
focus:null,
|
|
1243
|
+
swipe:null,
|
|
1244
|
+
custom:null,
|
|
1245
|
+
};
|
|
1246
|
+
this.observer={
|
|
1247
|
+
resize:null,
|
|
1248
|
+
intersection:null
|
|
1249
|
+
};
|
|
1250
|
+
if(element) Object.assign(this.cache,{element});
|
|
1251
|
+
// useDefaultStyle && this.style({
|
|
1252
|
+
// position: "relative",
|
|
1253
|
+
// boxSizing:"border-box",
|
|
1254
|
+
// margin:0,
|
|
1255
|
+
// padding:0,
|
|
1256
|
+
// width : "auto",
|
|
1257
|
+
// height : "auto"
|
|
1258
|
+
// });
|
|
1259
|
+
this.items = new UIStore();
|
|
1260
|
+
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1261
|
+
element && render && this?.render?.();
|
|
1262
|
+
if(
|
|
1263
|
+
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
1264
|
+
// &&
|
|
1265
|
+
// !globalThis.__Ziko__.__Config__.isSSC
|
|
1266
|
+
// &&
|
|
1267
|
+
this.isInteractive()){
|
|
1268
|
+
// this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
1269
|
+
// this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
1270
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
1271
|
+
}
|
|
1272
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
1273
|
+
}
|
|
1274
|
+
get element(){
|
|
1275
|
+
return this.cache.element;
|
|
1276
|
+
}
|
|
1277
|
+
[Symbol.iterator]() {
|
|
1278
|
+
return this.items[Symbol.iterator]();
|
|
1279
|
+
}
|
|
1280
|
+
maintain() {
|
|
1281
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1282
|
+
Object.defineProperty(this, i, {
|
|
1283
|
+
value: this.items[i],
|
|
1284
|
+
writable: true,
|
|
1285
|
+
configurable: true,
|
|
1286
|
+
enumerable: false
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
isInteractive(){
|
|
1291
|
+
return this.cache.isInteractive;
|
|
1292
|
+
}
|
|
1293
|
+
isUIElement(){
|
|
1294
|
+
return true;
|
|
1295
|
+
}
|
|
1296
|
+
// get st(){
|
|
1297
|
+
// return this.cache.style;
|
|
1298
|
+
// }
|
|
1299
|
+
// get attr(){
|
|
1300
|
+
// return this.cache.attributes;
|
|
1301
|
+
// }
|
|
1302
|
+
// get evt(){
|
|
1303
|
+
// return this.events;
|
|
1304
|
+
// }
|
|
1305
|
+
// get html(){
|
|
1306
|
+
// return this.element.innerHTML;
|
|
1307
|
+
// }
|
|
1308
|
+
// get text(){
|
|
1309
|
+
// return this.element.textContent;
|
|
1310
|
+
// }
|
|
1311
|
+
// get isBody(){
|
|
1312
|
+
// return this.element === globalThis?.document.body;
|
|
1313
|
+
// }
|
|
1314
|
+
// get parent(){
|
|
1315
|
+
// return this.cache.parent;
|
|
1316
|
+
// }
|
|
1317
|
+
// get width(){
|
|
1318
|
+
// return this.element.getBoundingClientRect().width;
|
|
1319
|
+
// }
|
|
1320
|
+
// get height(){
|
|
1321
|
+
// return this.element.getBoundingClientRect().height;
|
|
1322
|
+
// }
|
|
1323
|
+
// get top(){
|
|
1324
|
+
// return this.element.getBoundingClientRect().top;
|
|
1325
|
+
// }
|
|
1326
|
+
// get right(){
|
|
1327
|
+
// return this.element.getBoundingClientRect().right;
|
|
1328
|
+
// }
|
|
1329
|
+
// get bottom(){
|
|
1330
|
+
// return this.element.getBoundingClientRect().bottom;
|
|
1331
|
+
// }
|
|
1332
|
+
// get left(){
|
|
1333
|
+
// return this.element.getBoundingClientRect().left;
|
|
1334
|
+
// }
|
|
1335
|
+
// clone(render=false) {
|
|
1336
|
+
// // UI.__proto__=this.__proto__;
|
|
1337
|
+
// // if(this.items.length){
|
|
1338
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
1339
|
+
// // UI.append(...items);
|
|
1340
|
+
// // }
|
|
1341
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
1342
|
+
// // return UI.render(render);
|
|
1343
|
+
// }
|
|
1344
|
+
|
|
1345
|
+
// freeze(freeze){
|
|
1346
|
+
// this.cache.isFrozzen=freeze;
|
|
1347
|
+
// return this;
|
|
1348
|
+
// }
|
|
1349
|
+
// setTarget(tg) {
|
|
1350
|
+
// if(this.isBody) return ;
|
|
1351
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
1352
|
+
// this.unrender();
|
|
1353
|
+
// this.target = tg;
|
|
1354
|
+
// this.render();
|
|
1355
|
+
// return this;
|
|
1356
|
+
// }
|
|
1357
|
+
// describe(label){
|
|
1358
|
+
// if(label)this.setAttr("aria-label",label)
|
|
1359
|
+
// }
|
|
1360
|
+
// get children() {
|
|
1361
|
+
// return [...this.element.children];
|
|
1362
|
+
// }
|
|
1363
|
+
// get cloneElement() {
|
|
1364
|
+
// return this.element.cloneNode(true);
|
|
1365
|
+
// }
|
|
1366
|
+
// setClasses(...value) {
|
|
1367
|
+
// this.setAttr("class", value.join(" "));
|
|
1368
|
+
// return this;
|
|
1369
|
+
// }
|
|
1370
|
+
// get classes(){
|
|
1371
|
+
// const classes=this.element.getAttribute("class");
|
|
1372
|
+
// return classes===null?[]:classes.split(" ");
|
|
1373
|
+
// }
|
|
1374
|
+
// addClass() {
|
|
1375
|
+
// /*this.setAttr("class", value);
|
|
1376
|
+
// return this;*/
|
|
1377
|
+
// }
|
|
1378
|
+
// setId(id) {
|
|
1379
|
+
// this.setAttr("id", id);
|
|
1380
|
+
// return this;
|
|
1381
|
+
// }
|
|
1382
|
+
// get id() {
|
|
1383
|
+
// return this.element.getAttribute("id");
|
|
1384
|
+
// }
|
|
1385
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
1386
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
1387
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
1388
|
+
// return this;
|
|
1389
|
+
// }
|
|
1390
|
+
// To Fix
|
|
1391
|
+
// onKeysDown({keys=[],callback}={}){
|
|
1392
|
+
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
1393
|
+
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
1394
|
+
// return this;
|
|
1395
|
+
// }
|
|
1396
|
+
// onSelect(...callbacks){
|
|
1397
|
+
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
1398
|
+
// this.events.clipboard.onSelect(...callbacks);
|
|
1399
|
+
// return this;
|
|
1400
|
+
// }
|
|
1401
|
+
// on(event_name,...callbacks){
|
|
1402
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1403
|
+
// this.events.custom.on(event_name,...callbacks);
|
|
1404
|
+
// return this;
|
|
1405
|
+
// }
|
|
1406
|
+
// emit(event_name,detail={}){
|
|
1407
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1408
|
+
// this.events.custom.emit(event_name,detail);
|
|
1409
|
+
// return this;
|
|
1410
|
+
// }
|
|
1411
|
+
// watchAttr(callback){
|
|
1412
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
1413
|
+
// return this;
|
|
1414
|
+
// }
|
|
1415
|
+
// watchChildren(callback){
|
|
1416
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
1417
|
+
// return this;
|
|
1418
|
+
// }
|
|
1419
|
+
// watchSize(callback){
|
|
1420
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
1421
|
+
// this.observer.resize.start();
|
|
1422
|
+
// return this;
|
|
1423
|
+
// }
|
|
1424
|
+
// watchIntersection(callback,config){
|
|
1425
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
1426
|
+
// this.observer.intersection.start();
|
|
1427
|
+
// return this;
|
|
1428
|
+
// }
|
|
1429
|
+
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
function register_to_class(target, ...mixins){
|
|
1433
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1434
|
+
}
|
|
1435
|
+
function _register_to_class_(target, mixin) {
|
|
1436
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1437
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1438
|
+
const desc = descriptors[key];
|
|
1439
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1440
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1441
|
+
} else if (typeof desc.value === 'function') {
|
|
1442
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1443
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1240
1449
|
if(!globalThis.__Ziko__) __init__global__();
|
|
1241
1450
|
|
|
1242
1451
|
// HMR persistence
|
|
1243
|
-
if (import.meta.hot) {
|
|
1244
|
-
import.meta.hot.data.__Ziko__ = import.meta.hot.data
|
|
1452
|
+
if (import.meta.hot?.data) {
|
|
1453
|
+
import.meta.hot.data.__Ziko__ = import.meta.hot.data?.__Ziko__ || globalThis?.__Ziko__;
|
|
1245
1454
|
globalThis.__Ziko__ = import.meta.hot.data.__Ziko__;
|
|
1246
1455
|
// import.meta.hot.accept(n=>console.log(n));
|
|
1247
1456
|
// console.log(import.meta.hot.data.__Ziko__.__State__.store)
|
|
@@ -1299,58 +1508,14 @@ const isStateGetter = (arg) => {
|
|
|
1299
1508
|
return typeof arg === 'function' && arg?.()?.isStateGetter?.();
|
|
1300
1509
|
};
|
|
1301
1510
|
|
|
1302
|
-
const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1511
|
+
const camel2hyphencase$1 = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1303
1512
|
|
|
1304
|
-
const is_camelcase = (text = '') =>{
|
|
1513
|
+
const is_camelcase$1 = (text = '') =>{
|
|
1305
1514
|
if (text.length === 0) return false;
|
|
1306
1515
|
const camelCasePattern = /^[a-z][a-zA-Z0-9]*$/;
|
|
1307
1516
|
return camelCasePattern.test(text);
|
|
1308
1517
|
};
|
|
1309
1518
|
|
|
1310
|
-
// To Do add getter, watchAttr
|
|
1311
|
-
const AttrsMethods = {
|
|
1312
|
-
setAttr(name, value) {
|
|
1313
|
-
if(name instanceof Object){
|
|
1314
|
-
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1315
|
-
for(let i=0;i<names.length;i++){
|
|
1316
|
-
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1317
|
-
_set_attrs_.call(this, names[i], values[i]);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
else {
|
|
1321
|
-
if(value instanceof Array) value = value.join(" ");
|
|
1322
|
-
_set_attrs_.call(this, name, value);
|
|
1323
|
-
}
|
|
1324
|
-
return this;
|
|
1325
|
-
},
|
|
1326
|
-
removeAttr(...names) {
|
|
1327
|
-
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1328
|
-
return this;
|
|
1329
|
-
},
|
|
1330
|
-
getAttr(name){
|
|
1331
|
-
name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1332
|
-
return this.element.attributes[name].value;
|
|
1333
|
-
},
|
|
1334
|
-
setContentEditable(bool = true) {
|
|
1335
|
-
this.setAttr("contenteditable", bool);
|
|
1336
|
-
return this;
|
|
1337
|
-
}
|
|
1338
|
-
};
|
|
1339
|
-
|
|
1340
|
-
function _set_attrs_(name, value){
|
|
1341
|
-
if(this.element?.tagName !== "svg") name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1342
|
-
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1343
|
-
if(isStateGetter(value)){
|
|
1344
|
-
const getter = value();
|
|
1345
|
-
getter._subscribe(
|
|
1346
|
-
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1347
|
-
this
|
|
1348
|
-
);
|
|
1349
|
-
}
|
|
1350
|
-
else this.element?.setAttribute(name, value);
|
|
1351
|
-
Object.assign(this.cache.attributes, {[name]:value});
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
1519
|
class ZikoUIText extends UINode {
|
|
1355
1520
|
constructor(...value) {
|
|
1356
1521
|
super("span", "text", false, ...value);
|
|
@@ -1362,75 +1527,6 @@ class ZikoUIText extends UINode {
|
|
|
1362
1527
|
}
|
|
1363
1528
|
const text = (...str) => new ZikoUIText(...str);
|
|
1364
1529
|
|
|
1365
|
-
const DomMethods = {
|
|
1366
|
-
append(...ele) {
|
|
1367
|
-
__addItem__.call(this, "append", "push", ...ele);
|
|
1368
|
-
return this;
|
|
1369
|
-
},
|
|
1370
|
-
prepend(...ele) {
|
|
1371
|
-
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
1372
|
-
return this;
|
|
1373
|
-
},
|
|
1374
|
-
insertAt(index, ...ele) {
|
|
1375
|
-
if (index >= this.element.children.length) this.append(...ele);
|
|
1376
|
-
else
|
|
1377
|
-
for (let i = 0; i < ele.length; i++) {
|
|
1378
|
-
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
1379
|
-
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
1380
|
-
this.items.splice(index, 0, ele[i]);
|
|
1381
|
-
}
|
|
1382
|
-
return this;
|
|
1383
|
-
},
|
|
1384
|
-
remove(...ele) {
|
|
1385
|
-
const remove = (ele) => {
|
|
1386
|
-
if (typeof ele === "number") ele = this.items[ele];
|
|
1387
|
-
if (ele?.isZikoUIElement) this.element?.removeChild(ele.element);
|
|
1388
|
-
this.items = this.items.filter((n) => n !== ele);
|
|
1389
|
-
};
|
|
1390
|
-
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
1391
|
-
for (let i = 0; i < this.items.length; i++)
|
|
1392
|
-
Object.assign(this, { [[i]]: this.items[i] });
|
|
1393
|
-
// Remove from item
|
|
1394
|
-
return this;
|
|
1395
|
-
},
|
|
1396
|
-
clear(){
|
|
1397
|
-
this?.items?.forEach(n=>n.unrender());
|
|
1398
|
-
this.element.innerHTML = "";
|
|
1399
|
-
return this;
|
|
1400
|
-
},
|
|
1401
|
-
render(target = this.target) {
|
|
1402
|
-
if(this.isBody)return ;
|
|
1403
|
-
if(target?.isZikoUIElement)target=target.element;
|
|
1404
|
-
this.target=target;
|
|
1405
|
-
this.target?.appendChild(this.element);
|
|
1406
|
-
return this;
|
|
1407
|
-
},
|
|
1408
|
-
unrender(){
|
|
1409
|
-
if(this.cache.parent)this.cache.parent.remove(this);
|
|
1410
|
-
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
1411
|
-
return this;
|
|
1412
|
-
},
|
|
1413
|
-
renderAfter(t = 1) {
|
|
1414
|
-
setTimeout(() => this.render(), t);
|
|
1415
|
-
return this;
|
|
1416
|
-
},
|
|
1417
|
-
unrenderAfter(t = 1) {
|
|
1418
|
-
setTimeout(() => this.unrender(), t);
|
|
1419
|
-
return this;
|
|
1420
|
-
},
|
|
1421
|
-
after(ui){
|
|
1422
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
1423
|
-
this.element?.after(ui);
|
|
1424
|
-
return this;
|
|
1425
|
-
},
|
|
1426
|
-
before(ui){
|
|
1427
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
1428
|
-
this.element?.before(ui);
|
|
1429
|
-
return this;
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
};
|
|
1433
|
-
|
|
1434
1530
|
async function __addItem__(adder, pusher, ...ele) {
|
|
1435
1531
|
if (this.cache.isFrozzen) {
|
|
1436
1532
|
console.warn("You can't append new item to frozzen element");
|
|
@@ -1475,12 +1571,147 @@ async function __addItem__(adder, pusher, ...ele) {
|
|
|
1475
1571
|
}
|
|
1476
1572
|
this.maintain();
|
|
1477
1573
|
return this;
|
|
1574
|
+
}
|
|
1575
|
+
function _set_attrs_(name, value){
|
|
1576
|
+
if(this.element instanceof globalThis?.SVGAElement) name = is_camelcase$1(name) ? camel2hyphencase$1(name) : name;
|
|
1577
|
+
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1578
|
+
if(isStateGetter(value)){
|
|
1579
|
+
const getter = value();
|
|
1580
|
+
getter._subscribe(
|
|
1581
|
+
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1582
|
+
this
|
|
1583
|
+
);
|
|
1584
|
+
}
|
|
1585
|
+
else this.element?.setAttribute(name, value);
|
|
1586
|
+
Object.assign(this.cache.attributes, {[name]:value});
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// import {
|
|
1590
|
+
// is_camelcase,
|
|
1591
|
+
// camel2hyphencase
|
|
1592
|
+
// } from '../../data/string/index.js'
|
|
1593
|
+
|
|
1594
|
+
function setAttr(name, value) {
|
|
1595
|
+
if(name instanceof Object){
|
|
1596
|
+
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1597
|
+
for(let i=0;i<names.length;i++){
|
|
1598
|
+
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1599
|
+
_set_attrs_.call(this, names[i], values[i]);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
else {
|
|
1603
|
+
if(value instanceof Array) value = value.join(" ");
|
|
1604
|
+
_set_attrs_.call(this, name, value);
|
|
1605
|
+
}
|
|
1606
|
+
return this;
|
|
1607
|
+
}
|
|
1608
|
+
function removeAttr(...names) {
|
|
1609
|
+
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1610
|
+
return this;
|
|
1611
|
+
}
|
|
1612
|
+
function getAttr(name){
|
|
1613
|
+
name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1614
|
+
return this.element.attributes[name].value;
|
|
1615
|
+
}
|
|
1616
|
+
function setContentEditable(bool = true) {
|
|
1617
|
+
this.setAttr("contenteditable", bool);
|
|
1618
|
+
return this;
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
var AttrsMethods = /*#__PURE__*/Object.freeze({
|
|
1622
|
+
__proto__: null,
|
|
1623
|
+
getAttr: getAttr,
|
|
1624
|
+
removeAttr: removeAttr,
|
|
1625
|
+
setAttr: setAttr,
|
|
1626
|
+
setContentEditable: setContentEditable
|
|
1627
|
+
});
|
|
1628
|
+
|
|
1629
|
+
function append(...ele) {
|
|
1630
|
+
__addItem__.call(this, "append", "push", ...ele);
|
|
1631
|
+
return this;
|
|
1632
|
+
}
|
|
1633
|
+
function prepend(...ele) {
|
|
1634
|
+
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
1635
|
+
return this;
|
|
1636
|
+
}
|
|
1637
|
+
function insertAt(index, ...ele) {
|
|
1638
|
+
if (index >= this.element.children.length) this.append(...ele);
|
|
1639
|
+
else
|
|
1640
|
+
for (let i = 0; i < ele.length; i++) {
|
|
1641
|
+
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
1642
|
+
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
1643
|
+
this.items.splice(index, 0, ele[i]);
|
|
1644
|
+
}
|
|
1645
|
+
return this;
|
|
1646
|
+
}
|
|
1647
|
+
function remove(...ele) {
|
|
1648
|
+
const remove = (ele) => {
|
|
1649
|
+
if (typeof ele === "number") ele = this.items[ele];
|
|
1650
|
+
if (ele?.isUIElement) this.element?.removeChild(ele.element);
|
|
1651
|
+
this.items = this.items.filter((n) => n !== ele);
|
|
1652
|
+
};
|
|
1653
|
+
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
1654
|
+
for (let i = 0; i < this.items.length; i++)
|
|
1655
|
+
Object.assign(this, { [[i]]: this.items[i] });
|
|
1656
|
+
// Remove from item
|
|
1657
|
+
return this;
|
|
1658
|
+
}
|
|
1659
|
+
function clear(){
|
|
1660
|
+
this?.items?.forEach(n=>n.unrender());
|
|
1661
|
+
this.element.innerHTML = "";
|
|
1662
|
+
return this;
|
|
1663
|
+
}
|
|
1664
|
+
function render(target = this.target) {
|
|
1665
|
+
if(this.isBody)return ;
|
|
1666
|
+
if(target?.isUIElement)target=target.element;
|
|
1667
|
+
this.target=target;
|
|
1668
|
+
this.target?.appendChild(this.element);
|
|
1669
|
+
return this;
|
|
1670
|
+
}
|
|
1671
|
+
function unrender(){
|
|
1672
|
+
if(this.cache.parent)this.cache.parent.remove(this);
|
|
1673
|
+
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
1674
|
+
return this;
|
|
1675
|
+
}
|
|
1676
|
+
function renderAfter(t = 1) {
|
|
1677
|
+
setTimeout(() => this.render(), t);
|
|
1678
|
+
return this;
|
|
1679
|
+
}
|
|
1680
|
+
function unrenderAfter(t = 1) {
|
|
1681
|
+
setTimeout(() => this.unrender(), t);
|
|
1682
|
+
return this;
|
|
1683
|
+
}
|
|
1684
|
+
function after(ui){
|
|
1685
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1686
|
+
this.element?.after(ui);
|
|
1687
|
+
return this;
|
|
1688
|
+
}
|
|
1689
|
+
function before(ui){
|
|
1690
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1691
|
+
this.element?.before(ui);
|
|
1692
|
+
return this;
|
|
1478
1693
|
}
|
|
1479
1694
|
|
|
1695
|
+
var DomMethods = /*#__PURE__*/Object.freeze({
|
|
1696
|
+
__proto__: null,
|
|
1697
|
+
after: after,
|
|
1698
|
+
append: append,
|
|
1699
|
+
before: before,
|
|
1700
|
+
clear: clear,
|
|
1701
|
+
insertAt: insertAt,
|
|
1702
|
+
prepend: prepend,
|
|
1703
|
+
remove: remove,
|
|
1704
|
+
render: render,
|
|
1705
|
+
renderAfter: renderAfter,
|
|
1706
|
+
unrender: unrender,
|
|
1707
|
+
unrenderAfter: unrenderAfter
|
|
1708
|
+
});
|
|
1709
|
+
|
|
1480
1710
|
const Events = {
|
|
1481
1711
|
'Click' : [
|
|
1482
1712
|
'Click',
|
|
1483
|
-
'DblClick'
|
|
1713
|
+
'DblClick',
|
|
1714
|
+
'ClickAway'
|
|
1484
1715
|
],
|
|
1485
1716
|
'Ptr' : [
|
|
1486
1717
|
'PtrMove',
|
|
@@ -1696,9 +1927,11 @@ class __ZikoEvent__ {
|
|
|
1696
1927
|
}
|
|
1697
1928
|
}
|
|
1698
1929
|
|
|
1930
|
+
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
1699
1931
|
class ZikoEventClick extends __ZikoEvent__{
|
|
1700
1932
|
constructor(target, customizer){
|
|
1701
1933
|
super(target, Events.Click, details_setter$a, customizer);
|
|
1934
|
+
// register_click_away_event(target.element)
|
|
1702
1935
|
}
|
|
1703
1936
|
}
|
|
1704
1937
|
function details_setter$a(){
|
|
@@ -1706,7 +1939,7 @@ function details_setter$a(){
|
|
|
1706
1939
|
else this.dx = 1;
|
|
1707
1940
|
// console.log(this.currentEvent)
|
|
1708
1941
|
}
|
|
1709
|
-
const
|
|
1942
|
+
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
1710
1943
|
|
|
1711
1944
|
class ZikoEventClipboard extends __ZikoEvent__{
|
|
1712
1945
|
constructor(target, customizer){
|
|
@@ -1716,7 +1949,7 @@ class ZikoEventClipboard extends __ZikoEvent__{
|
|
|
1716
1949
|
function details_setter$9(){
|
|
1717
1950
|
|
|
1718
1951
|
}
|
|
1719
|
-
const
|
|
1952
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
1720
1953
|
|
|
1721
1954
|
class ZikoEventCustom extends __ZikoEvent__{
|
|
1722
1955
|
constructor(target, events, customizer){
|
|
@@ -1750,7 +1983,7 @@ class ZikoEventDrag extends __ZikoEvent__{
|
|
|
1750
1983
|
function details_setter$7(){
|
|
1751
1984
|
|
|
1752
1985
|
}
|
|
1753
|
-
const
|
|
1986
|
+
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
1754
1987
|
|
|
1755
1988
|
class ZikoEventFocus extends __ZikoEvent__{
|
|
1756
1989
|
constructor(target, customizer){
|
|
@@ -1760,7 +1993,7 @@ class ZikoEventFocus extends __ZikoEvent__{
|
|
|
1760
1993
|
function details_setter$6(){
|
|
1761
1994
|
|
|
1762
1995
|
}
|
|
1763
|
-
const
|
|
1996
|
+
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
1764
1997
|
|
|
1765
1998
|
let ZikoEventHash$1 = class ZikoEventHash extends __ZikoEvent__{
|
|
1766
1999
|
constructor(target, customizer){
|
|
@@ -1791,7 +2024,7 @@ function details_setter$4(){
|
|
|
1791
2024
|
|
|
1792
2025
|
}
|
|
1793
2026
|
}
|
|
1794
|
-
const
|
|
2027
|
+
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
1795
2028
|
|
|
1796
2029
|
class ZikoEventMouse extends __ZikoEvent__{
|
|
1797
2030
|
constructor(target, customizer){
|
|
@@ -1801,7 +2034,7 @@ class ZikoEventMouse extends __ZikoEvent__{
|
|
|
1801
2034
|
function details_setter$3(){
|
|
1802
2035
|
|
|
1803
2036
|
}
|
|
1804
|
-
const
|
|
2037
|
+
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
1805
2038
|
|
|
1806
2039
|
class ZikoEventPointer extends __ZikoEvent__{
|
|
1807
2040
|
constructor(target, customizer){
|
|
@@ -1842,7 +2075,7 @@ function details_setter$2(){
|
|
|
1842
2075
|
// else this.dx = 1
|
|
1843
2076
|
// console.log(this.currentEvent)
|
|
1844
2077
|
}
|
|
1845
|
-
const
|
|
2078
|
+
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
1846
2079
|
|
|
1847
2080
|
class ZikoEventTouch extends __ZikoEvent__{
|
|
1848
2081
|
constructor(target, customizer){
|
|
@@ -1862,17 +2095,17 @@ class ZikoEventWheel extends __ZikoEvent__{
|
|
|
1862
2095
|
function details_setter(){
|
|
1863
2096
|
|
|
1864
2097
|
}
|
|
1865
|
-
const
|
|
2098
|
+
const bind_wheel_event = (target, customizer) => new ZikoEventWheel(target, customizer);
|
|
1866
2099
|
|
|
1867
2100
|
const binderMap = {
|
|
1868
|
-
ptr:
|
|
1869
|
-
mouse :
|
|
1870
|
-
key:
|
|
1871
|
-
click :
|
|
1872
|
-
drag :
|
|
1873
|
-
clipboard :
|
|
1874
|
-
focus :
|
|
1875
|
-
wheel :
|
|
2101
|
+
ptr: bind_pointer_event,
|
|
2102
|
+
mouse : bind_mouse_event,
|
|
2103
|
+
key: bind_key_event,
|
|
2104
|
+
click : bind_click_event,
|
|
2105
|
+
drag : bind_drag_event,
|
|
2106
|
+
clipboard : bind_clipboard_event,
|
|
2107
|
+
focus : bind_focus_event,
|
|
2108
|
+
wheel : bind_wheel_event
|
|
1876
2109
|
};
|
|
1877
2110
|
|
|
1878
2111
|
const EventsMethodes = {};
|
|
@@ -1888,55 +2121,68 @@ Object.entries(Events).forEach(([name, eventList]) => {
|
|
|
1888
2121
|
});
|
|
1889
2122
|
});
|
|
1890
2123
|
|
|
1891
|
-
|
|
1892
|
-
at(index)
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
forEach(callback)
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
map(callback)
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
},
|
|
1905
|
-
};
|
|
2124
|
+
function at(index) {
|
|
2125
|
+
return this.items.at(index);
|
|
2126
|
+
}
|
|
2127
|
+
function forEach(callback) {
|
|
2128
|
+
this.items.forEach(callback);
|
|
2129
|
+
return this;
|
|
2130
|
+
}
|
|
2131
|
+
function map(callback) {
|
|
2132
|
+
return this.items.map(callback);
|
|
2133
|
+
}
|
|
2134
|
+
function find(condition) {
|
|
2135
|
+
return this.items.filter(condition);
|
|
2136
|
+
}
|
|
1906
2137
|
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
2138
|
+
var IndexingMethods = /*#__PURE__*/Object.freeze({
|
|
2139
|
+
__proto__: null,
|
|
2140
|
+
at: at,
|
|
2141
|
+
find: find,
|
|
2142
|
+
forEach: forEach,
|
|
2143
|
+
map: map
|
|
2144
|
+
});
|
|
2145
|
+
|
|
2146
|
+
function style(styles){
|
|
2147
|
+
for(let key in styles){
|
|
2148
|
+
const value = styles[key];
|
|
2149
|
+
if(isStateGetter(value)){
|
|
2150
|
+
const getter = value();
|
|
2151
|
+
Object.assign(this.element.style, {[key] : getter.value});
|
|
2152
|
+
getter._subscribe(
|
|
2153
|
+
(newValue) => {
|
|
2154
|
+
console.log({newValue});
|
|
2155
|
+
Object.assign(this.element.style, {[key] : newValue});
|
|
2156
|
+
},
|
|
2157
|
+
// this
|
|
2158
|
+
);
|
|
1923
2159
|
}
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
2160
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2161
|
+
}
|
|
2162
|
+
return this;
|
|
2163
|
+
}
|
|
2164
|
+
function size(width, height){
|
|
2165
|
+
return this.style({width, height})
|
|
2166
|
+
}
|
|
2167
|
+
function hide(){
|
|
1930
2168
|
|
|
1931
|
-
|
|
1932
|
-
|
|
2169
|
+
}
|
|
2170
|
+
function show(){
|
|
1933
2171
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2172
|
+
}
|
|
2173
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2174
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2175
|
+
return this;
|
|
2176
|
+
}
|
|
2177
|
+
|
|
2178
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2179
|
+
__proto__: null,
|
|
2180
|
+
animate: animate,
|
|
2181
|
+
hide: hide,
|
|
2182
|
+
show: show,
|
|
2183
|
+
size: size,
|
|
2184
|
+
style: style
|
|
2185
|
+
});
|
|
1940
2186
|
|
|
1941
2187
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
1942
2188
|
this.event=e;
|
|
@@ -2598,22 +2844,22 @@ class ZikoScreenObserver {
|
|
|
2598
2844
|
});
|
|
2599
2845
|
}
|
|
2600
2846
|
get x0(){
|
|
2601
|
-
return map(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2847
|
+
return map$1(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2602
2848
|
}
|
|
2603
2849
|
get y0(){
|
|
2604
|
-
return - map(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2850
|
+
return - map$1(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2605
2851
|
}
|
|
2606
2852
|
get x1(){
|
|
2607
|
-
return map(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2853
|
+
return map$1(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2608
2854
|
}
|
|
2609
2855
|
get y1(){
|
|
2610
|
-
return - map(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2856
|
+
return - map$1(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2611
2857
|
}
|
|
2612
2858
|
get cx(){
|
|
2613
|
-
return map(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2859
|
+
return map$1(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2614
2860
|
}
|
|
2615
2861
|
get cy(){
|
|
2616
|
-
return - map(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2862
|
+
return - map$1(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2617
2863
|
}
|
|
2618
2864
|
}
|
|
2619
2865
|
|
|
@@ -2875,22 +3121,12 @@ class ZikoUseMediaQuery {
|
|
|
2875
3121
|
|
|
2876
3122
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
2877
3123
|
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
|
|
3124
|
+
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3125
|
+
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
2881
3126
|
super();
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
|
|
2885
|
-
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
2886
|
-
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
2887
|
-
default : throw Error("Not supported")
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
else {
|
|
2891
|
-
this.target = element?.parentElement;
|
|
2892
|
-
}
|
|
2893
|
-
register(
|
|
3127
|
+
console.log({type});
|
|
3128
|
+
// console.log(this)
|
|
3129
|
+
register_to_class(
|
|
2894
3130
|
this,
|
|
2895
3131
|
AttrsMethods,
|
|
2896
3132
|
DomMethods,
|
|
@@ -2898,61 +3134,7 @@ class UIElement extends UINode{
|
|
|
2898
3134
|
IndexingMethods,
|
|
2899
3135
|
EventsMethodes
|
|
2900
3136
|
);
|
|
2901
|
-
|
|
2902
|
-
name,
|
|
2903
|
-
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
2904
|
-
parent:null,
|
|
2905
|
-
isBody:false,
|
|
2906
|
-
isRoot:false,
|
|
2907
|
-
isHidden: false,
|
|
2908
|
-
isFrozzen:false,
|
|
2909
|
-
legacyParent : null,
|
|
2910
|
-
attributes: {},
|
|
2911
|
-
filters: {},
|
|
2912
|
-
temp:{}
|
|
2913
|
-
});
|
|
2914
|
-
this.events = {
|
|
2915
|
-
ptr:null,
|
|
2916
|
-
mouse:null,
|
|
2917
|
-
wheel:null,
|
|
2918
|
-
key:null,
|
|
2919
|
-
drag:null,
|
|
2920
|
-
drop:null,
|
|
2921
|
-
click:null,
|
|
2922
|
-
clipboard:null,
|
|
2923
|
-
focus:null,
|
|
2924
|
-
swipe:null,
|
|
2925
|
-
custom:null,
|
|
2926
|
-
};
|
|
2927
|
-
this.observer={
|
|
2928
|
-
resize:null,
|
|
2929
|
-
intersection:null
|
|
2930
|
-
};
|
|
2931
|
-
if(element) Object.assign(this.cache,{element});
|
|
2932
|
-
// this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
2933
|
-
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
2934
|
-
useDefaultStyle && this.style({
|
|
2935
|
-
position: "relative",
|
|
2936
|
-
boxSizing:"border-box",
|
|
2937
|
-
margin:0,
|
|
2938
|
-
padding:0,
|
|
2939
|
-
width : "auto",
|
|
2940
|
-
height : "auto"
|
|
2941
|
-
});
|
|
2942
|
-
this.items = new UIStore();
|
|
2943
|
-
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
2944
|
-
element && render && this?.render?.();
|
|
2945
|
-
if(
|
|
2946
|
-
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
2947
|
-
// &&
|
|
2948
|
-
// !globalThis.__Ziko__.__Config__.isSSC
|
|
2949
|
-
// &&
|
|
2950
|
-
this.isInteractive()
|
|
2951
|
-
){
|
|
2952
|
-
this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
2953
|
-
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
2954
|
-
}
|
|
2955
|
-
globalThis.__Ziko__.__UI__.push(this);
|
|
3137
|
+
this.init(element, name, type, render);
|
|
2956
3138
|
}
|
|
2957
3139
|
get element(){
|
|
2958
3140
|
return this.cache.element;
|
|
@@ -2960,9 +3142,9 @@ class UIElement extends UINode{
|
|
|
2960
3142
|
isInteractive(){
|
|
2961
3143
|
return this.cache.isInteractive;
|
|
2962
3144
|
}
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
}
|
|
3145
|
+
// isUIElement(){
|
|
3146
|
+
// return true;
|
|
3147
|
+
// }
|
|
2966
3148
|
get st(){
|
|
2967
3149
|
return this.cache.style;
|
|
2968
3150
|
}
|
|
@@ -3002,73 +3184,73 @@ class UIElement extends UINode{
|
|
|
3002
3184
|
get left(){
|
|
3003
3185
|
return this.element.getBoundingClientRect().left;
|
|
3004
3186
|
}
|
|
3005
|
-
clone(render=false) {
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
}
|
|
3014
|
-
[Symbol.iterator]() {
|
|
3015
|
-
|
|
3016
|
-
}
|
|
3017
|
-
maintain() {
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
}
|
|
3027
|
-
freeze(freeze){
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
}
|
|
3187
|
+
// clone(render=false) {
|
|
3188
|
+
// // UI.__proto__=this.__proto__;
|
|
3189
|
+
// // if(this.items.length){
|
|
3190
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
3191
|
+
// // UI.append(...items);
|
|
3192
|
+
// // }
|
|
3193
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
3194
|
+
// // return UI.render(render);
|
|
3195
|
+
// }
|
|
3196
|
+
// [Symbol.iterator]() {
|
|
3197
|
+
// return this.items[Symbol.iterator]();
|
|
3198
|
+
// }
|
|
3199
|
+
// maintain() {
|
|
3200
|
+
// for (let i = 0; i < this.items.length; i++) {
|
|
3201
|
+
// Object.defineProperty(this, i, {
|
|
3202
|
+
// value: this.items[i],
|
|
3203
|
+
// writable: true,
|
|
3204
|
+
// configurable: true,
|
|
3205
|
+
// enumerable: false
|
|
3206
|
+
// });
|
|
3207
|
+
// }
|
|
3208
|
+
// }
|
|
3209
|
+
// freeze(freeze){
|
|
3210
|
+
// this.cache.isFrozzen=freeze;
|
|
3211
|
+
// return this;
|
|
3212
|
+
// }
|
|
3031
3213
|
// setTarget(tg) {
|
|
3032
3214
|
// if(this.isBody) return ;
|
|
3033
|
-
// if (tg?.
|
|
3215
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
3034
3216
|
// this.unrender();
|
|
3035
3217
|
// this.target = tg;
|
|
3036
3218
|
// this.render();
|
|
3037
3219
|
// return this;
|
|
3038
3220
|
// }
|
|
3039
|
-
describe(label){
|
|
3040
|
-
|
|
3041
|
-
}
|
|
3042
|
-
get children() {
|
|
3043
|
-
|
|
3044
|
-
}
|
|
3045
|
-
get cloneElement() {
|
|
3046
|
-
|
|
3047
|
-
}
|
|
3048
|
-
setClasses(...value) {
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
}
|
|
3052
|
-
get classes(){
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
}
|
|
3056
|
-
addClass() {
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
}
|
|
3060
|
-
setId(id) {
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
}
|
|
3064
|
-
get id() {
|
|
3065
|
-
|
|
3066
|
-
}
|
|
3067
|
-
onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
}
|
|
3221
|
+
// describe(label){
|
|
3222
|
+
// if(label)this.setAttr("aria-label",label)
|
|
3223
|
+
// }
|
|
3224
|
+
// get children() {
|
|
3225
|
+
// return [...this.element.children];
|
|
3226
|
+
// }
|
|
3227
|
+
// get cloneElement() {
|
|
3228
|
+
// return this.element.cloneNode(true);
|
|
3229
|
+
// }
|
|
3230
|
+
// setClasses(...value) {
|
|
3231
|
+
// this.setAttr("class", value.join(" "));
|
|
3232
|
+
// return this;
|
|
3233
|
+
// }
|
|
3234
|
+
// get classes(){
|
|
3235
|
+
// const classes=this.element.getAttribute("class");
|
|
3236
|
+
// return classes===null?[]:classes.split(" ");
|
|
3237
|
+
// }
|
|
3238
|
+
// addClass() {
|
|
3239
|
+
// /*this.setAttr("class", value);
|
|
3240
|
+
// return this;*/
|
|
3241
|
+
// }
|
|
3242
|
+
// setId(id) {
|
|
3243
|
+
// this.setAttr("id", id);
|
|
3244
|
+
// return this;
|
|
3245
|
+
// }
|
|
3246
|
+
// get id() {
|
|
3247
|
+
// return this.element.getAttribute("id");
|
|
3248
|
+
// }
|
|
3249
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3250
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
3251
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
3252
|
+
// return this;
|
|
3253
|
+
// }
|
|
3072
3254
|
// To Fix
|
|
3073
3255
|
// onKeysDown({keys=[],callback}={}){
|
|
3074
3256
|
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
@@ -3090,26 +3272,26 @@ class UIElement extends UINode{
|
|
|
3090
3272
|
this.events.custom.emit(event_name,detail);
|
|
3091
3273
|
return this;
|
|
3092
3274
|
}
|
|
3093
|
-
watchAttr(callback){
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
}
|
|
3097
|
-
watchChildren(callback){
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
}
|
|
3101
|
-
watchSize(callback){
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
}
|
|
3106
|
-
watchIntersection(callback,config){
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
}
|
|
3275
|
+
// watchAttr(callback){
|
|
3276
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
3277
|
+
// return this;
|
|
3278
|
+
// }
|
|
3279
|
+
// watchChildren(callback){
|
|
3280
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
3281
|
+
// return this;
|
|
3282
|
+
// }
|
|
3283
|
+
// watchSize(callback){
|
|
3284
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
3285
|
+
// this.observer.resize.start();
|
|
3286
|
+
// return this;
|
|
3287
|
+
// }
|
|
3288
|
+
// watchIntersection(callback,config){
|
|
3289
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
3290
|
+
// this.observer.intersection.start();
|
|
3291
|
+
// return this;
|
|
3292
|
+
// }
|
|
3111
3293
|
|
|
3112
|
-
}
|
|
3294
|
+
};
|
|
3113
3295
|
|
|
3114
3296
|
const HTMLTags = [
|
|
3115
3297
|
'a',
|
|
@@ -3199,7 +3381,6 @@ const HTMLTags = [
|
|
|
3199
3381
|
'sub',
|
|
3200
3382
|
'summary',
|
|
3201
3383
|
'sup',
|
|
3202
|
-
'svg',
|
|
3203
3384
|
'table',
|
|
3204
3385
|
'tbody',
|
|
3205
3386
|
'td',
|
|
@@ -3233,6 +3414,9 @@ const SVGTags = [
|
|
|
3233
3414
|
"desc", "title", "metadata", "foreignObject"
|
|
3234
3415
|
];
|
|
3235
3416
|
|
|
3417
|
+
// const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
|
|
3418
|
+
// const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
|
|
3419
|
+
|
|
3236
3420
|
const tags = new Proxy({}, {
|
|
3237
3421
|
get(target, prop) {
|
|
3238
3422
|
if (typeof prop !== 'string') return undefined;
|
|
@@ -3240,16 +3424,22 @@ const tags = new Proxy({}, {
|
|
|
3240
3424
|
let type ;
|
|
3241
3425
|
if(HTMLTags.includes(tag)) type = 'html';
|
|
3242
3426
|
if(SVGTags.includes(tag)) type = 'svg';
|
|
3427
|
+
console.log(type);
|
|
3243
3428
|
return (...args)=>{
|
|
3244
3429
|
// Fix undefined
|
|
3245
3430
|
// console.log(isStateGetter(args[0]))
|
|
3431
|
+
// console.log(!!args)
|
|
3432
|
+
if(args.length === 0) {
|
|
3433
|
+
console.log('length 0');
|
|
3434
|
+
return new UIElement$1({element : tag, name : tag, type})
|
|
3435
|
+
}
|
|
3246
3436
|
if(
|
|
3247
3437
|
['string', 'number'].includes(typeof args[0])
|
|
3248
|
-
|| args[0] instanceof UIElement
|
|
3438
|
+
|| args[0] instanceof UIElement$1
|
|
3249
3439
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3250
|
-
) return new UIElement({element : tag, name : tag, type}).append(...args);
|
|
3440
|
+
) return new UIElement$1({element : tag, name : tag, type}).append(...args);
|
|
3251
3441
|
// console.log(args[0])
|
|
3252
|
-
return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
|
|
3442
|
+
return new UIElement$1({element : tag, type}).setAttr(args.shift()).append(...args)
|
|
3253
3443
|
}
|
|
3254
3444
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3255
3445
|
// return (...args)=>{
|
|
@@ -3272,7 +3462,7 @@ const tags = new Proxy({}, {
|
|
|
3272
3462
|
}
|
|
3273
3463
|
});
|
|
3274
3464
|
|
|
3275
|
-
class ZikoUIFlex extends UIElement {
|
|
3465
|
+
class ZikoUIFlex extends UIElement$1 {
|
|
3276
3466
|
constructor(tag = "div", w = "100%", h = "100%") {
|
|
3277
3467
|
super({element : tag , name : "Flex"});
|
|
3278
3468
|
this.direction = "cols";
|
|
@@ -3371,37 +3561,11 @@ function map_pos_y(align){
|
|
|
3371
3561
|
return map_pos_x(-align);
|
|
3372
3562
|
}
|
|
3373
3563
|
|
|
3374
|
-
class
|
|
3375
|
-
constructor(
|
|
3376
|
-
|
|
3377
|
-
this.direction = "cols";
|
|
3378
|
-
if (typeof w == "number") w += "%";
|
|
3379
|
-
if (typeof h == "number") h += "%";
|
|
3380
|
-
this.style({ border: "1px solid black", width: w, height: h });
|
|
3381
|
-
this.style({ display: "grid" });
|
|
3382
|
-
// this.render();
|
|
3383
|
-
}
|
|
3384
|
-
get isGird(){
|
|
3385
|
-
return true;
|
|
3386
|
-
}
|
|
3387
|
-
columns(n) {
|
|
3388
|
-
let temp = "";
|
|
3389
|
-
for (let i = 0; i < n; i++) temp = temp.concat(" auto");
|
|
3390
|
-
this.#templateColumns(temp);
|
|
3391
|
-
return this;
|
|
3392
|
-
}
|
|
3393
|
-
#templateColumns(temp = "auto auto") {
|
|
3394
|
-
this.style({ gridTemplateColumns: temp });
|
|
3395
|
-
return this;
|
|
3396
|
-
}
|
|
3397
|
-
gap(w = 10, h = w) {
|
|
3398
|
-
if(typeof (w) === "number")w += "px";
|
|
3399
|
-
if(typeof (h) === "number")h += "px";
|
|
3400
|
-
this.style({gridColumnGap: w,gridRowGap: h});
|
|
3401
|
-
return this;
|
|
3564
|
+
class UIElement extends UIElementCore{
|
|
3565
|
+
constructor({element, name, type, render}){
|
|
3566
|
+
super({element, name, type, render});
|
|
3402
3567
|
}
|
|
3403
|
-
}
|
|
3404
|
-
const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
|
|
3568
|
+
}
|
|
3405
3569
|
|
|
3406
3570
|
class ZikoUISuspense extends UIElement{
|
|
3407
3571
|
constructor(fallback_ui, callback){
|
|
@@ -3427,12 +3591,16 @@ class ZikoUISuspense extends UIElement{
|
|
|
3427
3591
|
|
|
3428
3592
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3429
3593
|
|
|
3430
|
-
class
|
|
3431
|
-
constructor(
|
|
3432
|
-
super({element :
|
|
3433
|
-
this.element.append(
|
|
3594
|
+
class UIHTMLWrapper extends UIElement$1 {
|
|
3595
|
+
constructor(content){
|
|
3596
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3597
|
+
this.element.append(html2dom(content));
|
|
3598
|
+
this.style({
|
|
3599
|
+
display : 'contents'
|
|
3600
|
+
});
|
|
3434
3601
|
}
|
|
3435
3602
|
}
|
|
3603
|
+
|
|
3436
3604
|
function html2dom(htmlString) {
|
|
3437
3605
|
if(globalThis?.DOMParser){
|
|
3438
3606
|
const parser = new DOMParser();
|
|
@@ -3440,261 +3608,50 @@ function html2dom(htmlString) {
|
|
|
3440
3608
|
doc.body.firstChild.style.display = "contents";
|
|
3441
3609
|
return doc.body.firstChild;
|
|
3442
3610
|
}
|
|
3443
|
-
}
|
|
3444
|
-
function svg2dom(svgString) {
|
|
3445
|
-
if(globalThis?.DOMParser){
|
|
3446
|
-
const parser = new DOMParser();
|
|
3447
|
-
const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
|
|
3448
|
-
return doc.documentElement; // SVG elements are usually at the root
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
|
-
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
3452
|
-
constructor(HTMLContent){
|
|
3453
|
-
super(HTMLContent, "html");
|
|
3454
|
-
}
|
|
3455
3611
|
}
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
super(SVGContent, "svg");
|
|
3459
|
-
}
|
|
3460
|
-
}
|
|
3461
|
-
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
3462
|
-
const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
|
|
3612
|
+
|
|
3613
|
+
const HTMLWrapper = (content) => new UIHTMLWrapper(content);
|
|
3463
3614
|
|
|
3464
|
-
class
|
|
3465
|
-
constructor(
|
|
3466
|
-
super(
|
|
3467
|
-
this.
|
|
3615
|
+
class UISVGWrapper extends UIElement$1 {
|
|
3616
|
+
constructor(content){
|
|
3617
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3618
|
+
this.element.append(svg2dom(content));
|
|
3468
3619
|
this.style({
|
|
3469
|
-
|
|
3470
|
-
});
|
|
3471
|
-
this.transformMatrix = new Matrix([
|
|
3472
|
-
[1,0,0],
|
|
3473
|
-
[0,1,0],
|
|
3474
|
-
[0,0,1]
|
|
3475
|
-
]);
|
|
3476
|
-
this.axisMatrix = new Matrix([
|
|
3477
|
-
[-10,-10],
|
|
3478
|
-
[10,10]
|
|
3479
|
-
]);
|
|
3480
|
-
// setTimeout(()=>this.resize(w,h),0);
|
|
3481
|
-
requestAnimationFrame(()=>this.resize(w,h),0);
|
|
3482
|
-
this.on("sizeupdated",()=>this.adjust());
|
|
3483
|
-
}
|
|
3484
|
-
get Xmin(){
|
|
3485
|
-
return this.axisMatrix[0][0];
|
|
3486
|
-
}
|
|
3487
|
-
get Ymin(){
|
|
3488
|
-
return this.axisMatrix[0][1];
|
|
3489
|
-
}
|
|
3490
|
-
get Xmax(){
|
|
3491
|
-
return this.axisMatrix[1][0];
|
|
3492
|
-
}
|
|
3493
|
-
get Ymax(){
|
|
3494
|
-
return this.axisMatrix[1][1];
|
|
3495
|
-
}
|
|
3496
|
-
get ImageData(){
|
|
3497
|
-
return this.ctx.getImageData(0,0,c.Width,c.Height);
|
|
3498
|
-
}
|
|
3499
|
-
draw(all=true){
|
|
3500
|
-
if(all){
|
|
3501
|
-
this.clear();
|
|
3502
|
-
this.items.forEach(element => {
|
|
3503
|
-
element.parent=this;
|
|
3504
|
-
element.draw(this.ctx);
|
|
3505
|
-
});
|
|
3506
|
-
}
|
|
3507
|
-
else {
|
|
3508
|
-
this.items.at(-1).parent=this;
|
|
3509
|
-
this.items.at(-1).draw(this.ctx);
|
|
3510
|
-
}
|
|
3511
|
-
this.maintain();
|
|
3512
|
-
return this;
|
|
3513
|
-
}
|
|
3514
|
-
applyTransformMatrix(){
|
|
3515
|
-
this.ctx.setTransform(
|
|
3516
|
-
this.transformMatrix[0][0],
|
|
3517
|
-
this.transformMatrix[1][0],
|
|
3518
|
-
this.transformMatrix[0][1],
|
|
3519
|
-
this.transformMatrix[1][1],
|
|
3520
|
-
this.transformMatrix[0][2],
|
|
3521
|
-
this.transformMatrix[1][2],
|
|
3522
|
-
);
|
|
3523
|
-
return this;
|
|
3524
|
-
}
|
|
3525
|
-
resize(w,h){
|
|
3526
|
-
this.size(w,h);
|
|
3527
|
-
this.lineWidth();
|
|
3528
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
3529
|
-
this.emit("sizeupdated");
|
|
3530
|
-
return this;
|
|
3531
|
-
}
|
|
3532
|
-
adjust(){
|
|
3533
|
-
this.element.width =this.element?.getBoundingClientRect().width;
|
|
3534
|
-
this.element.height =this.element?.getBoundingClientRect().height;
|
|
3535
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
3536
|
-
return this;
|
|
3537
|
-
}
|
|
3538
|
-
view(xMin,yMin,xMax,yMax){
|
|
3539
|
-
this.transformMatrix[0][0]=this.width/(xMax-xMin); // scaleX
|
|
3540
|
-
this.transformMatrix[1][1]=-this.height/(yMax-yMin); // scaleY
|
|
3541
|
-
this.transformMatrix[0][2]=this.width/2;
|
|
3542
|
-
this.transformMatrix[1][2]=this.height/2;
|
|
3543
|
-
this.axisMatrix=new Matrix([
|
|
3544
|
-
[xMin,yMin],
|
|
3545
|
-
[xMax,yMax]
|
|
3546
|
-
]);
|
|
3547
|
-
|
|
3548
|
-
this.applyTransformMatrix();
|
|
3549
|
-
this.clear();
|
|
3550
|
-
this.lineWidth(1);
|
|
3551
|
-
this.draw();
|
|
3552
|
-
return this;
|
|
3553
|
-
}
|
|
3554
|
-
reset(){
|
|
3555
|
-
this.ctx.setTransform(1,0,0,0,0,0);
|
|
3556
|
-
return this;
|
|
3557
|
-
}
|
|
3558
|
-
append(element){
|
|
3559
|
-
this.items.push(element);
|
|
3560
|
-
this.draw(false);
|
|
3561
|
-
return this;
|
|
3562
|
-
}
|
|
3563
|
-
background(color){
|
|
3564
|
-
this.ctx.fillStyle = color;
|
|
3565
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3566
|
-
this.ctx.fillRect(0, 0, this.width, this.height);
|
|
3567
|
-
this.applyTransformMatrix();
|
|
3568
|
-
this.draw();
|
|
3569
|
-
}
|
|
3570
|
-
lineWidth(w){
|
|
3571
|
-
this.ctx.lineWidth=w/this.transformMatrix[0][0];
|
|
3572
|
-
return this
|
|
3573
|
-
}
|
|
3574
|
-
getImageData(x=0,y=0,w=this.width,h=this.height){
|
|
3575
|
-
return this.ctx.getImageData(x,y,w,h);
|
|
3576
|
-
}
|
|
3577
|
-
clear(){
|
|
3578
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3579
|
-
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
3580
|
-
this.applyTransformMatrix();
|
|
3581
|
-
return this;
|
|
3582
|
-
}
|
|
3583
|
-
clone(){
|
|
3584
|
-
console.log(this.width);
|
|
3585
|
-
const canvas=new ZikoUICanvas();
|
|
3586
|
-
canvas.items=this.items;
|
|
3587
|
-
canvas.transformMatrix=this.transformMatrix;
|
|
3588
|
-
canvas.axisMatrix=this.axisMatrix;
|
|
3589
|
-
Object.assign(canvas.cache,{...this.cache});
|
|
3590
|
-
//waitForUIElm(this)
|
|
3591
|
-
//console.log(element)
|
|
3592
|
-
this.size(this.element.style.width,this.element.style.width);
|
|
3593
|
-
this.applyTransformMatrix();
|
|
3594
|
-
this.draw();
|
|
3595
|
-
this.adjust();
|
|
3596
|
-
return canvas;
|
|
3597
|
-
}
|
|
3598
|
-
toImage() {
|
|
3599
|
-
this.img = document?.createElement("img");
|
|
3600
|
-
this.img.src = this.element?.toDataURL("image/png");
|
|
3601
|
-
return this;
|
|
3602
|
-
}
|
|
3603
|
-
toBlob() {
|
|
3604
|
-
var canvas = this.element;
|
|
3605
|
-
canvas.toBlob(function (blob) {
|
|
3606
|
-
var newImg = document?.createElement("img"),
|
|
3607
|
-
url = URL.createObjectURL(blob);
|
|
3608
|
-
newImg.onload = function () {
|
|
3609
|
-
URL.revokeObjectURL(url);
|
|
3610
|
-
};
|
|
3611
|
-
newImg.src = url;
|
|
3612
|
-
console.log(newImg);
|
|
3620
|
+
display : 'contents'
|
|
3613
3621
|
});
|
|
3614
3622
|
}
|
|
3615
|
-
zoomIn(){
|
|
3616
|
-
|
|
3617
|
-
}
|
|
3618
|
-
zoomOut(){
|
|
3619
|
-
|
|
3620
|
-
}
|
|
3621
|
-
undo(n){
|
|
3622
|
-
|
|
3623
|
-
}
|
|
3624
|
-
redo(n){
|
|
3625
|
-
|
|
3626
|
-
}
|
|
3627
|
-
stream(){
|
|
3628
|
-
|
|
3629
|
-
}
|
|
3630
3623
|
}
|
|
3631
3624
|
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
}
|
|
3656
|
-
view(x1,y1,x2,y2){
|
|
3657
|
-
let width=Math.abs(x2-x1);
|
|
3658
|
-
let height=Math.abs(y2-y1);
|
|
3659
|
-
this.setAttr("viewBox",[x1,y1,width,height].join(" "));
|
|
3660
|
-
this.st.scaleY(-1);
|
|
3661
|
-
return this;
|
|
3662
|
-
}
|
|
3663
|
-
add(...svgElement){
|
|
3664
|
-
for(let i=0;i<svgElement.length;i++){
|
|
3665
|
-
this.element.append(svgElement[i].element);
|
|
3666
|
-
this.items.push(svgElement[i]);
|
|
3667
|
-
}
|
|
3668
|
-
this.maintain();
|
|
3669
|
-
return this;
|
|
3670
|
-
}
|
|
3671
|
-
remove(...svgElement){
|
|
3672
|
-
for(let i=0;i<svgElement.length;i++){
|
|
3673
|
-
this.element?.removeChild(svgElement[i].element);
|
|
3674
|
-
this.items=this.items.filter(n=>!svgElement);
|
|
3675
|
-
}
|
|
3676
|
-
this.maintain();
|
|
3677
|
-
return this;
|
|
3678
|
-
}
|
|
3679
|
-
mask(){
|
|
3680
|
-
|
|
3681
|
-
}
|
|
3682
|
-
toString(){
|
|
3683
|
-
return (new XMLSerializer()).serializeToString(this.element);
|
|
3684
|
-
}
|
|
3685
|
-
btoa(){
|
|
3686
|
-
return btoa(this.toString())
|
|
3687
|
-
}
|
|
3688
|
-
toImg(){
|
|
3689
|
-
return 'data:image/svg+xml;base64,'+this.btoa()
|
|
3690
|
-
}
|
|
3691
|
-
toImg2(){
|
|
3692
|
-
return "data:image/svg+xml;charset=utf8,"+this.toString().replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("#","%23").replaceAll('"',"'");
|
|
3693
|
-
}
|
|
3694
|
-
|
|
3625
|
+
function svg2dom(svgString) {
|
|
3626
|
+
if (typeof DOMParser !== "undefined") {
|
|
3627
|
+
const parser = new DOMParser();
|
|
3628
|
+
const doc = parser.parseFromString(svgString.trim(), "image/svg+xml");
|
|
3629
|
+
const svg = doc.documentElement;
|
|
3630
|
+
|
|
3631
|
+
if (svg.nodeName === "parsererror") {
|
|
3632
|
+
throw new Error("Invalid SVG string");
|
|
3633
|
+
}
|
|
3634
|
+
if(svg.hasAttribute('xmlns')) return svg
|
|
3635
|
+
// TO Fix ...
|
|
3636
|
+
const {children, attributes} = svg;
|
|
3637
|
+
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3638
|
+
for(let {name, value} of attributes){
|
|
3639
|
+
element.setAttribute(name, value);
|
|
3640
|
+
}
|
|
3641
|
+
element.append(...children);
|
|
3642
|
+
|
|
3643
|
+
globalThis.svg = svg;
|
|
3644
|
+
globalThis.children = children;
|
|
3645
|
+
globalThis.attributes = attributes;
|
|
3646
|
+
globalThis.element = element;
|
|
3647
|
+
return element;
|
|
3695
3648
|
}
|
|
3649
|
+
throw new Error("DOMParser is not available in this environment");
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3652
|
+
|
|
3696
3653
|
|
|
3697
|
-
|
|
3654
|
+
const SVGWrapper = (content) => new UISVGWrapper(content);
|
|
3698
3655
|
|
|
3699
3656
|
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3700
3657
|
if (globalThis.customElements?.get(name)) {
|
|
@@ -4964,7 +4921,7 @@ class TimeAnimation {
|
|
|
4964
4921
|
this.t += this.state.step;
|
|
4965
4922
|
this.i++;
|
|
4966
4923
|
|
|
4967
|
-
this.tx = map(this.t, 0, this.state.duration, 0, 1);
|
|
4924
|
+
this.tx = map$1(this.t, 0, this.state.duration, 0, 1);
|
|
4968
4925
|
this.ty = this.state.ease(this.tx);
|
|
4969
4926
|
|
|
4970
4927
|
this.callback(this);
|
|
@@ -5409,7 +5366,7 @@ class ZikoApp {
|
|
|
5409
5366
|
return this;
|
|
5410
5367
|
}
|
|
5411
5368
|
setWrapper(wrapper){
|
|
5412
|
-
if(wrapper?.
|
|
5369
|
+
if(wrapper?.isUIElement) this.wrapper = wrapper;
|
|
5413
5370
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5414
5371
|
return this;
|
|
5415
5372
|
}
|
|
@@ -5481,7 +5438,7 @@ class ZikoSPA extends ZikoApp{
|
|
|
5481
5438
|
}
|
|
5482
5439
|
clear(){
|
|
5483
5440
|
[...this.routes].forEach(n=>{
|
|
5484
|
-
!isDynamic(n[0]) && n[1]?.
|
|
5441
|
+
!isDynamic(n[0]) && n[1]?.isUIElement && n[1].unrender();
|
|
5485
5442
|
});
|
|
5486
5443
|
// this.wrapper.clear();
|
|
5487
5444
|
return this;
|
|
@@ -5494,10 +5451,10 @@ class ZikoSPA extends ZikoApp{
|
|
|
5494
5451
|
element = callback.call(this,params);
|
|
5495
5452
|
}
|
|
5496
5453
|
else {
|
|
5497
|
-
callback?.
|
|
5454
|
+
callback?.isUIElement && callback.render(this.wrapper);
|
|
5498
5455
|
if(typeof callback === "function") element = callback();
|
|
5499
5456
|
}
|
|
5500
|
-
if(element?.
|
|
5457
|
+
if(element?.isUIElement) element.render(this.wrapper);
|
|
5501
5458
|
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
5502
5459
|
if(element instanceof Promise){
|
|
5503
5460
|
element.then(e=>e.render(this.wrapper));
|
|
@@ -5570,11 +5527,12 @@ function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts'])
|
|
|
5570
5527
|
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
5571
5528
|
const parts = normalizedPath.split('/');
|
|
5572
5529
|
const rootParts = root.split('/');
|
|
5573
|
-
const rootIndex = parts.indexOf(rootParts
|
|
5530
|
+
const rootIndex = parts.indexOf(rootParts.at(-1));
|
|
5574
5531
|
if (rootIndex !== -1) {
|
|
5575
5532
|
const subsequentParts = parts.slice(rootIndex + 1);
|
|
5576
|
-
const lastPart =
|
|
5533
|
+
const lastPart = parts.at(-1);
|
|
5577
5534
|
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
5535
|
+
// console.log({extensions, subsequentParts, lastPart, isIndexFile, rootParts, rootIndex, parts})
|
|
5578
5536
|
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
5579
5537
|
if (isIndexFile) {
|
|
5580
5538
|
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
@@ -5934,4 +5892,4 @@ if(globalThis?.document){
|
|
|
5934
5892
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
5935
5893
|
}
|
|
5936
5894
|
|
|
5937
|
-
export { App, Arc, Back, Base,
|
|
5895
|
+
export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
|