ziko 0.38.0 → 0.39.0
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 +165 -759
- package/dist/ziko.js +165 -759
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +164 -756
- package/package.json +2 -1
- package/src/__helpers__/composition-dep/compose-class.js +46 -0
- package/src/__helpers__/register/index.js +6 -0
- package/src/__helpers__/register/register-to-class.js +16 -0
- package/src/__helpers__/register/register-to-instance.js +18 -0
- package/src/__ziko__/index.js +12 -11
- package/src/events/types/clipboard.d.ts +2 -2
- package/src/events/types/focus.d.ts +2 -2
- package/src/events/types/pointer.d.ts +2 -2
- package/src/hooks/use-state.js +5 -0
- package/src/reactivity/hooks/UI/index.js +1 -1
- package/src/ui/__methods__/attrs.js +46 -0
- package/src/ui/__methods__/index.js +5 -0
- package/src/ui/__methods__/style.js +14 -0
- package/src/ui/__utils__/index.js +2 -2
- package/src/ui/constructors/{ZikoUIElement.js → UIElement.js} +30 -82
- package/src/ui/constructors/{ZikoUINode.js → UINode.js} +2 -2
- package/src/ui/flex/index.js +8 -8
- package/src/ui/graphics/canvas.js +2 -2
- package/src/ui/graphics/svg.js +2 -2
- package/src/ui/grid/index.js +4 -4
- package/src/ui/index.js +2 -2
- package/src/ui/suspense/index.js +3 -3
- package/src/ui/tags/index.d.ts.txt +125 -125
- package/src/ui/tags/index.js +28 -18
- package/src/ui/text/index.js +2 -2
- package/src/ui/wrapper/index.js +3 -3
- package/src/__helpers__/composition/compose-class.js +0 -28
- /package/src/__helpers__/{composition → composition-dep}/compose-instance.js +0 -0
- /package/src/__helpers__/{composition → composition-dep}/compose.js +0 -0
- /package/src/__helpers__/{composition → composition-dep}/index.js +0 -0
- /package/src/ui/constructors/{ZikoUIElementMethodesToBeMoved.js → ZikoUIElementMethodesToBeMoved-dep.js} +0 -0
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 Aug 18 2025 11:00:54 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
|
|
@@ -951,21 +951,6 @@
|
|
|
951
951
|
}
|
|
952
952
|
};
|
|
953
953
|
|
|
954
|
-
async function fetchdom(url='https://github.com/zakarialaoui10'){
|
|
955
|
-
const data=await fetch(url);
|
|
956
|
-
const html=await data.text();
|
|
957
|
-
const dom= new DOMParser().parseFromString(html,'text/xml');
|
|
958
|
-
return dom.documentElement
|
|
959
|
-
}
|
|
960
|
-
function fetchdomSync(url='https://github.com/zakarialaoui10'){
|
|
961
|
-
const data=preload(url);
|
|
962
|
-
const dom= new DOMParser().parseFromString(data,'text/xml');
|
|
963
|
-
return dom.documentElement;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
globalThis.fetchdom=fetchdom;
|
|
967
|
-
globalThis.fetchdomSync=fetchdomSync;
|
|
968
|
-
|
|
969
954
|
const csv2arr = (csv, delimiter = ",")=>csv.trim().trimEnd().split("\n").map(n=>n.split(delimiter));
|
|
970
955
|
const csv2matrix = (csv, delimiter = ",")=>new Matrix(csv2arr(csv,delimiter));
|
|
971
956
|
const csv2object = (csv, delimiter = ",") => {
|
|
@@ -1064,7 +1049,7 @@
|
|
|
1064
1049
|
}
|
|
1065
1050
|
};
|
|
1066
1051
|
|
|
1067
|
-
class
|
|
1052
|
+
class UINode {
|
|
1068
1053
|
constructor(node){
|
|
1069
1054
|
this.cache = {
|
|
1070
1055
|
node
|
|
@@ -1078,38 +1063,29 @@
|
|
|
1078
1063
|
}
|
|
1079
1064
|
}
|
|
1080
1065
|
|
|
1081
|
-
globalThis.node = (node) => new
|
|
1066
|
+
globalThis.node = (node) => new UINode(node);
|
|
1082
1067
|
|
|
1083
|
-
function
|
|
1068
|
+
function register_to_class(target, ...mixins){
|
|
1069
|
+
mixins.forEach(n => _register_to_class_(target, n));
|
|
1070
|
+
}
|
|
1071
|
+
function _register_to_class_(target, mixin) {
|
|
1084
1072
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1085
|
-
|
|
1086
|
-
class Composed extends Class {
|
|
1087
|
-
constructor(...args) {
|
|
1088
|
-
super(...args);
|
|
1089
|
-
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1090
|
-
const desc = descriptors[key];
|
|
1091
|
-
|
|
1092
|
-
if (typeof desc.value === 'function') {
|
|
1093
|
-
this[key] = desc.value.bind(this);
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
1073
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
1100
1074
|
const desc = descriptors[key];
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1075
|
+
if ('get' in desc || 'set' in desc || typeof desc.value !== 'function') {
|
|
1076
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1077
|
+
} else if (typeof desc.value === 'function') {
|
|
1078
|
+
if (!Object.getPrototypeOf(target).hasOwnProperty(key)) {
|
|
1079
|
+
Object.defineProperty(Object.getPrototypeOf(target), key, desc);
|
|
1080
|
+
}
|
|
1106
1081
|
}
|
|
1107
1082
|
}
|
|
1108
|
-
|
|
1109
|
-
return Composed;
|
|
1110
1083
|
}
|
|
1111
1084
|
|
|
1112
|
-
function
|
|
1085
|
+
function register_to_instance(target, ...mixins){
|
|
1086
|
+
mixins.forEach(n => _register_to_instance_(target, n));
|
|
1087
|
+
}
|
|
1088
|
+
function _register_to_instance_(instance, mixin) {
|
|
1113
1089
|
const descriptors = Object.getOwnPropertyDescriptors(mixin);
|
|
1114
1090
|
|
|
1115
1091
|
for (const key of Reflect.ownKeys(descriptors)) {
|
|
@@ -1125,17 +1101,60 @@
|
|
|
1125
1101
|
}
|
|
1126
1102
|
}
|
|
1127
1103
|
|
|
1128
|
-
|
|
1129
|
-
if
|
|
1130
|
-
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1104
|
+
const register = (target, ...mixins) => {
|
|
1105
|
+
if(typeof target === 'function') register_to_class(target, ...mixins);
|
|
1106
|
+
else register_to_instance(target, ...mixins);
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
const isStateGetter = (arg) => {
|
|
1110
|
+
return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
|
|
1111
|
+
};
|
|
1112
|
+
|
|
1113
|
+
// To Do add getter, watchAttr
|
|
1114
|
+
const AttrsMethods = {
|
|
1115
|
+
setAttr(name, value) {
|
|
1116
|
+
if(name instanceof Object){
|
|
1117
|
+
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
1118
|
+
for(let i=0;i<names.length;i++){
|
|
1119
|
+
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
1120
|
+
_set_attrs_.call(this, names[i], values[i]);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
else {
|
|
1124
|
+
if(value instanceof Array) value = value.join(" ");
|
|
1125
|
+
_set_attrs_.call(this, name, value);
|
|
1126
|
+
}
|
|
1127
|
+
return this;
|
|
1128
|
+
},
|
|
1129
|
+
removeAttr(...names) {
|
|
1130
|
+
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
1131
|
+
return this;
|
|
1132
|
+
},
|
|
1133
|
+
getAttr(name){
|
|
1134
|
+
name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
|
|
1135
|
+
return this.element.attributes[name].value;
|
|
1136
|
+
},
|
|
1137
|
+
setContentEditable(bool = true) {
|
|
1138
|
+
this.setAttr("contenteditable", bool);
|
|
1139
|
+
return this;
|
|
1135
1140
|
}
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1143
|
+
function _set_attrs_(name, value){
|
|
1144
|
+
if(this.element?.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
|
|
1145
|
+
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
1146
|
+
if(isStateGetter(value)){
|
|
1147
|
+
const getter = value();
|
|
1148
|
+
getter._subscribe(
|
|
1149
|
+
(newValue) => this.element?.setAttribute(name, newValue),
|
|
1150
|
+
this
|
|
1151
|
+
);
|
|
1152
|
+
}
|
|
1153
|
+
else this.element?.setAttribute(name, value);
|
|
1154
|
+
Object.assign(this.cache.attributes, {[name]:value});
|
|
1136
1155
|
}
|
|
1137
1156
|
|
|
1138
|
-
class ZikoUIText extends
|
|
1157
|
+
class ZikoUIText extends UINode {
|
|
1139
1158
|
constructor(...value) {
|
|
1140
1159
|
super("span", "text", false, ...value);
|
|
1141
1160
|
this.element = globalThis?.document?.createTextNode(...value);
|
|
@@ -1254,22 +1273,6 @@
|
|
|
1254
1273
|
return this;
|
|
1255
1274
|
}
|
|
1256
1275
|
|
|
1257
|
-
const IndexingMethods = {
|
|
1258
|
-
at(index) {
|
|
1259
|
-
return this.items.at(index);
|
|
1260
|
-
},
|
|
1261
|
-
forEach(callback) {
|
|
1262
|
-
this.items.forEach(callback);
|
|
1263
|
-
return this;
|
|
1264
|
-
},
|
|
1265
|
-
map(callback) {
|
|
1266
|
-
return this.items.map(callback);
|
|
1267
|
-
},
|
|
1268
|
-
find(condition) {
|
|
1269
|
-
return this.items.filter(condition);
|
|
1270
|
-
},
|
|
1271
|
-
};
|
|
1272
|
-
|
|
1273
1276
|
const Events = {
|
|
1274
1277
|
'Click' : [
|
|
1275
1278
|
'Click',
|
|
@@ -1681,587 +1684,36 @@
|
|
|
1681
1684
|
});
|
|
1682
1685
|
});
|
|
1683
1686
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
this.
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
fontSize: "1em",
|
|
1691
|
-
color : "green"
|
|
1692
|
-
},
|
|
1693
|
-
other: {
|
|
1694
|
-
fontSize : "2em",
|
|
1695
|
-
color : "cyan"
|
|
1696
|
-
}
|
|
1697
|
-
};
|
|
1698
|
-
style && this.add(style);
|
|
1699
|
-
use && this.use(use);
|
|
1700
|
-
}
|
|
1701
|
-
|
|
1702
|
-
get current() {
|
|
1703
|
-
return [...this.keys].reduce((key, value) => {
|
|
1704
|
-
key[value] = `var(--${value}-${this.id})`;
|
|
1705
|
-
return key;
|
|
1706
|
-
}, {});
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
add(name, style = {}) {
|
|
1710
|
-
if (name && typeof name === 'object' && !Array.isArray(name)) {
|
|
1711
|
-
Object.assign(this.styles, name);
|
|
1712
|
-
} else if (typeof name === 'string') {
|
|
1713
|
-
Object.assign(this.styles, { [name]: style });
|
|
1714
|
-
}
|
|
1715
|
-
return this;
|
|
1716
|
-
}
|
|
1717
|
-
|
|
1718
|
-
#useStyleIndex(index) {
|
|
1719
|
-
const keys = Object.keys(this.styles);
|
|
1720
|
-
for (let a in this.styles[keys[index]]) {
|
|
1721
|
-
if (Object.prototype.hasOwnProperty.call(this.styles[keys[index]], a)) {
|
|
1722
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[keys[index]][a]);
|
|
1723
|
-
this.keys.add(a);
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
return this;
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
#useStyleName(name) {
|
|
1730
|
-
if (!this.styles[name]) return this;
|
|
1731
|
-
for (let a in this.styles[name]) {
|
|
1732
|
-
if (Object.prototype.hasOwnProperty.call(this.styles[name], a)) {
|
|
1733
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[name][a]);
|
|
1734
|
-
this.keys.add(a);
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
return this;
|
|
1738
|
-
}
|
|
1739
|
-
|
|
1740
|
-
#useStyleObject(style) {
|
|
1741
|
-
for (let a in style) {
|
|
1742
|
-
if (Object.prototype.hasOwnProperty.call(style, a)) {
|
|
1743
|
-
document.documentElement.style.setProperty(`--${a}-${this.id}`, style[a]);
|
|
1744
|
-
this.keys.add(a);
|
|
1745
|
-
}
|
|
1746
|
-
}
|
|
1747
|
-
return this;
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
use(style) {
|
|
1751
|
-
if (typeof style === "number") return this.#useStyleIndex(style);
|
|
1752
|
-
if (typeof style === "string") return this.#useStyleName(style);
|
|
1753
|
-
if (style && typeof style === "object") return this.#useStyleObject(style);
|
|
1687
|
+
const IndexingMethods = {
|
|
1688
|
+
at(index) {
|
|
1689
|
+
return this.items.at(index);
|
|
1690
|
+
},
|
|
1691
|
+
forEach(callback) {
|
|
1692
|
+
this.items.forEach(callback);
|
|
1754
1693
|
return this;
|
|
1755
|
-
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
if(value instanceof Array)value=value.map(n=>typeof n==="number"?n+=suffixe:n).join(" ");
|
|
1763
|
-
return value;
|
|
1694
|
+
},
|
|
1695
|
+
map(callback) {
|
|
1696
|
+
return this.items.map(callback);
|
|
1697
|
+
},
|
|
1698
|
+
find(condition) {
|
|
1699
|
+
return this.items.filter(condition);
|
|
1700
|
+
},
|
|
1764
1701
|
};
|
|
1765
1702
|
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
this.target=null;
|
|
1769
|
-
this.styles=new Map(
|
|
1770
|
-
[["default",defaultStyle]]
|
|
1771
|
-
);
|
|
1772
|
-
this.cache={
|
|
1773
|
-
isHidden:false,
|
|
1774
|
-
isFaddedOut:false,
|
|
1775
|
-
transformation:{
|
|
1776
|
-
Flip:[0,0,0],
|
|
1777
|
-
matrix:new Matrix([
|
|
1778
|
-
[1,0,0,0],
|
|
1779
|
-
[0,1,0,0],
|
|
1780
|
-
[0,0,1,0],
|
|
1781
|
-
[0,0,0,1]
|
|
1782
|
-
])
|
|
1783
|
-
}
|
|
1784
|
-
};
|
|
1785
|
-
}
|
|
1703
|
+
// Process width and height
|
|
1704
|
+
const StyleMethods = {
|
|
1786
1705
|
style(styles){
|
|
1787
|
-
|
|
1788
|
-
if(Str.isCamelCase(key)){
|
|
1789
|
-
delete styles[key];
|
|
1790
|
-
Object.assign(styles,{[Str.camel2hyphencase(key)]:value});
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
if(this?.target?.element?.style)Object.assign(this?.target?.element?.style, styles);
|
|
1794
|
-
return this;
|
|
1795
|
-
}
|
|
1796
|
-
linkTo(target){
|
|
1797
|
-
this.target=target;
|
|
1798
|
-
return this;
|
|
1799
|
-
}
|
|
1800
|
-
use(name="default"){
|
|
1801
|
-
this.style(this.styles.get(name));
|
|
1802
|
-
return this;
|
|
1803
|
-
}
|
|
1804
|
-
update(name,styles){
|
|
1805
|
-
const old=this.styles.get(name);
|
|
1806
|
-
old?this.styles.set(name,Object.assign(old,styles)):this.styles.set(name,styles);
|
|
1807
|
-
return this;
|
|
1808
|
-
}
|
|
1809
|
-
add(name,styles){
|
|
1810
|
-
this.styles.set(name,styles);
|
|
1811
|
-
return this;
|
|
1812
|
-
}
|
|
1813
|
-
replace(name,styles){
|
|
1814
|
-
this.styles.set(name,styles);
|
|
1815
|
-
return this;
|
|
1816
|
-
}
|
|
1817
|
-
delete(...names){
|
|
1818
|
-
names.forEach(n=>this.styles.delete(n));
|
|
1819
|
-
return this;
|
|
1820
|
-
}
|
|
1821
|
-
updateDefaultStyle(){
|
|
1822
|
-
const defaultStyle=Object.fromEntries(
|
|
1823
|
-
Object.entries(this.target.element.style).filter(n=>isNaN(+n[0]))
|
|
1824
|
-
);
|
|
1825
|
-
this.update("default",defaultStyle);
|
|
1826
|
-
return this;
|
|
1827
|
-
}
|
|
1828
|
-
hover(styles){
|
|
1829
|
-
//this.updateDefaultStyle()
|
|
1830
|
-
if(styles)this.add("hover",styles);
|
|
1831
|
-
this.target?.element?.addEventListener("pointerenter",()=>this.use("hover"));
|
|
1832
|
-
this.target?.element?.addEventListener("pointerleave",()=>this.use("default"));
|
|
1833
|
-
return this;
|
|
1834
|
-
}
|
|
1835
|
-
// Checkers
|
|
1836
|
-
isInline(){
|
|
1837
|
-
return getComputedStyle(this.target.element).display.includes("inline");
|
|
1838
|
-
}
|
|
1839
|
-
isBlock(){
|
|
1840
|
-
return !(this.isInline());
|
|
1841
|
-
}
|
|
1842
|
-
// Size
|
|
1843
|
-
size(width,height){
|
|
1844
|
-
this.style({
|
|
1845
|
-
width,
|
|
1846
|
-
height
|
|
1847
|
-
});
|
|
1848
|
-
return this;
|
|
1849
|
-
}
|
|
1850
|
-
width(w){
|
|
1851
|
-
if(w instanceof Object){
|
|
1852
|
-
if(w instanceof Array)w={min:w[0],max:w[1]};
|
|
1853
|
-
if("min" in w || "max" in w){
|
|
1854
|
-
let min= w.min ?? w.max;
|
|
1855
|
-
let max= w.max ?? w.min;
|
|
1856
|
-
min=addSuffixeToNumber(min,"px");
|
|
1857
|
-
max=addSuffixeToNumber(max,"px");
|
|
1858
|
-
this.style({ minWidth: min, maxWidth: max }, { target, maskVector });
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
else {
|
|
1862
|
-
w=addSuffixeToNumber(w,"px");
|
|
1863
|
-
this.style({width:w});
|
|
1864
|
-
}
|
|
1865
|
-
return this
|
|
1866
|
-
}
|
|
1867
|
-
height(h){
|
|
1868
|
-
if(h instanceof Object){
|
|
1869
|
-
if(h instanceof Array)h={min:h[0],max:h[1]};
|
|
1870
|
-
if("min" in h || "max" in h){
|
|
1871
|
-
let min= h.min ?? h.max;
|
|
1872
|
-
let max= h.max ?? h.min;
|
|
1873
|
-
min=addSuffixeToNumber(min,"px");
|
|
1874
|
-
max=addSuffixeToNumber(max,"px");
|
|
1875
|
-
this.style({ minHeight: min, maxHeight: max }, { target, maskVector });
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
else {
|
|
1879
|
-
h=addSuffixeToNumber(h,"px");
|
|
1880
|
-
this.style({height:h});
|
|
1881
|
-
}
|
|
1882
|
-
return this
|
|
1883
|
-
}
|
|
1884
|
-
enableResize(h=false,v=false){
|
|
1885
|
-
let resize="none";
|
|
1886
|
-
if(h)v?resize="both":resize="horizontal";
|
|
1887
|
-
else v?resize="vertical":resize="none";
|
|
1888
|
-
this.style({
|
|
1889
|
-
resize,
|
|
1890
|
-
overflow:"hidden"
|
|
1891
|
-
});
|
|
1892
|
-
if(this.isInline()){
|
|
1893
|
-
console.group("Ziko Issue : Temporarily Incompatible Method");
|
|
1894
|
-
console.warn(".enableResize has no effect on inline elements!");
|
|
1895
|
-
console.info("%cConsider using other display types such as block, inline-block, flex, or grid for proper resizing behavior.","color:gold;background-color:#3333cc;padding:5px");
|
|
1896
|
-
console.groupEnd();
|
|
1897
|
-
}
|
|
1898
|
-
return this;
|
|
1899
|
-
}
|
|
1900
|
-
// Apparence
|
|
1901
|
-
hide({after, target, maskVector } = {}){
|
|
1902
|
-
if(typeof after==="number"){
|
|
1903
|
-
const wrapper=()=>this.hide({target,maskVector});
|
|
1904
|
-
setTimeout(wrapper, after);
|
|
1905
|
-
clearTimeout(wrapper);
|
|
1906
|
-
}
|
|
1907
|
-
else {
|
|
1908
|
-
this.cache.isHidden=true;
|
|
1909
|
-
this.style({display:"none"},{target,maskVector});
|
|
1910
|
-
}
|
|
1911
|
-
return this;
|
|
1912
|
-
}
|
|
1913
|
-
show({after, target, maskVector } = {}){
|
|
1914
|
-
if(typeof after==="number"){
|
|
1915
|
-
const wrapper=()=>this.show({target,maskVector});
|
|
1916
|
-
setTimeout(wrapper, after);
|
|
1917
|
-
clearTimeout(wrapper);
|
|
1918
|
-
}
|
|
1919
|
-
else {
|
|
1920
|
-
this.cache.isHidden=false;
|
|
1921
|
-
this.style({display:""},{target,maskVector});
|
|
1922
|
-
}
|
|
1923
|
-
return this;
|
|
1924
|
-
}
|
|
1925
|
-
color(color){
|
|
1926
|
-
this.style({color});
|
|
1927
|
-
return this;
|
|
1928
|
-
}
|
|
1929
|
-
background(background){
|
|
1930
|
-
this.style({background});
|
|
1931
|
-
return this;
|
|
1932
|
-
}
|
|
1933
|
-
backgroundColor(backgroundColor){
|
|
1934
|
-
this.style({backgroundColor});
|
|
1706
|
+
Object.assign(this.element.style, styles);
|
|
1935
1707
|
return this;
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
this.style({
|
|
1939
|
-
|
|
1940
|
-
}
|
|
1941
|
-
|
|
1942
|
-
position(position){
|
|
1943
|
-
this.style({position});
|
|
1944
|
-
return this
|
|
1945
|
-
}
|
|
1946
|
-
display(disp, { target, maskVector } = {}) {
|
|
1947
|
-
this.style({ display: disp }, { target, maskVector });
|
|
1948
|
-
return this;
|
|
1949
|
-
}
|
|
1950
|
-
zIndex(z){
|
|
1951
|
-
this.style({zIndex:z});
|
|
1952
|
-
return this;
|
|
1953
|
-
}
|
|
1954
|
-
float(float, { target, maskVector } = {}) {
|
|
1955
|
-
this.style({ float: float }, { target, maskVector });
|
|
1956
|
-
return this;
|
|
1957
|
-
}
|
|
1958
|
-
// Box Model
|
|
1959
|
-
border(border = "1px solid red", { target, maskVector } = {}){
|
|
1960
|
-
this.style({border}, { target, maskVector });
|
|
1961
|
-
return this;
|
|
1962
|
-
}
|
|
1963
|
-
borderTop(borderTop = "1px solid red", { target, maskVector } = {}){
|
|
1964
|
-
this.style({borderTop}, { target, maskVector });
|
|
1965
|
-
return this;
|
|
1966
|
-
}
|
|
1967
|
-
borderRight(borderRight = "1px solid red", { target, maskVector } = {}){
|
|
1968
|
-
this.style({borderRight}, { target, maskVector });
|
|
1969
|
-
return this;
|
|
1970
|
-
}
|
|
1971
|
-
borderBottom(borderBottom = "1px solid red", { target, maskVector } = {}){
|
|
1972
|
-
this.style({borderBottom}, { target, maskVector });
|
|
1973
|
-
return this;
|
|
1974
|
-
}
|
|
1975
|
-
borderLeft(borderLeft = "1px solid red", { target, maskVector } = {}){
|
|
1976
|
-
this.style({borderLeft}, { target, maskVector });
|
|
1977
|
-
return this;
|
|
1978
|
-
}
|
|
1979
|
-
borderRadius(radius){
|
|
1980
|
-
radius=addSuffixeToNumber(radius,"px");
|
|
1981
|
-
this.style({ borderRadius: radius }, { target, maskVector });
|
|
1982
|
-
return this;
|
|
1983
|
-
}
|
|
1984
|
-
margin(margin){
|
|
1985
|
-
margin=addSuffixeToNumber(margin,"px");
|
|
1986
|
-
this.style({ margin }, { target, maskVector });
|
|
1987
|
-
return this;
|
|
1988
|
-
}
|
|
1989
|
-
marginTop(marginTop){
|
|
1990
|
-
marginTop=addSuffixeToNumber(marginTop,"px");
|
|
1991
|
-
this.style({marginTop});
|
|
1992
|
-
return this;
|
|
1993
|
-
}
|
|
1994
|
-
marginRight(marginRight){
|
|
1995
|
-
marginRight=addSuffixeToNumber(marginRight,"px");
|
|
1996
|
-
this.style({marginRight});
|
|
1997
|
-
return this;
|
|
1998
|
-
}
|
|
1999
|
-
marginBootom(marginBootom){
|
|
2000
|
-
marginBootom=addSuffixeToNumber(marginBootom,"px");
|
|
2001
|
-
this.style({marginBootom});
|
|
2002
|
-
return this;
|
|
2003
|
-
}
|
|
2004
|
-
marginLeft(marginLeft){
|
|
2005
|
-
marginLeft=addSuffixeToNumber(marginLeft,"px");
|
|
2006
|
-
this.style({marginLeft});
|
|
2007
|
-
return this;
|
|
2008
|
-
}
|
|
2009
|
-
padding(padding){
|
|
2010
|
-
padding=addSuffixeToNumber(padding,"px");
|
|
2011
|
-
this.style({padding});
|
|
2012
|
-
return this;
|
|
2013
|
-
}
|
|
2014
|
-
paddingTop(paddingTop){
|
|
2015
|
-
paddingTop=addSuffixeToNumber(paddingTop,"px");
|
|
2016
|
-
this.style({paddingTop});
|
|
2017
|
-
return this;
|
|
2018
|
-
}
|
|
2019
|
-
paddingRight(paddingRight){
|
|
2020
|
-
paddingRight=addSuffixeToNumber(paddingRight,"px");
|
|
2021
|
-
this.style({paddingRight});
|
|
2022
|
-
return this;
|
|
2023
|
-
}
|
|
2024
|
-
paddingBootom(paddingBootom){
|
|
2025
|
-
paddingBootom=addSuffixeToNumber(paddingBootom,"px");
|
|
2026
|
-
this.style({paddingBootom});
|
|
2027
|
-
return this;
|
|
2028
|
-
}
|
|
2029
|
-
paddingLeft(paddingLeft){
|
|
2030
|
-
paddingLeft=addSuffixeToNumber(paddingLeft,"px");
|
|
2031
|
-
this.style({paddingLeft});
|
|
2032
|
-
return this;
|
|
2033
|
-
}
|
|
2034
|
-
// Typographie
|
|
2035
|
-
font(font){
|
|
2036
|
-
this.style({font});
|
|
2037
|
-
return this;
|
|
2038
|
-
}
|
|
2039
|
-
fontFamily(fontFamily=""){
|
|
2040
|
-
this.style({fontFamily});
|
|
2041
|
-
return this;
|
|
2042
|
-
}
|
|
2043
|
-
fontSize(fontSize){
|
|
2044
|
-
this.style({fontSize});
|
|
2045
|
-
return this;
|
|
2046
|
-
}
|
|
2047
|
-
// Misc
|
|
2048
|
-
cursor(type="pointer"){
|
|
2049
|
-
this.style({ cursor: type });
|
|
2050
|
-
return this;
|
|
2051
|
-
}
|
|
2052
|
-
overflow(x,y){
|
|
2053
|
-
const values=["hidden","auto"];
|
|
2054
|
-
this.style({
|
|
2055
|
-
overflowX:typeof x==="number"?values[x]:x,
|
|
2056
|
-
overflowY:typeof y==="number"?values[y]:y
|
|
2057
|
-
},{target,maskVector});
|
|
2058
|
-
return this;
|
|
2059
|
-
}
|
|
2060
|
-
clip(polygon, { target, maskVector } = {}) {
|
|
2061
|
-
if (typeof polygon === "string") polygon = "polygon(" + polygon + ")";
|
|
2062
|
-
this.style({ clipPath: polygon }, { target, maskVector });
|
|
2063
|
-
return this;
|
|
2064
|
-
}
|
|
2065
|
-
// Transfromations
|
|
2066
|
-
fadeOut(transitionTimming = 1) {
|
|
2067
|
-
this.style({
|
|
2068
|
-
transition:`opacity ${transitionTimming/1000}s`,
|
|
2069
|
-
opacity: 0
|
|
2070
|
-
});
|
|
2071
|
-
this.cache.isFaddedOut=true;
|
|
2072
|
-
return this;
|
|
2073
|
-
}
|
|
2074
|
-
fadeIn(transitionTimming = 1) {
|
|
2075
|
-
this.style({
|
|
2076
|
-
transition: `opacity ${transitionTimming/1000}s`,
|
|
2077
|
-
opacity: 1
|
|
2078
|
-
});
|
|
2079
|
-
this.cache.isFaddedOut=false;
|
|
2080
|
-
return this;
|
|
2081
|
-
}
|
|
2082
|
-
toggleFade(t_in = 1000,t_out=t_in){
|
|
2083
|
-
this.cache.isFaddedOut?this.fadeIn(t_in):this.fadeOut(t_out);
|
|
2084
|
-
return this;
|
|
2085
|
-
}
|
|
2086
|
-
morphBorderRadius(newValue, transitionTimming){
|
|
2087
|
-
this.style({
|
|
2088
|
-
borderRadius: newValue,
|
|
2089
|
-
transition: `borderRadius ${transitionTimming/1000}s`,
|
|
2090
|
-
});
|
|
2091
|
-
return this;
|
|
2092
|
-
}
|
|
2093
|
-
#applyTransformMatrix(transitionTimming){
|
|
2094
|
-
const transformMatrix = this.cache.transformation.matrix.arr.join(",");
|
|
2095
|
-
this.style({
|
|
2096
|
-
transform: `matrix3d(${transformMatrix})`,
|
|
2097
|
-
"-webkit-transform": `matrix3d(${transformMatrix})`,
|
|
2098
|
-
"-moz-transform": `matrix3d(${transformMatrix})`,
|
|
2099
|
-
"-ms-transform": `matrix3d(${transformMatrix})`,
|
|
2100
|
-
"-o-transform": `matrix3d(${transformMatrix})`
|
|
2101
|
-
});
|
|
2102
|
-
if (transitionTimming != 0) this.style({ transition: `transform ${transitionTimming/1000}s ease` });
|
|
2103
|
-
}
|
|
2104
|
-
translate(dx, dy = dx ,dz = 0, transitionTimming = 0) {
|
|
2105
|
-
this.cache.transformation.matrix.set(3,0,dx);
|
|
2106
|
-
this.cache.transformation.matrix.set(3,1,dy);
|
|
2107
|
-
this.cache.transformation.matrix.set(3,2,dz);
|
|
2108
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2109
|
-
return this;
|
|
2110
|
-
}
|
|
2111
|
-
translateX(dx, transitionTimming = 0) {
|
|
2112
|
-
this.cache.transformation.matrix.set(3,0,dx);
|
|
2113
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2114
|
-
return this;
|
|
2115
|
-
}
|
|
2116
|
-
translateY(dy, transitionTimming = 0) {
|
|
2117
|
-
this.cache.transformation.matrix.set(3,1,dy);
|
|
2118
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2119
|
-
return this;
|
|
2120
|
-
}
|
|
2121
|
-
translateZ(dz, transitionTimming = 0) {
|
|
2122
|
-
const d=-1/this.cache.transformation.matrix[2][2];
|
|
2123
|
-
this.cache.transformation.matrix.set(3,2,z);
|
|
2124
|
-
this.cache.transformation.matrix.set(3,3,1-(dz/d));
|
|
2125
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2126
|
-
return this;
|
|
2127
|
-
}
|
|
2128
|
-
perspective(distance,transitionTimming=0){
|
|
2129
|
-
const z=this.cache.transformation.matrix[3][2];
|
|
2130
|
-
this.cache.transformation.matrix.set(2,2,-1/d);
|
|
2131
|
-
this.cache.transformation.matrix.set(3,3,1-(z/distance));
|
|
2132
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2133
|
-
return this;
|
|
2134
|
-
}
|
|
2135
|
-
scale(sx, sy = sx, transitionTimming = 0) {
|
|
2136
|
-
this.cache.transformation.matrix.set(0,0,sx);
|
|
2137
|
-
this.cache.transformation.matrix.set(1,1,sy);
|
|
2138
|
-
// const transformMatrix = this.cache.transformation.matrix.arr.join(",");
|
|
2139
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2140
|
-
return this;
|
|
2141
|
-
}
|
|
2142
|
-
scaleX(x = 1 , transitionTimming = 0) {
|
|
2143
|
-
this.cache.transformation.matrix.set(0,0,x);
|
|
2144
|
-
// const transformMatrix = this.cache.transformation.matrix.arr.join(",");
|
|
2145
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2146
|
-
return this;
|
|
2147
|
-
}
|
|
2148
|
-
scaleY(y = 1, transitionTimming = 0) {
|
|
2149
|
-
this.cache.transformation.matrix.set(1,1,y);
|
|
2150
|
-
this.cache.transformation.matrix.arr.join(",");
|
|
2151
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2152
|
-
return this;
|
|
2153
|
-
}
|
|
2154
|
-
skew(x, y = x, transitionTimming = 0) {
|
|
2155
|
-
this.cache.transformation.matrix.set(0,1,x);
|
|
2156
|
-
this.cache.transformation.matrix.set(1,0,y);
|
|
2157
|
-
this.cache.transformation.matrix.arr.join(",");
|
|
2158
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2159
|
-
return this;
|
|
2160
|
-
}
|
|
2161
|
-
skewX(x = 1 , transitionTimming = 0) {
|
|
2162
|
-
this.cache.transformation.matrix.set(0,1,x);
|
|
2163
|
-
this.cache.transformation.matrix.arr.join(",");
|
|
2164
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2165
|
-
return this;
|
|
2166
|
-
}
|
|
2167
|
-
skewY(y = 1, transitionTimming = 0) {
|
|
2168
|
-
this.cache.transformation.matrix.set(1,0,y);
|
|
2169
|
-
this.cache.transformation.matrix.arr.join(",");
|
|
2170
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2171
|
-
return this;
|
|
2172
|
-
}
|
|
2173
|
-
rotateX(rx, transitionTimming = 0) {
|
|
2174
|
-
this.cache.transformation.matrix.set(1,1,cos(rx));
|
|
2175
|
-
this.cache.transformation.matrix.set(1,2,-sin(rx));
|
|
2176
|
-
this.cache.transformation.matrix.set(2,1,sin(rx));
|
|
2177
|
-
this.cache.transformation.matrix.set(1,2,cos(rx));
|
|
2178
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2179
|
-
return this;
|
|
2180
|
-
}
|
|
2181
|
-
rotateY(ry, transitionTimming = 0) {
|
|
2182
|
-
this.cache.transformation.matrix.set(0,0,cos(ry));
|
|
2183
|
-
this.cache.transformation.matrix.set(0,2,sin(ry));
|
|
2184
|
-
this.cache.transformation.matrix.set(2,0,-sin(ry));
|
|
2185
|
-
this.cache.transformation.matrix.set(2,2,cos(ry));
|
|
2186
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2187
|
-
return this;
|
|
2188
|
-
}
|
|
2189
|
-
rotateZ(rz, transitionTimming = 0) {
|
|
2190
|
-
this.cache.transformation.matrix.set(0,0,cos(rz));
|
|
2191
|
-
this.cache.transformation.matrix.set(0,1,-sin(rz));
|
|
2192
|
-
this.cache.transformation.matrix.set(1,0,sin(rz));
|
|
2193
|
-
this.cache.transformation.matrix.set(1,1,cos(rz));
|
|
2194
|
-
this.#applyTransformMatrix(transitionTimming);
|
|
2195
|
-
return this;
|
|
2196
|
-
}
|
|
2197
|
-
flipeX(transitionTimming = 1) {
|
|
2198
|
-
this.cache.transformation.Flip[0] += 180;
|
|
2199
|
-
this.cache.transformation.Flip[0] %= 360;
|
|
2200
|
-
this.rotateX(this.cache.transformation.Flip[0], transitionTimming);
|
|
2201
|
-
return this;
|
|
2202
|
-
}
|
|
2203
|
-
flipeY(transitionTimming = 1) {
|
|
2204
|
-
this.cache.transformation.Flip[1] += 180 ;
|
|
2205
|
-
this.cache.transformation.Flip[1] %= 360;
|
|
2206
|
-
this.rotateY(this.cache.transformation.Flip[1], transitionTimming);
|
|
2207
|
-
return this;
|
|
2208
|
-
}
|
|
2209
|
-
flipeZ(transitionTimming = 1) {
|
|
2210
|
-
this.cache.transformation.Flip[2] += 180;
|
|
2211
|
-
this.cache.transformation.Flip[2] %= 360;
|
|
2212
|
-
this.rotateZ(this.cache.transformation.Flip[2], transitionTimming);
|
|
2213
|
-
return this;
|
|
2214
|
-
}
|
|
2215
|
-
slideHeightIn(transitionTimming = 1, h = this.h) {
|
|
2216
|
-
this.style({ transition: transitionTimming + "s", height: h });
|
|
2217
|
-
return this;
|
|
2218
|
-
}
|
|
2219
|
-
slideHeightOut(transitionTimming = 1) {
|
|
2220
|
-
this.style({ transition: transitionTimming + "s", height: 0 });
|
|
2221
|
-
this.target?.element?.n("transitionend", () =>
|
|
2222
|
-
this.style({ opacity: "none" }),
|
|
2223
|
-
);
|
|
2224
|
-
return this;
|
|
2225
|
-
}
|
|
2226
|
-
slideWidthIn(transitionTimming = 1, w = this.w) {
|
|
2227
|
-
this.style({ transition: transitionTimming + "s", width: w });
|
|
2228
|
-
return this;
|
|
2229
|
-
}
|
|
2230
|
-
slideWidthOut(transitionTimming = 1) {
|
|
2231
|
-
this.style({ transition: transitionTimming + "s", width: 0 });
|
|
2232
|
-
const wrapper=()=>{
|
|
2233
|
-
this.style({ opacity: "none" });
|
|
2234
|
-
};
|
|
2235
|
-
this.target?.element?.addEventListener("transitionend",wrapper);
|
|
2236
|
-
this.target?.element?.removeEventListener("transitionend",wrapper);
|
|
2237
|
-
return this;
|
|
2238
|
-
}
|
|
2239
|
-
slideIn({ transitionTimming = 1, w = "100%", h = "auto" } = {}) {
|
|
2240
|
-
this.style({
|
|
2241
|
-
transition: transitionTimming + "s",
|
|
2242
|
-
width: w,
|
|
2243
|
-
height: h,
|
|
2244
|
-
visibility: "visible",
|
|
2245
|
-
});
|
|
2246
|
-
return this;
|
|
2247
|
-
}
|
|
2248
|
-
slideOut({ transitionTimming = 1, width = 0, heightransitionTimming = 0 } = {}) {
|
|
2249
|
-
this.style({
|
|
2250
|
-
visibility: "hidden",
|
|
2251
|
-
transition: transitionTimming + "s",
|
|
2252
|
-
opacity: "none",
|
|
2253
|
-
width: width,
|
|
2254
|
-
height: height,
|
|
2255
|
-
});
|
|
2256
|
-
const wrapper=()=>{
|
|
2257
|
-
this.style({ opacity: "none" });
|
|
2258
|
-
};
|
|
2259
|
-
this.target?.element?.addEventListener("transitionend",wrapper);
|
|
2260
|
-
this.target?.element?.removeEventListener("transitionend",wrapper);
|
|
1708
|
+
},
|
|
1709
|
+
size(width, height){
|
|
1710
|
+
return this.style({width, height})
|
|
1711
|
+
},
|
|
1712
|
+
animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
1713
|
+
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
2261
1714
|
return this;
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
}
|
|
1715
|
+
}
|
|
1716
|
+
};
|
|
2265
1717
|
|
|
2266
1718
|
function EVENT_CONTROLLER(e,EVENT,setter,push_object){
|
|
2267
1719
|
this.event=e;
|
|
@@ -3288,43 +2740,42 @@
|
|
|
3288
2740
|
}
|
|
3289
2741
|
};
|
|
3290
2742
|
|
|
3291
|
-
|
|
3292
|
-
globalThis
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3299
|
-
|
|
2743
|
+
function __init__global__(){
|
|
2744
|
+
if ( !globalThis?.__Ziko__ ){
|
|
2745
|
+
globalThis.__Ziko__ = {
|
|
2746
|
+
__UI__,
|
|
2747
|
+
__HYDRATION__,
|
|
2748
|
+
__HYDRATION_MAP__,
|
|
2749
|
+
__Config__,
|
|
2750
|
+
__CACHE__,
|
|
2751
|
+
};
|
|
2752
|
+
defineParamsGetter$1(__Ziko__);
|
|
2753
|
+
}
|
|
3300
2754
|
}
|
|
3301
2755
|
|
|
3302
|
-
|
|
3303
|
-
|
|
2756
|
+
__init__global__();
|
|
2757
|
+
class UIElement extends UINode{
|
|
2758
|
+
constructor({element, name ='', type="html", useDefaultStyle=false}={}){
|
|
3304
2759
|
super();
|
|
3305
2760
|
this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
|
|
3306
2761
|
if(typeof element === "string") {
|
|
3307
|
-
switch(
|
|
2762
|
+
switch(type){
|
|
3308
2763
|
case "html" : element = globalThis?.document?.createElement(element); break;
|
|
3309
2764
|
case "svg" : element = globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", element);
|
|
3310
2765
|
default : throw Error("Not supported")
|
|
3311
2766
|
}
|
|
3312
2767
|
}
|
|
3313
2768
|
else {
|
|
3314
|
-
this.target = element
|
|
2769
|
+
this.target = element?.parentElement;
|
|
3315
2770
|
}
|
|
3316
|
-
|
|
3317
|
-
compose(
|
|
2771
|
+
register(
|
|
3318
2772
|
this,
|
|
3319
|
-
|
|
3320
|
-
|
|
2773
|
+
AttrsMethods,
|
|
2774
|
+
DomMethods,
|
|
2775
|
+
StyleMethods,
|
|
2776
|
+
IndexingMethods,
|
|
3321
2777
|
EventsMethodes
|
|
3322
2778
|
);
|
|
3323
|
-
// if(false){
|
|
3324
|
-
// import("../methods/tree.js").then(({ default: ExternalMethods }) => {
|
|
3325
|
-
// compose(this, ExternalMethods);
|
|
3326
|
-
// });
|
|
3327
|
-
// }
|
|
3328
2779
|
Object.assign(this.cache, {
|
|
3329
2780
|
name,
|
|
3330
2781
|
isInteractive : [true, false][Math.floor(2*Math.random())],
|
|
@@ -3334,7 +2785,6 @@
|
|
|
3334
2785
|
isHidden: false,
|
|
3335
2786
|
isFrozzen:false,
|
|
3336
2787
|
legacyParent : null,
|
|
3337
|
-
style: new ZikoUIElementStyle({}),
|
|
3338
2788
|
attributes: {},
|
|
3339
2789
|
filters: {},
|
|
3340
2790
|
temp:{}
|
|
@@ -3359,7 +2809,6 @@
|
|
|
3359
2809
|
if(element)Object.assign(this.cache,{element});
|
|
3360
2810
|
this.uuid = `${this.cache.name}-${Random.string(16)}`;
|
|
3361
2811
|
this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
|
|
3362
|
-
this.cache.style.linkTo(this);
|
|
3363
2812
|
useDefaultStyle && this.style({
|
|
3364
2813
|
position: "relative",
|
|
3365
2814
|
boxSizing:"border-box",
|
|
@@ -3392,10 +2841,6 @@
|
|
|
3392
2841
|
isZikoUIElement(){
|
|
3393
2842
|
return true;
|
|
3394
2843
|
}
|
|
3395
|
-
register(){
|
|
3396
|
-
|
|
3397
|
-
return this;
|
|
3398
|
-
}
|
|
3399
2844
|
get st(){
|
|
3400
2845
|
return this.cache.style;
|
|
3401
2846
|
}
|
|
@@ -3445,25 +2890,17 @@
|
|
|
3445
2890
|
else UI.element=this.element.cloneNode(true);
|
|
3446
2891
|
return UI.render(render);
|
|
3447
2892
|
}
|
|
3448
|
-
style(styles){
|
|
3449
|
-
styles instanceof ZikoUseStyle ? this.st.style(styles.current): this.st.style(styles);
|
|
3450
|
-
return this;
|
|
3451
|
-
}
|
|
3452
|
-
size(width,height){
|
|
3453
|
-
this.st.size(width,height);
|
|
3454
|
-
return this;
|
|
3455
|
-
}
|
|
3456
2893
|
[Symbol.iterator]() {
|
|
3457
2894
|
return this.items[Symbol.iterator]();
|
|
3458
2895
|
}
|
|
3459
2896
|
maintain() {
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
2897
|
+
for (let i = 0; i < this.items.length; i++) {
|
|
2898
|
+
Object.defineProperty(this, i, {
|
|
2899
|
+
value: this.items[i],
|
|
2900
|
+
writable: true,
|
|
2901
|
+
configurable: true,
|
|
2902
|
+
enumerable: false
|
|
2903
|
+
});
|
|
3467
2904
|
}
|
|
3468
2905
|
}
|
|
3469
2906
|
freeze(freeze){
|
|
@@ -3481,43 +2918,6 @@
|
|
|
3481
2918
|
describe(label){
|
|
3482
2919
|
if(label)this.setAttr("aria-label",label);
|
|
3483
2920
|
}
|
|
3484
|
-
animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
|
|
3485
|
-
this.element?.animate(keyframe,{duration, iterations, easing});
|
|
3486
|
-
return this;
|
|
3487
|
-
}
|
|
3488
|
-
// Attributes
|
|
3489
|
-
#setAttr(name, value){
|
|
3490
|
-
if(this.element?.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
|
|
3491
|
-
if(this?.attr[name] && this?.attr[name]===value) return;
|
|
3492
|
-
this.element?.setAttribute(name, value);
|
|
3493
|
-
Object.assign(this.cache.attributes, {[name]:value});
|
|
3494
|
-
}
|
|
3495
|
-
setAttr(name, value) {
|
|
3496
|
-
if(name instanceof Object){
|
|
3497
|
-
const [names,values]=[Object.keys(name),Object.values(name)];
|
|
3498
|
-
for(let i=0;i<names.length;i++){
|
|
3499
|
-
if(values[i] instanceof Array)value[i] = values[i].join(" ");
|
|
3500
|
-
this.#setAttr(names[i], values[i]);
|
|
3501
|
-
}
|
|
3502
|
-
}
|
|
3503
|
-
else {
|
|
3504
|
-
if(value instanceof Array)value = value.join(" ");
|
|
3505
|
-
this.#setAttr(name, value);
|
|
3506
|
-
}
|
|
3507
|
-
return this;
|
|
3508
|
-
}
|
|
3509
|
-
removeAttr(...names) {
|
|
3510
|
-
for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
|
|
3511
|
-
return this;
|
|
3512
|
-
}
|
|
3513
|
-
getAttr(name){
|
|
3514
|
-
name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
|
|
3515
|
-
return this.element.attributes[name].value;
|
|
3516
|
-
}
|
|
3517
|
-
setContentEditable(bool = true) {
|
|
3518
|
-
this.setAttr("contenteditable", bool);
|
|
3519
|
-
return this;
|
|
3520
|
-
}
|
|
3521
2921
|
get children() {
|
|
3522
2922
|
return [...this.element.children];
|
|
3523
2923
|
}
|
|
@@ -3716,23 +3116,32 @@
|
|
|
3716
3116
|
get(target, prop) {
|
|
3717
3117
|
if (typeof prop !== 'string') return undefined;
|
|
3718
3118
|
let tag = prop.replaceAll("_","-").toLowerCase();
|
|
3119
|
+
let type ;
|
|
3120
|
+
if(HTMLTags.includes(tag)) type = 'html';
|
|
3121
|
+
if(SVGTags.includes(tag)) type = 'svg';
|
|
3719
3122
|
if(HTMLTags.includes(tag)) return (...args)=>{
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
//
|
|
3123
|
+
console.log(isStateGetter(args[0]));
|
|
3124
|
+
// if(typeof args[0] === 'function') {
|
|
3125
|
+
// console.log(args[0], args[0]?.() instanceof StateGetter)
|
|
3126
|
+
// globalThis.a = args[0]
|
|
3127
|
+
// console.log({t : a.constructor})
|
|
3128
|
+
// }
|
|
3129
|
+
if(
|
|
3130
|
+
['string', 'number'].includes(typeof args[0])
|
|
3131
|
+
|| args[0] instanceof UIElement
|
|
3132
|
+
|| (typeof args[0] === 'function' && args[0]().isStateGetter())
|
|
3133
|
+
) return new UIElement({element :tag, name : tag, type}).append(...args);
|
|
3134
|
+
return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
|
|
3135
|
+
}
|
|
3136
|
+
// if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
|
|
3137
|
+
// return (...args)=>{
|
|
3138
|
+
// if(!(args[0] instanceof UIElement) && args[0] instanceof Object){
|
|
3139
|
+
// let attributes = args.shift()
|
|
3140
|
+
// return new UIElement(tag).setAttr(attributes).append(...args)
|
|
3141
|
+
// }
|
|
3142
|
+
// return new UIElement(tag).append(...args);
|
|
3143
|
+
// }
|
|
3144
|
+
// // switch(tag){
|
|
3736
3145
|
// case "html" : globalThis?.document?.createElement("html")
|
|
3737
3146
|
// case "head" :
|
|
3738
3147
|
// case "style" :
|
|
@@ -3740,14 +3149,14 @@
|
|
|
3740
3149
|
// case "meta" :
|
|
3741
3150
|
// case "srcipt":
|
|
3742
3151
|
// case "body" : return null; break;
|
|
3743
|
-
// default : return new
|
|
3152
|
+
// default : return new UIElement(tag);
|
|
3744
3153
|
// }
|
|
3745
3154
|
}
|
|
3746
3155
|
});
|
|
3747
3156
|
|
|
3748
|
-
class ZikoUIFlex extends
|
|
3157
|
+
class ZikoUIFlex extends UIElement {
|
|
3749
3158
|
constructor(tag = "div", w = "100%", h = "100%") {
|
|
3750
|
-
super(tag ,"Flex");
|
|
3159
|
+
super({element : tag , name : "Flex"});
|
|
3751
3160
|
this.direction = "cols";
|
|
3752
3161
|
if (typeof w == "number") w += "%";
|
|
3753
3162
|
if (typeof h == "number") h += "%";
|
|
@@ -3815,13 +3224,13 @@
|
|
|
3815
3224
|
}
|
|
3816
3225
|
}
|
|
3817
3226
|
|
|
3818
|
-
const Flex = (...
|
|
3227
|
+
const Flex = (...UIElement) =>{
|
|
3819
3228
|
let tag="div";
|
|
3820
|
-
if(typeof
|
|
3821
|
-
tag=
|
|
3822
|
-
|
|
3229
|
+
if(typeof UIElement[0]==="string"){
|
|
3230
|
+
tag=UIElement[0];
|
|
3231
|
+
UIElement.pop();
|
|
3823
3232
|
}
|
|
3824
|
-
return new ZikoUIFlex(tag).append(...
|
|
3233
|
+
return new ZikoUIFlex(tag).append(...UIElement);
|
|
3825
3234
|
};
|
|
3826
3235
|
function set_vertical(direction){
|
|
3827
3236
|
direction == 1
|
|
@@ -3844,9 +3253,9 @@
|
|
|
3844
3253
|
return map_pos_x(-align);
|
|
3845
3254
|
}
|
|
3846
3255
|
|
|
3847
|
-
class ZikoUIGrid extends
|
|
3256
|
+
class ZikoUIGrid extends UIElement {
|
|
3848
3257
|
constructor(tag ="div", w = "50vw", h = "50vh") {
|
|
3849
|
-
super(tag,"Grid");
|
|
3258
|
+
super({element : tag, name : "Grid"});
|
|
3850
3259
|
this.direction = "cols";
|
|
3851
3260
|
if (typeof w == "number") w += "%";
|
|
3852
3261
|
if (typeof h == "number") h += "%";
|
|
@@ -3874,11 +3283,11 @@
|
|
|
3874
3283
|
return this;
|
|
3875
3284
|
}
|
|
3876
3285
|
}
|
|
3877
|
-
const Grid$1 = (...
|
|
3286
|
+
const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
|
|
3878
3287
|
|
|
3879
|
-
class ZikoUISuspense extends
|
|
3288
|
+
class ZikoUISuspense extends UIElement{
|
|
3880
3289
|
constructor(fallback_ui, callback){
|
|
3881
|
-
super("div", "suspense");
|
|
3290
|
+
super({element : "div", name : "suspense"});
|
|
3882
3291
|
this.setAttr({
|
|
3883
3292
|
dataTemp : "suspense"
|
|
3884
3293
|
});
|
|
@@ -3900,9 +3309,9 @@
|
|
|
3900
3309
|
|
|
3901
3310
|
const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
|
|
3902
3311
|
|
|
3903
|
-
class ZikoUIXMLWrapper extends
|
|
3312
|
+
class ZikoUIXMLWrapper extends UIElement{
|
|
3904
3313
|
constructor(XMLContent, type){
|
|
3905
|
-
super("div", "");
|
|
3314
|
+
super({element : "div", name : ""});
|
|
3906
3315
|
this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
|
|
3907
3316
|
}
|
|
3908
3317
|
}
|
|
@@ -3934,7 +3343,7 @@
|
|
|
3934
3343
|
const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
|
|
3935
3344
|
const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
|
|
3936
3345
|
|
|
3937
|
-
class ZikoUICanvas extends
|
|
3346
|
+
class ZikoUICanvas extends UIElement{
|
|
3938
3347
|
constructor(w,h){
|
|
3939
3348
|
super("canvas","canvas");
|
|
3940
3349
|
this.ctx = this.element?.getContext("2d");
|
|
@@ -4104,7 +3513,7 @@
|
|
|
4104
3513
|
|
|
4105
3514
|
const Canvas=(w,h)=>new ZikoUICanvas(w,h);
|
|
4106
3515
|
|
|
4107
|
-
class ZikoUISvg extends
|
|
3516
|
+
class ZikoUISvg extends UIElement {
|
|
4108
3517
|
constructor(w=360,h=300) {
|
|
4109
3518
|
super("svg","svg");
|
|
4110
3519
|
//this.cache={};
|
|
@@ -5804,8 +5213,7 @@
|
|
|
5804
5213
|
const useAnimation=(callback,ease=Ease.Linear,step=50,config)=>new ZikoTimeAnimation(callback,ease=Ease.Linear,step=50,config);
|
|
5805
5214
|
|
|
5806
5215
|
const debounce=(fn,delay=1000)=>{
|
|
5807
|
-
|
|
5808
|
-
return (...args) => id ? clearTimeout(id) : setTimeout(()=>fn(...args),delay);
|
|
5216
|
+
return (...args) => setTimeout(()=>fn(...args),delay);
|
|
5809
5217
|
};
|
|
5810
5218
|
const throttle=(fn,delay)=>{
|
|
5811
5219
|
let lastTime=0;
|
|
@@ -6292,6 +5700,8 @@
|
|
|
6292
5700
|
exports.Str = Str;
|
|
6293
5701
|
exports.Suspense = Suspense;
|
|
6294
5702
|
exports.Svg = Svg;
|
|
5703
|
+
exports.UIElement = UIElement;
|
|
5704
|
+
exports.UINode = UINode;
|
|
6295
5705
|
exports.Utils = Utils;
|
|
6296
5706
|
exports.ZikoApp = ZikoApp;
|
|
6297
5707
|
exports.ZikoCustomEvent = ZikoCustomEvent;
|
|
@@ -6311,18 +5721,15 @@
|
|
|
6311
5721
|
exports.ZikoMutationObserver = ZikoMutationObserver;
|
|
6312
5722
|
exports.ZikoSPA = ZikoSPA;
|
|
6313
5723
|
exports.ZikoUICanvas = ZikoUICanvas;
|
|
6314
|
-
exports.ZikoUIElement = ZikoUIElement;
|
|
6315
5724
|
exports.ZikoUIFlex = ZikoUIFlex;
|
|
6316
5725
|
exports.ZikoUIGrid = ZikoUIGrid;
|
|
6317
5726
|
exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
|
|
6318
|
-
exports.ZikoUINode = ZikoUINode;
|
|
6319
5727
|
exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
|
|
6320
5728
|
exports.ZikoUISuspense = ZikoUISuspense;
|
|
6321
5729
|
exports.ZikoUISvg = ZikoUISvg;
|
|
6322
5730
|
exports.ZikoUIText = ZikoUIText;
|
|
6323
5731
|
exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
|
|
6324
5732
|
exports.ZikoUseRoot = ZikoUseRoot;
|
|
6325
|
-
exports.ZikoUseStyle = ZikoUseStyle;
|
|
6326
5733
|
exports.__ZikoEvent__ = __ZikoEvent__;
|
|
6327
5734
|
exports.abs = abs;
|
|
6328
5735
|
exports.accum = accum;
|
|
@@ -6449,7 +5856,6 @@
|
|
|
6449
5856
|
exports.useMeta = useMeta;
|
|
6450
5857
|
exports.useRoot = useRoot;
|
|
6451
5858
|
exports.useSessionStorage = useSessionStorage;
|
|
6452
|
-
exports.useStyle = useStyle;
|
|
6453
5859
|
exports.useSuccesifKeys = useSuccesifKeys;
|
|
6454
5860
|
exports.useSwipeEvent = useSwipeEvent;
|
|
6455
5861
|
exports.useThread = useThread;
|