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.js 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
@@ -1049,7 +1049,7 @@
1049
1049
  }
1050
1050
  };
1051
1051
 
1052
- class ZikoUINode {
1052
+ class UINode {
1053
1053
  constructor(node){
1054
1054
  this.cache = {
1055
1055
  node
@@ -1063,7 +1063,7 @@
1063
1063
  }
1064
1064
  }
1065
1065
 
1066
- globalThis.node = (node) => new ZikoUINode(node);
1066
+ globalThis.node = (node) => new UINode(node);
1067
1067
 
1068
1068
  function register_to_class(target, ...mixins){
1069
1069
  mixins.forEach(n => _register_to_class_(target, n));
@@ -1106,7 +1106,55 @@
1106
1106
  else register_to_instance(target, ...mixins);
1107
1107
  };
1108
1108
 
1109
- class ZikoUIText extends ZikoUINode {
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;
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});
1155
+ }
1156
+
1157
+ class ZikoUIText extends UINode {
1110
1158
  constructor(...value) {
1111
1159
  super("span", "text", false, ...value);
1112
1160
  this.element = globalThis?.document?.createTextNode(...value);
@@ -1652,587 +1700,20 @@
1652
1700
  },
1653
1701
  };
1654
1702
 
1655
- class ZikoUseStyle {
1656
- constructor(style = {}, use = style.hasOwnProperty("default")? "default" : Object.keys(style)[0], id = 0) {
1657
- this.id = "Ziko-Style-" + id;
1658
- this.keys = new Set();
1659
- this.styles = {
1660
- default: {
1661
- fontSize: "1em",
1662
- color : "green"
1663
- },
1664
- other: {
1665
- fontSize : "2em",
1666
- color : "cyan"
1667
- }
1668
- };
1669
- style && this.add(style);
1670
- use && this.use(use);
1671
- }
1672
-
1673
- get current() {
1674
- return [...this.keys].reduce((key, value) => {
1675
- key[value] = `var(--${value}-${this.id})`;
1676
- return key;
1677
- }, {});
1678
- }
1679
-
1680
- add(name, style = {}) {
1681
- if (name && typeof name === 'object' && !Array.isArray(name)) {
1682
- Object.assign(this.styles, name);
1683
- } else if (typeof name === 'string') {
1684
- Object.assign(this.styles, { [name]: style });
1685
- }
1686
- return this;
1687
- }
1688
-
1689
- #useStyleIndex(index) {
1690
- const keys = Object.keys(this.styles);
1691
- for (let a in this.styles[keys[index]]) {
1692
- if (Object.prototype.hasOwnProperty.call(this.styles[keys[index]], a)) {
1693
- document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[keys[index]][a]);
1694
- this.keys.add(a);
1695
- }
1696
- }
1697
- return this;
1698
- }
1699
-
1700
- #useStyleName(name) {
1701
- if (!this.styles[name]) return this;
1702
- for (let a in this.styles[name]) {
1703
- if (Object.prototype.hasOwnProperty.call(this.styles[name], a)) {
1704
- document.documentElement.style.setProperty(`--${a}-${this.id}`, this.styles[name][a]);
1705
- this.keys.add(a);
1706
- }
1707
- }
1708
- return this;
1709
- }
1710
-
1711
- #useStyleObject(style) {
1712
- for (let a in style) {
1713
- if (Object.prototype.hasOwnProperty.call(style, a)) {
1714
- document.documentElement.style.setProperty(`--${a}-${this.id}`, style[a]);
1715
- this.keys.add(a);
1716
- }
1717
- }
1718
- return this;
1719
- }
1720
-
1721
- use(style) {
1722
- if (typeof style === "number") return this.#useStyleIndex(style);
1723
- if (typeof style === "string") return this.#useStyleName(style);
1724
- if (style && typeof style === "object") return this.#useStyleObject(style);
1725
- return this;
1726
- }
1727
- }
1728
-
1729
- const useStyle = (styles, use, id) => new ZikoUseStyle(styles, use, id);
1730
-
1731
- const addSuffixeToNumber=(value,suffixe="px")=>{
1732
- if(typeof value === "number") value+=suffixe;
1733
- if(value instanceof Array)value=value.map(n=>typeof n==="number"?n+=suffixe:n).join(" ");
1734
- return value;
1735
- };
1736
-
1737
- class ZikoUIElementStyle{
1738
- constructor(defaultStyle={}){
1739
- this.target=null;
1740
- this.styles=new Map(
1741
- [["default",defaultStyle]]
1742
- );
1743
- this.cache={
1744
- isHidden:false,
1745
- isFaddedOut:false,
1746
- transformation:{
1747
- Flip:[0,0,0],
1748
- matrix:new Matrix([
1749
- [1,0,0,0],
1750
- [0,1,0,0],
1751
- [0,0,1,0],
1752
- [0,0,0,1]
1753
- ])
1754
- }
1755
- };
1756
- }
1703
+ // Process width and height
1704
+ const StyleMethods = {
1757
1705
  style(styles){
1758
- for(const [key, value] of Object.entries(styles)){
1759
- if(Str.isCamelCase(key)){
1760
- delete styles[key];
1761
- Object.assign(styles,{[Str.camel2hyphencase(key)]:value});
1762
- }
1763
- }
1764
- if(this?.target?.element?.style)Object.assign(this?.target?.element?.style, styles);
1765
- return this;
1766
- }
1767
- linkTo(target){
1768
- this.target=target;
1769
- return this;
1770
- }
1771
- use(name="default"){
1772
- this.style(this.styles.get(name));
1773
- return this;
1774
- }
1775
- update(name,styles){
1776
- const old=this.styles.get(name);
1777
- old?this.styles.set(name,Object.assign(old,styles)):this.styles.set(name,styles);
1778
- return this;
1779
- }
1780
- add(name,styles){
1781
- this.styles.set(name,styles);
1782
- return this;
1783
- }
1784
- replace(name,styles){
1785
- this.styles.set(name,styles);
1786
- return this;
1787
- }
1788
- delete(...names){
1789
- names.forEach(n=>this.styles.delete(n));
1790
- return this;
1791
- }
1792
- updateDefaultStyle(){
1793
- const defaultStyle=Object.fromEntries(
1794
- Object.entries(this.target.element.style).filter(n=>isNaN(+n[0]))
1795
- );
1796
- this.update("default",defaultStyle);
1797
- return this;
1798
- }
1799
- hover(styles){
1800
- //this.updateDefaultStyle()
1801
- if(styles)this.add("hover",styles);
1802
- this.target?.element?.addEventListener("pointerenter",()=>this.use("hover"));
1803
- this.target?.element?.addEventListener("pointerleave",()=>this.use("default"));
1804
- return this;
1805
- }
1806
- // Checkers
1807
- isInline(){
1808
- return getComputedStyle(this.target.element).display.includes("inline");
1809
- }
1810
- isBlock(){
1811
- return !(this.isInline());
1812
- }
1813
- // Size
1814
- size(width,height){
1815
- this.style({
1816
- width,
1817
- height
1818
- });
1819
- return this;
1820
- }
1821
- width(w){
1822
- if(w instanceof Object){
1823
- if(w instanceof Array)w={min:w[0],max:w[1]};
1824
- if("min" in w || "max" in w){
1825
- let min= w.min ?? w.max;
1826
- let max= w.max ?? w.min;
1827
- min=addSuffixeToNumber(min,"px");
1828
- max=addSuffixeToNumber(max,"px");
1829
- this.style({ minWidth: min, maxWidth: max }, { target, maskVector });
1830
- }
1831
- }
1832
- else {
1833
- w=addSuffixeToNumber(w,"px");
1834
- this.style({width:w});
1835
- }
1836
- return this
1837
- }
1838
- height(h){
1839
- if(h instanceof Object){
1840
- if(h instanceof Array)h={min:h[0],max:h[1]};
1841
- if("min" in h || "max" in h){
1842
- let min= h.min ?? h.max;
1843
- let max= h.max ?? h.min;
1844
- min=addSuffixeToNumber(min,"px");
1845
- max=addSuffixeToNumber(max,"px");
1846
- this.style({ minHeight: min, maxHeight: max }, { target, maskVector });
1847
- }
1848
- }
1849
- else {
1850
- h=addSuffixeToNumber(h,"px");
1851
- this.style({height:h});
1852
- }
1853
- return this
1854
- }
1855
- enableResize(h=false,v=false){
1856
- let resize="none";
1857
- if(h)v?resize="both":resize="horizontal";
1858
- else v?resize="vertical":resize="none";
1859
- this.style({
1860
- resize,
1861
- overflow:"hidden"
1862
- });
1863
- if(this.isInline()){
1864
- console.group("Ziko Issue : Temporarily Incompatible Method");
1865
- console.warn(".enableResize has no effect on inline elements!");
1866
- 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");
1867
- console.groupEnd();
1868
- }
1869
- return this;
1870
- }
1871
- // Apparence
1872
- hide({after, target, maskVector } = {}){
1873
- if(typeof after==="number"){
1874
- const wrapper=()=>this.hide({target,maskVector});
1875
- setTimeout(wrapper, after);
1876
- clearTimeout(wrapper);
1877
- }
1878
- else {
1879
- this.cache.isHidden=true;
1880
- this.style({display:"none"},{target,maskVector});
1881
- }
1882
- return this;
1883
- }
1884
- show({after, target, maskVector } = {}){
1885
- if(typeof after==="number"){
1886
- const wrapper=()=>this.show({target,maskVector});
1887
- setTimeout(wrapper, after);
1888
- clearTimeout(wrapper);
1889
- }
1890
- else {
1891
- this.cache.isHidden=false;
1892
- this.style({display:""},{target,maskVector});
1893
- }
1894
- return this;
1895
- }
1896
- color(color){
1897
- this.style({color});
1898
- return this;
1899
- }
1900
- background(background){
1901
- this.style({background});
1902
- return this;
1903
- }
1904
- backgroundColor(backgroundColor){
1905
- this.style({backgroundColor});
1906
- return this;
1907
- }
1908
- opacity(opacity, { target, maskVector } = {}) {
1909
- this.style({ opacity }, { target, maskVector });
1910
- return this;
1911
- }
1912
- // Placement
1913
- position(position){
1914
- this.style({position});
1915
- return this
1916
- }
1917
- display(disp, { target, maskVector } = {}) {
1918
- this.style({ display: disp }, { target, maskVector });
1919
- return this;
1920
- }
1921
- zIndex(z){
1922
- this.style({zIndex:z});
1923
- return this;
1924
- }
1925
- float(float, { target, maskVector } = {}) {
1926
- this.style({ float: float }, { target, maskVector });
1927
- return this;
1928
- }
1929
- // Box Model
1930
- border(border = "1px solid red", { target, maskVector } = {}){
1931
- this.style({border}, { target, maskVector });
1932
- return this;
1933
- }
1934
- borderTop(borderTop = "1px solid red", { target, maskVector } = {}){
1935
- this.style({borderTop}, { target, maskVector });
1936
- return this;
1937
- }
1938
- borderRight(borderRight = "1px solid red", { target, maskVector } = {}){
1939
- this.style({borderRight}, { target, maskVector });
1940
- return this;
1941
- }
1942
- borderBottom(borderBottom = "1px solid red", { target, maskVector } = {}){
1943
- this.style({borderBottom}, { target, maskVector });
1706
+ Object.assign(this.element.style, styles);
1944
1707
  return this;
1945
- }
1946
- borderLeft(borderLeft = "1px solid red", { target, maskVector } = {}){
1947
- this.style({borderLeft}, { target, maskVector });
1948
- return this;
1949
- }
1950
- borderRadius(radius){
1951
- radius=addSuffixeToNumber(radius,"px");
1952
- this.style({ borderRadius: radius }, { target, maskVector });
1953
- return this;
1954
- }
1955
- margin(margin){
1956
- margin=addSuffixeToNumber(margin,"px");
1957
- this.style({ margin }, { target, maskVector });
1958
- return this;
1959
- }
1960
- marginTop(marginTop){
1961
- marginTop=addSuffixeToNumber(marginTop,"px");
1962
- this.style({marginTop});
1963
- return this;
1964
- }
1965
- marginRight(marginRight){
1966
- marginRight=addSuffixeToNumber(marginRight,"px");
1967
- this.style({marginRight});
1968
- return this;
1969
- }
1970
- marginBootom(marginBootom){
1971
- marginBootom=addSuffixeToNumber(marginBootom,"px");
1972
- this.style({marginBootom});
1973
- return this;
1974
- }
1975
- marginLeft(marginLeft){
1976
- marginLeft=addSuffixeToNumber(marginLeft,"px");
1977
- this.style({marginLeft});
1978
- return this;
1979
- }
1980
- padding(padding){
1981
- padding=addSuffixeToNumber(padding,"px");
1982
- this.style({padding});
1983
- return this;
1984
- }
1985
- paddingTop(paddingTop){
1986
- paddingTop=addSuffixeToNumber(paddingTop,"px");
1987
- this.style({paddingTop});
1988
- return this;
1989
- }
1990
- paddingRight(paddingRight){
1991
- paddingRight=addSuffixeToNumber(paddingRight,"px");
1992
- this.style({paddingRight});
1993
- return this;
1994
- }
1995
- paddingBootom(paddingBootom){
1996
- paddingBootom=addSuffixeToNumber(paddingBootom,"px");
1997
- this.style({paddingBootom});
1998
- return this;
1999
- }
2000
- paddingLeft(paddingLeft){
2001
- paddingLeft=addSuffixeToNumber(paddingLeft,"px");
2002
- this.style({paddingLeft});
2003
- return this;
2004
- }
2005
- // Typographie
2006
- font(font){
2007
- this.style({font});
2008
- return this;
2009
- }
2010
- fontFamily(fontFamily=""){
2011
- this.style({fontFamily});
2012
- return this;
2013
- }
2014
- fontSize(fontSize){
2015
- this.style({fontSize});
2016
- return this;
2017
- }
2018
- // Misc
2019
- cursor(type="pointer"){
2020
- this.style({ cursor: type });
2021
- return this;
2022
- }
2023
- overflow(x,y){
2024
- const values=["hidden","auto"];
2025
- this.style({
2026
- overflowX:typeof x==="number"?values[x]:x,
2027
- overflowY:typeof y==="number"?values[y]:y
2028
- },{target,maskVector});
2029
- return this;
2030
- }
2031
- clip(polygon, { target, maskVector } = {}) {
2032
- if (typeof polygon === "string") polygon = "polygon(" + polygon + ")";
2033
- this.style({ clipPath: polygon }, { target, maskVector });
2034
- return this;
2035
- }
2036
- // Transfromations
2037
- fadeOut(transitionTimming = 1) {
2038
- this.style({
2039
- transition:`opacity ${transitionTimming/1000}s`,
2040
- opacity: 0
2041
- });
2042
- this.cache.isFaddedOut=true;
2043
- return this;
2044
- }
2045
- fadeIn(transitionTimming = 1) {
2046
- this.style({
2047
- transition: `opacity ${transitionTimming/1000}s`,
2048
- opacity: 1
2049
- });
2050
- this.cache.isFaddedOut=false;
2051
- return this;
2052
- }
2053
- toggleFade(t_in = 1000,t_out=t_in){
2054
- this.cache.isFaddedOut?this.fadeIn(t_in):this.fadeOut(t_out);
2055
- return this;
2056
- }
2057
- morphBorderRadius(newValue, transitionTimming){
2058
- this.style({
2059
- borderRadius: newValue,
2060
- transition: `borderRadius ${transitionTimming/1000}s`,
2061
- });
2062
- return this;
2063
- }
2064
- #applyTransformMatrix(transitionTimming){
2065
- const transformMatrix = this.cache.transformation.matrix.arr.join(",");
2066
- this.style({
2067
- transform: `matrix3d(${transformMatrix})`,
2068
- "-webkit-transform": `matrix3d(${transformMatrix})`,
2069
- "-moz-transform": `matrix3d(${transformMatrix})`,
2070
- "-ms-transform": `matrix3d(${transformMatrix})`,
2071
- "-o-transform": `matrix3d(${transformMatrix})`
2072
- });
2073
- if (transitionTimming != 0) this.style({ transition: `transform ${transitionTimming/1000}s ease` });
2074
- }
2075
- translate(dx, dy = dx ,dz = 0, transitionTimming = 0) {
2076
- this.cache.transformation.matrix.set(3,0,dx);
2077
- this.cache.transformation.matrix.set(3,1,dy);
2078
- this.cache.transformation.matrix.set(3,2,dz);
2079
- this.#applyTransformMatrix(transitionTimming);
2080
- return this;
2081
- }
2082
- translateX(dx, transitionTimming = 0) {
2083
- this.cache.transformation.matrix.set(3,0,dx);
2084
- this.#applyTransformMatrix(transitionTimming);
2085
- return this;
2086
- }
2087
- translateY(dy, transitionTimming = 0) {
2088
- this.cache.transformation.matrix.set(3,1,dy);
2089
- this.#applyTransformMatrix(transitionTimming);
2090
- return this;
2091
- }
2092
- translateZ(dz, transitionTimming = 0) {
2093
- const d=-1/this.cache.transformation.matrix[2][2];
2094
- this.cache.transformation.matrix.set(3,2,z);
2095
- this.cache.transformation.matrix.set(3,3,1-(dz/d));
2096
- this.#applyTransformMatrix(transitionTimming);
2097
- return this;
2098
- }
2099
- perspective(distance,transitionTimming=0){
2100
- const z=this.cache.transformation.matrix[3][2];
2101
- this.cache.transformation.matrix.set(2,2,-1/d);
2102
- this.cache.transformation.matrix.set(3,3,1-(z/distance));
2103
- this.#applyTransformMatrix(transitionTimming);
2104
- return this;
2105
- }
2106
- scale(sx, sy = sx, transitionTimming = 0) {
2107
- this.cache.transformation.matrix.set(0,0,sx);
2108
- this.cache.transformation.matrix.set(1,1,sy);
2109
- // const transformMatrix = this.cache.transformation.matrix.arr.join(",");
2110
- this.#applyTransformMatrix(transitionTimming);
2111
- return this;
2112
- }
2113
- scaleX(x = 1 , transitionTimming = 0) {
2114
- this.cache.transformation.matrix.set(0,0,x);
2115
- // const transformMatrix = this.cache.transformation.matrix.arr.join(",");
2116
- this.#applyTransformMatrix(transitionTimming);
2117
- return this;
2118
- }
2119
- scaleY(y = 1, transitionTimming = 0) {
2120
- this.cache.transformation.matrix.set(1,1,y);
2121
- this.cache.transformation.matrix.arr.join(",");
2122
- this.#applyTransformMatrix(transitionTimming);
2123
- return this;
2124
- }
2125
- skew(x, y = x, transitionTimming = 0) {
2126
- this.cache.transformation.matrix.set(0,1,x);
2127
- this.cache.transformation.matrix.set(1,0,y);
2128
- this.cache.transformation.matrix.arr.join(",");
2129
- this.#applyTransformMatrix(transitionTimming);
2130
- return this;
2131
- }
2132
- skewX(x = 1 , transitionTimming = 0) {
2133
- this.cache.transformation.matrix.set(0,1,x);
2134
- this.cache.transformation.matrix.arr.join(",");
2135
- this.#applyTransformMatrix(transitionTimming);
2136
- return this;
2137
- }
2138
- skewY(y = 1, transitionTimming = 0) {
2139
- this.cache.transformation.matrix.set(1,0,y);
2140
- this.cache.transformation.matrix.arr.join(",");
2141
- this.#applyTransformMatrix(transitionTimming);
2142
- return this;
2143
- }
2144
- rotateX(rx, transitionTimming = 0) {
2145
- this.cache.transformation.matrix.set(1,1,cos(rx));
2146
- this.cache.transformation.matrix.set(1,2,-sin(rx));
2147
- this.cache.transformation.matrix.set(2,1,sin(rx));
2148
- this.cache.transformation.matrix.set(1,2,cos(rx));
2149
- this.#applyTransformMatrix(transitionTimming);
2150
- return this;
2151
- }
2152
- rotateY(ry, transitionTimming = 0) {
2153
- this.cache.transformation.matrix.set(0,0,cos(ry));
2154
- this.cache.transformation.matrix.set(0,2,sin(ry));
2155
- this.cache.transformation.matrix.set(2,0,-sin(ry));
2156
- this.cache.transformation.matrix.set(2,2,cos(ry));
2157
- this.#applyTransformMatrix(transitionTimming);
2158
- return this;
2159
- }
2160
- rotateZ(rz, transitionTimming = 0) {
2161
- this.cache.transformation.matrix.set(0,0,cos(rz));
2162
- this.cache.transformation.matrix.set(0,1,-sin(rz));
2163
- this.cache.transformation.matrix.set(1,0,sin(rz));
2164
- this.cache.transformation.matrix.set(1,1,cos(rz));
2165
- this.#applyTransformMatrix(transitionTimming);
2166
- return this;
2167
- }
2168
- flipeX(transitionTimming = 1) {
2169
- this.cache.transformation.Flip[0] += 180;
2170
- this.cache.transformation.Flip[0] %= 360;
2171
- this.rotateX(this.cache.transformation.Flip[0], transitionTimming);
2172
- return this;
2173
- }
2174
- flipeY(transitionTimming = 1) {
2175
- this.cache.transformation.Flip[1] += 180 ;
2176
- this.cache.transformation.Flip[1] %= 360;
2177
- this.rotateY(this.cache.transformation.Flip[1], transitionTimming);
2178
- return this;
2179
- }
2180
- flipeZ(transitionTimming = 1) {
2181
- this.cache.transformation.Flip[2] += 180;
2182
- this.cache.transformation.Flip[2] %= 360;
2183
- this.rotateZ(this.cache.transformation.Flip[2], transitionTimming);
2184
- return this;
2185
- }
2186
- slideHeightIn(transitionTimming = 1, h = this.h) {
2187
- this.style({ transition: transitionTimming + "s", height: h });
2188
- return this;
2189
- }
2190
- slideHeightOut(transitionTimming = 1) {
2191
- this.style({ transition: transitionTimming + "s", height: 0 });
2192
- this.target?.element?.n("transitionend", () =>
2193
- this.style({ opacity: "none" }),
2194
- );
2195
- return this;
2196
- }
2197
- slideWidthIn(transitionTimming = 1, w = this.w) {
2198
- this.style({ transition: transitionTimming + "s", width: w });
2199
- return this;
2200
- }
2201
- slideWidthOut(transitionTimming = 1) {
2202
- this.style({ transition: transitionTimming + "s", width: 0 });
2203
- const wrapper=()=>{
2204
- this.style({ opacity: "none" });
2205
- };
2206
- this.target?.element?.addEventListener("transitionend",wrapper);
2207
- this.target?.element?.removeEventListener("transitionend",wrapper);
2208
- return this;
2209
- }
2210
- slideIn({ transitionTimming = 1, w = "100%", h = "auto" } = {}) {
2211
- this.style({
2212
- transition: transitionTimming + "s",
2213
- width: w,
2214
- height: h,
2215
- visibility: "visible",
2216
- });
2217
- return this;
2218
- }
2219
- slideOut({ transitionTimming = 1, width = 0, heightransitionTimming = 0 } = {}) {
2220
- this.style({
2221
- visibility: "hidden",
2222
- transition: transitionTimming + "s",
2223
- opacity: "none",
2224
- width: width,
2225
- height: height,
2226
- });
2227
- const wrapper=()=>{
2228
- this.style({ opacity: "none" });
2229
- };
2230
- this.target?.element?.addEventListener("transitionend",wrapper);
2231
- 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});
2232
1714
  return this;
2233
- }
2234
-
2235
- }
1715
+ }
1716
+ };
2236
1717
 
2237
1718
  function EVENT_CONTROLLER(e,EVENT,setter,push_object){
2238
1719
  this.event=e;
@@ -3273,8 +2754,8 @@
3273
2754
  }
3274
2755
 
3275
2756
  __init__global__();
3276
- class ZikoUIElement extends ZikoUINode{
3277
- constructor(element, name="", {type="html", useDefaultStyle=false}={}){
2757
+ class UIElement extends UINode{
2758
+ constructor({element, name ='', type="html", useDefaultStyle=false}={}){
3278
2759
  super();
3279
2760
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
3280
2761
  if(typeof element === "string") {
@@ -3285,9 +2766,16 @@
3285
2766
  }
3286
2767
  }
3287
2768
  else {
3288
- this.target = element.parentElement;
3289
- }
3290
- register(this, DomMethods, IndexingMethods, EventsMethodes);
2769
+ this.target = element?.parentElement;
2770
+ }
2771
+ register(
2772
+ this,
2773
+ AttrsMethods,
2774
+ DomMethods,
2775
+ StyleMethods,
2776
+ IndexingMethods,
2777
+ EventsMethodes
2778
+ );
3291
2779
  Object.assign(this.cache, {
3292
2780
  name,
3293
2781
  isInteractive : [true, false][Math.floor(2*Math.random())],
@@ -3297,7 +2785,6 @@
3297
2785
  isHidden: false,
3298
2786
  isFrozzen:false,
3299
2787
  legacyParent : null,
3300
- style: new ZikoUIElementStyle({}),
3301
2788
  attributes: {},
3302
2789
  filters: {},
3303
2790
  temp:{}
@@ -3322,7 +2809,6 @@
3322
2809
  if(element)Object.assign(this.cache,{element});
3323
2810
  this.uuid = `${this.cache.name}-${Random.string(16)}`;
3324
2811
  this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
3325
- this.cache.style.linkTo(this);
3326
2812
  useDefaultStyle && this.style({
3327
2813
  position: "relative",
3328
2814
  boxSizing:"border-box",
@@ -3404,25 +2890,17 @@
3404
2890
  else UI.element=this.element.cloneNode(true);
3405
2891
  return UI.render(render);
3406
2892
  }
3407
- style(styles){
3408
- styles instanceof ZikoUseStyle ? this.st.style(styles.current): this.st.style(styles);
3409
- return this;
3410
- }
3411
- size(width,height){
3412
- this.st.size(width,height);
3413
- return this;
3414
- }
3415
2893
  [Symbol.iterator]() {
3416
2894
  return this.items[Symbol.iterator]();
3417
2895
  }
3418
2896
  maintain() {
3419
- for (let i = 0; i < this.items.length; i++) {
3420
- Object.defineProperty(this, i, {
3421
- value: this.items[i],
3422
- writable: true,
3423
- configurable: true,
3424
- enumerable: false
3425
- });
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
+ });
3426
2904
  }
3427
2905
  }
3428
2906
  freeze(freeze){
@@ -3440,43 +2918,6 @@
3440
2918
  describe(label){
3441
2919
  if(label)this.setAttr("aria-label",label);
3442
2920
  }
3443
- animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
3444
- this.element?.animate(keyframe,{duration, iterations, easing});
3445
- return this;
3446
- }
3447
- // Attributes
3448
- #setAttr(name, value){
3449
- if(this.element?.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
3450
- if(this?.attr[name] && this?.attr[name]===value) return;
3451
- this.element?.setAttribute(name, value);
3452
- Object.assign(this.cache.attributes, {[name]:value});
3453
- }
3454
- setAttr(name, value) {
3455
- if(name instanceof Object){
3456
- const [names,values]=[Object.keys(name),Object.values(name)];
3457
- for(let i=0;i<names.length;i++){
3458
- if(values[i] instanceof Array)value[i] = values[i].join(" ");
3459
- this.#setAttr(names[i], values[i]);
3460
- }
3461
- }
3462
- else {
3463
- if(value instanceof Array)value = value.join(" ");
3464
- this.#setAttr(name, value);
3465
- }
3466
- return this;
3467
- }
3468
- removeAttr(...names) {
3469
- for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
3470
- return this;
3471
- }
3472
- getAttr(name){
3473
- name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
3474
- return this.element.attributes[name].value;
3475
- }
3476
- setContentEditable(bool = true) {
3477
- this.setAttr("contenteditable", bool);
3478
- return this;
3479
- }
3480
2921
  get children() {
3481
2922
  return [...this.element.children];
3482
2923
  }
@@ -3671,10 +3112,6 @@
3671
3112
  "desc", "title", "metadata", "foreignObject"
3672
3113
  ];
3673
3114
 
3674
- const isStateGetter = (arg) => {
3675
- return typeof(arg) === 'function' && arg?.()?.isStateGetter?.()
3676
- };
3677
-
3678
3115
  const tags = new Proxy({}, {
3679
3116
  get(target, prop) {
3680
3117
  if (typeof prop !== 'string') return undefined;
@@ -3691,18 +3128,18 @@
3691
3128
  // }
3692
3129
  if(
3693
3130
  ['string', 'number'].includes(typeof args[0])
3694
- || args[0] instanceof ZikoUIElement
3131
+ || args[0] instanceof UIElement
3695
3132
  || (typeof args[0] === 'function' && args[0]().isStateGetter())
3696
- ) return new ZikoUIElement(tag, tag, {type}).append(...args);
3697
- return new ZikoUIElement(tag).setAttr(args.shift()).append(...args)
3133
+ ) return new UIElement({element :tag, name : tag, type}).append(...args);
3134
+ return new UIElement({element : tag}).setAttr(args.shift()).append(...args)
3698
3135
  }
3699
- // if(SVGTags.includes(tag)) return (...args) => new ZikoUIElement(tag,"",{el_type : "svg"}).append(...args);
3136
+ // if(SVGTags.includes(tag)) return (...args) => new UIElement(tag,"",{el_type : "svg"}).append(...args);
3700
3137
  // return (...args)=>{
3701
- // if(!(args[0] instanceof ZikoUIElement) && args[0] instanceof Object){
3138
+ // if(!(args[0] instanceof UIElement) && args[0] instanceof Object){
3702
3139
  // let attributes = args.shift()
3703
- // return new ZikoUIElement(tag).setAttr(attributes).append(...args)
3140
+ // return new UIElement(tag).setAttr(attributes).append(...args)
3704
3141
  // }
3705
- // return new ZikoUIElement(tag).append(...args);
3142
+ // return new UIElement(tag).append(...args);
3706
3143
  // }
3707
3144
  // // switch(tag){
3708
3145
  // case "html" : globalThis?.document?.createElement("html")
@@ -3712,14 +3149,14 @@
3712
3149
  // case "meta" :
3713
3150
  // case "srcipt":
3714
3151
  // case "body" : return null; break;
3715
- // default : return new ZikoUIElement(tag);
3152
+ // default : return new UIElement(tag);
3716
3153
  // }
3717
3154
  }
3718
3155
  });
3719
3156
 
3720
- class ZikoUIFlex extends ZikoUIElement {
3157
+ class ZikoUIFlex extends UIElement {
3721
3158
  constructor(tag = "div", w = "100%", h = "100%") {
3722
- super(tag ,"Flex");
3159
+ super({element : tag , name : "Flex"});
3723
3160
  this.direction = "cols";
3724
3161
  if (typeof w == "number") w += "%";
3725
3162
  if (typeof h == "number") h += "%";
@@ -3787,13 +3224,13 @@
3787
3224
  }
3788
3225
  }
3789
3226
 
3790
- const Flex = (...ZikoUIElement) =>{
3227
+ const Flex = (...UIElement) =>{
3791
3228
  let tag="div";
3792
- if(typeof ZikoUIElement[0]==="string"){
3793
- tag=ZikoUIElement[0];
3794
- ZikoUIElement.pop();
3229
+ if(typeof UIElement[0]==="string"){
3230
+ tag=UIElement[0];
3231
+ UIElement.pop();
3795
3232
  }
3796
- return new ZikoUIFlex(tag).append(...ZikoUIElement);
3233
+ return new ZikoUIFlex(tag).append(...UIElement);
3797
3234
  };
3798
3235
  function set_vertical(direction){
3799
3236
  direction == 1
@@ -3816,9 +3253,9 @@
3816
3253
  return map_pos_x(-align);
3817
3254
  }
3818
3255
 
3819
- class ZikoUIGrid extends ZikoUIElement {
3256
+ class ZikoUIGrid extends UIElement {
3820
3257
  constructor(tag ="div", w = "50vw", h = "50vh") {
3821
- super(tag,"Grid");
3258
+ super({element : tag, name : "Grid"});
3822
3259
  this.direction = "cols";
3823
3260
  if (typeof w == "number") w += "%";
3824
3261
  if (typeof h == "number") h += "%";
@@ -3846,11 +3283,11 @@
3846
3283
  return this;
3847
3284
  }
3848
3285
  }
3849
- const Grid$1 = (...ZikoUIElement) => new ZikoUIGrid("div").append(...ZikoUIElement);
3286
+ const Grid$1 = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
3850
3287
 
3851
- class ZikoUISuspense extends ZikoUIElement{
3288
+ class ZikoUISuspense extends UIElement{
3852
3289
  constructor(fallback_ui, callback){
3853
- super("div", "suspense");
3290
+ super({element : "div", name : "suspense"});
3854
3291
  this.setAttr({
3855
3292
  dataTemp : "suspense"
3856
3293
  });
@@ -3872,9 +3309,9 @@
3872
3309
 
3873
3310
  const Suspense = (fallback_ui, callback) => new ZikoUISuspense(fallback_ui, callback);
3874
3311
 
3875
- class ZikoUIXMLWrapper extends ZikoUIElement{
3312
+ class ZikoUIXMLWrapper extends UIElement{
3876
3313
  constructor(XMLContent, type){
3877
- super("div", "");
3314
+ super({element : "div", name : ""});
3878
3315
  this.element.append(type==="svg"?svg2dom(XMLContent):html2dom(XMLContent));
3879
3316
  }
3880
3317
  }
@@ -3906,7 +3343,7 @@
3906
3343
  const HTMLWrapper = (HTMLContent) => new ZikoUIHTMLWrapper(HTMLContent);
3907
3344
  const SVGWrapper = (SVGContent) => new ZikoUISVGWrapper(SVGContent);
3908
3345
 
3909
- class ZikoUICanvas extends ZikoUIElement{
3346
+ class ZikoUICanvas extends UIElement{
3910
3347
  constructor(w,h){
3911
3348
  super("canvas","canvas");
3912
3349
  this.ctx = this.element?.getContext("2d");
@@ -4076,7 +3513,7 @@
4076
3513
 
4077
3514
  const Canvas=(w,h)=>new ZikoUICanvas(w,h);
4078
3515
 
4079
- class ZikoUISvg extends ZikoUIElement {
3516
+ class ZikoUISvg extends UIElement {
4080
3517
  constructor(w=360,h=300) {
4081
3518
  super("svg","svg");
4082
3519
  //this.cache={};
@@ -6263,6 +5700,8 @@
6263
5700
  exports.Str = Str;
6264
5701
  exports.Suspense = Suspense;
6265
5702
  exports.Svg = Svg;
5703
+ exports.UIElement = UIElement;
5704
+ exports.UINode = UINode;
6266
5705
  exports.Utils = Utils;
6267
5706
  exports.ZikoApp = ZikoApp;
6268
5707
  exports.ZikoCustomEvent = ZikoCustomEvent;
@@ -6282,18 +5721,15 @@
6282
5721
  exports.ZikoMutationObserver = ZikoMutationObserver;
6283
5722
  exports.ZikoSPA = ZikoSPA;
6284
5723
  exports.ZikoUICanvas = ZikoUICanvas;
6285
- exports.ZikoUIElement = ZikoUIElement;
6286
5724
  exports.ZikoUIFlex = ZikoUIFlex;
6287
5725
  exports.ZikoUIGrid = ZikoUIGrid;
6288
5726
  exports.ZikoUIHTMLWrapper = ZikoUIHTMLWrapper;
6289
- exports.ZikoUINode = ZikoUINode;
6290
5727
  exports.ZikoUISVGWrapper = ZikoUISVGWrapper;
6291
5728
  exports.ZikoUISuspense = ZikoUISuspense;
6292
5729
  exports.ZikoUISvg = ZikoUISvg;
6293
5730
  exports.ZikoUIText = ZikoUIText;
6294
5731
  exports.ZikoUIXMLWrapper = ZikoUIXMLWrapper;
6295
5732
  exports.ZikoUseRoot = ZikoUseRoot;
6296
- exports.ZikoUseStyle = ZikoUseStyle;
6297
5733
  exports.__ZikoEvent__ = __ZikoEvent__;
6298
5734
  exports.abs = abs;
6299
5735
  exports.accum = accum;
@@ -6420,7 +5856,6 @@
6420
5856
  exports.useMeta = useMeta;
6421
5857
  exports.useRoot = useRoot;
6422
5858
  exports.useSessionStorage = useSessionStorage;
6423
- exports.useStyle = useStyle;
6424
5859
  exports.useSuccesifKeys = useSuccesifKeys;
6425
5860
  exports.useSwipeEvent = useSwipeEvent;
6426
5861
  exports.useThread = useThread;