ziko 0.0.15 → 0.0.17
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 +111 -17
- package/dist/ziko.js +116 -18
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +109 -19
- package/package.json +2 -2
- package/src/app/index.js +3 -2
- package/src/app/params.js +5 -5
- package/src/app/spa-file-based-routing.js +74 -0
- package/src/app/spa.js +1 -2
- package/src/app/ziko-app.js +2 -2
- package/src/index.js +2 -1
- package/src/ui/elements/primitives/misc/index.js +1 -0
- package/src/ui/elements/primitives/misc/xml-wrapper.js +37 -0
- package/src/ui/index.js +10 -1
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 : Sun Oct 13 2024 15:43:24 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
|
|
@@ -3881,7 +3881,7 @@ class ZikoHead{
|
|
|
3881
3881
|
}
|
|
3882
3882
|
}
|
|
3883
3883
|
|
|
3884
|
-
const useHead
|
|
3884
|
+
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
3885
3885
|
|
|
3886
3886
|
const LightThemes={
|
|
3887
3887
|
cozyCottonCandy: {
|
|
@@ -5798,7 +5798,7 @@ const Hooks={
|
|
|
5798
5798
|
useTitle,
|
|
5799
5799
|
useFavIcon,
|
|
5800
5800
|
useMeta,
|
|
5801
|
-
useHead
|
|
5801
|
+
useHead,
|
|
5802
5802
|
useThrottle,
|
|
5803
5803
|
useDebounce,
|
|
5804
5804
|
useLocaleStorage,
|
|
@@ -7062,6 +7062,35 @@ class ZikoUIInputDateTime extends ZikoUIInput {
|
|
|
7062
7062
|
}
|
|
7063
7063
|
const inputDateTime = () => new ZikoUIInputDateTime();
|
|
7064
7064
|
|
|
7065
|
+
class ZikoUIXMLWrapper extends ZikoUIElement$1{
|
|
7066
|
+
constructor(XMLContent, type){
|
|
7067
|
+
super("div", "");
|
|
7068
|
+
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
|
|
7069
|
+
}
|
|
7070
|
+
}
|
|
7071
|
+
function html2dom(htmlString) {
|
|
7072
|
+
const parser = new DOMParser();
|
|
7073
|
+
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
7074
|
+
return doc.body.firstChild;
|
|
7075
|
+
}
|
|
7076
|
+
function svg2dom(svgString) {
|
|
7077
|
+
const parser = new DOMParser();
|
|
7078
|
+
const doc = parser.parseFromString(svgString, 'image/svg+xml');
|
|
7079
|
+
return doc.documentElement; // SVG elements are usually at the root
|
|
7080
|
+
}
|
|
7081
|
+
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
7082
|
+
constructor(HTMLContent){
|
|
7083
|
+
super(HTMLContent, "html");
|
|
7084
|
+
}
|
|
7085
|
+
}
|
|
7086
|
+
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
7087
|
+
constructor(SVGContent){
|
|
7088
|
+
super(SVGContent, "svg");
|
|
7089
|
+
}
|
|
7090
|
+
}
|
|
7091
|
+
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
7092
|
+
const SVGWrapper = (SVGContent) => new ZikoUIHTMLWrapper(SVGContent);
|
|
7093
|
+
|
|
7065
7094
|
class ZikoUIHtmlTag extends ZikoUIContainerElement {
|
|
7066
7095
|
constructor(element) {
|
|
7067
7096
|
super(element,"html");
|
|
@@ -7150,10 +7179,15 @@ class ZikoUIBr extends ZikoUIElement$1 {
|
|
|
7150
7179
|
|
|
7151
7180
|
var Misc = /*#__PURE__*/Object.freeze({
|
|
7152
7181
|
__proto__: null,
|
|
7182
|
+
HTMLWrapper: HTMLWrapper,
|
|
7183
|
+
SVGWrapper: SVGWrapper,
|
|
7153
7184
|
ZikoUIBr: ZikoUIBr,
|
|
7185
|
+
ZikoUIHTMLWrapper: ZikoUIHTMLWrapper,
|
|
7154
7186
|
ZikoUIHr: ZikoUIHr,
|
|
7155
7187
|
ZikoUIHtmlTag: ZikoUIHtmlTag,
|
|
7156
7188
|
ZikoUILink: ZikoUILink,
|
|
7189
|
+
ZikoUISVGWrapper: ZikoUISVGWrapper,
|
|
7190
|
+
ZikoUIXMLWrapper: ZikoUIXMLWrapper,
|
|
7157
7191
|
br: br,
|
|
7158
7192
|
brs: brs,
|
|
7159
7193
|
btn: btn,
|
|
@@ -13277,7 +13311,7 @@ class ZikoApp {
|
|
|
13277
13311
|
this.head && this.setHead(this.head);
|
|
13278
13312
|
this.wrapper && this.setWrapper(this.wrapper);
|
|
13279
13313
|
this.target && this.setTarget(this.target);
|
|
13280
|
-
this.wrapper.render(this.target);
|
|
13314
|
+
if(this.wrapper && this.target)this.wrapper.render(this.target);
|
|
13281
13315
|
}
|
|
13282
13316
|
setTarget(target){
|
|
13283
13317
|
if(target instanceof HTMLElement) this.target = target;
|
|
@@ -13420,8 +13454,6 @@ function isDynamic(path) {
|
|
|
13420
13454
|
class ZikoSPA extends ZikoApp{
|
|
13421
13455
|
constructor({head, wrapper, target, routes}){
|
|
13422
13456
|
super({head, wrapper, target});
|
|
13423
|
-
// this.wrapper=wrapper;
|
|
13424
|
-
console.log(target);
|
|
13425
13457
|
this.routes=new Map([
|
|
13426
13458
|
["404",text$1("Error 404")],
|
|
13427
13459
|
...Object.entries(routes)
|
|
@@ -13448,6 +13480,7 @@ class ZikoSPA extends ZikoApp{
|
|
|
13448
13480
|
if(typeof callback === "function") element = callback();
|
|
13449
13481
|
}
|
|
13450
13482
|
if(element?.isZikoUIElement) element.render(this.wrapper);
|
|
13483
|
+
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
13451
13484
|
if(element instanceof Promise){
|
|
13452
13485
|
element.then(e=>e.render(this.wrapper));
|
|
13453
13486
|
}
|
|
@@ -13472,7 +13505,7 @@ var Spa = /*#__PURE__*/Object.freeze({
|
|
|
13472
13505
|
ZikoSPA: ZikoSPA
|
|
13473
13506
|
});
|
|
13474
13507
|
|
|
13475
|
-
function
|
|
13508
|
+
function parseQueryParams(queryString) {
|
|
13476
13509
|
const params = {};
|
|
13477
13510
|
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
13478
13511
|
const [key, value] = match.split('=');
|
|
@@ -13481,19 +13514,19 @@ function parseParams(queryString) {
|
|
|
13481
13514
|
return params;
|
|
13482
13515
|
}
|
|
13483
13516
|
|
|
13484
|
-
function defineParamsGetter(target
|
|
13517
|
+
function defineParamsGetter(target ){
|
|
13485
13518
|
Object.defineProperties(target, {
|
|
13486
13519
|
'QueryParams': {
|
|
13487
13520
|
get: function() {
|
|
13488
|
-
return
|
|
13521
|
+
return parseQueryParams(globalThis.location.search.substring(1));
|
|
13489
13522
|
},
|
|
13490
13523
|
configurable: false,
|
|
13491
13524
|
enumerable: true
|
|
13492
13525
|
},
|
|
13493
13526
|
'HashParams': {
|
|
13494
13527
|
get: function() {
|
|
13495
|
-
const hash =
|
|
13496
|
-
return
|
|
13528
|
+
const hash = globalThis.location.hash.substring(1);
|
|
13529
|
+
return hash.split("#");
|
|
13497
13530
|
},
|
|
13498
13531
|
configurable: false,
|
|
13499
13532
|
enumerable: true
|
|
@@ -13501,11 +13534,6 @@ function defineParamsGetter(target = globalThis){
|
|
|
13501
13534
|
});
|
|
13502
13535
|
}
|
|
13503
13536
|
|
|
13504
|
-
var Params = /*#__PURE__*/Object.freeze({
|
|
13505
|
-
__proto__: null,
|
|
13506
|
-
defineParamsGetter: defineParamsGetter
|
|
13507
|
-
});
|
|
13508
|
-
|
|
13509
13537
|
const __UI__={};
|
|
13510
13538
|
const __Config__={
|
|
13511
13539
|
default:{
|
|
@@ -13529,12 +13557,71 @@ var Global = /*#__PURE__*/Object.freeze({
|
|
|
13529
13557
|
__UI__: __UI__
|
|
13530
13558
|
});
|
|
13531
13559
|
|
|
13560
|
+
// import.meta.glob('./src/pages/**/*.js')
|
|
13561
|
+
async function FileBasedRouting(pages /* use import.meta.glob */){
|
|
13562
|
+
const routes = Object.keys(pages);
|
|
13563
|
+
const root = findCommonPath(routes);
|
|
13564
|
+
// console.log({root})
|
|
13565
|
+
const pairs = {};
|
|
13566
|
+
for(let i=0; i<routes.length; i++){
|
|
13567
|
+
const module = await pages[routes[i]]();
|
|
13568
|
+
const component = await module.default;
|
|
13569
|
+
Object.assign(pairs,{[customPath(routes[i], root)]:component});
|
|
13570
|
+
}
|
|
13571
|
+
return SPA({
|
|
13572
|
+
target : document.body,
|
|
13573
|
+
routes : {
|
|
13574
|
+
"/" : ()=>{},
|
|
13575
|
+
...pairs
|
|
13576
|
+
},
|
|
13577
|
+
wrapper : Section()
|
|
13578
|
+
})
|
|
13579
|
+
}
|
|
13580
|
+
function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts']) {
|
|
13581
|
+
if(root.at(-1)==="/") root = root.slice(0, -1);
|
|
13582
|
+
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
13583
|
+
const parts = normalizedPath.split('/');
|
|
13584
|
+
const rootParts = root.split('/');
|
|
13585
|
+
const rootIndex = parts.indexOf(rootParts[rootParts.length - 1]);
|
|
13586
|
+
if (rootIndex !== -1) {
|
|
13587
|
+
const subsequentParts = parts.slice(rootIndex + 1);
|
|
13588
|
+
const lastPart = subsequentParts[subsequentParts.length - 1];
|
|
13589
|
+
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
13590
|
+
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
13591
|
+
if (isIndexFile) {
|
|
13592
|
+
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
13593
|
+
}
|
|
13594
|
+
if (hasValidExtension) {
|
|
13595
|
+
return '/' + subsequentParts.join('/').replace(/\.(js|ts)$/, '');
|
|
13596
|
+
}
|
|
13597
|
+
}
|
|
13598
|
+
return '';
|
|
13599
|
+
}
|
|
13600
|
+
function findCommonPath(paths) {
|
|
13601
|
+
if (paths.length === 0) return '';
|
|
13602
|
+
const splitPaths = paths.map(path => path.split('/'));
|
|
13603
|
+
const minLength = Math.min(...splitPaths.map(parts => parts.length));
|
|
13604
|
+
let commonParts = [];
|
|
13605
|
+
for (let i = 0; i < minLength; i++) {
|
|
13606
|
+
const part = splitPaths[0][i];
|
|
13607
|
+
if (splitPaths.every(parts => parts[i] === part || parts[i].startsWith('['))) {
|
|
13608
|
+
commonParts.push(part);
|
|
13609
|
+
} else {
|
|
13610
|
+
break;
|
|
13611
|
+
}
|
|
13612
|
+
}
|
|
13613
|
+
const commonPath = commonParts.join('/') + (commonParts.length ? '/' : '');
|
|
13614
|
+
return commonPath;
|
|
13615
|
+
}
|
|
13616
|
+
|
|
13617
|
+
// import * as Params from "./params"
|
|
13618
|
+
|
|
13532
13619
|
const App={
|
|
13533
13620
|
...__App__,
|
|
13534
13621
|
...JsonStyleSheet,
|
|
13535
13622
|
...Spa,
|
|
13536
13623
|
...Global,
|
|
13537
|
-
...Params
|
|
13624
|
+
// ...Params
|
|
13538
13625
|
};
|
|
13539
13626
|
|
|
13540
13627
|
[
|
|
@@ -13570,6 +13657,7 @@ if ( globalThis.__Ziko__ ) {
|
|
|
13570
13657
|
ExtractAll,
|
|
13571
13658
|
RemoveAll
|
|
13572
13659
|
};
|
|
13660
|
+
defineParamsGetter(__Ziko__);
|
|
13573
13661
|
}
|
|
13574
13662
|
// globalThis.__Ziko__={
|
|
13575
13663
|
// ...Ziko,
|
|
@@ -13615,10 +13703,12 @@ exports.Complex = Complex;
|
|
|
13615
13703
|
exports.E = E;
|
|
13616
13704
|
exports.EPSILON = EPSILON;
|
|
13617
13705
|
exports.Ease = Ease;
|
|
13706
|
+
exports.FileBasedRouting = FileBasedRouting;
|
|
13618
13707
|
exports.Flex = Flex$1;
|
|
13619
13708
|
exports.Footer = Footer;
|
|
13620
13709
|
exports.Form = Form;
|
|
13621
13710
|
exports.Grid = Grid$1;
|
|
13711
|
+
exports.HTMLWrapper = HTMLWrapper;
|
|
13622
13712
|
exports.Header = Header;
|
|
13623
13713
|
exports.LinearSystem = LinearSystem;
|
|
13624
13714
|
exports.Logic = Logic$1;
|
|
@@ -13630,6 +13720,7 @@ exports.PI = PI;
|
|
|
13630
13720
|
exports.Permutation = Permutation;
|
|
13631
13721
|
exports.Random = Random;
|
|
13632
13722
|
exports.SPA = SPA;
|
|
13723
|
+
exports.SVGWrapper = SVGWrapper;
|
|
13633
13724
|
exports.Section = Section;
|
|
13634
13725
|
exports.Signal = Signal;
|
|
13635
13726
|
exports.Slider = Slider;
|
|
@@ -13660,6 +13751,7 @@ exports.ZikoUIFlex = ZikoUIFlex$1;
|
|
|
13660
13751
|
exports.ZikoUIFooter = ZikoUIFooter;
|
|
13661
13752
|
exports.ZikoUIForm = ZikoUIForm;
|
|
13662
13753
|
exports.ZikoUIGrid = ZikoUIGrid;
|
|
13754
|
+
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
13663
13755
|
exports.ZikoUIHeader = ZikoUIHeader;
|
|
13664
13756
|
exports.ZikoUIHeading = ZikoUIHeading;
|
|
13665
13757
|
exports.ZikoUIHorizontalSlider = ZikoUIHorizontalSlider;
|
|
@@ -13690,6 +13782,7 @@ exports.ZikoUIModal = ZikoUIModal;
|
|
|
13690
13782
|
exports.ZikoUINav = ZikoUINav;
|
|
13691
13783
|
exports.ZikoUIParagraphe = ZikoUIParagraphe;
|
|
13692
13784
|
exports.ZikoUIQuote = ZikoUIQuote;
|
|
13785
|
+
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
13693
13786
|
exports.ZikoUISection = ZikoUISection;
|
|
13694
13787
|
exports.ZikoUISelect = ZikoUISelect;
|
|
13695
13788
|
exports.ZikoUISubText = ZikoUISubText;
|
|
@@ -13700,6 +13793,7 @@ exports.ZikoUITextArea = ZikoUITextArea;
|
|
|
13700
13793
|
exports.ZikoUIVerticalSlider = ZikoUIVerticalSlider;
|
|
13701
13794
|
exports.ZikoUIVerticalSplitter = ZikoUIVerticalSplitter;
|
|
13702
13795
|
exports.ZikoUIVideo = ZikoUIVideo;
|
|
13796
|
+
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
13703
13797
|
exports.__Config__ = __Config__;
|
|
13704
13798
|
exports.__UI__ = __UI__;
|
|
13705
13799
|
exports.abbrText = abbrText;
|
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 : Sun Oct 13 2024 19:56:33 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
|
|
@@ -3883,7 +3883,7 @@
|
|
|
3883
3883
|
}
|
|
3884
3884
|
}
|
|
3885
3885
|
|
|
3886
|
-
const useHead
|
|
3886
|
+
const useHead=({ title, lang, icon, meta, noscript })=>new ZikoHead({ title, lang, icon, meta, noscript });
|
|
3887
3887
|
|
|
3888
3888
|
const LightThemes={
|
|
3889
3889
|
cozyCottonCandy: {
|
|
@@ -5800,7 +5800,7 @@
|
|
|
5800
5800
|
useTitle,
|
|
5801
5801
|
useFavIcon,
|
|
5802
5802
|
useMeta,
|
|
5803
|
-
useHead
|
|
5803
|
+
useHead,
|
|
5804
5804
|
useThrottle,
|
|
5805
5805
|
useDebounce,
|
|
5806
5806
|
useLocaleStorage,
|
|
@@ -7064,6 +7064,35 @@
|
|
|
7064
7064
|
}
|
|
7065
7065
|
const inputDateTime = () => new ZikoUIInputDateTime();
|
|
7066
7066
|
|
|
7067
|
+
class ZikoUIXMLWrapper extends ZikoUIElement$1{
|
|
7068
|
+
constructor(XMLContent, type){
|
|
7069
|
+
super("div", "");
|
|
7070
|
+
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
|
|
7071
|
+
}
|
|
7072
|
+
}
|
|
7073
|
+
function html2dom(htmlString) {
|
|
7074
|
+
const parser = new DOMParser();
|
|
7075
|
+
const doc = parser.parseFromString(`<div>${htmlString}</div>`, 'text/html');
|
|
7076
|
+
return doc.body.firstChild;
|
|
7077
|
+
}
|
|
7078
|
+
function svg2dom(svgString) {
|
|
7079
|
+
const parser = new DOMParser();
|
|
7080
|
+
const doc = parser.parseFromString(svgString, 'image/svg+xml');
|
|
7081
|
+
return doc.documentElement; // SVG elements are usually at the root
|
|
7082
|
+
}
|
|
7083
|
+
class ZikoUIHTMLWrapper extends ZikoUIXMLWrapper{
|
|
7084
|
+
constructor(HTMLContent){
|
|
7085
|
+
super(HTMLContent, "html");
|
|
7086
|
+
}
|
|
7087
|
+
}
|
|
7088
|
+
class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
|
|
7089
|
+
constructor(SVGContent){
|
|
7090
|
+
super(SVGContent, "svg");
|
|
7091
|
+
}
|
|
7092
|
+
}
|
|
7093
|
+
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
7094
|
+
const SVGWrapper = (SVGContent) => new ZikoUIHTMLWrapper(SVGContent);
|
|
7095
|
+
|
|
7067
7096
|
class ZikoUIHtmlTag extends ZikoUIContainerElement {
|
|
7068
7097
|
constructor(element) {
|
|
7069
7098
|
super(element,"html");
|
|
@@ -7152,10 +7181,15 @@
|
|
|
7152
7181
|
|
|
7153
7182
|
var Misc = /*#__PURE__*/Object.freeze({
|
|
7154
7183
|
__proto__: null,
|
|
7184
|
+
HTMLWrapper: HTMLWrapper,
|
|
7185
|
+
SVGWrapper: SVGWrapper,
|
|
7155
7186
|
ZikoUIBr: ZikoUIBr,
|
|
7187
|
+
ZikoUIHTMLWrapper: ZikoUIHTMLWrapper,
|
|
7156
7188
|
ZikoUIHr: ZikoUIHr,
|
|
7157
7189
|
ZikoUIHtmlTag: ZikoUIHtmlTag,
|
|
7158
7190
|
ZikoUILink: ZikoUILink,
|
|
7191
|
+
ZikoUISVGWrapper: ZikoUISVGWrapper,
|
|
7192
|
+
ZikoUIXMLWrapper: ZikoUIXMLWrapper,
|
|
7159
7193
|
br: br,
|
|
7160
7194
|
brs: brs,
|
|
7161
7195
|
btn: btn,
|
|
@@ -9515,7 +9549,9 @@
|
|
|
9515
9549
|
...Table,
|
|
9516
9550
|
...Semantic,
|
|
9517
9551
|
...Misc,
|
|
9518
|
-
...Derived
|
|
9552
|
+
...Derived,
|
|
9553
|
+
ZikoUIElement: ZikoUIElement$1,
|
|
9554
|
+
ZikoUIContainerElement
|
|
9519
9555
|
};
|
|
9520
9556
|
|
|
9521
9557
|
const svg2str=svg=>(new XMLSerializer()).serializeToString(svg);
|
|
@@ -13279,7 +13315,7 @@
|
|
|
13279
13315
|
this.head && this.setHead(this.head);
|
|
13280
13316
|
this.wrapper && this.setWrapper(this.wrapper);
|
|
13281
13317
|
this.target && this.setTarget(this.target);
|
|
13282
|
-
this.wrapper.render(this.target);
|
|
13318
|
+
if(this.wrapper && this.target)this.wrapper.render(this.target);
|
|
13283
13319
|
}
|
|
13284
13320
|
setTarget(target){
|
|
13285
13321
|
if(target instanceof HTMLElement) this.target = target;
|
|
@@ -13422,8 +13458,6 @@
|
|
|
13422
13458
|
class ZikoSPA extends ZikoApp{
|
|
13423
13459
|
constructor({head, wrapper, target, routes}){
|
|
13424
13460
|
super({head, wrapper, target});
|
|
13425
|
-
// this.wrapper=wrapper;
|
|
13426
|
-
console.log(target);
|
|
13427
13461
|
this.routes=new Map([
|
|
13428
13462
|
["404",text$1("Error 404")],
|
|
13429
13463
|
...Object.entries(routes)
|
|
@@ -13450,6 +13484,7 @@
|
|
|
13450
13484
|
if(typeof callback === "function") element = callback();
|
|
13451
13485
|
}
|
|
13452
13486
|
if(element?.isZikoUIElement) element.render(this.wrapper);
|
|
13487
|
+
// if(element?.isZikoApp) element.render(this.wrapper);
|
|
13453
13488
|
if(element instanceof Promise){
|
|
13454
13489
|
element.then(e=>e.render(this.wrapper));
|
|
13455
13490
|
}
|
|
@@ -13474,7 +13509,7 @@
|
|
|
13474
13509
|
ZikoSPA: ZikoSPA
|
|
13475
13510
|
});
|
|
13476
13511
|
|
|
13477
|
-
function
|
|
13512
|
+
function parseQueryParams(queryString) {
|
|
13478
13513
|
const params = {};
|
|
13479
13514
|
queryString.replace(/[A-Z0-9]+?=([\w|:|\/\.]*)/gi, (match) => {
|
|
13480
13515
|
const [key, value] = match.split('=');
|
|
@@ -13483,19 +13518,19 @@
|
|
|
13483
13518
|
return params;
|
|
13484
13519
|
}
|
|
13485
13520
|
|
|
13486
|
-
function defineParamsGetter(target
|
|
13521
|
+
function defineParamsGetter(target ){
|
|
13487
13522
|
Object.defineProperties(target, {
|
|
13488
13523
|
'QueryParams': {
|
|
13489
13524
|
get: function() {
|
|
13490
|
-
return
|
|
13525
|
+
return parseQueryParams(globalThis.location.search.substring(1));
|
|
13491
13526
|
},
|
|
13492
13527
|
configurable: false,
|
|
13493
13528
|
enumerable: true
|
|
13494
13529
|
},
|
|
13495
13530
|
'HashParams': {
|
|
13496
13531
|
get: function() {
|
|
13497
|
-
const hash =
|
|
13498
|
-
return
|
|
13532
|
+
const hash = globalThis.location.hash.substring(1);
|
|
13533
|
+
return hash.split("#");
|
|
13499
13534
|
},
|
|
13500
13535
|
configurable: false,
|
|
13501
13536
|
enumerable: true
|
|
@@ -13503,11 +13538,6 @@
|
|
|
13503
13538
|
});
|
|
13504
13539
|
}
|
|
13505
13540
|
|
|
13506
|
-
var Params = /*#__PURE__*/Object.freeze({
|
|
13507
|
-
__proto__: null,
|
|
13508
|
-
defineParamsGetter: defineParamsGetter
|
|
13509
|
-
});
|
|
13510
|
-
|
|
13511
13541
|
const __UI__={};
|
|
13512
13542
|
const __Config__={
|
|
13513
13543
|
default:{
|
|
@@ -13531,12 +13561,71 @@
|
|
|
13531
13561
|
__UI__: __UI__
|
|
13532
13562
|
});
|
|
13533
13563
|
|
|
13564
|
+
// import.meta.glob('./src/pages/**/*.js')
|
|
13565
|
+
async function FileBasedRouting(pages /* use import.meta.glob */){
|
|
13566
|
+
const routes = Object.keys(pages);
|
|
13567
|
+
const root = findCommonPath(routes);
|
|
13568
|
+
// console.log({root})
|
|
13569
|
+
const pairs = {};
|
|
13570
|
+
for(let i=0; i<routes.length; i++){
|
|
13571
|
+
const module = await pages[routes[i]]();
|
|
13572
|
+
const component = await module.default;
|
|
13573
|
+
Object.assign(pairs,{[customPath(routes[i], root)]:component});
|
|
13574
|
+
}
|
|
13575
|
+
return SPA({
|
|
13576
|
+
target : document.body,
|
|
13577
|
+
routes : {
|
|
13578
|
+
"/" : ()=>{},
|
|
13579
|
+
...pairs
|
|
13580
|
+
},
|
|
13581
|
+
wrapper : Section()
|
|
13582
|
+
})
|
|
13583
|
+
}
|
|
13584
|
+
function customPath(inputPath, root = './src/pages', extensions = ['js', 'ts']) {
|
|
13585
|
+
if(root.at(-1)==="/") root = root.slice(0, -1);
|
|
13586
|
+
const normalizedPath = inputPath.replace(/\\/g, '/').replace(/\[(\w+)\]/g, '$1/:$1');
|
|
13587
|
+
const parts = normalizedPath.split('/');
|
|
13588
|
+
const rootParts = root.split('/');
|
|
13589
|
+
const rootIndex = parts.indexOf(rootParts[rootParts.length - 1]);
|
|
13590
|
+
if (rootIndex !== -1) {
|
|
13591
|
+
const subsequentParts = parts.slice(rootIndex + 1);
|
|
13592
|
+
const lastPart = subsequentParts[subsequentParts.length - 1];
|
|
13593
|
+
const isIndexFile = lastPart === 'index.js' || lastPart === 'index.ts';
|
|
13594
|
+
const hasValidExtension = extensions.some(ext => lastPart === `.${ext}` || lastPart.endsWith(`.${ext}`));
|
|
13595
|
+
if (isIndexFile) {
|
|
13596
|
+
return '/' + (subsequentParts.length > 1 ? subsequentParts.slice(0, -1).join('/') : '');
|
|
13597
|
+
}
|
|
13598
|
+
if (hasValidExtension) {
|
|
13599
|
+
return '/' + subsequentParts.join('/').replace(/\.(js|ts)$/, '');
|
|
13600
|
+
}
|
|
13601
|
+
}
|
|
13602
|
+
return '';
|
|
13603
|
+
}
|
|
13604
|
+
function findCommonPath(paths) {
|
|
13605
|
+
if (paths.length === 0) return '';
|
|
13606
|
+
const splitPaths = paths.map(path => path.split('/'));
|
|
13607
|
+
const minLength = Math.min(...splitPaths.map(parts => parts.length));
|
|
13608
|
+
let commonParts = [];
|
|
13609
|
+
for (let i = 0; i < minLength; i++) {
|
|
13610
|
+
const part = splitPaths[0][i];
|
|
13611
|
+
if (splitPaths.every(parts => parts[i] === part || parts[i].startsWith('['))) {
|
|
13612
|
+
commonParts.push(part);
|
|
13613
|
+
} else {
|
|
13614
|
+
break;
|
|
13615
|
+
}
|
|
13616
|
+
}
|
|
13617
|
+
const commonPath = commonParts.join('/') + (commonParts.length ? '/' : '');
|
|
13618
|
+
return commonPath;
|
|
13619
|
+
}
|
|
13620
|
+
|
|
13621
|
+
// import * as Params from "./params"
|
|
13622
|
+
|
|
13534
13623
|
const App={
|
|
13535
13624
|
...__App__,
|
|
13536
13625
|
...JsonStyleSheet,
|
|
13537
13626
|
...Spa,
|
|
13538
13627
|
...Global,
|
|
13539
|
-
...Params
|
|
13628
|
+
// ...Params
|
|
13540
13629
|
};
|
|
13541
13630
|
|
|
13542
13631
|
[
|
|
@@ -13572,6 +13661,7 @@
|
|
|
13572
13661
|
ExtractAll,
|
|
13573
13662
|
RemoveAll
|
|
13574
13663
|
};
|
|
13664
|
+
defineParamsGetter(__Ziko__);
|
|
13575
13665
|
}
|
|
13576
13666
|
// globalThis.__Ziko__={
|
|
13577
13667
|
// ...Ziko,
|
|
@@ -13617,10 +13707,12 @@
|
|
|
13617
13707
|
exports.E = E;
|
|
13618
13708
|
exports.EPSILON = EPSILON;
|
|
13619
13709
|
exports.Ease = Ease;
|
|
13710
|
+
exports.FileBasedRouting = FileBasedRouting;
|
|
13620
13711
|
exports.Flex = Flex$1;
|
|
13621
13712
|
exports.Footer = Footer;
|
|
13622
13713
|
exports.Form = Form;
|
|
13623
13714
|
exports.Grid = Grid$1;
|
|
13715
|
+
exports.HTMLWrapper = HTMLWrapper;
|
|
13624
13716
|
exports.Header = Header;
|
|
13625
13717
|
exports.LinearSystem = LinearSystem;
|
|
13626
13718
|
exports.Logic = Logic$1;
|
|
@@ -13632,6 +13724,7 @@
|
|
|
13632
13724
|
exports.Permutation = Permutation;
|
|
13633
13725
|
exports.Random = Random;
|
|
13634
13726
|
exports.SPA = SPA;
|
|
13727
|
+
exports.SVGWrapper = SVGWrapper;
|
|
13635
13728
|
exports.Section = Section;
|
|
13636
13729
|
exports.Signal = Signal;
|
|
13637
13730
|
exports.Slider = Slider;
|
|
@@ -13656,12 +13749,15 @@
|
|
|
13656
13749
|
exports.ZikoUICanvas = ZikoUICanvas;
|
|
13657
13750
|
exports.ZikoUICodeNote = ZikoUICodeNote;
|
|
13658
13751
|
exports.ZikoUICodeText = ZikoUICodeText;
|
|
13752
|
+
exports.ZikoUIContainerElement = ZikoUIContainerElement;
|
|
13659
13753
|
exports.ZikoUIDefintion = ZikoUIDefintion;
|
|
13754
|
+
exports.ZikoUIElement = ZikoUIElement$1;
|
|
13660
13755
|
exports.ZikoUIFigure = ZikoUIFigure;
|
|
13661
13756
|
exports.ZikoUIFlex = ZikoUIFlex$1;
|
|
13662
13757
|
exports.ZikoUIFooter = ZikoUIFooter;
|
|
13663
13758
|
exports.ZikoUIForm = ZikoUIForm;
|
|
13664
13759
|
exports.ZikoUIGrid = ZikoUIGrid;
|
|
13760
|
+
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
13665
13761
|
exports.ZikoUIHeader = ZikoUIHeader;
|
|
13666
13762
|
exports.ZikoUIHeading = ZikoUIHeading;
|
|
13667
13763
|
exports.ZikoUIHorizontalSlider = ZikoUIHorizontalSlider;
|
|
@@ -13692,6 +13788,7 @@
|
|
|
13692
13788
|
exports.ZikoUINav = ZikoUINav;
|
|
13693
13789
|
exports.ZikoUIParagraphe = ZikoUIParagraphe;
|
|
13694
13790
|
exports.ZikoUIQuote = ZikoUIQuote;
|
|
13791
|
+
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
13695
13792
|
exports.ZikoUISection = ZikoUISection;
|
|
13696
13793
|
exports.ZikoUISelect = ZikoUISelect;
|
|
13697
13794
|
exports.ZikoUISubText = ZikoUISubText;
|
|
@@ -13702,6 +13799,7 @@
|
|
|
13702
13799
|
exports.ZikoUIVerticalSlider = ZikoUIVerticalSlider;
|
|
13703
13800
|
exports.ZikoUIVerticalSplitter = ZikoUIVerticalSplitter;
|
|
13704
13801
|
exports.ZikoUIVideo = ZikoUIVideo;
|
|
13802
|
+
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
13705
13803
|
exports.__Config__ = __Config__;
|
|
13706
13804
|
exports.__UI__ = __UI__;
|
|
13707
13805
|
exports.abbrText = abbrText;
|