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
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import { Dialog } from "../ui/dialog";
|
|
|
15
15
|
import { Label } from "../ui/label.ui";
|
|
16
16
|
import { Seo } from "./seo";
|
|
17
17
|
import { DarkTheme, LightTheme, ThemeManager } from "./themes.core";
|
|
18
|
+
import { Loading } from "../ui/loading.ui";
|
|
18
19
|
|
|
19
20
|
class WApplication implements IApplication {
|
|
20
21
|
seo: Seo;
|
|
@@ -25,6 +26,7 @@ class WApplication implements IApplication {
|
|
|
25
26
|
|
|
26
27
|
alertDialog: Dialog;
|
|
27
28
|
confirmDialog: Dialog;
|
|
29
|
+
loading: Loading;
|
|
28
30
|
|
|
29
31
|
mediaQueries: Map<string, IScreenSize>;
|
|
30
32
|
|
|
@@ -56,6 +58,8 @@ class WApplication implements IApplication {
|
|
|
56
58
|
this.alertDialog = new Dialog("Dialog.alert", null);
|
|
57
59
|
this.confirmDialog = new Dialog("Dialog.confirm", null);
|
|
58
60
|
|
|
61
|
+
this.loading = new Loading("loading", null);
|
|
62
|
+
|
|
59
63
|
this.theme.load();
|
|
60
64
|
}
|
|
61
65
|
|
|
@@ -116,7 +120,12 @@ class WApplication implements IApplication {
|
|
|
116
120
|
this.root.render();
|
|
117
121
|
}
|
|
118
122
|
|
|
119
|
-
addMediaQuery(
|
|
123
|
+
addMediaQuery(
|
|
124
|
+
query: string,
|
|
125
|
+
minWidth: number,
|
|
126
|
+
maxWidth: number,
|
|
127
|
+
cb: (app: IApplication) => void
|
|
128
|
+
): void {
|
|
120
129
|
this.mediaQueries.set(query, { minWidth, maxWidth, cb });
|
|
121
130
|
}
|
|
122
131
|
|
|
@@ -162,6 +171,15 @@ class WApplication implements IApplication {
|
|
|
162
171
|
setRoot(root: Widget): void {
|
|
163
172
|
this.root = root;
|
|
164
173
|
}
|
|
174
|
+
|
|
175
|
+
public showLoading(): void {
|
|
176
|
+
this.loading.setVisible(true);
|
|
177
|
+
this.loading.raisteTop();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public hideLoading(): void {
|
|
181
|
+
this.loading.setVisible(false);
|
|
182
|
+
}
|
|
165
183
|
}
|
|
166
184
|
|
|
167
185
|
export default WApplication;
|
package/src/index.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import Application from "./core/application.core"
|
|
2
|
-
import {DOMcreateElement, DOMcreateFragment} from "./core/jsxsupport"
|
|
3
|
-
import {Widget, WidgetTypes, WidgetAlignTypes} from "./ui/widget.ui"
|
|
4
|
-
import {initWidgetCollection} from "./ui/widget.collection"
|
|
1
|
+
import Application from "./core/application.core";
|
|
2
|
+
import { DOMcreateElement, DOMcreateFragment } from "./core/jsxsupport";
|
|
3
|
+
import { Widget, WidgetTypes, WidgetAlignTypes } from "./ui/widget.ui";
|
|
4
|
+
import { initWidgetCollection } from "./ui/widget.collection";
|
|
5
|
+
import { createWidget } from "./ui/widget.builder.ui";
|
|
5
6
|
|
|
6
7
|
initWidgetCollection();
|
|
7
8
|
|
|
8
|
-
export{
|
|
9
|
+
export {
|
|
9
10
|
Application,
|
|
11
|
+
createWidget,
|
|
10
12
|
Widget,
|
|
11
13
|
WidgetTypes,
|
|
12
14
|
WidgetAlignTypes,
|
|
13
15
|
DOMcreateElement,
|
|
14
|
-
DOMcreateFragment
|
|
15
|
-
}
|
|
16
|
-
|
|
16
|
+
DOMcreateFragment,
|
|
17
|
+
};
|
|
@@ -4,6 +4,7 @@ import { IWidget } from "./widget.interface";
|
|
|
4
4
|
import { Dialog } from "../ui/dialog";
|
|
5
5
|
import { Seo } from "../core/seo";
|
|
6
6
|
import { ThemeManager } from "../core/themes.core";
|
|
7
|
+
import { Vector2D } from "src/types/vector2d.type";
|
|
7
8
|
|
|
8
9
|
export interface IScreenSize {
|
|
9
10
|
minWidth: number;
|
|
@@ -42,4 +43,7 @@ export interface IApplication {
|
|
|
42
43
|
|
|
43
44
|
confirm(msg: string): void;
|
|
44
45
|
alert(msg: string): void;
|
|
46
|
+
|
|
47
|
+
showLoading(): void;
|
|
48
|
+
hideLoading(): void;
|
|
45
49
|
}
|
|
@@ -54,6 +54,8 @@ export interface IWidget {
|
|
|
54
54
|
unsubscribe: (event: WUIEvent) => void;
|
|
55
55
|
run(eventId: WUIEvent): void;
|
|
56
56
|
|
|
57
|
+
dispose(): void;
|
|
58
|
+
|
|
57
59
|
setPadding(p: number): void;
|
|
58
60
|
|
|
59
61
|
setX(x: number): void;
|
|
@@ -85,8 +87,8 @@ export interface IWidget {
|
|
|
85
87
|
|
|
86
88
|
getPadding(): number;
|
|
87
89
|
|
|
88
|
-
getX(): number;
|
|
89
|
-
getY(): number;
|
|
90
|
+
getX(recursive?: boolean): number;
|
|
91
|
+
getY(recursive?: boolean): number;
|
|
90
92
|
getW(): number;
|
|
91
93
|
getH(): number;
|
|
92
94
|
|
package/src/ui/Icon.ui.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { Colors } from "./colors.ui";
|
|
2
2
|
import { Widget } from "./widget.ui";
|
|
3
3
|
|
|
4
|
-
export type IconVariants =
|
|
5
|
-
| "Filled"
|
|
6
|
-
| "Outlined"
|
|
7
|
-
| "Round"
|
|
8
|
-
| "Sharp"
|
|
9
|
-
| "Two Tone";
|
|
4
|
+
export type IconVariants = "Filled" | "Outlined" | "Round" | "Sharp" | "Two Tone";
|
|
10
5
|
|
|
11
6
|
export class Icon extends Widget {
|
|
12
7
|
variant: IconVariants;
|
|
@@ -17,7 +12,7 @@ export class Icon extends Widget {
|
|
|
17
12
|
id: string,
|
|
18
13
|
icon: string,
|
|
19
14
|
variant: IconVariants = "Filled",
|
|
20
|
-
parent: Widget
|
|
15
|
+
parent: Widget | null = null
|
|
21
16
|
) {
|
|
22
17
|
super(id, "span", parent);
|
|
23
18
|
|
|
@@ -29,8 +24,7 @@ export class Icon extends Widget {
|
|
|
29
24
|
this.addClass("material-icons");
|
|
30
25
|
} else {
|
|
31
26
|
this.addClass(
|
|
32
|
-
"material-icons-" +
|
|
33
|
-
this.variant.toString().replace(" ", "-").toLowerCase()
|
|
27
|
+
"material-icons-" + this.variant.toString().replace(" ", "-").toLowerCase()
|
|
34
28
|
);
|
|
35
29
|
}
|
|
36
30
|
|
package/src/ui/IconButton.ui.ts
CHANGED
|
@@ -8,6 +8,9 @@ export class IconButton extends Button {
|
|
|
8
8
|
icon: Icon;
|
|
9
9
|
label: Label;
|
|
10
10
|
|
|
11
|
+
showIcon: boolean;
|
|
12
|
+
showText: boolean;
|
|
13
|
+
|
|
11
14
|
constructor(id: string, icon: string = "dark_mode", parent: Widget | null = null) {
|
|
12
15
|
super(id, parent);
|
|
13
16
|
|
|
@@ -15,9 +18,36 @@ export class IconButton extends Button {
|
|
|
15
18
|
this.icon = new Icon(id + ".icon", icon, undefined, this);
|
|
16
19
|
this.label = new Label(id + ".label", undefined, this);
|
|
17
20
|
|
|
21
|
+
this.showIcon = true;
|
|
22
|
+
this.showText = true;
|
|
23
|
+
|
|
18
24
|
this.init();
|
|
19
25
|
}
|
|
20
26
|
|
|
27
|
+
public displayIcon(): void {
|
|
28
|
+
this.showIcon = true;
|
|
29
|
+
this.icon.setVisible(true);
|
|
30
|
+
this.render();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public hideIcon(): void {
|
|
34
|
+
this.showIcon = false;
|
|
35
|
+
this.icon.setVisible(false);
|
|
36
|
+
this.render();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public displayText(): void {
|
|
40
|
+
this.showText = true;
|
|
41
|
+
this.label.setVisible(true);
|
|
42
|
+
this.render();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public hideText(): void {
|
|
46
|
+
this.showText = false;
|
|
47
|
+
this.label.setVisible(false);
|
|
48
|
+
this.render();
|
|
49
|
+
}
|
|
50
|
+
|
|
21
51
|
public init(): void {
|
|
22
52
|
super.init();
|
|
23
53
|
}
|
|
@@ -37,7 +67,7 @@ export class IconButton extends Button {
|
|
|
37
67
|
this.icon.getBody().style.position = "absolute";
|
|
38
68
|
|
|
39
69
|
const startX = this.getBody().clientWidth / 2 - iconWidth / 2;
|
|
40
|
-
const startY = this.getH() / 2 -
|
|
70
|
+
const startY = this.getH() / 2 - this.icon.getH() / 2;
|
|
41
71
|
|
|
42
72
|
this.icon.setX(startX);
|
|
43
73
|
this.icon.setY(startY);
|
|
@@ -49,8 +79,14 @@ export class IconButton extends Button {
|
|
|
49
79
|
|
|
50
80
|
const startX = padding; //this.getBody().clientWidth / 2 - (iconWidth + labelWidth) / 2;
|
|
51
81
|
const startLabelX = startX + iconWidth + padding;
|
|
52
|
-
|
|
53
|
-
|
|
82
|
+
let startY = this.getH() / 2 - iconWidth / 2;
|
|
83
|
+
let startLabelY = this.getH() / 2 - labelHeight / 2;
|
|
84
|
+
|
|
85
|
+
if (this.getType() !== WidgetTypes.FILL) {
|
|
86
|
+
startY = this.getH() / 2 - this.icon.getH() / 2;
|
|
87
|
+
this.label.getBody().style.lineHeight = this.getH() + "px";
|
|
88
|
+
startLabelY = this.getH() / 2 - this.label.getH() / 2;
|
|
89
|
+
}
|
|
54
90
|
|
|
55
91
|
if (startX < 0 || startY < 0) {
|
|
56
92
|
setTimeout(() => {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import "./styles/accordion.css";
|
|
2
|
+
import { IconButton } from "./IconButton.ui";
|
|
3
|
+
import { Label } from "./label.ui";
|
|
4
|
+
import { Widget, WidgetTypes } from "./widget.ui";
|
|
5
|
+
|
|
6
|
+
const ACCORDION_HEADER_HEIGHT = 40;
|
|
7
|
+
|
|
8
|
+
type AccordionItem = {
|
|
9
|
+
header: Widget;
|
|
10
|
+
content: Widget;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export class Accordion extends Widget {
|
|
14
|
+
items: Map<string, AccordionItem>;
|
|
15
|
+
selectedItemId: string | null;
|
|
16
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
17
|
+
super(id, "div", parent);
|
|
18
|
+
|
|
19
|
+
this.items = new Map<string, AccordionItem>();
|
|
20
|
+
|
|
21
|
+
this.selectedItemId = null;
|
|
22
|
+
|
|
23
|
+
this.addClass("WUIAccordion");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public selectItem(id: string): void {
|
|
27
|
+
const selected = this.items.get(id);
|
|
28
|
+
|
|
29
|
+
if (this.selectedItemId !== null) {
|
|
30
|
+
//deseleccionamos
|
|
31
|
+
const previous = this.items.get(this.selectedItemId);
|
|
32
|
+
|
|
33
|
+
if (previous) {
|
|
34
|
+
previous.content.setFixedSize(0);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (selected) {
|
|
39
|
+
this.selectedItemId = id;
|
|
40
|
+
selected.content.setFixedSize(null);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
this.render();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public addItem(title: string, icon: string, content: Widget): void {
|
|
47
|
+
const header =
|
|
48
|
+
icon !== ""
|
|
49
|
+
? new IconButton(content.id + ".header", icon, null)
|
|
50
|
+
: new Label(content.id + ".header", "span", null);
|
|
51
|
+
|
|
52
|
+
header.setType(WidgetTypes.FILL);
|
|
53
|
+
header.setFixedSize(ACCORDION_HEADER_HEIGHT);
|
|
54
|
+
header.setText(title);
|
|
55
|
+
|
|
56
|
+
header.subscribe({
|
|
57
|
+
event: "click",
|
|
58
|
+
then: (_e, _w) => {
|
|
59
|
+
this.selectItem(content.id);
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
content.setType(WidgetTypes.FILL);
|
|
64
|
+
content.setFixedSize(0);
|
|
65
|
+
|
|
66
|
+
this.items.set(content.id, { header, content });
|
|
67
|
+
|
|
68
|
+
this.addChild(header);
|
|
69
|
+
this.addChild(content);
|
|
70
|
+
}
|
|
71
|
+
}
|
package/src/ui/button.ui.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
1
|
import "./styles/button.css";
|
|
2
|
+
import "./styles/stackbutton.css";
|
|
3
|
+
import "./styles/vstackbutton.css";
|
|
2
4
|
import { Colors } from "./colors.ui";
|
|
3
5
|
import { Widget } from "./widget.ui";
|
|
4
6
|
|
|
5
|
-
export type ButonVariants =
|
|
7
|
+
export type ButonVariants =
|
|
8
|
+
| "contained"
|
|
9
|
+
| "outlined"
|
|
10
|
+
| "text"
|
|
11
|
+
| "stack-start"
|
|
12
|
+
| "stack-middle"
|
|
13
|
+
| "stack-end"
|
|
14
|
+
| "stack-start-active"
|
|
15
|
+
| "stack-middle-active"
|
|
16
|
+
| "stack-end-active"
|
|
17
|
+
| "stack-vertical-start"
|
|
18
|
+
| "stack-vertical-middle"
|
|
19
|
+
| "stack-vertical-end"
|
|
20
|
+
| "stack-vertical-start-active"
|
|
21
|
+
| "stack-vertical-middle-active"
|
|
22
|
+
| "stack-vertical-end-active";
|
|
6
23
|
export type ButonSizes = "small" | "medium" | "large";
|
|
7
24
|
|
|
8
25
|
export class Button extends Widget {
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./styles/buttoncolor.css";
|
|
2
|
+
import { Button } from "./button.ui";
|
|
3
|
+
import { Widget } from "./widget.ui";
|
|
4
|
+
|
|
5
|
+
export class ButtonColor extends Button {
|
|
6
|
+
inputColor: Widget;
|
|
7
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
8
|
+
super(id, parent);
|
|
9
|
+
|
|
10
|
+
this.inputColor = new Widget(id + ".inputColor", "input", this);
|
|
11
|
+
this.inputColor.getBody().setAttribute("type", "color");
|
|
12
|
+
this.inputColor.addClass("WUIButtonColorInput");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public setValue(value: string): void {
|
|
16
|
+
this.inputColor.getBody().setAttribute("value", value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public getValue(): string {
|
|
20
|
+
const value = this.inputColor.getBody().getAttribute("value");
|
|
21
|
+
|
|
22
|
+
return value ? value : "";
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Button } from "./button.ui";
|
|
2
|
+
import { Menu } from "./menu.ui";
|
|
3
|
+
import { SelectItem } from "./select.ui";
|
|
4
|
+
|
|
5
|
+
export class ButtonMenu extends Button {
|
|
6
|
+
menu: Menu;
|
|
7
|
+
items: Array<SelectItem>;
|
|
8
|
+
selectedItem: SelectItem | null;
|
|
9
|
+
|
|
10
|
+
public constructor(id: string) {
|
|
11
|
+
super(id);
|
|
12
|
+
|
|
13
|
+
this.menu = new Menu(this.id + ".menu", this.id, null);
|
|
14
|
+
|
|
15
|
+
this.items = new Array<SelectItem>();
|
|
16
|
+
this.selectedItem = null;
|
|
17
|
+
|
|
18
|
+
this.subscribe({
|
|
19
|
+
event: "click",
|
|
20
|
+
then: () => {
|
|
21
|
+
this.menu.clearOptions();
|
|
22
|
+
this.items.forEach((item) => {
|
|
23
|
+
this.menu.addOption(item.id, item.icon, item.label);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
this.menu.wakeUp();
|
|
27
|
+
|
|
28
|
+
if (this.getW() > this.menu.getW()) {
|
|
29
|
+
this.menu.setW(this.getBody().clientWidth);
|
|
30
|
+
console.log("cambiando ancho...");
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/*this.menu.subscribe({
|
|
36
|
+
event: "option-clicked",
|
|
37
|
+
then: (_e, clickedOption) => {
|
|
38
|
+
const option = clickedOption as IconButton;
|
|
39
|
+
|
|
40
|
+
const fintOption = this.items.find((item) => item.id === option.id);
|
|
41
|
+
|
|
42
|
+
if (fintOption) {
|
|
43
|
+
this.selectedItem = fintOption;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const selectedText = this.selectedItem?.label;
|
|
47
|
+
if (selectedText) {
|
|
48
|
+
this.setText(selectedText);
|
|
49
|
+
} else {
|
|
50
|
+
this.setText("");
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
});*/
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public addItem(id: string, label: string, icon: string): void {
|
|
57
|
+
this.items.push(new SelectItem(id, label, icon));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { OrientationTypes } from "src/types/orientation.type";
|
|
2
|
+
import { IconButton } from "./IconButton.ui";
|
|
3
|
+
import { ButonVariants, Button } from "./button.ui";
|
|
4
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
5
|
+
|
|
6
|
+
export class ButtonStack extends Widget {
|
|
7
|
+
orientation: OrientationTypes;
|
|
8
|
+
buttons: Map<string, Button | IconButton>;
|
|
9
|
+
activeButton: string | null;
|
|
10
|
+
constructor(
|
|
11
|
+
id: string,
|
|
12
|
+
orientation: OrientationTypes = "horizontal",
|
|
13
|
+
parent: Widget | null = null
|
|
14
|
+
) {
|
|
15
|
+
super(id, "div", parent);
|
|
16
|
+
|
|
17
|
+
this.orientation = orientation;
|
|
18
|
+
|
|
19
|
+
if (this.orientation === "horizontal") {
|
|
20
|
+
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
21
|
+
} else {
|
|
22
|
+
this.setAlign(WidgetAlignTypes.VERTICAL);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
this.activeButton = null;
|
|
26
|
+
|
|
27
|
+
this.buttons = new Map<string, Button | IconButton>();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public setActive(buttonId: string): void {
|
|
31
|
+
this.activeButton = buttonId;
|
|
32
|
+
this.configureStyles();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private configureStyles(): void {
|
|
36
|
+
const buttonsList = Array.from(this.buttons.entries());
|
|
37
|
+
for (let i = 0; i < buttonsList.length; i++) {
|
|
38
|
+
const [_key, button] = buttonsList[i] as [string, Button | IconButton];
|
|
39
|
+
|
|
40
|
+
button.deleteAllClasses();
|
|
41
|
+
|
|
42
|
+
if (this.thereIsOnlyOneButton()) {
|
|
43
|
+
this.setButtonVariant(button, "outlined");
|
|
44
|
+
} else if (this.thereAreTwoButtons()) {
|
|
45
|
+
if (i === 0) {
|
|
46
|
+
this.setButtonVariant(button, "stack-start");
|
|
47
|
+
} else if (i === 1) {
|
|
48
|
+
this.setButtonVariant(button, "stack-end");
|
|
49
|
+
}
|
|
50
|
+
} else if (this.thereAreMoreThanTwoButtons()) {
|
|
51
|
+
if (i === 0) {
|
|
52
|
+
this.setButtonVariant(button, "stack-start");
|
|
53
|
+
} else if (i === buttonsList.length - 1) {
|
|
54
|
+
this.setButtonVariant(button, "stack-end");
|
|
55
|
+
} else {
|
|
56
|
+
this.setButtonVariant(button, "stack-middle");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private setButtonVariant(button: Button | IconButton, variant: ButonVariants): void {
|
|
63
|
+
let fixedVariant = variant as string;
|
|
64
|
+
|
|
65
|
+
if (this.orientation === "vertical") {
|
|
66
|
+
fixedVariant = fixedVariant.replace("stack", "stack-vertical");
|
|
67
|
+
}
|
|
68
|
+
if (button.id === this.activeButton) {
|
|
69
|
+
button.setVariant((fixedVariant + "-active") as ButonVariants);
|
|
70
|
+
} else {
|
|
71
|
+
button.setVariant(fixedVariant as ButonVariants);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public addButton(button: Button | IconButton): void {
|
|
76
|
+
this.buttons.set(button.id, button);
|
|
77
|
+
button.setType(WidgetTypes.FILL);
|
|
78
|
+
button.subscribe({ event: "click", then: () => this.setActive(button.id) });
|
|
79
|
+
this.addChild(button);
|
|
80
|
+
this.configureStyles();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private thereIsOnlyOneButton(): boolean {
|
|
84
|
+
return this.buttons.size === 1;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
private thereAreTwoButtons(): boolean {
|
|
88
|
+
return this.buttons.size === 2;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private thereAreMoreThanTwoButtons(): boolean {
|
|
92
|
+
return this.buttons.size > 2;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ToggleButton } from "./toggle.ui";
|
|
2
|
+
import { Widget } from "./widget.ui";
|
|
3
|
+
|
|
4
|
+
export class Checkbox extends ToggleButton {
|
|
5
|
+
constructor(id: string, text: string = "", parent: Widget | null = null) {
|
|
6
|
+
super(id, text, "check_box_outline_blank", "check_box_outlined", parent);
|
|
7
|
+
}
|
|
8
|
+
}
|
package/src/ui/datagrid.ui.ts
CHANGED
|
@@ -51,11 +51,25 @@ export class DataGrid extends Widget {
|
|
|
51
51
|
this.addChild(this.footerContainer);
|
|
52
52
|
|
|
53
53
|
this.verticalScrollbar = new Scroll(id + ".VerticalScrollbar", this.dataContainer);
|
|
54
|
-
this.horizontalScrollbar = new Scroll(
|
|
54
|
+
this.horizontalScrollbar = new Scroll(
|
|
55
|
+
id + ".HorizontalScrollbar",
|
|
56
|
+
this.dataContainer,
|
|
57
|
+
"horizontal"
|
|
58
|
+
);
|
|
55
59
|
|
|
56
60
|
this.columns = new Array<DataGridColumn>();
|
|
57
61
|
|
|
58
62
|
this.data = new Array<any>();
|
|
63
|
+
|
|
64
|
+
this.addClass("WUIDataGrid");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public hideFooter(): void {
|
|
68
|
+
this.footerContainer.setFixedSize(0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public showFooter(): void {
|
|
72
|
+
this.footerContainer.setFixedSize(DATA_GRID_FOOTER_HEIGHT);
|
|
59
73
|
}
|
|
60
74
|
|
|
61
75
|
private getFreeWidth(): number {
|
|
@@ -138,6 +152,7 @@ export class DataGrid extends Widget {
|
|
|
138
152
|
row.setType(WidgetTypes.CUSTOM);
|
|
139
153
|
row.getBody().style.position = "absolute";
|
|
140
154
|
row.getBody().style.overflow = "hidden";
|
|
155
|
+
row.addClass("WUIDataGrid-Row");
|
|
141
156
|
|
|
142
157
|
this.dataContainer.addChild(row);
|
|
143
158
|
|
package/src/ui/draggable.ui.ts
CHANGED
|
@@ -18,6 +18,8 @@ export class Draggable {
|
|
|
18
18
|
maxX: number | null;
|
|
19
19
|
maxY: number | null;
|
|
20
20
|
|
|
21
|
+
draggingClass: string | null;
|
|
22
|
+
|
|
21
23
|
constructor(widget: Widget, orientation: DragOrientation = "both") {
|
|
22
24
|
this.target = widget;
|
|
23
25
|
|
|
@@ -25,6 +27,8 @@ export class Draggable {
|
|
|
25
27
|
this.background.setType(WidgetTypes.CUSTOM);
|
|
26
28
|
this.background.addClass("WUIDraggableBackground");
|
|
27
29
|
|
|
30
|
+
this.draggingClass = null;
|
|
31
|
+
|
|
28
32
|
this.dragDistX = 0;
|
|
29
33
|
this.dragDistY = 0;
|
|
30
34
|
|
|
@@ -70,6 +74,16 @@ export class Draggable {
|
|
|
70
74
|
this.endDrag();
|
|
71
75
|
},
|
|
72
76
|
});
|
|
77
|
+
|
|
78
|
+
this.background.setVisible(false);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public setBackgroundCursor(cursor: string): void {
|
|
82
|
+
this.background.getBody().style.cursor = cursor;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
public setDraggingClass(draggingClass: string | null): void {
|
|
86
|
+
this.draggingClass = draggingClass;
|
|
73
87
|
}
|
|
74
88
|
|
|
75
89
|
private startDrag(e: MouseEvent): void {
|
|
@@ -81,6 +95,10 @@ export class Draggable {
|
|
|
81
95
|
this.dragging = true;
|
|
82
96
|
this.background.setVisible(true);
|
|
83
97
|
this.background.raisteTop();
|
|
98
|
+
|
|
99
|
+
if (this.draggingClass) {
|
|
100
|
+
this.target.addClass(this.draggingClass);
|
|
101
|
+
}
|
|
84
102
|
}
|
|
85
103
|
|
|
86
104
|
private draggingTarget(e: MouseEvent): void {
|
|
@@ -123,6 +141,10 @@ export class Draggable {
|
|
|
123
141
|
private endDrag(): void {
|
|
124
142
|
this.dragging = false;
|
|
125
143
|
this.background.setVisible(false);
|
|
144
|
+
|
|
145
|
+
if (this.draggingClass) {
|
|
146
|
+
this.target.deleteClass(this.draggingClass);
|
|
147
|
+
}
|
|
126
148
|
}
|
|
127
149
|
|
|
128
150
|
public setMaxX(x: number | null): void {
|