ziko 0.0.24 → 0.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ziko.cjs +1 -1
- package/dist/ziko.js +1 -1
- package/dist/ziko.min.js +1 -1
- package/dist/ziko.mjs +1 -1
- package/package.json +1 -1
- package/src/data/parser/index.js +1 -1
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/arc.js +0 -43
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/image.js +0 -0
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/line.js +0 -26
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/path.js +0 -0
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/points.js +0 -48
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/polygon.js +0 -7
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/polyline.js +0 -0
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/rect.js +0 -46
- package/src/graphics/canvas/elements ( To Be Moved )/Basic/text.js +0 -0
- package/src/graphics/canvas/elements ( To Be Moved )/Chart/histogram.js +0 -0
- package/src/graphics/canvas/elements ( To Be Moved )/Chart/plot.js +0 -0
- package/src/graphics/canvas/elements ( To Be Moved )/Chart/scatter.js +0 -2
- package/src/graphics/canvas/elements ( To Be Moved )/Chart/stem.js +0 -0
- package/src/graphics/canvas/elements ( To Be Moved )/Element.js +0 -115
- package/src/graphics/canvas/elements ( To Be Moved )/index.js +0 -13
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/circle.js +0 -29
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/ellipse.js +0 -24
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/foreign-object.js +0 -36
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/groupe.js +0 -32
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/image.js +0 -36
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/index.js +0 -11
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/line.js +0 -32
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/link.js +0 -33
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/path.js +0 -62
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/polygon.js +0 -32
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/polyline.js +0 -7
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/rect.js +0 -46
- package/src/graphics/svg/Elements ( To Be Moved )/Basic/text.js +0 -29
- package/src/graphics/svg/Elements ( To Be Moved )/Derived/grid.js +0 -9
- package/src/graphics/svg/Elements ( To Be Moved )/Derived/index.js +0 -1
- package/src/graphics/svg/Elements ( To Be Moved )/index.js +0 -2
- package/src/graphics/svg/Elements ( To Be Moved )/ziko-svg-element.js +0 -48
- package/src/ui/elements/derived ( To Be Moved)/accordion/accordion.js +0 -42
- package/src/ui/elements/derived ( To Be Moved)/accordion/collapsible.js +0 -82
- package/src/ui/elements/derived ( To Be Moved)/accordion/index.js +0 -2
- package/src/ui/elements/derived ( To Be Moved)/alert/alert.js +0 -80
- package/src/ui/elements/derived ( To Be Moved)/alert/index.js +0 -1
- package/src/ui/elements/derived ( To Be Moved)/alert/palette.js +0 -52
- package/src/ui/elements/derived ( To Be Moved)/carousel/index.js +0 -51
- package/src/ui/elements/derived ( To Be Moved)/code-note/SubElements.js.txt +0 -105
- package/src/ui/elements/derived ( To Be Moved)/code-note/code-cell.js +0 -195
- package/src/ui/elements/derived ( To Be Moved)/code-note/code-note.js +0 -72
- package/src/ui/elements/derived ( To Be Moved)/code-note/index.js +0 -2
- package/src/ui/elements/derived ( To Be Moved)/code-note/sub-elements.js +0 -67
- package/src/ui/elements/derived ( To Be Moved)/index.js +0 -12
- package/src/ui/elements/derived ( To Be Moved)/menu/index.js +0 -1
- package/src/ui/elements/derived ( To Be Moved)/menu/menu3d.js +0 -260
- package/src/ui/elements/derived ( To Be Moved)/modal/index.js +0 -92
- package/src/ui/elements/derived ( To Be Moved)/pagination/breadcrumbs.js +0 -54
- package/src/ui/elements/derived ( To Be Moved)/pagination/index.js +0 -1
- package/src/ui/elements/derived ( To Be Moved)/slider/__ZikoUISlider__.js +0 -112
- package/src/ui/elements/derived ( To Be Moved)/slider/hSlider.js +0 -34
- package/src/ui/elements/derived ( To Be Moved)/slider/index.js +0 -12
- package/src/ui/elements/derived ( To Be Moved)/slider/vSlider.js +0 -27
- package/src/ui/elements/derived ( To Be Moved)/splitter/__ZikoUISplitter__.js +0 -62
- package/src/ui/elements/derived ( To Be Moved)/splitter/hsplitter.js +0 -40
- package/src/ui/elements/derived ( To Be Moved)/splitter/index.js +0 -12
- package/src/ui/elements/derived ( To Be Moved)/splitter/vsplitter.js +0 -40
- package/src/ui/elements/derived ( To Be Moved)/tabs/index.js +0 -180
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import { Flex, ZikoUIFlex } from "../Flex";
|
|
2
|
-
import { ZikoUICodeNote } from "./code-note";
|
|
3
|
-
import {
|
|
4
|
-
Input,
|
|
5
|
-
Output,
|
|
6
|
-
Right,
|
|
7
|
-
Left
|
|
8
|
-
} from "./sub-elements";
|
|
9
|
-
class ZikoUICodeCell extends ZikoUIFlex{
|
|
10
|
-
constructor(code="",{type="js",order=null}={}){
|
|
11
|
-
super("section")
|
|
12
|
-
Object.assign(this.cache,{
|
|
13
|
-
state:null,
|
|
14
|
-
order,
|
|
15
|
-
type,
|
|
16
|
-
metadata:{
|
|
17
|
-
created:Date.now(),
|
|
18
|
-
updated:null
|
|
19
|
-
}
|
|
20
|
-
})
|
|
21
|
-
this.Input=Input(code);
|
|
22
|
-
this.Output=Output();
|
|
23
|
-
this.InOut=Flex(
|
|
24
|
-
this.Input,
|
|
25
|
-
this.Output
|
|
26
|
-
).vertical().style({
|
|
27
|
-
width:"100%",
|
|
28
|
-
margin:"10px auto"
|
|
29
|
-
});
|
|
30
|
-
this.RightControl=Right(this);
|
|
31
|
-
this.LeftControl=Left(this)
|
|
32
|
-
this.append(
|
|
33
|
-
this.LeftControl,
|
|
34
|
-
this.InOut,
|
|
35
|
-
this.RightControl
|
|
36
|
-
)
|
|
37
|
-
this.horizontal(-1,1).style({
|
|
38
|
-
//background:"#444",
|
|
39
|
-
width:"95vw",
|
|
40
|
-
margin:"0 auto",
|
|
41
|
-
border:"1px darkblue dotted"
|
|
42
|
-
})
|
|
43
|
-
let cm_content = this.Input.element.getElementsByClassName("cm-content")[0];
|
|
44
|
-
if( cm_content ){
|
|
45
|
-
cm_content.addEventListener("keydown",e=>{
|
|
46
|
-
if(e.key === "Enter" && e.shiftKey){
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
this.execute(this.cache.order);
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
else{
|
|
53
|
-
this.Input.onKeyDown(e=>{
|
|
54
|
-
if(e.kd==="Enter"){
|
|
55
|
-
if(e.event.shiftKey){
|
|
56
|
-
e.event.preventDefault();
|
|
57
|
-
this.execute(this.cache.order);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
//console.log(this.Input.element.firstChild.firstChild.textContent.at(-1))
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if(this.cache.parent instanceof ZikoUICodeNote){
|
|
64
|
-
if(e.kd==="ArrowDown" && e.event.shiftKey ){
|
|
65
|
-
this.cache.parent.next();
|
|
66
|
-
}
|
|
67
|
-
if(e.kd==="ArrowUp" && e.event.shiftKey){
|
|
68
|
-
this.cache.parent.previous();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
)
|
|
73
|
-
this.Input.onFocus(()=>{
|
|
74
|
-
if(this.cache.parent instanceof ZikoUICodeNote){
|
|
75
|
-
this.cache.parent.cache.currentNote=this;
|
|
76
|
-
this.cache.parent.setCurrentNote(this);
|
|
77
|
-
}
|
|
78
|
-
})
|
|
79
|
-
this.Input.onPaste((e)=>{
|
|
80
|
-
//e.event.preventDefault();
|
|
81
|
-
//this.setValue(this.codeText.trim())
|
|
82
|
-
})
|
|
83
|
-
// this.Input.onKeyPress(e=>{
|
|
84
|
-
// if(e.kp==="(")a.Input.element.textContent+=")";
|
|
85
|
-
// if(e.kp==="[")a.Input.element.textContent+="]";
|
|
86
|
-
// if(e.kp==="{")a.Input.element.textContent+="}";
|
|
87
|
-
// })
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
get isCodeCell(){
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
// space  
|
|
94
|
-
get codeText() {
|
|
95
|
-
return (this.Input.element.getElementsByClassName("cm-content")[0])
|
|
96
|
-
?this.Input.element.getElementsByClassName("cm-content")[0].innerText.trim()
|
|
97
|
-
:this.Input.element.innerText.trim()
|
|
98
|
-
// return this.Input.element.innerText.trim();
|
|
99
|
-
}
|
|
100
|
-
get codeHTML() {
|
|
101
|
-
return this.Input.element.innerHTML;
|
|
102
|
-
}
|
|
103
|
-
get outputHTML(){
|
|
104
|
-
return this.Output.element.innerHTML;
|
|
105
|
-
}
|
|
106
|
-
setValue(codeText){
|
|
107
|
-
this.Input[0].setValue(codeText);
|
|
108
|
-
return this;
|
|
109
|
-
}
|
|
110
|
-
cellData(){
|
|
111
|
-
return {
|
|
112
|
-
input:this.codeText,
|
|
113
|
-
output:this.outputHTML,
|
|
114
|
-
order:this.cache.order,
|
|
115
|
-
type:this.cache.type
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
execute(order){
|
|
119
|
-
this.clearOutput();
|
|
120
|
-
this.evaluate(order);
|
|
121
|
-
this.cache.metadata.updated=Date.now();
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
#evaluateJs(order){
|
|
125
|
-
try{
|
|
126
|
-
this.LeftControl[0].setValue("pending");
|
|
127
|
-
this.cache.state="pending";
|
|
128
|
-
// globalThis.eval(this.Input.element.innerText);
|
|
129
|
-
globalThis.eval(this.codeText);
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
catch(err){
|
|
133
|
-
console.log(err)
|
|
134
|
-
text(`Error : ${err.message}`).style({
|
|
135
|
-
color:"red",
|
|
136
|
-
background:"gold",
|
|
137
|
-
border:"2px red solid",
|
|
138
|
-
padding:"10px",
|
|
139
|
-
margin:"10px 0",
|
|
140
|
-
display:"flex",
|
|
141
|
-
justifyContent: "center",
|
|
142
|
-
});
|
|
143
|
-
this.LeftControl[0].setValue("Err");
|
|
144
|
-
this.cache.state="Error";
|
|
145
|
-
}
|
|
146
|
-
finally{
|
|
147
|
-
if(this.cache.state==="pending"){
|
|
148
|
-
this.cache.state="success";
|
|
149
|
-
this.setOrder(order);
|
|
150
|
-
if(this.cache.parent instanceof ZikoUICodeNote){
|
|
151
|
-
this.cache.parent.incrementOrder();
|
|
152
|
-
this.cache.parent.next();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
#evaluateMd(){
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
#evaluateHtml(){
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
evaluate(order){
|
|
164
|
-
globalThis.__Ziko__.__Config__.default.target=this.Output.element;
|
|
165
|
-
switch(this.cache.type){
|
|
166
|
-
case "js":this.#evaluateJs(order);break;
|
|
167
|
-
}
|
|
168
|
-
return this;
|
|
169
|
-
}
|
|
170
|
-
clearInput(){
|
|
171
|
-
this.Output.element.innerText="";
|
|
172
|
-
return this;
|
|
173
|
-
}
|
|
174
|
-
clearOutput(){
|
|
175
|
-
this.Output.element.innerText="";
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
setOrder(order,render=true){
|
|
179
|
-
this.cache.order=order;
|
|
180
|
-
if(render){
|
|
181
|
-
(typeof order === "number")?this.LeftControl[0].setValue(`[${order}]`):this.LeftControl[0].setValue("[-]");
|
|
182
|
-
}
|
|
183
|
-
return this;
|
|
184
|
-
}
|
|
185
|
-
focus(){
|
|
186
|
-
this.Input.element.focus();
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const CodeCell=(codeText,{type,order}={})=>new ZikoUICodeCell(codeText,{type,order});
|
|
193
|
-
export{
|
|
194
|
-
CodeCell
|
|
195
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { ZikoUIFlex } from "../Flex";
|
|
2
|
-
import { CodeCell } from "./code-cell";
|
|
3
|
-
class ZikoUICodeNote extends ZikoUIFlex{
|
|
4
|
-
constructor(){
|
|
5
|
-
super("section");
|
|
6
|
-
Object.assign(this.cache,{
|
|
7
|
-
order:0,
|
|
8
|
-
currentNote:null,
|
|
9
|
-
currentNoteIndex:null
|
|
10
|
-
})
|
|
11
|
-
this.vertical(0,0);
|
|
12
|
-
}
|
|
13
|
-
get isCodeNote(){
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
setCurrentNote(currentNote){
|
|
17
|
-
this.cache.currentNote=currentNote;
|
|
18
|
-
this.cache.currentNoteIndex=this.items.findIndex(n=>n===currentNote);
|
|
19
|
-
currentNote.focus();
|
|
20
|
-
this.items.forEach(n=>n.Input.style({
|
|
21
|
-
border: "1px solid #ccc"
|
|
22
|
-
}))
|
|
23
|
-
currentNote.Input.style({
|
|
24
|
-
border:"2px lightgreen solid"
|
|
25
|
-
});
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
addNote(text=""){
|
|
29
|
-
this.append(CodeCell(text));
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
execute(){
|
|
33
|
-
this.cache.currentNote.execute();
|
|
34
|
-
this.incrementOrder();
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
incrementOrder(){
|
|
38
|
-
this.cache.order++;
|
|
39
|
-
this.cache.currentNote.setOrder(this.cache.order);
|
|
40
|
-
return this;
|
|
41
|
-
}
|
|
42
|
-
next(){
|
|
43
|
-
if(this.cache.currentNote===this.items.at(-1)){
|
|
44
|
-
this.addNote();
|
|
45
|
-
this.setCurrentNote(this.items.at(-1));
|
|
46
|
-
}
|
|
47
|
-
else this.setCurrentNote(this.items[this.cache.currentNoteIndex+1]);
|
|
48
|
-
return this;
|
|
49
|
-
}
|
|
50
|
-
previous(){
|
|
51
|
-
// add append before
|
|
52
|
-
if(this.cache.currentNote!==this.items[0]){
|
|
53
|
-
this.setCurrentNote(this.items[this.cache.currentNoteIndex-1]);
|
|
54
|
-
}
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
data(){
|
|
58
|
-
return this.items.map(n=>n.cellData());
|
|
59
|
-
}
|
|
60
|
-
serialize(){
|
|
61
|
-
return JSON.stringify(this.data());
|
|
62
|
-
}
|
|
63
|
-
import(data=[]){
|
|
64
|
-
data.forEach((n,i)=>this.addNote(data[i].input));
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
const CodeNote=()=>new ZikoUICodeNote();
|
|
69
|
-
export{
|
|
70
|
-
CodeNote,
|
|
71
|
-
ZikoUICodeNote
|
|
72
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { html } from "../../primitives/misc/index.js";
|
|
2
|
-
import { Flex } from "../flex";
|
|
3
|
-
import { text } from "../../primitives/text/index.js";
|
|
4
|
-
import { ZikoUICodeNote } from "./code-note.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const Input=(codeText="")=>html("code",codeText).style({
|
|
8
|
-
width:"100%",
|
|
9
|
-
height:"auto",
|
|
10
|
-
padding:"10px",
|
|
11
|
-
boxSizing:"border-box",
|
|
12
|
-
border: "1px solid #ccc",
|
|
13
|
-
outline: "none",
|
|
14
|
-
fontSize: "1rem",
|
|
15
|
-
fontFamily: "Lucida Console, Courier New, monospace",
|
|
16
|
-
padding: "1rem 0.5rem",
|
|
17
|
-
wordBreak:"break-all",
|
|
18
|
-
background:"#f6f8fa",
|
|
19
|
-
color:"#0062C3"
|
|
20
|
-
}).setAttr("contenteditable",true).setAttr("spellcheck",false);
|
|
21
|
-
|
|
22
|
-
const Output=()=>html("output").style({
|
|
23
|
-
width:"100%",
|
|
24
|
-
height:"auto",
|
|
25
|
-
padding:"5px 0",
|
|
26
|
-
})
|
|
27
|
-
const Left=(ctx)=>Flex(
|
|
28
|
-
text("[ ]")
|
|
29
|
-
).style({
|
|
30
|
-
width:"50px",
|
|
31
|
-
//height:getComputedStyle(ctx.Input.element).height,
|
|
32
|
-
height:"50px",
|
|
33
|
-
margin:"10px 4px",
|
|
34
|
-
padding:"5px",
|
|
35
|
-
color:"darkblue",
|
|
36
|
-
borderBottom:"4px solid gold",
|
|
37
|
-
}).horizontal(0,0);
|
|
38
|
-
const BTN_STYLE={
|
|
39
|
-
background:"none",
|
|
40
|
-
width:"25px",
|
|
41
|
-
height:"25px",
|
|
42
|
-
fontSize:"1.2rem",
|
|
43
|
-
cursor:"pointer"
|
|
44
|
-
}
|
|
45
|
-
const Right=(ctx)=>Flex(
|
|
46
|
-
text('▶️').style(BTN_STYLE).onClick(e=>{
|
|
47
|
-
if(ctx.parent instanceof ZikoUICodeNote)ctx.parent.setCurrentNote(ctx);
|
|
48
|
-
ctx.execute();
|
|
49
|
-
globalThis.__Ziko__.__Config__.default.target=e.target.parent.parent[1][1];
|
|
50
|
-
}),
|
|
51
|
-
text('📋').style(BTN_STYLE).onClick(()=>{
|
|
52
|
-
navigator.clipboard.writeText(ctx.codeText)
|
|
53
|
-
}),
|
|
54
|
-
text('✖️').style(BTN_STYLE).onClick(()=>ctx.remove()),
|
|
55
|
-
text('✖️').style(BTN_STYLE).onClick(()=>ctx.remove()),
|
|
56
|
-
).style({
|
|
57
|
-
width:"70px",
|
|
58
|
-
height:"50px",
|
|
59
|
-
//background:"cyan",
|
|
60
|
-
margin:"10px 0"
|
|
61
|
-
}).horizontal(0,0).wrap(true);
|
|
62
|
-
export{
|
|
63
|
-
Input,
|
|
64
|
-
Output,
|
|
65
|
-
Right,
|
|
66
|
-
Left
|
|
67
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export * from "./flex";
|
|
2
|
-
export * from "./grid";
|
|
3
|
-
// export * from "./accordion";
|
|
4
|
-
// export * from "./carousel";
|
|
5
|
-
// export * from "./code-note";
|
|
6
|
-
// export * from "./tabs";
|
|
7
|
-
// export * from "./alert";
|
|
8
|
-
// export * from "./splitter";
|
|
9
|
-
// export * from "./pagination";
|
|
10
|
-
// export * from "./menu";
|
|
11
|
-
// export * from "./modal"
|
|
12
|
-
// export * from "./slider"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./menu3d.js"
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
import ZikoUIElement from "../../primitives/ZikoUIElement.js";
|
|
2
|
-
import { ZikoUIFlex } from "../flex"
|
|
3
|
-
class ZikoUIMenu3d extends ZikoUIFlex{
|
|
4
|
-
constructor(controller, content){
|
|
5
|
-
super("div", "menu3d")
|
|
6
|
-
this.controller = controller;
|
|
7
|
-
this.content = content;
|
|
8
|
-
this.cover = null;
|
|
9
|
-
Object.assign(this.cache,{
|
|
10
|
-
config:{
|
|
11
|
-
useTransfo : false,
|
|
12
|
-
isOpen : false,
|
|
13
|
-
position : "left",
|
|
14
|
-
threshold : 40,
|
|
15
|
-
angle : 70,
|
|
16
|
-
overlap : 6,
|
|
17
|
-
width : 300,
|
|
18
|
-
height : 300,
|
|
19
|
-
transitionDuration: '0.5s',
|
|
20
|
-
transitionEasing: 'ease',
|
|
21
|
-
menuTransformOrigin : null,
|
|
22
|
-
menuTransformClosed : null,
|
|
23
|
-
menuTransformOpened : null,
|
|
24
|
-
contentTransformOrigin : null,
|
|
25
|
-
contentTransformClosed : null,
|
|
26
|
-
contentTransformOpened : null,
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
this.append(
|
|
30
|
-
this.controller,
|
|
31
|
-
this.content
|
|
32
|
-
)
|
|
33
|
-
this.update();
|
|
34
|
-
}
|
|
35
|
-
get isOpen(){
|
|
36
|
-
return this.cache.config.isOpen;
|
|
37
|
-
}
|
|
38
|
-
update(){
|
|
39
|
-
this.controller.style({
|
|
40
|
-
display:"none",
|
|
41
|
-
padding:"20px",
|
|
42
|
-
overflow:"auto",
|
|
43
|
-
background:"darkblue",
|
|
44
|
-
color: "#eee",
|
|
45
|
-
webkitboxSizing: "border-box",
|
|
46
|
-
mozBoxSizing: "border-box",
|
|
47
|
-
boxSizing:"border-box",
|
|
48
|
-
});
|
|
49
|
-
this.content.style({
|
|
50
|
-
padding:"20px 40px",
|
|
51
|
-
width: "100%",
|
|
52
|
-
height: "100%",
|
|
53
|
-
// overflowY:"auto",
|
|
54
|
-
background:"gold",
|
|
55
|
-
color: "#eee",
|
|
56
|
-
webkitboxSizing: "border-box",
|
|
57
|
-
mozBoxSizing: "border-box",
|
|
58
|
-
boxSizing:"border-box",
|
|
59
|
-
webkitOverflowScrolling:"touch",
|
|
60
|
-
webkitTransformStyle: "preserve-3d"
|
|
61
|
-
});
|
|
62
|
-
this.setupPositions();
|
|
63
|
-
this.setupWrapper();
|
|
64
|
-
this.setupCover()
|
|
65
|
-
this.setupMenu();
|
|
66
|
-
this.setupContent()
|
|
67
|
-
}
|
|
68
|
-
setupPositions() {
|
|
69
|
-
this.cache.config.menuTransformOpened = '';
|
|
70
|
-
this.cache.config.contentTransformClosed = '';
|
|
71
|
-
let menuAngle = this.cache.config.angle;
|
|
72
|
-
let contentAngle = this.cache.config.angle / -2;
|
|
73
|
-
switch( this.cache.config.position ) {
|
|
74
|
-
case "top":
|
|
75
|
-
this.cache.config.menuTransformOrigin = '50% 0%';
|
|
76
|
-
this.cache.config.menuTransformClosed = `rotateX(${menuAngle}deg) translateY(-100%) translateY(${this.cache.config.overlap}px)`
|
|
77
|
-
this.cache.config.contentTransformOrigin = '50% 0';
|
|
78
|
-
this.cache.config.contentTransformOpened = `translateY(${this.height/2}px) rotateX(${contentAngle}deg)`
|
|
79
|
-
break;
|
|
80
|
-
case "right":
|
|
81
|
-
this.cache.config.menuTransformOrigin = '100% 50%';
|
|
82
|
-
this.cache.config.menuTransformClosed = 'rotateY( ' + menuAngle + 'deg ) translateX( 100% ) translateX( -2px ) scale( 1.01 )';
|
|
83
|
-
this.cache.config.contentTransformOrigin = '100% 50%';
|
|
84
|
-
this.cache.config.contentTransformOpened = 'translateX( -'+ this.width/2 +'px ) rotateY( ' + contentAngle + 'deg )';
|
|
85
|
-
break;
|
|
86
|
-
case "bottom":
|
|
87
|
-
this.cache.config.menuTransformOrigin = '50% 100%';
|
|
88
|
-
this.cache.config.menuTransformClosed = 'rotateX( ' + -menuAngle + 'deg ) translateY( 100% ) translateY( -'+ this.cache.config.overlap +'px )';
|
|
89
|
-
this.cache.config.contentTransformOrigin = '50% 100%';
|
|
90
|
-
this.cache.config.contentTransformOpened = 'translateY( -'+ this.height/2 +'px ) rotateX( ' + -contentAngle + 'deg )';
|
|
91
|
-
break;
|
|
92
|
-
default:
|
|
93
|
-
this.cache.config.menuTransformOrigin = '100% 50%';
|
|
94
|
-
this.cache.config.menuTransformClosed = 'translateX( -100% ) translateX( '+ this.cache.config.overlap +'px ) scale( 1.01 ) rotateY( ' + -menuAngle + 'deg )';
|
|
95
|
-
this.cache.config.contentTransformOrigin = '0 50%';
|
|
96
|
-
this.cache.config.contentTransformOpened = 'translateX( '+ this.width/2 +'px ) rotateY( ' + -contentAngle + 'deg )';
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
setupWrapper() {
|
|
101
|
-
this.style({
|
|
102
|
-
perspective : "800px",
|
|
103
|
-
perspectiveOrigin : this.cache.config.contentTransformOrigin
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
setupCover(){
|
|
107
|
-
if( this.cover ) this.cover.element.parentNode.removeChild( this.cover.element );
|
|
108
|
-
this.cover=new ZikoUIElement("div","div").style({
|
|
109
|
-
position:"absolute",
|
|
110
|
-
display:"block",
|
|
111
|
-
width:"100%",
|
|
112
|
-
height:"100%",
|
|
113
|
-
left:0,
|
|
114
|
-
top:0,
|
|
115
|
-
zIndex:1000,
|
|
116
|
-
visibility:"hidden",
|
|
117
|
-
opacity:0,
|
|
118
|
-
transition: `all ${this.cache.config.transitionDuration} ${this.cache.config.transitionEasing}`
|
|
119
|
-
})
|
|
120
|
-
this.content.element.appendChild( this.cover.element );
|
|
121
|
-
}
|
|
122
|
-
setupMenu() {
|
|
123
|
-
// var style = dom.menu.style;
|
|
124
|
-
switch( this.cache.config.position ) {
|
|
125
|
-
case "top":
|
|
126
|
-
this.controller.style({
|
|
127
|
-
width : "100%",
|
|
128
|
-
height : `${this.height/2}px`
|
|
129
|
-
});break;
|
|
130
|
-
case "right":
|
|
131
|
-
this.controller.style({
|
|
132
|
-
right : 0,
|
|
133
|
-
width : `${this.width/2}px`,
|
|
134
|
-
height : "100%"
|
|
135
|
-
});break;
|
|
136
|
-
case "bottom":
|
|
137
|
-
this.controller.style({
|
|
138
|
-
bottom : "0",
|
|
139
|
-
width : "100%",
|
|
140
|
-
height : `${this.height/2}px`
|
|
141
|
-
});break;
|
|
142
|
-
case "left":
|
|
143
|
-
this.controller.style({
|
|
144
|
-
width : `${this.width/2}px`,
|
|
145
|
-
height : "100%"
|
|
146
|
-
});break;
|
|
147
|
-
}
|
|
148
|
-
this.controller.style({
|
|
149
|
-
position : "fixed",
|
|
150
|
-
display : "block",
|
|
151
|
-
zIndex : 1,
|
|
152
|
-
transform : this.cache.config.menuTransformClosed,
|
|
153
|
-
transformOrigin : this.cache.config.menuTransformOrigin,
|
|
154
|
-
transition : 'all ' + this.cache.config.transitionDuration +' '+ this.cache.config.transitionEasing
|
|
155
|
-
})
|
|
156
|
-
}
|
|
157
|
-
setupContent() {
|
|
158
|
-
this.content.style({
|
|
159
|
-
transform : this.cache.config.contentTransformClosed,
|
|
160
|
-
transformOrigin : this.cache.config.contentTransformOrigin,
|
|
161
|
-
transition : `all ${this.cache.config.transitionDuration} ${this.cache.config.transitionEasing}`
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
open(){
|
|
165
|
-
if(!this.cache.config.isOpen){
|
|
166
|
-
this.cache.config.isOpen = true;
|
|
167
|
-
this.cover.style({
|
|
168
|
-
height : this.content.element.scrollHeight + "px",
|
|
169
|
-
visibility : "visible",
|
|
170
|
-
opacity : 1,
|
|
171
|
-
})
|
|
172
|
-
if(this.cache.config.useTransfo)this.content.style({
|
|
173
|
-
transform : this.cache.config.contentTransformOpened,
|
|
174
|
-
userSelect : "default"
|
|
175
|
-
})
|
|
176
|
-
this.controller.style({
|
|
177
|
-
transform : this.cache.config.menuTransformOpened,
|
|
178
|
-
useSelect : "none"
|
|
179
|
-
});
|
|
180
|
-
this.emit("opened");
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
close() {
|
|
184
|
-
if( this.cache.config.isOpen ) {
|
|
185
|
-
this.cache.config.isOpen = false;
|
|
186
|
-
this.cover.style({
|
|
187
|
-
// height : this.content.element.scrollHeight + "px",
|
|
188
|
-
visibility : "hidden",
|
|
189
|
-
opacity : 0,
|
|
190
|
-
})
|
|
191
|
-
this.content.style({
|
|
192
|
-
transform : this.cache.config.contentTransformClosed,
|
|
193
|
-
useSelect : "default"
|
|
194
|
-
})
|
|
195
|
-
this.controller.style({
|
|
196
|
-
transform : this.cache.config.menuTransformClosed,
|
|
197
|
-
userSelect : "none"
|
|
198
|
-
})
|
|
199
|
-
}
|
|
200
|
-
this.emit("closed");
|
|
201
|
-
}
|
|
202
|
-
onOpen(callback){
|
|
203
|
-
this.on("opened", callback.bind(this));
|
|
204
|
-
return this;
|
|
205
|
-
}
|
|
206
|
-
onClose(callback){
|
|
207
|
-
this.on("closed", callback.bind(this));
|
|
208
|
-
return this;
|
|
209
|
-
}
|
|
210
|
-
#usePosition(position){
|
|
211
|
-
if(this.cache.config.position!==position){
|
|
212
|
-
this.cache.config.position=position;
|
|
213
|
-
const isOpen = this.isOpen;
|
|
214
|
-
this.close();
|
|
215
|
-
this.update();
|
|
216
|
-
if(isOpen)this.open();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
useRight(){
|
|
220
|
-
this.#usePosition("left");
|
|
221
|
-
return this;
|
|
222
|
-
}
|
|
223
|
-
useRight(){
|
|
224
|
-
this.#usePosition("right");
|
|
225
|
-
return this;
|
|
226
|
-
}
|
|
227
|
-
useTop(){
|
|
228
|
-
this.#usePosition("top");
|
|
229
|
-
return this;
|
|
230
|
-
}
|
|
231
|
-
useBottom(){
|
|
232
|
-
this.#usePosition("bottom");
|
|
233
|
-
return this;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
const menu3d = (controller, content) => new ZikoUIMenu3d(controller, content);
|
|
237
|
-
globalThis.menu3d = menu3d;
|
|
238
|
-
export{
|
|
239
|
-
menu3d,
|
|
240
|
-
ZikoUIMenu3d
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
/*
|
|
245
|
-
|
|
246
|
-
a = menu3d(Flex(text("Menu")), Flex(text("Content")))
|
|
247
|
-
.size("80vw", "50vh")
|
|
248
|
-
.style({ userSelect: "none" });
|
|
249
|
-
a.onOpen((e) => console.log(e));
|
|
250
|
-
a.open();
|
|
251
|
-
a.controller.onSwipe(0.05, 1, (e) => {
|
|
252
|
-
if (e.event.detail.direction.x === "left") a.close();
|
|
253
|
-
});
|
|
254
|
-
a.content.onSwipe(0.1, 1, (e) => {
|
|
255
|
-
if (e.event.detail.direction.x === "left") a.close();
|
|
256
|
-
if (e.event.detail.direction.x === "right") a.open();
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
*/
|