ziko 0.45.1 → 0.45.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.js +98 -61
- 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/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.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Mon Sep 01 2025 13:22:11 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -1204,22 +1204,21 @@
|
|
|
1204
1204
|
|
|
1205
1205
|
__init__global__();
|
|
1206
1206
|
class UIElementCore extends UINode{
|
|
1207
|
-
constructor({
|
|
1208
|
-
element,
|
|
1209
|
-
name ='',
|
|
1210
|
-
type="html",
|
|
1211
|
-
render = __Ziko__.__Config__.default.render,
|
|
1212
|
-
isInteractive = false,
|
|
1213
|
-
}={}){
|
|
1207
|
+
constructor(){
|
|
1214
1208
|
super();
|
|
1215
|
-
this.init(element, name, type, render, isInteractive);
|
|
1216
1209
|
}
|
|
1217
1210
|
init(element, name, type, render, isInteractive = [true, false][Math.floor(2*Math.random())]){
|
|
1218
1211
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1219
1212
|
if(typeof element === "string") {
|
|
1220
1213
|
switch(type){
|
|
1221
|
-
case "html" :
|
|
1222
|
-
|
|
1214
|
+
case "html" : {
|
|
1215
|
+
element = globalThis?.document?.createElement(element);
|
|
1216
|
+
console.log('1');
|
|
1217
|
+
} break;
|
|
1218
|
+
case "svg" : {
|
|
1219
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1220
|
+
console.log('2');
|
|
1221
|
+
} break;
|
|
1223
1222
|
default : throw Error("Not supported")
|
|
1224
1223
|
}
|
|
1225
1224
|
}
|
|
@@ -1273,7 +1272,7 @@
|
|
|
1273
1272
|
// &&
|
|
1274
1273
|
this.isInteractive()){
|
|
1275
1274
|
// this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
1276
|
-
this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
1275
|
+
// this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
1277
1276
|
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
1278
1277
|
}
|
|
1279
1278
|
globalThis.__Ziko__.__UI__.push(this);
|
|
@@ -1453,49 +1452,11 @@
|
|
|
1453
1452
|
}
|
|
1454
1453
|
}
|
|
1455
1454
|
|
|
1456
|
-
function register_to_instance(target, ...mixins){
|
|
1457
|
-
console.log('register to instance');
|
|
1458
|
-
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1459
|
-
}
|
|
1460
|
-
function _register_to_instance_(instance, mixin) {
|
|
1461
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1462
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1463
|
-
const desc = descriptors[key];
|
|
1464
|
-
if ('get' in desc || 'set' in desc) {
|
|
1465
|
-
Object.defineProperty(instance, key, {
|
|
1466
|
-
...desc,
|
|
1467
|
-
configurable: true // 🔑 make it replaceable
|
|
1468
|
-
});
|
|
1469
|
-
} else if (typeof desc.value === 'function') {
|
|
1470
|
-
Object.defineProperty(instance, key, {
|
|
1471
|
-
value: desc.value.bind(instance),
|
|
1472
|
-
writable: true, // 🔑 allow reassignment
|
|
1473
|
-
configurable: true, // 🔑 allow redefinition
|
|
1474
|
-
enumerable: false
|
|
1475
|
-
});
|
|
1476
|
-
} else {
|
|
1477
|
-
Object.defineProperty(instance, key, {
|
|
1478
|
-
value: desc.value,
|
|
1479
|
-
writable: true,
|
|
1480
|
-
configurable: true,
|
|
1481
|
-
enumerable: true
|
|
1482
|
-
});
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
const register = (target, ...mixins) => {
|
|
1488
|
-
console.log(target);
|
|
1489
|
-
// return register_to_class(target, ...mixins)
|
|
1490
|
-
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1491
|
-
else register_to_instance(target, ...mixins);
|
|
1492
|
-
};
|
|
1493
|
-
|
|
1494
1455
|
if(!globalThis.__Ziko__) __init__global__();
|
|
1495
1456
|
|
|
1496
1457
|
// HMR persistence
|
|
1497
|
-
if (undefined) {
|
|
1498
|
-
undefined.data.__Ziko__ = undefined.data
|
|
1458
|
+
if (undefined?.data) {
|
|
1459
|
+
undefined.data.__Ziko__ = undefined.data?.__Ziko__ || globalThis?.__Ziko__;
|
|
1499
1460
|
globalThis.__Ziko__ = undefined.data.__Ziko__;
|
|
1500
1461
|
// import.meta.hot.accept(n=>console.log(n));
|
|
1501
1462
|
// console.log(import.meta.hot.data.__Ziko__.__State__.store)
|
|
@@ -1618,7 +1579,7 @@
|
|
|
1618
1579
|
return this;
|
|
1619
1580
|
}
|
|
1620
1581
|
function _set_attrs_(name, value){
|
|
1621
|
-
if(this.element
|
|
1582
|
+
if(this.element instanceof globalThis?.SVGAElement) name = is_camelcase$1(name) ? camel2hyphencase$1(name) : name;
|
|
1622
1583
|
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1623
1584
|
if(isStateGetter(value)){
|
|
1624
1585
|
const getter = value();
|
|
@@ -3167,10 +3128,11 @@
|
|
|
3167
3128
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
3168
3129
|
|
|
3169
3130
|
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3170
|
-
constructor({element, name ='', type=
|
|
3171
|
-
super(
|
|
3172
|
-
console.log(
|
|
3173
|
-
|
|
3131
|
+
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
3132
|
+
super();
|
|
3133
|
+
console.log({type});
|
|
3134
|
+
// console.log(this)
|
|
3135
|
+
register_to_class(
|
|
3174
3136
|
this,
|
|
3175
3137
|
AttrsMethods,
|
|
3176
3138
|
DomMethods,
|
|
@@ -3425,7 +3387,6 @@
|
|
|
3425
3387
|
'sub',
|
|
3426
3388
|
'summary',
|
|
3427
3389
|
'sup',
|
|
3428
|
-
'svg',
|
|
3429
3390
|
'table',
|
|
3430
3391
|
'tbody',
|
|
3431
3392
|
'td',
|
|
@@ -3459,6 +3420,9 @@
|
|
|
3459
3420
|
"desc", "title", "metadata", "foreignObject"
|
|
3460
3421
|
];
|
|
3461
3422
|
|
|
3423
|
+
// const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
|
|
3424
|
+
// const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
|
|
3425
|
+
|
|
3462
3426
|
const tags = new Proxy({}, {
|
|
3463
3427
|
get(target, prop) {
|
|
3464
3428
|
if (typeof prop !== 'string') return undefined;
|
|
@@ -3466,16 +3430,22 @@
|
|
|
3466
3430
|
let type ;
|
|
3467
3431
|
if(HTMLTags.includes(tag)) type = 'html';
|
|
3468
3432
|
if(SVGTags.includes(tag)) type = 'svg';
|
|
3433
|
+
console.log(type);
|
|
3469
3434
|
return (...args)=>{
|
|
3470
3435
|
// Fix undefined
|
|
3471
3436
|
// console.log(isStateGetter(args[0]))
|
|
3437
|
+
// console.log(!!args)
|
|
3438
|
+
if(args.length === 0) {
|
|
3439
|
+
console.log('length 0');
|
|
3440
|
+
return new UIElement$1({element : tag, name : tag, type})
|
|
3441
|
+
}
|
|
3472
3442
|
if(
|
|
3473
3443
|
['string', 'number'].includes(typeof args[0])
|
|
3474
3444
|
|| args[0] instanceof UIElement$1
|
|
3475
3445
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3476
3446
|
) return new UIElement$1({element : tag, name : tag, type}).append(...args);
|
|
3477
3447
|
// console.log(args[0])
|
|
3478
|
-
return new UIElement$1({element : tag}).setAttr(args.shift()).append(...args)
|
|
3448
|
+
return new UIElement$1({element : tag, type}).setAttr(args.shift()).append(...args)
|
|
3479
3449
|
}
|
|
3480
3450
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3481
3451
|
// return (...args)=>{
|
|
@@ -3627,6 +3597,68 @@
|
|
|
3627
3597
|
|
|
3628
3598
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3629
3599
|
|
|
3600
|
+
class UIHTMLWrapper extends UIElement$1 {
|
|
3601
|
+
constructor(content){
|
|
3602
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3603
|
+
this.element.append(html2dom(content));
|
|
3604
|
+
this.style({
|
|
3605
|
+
display : 'contents'
|
|
3606
|
+
});
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3610
|
+
function html2dom(htmlString) {
|
|
3611
|
+
if(globalThis?.DOMParser){
|
|
3612
|
+
const parser = new DOMParser();
|
|
3613
|
+
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
3614
|
+
doc.body.firstChild.style.display = "contents";
|
|
3615
|
+
return doc.body.firstChild;
|
|
3616
|
+
}
|
|
3617
|
+
}
|
|
3618
|
+
|
|
3619
|
+
const HTMLWrapper = (content) => new UIHTMLWrapper(content);
|
|
3620
|
+
|
|
3621
|
+
class UISVGWrapper extends UIElement$1 {
|
|
3622
|
+
constructor(content){
|
|
3623
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3624
|
+
this.element.append(svg2dom(content));
|
|
3625
|
+
this.style({
|
|
3626
|
+
display : 'contents'
|
|
3627
|
+
});
|
|
3628
|
+
}
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
function svg2dom(svgString) {
|
|
3632
|
+
if (typeof DOMParser !== "undefined") {
|
|
3633
|
+
const parser = new DOMParser();
|
|
3634
|
+
const doc = parser.parseFromString(svgString.trim(), "image/svg+xml");
|
|
3635
|
+
const svg = doc.documentElement;
|
|
3636
|
+
|
|
3637
|
+
if (svg.nodeName === "parsererror") {
|
|
3638
|
+
throw new Error("Invalid SVG string");
|
|
3639
|
+
}
|
|
3640
|
+
if(svg.hasAttribute('xmlns')) return svg
|
|
3641
|
+
// TO Fix ...
|
|
3642
|
+
const {children, attributes} = svg;
|
|
3643
|
+
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3644
|
+
for(let {name, value} of attributes){
|
|
3645
|
+
element.setAttribute(name, value);
|
|
3646
|
+
}
|
|
3647
|
+
element.append(...children);
|
|
3648
|
+
|
|
3649
|
+
globalThis.svg = svg;
|
|
3650
|
+
globalThis.children = children;
|
|
3651
|
+
globalThis.attributes = attributes;
|
|
3652
|
+
globalThis.element = element;
|
|
3653
|
+
return element;
|
|
3654
|
+
}
|
|
3655
|
+
throw new Error("DOMParser is not available in this environment");
|
|
3656
|
+
}
|
|
3657
|
+
|
|
3658
|
+
|
|
3659
|
+
|
|
3660
|
+
const SVGWrapper = (content) => new UISVGWrapper(content);
|
|
3661
|
+
|
|
3630
3662
|
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3631
3663
|
if (globalThis.customElements?.get(name)) {
|
|
3632
3664
|
console.warn(`Custom element "${name}" is already defined`);
|
|
@@ -5501,11 +5533,12 @@
|
|
|
5501
5533
|
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
5502
5534
|
const parts = normalizedPath.split('/');
|
|
5503
5535
|
const rootParts = root.split('/');
|
|
5504
|
-
const rootIndex = parts.indexOf(rootParts
|
|
5536
|
+
const rootIndex = parts.indexOf(rootParts.at(-1));
|
|
5505
5537
|
if (rootIndex !== -1) {
|
|
5506
5538
|
const subsequentParts = parts.slice(rootIndex + 1);
|
|
5507
|
-
const lastPart =
|
|
5539
|
+
const lastPart = parts.at(-1);
|
|
5508
5540
|
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
5541
|
+
// console.log({extensions, subsequentParts, lastPart, isIndexFile, rootParts, rootIndex, parts})
|
|
5509
5542
|
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
5510
5543
|
if (isIndexFile) {
|
|
5511
5544
|
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
@@ -5878,6 +5911,7 @@
|
|
|
5878
5911
|
exports.Elastic = Elastic;
|
|
5879
5912
|
exports.FileBasedRouting = FileBasedRouting;
|
|
5880
5913
|
exports.Flex = Flex;
|
|
5914
|
+
exports.HTMLWrapper = HTMLWrapper;
|
|
5881
5915
|
exports.InBack = InBack;
|
|
5882
5916
|
exports.InBounce = InBounce;
|
|
5883
5917
|
exports.InCirc = InCirc;
|
|
@@ -5915,6 +5949,7 @@
|
|
|
5915
5949
|
exports.Permutation = Permutation;
|
|
5916
5950
|
exports.Random = Random;
|
|
5917
5951
|
exports.SPA = SPA;
|
|
5952
|
+
exports.SVGWrapper = SVGWrapper;
|
|
5918
5953
|
exports.Scheduler = Scheduler;
|
|
5919
5954
|
exports.Step = Step;
|
|
5920
5955
|
exports.Suspense = Suspense;
|
|
@@ -5923,7 +5958,9 @@
|
|
|
5923
5958
|
exports.TimeLoop = TimeLoop;
|
|
5924
5959
|
exports.TimeScheduler = TimeScheduler;
|
|
5925
5960
|
exports.UIElement = UIElement$1;
|
|
5961
|
+
exports.UIHTMLWrapper = UIHTMLWrapper;
|
|
5926
5962
|
exports.UINode = UINode;
|
|
5963
|
+
exports.UISVGWrapper = UISVGWrapper;
|
|
5927
5964
|
exports.Utils = Utils;
|
|
5928
5965
|
exports.ZikoApp = ZikoApp;
|
|
5929
5966
|
exports.ZikoCustomEvent = ZikoCustomEvent;
|
package/dist/ziko.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Mon Sep 01 2025 13:22:11 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -1198,22 +1198,21 @@ function __init__global__(){
|
|
|
1198
1198
|
|
|
1199
1199
|
__init__global__();
|
|
1200
1200
|
class UIElementCore extends UINode{
|
|
1201
|
-
constructor({
|
|
1202
|
-
element,
|
|
1203
|
-
name ='',
|
|
1204
|
-
type="html",
|
|
1205
|
-
render = __Ziko__.__Config__.default.render,
|
|
1206
|
-
isInteractive = false,
|
|
1207
|
-
}={}){
|
|
1201
|
+
constructor(){
|
|
1208
1202
|
super();
|
|
1209
|
-
this.init(element, name, type, render, isInteractive);
|
|
1210
1203
|
}
|
|
1211
1204
|
init(element, name, type, render, isInteractive = [true, false][Math.floor(2*Math.random())]){
|
|
1212
1205
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
1213
1206
|
if(typeof element === "string") {
|
|
1214
1207
|
switch(type){
|
|
1215
|
-
case "html" :
|
|
1216
|
-
|
|
1208
|
+
case "html" : {
|
|
1209
|
+
element = globalThis?.document?.createElement(element);
|
|
1210
|
+
console.log('1');
|
|
1211
|
+
} break;
|
|
1212
|
+
case "svg" : {
|
|
1213
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
1214
|
+
console.log('2');
|
|
1215
|
+
} break;
|
|
1217
1216
|
default : throw Error("Not supported")
|
|
1218
1217
|
}
|
|
1219
1218
|
}
|
|
@@ -1267,7 +1266,7 @@ class UIElementCore extends UINode{
|
|
|
1267
1266
|
// &&
|
|
1268
1267
|
this.isInteractive()){
|
|
1269
1268
|
// this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
1270
|
-
this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
1269
|
+
// this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
1271
1270
|
globalThis.__Ziko__.__HYDRATION__.register(() => this);
|
|
1272
1271
|
}
|
|
1273
1272
|
globalThis.__Ziko__.__UI__.push(this);
|
|
@@ -1447,49 +1446,11 @@ function _register_to_class_(target, mixin) {
|
|
|
1447
1446
|
}
|
|
1448
1447
|
}
|
|
1449
1448
|
|
|
1450
|
-
function register_to_instance(target, ...mixins){
|
|
1451
|
-
console.log('register to instance');
|
|
1452
|
-
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1453
|
-
}
|
|
1454
|
-
function _register_to_instance_(instance, mixin) {
|
|
1455
|
-
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1456
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1457
|
-
const desc = descriptors[key];
|
|
1458
|
-
if ('get' in desc || 'set' in desc) {
|
|
1459
|
-
Object.defineProperty(instance, key, {
|
|
1460
|
-
...desc,
|
|
1461
|
-
configurable: true // 🔑 make it replaceable
|
|
1462
|
-
});
|
|
1463
|
-
} else if (typeof desc.value === 'function') {
|
|
1464
|
-
Object.defineProperty(instance, key, {
|
|
1465
|
-
value: desc.value.bind(instance),
|
|
1466
|
-
writable: true, // 🔑 allow reassignment
|
|
1467
|
-
configurable: true, // 🔑 allow redefinition
|
|
1468
|
-
enumerable: false
|
|
1469
|
-
});
|
|
1470
|
-
} else {
|
|
1471
|
-
Object.defineProperty(instance, key, {
|
|
1472
|
-
value: desc.value,
|
|
1473
|
-
writable: true,
|
|
1474
|
-
configurable: true,
|
|
1475
|
-
enumerable: true
|
|
1476
|
-
});
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
const register = (target, ...mixins) => {
|
|
1482
|
-
console.log(target);
|
|
1483
|
-
// return register_to_class(target, ...mixins)
|
|
1484
|
-
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1485
|
-
else register_to_instance(target, ...mixins);
|
|
1486
|
-
};
|
|
1487
|
-
|
|
1488
1449
|
if(!globalThis.__Ziko__) __init__global__();
|
|
1489
1450
|
|
|
1490
1451
|
// HMR persistence
|
|
1491
|
-
if (import.meta.hot) {
|
|
1492
|
-
import.meta.hot.data.__Ziko__ = import.meta.hot.data
|
|
1452
|
+
if (import.meta.hot?.data) {
|
|
1453
|
+
import.meta.hot.data.__Ziko__ = import.meta.hot.data?.__Ziko__ || globalThis?.__Ziko__;
|
|
1493
1454
|
globalThis.__Ziko__ = import.meta.hot.data.__Ziko__;
|
|
1494
1455
|
// import.meta.hot.accept(n=>console.log(n));
|
|
1495
1456
|
// console.log(import.meta.hot.data.__Ziko__.__State__.store)
|
|
@@ -1612,7 +1573,7 @@ async function __addItem__(adder, pusher, ...ele) {
|
|
|
1612
1573
|
return this;
|
|
1613
1574
|
}
|
|
1614
1575
|
function _set_attrs_(name, value){
|
|
1615
|
-
if(this.element
|
|
1576
|
+
if(this.element instanceof globalThis?.SVGAElement) name = is_camelcase$1(name) ? camel2hyphencase$1(name) : name;
|
|
1616
1577
|
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1617
1578
|
if(isStateGetter(value)){
|
|
1618
1579
|
const getter = value();
|
|
@@ -3161,10 +3122,11 @@ class ZikoUseMediaQuery {
|
|
|
3161
3122
|
const useMediaQuery = (mediaQueryRules,fallback) => new ZikoUseMediaQuery(mediaQueryRules,fallback);
|
|
3162
3123
|
|
|
3163
3124
|
let UIElement$1 = class UIElement extends UIElementCore{
|
|
3164
|
-
constructor({element, name ='', type=
|
|
3165
|
-
super(
|
|
3166
|
-
console.log(
|
|
3167
|
-
|
|
3125
|
+
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
3126
|
+
super();
|
|
3127
|
+
console.log({type});
|
|
3128
|
+
// console.log(this)
|
|
3129
|
+
register_to_class(
|
|
3168
3130
|
this,
|
|
3169
3131
|
AttrsMethods,
|
|
3170
3132
|
DomMethods,
|
|
@@ -3419,7 +3381,6 @@ const HTMLTags = [
|
|
|
3419
3381
|
'sub',
|
|
3420
3382
|
'summary',
|
|
3421
3383
|
'sup',
|
|
3422
|
-
'svg',
|
|
3423
3384
|
'table',
|
|
3424
3385
|
'tbody',
|
|
3425
3386
|
'td',
|
|
@@ -3453,6 +3414,9 @@ const SVGTags = [
|
|
|
3453
3414
|
"desc", "title", "metadata", "foreignObject"
|
|
3454
3415
|
];
|
|
3455
3416
|
|
|
3417
|
+
// const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
|
|
3418
|
+
// const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
|
|
3419
|
+
|
|
3456
3420
|
const tags = new Proxy({}, {
|
|
3457
3421
|
get(target, prop) {
|
|
3458
3422
|
if (typeof prop !== 'string') return undefined;
|
|
@@ -3460,16 +3424,22 @@ const tags = new Proxy({}, {
|
|
|
3460
3424
|
let type ;
|
|
3461
3425
|
if(HTMLTags.includes(tag)) type = 'html';
|
|
3462
3426
|
if(SVGTags.includes(tag)) type = 'svg';
|
|
3427
|
+
console.log(type);
|
|
3463
3428
|
return (...args)=>{
|
|
3464
3429
|
// Fix undefined
|
|
3465
3430
|
// console.log(isStateGetter(args[0]))
|
|
3431
|
+
// console.log(!!args)
|
|
3432
|
+
if(args.length === 0) {
|
|
3433
|
+
console.log('length 0');
|
|
3434
|
+
return new UIElement$1({element : tag, name : tag, type})
|
|
3435
|
+
}
|
|
3466
3436
|
if(
|
|
3467
3437
|
['string', 'number'].includes(typeof args[0])
|
|
3468
3438
|
|| args[0] instanceof UIElement$1
|
|
3469
3439
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3470
3440
|
) return new UIElement$1({element : tag, name : tag, type}).append(...args);
|
|
3471
3441
|
// console.log(args[0])
|
|
3472
|
-
return new UIElement$1({element : tag}).setAttr(args.shift()).append(...args)
|
|
3442
|
+
return new UIElement$1({element : tag, type}).setAttr(args.shift()).append(...args)
|
|
3473
3443
|
}
|
|
3474
3444
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3475
3445
|
// return (...args)=>{
|
|
@@ -3621,6 +3591,68 @@ class ZikoUISuspense extends UIElement{
|
|
|
3621
3591
|
|
|
3622
3592
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3623
3593
|
|
|
3594
|
+
class UIHTMLWrapper extends UIElement$1 {
|
|
3595
|
+
constructor(content){
|
|
3596
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3597
|
+
this.element.append(html2dom(content));
|
|
3598
|
+
this.style({
|
|
3599
|
+
display : 'contents'
|
|
3600
|
+
});
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
function html2dom(htmlString) {
|
|
3605
|
+
if(globalThis?.DOMParser){
|
|
3606
|
+
const parser = new DOMParser();
|
|
3607
|
+
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
3608
|
+
doc.body.firstChild.style.display = "contents";
|
|
3609
|
+
return doc.body.firstChild;
|
|
3610
|
+
}
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
const HTMLWrapper = (content) => new UIHTMLWrapper(content);
|
|
3614
|
+
|
|
3615
|
+
class UISVGWrapper extends UIElement$1 {
|
|
3616
|
+
constructor(content){
|
|
3617
|
+
super({element : 'div', name : 'html_wrappper'});
|
|
3618
|
+
this.element.append(svg2dom(content));
|
|
3619
|
+
this.style({
|
|
3620
|
+
display : 'contents'
|
|
3621
|
+
});
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
|
|
3625
|
+
function svg2dom(svgString) {
|
|
3626
|
+
if (typeof DOMParser !== "undefined") {
|
|
3627
|
+
const parser = new DOMParser();
|
|
3628
|
+
const doc = parser.parseFromString(svgString.trim(), "image/svg+xml");
|
|
3629
|
+
const svg = doc.documentElement;
|
|
3630
|
+
|
|
3631
|
+
if (svg.nodeName === "parsererror") {
|
|
3632
|
+
throw new Error("Invalid SVG string");
|
|
3633
|
+
}
|
|
3634
|
+
if(svg.hasAttribute('xmlns')) return svg
|
|
3635
|
+
// TO Fix ...
|
|
3636
|
+
const {children, attributes} = svg;
|
|
3637
|
+
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3638
|
+
for(let {name, value} of attributes){
|
|
3639
|
+
element.setAttribute(name, value);
|
|
3640
|
+
}
|
|
3641
|
+
element.append(...children);
|
|
3642
|
+
|
|
3643
|
+
globalThis.svg = svg;
|
|
3644
|
+
globalThis.children = children;
|
|
3645
|
+
globalThis.attributes = attributes;
|
|
3646
|
+
globalThis.element = element;
|
|
3647
|
+
return element;
|
|
3648
|
+
}
|
|
3649
|
+
throw new Error("DOMParser is not available in this environment");
|
|
3650
|
+
}
|
|
3651
|
+
|
|
3652
|
+
|
|
3653
|
+
|
|
3654
|
+
const SVGWrapper = (content) => new UISVGWrapper(content);
|
|
3655
|
+
|
|
3624
3656
|
function define_wc(name, UIElement, props = {}, { mode = 'open'} = {}) {
|
|
3625
3657
|
if (globalThis.customElements?.get(name)) {
|
|
3626
3658
|
console.warn(`Custom element "${name}" is already defined`);
|
|
@@ -5495,11 +5527,12 @@ function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts'])
|
|
|
5495
5527
|
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
5496
5528
|
const parts = normalizedPath.split('/');
|
|
5497
5529
|
const rootParts = root.split('/');
|
|
5498
|
-
const rootIndex = parts.indexOf(rootParts
|
|
5530
|
+
const rootIndex = parts.indexOf(rootParts.at(-1));
|
|
5499
5531
|
if (rootIndex !== -1) {
|
|
5500
5532
|
const subsequentParts = parts.slice(rootIndex + 1);
|
|
5501
|
-
const lastPart =
|
|
5533
|
+
const lastPart = parts.at(-1);
|
|
5502
5534
|
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
5535
|
+
// console.log({extensions, subsequentParts, lastPart, isIndexFile, rootParts, rootIndex, parts})
|
|
5503
5536
|
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
5504
5537
|
if (isIndexFile) {
|
|
5505
5538
|
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
@@ -5859,4 +5892,4 @@ if(globalThis?.document){
|
|
|
5859
5892
|
document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
|
|
5860
5893
|
}
|
|
5861
5894
|
|
|
5862
|
-
export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, Scheduler, Step, Suspense, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UINode, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
|
|
5895
|
+
export { App, Arc, Back, Base, Clock, Combinaison, Complex, Discret, E, EPSILON, Elastic, FileBasedRouting, Flex, HTMLWrapper, InBack, InBounce, InCirc, InCubic, InElastic, InExpo, InOutBack, InOutBounce, InOutCirc, InOutCubic, InOutElastic, InOutExpo, InOutQuad, InOutQuart, InOutQuint, InOutSin, InQuad, InQuart, InQuint, InSin, Linear, Logic$1 as Logic, Matrix, OutBack, OutBounce, OutCirc, OutCubic, OutElastic, OutExpo, OutQuad, OutQuart, OutQuint, OutSin, PI$2 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Step, Suspense, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, Utils, ZikoApp, ZikoCustomEvent, ZikoEventClick, ZikoEventClipboard, ZikoEventCustom, ZikoEventDrag, ZikoEventFocus, ZikoEventInput, ZikoEventKey, ZikoEventMouse, ZikoEventPointer, ZikoEventSwipe, ZikoEventTouch, ZikoEventWheel, ZikoHead, ZikoMutationObserver, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, ZikoUseRoot, __ZikoEvent__, abs, accum, acos$1 as acos, acosh, acot, add, animation, arange, arr2str, asin, asinh, atan, atan2, atanh, bindCustomEvent, bindHashEvent, bindTouchEvent, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_wheel_event, cartesianProduct, ceil, clamp, clock, combinaison, complex, cos$2 as cos, cosh$1 as cosh, cot, coth, csc, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, div, e, fact, floor, geomspace, getEvent, hypot, inRange, isApproximatlyEqual, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linspace, ln, logspace, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, min, modulo, mul, norm, nums, obj2str, ones, pgcd, pow$1 as pow, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$2 as sin, sinc, sinh$1 as sinh, sleep, sqrt$2 as sqrt, sqrtn, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, useChannel, useCustomEvent, useDerived, useEventEmitter, useFavIcon, useHashEvent, useHead, useInputEvent, useLocaleStorage, useMediaQuery, useMeta, useReactive, useRoot, useSessionStorage, useState, useSuccesifKeys, useSwipeEvent, useThread, useTitle, wait, waitForUIElm, waitForUIElmSync, watch, watchAttr, watchChildren, watchIntersection, watchScreen, watchSize, zeros };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.2",
|
|
4
4
|
"description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"front-end",
|
|
@@ -24,11 +24,12 @@ function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts'])
|
|
|
24
24
|
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
25
25
|
const parts = normalizedPath.split('/');
|
|
26
26
|
const rootParts = root.split('/');
|
|
27
|
-
const rootIndex = parts.indexOf(rootParts
|
|
27
|
+
const rootIndex = parts.indexOf(rootParts.at(-1));
|
|
28
28
|
if (rootIndex !== -1) {
|
|
29
29
|
const subsequentParts = parts.slice(rootIndex + 1);
|
|
30
|
-
const lastPart =
|
|
30
|
+
const lastPart = parts.at(-1);
|
|
31
31
|
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
32
|
+
// console.log({extensions, subsequentParts, lastPart, isIndexFile, rootParts, rootIndex, parts})
|
|
32
33
|
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
33
34
|
if (isIndexFile) {
|
|
34
35
|
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
package/src/hooks/use-state.js
CHANGED
|
@@ -2,8 +2,8 @@ import { __init__global__ } from "../__ziko__/index.js";
|
|
|
2
2
|
if(!globalThis.__Ziko__) __init__global__()
|
|
3
3
|
|
|
4
4
|
// HMR persistence
|
|
5
|
-
if (import.meta.hot) {
|
|
6
|
-
import.meta.hot.data.__Ziko__ = import.meta.hot.data
|
|
5
|
+
if (import.meta.hot?.data) {
|
|
6
|
+
import.meta.hot.data.__Ziko__ = import.meta.hot.data?.__Ziko__ || globalThis?.__Ziko__;
|
|
7
7
|
globalThis.__Ziko__ = import.meta.hot.data.__Ziko__;
|
|
8
8
|
// import.meta.hot.accept(n=>console.log(n));
|
|
9
9
|
// console.log(import.meta.hot.data.__Ziko__.__State__.store)
|
|
@@ -50,7 +50,7 @@ export async function __addItem__(adder, pusher, ...ele) {
|
|
|
50
50
|
return this;
|
|
51
51
|
}
|
|
52
52
|
export function _set_attrs_(name, value){
|
|
53
|
-
if(this.element
|
|
53
|
+
if(this.element instanceof globalThis?.SVGAElement) name = is_camelcase(name) ? camel2hyphencase(name) : name;
|
|
54
54
|
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
55
55
|
if(isStateGetter(value)){
|
|
56
56
|
const getter = value()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UIElementCore } from "./UIElementCore.js";
|
|
2
|
-
import {
|
|
2
|
+
import { register_to_class } from "../../__helpers__/register/register-to-class.js";
|
|
3
3
|
import {
|
|
4
4
|
AttrsMethods,
|
|
5
5
|
DomMethods,
|
|
@@ -16,10 +16,11 @@ import {
|
|
|
16
16
|
watchChildren
|
|
17
17
|
} from "../../reactivity/index.js"
|
|
18
18
|
class UIElement extends UIElementCore{
|
|
19
|
-
constructor({element, name ='', type=
|
|
20
|
-
super(
|
|
21
|
-
console.log(
|
|
22
|
-
|
|
19
|
+
constructor({element, name ='', type='html', render = __Ziko__.__Config__.default.render}={}){
|
|
20
|
+
super()
|
|
21
|
+
console.log({type})
|
|
22
|
+
// console.log(this)
|
|
23
|
+
register_to_class(
|
|
23
24
|
this,
|
|
24
25
|
AttrsMethods,
|
|
25
26
|
DomMethods,
|
|
@@ -2,22 +2,21 @@ import {UINode} from "./UINode.js";
|
|
|
2
2
|
import {__init__global__, UIStore} from '../../__ziko__/index.js';
|
|
3
3
|
__init__global__()
|
|
4
4
|
class UIElementCore extends UINode{
|
|
5
|
-
constructor({
|
|
6
|
-
element,
|
|
7
|
-
name ='',
|
|
8
|
-
type="html",
|
|
9
|
-
render = __Ziko__.__Config__.default.render,
|
|
10
|
-
isInteractive = false,
|
|
11
|
-
}={}){
|
|
5
|
+
constructor(){
|
|
12
6
|
super()
|
|
13
|
-
this.init(element, name, type, render, isInteractive)
|
|
14
7
|
}
|
|
15
8
|
init(element, name, type, render, isInteractive = [true, false][Math.floor(2*Math.random())]){
|
|
16
9
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
17
10
|
if(typeof element === "string") {
|
|
18
11
|
switch(type){
|
|
19
|
-
case "html" :
|
|
20
|
-
|
|
12
|
+
case "html" : {
|
|
13
|
+
element = globalThis?.document?.createElement(element);
|
|
14
|
+
console.log('1')
|
|
15
|
+
}; break;
|
|
16
|
+
case "svg" : {
|
|
17
|
+
element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
18
|
+
console.log('2')
|
|
19
|
+
}; break;
|
|
21
20
|
default : throw Error("Not supported")
|
|
22
21
|
}
|
|
23
22
|
}
|
|
@@ -71,7 +70,7 @@ class UIElementCore extends UINode{
|
|
|
71
70
|
// &&
|
|
72
71
|
this.isInteractive()){
|
|
73
72
|
// this.setAttr("ziko-hydration-index", globalThis.__Ziko__.__HYDRATION__.index);
|
|
74
|
-
this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
73
|
+
// this.element.setAttribute('ziko-hydration-index', globalThis.__Ziko__.__HYDRATION__.index)
|
|
75
74
|
globalThis.__Ziko__.__HYDRATION__.register(() => this)
|
|
76
75
|
}
|
|
77
76
|
globalThis.__Ziko__.__UI__.push(this)
|
package/src/ui/index.js
CHANGED
|
@@ -5,6 +5,6 @@ export * from './text/index.js';
|
|
|
5
5
|
export * from './flex/index.js';
|
|
6
6
|
// export * from './grid/index.js';
|
|
7
7
|
export * from './suspense/index.js';
|
|
8
|
-
|
|
8
|
+
export * from './wrappers/index.js';
|
|
9
9
|
// export * from './graphics/index.js'
|
|
10
10
|
export * from './web-component/index.js'
|
package/src/ui/tags/index.js
CHANGED
|
@@ -9,8 +9,8 @@ const _h=(tag, type, attributes, ...children)=>{
|
|
|
9
9
|
children && element.append(...children);
|
|
10
10
|
return element;
|
|
11
11
|
}
|
|
12
|
-
const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
|
|
13
|
-
const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
|
|
12
|
+
// const h=(tag, attributes = {}, ...children)=> _h(tag, "html", attributes, ...children);
|
|
13
|
+
// const s=(tag, attributes = {}, ...children)=> _h(tag, "svg", attributes, ...children);
|
|
14
14
|
|
|
15
15
|
const tags = new Proxy({}, {
|
|
16
16
|
get(target, prop) {
|
|
@@ -19,16 +19,22 @@ const tags = new Proxy({}, {
|
|
|
19
19
|
let type ;
|
|
20
20
|
if(HTMLTags.includes(tag)) type = 'html'
|
|
21
21
|
if(SVGTags.includes(tag)) type = 'svg'
|
|
22
|
+
console.log(type)
|
|
22
23
|
return (...args)=>{
|
|
23
24
|
// Fix undefined
|
|
24
25
|
// console.log(isStateGetter(args[0]))
|
|
26
|
+
// console.log(!!args)
|
|
27
|
+
if(args.length === 0) {
|
|
28
|
+
console.log('length 0')
|
|
29
|
+
return new UIElement({element : tag, name : tag, type})
|
|
30
|
+
}
|
|
25
31
|
if(
|
|
26
32
|
['string', 'number'].includes(typeof args[0])
|
|
27
33
|
|| args[0] instanceof UIElement
|
|
28
34
|
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
29
35
|
) return new UIElement({element : tag, name : tag, type}).append(...args);
|
|
30
36
|
// console.log(args[0])
|
|
31
|
-
return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
|
|
37
|
+
return new UIElement({element : tag, type}).setAttr(args.shift()).append(...args)
|
|
32
38
|
}
|
|
33
39
|
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
34
40
|
// return (...args)=>{
|
package/src/ui/tags/tags-list.js
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { UIElement } from "../../constructors/UIElement.js";
|
|
2
|
+
|
|
3
|
+
class UIHTMLWrapper extends UIElement {
|
|
4
|
+
constructor(content){
|
|
5
|
+
super({element : 'div', name : 'html_wrappper'})
|
|
6
|
+
this.element.append(html2dom(content))
|
|
7
|
+
this.style({
|
|
8
|
+
display : 'contents'
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function html2dom(htmlString) {
|
|
14
|
+
if(globalThis?.DOMParser){
|
|
15
|
+
const parser = new DOMParser();
|
|
16
|
+
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
17
|
+
doc.body.firstChild.style.display = "contents"
|
|
18
|
+
return doc.body.firstChild;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const HTMLWrapper = (content) => new UIHTMLWrapper(content)
|
|
23
|
+
export{
|
|
24
|
+
UIHTMLWrapper,
|
|
25
|
+
HTMLWrapper
|
|
26
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { UIElement } from "../../constructors/UIElement.js";
|
|
2
|
+
|
|
3
|
+
class UISVGWrapper extends UIElement {
|
|
4
|
+
constructor(content){
|
|
5
|
+
super({element : 'div', name : 'html_wrappper'})
|
|
6
|
+
this.element.append(svg2dom(content));
|
|
7
|
+
this.style({
|
|
8
|
+
display : 'contents'
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function svg2dom(svgString) {
|
|
14
|
+
if (typeof DOMParser !== "undefined") {
|
|
15
|
+
const parser = new DOMParser();
|
|
16
|
+
const doc = parser.parseFromString(svgString.trim(), "image/svg+xml");
|
|
17
|
+
const svg = doc.documentElement;
|
|
18
|
+
|
|
19
|
+
if (svg.nodeName === "parsererror") {
|
|
20
|
+
throw new Error("Invalid SVG string");
|
|
21
|
+
}
|
|
22
|
+
if(svg.hasAttribute('xmlns')) return svg
|
|
23
|
+
// TO Fix ...
|
|
24
|
+
const {children, attributes} = svg;
|
|
25
|
+
const element = document.createElementNS("http://www.w3.org/2000/svg", "svg")
|
|
26
|
+
for(let {name, value} of attributes){
|
|
27
|
+
element.setAttribute(name, value)
|
|
28
|
+
}
|
|
29
|
+
element.append(...children)
|
|
30
|
+
|
|
31
|
+
globalThis.svg = svg
|
|
32
|
+
globalThis.children = children
|
|
33
|
+
globalThis.attributes = attributes
|
|
34
|
+
globalThis.element = element
|
|
35
|
+
return element;
|
|
36
|
+
}
|
|
37
|
+
throw new Error("DOMParser is not available in this environment");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
const SVGWrapper = (content) => new UISVGWrapper(content)
|
|
43
|
+
export{
|
|
44
|
+
UISVGWrapper,
|
|
45
|
+
SVGWrapper
|
|
46
|
+
}
|
package/src/ui/wrapper/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {UIElement} from "../constructors/UIElement.js";
|
|
2
|
-
class ZikoUIXMLWrapper extends UIElement{
|
|
3
|
-
constructor(XMLContent, type){
|
|
4
|
-
super({element : "div", name : ""})
|
|
5
|
-
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent))
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
function html2dom(htmlString) {
|
|
9
|
-
if(globalThis?.DOMParser){
|
|
10
|
-
const parser = new DOMParser();
|
|
11
|
-
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
12
|
-
doc.body.firstChild.style.display = "contents"
|
|
13
|
-
return doc.body.firstChild;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function svg2dom(svgString) {
|
|
17
|
-
if(globalThis?.DOMParser){
|
|
18
|
-
const parser = new DOMParser();
|
|
19
|
-
const doc = parser.parseFromString(svgString.replace(/\s+/g, ' ').trim(), 'image/svg+xml');
|
|
20
|
-
return doc.documentElement; // SVG elements are usually at the root
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
24
|
-
constructor(HTMLContent){
|
|
25
|
-
super(HTMLContent, "html")
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
29
|
-
constructor(SVGContent){
|
|
30
|
-
super(SVGContent, "svg")
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
34
|
-
const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
|
|
35
|
-
|
|
36
|
-
export{
|
|
37
|
-
ZikoUIXMLWrapper,
|
|
38
|
-
ZikoUIHTMLWrapper,
|
|
39
|
-
ZikoUISVGWrapper,
|
|
40
|
-
HTMLWrapper,
|
|
41
|
-
SVGWrapper
|
|
42
|
-
}
|