ziko 0.38.1 → 0.40.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.
Files changed (51) hide show
  1. package/dist/ziko.cjs +962 -1360
  2. package/dist/ziko.js +962 -1360
  3. package/dist/ziko.min.js +2 -2
  4. package/dist/ziko.mjs +902 -1342
  5. package/package.json +1 -1
  6. package/src/data/index.js +2 -2
  7. package/src/data/string/checkers.js +27 -0
  8. package/src/data/string/converters.js +24 -0
  9. package/src/data/string/index.js +2 -1
  10. package/src/data/string-dep/index.js +1 -0
  11. package/src/events/types/clipboard.d.ts +2 -2
  12. package/src/events/types/focus.d.ts +2 -2
  13. package/src/events/types/pointer.d.ts +2 -2
  14. package/src/hooks/use-state.js +11 -8
  15. package/src/index.js +2 -1
  16. package/src/math/index.js +17 -17
  17. package/src/reactivity/hooks/UI/index.js +1 -1
  18. package/src/reactivity/hooks/UI/useRoot.js +3 -3
  19. package/src/time/animation/index.js +88 -70
  20. package/src/time/clocks/clock.js +62 -0
  21. package/src/time/clocks/index.js +3 -0
  22. package/src/time/clocks/scheduler.js +69 -0
  23. package/src/time/clocks/tick.js +34 -0
  24. package/src/time/converters/index.js +1 -0
  25. package/src/time/delay/index.js +2 -0
  26. package/src/time/delay/sleep.js +3 -0
  27. package/src/time/delay/timeout.js +15 -0
  28. package/src/time/ease/index.js +77 -0
  29. package/src/time/index.js +6 -9
  30. package/src/time/loop/index.js +67 -51
  31. package/src/time/utils/index.js +2 -2
  32. package/src/ui/__methods__/attrs.js +49 -0
  33. package/src/ui/__methods__/index.js +2 -1
  34. package/src/ui/__methods__/style.js +34 -0
  35. package/src/ui/__utils__/index.js +2 -2
  36. package/src/ui/constructors/{ZikoUIElement.js → UIElement.js} +23 -64
  37. package/src/ui/constructors/{ZikoUINode.js → UINode.js} +2 -2
  38. package/src/ui/constructors/style/index.js +2 -1
  39. package/src/ui/flex/index.js +8 -8
  40. package/src/ui/graphics/canvas.js +2 -2
  41. package/src/ui/graphics/svg.js +2 -2
  42. package/src/ui/grid/index.js +4 -4
  43. package/src/ui/index.js +2 -2
  44. package/src/ui/suspense/index.js +3 -3
  45. package/src/ui/tags/index.d.ts.txt +125 -125
  46. package/src/ui/tags/index.js +12 -16
  47. package/src/ui/text/index.js +2 -2
  48. package/src/ui/wrapper/index.js +3 -3
  49. package/src/time/utils/ease.js +0 -144
  50. /package/src/data/{string → string-dep}/patterns.js +0 -0
  51. /package/src/data/{string → string-dep}/string.js +0 -0
@@ -0,0 +1,77 @@
1
+ const {PI, sqrt, cos, sin, acos, pow} = Math;
2
+
3
+ export const Linear = t => t
4
+ export const InSin = t => 1 - cos((t * PI) / 2);
5
+ export const OutSin = t => sin((t * PI) / 2);
6
+ export const InOutSin = t => -(cos(PI * t) - 1) / 2;
7
+
8
+ export const InQuad = t => t**2;
9
+ export const OutQuad = t => 1 - (1-t)**2;
10
+ export const InOutQuad = t => t < 0.5 ? 2 * (t**2) : 1 - (-2 * t + 2)**2 / 2;
11
+
12
+ export const InCubic = t => t**3;
13
+ export const OutCubic = t => 1 - (1-t)**3;
14
+ export const InOutCubic = t => t < 0.5 ? 4 * (t**3) : 1 - (-2 * t + 2)**3 / 2;
15
+
16
+ export const InQuart = t => t**4;
17
+ export const OutQuart = t => 1 - (1-t)**4;
18
+ export const InOutQuart = t => t < 0.5 ? 8 * (t**4) : 1 - (-2 * t + 2)**4 / 2;
19
+
20
+ export const InQuint = t => t**5;
21
+ export const OutQuint = t => 1 - (1-t)**5;
22
+ export const InOutQuint = t => t < 0.5 ? 16 * (t**5) : 1 - (-2 * t + 2)**5 / 2;
23
+
24
+ export const InExpo = t => t === 0 ? 0 : 2**(10*t - 10)
25
+ export const OutExpo = t => t === 1 ? 1 : 1 - 2**(-10 * t)
26
+ export const InOutExpo = t => t === 0? 0: t === 1? 1: t < 0.5 ? 2**(20 * t - 10) / 2: (2 - 2**(-20 * t + 10)) / 2;
27
+
28
+ export const InCirc = t => 1 - sqrt(1 - t**2);
29
+ export const OutCirc = t => sqrt(1 - (t-1)**2);
30
+ export const InOutCirc = t => t < 0.5? (1 - sqrt(1 - (2*t)**2)) / 2: (sqrt(1 - (-2*t+2)**2) + 1) / 2;
31
+
32
+ export const Arc = t => 1 - sin(acos(t));
33
+ export const Back = (t, x = 1) => (t**2) * ((x+1)*t - x);
34
+ export const Elastic = t => -2*pow(2, 10 * (t - 1)) * cos(20 * PI * t / 3 * t);
35
+
36
+ export const InBack = (t, c1 = 1.70158, c3 = c1 + 1) => c3 * pow(t,3)- c1 * (t**2);
37
+ export const OutBack = (t, c1 = 1.70158, c3 = c1 + 1) => 1 + c3 * pow(t - 1, 3) + c1 * pow(t - 1, 2);
38
+ export const InOutBack = (t, c1 = 1.70158, c2 = c1 * 1.525) => t < 0.5 ? (pow(2 * t, 2) * ((c2 + 1) * 2 * t - c2)) / 2 : (pow(2 * t - 2, 2) * ((c2 + 1) * (t * 2 - 2) + c2) + 2) / 2;
39
+
40
+ export const InElastic = (t, c4 = 2*PI/3) => {
41
+ return t === 0
42
+ ? 0
43
+ : t === 1
44
+ ? 1
45
+ : -pow(2, 10 * t - 10) * sin((t * 10 - 10.75) * c4);
46
+ }
47
+
48
+ export const OutElastic = (t, c4 = 2*PI/3) => {
49
+ return t === 0
50
+ ? 0
51
+ : t === 1
52
+ ? 1
53
+ : pow(2, -10 * t) * sin((t * 10 - 0.75) * c4) + 1;
54
+ }
55
+ export const InOutElastic = (t, c5 = 2 * PI / 4.5) => {
56
+ return t === 0
57
+ ? 0
58
+ : t === 1
59
+ ? 1
60
+ : t < 0.5
61
+ ? -(pow(2, 20 * t - 10) * sin((20 * t - 11.125) * c5)) / 2
62
+ : (pow(2, -20 * t + 10) * sin((20 * t - 11.125) * c5)) / 2 + 1;
63
+ }
64
+
65
+ export const InBounce = (t, n1 = 7.5625, d1 = 2.75) => 1 - OutBounce(1-t, n1, d1);
66
+ export const OutBounce = (t, n1 = 7.5625, d1 = 2.75) => {
67
+ if(t<1/d1) return n1 * t * t;
68
+ if(t < 2 / d1) return n1 * (t -= 1.5 / d1) * t + 0.75;
69
+ if(t < 2.5 / d1) return n1 * (t -= 2.25 / d1) * t + 0.9375;
70
+ return n1 * (t -= 2.625 / d1) * t + 0.984375;
71
+ }
72
+
73
+ export const InOutBounce = (t, n1 = 7.5625, d1 = 2.75) => t < 0.5 ? OutBounce(1 - 2 * t, n1, d1)/2 : OutBounce(2 * t - 1, n1, d1)/2
74
+
75
+
76
+ export const Step = (t, steps = 5) => Math.floor(t*steps) / steps;
77
+ export const Discret = (t, segments = 5) => Math.ceil(t*segments) / segments;
package/src/time/index.js CHANGED
@@ -1,11 +1,8 @@
1
- export * from './loop/index.js'
2
1
  export * from './animation/index.js'
3
- export * from './utils/index.js';
2
+ export * from './clocks/index.js'
3
+ export * from './converters/index.js'
4
4
  export * from './decorators/index.js';
5
- // import * as Utils from './utils'
6
- // const Time = {
7
- // ...Loop,
8
- // ...Animation,
9
- // ...Utils
10
- // }
11
- // export default Time
5
+ export * from './delay/index.js'
6
+ export * from './ease/index.js'
7
+ export * from './loop/index.js'
8
+ export * from './utils/index.js';
@@ -1,87 +1,103 @@
1
- class ZikoTimeLoop {
2
- constructor(callback, step = 1000/30, startTime=0, endTime = Infinity, started = true) {
1
+ export class TimeLoop {
2
+ constructor(callback, { step = 1000, t0 = 0, t1 = Infinity, autoplay = true } = {}) {
3
3
  this.callback = callback;
4
4
  this.cache = {
5
5
  isRunning: false,
6
- AnimationId : null,
7
- t0 : null,
6
+ id: null,
7
+ last_tick: null,
8
8
  step,
9
- // fps,
10
- startTime,
11
- endTime,
12
- started
9
+ t0,
10
+ t1,
11
+ autoplay,
12
+ pauseTime: null,
13
+ frame : 0,
13
14
  };
14
- this.init();
15
- this.i=0;
16
- }
17
- init(){
18
- // if(this.cache.step && this.cache.fps){
19
- // console.warn(`Fps will be adjusted from ${this.cache.fps} to ${1000/this.cache.step} to ensure a smoother animation`);
20
- // this.cache.fps=1000/this.cache.step;
21
- // }
22
- if(this.cache.started){
23
- this.cache.startTime?this.startAfter(this.cache.startTime):this.start();
24
- if(this.cache.endTime&&this.cache.endTime!==Infinity)this.stopAfter(this.cache.endTime);
15
+
16
+ if (autoplay) {
17
+ t0 ? this.startAfter(t0) : this.start();
18
+ if (t1 !== Infinity) this.stopAfter(t1);
25
19
  }
26
- return this;
27
20
  }
28
- // get TIME_STEP() {
29
- // // return this.cache.step?this.cache.step:1000 / this.cache.fps;
30
- // return this.cache.step;
31
- // }
21
+
22
+ get frame(){
23
+ return this.cache.frame;
24
+ }
25
+ get elapsed(){
26
+ return this.cache.elapsed;
27
+ }
28
+
32
29
  start() {
33
30
  if (!this.cache.isRunning) {
34
- this.i=0;
31
+ this.cache.frame = 0;
35
32
  this.cache.isRunning = true;
36
- this.cache.t0 = Date.now();
33
+ this.cache.last_tick = Date.now();
37
34
  this.animate();
38
35
  }
39
36
  return this;
40
37
  }
38
+
41
39
  pause() {
42
40
  if (this.cache.isRunning) {
43
- clearTimeout(this.cache.AnimationId);
41
+ clearTimeout(this.cache.id);
44
42
  this.cache.isRunning = false;
43
+ this.cache.pauseTime = Date.now();
45
44
  }
46
45
  return this;
47
46
  }
48
- stop(){
49
- this.pause();
50
- this.i=0;
47
+
48
+ resume() {
49
+ if (!this.cache.isRunning) {
50
+ this.cache.isRunning = true;
51
+ if (this.cache.pauseTime) {
52
+ // adjust start time so delta stays consistent
53
+ const pausedDuration = Date.now() - this.cache.pauseTime;
54
+ this.cache.last_tick += pausedDuration;
55
+ }
56
+ this.animate();
57
+ }
51
58
  return this;
52
59
  }
53
- resume(){
54
- this.cache.isRunning=true;
55
- this.animate();
60
+
61
+ stop() {
62
+ this.pause();
63
+ this.cache.frame = 0;
56
64
  return this;
57
65
  }
58
- startAfter(t=1000){
59
- setTimeout(this.start.bind(this),t);
66
+
67
+ startAfter(t = 1000) {
68
+ setTimeout(() => this.start(), t);
60
69
  return this;
61
70
  }
62
- stopAfter(t=1000){
63
- setTimeout(this.stop.bind(this),t);
64
- return this;
71
+
72
+ stopAfter(t = 1000) {
73
+ setTimeout(() => this.stop(), t);
74
+ return this;
65
75
  }
76
+
66
77
  animate = () => {
67
78
  if (this.cache.isRunning) {
68
79
  const now = Date.now();
69
- const delta = now - this.cache.t0;
70
- if (delta > this.cache.step) {
80
+ const delta = now - this.cache.last_tick;
81
+
82
+ if (delta >= this.cache.step) {
83
+ this.cache.elapsed = now - (this.cache.t0 || 0);
71
84
  this.callback(this);
72
- this.i++;
73
- this.cache.t0 = now - (delta % this.cache.step);
85
+ this.cache.frame++;
86
+ this.cache.last_tick = now - (delta % this.cache.step);
74
87
  }
75
- this.cache.AnimationId = setTimeout(this.animate, 0);
76
- };
88
+
89
+ this.cache.id = setTimeout(this.animate, 0);
90
+ }
77
91
  }
78
92
  }
79
- const useFps = fps => 1000/fps;
80
- const useTimeLoop = (callback, step, startTime, endTime, started) => new ZikoTimeLoop(callback, step, startTime, endTime, started);
81
93
 
94
+ export const loop = (callback, options = {}) => new TimeLoop(callback, options);
95
+
96
+
97
+ // Helpers
98
+ // const useFps = (fps) => 1000 / fps;
99
+
100
+ // const _loop = loop( e => {
101
+ // console.log("Frame:", e.frame, " Elapsed: ", e.elapsed);
102
+ // });
82
103
 
83
- //const a = useTimeLoop((e) => console.log(e.i), {step:100,fps:30,t:[500,4001],start:true});
84
- export {
85
- useTimeLoop,
86
- useFps
87
- }
@@ -1,4 +1,4 @@
1
- import Ease from "./ease.js";
1
+ // import Ease from "./ease.js";
2
2
  const wait=(delayInMS)=>{
3
3
  return new Promise((resolve) => setTimeout(resolve, delayInMS));
4
4
  }
@@ -11,7 +11,7 @@ const timeTaken = callback => {
11
11
  export{
12
12
  wait,
13
13
  timeTaken,
14
- Ease
14
+ // Ease
15
15
  }
16
16
  export * from "./performance.js";
17
17
  export * from "./ui.js"
@@ -0,0 +1,49 @@
1
+ import { isStateGetter } from "../../hooks/use-state.js";
2
+ import {
3
+ is_camelcase,
4
+ camel2hyphencase
5
+ } from '../../data/string/index.js'
6
+
7
+ // To Do add getter, watchAttr
8
+ export const AttrsMethods = {
9
+ setAttr(name, value) {
10
+ if(name instanceof Object){
11
+ const [names,values]=[Object.keys(name),Object.values(name)];
12
+ for(let i=0;i<names.length;i++){
13
+ if(values[i] instanceof Array)value[i] = values[i].join(" ");
14
+ _set_attrs_.call(this, names[i], values[i])
15
+ }
16
+ }
17
+ else{
18
+ if(value instanceof Array) value = value.join(" ");
19
+ _set_attrs_.call(this, name, value)
20
+ }
21
+ return this;
22
+ },
23
+ removeAttr(...names) {
24
+ for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
25
+ return this;
26
+ },
27
+ getAttr(name){
28
+ name = is_camelcase(name) ? camel2hyphencase(name) : name;
29
+ return this.element.attributes[name].value;
30
+ },
31
+ setContentEditable(bool = true) {
32
+ this.setAttr("contenteditable", bool);
33
+ return this;
34
+ }
35
+ };
36
+
37
+ function _set_attrs_(name, value){
38
+ if(this.element?.tagName !== "svg") name = is_camelcase(name) ? camel2hyphencase(name) : name;
39
+ if(this?.attr[name] && this?.attr[name]===value) return;
40
+ if(isStateGetter(value)){
41
+ const getter = value()
42
+ getter._subscribe(
43
+ (newValue) => this.element?.setAttribute(name, newValue),
44
+ this
45
+ );
46
+ }
47
+ else this.element?.setAttribute(name, value)
48
+ Object.assign(this.cache.attributes, {[name]:value});
49
+ }
@@ -1,4 +1,5 @@
1
+ export * from './attrs.js'
1
2
  export * from './dom.js'
2
3
  export * from './events.js'
3
4
  export * from './indexing.js'
4
- // export * from './style.js'
5
+ export * from './style.js'
@@ -0,0 +1,34 @@
1
+ import { isStateGetter } from '../../hooks/use-state.js'
2
+ export const StyleMethods = {
3
+ style(styles){
4
+ for(let key in styles){
5
+ const value = styles[key];
6
+ if(isStateGetter(value)){
7
+ const getter = value()
8
+ Object.assign(this.element.style, {[key] : getter.value})
9
+ getter._subscribe(
10
+ (newValue) => {
11
+ console.log({newValue})
12
+ Object.assign(this.element.style, {[key] : newValue})
13
+ },
14
+ // this
15
+ );
16
+ }
17
+ else Object.assign(this.element.style, {[key] : value})
18
+ }
19
+ return this;
20
+ },
21
+ size(width, height){
22
+ return this.style({width, height})
23
+ },
24
+ hide(){
25
+
26
+ },
27
+ show(){
28
+
29
+ },
30
+ animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
31
+ this.element?.animate(keyframe,{duration, iterations, easing});
32
+ return this;
33
+ }
34
+ }
@@ -1,11 +1,11 @@
1
- import ZikoUIElement from "../constructors/ZikoUIElement.js";
1
+ import UIElement from "../constructors/UIElement.js";
2
2
  const Id = (a) => document.getElementById(a);
3
3
  const Class = (a) => [...document.getElementsByClassName(a)];
4
4
  const $=(...selector)=>{
5
5
  var ele=[]
6
6
  for(let i=0;i<selector.length;i++){
7
7
  if(typeof selector[i]=="string")ele.push(...document.querySelectorAll(selector[i]));
8
- if(selector[i] instanceof ZikoUIElement)ele.push(selector[i].element)
8
+ if(selector[i] instanceof UIElement)ele.push(selector[i].element)
9
9
  }
10
10
  return ele.length===1?ele[0]:ele;
11
11
  }
@@ -1,12 +1,12 @@
1
- import ZikoUINode from "./ZikoUINode.js";
1
+ import UINode from "./UINode.js";
2
2
  import { register } from "../../__helpers__/register/index.js";
3
3
  import {
4
+ AttrsMethods,
4
5
  DomMethods,
5
6
  IndexingMethods,
6
- EventsMethodes
7
+ EventsMethodes,
8
+ StyleMethods
7
9
  } from "../__methods__/index.js";
8
- import { ZikoUseStyle } from "../../reactivity/hooks/UI/useStyle.js";
9
- import { ZikoUIElementStyle } from "./style/index.js";
10
10
 
11
11
  import {
12
12
  useCustomEvent,
@@ -17,11 +17,10 @@ import {
17
17
  watchChildren
18
18
  } from "../../reactivity/index.js"
19
19
  import { Random } from "../../math/index.js";
20
- import { Str } from "../../data/index.js";
21
20
  import {__init__global__} from '../../__ziko__/index.js';
22
21
  __init__global__()
23
- class ZikoUIElement extends ZikoUINode{
24
- constructor(element, name="", {type="html", useDefaultStyle=false}={}){
22
+ class UIElement extends UINode{
23
+ constructor({element, name ='', type="html", useDefaultStyle=false}={}){
25
24
  super()
26
25
  this.target = globalThis.__Ziko__.__Config__.default.target||globalThis?.document?.body;
27
26
  if(typeof element === "string") {
@@ -32,9 +31,16 @@ class ZikoUIElement extends ZikoUINode{
32
31
  }
33
32
  }
34
33
  else{
35
- this.target = element.parentElement;
34
+ this.target = element?.parentElement;
36
35
  }
37
- register(this, DomMethods, IndexingMethods, EventsMethodes);
36
+ register(
37
+ this,
38
+ AttrsMethods,
39
+ DomMethods,
40
+ StyleMethods,
41
+ IndexingMethods,
42
+ EventsMethodes
43
+ );
38
44
  Object.assign(this.cache, {
39
45
  name,
40
46
  isInteractive : [true, false][Math.floor(2*Math.random())],
@@ -44,7 +50,6 @@ class ZikoUIElement extends ZikoUINode{
44
50
  isHidden: false,
45
51
  isFrozzen:false,
46
52
  legacyParent : null,
47
- style: new ZikoUIElementStyle({}),
48
53
  attributes: {},
49
54
  filters: {},
50
55
  temp:{}
@@ -69,7 +74,6 @@ class ZikoUIElement extends ZikoUINode{
69
74
  if(element)Object.assign(this.cache,{element});
70
75
  this.uuid = `${this.cache.name}-${Random.string(16)}`
71
76
  this.ui_index = globalThis.__Ziko__.__CACHE__.get_ui_index();
72
- this.cache.style.linkTo(this);
73
77
  useDefaultStyle && this.style({
74
78
  position: "relative",
75
79
  boxSizing:"border-box",
@@ -151,25 +155,17 @@ class ZikoUIElement extends ZikoUINode{
151
155
  else UI.element=this.element.cloneNode(true);
152
156
  return UI.render(render);
153
157
  }
154
- style(styles){
155
- styles instanceof ZikoUseStyle ? this.st.style(styles.current): this.st.style(styles);
156
- return this;
157
- }
158
- size(width,height){
159
- this.st.size(width,height);
160
- return this;
161
- }
162
158
  [Symbol.iterator]() {
163
159
  return this.items[Symbol.iterator]();
164
160
  }
165
161
  maintain() {
166
- for (let i = 0; i < this.items.length; i++) {
167
- Object.defineProperty(this, i, {
168
- value: this.items[i],
169
- writable: true,
170
- configurable: true,
171
- enumerable: false
172
- });
162
+ for (let i = 0; i < this.items.length; i++) {
163
+ Object.defineProperty(this, i, {
164
+ value: this.items[i],
165
+ writable: true,
166
+ configurable: true,
167
+ enumerable: false
168
+ });
173
169
  }
174
170
  }
175
171
  freeze(freeze){
@@ -187,43 +183,6 @@ class ZikoUIElement extends ZikoUINode{
187
183
  describe(label){
188
184
  if(label)this.setAttr("aria-label",label)
189
185
  }
190
- animate(keyframe, {duration=1000, iterations=1, easing="ease"}={}){
191
- this.element?.animate(keyframe,{duration, iterations, easing});
192
- return this;
193
- }
194
- // Attributes
195
- #setAttr(name, value){
196
- if(this.element?.tagName !== "svg") name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
197
- if(this?.attr[name] && this?.attr[name]===value) return;
198
- this.element?.setAttribute(name, value)
199
- Object.assign(this.cache.attributes, {[name]:value});
200
- }
201
- setAttr(name, value) {
202
- if(name instanceof Object){
203
- const [names,values]=[Object.keys(name),Object.values(name)];
204
- for(let i=0;i<names.length;i++){
205
- if(values[i] instanceof Array)value[i] = values[i].join(" ");
206
- this.#setAttr(names[i], values[i])
207
- }
208
- }
209
- else{
210
- if(value instanceof Array)value = value.join(" ");
211
- this.#setAttr(name, value)
212
- }
213
- return this;
214
- }
215
- removeAttr(...names) {
216
- for(let i=0;i<names.length;i++)this.element?.removeAttribute(names[i]);
217
- return this;
218
- }
219
- getAttr(name){
220
- name = Str.isCamelCase(name) ? Str.camel2hyphencase(name) : name;
221
- return this.element.attributes[name].value;
222
- }
223
- setContentEditable(bool = true) {
224
- this.setAttr("contenteditable", bool);
225
- return this;
226
- }
227
186
  get children() {
228
187
  return [...this.element.children];
229
188
  }
@@ -295,4 +254,4 @@ class ZikoUIElement extends ZikoUINode{
295
254
  }
296
255
 
297
256
  }
298
- export default ZikoUIElement;
257
+ export default UIElement;
@@ -1,4 +1,4 @@
1
- export default class ZikoUINode {
1
+ export default class UINode {
2
2
  constructor(node){
3
3
  this.cache = {
4
4
  node
@@ -12,4 +12,4 @@ export default class ZikoUINode {
12
12
  }
13
13
  }
14
14
 
15
- globalThis.node = (node) => new ZikoUINode(node);
15
+ globalThis.node = (node) => new UINode(node);
@@ -1,6 +1,7 @@
1
1
  import { addSuffixeToNumber } from "../../__utils__/index.js";
2
2
  import { Matrix,cos,sin} from "../../../math/index.js";
3
3
  import { Str } from "../../../data/index.js";
4
+ import { camel2hyphencase } from '../../../data/string/converters.js'
4
5
  class ZikoUIElementStyle{
5
6
  constructor(defaultStyle={}){
6
7
  this.target=null;
@@ -25,7 +26,7 @@ class ZikoUIElementStyle{
25
26
  for(const [key, value] of Object.entries(styles)){
26
27
  if(Str.isCamelCase(key)){
27
28
  delete styles[key];
28
- Object.assign(styles,{[Str.camel2hyphencase(key)]:value})
29
+ Object.assign(styles,{[camel2hyphencase(key)]:value})
29
30
  }
30
31
  }
31
32
  if(this?.target?.element?.style)Object.assign(this?.target?.element?.style, styles);
@@ -1,7 +1,7 @@
1
- import ZikoUIElement from "../constructors/ZikoUIElement.js";
2
- class ZikoUIFlex extends ZikoUIElement {
1
+ import UIElement from "../constructors/UIElement.js";
2
+ class ZikoUIFlex extends UIElement {
3
3
  constructor(tag = "div", w = "100%", h = "100%") {
4
- super(tag ,"Flex");
4
+ super({element : tag , name : "Flex"});
5
5
  this.direction = "cols";
6
6
  if (typeof w == "number") w += "%";
7
7
  if (typeof h == "number") h += "%";
@@ -69,13 +69,13 @@ class ZikoUIFlex extends ZikoUIElement {
69
69
  }
70
70
  }
71
71
 
72
- const Flex = (...ZikoUIElement) =>{
72
+ const Flex = (...UIElement) =>{
73
73
  let tag="div";
74
- if(typeof ZikoUIElement[0]==="string"){
75
- tag=ZikoUIElement[0];
76
- ZikoUIElement.pop();
74
+ if(typeof UIElement[0]==="string"){
75
+ tag=UIElement[0];
76
+ UIElement.pop();
77
77
  }
78
- return new ZikoUIFlex(tag).append(...ZikoUIElement);
78
+ return new ZikoUIFlex(tag).append(...UIElement);
79
79
  }
80
80
  function set_vertical(direction){
81
81
  direction == 1
@@ -1,6 +1,6 @@
1
- import ZikoUIElement from "../constructors/ZikoUIElement.js";
1
+ import UIElement from "../constructors/UIElement.js";
2
2
  import {Matrix} from "../../math/matrix/Matrix.js"
3
- class ZikoUICanvas extends ZikoUIElement{
3
+ class ZikoUICanvas extends UIElement{
4
4
  constructor(w,h){
5
5
  super("canvas","canvas");
6
6
  this.ctx = this.element?.getContext("2d");
@@ -1,5 +1,5 @@
1
- import ZikoUIElement from "../constructors/ZikoUIElement.js";
2
- class ZikoUISvg extends ZikoUIElement {
1
+ import UIElement from "../constructors/UIElement.js";
2
+ class ZikoUISvg extends UIElement {
3
3
  constructor(w=360,h=300) {
4
4
  super("svg","svg");
5
5
  //this.cache={};
@@ -1,7 +1,7 @@
1
- import ZikoUIElement from "../constructors/ZikoUIElement.js"
2
- class ZikoUIGrid extends ZikoUIElement {
1
+ import UIElement from "../constructors/UIElement.js"
2
+ class ZikoUIGrid extends UIElement {
3
3
  constructor(tag ="div", w = "50vw", h = "50vh") {
4
- super(tag,"Grid");
4
+ super({element : tag, name : "Grid"});
5
5
  this.direction = "cols";
6
6
  if (typeof w == "number") w += "%";
7
7
  if (typeof h == "number") h += "%";
@@ -29,5 +29,5 @@ class ZikoUIGrid extends ZikoUIElement {
29
29
  return this;
30
30
  }
31
31
  }
32
- const Grid = (...ZikoUIElement) => new ZikoUIGrid("div").append(...ZikoUIElement);
32
+ const Grid = (...UIElement) => new ZikoUIGrid("div").append(...UIElement);
33
33
  export {Grid,ZikoUIGrid};
package/src/ui/index.js CHANGED
@@ -1,5 +1,5 @@
1
- export { default as ZikoUIElement } from "./constructors/ZikoUIElement.js"
2
- export { default as ZikoUINode } from "./constructors/ZikoUINode.js"
1
+ export { default as UIElement } from "./constructors/UIElement.js"
2
+ export { default as UINode } from "./constructors/UINode.js"
3
3
  export * from './tags/index.js';
4
4
  export * from './text/index.js';
5
5
  export * from './flex/index.js';
@@ -1,7 +1,7 @@
1
- import ZikoUIElement from "../constructors/ZikoUIElement";
2
- class ZikoUISuspense extends ZikoUIElement{
1
+ import UIElement from "../constructors/UIElement";
2
+ class ZikoUISuspense extends UIElement{
3
3
  constructor(fallback_ui, callback){
4
- super("div", "suspense")
4
+ super({element : "div", name : "suspense"})
5
5
  this.setAttr({
6
6
  dataTemp : "suspense"
7
7
  })