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.js
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
|
|
@@ -255,17 +255,17 @@
|
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
|
-
const map=(value, a, b, c, d)=>{
|
|
258
|
+
const map$1=(value, a, b, c, d)=>{
|
|
259
259
|
if (typeof value === "number") return lerp(norm(value, a, b), c, d);
|
|
260
|
-
else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, map(value.arr.flat(1), a, b, c, d));
|
|
261
|
-
else if (value instanceof Complex) return new Complex(map(value.a, b, c, d), map(value.b, a, b, c, d));
|
|
260
|
+
else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, map$1(value.arr.flat(1), a, b, c, d));
|
|
261
|
+
else if (value instanceof Complex) return new Complex(map$1(value.a, b, c, d), map$1(value.b, a, b, c, d));
|
|
262
262
|
else if (value instanceof Array) {
|
|
263
263
|
if (value.every((n) => typeof (n === "number"))) {
|
|
264
|
-
return value.map((n) => map(n, a, b, c, d));
|
|
264
|
+
return value.map((n) => map$1(n, a, b, c, d));
|
|
265
265
|
} else {
|
|
266
266
|
let y = new Array(value.length);
|
|
267
267
|
for (let i = 0; i < value.length; i++) {
|
|
268
|
-
y[i] = map(value[i], a, b, c, d);
|
|
268
|
+
y[i] = map$1(value[i], a, b, c, d);
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
}
|
|
@@ -538,7 +538,7 @@
|
|
|
538
538
|
nums,
|
|
539
539
|
norm,
|
|
540
540
|
lerp,
|
|
541
|
-
map,
|
|
541
|
+
map: map$1,
|
|
542
542
|
clamp,
|
|
543
543
|
arange,
|
|
544
544
|
linspace,
|
|
@@ -1080,47 +1080,6 @@
|
|
|
1080
1080
|
|
|
1081
1081
|
// globalThis.node = (node) => new UINode(node);
|
|
1082
1082
|
|
|
1083
|
-
function register_to_class(target, ...mixins){
|
|
1084
|
-
mixins.forEach(n => _register_to_class_(target, n));
|
|
1085
|
-
}
|
|
1086
|
-
function _register_to_class_(target, mixin) {
|
|
1087
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1088
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1089
|
-
const desc = descriptors[key];
|
|
1090
|
-
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1091
|
-
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1092
|
-
} else if (typeof desc.value === 'function') {
|
|
1093
|
-
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1094
|
-
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
function register_to_instance(target, ...mixins){
|
|
1101
|
-
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1102
|
-
}
|
|
1103
|
-
function _register_to_instance_(instance, mixin) {
|
|
1104
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1105
|
-
|
|
1106
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1107
|
-
const desc = descriptors[key];
|
|
1108
|
-
|
|
1109
|
-
if ('get' in desc || 'set' in desc) {
|
|
1110
|
-
Object.defineProperty(instance, key, desc);
|
|
1111
|
-
} else if (typeof desc.value === 'function') {
|
|
1112
|
-
instance[key] = desc.value.bind(instance);
|
|
1113
|
-
} else {
|
|
1114
|
-
instance[key] = desc.value;
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
const register = (target, ...mixins) => {
|
|
1120
|
-
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1121
|
-
else register_to_instance(target, ...mixins);
|
|
1122
|
-
};
|
|
1123
|
-
|
|
1124
1083
|
function parseQueryParams$1(queryString) {
|
|
1125
1084
|
const params = {};
|
|
1126
1085
|
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
@@ -1243,11 +1202,261 @@
|
|
|
1243
1202
|
}
|
|
1244
1203
|
}
|
|
1245
1204
|
|
|
1205
|
+
__init__global__();
|
|
1206
|
+
class UIElementCore extends UINode{
|
|
1207
|
+
constructor(){
|
|
1208
|
+
super();
|
|
1209
|
+
}
|
|
1210
|
+
init(element, name, type, render, isInteractive = [true, false][Math.floor(2*Math.random())]){
|
|
1211
|
+
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1212
|
+
if(typeof element === "string") {
|
|
1213
|
+
switch(type){
|
|
1214
|
+
case "html" : {
|
|
1215
|
+
element = globalThis?.document?.createElement(element);
|
|
1216
|
+
console.log('1');
|
|
1217
|
+
} break;
|
|
1218
|
+
case "svg" : {
|
|
1219
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1220
|
+
console.log('2');
|
|
1221
|
+
} break;
|
|
1222
|
+
default : throw Error("Not supported")
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
else this.target = element?.parentElement;
|
|
1226
|
+
Object.assign(this.cache, {
|
|
1227
|
+
name,
|
|
1228
|
+
isInteractive,
|
|
1229
|
+
parent:null,
|
|
1230
|
+
isBody:false,
|
|
1231
|
+
isRoot:false,
|
|
1232
|
+
isHidden: false,
|
|
1233
|
+
isFrozzen:false,
|
|
1234
|
+
legacyParent : null,
|
|
1235
|
+
attributes: {},
|
|
1236
|
+
filters: {},
|
|
1237
|
+
temp:{}
|
|
1238
|
+
});
|
|
1239
|
+
this.events = {
|
|
1240
|
+
ptr:null,
|
|
1241
|
+
mouse:null,
|
|
1242
|
+
wheel:null,
|
|
1243
|
+
key:null,
|
|
1244
|
+
drag:null,
|
|
1245
|
+
drop:null,
|
|
1246
|
+
click:null,
|
|
1247
|
+
clipboard:null,
|
|
1248
|
+
focus:null,
|
|
1249
|
+
swipe:null,
|
|
1250
|
+
custom:null,
|
|
1251
|
+
};
|
|
1252
|
+
this.observer={
|
|
1253
|
+
resize:null,
|
|
1254
|
+
intersection:null
|
|
1255
|
+
};
|
|
1256
|
+
if(element) Object.assign(this.cache,{element});
|
|
1257
|
+
// useDefaultStyle && this.style({
|
|
1258
|
+
// position: "relative",
|
|
1259
|
+
// boxSizing:"border-box",
|
|
1260
|
+
// margin:0,
|
|
1261
|
+
// padding:0,
|
|
1262
|
+
// width : "auto",
|
|
1263
|
+
// height : "auto"
|
|
1264
|
+
// });
|
|
1265
|
+
this.items = new UIStore();
|
|
1266
|
+
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1267
|
+
element && render && this?.render?.();
|
|
1268
|
+
if(
|
|
1269
|
+
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
1270
|
+
// &&
|
|
1271
|
+
// !globalThis.__Ziko__.__Config__.isSSC
|
|
1272
|
+
// &&
|
|
1273
|
+
this.isInteractive()){
|
|
1274
|
+
// this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
1275
|
+
// this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
1276
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
1277
|
+
}
|
|
1278
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
1279
|
+
}
|
|
1280
|
+
get element(){
|
|
1281
|
+
return this.cache.element;
|
|
1282
|
+
}
|
|
1283
|
+
[Symbol.iterator]() {
|
|
1284
|
+
return this.items[Symbol.iterator]();
|
|
1285
|
+
}
|
|
1286
|
+
maintain() {
|
|
1287
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1288
|
+
Object.defineProperty(this, i, {
|
|
1289
|
+
value: this.items[i],
|
|
1290
|
+
writable: true,
|
|
1291
|
+
configurable: true,
|
|
1292
|
+
enumerable: false
|
|
1293
|
+
});
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
isInteractive(){
|
|
1297
|
+
return this.cache.isInteractive;
|
|
1298
|
+
}
|
|
1299
|
+
isUIElement(){
|
|
1300
|
+
return true;
|
|
1301
|
+
}
|
|
1302
|
+
// get st(){
|
|
1303
|
+
// return this.cache.style;
|
|
1304
|
+
// }
|
|
1305
|
+
// get attr(){
|
|
1306
|
+
// return this.cache.attributes;
|
|
1307
|
+
// }
|
|
1308
|
+
// get evt(){
|
|
1309
|
+
// return this.events;
|
|
1310
|
+
// }
|
|
1311
|
+
// get html(){
|
|
1312
|
+
// return this.element.innerHTML;
|
|
1313
|
+
// }
|
|
1314
|
+
// get text(){
|
|
1315
|
+
// return this.element.textContent;
|
|
1316
|
+
// }
|
|
1317
|
+
// get isBody(){
|
|
1318
|
+
// return this.element === globalThis?.document.body;
|
|
1319
|
+
// }
|
|
1320
|
+
// get parent(){
|
|
1321
|
+
// return this.cache.parent;
|
|
1322
|
+
// }
|
|
1323
|
+
// get width(){
|
|
1324
|
+
// return this.element.getBoundingClientRect().width;
|
|
1325
|
+
// }
|
|
1326
|
+
// get height(){
|
|
1327
|
+
// return this.element.getBoundingClientRect().height;
|
|
1328
|
+
// }
|
|
1329
|
+
// get top(){
|
|
1330
|
+
// return this.element.getBoundingClientRect().top;
|
|
1331
|
+
// }
|
|
1332
|
+
// get right(){
|
|
1333
|
+
// return this.element.getBoundingClientRect().right;
|
|
1334
|
+
// }
|
|
1335
|
+
// get bottom(){
|
|
1336
|
+
// return this.element.getBoundingClientRect().bottom;
|
|
1337
|
+
// }
|
|
1338
|
+
// get left(){
|
|
1339
|
+
// return this.element.getBoundingClientRect().left;
|
|
1340
|
+
// }
|
|
1341
|
+
// clone(render=false) {
|
|
1342
|
+
// // UI.__proto__=this.__proto__;
|
|
1343
|
+
// // if(this.items.length){
|
|
1344
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
1345
|
+
// // UI.append(...items);
|
|
1346
|
+
// // }
|
|
1347
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
1348
|
+
// // return UI.render(render);
|
|
1349
|
+
// }
|
|
1350
|
+
|
|
1351
|
+
// freeze(freeze){
|
|
1352
|
+
// this.cache.isFrozzen=freeze;
|
|
1353
|
+
// return this;
|
|
1354
|
+
// }
|
|
1355
|
+
// setTarget(tg) {
|
|
1356
|
+
// if(this.isBody) return ;
|
|
1357
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
1358
|
+
// this.unrender();
|
|
1359
|
+
// this.target = tg;
|
|
1360
|
+
// this.render();
|
|
1361
|
+
// return this;
|
|
1362
|
+
// }
|
|
1363
|
+
// describe(label){
|
|
1364
|
+
// if(label)this.setAttr("aria-label",label)
|
|
1365
|
+
// }
|
|
1366
|
+
// get children() {
|
|
1367
|
+
// return [...this.element.children];
|
|
1368
|
+
// }
|
|
1369
|
+
// get cloneElement() {
|
|
1370
|
+
// return this.element.cloneNode(true);
|
|
1371
|
+
// }
|
|
1372
|
+
// setClasses(...value) {
|
|
1373
|
+
// this.setAttr("class", value.join(" "));
|
|
1374
|
+
// return this;
|
|
1375
|
+
// }
|
|
1376
|
+
// get classes(){
|
|
1377
|
+
// const classes=this.element.getAttribute("class");
|
|
1378
|
+
// return classes===null?[]:classes.split(" ");
|
|
1379
|
+
// }
|
|
1380
|
+
// addClass() {
|
|
1381
|
+
// /*this.setAttr("class", value);
|
|
1382
|
+
// return this;*/
|
|
1383
|
+
// }
|
|
1384
|
+
// setId(id) {
|
|
1385
|
+
// this.setAttr("id", id);
|
|
1386
|
+
// return this;
|
|
1387
|
+
// }
|
|
1388
|
+
// get id() {
|
|
1389
|
+
// return this.element.getAttribute("id");
|
|
1390
|
+
// }
|
|
1391
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
1392
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
1393
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
1394
|
+
// return this;
|
|
1395
|
+
// }
|
|
1396
|
+
// To Fix
|
|
1397
|
+
// onKeysDown({keys=[],callback}={}){
|
|
1398
|
+
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
1399
|
+
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
1400
|
+
// return this;
|
|
1401
|
+
// }
|
|
1402
|
+
// onSelect(...callbacks){
|
|
1403
|
+
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
1404
|
+
// this.events.clipboard.onSelect(...callbacks);
|
|
1405
|
+
// return this;
|
|
1406
|
+
// }
|
|
1407
|
+
// on(event_name,...callbacks){
|
|
1408
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1409
|
+
// this.events.custom.on(event_name,...callbacks);
|
|
1410
|
+
// return this;
|
|
1411
|
+
// }
|
|
1412
|
+
// emit(event_name,detail={}){
|
|
1413
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1414
|
+
// this.events.custom.emit(event_name,detail);
|
|
1415
|
+
// return this;
|
|
1416
|
+
// }
|
|
1417
|
+
// watchAttr(callback){
|
|
1418
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
1419
|
+
// return this;
|
|
1420
|
+
// }
|
|
1421
|
+
// watchChildren(callback){
|
|
1422
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
1423
|
+
// return this;
|
|
1424
|
+
// }
|
|
1425
|
+
// watchSize(callback){
|
|
1426
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
1427
|
+
// this.observer.resize.start();
|
|
1428
|
+
// return this;
|
|
1429
|
+
// }
|
|
1430
|
+
// watchIntersection(callback,config){
|
|
1431
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
1432
|
+
// this.observer.intersection.start();
|
|
1433
|
+
// return this;
|
|
1434
|
+
// }
|
|
1435
|
+
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
function register_to_class(target, ...mixins){
|
|
1439
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1440
|
+
}
|
|
1441
|
+
function _register_to_class_(target, mixin) {
|
|
1442
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1443
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1444
|
+
const desc = descriptors[key];
|
|
1445
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1446
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1447
|
+
} else if (typeof desc.value === 'function') {
|
|
1448
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1449
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
|
|
1246
1455
|
if(!globalThis.__Ziko__) __init__global__();
|
|
1247
1456
|
|
|
1248
1457
|
// HMR persistence
|
|
1249
|
-
if (undefined) {
|
|
1250
|
-
undefined.data.__Ziko__ = undefined.data
|
|
1458
|
+
if (undefined?.data) {
|
|
1459
|
+
undefined.data.__Ziko__ = undefined.data?.__Ziko__ || globalThis?.__Ziko__;
|
|
1251
1460
|
globalThis.__Ziko__ = undefined.data.__Ziko__;
|
|
1252
1461
|
// import.meta.hot.accept(n=>console.log(n));
|
|
1253
1462
|
// console.log(import.meta.hot.data.__Ziko__.__State__.store)
|
|
@@ -1305,58 +1514,14 @@
|
|
|
1305
1514
|
return typeof arg === 'function' && arg?.()?.isStateGetter?.();
|
|
1306
1515
|
};
|
|
1307
1516
|
|
|
1308
|
-
const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1517
|
+
const camel2hyphencase$1 = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1309
1518
|
|
|
1310
|
-
const is_camelcase = (text = '') =>{
|
|
1519
|
+
const is_camelcase$1 = (text = '') =>{
|
|
1311
1520
|
if (text.length === 0) return false;
|
|
1312
1521
|
const camelCasePattern = /^[a-z][a-zA-Z0-9]*$/;
|
|
1313
1522
|
return camelCasePattern.test(text);
|
|
1314
1523
|
};
|
|
1315
1524
|
|
|
1316
|
-
// To Do add getter, watchAttr
|
|
1317
|
-
const AttrsMethods = {
|
|
1318
|
-
setAttr(name, value) {
|
|
1319
|
-
if(name instanceof Object){
|
|
1320
|
-
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1321
|
-
for(let i=0;i<names.length;i++){
|
|
1322
|
-
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1323
|
-
_set_attrs_.call(this, names[i], values[i]);
|
|
1324
|
-
}
|
|
1325
|
-
}
|
|
1326
|
-
else {
|
|
1327
|
-
if(value instanceof Array) value = value.join(" ");
|
|
1328
|
-
_set_attrs_.call(this, name, value);
|
|
1329
|
-
}
|
|
1330
|
-
return this;
|
|
1331
|
-
},
|
|
1332
|
-
removeAttr(...names) {
|
|
1333
|
-
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1334
|
-
return this;
|
|
1335
|
-
},
|
|
1336
|
-
getAttr(name){
|
|
1337
|
-
name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1338
|
-
return this.element.attributes[name].value;
|
|
1339
|
-
},
|
|
1340
|
-
setContentEditable(bool = true) {
|
|
1341
|
-
this.setAttr("contenteditable", bool);
|
|
1342
|
-
return this;
|
|
1343
|
-
}
|
|
1344
|
-
};
|
|
1345
|
-
|
|
1346
|
-
function _set_attrs_(name, value){
|
|
1347
|
-
if(this.element?.tagName !== "svg") name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1348
|
-
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1349
|
-
if(isStateGetter(value)){
|
|
1350
|
-
const getter = value();
|
|
1351
|
-
getter._subscribe(
|
|
1352
|
-
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1353
|
-
this
|
|
1354
|
-
);
|
|
1355
|
-
}
|
|
1356
|
-
else this.element?.setAttribute(name, value);
|
|
1357
|
-
Object.assign(this.cache.attributes, {[name]:value});
|
|
1358
|
-
}
|
|
1359
|
-
|
|
1360
1525
|
class ZikoUIText extends UINode {
|
|
1361
1526
|
constructor(...value) {
|
|
1362
1527
|
super("span", "text", false, ...value);
|
|
@@ -1368,75 +1533,6 @@
|
|
|
1368
1533
|
}
|
|
1369
1534
|
const text = (...str) => new ZikoUIText(...str);
|
|
1370
1535
|
|
|
1371
|
-
const DomMethods = {
|
|
1372
|
-
append(...ele) {
|
|
1373
|
-
__addItem__.call(this, "append", "push", ...ele);
|
|
1374
|
-
return this;
|
|
1375
|
-
},
|
|
1376
|
-
prepend(...ele) {
|
|
1377
|
-
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
1378
|
-
return this;
|
|
1379
|
-
},
|
|
1380
|
-
insertAt(index, ...ele) {
|
|
1381
|
-
if (index >= this.element.children.length) this.append(...ele);
|
|
1382
|
-
else
|
|
1383
|
-
for (let i = 0; i < ele.length; i++) {
|
|
1384
|
-
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
1385
|
-
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
1386
|
-
this.items.splice(index, 0, ele[i]);
|
|
1387
|
-
}
|
|
1388
|
-
return this;
|
|
1389
|
-
},
|
|
1390
|
-
remove(...ele) {
|
|
1391
|
-
const remove = (ele) => {
|
|
1392
|
-
if (typeof ele === "number") ele = this.items[ele];
|
|
1393
|
-
if (ele?.isZikoUIElement) this.element?.removeChild(ele.element);
|
|
1394
|
-
this.items = this.items.filter((n) => n !== ele);
|
|
1395
|
-
};
|
|
1396
|
-
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
1397
|
-
for (let i = 0; i < this.items.length; i++)
|
|
1398
|
-
Object.assign(this, { [[i]]: this.items[i] });
|
|
1399
|
-
// Remove from item
|
|
1400
|
-
return this;
|
|
1401
|
-
},
|
|
1402
|
-
clear(){
|
|
1403
|
-
this?.items?.forEach(n=>n.unrender());
|
|
1404
|
-
this.element.innerHTML = "";
|
|
1405
|
-
return this;
|
|
1406
|
-
},
|
|
1407
|
-
render(target = this.target) {
|
|
1408
|
-
if(this.isBody)return ;
|
|
1409
|
-
if(target?.isZikoUIElement)target=target.element;
|
|
1410
|
-
this.target=target;
|
|
1411
|
-
this.target?.appendChild(this.element);
|
|
1412
|
-
return this;
|
|
1413
|
-
},
|
|
1414
|
-
unrender(){
|
|
1415
|
-
if(this.cache.parent)this.cache.parent.remove(this);
|
|
1416
|
-
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
1417
|
-
return this;
|
|
1418
|
-
},
|
|
1419
|
-
renderAfter(t = 1) {
|
|
1420
|
-
setTimeout(() => this.render(), t);
|
|
1421
|
-
return this;
|
|
1422
|
-
},
|
|
1423
|
-
unrenderAfter(t = 1) {
|
|
1424
|
-
setTimeout(() => this.unrender(), t);
|
|
1425
|
-
return this;
|
|
1426
|
-
},
|
|
1427
|
-
after(ui){
|
|
1428
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
1429
|
-
this.element?.after(ui);
|
|
1430
|
-
return this;
|
|
1431
|
-
},
|
|
1432
|
-
before(ui){
|
|
1433
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
1434
|
-
this.element?.before(ui);
|
|
1435
|
-
return this;
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
};
|
|
1439
|
-
|
|
1440
1536
|
async function __addItem__(adder, pusher, ...ele) {
|
|
1441
1537
|
if (this.cache.isFrozzen) {
|
|
1442
1538
|
console.warn("You can't append new item to frozzen element");
|
|
@@ -1481,12 +1577,147 @@
|
|
|
1481
1577
|
}
|
|
1482
1578
|
this.maintain();
|
|
1483
1579
|
return this;
|
|
1580
|
+
}
|
|
1581
|
+
function _set_attrs_(name, value){
|
|
1582
|
+
if(this.element instanceof globalThis?.SVGAElement) name = is_camelcase$1(name) ? camel2hyphencase$1(name) : name;
|
|
1583
|
+
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1584
|
+
if(isStateGetter(value)){
|
|
1585
|
+
const getter = value();
|
|
1586
|
+
getter._subscribe(
|
|
1587
|
+
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1588
|
+
this
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1591
|
+
else this.element?.setAttribute(name, value);
|
|
1592
|
+
Object.assign(this.cache.attributes, {[name]:value});
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
// import {
|
|
1596
|
+
// is_camelcase,
|
|
1597
|
+
// camel2hyphencase
|
|
1598
|
+
// } from '../../data/string/index.js'
|
|
1599
|
+
|
|
1600
|
+
function setAttr(name, value) {
|
|
1601
|
+
if(name instanceof Object){
|
|
1602
|
+
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1603
|
+
for(let i=0;i<names.length;i++){
|
|
1604
|
+
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1605
|
+
_set_attrs_.call(this, names[i], values[i]);
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1608
|
+
else {
|
|
1609
|
+
if(value instanceof Array) value = value.join(" ");
|
|
1610
|
+
_set_attrs_.call(this, name, value);
|
|
1611
|
+
}
|
|
1612
|
+
return this;
|
|
1613
|
+
}
|
|
1614
|
+
function removeAttr(...names) {
|
|
1615
|
+
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1616
|
+
return this;
|
|
1617
|
+
}
|
|
1618
|
+
function getAttr(name){
|
|
1619
|
+
name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1620
|
+
return this.element.attributes[name].value;
|
|
1621
|
+
}
|
|
1622
|
+
function setContentEditable(bool = true) {
|
|
1623
|
+
this.setAttr("contenteditable", bool);
|
|
1624
|
+
return this;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
var AttrsMethods = /*#__PURE__*/Object.freeze({
|
|
1628
|
+
__proto__: null,
|
|
1629
|
+
getAttr: getAttr,
|
|
1630
|
+
removeAttr: removeAttr,
|
|
1631
|
+
setAttr: setAttr,
|
|
1632
|
+
setContentEditable: setContentEditable
|
|
1633
|
+
});
|
|
1634
|
+
|
|
1635
|
+
function append(...ele) {
|
|
1636
|
+
__addItem__.call(this, "append", "push", ...ele);
|
|
1637
|
+
return this;
|
|
1638
|
+
}
|
|
1639
|
+
function prepend(...ele) {
|
|
1640
|
+
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
1641
|
+
return this;
|
|
1642
|
+
}
|
|
1643
|
+
function insertAt(index, ...ele) {
|
|
1644
|
+
if (index >= this.element.children.length) this.append(...ele);
|
|
1645
|
+
else
|
|
1646
|
+
for (let i = 0; i < ele.length; i++) {
|
|
1647
|
+
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
1648
|
+
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
1649
|
+
this.items.splice(index, 0, ele[i]);
|
|
1650
|
+
}
|
|
1651
|
+
return this;
|
|
1652
|
+
}
|
|
1653
|
+
function remove(...ele) {
|
|
1654
|
+
const remove = (ele) => {
|
|
1655
|
+
if (typeof ele === "number") ele = this.items[ele];
|
|
1656
|
+
if (ele?.isUIElement) this.element?.removeChild(ele.element);
|
|
1657
|
+
this.items = this.items.filter((n) => n !== ele);
|
|
1658
|
+
};
|
|
1659
|
+
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
1660
|
+
for (let i = 0; i < this.items.length; i++)
|
|
1661
|
+
Object.assign(this, { [[i]]: this.items[i] });
|
|
1662
|
+
// Remove from item
|
|
1663
|
+
return this;
|
|
1664
|
+
}
|
|
1665
|
+
function clear(){
|
|
1666
|
+
this?.items?.forEach(n=>n.unrender());
|
|
1667
|
+
this.element.innerHTML = "";
|
|
1668
|
+
return this;
|
|
1669
|
+
}
|
|
1670
|
+
function render(target = this.target) {
|
|
1671
|
+
if(this.isBody)return ;
|
|
1672
|
+
if(target?.isUIElement)target=target.element;
|
|
1673
|
+
this.target=target;
|
|
1674
|
+
this.target?.appendChild(this.element);
|
|
1675
|
+
return this;
|
|
1676
|
+
}
|
|
1677
|
+
function unrender(){
|
|
1678
|
+
if(this.cache.parent)this.cache.parent.remove(this);
|
|
1679
|
+
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
1680
|
+
return this;
|
|
1681
|
+
}
|
|
1682
|
+
function renderAfter(t = 1) {
|
|
1683
|
+
setTimeout(() => this.render(), t);
|
|
1684
|
+
return this;
|
|
1685
|
+
}
|
|
1686
|
+
function unrenderAfter(t = 1) {
|
|
1687
|
+
setTimeout(() => this.unrender(), t);
|
|
1688
|
+
return this;
|
|
1689
|
+
}
|
|
1690
|
+
function after(ui){
|
|
1691
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1692
|
+
this.element?.after(ui);
|
|
1693
|
+
return this;
|
|
1694
|
+
}
|
|
1695
|
+
function before(ui){
|
|
1696
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1697
|
+
this.element?.before(ui);
|
|
1698
|
+
return this;
|
|
1484
1699
|
}
|
|
1485
1700
|
|
|
1701
|
+
var DomMethods = /*#__PURE__*/Object.freeze({
|
|
1702
|
+
__proto__: null,
|
|
1703
|
+
after: after,
|
|
1704
|
+
append: append,
|
|
1705
|
+
before: before,
|
|
1706
|
+
clear: clear,
|
|
1707
|
+
insertAt: insertAt,
|
|
1708
|
+
prepend: prepend,
|
|
1709
|
+
remove: remove,
|
|
1710
|
+
render: render,
|
|
1711
|
+
renderAfter: renderAfter,
|
|
1712
|
+
unrender: unrender,
|
|
1713
|
+
unrenderAfter: unrenderAfter
|
|
1714
|
+
});
|
|
1715
|
+
|
|
1486
1716
|
const Events = {
|
|
1487
1717
|
'Click' : [
|
|
1488
1718
|
'Click',
|
|
1489
|
-
'DblClick'
|
|
1719
|
+
'DblClick',
|
|
1720
|
+
'ClickAway'
|
|
1490
1721
|
],
|
|
1491
1722
|
'Ptr' : [
|
|
1492
1723
|
'PtrMove',
|
|
@@ -1702,9 +1933,11 @@
|
|
|
1702
1933
|
}
|
|
1703
1934
|
}
|
|
1704
1935
|
|
|
1936
|
+
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
1705
1937
|
class ZikoEventClick extends __ZikoEvent__{
|
|
1706
1938
|
constructor(target, customizer){
|
|
1707
1939
|
super(target, Events.Click, details_setter$a, customizer);
|
|
1940
|
+
// register_click_away_event(target.element)
|
|
1708
1941
|
}
|
|
1709
1942
|
}
|
|
1710
1943
|
function details_setter$a(){
|
|
@@ -1712,7 +1945,7 @@
|
|
|
1712
1945
|
else this.dx = 1;
|
|
1713
1946
|
// console.log(this.currentEvent)
|
|
1714
1947
|
}
|
|
1715
|
-
const
|
|
1948
|
+
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
1716
1949
|
|
|
1717
1950
|
class ZikoEventClipboard extends __ZikoEvent__{
|
|
1718
1951
|
constructor(target, customizer){
|
|
@@ -1722,7 +1955,7 @@
|
|
|
1722
1955
|
function details_setter$9(){
|
|
1723
1956
|
|
|
1724
1957
|
}
|
|
1725
|
-
const
|
|
1958
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
1726
1959
|
|
|
1727
1960
|
class ZikoEventCustom extends __ZikoEvent__{
|
|
1728
1961
|
constructor(target, events, customizer){
|
|
@@ -1756,7 +1989,7 @@
|
|
|
1756
1989
|
function details_setter$7(){
|
|
1757
1990
|
|
|
1758
1991
|
}
|
|
1759
|
-
const
|
|
1992
|
+
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
1760
1993
|
|
|
1761
1994
|
class ZikoEventFocus extends __ZikoEvent__{
|
|
1762
1995
|
constructor(target, customizer){
|
|
@@ -1766,7 +1999,7 @@
|
|
|
1766
1999
|
function details_setter$6(){
|
|
1767
2000
|
|
|
1768
2001
|
}
|
|
1769
|
-
const
|
|
2002
|
+
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
1770
2003
|
|
|
1771
2004
|
let ZikoEventHash$1 = class ZikoEventHash extends __ZikoEvent__{
|
|
1772
2005
|
constructor(target, customizer){
|
|
@@ -1797,7 +2030,7 @@
|
|
|
1797
2030
|
|
|
1798
2031
|
}
|
|
1799
2032
|
}
|
|
1800
|
-
const
|
|
2033
|
+
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
1801
2034
|
|
|
1802
2035
|
class ZikoEventMouse extends __ZikoEvent__{
|
|
1803
2036
|
constructor(target, customizer){
|
|
@@ -1807,7 +2040,7 @@
|
|
|
1807
2040
|
function details_setter$3(){
|
|
1808
2041
|
|
|
1809
2042
|
}
|
|
1810
|
-
const
|
|
2043
|
+
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
1811
2044
|
|
|
1812
2045
|
class ZikoEventPointer extends __ZikoEvent__{
|
|
1813
2046
|
constructor(target, customizer){
|
|
@@ -1848,7 +2081,7 @@
|
|
|
1848
2081
|
// else this.dx = 1
|
|
1849
2082
|
// console.log(this.currentEvent)
|
|
1850
2083
|
}
|
|
1851
|
-
const
|
|
2084
|
+
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
1852
2085
|
|
|
1853
2086
|
class ZikoEventTouch extends __ZikoEvent__{
|
|
1854
2087
|
constructor(target, customizer){
|
|
@@ -1868,17 +2101,17 @@
|
|
|
1868
2101
|
function details_setter(){
|
|
1869
2102
|
|
|
1870
2103
|
}
|
|
1871
|
-
const
|
|
2104
|
+
const bind_wheel_event = (target, customizer) => new ZikoEventWheel(target, customizer);
|
|
1872
2105
|
|
|
1873
2106
|
const binderMap = {
|
|
1874
|
-
ptr:
|
|
1875
|
-
mouse :
|
|
1876
|
-
key:
|
|
1877
|
-
click :
|
|
1878
|
-
drag :
|
|
1879
|
-
clipboard :
|
|
1880
|
-
focus :
|
|
1881
|
-
wheel :
|
|
2107
|
+
ptr: bind_pointer_event,
|
|
2108
|
+
mouse : bind_mouse_event,
|
|
2109
|
+
key: bind_key_event,
|
|
2110
|
+
click : bind_click_event,
|
|
2111
|
+
drag : bind_drag_event,
|
|
2112
|
+
clipboard : bind_clipboard_event,
|
|
2113
|
+
focus : bind_focus_event,
|
|
2114
|
+
wheel : bind_wheel_event
|
|
1882
2115
|
};
|
|
1883
2116
|
|
|
1884
2117
|
const EventsMethodes = {};
|
|
@@ -1894,55 +2127,68 @@
|
|
|
1894
2127
|
});
|
|
1895
2128
|
});
|
|
1896
2129
|
|
|
1897
|
-
|
|
1898
|
-
at(index)
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
forEach(callback)
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
map(callback)
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
},
|
|
1911
|
-
};
|
|
2130
|
+
function at(index) {
|
|
2131
|
+
return this.items.at(index);
|
|
2132
|
+
}
|
|
2133
|
+
function forEach(callback) {
|
|
2134
|
+
this.items.forEach(callback);
|
|
2135
|
+
return this;
|
|
2136
|
+
}
|
|
2137
|
+
function map(callback) {
|
|
2138
|
+
return this.items.map(callback);
|
|
2139
|
+
}
|
|
2140
|
+
function find(condition) {
|
|
2141
|
+
return this.items.filter(condition);
|
|
2142
|
+
}
|
|
1912
2143
|
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
2144
|
+
var IndexingMethods = /*#__PURE__*/Object.freeze({
|
|
2145
|
+
__proto__: null,
|
|
2146
|
+
at: at,
|
|
2147
|
+
find: find,
|
|
2148
|
+
forEach: forEach,
|
|
2149
|
+
map: map
|
|
2150
|
+
});
|
|
2151
|
+
|
|
2152
|
+
function style(styles){
|
|
2153
|
+
for(let key in styles){
|
|
2154
|
+
const value = styles[key];
|
|
2155
|
+
if(isStateGetter(value)){
|
|
2156
|
+
const getter = value();
|
|
2157
|
+
Object.assign(this.element.style, {[key] : getter.value});
|
|
2158
|
+
getter._subscribe(
|
|
2159
|
+
(newValue) => {
|
|
2160
|
+
console.log({newValue});
|
|
2161
|
+
Object.assign(this.element.style, {[key] : newValue});
|
|
2162
|
+
},
|
|
2163
|
+
// this
|
|
2164
|
+
);
|
|
1929
2165
|
}
|
|
1930
|
-
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2166
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2167
|
+
}
|
|
2168
|
+
return this;
|
|
2169
|
+
}
|
|
2170
|
+
function size(width, height){
|
|
2171
|
+
return this.style({width, height})
|
|
2172
|
+
}
|
|
2173
|
+
function hide(){
|
|
1936
2174
|
|
|
1937
|
-
|
|
1938
|
-
|
|
2175
|
+
}
|
|
2176
|
+
function show(){
|
|
1939
2177
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
2178
|
+
}
|
|
2179
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2180
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2181
|
+
return this;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2185
|
+
__proto__: null,
|
|
2186
|
+
animate: animate,
|
|
2187
|
+
hide: hide,
|
|
2188
|
+
show: show,
|
|
2189
|
+
size: size,
|
|
2190
|
+
style: style
|
|
2191
|
+
});
|
|
1946
2192
|
|
|
1947
2193
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
1948
2194
|
this.event=e;
|
|
@@ -2604,22 +2850,22 @@
|
|
|
2604
2850
|
});
|
|
2605
2851
|
}
|
|
2606
2852
|
get x0(){
|
|
2607
|
-
return map(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2853
|
+
return map$1(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2608
2854
|
}
|
|
2609
2855
|
get y0(){
|
|
2610
|
-
return - map(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2856
|
+
return - map$1(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2611
2857
|
}
|
|
2612
2858
|
get x1(){
|
|
2613
|
-
return map(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2859
|
+
return map$1(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2614
2860
|
}
|
|
2615
2861
|
get y1(){
|
|
2616
|
-
return - map(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2862
|
+
return - map$1(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2617
2863
|
}
|
|
2618
2864
|
get cx(){
|
|
2619
|
-
return map(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2865
|
+
return map$1(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2620
2866
|
}
|
|
2621
2867
|
get cy(){
|
|
2622
|
-
return - map(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2868
|
+
return - map$1(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2623
2869
|
}
|
|
2624
2870
|
}
|
|
2625
2871
|
|
|
@@ -2881,22 +3127,12 @@
|
|
|
2881
3127
|
|
|
2882
3128
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
2883
3129
|
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
|
|
3130
|
+
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3131
|
+
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
2887
3132
|
super();
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
2892
|
-
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
2893
|
-
default : throw Error("Not supported")
|
|
2894
|
-
}
|
|
2895
|
-
}
|
|
2896
|
-
else {
|
|
2897
|
-
this.target = element?.parentElement;
|
|
2898
|
-
}
|
|
2899
|
-
register(
|
|
3133
|
+
console.log({type});
|
|
3134
|
+
// console.log(this)
|
|
3135
|
+
register_to_class(
|
|
2900
3136
|
this,
|
|
2901
3137
|
AttrsMethods,
|
|
2902
3138
|
DomMethods,
|
|
@@ -2904,61 +3140,7 @@
|
|
|
2904
3140
|
IndexingMethods,
|
|
2905
3141
|
EventsMethodes
|
|
2906
3142
|
);
|
|
2907
|
-
|
|
2908
|
-
name,
|
|
2909
|
-
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
2910
|
-
parent:null,
|
|
2911
|
-
isBody:false,
|
|
2912
|
-
isRoot:false,
|
|
2913
|
-
isHidden: false,
|
|
2914
|
-
isFrozzen:false,
|
|
2915
|
-
legacyParent : null,
|
|
2916
|
-
attributes: {},
|
|
2917
|
-
filters: {},
|
|
2918
|
-
temp:{}
|
|
2919
|
-
});
|
|
2920
|
-
this.events = {
|
|
2921
|
-
ptr:null,
|
|
2922
|
-
mouse:null,
|
|
2923
|
-
wheel:null,
|
|
2924
|
-
key:null,
|
|
2925
|
-
drag:null,
|
|
2926
|
-
drop:null,
|
|
2927
|
-
click:null,
|
|
2928
|
-
clipboard:null,
|
|
2929
|
-
focus:null,
|
|
2930
|
-
swipe:null,
|
|
2931
|
-
custom:null,
|
|
2932
|
-
};
|
|
2933
|
-
this.observer={
|
|
2934
|
-
resize:null,
|
|
2935
|
-
intersection:null
|
|
2936
|
-
};
|
|
2937
|
-
if(element) Object.assign(this.cache,{element});
|
|
2938
|
-
// this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
2939
|
-
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
2940
|
-
useDefaultStyle && this.style({
|
|
2941
|
-
position: "relative",
|
|
2942
|
-
boxSizing:"border-box",
|
|
2943
|
-
margin:0,
|
|
2944
|
-
padding:0,
|
|
2945
|
-
width : "auto",
|
|
2946
|
-
height : "auto"
|
|
2947
|
-
});
|
|
2948
|
-
this.items = new UIStore();
|
|
2949
|
-
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
2950
|
-
element && render && this?.render?.();
|
|
2951
|
-
if(
|
|
2952
|
-
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
2953
|
-
// &&
|
|
2954
|
-
// !globalThis.__Ziko__.__Config__.isSSC
|
|
2955
|
-
// &&
|
|
2956
|
-
this.isInteractive()
|
|
2957
|
-
){
|
|
2958
|
-
this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
2959
|
-
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
2960
|
-
}
|
|
2961
|
-
globalThis.__Ziko__.__UI__.push(this);
|
|
3143
|
+
this.init(element, name, type, render);
|
|
2962
3144
|
}
|
|
2963
3145
|
get element(){
|
|
2964
3146
|
return this.cache.element;
|
|
@@ -2966,9 +3148,9 @@
|
|
|
2966
3148
|
isInteractive(){
|
|
2967
3149
|
return this.cache.isInteractive;
|
|
2968
3150
|
}
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
}
|
|
3151
|
+
// isUIElement(){
|
|
3152
|
+
// return true;
|
|
3153
|
+
// }
|
|
2972
3154
|
get st(){
|
|
2973
3155
|
return this.cache.style;
|
|
2974
3156
|
}
|
|
@@ -3008,73 +3190,73 @@
|
|
|
3008
3190
|
get left(){
|
|
3009
3191
|
return this.element.getBoundingClientRect().left;
|
|
3010
3192
|
}
|
|
3011
|
-
clone(render=false) {
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
}
|
|
3020
|
-
[Symbol.iterator]() {
|
|
3021
|
-
|
|
3022
|
-
}
|
|
3023
|
-
maintain() {
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
}
|
|
3033
|
-
freeze(freeze){
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
}
|
|
3193
|
+
// clone(render=false) {
|
|
3194
|
+
// // UI.__proto__=this.__proto__;
|
|
3195
|
+
// // if(this.items.length){
|
|
3196
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
3197
|
+
// // UI.append(...items);
|
|
3198
|
+
// // }
|
|
3199
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
3200
|
+
// // return UI.render(render);
|
|
3201
|
+
// }
|
|
3202
|
+
// [Symbol.iterator]() {
|
|
3203
|
+
// return this.items[Symbol.iterator]();
|
|
3204
|
+
// }
|
|
3205
|
+
// maintain() {
|
|
3206
|
+
// for (let i = 0; i < this.items.length; i++) {
|
|
3207
|
+
// Object.defineProperty(this, i, {
|
|
3208
|
+
// value: this.items[i],
|
|
3209
|
+
// writable: true,
|
|
3210
|
+
// configurable: true,
|
|
3211
|
+
// enumerable: false
|
|
3212
|
+
// });
|
|
3213
|
+
// }
|
|
3214
|
+
// }
|
|
3215
|
+
// freeze(freeze){
|
|
3216
|
+
// this.cache.isFrozzen=freeze;
|
|
3217
|
+
// return this;
|
|
3218
|
+
// }
|
|
3037
3219
|
// setTarget(tg) {
|
|
3038
3220
|
// if(this.isBody) return ;
|
|
3039
|
-
// if (tg?.
|
|
3221
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
3040
3222
|
// this.unrender();
|
|
3041
3223
|
// this.target = tg;
|
|
3042
3224
|
// this.render();
|
|
3043
3225
|
// return this;
|
|
3044
3226
|
// }
|
|
3045
|
-
describe(label){
|
|
3046
|
-
|
|
3047
|
-
}
|
|
3048
|
-
get children() {
|
|
3049
|
-
|
|
3050
|
-
}
|
|
3051
|
-
get cloneElement() {
|
|
3052
|
-
|
|
3053
|
-
}
|
|
3054
|
-
setClasses(...value) {
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
}
|
|
3058
|
-
get classes(){
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
}
|
|
3062
|
-
addClass() {
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
}
|
|
3066
|
-
setId(id) {
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
}
|
|
3070
|
-
get id() {
|
|
3071
|
-
|
|
3072
|
-
}
|
|
3073
|
-
onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
}
|
|
3227
|
+
// describe(label){
|
|
3228
|
+
// if(label)this.setAttr("aria-label",label)
|
|
3229
|
+
// }
|
|
3230
|
+
// get children() {
|
|
3231
|
+
// return [...this.element.children];
|
|
3232
|
+
// }
|
|
3233
|
+
// get cloneElement() {
|
|
3234
|
+
// return this.element.cloneNode(true);
|
|
3235
|
+
// }
|
|
3236
|
+
// setClasses(...value) {
|
|
3237
|
+
// this.setAttr("class", value.join(" "));
|
|
3238
|
+
// return this;
|
|
3239
|
+
// }
|
|
3240
|
+
// get classes(){
|
|
3241
|
+
// const classes=this.element.getAttribute("class");
|
|
3242
|
+
// return classes===null?[]:classes.split(" ");
|
|
3243
|
+
// }
|
|
3244
|
+
// addClass() {
|
|
3245
|
+
// /*this.setAttr("class", value);
|
|
3246
|
+
// return this;*/
|
|
3247
|
+
// }
|
|
3248
|
+
// setId(id) {
|
|
3249
|
+
// this.setAttr("id", id);
|
|
3250
|
+
// return this;
|
|
3251
|
+
// }
|
|
3252
|
+
// get id() {
|
|
3253
|
+
// return this.element.getAttribute("id");
|
|
3254
|
+
// }
|
|
3255
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3256
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
3257
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
3258
|
+
// return this;
|
|
3259
|
+
// }
|
|
3078
3260
|
// To Fix
|
|
3079
3261
|
// onKeysDown({keys=[],callback}={}){
|
|
3080
3262
|
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
@@ -3096,26 +3278,26 @@
|
|
|
3096
3278
|
this.events.custom.emit(event_name,detail);
|
|
3097
3279
|
return this;
|
|
3098
3280
|
}
|
|
3099
|
-
watchAttr(callback){
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
}
|
|
3103
|
-
watchChildren(callback){
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
}
|
|
3107
|
-
watchSize(callback){
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
}
|
|
3112
|
-
watchIntersection(callback,config){
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
}
|
|
3281
|
+
// watchAttr(callback){
|
|
3282
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
3283
|
+
// return this;
|
|
3284
|
+
// }
|
|
3285
|
+
// watchChildren(callback){
|
|
3286
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
3287
|
+
// return this;
|
|
3288
|
+
// }
|
|
3289
|
+
// watchSize(callback){
|
|
3290
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
3291
|
+
// this.observer.resize.start();
|
|
3292
|
+
// return this;
|
|
3293
|
+
// }
|
|
3294
|
+
// watchIntersection(callback,config){
|
|
3295
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
3296
|
+
// this.observer.intersection.start();
|
|
3297
|
+
// return this;
|
|
3298
|
+
// }
|
|
3117
3299
|
|
|
3118
|
-
}
|
|
3300
|
+
};
|
|
3119
3301
|
|
|
3120
3302
|
const HTMLTags = [
|
|
3121
3303
|
'a',
|
|
@@ -3205,7 +3387,6 @@
|
|
|
3205
3387
|
'sub',
|
|
3206
3388
|
'summary',
|
|
3207
3389
|
'sup',
|
|
3208
|
-
'svg',
|
|
3209
3390
|
'table',
|
|
3210
3391
|
'tbody',
|
|
3211
3392
|
'td',
|
|
@@ -3239,6 +3420,9 @@
|
|
|
3239
3420
|
"desc", "title", "metadata", "foreignObject"
|
|
3240
3421
|
];
|
|
3241
3422
|
|
|
3423
|
+
// const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
|
|
3424
|
+
// const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
|
|
3425
|
+
|
|
3242
3426
|
const tags = new Proxy({}, {
|
|
3243
3427
|
get(target, prop) {
|
|
3244
3428
|
if (typeof prop !== 'string') return undefined;
|
|
@@ -3246,16 +3430,22 @@
|
|
|
3246
3430
|
let type ;
|
|
3247
3431
|
if(HTMLTags.includes(tag)) type = 'html';
|
|
3248
3432
|
if(SVGTags.includes(tag)) type = 'svg';
|
|
3433
|
+
console.log(type);
|
|
3249
3434
|
return (...args)=>{
|
|
3250
3435
|
// Fix undefined
|
|
3251
3436
|
// console.log(isStateGetter(args[0]))
|
|
3437
|
+
// console.log(!!args)
|
|
3438
|
+
if(args.length === 0) {
|
|
3439
|
+
console.log('length 0');
|
|
3440
|
+
return new UIElement$1({element : tag, name : tag, type})
|
|
3441
|
+
}
|
|
3252
3442
|
if(
|
|
3253
3443
|
['string', 'number'].includes(typeof args[0])
|
|
3254
|
-
|| args[0] instanceof UIElement
|
|
3444
|
+
|| args[0] instanceof UIElement$1
|
|
3255
3445
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3256
|
-
) return new UIElement({element : tag, name : tag, type}).append(...args);
|
|
3446
|
+
) return new UIElement$1({element : tag, name : tag, type}).append(...args);
|
|
3257
3447
|
// console.log(args[0])
|
|
3258
|
-
return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
|
|
3448
|
+
return new UIElement$1({element : tag, type}).setAttr(args.shift()).append(...args)
|
|
3259
3449
|
}
|
|
3260
3450
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3261
3451
|
// return (...args)=>{
|
|
@@ -3278,7 +3468,7 @@
|
|
|
3278
3468
|
}
|
|
3279
3469
|
});
|
|
3280
3470
|
|
|
3281
|
-
class ZikoUIFlex extends UIElement {
|
|
3471
|
+
class ZikoUIFlex extends UIElement$1 {
|
|
3282
3472
|
constructor(tag = "div", w = "100%", h = "100%") {
|
|
3283
3473
|
super({element : tag , name : "Flex"});
|
|
3284
3474
|
this.direction = "cols";
|
|
@@ -3377,37 +3567,11 @@
|
|
|
3377
3567
|
return map_pos_x(-align);
|
|
3378
3568
|
}
|
|
3379
3569
|
|
|
3380
|
-
class
|
|
3381
|
-
constructor(
|
|
3382
|
-
|
|
3383
|
-
this.direction = "cols";
|
|
3384
|
-
if (typeof w == "number") w += "%";
|
|
3385
|
-
if (typeof h == "number") h += "%";
|
|
3386
|
-
this.style({ border: "1px solid black", width: w, height: h });
|
|
3387
|
-
this.style({ display: "grid" });
|
|
3388
|
-
// this.render();
|
|
3389
|
-
}
|
|
3390
|
-
get isGird(){
|
|
3391
|
-
return true;
|
|
3392
|
-
}
|
|
3393
|
-
columns(n) {
|
|
3394
|
-
let temp = "";
|
|
3395
|
-
for (let i = 0; i < n; i++) temp = temp.concat(" auto");
|
|
3396
|
-
this.#templateColumns(temp);
|
|
3397
|
-
return this;
|
|
3398
|
-
}
|
|
3399
|
-
#templateColumns(temp = "auto auto") {
|
|
3400
|
-
this.style({ gridTemplateColumns: temp });
|
|
3401
|
-
return this;
|
|
3402
|
-
}
|
|
3403
|
-
gap(w = 10, h = w) {
|
|
3404
|
-
if(typeof (w) === "number")w += "px";
|
|
3405
|
-
if(typeof (h) === "number")h += "px";
|
|
3406
|
-
this.style({gridColumnGap: w,gridRowGap: h});
|
|
3407
|
-
return this;
|
|
3570
|
+
class UIElement extends UIElementCore{
|
|
3571
|
+
constructor({element, name, type, render}){
|
|
3572
|
+
super({element, name, type, render});
|
|
3408
3573
|
}
|
|
3409
|
-
}
|
|
3410
|
-
const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
|
|
3574
|
+
}
|
|
3411
3575
|
|
|
3412
3576
|
class ZikoUISuspense extends UIElement{
|
|
3413
3577
|
constructor(fallback_ui, callback){
|
|
@@ -3433,12 +3597,16 @@
|
|
|
3433
3597
|
|
|
3434
3598
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3435
3599
|
|
|
3436
|
-
class
|
|
3437
|
-
constructor(
|
|
3438
|
-
super({element :
|
|
3439
|
-
this.element.append(
|
|
3600
|
+
class UIHTMLWrapper extends UIElement$1 {
|
|
3601
|
+
constructor(content){
|
|
3602
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3603
|
+
this.element.append(html2dom(content));
|
|
3604
|
+
this.style({
|
|
3605
|
+
display : 'contents'
|
|
3606
|
+
});
|
|
3440
3607
|
}
|
|
3441
3608
|
}
|
|
3609
|
+
|
|
3442
3610
|
function html2dom(htmlString) {
|
|
3443
3611
|
if(globalThis?.DOMParser){
|
|
3444
3612
|
const parser = new DOMParser();
|
|
@@ -3446,261 +3614,50 @@
|
|
|
3446
3614
|
doc.body.firstChild.style.display = "contents";
|
|
3447
3615
|
return doc.body.firstChild;
|
|
3448
3616
|
}
|
|
3449
|
-
}
|
|
3450
|
-
function svg2dom(svgString) {
|
|
3451
|
-
if(globalThis?.DOMParser){
|
|
3452
|
-
const parser = new DOMParser();
|
|
3453
|
-
const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
|
|
3454
|
-
return doc.documentElement; // SVG elements are usually at the root
|
|
3455
|
-
}
|
|
3456
|
-
}
|
|
3457
|
-
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
3458
|
-
constructor(HTMLContent){
|
|
3459
|
-
super(HTMLContent, "html");
|
|
3460
|
-
}
|
|
3461
3617
|
}
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
super(SVGContent, "svg");
|
|
3465
|
-
}
|
|
3466
|
-
}
|
|
3467
|
-
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
3468
|
-
const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
|
|
3618
|
+
|
|
3619
|
+
const HTMLWrapper = (content) => new UIHTMLWrapper(content);
|
|
3469
3620
|
|
|
3470
|
-
class
|
|
3471
|
-
constructor(
|
|
3472
|
-
super(
|
|
3473
|
-
this.
|
|
3621
|
+
class UISVGWrapper extends UIElement$1 {
|
|
3622
|
+
constructor(content){
|
|
3623
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3624
|
+
this.element.append(svg2dom(content));
|
|
3474
3625
|
this.style({
|
|
3475
|
-
|
|
3476
|
-
});
|
|
3477
|
-
this.transformMatrix = new Matrix([
|
|
3478
|
-
[1,0,0],
|
|
3479
|
-
[0,1,0],
|
|
3480
|
-
[0,0,1]
|
|
3481
|
-
]);
|
|
3482
|
-
this.axisMatrix = new Matrix([
|
|
3483
|
-
[-10,-10],
|
|
3484
|
-
[10,10]
|
|
3485
|
-
]);
|
|
3486
|
-
// setTimeout(()=>this.resize(w,h),0);
|
|
3487
|
-
requestAnimationFrame(()=>this.resize(w,h),0);
|
|
3488
|
-
this.on("sizeupdated",()=>this.adjust());
|
|
3489
|
-
}
|
|
3490
|
-
get Xmin(){
|
|
3491
|
-
return this.axisMatrix[0][0];
|
|
3492
|
-
}
|
|
3493
|
-
get Ymin(){
|
|
3494
|
-
return this.axisMatrix[0][1];
|
|
3495
|
-
}
|
|
3496
|
-
get Xmax(){
|
|
3497
|
-
return this.axisMatrix[1][0];
|
|
3498
|
-
}
|
|
3499
|
-
get Ymax(){
|
|
3500
|
-
return this.axisMatrix[1][1];
|
|
3501
|
-
}
|
|
3502
|
-
get ImageData(){
|
|
3503
|
-
return this.ctx.getImageData(0,0,c.Width,c.Height);
|
|
3504
|
-
}
|
|
3505
|
-
draw(all=true){
|
|
3506
|
-
if(all){
|
|
3507
|
-
this.clear();
|
|
3508
|
-
this.items.forEach(element => {
|
|
3509
|
-
element.parent=this;
|
|
3510
|
-
element.draw(this.ctx);
|
|
3511
|
-
});
|
|
3512
|
-
}
|
|
3513
|
-
else {
|
|
3514
|
-
this.items.at(-1).parent=this;
|
|
3515
|
-
this.items.at(-1).draw(this.ctx);
|
|
3516
|
-
}
|
|
3517
|
-
this.maintain();
|
|
3518
|
-
return this;
|
|
3519
|
-
}
|
|
3520
|
-
applyTransformMatrix(){
|
|
3521
|
-
this.ctx.setTransform(
|
|
3522
|
-
this.transformMatrix[0][0],
|
|
3523
|
-
this.transformMatrix[1][0],
|
|
3524
|
-
this.transformMatrix[0][1],
|
|
3525
|
-
this.transformMatrix[1][1],
|
|
3526
|
-
this.transformMatrix[0][2],
|
|
3527
|
-
this.transformMatrix[1][2],
|
|
3528
|
-
);
|
|
3529
|
-
return this;
|
|
3530
|
-
}
|
|
3531
|
-
resize(w,h){
|
|
3532
|
-
this.size(w,h);
|
|
3533
|
-
this.lineWidth();
|
|
3534
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
3535
|
-
this.emit("sizeupdated");
|
|
3536
|
-
return this;
|
|
3537
|
-
}
|
|
3538
|
-
adjust(){
|
|
3539
|
-
this.element.width =this.element?.getBoundingClientRect().width;
|
|
3540
|
-
this.element.height =this.element?.getBoundingClientRect().height;
|
|
3541
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
3542
|
-
return this;
|
|
3543
|
-
}
|
|
3544
|
-
view(xMin,yMin,xMax,yMax){
|
|
3545
|
-
this.transformMatrix[0][0]=this.width/(xMax-xMin); // scaleX
|
|
3546
|
-
this.transformMatrix[1][1]=-this.height/(yMax-yMin); // scaleY
|
|
3547
|
-
this.transformMatrix[0][2]=this.width/2;
|
|
3548
|
-
this.transformMatrix[1][2]=this.height/2;
|
|
3549
|
-
this.axisMatrix=new Matrix([
|
|
3550
|
-
[xMin,yMin],
|
|
3551
|
-
[xMax,yMax]
|
|
3552
|
-
]);
|
|
3553
|
-
|
|
3554
|
-
this.applyTransformMatrix();
|
|
3555
|
-
this.clear();
|
|
3556
|
-
this.lineWidth(1);
|
|
3557
|
-
this.draw();
|
|
3558
|
-
return this;
|
|
3559
|
-
}
|
|
3560
|
-
reset(){
|
|
3561
|
-
this.ctx.setTransform(1,0,0,0,0,0);
|
|
3562
|
-
return this;
|
|
3563
|
-
}
|
|
3564
|
-
append(element){
|
|
3565
|
-
this.items.push(element);
|
|
3566
|
-
this.draw(false);
|
|
3567
|
-
return this;
|
|
3568
|
-
}
|
|
3569
|
-
background(color){
|
|
3570
|
-
this.ctx.fillStyle = color;
|
|
3571
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3572
|
-
this.ctx.fillRect(0, 0, this.width, this.height);
|
|
3573
|
-
this.applyTransformMatrix();
|
|
3574
|
-
this.draw();
|
|
3575
|
-
}
|
|
3576
|
-
lineWidth(w){
|
|
3577
|
-
this.ctx.lineWidth=w/this.transformMatrix[0][0];
|
|
3578
|
-
return this
|
|
3579
|
-
}
|
|
3580
|
-
getImageData(x=0,y=0,w=this.width,h=this.height){
|
|
3581
|
-
return this.ctx.getImageData(x,y,w,h);
|
|
3582
|
-
}
|
|
3583
|
-
clear(){
|
|
3584
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3585
|
-
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
3586
|
-
this.applyTransformMatrix();
|
|
3587
|
-
return this;
|
|
3588
|
-
}
|
|
3589
|
-
clone(){
|
|
3590
|
-
console.log(this.width);
|
|
3591
|
-
const canvas=new ZikoUICanvas();
|
|
3592
|
-
canvas.items=this.items;
|
|
3593
|
-
canvas.transformMatrix=this.transformMatrix;
|
|
3594
|
-
canvas.axisMatrix=this.axisMatrix;
|
|
3595
|
-
Object.assign(canvas.cache,{...this.cache});
|
|
3596
|
-
//waitForUIElm(this)
|
|
3597
|
-
//console.log(element)
|
|
3598
|
-
this.size(this.element.style.width,this.element.style.width);
|
|
3599
|
-
this.applyTransformMatrix();
|
|
3600
|
-
this.draw();
|
|
3601
|
-
this.adjust();
|
|
3602
|
-
return canvas;
|
|
3603
|
-
}
|
|
3604
|
-
toImage() {
|
|
3605
|
-
this.img = document?.createElement("img");
|
|
3606
|
-
this.img.src = this.element?.toDataURL("image/png");
|
|
3607
|
-
return this;
|
|
3608
|
-
}
|
|
3609
|
-
toBlob() {
|
|
3610
|
-
var canvas = this.element;
|
|
3611
|
-
canvas.toBlob(function (blob) {
|
|
3612
|
-
var newImg = document?.createElement("img"),
|
|
3613
|
-
url = URL.createObjectURL(blob);
|
|
3614
|
-
newImg.onload = function () {
|
|
3615
|
-
URL.revokeObjectURL(url);
|
|
3616
|
-
};
|
|
3617
|
-
newImg.src = url;
|
|
3618
|
-
console.log(newImg);
|
|
3626
|
+
display : 'contents'
|
|
3619
3627
|
});
|
|
3620
3628
|
}
|
|
3621
|
-
zoomIn(){
|
|
3622
|
-
|
|
3623
|
-
}
|
|
3624
|
-
zoomOut(){
|
|
3625
|
-
|
|
3626
|
-
}
|
|
3627
|
-
undo(n){
|
|
3628
|
-
|
|
3629
|
-
}
|
|
3630
|
-
redo(n){
|
|
3631
|
-
|
|
3632
|
-
}
|
|
3633
|
-
stream(){
|
|
3634
|
-
|
|
3635
|
-
}
|
|
3636
3629
|
}
|
|
3637
3630
|
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
}
|
|
3662
|
-
view(x1,y1,x2,y2){
|
|
3663
|
-
let width=Math.abs(x2-x1);
|
|
3664
|
-
let height=Math.abs(y2-y1);
|
|
3665
|
-
this.setAttr("viewBox",[x1,y1,width,height].join(" "));
|
|
3666
|
-
this.st.scaleY(-1);
|
|
3667
|
-
return this;
|
|
3668
|
-
}
|
|
3669
|
-
add(...svgElement){
|
|
3670
|
-
for(let i=0;i<svgElement.length;i++){
|
|
3671
|
-
this.element.append(svgElement[i].element);
|
|
3672
|
-
this.items.push(svgElement[i]);
|
|
3673
|
-
}
|
|
3674
|
-
this.maintain();
|
|
3675
|
-
return this;
|
|
3676
|
-
}
|
|
3677
|
-
remove(...svgElement){
|
|
3678
|
-
for(let i=0;i<svgElement.length;i++){
|
|
3679
|
-
this.element?.removeChild(svgElement[i].element);
|
|
3680
|
-
this.items=this.items.filter(n=>!svgElement);
|
|
3681
|
-
}
|
|
3682
|
-
this.maintain();
|
|
3683
|
-
return this;
|
|
3684
|
-
}
|
|
3685
|
-
mask(){
|
|
3686
|
-
|
|
3687
|
-
}
|
|
3688
|
-
toString(){
|
|
3689
|
-
return (new XMLSerializer()).serializeToString(this.element);
|
|
3690
|
-
}
|
|
3691
|
-
btoa(){
|
|
3692
|
-
return btoa(this.toString())
|
|
3693
|
-
}
|
|
3694
|
-
toImg(){
|
|
3695
|
-
return 'data:image/svg+xml;base64,'+this.btoa()
|
|
3696
|
-
}
|
|
3697
|
-
toImg2(){
|
|
3698
|
-
return "data:image/svg+xml;charset=utf8,"+this.toString().replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("#","%23").replaceAll('"',"'");
|
|
3699
|
-
}
|
|
3700
|
-
|
|
3631
|
+
function svg2dom(svgString) {
|
|
3632
|
+
if (typeof DOMParser !== "undefined") {
|
|
3633
|
+
const parser = new DOMParser();
|
|
3634
|
+
const doc = parser.parseFromString(svgString.trim(), "image/svg+xml");
|
|
3635
|
+
const svg = doc.documentElement;
|
|
3636
|
+
|
|
3637
|
+
if (svg.nodeName === "parsererror") {
|
|
3638
|
+
throw new Error("Invalid SVG string");
|
|
3639
|
+
}
|
|
3640
|
+
if(svg.hasAttribute('xmlns')) return svg
|
|
3641
|
+
// TO Fix ...
|
|
3642
|
+
const {children, attributes} = svg;
|
|
3643
|
+
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3644
|
+
for(let {name, value} of attributes){
|
|
3645
|
+
element.setAttribute(name, value);
|
|
3646
|
+
}
|
|
3647
|
+
element.append(...children);
|
|
3648
|
+
|
|
3649
|
+
globalThis.svg = svg;
|
|
3650
|
+
globalThis.children = children;
|
|
3651
|
+
globalThis.attributes = attributes;
|
|
3652
|
+
globalThis.element = element;
|
|
3653
|
+
return element;
|
|
3701
3654
|
}
|
|
3655
|
+
throw new Error("DOMParser is not available in this environment");
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
|
|
3702
3659
|
|
|
3703
|
-
|
|
3660
|
+
const SVGWrapper = (content) => new UISVGWrapper(content);
|
|
3704
3661
|
|
|
3705
3662
|
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3706
3663
|
if (globalThis.customElements?.get(name)) {
|
|
@@ -4970,7 +4927,7 @@
|
|
|
4970
4927
|
this.t += this.state.step;
|
|
4971
4928
|
this.i++;
|
|
4972
4929
|
|
|
4973
|
-
this.tx = map(this.t, 0, this.state.duration, 0, 1);
|
|
4930
|
+
this.tx = map$1(this.t, 0, this.state.duration, 0, 1);
|
|
4974
4931
|
this.ty = this.state.ease(this.tx);
|
|
4975
4932
|
|
|
4976
4933
|
this.callback(this);
|
|
@@ -5415,7 +5372,7 @@
|
|
|
5415
5372
|
return this;
|
|
5416
5373
|
}
|
|
5417
5374
|
setWrapper(wrapper){
|
|
5418
|
-
if(wrapper?.
|
|
5375
|
+
if(wrapper?.isUIElement) this.wrapper = wrapper;
|
|
5419
5376
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5420
5377
|
return this;
|
|
5421
5378
|
}
|
|
@@ -5487,7 +5444,7 @@
|
|
|
5487
5444
|
}
|
|
5488
5445
|
clear(){
|
|
5489
5446
|
[...this.routes].forEach(n=>{
|
|
5490
|
-
!isDynamic(n[0]) && n[1]?.
|
|
5447
|
+
!isDynamic(n[0]) && n[1]?.isUIElement && n[1].unrender();
|
|
5491
5448
|
});
|
|
5492
5449
|
// this.wrapper.clear();
|
|
5493
5450
|
return this;
|
|
@@ -5500,10 +5457,10 @@
|
|
|
5500
5457
|
element = callback.call(this,params);
|
|
5501
5458
|
}
|
|
5502
5459
|
else {
|
|
5503
|
-
callback?.
|
|
5460
|
+
callback?.isUIElement && callback.render(this.wrapper);
|
|
5504
5461
|
if(typeof callback === "function") element = callback();
|
|
5505
5462
|
}
|
|
5506
|
-
if(element?.
|
|
5463
|
+
if(element?.isUIElement) element.render(this.wrapper);
|
|
5507
5464
|
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
5508
5465
|
if(element instanceof Promise){
|
|
5509
5466
|
element.then(e=>e.render(this.wrapper));
|
|
@@ -5576,11 +5533,12 @@
|
|
|
5576
5533
|
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
5577
5534
|
const parts = normalizedPath.split('/');
|
|
5578
5535
|
const rootParts = root.split('/');
|
|
5579
|
-
const rootIndex = parts.indexOf(rootParts
|
|
5536
|
+
const rootIndex = parts.indexOf(rootParts.at(-1));
|
|
5580
5537
|
if (rootIndex !== -1) {
|
|
5581
5538
|
const subsequentParts = parts.slice(rootIndex + 1);
|
|
5582
|
-
const lastPart =
|
|
5539
|
+
const lastPart = parts.at(-1);
|
|
5583
5540
|
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
5541
|
+
// console.log({extensions, subsequentParts, lastPart, isIndexFile, rootParts, rootIndex, parts})
|
|
5584
5542
|
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
5585
5543
|
if (isIndexFile) {
|
|
5586
5544
|
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
@@ -5944,7 +5902,6 @@
|
|
|
5944
5902
|
exports.Arc = Arc;
|
|
5945
5903
|
exports.Back = Back;
|
|
5946
5904
|
exports.Base = Base;
|
|
5947
|
-
exports.Canvas = Canvas;
|
|
5948
5905
|
exports.Clock = Clock;
|
|
5949
5906
|
exports.Combinaison = Combinaison;
|
|
5950
5907
|
exports.Complex = Complex;
|
|
@@ -5954,7 +5911,6 @@
|
|
|
5954
5911
|
exports.Elastic = Elastic;
|
|
5955
5912
|
exports.FileBasedRouting = FileBasedRouting;
|
|
5956
5913
|
exports.Flex = Flex;
|
|
5957
|
-
exports.Grid = Grid$1;
|
|
5958
5914
|
exports.HTMLWrapper = HTMLWrapper;
|
|
5959
5915
|
exports.InBack = InBack;
|
|
5960
5916
|
exports.InBounce = InBounce;
|
|
@@ -5997,13 +5953,14 @@
|
|
|
5997
5953
|
exports.Scheduler = Scheduler;
|
|
5998
5954
|
exports.Step = Step;
|
|
5999
5955
|
exports.Suspense = Suspense;
|
|
6000
|
-
exports.Svg = Svg;
|
|
6001
5956
|
exports.Tick = Tick;
|
|
6002
5957
|
exports.TimeAnimation = TimeAnimation;
|
|
6003
5958
|
exports.TimeLoop = TimeLoop;
|
|
6004
5959
|
exports.TimeScheduler = TimeScheduler;
|
|
6005
|
-
exports.UIElement = UIElement;
|
|
5960
|
+
exports.UIElement = UIElement$1;
|
|
5961
|
+
exports.UIHTMLWrapper = UIHTMLWrapper;
|
|
6006
5962
|
exports.UINode = UINode;
|
|
5963
|
+
exports.UISVGWrapper = UISVGWrapper;
|
|
6007
5964
|
exports.Utils = Utils;
|
|
6008
5965
|
exports.ZikoApp = ZikoApp;
|
|
6009
5966
|
exports.ZikoCustomEvent = ZikoCustomEvent;
|
|
@@ -6022,15 +5979,9 @@
|
|
|
6022
5979
|
exports.ZikoHead = ZikoHead;
|
|
6023
5980
|
exports.ZikoMutationObserver = ZikoMutationObserver;
|
|
6024
5981
|
exports.ZikoSPA = ZikoSPA;
|
|
6025
|
-
exports.ZikoUICanvas = ZikoUICanvas;
|
|
6026
5982
|
exports.ZikoUIFlex = ZikoUIFlex;
|
|
6027
|
-
exports.ZikoUIGrid = ZikoUIGrid;
|
|
6028
|
-
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
6029
|
-
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
6030
5983
|
exports.ZikoUISuspense = ZikoUISuspense;
|
|
6031
|
-
exports.ZikoUISvg = ZikoUISvg;
|
|
6032
5984
|
exports.ZikoUIText = ZikoUIText;
|
|
6033
|
-
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
6034
5985
|
exports.ZikoUseRoot = ZikoUseRoot;
|
|
6035
5986
|
exports.__ZikoEvent__ = __ZikoEvent__;
|
|
6036
5987
|
exports.abs = abs;
|
|
@@ -6047,17 +5998,17 @@
|
|
|
6047
5998
|
exports.atan = atan;
|
|
6048
5999
|
exports.atan2 = atan2;
|
|
6049
6000
|
exports.atanh = atanh;
|
|
6050
|
-
exports.bindClickEvent = bindClickEvent;
|
|
6051
|
-
exports.bindClipboardEvent = bindClipboardEvent;
|
|
6052
6001
|
exports.bindCustomEvent = bindCustomEvent;
|
|
6053
|
-
exports.bindDragEvent = bindDragEvent;
|
|
6054
|
-
exports.bindFocusEvent = bindFocusEvent;
|
|
6055
6002
|
exports.bindHashEvent = bindHashEvent;
|
|
6056
|
-
exports.bindKeyEvent = bindKeyEvent;
|
|
6057
|
-
exports.bindMouseEvent = bindMouseEvent;
|
|
6058
|
-
exports.bindPointerEvent = bindPointerEvent;
|
|
6059
6003
|
exports.bindTouchEvent = bindTouchEvent;
|
|
6060
|
-
exports.
|
|
6004
|
+
exports.bind_click_event = bind_click_event;
|
|
6005
|
+
exports.bind_clipboard_event = bind_clipboard_event;
|
|
6006
|
+
exports.bind_drag_event = bind_drag_event;
|
|
6007
|
+
exports.bind_focus_event = bind_focus_event;
|
|
6008
|
+
exports.bind_key_event = bind_key_event;
|
|
6009
|
+
exports.bind_mouse_event = bind_mouse_event;
|
|
6010
|
+
exports.bind_pointer_event = bind_pointer_event;
|
|
6011
|
+
exports.bind_wheel_event = bind_wheel_event;
|
|
6061
6012
|
exports.cartesianProduct = cartesianProduct;
|
|
6062
6013
|
exports.ceil = ceil;
|
|
6063
6014
|
exports.clamp = clamp;
|
|
@@ -6101,7 +6052,7 @@
|
|
|
6101
6052
|
exports.ln = ln;
|
|
6102
6053
|
exports.logspace = logspace;
|
|
6103
6054
|
exports.loop = loop;
|
|
6104
|
-
exports.map = map;
|
|
6055
|
+
exports.map = map$1;
|
|
6105
6056
|
exports.mapfun = mapfun$1;
|
|
6106
6057
|
exports.matrix = matrix;
|
|
6107
6058
|
exports.matrix2 = matrix2;
|