ziko 0.45.2 → 0.45.4
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 +689 -696
- package/dist/ziko.js +49 -7
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +48 -8
- package/package.json +1 -1
- package/src/ui/__methods__/dom.js +7 -0
- package/src/ui/constructors/UIElement.js +2 -2
- package/src/ui/constructors/UIElementCore.js +2 -2
- package/src/ui/index.js +2 -1
- package/src/ui/logic/index.js +1 -0
- package/src/ui/logic/switch/index.js +38 -0
- package/src/ui/tags/index.js +2 -2
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 : Thu Sep 04 2025 20:47:52 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,155 @@ 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;
|
|
1480
1621
|
}
|
|
1481
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 replaceElementWith(new_element){
|
|
1679
|
+
this.cache.element.replaceWith(new_element);
|
|
1680
|
+
this.cache.element = new_element;
|
|
1681
|
+
|
|
1682
|
+
// To do : Dispose Events and States
|
|
1683
|
+
return this
|
|
1684
|
+
}
|
|
1685
|
+
function renderAfter(t = 1) {
|
|
1686
|
+
setTimeout(() => this.render(), t);
|
|
1687
|
+
return this;
|
|
1688
|
+
}
|
|
1689
|
+
function unrenderAfter(t = 1) {
|
|
1690
|
+
setTimeout(() => this.unrender(), t);
|
|
1691
|
+
return this;
|
|
1692
|
+
}
|
|
1693
|
+
function after(ui){
|
|
1694
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1695
|
+
this.element?.after(ui);
|
|
1696
|
+
return this;
|
|
1697
|
+
}
|
|
1698
|
+
function before(ui){
|
|
1699
|
+
if(ui?.isUIElement) ui=ui.element;
|
|
1700
|
+
this.element?.before(ui);
|
|
1701
|
+
return this;
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
var DomMethods = /*#__PURE__*/Object.freeze({
|
|
1705
|
+
__proto__: null,
|
|
1706
|
+
after: after,
|
|
1707
|
+
append: append,
|
|
1708
|
+
before: before,
|
|
1709
|
+
clear: clear,
|
|
1710
|
+
insertAt: insertAt,
|
|
1711
|
+
prepend: prepend,
|
|
1712
|
+
remove: remove,
|
|
1713
|
+
render: render,
|
|
1714
|
+
renderAfter: renderAfter,
|
|
1715
|
+
replaceElementWith: replaceElementWith,
|
|
1716
|
+
unrender: unrender,
|
|
1717
|
+
unrenderAfter: unrenderAfter
|
|
1718
|
+
});
|
|
1719
|
+
|
|
1482
1720
|
const Events = {
|
|
1483
1721
|
'Click' : [
|
|
1484
1722
|
'Click',
|
|
1485
|
-
'DblClick'
|
|
1723
|
+
'DblClick',
|
|
1724
|
+
'ClickAway'
|
|
1486
1725
|
],
|
|
1487
1726
|
'Ptr' : [
|
|
1488
1727
|
'PtrMove',
|
|
@@ -1698,9 +1937,11 @@ class __ZikoEvent__ {
|
|
|
1698
1937
|
}
|
|
1699
1938
|
}
|
|
1700
1939
|
|
|
1940
|
+
// import { register_click_away_event } from "./custom-events/click-away.js";
|
|
1701
1941
|
class ZikoEventClick extends __ZikoEvent__{
|
|
1702
1942
|
constructor(target, customizer){
|
|
1703
1943
|
super(target, Events.Click, details_setter$a, customizer);
|
|
1944
|
+
// register_click_away_event(target.element)
|
|
1704
1945
|
}
|
|
1705
1946
|
}
|
|
1706
1947
|
function details_setter$a(){
|
|
@@ -1708,7 +1949,7 @@ function details_setter$a(){
|
|
|
1708
1949
|
else this.dx = 1;
|
|
1709
1950
|
// console.log(this.currentEvent)
|
|
1710
1951
|
}
|
|
1711
|
-
const
|
|
1952
|
+
const bind_click_event = (target, customizer) => new ZikoEventClick(target, customizer);
|
|
1712
1953
|
|
|
1713
1954
|
class ZikoEventClipboard extends __ZikoEvent__{
|
|
1714
1955
|
constructor(target, customizer){
|
|
@@ -1718,7 +1959,7 @@ class ZikoEventClipboard extends __ZikoEvent__{
|
|
|
1718
1959
|
function details_setter$9(){
|
|
1719
1960
|
|
|
1720
1961
|
}
|
|
1721
|
-
const
|
|
1962
|
+
const bind_clipboard_event = (target, customizer) => new ZikoEventClipboard(target, customizer);
|
|
1722
1963
|
|
|
1723
1964
|
class ZikoEventCustom extends __ZikoEvent__{
|
|
1724
1965
|
constructor(target, events, customizer){
|
|
@@ -1752,7 +1993,7 @@ class ZikoEventDrag extends __ZikoEvent__{
|
|
|
1752
1993
|
function details_setter$7(){
|
|
1753
1994
|
|
|
1754
1995
|
}
|
|
1755
|
-
const
|
|
1996
|
+
const bind_drag_event = (target, customizer) => new ZikoEventDrag(target, customizer);
|
|
1756
1997
|
|
|
1757
1998
|
class ZikoEventFocus extends __ZikoEvent__{
|
|
1758
1999
|
constructor(target, customizer){
|
|
@@ -1762,7 +2003,7 @@ class ZikoEventFocus extends __ZikoEvent__{
|
|
|
1762
2003
|
function details_setter$6(){
|
|
1763
2004
|
|
|
1764
2005
|
}
|
|
1765
|
-
const
|
|
2006
|
+
const bind_focus_event = (target, customizer) => new ZikoEventFocus(target, customizer);
|
|
1766
2007
|
|
|
1767
2008
|
let ZikoEventHash$1 = class ZikoEventHash extends __ZikoEvent__{
|
|
1768
2009
|
constructor(target, customizer){
|
|
@@ -1793,7 +2034,7 @@ function details_setter$4(){
|
|
|
1793
2034
|
|
|
1794
2035
|
}
|
|
1795
2036
|
}
|
|
1796
|
-
const
|
|
2037
|
+
const bind_key_event = (target, customizer) => new ZikoEventKey(target, customizer);
|
|
1797
2038
|
|
|
1798
2039
|
class ZikoEventMouse extends __ZikoEvent__{
|
|
1799
2040
|
constructor(target, customizer){
|
|
@@ -1803,7 +2044,7 @@ class ZikoEventMouse extends __ZikoEvent__{
|
|
|
1803
2044
|
function details_setter$3(){
|
|
1804
2045
|
|
|
1805
2046
|
}
|
|
1806
|
-
const
|
|
2047
|
+
const bind_mouse_event = (target, customizer) => new ZikoEventMouse(target, customizer);
|
|
1807
2048
|
|
|
1808
2049
|
class ZikoEventPointer extends __ZikoEvent__{
|
|
1809
2050
|
constructor(target, customizer){
|
|
@@ -1844,7 +2085,7 @@ function details_setter$2(){
|
|
|
1844
2085
|
// else this.dx = 1
|
|
1845
2086
|
// console.log(this.currentEvent)
|
|
1846
2087
|
}
|
|
1847
|
-
const
|
|
2088
|
+
const bind_pointer_event = (target, customizer) => new ZikoEventPointer(target, customizer);
|
|
1848
2089
|
|
|
1849
2090
|
class ZikoEventTouch extends __ZikoEvent__{
|
|
1850
2091
|
constructor(target, customizer){
|
|
@@ -1864,17 +2105,17 @@ class ZikoEventWheel extends __ZikoEvent__{
|
|
|
1864
2105
|
function details_setter(){
|
|
1865
2106
|
|
|
1866
2107
|
}
|
|
1867
|
-
const
|
|
2108
|
+
const bind_wheel_event = (target, customizer) => new ZikoEventWheel(target, customizer);
|
|
1868
2109
|
|
|
1869
2110
|
const binderMap = {
|
|
1870
|
-
ptr:
|
|
1871
|
-
mouse :
|
|
1872
|
-
key:
|
|
1873
|
-
click :
|
|
1874
|
-
drag :
|
|
1875
|
-
clipboard :
|
|
1876
|
-
focus :
|
|
1877
|
-
wheel :
|
|
2111
|
+
ptr: bind_pointer_event,
|
|
2112
|
+
mouse : bind_mouse_event,
|
|
2113
|
+
key: bind_key_event,
|
|
2114
|
+
click : bind_click_event,
|
|
2115
|
+
drag : bind_drag_event,
|
|
2116
|
+
clipboard : bind_clipboard_event,
|
|
2117
|
+
focus : bind_focus_event,
|
|
2118
|
+
wheel : bind_wheel_event
|
|
1878
2119
|
};
|
|
1879
2120
|
|
|
1880
2121
|
const EventsMethodes = {};
|
|
@@ -1890,55 +2131,68 @@ Object.entries(Events).forEach(([name, eventList]) => {
|
|
|
1890
2131
|
});
|
|
1891
2132
|
});
|
|
1892
2133
|
|
|
1893
|
-
|
|
1894
|
-
at(index)
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
forEach(callback)
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
map(callback)
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2134
|
+
function at(index) {
|
|
2135
|
+
return this.items.at(index);
|
|
2136
|
+
}
|
|
2137
|
+
function forEach(callback) {
|
|
2138
|
+
this.items.forEach(callback);
|
|
2139
|
+
return this;
|
|
2140
|
+
}
|
|
2141
|
+
function map(callback) {
|
|
2142
|
+
return this.items.map(callback);
|
|
2143
|
+
}
|
|
2144
|
+
function find(condition) {
|
|
2145
|
+
return this.items.filter(condition);
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
var IndexingMethods = /*#__PURE__*/Object.freeze({
|
|
2149
|
+
__proto__: null,
|
|
2150
|
+
at: at,
|
|
2151
|
+
find: find,
|
|
2152
|
+
forEach: forEach,
|
|
2153
|
+
map: map
|
|
2154
|
+
});
|
|
1908
2155
|
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
(newValue)
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
);
|
|
1923
|
-
}
|
|
1924
|
-
else Object.assign(this.element.style, {[key] : value});
|
|
2156
|
+
function style(styles){
|
|
2157
|
+
for(let key in styles){
|
|
2158
|
+
const value = styles[key];
|
|
2159
|
+
if(isStateGetter(value)){
|
|
2160
|
+
const getter = value();
|
|
2161
|
+
Object.assign(this.element.style, {[key] : getter.value});
|
|
2162
|
+
getter._subscribe(
|
|
2163
|
+
(newValue) => {
|
|
2164
|
+
console.log({newValue});
|
|
2165
|
+
Object.assign(this.element.style, {[key] : newValue});
|
|
2166
|
+
},
|
|
2167
|
+
// this
|
|
2168
|
+
);
|
|
1925
2169
|
}
|
|
1926
|
-
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2170
|
+
else Object.assign(this.element.style, {[key] : value});
|
|
2171
|
+
}
|
|
2172
|
+
return this;
|
|
2173
|
+
}
|
|
2174
|
+
function size(width, height){
|
|
2175
|
+
return this.style({width, height})
|
|
2176
|
+
}
|
|
2177
|
+
function hide(){
|
|
1932
2178
|
|
|
1933
|
-
|
|
1934
|
-
|
|
2179
|
+
}
|
|
2180
|
+
function show(){
|
|
1935
2181
|
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
2182
|
+
}
|
|
2183
|
+
function animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
2184
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2185
|
+
return this;
|
|
2186
|
+
}
|
|
2187
|
+
|
|
2188
|
+
var StyleMethods = /*#__PURE__*/Object.freeze({
|
|
2189
|
+
__proto__: null,
|
|
2190
|
+
animate: animate,
|
|
2191
|
+
hide: hide,
|
|
2192
|
+
show: show,
|
|
2193
|
+
size: size,
|
|
2194
|
+
style: style
|
|
2195
|
+
});
|
|
1942
2196
|
|
|
1943
2197
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
1944
2198
|
this.event=e;
|
|
@@ -2600,22 +2854,22 @@ class ZikoScreenObserver {
|
|
|
2600
2854
|
});
|
|
2601
2855
|
}
|
|
2602
2856
|
get x0(){
|
|
2603
|
-
return map(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2857
|
+
return map$1(globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2604
2858
|
}
|
|
2605
2859
|
get y0(){
|
|
2606
|
-
return - map(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2860
|
+
return - map$1(globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2607
2861
|
}
|
|
2608
2862
|
get x1(){
|
|
2609
|
-
return map(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2863
|
+
return map$1(globalThis?.screenX + globalThis?.outerWidth, 0, globalThis.screen.availWidth, -1, 1);
|
|
2610
2864
|
}
|
|
2611
2865
|
get y1(){
|
|
2612
|
-
return - map(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2866
|
+
return - map$1(globalThis?.screenY + globalThis?.outerHeight, 0, globalThis.screen.availHeight, -1, 1);
|
|
2613
2867
|
}
|
|
2614
2868
|
get cx(){
|
|
2615
|
-
return map(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2869
|
+
return map$1(globalThis?.outerWidth/2+globalThis?.screenX, 0, globalThis.screen.availWidth, -1, 1);
|
|
2616
2870
|
}
|
|
2617
2871
|
get cy(){
|
|
2618
|
-
return - map(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2872
|
+
return - map$1(globalThis?.outerHeight/2+ globalThis?.screenY, 0, globalThis.screen.availHeight, -1, 1);
|
|
2619
2873
|
}
|
|
2620
2874
|
}
|
|
2621
2875
|
|
|
@@ -2877,22 +3131,12 @@ class ZikoUseMediaQuery {
|
|
|
2877
3131
|
|
|
2878
3132
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
2879
3133
|
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
constructor({element, name ='', type="html", render = __Ziko__.__Config__.default.render, useDefaultStyle=false}={}){
|
|
3134
|
+
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3135
|
+
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
2883
3136
|
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(
|
|
3137
|
+
// console.log({type})
|
|
3138
|
+
// console.log(this)
|
|
3139
|
+
register_to_class(
|
|
2896
3140
|
this,
|
|
2897
3141
|
AttrsMethods,
|
|
2898
3142
|
DomMethods,
|
|
@@ -2900,61 +3144,7 @@ class UIElement extends UINode{
|
|
|
2900
3144
|
IndexingMethods,
|
|
2901
3145
|
EventsMethodes
|
|
2902
3146
|
);
|
|
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);
|
|
3147
|
+
if(element)this.init(element, name, type, render);
|
|
2958
3148
|
}
|
|
2959
3149
|
get element(){
|
|
2960
3150
|
return this.cache.element;
|
|
@@ -2962,9 +3152,9 @@ class UIElement extends UINode{
|
|
|
2962
3152
|
isInteractive(){
|
|
2963
3153
|
return this.cache.isInteractive;
|
|
2964
3154
|
}
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
}
|
|
3155
|
+
// isUIElement(){
|
|
3156
|
+
// return true;
|
|
3157
|
+
// }
|
|
2968
3158
|
get st(){
|
|
2969
3159
|
return this.cache.style;
|
|
2970
3160
|
}
|
|
@@ -3004,73 +3194,73 @@ class UIElement extends UINode{
|
|
|
3004
3194
|
get left(){
|
|
3005
3195
|
return this.element.getBoundingClientRect().left;
|
|
3006
3196
|
}
|
|
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
|
-
}
|
|
3197
|
+
// clone(render=false) {
|
|
3198
|
+
// // UI.__proto__=this.__proto__;
|
|
3199
|
+
// // if(this.items.length){
|
|
3200
|
+
// // const items = [...this.items].map(n=>n.clone());
|
|
3201
|
+
// // UI.append(...items);
|
|
3202
|
+
// // }
|
|
3203
|
+
// // else UI.element=this.element.cloneNode(true);
|
|
3204
|
+
// // return UI.render(render);
|
|
3205
|
+
// }
|
|
3206
|
+
// [Symbol.iterator]() {
|
|
3207
|
+
// return this.items[Symbol.iterator]();
|
|
3208
|
+
// }
|
|
3209
|
+
// maintain() {
|
|
3210
|
+
// for (let i = 0; i < this.items.length; i++) {
|
|
3211
|
+
// Object.defineProperty(this, i, {
|
|
3212
|
+
// value: this.items[i],
|
|
3213
|
+
// writable: true,
|
|
3214
|
+
// configurable: true,
|
|
3215
|
+
// enumerable: false
|
|
3216
|
+
// });
|
|
3217
|
+
// }
|
|
3218
|
+
// }
|
|
3219
|
+
// freeze(freeze){
|
|
3220
|
+
// this.cache.isFrozzen=freeze;
|
|
3221
|
+
// return this;
|
|
3222
|
+
// }
|
|
3033
3223
|
// setTarget(tg) {
|
|
3034
3224
|
// if(this.isBody) return ;
|
|
3035
|
-
// if (tg?.
|
|
3225
|
+
// if (tg?.isUIElement) tg = tg.element;
|
|
3036
3226
|
// this.unrender();
|
|
3037
3227
|
// this.target = tg;
|
|
3038
3228
|
// this.render();
|
|
3039
3229
|
// return this;
|
|
3040
3230
|
// }
|
|
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
|
-
}
|
|
3231
|
+
// describe(label){
|
|
3232
|
+
// if(label)this.setAttr("aria-label",label)
|
|
3233
|
+
// }
|
|
3234
|
+
// get children() {
|
|
3235
|
+
// return [...this.element.children];
|
|
3236
|
+
// }
|
|
3237
|
+
// get cloneElement() {
|
|
3238
|
+
// return this.element.cloneNode(true);
|
|
3239
|
+
// }
|
|
3240
|
+
// setClasses(...value) {
|
|
3241
|
+
// this.setAttr("class", value.join(" "));
|
|
3242
|
+
// return this;
|
|
3243
|
+
// }
|
|
3244
|
+
// get classes(){
|
|
3245
|
+
// const classes=this.element.getAttribute("class");
|
|
3246
|
+
// return classes===null?[]:classes.split(" ");
|
|
3247
|
+
// }
|
|
3248
|
+
// addClass() {
|
|
3249
|
+
// /*this.setAttr("class", value);
|
|
3250
|
+
// return this;*/
|
|
3251
|
+
// }
|
|
3252
|
+
// setId(id) {
|
|
3253
|
+
// this.setAttr("id", id);
|
|
3254
|
+
// return this;
|
|
3255
|
+
// }
|
|
3256
|
+
// get id() {
|
|
3257
|
+
// return this.element.getAttribute("id");
|
|
3258
|
+
// }
|
|
3259
|
+
// onSwipe(width_threshold, height_threshold,...callbacks){
|
|
3260
|
+
// if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
|
|
3261
|
+
// this.events.swipe.onSwipe(...callbacks);
|
|
3262
|
+
// return this;
|
|
3263
|
+
// }
|
|
3074
3264
|
// To Fix
|
|
3075
3265
|
// onKeysDown({keys=[],callback}={}){
|
|
3076
3266
|
// if(!this.events.key)this.events.key = useKeyEvent(this);
|
|
@@ -3092,26 +3282,26 @@ class UIElement extends UINode{
|
|
|
3092
3282
|
this.events.custom.emit(event_name,detail);
|
|
3093
3283
|
return this;
|
|
3094
3284
|
}
|
|
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
|
-
}
|
|
3285
|
+
// watchAttr(callback){
|
|
3286
|
+
// if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
|
|
3287
|
+
// return this;
|
|
3288
|
+
// }
|
|
3289
|
+
// watchChildren(callback){
|
|
3290
|
+
// if(!this.observer.children)this.observer.children = watchChildren(this,callback);
|
|
3291
|
+
// return this;
|
|
3292
|
+
// }
|
|
3293
|
+
// watchSize(callback){
|
|
3294
|
+
// if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
|
|
3295
|
+
// this.observer.resize.start();
|
|
3296
|
+
// return this;
|
|
3297
|
+
// }
|
|
3298
|
+
// watchIntersection(callback,config){
|
|
3299
|
+
// if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
|
|
3300
|
+
// this.observer.intersection.start();
|
|
3301
|
+
// return this;
|
|
3302
|
+
// }
|
|
3113
3303
|
|
|
3114
|
-
}
|
|
3304
|
+
};
|
|
3115
3305
|
|
|
3116
3306
|
const HTMLTags = [
|
|
3117
3307
|
'a',
|
|
@@ -3201,7 +3391,6 @@ const HTMLTags = [
|
|
|
3201
3391
|
'sub',
|
|
3202
3392
|
'summary',
|
|
3203
3393
|
'sup',
|
|
3204
|
-
'svg',
|
|
3205
3394
|
'table',
|
|
3206
3395
|
'tbody',
|
|
3207
3396
|
'td',
|
|
@@ -3235,6 +3424,9 @@ const SVGTags = [
|
|
|
3235
3424
|
"desc", "title", "metadata", "foreignObject"
|
|
3236
3425
|
];
|
|
3237
3426
|
|
|
3427
|
+
// const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
|
|
3428
|
+
// const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
|
|
3429
|
+
|
|
3238
3430
|
const tags = new Proxy({}, {
|
|
3239
3431
|
get(target, prop) {
|
|
3240
3432
|
if (typeof prop !== 'string') return undefined;
|
|
@@ -3242,16 +3434,22 @@ const tags = new Proxy({}, {
|
|
|
3242
3434
|
let type ;
|
|
3243
3435
|
if(HTMLTags.includes(tag)) type = 'html';
|
|
3244
3436
|
if(SVGTags.includes(tag)) type = 'svg';
|
|
3437
|
+
// console.log(type)
|
|
3245
3438
|
return (...args)=>{
|
|
3246
3439
|
// Fix undefined
|
|
3247
3440
|
// console.log(isStateGetter(args[0]))
|
|
3441
|
+
// console.log(!!args)
|
|
3442
|
+
if(args.length === 0) {
|
|
3443
|
+
// console.log('length 0')
|
|
3444
|
+
return new UIElement$1({element : tag, name : tag, type})
|
|
3445
|
+
}
|
|
3248
3446
|
if(
|
|
3249
3447
|
['string', 'number'].includes(typeof args[0])
|
|
3250
|
-
|| args[0] instanceof UIElement
|
|
3448
|
+
|| args[0] instanceof UIElement$1
|
|
3251
3449
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3252
|
-
) return new UIElement({element : tag, name : tag, type}).append(...args);
|
|
3450
|
+
) return new UIElement$1({element : tag, name : tag, type}).append(...args);
|
|
3253
3451
|
// console.log(args[0])
|
|
3254
|
-
return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
|
|
3452
|
+
return new UIElement$1({element : tag, type}).setAttr(args.shift()).append(...args)
|
|
3255
3453
|
}
|
|
3256
3454
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3257
3455
|
// return (...args)=>{
|
|
@@ -3274,7 +3472,7 @@ const tags = new Proxy({}, {
|
|
|
3274
3472
|
}
|
|
3275
3473
|
});
|
|
3276
3474
|
|
|
3277
|
-
class ZikoUIFlex extends UIElement {
|
|
3475
|
+
class ZikoUIFlex extends UIElement$1 {
|
|
3278
3476
|
constructor(tag = "div", w = "100%", h = "100%") {
|
|
3279
3477
|
super({element : tag , name : "Flex"});
|
|
3280
3478
|
this.direction = "cols";
|
|
@@ -3373,37 +3571,11 @@ function map_pos_y(align){
|
|
|
3373
3571
|
return map_pos_x(-align);
|
|
3374
3572
|
}
|
|
3375
3573
|
|
|
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;
|
|
3574
|
+
class UIElement extends UIElementCore{
|
|
3575
|
+
constructor({element, name, type, render}){
|
|
3576
|
+
super({element, name, type, render});
|
|
3404
3577
|
}
|
|
3405
|
-
}
|
|
3406
|
-
const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
|
|
3578
|
+
}
|
|
3407
3579
|
|
|
3408
3580
|
class ZikoUISuspense extends UIElement{
|
|
3409
3581
|
constructor(fallback_ui, callback){
|
|
@@ -3429,12 +3601,16 @@ class ZikoUISuspense extends UIElement{
|
|
|
3429
3601
|
|
|
3430
3602
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3431
3603
|
|
|
3432
|
-
class
|
|
3433
|
-
constructor(
|
|
3434
|
-
super({element :
|
|
3435
|
-
this.element.append(
|
|
3604
|
+
class UIHTMLWrapper extends UIElement$1 {
|
|
3605
|
+
constructor(content){
|
|
3606
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3607
|
+
this.element.append(html2dom(content));
|
|
3608
|
+
this.style({
|
|
3609
|
+
display : 'contents'
|
|
3610
|
+
});
|
|
3436
3611
|
}
|
|
3437
3612
|
}
|
|
3613
|
+
|
|
3438
3614
|
function html2dom(htmlString) {
|
|
3439
3615
|
if(globalThis?.DOMParser){
|
|
3440
3616
|
const parser = new DOMParser();
|
|
@@ -3442,261 +3618,50 @@ function html2dom(htmlString) {
|
|
|
3442
3618
|
doc.body.firstChild.style.display = "contents";
|
|
3443
3619
|
return doc.body.firstChild;
|
|
3444
3620
|
}
|
|
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
|
-
}
|
|
3458
|
-
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
3459
|
-
constructor(SVGContent){
|
|
3460
|
-
super(SVGContent, "svg");
|
|
3461
|
-
}
|
|
3462
3621
|
}
|
|
3463
|
-
|
|
3464
|
-
const
|
|
3622
|
+
|
|
3623
|
+
const HTMLWrapper = (content) => new UIHTMLWrapper(content);
|
|
3465
3624
|
|
|
3466
|
-
class
|
|
3467
|
-
constructor(
|
|
3468
|
-
super(
|
|
3469
|
-
this.
|
|
3625
|
+
class UISVGWrapper extends UIElement$1 {
|
|
3626
|
+
constructor(content){
|
|
3627
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3628
|
+
this.element.append(svg2dom(content));
|
|
3470
3629
|
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);
|
|
3630
|
+
display : 'contents'
|
|
3615
3631
|
});
|
|
3616
3632
|
}
|
|
3617
|
-
zoomIn(){
|
|
3618
|
-
|
|
3619
|
-
}
|
|
3620
|
-
zoomOut(){
|
|
3621
|
-
|
|
3622
|
-
}
|
|
3623
|
-
undo(n){
|
|
3624
|
-
|
|
3625
|
-
}
|
|
3626
|
-
redo(n){
|
|
3627
|
-
|
|
3628
|
-
}
|
|
3629
|
-
stream(){
|
|
3630
|
-
|
|
3631
|
-
}
|
|
3632
3633
|
}
|
|
3633
3634
|
|
|
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
|
-
|
|
3635
|
+
function svg2dom(svgString) {
|
|
3636
|
+
if (typeof DOMParser !== "undefined") {
|
|
3637
|
+
const parser = new DOMParser();
|
|
3638
|
+
const doc = parser.parseFromString(svgString.trim(), "image/svg+xml");
|
|
3639
|
+
const svg = doc.documentElement;
|
|
3640
|
+
|
|
3641
|
+
if (svg.nodeName === "parsererror") {
|
|
3642
|
+
throw new Error("Invalid SVG string");
|
|
3643
|
+
}
|
|
3644
|
+
if(svg.hasAttribute('xmlns')) return svg
|
|
3645
|
+
// TO Fix ...
|
|
3646
|
+
const {children, attributes} = svg;
|
|
3647
|
+
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3648
|
+
for(let {name, value} of attributes){
|
|
3649
|
+
element.setAttribute(name, value);
|
|
3650
|
+
}
|
|
3651
|
+
element.append(...children);
|
|
3652
|
+
|
|
3653
|
+
globalThis.svg = svg;
|
|
3654
|
+
globalThis.children = children;
|
|
3655
|
+
globalThis.attributes = attributes;
|
|
3656
|
+
globalThis.element = element;
|
|
3657
|
+
return element;
|
|
3697
3658
|
}
|
|
3659
|
+
throw new Error("DOMParser is not available in this environment");
|
|
3660
|
+
}
|
|
3661
|
+
|
|
3698
3662
|
|
|
3699
|
-
|
|
3663
|
+
|
|
3664
|
+
const SVGWrapper = (content) => new UISVGWrapper(content);
|
|
3700
3665
|
|
|
3701
3666
|
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3702
3667
|
if (globalThis.customElements?.get(name)) {
|
|
@@ -3743,6 +3708,38 @@ function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
|
3743
3708
|
);
|
|
3744
3709
|
}
|
|
3745
3710
|
|
|
3711
|
+
class UISwitch extends UIElement$1{
|
|
3712
|
+
constructor(key, cases){
|
|
3713
|
+
super();
|
|
3714
|
+
this.key = key;
|
|
3715
|
+
this.cases = cases;
|
|
3716
|
+
this.init();
|
|
3717
|
+
}
|
|
3718
|
+
init(){
|
|
3719
|
+
Object.values(this.cases).filter(n=>n != this.current).forEach(n=>n.unrender());
|
|
3720
|
+
super.init(this.current.element);
|
|
3721
|
+
}
|
|
3722
|
+
get current(){
|
|
3723
|
+
const matched = Object.keys(this.cases).find(n => n == this.key) ?? 'default';
|
|
3724
|
+
return this.cases[matched]
|
|
3725
|
+
}
|
|
3726
|
+
updateKey(key){
|
|
3727
|
+
this.key = key;
|
|
3728
|
+
this.replaceElementWith(this.current.element);
|
|
3729
|
+
// this.cache.element.replaceWith(this.current.element)
|
|
3730
|
+
// this.cache.element = this.current.element;
|
|
3731
|
+
return this;
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
}
|
|
3735
|
+
|
|
3736
|
+
const Switch=({key, cases})=> new UISwitch(key, cases);
|
|
3737
|
+
|
|
3738
|
+
// export const Switch=({key, cases}) => {
|
|
3739
|
+
// const matched = Object.keys(cases).find(n => n == key) ?? 'default';
|
|
3740
|
+
// return this.cases[matched]()
|
|
3741
|
+
// }
|
|
3742
|
+
|
|
3746
3743
|
const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
|
|
3747
3744
|
const svg2ascii=svg=>btoa(svg2str(svg));
|
|
3748
3745
|
const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
|
|
@@ -4966,7 +4963,7 @@ class TimeAnimation {
|
|
|
4966
4963
|
this.t += this.state.step;
|
|
4967
4964
|
this.i++;
|
|
4968
4965
|
|
|
4969
|
-
this.tx = map(this.t, 0, this.state.duration, 0, 1);
|
|
4966
|
+
this.tx = map$1(this.t, 0, this.state.duration, 0, 1);
|
|
4970
4967
|
this.ty = this.state.ease(this.tx);
|
|
4971
4968
|
|
|
4972
4969
|
this.callback(this);
|
|
@@ -5411,7 +5408,7 @@ class ZikoApp {
|
|
|
5411
5408
|
return this;
|
|
5412
5409
|
}
|
|
5413
5410
|
setWrapper(wrapper){
|
|
5414
|
-
if(wrapper?.
|
|
5411
|
+
if(wrapper?.isUIElement) this.wrapper = wrapper;
|
|
5415
5412
|
else if(typeof wrapper === "function") this.wrapper = wrapper();
|
|
5416
5413
|
return this;
|
|
5417
5414
|
}
|
|
@@ -5483,7 +5480,7 @@ class ZikoSPA extends ZikoApp{
|
|
|
5483
5480
|
}
|
|
5484
5481
|
clear(){
|
|
5485
5482
|
[...this.routes].forEach(n=>{
|
|
5486
|
-
!isDynamic(n[0]) && n[1]?.
|
|
5483
|
+
!isDynamic(n[0]) && n[1]?.isUIElement && n[1].unrender();
|
|
5487
5484
|
});
|
|
5488
5485
|
// this.wrapper.clear();
|
|
5489
5486
|
return this;
|
|
@@ -5496,10 +5493,10 @@ class ZikoSPA extends ZikoApp{
|
|
|
5496
5493
|
element = callback.call(this,params);
|
|
5497
5494
|
}
|
|
5498
5495
|
else {
|
|
5499
|
-
callback?.
|
|
5496
|
+
callback?.isUIElement && callback.render(this.wrapper);
|
|
5500
5497
|
if(typeof callback === "function") element = callback();
|
|
5501
5498
|
}
|
|
5502
|
-
if(element?.
|
|
5499
|
+
if(element?.isUIElement) element.render(this.wrapper);
|
|
5503
5500
|
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
5504
5501
|
if(element instanceof Promise){
|
|
5505
5502
|
element.then(e=>e.render(this.wrapper));
|
|
@@ -5572,11 +5569,12 @@ function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts'])
|
|
|
5572
5569
|
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
5573
5570
|
const parts = normalizedPath.split('/');
|
|
5574
5571
|
const rootParts = root.split('/');
|
|
5575
|
-
const rootIndex = parts.indexOf(rootParts
|
|
5572
|
+
const rootIndex = parts.indexOf(rootParts.at(-1));
|
|
5576
5573
|
if (rootIndex !== -1) {
|
|
5577
5574
|
const subsequentParts = parts.slice(rootIndex + 1);
|
|
5578
|
-
const lastPart =
|
|
5575
|
+
const lastPart = parts.at(-1);
|
|
5579
5576
|
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
5577
|
+
// console.log({extensions, subsequentParts, lastPart, isIndexFile, rootParts, rootIndex, parts})
|
|
5580
5578
|
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
5581
5579
|
if (isIndexFile) {
|
|
5582
5580
|
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
@@ -5940,7 +5938,6 @@ exports.App = App;
|
|
|
5940
5938
|
exports.Arc = Arc;
|
|
5941
5939
|
exports.Back = Back;
|
|
5942
5940
|
exports.Base = Base;
|
|
5943
|
-
exports.Canvas = Canvas;
|
|
5944
5941
|
exports.Clock = Clock;
|
|
5945
5942
|
exports.Combinaison = Combinaison;
|
|
5946
5943
|
exports.Complex = Complex;
|
|
@@ -5950,7 +5947,6 @@ exports.EPSILON = EPSILON;
|
|
|
5950
5947
|
exports.Elastic = Elastic;
|
|
5951
5948
|
exports.FileBasedRouting = FileBasedRouting;
|
|
5952
5949
|
exports.Flex = Flex;
|
|
5953
|
-
exports.Grid = Grid$1;
|
|
5954
5950
|
exports.HTMLWrapper = HTMLWrapper;
|
|
5955
5951
|
exports.InBack = InBack;
|
|
5956
5952
|
exports.InBounce = InBounce;
|
|
@@ -5993,13 +5989,16 @@ exports.SVGWrapper = SVGWrapper;
|
|
|
5993
5989
|
exports.Scheduler = Scheduler;
|
|
5994
5990
|
exports.Step = Step;
|
|
5995
5991
|
exports.Suspense = Suspense;
|
|
5996
|
-
exports.
|
|
5992
|
+
exports.Switch = Switch;
|
|
5997
5993
|
exports.Tick = Tick;
|
|
5998
5994
|
exports.TimeAnimation = TimeAnimation;
|
|
5999
5995
|
exports.TimeLoop = TimeLoop;
|
|
6000
5996
|
exports.TimeScheduler = TimeScheduler;
|
|
6001
|
-
exports.UIElement = UIElement;
|
|
5997
|
+
exports.UIElement = UIElement$1;
|
|
5998
|
+
exports.UIHTMLWrapper = UIHTMLWrapper;
|
|
6002
5999
|
exports.UINode = UINode;
|
|
6000
|
+
exports.UISVGWrapper = UISVGWrapper;
|
|
6001
|
+
exports.UISwitch = UISwitch;
|
|
6003
6002
|
exports.Utils = Utils;
|
|
6004
6003
|
exports.ZikoApp = ZikoApp;
|
|
6005
6004
|
exports.ZikoCustomEvent = ZikoCustomEvent;
|
|
@@ -6018,15 +6017,9 @@ exports.ZikoEventWheel = ZikoEventWheel;
|
|
|
6018
6017
|
exports.ZikoHead = ZikoHead;
|
|
6019
6018
|
exports.ZikoMutationObserver = ZikoMutationObserver;
|
|
6020
6019
|
exports.ZikoSPA = ZikoSPA;
|
|
6021
|
-
exports.ZikoUICanvas = ZikoUICanvas;
|
|
6022
6020
|
exports.ZikoUIFlex = ZikoUIFlex;
|
|
6023
|
-
exports.ZikoUIGrid = ZikoUIGrid;
|
|
6024
|
-
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
6025
|
-
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
6026
6021
|
exports.ZikoUISuspense = ZikoUISuspense;
|
|
6027
|
-
exports.ZikoUISvg = ZikoUISvg;
|
|
6028
6022
|
exports.ZikoUIText = ZikoUIText;
|
|
6029
|
-
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
6030
6023
|
exports.ZikoUseRoot = ZikoUseRoot;
|
|
6031
6024
|
exports.__ZikoEvent__ = __ZikoEvent__;
|
|
6032
6025
|
exports.abs = abs;
|
|
@@ -6043,17 +6036,17 @@ exports.asinh = asinh;
|
|
|
6043
6036
|
exports.atan = atan;
|
|
6044
6037
|
exports.atan2 = atan2;
|
|
6045
6038
|
exports.atanh = atanh;
|
|
6046
|
-
exports.bindClickEvent = bindClickEvent;
|
|
6047
|
-
exports.bindClipboardEvent = bindClipboardEvent;
|
|
6048
6039
|
exports.bindCustomEvent = bindCustomEvent;
|
|
6049
|
-
exports.bindDragEvent = bindDragEvent;
|
|
6050
|
-
exports.bindFocusEvent = bindFocusEvent;
|
|
6051
6040
|
exports.bindHashEvent = bindHashEvent;
|
|
6052
|
-
exports.bindKeyEvent = bindKeyEvent;
|
|
6053
|
-
exports.bindMouseEvent = bindMouseEvent;
|
|
6054
|
-
exports.bindPointerEvent = bindPointerEvent;
|
|
6055
6041
|
exports.bindTouchEvent = bindTouchEvent;
|
|
6056
|
-
exports.
|
|
6042
|
+
exports.bind_click_event = bind_click_event;
|
|
6043
|
+
exports.bind_clipboard_event = bind_clipboard_event;
|
|
6044
|
+
exports.bind_drag_event = bind_drag_event;
|
|
6045
|
+
exports.bind_focus_event = bind_focus_event;
|
|
6046
|
+
exports.bind_key_event = bind_key_event;
|
|
6047
|
+
exports.bind_mouse_event = bind_mouse_event;
|
|
6048
|
+
exports.bind_pointer_event = bind_pointer_event;
|
|
6049
|
+
exports.bind_wheel_event = bind_wheel_event;
|
|
6057
6050
|
exports.cartesianProduct = cartesianProduct;
|
|
6058
6051
|
exports.ceil = ceil;
|
|
6059
6052
|
exports.clamp = clamp;
|
|
@@ -6097,7 +6090,7 @@ exports.linspace = linspace;
|
|
|
6097
6090
|
exports.ln = ln;
|
|
6098
6091
|
exports.logspace = logspace;
|
|
6099
6092
|
exports.loop = loop;
|
|
6100
|
-
exports.map = map;
|
|
6093
|
+
exports.map = map$1;
|
|
6101
6094
|
exports.mapfun = mapfun$1;
|
|
6102
6095
|
exports.matrix = matrix;
|
|
6103
6096
|
exports.matrix2 = matrix2;
|