cedro 0.1.4 → 0.1.6
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/core/application.core.ts +19 -1
- package/src/index.ts +9 -8
- package/src/interfaces/application.interface.ts +4 -0
- package/src/interfaces/widget.interface.ts +4 -2
- package/src/ui/Icon.ui.ts +3 -9
- package/src/ui/IconButton.ui.ts +39 -3
- package/src/ui/accordion.ui.ts +71 -0
- package/src/ui/button.ui.ts +18 -1
- package/src/ui/buttonColor.ui.ts +24 -0
- package/src/ui/buttonmenu.ui.ts +59 -0
- package/src/ui/buttonstack.ui.ts +94 -0
- package/src/ui/checkbox.ui.ts +8 -0
- package/src/ui/datagrid.ui.ts +16 -1
- package/src/ui/draggable.ui.ts +22 -0
- package/src/ui/hpanel.ui.ts +127 -0
- package/src/ui/iconButtonMenu.ui.ts +59 -0
- package/src/ui/image.ui.ts +49 -0
- package/src/ui/index.ts +32 -2
- package/src/ui/loading.ui.ts +10 -0
- package/src/ui/menu.ui.ts +41 -47
- package/src/ui/progressbar.ui.ts +74 -0
- package/src/ui/radiobutton.ts +8 -0
- package/src/ui/scroll.ui.ts +1 -2
- package/src/ui/select.ui.ts +3 -0
- package/src/ui/styles/accordion.css +9 -0
- package/src/ui/styles/button.css +0 -3
- package/src/ui/styles/buttoncolor.css +8 -0
- package/src/ui/styles/datagrid.css +28 -2
- package/src/ui/styles/hpanel.css +12 -0
- package/src/ui/styles/image.css +19 -0
- package/src/ui/styles/loading.css +12 -0
- package/src/ui/styles/loading.svg +49 -0
- package/src/ui/styles/main.css +7 -0
- package/src/ui/styles/menu.css +0 -1
- package/src/ui/styles/progressbar.css +19 -0
- package/src/ui/styles/scroll.css +1 -1
- package/src/ui/styles/stackbutton.css +205 -0
- package/src/ui/styles/tabs.css +45 -0
- package/src/ui/styles/textarea.css +13 -0
- package/src/ui/styles/textbox.css +66 -0
- package/src/ui/styles/toolbar.css +19 -0
- package/src/ui/styles/valuebar.css +26 -0
- package/src/ui/styles/vpanel.css +12 -0
- package/src/ui/styles/vstackbutton.css +202 -0
- package/src/ui/switch.ui.ts +7 -0
- package/src/ui/tabs.ui.ts +79 -28
- package/src/ui/textarea.ui.ts +20 -0
- package/src/ui/textbox.ui.ts +9 -0
- package/src/ui/toggle.ui.ts +49 -0
- package/src/ui/toolbar.ui.ts +35 -7
- package/src/ui/valuebar.ui.ts +116 -0
- package/src/ui/vpanel.ui.ts +128 -0
- package/src/ui/widget.ui.ts +28 -3
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/****************************************************************************/
|
|
2
|
+
/***********************************STACK-START******************************/
|
|
3
|
+
/****************************************************************************/
|
|
4
|
+
|
|
5
|
+
.WUIButton-stack-vertical-start {
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
font-weight: 500;
|
|
8
|
+
text-align: center;
|
|
9
|
+
background-color: transparent;
|
|
10
|
+
border-left: solid 0.13rem;
|
|
11
|
+
border-top: solid 0.13rem;
|
|
12
|
+
border-right: solid 0.13rem;
|
|
13
|
+
border-bottom: none;
|
|
14
|
+
font-size: 1rem;
|
|
15
|
+
border-top-left-radius: 0.25rem;
|
|
16
|
+
border-top-right-radius: 0.25rem;
|
|
17
|
+
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
|
|
18
|
+
border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
19
|
+
text-transform: uppercase;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.WUIButton-stack-vertical-start-color-primary {
|
|
23
|
+
color: var(--palette-text-primary);
|
|
24
|
+
background-color: var(--palette-background-default);
|
|
25
|
+
border-color: var(--palette-primary-main);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.WUIButton-stack-vertical-start-color-primary:hover {
|
|
29
|
+
color: var(--palette-primary-text-light);
|
|
30
|
+
background-color: var(--palette-primary-light);
|
|
31
|
+
border-color: var(--palette-primary-main);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/****************************************************************************/
|
|
35
|
+
/***********************************STACK-MIDDLE******************************/
|
|
36
|
+
/****************************************************************************/
|
|
37
|
+
|
|
38
|
+
.WUIButton-stack-vertical-middle {
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
text-align: center;
|
|
42
|
+
background-color: transparent;
|
|
43
|
+
border-left: solid 0.13rem;
|
|
44
|
+
border-top: solid 0.13rem;
|
|
45
|
+
border-right: solid 0.13rem;
|
|
46
|
+
border-bottom: none;
|
|
47
|
+
font-size: 1rem;
|
|
48
|
+
border-radius: 0;
|
|
49
|
+
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
|
|
50
|
+
border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
51
|
+
text-transform: uppercase;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.WUIButton-stack-vertical-middle-color-primary {
|
|
55
|
+
color: var(--palette-text-primary);
|
|
56
|
+
background-color: var(--palette-background-default);
|
|
57
|
+
border-color: var(--palette-primary-main);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.WUIButton-stack-vertical-middle-color-primary:hover {
|
|
61
|
+
color: var(--palette-primary-text-light);
|
|
62
|
+
background-color: var(--palette-primary-light);
|
|
63
|
+
border-color: var(--palette-primary-main);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**************************************************************************/
|
|
67
|
+
/***********************************STACK-END******************************/
|
|
68
|
+
/**************************************************************************/
|
|
69
|
+
|
|
70
|
+
.WUIButton-stack-vertical-end {
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
font-weight: 500;
|
|
73
|
+
text-align: center;
|
|
74
|
+
background-color: transparent;
|
|
75
|
+
border-left: solid 0.13rem;
|
|
76
|
+
border-right: solid 0.13rem;
|
|
77
|
+
border-top: solid 0.13rem;
|
|
78
|
+
border-bottom: solid 0.13rem;
|
|
79
|
+
font-size: 1rem;
|
|
80
|
+
border-top-left-radius: 0;
|
|
81
|
+
border-bottom-left-radius: 0.25rem;
|
|
82
|
+
border-top-right-radius: 0;
|
|
83
|
+
border-bottom-right-radius: 0.25rem;
|
|
84
|
+
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
|
|
85
|
+
border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
86
|
+
text-transform: uppercase;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.WUIButton-stack-vertical-end-color-primary {
|
|
90
|
+
color: var(--palette-text-primary);
|
|
91
|
+
background-color: var(--palette-background-default);
|
|
92
|
+
border-color: var(--palette-primary-main);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.WUIButton-stack-vertical-end-color-primary:hover {
|
|
96
|
+
color: var(--palette-primary-text-light);
|
|
97
|
+
background-color: var(--palette-primary-light);
|
|
98
|
+
border-color: var(--palette-primary-main);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/************************************************************************/
|
|
102
|
+
/******************************STACK-START-ACTIVE************************/
|
|
103
|
+
/************************************************************************/
|
|
104
|
+
|
|
105
|
+
.WUIButton-stack-vertical-start-active {
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
font-weight: 500;
|
|
108
|
+
text-align: center;
|
|
109
|
+
color: var(--palette-primary-text-light);
|
|
110
|
+
background-color: var(--palette-primary-light);
|
|
111
|
+
border-left: solid 0.13rem;
|
|
112
|
+
border-top: solid 0.13rem;
|
|
113
|
+
border-right: solid 0.13rem;
|
|
114
|
+
border-bottom: none;
|
|
115
|
+
font-size: 1rem;
|
|
116
|
+
border-top-left-radius: 0.25rem;
|
|
117
|
+
border-top-right-radius: 0.25rem;
|
|
118
|
+
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
|
|
119
|
+
border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
120
|
+
text-transform: uppercase;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.WUIButton-stack-vertical-start-active-color-primary {
|
|
124
|
+
color: var(--palette-primary-text-light);
|
|
125
|
+
background-color: var(--palette-primary-light);
|
|
126
|
+
border-color: var(--palette-primary-main);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.WUIButton-stack-vertical-start-active-color-primary:hover {
|
|
130
|
+
color: var(--palette-primary-text-light);
|
|
131
|
+
background-color: var(--palette-primary-light);
|
|
132
|
+
border-color: var(--palette-primary-main);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/*************************************************************************/
|
|
136
|
+
/**************************STACK-MIDDLE-ACTIVE****************************/
|
|
137
|
+
/*************************************************************************/
|
|
138
|
+
|
|
139
|
+
.WUIButton-stack-vertical-middle-active {
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
font-weight: 500;
|
|
142
|
+
text-align: center;
|
|
143
|
+
color: var(--palette-primary-text-light);
|
|
144
|
+
background-color: var(--palette-primary-light);
|
|
145
|
+
border-left: solid 0.13rem;
|
|
146
|
+
border-top: solid 0.13rem;
|
|
147
|
+
border-right: solid 0.13rem;
|
|
148
|
+
border-bottom: none;
|
|
149
|
+
font-size: 1rem;
|
|
150
|
+
border-radius: 0;
|
|
151
|
+
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
|
|
152
|
+
border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
153
|
+
text-transform: uppercase;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.WUIButton-stack-vertical-middle-active-color-primary {
|
|
157
|
+
color: var(--palette-primary-text-light);
|
|
158
|
+
background-color: var(--palette-primary-light);
|
|
159
|
+
border-color: var(--palette-primary-main);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
.WUIButton-stack-vertical-middle-active-color-primary:hover {
|
|
163
|
+
color: var(--palette-primary-text-light);
|
|
164
|
+
background-color: var(--palette-primary-light);
|
|
165
|
+
border-color: var(--palette-primary-main);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**************************************************************************/
|
|
169
|
+
/********************************STACK-END-ACTIVE**************************/
|
|
170
|
+
/**************************************************************************/
|
|
171
|
+
|
|
172
|
+
.WUIButton-stack-vertical-end-active {
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
font-weight: 500;
|
|
175
|
+
text-align: center;
|
|
176
|
+
color: var(--palette-primary-text-light);
|
|
177
|
+
background-color: var(--palette-primary-light);
|
|
178
|
+
border-left: solid 0.13rem;
|
|
179
|
+
border-right: solid 0.13rem;
|
|
180
|
+
border-top: solid 0.13rem;
|
|
181
|
+
border-bottom: solid 0.13rem;
|
|
182
|
+
font-size: 1rem;
|
|
183
|
+
border-top-left-radius: 0;
|
|
184
|
+
border-bottom-left-radius: 0.25rem;
|
|
185
|
+
border-top-right-radius: 0;
|
|
186
|
+
border-bottom-right-radius: 0.25rem;
|
|
187
|
+
transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out,
|
|
188
|
+
border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
|
|
189
|
+
text-transform: uppercase;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.WUIButton-stack-vertical-end-active-color-primary {
|
|
193
|
+
color: var(--palette-primary-text-light);
|
|
194
|
+
background-color: var(--palette-primary-light);
|
|
195
|
+
border-color: var(--palette-primary-main);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
.WUIButton-stack-vertical-end-active-color-primary:hover {
|
|
199
|
+
color: var(--palette-primary-text-light);
|
|
200
|
+
background-color: var(--palette-primary-light);
|
|
201
|
+
border-color: var(--palette-primary-main);
|
|
202
|
+
}
|
package/src/ui/tabs.ui.ts
CHANGED
|
@@ -5,31 +5,24 @@ import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
|
5
5
|
import { Toolbar } from "./toolbar.ui";
|
|
6
6
|
import { Label } from "./label.ui";
|
|
7
7
|
import { IconButton } from "./IconButton.ui";
|
|
8
|
+
import { Scroll } from "./scroll.ui";
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const TAB_HEADER_SIZE = 40;
|
|
10
11
|
|
|
11
12
|
export type TabItem = {
|
|
12
13
|
title: string;
|
|
13
14
|
content: Widget;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
|
-
class TabControl extends Label {
|
|
17
|
-
constructor(id: string, parent: Widget | null = null, text: string) {
|
|
18
|
-
super(id, "span", parent);
|
|
19
|
-
this.setText(text);
|
|
20
|
-
this.addClass("WUITabControl");
|
|
21
|
-
this.getBody().style.lineHeight = TAB_HEADER_HEIGHT + "px";
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
17
|
export class Tabs extends Widget {
|
|
25
18
|
orientation: OrientationTypes;
|
|
26
19
|
|
|
27
|
-
header: Widget;
|
|
28
20
|
content: Widget;
|
|
29
|
-
|
|
30
21
|
itemControls: Toolbar;
|
|
31
22
|
|
|
32
23
|
items: Map<string, TabItem>;
|
|
24
|
+
itemsScrollable: Map<string, boolean>;
|
|
25
|
+
verticalScrollbar: Scroll | null;
|
|
33
26
|
|
|
34
27
|
constructor(
|
|
35
28
|
id: string,
|
|
@@ -39,10 +32,6 @@ export class Tabs extends Widget {
|
|
|
39
32
|
super(id, "div", parent);
|
|
40
33
|
this.orientation = orientation;
|
|
41
34
|
|
|
42
|
-
this.header = new Widget(id + ".header", "div");
|
|
43
|
-
this.header.setType(WidgetTypes.FILL);
|
|
44
|
-
this.header.setFixedSize(TAB_HEADER_HEIGHT);
|
|
45
|
-
|
|
46
35
|
this.content = new Widget(id + ".content", "div");
|
|
47
36
|
this.content.setType(WidgetTypes.FILL);
|
|
48
37
|
this.content.addClass("WUITabContainer");
|
|
@@ -55,24 +44,44 @@ export class Tabs extends Widget {
|
|
|
55
44
|
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
56
45
|
}
|
|
57
46
|
|
|
58
|
-
this.addChild(this.header);
|
|
59
|
-
this.addChild(this.content);
|
|
60
|
-
|
|
61
47
|
this.items = new Map<string, TabItem>();
|
|
48
|
+
this.itemsScrollable = new Map<string, boolean>();
|
|
49
|
+
this.verticalScrollbar = null;
|
|
62
50
|
|
|
63
|
-
this.itemControls = new Toolbar(id + ".itemControls",
|
|
51
|
+
this.itemControls = new Toolbar(id + ".itemControls", null, orientation);
|
|
52
|
+
this.itemControls.setVariant("contained");
|
|
53
|
+
this.itemControls.setFixedSize(TAB_HEADER_SIZE);
|
|
54
|
+
|
|
55
|
+
this.addChild(this.itemControls);
|
|
56
|
+
this.addChild(this.content);
|
|
57
|
+
|
|
58
|
+
this.addClass("WUITab");
|
|
64
59
|
}
|
|
65
60
|
|
|
66
61
|
public setOrientation(orientation: OrientationTypes) {
|
|
67
62
|
this.orientation = orientation;
|
|
68
63
|
}
|
|
69
64
|
|
|
70
|
-
public addTab(id: string, title: string, content: Widget) {
|
|
65
|
+
public addTab(id: string, title: string, content: Widget, scrollable: boolean = false) {
|
|
71
66
|
this.items.set(id, { title, content });
|
|
67
|
+
this.itemsScrollable.set(id, scrollable);
|
|
68
|
+
|
|
69
|
+
const itemControl = new Label(id + ".itemControl", "span");
|
|
70
|
+
|
|
71
|
+
itemControl.setText(title);
|
|
72
|
+
itemControl.addClass("WUITabControl");
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
if (this.orientation === "horizontal") {
|
|
75
|
+
itemControl.setH(TAB_HEADER_SIZE);
|
|
76
|
+
itemControl.getBody().style.lineHeight = TAB_HEADER_SIZE + "px";
|
|
77
|
+
} else if (this.orientation === "vertical") {
|
|
78
|
+
itemControl.getBody().style.writingMode = "vertical-rl";
|
|
79
|
+
itemControl.getBody().style.transform = "scale(-1,-1)";
|
|
80
|
+
itemControl.getBody().style.paddingTop = "15px";
|
|
81
|
+
itemControl.getBody().style.paddingBottom = "15px";
|
|
82
|
+
itemControl.getBody().style.paddingRight = "12px";
|
|
83
|
+
itemControl.setW(TAB_HEADER_SIZE);
|
|
84
|
+
}
|
|
76
85
|
|
|
77
86
|
itemControl.subscribe({
|
|
78
87
|
event: "click",
|
|
@@ -84,12 +93,13 @@ export class Tabs extends Widget {
|
|
|
84
93
|
this.itemControls.addItem(id, itemControl);
|
|
85
94
|
}
|
|
86
95
|
|
|
87
|
-
public addIconTab(id: string, icon: string, content: Widget) {
|
|
96
|
+
public addIconTab(id: string, icon: string, content: Widget, scrollable: boolean = false) {
|
|
88
97
|
this.items.set(id, { title: icon, content });
|
|
98
|
+
this.itemsScrollable.set(id, scrollable);
|
|
89
99
|
|
|
90
100
|
const itemControl = new IconButton(id + ".itemControl", icon);
|
|
91
101
|
itemControl.setW(40);
|
|
92
|
-
itemControl.setH(
|
|
102
|
+
itemControl.setH(TAB_HEADER_SIZE);
|
|
93
103
|
|
|
94
104
|
itemControl.subscribe({
|
|
95
105
|
event: "click",
|
|
@@ -110,22 +120,63 @@ export class Tabs extends Widget {
|
|
|
110
120
|
this.items.get(itemId)?.content.setVisible(false);
|
|
111
121
|
const ctrlTab = window.w.get(itemId + ".itemControl");
|
|
112
122
|
if (ctrlTab) {
|
|
113
|
-
|
|
114
|
-
|
|
123
|
+
if (this.orientation === "horizontal") {
|
|
124
|
+
ctrlTab.deleteClass("WUITabControlActive");
|
|
125
|
+
ctrlTab.addClass("WUITabControl");
|
|
126
|
+
} else if (this.orientation === "vertical") {
|
|
127
|
+
if (ctrlTab instanceof IconButton) {
|
|
128
|
+
ctrlTab.deleteClass("WUITabControlActiveIcon_VL");
|
|
129
|
+
} else if (ctrlTab instanceof Label) {
|
|
130
|
+
ctrlTab.deleteClass("WUITabControlActive_VL");
|
|
131
|
+
}
|
|
132
|
+
ctrlTab.addClass("WUITabControl");
|
|
133
|
+
}
|
|
115
134
|
}
|
|
116
135
|
} else {
|
|
117
136
|
const ctrlTab = window.w.get(itemId + ".itemControl");
|
|
118
137
|
if (ctrlTab) {
|
|
119
|
-
|
|
138
|
+
if (this.orientation === "horizontal") {
|
|
139
|
+
ctrlTab.addClass("WUITabControlActive");
|
|
140
|
+
} else if (this.orientation === "vertical") {
|
|
141
|
+
if (ctrlTab instanceof IconButton) {
|
|
142
|
+
ctrlTab.addClass("WUITabControlActiveIcon_VL");
|
|
143
|
+
} else if (ctrlTab instanceof Label) {
|
|
144
|
+
ctrlTab.addClass("WUITabControlActive_VL");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
120
147
|
}
|
|
121
148
|
}
|
|
122
149
|
}
|
|
123
150
|
|
|
124
151
|
if (actualTab) {
|
|
125
152
|
this.items.get(id)?.content.setVisible(true);
|
|
153
|
+
const scrollable = this.itemsScrollable.get(id);
|
|
154
|
+
|
|
126
155
|
this.content.addChild(actualTab.content);
|
|
156
|
+
|
|
157
|
+
if (scrollable) {
|
|
158
|
+
if (this.verticalScrollbar == null) {
|
|
159
|
+
this.verticalScrollbar = new Scroll(
|
|
160
|
+
actualTab.content.id + ".verticalScrollbar",
|
|
161
|
+
this.content,
|
|
162
|
+
"vertical"
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
} else {
|
|
166
|
+
if (this.verticalScrollbar) {
|
|
167
|
+
this.verticalScrollbar.dispose();
|
|
168
|
+
this.verticalScrollbar = null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
127
171
|
}
|
|
128
172
|
|
|
129
173
|
this.render();
|
|
130
174
|
}
|
|
175
|
+
|
|
176
|
+
public render(): void {
|
|
177
|
+
super.render();
|
|
178
|
+
if (this.verticalScrollbar) {
|
|
179
|
+
this.verticalScrollbar.render();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
131
182
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "./styles/textarea.css";
|
|
2
|
+
import { Widget } from "./widget.ui";
|
|
3
|
+
|
|
4
|
+
export class TextArea extends Widget {
|
|
5
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
6
|
+
super(id, "textarea", parent);
|
|
7
|
+
|
|
8
|
+
this.addClass("WUITextArea");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public setText(text: string): void {
|
|
12
|
+
const textArea = this.getBody() as HTMLTextAreaElement;
|
|
13
|
+
textArea.value = text;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public getText(): string {
|
|
17
|
+
const textArea = this.getBody() as HTMLTextAreaElement;
|
|
18
|
+
return textArea.value;
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/ui/textbox.ui.ts
CHANGED
|
@@ -3,10 +3,14 @@ import { Widget, WidgetTypes } from "./widget.ui";
|
|
|
3
3
|
|
|
4
4
|
export type InputTypes =
|
|
5
5
|
| "text"
|
|
6
|
+
| "date"
|
|
7
|
+
| "datetime-local"
|
|
8
|
+
| "file"
|
|
6
9
|
| "number"
|
|
7
10
|
| "password"
|
|
8
11
|
| "email"
|
|
9
12
|
| "url"
|
|
13
|
+
| "color"
|
|
10
14
|
| "tel";
|
|
11
15
|
|
|
12
16
|
export class Textbox extends Widget {
|
|
@@ -71,6 +75,10 @@ export class Textbox extends Widget {
|
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
private positionLabel(): void {
|
|
78
|
+
if (this.title === "") {
|
|
79
|
+
this.label.setVisible(false);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
74
82
|
if (this.getValue() === "") {
|
|
75
83
|
this.moveLabelToCenter();
|
|
76
84
|
} else {
|
|
@@ -99,6 +107,7 @@ export class Textbox extends Widget {
|
|
|
99
107
|
|
|
100
108
|
this.positionLabel();
|
|
101
109
|
this.input.setWH(this.getW(), this.getH());
|
|
110
|
+
this.input.getBody().style.lineHeight = this.getH() + "px";
|
|
102
111
|
this.input.render();
|
|
103
112
|
|
|
104
113
|
super.render();
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Widget } from "./widget.ui";
|
|
2
|
+
import { IconButton } from "./IconButton.ui";
|
|
3
|
+
|
|
4
|
+
export class ToggleButton extends IconButton {
|
|
5
|
+
state: boolean;
|
|
6
|
+
toggleOnIcon: string;
|
|
7
|
+
toggleOffIcon: string;
|
|
8
|
+
|
|
9
|
+
constructor(
|
|
10
|
+
id: string,
|
|
11
|
+
text: string = "",
|
|
12
|
+
toggleOnIcon: string = "toggle_on",
|
|
13
|
+
toggleOffIcon: string = "toggle_off",
|
|
14
|
+
parent: Widget | null = null
|
|
15
|
+
) {
|
|
16
|
+
super(id, toggleOffIcon, parent);
|
|
17
|
+
|
|
18
|
+
this.toggleOnIcon = toggleOnIcon;
|
|
19
|
+
this.toggleOffIcon = toggleOffIcon;
|
|
20
|
+
|
|
21
|
+
this.state = false;
|
|
22
|
+
|
|
23
|
+
if (text) {
|
|
24
|
+
this.setText(text);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
this.setVariant("text");
|
|
28
|
+
|
|
29
|
+
this.subscribe({
|
|
30
|
+
event: "click",
|
|
31
|
+
then: () => {
|
|
32
|
+
this.toggle();
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public setState(state: boolean): void {
|
|
38
|
+
this.state = state;
|
|
39
|
+
this.setIcon(state ? this.toggleOnIcon : this.toggleOffIcon);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public toggle(): void {
|
|
43
|
+
this.setState(!this.state);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public getState(): boolean {
|
|
47
|
+
return this.state;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/src/ui/toolbar.ui.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import "./styles/toolbar.css";
|
|
1
2
|
import { IWidget } from "src/interfaces/widget.interface";
|
|
2
|
-
import { Widget, WidgetTypes } from "./widget.ui";
|
|
3
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
3
4
|
import { IconButton } from "./IconButton.ui";
|
|
4
5
|
import { OrientationTypes } from "src/types/orientation.type";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
export type ToolbarVariants = "contained" | "outlined";
|
|
8
|
+
|
|
9
|
+
const TOOLBAR_SIZE = 48;
|
|
7
10
|
const TOOLBAR_BUTTON_SIZE = 40;
|
|
8
11
|
|
|
9
12
|
export class Toolbar extends Widget {
|
|
10
13
|
orientation: OrientationTypes;
|
|
14
|
+
variant: ToolbarVariants;
|
|
11
15
|
items: Map<string, IWidget>;
|
|
12
16
|
size: number; //Indica el alto o ancho de la toolbar.
|
|
13
17
|
|
|
@@ -15,18 +19,33 @@ export class Toolbar extends Widget {
|
|
|
15
19
|
btnLeft: IconButton;
|
|
16
20
|
btnRight: IconButton;
|
|
17
21
|
|
|
18
|
-
constructor(
|
|
22
|
+
constructor(
|
|
23
|
+
id: string,
|
|
24
|
+
parent: Widget | null = null,
|
|
25
|
+
orientationType: OrientationTypes = "horizontal"
|
|
26
|
+
) {
|
|
19
27
|
super(id, "div", parent);
|
|
20
28
|
this.orientation = orientationType;
|
|
21
29
|
this.size = TOOLBAR_SIZE;
|
|
22
30
|
this.items = new Map<string, IWidget>();
|
|
23
31
|
|
|
32
|
+
this.variant = "outlined";
|
|
33
|
+
|
|
34
|
+
if (this.orientation === "vertical") {
|
|
35
|
+
this.setAlign(WidgetAlignTypes.VERTICAL);
|
|
36
|
+
} else {
|
|
37
|
+
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
this.setType(WidgetTypes.FILL);
|
|
41
|
+
this.setFixedSize(TOOLBAR_SIZE);
|
|
42
|
+
this.addClass("WUIToolbar-" + this.variant);
|
|
43
|
+
|
|
24
44
|
this.itemsContainer = new Widget(this.id + ".itemsContainer", "div", this);
|
|
25
45
|
this.itemsContainer.setType(WidgetTypes.CUSTOM);
|
|
26
46
|
this.itemsContainer.getBody().style.position = "absolute";
|
|
27
47
|
this.itemsContainer.getBody().style.overflow = "hidden";
|
|
28
48
|
|
|
29
|
-
this.setType(WidgetTypes.FILL);
|
|
30
49
|
this.getBody().style.overflow = "hidden";
|
|
31
50
|
|
|
32
51
|
this.btnLeft = new IconButton(this.id + ".btnLeft", this.getIconLeft());
|
|
@@ -66,6 +85,12 @@ export class Toolbar extends Widget {
|
|
|
66
85
|
});
|
|
67
86
|
}
|
|
68
87
|
|
|
88
|
+
public setVariant(variant: ToolbarVariants): void {
|
|
89
|
+
this.deleteClass("WUIToolbar-" + this.variant);
|
|
90
|
+
this.variant = variant;
|
|
91
|
+
this.addClass("WUIToolbar-" + this.variant);
|
|
92
|
+
}
|
|
93
|
+
|
|
69
94
|
public getIconLeft(): string {
|
|
70
95
|
if (this.orientation === "horizontal") {
|
|
71
96
|
return "arrow_left";
|
|
@@ -134,8 +159,11 @@ export class Toolbar extends Widget {
|
|
|
134
159
|
}
|
|
135
160
|
|
|
136
161
|
public render(): void {
|
|
162
|
+
super.render();
|
|
137
163
|
const fullSize = this.getFullSize();
|
|
138
|
-
const
|
|
164
|
+
const parent = this.getParent();
|
|
165
|
+
const parentH = parent?.getH() || 0;
|
|
166
|
+
const availableSize = this.orientation === "horizontal" ? this.getW() : parentH;
|
|
139
167
|
|
|
140
168
|
if (fullSize > availableSize) {
|
|
141
169
|
this.btnLeft.setVisible(true);
|
|
@@ -190,14 +218,14 @@ export class Toolbar extends Widget {
|
|
|
190
218
|
item.setY(currentPosition);
|
|
191
219
|
currentPosition += item.getH();
|
|
192
220
|
item.setX(0);
|
|
221
|
+
item.setW(TOOLBAR_BUTTON_SIZE);
|
|
193
222
|
} else {
|
|
194
223
|
item.setX(currentPosition);
|
|
195
224
|
item.setY(0);
|
|
225
|
+
item.setH(TOOLBAR_BUTTON_SIZE);
|
|
196
226
|
currentPosition += item.getW();
|
|
197
227
|
}
|
|
198
228
|
item.render();
|
|
199
229
|
}
|
|
200
|
-
|
|
201
|
-
super.render();
|
|
202
230
|
}
|
|
203
231
|
}
|