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