ziko 0.60.1 → 0.61.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/package.json +1 -1
- package/src/provider/index.js +15 -0
- package/src/ui/flex/index.js +20 -34
- package/src/ui/flex/utils/index.js +20 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ziko",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.0",
|
|
4
4
|
"description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"front-end",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class ZikoProvider {
|
|
2
|
+
init(component){
|
|
3
|
+
if(component instanceof ZikoProvider) this.component = component.component;
|
|
4
|
+
}
|
|
5
|
+
get element(){
|
|
6
|
+
return this.component.element;
|
|
7
|
+
}
|
|
8
|
+
mount(target){
|
|
9
|
+
this.component.mount(target);
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
unmount(){
|
|
13
|
+
this.component.unmount()
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/ui/flex/index.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import { UIElement } from "../constructors/UIElement.js";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
set_vertical,
|
|
4
|
+
set_horizontal,
|
|
5
|
+
map_pos_x,
|
|
6
|
+
map_pos_y
|
|
7
|
+
} from './utils/index.js'
|
|
8
|
+
class UIFlex extends UIElement {
|
|
9
|
+
constructor({tag = "div", orientation = "h", order, w = "100%", h = "100%"} = {}) {
|
|
4
10
|
super({element : tag , name : "Flex"});
|
|
5
11
|
this.direction = "cols";
|
|
6
|
-
if (typeof w == "number") w += "%";
|
|
7
|
-
if (typeof h == "number") h += "%";
|
|
8
|
-
this.style({ width: w, height: h });
|
|
9
12
|
this.style({ display: "flex" });
|
|
10
13
|
// this.mount();
|
|
11
14
|
}
|
|
12
|
-
|
|
15
|
+
isFlex(){
|
|
13
16
|
return true;
|
|
14
17
|
}
|
|
15
|
-
|
|
18
|
+
responsify(respBreakPoint, wrap = true) {
|
|
16
19
|
this.wrap(wrap);
|
|
17
|
-
if (this.element.clientWidth <
|
|
20
|
+
if (this.element.clientWidth < respBreakPoint) this.vertical();
|
|
18
21
|
else this.horizontal();
|
|
19
22
|
return this;
|
|
20
23
|
}
|
|
@@ -46,16 +49,18 @@ class ZikoUIFlex extends UIElement {
|
|
|
46
49
|
this.style({ justifyContent: align });
|
|
47
50
|
return this;
|
|
48
51
|
}
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
// verticalize
|
|
53
|
+
vertical(x, y, order = 1) {
|
|
54
|
+
set_vertical.call(this, order)
|
|
51
55
|
this.style({
|
|
52
56
|
alignItems: typeof(x)==="number"?map_pos_x.call(this,x):x,
|
|
53
57
|
justifyContent: typeof(y)=="number"?map_pos_y.call(this,y):y
|
|
54
58
|
});
|
|
55
59
|
return this;
|
|
56
60
|
}
|
|
57
|
-
|
|
58
|
-
|
|
61
|
+
// horizontalize
|
|
62
|
+
horizontal(x, y, order = 1) {
|
|
63
|
+
set_horizontal.call(this, order)
|
|
59
64
|
this.style({
|
|
60
65
|
alignItems: typeof(y)=="number"?map_pos_y.call(this,y):y,
|
|
61
66
|
justifyContent: typeof(x)==="number"?map_pos_x.call(this,x):x
|
|
@@ -75,29 +80,10 @@ const Flex = (...UIElement) =>{
|
|
|
75
80
|
tag=UIElement[0];
|
|
76
81
|
UIElement.pop();
|
|
77
82
|
}
|
|
78
|
-
return new
|
|
79
|
-
}
|
|
80
|
-
function set_vertical(direction){
|
|
81
|
-
direction == 1
|
|
82
|
-
? this.style({ flexDirection: "column" })
|
|
83
|
-
: direction == -1 && this.style({ flexDirection: "column-reverse" });
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
function set_horizontal(direction){
|
|
87
|
-
direction == 1
|
|
88
|
-
? this.style({ flexDirection: "row" })
|
|
89
|
-
: direction == -1 && this.style({ flexDirection: "row-reverse" });
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
function map_pos_x(align){
|
|
93
|
-
let pos = ["flex-start", "center", "flex-end"];
|
|
94
|
-
if (typeof align === "number") align = pos[align + 1];
|
|
95
|
-
return align;
|
|
96
|
-
}
|
|
97
|
-
function map_pos_y(align){
|
|
98
|
-
return map_pos_x(-align);
|
|
83
|
+
return new UIFlex(tag).append(...UIElement);
|
|
99
84
|
}
|
|
85
|
+
|
|
100
86
|
export{
|
|
101
87
|
Flex,
|
|
102
|
-
|
|
88
|
+
UIFlex
|
|
103
89
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export function set_vertical(direction){
|
|
2
|
+
direction == 1
|
|
3
|
+
? this.style({ flexDirection: "column" })
|
|
4
|
+
: direction == -1 && this.style({ flexDirection: "column-reverse" });
|
|
5
|
+
return this;
|
|
6
|
+
}
|
|
7
|
+
export function set_horizontal(direction){
|
|
8
|
+
direction == 1
|
|
9
|
+
? this.style({ flexDirection: "row" })
|
|
10
|
+
: direction == -1 && this.style({ flexDirection: "row-reverse" });
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
export function map_pos_x(align){
|
|
14
|
+
let pos = ["flex-start", "center", "flex-end"];
|
|
15
|
+
if (typeof align === "number") align = pos[align + 1];
|
|
16
|
+
return align;
|
|
17
|
+
}
|
|
18
|
+
export function map_pos_y(align){
|
|
19
|
+
return map_pos_x(-align);
|
|
20
|
+
}
|