ziko 0.45.1 → 0.45.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.cjs +647 -696
- package/dist/ziko.js +98 -61
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +95 -62
- package/package.json +1 -1
- package/src/app/spa-file-based-routing.js +3 -2
- package/src/hooks/use-state.js +2 -2
- package/src/ui/__methods__/utils/index.js +1 -1
- package/src/ui/constructors/UIElement.js +6 -5
- package/src/ui/constructors/UIElementCore.js +10 -11
- package/src/ui/index.js +1 -1
- package/src/ui/logic/switch/index.js +28 -0
- package/src/ui/tags/index.js +9 -3
- package/src/ui/tags/tags-list.js +0 -1
- package/src/ui/wrappers/html/index.js +26 -0
- package/src/ui/wrappers/index.js +2 -0
- package/src/ui/wrappers/svg/index.js +46 -0
- package/src/ui/wrapper/index.js +0 -42
package/dist/ziko.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Project: ziko.js
|
|
4
4
|
Author: Zakaria Elalaoui
|
|
5
|
-
Date :
|
|
5
|
+
Date : Wed Sep 03 2025 15:22:46 GMT+0100 (UTC+01:00)
|
|
6
6
|
Git-Repo : https://github.com/zakarialaoui10/ziko.js
|
|
7
7
|
Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
|
|
8
8
|
Released under MIT License
|
|
@@ -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;
|