ziko 0.45.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.js +626 -712
- 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 +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/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.mjs
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
|
|
@@ -249,17 +249,17 @@ const lerp=(value, min, max)=>{
|
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
};
|
|
252
|
-
const map=(value, a, b, c, d)=>{
|
|
252
|
+
const map$1=(value, a, b, c, d)=>{
|
|
253
253
|
if (typeof value === "number") return lerp(norm(value, a, b), c, d);
|
|
254
|
-
else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, map(value.arr.flat(1), a, b, c, d));
|
|
255
|
-
else if (value instanceof Complex) return new Complex(map(value.a, b, c, d), map(value.b, a, b, c, d));
|
|
254
|
+
else if (value instanceof Matrix) return new Matrix(value.rows, value.cols, map$1(value.arr.flat(1), a, b, c, d));
|
|
255
|
+
else if (value instanceof Complex) return new Complex(map$1(value.a, b, c, d), map$1(value.b, a, b, c, d));
|
|
256
256
|
else if (value instanceof Array) {
|
|
257
257
|
if (value.every((n) => typeof (n === "number"))) {
|
|
258
|
-
return value.map((n) => map(n, a, b, c, d));
|
|
258
|
+
return value.map((n) => map$1(n, a, b, c, d));
|
|
259
259
|
} else {
|
|
260
260
|
let y = new Array(value.length);
|
|
261
261
|
for (let i = 0; i < value.length; i++) {
|
|
262
|
-
y[i] = map(value[i], a, b, c, d);
|
|
262
|
+
y[i] = map$1(value[i], a, b, c, d);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
}
|
|
@@ -532,7 +532,7 @@ const Utils={
|
|
|
532
532
|
nums,
|
|
533
533
|
norm,
|
|
534
534
|
lerp,
|
|
535
|
-
map,
|
|
535
|
+
map: map$1,
|
|
536
536
|
clamp,
|
|
537
537
|
arange,
|
|
538
538
|
linspace,
|
|
@@ -1074,47 +1074,6 @@ class UINode {
|
|
|
1074
1074
|
|
|
1075
1075
|
// globalThis.node = (node) => new UINode(node);
|
|
1076
1076
|
|
|
1077
|
-
function register_to_class(target, ...mixins){
|
|
1078
|
-
mixins.forEach(n => _register_to_class_(target, n));
|
|
1079
|
-
}
|
|
1080
|
-
function _register_to_class_(target, mixin) {
|
|
1081
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1082
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1083
|
-
const desc = descriptors[key];
|
|
1084
|
-
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1085
|
-
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1086
|
-
} else if (typeof desc.value === 'function') {
|
|
1087
|
-
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1088
|
-
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1089
|
-
}
|
|
1090
|
-
}
|
|
1091
|
-
}
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
function register_to_instance(target, ...mixins){
|
|
1095
|
-
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1096
|
-
}
|
|
1097
|
-
function _register_to_instance_(instance, mixin) {
|
|
1098
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1099
|
-
|
|
1100
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1101
|
-
const desc = descriptors[key];
|
|
1102
|
-
|
|
1103
|
-
if ('get' in desc || 'set' in desc) {
|
|
1104
|
-
Object.defineProperty(instance, key, desc);
|
|
1105
|
-
} else if (typeof desc.value === 'function') {
|
|
1106
|
-
instance[key] = desc.value.bind(instance);
|
|
1107
|
-
} else {
|
|
1108
|
-
instance[key] = desc.value;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
const register = (target, ...mixins) => {
|
|
1114
|
-
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1115
|
-
else register_to_instance(target, ...mixins);
|
|
1116
|
-
};
|
|
1117
|
-
|
|
1118
1077
|
function parseQueryParams$1(queryString) {
|
|
1119
1078
|
const params = {};
|
|
1120
1079
|
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
@@ -1237,6 +1196,295 @@ function __init__global__(){
|
|
|
1237
1196
|
}
|
|
1238
1197
|
}
|
|
1239
1198
|
|
|
1199
|
+
__init__global__();
|
|
1200
|
+
class UIElementCore extends UINode{
|
|
1201
|
+
constructor({
|
|
1202
|
+
element,
|
|
1203
|
+
name ='',
|
|
1204
|
+
type="html",
|
|
1205
|
+
render = __Ziko__.__Config__.default.render,
|
|
1206
|
+
isInteractive = false,
|
|
1207
|
+
}={}){
|
|
1208
|
+
super();
|
|
1209
|
+
this.init(element, name, type, render, isInteractive);
|
|
1210
|
+
}
|
|
1211
|
+
init(element, name, type, render, isInteractive = [true, false][Math.floor(2*Math.random())]){
|
|
1212
|
+
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1213
|
+
if(typeof element === "string") {
|
|
1214
|
+
switch(type){
|
|
1215
|
+
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
1216
|
+
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1217
|
+
default : throw Error("Not supported")
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
else this.target = element?.parentElement;
|
|
1221
|
+
Object.assign(this.cache, {
|
|
1222
|
+
name,
|
|
1223
|
+
isInteractive,
|
|
1224
|
+
parent:null,
|
|
1225
|
+
isBody:false,
|
|
1226
|
+
isRoot:false,
|
|
1227
|
+
isHidden: false,
|
|
1228
|
+
isFrozzen:false,
|
|
1229
|
+
legacyParent : null,
|
|
1230
|
+
attributes: {},
|
|
1231
|
+
filters: {},
|
|
1232
|
+
temp:{}
|
|
1233
|
+
});
|
|
1234
|
+
this.events = {
|
|
1235
|
+
ptr:null,
|
|
1236
|
+
mouse:null,
|
|
1237
|
+
wheel:null,
|
|
1238
|
+
key:null,
|
|
1239
|
+
drag:null,
|
|
1240
|
+
drop:null,
|
|
1241
|
+
click:null,
|
|
1242
|
+
clipboard:null,
|
|
1243
|
+
focus:null,
|
|
1244
|
+
swipe:null,
|
|
1245
|
+
custom:null,
|
|
1246
|
+
};
|
|
1247
|
+
this.observer={
|
|
1248
|
+
resize:null,
|
|
1249
|
+
intersection:null
|
|
1250
|
+
};
|
|
1251
|
+
if(element) Object.assign(this.cache,{element});
|
|
1252
|
+
// useDefaultStyle && this.style({
|
|
1253
|
+
// position: "relative",
|
|
1254
|
+
// boxSizing:"border-box",
|
|
1255
|
+
// margin:0,
|
|
1256
|
+
// padding:0,
|
|
1257
|
+
// width : "auto",
|
|
1258
|
+
// height : "auto"
|
|
1259
|
+
// });
|
|
1260
|
+
this.items = new UIStore();
|
|
1261
|
+
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
1262
|
+
element && render && this?.render?.();
|
|
1263
|
+
if(
|
|
1264
|
+
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
1265
|
+
// &&
|
|
1266
|
+
// !globalThis.__Ziko__.__Config__.isSSC
|
|
1267
|
+
// &&
|
|
1268
|
+
this.isInteractive()){
|
|
1269
|
+
// this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
1270
|
+
this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index);
|
|
1271
|
+
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
1272
|
+
}
|
|
1273
|
+
globalThis.__Ziko__.__UI__.push(this);
|
|
1274
|
+
}
|
|
1275
|
+
get element(){
|
|
1276
|
+
return this.cache.element;
|
|
1277
|
+
}
|
|
1278
|
+
[Symbol.iterator]() {
|
|
1279
|
+
return this.items[Symbol.iterator]();
|
|
1280
|
+
}
|
|
1281
|
+
maintain() {
|
|
1282
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
1283
|
+
Object.defineProperty(this, i, {
|
|
1284
|
+
value: this.items[i],
|
|
1285
|
+
writable: true,
|
|
1286
|
+
configurable: true,
|
|
1287
|
+
enumerable: false
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
isInteractive(){
|
|
1292
|
+
return this.cache.isInteractive;
|
|
1293
|
+
}
|
|
1294
|
+
isUIElement(){
|
|
1295
|
+
return true;
|
|
1296
|
+
}
|
|
1297
|
+
// get st(){
|
|
1298
|
+
// return this.cache.style;
|
|
1299
|
+
// }
|
|
1300
|
+
// get attr(){
|
|
1301
|
+
// return this.cache.attributes;
|
|
1302
|
+
// }
|
|
1303
|
+
// get evt(){
|
|
1304
|
+
// return this.events;
|
|
1305
|
+
// }
|
|
1306
|
+
// get html(){
|
|
1307
|
+
// return this.element.innerHTML;
|
|
1308
|
+
// }
|
|
1309
|
+
// get text(){
|
|
1310
|
+
// return this.element.textContent;
|
|
1311
|
+
// }
|
|
1312
|
+
// get isBody(){
|
|
1313
|
+
// return this.element === globalThis?.document.body;
|
|
1314
|
+
// }
|
|
1315
|
+
// get parent(){
|
|
1316
|
+
// return this.cache.parent;
|
|
1317
|
+
// }
|
|
1318
|
+
// get width(){
|
|
1319
|
+
// return this.element.getBoundingClientRect().width;
|
|
1320
|
+
// }
|
|
1321
|
+
// get height(){
|
|
1322
|
+
// return this.element.getBoundingClientRect().height;
|
|
1323
|
+
// }
|
|
1324
|
+
// get top(){
|
|
1325
|
+
// return this.element.getBoundingClientRect().top;
|
|
1326
|
+
// }
|
|
1327
|
+
// get right(){
|
|
1328
|
+
// return this.element.getBoundingClientRect().right;
|
|
1329
|
+
// }
|
|
1330
|
+
// get bottom(){
|
|
1331
|
+
// return this.element.getBoundingClientRect().bottom;
|
|
1332
|
+
// }
|
|
1333
|
+
// get left(){
|
|
1334
|
+
// return this.element.getBoundingClientRect().left;
|
|
1335
|
+
// }
|
|
1336
|
+
// clone(render=false) {
|
|
1337
|
+
// // UI.__proto__=this.__proto__;
|
|
1338
|
+
// // if(this.items.length){
|
|
1339
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
1340
|
+
// // UI.append(...items);
|
|
1341
|
+
// // }
|
|
1342
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
1343
|
+
// // return UI.render(render);
|
|
1344
|
+
// }
|
|
1345
|
+
|
|
1346
|
+
// freeze(freeze){
|
|
1347
|
+
// this.cache.isFrozzen=freeze;
|
|
1348
|
+
// return this;
|
|
1349
|
+
// }
|
|
1350
|
+
// setTarget(tg) {
|
|
1351
|
+
// if(this.isBody) return ;
|
|
1352
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
1353
|
+
// this.unrender();
|
|
1354
|
+
// this.target = tg;
|
|
1355
|
+
// this.render();
|
|
1356
|
+
// return this;
|
|
1357
|
+
// }
|
|
1358
|
+
// describe(label){
|
|
1359
|
+
// if(label)this.setAttr("aria-label",label)
|
|
1360
|
+
// }
|
|
1361
|
+
// get children() {
|
|
1362
|
+
// return [...this.element.children];
|
|
1363
|
+
// }
|
|
1364
|
+
// get cloneElement() {
|
|
1365
|
+
// return this.element.cloneNode(true);
|
|
1366
|
+
// }
|
|
1367
|
+
// setClasses(...value) {
|
|
1368
|
+
// this.setAttr("class", value.join(" "));
|
|
1369
|
+
// return this;
|
|
1370
|
+
// }
|
|
1371
|
+
// get classes(){
|
|
1372
|
+
// const classes=this.element.getAttribute("class");
|
|
1373
|
+
// return classes===null?[]:classes.split(" ");
|
|
1374
|
+
// }
|
|
1375
|
+
// addClass() {
|
|
1376
|
+
// /*this.setAttr("class", value);
|
|
1377
|
+
// return this;*/
|
|
1378
|
+
// }
|
|
1379
|
+
// setId(id) {
|
|
1380
|
+
// this.setAttr("id", id);
|
|
1381
|
+
// return this;
|
|
1382
|
+
// }
|
|
1383
|
+
// get id() {
|
|
1384
|
+
// return this.element.getAttribute("id");
|
|
1385
|
+
// }
|
|
1386
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
1387
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
1388
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
1389
|
+
// return this;
|
|
1390
|
+
// }
|
|
1391
|
+
// To Fix
|
|
1392
|
+
// onKeysDown({keys=[],callback}={}){
|
|
1393
|
+
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
1394
|
+
// this.events.key.handleSuccessifKeys({keys,callback});
|
|
1395
|
+
// return this;
|
|
1396
|
+
// }
|
|
1397
|
+
// onSelect(...callbacks){
|
|
1398
|
+
// if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
|
|
1399
|
+
// this.events.clipboard.onSelect(...callbacks);
|
|
1400
|
+
// return this;
|
|
1401
|
+
// }
|
|
1402
|
+
// on(event_name,...callbacks){
|
|
1403
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1404
|
+
// this.events.custom.on(event_name,...callbacks);
|
|
1405
|
+
// return this;
|
|
1406
|
+
// }
|
|
1407
|
+
// emit(event_name,detail={}){
|
|
1408
|
+
// if(!this.events.custom)this.events.custom = useCustomEvent(this);
|
|
1409
|
+
// this.events.custom.emit(event_name,detail);
|
|
1410
|
+
// return this;
|
|
1411
|
+
// }
|
|
1412
|
+
// watchAttr(callback){
|
|
1413
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
1414
|
+
// return this;
|
|
1415
|
+
// }
|
|
1416
|
+
// watchChildren(callback){
|
|
1417
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
1418
|
+
// return this;
|
|
1419
|
+
// }
|
|
1420
|
+
// watchSize(callback){
|
|
1421
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
1422
|
+
// this.observer.resize.start();
|
|
1423
|
+
// return this;
|
|
1424
|
+
// }
|
|
1425
|
+
// watchIntersection(callback,config){
|
|
1426
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
1427
|
+
// this.observer.intersection.start();
|
|
1428
|
+
// return this;
|
|
1429
|
+
// }
|
|
1430
|
+
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1433
|
+
function register_to_class(target, ...mixins){
|
|
1434
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1435
|
+
}
|
|
1436
|
+
function _register_to_class_(target, mixin) {
|
|
1437
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1438
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1439
|
+
const desc = descriptors[key];
|
|
1440
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1441
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1442
|
+
} else if (typeof desc.value === 'function') {
|
|
1443
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1444
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1445
|
+
}
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
function register_to_instance(target, ...mixins){
|
|
1451
|
+
console.log('register to instance');
|
|
1452
|
+
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1453
|
+
}
|
|
1454
|
+
function _register_to_instance_(instance, mixin) {
|
|
1455
|
+
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1456
|
+
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1457
|
+
const desc = descriptors[key];
|
|
1458
|
+
if ('get' in desc || 'set' in desc) {
|
|
1459
|
+
Object.defineProperty(instance, key, {
|
|
1460
|
+
...desc,
|
|
1461
|
+
configurable: true // 🔑 make it replaceable
|
|
1462
|
+
});
|
|
1463
|
+
} else if (typeof desc.value === 'function') {
|
|
1464
|
+
Object.defineProperty(instance, key, {
|
|
1465
|
+
value: desc.value.bind(instance),
|
|
1466
|
+
writable: true, // 🔑 allow reassignment
|
|
1467
|
+
configurable: true, // 🔑 allow redefinition
|
|
1468
|
+
enumerable: false
|
|
1469
|
+
});
|
|
1470
|
+
} else {
|
|
1471
|
+
Object.defineProperty(instance, key, {
|
|
1472
|
+
value: desc.value,
|
|
1473
|
+
writable: true,
|
|
1474
|
+
configurable: true,
|
|
1475
|
+
enumerable: true
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
const register = (target, ...mixins) => {
|
|
1482
|
+
console.log(target);
|
|
1483
|
+
// return register_to_class(target, ...mixins)
|
|
1484
|
+
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1485
|
+
else register_to_instance(target, ...mixins);
|
|
1486
|
+
};
|
|
1487
|
+
|
|
1240
1488
|
if(!globalThis.__Ziko__) __init__global__();
|
|
1241
1489
|
|
|
1242
1490
|
// HMR persistence
|
|
@@ -1299,58 +1547,14 @@ const isStateGetter = (arg) => {
|
|
|
1299
1547
|
return typeof arg === 'function' && arg?.()?.isStateGetter?.();
|
|
1300
1548
|
};
|
|
1301
1549
|
|
|
1302
|
-
const camel2hyphencase = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1550
|
+
const camel2hyphencase$1 = (text = '') => text.replace(/[A-Z]/g, match => '-' + match.toLowerCase());
|
|
1303
1551
|
|
|
1304
|
-
const is_camelcase = (text = '') =>{
|
|
1552
|
+
const is_camelcase$1 = (text = '') =>{
|
|
1305
1553
|
if (text.length === 0) return false;
|
|
1306
1554
|
const camelCasePattern = /^[a-z][a-zA-Z0-9]*$/;
|
|
1307
1555
|
return camelCasePattern.test(text);
|
|
1308
1556
|
};
|
|
1309
1557
|
|
|
1310
|
-
// To Do add getter, watchAttr
|
|
1311
|
-
const AttrsMethods = {
|
|
1312
|
-
setAttr(name, value) {
|
|
1313
|
-
if(name instanceof Object){
|
|
1314
|
-
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1315
|
-
for(let i=0;i<names.length;i++){
|
|
1316
|
-
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1317
|
-
_set_attrs_.call(this, names[i], values[i]);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1320
|
-
else {
|
|
1321
|
-
if(value instanceof Array) value = value.join(" ");
|
|
1322
|
-
_set_attrs_.call(this, name, value);
|
|
1323
|
-
}
|
|
1324
|
-
return this;
|
|
1325
|
-
},
|
|
1326
|
-
removeAttr(...names) {
|
|
1327
|
-
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1328
|
-
return this;
|
|
1329
|
-
},
|
|
1330
|
-
getAttr(name){
|
|
1331
|
-
name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1332
|
-
return this.element.attributes[name].value;
|
|
1333
|
-
},
|
|
1334
|
-
setContentEditable(bool = true) {
|
|
1335
|
-
this.setAttr("contenteditable", bool);
|
|
1336
|
-
return this;
|
|
1337
|
-
}
|
|
1338
|
-
};
|
|
1339
|
-
|
|
1340
|
-
function _set_attrs_(name, value){
|
|
1341
|
-
if(this.element?.tagName !== "svg") name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1342
|
-
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1343
|
-
if(isStateGetter(value)){
|
|
1344
|
-
const getter = value();
|
|
1345
|
-
getter._subscribe(
|
|
1346
|
-
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1347
|
-
this
|
|
1348
|
-
);
|
|
1349
|
-
}
|
|
1350
|
-
else this.element?.setAttribute(name, value);
|
|
1351
|
-
Object.assign(this.cache.attributes, {[name]:value});
|
|
1352
|
-
}
|
|
1353
|
-
|
|
1354
1558
|
class ZikoUIText extends UINode {
|
|
1355
1559
|
constructor(...value) {
|
|
1356
1560
|
super("span", "text", false, ...value);
|
|
@@ -1362,75 +1566,6 @@ class ZikoUIText extends UINode {
|
|
|
1362
1566
|
}
|
|
1363
1567
|
const text = (...str) => new ZikoUIText(...str);
|
|
1364
1568
|
|
|
1365
|
-
const DomMethods = {
|
|
1366
|
-
append(...ele) {
|
|
1367
|
-
__addItem__.call(this, "append", "push", ...ele);
|
|
1368
|
-
return this;
|
|
1369
|
-
},
|
|
1370
|
-
prepend(...ele) {
|
|
1371
|
-
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
1372
|
-
return this;
|
|
1373
|
-
},
|
|
1374
|
-
insertAt(index, ...ele) {
|
|
1375
|
-
if (index >= this.element.children.length) this.append(...ele);
|
|
1376
|
-
else
|
|
1377
|
-
for (let i = 0; i < ele.length; i++) {
|
|
1378
|
-
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
1379
|
-
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
1380
|
-
this.items.splice(index, 0, ele[i]);
|
|
1381
|
-
}
|
|
1382
|
-
return this;
|
|
1383
|
-
},
|
|
1384
|
-
remove(...ele) {
|
|
1385
|
-
const remove = (ele) => {
|
|
1386
|
-
if (typeof ele === "number") ele = this.items[ele];
|
|
1387
|
-
if (ele?.isZikoUIElement) this.element?.removeChild(ele.element);
|
|
1388
|
-
this.items = this.items.filter((n) => n !== ele);
|
|
1389
|
-
};
|
|
1390
|
-
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
1391
|
-
for (let i = 0; i < this.items.length; i++)
|
|
1392
|
-
Object.assign(this, { [[i]]: this.items[i] });
|
|
1393
|
-
// Remove from item
|
|
1394
|
-
return this;
|
|
1395
|
-
},
|
|
1396
|
-
clear(){
|
|
1397
|
-
this?.items?.forEach(n=>n.unrender());
|
|
1398
|
-
this.element.innerHTML = "";
|
|
1399
|
-
return this;
|
|
1400
|
-
},
|
|
1401
|
-
render(target = this.target) {
|
|
1402
|
-
if(this.isBody)return ;
|
|
1403
|
-
if(target?.isZikoUIElement)target=target.element;
|
|
1404
|
-
this.target=target;
|
|
1405
|
-
this.target?.appendChild(this.element);
|
|
1406
|
-
return this;
|
|
1407
|
-
},
|
|
1408
|
-
unrender(){
|
|
1409
|
-
if(this.cache.parent)this.cache.parent.remove(this);
|
|
1410
|
-
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
1411
|
-
return this;
|
|
1412
|
-
},
|
|
1413
|
-
renderAfter(t = 1) {
|
|
1414
|
-
setTimeout(() => this.render(), t);
|
|
1415
|
-
return this;
|
|
1416
|
-
},
|
|
1417
|
-
unrenderAfter(t = 1) {
|
|
1418
|
-
setTimeout(() => this.unrender(), t);
|
|
1419
|
-
return this;
|
|
1420
|
-
},
|
|
1421
|
-
after(ui){
|
|
1422
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
1423
|
-
this.element?.after(ui);
|
|
1424
|
-
return this;
|
|
1425
|
-
},
|
|
1426
|
-
before(ui){
|
|
1427
|
-
if(ui?.isZikoUIElement) ui=ui.element;
|
|
1428
|
-
this.element?.before(ui);
|
|
1429
|
-
return this;
|
|
1430
|
-
}
|
|
1431
|
-
|
|
1432
|
-
};
|
|
1433
|
-
|
|
1434
1569
|
async function __addItem__(adder, pusher, ...ele) {
|
|
1435
1570
|
if (this.cache.isFrozzen) {
|
|
1436
1571
|
console.warn("You can't append new item to frozzen element");
|
|
@@ -1475,12 +1610,147 @@ async function __addItem__(adder, pusher, ...ele) {
|
|
|
1475
1610
|
}
|
|
1476
1611
|
this.maintain();
|
|
1477
1612
|
return this;
|
|
1613
|
+
}
|
|
1614
|
+
function _set_attrs_(name, value){
|
|
1615
|
+
if(this.element?.tagName !== "svg") name = is_camelcase$1(name) ? camel2hyphencase$1(name) : name;
|
|
1616
|
+
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1617
|
+
if(isStateGetter(value)){
|
|
1618
|
+
const getter = value();
|
|
1619
|
+
getter._subscribe(
|
|
1620
|
+
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1621
|
+
this
|
|
1622
|
+
);
|
|
1623
|
+
}
|
|
1624
|
+
else this.element?.setAttribute(name, value);
|
|
1625
|
+
Object.assign(this.cache.attributes, {[name]:value});
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
// import {
|
|
1629
|
+
// is_camelcase,
|
|
1630
|
+
// camel2hyphencase
|
|
1631
|
+
// } from '../../data/string/index.js'
|
|
1632
|
+
|
|
1633
|
+
function setAttr(name, value) {
|
|
1634
|
+
if(name instanceof Object){
|
|
1635
|
+
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1636
|
+
for(let i=0;i<names.length;i++){
|
|
1637
|
+
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1638
|
+
_set_attrs_.call(this, names[i], values[i]);
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
else {
|
|
1642
|
+
if(value instanceof Array) value = value.join(" ");
|
|
1643
|
+
_set_attrs_.call(this, name, value);
|
|
1644
|
+
}
|
|
1645
|
+
return this;
|
|
1646
|
+
}
|
|
1647
|
+
function removeAttr(...names) {
|
|
1648
|
+
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1649
|
+
return this;
|
|
1650
|
+
}
|
|
1651
|
+
function getAttr(name){
|
|
1652
|
+
name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
1653
|
+
return this.element.attributes[name].value;
|
|
1654
|
+
}
|
|
1655
|
+
function setContentEditable(bool = true) {
|
|
1656
|
+
this.setAttr("contenteditable", bool);
|
|
1657
|
+
return this;
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
var AttrsMethods = /*#__PURE__*/Object.freeze({
|
|
1661
|
+
__proto__: null,
|
|
1662
|
+
getAttr: getAttr,
|
|
1663
|
+
removeAttr: removeAttr,
|
|
1664
|
+
setAttr: setAttr,
|
|
1665
|
+
setContentEditable: setContentEditable
|
|
1666
|
+
});
|
|
1667
|
+
|
|
1668
|
+
function append(...ele) {
|
|
1669
|
+
__addItem__.call(this, "append", "push", ...ele);
|
|
1670
|
+
return this;
|
|
1671
|
+
}
|
|
1672
|
+
function prepend(...ele) {
|
|
1673
|
+
this.__addItem__.call(this, "prepend", "unshift", ...ele);
|
|
1674
|
+
return this;
|
|
1675
|
+
}
|
|
1676
|
+
function insertAt(index, ...ele) {
|
|
1677
|
+
if (index >= this.element.children.length) this.append(...ele);
|
|
1678
|
+
else
|
|
1679
|
+
for (let i = 0; i < ele.length; i++) {
|
|
1680
|
+
if (["number", "string"].includes(typeof ele[i])) ele[i] = text(ele[i]);
|
|
1681
|
+
this.element?.insertBefore(ele[i].element, this.items[index].element);
|
|
1682
|
+
this.items.splice(index, 0, ele[i]);
|
|
1683
|
+
}
|
|
1684
|
+
return this;
|
|
1685
|
+
}
|
|
1686
|
+
function remove(...ele) {
|
|
1687
|
+
const remove = (ele) => {
|
|
1688
|
+
if (typeof ele === "number") ele = this.items[ele];
|
|
1689
|
+
if (ele?.isUIElement) this.element?.removeChild(ele.element);
|
|
1690
|
+
this.items = this.items.filter((n) => n !== ele);
|
|
1691
|
+
};
|
|
1692
|
+
for (let i = 0; i < ele.length; i++) remove(ele[i]);
|
|
1693
|
+
for (let i = 0; i < this.items.length; i++)
|
|
1694
|
+
Object.assign(this, { [[i]]: this.items[i] });
|
|
1695
|
+
// Remove from item
|
|
1696
|
+
return this;
|
|
1697
|
+
}
|
|
1698
|
+
function clear(){
|
|
1699
|
+
this?.items?.forEach(n=>n.unrender());
|
|
1700
|
+
this.element.innerHTML = "";
|
|
1701
|
+
return this;
|
|
1702
|
+
}
|
|
1703
|
+
function render(target = this.target) {
|
|
1704
|
+
if(this.isBody)return ;
|
|
1705
|
+
if(target?.isUIElement)target=target.element;
|
|
1706
|
+
this.target=target;
|
|
1707
|
+
this.target?.appendChild(this.element);
|
|
1708
|
+
return this;
|
|
1709
|
+
}
|
|
1710
|
+
function unrender(){
|
|
1711
|
+
if(this.cache.parent)this.cache.parent.remove(this);
|
|
1712
|
+
else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
|
|
1713
|
+
return this;
|
|
1714
|
+
}
|
|
1715
|
+
function renderAfter(t = 1) {
|
|
1716
|
+
setTimeout(() => this.render(), t);
|
|
1717
|
+
return this;
|
|
1718
|
+
}
|
|
1719
|
+
function unrenderAfter(t = 1) {
|
|
1720
|
+
setTimeout(() => this.unrender(), t);
|
|
1721
|
+
return this;
|
|
1722
|
+
}
|
|
1723
|
+
function after(ui){
|
|
1724
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1725
|
+
this.element?.after(ui);
|
|
1726
|
+
return this;
|
|
1727
|
+
}
|
|
1728
|
+
function before(ui){
|
|
1729
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1730
|
+
this.element?.before(ui);
|
|
1731
|
+
return this;
|
|
1478
1732
|
}
|
|
1479
1733
|
|
|
1734
|
+
var DomMethods = /*#__PURE__*/Object.freeze({
|
|
1735
|
+
__proto__: null,
|
|
1736
|
+
after: after,
|
|
1737
|
+
append: append,
|
|
1738
|
+
before: before,
|
|
1739
|
+
clear: clear,
|
|
1740
|
+
insertAt: insertAt,
|
|
1741
|
+
prepend: prepend,
|
|
1742
|
+
remove: remove,
|
|
1743
|
+
render: render,
|
|
1744
|
+
renderAfter: renderAfter,
|
|
1745
|
+
unrender: unrender,
|
|
1746
|
+
unrenderAfter: unrenderAfter
|
|
1747
|
+
});
|
|
1748
|
+
|
|
1480
1749
|
const Events = {
|
|
1481
1750
|
'Click' : [
|
|
1482
1751
|
'Click',
|
|
1483
|
-
'DblClick'
|
|
1752
|
+
'DblClick',
|
|
1753
|
+
'ClickAway'
|
|
1484
1754
|
],
|
|
1485
1755
|
'Ptr' : [
|
|
1486
1756
|
'PtrMove',
|
|
@@ -1696,9 +1966,11 @@ class __ZikoEvent__ {
|
|
|
1696
1966
|
}
|
|
1697
1967
|
}
|
|
1698
1968
|
|
|
1969
|
+
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
1699
1970
|
class ZikoEventClick extends __ZikoEvent__{
|
|
1700
1971
|
constructor(target, customizer){
|
|
1701
1972
|
super(target, Events.Click, details_setter$a, customizer);
|
|
1973
|
+
// register_click_away_event(target.element)
|
|
1702
1974
|
}
|
|
1703
1975
|
}
|
|
1704
1976
|
function details_setter$a(){
|
|
@@ -1706,7 +1978,7 @@ function details_setter$a(){
|
|
|
1706
1978
|
else this.dx = 1;
|
|
1707
1979
|
// console.log(this.currentEvent)
|
|
1708
1980
|
}
|
|
1709
|
-
const
|
|
1981
|
+
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
1710
1982
|
|
|
1711
1983
|
class ZikoEventClipboard extends __ZikoEvent__{
|
|
1712
1984
|
constructor(target, customizer){
|
|
@@ -1716,7 +1988,7 @@ class ZikoEventClipboard extends __ZikoEvent__{
|
|
|
1716
1988
|
function details_setter$9(){
|
|
1717
1989
|
|
|
1718
1990
|
}
|
|
1719
|
-
const
|
|
1991
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
1720
1992
|
|
|
1721
1993
|
class ZikoEventCustom extends __ZikoEvent__{
|
|
1722
1994
|
constructor(target, events, customizer){
|
|
@@ -1750,7 +2022,7 @@ class ZikoEventDrag extends __ZikoEvent__{
|
|
|
1750
2022
|
function details_setter$7(){
|
|
1751
2023
|
|
|
1752
2024
|
}
|
|
1753
|
-
const
|
|
2025
|
+
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
1754
2026
|
|
|
1755
2027
|
class ZikoEventFocus extends __ZikoEvent__{
|
|
1756
2028
|
constructor(target, customizer){
|
|
@@ -1760,7 +2032,7 @@ class ZikoEventFocus extends __ZikoEvent__{
|
|
|
1760
2032
|
function details_setter$6(){
|
|
1761
2033
|
|
|
1762
2034
|
}
|
|
1763
|
-
const
|
|
2035
|
+
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
1764
2036
|
|
|
1765
2037
|
let ZikoEventHash$1 = class ZikoEventHash extends __ZikoEvent__{
|
|
1766
2038
|
constructor(target, customizer){
|
|
@@ -1791,7 +2063,7 @@ function details_setter$4(){
|
|
|
1791
2063
|
|
|
1792
2064
|
}
|
|
1793
2065
|
}
|
|
1794
|
-
const
|
|
2066
|
+
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
1795
2067
|
|
|
1796
2068
|
class ZikoEventMouse extends __ZikoEvent__{
|
|
1797
2069
|
constructor(target, customizer){
|
|
@@ -1801,7 +2073,7 @@ class ZikoEventMouse extends __ZikoEvent__{
|
|
|
1801
2073
|
function details_setter$3(){
|
|
1802
2074
|
|
|
1803
2075
|
}
|
|
1804
|
-
const
|
|
2076
|
+
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
1805
2077
|
|
|
1806
2078
|
class ZikoEventPointer extends __ZikoEvent__{
|
|
1807
2079
|
constructor(target, customizer){
|
|
@@ -1842,7 +2114,7 @@ function details_setter$2(){
|
|
|
1842
2114
|
// else this.dx = 1
|
|
1843
2115
|
// console.log(this.currentEvent)
|
|
1844
2116
|
}
|
|
1845
|
-
const
|
|
2117
|
+
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
1846
2118
|
|
|
1847
2119
|
class ZikoEventTouch extends __ZikoEvent__{
|
|
1848
2120
|
constructor(target, customizer){
|
|
@@ -1862,17 +2134,17 @@ class ZikoEventWheel extends __ZikoEvent__{
|
|
|
1862
2134
|
function details_setter(){
|
|
1863
2135
|
|
|
1864
2136
|
}
|
|
1865
|
-
const
|
|
2137
|
+
const bind_wheel_event = (target, customizer) => new ZikoEventWheel(target, customizer);
|
|
1866
2138
|
|
|
1867
2139
|
const binderMap = {
|
|
1868
|
-
ptr:
|
|
1869
|
-
mouse :
|
|
1870
|
-
key:
|
|
1871
|
-
click :
|
|
1872
|
-
drag :
|
|
1873
|
-
clipboard :
|
|
1874
|
-
focus :
|
|
1875
|
-
wheel :
|
|
2140
|
+
ptr: bind_pointer_event,
|
|
2141
|
+
mouse : bind_mouse_event,
|
|
2142
|
+
key: bind_key_event,
|
|
2143
|
+
click : bind_click_event,
|
|
2144
|
+
drag : bind_drag_event,
|
|
2145
|
+
clipboard : bind_clipboard_event,
|
|
2146
|
+
focus : bind_focus_event,
|
|
2147
|
+
wheel : bind_wheel_event
|
|
1876
2148
|
};
|
|
1877
2149
|
|
|
1878
2150
|
const EventsMethodes = {};
|
|
@@ -1888,55 +2160,68 @@ Object.entries(Events).forEach(([name, eventList]) => {
|
|
|
1888
2160
|
});
|
|
1889
2161
|
});
|
|
1890
2162
|
|
|
1891
|
-
|
|
1892
|
-
at(index)
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
forEach(callback)
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
map(callback)
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
},
|
|
1905
|
-
};
|
|
2163
|
+
function at(index) {
|
|
2164
|
+
return this.items.at(index);
|
|
2165
|
+
}
|
|
2166
|
+
function forEach(callback) {
|
|
2167
|
+
this.items.forEach(callback);
|
|
2168
|
+
return this;
|
|
2169
|
+
}
|
|
2170
|
+
function map(callback) {
|
|
2171
|
+
return this.items.map(callback);
|
|
2172
|
+
}
|
|
2173
|
+
function find(condition) {
|
|
2174
|
+
return this.items.filter(condition);
|
|
2175
|
+
}
|
|
1906
2176
|
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
2177
|
+
var IndexingMethods = /*#__PURE__*/Object.freeze({
|
|
2178
|
+
__proto__: null,
|
|
2179
|
+
at: at,
|
|
2180
|
+
find: find,
|
|
2181
|
+
forEach: forEach,
|
|
2182
|
+
map: map
|
|
2183
|
+
});
|
|
2184
|
+
|
|
2185
|
+
function style(styles){
|
|
2186
|
+
for(let key in styles){
|
|
2187
|
+
const value = styles[key];
|
|
2188
|
+
if(isStateGetter(value)){
|
|
2189
|
+
const getter = value();
|
|
2190
|
+
Object.assign(this.element.style, {[key] : getter.value});
|
|
2191
|
+
getter._subscribe(
|
|
2192
|
+
(newValue) => {
|
|
2193
|
+
console.log({newValue});
|
|
2194
|
+
Object.assign(this.element.style, {[key] : newValue});
|
|
2195
|
+
},
|
|
2196
|
+
// this
|
|
2197
|
+
);
|
|
1923
2198
|
}
|
|
1924
|
-
|
|
1925
|
-
}
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
2199
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2200
|
+
}
|
|
2201
|
+
return this;
|
|
2202
|
+
}
|
|
2203
|
+
function size(width, height){
|
|
2204
|
+
return this.style({width, height})
|
|
2205
|
+
}
|
|
2206
|
+
function hide(){
|
|
1930
2207
|
|
|
1931
|
-
|
|
1932
|
-
|
|
2208
|
+
}
|
|
2209
|
+
function show(){
|
|
1933
2210
|
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
2211
|
+
}
|
|
2212
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2213
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2214
|
+
return this;
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2218
|
+
__proto__: null,
|
|
2219
|
+
animate: animate,
|
|
2220
|
+
hide: hide,
|
|
2221
|
+
show: show,
|
|
2222
|
+
size: size,
|
|
2223
|
+
style: style
|
|
2224
|
+
});
|
|
1940
2225
|
|
|
1941
2226
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
1942
2227
|
this.event=e;
|
|
@@ -2598,22 +2883,22 @@ class ZikoScreenObserver {
|
|
|
2598
2883
|
});
|
|
2599
2884
|
}
|
|
2600
2885
|
get x0(){
|
|
2601
|
-
return map(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2886
|
+
return map$1(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2602
2887
|
}
|
|
2603
2888
|
get y0(){
|
|
2604
|
-
return - map(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2889
|
+
return - map$1(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2605
2890
|
}
|
|
2606
2891
|
get x1(){
|
|
2607
|
-
return map(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2892
|
+
return map$1(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2608
2893
|
}
|
|
2609
2894
|
get y1(){
|
|
2610
|
-
return - map(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2895
|
+
return - map$1(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2611
2896
|
}
|
|
2612
2897
|
get cx(){
|
|
2613
|
-
return map(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2898
|
+
return map$1(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2614
2899
|
}
|
|
2615
2900
|
get cy(){
|
|
2616
|
-
return - map(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2901
|
+
return - map$1(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2617
2902
|
}
|
|
2618
2903
|
}
|
|
2619
2904
|
|
|
@@ -2875,21 +3160,10 @@ class ZikoUseMediaQuery {
|
|
|
2875
3160
|
|
|
2876
3161
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
2877
3162
|
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
2883
|
-
if(typeof element === "string") {
|
|
2884
|
-
switch(type){
|
|
2885
|
-
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
2886
|
-
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
2887
|
-
default : throw Error("Not supported")
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
else {
|
|
2891
|
-
this.target = element?.parentElement;
|
|
2892
|
-
}
|
|
3163
|
+
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3164
|
+
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render}={}){
|
|
3165
|
+
super({element, name, type, render});
|
|
3166
|
+
console.log(this);
|
|
2893
3167
|
register(
|
|
2894
3168
|
this,
|
|
2895
3169
|
AttrsMethods,
|
|
@@ -2898,61 +3172,7 @@ class UIElement extends UINode{
|
|
|
2898
3172
|
IndexingMethods,
|
|
2899
3173
|
EventsMethodes
|
|
2900
3174
|
);
|
|
2901
|
-
|
|
2902
|
-
name,
|
|
2903
|
-
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
2904
|
-
parent:null,
|
|
2905
|
-
isBody:false,
|
|
2906
|
-
isRoot:false,
|
|
2907
|
-
isHidden: false,
|
|
2908
|
-
isFrozzen:false,
|
|
2909
|
-
legacyParent : null,
|
|
2910
|
-
attributes: {},
|
|
2911
|
-
filters: {},
|
|
2912
|
-
temp:{}
|
|
2913
|
-
});
|
|
2914
|
-
this.events = {
|
|
2915
|
-
ptr:null,
|
|
2916
|
-
mouse:null,
|
|
2917
|
-
wheel:null,
|
|
2918
|
-
key:null,
|
|
2919
|
-
drag:null,
|
|
2920
|
-
drop:null,
|
|
2921
|
-
click:null,
|
|
2922
|
-
clipboard:null,
|
|
2923
|
-
focus:null,
|
|
2924
|
-
swipe:null,
|
|
2925
|
-
custom:null,
|
|
2926
|
-
};
|
|
2927
|
-
this.observer={
|
|
2928
|
-
resize:null,
|
|
2929
|
-
intersection:null
|
|
2930
|
-
};
|
|
2931
|
-
if(element) Object.assign(this.cache,{element});
|
|
2932
|
-
// this.uuid = `${this.cache.name}-${Random.string(16)}`
|
|
2933
|
-
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
2934
|
-
useDefaultStyle && this.style({
|
|
2935
|
-
position: "relative",
|
|
2936
|
-
boxSizing:"border-box",
|
|
2937
|
-
margin:0,
|
|
2938
|
-
padding:0,
|
|
2939
|
-
width : "auto",
|
|
2940
|
-
height : "auto"
|
|
2941
|
-
});
|
|
2942
|
-
this.items = new UIStore();
|
|
2943
|
-
globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
|
|
2944
|
-
element && render && this?.render?.();
|
|
2945
|
-
if(
|
|
2946
|
-
// globalThis.__Ziko__.__Config__.renderingMode !== "spa"
|
|
2947
|
-
// &&
|
|
2948
|
-
// !globalThis.__Ziko__.__Config__.isSSC
|
|
2949
|
-
// &&
|
|
2950
|
-
this.isInteractive()
|
|
2951
|
-
){
|
|
2952
|
-
this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
2953
|
-
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
2954
|
-
}
|
|
2955
|
-
globalThis.__Ziko__.__UI__.push(this);
|
|
3175
|
+
this.init(element, name, type, render);
|
|
2956
3176
|
}
|
|
2957
3177
|
get element(){
|
|
2958
3178
|
return this.cache.element;
|
|
@@ -2960,9 +3180,9 @@ class UIElement extends UINode{
|
|
|
2960
3180
|
isInteractive(){
|
|
2961
3181
|
return this.cache.isInteractive;
|
|
2962
3182
|
}
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
}
|
|
3183
|
+
// isUIElement(){
|
|
3184
|
+
// return true;
|
|
3185
|
+
// }
|
|
2966
3186
|
get st(){
|
|
2967
3187
|
return this.cache.style;
|
|
2968
3188
|
}
|
|
@@ -3002,73 +3222,73 @@ class UIElement extends UINode{
|
|
|
3002
3222
|
get left(){
|
|
3003
3223
|
return this.element.getBoundingClientRect().left;
|
|
3004
3224
|
}
|
|
3005
|
-
clone(render=false) {
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
}
|
|
3014
|
-
[Symbol.iterator]() {
|
|
3015
|
-
|
|
3016
|
-
}
|
|
3017
|
-
maintain() {
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
}
|
|
3027
|
-
freeze(freeze){
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
}
|
|
3225
|
+
// clone(render=false) {
|
|
3226
|
+
// // UI.__proto__=this.__proto__;
|
|
3227
|
+
// // if(this.items.length){
|
|
3228
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
3229
|
+
// // UI.append(...items);
|
|
3230
|
+
// // }
|
|
3231
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
3232
|
+
// // return UI.render(render);
|
|
3233
|
+
// }
|
|
3234
|
+
// [Symbol.iterator]() {
|
|
3235
|
+
// return this.items[Symbol.iterator]();
|
|
3236
|
+
// }
|
|
3237
|
+
// maintain() {
|
|
3238
|
+
// for (let i = 0; i < this.items.length; i++) {
|
|
3239
|
+
// Object.defineProperty(this, i, {
|
|
3240
|
+
// value: this.items[i],
|
|
3241
|
+
// writable: true,
|
|
3242
|
+
// configurable: true,
|
|
3243
|
+
// enumerable: false
|
|
3244
|
+
// });
|
|
3245
|
+
// }
|
|
3246
|
+
// }
|
|
3247
|
+
// freeze(freeze){
|
|
3248
|
+
// this.cache.isFrozzen=freeze;
|
|
3249
|
+
// return this;
|
|
3250
|
+
// }
|
|
3031
3251
|
// setTarget(tg) {
|
|
3032
3252
|
// if(this.isBody) return ;
|
|
3033
|
-
// if (tg?.
|
|
3253
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
3034
3254
|
// this.unrender();
|
|
3035
3255
|
// this.target = tg;
|
|
3036
3256
|
// this.render();
|
|
3037
3257
|
// return this;
|
|
3038
3258
|
// }
|
|
3039
|
-
describe(label){
|
|
3040
|
-
|
|
3041
|
-
}
|
|
3042
|
-
get children() {
|
|
3043
|
-
|
|
3044
|
-
}
|
|
3045
|
-
get cloneElement() {
|
|
3046
|
-
|
|
3047
|
-
}
|
|
3048
|
-
setClasses(...value) {
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
}
|
|
3052
|
-
get classes(){
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
}
|
|
3056
|
-
addClass() {
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
}
|
|
3060
|
-
setId(id) {
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
}
|
|
3064
|
-
get id() {
|
|
3065
|
-
|
|
3066
|
-
}
|
|
3067
|
-
onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
}
|
|
3259
|
+
// describe(label){
|
|
3260
|
+
// if(label)this.setAttr("aria-label",label)
|
|
3261
|
+
// }
|
|
3262
|
+
// get children() {
|
|
3263
|
+
// return [...this.element.children];
|
|
3264
|
+
// }
|
|
3265
|
+
// get cloneElement() {
|
|
3266
|
+
// return this.element.cloneNode(true);
|
|
3267
|
+
// }
|
|
3268
|
+
// setClasses(...value) {
|
|
3269
|
+
// this.setAttr("class", value.join(" "));
|
|
3270
|
+
// return this;
|
|
3271
|
+
// }
|
|
3272
|
+
// get classes(){
|
|
3273
|
+
// const classes=this.element.getAttribute("class");
|
|
3274
|
+
// return classes===null?[]:classes.split(" ");
|
|
3275
|
+
// }
|
|
3276
|
+
// addClass() {
|
|
3277
|
+
// /*this.setAttr("class", value);
|
|
3278
|
+
// return this;*/
|
|
3279
|
+
// }
|
|
3280
|
+
// setId(id) {
|
|
3281
|
+
// this.setAttr("id", id);
|
|
3282
|
+
// return this;
|
|
3283
|
+
// }
|
|
3284
|
+
// get id() {
|
|
3285
|
+
// return this.element.getAttribute("id");
|
|
3286
|
+
// }
|
|
3287
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3288
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
3289
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
3290
|
+
// return this;
|
|
3291
|
+
// }
|
|
3072
3292
|
// To Fix
|
|
3073
3293
|
// onKeysDown({keys=[],callback}={}){
|
|
3074
3294
|
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
@@ -3090,26 +3310,26 @@ class UIElement extends UINode{
|
|
|
3090
3310
|
this.events.custom.emit(event_name,detail);
|
|
3091
3311
|
return this;
|
|
3092
3312
|
}
|
|
3093
|
-
watchAttr(callback){
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
}
|
|
3097
|
-
watchChildren(callback){
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
}
|
|
3101
|
-
watchSize(callback){
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
}
|
|
3106
|
-
watchIntersection(callback,config){
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
}
|
|
3313
|
+
// watchAttr(callback){
|
|
3314
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
3315
|
+
// return this;
|
|
3316
|
+
// }
|
|
3317
|
+
// watchChildren(callback){
|
|
3318
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
3319
|
+
// return this;
|
|
3320
|
+
// }
|
|
3321
|
+
// watchSize(callback){
|
|
3322
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
3323
|
+
// this.observer.resize.start();
|
|
3324
|
+
// return this;
|
|
3325
|
+
// }
|
|
3326
|
+
// watchIntersection(callback,config){
|
|
3327
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
3328
|
+
// this.observer.intersection.start();
|
|
3329
|
+
// return this;
|
|
3330
|
+
// }
|
|
3111
3331
|
|
|
3112
|
-
}
|
|
3332
|
+
};
|
|
3113
3333
|
|
|
3114
3334
|
const HTMLTags = [
|
|
3115
3335
|
'a',
|
|
@@ -3245,11 +3465,11 @@ const tags = new Proxy({}, {
|
|
|
3245
3465
|
// console.log(isStateGetter(args[0]))
|
|
3246
3466
|
if(
|
|
3247
3467
|
['string', 'number'].includes(typeof args[0])
|
|
3248
|
-
|| args[0] instanceof UIElement
|
|
3468
|
+
|| args[0] instanceof UIElement$1
|
|
3249
3469
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3250
|
-
) return new UIElement({element : tag, name : tag, type}).append(...args);
|
|
3470
|
+
) return new UIElement$1({element : tag, name : tag, type}).append(...args);
|
|
3251
3471
|
// console.log(args[0])
|
|
3252
|
-
return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
|
|
3472
|
+
return new UIElement$1({element : tag}).setAttr(args.shift()).append(...args)
|
|
3253
3473
|
}
|
|
3254
3474
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3255
3475
|
// return (...args)=>{
|
|
@@ -3272,7 +3492,7 @@ const tags = new Proxy({}, {
|
|
|
3272
3492
|
}
|
|
3273
3493
|
});
|
|
3274
3494
|
|
|
3275
|
-
class ZikoUIFlex extends UIElement {
|
|
3495
|
+
class ZikoUIFlex extends UIElement$1 {
|
|
3276
3496
|
constructor(tag = "div", w = "100%", h = "100%") {
|
|
3277
3497
|
super({element : tag , name : "Flex"});
|
|
3278
3498
|
this.direction = "cols";
|
|
@@ -3371,37 +3591,11 @@ function map_pos_y(align){
|
|
|
3371
3591
|
return map_pos_x(-align);
|
|
3372
3592
|
}
|
|
3373
3593
|
|
|
3374
|
-
class
|
|
3375
|
-
constructor(
|
|
3376
|
-
|
|
3377
|
-
this.direction = "cols";
|
|
3378
|
-
if (typeof w == "number") w += "%";
|
|
3379
|
-
if (typeof h == "number") h += "%";
|
|
3380
|
-
this.style({ border: "1px solid black", width: w, height: h });
|
|
3381
|
-
this.style({ display: "grid" });
|
|
3382
|
-
// this.render();
|
|
3383
|
-
}
|
|
3384
|
-
get isGird(){
|
|
3385
|
-
return true;
|
|
3386
|
-
}
|
|
3387
|
-
columns(n) {
|
|
3388
|
-
let temp = "";
|
|
3389
|
-
for (let i = 0; i < n; i++) temp = temp.concat(" auto");
|
|
3390
|
-
this.#templateColumns(temp);
|
|
3391
|
-
return this;
|
|
3392
|
-
}
|
|
3393
|
-
#templateColumns(temp = "auto auto") {
|
|
3394
|
-
this.style({ gridTemplateColumns: temp });
|
|
3395
|
-
return this;
|
|
3396
|
-
}
|
|
3397
|
-
gap(w = 10, h = w) {
|
|
3398
|
-
if(typeof (w) === "number")w += "px";
|
|
3399
|
-
if(typeof (h) === "number")h += "px";
|
|
3400
|
-
this.style({gridColumnGap: w,gridRowGap: h});
|
|
3401
|
-
return this;
|
|
3594
|
+
class UIElement extends UIElementCore{
|
|
3595
|
+
constructor({element, name, type, render}){
|
|
3596
|
+
super({element, name, type, render});
|
|
3402
3597
|
}
|
|
3403
|
-
}
|
|
3404
|
-
const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
|
|
3598
|
+
}
|
|
3405
3599
|
|
|
3406
3600
|
class ZikoUISuspense extends UIElement{
|
|
3407
3601
|
constructor(fallback_ui, callback){
|
|
@@ -3427,275 +3621,6 @@ class ZikoUISuspense extends UIElement{
|
|
|
3427
3621
|
|
|
3428
3622
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3429
3623
|
|
|
3430
|
-
class ZikoUIXMLWrapper extends UIElement{
|
|
3431
|
-
constructor(XMLContent, type){
|
|
3432
|
-
super({element : "div", name : ""});
|
|
3433
|
-
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
|
|
3434
|
-
}
|
|
3435
|
-
}
|
|
3436
|
-
function html2dom(htmlString) {
|
|
3437
|
-
if(globalThis?.DOMParser){
|
|
3438
|
-
const parser = new DOMParser();
|
|
3439
|
-
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
3440
|
-
doc.body.firstChild.style.display = "contents";
|
|
3441
|
-
return doc.body.firstChild;
|
|
3442
|
-
}
|
|
3443
|
-
}
|
|
3444
|
-
function svg2dom(svgString) {
|
|
3445
|
-
if(globalThis?.DOMParser){
|
|
3446
|
-
const parser = new DOMParser();
|
|
3447
|
-
const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
|
|
3448
|
-
return doc.documentElement; // SVG elements are usually at the root
|
|
3449
|
-
}
|
|
3450
|
-
}
|
|
3451
|
-
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
3452
|
-
constructor(HTMLContent){
|
|
3453
|
-
super(HTMLContent, "html");
|
|
3454
|
-
}
|
|
3455
|
-
}
|
|
3456
|
-
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
3457
|
-
constructor(SVGContent){
|
|
3458
|
-
super(SVGContent, "svg");
|
|
3459
|
-
}
|
|
3460
|
-
}
|
|
3461
|
-
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
3462
|
-
const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
|
|
3463
|
-
|
|
3464
|
-
class ZikoUICanvas extends UIElement{
|
|
3465
|
-
constructor(w,h){
|
|
3466
|
-
super("canvas","canvas");
|
|
3467
|
-
this.ctx = this.element?.getContext("2d");
|
|
3468
|
-
this.style({
|
|
3469
|
-
border:"1px red solid",
|
|
3470
|
-
});
|
|
3471
|
-
this.transformMatrix = new Matrix([
|
|
3472
|
-
[1,0,0],
|
|
3473
|
-
[0,1,0],
|
|
3474
|
-
[0,0,1]
|
|
3475
|
-
]);
|
|
3476
|
-
this.axisMatrix = new Matrix([
|
|
3477
|
-
[-10,-10],
|
|
3478
|
-
[10,10]
|
|
3479
|
-
]);
|
|
3480
|
-
// setTimeout(()=>this.resize(w,h),0);
|
|
3481
|
-
requestAnimationFrame(()=>this.resize(w,h),0);
|
|
3482
|
-
this.on("sizeupdated",()=>this.adjust());
|
|
3483
|
-
}
|
|
3484
|
-
get Xmin(){
|
|
3485
|
-
return this.axisMatrix[0][0];
|
|
3486
|
-
}
|
|
3487
|
-
get Ymin(){
|
|
3488
|
-
return this.axisMatrix[0][1];
|
|
3489
|
-
}
|
|
3490
|
-
get Xmax(){
|
|
3491
|
-
return this.axisMatrix[1][0];
|
|
3492
|
-
}
|
|
3493
|
-
get Ymax(){
|
|
3494
|
-
return this.axisMatrix[1][1];
|
|
3495
|
-
}
|
|
3496
|
-
get ImageData(){
|
|
3497
|
-
return this.ctx.getImageData(0,0,c.Width,c.Height);
|
|
3498
|
-
}
|
|
3499
|
-
draw(all=true){
|
|
3500
|
-
if(all){
|
|
3501
|
-
this.clear();
|
|
3502
|
-
this.items.forEach(element => {
|
|
3503
|
-
element.parent=this;
|
|
3504
|
-
element.draw(this.ctx);
|
|
3505
|
-
});
|
|
3506
|
-
}
|
|
3507
|
-
else {
|
|
3508
|
-
this.items.at(-1).parent=this;
|
|
3509
|
-
this.items.at(-1).draw(this.ctx);
|
|
3510
|
-
}
|
|
3511
|
-
this.maintain();
|
|
3512
|
-
return this;
|
|
3513
|
-
}
|
|
3514
|
-
applyTransformMatrix(){
|
|
3515
|
-
this.ctx.setTransform(
|
|
3516
|
-
this.transformMatrix[0][0],
|
|
3517
|
-
this.transformMatrix[1][0],
|
|
3518
|
-
this.transformMatrix[0][1],
|
|
3519
|
-
this.transformMatrix[1][1],
|
|
3520
|
-
this.transformMatrix[0][2],
|
|
3521
|
-
this.transformMatrix[1][2],
|
|
3522
|
-
);
|
|
3523
|
-
return this;
|
|
3524
|
-
}
|
|
3525
|
-
resize(w,h){
|
|
3526
|
-
this.size(w,h);
|
|
3527
|
-
this.lineWidth();
|
|
3528
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
3529
|
-
this.emit("sizeupdated");
|
|
3530
|
-
return this;
|
|
3531
|
-
}
|
|
3532
|
-
adjust(){
|
|
3533
|
-
this.element.width =this.element?.getBoundingClientRect().width;
|
|
3534
|
-
this.element.height =this.element?.getBoundingClientRect().height;
|
|
3535
|
-
this.view(this.axisMatrix[0][0], this.axisMatrix[0][1], this.axisMatrix[1][0], this.axisMatrix[1][1]);
|
|
3536
|
-
return this;
|
|
3537
|
-
}
|
|
3538
|
-
view(xMin,yMin,xMax,yMax){
|
|
3539
|
-
this.transformMatrix[0][0]=this.width/(xMax-xMin); // scaleX
|
|
3540
|
-
this.transformMatrix[1][1]=-this.height/(yMax-yMin); // scaleY
|
|
3541
|
-
this.transformMatrix[0][2]=this.width/2;
|
|
3542
|
-
this.transformMatrix[1][2]=this.height/2;
|
|
3543
|
-
this.axisMatrix=new Matrix([
|
|
3544
|
-
[xMin,yMin],
|
|
3545
|
-
[xMax,yMax]
|
|
3546
|
-
]);
|
|
3547
|
-
|
|
3548
|
-
this.applyTransformMatrix();
|
|
3549
|
-
this.clear();
|
|
3550
|
-
this.lineWidth(1);
|
|
3551
|
-
this.draw();
|
|
3552
|
-
return this;
|
|
3553
|
-
}
|
|
3554
|
-
reset(){
|
|
3555
|
-
this.ctx.setTransform(1,0,0,0,0,0);
|
|
3556
|
-
return this;
|
|
3557
|
-
}
|
|
3558
|
-
append(element){
|
|
3559
|
-
this.items.push(element);
|
|
3560
|
-
this.draw(false);
|
|
3561
|
-
return this;
|
|
3562
|
-
}
|
|
3563
|
-
background(color){
|
|
3564
|
-
this.ctx.fillStyle = color;
|
|
3565
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3566
|
-
this.ctx.fillRect(0, 0, this.width, this.height);
|
|
3567
|
-
this.applyTransformMatrix();
|
|
3568
|
-
this.draw();
|
|
3569
|
-
}
|
|
3570
|
-
lineWidth(w){
|
|
3571
|
-
this.ctx.lineWidth=w/this.transformMatrix[0][0];
|
|
3572
|
-
return this
|
|
3573
|
-
}
|
|
3574
|
-
getImageData(x=0,y=0,w=this.width,h=this.height){
|
|
3575
|
-
return this.ctx.getImageData(x,y,w,h);
|
|
3576
|
-
}
|
|
3577
|
-
clear(){
|
|
3578
|
-
this.ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
3579
|
-
this.ctx.clearRect(0, 0, this.width, this.height);
|
|
3580
|
-
this.applyTransformMatrix();
|
|
3581
|
-
return this;
|
|
3582
|
-
}
|
|
3583
|
-
clone(){
|
|
3584
|
-
console.log(this.width);
|
|
3585
|
-
const canvas=new ZikoUICanvas();
|
|
3586
|
-
canvas.items=this.items;
|
|
3587
|
-
canvas.transformMatrix=this.transformMatrix;
|
|
3588
|
-
canvas.axisMatrix=this.axisMatrix;
|
|
3589
|
-
Object.assign(canvas.cache,{...this.cache});
|
|
3590
|
-
//waitForUIElm(this)
|
|
3591
|
-
//console.log(element)
|
|
3592
|
-
this.size(this.element.style.width,this.element.style.width);
|
|
3593
|
-
this.applyTransformMatrix();
|
|
3594
|
-
this.draw();
|
|
3595
|
-
this.adjust();
|
|
3596
|
-
return canvas;
|
|
3597
|
-
}
|
|
3598
|
-
toImage() {
|
|
3599
|
-
this.img = document?.createElement("img");
|
|
3600
|
-
this.img.src = this.element?.toDataURL("image/png");
|
|
3601
|
-
return this;
|
|
3602
|
-
}
|
|
3603
|
-
toBlob() {
|
|
3604
|
-
var canvas = this.element;
|
|
3605
|
-
canvas.toBlob(function (blob) {
|
|
3606
|
-
var newImg = document?.createElement("img"),
|
|
3607
|
-
url = URL.createObjectURL(blob);
|
|
3608
|
-
newImg.onload = function () {
|
|
3609
|
-
URL.revokeObjectURL(url);
|
|
3610
|
-
};
|
|
3611
|
-
newImg.src = url;
|
|
3612
|
-
console.log(newImg);
|
|
3613
|
-
});
|
|
3614
|
-
}
|
|
3615
|
-
zoomIn(){
|
|
3616
|
-
|
|
3617
|
-
}
|
|
3618
|
-
zoomOut(){
|
|
3619
|
-
|
|
3620
|
-
}
|
|
3621
|
-
undo(n){
|
|
3622
|
-
|
|
3623
|
-
}
|
|
3624
|
-
redo(n){
|
|
3625
|
-
|
|
3626
|
-
}
|
|
3627
|
-
stream(){
|
|
3628
|
-
|
|
3629
|
-
}
|
|
3630
|
-
}
|
|
3631
|
-
|
|
3632
|
-
const Canvas=(w,h)=>new ZikoUICanvas(w,h);
|
|
3633
|
-
|
|
3634
|
-
class ZikoUISvg extends UIElement {
|
|
3635
|
-
constructor(w=360,h=300) {
|
|
3636
|
-
super("svg","svg");
|
|
3637
|
-
//this.cache={};
|
|
3638
|
-
// this.setAttr("width",w);
|
|
3639
|
-
// this.setAttr("height",h);
|
|
3640
|
-
// this.setAttr({
|
|
3641
|
-
// width : w,
|
|
3642
|
-
// height : h
|
|
3643
|
-
// })
|
|
3644
|
-
this.style({border:"1px black solid"});
|
|
3645
|
-
//this.view(-w/2,-h/2,w/2,h/2);
|
|
3646
|
-
this.size(w, h);
|
|
3647
|
-
this.view(-10,-10,10,10);
|
|
3648
|
-
}
|
|
3649
|
-
size(w, h){
|
|
3650
|
-
this.setAttr({
|
|
3651
|
-
width : w,
|
|
3652
|
-
height : h
|
|
3653
|
-
});
|
|
3654
|
-
return this
|
|
3655
|
-
}
|
|
3656
|
-
view(x1,y1,x2,y2){
|
|
3657
|
-
let width=Math.abs(x2-x1);
|
|
3658
|
-
let height=Math.abs(y2-y1);
|
|
3659
|
-
this.setAttr("viewBox",[x1,y1,width,height].join(" "));
|
|
3660
|
-
this.st.scaleY(-1);
|
|
3661
|
-
return this;
|
|
3662
|
-
}
|
|
3663
|
-
add(...svgElement){
|
|
3664
|
-
for(let i=0;i<svgElement.length;i++){
|
|
3665
|
-
this.element.append(svgElement[i].element);
|
|
3666
|
-
this.items.push(svgElement[i]);
|
|
3667
|
-
}
|
|
3668
|
-
this.maintain();
|
|
3669
|
-
return this;
|
|
3670
|
-
}
|
|
3671
|
-
remove(...svgElement){
|
|
3672
|
-
for(let i=0;i<svgElement.length;i++){
|
|
3673
|
-
this.element?.removeChild(svgElement[i].element);
|
|
3674
|
-
this.items=this.items.filter(n=>!svgElement);
|
|
3675
|
-
}
|
|
3676
|
-
this.maintain();
|
|
3677
|
-
return this;
|
|
3678
|
-
}
|
|
3679
|
-
mask(){
|
|
3680
|
-
|
|
3681
|
-
}
|
|
3682
|
-
toString(){
|
|
3683
|
-
return (new XMLSerializer()).serializeToString(this.element);
|
|
3684
|
-
}
|
|
3685
|
-
btoa(){
|
|
3686
|
-
return btoa(this.toString())
|
|
3687
|
-
}
|
|
3688
|
-
toImg(){
|
|
3689
|
-
return 'data:image/svg+xml;base64,'+this.btoa()
|
|
3690
|
-
}
|
|
3691
|
-
toImg2(){
|
|
3692
|
-
return "data:image/svg+xml;charset=utf8,"+this.toString().replaceAll("<","%3C").replaceAll(">","%3E").replaceAll("#","%23").replaceAll('"',"'");
|
|
3693
|
-
}
|
|
3694
|
-
|
|
3695
|
-
}
|
|
3696
|
-
|
|
3697
|
-
const Svg =(w,h)=>new ZikoUISvg(w,h);
|
|
3698
|
-
|
|
3699
3624
|
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3700
3625
|
if (globalThis.customElements?.get(name)) {
|
|
3701
3626
|
console.warn(`Custom element "${name}" is already defined`);
|
|
@@ -4964,7 +4889,7 @@ class TimeAnimation {
|
|
|
4964
4889
|
this.t += this.state.step;
|
|
4965
4890
|
this.i++;
|
|
4966
4891
|
|
|
4967
|
-
this.tx = map(this.t, 0, this.state.duration, 0, 1);
|
|
4892
|
+
this.tx = map$1(this.t, 0, this.state.duration, 0, 1);
|
|
4968
4893
|
this.ty = this.state.ease(this.tx);
|
|
4969
4894
|
|
|
4970
4895
|
this.callback(this);
|
|
@@ -5409,7 +5334,7 @@ class ZikoApp {
|
|
|
5409
5334
|
return this;
|
|
5410
5335
|
}
|
|
5411
5336
|
setWrapper(wrapper){
|
|
5412
|
-
if(wrapper?.
|
|
5337
|
+
if(wrapper?.isUIElement) this.wrapper = wrapper;
|
|
5413
5338
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5414
5339
|
return this;
|
|
5415
5340
|
}
|
|
@@ -5481,7 +5406,7 @@ class ZikoSPA extends ZikoApp{
|
|
|
5481
5406
|
}
|
|
5482
5407
|
clear(){
|
|
5483
5408
|
[...this.routes].forEach(n=>{
|
|
5484
|
-
!isDynamic(n[0]) && n[1]?.
|
|
5409
|
+
!isDynamic(n[0]) && n[1]?.isUIElement && n[1].unrender();
|
|
5485
5410
|
});
|
|
5486
5411
|
// this.wrapper.clear();
|
|
5487
5412
|
return this;
|
|
@@ -5494,10 +5419,10 @@ class ZikoSPA extends ZikoApp{
|
|
|
5494
5419
|
element = callback.call(this,params);
|
|
5495
5420
|
}
|
|
5496
5421
|
else {
|
|
5497
|
-
callback?.
|
|
5422
|
+
callback?.isUIElement && callback.render(this.wrapper);
|
|
5498
5423
|
if(typeof callback === "function") element = callback();
|
|
5499
5424
|
}
|
|
5500
|
-
if(element?.
|
|
5425
|
+
if(element?.isUIElement) element.render(this.wrapper);
|
|
5501
5426
|
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
5502
5427
|
if(element instanceof Promise){
|
|
5503
5428
|
element.then(e=>e.render(this.wrapper));
|
|
@@ -5934,4 +5859,4 @@ if(globalThis?.document){
|
|
|
5934
5859
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
5935
5860
|
}
|
|
5936
5861
|
|
|
5937
|
-
export { App, Arc, Back, Base,
|
|
5862
|
+
export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, Scheduler, Step, Suspense, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UINode, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
|