ziko 0.0.17 → 0.0.19

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.
Files changed (267) hide show
  1. package/README.md +91 -200
  2. package/package.json +17 -46
  3. package/src/__helpers__/index.js +61 -61
  4. package/src/app/json-style-sheet.js +64 -64
  5. package/src/app/spa-file-based-routing.js +0 -1
  6. package/src/app/ziko-app.js +38 -38
  7. package/src/data/api/fetchdom.js +13 -13
  8. package/src/data/api/index.js +3 -3
  9. package/src/data/api/preload.js +10 -10
  10. package/src/data/converter/adoc.js +130 -130
  11. package/src/data/converter/array.js +42 -42
  12. package/src/data/converter/canvas.js +24 -24
  13. package/src/data/converter/css.js +36 -36
  14. package/src/data/converter/csv.js +32 -32
  15. package/src/data/converter/idea.txt +9 -9
  16. package/src/data/converter/index.js +36 -36
  17. package/src/data/converter/json.js +80 -80
  18. package/src/data/converter/markdown.js +95 -95
  19. package/src/data/converter/object.js +69 -69
  20. package/src/data/converter/svg.js +10 -10
  21. package/src/data/datatypes/color.js +11 -0
  22. package/src/data/index.js +16 -16
  23. package/src/data/parser/xml.js +46 -46
  24. package/src/data/string/patterns.js +11 -11
  25. package/src/data/string/string.js +169 -169
  26. package/src/global/{themes → _themes}/dark.js +884 -884
  27. package/src/global/{themes → _themes}/index.js +10 -10
  28. package/src/global/{themes → _themes}/light.js +254 -254
  29. package/src/global/app/index.js +45 -45
  30. package/src/global/component/index.js +38 -38
  31. package/src/global/globals/index.js +20 -20
  32. package/src/global/index.js +3 -11
  33. package/src/global/params/index.js +39 -39
  34. package/src/global/router/index.js +66 -66
  35. package/src/global/seo/index.js +42 -42
  36. package/src/graphics/canvas/canvas.js +176 -189
  37. package/src/graphics/canvas/elements/Basic/arc.js +42 -42
  38. package/src/graphics/canvas/elements/Basic/line.js +25 -25
  39. package/src/graphics/canvas/elements/Basic/points.js +47 -47
  40. package/src/graphics/canvas/elements/Basic/polygon.js +6 -6
  41. package/src/graphics/canvas/elements/Basic/rect.js +45 -45
  42. package/src/graphics/canvas/elements/Chart/scatter.js +2 -2
  43. package/src/graphics/canvas/elements/Element.js +114 -114
  44. package/src/graphics/canvas/elements/index.js +13 -13
  45. package/src/graphics/canvas/index.js +2 -15
  46. package/src/graphics/canvas/utils/color.js +7 -7
  47. package/src/graphics/canvas/utils/floodFill.js +57 -57
  48. package/src/graphics/index.js +10 -69
  49. package/src/graphics/svg/Elements/Basic/circle.js +29 -26
  50. package/src/graphics/svg/Elements/Basic/ellipse.js +24 -21
  51. package/src/graphics/svg/Elements/Basic/{foreignObject.js → foreign-object.js} +36 -33
  52. package/src/graphics/svg/Elements/Basic/groupe.js +32 -29
  53. package/src/graphics/svg/Elements/Basic/image.js +36 -33
  54. package/src/graphics/svg/Elements/Basic/index.js +11 -0
  55. package/src/graphics/svg/Elements/Basic/line.js +32 -29
  56. package/src/graphics/svg/Elements/Basic/link.js +33 -30
  57. package/src/graphics/svg/Elements/Basic/path.js +62 -59
  58. package/src/graphics/svg/Elements/Basic/polygon.js +31 -31
  59. package/src/graphics/svg/Elements/Basic/polyline.js +7 -4
  60. package/src/graphics/svg/Elements/Basic/rect.js +46 -43
  61. package/src/graphics/svg/Elements/Basic/text.js +29 -26
  62. package/src/graphics/svg/Elements/Derived/grid.js +8 -8
  63. package/src/graphics/svg/Elements/Derived/index.js +1 -0
  64. package/src/graphics/svg/Elements/index.js +2 -14
  65. package/src/graphics/svg/Elements/{ZikoSvgElement.js → ziko-svg-element.js} +48 -46
  66. package/src/graphics/svg/index.js +2 -2
  67. package/src/graphics/svg/svg.js +68 -114
  68. package/src/index.js +85 -84
  69. package/src/math/calculus/index.js +2 -2
  70. package/src/math/calculus/special-functions/bessel.js +30 -30
  71. package/src/math/calculus/special-functions/beta.js +37 -37
  72. package/src/math/calculus/special-functions/gamma.js +29 -29
  73. package/src/math/calculus/special-functions/index.js +4 -4
  74. package/src/math/complex/index.js +202 -202
  75. package/src/math/const.js +2 -2
  76. package/src/math/discret/Combinaison/index.js +33 -33
  77. package/src/math/discret/Conversion/index.js +85 -85
  78. package/src/math/discret/Logic/index.js +45 -45
  79. package/src/math/discret/Permutation/index.js +30 -30
  80. package/src/math/discret/Set/index.js +1 -1
  81. package/src/math/discret/Set/power-set.js +14 -14
  82. package/src/math/discret/Set/sub-set.js +10 -10
  83. package/src/math/discret/index.js +11 -11
  84. package/src/math/functions/index.js +161 -161
  85. package/src/math/index.js +32 -32
  86. package/src/math/matrix/Decomposition.js +90 -90
  87. package/src/math/matrix/LinearSystem.js +9 -9
  88. package/src/math/matrix/Matrix.js +716 -716
  89. package/src/math/matrix/index.js +2 -2
  90. package/src/math/random/index.js +172 -172
  91. package/src/math/signal/__np.py.txt +39 -39
  92. package/src/math/signal/conv.js +174 -174
  93. package/src/math/signal/fft.js +54 -54
  94. package/src/math/signal/filter.js +38 -38
  95. package/src/math/signal/functions.js +145 -145
  96. package/src/math/signal/index.js +109 -109
  97. package/src/math/statistics/Functions/index.js +99 -99
  98. package/src/math/statistics/index.js +15 -15
  99. package/src/math/utils/arithmetic.js +138 -138
  100. package/src/math/utils/checkers.js +29 -29
  101. package/src/math/utils/conversions.js +19 -19
  102. package/src/math/utils/discret.js +51 -51
  103. package/src/math/utils/index.js +101 -101
  104. package/src/math/utils/mapfun.js +49 -49
  105. package/src/reactivity/events/Input.js +61 -61
  106. package/src/reactivity/events/Pointer.js +231 -231
  107. package/src/reactivity/events/ZikoEvent.js +90 -90
  108. package/src/reactivity/events/click.js +59 -59
  109. package/src/reactivity/events/clipboard.js +87 -87
  110. package/src/reactivity/events/custom-event.js +56 -56
  111. package/src/reactivity/events/drag.js +136 -136
  112. package/src/reactivity/events/focus.js +58 -58
  113. package/src/reactivity/events/hash.js +46 -46
  114. package/src/reactivity/events/index.js +12 -63
  115. package/src/reactivity/events/key.js +101 -101
  116. package/src/reactivity/events/mouse.js +232 -232
  117. package/src/reactivity/events/swipe.js +149 -149
  118. package/src/reactivity/events/wheel.js +46 -46
  119. package/src/reactivity/hooks/{contexte → Contexte}/useSuccesifKeys.js +13 -13
  120. package/src/reactivity/hooks/{decorators → Decorators}/index.js +6 -6
  121. package/src/reactivity/hooks/{decorators → Decorators}/time.js +16 -16
  122. package/src/reactivity/hooks/{decorators → Decorators}/type.js +87 -87
  123. package/src/reactivity/hooks/{head/useCssText.js → Head/_useCssText.js} +20 -20
  124. package/src/reactivity/hooks/{head → Head}/index.js +5 -5
  125. package/src/reactivity/hooks/{head → Head}/useFavIcon.js +37 -37
  126. package/src/reactivity/hooks/{head → Head}/useHead.js +27 -27
  127. package/src/reactivity/hooks/{head → Head}/useMeta.js +52 -52
  128. package/src/reactivity/hooks/{head → Head}/useTitle.js +29 -29
  129. package/src/reactivity/hooks/{interactions/useBluetooth.js → Interactions/_useBluetooth.js} +47 -47
  130. package/src/reactivity/hooks/{interactions → Interactions}/index.js +4 -4
  131. package/src/reactivity/hooks/{interactions → Interactions}/useChannel.js +49 -49
  132. package/src/reactivity/hooks/{interactions → Interactions}/useEventEmmiter.js +63 -63
  133. package/src/reactivity/hooks/{interactions → Interactions}/useThread.js +43 -43
  134. package/src/reactivity/hooks/Sensors/index.js +2 -0
  135. package/src/reactivity/hooks/{sensors → Sensors}/useBattery.js +35 -35
  136. package/src/reactivity/hooks/{sensors → Sensors}/useGeolocation.js +16 -16
  137. package/src/reactivity/hooks/{storage → Storage}/useStorage.js +72 -72
  138. package/src/reactivity/hooks/{ui → UI}/index.js +6 -5
  139. package/src/reactivity/hooks/{ui → UI}/useMediaQuery.js +43 -43
  140. package/src/reactivity/hooks/UI/useRoot.js +39 -0
  141. package/src/reactivity/hooks/{ui → UI}/useStyle.js +79 -79
  142. package/src/reactivity/hooks/{ui → UI}/useTheme.js +61 -61
  143. package/src/reactivity/hooks/index.js +8 -91
  144. package/src/reactivity/hooks/todo.md +26 -26
  145. package/src/reactivity/idea +1 -1
  146. package/src/reactivity/index.js +11 -11
  147. package/src/reactivity/observer/attributes.js +28 -28
  148. package/src/reactivity/observer/children.js +36 -36
  149. package/src/reactivity/observer/index.js +6 -6
  150. package/src/reactivity/observer/intersection.js +43 -43
  151. package/src/reactivity/observer/mutation.js +112 -112
  152. package/src/reactivity/observer/resize.js +46 -46
  153. package/src/reactivity/observer/screen.js +44 -44
  154. package/src/reactivity/observer/screen.js.txt +83 -83
  155. package/src/reactivity/observer/screen.txt +12 -12
  156. package/src/time/animation.js +75 -75
  157. package/src/time/index.js +11 -11
  158. package/src/time/loop.js +87 -87
  159. package/src/time/utils/decorators.js +16 -16
  160. package/src/time/utils/ease.js +143 -143
  161. package/src/time/utils/index.js +17 -17
  162. package/src/time/utils/performance.js +15 -15
  163. package/src/time/utils/ui.js +25 -25
  164. package/src/types.js +73 -73
  165. package/src/ui/elements/derived/accordion/accordion.js +42 -42
  166. package/src/ui/elements/derived/accordion/collapsible.js +82 -82
  167. package/src/ui/elements/derived/accordion/index.js +1 -1
  168. package/src/ui/elements/derived/alert/alert.js +80 -80
  169. package/src/ui/elements/derived/alert/palette.js +51 -51
  170. package/src/ui/elements/derived/carousel/index.js +50 -50
  171. package/src/ui/elements/derived/code-note/SubElements.js.txt +104 -104
  172. package/src/ui/elements/derived/code-note/code-cell.js +194 -194
  173. package/src/ui/elements/derived/code-note/code-note.js +71 -71
  174. package/src/ui/elements/derived/code-note/index.js +1 -1
  175. package/src/ui/elements/derived/code-note/sub-elements.js +66 -66
  176. package/src/ui/elements/derived/elements/Swipper.js +3 -3
  177. package/src/ui/elements/derived/elements/index.js +9 -9
  178. package/src/ui/elements/derived/flex/index.js +102 -102
  179. package/src/ui/elements/derived/grid/index.js +32 -32
  180. package/src/ui/elements/derived/index.js +11 -11
  181. package/src/ui/elements/derived/menu/menu3d.js +259 -259
  182. package/src/ui/elements/derived/modal/index.js +91 -91
  183. package/src/ui/elements/derived/pagination/breadcrumbs.js +53 -53
  184. package/src/ui/elements/derived/slider/__ZikoUISlider__.js +111 -111
  185. package/src/ui/elements/derived/slider/hSlider.js +33 -33
  186. package/src/ui/elements/derived/slider/index.js +11 -11
  187. package/src/ui/elements/derived/slider/vSlider.js +26 -26
  188. package/src/ui/elements/derived/splitter/__ZikoUISplitter__.js +61 -61
  189. package/src/ui/elements/derived/splitter/hsplitter.js +39 -39
  190. package/src/ui/elements/derived/splitter/index.js +11 -11
  191. package/src/ui/elements/derived/splitter/vsplitter.js +39 -39
  192. package/src/ui/elements/derived/tabs/index.js +179 -179
  193. package/src/ui/elements/primitives/ZikoUIContainerElement.js +163 -126
  194. package/src/ui/elements/primitives/ZikoUIElement.js +492 -492
  195. package/src/ui/elements/primitives/embaded/html.js +19 -19
  196. package/src/ui/elements/primitives/embaded/index.js +3 -3
  197. package/src/ui/elements/primitives/embaded/pdf.js +16 -16
  198. package/src/ui/elements/primitives/embaded/youtube.js +23 -23
  199. package/src/ui/elements/primitives/index.js +7 -7
  200. package/src/ui/elements/primitives/io/Form/index.js +41 -41
  201. package/src/ui/elements/primitives/io/Form/index.js.txt +104 -104
  202. package/src/ui/elements/primitives/io/Inputs/__helpers__.js +51 -51
  203. package/src/ui/elements/primitives/io/Inputs/index.js +12 -12
  204. package/src/ui/elements/primitives/io/Inputs/input/index.js +98 -98
  205. package/src/ui/elements/primitives/io/Inputs/input-camera/index.js +26 -26
  206. package/src/ui/elements/primitives/io/Inputs/input-checkbox/index.js +25 -25
  207. package/src/ui/elements/primitives/io/Inputs/input-color/index.js +15 -15
  208. package/src/ui/elements/primitives/io/Inputs/input-date-time/index.js +2 -2
  209. package/src/ui/elements/primitives/io/Inputs/input-date-time/input-date-time.js +13 -13
  210. package/src/ui/elements/primitives/io/Inputs/input-date-time/input-date.js +13 -13
  211. package/src/ui/elements/primitives/io/Inputs/input-date-time/input-time.js +13 -13
  212. package/src/ui/elements/primitives/io/Inputs/input-email-password/index.js +1 -1
  213. package/src/ui/elements/primitives/io/Inputs/input-email-password/input-email.js +14 -14
  214. package/src/ui/elements/primitives/io/Inputs/input-email-password/input-password.js +13 -13
  215. package/src/ui/elements/primitives/io/Inputs/input-file/input-image.js +42 -42
  216. package/src/ui/elements/primitives/io/Inputs/input-number/index.js +36 -36
  217. package/src/ui/elements/primitives/io/Inputs/input-radio/index.js +25 -25
  218. package/src/ui/elements/primitives/io/Inputs/input-search/index.js +45 -45
  219. package/src/ui/elements/primitives/io/Inputs/input-slider/index.js +34 -34
  220. package/src/ui/elements/primitives/io/Select/index.js +19 -19
  221. package/src/ui/elements/primitives/io/Textarea/index.js +17 -17
  222. package/src/ui/elements/primitives/io/index.js +3 -3
  223. package/src/ui/elements/primitives/list/index.js +138 -138
  224. package/src/ui/elements/primitives/media/Audio/index.js +16 -16
  225. package/src/ui/elements/primitives/media/Image/figure.js +18 -18
  226. package/src/ui/elements/primitives/media/Image/image.js +36 -36
  227. package/src/ui/elements/primitives/media/Image/index.js +1 -1
  228. package/src/ui/elements/primitives/media/Video/index.js +26 -26
  229. package/src/ui/elements/primitives/media/__ZikoUIDynamicMediaELement__.js +46 -46
  230. package/src/ui/elements/primitives/media/index.js +2 -2
  231. package/src/ui/elements/primitives/misc/index.js +101 -101
  232. package/src/ui/elements/primitives/misc/xml-wrapper.js +3 -2
  233. package/src/ui/elements/primitives/semantic/index.js +81 -81
  234. package/src/ui/elements/primitives/table/elements.js +93 -93
  235. package/src/ui/elements/primitives/table/index.js +2 -2
  236. package/src/ui/elements/primitives/table/table.js +115 -115
  237. package/src/ui/elements/primitives/table/utils.js +11 -11
  238. package/src/ui/elements/primitives/text/__ZikoUIText__.js +71 -71
  239. package/src/ui/elements/primitives/text/heading.js +35 -35
  240. package/src/ui/elements/primitives/text/index.js +2 -2
  241. package/src/ui/elements/primitives/text/p.js +26 -26
  242. package/src/ui/elements/primitives/text/text.js +80 -80
  243. package/src/ui/index.js +37 -37
  244. package/src/ui/style/index.js +504 -515
  245. package/src/ui/utils/index.js +69 -69
  246. package/starter/bin/index.js +11 -11
  247. package/dist/ziko.cjs +0 -14018
  248. package/dist/ziko.js +0 -14028
  249. package/dist/ziko.min.js +0 -9
  250. package/dist/ziko.mjs +0 -13688
  251. package/src/graphics/canvas/elements/Groupe.js +0 -0
  252. package/src/graphics/canvas/elements/grid.js +0 -0
  253. package/src/graphics/canvas/filter/index.js +0 -0
  254. package/src/graphics/canvas/paint/index.js +0 -0
  255. package/src/reactivity/hooks/sensors/index.js +0 -2
  256. /package/src/reactivity/hooks/{contexte → Contexte}/index.js +0 -0
  257. /package/src/reactivity/hooks/{interactions → Interactions}/useSerial.js +0 -0
  258. /package/src/reactivity/hooks/{interactions → Interactions}/useUsb.js +0 -0
  259. /package/src/reactivity/hooks/{sensors → Sensors}/useCamera.js +0 -0
  260. /package/src/reactivity/hooks/{sensors → Sensors}/useMicro.js +0 -0
  261. /package/src/reactivity/hooks/{sensors → Sensors}/useOrientation.js +0 -0
  262. /package/src/reactivity/hooks/{storage → Storage}/index.js +0 -0
  263. /package/src/reactivity/hooks/{storage → Storage}/useCookie.js +0 -0
  264. /package/src/reactivity/hooks/{storage → Storage}/useIndexedDb.js +0 -0
  265. /package/src/reactivity/hooks/{ui → UI}/useCssLink.js +0 -0
  266. /package/src/reactivity/hooks/{ui → UI}/useLinearGradient.js +0 -0
  267. /package/src/reactivity/hooks/{ui → UI}/useRadialGradient.js +0 -0
@@ -1,492 +1,492 @@
1
- import { ZikoUseStyle } from "../../../reactivity/hooks/UI/useStyle.js";
2
- import { ZikoUIElementStyle } from "../../style/index.js";
3
- import {
4
- usePointerEvent,
5
- useMouseEvent,
6
- useWheelEvent,
7
- useKeyEvent,
8
- useDragEvent ,
9
- useDropEvent,
10
- useClickEvent ,
11
- useClipboardEvent ,
12
- useFocusEvent,
13
- useCustomEvent,
14
- useSwipeEvent,
15
- watchIntersection,
16
- watchSize,
17
- watchAttr,
18
- watchChildren
19
- } from "../../../reactivity/index.js"
20
- import { Random } from "../../../math/index.js";
21
- import { Str } from "../../../data/index.js";
22
- class ZikoUIElement {
23
- constructor(element ,name="") {
24
- this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
25
- if(typeof element === "string") {
26
- element === "svg" ? element=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", "svg"): element = globalThis?.document?.createElement(element);
27
- }
28
- this.element = element;
29
- this.uuid=this.constructor.name+"-"+Random.string(10);
30
- this.cache = {
31
- name,
32
- parent:null,
33
- isBody:false,
34
- isRoot:false,
35
- isHidden: false,
36
- isFrozzen:false,
37
- legacyParent : null,
38
- style: new ZikoUIElementStyle({}),
39
- attributes: {},
40
- filters: {},
41
- temp:{}
42
- };
43
- this.events = {
44
- ptr:null,
45
- mouse:null,
46
- wheel:null,
47
- key:null,
48
- drag:null,
49
- drop:null,
50
- click:null,
51
- clipboard:null,
52
- focus:null,
53
- swipe:null,
54
- custom:null,
55
- }
56
- this.observer={
57
- resize:null,
58
- intersection:null
59
- }
60
- this.cache.style.linkTo(this);
61
- this.style({
62
- position: "relative",
63
- boxSizing:"border-box",
64
- // fontFamily:"verdana",
65
- margin:0,
66
- padding:0,
67
- });
68
- this.size("auto", "auto");
69
- globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
70
- globalThis.__Ziko__.__Config__.default.render && this.render()
71
- }
72
- get isZikoUIElement(){
73
- return true
74
- }
75
- get st(){
76
- return this.cache.style;
77
- }
78
- get attr(){
79
- return this.cache.attributes;
80
- }
81
- get evt(){
82
- return this.cache.events;
83
- }
84
- get html(){
85
- return this.element.innerHTML;
86
- }
87
- get text(){
88
- return this.element.textContent;
89
- }
90
- get isBody(){
91
- return this.element === globalThis?.document.body;
92
- }
93
- get __app__(){
94
- if(this.cache.isRoot)return this;
95
- let root=this.cache.parent;
96
- while(1){
97
- if(!root)return null;
98
- if(root.cache.isRoot)return root;
99
- root=root.parent;
100
- }
101
- }
102
- get parent(){
103
- return this.cache.parent;
104
- }
105
- get width(){
106
- return this.element.getBoundingClientRect().width;
107
- }
108
- get height(){
109
- return this.element.getBoundingClientRect().height;
110
- }
111
- get top(){
112
- return this.element.getBoundingClientRect().top;
113
- }
114
- get right(){
115
- return this.element.getBoundingClientRect().right;
116
- }
117
- get bottom(){
118
- return this.element.getBoundingClientRect().bottom;
119
- }
120
- get left(){
121
- return this.element.getBoundingClientRect().left;
122
- }
123
- clone(render=false) {
124
- const UI = new this.constructor();
125
- UI.__proto__=this.__proto__;
126
- if(this.items.length){
127
- const items = [...this.items].map(n=>n.clone());
128
- UI.append(...items);
129
- }
130
- else UI.element=this.element.cloneNode(true);
131
- return UI.render(render);
132
- }
133
- style(styles){
134
- styles instanceof ZikoUseStyle ? this.st.style(styles.current): this.st.style(styles);
135
- return this;
136
- }
137
- size(width,height){
138
- this.st.size(width,height);
139
- return this;
140
- }
141
- get #SwitchedStyleRTL_LTR(){
142
- const CalculedStyle = globalThis.getComputedStyle(this.element);
143
- const SwitchedStyle = {}
144
- if(CalculedStyle.marginRight!=="0px")Object.assign(SwitchedStyle, {marginLeft: CalculedStyle.marginRight});
145
- if(CalculedStyle.marginLeft!=="0px")Object.assign(SwitchedStyle, {marginRight: CalculedStyle.marginLeft});
146
- if(CalculedStyle.paddingRight!=="0px")Object.assign(SwitchedStyle, {paddingLeft: CalculedStyle.paddingRight});
147
- if(CalculedStyle.paddingLeft!=="0px")Object.assign(SwitchedStyle, {paddingRight: CalculedStyle.paddingLeft});
148
- if(CalculedStyle.left!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.left});
149
- if(CalculedStyle.right!=="0px")Object.assign(SwitchedStyle, {left: CalculedStyle.right});
150
- if(CalculedStyle.textAlign === "right")Object.assign(SwitchedStyle, {textAlign: "left"});
151
- if(CalculedStyle.textAlign === "left")Object.assign(SwitchedStyle, {textAlign: "right"});
152
- if(CalculedStyle.float === "right")Object.assign(SwitchedStyle, {float: "left"});
153
- if(CalculedStyle.float === "left")Object.assign(SwitchedStyle, {float: "right"});
154
- if(CalculedStyle.borderRadiusLeft!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusRight});
155
- if(CalculedStyle.borderRadiusRight!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusLeft});
156
- if(["flex","inline-flex"].includes(CalculedStyle.display)){
157
- if(CalculedStyle.justifyContent === "flex-end")Object.assign(SwitchedStyle, {justifyContent: "flex-start"});
158
- if(CalculedStyle.justifyContent === "flex-start")Object.assign(SwitchedStyle, {justifyContent: "flex-end"});
159
- }
160
- return SwitchedStyle;
161
- }
162
- useRtl(switchAll = false){
163
- switchAll ? this.style({
164
- ...this.#SwitchedStyleRTL_LTR,
165
- direction : "rtl"
166
- }) : this.style({direction : "rtl"});
167
- return this;
168
- }
169
- useLtr(switchAll = false){
170
- switchAll ? this.style({
171
- ...this.#SwitchedStyleRTL_LTR,
172
- direction : "ltr"
173
- }) : this.style({direction : "ltr"});
174
- return this;
175
- }
176
- freeze(freeze){
177
- this.cache.isFrozzen=freeze;
178
- return this;
179
- }
180
- setTarget(tg) {
181
- if(this.isBody) return ;
182
- if (tg instanceof ZikoUIElement) tg = tg.element;
183
- this.unrender();
184
- this.target = tg;
185
- this.render();
186
- return this;
187
- }
188
- describe(label){
189
- if(label)this.setAttr("aria-label",label)
190
- }
191
- clear(){
192
- this?.items?.forEach(n=>n.unrender());
193
- this.element.innerHTML = "";
194
- return this;
195
- }
196
- render(target = this.target) {
197
- if(this.isBody)return ;
198
- if(target instanceof ZikoUIElement)target=target.element;
199
- this.target=target;
200
- this.target?.appendChild(this.element);
201
- return this;
202
- }
203
- unrender(){
204
- if(this.cache.parent)this.cache.parent.remove(this);
205
- else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
206
- return this;
207
- }
208
- renderAfter(t = 1) {
209
- setTimeout(() => this.render(), t);
210
- return this;
211
- }
212
- unrenderAfter(t = 1) {
213
- setTimeout(() => this.unrender(), t);
214
- return this;
215
- }
216
- after(ui){
217
- if(ui instanceof ZikoUIElement) ui=ui.element;
218
- this.element?.after(ui)
219
- return this;
220
- }
221
- before(ui){
222
- if(ui instanceof ZikoUIElement) ui=ui.element;
223
- this.element?.before(ui)
224
- return this;
225
- }
226
- animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
227
- this.element?.animate(keyframe,{duration, iterations, easing});
228
- return this;
229
- }
230
- // Attributes
231
- #setAttr(name, value){
232
- name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
233
- if(this?.attr[name] && this?.attr[name]===value) return;
234
- this.element.setAttribute(name, value)
235
- Object.assign(this.cache.attributes, {[name]:value});
236
- }
237
- setAttr(name, value) {
238
- if(name instanceof Object){
239
- const [names,values]=[Object.keys(name),Object.values(name)];
240
- for(let i=0;i<names.length;i++){
241
- if(values[i] instanceof Array)value[i] = values[i].join(" ");
242
- this.#setAttr(names[i], values[i])
243
- }
244
- }
245
- else{
246
- if(value instanceof Array)value = value.join(" ");
247
- this.#setAttr(name, value)
248
- }
249
- return this;
250
- }
251
- removeAttr(...names) {
252
- for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
253
- return this;
254
- }
255
- getAttr(name){
256
- name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
257
- return this.element.attributes[name].value;
258
- }
259
- setContentEditable(bool = true) {
260
- this.setAttr("contenteditable", bool);
261
- return this;
262
- }
263
- get children() {
264
- return [...this.element.children];
265
- }
266
- get cloneElement() {
267
- return this.element.cloneNode(true);
268
- }
269
- setClasses(...value) {
270
- this.setAttr("class", value.join(" "));
271
- return this;
272
- }
273
- get classes(){
274
- const classes=this.element.getAttribute("class");
275
- return classes===null?[]:classes.split(" ");
276
- }
277
- addClass() {
278
- /*this.setAttr("class", value);
279
- return this;*/
280
- }
281
- setId(id) {
282
- this.setAttr("id", id);
283
- return this;
284
- }
285
- get id() {
286
- return this.element.getAttribute("id");
287
- }
288
- onPtrMove(...callbacks){
289
- if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
290
- this.events.ptr.onMove(...callbacks);
291
- return this;
292
- }
293
- onPtrDown(...callbacks){
294
- if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
295
- this.events.ptr.onDown(...callbacks);
296
- return this;
297
- }
298
- onPtrUp(...callbacks){
299
- if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
300
- this.events.ptr.onUp(...callbacks);
301
- return this;
302
- }
303
- onPtrEnter(...callbacks){
304
- if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
305
- this.events.ptr.onEnter(...callbacks);
306
- return this;
307
- }
308
- onPtrLeave(...callbacks){
309
- if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
310
- this.events.ptr.onLeave(...callbacks);
311
- return this;
312
- }
313
- onPtrOut(...callbacks){
314
- if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
315
- this.events.ptr.onOut(...callbacks);
316
- return this;
317
- }
318
- onPtrCancel(...callbacks){
319
- if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
320
- this.events.ptr.onCancel(...callbacks);
321
- return this;
322
- }
323
- onSwipe(width_threshold, height_threshold,...callbacks){
324
- if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
325
- this.events.swipe.onSwipe(...callbacks);
326
- return this;
327
- }
328
- onMouseMove(...callbacks){
329
- if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
330
- this.events.mouse.onMove(...callbacks);
331
- return this;
332
- }
333
- onMouseDown(...callbacks){
334
- if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
335
- this.events.mouse.onDown(...callbacks);
336
- return this;
337
- }
338
- onMouseUp(...callbacks){
339
- if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
340
- this.events.mouse.onUp(...callbacks);
341
- return this;
342
- }
343
- onMouseEnter(...callbacks){
344
- if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
345
- this.events.mouse.onEnter(...callbacks);
346
- return this;
347
- }
348
- onMouseLeave(...callbacks){
349
- if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
350
- this.events.mouse.onLeave(...callbacks);
351
- return this;
352
- }
353
- onMouseOut(...callbacks){
354
- if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
355
- this.events.mouse.onOut(...callbacks);
356
- return this;
357
- }
358
- onWheel(...callbacks){
359
- if(!this.events.wheel)this.events.wheel = useWheelEvent(this);
360
- this.events.wheel.onWheel(...callbacks);
361
- return this;
362
- }
363
- onKeyDown(...callbacks){
364
- if(!this.events.key)this.events.key = useKeyEvent(this);
365
- this.events.key.onDown(...callbacks);
366
- return this;
367
- }
368
- onKeyPress(...callbacks){
369
- if(!this.events.key)this.events.key = useKeyEvent(this);
370
- this.events.key.onPress(...callbacks);
371
- return this;
372
- }
373
- onKeyUp(...callbacks){
374
- if(!this.events.key)this.events.key = useKeyEvent(this);
375
- this.events.key.onUp(...callbacks);
376
- return this;
377
- }
378
- onKeysDown({keys=[],callback}={}){
379
- if(!this.events.key)this.events.key = useKeyEvent(this);
380
- this.events.key.handleSuccessifKeys({keys,callback});
381
- return this;
382
- }
383
- onDragStart(...callbacks){
384
- if(!this.events.drag)this.events.drag = useDragEvent(this);
385
- this.events.drag.onStart(...callbacks);
386
- return this;
387
- }
388
- onDrag(...callbacks){
389
- if(!this.events.drag)this.events.drag = useDragEvent(this);
390
- this.events.drag.onDrag(...callbacks);
391
- return this;
392
- }
393
- onDragEnd(...callbacks){
394
- if(!this.events.drag)this.events.drag = useDragEvent(this);
395
- this.events.drag.onEnd(...callbacks);
396
- return this;
397
- }
398
- onDrop(...callbacks){
399
- if(!this.events.drop)this.events.drop = useDropEvent(this);
400
- this.events.drop.onDrop(...callbacks);
401
- return this;
402
- }
403
- onClick(...callbacks){
404
- if(!this.events.click)this.events.click = useClickEvent(this);
405
- this.events.click.onClick(...callbacks);
406
- return this;
407
- }
408
- onDbClick(...callbacks){
409
- if(!this.events.click)this.events.click = useClickEvent(this);
410
- this.events.click.onDbClick(...callbacks);
411
- return this;
412
- }
413
- onCopy(...callbacks){
414
- if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
415
- this.events.clipboard.onCopy(...callbacks);
416
- return this;
417
- }
418
- onCut(...callbacks){
419
- if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
420
- this.events.clipboard.onCut(...callbacks);
421
- return this;
422
- }
423
- onPaste(...callbacks){
424
- if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
425
- this.events.clipboard.onPaste(...callbacks);
426
- return this;
427
- }
428
- onSelect(...callbacks){
429
- if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
430
- this.events.clipboard.onSelect(...callbacks);
431
- return this;
432
- }
433
- onFocus(...callbacks){
434
- if(!this.events.focus)this.events.focus = useFocusEvent(this);
435
- this.events.focus.onFocus(...callbacks);
436
- return this;
437
- }
438
- onBlur(...callbacks){
439
- if(!this.events.focus)this.events.focus = useFocusEvent(this);
440
- this.events.focus.onFocus(...callbacks);
441
- return this;
442
- }
443
- on(event_name,...callbacks){
444
- if(!this.events.custom)this.events.custom = useCustomEvent(this);
445
- this.events.custom.on(event_name,...callbacks);
446
- return this;
447
- }
448
- emit(event_name,detail={}){
449
- if(!this.events.custom)this.events.custom = useCustomEvent(this);
450
- this.events.custom.emit(event_name,detail);
451
- return this;
452
- }
453
- watchAttr(callback){
454
- if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
455
- return this;
456
- }
457
- watchChildren(callback){
458
- if(!this.observer.children)this.observer.children = watchChildren(this,callback);
459
- return this;
460
- }
461
- watchSize(callback){
462
- if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
463
- this.observer.resize.start();
464
- return this;
465
- }
466
- watchIntersection(callback,config){
467
- if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
468
- this.observer.intersection.start();
469
- return this;
470
- }
471
- setFullScreen(set = true, e) {
472
- if(!this.element.requestFullscreen){
473
- console.error("Fullscreen API is not supported in this browser.");
474
- return this;
475
- }
476
- if (set) this.element.requestFullscreen(e);
477
- else globalThis.document.exitFullscreen();
478
- return this;
479
- }
480
- toggleFullScreen(e) {
481
- if (!globalThis.document.fullscreenElement) this.element.requestFullscreen(e);
482
- else globalThis.document.exitFullscreen();
483
- return this;
484
- }
485
- toPdf(){
486
- if(__ZikoPdf__){
487
-
488
- }
489
- return this;
490
- }
491
- }
492
- export default ZikoUIElement;
1
+ import { ZikoUseStyle } from "../../../reactivity/hooks/UI/useStyle.js";
2
+ import { ZikoUIElementStyle } from "../../style/index.js";
3
+ import {
4
+ usePointerEvent,
5
+ useMouseEvent,
6
+ useWheelEvent,
7
+ useKeyEvent,
8
+ useDragEvent ,
9
+ useDropEvent,
10
+ useClickEvent ,
11
+ useClipboardEvent ,
12
+ useFocusEvent,
13
+ useCustomEvent,
14
+ useSwipeEvent,
15
+ watchIntersection,
16
+ watchSize,
17
+ watchAttr,
18
+ watchChildren
19
+ } from "../../../reactivity/index.js"
20
+ import { Random } from "../../../math/index.js";
21
+ import { Str } from "../../../data/index.js";
22
+ class ZikoUIElement {
23
+ constructor(element ,name="") {
24
+ this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
25
+ if(typeof element === "string") {
26
+ element === "svg" ? element=globalThis?.document?.createElementNS("http://www.w3.org/2000/svg", "svg"): element = globalThis?.document?.createElement(element);
27
+ }
28
+ if(element)this.element = element;
29
+ this.uuid=this.constructor.name+"-"+Random.string(10);
30
+ this.cache = {
31
+ name,
32
+ parent:null,
33
+ isBody:false,
34
+ isRoot:false,
35
+ isHidden: false,
36
+ isFrozzen:false,
37
+ legacyParent : null,
38
+ style: new ZikoUIElementStyle({}),
39
+ attributes: {},
40
+ filters: {},
41
+ temp:{}
42
+ };
43
+ this.events = {
44
+ ptr:null,
45
+ mouse:null,
46
+ wheel:null,
47
+ key:null,
48
+ drag:null,
49
+ drop:null,
50
+ click:null,
51
+ clipboard:null,
52
+ focus:null,
53
+ swipe:null,
54
+ custom:null,
55
+ }
56
+ this.observer={
57
+ resize:null,
58
+ intersection:null
59
+ }
60
+ this.cache.style.linkTo(this);
61
+ this.style({
62
+ position: "relative",
63
+ boxSizing:"border-box",
64
+ // fontFamily:"verdana",
65
+ margin:0,
66
+ padding:0,
67
+ });
68
+ this.size("auto", "auto");
69
+ globalThis.__Ziko__.__UI__[this.cache.name]?globalThis.__Ziko__.__UI__[this.cache.name]?.push(this):globalThis.__Ziko__.__UI__[this.cache.name]=[this];
70
+ element && globalThis.__Ziko__.__Config__.default.render && this.render()
71
+ }
72
+ get isZikoUIElement(){
73
+ return true
74
+ }
75
+ get st(){
76
+ return this.cache.style;
77
+ }
78
+ get attr(){
79
+ return this.cache.attributes;
80
+ }
81
+ get evt(){
82
+ return this.cache.events;
83
+ }
84
+ get html(){
85
+ return this.element.innerHTML;
86
+ }
87
+ get text(){
88
+ return this.element.textContent;
89
+ }
90
+ get isBody(){
91
+ return this.element === globalThis?.document.body;
92
+ }
93
+ get __app__(){
94
+ if(this.cache.isRoot)return this;
95
+ let root=this.cache.parent;
96
+ while(1){
97
+ if(!root)return null;
98
+ if(root.cache.isRoot)return root;
99
+ root=root.parent;
100
+ }
101
+ }
102
+ get parent(){
103
+ return this.cache.parent;
104
+ }
105
+ get width(){
106
+ return this.element.getBoundingClientRect().width;
107
+ }
108
+ get height(){
109
+ return this.element.getBoundingClientRect().height;
110
+ }
111
+ get top(){
112
+ return this.element.getBoundingClientRect().top;
113
+ }
114
+ get right(){
115
+ return this.element.getBoundingClientRect().right;
116
+ }
117
+ get bottom(){
118
+ return this.element.getBoundingClientRect().bottom;
119
+ }
120
+ get left(){
121
+ return this.element.getBoundingClientRect().left;
122
+ }
123
+ clone(render=false) {
124
+ const UI = new this.constructor();
125
+ UI.__proto__=this.__proto__;
126
+ if(this.items.length){
127
+ const items = [...this.items].map(n=>n.clone());
128
+ UI.append(...items);
129
+ }
130
+ else UI.element=this.element.cloneNode(true);
131
+ return UI.render(render);
132
+ }
133
+ style(styles){
134
+ styles instanceof ZikoUseStyle ? this.st.style(styles.current): this.st.style(styles);
135
+ return this;
136
+ }
137
+ size(width,height){
138
+ this.st.size(width,height);
139
+ return this;
140
+ }
141
+ get #SwitchedStyleRTL_LTR(){
142
+ const CalculedStyle = globalThis.getComputedStyle(this.element);
143
+ const SwitchedStyle = {}
144
+ if(CalculedStyle.marginRight!=="0px")Object.assign(SwitchedStyle, {marginLeft: CalculedStyle.marginRight});
145
+ if(CalculedStyle.marginLeft!=="0px")Object.assign(SwitchedStyle, {marginRight: CalculedStyle.marginLeft});
146
+ if(CalculedStyle.paddingRight!=="0px")Object.assign(SwitchedStyle, {paddingLeft: CalculedStyle.paddingRight});
147
+ if(CalculedStyle.paddingLeft!=="0px")Object.assign(SwitchedStyle, {paddingRight: CalculedStyle.paddingLeft});
148
+ if(CalculedStyle.left!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.left});
149
+ if(CalculedStyle.right!=="0px")Object.assign(SwitchedStyle, {left: CalculedStyle.right});
150
+ if(CalculedStyle.textAlign === "right")Object.assign(SwitchedStyle, {textAlign: "left"});
151
+ if(CalculedStyle.textAlign === "left")Object.assign(SwitchedStyle, {textAlign: "right"});
152
+ if(CalculedStyle.float === "right")Object.assign(SwitchedStyle, {float: "left"});
153
+ if(CalculedStyle.float === "left")Object.assign(SwitchedStyle, {float: "right"});
154
+ if(CalculedStyle.borderRadiusLeft!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusRight});
155
+ if(CalculedStyle.borderRadiusRight!=="0px")Object.assign(SwitchedStyle, {right: CalculedStyle.borderRadiusLeft});
156
+ if(["flex","inline-flex"].includes(CalculedStyle.display)){
157
+ if(CalculedStyle.justifyContent === "flex-end")Object.assign(SwitchedStyle, {justifyContent: "flex-start"});
158
+ if(CalculedStyle.justifyContent === "flex-start")Object.assign(SwitchedStyle, {justifyContent: "flex-end"});
159
+ }
160
+ return SwitchedStyle;
161
+ }
162
+ useRtl(switchAll = false){
163
+ switchAll ? this.style({
164
+ ...this.#SwitchedStyleRTL_LTR,
165
+ direction : "rtl"
166
+ }) : this.style({direction : "rtl"});
167
+ return this;
168
+ }
169
+ useLtr(switchAll = false){
170
+ switchAll ? this.style({
171
+ ...this.#SwitchedStyleRTL_LTR,
172
+ direction : "ltr"
173
+ }) : this.style({direction : "ltr"});
174
+ return this;
175
+ }
176
+ freeze(freeze){
177
+ this.cache.isFrozzen=freeze;
178
+ return this;
179
+ }
180
+ setTarget(tg) {
181
+ if(this.isBody) return ;
182
+ if (tg instanceof ZikoUIElement) tg = tg.element;
183
+ this.unrender();
184
+ this.target = tg;
185
+ this.render();
186
+ return this;
187
+ }
188
+ describe(label){
189
+ if(label)this.setAttr("aria-label",label)
190
+ }
191
+ clear(){
192
+ this?.items?.forEach(n=>n.unrender());
193
+ this.element.innerHTML = "";
194
+ return this;
195
+ }
196
+ render(target = this.target) {
197
+ if(this.isBody)return ;
198
+ if(target instanceof ZikoUIElement)target=target.element;
199
+ this.target=target;
200
+ this.target?.appendChild(this.element);
201
+ return this;
202
+ }
203
+ unrender(){
204
+ if(this.cache.parent)this.cache.parent.remove(this);
205
+ else if(this.target?.children?.length && [...this.target?.children].includes(this.element)) this.target.removeChild(this.element);
206
+ return this;
207
+ }
208
+ renderAfter(t = 1) {
209
+ setTimeout(() => this.render(), t);
210
+ return this;
211
+ }
212
+ unrenderAfter(t = 1) {
213
+ setTimeout(() => this.unrender(), t);
214
+ return this;
215
+ }
216
+ after(ui){
217
+ if(ui instanceof ZikoUIElement) ui=ui.element;
218
+ this.element?.after(ui)
219
+ return this;
220
+ }
221
+ before(ui){
222
+ if(ui instanceof ZikoUIElement) ui=ui.element;
223
+ this.element?.before(ui)
224
+ return this;
225
+ }
226
+ animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
227
+ this.element?.animate(keyframe,{duration, iterations, easing});
228
+ return this;
229
+ }
230
+ // Attributes
231
+ #setAttr(name, value){
232
+ if(this.element.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
233
+ if(this?.attr[name] && this?.attr[name]===value) return;
234
+ this.element.setAttribute(name, value)
235
+ Object.assign(this.cache.attributes, {[name]:value});
236
+ }
237
+ setAttr(name, value) {
238
+ if(name instanceof Object){
239
+ const [names,values]=[Object.keys(name),Object.values(name)];
240
+ for(let i=0;i<names.length;i++){
241
+ if(values[i] instanceof Array)value[i] = values[i].join(" ");
242
+ this.#setAttr(names[i], values[i])
243
+ }
244
+ }
245
+ else{
246
+ if(value instanceof Array)value = value.join(" ");
247
+ this.#setAttr(name, value)
248
+ }
249
+ return this;
250
+ }
251
+ removeAttr(...names) {
252
+ for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
253
+ return this;
254
+ }
255
+ getAttr(name){
256
+ name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
257
+ return this.element.attributes[name].value;
258
+ }
259
+ setContentEditable(bool = true) {
260
+ this.setAttr("contenteditable", bool);
261
+ return this;
262
+ }
263
+ get children() {
264
+ return [...this.element.children];
265
+ }
266
+ get cloneElement() {
267
+ return this.element.cloneNode(true);
268
+ }
269
+ setClasses(...value) {
270
+ this.setAttr("class", value.join(" "));
271
+ return this;
272
+ }
273
+ get classes(){
274
+ const classes=this.element.getAttribute("class");
275
+ return classes===null?[]:classes.split(" ");
276
+ }
277
+ addClass() {
278
+ /*this.setAttr("class", value);
279
+ return this;*/
280
+ }
281
+ setId(id) {
282
+ this.setAttr("id", id);
283
+ return this;
284
+ }
285
+ get id() {
286
+ return this.element.getAttribute("id");
287
+ }
288
+ onPtrMove(...callbacks){
289
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
290
+ this.events.ptr.onMove(...callbacks);
291
+ return this;
292
+ }
293
+ onPtrDown(...callbacks){
294
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
295
+ this.events.ptr.onDown(...callbacks);
296
+ return this;
297
+ }
298
+ onPtrUp(...callbacks){
299
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
300
+ this.events.ptr.onUp(...callbacks);
301
+ return this;
302
+ }
303
+ onPtrEnter(...callbacks){
304
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
305
+ this.events.ptr.onEnter(...callbacks);
306
+ return this;
307
+ }
308
+ onPtrLeave(...callbacks){
309
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
310
+ this.events.ptr.onLeave(...callbacks);
311
+ return this;
312
+ }
313
+ onPtrOut(...callbacks){
314
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
315
+ this.events.ptr.onOut(...callbacks);
316
+ return this;
317
+ }
318
+ onPtrCancel(...callbacks){
319
+ if(!this.events.ptr)this.events.ptr = usePointerEvent(this);
320
+ this.events.ptr.onCancel(...callbacks);
321
+ return this;
322
+ }
323
+ onSwipe(width_threshold, height_threshold,...callbacks){
324
+ if(!this.events.swipe)this.events.swipe = useSwipeEvent(this, width_threshold, height_threshold);
325
+ this.events.swipe.onSwipe(...callbacks);
326
+ return this;
327
+ }
328
+ onMouseMove(...callbacks){
329
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
330
+ this.events.mouse.onMove(...callbacks);
331
+ return this;
332
+ }
333
+ onMouseDown(...callbacks){
334
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
335
+ this.events.mouse.onDown(...callbacks);
336
+ return this;
337
+ }
338
+ onMouseUp(...callbacks){
339
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
340
+ this.events.mouse.onUp(...callbacks);
341
+ return this;
342
+ }
343
+ onMouseEnter(...callbacks){
344
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
345
+ this.events.mouse.onEnter(...callbacks);
346
+ return this;
347
+ }
348
+ onMouseLeave(...callbacks){
349
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
350
+ this.events.mouse.onLeave(...callbacks);
351
+ return this;
352
+ }
353
+ onMouseOut(...callbacks){
354
+ if(!this.events.mouse)this.events.mouse = useMouseEvent(this);
355
+ this.events.mouse.onOut(...callbacks);
356
+ return this;
357
+ }
358
+ onWheel(...callbacks){
359
+ if(!this.events.wheel)this.events.wheel = useWheelEvent(this);
360
+ this.events.wheel.onWheel(...callbacks);
361
+ return this;
362
+ }
363
+ onKeyDown(...callbacks){
364
+ if(!this.events.key)this.events.key = useKeyEvent(this);
365
+ this.events.key.onDown(...callbacks);
366
+ return this;
367
+ }
368
+ onKeyPress(...callbacks){
369
+ if(!this.events.key)this.events.key = useKeyEvent(this);
370
+ this.events.key.onPress(...callbacks);
371
+ return this;
372
+ }
373
+ onKeyUp(...callbacks){
374
+ if(!this.events.key)this.events.key = useKeyEvent(this);
375
+ this.events.key.onUp(...callbacks);
376
+ return this;
377
+ }
378
+ onKeysDown({keys=[],callback}={}){
379
+ if(!this.events.key)this.events.key = useKeyEvent(this);
380
+ this.events.key.handleSuccessifKeys({keys,callback});
381
+ return this;
382
+ }
383
+ onDragStart(...callbacks){
384
+ if(!this.events.drag)this.events.drag = useDragEvent(this);
385
+ this.events.drag.onStart(...callbacks);
386
+ return this;
387
+ }
388
+ onDrag(...callbacks){
389
+ if(!this.events.drag)this.events.drag = useDragEvent(this);
390
+ this.events.drag.onDrag(...callbacks);
391
+ return this;
392
+ }
393
+ onDragEnd(...callbacks){
394
+ if(!this.events.drag)this.events.drag = useDragEvent(this);
395
+ this.events.drag.onEnd(...callbacks);
396
+ return this;
397
+ }
398
+ onDrop(...callbacks){
399
+ if(!this.events.drop)this.events.drop = useDropEvent(this);
400
+ this.events.drop.onDrop(...callbacks);
401
+ return this;
402
+ }
403
+ onClick(...callbacks){
404
+ if(!this.events.click)this.events.click = useClickEvent(this);
405
+ this.events.click.onClick(...callbacks);
406
+ return this;
407
+ }
408
+ onDbClick(...callbacks){
409
+ if(!this.events.click)this.events.click = useClickEvent(this);
410
+ this.events.click.onDbClick(...callbacks);
411
+ return this;
412
+ }
413
+ onCopy(...callbacks){
414
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
415
+ this.events.clipboard.onCopy(...callbacks);
416
+ return this;
417
+ }
418
+ onCut(...callbacks){
419
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
420
+ this.events.clipboard.onCut(...callbacks);
421
+ return this;
422
+ }
423
+ onPaste(...callbacks){
424
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
425
+ this.events.clipboard.onPaste(...callbacks);
426
+ return this;
427
+ }
428
+ onSelect(...callbacks){
429
+ if(!this.events.clipboard)this.events.clipboard = useClipboardEvent(this);
430
+ this.events.clipboard.onSelect(...callbacks);
431
+ return this;
432
+ }
433
+ onFocus(...callbacks){
434
+ if(!this.events.focus)this.events.focus = useFocusEvent(this);
435
+ this.events.focus.onFocus(...callbacks);
436
+ return this;
437
+ }
438
+ onBlur(...callbacks){
439
+ if(!this.events.focus)this.events.focus = useFocusEvent(this);
440
+ this.events.focus.onFocus(...callbacks);
441
+ return this;
442
+ }
443
+ on(event_name,...callbacks){
444
+ if(!this.events.custom)this.events.custom = useCustomEvent(this);
445
+ this.events.custom.on(event_name,...callbacks);
446
+ return this;
447
+ }
448
+ emit(event_name,detail={}){
449
+ if(!this.events.custom)this.events.custom = useCustomEvent(this);
450
+ this.events.custom.emit(event_name,detail);
451
+ return this;
452
+ }
453
+ watchAttr(callback){
454
+ if(!this.observer.attr)this.observer.attr = watchAttr(this,callback);
455
+ return this;
456
+ }
457
+ watchChildren(callback){
458
+ if(!this.observer.children)this.observer.children = watchChildren(this,callback);
459
+ return this;
460
+ }
461
+ watchSize(callback){
462
+ if(!this.observer.resize)this.observer.resize = watchSize(this,callback);
463
+ this.observer.resize.start();
464
+ return this;
465
+ }
466
+ watchIntersection(callback,config){
467
+ if(!this.observer.intersection)this.observer.intersection = watchIntersection(this,callback,config);
468
+ this.observer.intersection.start();
469
+ return this;
470
+ }
471
+ setFullScreen(set = true, e) {
472
+ if(!this.element.requestFullscreen){
473
+ console.error("Fullscreen API is not supported in this browser.");
474
+ return this;
475
+ }
476
+ if (set) this.element.requestFullscreen(e);
477
+ else globalThis.document.exitFullscreen();
478
+ return this;
479
+ }
480
+ toggleFullScreen(e) {
481
+ if (!globalThis.document.fullscreenElement) this.element.requestFullscreen(e);
482
+ else globalThis.document.exitFullscreen();
483
+ return this;
484
+ }
485
+ toPdf(){
486
+ if(__ZikoPdf__){
487
+
488
+ }
489
+ return this;
490
+ }
491
+ }
492
+ export default ZikoUIElement;