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.
Files changed (65) hide show
  1. package/dist/ziko.cjs +1 -1
  2. package/dist/ziko.js +1 -1
  3. package/dist/ziko.min.js +1 -1
  4. package/dist/ziko.mjs +1 -1
  5. package/package.json +1 -1
  6. package/src/data/parser/index.js +1 -1
  7. package/src/graphics/canvas/elements ( To Be Moved )/Basic/arc.js +0 -43
  8. package/src/graphics/canvas/elements ( To Be Moved )/Basic/image.js +0 -0
  9. package/src/graphics/canvas/elements ( To Be Moved )/Basic/line.js +0 -26
  10. package/src/graphics/canvas/elements ( To Be Moved )/Basic/path.js +0 -0
  11. package/src/graphics/canvas/elements ( To Be Moved )/Basic/points.js +0 -48
  12. package/src/graphics/canvas/elements ( To Be Moved )/Basic/polygon.js +0 -7
  13. package/src/graphics/canvas/elements ( To Be Moved )/Basic/polyline.js +0 -0
  14. package/src/graphics/canvas/elements ( To Be Moved )/Basic/rect.js +0 -46
  15. package/src/graphics/canvas/elements ( To Be Moved )/Basic/text.js +0 -0
  16. package/src/graphics/canvas/elements ( To Be Moved )/Chart/histogram.js +0 -0
  17. package/src/graphics/canvas/elements ( To Be Moved )/Chart/plot.js +0 -0
  18. package/src/graphics/canvas/elements ( To Be Moved )/Chart/scatter.js +0 -2
  19. package/src/graphics/canvas/elements ( To Be Moved )/Chart/stem.js +0 -0
  20. package/src/graphics/canvas/elements ( To Be Moved )/Element.js +0 -115
  21. package/src/graphics/canvas/elements ( To Be Moved )/index.js +0 -13
  22. package/src/graphics/svg/Elements ( To Be Moved )/Basic/circle.js +0 -29
  23. package/src/graphics/svg/Elements ( To Be Moved )/Basic/ellipse.js +0 -24
  24. package/src/graphics/svg/Elements ( To Be Moved )/Basic/foreign-object.js +0 -36
  25. package/src/graphics/svg/Elements ( To Be Moved )/Basic/groupe.js +0 -32
  26. package/src/graphics/svg/Elements ( To Be Moved )/Basic/image.js +0 -36
  27. package/src/graphics/svg/Elements ( To Be Moved )/Basic/index.js +0 -11
  28. package/src/graphics/svg/Elements ( To Be Moved )/Basic/line.js +0 -32
  29. package/src/graphics/svg/Elements ( To Be Moved )/Basic/link.js +0 -33
  30. package/src/graphics/svg/Elements ( To Be Moved )/Basic/path.js +0 -62
  31. package/src/graphics/svg/Elements ( To Be Moved )/Basic/polygon.js +0 -32
  32. package/src/graphics/svg/Elements ( To Be Moved )/Basic/polyline.js +0 -7
  33. package/src/graphics/svg/Elements ( To Be Moved )/Basic/rect.js +0 -46
  34. package/src/graphics/svg/Elements ( To Be Moved )/Basic/text.js +0 -29
  35. package/src/graphics/svg/Elements ( To Be Moved )/Derived/grid.js +0 -9
  36. package/src/graphics/svg/Elements ( To Be Moved )/Derived/index.js +0 -1
  37. package/src/graphics/svg/Elements ( To Be Moved )/index.js +0 -2
  38. package/src/graphics/svg/Elements ( To Be Moved )/ziko-svg-element.js +0 -48
  39. package/src/ui/elements/derived ( To Be Moved)/accordion/accordion.js +0 -42
  40. package/src/ui/elements/derived ( To Be Moved)/accordion/collapsible.js +0 -82
  41. package/src/ui/elements/derived ( To Be Moved)/accordion/index.js +0 -2
  42. package/src/ui/elements/derived ( To Be Moved)/alert/alert.js +0 -80
  43. package/src/ui/elements/derived ( To Be Moved)/alert/index.js +0 -1
  44. package/src/ui/elements/derived ( To Be Moved)/alert/palette.js +0 -52
  45. package/src/ui/elements/derived ( To Be Moved)/carousel/index.js +0 -51
  46. package/src/ui/elements/derived ( To Be Moved)/code-note/SubElements.js.txt +0 -105
  47. package/src/ui/elements/derived ( To Be Moved)/code-note/code-cell.js +0 -195
  48. package/src/ui/elements/derived ( To Be Moved)/code-note/code-note.js +0 -72
  49. package/src/ui/elements/derived ( To Be Moved)/code-note/index.js +0 -2
  50. package/src/ui/elements/derived ( To Be Moved)/code-note/sub-elements.js +0 -67
  51. package/src/ui/elements/derived ( To Be Moved)/index.js +0 -12
  52. package/src/ui/elements/derived ( To Be Moved)/menu/index.js +0 -1
  53. package/src/ui/elements/derived ( To Be Moved)/menu/menu3d.js +0 -260
  54. package/src/ui/elements/derived ( To Be Moved)/modal/index.js +0 -92
  55. package/src/ui/elements/derived ( To Be Moved)/pagination/breadcrumbs.js +0 -54
  56. package/src/ui/elements/derived ( To Be Moved)/pagination/index.js +0 -1
  57. package/src/ui/elements/derived ( To Be Moved)/slider/__ZikoUISlider__.js +0 -112
  58. package/src/ui/elements/derived ( To Be Moved)/slider/hSlider.js +0 -34
  59. package/src/ui/elements/derived ( To Be Moved)/slider/index.js +0 -12
  60. package/src/ui/elements/derived ( To Be Moved)/slider/vSlider.js +0 -27
  61. package/src/ui/elements/derived ( To Be Moved)/splitter/__ZikoUISplitter__.js +0 -62
  62. package/src/ui/elements/derived ( To Be Moved)/splitter/hsplitter.js +0 -40
  63. package/src/ui/elements/derived ( To Be Moved)/splitter/index.js +0 -12
  64. package/src/ui/elements/derived ( To Be Moved)/splitter/vsplitter.js +0 -40
  65. package/src/ui/elements/derived ( To Be Moved)/tabs/index.js +0 -180
@@ -1,92 +0,0 @@
1
- import ZikoUIContainerElement from "../../primitives/ZikoUIContainerElement.js";
2
- class ZikoUIModal extends ZikoUIContainerElement{
3
- constructor(...UIElements){
4
- super("dialog", "modal")
5
- this.append(...UIElements);
6
- Object.assign(this.cache,{
7
- config:{
8
- mode:"modal",
9
- useTransition:true
10
- }
11
- });
12
- this.style({
13
- display:"flex",
14
- justifyContent:"center",
15
- alignItems:"center",
16
- position: "absolute",
17
- top: "50%",
18
- left: "50%",
19
- transform: "translate(-50%, -50%)",
20
- padding: "20px",
21
- border: "none",
22
- backgroundCcolor: "#f5f5f5",
23
- boxShadow: "0px 4px 10px rgba(0, 0, 0, 0.1)",
24
- borderRadius: "8px"
25
- });
26
- this.close()
27
- }
28
- open(){
29
- if(!this.element.open){
30
- switch(this.cache.config.mode){
31
- case "modal": this.element.showModal(); break;
32
- case "dialog": this.element.show(); break;
33
- default : this.element.show(); break;
34
- }
35
- // this.style({
36
- // display : "flex",
37
- // })
38
- this.st.fadeIn(1000)
39
- this.emit("modal:opened");
40
- }
41
- return this;
42
- }
43
- close(){
44
- // this.style({
45
- // display : "none"
46
- // })
47
- this.st.fadeOut(1000)
48
- if(this.element.open){
49
- this.element.close();
50
- }
51
- this.emit("modal:closed");
52
- return this;
53
- }
54
- closeAfter(t = 1000){
55
- globalThis?.setTimeout(()=>this.close(), t);
56
- return this;
57
- }
58
- onOpen(callback){
59
- this.on("modal:opened",callback.bind(this));
60
- return this;
61
- }
62
- onClose(callback){
63
- this.on("modal:closed",callback.bind(this));
64
- return this;
65
- }
66
- useModal(){
67
- this.cache.config.mode = "modal";
68
- return this;
69
- }
70
- useDialog(){
71
- this.cache.config.mode = "dialog";
72
- return this;
73
- }
74
- useTransition(enabled = true){
75
- this.cache.config.useTransition = enabled;
76
- return this;
77
- }
78
- }
79
-
80
- const Modal=(...UIElements)=>new ZikoUIModal(...UIElements);
81
- export{
82
- Modal,
83
- ZikoUIModal
84
- }
85
-
86
- /*
87
- a=Modal(text("Hello")).style({
88
- width:"100%",
89
- height:"100%"
90
- })
91
- Flex(a).size("400px","400px").style({border:"1px red solid"})
92
- */
@@ -1,54 +0,0 @@
1
- import ZikoUIElement from "../../primitives/ZikoUIElement.js";
2
- import { html } from "../../primitives/misc/index.js";
3
- import { text } from "../../primitives/text/index.js";
4
- class ZikoUIBreadcrumbs extends ZikoUIElement{
5
- constructor(...items){
6
- super("ul", "Breadcrumbs")
7
- Object.assign(this.cache,{
8
- separatorTextContent:"/"
9
- })
10
- this.style({
11
- listStyle: "none",
12
- display: "flex",
13
- flexWrap: "wrap"
14
- })
15
- this.list=html('li').style({
16
- display: "flex",
17
- flexWrap: "wrap"
18
- });
19
- this.append(...items);
20
- }
21
- #addItem(item){
22
- if(["string","number","boolean"].includes(typeof item))item = text(item);
23
- const li = html("li", item).style({
24
- display: "flex",
25
- alignItems: "center"
26
- });
27
- if(this.element.children.length>0){
28
- const separator = text(this.cache.separatorTextContent).style({
29
- padding: "0 4px"
30
- });
31
- this.element?.append(separator.element);
32
- }
33
- this.element?.append(li.element);
34
- }
35
- append(...items){
36
- items.forEach(n=>this.#addItem(n));
37
- return this;
38
- }
39
- configSeparator(separatorTextContent = this.cache.separator, style = {}){
40
- this.cache.separatorTextContent = separatorTextContent;
41
- const separators = [...this.element.children].filter(n=>n.tagName==="SPAN");
42
- separators.forEach(node=>{
43
- node.textContent = separatorTextContent;
44
- Object.assign(node.style, style);
45
- }
46
- );
47
- return this;
48
- }
49
- }
50
- const Breadcrumbs=(...items)=>new ZikoUIBreadcrumbs(...items);
51
- export{
52
- Breadcrumbs,
53
- ZikoUIBreadcrumbs
54
- }
@@ -1 +0,0 @@
1
- export * from "./breadcrumbs"
@@ -1,112 +0,0 @@
1
- import ZikoUIContainerElement from "../../primitives/ZikoUIContainerElement";
2
- import { Section } from "../../primitives/semantic";
3
- import { text } from "../../primitives/text";
4
- import { ZikoUIFlex,Flex } from "../Flex";
5
- import { ZikoUISection } from "../../primitives/semantic";
6
- class __ZikoUISlider__ extends ZikoUISection{
7
- constructor(){
8
- super("section","");
9
- Object.assign(this.cache,{
10
- currentIndex : 0,
11
- slideBuilder : null,
12
- })
13
- this.container = Flex().size("100%","100%").vertical(0,0).style({
14
- // width:"100%",
15
- overflow:"hidden"
16
- });
17
- // this.style({
18
- // // width:"100%",
19
- // overflow:"hidden"
20
- // });
21
- this.container.setAttr({
22
- ariaRoledescription : "carousel",
23
- ariaLive: "polite",
24
- ariaLabel : "Content Slider"
25
- })
26
- this.track = Section().size("100%","100%").style({
27
- transition : "transform 0.3s ease-in-out",
28
- });
29
- this.bullets = Flex().style({
30
- // position : "absolute",
31
- // top : 0,
32
- gap : "10px",
33
- padding:"10px",
34
- })
35
- this.container.append(
36
- this.track,
37
- this.bullets
38
- )
39
- this.append(this.container)
40
- }
41
- #updateAriaHidden(){
42
- for(let i=0;i<this.track.items.length;i++){
43
- this.track[i].setAttr({
44
- ariaHidden : (i!==this.cache.currentIndex)
45
- })
46
- }
47
- }
48
- goto(n = 0){
49
- this.cache.currentIndex = n;
50
- this.__updatePos();
51
- this.#updateAriaHidden()
52
- }
53
- next(n = 1){
54
- this.cache.currentIndex += n;
55
- this.__updatePos();
56
- this.#updateAriaHidden()
57
- return this;
58
- }
59
- previous(n = 1){
60
- this.cache.currentIndex -= n;
61
- this.__updatePos();
62
- this.#updateAriaHidden()
63
- return this;
64
- }
65
- #update(){
66
- const length = this.track.items.length;
67
- for(let i=0;i<length;i++){
68
- this.track.items[i].setAttr({
69
- ariaLabel : `Slide ${i+1} of ${length}`,
70
- dataSlideIndex : i
71
- })
72
- this.bullets.items[i].setAttr({
73
- dataIndex : i,
74
- ariaLabel : `Go to slide ${i}`
75
- })
76
- this.bullets[i].events.click?.destroy();
77
- this.bullets[i].onClick(()=>this.goto(i))
78
- }
79
- }
80
- #addSlide(UIElement){
81
- this.track.append(this.cache.slideBuilder(UIElement).setAttr({
82
- ariaRoledescription : "slide",
83
- role : "group",
84
- ariaLabel : "" // link to update
85
- }));
86
- const bullet = text().size("15px","15px").style({
87
- borderRadius:"50%",
88
- cursor : "pointer",
89
- border : "3px solid blue",
90
- background : "white"
91
- }).setAttr({
92
- role : "button",
93
- tabIndex : 0
94
- })
95
- .onPtrEnter(e=>e.target.st.background("gold").scale(1.2,1.2))
96
- .onPtrLeave(e=>e.target.st.background("white").scale(1,1))
97
- this.bullets.append(
98
- bullet
99
- )
100
- return this;
101
- }
102
- addSlides(...slides){
103
- slides.forEach(n=>this.#addSlide(n));
104
- this.#update();
105
- this.#updateAriaHidden();
106
- return this;
107
- }
108
- }
109
-
110
- export{
111
- __ZikoUISlider__
112
- }
@@ -1,34 +0,0 @@
1
- import { __ZikoUISlider__ } from "./__ZikoUISlider__";
2
- import { Flex } from "../Flex";
3
- class ZikoUIHorizontalSlider extends __ZikoUISlider__{
4
- constructor(...slides){
5
- super("section","hSlider")
6
- this.container.vertical(0,0)
7
- Object.assign(this.cache,{
8
- slideBuilder : (UIElement) => Flex(UIElement).style({
9
- minWidth : "100%",
10
- width:"100%",
11
- height:"100%",
12
- }).vertical(0,0)
13
- })
14
- this.track.size("100%","90%").style({
15
- display : "flex"
16
- })
17
- this.addSlides(...slides);
18
- this.bullets.horizontal(0,0).style({
19
- width : "100%",
20
- height : "10%",
21
- })
22
- }
23
- __updatePos(){
24
- const width = this.container.width;
25
- this.track.st.translateX(-this.cache.currentIndex * width);
26
- }
27
-
28
- }
29
-
30
- const hSlider=(...slides)=>new ZikoUIHorizontalSlider(...slides);
31
- export{
32
- hSlider,
33
- ZikoUIHorizontalSlider
34
- }
@@ -1,12 +0,0 @@
1
- export * from "./hSlider.js"
2
- export * from "./vSlider.js"
3
- import { hSlider } from "./hSlider.js"
4
- import { vSlider } from "./vSlider.js"
5
- const Slider = ({orintation = "horizontal",slides = []}) =>{
6
- if(["v","vertical"].includes(orintation.toLowerCase())) return vSlider(...slides);
7
- else if(["h","horizontal"].includes(orintation.toLowerCase())) return hSlider(...slides);
8
- else Error(`{ orientation : ${orintation}} Not supported`)
9
- }
10
- export{
11
- Slider
12
- }
@@ -1,27 +0,0 @@
1
- import { __ZikoUISlider__ } from "./__ZikoUISlider__";
2
- import { Flex } from "../Flex";
3
- class ZikoUIVerticalSlider extends __ZikoUISlider__{
4
- constructor(...slides){
5
- super("section","vSlider");
6
- Object.assign(this.cache,{
7
- slideBuilder : (UIElement) => Flex(UIElement).size("100%","100%").vertical(0, 0)
8
- })
9
- this.addSlides(...slides);
10
- this.container.horizontal(0,0)
11
- this.track.size("90%","100%")
12
- this.bullets.vertical(0,0).style({
13
- height : "100%",
14
- width : "10%"
15
- })
16
- }
17
- __updatePos(){
18
- const height = this.container.height;
19
- this.track.st.translateY(-this.cache.currentIndex * height);
20
- }
21
- }
22
-
23
- const vSlider=(...slides)=>new ZikoUIVerticalSlider(...slides);
24
- export{
25
- vSlider,
26
- ZikoUIVerticalSlider
27
- }
@@ -1,62 +0,0 @@
1
- import ZikoUIElement from "../../primitives/ZikoUIElement";
2
- class __ZikoUISplitter__ extends ZikoUIElement{
3
- constructor(flexDirection, resizerCursor, resizerProp){
4
- super("div", "Splitter")
5
- Object.assign(this.cache,{
6
- isResizing : false,
7
- flexDirection,
8
- resizerCursor,
9
- resizerProp
10
- })
11
- this.style({
12
- display:"flex",
13
- flexDirection : this.cache.flexDirection,
14
- border: "2px solid #333",
15
- overflow: "hidden"
16
- })
17
- this.resizer = new ZikoUIElement("div", "resizer").style({
18
- [this.cache.resizerProp]:"5px",
19
- backgroundColor: "gold",
20
- cursor: this.cache.resizerCursor,
21
- touchAction: "none",
22
- });
23
- this.onPtrDown(e=>{
24
- this.cache.isResizing = true;
25
- this.style({
26
- cursor : this.cache.resizerCursor // ns-resize
27
- });
28
- this.resizer.element.setPointerCapture(e.event.pointerId);
29
- })
30
- this.onPtrUp(e=>{
31
- this.cache.isResizing = false;
32
- this.style({
33
- cursor: "default"
34
- })
35
- this.resizer.element.releasePointerCapture(e.event.pointerId);
36
- })
37
- this.onPtrCancel(()=>{
38
- this.cache.isResizing = false;
39
- this.style({
40
- cursor: "default"
41
- })
42
- })
43
- this.onPtrOut(()=>{
44
- if (this.cache.isResizing) {
45
- this.cache.isResizing = false;
46
- this.style({
47
- cursor: "default"
48
- })
49
- }
50
- })
51
- }
52
- get isSplitter(){
53
- return true;
54
- }
55
- styleResizer(style={}){
56
- this.resizer.style(style);
57
- return this;
58
- }
59
- }
60
- export{
61
- __ZikoUISplitter__
62
- }
@@ -1,40 +0,0 @@
1
- import { __ZikoUISplitter__ } from "./__ZikoUISplitter__";
2
- class ZikoUIHorizontalSplitter extends __ZikoUISplitter__{
3
- constructor(leftPane, rightPane){
4
- super("row", "ew-resize", "width")
5
- this.leftPane = leftPane.style({
6
- width:"50%",
7
- flexGrow: 1,
8
- overflow: "hidden"
9
- });
10
- this.rightPane = rightPane.style({
11
- width:"50%",
12
- flexGrow: 1,
13
- overflow: "hidden"
14
- });
15
- this.element?.append(
16
- this.leftPane.element,
17
- this.resizer.element,
18
- this.rightPane.element
19
- );
20
- this.onPtrMove(e=>{
21
- if (!this.cache.isResizing) return;
22
- const containerWidth = this.element.getBoundingClientRect().width; // height
23
- const pointerRelativeXpos = e.event.clientX - this.element.getBoundingClientRect().x; // y
24
- let newLeftPaneWidth = (pointerRelativeXpos / containerWidth) * 100;
25
- let newRightPaneWidth = 100 - newLeftPaneWidth;
26
- if (newLeftPaneWidth < 0) newLeftPaneWidth = 0;
27
- if (newRightPaneWidth < 0) newRightPaneWidth = 0;
28
- this.leftPane.element.style.width = `${newLeftPaneWidth}%`;
29
- this.rightPane.element.style.width = `${newRightPaneWidth}%`;
30
- })
31
- }
32
- get isHorizontalSplitter(){
33
- return true;
34
- }
35
- }
36
- const hSplitter=(leftPane, rightPane)=>new ZikoUIHorizontalSplitter(leftPane, rightPane);
37
- export{
38
- ZikoUIHorizontalSplitter,
39
- hSplitter
40
- }
@@ -1,12 +0,0 @@
1
- export * from "./hsplitter.js"
2
- export * from "./vsplitter.js"
3
- import { hSplitter } from "./hsplitter.js"
4
- import { vSplitter } from "./vsplitter.js"
5
- const Splitter = ({orintation = "horizontal",slides = []}) =>{
6
- if(["v","vertical"].includes(orintation.toLowerCase())) return vSplitter(...slides);
7
- else if(["h","horizontal"].includes(orintation.toLowerCase())) return hSplitter(...slides);
8
- else Error(`{ orientation : ${orintation}} Not supported`)
9
- }
10
- export{
11
- Splitter
12
- }
@@ -1,40 +0,0 @@
1
- import { __ZikoUISplitter__ } from "./__ZikoUISplitter__";
2
- class ZikoUIVerticalSplitter extends __ZikoUISplitter__{
3
- constructor(topPane, bottomPane){
4
- super("column", "ns-resize", "height")
5
- this.topPane = topPane.style({
6
- height:"50%",
7
- flexGrow: 1,
8
- overflow: "hidden"
9
- });
10
- this.bottomPane = bottomPane.style({
11
- height:"50%",
12
- flexGrow: 1,
13
- overflow: "hidden"
14
- });
15
- this.element?.append(
16
- this.topPane.element,
17
- this.resizer.element,
18
- this.bottomPane.element
19
- );
20
- this.onPtrMove(e=>{
21
- if (!this.cache.isResizing) return;
22
- const containerHeight = this.element.getBoundingClientRect().height; // height
23
- const pointerRelativeYpos = e.event.clientY - this.element.getBoundingClientRect().y; // y
24
- let newTopPaneHeight = (pointerRelativeYpos / containerHeight) * 100;
25
- let newBottomPaneHeight = 100 - newTopPaneHeight;
26
- if (newTopPaneHeight < 0) newTopPaneHeight = 0;
27
- if (newBottomPaneHeight < 0) newBottomPaneHeight = 0;
28
- this.topPane.element.style.height = `${newTopPaneHeight}%`;
29
- this.bottomPane.element.style.height = `${newBottomPaneHeight}%`;
30
- })
31
- }
32
- get isHorizontalSplitter(){
33
- return true;
34
- }
35
- }
36
- const vSplitter=(topPane, bottomPane)=>new ZikoUIVerticalSplitter(topPane, bottomPane);
37
- export{
38
- ZikoUIVerticalSplitter,
39
- vSplitter
40
- }
@@ -1,180 +0,0 @@
1
- // Next
2
- // Previous
3
- // Vertical
4
- // Horizontal
5
- import { Flex, ZikoUIFlex } from "../Flex";
6
- class ZikoUITabs extends ZikoUIFlex{
7
- #ACTIVE_ELEMENT_INDEX=0;
8
- constructor(Controllers,Contents){
9
- super("div","Tabs");
10
- Object.assign(this.cache,{
11
- config:{
12
- controllersPercent : .50
13
- }
14
- })
15
- this.style({
16
- boxSizing:"border-box",
17
- backgroundColor: "blanchedalmond",
18
- border:"1px red solid",
19
- margin:"30px",
20
- });
21
- this.controllersContainer = Flex().size("auto","auto").style({
22
- boxSizing:"border-box",
23
- justifyContent:"center",
24
- alignItems:"center",
25
- textAlign:"center",
26
-
27
- minWidth:"50px",
28
- minHeight:"50px",
29
-
30
- backgroundColor:"darkblue",
31
- border:"1px darkblue solid",
32
-
33
- }).setAttr("role","tablist")
34
- this.contentContainer = Flex().style({
35
- boxSizing:"border-box",
36
- justifyContent:"center",
37
- alignItems:"center",
38
- textAlign:"center",
39
-
40
- width:"100%",
41
- height:"100%",
42
- backgroundColor:"darkslategrey",
43
- })
44
- this.append(
45
- this.controllersContainer,
46
- this.contentContainer
47
- )
48
- if(Controllers.length!==Contents.length)console.error("")
49
- else {
50
- this.controllersContainer.append(...Controllers);
51
- this.contentContainer.append(...Contents);
52
- }
53
- this.init()
54
- this.display(0);
55
- this.useVertical()
56
- }
57
- get isTabs(){
58
- return true;
59
- }
60
- init(){
61
- // Remove old listener
62
- for(let i=0;i<this.controllersContainer.length;i++){
63
- this.controllersContainer[i].setAttr("role","tab").setAttr("aria-controls",`tab${i}`);
64
- this.contentContainer[i].setAttr("role","tabpanel").setAttr("aria-labelledby",`tab${i}`).setAttr("tabindex",-1);
65
- }
66
- this.controllersContainer.forEach(item=>item.onClick(e=>{
67
- const tab=e.target.element.getAttribute("aria-controls");
68
- const index=+tab.slice(3)
69
- this.contentContainer.filter(n=>n.element.getAttribute("aria-labelledby")===tab,()=>{
70
- if(this.#ACTIVE_ELEMENT_INDEX!==index)this.display(index);
71
- })
72
- }))
73
- return this;
74
- }
75
- addPairs(ControllerItem,ContentItem){
76
- this.controllersContainer.append(ControllerItem);
77
- this.contentContainer.append(ContentItem);
78
- const length=this.controllersContainer.length;
79
- this.controllersContainer.at(-1).setAttr("role","tab").setAttr("aria-controls",`tab${length-1}`);
80
- this.contentContainer.at(-1).setAttr("role","tabpanel").setAttr("aria-labelledby",`tab${length-1}`).setAttr("tabindex",-1);
81
- // Add listener
82
- return this;
83
- }
84
- removePairs(index){
85
-
86
- }
87
- display(index){
88
- this.#ACTIVE_ELEMENT_INDEX=index%this.contentContainer.length;
89
- const ActiveContent = this.contentContainer.at(this.#ACTIVE_ELEMENT_INDEX);
90
- this.controllersContainer.forEach(n=>n.setAttr("tabindex",-1).setAttr("aria-selected",false));
91
- this.controllersContainer.at(this.#ACTIVE_ELEMENT_INDEX).setAttr("tabindex",0).setAttr("aria-selected",true);
92
-
93
- this.contentContainer.forEach(n=>n.st.hide());
94
-
95
- ActiveContent.st.translateX(100,0)
96
- ActiveContent.setAttr("tabindex",0).st.show();
97
- ActiveContent.st.translateX(0,1000)
98
-
99
- return this;
100
- }
101
- next(i=1){
102
- this.display(this.#ACTIVE_ELEMENT_INDEX+i);
103
- return this;
104
- }
105
- previous(i=1){
106
- this.display(this.#ACTIVE_ELEMENT_INDEX-i);
107
- return this;
108
- }
109
- useVertical(){
110
- this.vertical(0,0);
111
- this.controllersContainer.horizontal(0,0)
112
- this.controllersContainer.style({
113
- width : "100%",
114
- height : `${this.cache.config.controllersPercent*100}%`
115
- });
116
- this.contentContainer.style({
117
- width : "100%",
118
- height : `${(1-this.cache.config.controllersPercent)*100}%`
119
- })
120
- return this;
121
- }
122
- useHorizontal(){
123
- this.horizontal(0,0);
124
- this.controllersContainer.vertical(0, 0)
125
- this.controllersContainer.style({
126
- height : "100%",
127
- width : `${this.cache.config.controllersPercent*100}%`
128
- });
129
- this.contentContainer.style({
130
- height : "100%",
131
- width : `${(1-this.cache.config.controllersPercent)*100}%`
132
- })
133
- return this;
134
- }
135
- // useHorizontalSwippe(){
136
- // this.onPtrDown();
137
- // this.onPtrUp(e=>this.next(Math.sign(e.swippe.delta_x)));
138
- // return this;
139
- // }
140
- // useVerticalSwippe(){
141
- // this.onPtrDown();
142
- // this.onPtrUp(e=>this.next(Math.sign(e.swippe.delta_y)));
143
- // return this;
144
- // }
145
- }
146
-
147
- const Tabs=(Controllers,Contents)=>new ZikoUITabs(Controllers,Contents)
148
- export {Tabs}
149
-
150
- /*
151
-
152
- const cont=(txt = "A")=>btn(txt).style({width:"170px"})
153
- a=Tabs(
154
- [cont("A1"),cont("A2"),cont("A3"),cont("A4")],
155
- [cont("A1"),cont("A2"),cont("A3"),cont("A4")]
156
- ).vertical().size("400px")
157
- a.controllersContainer.style({
158
- overflowX:"auto"
159
- })
160
- a.useHorizontal()
161
-
162
- */
163
-
164
- /*
165
-
166
- a=Flex().size("400px","400px").style({background:"red"})
167
- a.element.animate([
168
- { borderRadius: "0" , background : "red" },
169
- { borderRadius: "50% 0" },
170
- { borderRadius: "50% 50%" },
171
- { borderRadius: "0 50%" },
172
- { borderRadius: "0", background : "yellow" },
173
- ],
174
- {
175
- // temporisation
176
- duration: 2000,
177
- iterations: Infinity,
178
- })
179
-
180
- */