ziko 0.44.0 → 0.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.cjs +58 -51
- package/dist/ziko.js +626 -712
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +617 -692
- 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.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 +39 -0
- package/src/events/custom-events/index.js +1 -0
- package/src/events/custom-events/swipe.js +58 -0
- package/src/events/custom-events/view.js +43 -0
- package/src/events/index.js +2 -14
- 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/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 +87 -154
- package/src/ui/constructors/UIElementCore.js +236 -0
- package/src/ui/index.js +3 -3
- package/src/ui/suspense/index.js +1 -1
- 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/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 : Sun Aug 31 2025 15:09:47 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,6 +1202,295 @@
|
|
|
1243
1202
|
}
|
|
1244
1203
|
}
|
|
1245
1204
|
|
|
1205
|
+
__init__global__();
|
|
1206
|
+
class UIElementCore extends UINode{
|
|
1207
|
+
constructor({
|
|
1208
|
+
element,
|
|
1209
|
+
name ='',
|
|
1210
|
+
type="html",
|
|
1211
|
+
render = __Ziko__.__Config__.default.render,
|
|
1212
|
+
isInteractive = false,
|
|
1213
|
+
}={}){
|
|
1214
|
+
super();
|
|
1215
|
+
this.init(element, name, type, render, isInteractive);
|
|
1216
|
+
}
|
|
1217
|
+
init(element, name, type, render, isInteractive = [true, false][Math.floor(2*Math.random())]){
|
|
1218
|
+
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1219
|
+
if(typeof element === "string") {
|
|
1220
|
+
switch(type){
|
|
1221
|
+
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
1222
|
+
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1223
|
+
default : throw Error("Not supported")
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
else this.target = element?.parentElement;
|
|
1227
|
+
Object.assign(this.cache, {
|
|
1228
|
+
name,
|
|
1229
|
+
isInteractive,
|
|
1230
|
+
parent:null,
|
|
1231
|
+
isBody:false,
|
|
1232
|
+
isRoot:false,
|
|
1233
|
+
isHidden: false,
|
|
1234
|
+
isFrozzen:false,
|
|
1235
|
+
legacyParent : null,
|
|
1236
|
+
attributes: {},
|
|
1237
|
+
filters: {},
|
|
1238
|
+
temp:{}
|
|
1239
|
+
});
|
|
1240
|
+
this.events = {
|
|
1241
|
+
ptr:null,
|
|
1242
|
+
mouse:null,
|
|
1243
|
+
wheel:null,
|
|
1244
|
+
key:null,
|
|
1245
|
+
drag:null,
|
|
1246
|
+
drop:null,
|
|
1247
|
+
click:null,
|
|
1248
|
+
clipboard:null,
|
|
1249
|
+
focus:null,
|
|
1250
|
+
swipe:null,
|
|
1251
|
+
custom:null,
|
|
1252
|
+
};
|
|
1253
|
+
this.observer={
|
|
1254
|
+
resize:null,
|
|
1255
|
+
intersection:null
|
|
1256
|
+
};
|
|
1257
|
+
if(element) Object.assign(this.cache,{element});
|
|
1258
|
+
// useDefaultStyle && this.style({
|
|
1259
|
+
// position: "relative",
|
|
1260
|
+
// boxSizing:"border-box",
|
|
1261
|
+
// margin:0,
|
|
1262
|
+
// padding:0,
|
|
1263
|
+
// width : "auto",
|
|
1264
|
+
// height : "auto"
|
|
1265
|
+
// });
|
|
1266
|
+
this.items = new UIStore();
|
|
1267
|
+
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1268
|
+
element && render && this?.render?.();
|
|
1269
|
+
if(
|
|
1270
|
+
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
1271
|
+
// &&
|
|
1272
|
+
// !globalThis.__Ziko__.__Config__.isSSC
|
|
1273
|
+
// &&
|
|
1274
|
+
this.isInteractive()){
|
|
1275
|
+
// this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
1276
|
+
this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index);
|
|
1277
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
1278
|
+
}
|
|
1279
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
1280
|
+
}
|
|
1281
|
+
get element(){
|
|
1282
|
+
return this.cache.element;
|
|
1283
|
+
}
|
|
1284
|
+
[Symbol.iterator]() {
|
|
1285
|
+
return this.items[Symbol.iterator]();
|
|
1286
|
+
}
|
|
1287
|
+
maintain() {
|
|
1288
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1289
|
+
Object.defineProperty(this, i, {
|
|
1290
|
+
value: this.items[i],
|
|
1291
|
+
writable: true,
|
|
1292
|
+
configurable: true,
|
|
1293
|
+
enumerable: false
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
isInteractive(){
|
|
1298
|
+
return this.cache.isInteractive;
|
|
1299
|
+
}
|
|
1300
|
+
isUIElement(){
|
|
1301
|
+
return true;
|
|
1302
|
+
}
|
|
1303
|
+
// get st(){
|
|
1304
|
+
// return this.cache.style;
|
|
1305
|
+
// }
|
|
1306
|
+
// get attr(){
|
|
1307
|
+
// return this.cache.attributes;
|
|
1308
|
+
// }
|
|
1309
|
+
// get evt(){
|
|
1310
|
+
// return this.events;
|
|
1311
|
+
// }
|
|
1312
|
+
// get html(){
|
|
1313
|
+
// return this.element.innerHTML;
|
|
1314
|
+
// }
|
|
1315
|
+
// get text(){
|
|
1316
|
+
// return this.element.textContent;
|
|
1317
|
+
// }
|
|
1318
|
+
// get isBody(){
|
|
1319
|
+
// return this.element === globalThis?.document.body;
|
|
1320
|
+
// }
|
|
1321
|
+
// get parent(){
|
|
1322
|
+
// return this.cache.parent;
|
|
1323
|
+
// }
|
|
1324
|
+
// get width(){
|
|
1325
|
+
// return this.element.getBoundingClientRect().width;
|
|
1326
|
+
// }
|
|
1327
|
+
// get height(){
|
|
1328
|
+
// return this.element.getBoundingClientRect().height;
|
|
1329
|
+
// }
|
|
1330
|
+
// get top(){
|
|
1331
|
+
// return this.element.getBoundingClientRect().top;
|
|
1332
|
+
// }
|
|
1333
|
+
// get right(){
|
|
1334
|
+
// return this.element.getBoundingClientRect().right;
|
|
1335
|
+
// }
|
|
1336
|
+
// get bottom(){
|
|
1337
|
+
// return this.element.getBoundingClientRect().bottom;
|
|
1338
|
+
// }
|
|
1339
|
+
// get left(){
|
|
1340
|
+
// return this.element.getBoundingClientRect().left;
|
|
1341
|
+
// }
|
|
1342
|
+
// clone(render=false) {
|
|
1343
|
+
// // UI.__proto__=this.__proto__;
|
|
1344
|
+
// // if(this.items.length){
|
|
1345
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
1346
|
+
// // UI.append(...items);
|
|
1347
|
+
// // }
|
|
1348
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
1349
|
+
// // return UI.render(render);
|
|
1350
|
+
// }
|
|
1351
|
+
|
|
1352
|
+
// freeze(freeze){
|
|
1353
|
+
// this.cache.isFrozzen=freeze;
|
|
1354
|
+
// return this;
|
|
1355
|
+
// }
|
|
1356
|
+
// setTarget(tg) {
|
|
1357
|
+
// if(this.isBody) return ;
|
|
1358
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
1359
|
+
// this.unrender();
|
|
1360
|
+
// this.target = tg;
|
|
1361
|
+
// this.render();
|
|
1362
|
+
// return this;
|
|
1363
|
+
// }
|
|
1364
|
+
// describe(label){
|
|
1365
|
+
// if(label)this.setAttr("aria-label",label)
|
|
1366
|
+
// }
|
|
1367
|
+
// get children() {
|
|
1368
|
+
// return [...this.element.children];
|
|
1369
|
+
// }
|
|
1370
|
+
// get cloneElement() {
|
|
1371
|
+
// return this.element.cloneNode(true);
|
|
1372
|
+
// }
|
|
1373
|
+
// setClasses(...value) {
|
|
1374
|
+
// this.setAttr("class", value.join(" "));
|
|
1375
|
+
// return this;
|
|
1376
|
+
// }
|
|
1377
|
+
// get classes(){
|
|
1378
|
+
// const classes=this.element.getAttribute("class");
|
|
1379
|
+
// return classes===null?[]:classes.split(" ");
|
|
1380
|
+
// }
|
|
1381
|
+
// addClass() {
|
|
1382
|
+
// /*this.setAttr("class", value);
|
|
1383
|
+
// return this;*/
|
|
1384
|
+
// }
|
|
1385
|
+
// setId(id) {
|
|
1386
|
+
// this.setAttr("id", id);
|
|
1387
|
+
// return this;
|
|
1388
|
+
// }
|
|
1389
|
+
// get id() {
|
|
1390
|
+
// return this.element.getAttribute("id");
|
|
1391
|
+
// }
|
|
1392
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
1393
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
1394
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
1395
|
+
// return this;
|
|
1396
|
+
// }
|
|
1397
|
+
// To Fix
|
|
1398
|
+
// onKeysDown({keys=[],callback}={}){
|
|
1399
|
+
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
1400
|
+
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
1401
|
+
// return this;
|
|
1402
|
+
// }
|
|
1403
|
+
// onSelect(...callbacks){
|
|
1404
|
+
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
1405
|
+
// this.events.clipboard.onSelect(...callbacks);
|
|
1406
|
+
// return this;
|
|
1407
|
+
// }
|
|
1408
|
+
// on(event_name,...callbacks){
|
|
1409
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1410
|
+
// this.events.custom.on(event_name,...callbacks);
|
|
1411
|
+
// return this;
|
|
1412
|
+
// }
|
|
1413
|
+
// emit(event_name,detail={}){
|
|
1414
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1415
|
+
// this.events.custom.emit(event_name,detail);
|
|
1416
|
+
// return this;
|
|
1417
|
+
// }
|
|
1418
|
+
// watchAttr(callback){
|
|
1419
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
1420
|
+
// return this;
|
|
1421
|
+
// }
|
|
1422
|
+
// watchChildren(callback){
|
|
1423
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
1424
|
+
// return this;
|
|
1425
|
+
// }
|
|
1426
|
+
// watchSize(callback){
|
|
1427
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
1428
|
+
// this.observer.resize.start();
|
|
1429
|
+
// return this;
|
|
1430
|
+
// }
|
|
1431
|
+
// watchIntersection(callback,config){
|
|
1432
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
1433
|
+
// this.observer.intersection.start();
|
|
1434
|
+
// return this;
|
|
1435
|
+
// }
|
|
1436
|
+
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
function register_to_class(target, ...mixins){
|
|
1440
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1441
|
+
}
|
|
1442
|
+
function _register_to_class_(target, mixin) {
|
|
1443
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1444
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1445
|
+
const desc = descriptors[key];
|
|
1446
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1447
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1448
|
+
} else if (typeof desc.value === 'function') {
|
|
1449
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1450
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
}
|
|
1455
|
+
|
|
1456
|
+
function register_to_instance(target, ...mixins){
|
|
1457
|
+
console.log('register to instance');
|
|
1458
|
+
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1459
|
+
}
|
|
1460
|
+
function _register_to_instance_(instance, mixin) {
|
|
1461
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1462
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1463
|
+
const desc = descriptors[key];
|
|
1464
|
+
if ('get' in desc || 'set' in desc) {
|
|
1465
|
+
Object.defineProperty(instance, key, {
|
|
1466
|
+
...desc,
|
|
1467
|
+
configurable: true // 🔑 make it replaceable
|
|
1468
|
+
});
|
|
1469
|
+
} else if (typeof desc.value === 'function') {
|
|
1470
|
+
Object.defineProperty(instance, key, {
|
|
1471
|
+
value: desc.value.bind(instance),
|
|
1472
|
+
writable: true, // 🔑 allow reassignment
|
|
1473
|
+
configurable: true, // 🔑 allow redefinition
|
|
1474
|
+
enumerable: false
|
|
1475
|
+
});
|
|
1476
|
+
} else {
|
|
1477
|
+
Object.defineProperty(instance, key, {
|
|
1478
|
+
value: desc.value,
|
|
1479
|
+
writable: true,
|
|
1480
|
+
configurable: true,
|
|
1481
|
+
enumerable: true
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
const register = (target, ...mixins) => {
|
|
1488
|
+
console.log(target);
|
|
1489
|
+
// return register_to_class(target, ...mixins)
|
|
1490
|
+
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1491
|
+
else register_to_instance(target, ...mixins);
|
|
1492
|
+
};
|
|
1493
|
+
|
|
1246
1494
|
if(!globalThis.__Ziko__) __init__global__();
|
|
1247
1495
|
|
|
1248
1496
|
// HMR persistence
|
|
@@ -1305,58 +1553,14 @@
|
|
|
1305
1553
|
return typeof arg === 'function' && arg?.()?.isStateGetter?.();
|
|
1306
1554
|
};
|
|
1307
1555
|
|
|
1308
|
-
const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1556
|
+
const camel2hyphencase$1 = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1309
1557
|
|
|
1310
|
-
const is_camelcase = (text = '') =>{
|
|
1558
|
+
const is_camelcase$1 = (text = '') =>{
|
|
1311
1559
|
if (text.length === 0) return false;
|
|
1312
1560
|
const camelCasePattern = /^[a-z][a-zA-Z0-9]*$/;
|
|
1313
1561
|
return camelCasePattern.test(text);
|
|
1314
1562
|
};
|
|
1315
1563
|
|
|
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
1564
|
class ZikoUIText extends UINode {
|
|
1361
1565
|
constructor(...value) {
|
|
1362
1566
|
super("span", "text", false, ...value);
|
|
@@ -1368,75 +1572,6 @@
|
|
|
1368
1572
|
}
|
|
1369
1573
|
const text = (...str) => new ZikoUIText(...str);
|
|
1370
1574
|
|
|
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
1575
|
async function __addItem__(adder, pusher, ...ele) {
|
|
1441
1576
|
if (this.cache.isFrozzen) {
|
|
1442
1577
|
console.warn("You can't append new item to frozzen element");
|
|
@@ -1481,12 +1616,147 @@
|
|
|
1481
1616
|
}
|
|
1482
1617
|
this.maintain();
|
|
1483
1618
|
return this;
|
|
1619
|
+
}
|
|
1620
|
+
function _set_attrs_(name, value){
|
|
1621
|
+
if(this.element?.tagName !== "svg") name = is_camelcase$1(name) ? camel2hyphencase$1(name) : name;
|
|
1622
|
+
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1623
|
+
if(isStateGetter(value)){
|
|
1624
|
+
const getter = value();
|
|
1625
|
+
getter._subscribe(
|
|
1626
|
+
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1627
|
+
this
|
|
1628
|
+
);
|
|
1629
|
+
}
|
|
1630
|
+
else this.element?.setAttribute(name, value);
|
|
1631
|
+
Object.assign(this.cache.attributes, {[name]:value});
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
// import {
|
|
1635
|
+
// is_camelcase,
|
|
1636
|
+
// camel2hyphencase
|
|
1637
|
+
// } from '../../data/string/index.js'
|
|
1638
|
+
|
|
1639
|
+
function setAttr(name, value) {
|
|
1640
|
+
if(name instanceof Object){
|
|
1641
|
+
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1642
|
+
for(let i=0;i<names.length;i++){
|
|
1643
|
+
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1644
|
+
_set_attrs_.call(this, names[i], values[i]);
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
else {
|
|
1648
|
+
if(value instanceof Array) value = value.join(" ");
|
|
1649
|
+
_set_attrs_.call(this, name, value);
|
|
1650
|
+
}
|
|
1651
|
+
return this;
|
|
1652
|
+
}
|
|
1653
|
+
function removeAttr(...names) {
|
|
1654
|
+
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1655
|
+
return this;
|
|
1656
|
+
}
|
|
1657
|
+
function getAttr(name){
|
|
1658
|
+
name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1659
|
+
return this.element.attributes[name].value;
|
|
1660
|
+
}
|
|
1661
|
+
function setContentEditable(bool = true) {
|
|
1662
|
+
this.setAttr("contenteditable", bool);
|
|
1663
|
+
return this;
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
var AttrsMethods = /*#__PURE__*/Object.freeze({
|
|
1667
|
+
__proto__: null,
|
|
1668
|
+
getAttr: getAttr,
|
|
1669
|
+
removeAttr: removeAttr,
|
|
1670
|
+
setAttr: setAttr,
|
|
1671
|
+
setContentEditable: setContentEditable
|
|
1672
|
+
});
|
|
1673
|
+
|
|
1674
|
+
function append(...ele) {
|
|
1675
|
+
__addItem__.call(this, "append", "push", ...ele);
|
|
1676
|
+
return this;
|
|
1677
|
+
}
|
|
1678
|
+
function prepend(...ele) {
|
|
1679
|
+
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
1680
|
+
return this;
|
|
1681
|
+
}
|
|
1682
|
+
function insertAt(index, ...ele) {
|
|
1683
|
+
if (index >= this.element.children.length) this.append(...ele);
|
|
1684
|
+
else
|
|
1685
|
+
for (let i = 0; i < ele.length; i++) {
|
|
1686
|
+
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
1687
|
+
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
1688
|
+
this.items.splice(index, 0, ele[i]);
|
|
1689
|
+
}
|
|
1690
|
+
return this;
|
|
1691
|
+
}
|
|
1692
|
+
function remove(...ele) {
|
|
1693
|
+
const remove = (ele) => {
|
|
1694
|
+
if (typeof ele === "number") ele = this.items[ele];
|
|
1695
|
+
if (ele?.isUIElement) this.element?.removeChild(ele.element);
|
|
1696
|
+
this.items = this.items.filter((n) => n !== ele);
|
|
1697
|
+
};
|
|
1698
|
+
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
1699
|
+
for (let i = 0; i < this.items.length; i++)
|
|
1700
|
+
Object.assign(this, { [[i]]: this.items[i] });
|
|
1701
|
+
// Remove from item
|
|
1702
|
+
return this;
|
|
1703
|
+
}
|
|
1704
|
+
function clear(){
|
|
1705
|
+
this?.items?.forEach(n=>n.unrender());
|
|
1706
|
+
this.element.innerHTML = "";
|
|
1707
|
+
return this;
|
|
1708
|
+
}
|
|
1709
|
+
function render(target = this.target) {
|
|
1710
|
+
if(this.isBody)return ;
|
|
1711
|
+
if(target?.isUIElement)target=target.element;
|
|
1712
|
+
this.target=target;
|
|
1713
|
+
this.target?.appendChild(this.element);
|
|
1714
|
+
return this;
|
|
1715
|
+
}
|
|
1716
|
+
function unrender(){
|
|
1717
|
+
if(this.cache.parent)this.cache.parent.remove(this);
|
|
1718
|
+
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
1719
|
+
return this;
|
|
1720
|
+
}
|
|
1721
|
+
function renderAfter(t = 1) {
|
|
1722
|
+
setTimeout(() => this.render(), t);
|
|
1723
|
+
return this;
|
|
1724
|
+
}
|
|
1725
|
+
function unrenderAfter(t = 1) {
|
|
1726
|
+
setTimeout(() => this.unrender(), t);
|
|
1727
|
+
return this;
|
|
1728
|
+
}
|
|
1729
|
+
function after(ui){
|
|
1730
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1731
|
+
this.element?.after(ui);
|
|
1732
|
+
return this;
|
|
1733
|
+
}
|
|
1734
|
+
function before(ui){
|
|
1735
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1736
|
+
this.element?.before(ui);
|
|
1737
|
+
return this;
|
|
1484
1738
|
}
|
|
1485
1739
|
|
|
1740
|
+
var DomMethods = /*#__PURE__*/Object.freeze({
|
|
1741
|
+
__proto__: null,
|
|
1742
|
+
after: after,
|
|
1743
|
+
append: append,
|
|
1744
|
+
before: before,
|
|
1745
|
+
clear: clear,
|
|
1746
|
+
insertAt: insertAt,
|
|
1747
|
+
prepend: prepend,
|
|
1748
|
+
remove: remove,
|
|
1749
|
+
render: render,
|
|
1750
|
+
renderAfter: renderAfter,
|
|
1751
|
+
unrender: unrender,
|
|
1752
|
+
unrenderAfter: unrenderAfter
|
|
1753
|
+
});
|
|
1754
|
+
|
|
1486
1755
|
const Events = {
|
|
1487
1756
|
'Click' : [
|
|
1488
1757
|
'Click',
|
|
1489
|
-
'DblClick'
|
|
1758
|
+
'DblClick',
|
|
1759
|
+
'ClickAway'
|
|
1490
1760
|
],
|
|
1491
1761
|
'Ptr' : [
|
|
1492
1762
|
'PtrMove',
|
|
@@ -1702,9 +1972,11 @@
|
|
|
1702
1972
|
}
|
|
1703
1973
|
}
|
|
1704
1974
|
|
|
1975
|
+
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
1705
1976
|
class ZikoEventClick extends __ZikoEvent__{
|
|
1706
1977
|
constructor(target, customizer){
|
|
1707
1978
|
super(target, Events.Click, details_setter$a, customizer);
|
|
1979
|
+
// register_click_away_event(target.element)
|
|
1708
1980
|
}
|
|
1709
1981
|
}
|
|
1710
1982
|
function details_setter$a(){
|
|
@@ -1712,7 +1984,7 @@
|
|
|
1712
1984
|
else this.dx = 1;
|
|
1713
1985
|
// console.log(this.currentEvent)
|
|
1714
1986
|
}
|
|
1715
|
-
const
|
|
1987
|
+
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
1716
1988
|
|
|
1717
1989
|
class ZikoEventClipboard extends __ZikoEvent__{
|
|
1718
1990
|
constructor(target, customizer){
|
|
@@ -1722,7 +1994,7 @@
|
|
|
1722
1994
|
function details_setter$9(){
|
|
1723
1995
|
|
|
1724
1996
|
}
|
|
1725
|
-
const
|
|
1997
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
1726
1998
|
|
|
1727
1999
|
class ZikoEventCustom extends __ZikoEvent__{
|
|
1728
2000
|
constructor(target, events, customizer){
|
|
@@ -1756,7 +2028,7 @@
|
|
|
1756
2028
|
function details_setter$7(){
|
|
1757
2029
|
|
|
1758
2030
|
}
|
|
1759
|
-
const
|
|
2031
|
+
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
1760
2032
|
|
|
1761
2033
|
class ZikoEventFocus extends __ZikoEvent__{
|
|
1762
2034
|
constructor(target, customizer){
|
|
@@ -1766,7 +2038,7 @@
|
|
|
1766
2038
|
function details_setter$6(){
|
|
1767
2039
|
|
|
1768
2040
|
}
|
|
1769
|
-
const
|
|
2041
|
+
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
1770
2042
|
|
|
1771
2043
|
let ZikoEventHash$1 = class ZikoEventHash extends __ZikoEvent__{
|
|
1772
2044
|
constructor(target, customizer){
|
|
@@ -1797,7 +2069,7 @@
|
|
|
1797
2069
|
|
|
1798
2070
|
}
|
|
1799
2071
|
}
|
|
1800
|
-
const
|
|
2072
|
+
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
1801
2073
|
|
|
1802
2074
|
class ZikoEventMouse extends __ZikoEvent__{
|
|
1803
2075
|
constructor(target, customizer){
|
|
@@ -1807,7 +2079,7 @@
|
|
|
1807
2079
|
function details_setter$3(){
|
|
1808
2080
|
|
|
1809
2081
|
}
|
|
1810
|
-
const
|
|
2082
|
+
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
1811
2083
|
|
|
1812
2084
|
class ZikoEventPointer extends __ZikoEvent__{
|
|
1813
2085
|
constructor(target, customizer){
|
|
@@ -1848,7 +2120,7 @@
|
|
|
1848
2120
|
// else this.dx = 1
|
|
1849
2121
|
// console.log(this.currentEvent)
|
|
1850
2122
|
}
|
|
1851
|
-
const
|
|
2123
|
+
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
1852
2124
|
|
|
1853
2125
|
class ZikoEventTouch extends __ZikoEvent__{
|
|
1854
2126
|
constructor(target, customizer){
|
|
@@ -1868,17 +2140,17 @@
|
|
|
1868
2140
|
function details_setter(){
|
|
1869
2141
|
|
|
1870
2142
|
}
|
|
1871
|
-
const
|
|
2143
|
+
const bind_wheel_event = (target, customizer) => new ZikoEventWheel(target, customizer);
|
|
1872
2144
|
|
|
1873
2145
|
const binderMap = {
|
|
1874
|
-
ptr:
|
|
1875
|
-
mouse :
|
|
1876
|
-
key:
|
|
1877
|
-
click :
|
|
1878
|
-
drag :
|
|
1879
|
-
clipboard :
|
|
1880
|
-
focus :
|
|
1881
|
-
wheel :
|
|
2146
|
+
ptr: bind_pointer_event,
|
|
2147
|
+
mouse : bind_mouse_event,
|
|
2148
|
+
key: bind_key_event,
|
|
2149
|
+
click : bind_click_event,
|
|
2150
|
+
drag : bind_drag_event,
|
|
2151
|
+
clipboard : bind_clipboard_event,
|
|
2152
|
+
focus : bind_focus_event,
|
|
2153
|
+
wheel : bind_wheel_event
|
|
1882
2154
|
};
|
|
1883
2155
|
|
|
1884
2156
|
const EventsMethodes = {};
|
|
@@ -1894,55 +2166,68 @@
|
|
|
1894
2166
|
});
|
|
1895
2167
|
});
|
|
1896
2168
|
|
|
1897
|
-
|
|
1898
|
-
at(index)
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
forEach(callback)
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
map(callback)
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
},
|
|
1911
|
-
};
|
|
2169
|
+
function at(index) {
|
|
2170
|
+
return this.items.at(index);
|
|
2171
|
+
}
|
|
2172
|
+
function forEach(callback) {
|
|
2173
|
+
this.items.forEach(callback);
|
|
2174
|
+
return this;
|
|
2175
|
+
}
|
|
2176
|
+
function map(callback) {
|
|
2177
|
+
return this.items.map(callback);
|
|
2178
|
+
}
|
|
2179
|
+
function find(condition) {
|
|
2180
|
+
return this.items.filter(condition);
|
|
2181
|
+
}
|
|
1912
2182
|
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
2183
|
+
var IndexingMethods = /*#__PURE__*/Object.freeze({
|
|
2184
|
+
__proto__: null,
|
|
2185
|
+
at: at,
|
|
2186
|
+
find: find,
|
|
2187
|
+
forEach: forEach,
|
|
2188
|
+
map: map
|
|
2189
|
+
});
|
|
2190
|
+
|
|
2191
|
+
function style(styles){
|
|
2192
|
+
for(let key in styles){
|
|
2193
|
+
const value = styles[key];
|
|
2194
|
+
if(isStateGetter(value)){
|
|
2195
|
+
const getter = value();
|
|
2196
|
+
Object.assign(this.element.style, {[key] : getter.value});
|
|
2197
|
+
getter._subscribe(
|
|
2198
|
+
(newValue) => {
|
|
2199
|
+
console.log({newValue});
|
|
2200
|
+
Object.assign(this.element.style, {[key] : newValue});
|
|
2201
|
+
},
|
|
2202
|
+
// this
|
|
2203
|
+
);
|
|
1929
2204
|
}
|
|
1930
|
-
|
|
1931
|
-
}
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
2205
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2206
|
+
}
|
|
2207
|
+
return this;
|
|
2208
|
+
}
|
|
2209
|
+
function size(width, height){
|
|
2210
|
+
return this.style({width, height})
|
|
2211
|
+
}
|
|
2212
|
+
function hide(){
|
|
1936
2213
|
|
|
1937
|
-
|
|
1938
|
-
|
|
2214
|
+
}
|
|
2215
|
+
function show(){
|
|
1939
2216
|
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
2217
|
+
}
|
|
2218
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2219
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2220
|
+
return this;
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2224
|
+
__proto__: null,
|
|
2225
|
+
animate: animate,
|
|
2226
|
+
hide: hide,
|
|
2227
|
+
show: show,
|
|
2228
|
+
size: size,
|
|
2229
|
+
style: style
|
|
2230
|
+
});
|
|
1946
2231
|
|
|
1947
2232
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
1948
2233
|
this.event=e;
|
|
@@ -2604,22 +2889,22 @@
|
|
|
2604
2889
|
});
|
|
2605
2890
|
}
|
|
2606
2891
|
get x0(){
|
|
2607
|
-
return map(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2892
|
+
return map$1(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2608
2893
|
}
|
|
2609
2894
|
get y0(){
|
|
2610
|
-
return - map(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2895
|
+
return - map$1(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2611
2896
|
}
|
|
2612
2897
|
get x1(){
|
|
2613
|
-
return map(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2898
|
+
return map$1(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2614
2899
|
}
|
|
2615
2900
|
get y1(){
|
|
2616
|
-
return - map(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2901
|
+
return - map$1(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2617
2902
|
}
|
|
2618
2903
|
get cx(){
|
|
2619
|
-
return map(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2904
|
+
return map$1(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2620
2905
|
}
|
|
2621
2906
|
get cy(){
|
|
2622
|
-
return - map(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2907
|
+
return - map$1(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2623
2908
|
}
|
|
2624
2909
|
}
|
|
2625
2910
|
|
|
@@ -2881,21 +3166,10 @@
|
|
|
2881
3166
|
|
|
2882
3167
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
2883
3168
|
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
2889
|
-
if(typeof element === "string") {
|
|
2890
|
-
switch(type){
|
|
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
|
-
}
|
|
3169
|
+
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3170
|
+
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render}={}){
|
|
3171
|
+
super({element, name, type, render});
|
|
3172
|
+
console.log(this);
|
|
2899
3173
|
register(
|
|
2900
3174
|
this,
|
|
2901
3175
|
AttrsMethods,
|
|
@@ -2904,61 +3178,7 @@
|
|
|
2904
3178
|
IndexingMethods,
|
|
2905
3179
|
EventsMethodes
|
|
2906
3180
|
);
|
|
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);
|
|
3181
|
+
this.init(element, name, type, render);
|
|
2962
3182
|
}
|
|
2963
3183
|
get element(){
|
|
2964
3184
|
return this.cache.element;
|
|
@@ -2966,9 +3186,9 @@
|
|
|
2966
3186
|
isInteractive(){
|
|
2967
3187
|
return this.cache.isInteractive;
|
|
2968
3188
|
}
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
}
|
|
3189
|
+
// isUIElement(){
|
|
3190
|
+
// return true;
|
|
3191
|
+
// }
|
|
2972
3192
|
get st(){
|
|
2973
3193
|
return this.cache.style;
|
|
2974
3194
|
}
|
|
@@ -3008,73 +3228,73 @@
|
|
|
3008
3228
|
get left(){
|
|
3009
3229
|
return this.element.getBoundingClientRect().left;
|
|
3010
3230
|
}
|
|
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
|
-
}
|
|
3231
|
+
// clone(render=false) {
|
|
3232
|
+
// // UI.__proto__=this.__proto__;
|
|
3233
|
+
// // if(this.items.length){
|
|
3234
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
3235
|
+
// // UI.append(...items);
|
|
3236
|
+
// // }
|
|
3237
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
3238
|
+
// // return UI.render(render);
|
|
3239
|
+
// }
|
|
3240
|
+
// [Symbol.iterator]() {
|
|
3241
|
+
// return this.items[Symbol.iterator]();
|
|
3242
|
+
// }
|
|
3243
|
+
// maintain() {
|
|
3244
|
+
// for (let i = 0; i < this.items.length; i++) {
|
|
3245
|
+
// Object.defineProperty(this, i, {
|
|
3246
|
+
// value: this.items[i],
|
|
3247
|
+
// writable: true,
|
|
3248
|
+
// configurable: true,
|
|
3249
|
+
// enumerable: false
|
|
3250
|
+
// });
|
|
3251
|
+
// }
|
|
3252
|
+
// }
|
|
3253
|
+
// freeze(freeze){
|
|
3254
|
+
// this.cache.isFrozzen=freeze;
|
|
3255
|
+
// return this;
|
|
3256
|
+
// }
|
|
3037
3257
|
// setTarget(tg) {
|
|
3038
3258
|
// if(this.isBody) return ;
|
|
3039
|
-
// if (tg?.
|
|
3259
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
3040
3260
|
// this.unrender();
|
|
3041
3261
|
// this.target = tg;
|
|
3042
3262
|
// this.render();
|
|
3043
3263
|
// return this;
|
|
3044
3264
|
// }
|
|
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
|
-
}
|
|
3265
|
+
// describe(label){
|
|
3266
|
+
// if(label)this.setAttr("aria-label",label)
|
|
3267
|
+
// }
|
|
3268
|
+
// get children() {
|
|
3269
|
+
// return [...this.element.children];
|
|
3270
|
+
// }
|
|
3271
|
+
// get cloneElement() {
|
|
3272
|
+
// return this.element.cloneNode(true);
|
|
3273
|
+
// }
|
|
3274
|
+
// setClasses(...value) {
|
|
3275
|
+
// this.setAttr("class", value.join(" "));
|
|
3276
|
+
// return this;
|
|
3277
|
+
// }
|
|
3278
|
+
// get classes(){
|
|
3279
|
+
// const classes=this.element.getAttribute("class");
|
|
3280
|
+
// return classes===null?[]:classes.split(" ");
|
|
3281
|
+
// }
|
|
3282
|
+
// addClass() {
|
|
3283
|
+
// /*this.setAttr("class", value);
|
|
3284
|
+
// return this;*/
|
|
3285
|
+
// }
|
|
3286
|
+
// setId(id) {
|
|
3287
|
+
// this.setAttr("id", id);
|
|
3288
|
+
// return this;
|
|
3289
|
+
// }
|
|
3290
|
+
// get id() {
|
|
3291
|
+
// return this.element.getAttribute("id");
|
|
3292
|
+
// }
|
|
3293
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3294
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
3295
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
3296
|
+
// return this;
|
|
3297
|
+
// }
|
|
3078
3298
|
// To Fix
|
|
3079
3299
|
// onKeysDown({keys=[],callback}={}){
|
|
3080
3300
|
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
@@ -3096,26 +3316,26 @@
|
|
|
3096
3316
|
this.events.custom.emit(event_name,detail);
|
|
3097
3317
|
return this;
|
|
3098
3318
|
}
|
|
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
|
-
}
|
|
3319
|
+
// watchAttr(callback){
|
|
3320
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
3321
|
+
// return this;
|
|
3322
|
+
// }
|
|
3323
|
+
// watchChildren(callback){
|
|
3324
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
3325
|
+
// return this;
|
|
3326
|
+
// }
|
|
3327
|
+
// watchSize(callback){
|
|
3328
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
3329
|
+
// this.observer.resize.start();
|
|
3330
|
+
// return this;
|
|
3331
|
+
// }
|
|
3332
|
+
// watchIntersection(callback,config){
|
|
3333
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
3334
|
+
// this.observer.intersection.start();
|
|
3335
|
+
// return this;
|
|
3336
|
+
// }
|
|
3117
3337
|
|
|
3118
|
-
}
|
|
3338
|
+
};
|
|
3119
3339
|
|
|
3120
3340
|
const HTMLTags = [
|
|
3121
3341
|
'a',
|
|
@@ -3251,11 +3471,11 @@
|
|
|
3251
3471
|
// console.log(isStateGetter(args[0]))
|
|
3252
3472
|
if(
|
|
3253
3473
|
['string', 'number'].includes(typeof args[0])
|
|
3254
|
-
|| args[0] instanceof UIElement
|
|
3474
|
+
|| args[0] instanceof UIElement$1
|
|
3255
3475
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3256
|
-
) return new UIElement({element : tag, name : tag, type}).append(...args);
|
|
3476
|
+
) return new UIElement$1({element : tag, name : tag, type}).append(...args);
|
|
3257
3477
|
// console.log(args[0])
|
|
3258
|
-
return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
|
|
3478
|
+
return new UIElement$1({element : tag}).setAttr(args.shift()).append(...args)
|
|
3259
3479
|
}
|
|
3260
3480
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3261
3481
|
// return (...args)=>{
|
|
@@ -3278,7 +3498,7 @@
|
|
|
3278
3498
|
}
|
|
3279
3499
|
});
|
|
3280
3500
|
|
|
3281
|
-
class ZikoUIFlex extends UIElement {
|
|
3501
|
+
class ZikoUIFlex extends UIElement$1 {
|
|
3282
3502
|
constructor(tag = "div", w = "100%", h = "100%") {
|
|
3283
3503
|
super({element : tag , name : "Flex"});
|
|
3284
3504
|
this.direction = "cols";
|
|
@@ -3377,37 +3597,11 @@
|
|
|
3377
3597
|
return map_pos_x(-align);
|
|
3378
3598
|
}
|
|
3379
3599
|
|
|
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;
|
|
3600
|
+
class UIElement extends UIElementCore{
|
|
3601
|
+
constructor({element, name, type, render}){
|
|
3602
|
+
super({element, name, type, render});
|
|
3408
3603
|
}
|
|
3409
|
-
}
|
|
3410
|
-
const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
|
|
3604
|
+
}
|
|
3411
3605
|
|
|
3412
3606
|
class ZikoUISuspense extends UIElement{
|
|
3413
3607
|
constructor(fallback_ui, callback){
|
|
@@ -3433,275 +3627,6 @@
|
|
|
3433
3627
|
|
|
3434
3628
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3435
3629
|
|
|
3436
|
-
class ZikoUIXMLWrapper extends UIElement{
|
|
3437
|
-
constructor(XMLContent, type){
|
|
3438
|
-
super({element : "div", name : ""});
|
|
3439
|
-
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
|
|
3440
|
-
}
|
|
3441
|
-
}
|
|
3442
|
-
function html2dom(htmlString) {
|
|
3443
|
-
if(globalThis?.DOMParser){
|
|
3444
|
-
const parser = new DOMParser();
|
|
3445
|
-
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
3446
|
-
doc.body.firstChild.style.display = "contents";
|
|
3447
|
-
return doc.body.firstChild;
|
|
3448
|
-
}
|
|
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
|
-
}
|
|
3462
|
-
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
3463
|
-
constructor(SVGContent){
|
|
3464
|
-
super(SVGContent, "svg");
|
|
3465
|
-
}
|
|
3466
|
-
}
|
|
3467
|
-
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
3468
|
-
const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
|
|
3469
|
-
|
|
3470
|
-
class ZikoUICanvas extends UIElement{
|
|
3471
|
-
constructor(w,h){
|
|
3472
|
-
super("canvas","canvas");
|
|
3473
|
-
this.ctx = this.element?.getContext("2d");
|
|
3474
|
-
this.style({
|
|
3475
|
-
border:"1px red solid",
|
|
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);
|
|
3619
|
-
});
|
|
3620
|
-
}
|
|
3621
|
-
zoomIn(){
|
|
3622
|
-
|
|
3623
|
-
}
|
|
3624
|
-
zoomOut(){
|
|
3625
|
-
|
|
3626
|
-
}
|
|
3627
|
-
undo(n){
|
|
3628
|
-
|
|
3629
|
-
}
|
|
3630
|
-
redo(n){
|
|
3631
|
-
|
|
3632
|
-
}
|
|
3633
|
-
stream(){
|
|
3634
|
-
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
|
|
3638
|
-
const Canvas=(w,h)=>new ZikoUICanvas(w,h);
|
|
3639
|
-
|
|
3640
|
-
class ZikoUISvg extends UIElement {
|
|
3641
|
-
constructor(w=360,h=300) {
|
|
3642
|
-
super("svg","svg");
|
|
3643
|
-
//this.cache={};
|
|
3644
|
-
// this.setAttr("width",w);
|
|
3645
|
-
// this.setAttr("height",h);
|
|
3646
|
-
// this.setAttr({
|
|
3647
|
-
// width : w,
|
|
3648
|
-
// height : h
|
|
3649
|
-
// })
|
|
3650
|
-
this.style({border:"1px black solid"});
|
|
3651
|
-
//this.view(-w/2,-h/2,w/2,h/2);
|
|
3652
|
-
this.size(w, h);
|
|
3653
|
-
this.view(-10,-10,10,10);
|
|
3654
|
-
}
|
|
3655
|
-
size(w, h){
|
|
3656
|
-
this.setAttr({
|
|
3657
|
-
width : w,
|
|
3658
|
-
height : h
|
|
3659
|
-
});
|
|
3660
|
-
return this
|
|
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
|
-
|
|
3701
|
-
}
|
|
3702
|
-
|
|
3703
|
-
const Svg =(w,h)=>new ZikoUISvg(w,h);
|
|
3704
|
-
|
|
3705
3630
|
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3706
3631
|
if (globalThis.customElements?.get(name)) {
|
|
3707
3632
|
console.warn(`Custom element "${name}" is already defined`);
|
|
@@ -4970,7 +4895,7 @@
|
|
|
4970
4895
|
this.t += this.state.step;
|
|
4971
4896
|
this.i++;
|
|
4972
4897
|
|
|
4973
|
-
this.tx = map(this.t, 0, this.state.duration, 0, 1);
|
|
4898
|
+
this.tx = map$1(this.t, 0, this.state.duration, 0, 1);
|
|
4974
4899
|
this.ty = this.state.ease(this.tx);
|
|
4975
4900
|
|
|
4976
4901
|
this.callback(this);
|
|
@@ -5415,7 +5340,7 @@
|
|
|
5415
5340
|
return this;
|
|
5416
5341
|
}
|
|
5417
5342
|
setWrapper(wrapper){
|
|
5418
|
-
if(wrapper?.
|
|
5343
|
+
if(wrapper?.isUIElement) this.wrapper = wrapper;
|
|
5419
5344
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5420
5345
|
return this;
|
|
5421
5346
|
}
|
|
@@ -5487,7 +5412,7 @@
|
|
|
5487
5412
|
}
|
|
5488
5413
|
clear(){
|
|
5489
5414
|
[...this.routes].forEach(n=>{
|
|
5490
|
-
!isDynamic(n[0]) && n[1]?.
|
|
5415
|
+
!isDynamic(n[0]) && n[1]?.isUIElement && n[1].unrender();
|
|
5491
5416
|
});
|
|
5492
5417
|
// this.wrapper.clear();
|
|
5493
5418
|
return this;
|
|
@@ -5500,10 +5425,10 @@
|
|
|
5500
5425
|
element = callback.call(this,params);
|
|
5501
5426
|
}
|
|
5502
5427
|
else {
|
|
5503
|
-
callback?.
|
|
5428
|
+
callback?.isUIElement && callback.render(this.wrapper);
|
|
5504
5429
|
if(typeof callback === "function") element = callback();
|
|
5505
5430
|
}
|
|
5506
|
-
if(element?.
|
|
5431
|
+
if(element?.isUIElement) element.render(this.wrapper);
|
|
5507
5432
|
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
5508
5433
|
if(element instanceof Promise){
|
|
5509
5434
|
element.then(e=>e.render(this.wrapper));
|
|
@@ -5944,7 +5869,6 @@
|
|
|
5944
5869
|
exports.Arc = Arc;
|
|
5945
5870
|
exports.Back = Back;
|
|
5946
5871
|
exports.Base = Base;
|
|
5947
|
-
exports.Canvas = Canvas;
|
|
5948
5872
|
exports.Clock = Clock;
|
|
5949
5873
|
exports.Combinaison = Combinaison;
|
|
5950
5874
|
exports.Complex = Complex;
|
|
@@ -5954,8 +5878,6 @@
|
|
|
5954
5878
|
exports.Elastic = Elastic;
|
|
5955
5879
|
exports.FileBasedRouting = FileBasedRouting;
|
|
5956
5880
|
exports.Flex = Flex;
|
|
5957
|
-
exports.Grid = Grid$1;
|
|
5958
|
-
exports.HTMLWrapper = HTMLWrapper;
|
|
5959
5881
|
exports.InBack = InBack;
|
|
5960
5882
|
exports.InBounce = InBounce;
|
|
5961
5883
|
exports.InCirc = InCirc;
|
|
@@ -5993,16 +5915,14 @@
|
|
|
5993
5915
|
exports.Permutation = Permutation;
|
|
5994
5916
|
exports.Random = Random;
|
|
5995
5917
|
exports.SPA = SPA;
|
|
5996
|
-
exports.SVGWrapper = SVGWrapper;
|
|
5997
5918
|
exports.Scheduler = Scheduler;
|
|
5998
5919
|
exports.Step = Step;
|
|
5999
5920
|
exports.Suspense = Suspense;
|
|
6000
|
-
exports.Svg = Svg;
|
|
6001
5921
|
exports.Tick = Tick;
|
|
6002
5922
|
exports.TimeAnimation = TimeAnimation;
|
|
6003
5923
|
exports.TimeLoop = TimeLoop;
|
|
6004
5924
|
exports.TimeScheduler = TimeScheduler;
|
|
6005
|
-
exports.UIElement = UIElement;
|
|
5925
|
+
exports.UIElement = UIElement$1;
|
|
6006
5926
|
exports.UINode = UINode;
|
|
6007
5927
|
exports.Utils = Utils;
|
|
6008
5928
|
exports.ZikoApp = ZikoApp;
|
|
@@ -6022,15 +5942,9 @@
|
|
|
6022
5942
|
exports.ZikoHead = ZikoHead;
|
|
6023
5943
|
exports.ZikoMutationObserver = ZikoMutationObserver;
|
|
6024
5944
|
exports.ZikoSPA = ZikoSPA;
|
|
6025
|
-
exports.ZikoUICanvas = ZikoUICanvas;
|
|
6026
5945
|
exports.ZikoUIFlex = ZikoUIFlex;
|
|
6027
|
-
exports.ZikoUIGrid = ZikoUIGrid;
|
|
6028
|
-
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
6029
|
-
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
6030
5946
|
exports.ZikoUISuspense = ZikoUISuspense;
|
|
6031
|
-
exports.ZikoUISvg = ZikoUISvg;
|
|
6032
5947
|
exports.ZikoUIText = ZikoUIText;
|
|
6033
|
-
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
6034
5948
|
exports.ZikoUseRoot = ZikoUseRoot;
|
|
6035
5949
|
exports.__ZikoEvent__ = __ZikoEvent__;
|
|
6036
5950
|
exports.abs = abs;
|
|
@@ -6047,17 +5961,17 @@
|
|
|
6047
5961
|
exports.atan = atan;
|
|
6048
5962
|
exports.atan2 = atan2;
|
|
6049
5963
|
exports.atanh = atanh;
|
|
6050
|
-
exports.bindClickEvent = bindClickEvent;
|
|
6051
|
-
exports.bindClipboardEvent = bindClipboardEvent;
|
|
6052
5964
|
exports.bindCustomEvent = bindCustomEvent;
|
|
6053
|
-
exports.bindDragEvent = bindDragEvent;
|
|
6054
|
-
exports.bindFocusEvent = bindFocusEvent;
|
|
6055
5965
|
exports.bindHashEvent = bindHashEvent;
|
|
6056
|
-
exports.bindKeyEvent = bindKeyEvent;
|
|
6057
|
-
exports.bindMouseEvent = bindMouseEvent;
|
|
6058
|
-
exports.bindPointerEvent = bindPointerEvent;
|
|
6059
5966
|
exports.bindTouchEvent = bindTouchEvent;
|
|
6060
|
-
exports.
|
|
5967
|
+
exports.bind_click_event = bind_click_event;
|
|
5968
|
+
exports.bind_clipboard_event = bind_clipboard_event;
|
|
5969
|
+
exports.bind_drag_event = bind_drag_event;
|
|
5970
|
+
exports.bind_focus_event = bind_focus_event;
|
|
5971
|
+
exports.bind_key_event = bind_key_event;
|
|
5972
|
+
exports.bind_mouse_event = bind_mouse_event;
|
|
5973
|
+
exports.bind_pointer_event = bind_pointer_event;
|
|
5974
|
+
exports.bind_wheel_event = bind_wheel_event;
|
|
6061
5975
|
exports.cartesianProduct = cartesianProduct;
|
|
6062
5976
|
exports.ceil = ceil;
|
|
6063
5977
|
exports.clamp = clamp;
|
|
@@ -6101,7 +6015,7 @@
|
|
|
6101
6015
|
exports.ln = ln;
|
|
6102
6016
|
exports.logspace = logspace;
|
|
6103
6017
|
exports.loop = loop;
|
|
6104
|
-
exports.map = map;
|
|
6018
|
+
exports.map = map$1;
|
|
6105
6019
|
exports.mapfun = mapfun$1;
|
|
6106
6020
|
exports.matrix = matrix;
|
|
6107
6021
|
exports.matrix2 = matrix2;
|