ziko 0.38.1 → 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 CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Sun Aug 17 2025 21:52:49 GMT+0100 (UTC+01:00)
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
@@ -1045,7 +1045,7 @@ const json2xmlFile=(json,indent)=>{
1045
1045
  }
1046
1046
  };
1047
1047
 
1048
- class ZikoUINode {
1048
+ class UINode {
1049
1049
  constructor(node){
1050
1050
  this.cache = {
1051
1051
  node
@@ -1059,7 +1059,7 @@ class ZikoUINode {
1059
1059
  }
1060
1060
  }
1061
1061
 
1062
- globalThis.node = (node) => new ZikoUINode(node);
1062
+ globalThis.node = (node) => new UINode(node);
1063
1063
 
1064
1064
  function register_to_class(target, ...mixins){
1065
1065
  mixins.forEach(n => _register_to_class_(target, n));
@@ -1102,7 +1102,55 @@ const register = (target, ...mixins) => {
1102
1102
  else register_to_instance(target, ...mixins);
1103
1103
  };
1104
1104
 
1105
- class ZikoUIText extends ZikoUINode {
1105
+ const isStateGetter = (arg) => {
1106
+ return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
1107
+ };
1108
+
1109
+ // To Do add getter, watchAttr
1110
+ const AttrsMethods = {
1111
+ setAttr(name, value) {
1112
+ if(name instanceof Object){
1113
+ const [names,values]=[Object.keys(name),Object.values(name)];
1114
+ for(let i=0;i<names.length;i++){
1115
+ if(values[i] instanceof Array)value[i] = values[i].join(" ");
1116
+ _set_attrs_.call(this, names[i], values[i]);
1117
+ }
1118
+ }
1119
+ else {
1120
+ if(value instanceof Array) value = value.join(" ");
1121
+ _set_attrs_.call(this, name, value);
1122
+ }
1123
+ return this;
1124
+ },
1125
+ removeAttr(...names) {
1126
+ for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
1127
+ return this;
1128
+ },
1129
+ getAttr(name){
1130
+ name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
1131
+ return this.element.attributes[name].value;
1132
+ },
1133
+ setContentEditable(bool = true) {
1134
+ this.setAttr("contenteditable", bool);
1135
+ return this;
1136
+ }
1137
+ };
1138
+
1139
+ function _set_attrs_(name, value){
1140
+ if(this.element?.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
1141
+ if(this?.attr[name] && this?.attr[name]===value) return;
1142
+ if(isStateGetter(value)){
1143
+ const getter = value();
1144
+ getter._subscribe(
1145
+ (newValue) => this.element?.setAttribute(name, newValue),
1146
+ this
1147
+ );
1148
+ }
1149
+ else this.element?.setAttribute(name, value);
1150
+ Object.assign(this.cache.attributes, {[name]:value});
1151
+ }
1152
+
1153
+ class ZikoUIText extends UINode {
1106
1154
  constructor(...value) {
1107
1155
  super("span", "text", false, ...value);
1108
1156
  this.element = globalThis?.document?.createTextNode(...value);
@@ -1648,587 +1696,20 @@ const IndexingMethods = {
1648
1696
  },
1649
1697
  };
1650
1698
 
1651
- class ZikoUseStyle {
1652
- constructor(style = {}, use = style.hasOwnProperty("default")? "default" : Object.keys(style)[0], id = 0) {
1653
- this.id = "Ziko-Style-" + id;
1654
- this.keys = new Set();
1655
- this.styles = {
1656
- default: {
1657
- fontSize: "1em",
1658
- color : "green"
1659
- },
1660
- other: {
1661
- fontSize : "2em",
1662
- color : "cyan"
1663
- }
1664
- };
1665
- style && this.add(style);
1666
- use && this.use(use);
1667
- }
1668
-
1669
- get current() {
1670
- return [...this.keys].reduce((key, value) => {
1671
- key[value] = `var(--${value}-${this.id})`;
1672
- return key;
1673
- }, {});
1674
- }
1675
-
1676
- add(name, style = {}) {
1677
- if (name && typeof name === 'object' && !Array.isArray(name)) {
1678
- Object.assign(this.styles, name);
1679
- } else if (typeof name === 'string') {
1680
- Object.assign(this.styles, { [name]: style });
1681
- }
1682
- return this;
1683
- }
1684
-
1685
- #useStyleIndex(index) {
1686
- const keys = Object.keys(this.styles);
1687
- for (let a in this.styles[keys[index]]) {
1688
- if (Object.prototype.hasOwnProperty.call(this.styles[keys[index]], a)) {
1689
- document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[keys[index]][a]);
1690
- this.keys.add(a);
1691
- }
1692
- }
1693
- return this;
1694
- }
1695
-
1696
- #useStyleName(name) {
1697
- if (!this.styles[name]) return this;
1698
- for (let a in this.styles[name]) {
1699
- if (Object.prototype.hasOwnProperty.call(this.styles[name], a)) {
1700
- document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[name][a]);
1701
- this.keys.add(a);
1702
- }
1703
- }
1704
- return this;
1705
- }
1706
-
1707
- #useStyleObject(style) {
1708
- for (let a in style) {
1709
- if (Object.prototype.hasOwnProperty.call(style, a)) {
1710
- document.documentElement.style.setProperty(`--${a}-${this.id}`, style[a]);
1711
- this.keys.add(a);
1712
- }
1713
- }
1714
- return this;
1715
- }
1716
-
1717
- use(style) {
1718
- if (typeof style === "number") return this.#useStyleIndex(style);
1719
- if (typeof style === "string") return this.#useStyleName(style);
1720
- if (style && typeof style === "object") return this.#useStyleObject(style);
1721
- return this;
1722
- }
1723
- }
1724
-
1725
- const useStyle = (styles, use, id) => new ZikoUseStyle(styles, use, id);
1726
-
1727
- const addSuffixeToNumber=(value,suffixe="px")=>{
1728
- if(typeof value === "number") value+=suffixe;
1729
- if(value instanceof Array)value=value.map(n=>typeof n==="number"?n+=suffixe:n).join(" ");
1730
- return value;
1731
- };
1732
-
1733
- class ZikoUIElementStyle{
1734
- constructor(defaultStyle={}){
1735
- this.target=null;
1736
- this.styles=new Map(
1737
- [["default",defaultStyle]]
1738
- );
1739
- this.cache={
1740
- isHidden:false,
1741
- isFaddedOut:false,
1742
- transformation:{
1743
- Flip:[0,0,0],
1744
- matrix:new Matrix([
1745
- [1,0,0,0],
1746
- [0,1,0,0],
1747
- [0,0,1,0],
1748
- [0,0,0,1]
1749
- ])
1750
- }
1751
- };
1752
- }
1699
+ // Process width and height
1700
+ const StyleMethods = {
1753
1701
  style(styles){
1754
- for(const [key, value] of Object.entries(styles)){
1755
- if(Str.isCamelCase(key)){
1756
- delete styles[key];
1757
- Object.assign(styles,{[Str.camel2hyphencase(key)]:value});
1758
- }
1759
- }
1760
- if(this?.target?.element?.style)Object.assign(this?.target?.element?.style, styles);
1761
- return this;
1762
- }
1763
- linkTo(target){
1764
- this.target=target;
1765
- return this;
1766
- }
1767
- use(name="default"){
1768
- this.style(this.styles.get(name));
1769
- return this;
1770
- }
1771
- update(name,styles){
1772
- const old=this.styles.get(name);
1773
- old?this.styles.set(name,Object.assign(old,styles)):this.styles.set(name,styles);
1774
- return this;
1775
- }
1776
- add(name,styles){
1777
- this.styles.set(name,styles);
1778
- return this;
1779
- }
1780
- replace(name,styles){
1781
- this.styles.set(name,styles);
1782
- return this;
1783
- }
1784
- delete(...names){
1785
- names.forEach(n=>this.styles.delete(n));
1786
- return this;
1787
- }
1788
- updateDefaultStyle(){
1789
- const defaultStyle=Object.fromEntries(
1790
- Object.entries(this.target.element.style).filter(n=>isNaN(+n[0]))
1791
- );
1792
- this.update("default",defaultStyle);
1793
- return this;
1794
- }
1795
- hover(styles){
1796
- //this.updateDefaultStyle()
1797
- if(styles)this.add("hover",styles);
1798
- this.target?.element?.addEventListener("pointerenter",()=>this.use("hover"));
1799
- this.target?.element?.addEventListener("pointerleave",()=>this.use("default"));
1800
- return this;
1801
- }
1802
- // Checkers
1803
- isInline(){
1804
- return getComputedStyle(this.target.element).display.includes("inline");
1805
- }
1806
- isBlock(){
1807
- return !(this.isInline());
1808
- }
1809
- // Size
1810
- size(width,height){
1811
- this.style({
1812
- width,
1813
- height
1814
- });
1815
- return this;
1816
- }
1817
- width(w){
1818
- if(w instanceof Object){
1819
- if(w instanceof Array)w={min:w[0],max:w[1]};
1820
- if("min" in w || "max" in w){
1821
- let min= w.min ?? w.max;
1822
- let max= w.max ?? w.min;
1823
- min=addSuffixeToNumber(min,"px");
1824
- max=addSuffixeToNumber(max,"px");
1825
- this.style({ minWidth: min, maxWidth: max }, { target, maskVector });
1826
- }
1827
- }
1828
- else {
1829
- w=addSuffixeToNumber(w,"px");
1830
- this.style({width:w});
1831
- }
1832
- return this
1833
- }
1834
- height(h){
1835
- if(h instanceof Object){
1836
- if(h instanceof Array)h={min:h[0],max:h[1]};
1837
- if("min" in h || "max" in h){
1838
- let min= h.min ?? h.max;
1839
- let max= h.max ?? h.min;
1840
- min=addSuffixeToNumber(min,"px");
1841
- max=addSuffixeToNumber(max,"px");
1842
- this.style({ minHeight: min, maxHeight: max }, { target, maskVector });
1843
- }
1844
- }
1845
- else {
1846
- h=addSuffixeToNumber(h,"px");
1847
- this.style({height:h});
1848
- }
1849
- return this
1850
- }
1851
- enableResize(h=false,v=false){
1852
- let resize="none";
1853
- if(h)v?resize="both":resize="horizontal";
1854
- else v?resize="vertical":resize="none";
1855
- this.style({
1856
- resize,
1857
- overflow:"hidden"
1858
- });
1859
- if(this.isInline()){
1860
- console.group("Ziko Issue : Temporarily Incompatible Method");
1861
- console.warn(".enableResize has no effect on inline elements!");
1862
- 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");
1863
- console.groupEnd();
1864
- }
1865
- return this;
1866
- }
1867
- // Apparence
1868
- hide({after, target, maskVector } = {}){
1869
- if(typeof after==="number"){
1870
- const wrapper=()=>this.hide({target,maskVector});
1871
- setTimeout(wrapper, after);
1872
- clearTimeout(wrapper);
1873
- }
1874
- else {
1875
- this.cache.isHidden=true;
1876
- this.style({display:"none"},{target,maskVector});
1877
- }
1878
- return this;
1879
- }
1880
- show({after, target, maskVector } = {}){
1881
- if(typeof after==="number"){
1882
- const wrapper=()=>this.show({target,maskVector});
1883
- setTimeout(wrapper, after);
1884
- clearTimeout(wrapper);
1885
- }
1886
- else {
1887
- this.cache.isHidden=false;
1888
- this.style({display:""},{target,maskVector});
1889
- }
1890
- return this;
1891
- }
1892
- color(color){
1893
- this.style({color});
1894
- return this;
1895
- }
1896
- background(background){
1897
- this.style({background});
1898
- return this;
1899
- }
1900
- backgroundColor(backgroundColor){
1901
- this.style({backgroundColor});
1902
- return this;
1903
- }
1904
- opacity(opacity, { target, maskVector } = {}) {
1905
- this.style({ opacity }, { target, maskVector });
1906
- return this;
1907
- }
1908
- // Placement
1909
- position(position){
1910
- this.style({position});
1911
- return this
1912
- }
1913
- display(disp, { target, maskVector } = {}) {
1914
- this.style({ display: disp }, { target, maskVector });
1915
- return this;
1916
- }
1917
- zIndex(z){
1918
- this.style({zIndex:z});
1919
- return this;
1920
- }
1921
- float(float, { target, maskVector } = {}) {
1922
- this.style({ float: float }, { target, maskVector });
1923
- return this;
1924
- }
1925
- // Box Model
1926
- border(border = "1px solid red", { target, maskVector } = {}){
1927
- this.style({border}, { target, maskVector });
1928
- return this;
1929
- }
1930
- borderTop(borderTop = "1px solid red", { target, maskVector } = {}){
1931
- this.style({borderTop}, { target, maskVector });
1932
- return this;
1933
- }
1934
- borderRight(borderRight = "1px solid red", { target, maskVector } = {}){
1935
- this.style({borderRight}, { target, maskVector });
1936
- return this;
1937
- }
1938
- borderBottom(borderBottom = "1px solid red", { target, maskVector } = {}){
1939
- this.style({borderBottom}, { target, maskVector });
1702
+ Object.assign(this.element.style, styles);
1940
1703
  return this;
1941
- }
1942
- borderLeft(borderLeft = "1px solid red", { target, maskVector } = {}){
1943
- this.style({borderLeft}, { target, maskVector });
1944
- return this;
1945
- }
1946
- borderRadius(radius){
1947
- radius=addSuffixeToNumber(radius,"px");
1948
- this.style({ borderRadius: radius }, { target, maskVector });
1949
- return this;
1950
- }
1951
- margin(margin){
1952
- margin=addSuffixeToNumber(margin,"px");
1953
- this.style({ margin }, { target, maskVector });
1954
- return this;
1955
- }
1956
- marginTop(marginTop){
1957
- marginTop=addSuffixeToNumber(marginTop,"px");
1958
- this.style({marginTop});
1959
- return this;
1960
- }
1961
- marginRight(marginRight){
1962
- marginRight=addSuffixeToNumber(marginRight,"px");
1963
- this.style({marginRight});
1964
- return this;
1965
- }
1966
- marginBootom(marginBootom){
1967
- marginBootom=addSuffixeToNumber(marginBootom,"px");
1968
- this.style({marginBootom});
1969
- return this;
1970
- }
1971
- marginLeft(marginLeft){
1972
- marginLeft=addSuffixeToNumber(marginLeft,"px");
1973
- this.style({marginLeft});
1974
- return this;
1975
- }
1976
- padding(padding){
1977
- padding=addSuffixeToNumber(padding,"px");
1978
- this.style({padding});
1979
- return this;
1980
- }
1981
- paddingTop(paddingTop){
1982
- paddingTop=addSuffixeToNumber(paddingTop,"px");
1983
- this.style({paddingTop});
1984
- return this;
1985
- }
1986
- paddingRight(paddingRight){
1987
- paddingRight=addSuffixeToNumber(paddingRight,"px");
1988
- this.style({paddingRight});
1989
- return this;
1990
- }
1991
- paddingBootom(paddingBootom){
1992
- paddingBootom=addSuffixeToNumber(paddingBootom,"px");
1993
- this.style({paddingBootom});
1994
- return this;
1995
- }
1996
- paddingLeft(paddingLeft){
1997
- paddingLeft=addSuffixeToNumber(paddingLeft,"px");
1998
- this.style({paddingLeft});
1999
- return this;
2000
- }
2001
- // Typographie
2002
- font(font){
2003
- this.style({font});
2004
- return this;
2005
- }
2006
- fontFamily(fontFamily=""){
2007
- this.style({fontFamily});
2008
- return this;
2009
- }
2010
- fontSize(fontSize){
2011
- this.style({fontSize});
2012
- return this;
2013
- }
2014
- // Misc
2015
- cursor(type="pointer"){
2016
- this.style({ cursor: type });
2017
- return this;
2018
- }
2019
- overflow(x,y){
2020
- const values=["hidden","auto"];
2021
- this.style({
2022
- overflowX:typeof x==="number"?values[x]:x,
2023
- overflowY:typeof y==="number"?values[y]:y
2024
- },{target,maskVector});
2025
- return this;
2026
- }
2027
- clip(polygon, { target, maskVector } = {}) {
2028
- if (typeof polygon === "string") polygon = "polygon(" + polygon + ")";
2029
- this.style({ clipPath: polygon }, { target, maskVector });
2030
- return this;
2031
- }
2032
- // Transfromations
2033
- fadeOut(transitionTimming = 1) {
2034
- this.style({
2035
- transition:`opacity ${transitionTimming/1000}s`,
2036
- opacity: 0
2037
- });
2038
- this.cache.isFaddedOut=true;
2039
- return this;
2040
- }
2041
- fadeIn(transitionTimming = 1) {
2042
- this.style({
2043
- transition: `opacity ${transitionTimming/1000}s`,
2044
- opacity: 1
2045
- });
2046
- this.cache.isFaddedOut=false;
2047
- return this;
2048
- }
2049
- toggleFade(t_in = 1000,t_out=t_in){
2050
- this.cache.isFaddedOut?this.fadeIn(t_in):this.fadeOut(t_out);
2051
- return this;
2052
- }
2053
- morphBorderRadius(newValue, transitionTimming){
2054
- this.style({
2055
- borderRadius: newValue,
2056
- transition: `borderRadius ${transitionTimming/1000}s`,
2057
- });
2058
- return this;
2059
- }
2060
- #applyTransformMatrix(transitionTimming){
2061
- const transformMatrix = this.cache.transformation.matrix.arr.join(",");
2062
- this.style({
2063
- transform: `matrix3d(${transformMatrix})`,
2064
- "-webkit-transform": `matrix3d(${transformMatrix})`,
2065
- "-moz-transform": `matrix3d(${transformMatrix})`,
2066
- "-ms-transform": `matrix3d(${transformMatrix})`,
2067
- "-o-transform": `matrix3d(${transformMatrix})`
2068
- });
2069
- if (transitionTimming != 0) this.style({ transition: `transform ${transitionTimming/1000}s ease` });
2070
- }
2071
- translate(dx, dy = dx ,dz = 0, transitionTimming = 0) {
2072
- this.cache.transformation.matrix.set(3,0,dx);
2073
- this.cache.transformation.matrix.set(3,1,dy);
2074
- this.cache.transformation.matrix.set(3,2,dz);
2075
- this.#applyTransformMatrix(transitionTimming);
2076
- return this;
2077
- }
2078
- translateX(dx, transitionTimming = 0) {
2079
- this.cache.transformation.matrix.set(3,0,dx);
2080
- this.#applyTransformMatrix(transitionTimming);
2081
- return this;
2082
- }
2083
- translateY(dy, transitionTimming = 0) {
2084
- this.cache.transformation.matrix.set(3,1,dy);
2085
- this.#applyTransformMatrix(transitionTimming);
2086
- return this;
2087
- }
2088
- translateZ(dz, transitionTimming = 0) {
2089
- const d=-1/this.cache.transformation.matrix[2][2];
2090
- this.cache.transformation.matrix.set(3,2,z);
2091
- this.cache.transformation.matrix.set(3,3,1-(dz/d));
2092
- this.#applyTransformMatrix(transitionTimming);
2093
- return this;
2094
- }
2095
- perspective(distance,transitionTimming=0){
2096
- const z=this.cache.transformation.matrix[3][2];
2097
- this.cache.transformation.matrix.set(2,2,-1/d);
2098
- this.cache.transformation.matrix.set(3,3,1-(z/distance));
2099
- this.#applyTransformMatrix(transitionTimming);
2100
- return this;
2101
- }
2102
- scale(sx, sy = sx, transitionTimming = 0) {
2103
- this.cache.transformation.matrix.set(0,0,sx);
2104
- this.cache.transformation.matrix.set(1,1,sy);
2105
- // const transformMatrix = this.cache.transformation.matrix.arr.join(",");
2106
- this.#applyTransformMatrix(transitionTimming);
2107
- return this;
2108
- }
2109
- scaleX(x = 1 , transitionTimming = 0) {
2110
- this.cache.transformation.matrix.set(0,0,x);
2111
- // const transformMatrix = this.cache.transformation.matrix.arr.join(",");
2112
- this.#applyTransformMatrix(transitionTimming);
2113
- return this;
2114
- }
2115
- scaleY(y = 1, transitionTimming = 0) {
2116
- this.cache.transformation.matrix.set(1,1,y);
2117
- this.cache.transformation.matrix.arr.join(",");
2118
- this.#applyTransformMatrix(transitionTimming);
2119
- return this;
2120
- }
2121
- skew(x, y = x, transitionTimming = 0) {
2122
- this.cache.transformation.matrix.set(0,1,x);
2123
- this.cache.transformation.matrix.set(1,0,y);
2124
- this.cache.transformation.matrix.arr.join(",");
2125
- this.#applyTransformMatrix(transitionTimming);
2126
- return this;
2127
- }
2128
- skewX(x = 1 , transitionTimming = 0) {
2129
- this.cache.transformation.matrix.set(0,1,x);
2130
- this.cache.transformation.matrix.arr.join(",");
2131
- this.#applyTransformMatrix(transitionTimming);
2132
- return this;
2133
- }
2134
- skewY(y = 1, transitionTimming = 0) {
2135
- this.cache.transformation.matrix.set(1,0,y);
2136
- this.cache.transformation.matrix.arr.join(",");
2137
- this.#applyTransformMatrix(transitionTimming);
2138
- return this;
2139
- }
2140
- rotateX(rx, transitionTimming = 0) {
2141
- this.cache.transformation.matrix.set(1,1,cos(rx));
2142
- this.cache.transformation.matrix.set(1,2,-sin(rx));
2143
- this.cache.transformation.matrix.set(2,1,sin(rx));
2144
- this.cache.transformation.matrix.set(1,2,cos(rx));
2145
- this.#applyTransformMatrix(transitionTimming);
2146
- return this;
2147
- }
2148
- rotateY(ry, transitionTimming = 0) {
2149
- this.cache.transformation.matrix.set(0,0,cos(ry));
2150
- this.cache.transformation.matrix.set(0,2,sin(ry));
2151
- this.cache.transformation.matrix.set(2,0,-sin(ry));
2152
- this.cache.transformation.matrix.set(2,2,cos(ry));
2153
- this.#applyTransformMatrix(transitionTimming);
2154
- return this;
2155
- }
2156
- rotateZ(rz, transitionTimming = 0) {
2157
- this.cache.transformation.matrix.set(0,0,cos(rz));
2158
- this.cache.transformation.matrix.set(0,1,-sin(rz));
2159
- this.cache.transformation.matrix.set(1,0,sin(rz));
2160
- this.cache.transformation.matrix.set(1,1,cos(rz));
2161
- this.#applyTransformMatrix(transitionTimming);
2162
- return this;
2163
- }
2164
- flipeX(transitionTimming = 1) {
2165
- this.cache.transformation.Flip[0] += 180;
2166
- this.cache.transformation.Flip[0] %= 360;
2167
- this.rotateX(this.cache.transformation.Flip[0], transitionTimming);
2168
- return this;
2169
- }
2170
- flipeY(transitionTimming = 1) {
2171
- this.cache.transformation.Flip[1] += 180 ;
2172
- this.cache.transformation.Flip[1] %= 360;
2173
- this.rotateY(this.cache.transformation.Flip[1], transitionTimming);
2174
- return this;
2175
- }
2176
- flipeZ(transitionTimming = 1) {
2177
- this.cache.transformation.Flip[2] += 180;
2178
- this.cache.transformation.Flip[2] %= 360;
2179
- this.rotateZ(this.cache.transformation.Flip[2], transitionTimming);
2180
- return this;
2181
- }
2182
- slideHeightIn(transitionTimming = 1, h = this.h) {
2183
- this.style({ transition: transitionTimming + "s", height: h });
2184
- return this;
2185
- }
2186
- slideHeightOut(transitionTimming = 1) {
2187
- this.style({ transition: transitionTimming + "s", height: 0 });
2188
- this.target?.element?.n("transitionend", () =>
2189
- this.style({ opacity: "none" }),
2190
- );
2191
- return this;
2192
- }
2193
- slideWidthIn(transitionTimming = 1, w = this.w) {
2194
- this.style({ transition: transitionTimming + "s", width: w });
2195
- return this;
2196
- }
2197
- slideWidthOut(transitionTimming = 1) {
2198
- this.style({ transition: transitionTimming + "s", width: 0 });
2199
- const wrapper=()=>{
2200
- this.style({ opacity: "none" });
2201
- };
2202
- this.target?.element?.addEventListener("transitionend",wrapper);
2203
- this.target?.element?.removeEventListener("transitionend",wrapper);
2204
- return this;
2205
- }
2206
- slideIn({ transitionTimming = 1, w = "100%", h = "auto" } = {}) {
2207
- this.style({
2208
- transition: transitionTimming + "s",
2209
- width: w,
2210
- height: h,
2211
- visibility: "visible",
2212
- });
2213
- return this;
2214
- }
2215
- slideOut({ transitionTimming = 1, width = 0, heightransitionTimming = 0 } = {}) {
2216
- this.style({
2217
- visibility: "hidden",
2218
- transition: transitionTimming + "s",
2219
- opacity: "none",
2220
- width: width,
2221
- height: height,
2222
- });
2223
- const wrapper=()=>{
2224
- this.style({ opacity: "none" });
2225
- };
2226
- this.target?.element?.addEventListener("transitionend",wrapper);
2227
- this.target?.element?.removeEventListener("transitionend",wrapper);
1704
+ },
1705
+ size(width, height){
1706
+ return this.style({width, height})
1707
+ },
1708
+ animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
1709
+ this.element?.animate(keyframe,{duration, iterations, easing});
2228
1710
  return this;
2229
- }
2230
-
2231
- }
1711
+ }
1712
+ };
2232
1713
 
2233
1714
  function EVENT_CONTROLLER(e,EVENT,setter,push_object){
2234
1715
  this.event=e;
@@ -3269,8 +2750,8 @@ function __init__global__(){
3269
2750
  }
3270
2751
 
3271
2752
  __init__global__();
3272
- class ZikoUIElement extends ZikoUINode{
3273
- constructor(element, name="", {type="html", useDefaultStyle=false}={}){
2753
+ class UIElement extends UINode{
2754
+ constructor({element, name ='', type="html", useDefaultStyle=false}={}){
3274
2755
  super();
3275
2756
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
3276
2757
  if(typeof element === "string") {
@@ -3281,9 +2762,16 @@ class ZikoUIElement extends ZikoUINode{
3281
2762
  }
3282
2763
  }
3283
2764
  else {
3284
- this.target = element.parentElement;
3285
- }
3286
- register(this, DomMethods, IndexingMethods, EventsMethodes);
2765
+ this.target = element?.parentElement;
2766
+ }
2767
+ register(
2768
+ this,
2769
+ AttrsMethods,
2770
+ DomMethods,
2771
+ StyleMethods,
2772
+ IndexingMethods,
2773
+ EventsMethodes
2774
+ );
3287
2775
  Object.assign(this.cache, {
3288
2776
  name,
3289
2777
  isInteractive : [true, false][Math.floor(2*Math.random())],
@@ -3293,7 +2781,6 @@ class ZikoUIElement extends ZikoUINode{
3293
2781
  isHidden: false,
3294
2782
  isFrozzen:false,
3295
2783
  legacyParent : null,
3296
- style: new ZikoUIElementStyle({}),
3297
2784
  attributes: {},
3298
2785
  filters: {},
3299
2786
  temp:{}
@@ -3318,7 +2805,6 @@ class ZikoUIElement extends ZikoUINode{
3318
2805
  if(element)Object.assign(this.cache,{element});
3319
2806
  this.uuid = `${this.cache.name}-${Random.string(16)}`;
3320
2807
  this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
3321
- this.cache.style.linkTo(this);
3322
2808
  useDefaultStyle && this.style({
3323
2809
  position: "relative",
3324
2810
  boxSizing:"border-box",
@@ -3400,25 +2886,17 @@ class ZikoUIElement extends ZikoUINode{
3400
2886
  else UI.element=this.element.cloneNode(true);
3401
2887
  return UI.render(render);
3402
2888
  }
3403
- style(styles){
3404
- styles instanceof ZikoUseStyle ? this.st.style(styles.current): this.st.style(styles);
3405
- return this;
3406
- }
3407
- size(width,height){
3408
- this.st.size(width,height);
3409
- return this;
3410
- }
3411
2889
  [Symbol.iterator]() {
3412
2890
  return this.items[Symbol.iterator]();
3413
2891
  }
3414
2892
  maintain() {
3415
- for (let i = 0; i < this.items.length; i++) {
3416
- Object.defineProperty(this, i, {
3417
- value: this.items[i],
3418
- writable: true,
3419
- configurable: true,
3420
- enumerable: false
3421
- });
2893
+ for (let i = 0; i < this.items.length; i++) {
2894
+ Object.defineProperty(this, i, {
2895
+ value: this.items[i],
2896
+ writable: true,
2897
+ configurable: true,
2898
+ enumerable: false
2899
+ });
3422
2900
  }
3423
2901
  }
3424
2902
  freeze(freeze){
@@ -3436,43 +2914,6 @@ class ZikoUIElement extends ZikoUINode{
3436
2914
  describe(label){
3437
2915
  if(label)this.setAttr("aria-label",label);
3438
2916
  }
3439
- animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
3440
- this.element?.animate(keyframe,{duration, iterations, easing});
3441
- return this;
3442
- }
3443
- // Attributes
3444
- #setAttr(name, value){
3445
- if(this.element?.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
3446
- if(this?.attr[name] && this?.attr[name]===value) return;
3447
- this.element?.setAttribute(name, value);
3448
- Object.assign(this.cache.attributes, {[name]:value});
3449
- }
3450
- setAttr(name, value) {
3451
- if(name instanceof Object){
3452
- const [names,values]=[Object.keys(name),Object.values(name)];
3453
- for(let i=0;i<names.length;i++){
3454
- if(values[i] instanceof Array)value[i] = values[i].join(" ");
3455
- this.#setAttr(names[i], values[i]);
3456
- }
3457
- }
3458
- else {
3459
- if(value instanceof Array)value = value.join(" ");
3460
- this.#setAttr(name, value);
3461
- }
3462
- return this;
3463
- }
3464
- removeAttr(...names) {
3465
- for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
3466
- return this;
3467
- }
3468
- getAttr(name){
3469
- name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
3470
- return this.element.attributes[name].value;
3471
- }
3472
- setContentEditable(bool = true) {
3473
- this.setAttr("contenteditable", bool);
3474
- return this;
3475
- }
3476
2917
  get children() {
3477
2918
  return [...this.element.children];
3478
2919
  }
@@ -3667,10 +3108,6 @@ const SVGTags = [
3667
3108
  "desc", "title", "metadata", "foreignObject"
3668
3109
  ];
3669
3110
 
3670
- const isStateGetter = (arg) => {
3671
- return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
3672
- };
3673
-
3674
3111
  const tags = new Proxy({}, {
3675
3112
  get(target, prop) {
3676
3113
  if (typeof prop !== 'string') return undefined;
@@ -3687,18 +3124,18 @@ const tags = new Proxy({}, {
3687
3124
  // }
3688
3125
  if(
3689
3126
  ['string', 'number'].includes(typeof args[0])
3690
- || args[0] instanceof ZikoUIElement
3127
+ || args[0] instanceof UIElement
3691
3128
  || (typeof args[0] === 'function' && args[0]().isStateGetter())
3692
- ) return new ZikoUIElement(tag, tag, {type}).append(...args);
3693
- return new ZikoUIElement(tag).setAttr(args.shift()).append(...args)
3129
+ ) return new UIElement({element :tag, name : tag, type}).append(...args);
3130
+ return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
3694
3131
  }
3695
- // if(SVGTags.includes(tag)) return (...args) => new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
3132
+ // if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
3696
3133
  // return (...args)=>{
3697
- // if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
3134
+ // if(!(args[0] instanceof UIElement) && args[0] instanceof Object){
3698
3135
  // let attributes = args.shift()
3699
- // return new ZikoUIElement(tag).setAttr(attributes).append(...args)
3136
+ // return new UIElement(tag).setAttr(attributes).append(...args)
3700
3137
  // }
3701
- // return new ZikoUIElement(tag).append(...args);
3138
+ // return new UIElement(tag).append(...args);
3702
3139
  // }
3703
3140
  // // switch(tag){
3704
3141
  // case "html" : globalThis?.document?.createElement("html")
@@ -3708,14 +3145,14 @@ const tags = new Proxy({}, {
3708
3145
  // case "meta" :
3709
3146
  // case "srcipt":
3710
3147
  // case "body" : return null; break;
3711
- // default : return new ZikoUIElement(tag);
3148
+ // default : return new UIElement(tag);
3712
3149
  // }
3713
3150
  }
3714
3151
  });
3715
3152
 
3716
- class ZikoUIFlex extends ZikoUIElement {
3153
+ class ZikoUIFlex extends UIElement {
3717
3154
  constructor(tag = "div", w = "100%", h = "100%") {
3718
- super(tag ,"Flex");
3155
+ super({element : tag , name : "Flex"});
3719
3156
  this.direction = "cols";
3720
3157
  if (typeof w == "number") w += "%";
3721
3158
  if (typeof h == "number") h += "%";
@@ -3783,13 +3220,13 @@ class ZikoUIFlex extends ZikoUIElement {
3783
3220
  }
3784
3221
  }
3785
3222
 
3786
- const Flex = (...ZikoUIElement) =>{
3223
+ const Flex = (...UIElement) =>{
3787
3224
  let tag="div";
3788
- if(typeof ZikoUIElement[0]==="string"){
3789
- tag=ZikoUIElement[0];
3790
- ZikoUIElement.pop();
3225
+ if(typeof UIElement[0]==="string"){
3226
+ tag=UIElement[0];
3227
+ UIElement.pop();
3791
3228
  }
3792
- return new ZikoUIFlex(tag).append(...ZikoUIElement);
3229
+ return new ZikoUIFlex(tag).append(...UIElement);
3793
3230
  };
3794
3231
  function set_vertical(direction){
3795
3232
  direction == 1
@@ -3812,9 +3249,9 @@ function map_pos_y(align){
3812
3249
  return map_pos_x(-align);
3813
3250
  }
3814
3251
 
3815
- class ZikoUIGrid extends ZikoUIElement {
3252
+ class ZikoUIGrid extends UIElement {
3816
3253
  constructor(tag ="div", w = "50vw", h = "50vh") {
3817
- super(tag,"Grid");
3254
+ super({element : tag, name : "Grid"});
3818
3255
  this.direction = "cols";
3819
3256
  if (typeof w == "number") w += "%";
3820
3257
  if (typeof h == "number") h += "%";
@@ -3842,11 +3279,11 @@ class ZikoUIGrid extends ZikoUIElement {
3842
3279
  return this;
3843
3280
  }
3844
3281
  }
3845
- const Grid$1 = (...ZikoUIElement) => new ZikoUIGrid("div").append(...ZikoUIElement);
3282
+ const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
3846
3283
 
3847
- class ZikoUISuspense extends ZikoUIElement{
3284
+ class ZikoUISuspense extends UIElement{
3848
3285
  constructor(fallback_ui, callback){
3849
- super("div", "suspense");
3286
+ super({element : "div", name : "suspense"});
3850
3287
  this.setAttr({
3851
3288
  dataTemp : "suspense"
3852
3289
  });
@@ -3868,9 +3305,9 @@ class ZikoUISuspense extends ZikoUIElement{
3868
3305
 
3869
3306
  const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
3870
3307
 
3871
- class ZikoUIXMLWrapper extends ZikoUIElement{
3308
+ class ZikoUIXMLWrapper extends UIElement{
3872
3309
  constructor(XMLContent, type){
3873
- super("div", "");
3310
+ super({element : "div", name : ""});
3874
3311
  this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
3875
3312
  }
3876
3313
  }
@@ -3902,7 +3339,7 @@ class ZikoUISVGWrapper extends ZikoUIXMLWrapper{
3902
3339
  const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
3903
3340
  const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
3904
3341
 
3905
- class ZikoUICanvas extends ZikoUIElement{
3342
+ class ZikoUICanvas extends UIElement{
3906
3343
  constructor(w,h){
3907
3344
  super("canvas","canvas");
3908
3345
  this.ctx = this.element?.getContext("2d");
@@ -4072,7 +3509,7 @@ class ZikoUICanvas extends ZikoUIElement{
4072
3509
 
4073
3510
  const Canvas=(w,h)=>new ZikoUICanvas(w,h);
4074
3511
 
4075
- class ZikoUISvg extends ZikoUIElement {
3512
+ class ZikoUISvg extends UIElement {
4076
3513
  constructor(w=360,h=300) {
4077
3514
  super("svg","svg");
4078
3515
  //this.cache={};
@@ -6259,6 +5696,8 @@ exports.SVGWrapper = SVGWrapper;
6259
5696
  exports.Str = Str;
6260
5697
  exports.Suspense = Suspense;
6261
5698
  exports.Svg = Svg;
5699
+ exports.UIElement = UIElement;
5700
+ exports.UINode = UINode;
6262
5701
  exports.Utils = Utils;
6263
5702
  exports.ZikoApp = ZikoApp;
6264
5703
  exports.ZikoCustomEvent = ZikoCustomEvent;
@@ -6278,18 +5717,15 @@ exports.ZikoHead = ZikoHead;
6278
5717
  exports.ZikoMutationObserver = ZikoMutationObserver;
6279
5718
  exports.ZikoSPA = ZikoSPA;
6280
5719
  exports.ZikoUICanvas = ZikoUICanvas;
6281
- exports.ZikoUIElement = ZikoUIElement;
6282
5720
  exports.ZikoUIFlex = ZikoUIFlex;
6283
5721
  exports.ZikoUIGrid = ZikoUIGrid;
6284
5722
  exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
6285
- exports.ZikoUINode = ZikoUINode;
6286
5723
  exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
6287
5724
  exports.ZikoUISuspense = ZikoUISuspense;
6288
5725
  exports.ZikoUISvg = ZikoUISvg;
6289
5726
  exports.ZikoUIText = ZikoUIText;
6290
5727
  exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
6291
5728
  exports.ZikoUseRoot = ZikoUseRoot;
6292
- exports.ZikoUseStyle = ZikoUseStyle;
6293
5729
  exports.__ZikoEvent__ = __ZikoEvent__;
6294
5730
  exports.abs = abs;
6295
5731
  exports.accum = accum;
@@ -6416,7 +5852,6 @@ exports.useMediaQuery = useMediaQuery;
6416
5852
  exports.useMeta = useMeta;
6417
5853
  exports.useRoot = useRoot;
6418
5854
  exports.useSessionStorage = useSessionStorage;
6419
- exports.useStyle = useStyle;
6420
5855
  exports.useSuccesifKeys = useSuccesifKeys;
6421
5856
  exports.useSwipeEvent = useSwipeEvent;
6422
5857
  exports.useThread = useThread;