cedro 0.1.7 → 0.1.9
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.builder.tsx +60 -0
- package/src/core/{application.core.ts → application.core.tsx} +68 -1
- package/src/index.ts +1 -1
- package/src/interfaces/application.interface.ts +7 -1
- package/src/interfaces/widget.interface.ts +3 -1
- package/src/ui/{IconButton.ui.ts → IconButton.ui.tsx} +79 -2
- package/src/ui/{button.ui.ts → button.ui.tsx} +63 -1
- package/src/ui/checkbox.ui.tsx +47 -0
- package/src/ui/container.ui.tsx +76 -0
- package/src/ui/{hpanel.ui.ts → hpanel.ui.tsx} +37 -0
- package/src/ui/image.ui.tsx +112 -0
- package/src/ui/index.ts +1 -1
- package/src/ui/label.ui.tsx +126 -0
- package/src/ui/progressbar.ui.tsx +134 -0
- package/src/ui/radiobutton.tsx +51 -0
- package/src/ui/styles/hpanel.css +1 -1
- package/src/ui/styles/progressbar.css +1 -1
- package/src/ui/styles/valuebar.css +1 -1
- package/src/ui/styles/vpanel.css +1 -1
- package/src/ui/switch.ui.tsx +46 -0
- package/src/ui/{tabs.ui.ts → tabs.ui.tsx} +86 -1
- package/src/ui/{textbox.ui.ts → textbox.ui.tsx} +54 -1
- package/src/ui/{toolbar.ui.ts → toolbar.ui.tsx} +38 -0
- package/src/ui/{valuebar.ui.ts → valuebar.ui.tsx} +37 -1
- package/src/ui/{vpanel.ui.ts → vpanel.ui.tsx} +37 -0
- package/src/ui/widget.builder.ts +159 -0
- package/src/ui/widget.collection.ts +35 -5
- package/src/ui/widget.ui.ts +107 -15
- package/src/ui/checkbox.ui.ts +0 -8
- package/src/ui/container.ui.ts +0 -33
- package/src/ui/image.ui.ts +0 -49
- package/src/ui/label.ui.ts +0 -57
- package/src/ui/progressbar.ui.ts +0 -74
- package/src/ui/radiobutton.ts +0 -8
- package/src/ui/switch.ui.ts +0 -7
- package/src/ui/widget.builder.ui.tsx +0 -676
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { UID } from "../core/uid";
|
|
2
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
3
|
+
import { createTextbox } from "./textbox.ui";
|
|
4
|
+
import { createButton } from "./button.ui";
|
|
5
|
+
import { addNewWidget } from "./widget.collection";
|
|
6
|
+
import { createLabel } from "./label.ui";
|
|
7
|
+
import { OrientationTypes } from "src/types/orientation.type";
|
|
8
|
+
import { createContainer } from "./container.ui";
|
|
9
|
+
import { createIconButton } from "./IconButton.ui";
|
|
10
|
+
import { createImage } from "./image.ui";
|
|
11
|
+
import { createCheckbox } from "./checkbox.ui";
|
|
12
|
+
import { createRadioButton } from "./radiobutton";
|
|
13
|
+
import { createToolbar } from "./toolbar.ui";
|
|
14
|
+
import { createProgressBar } from "./progressbar.ui";
|
|
15
|
+
import { createValueBar } from "./valuebar.ui";
|
|
16
|
+
import { VPanel, createVPanel } from "./vpanel.ui";
|
|
17
|
+
import { HPanel, createHPanel } from "./hpanel.ui";
|
|
18
|
+
import { Tabs, createTab } from "./tabs.ui";
|
|
19
|
+
import { createSwitch } from "./switch.ui";
|
|
20
|
+
|
|
21
|
+
export type WidgetEventProps = {
|
|
22
|
+
onClick?: () => {} | void;
|
|
23
|
+
onResize?: () => {} | void;
|
|
24
|
+
onMouseDown?: () => {} | void;
|
|
25
|
+
onMouseUp?: () => {} | void;
|
|
26
|
+
onMouseMove?: () => {} | void;
|
|
27
|
+
onMouseOut?: () => {} | void;
|
|
28
|
+
onMouseLeave?: () => {} | void;
|
|
29
|
+
onWheel?: () => {} | void;
|
|
30
|
+
onDrag?: () => {} | void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type WidgetProps = {
|
|
34
|
+
id: string;
|
|
35
|
+
type?: WidgetTypes | null;
|
|
36
|
+
padding?: number | null;
|
|
37
|
+
classNames?: string | null;
|
|
38
|
+
fixedSize?: number | null;
|
|
39
|
+
orientation?: OrientationTypes | null;
|
|
40
|
+
} & WidgetEventProps;
|
|
41
|
+
|
|
42
|
+
export function createWidget(
|
|
43
|
+
content: any,
|
|
44
|
+
parent: Widget | null = null,
|
|
45
|
+
freedom: boolean = false
|
|
46
|
+
): Widget | null {
|
|
47
|
+
if (!content.tagName) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
let widget: Widget | null = null;
|
|
52
|
+
let widgetProps: WidgetProps = {
|
|
53
|
+
id: content.id ? content.id : UID(),
|
|
54
|
+
type:
|
|
55
|
+
content.getAttribute("w-type") === null
|
|
56
|
+
? WidgetTypes.FILL
|
|
57
|
+
: parseInt(content.getAttribute("w-type")),
|
|
58
|
+
orientation:
|
|
59
|
+
content.getAttribute("w-orientation") === null
|
|
60
|
+
? "horizontal"
|
|
61
|
+
: content.getAttribute("w-orientation"),
|
|
62
|
+
padding:
|
|
63
|
+
content.getAttribute("w-padding") === null
|
|
64
|
+
? 0
|
|
65
|
+
: parseInt(content.getAttribute("w-padding")),
|
|
66
|
+
fixedSize:
|
|
67
|
+
content.getAttribute("w-fixed-size") === null
|
|
68
|
+
? null
|
|
69
|
+
: parseInt(content.getAttribute("w-fixed-size")),
|
|
70
|
+
classNames:
|
|
71
|
+
content.getAttribute("w-classes") === null ? null : content.getAttribute("w-classes"),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
if (content.getAttribute("w-textbox")) {
|
|
75
|
+
widget = createTextbox(widgetProps.id, content, parent);
|
|
76
|
+
} else if (content.getAttribute("w-button")) {
|
|
77
|
+
widget = createButton(widgetProps.id, content, parent);
|
|
78
|
+
} else if (content.getAttribute("w-icon-button")) {
|
|
79
|
+
widget = createIconButton(widgetProps.id, content, parent);
|
|
80
|
+
} else if (content.getAttribute("w-label")) {
|
|
81
|
+
widget = createLabel(widgetProps.id, content, parent);
|
|
82
|
+
} else if (content.getAttribute("w-image")) {
|
|
83
|
+
widget = createImage(widgetProps.id, content, parent);
|
|
84
|
+
} else if (content.getAttribute("w-checkbox")) {
|
|
85
|
+
widget = createCheckbox(widgetProps.id, content, parent);
|
|
86
|
+
} else if (content.getAttribute("w-radiobutton")) {
|
|
87
|
+
widget = createRadioButton(widgetProps.id, content, parent);
|
|
88
|
+
} else if (content.getAttribute("w-switch")) {
|
|
89
|
+
widget = createSwitch(widgetProps.id, content, parent);
|
|
90
|
+
} else if (content.getAttribute("w-toolbar")) {
|
|
91
|
+
widget = createToolbar(widgetProps.id, content, parent);
|
|
92
|
+
} else if (content.getAttribute("w-progressbar")) {
|
|
93
|
+
widget = createProgressBar(widgetProps.id, content, parent);
|
|
94
|
+
} else if (content.getAttribute("w-valuebar")) {
|
|
95
|
+
widget = createValueBar(widgetProps.id, content, parent);
|
|
96
|
+
} else if (content.getAttribute("w-tab")) {
|
|
97
|
+
widget = createTab(widgetProps.id, content, parent);
|
|
98
|
+
} else if (content.getAttribute("w-vpanel")) {
|
|
99
|
+
widget = createVPanel(widgetProps.id, content, parent);
|
|
100
|
+
} else if (content.getAttribute("w-hpanel")) {
|
|
101
|
+
widget = createHPanel(widgetProps.id, content, parent);
|
|
102
|
+
} else if (content.getAttribute("w-container")) {
|
|
103
|
+
widget = createContainer(content, parent);
|
|
104
|
+
} else {
|
|
105
|
+
widget = new Widget(widgetProps.id, content.tagName, parent);
|
|
106
|
+
|
|
107
|
+
if (widgetProps.type === WidgetTypes.FREE) {
|
|
108
|
+
freedom = true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
content.getAttributeNames().forEach((key: string) => {
|
|
112
|
+
if (widget) widget.getBody().setAttribute(key, content.getAttribute(key));
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
(content as HTMLElement).childNodes.forEach((child) => {
|
|
116
|
+
if (child.hasChildNodes() == true) {
|
|
117
|
+
createWidget(child, widget, freedom);
|
|
118
|
+
} else {
|
|
119
|
+
if (widget) widget.getBody().appendChild(child);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (widget) {
|
|
125
|
+
if (!freedom && widgetProps.type) {
|
|
126
|
+
widget.setType(widgetProps.type);
|
|
127
|
+
} else {
|
|
128
|
+
widget.setType(WidgetTypes.FREE);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (
|
|
132
|
+
widgetProps.orientation &&
|
|
133
|
+
!(widget instanceof VPanel) &&
|
|
134
|
+
!(widget instanceof HPanel) &&
|
|
135
|
+
!(widget instanceof Tabs)
|
|
136
|
+
) {
|
|
137
|
+
if (widgetProps.orientation === "vertical") {
|
|
138
|
+
widget.setAlign(WidgetAlignTypes.VERTICAL);
|
|
139
|
+
} else {
|
|
140
|
+
widget.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (widgetProps.padding) widget.setPadding(widgetProps.padding);
|
|
144
|
+
if (widgetProps.fixedSize) widget.setFixedSize(widgetProps.fixedSize);
|
|
145
|
+
|
|
146
|
+
if (widgetProps.classNames) {
|
|
147
|
+
const clases = widgetProps.classNames.split(" ");
|
|
148
|
+
for (const clase of clases) {
|
|
149
|
+
widget.addClass(clase);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
addNewWidget(widgetProps.id, widget);
|
|
154
|
+
|
|
155
|
+
return widget;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
@@ -1,19 +1,49 @@
|
|
|
1
|
-
import
|
|
1
|
+
import WApplication from "src/core/application.core";
|
|
2
|
+
import { IWidget, WUICallback } from "../interfaces/widget.interface";
|
|
2
3
|
|
|
3
4
|
declare global {
|
|
4
5
|
interface Window {
|
|
6
|
+
app: WApplication | undefined;
|
|
5
7
|
w: Map<string, IWidget>;
|
|
8
|
+
widgetConnections: Map<string, WUICallback>;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
var w: Map<string, IWidget>;
|
|
12
|
+
var app: WApplication | undefined;
|
|
13
|
+
var widgetConnections: Map<string, WUICallback>;
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
export const initWidgetCollection = () => {
|
|
12
|
-
|
|
13
|
-
if(!window.w) {
|
|
17
|
+
if (!window.w) {
|
|
14
18
|
window.w = new Map<string, IWidget>();
|
|
15
19
|
w = window.w;
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
21
|
|
|
22
|
+
initWidgetConnections();
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const initWidgetConnections = () => {
|
|
26
|
+
if (!window.widgetConnections) {
|
|
27
|
+
window.widgetConnections = new Map<string, WUICallback>();
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const addNewWidget = (id: string, widget: IWidget) => {
|
|
32
|
+
initWidgetCollection();
|
|
33
|
+
w.set(id, widget);
|
|
34
|
+
run("widget-added-" + id);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const connectWidget = (id: string, callback: WUICallback) => {
|
|
38
|
+
initWidgetConnections();
|
|
39
|
+
widgetConnections.set(id, callback);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const run = (eventId: string) => {
|
|
43
|
+
for (const [key, value] of widgetConnections.entries()) {
|
|
44
|
+
if (key == eventId) {
|
|
45
|
+
value.then(new Event(eventId), null);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
widgetConnections.delete(eventId);
|
|
49
|
+
};
|
package/src/ui/widget.ui.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { IWidget, WUIEvent, WUICallback } from "../interfaces/widget.interface";
|
|
2
2
|
import { Vector2D } from "../types/vector2d.type";
|
|
3
|
+
import { WidgetEventProps, WidgetProps } from "./widget.builder";
|
|
4
|
+
import { addNewWidget, connectWidget } from "./widget.collection";
|
|
3
5
|
|
|
4
6
|
export enum WidgetTypes {
|
|
5
7
|
FILL = 1,
|
|
@@ -141,14 +143,7 @@ export class Widget implements IWidget {
|
|
|
141
143
|
|
|
142
144
|
this.getMaxZIndex();
|
|
143
145
|
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
public dispose(): void {
|
|
148
|
-
this.removeAllChilds();
|
|
149
|
-
const body = this.getBody();
|
|
150
|
-
const parent = body.parentNode;
|
|
151
|
-
parent?.removeChild(body);
|
|
146
|
+
addNewWidget(this.id, this);
|
|
152
147
|
}
|
|
153
148
|
|
|
154
149
|
public run(eventId: WUIEvent): void {
|
|
@@ -792,7 +787,7 @@ export class Widget implements IWidget {
|
|
|
792
787
|
this.setVisible(!this.visible);
|
|
793
788
|
}
|
|
794
789
|
|
|
795
|
-
renderHTML(content: any): HTMLElement {
|
|
790
|
+
public renderHTML(content: any): HTMLElement {
|
|
796
791
|
this.body.appendChild(content);
|
|
797
792
|
return content as HTMLElement;
|
|
798
793
|
}
|
|
@@ -813,15 +808,15 @@ export class Widget implements IWidget {
|
|
|
813
808
|
return maxZindex;
|
|
814
809
|
}
|
|
815
810
|
|
|
816
|
-
setZIndex(zIndex: number): void {
|
|
811
|
+
public setZIndex(zIndex: number): void {
|
|
817
812
|
this.getBody().style.zIndex = `${zIndex}`;
|
|
818
813
|
}
|
|
819
814
|
|
|
820
|
-
raisteTop(): void {
|
|
815
|
+
public raisteTop(): void {
|
|
821
816
|
this.setZIndex(this.getMaxZIndex() + 1);
|
|
822
817
|
}
|
|
823
818
|
|
|
824
|
-
raiseBottom(): void {
|
|
819
|
+
public raiseBottom(): void {
|
|
825
820
|
this.setZIndex(0);
|
|
826
821
|
}
|
|
827
822
|
|
|
@@ -831,7 +826,7 @@ export class Widget implements IWidget {
|
|
|
831
826
|
* @param {IWidget} guest - The widget to attach.
|
|
832
827
|
* @return {void} This function does not return anything.
|
|
833
828
|
*/
|
|
834
|
-
attachWidget(guest: IWidget): void {
|
|
829
|
+
public attachWidget(guest: IWidget): void {
|
|
835
830
|
this.removeAllChilds();
|
|
836
831
|
this.addChild(guest);
|
|
837
832
|
guest.setParent(this);
|
|
@@ -845,7 +840,7 @@ export class Widget implements IWidget {
|
|
|
845
840
|
*
|
|
846
841
|
* @return {void} No return value.
|
|
847
842
|
*/
|
|
848
|
-
removeAllChilds(): void {
|
|
843
|
+
public removeAllChilds(): void {
|
|
849
844
|
while (this.getBody().childNodes.length > 0) {
|
|
850
845
|
const child = this.getBody().firstChild;
|
|
851
846
|
if (child) this.getBody().removeChild(child);
|
|
@@ -854,7 +849,7 @@ export class Widget implements IWidget {
|
|
|
854
849
|
this.childs = [];
|
|
855
850
|
}
|
|
856
851
|
|
|
857
|
-
free(): void {
|
|
852
|
+
public free(): void {
|
|
858
853
|
if (this.childs) {
|
|
859
854
|
for (const child of this.childs) {
|
|
860
855
|
child.free();
|
|
@@ -862,4 +857,101 @@ export class Widget implements IWidget {
|
|
|
862
857
|
}
|
|
863
858
|
window.w.delete(this.id);
|
|
864
859
|
}
|
|
860
|
+
|
|
861
|
+
public dispose(): void {
|
|
862
|
+
this.removeAllChilds();
|
|
863
|
+
const body = this.getBody();
|
|
864
|
+
const parent = body.parentNode;
|
|
865
|
+
parent?.removeChild(body);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
export function getOnlyEventProps(props: WidgetProps): WidgetEventProps {
|
|
870
|
+
const eventProps = {
|
|
871
|
+
onClick: props.onClick,
|
|
872
|
+
onDrag: props.onDrag,
|
|
873
|
+
onResize: props.onResize,
|
|
874
|
+
onMouseDown: props.onMouseDown,
|
|
875
|
+
onMouseUp: props.onMouseUp,
|
|
876
|
+
onMouseMove: props.onMouseMove,
|
|
877
|
+
onMouseOut: props.onMouseOut,
|
|
878
|
+
onMouseLeave: props.onMouseLeave,
|
|
879
|
+
onWheel: props.onWheel,
|
|
880
|
+
};
|
|
881
|
+
|
|
882
|
+
return eventProps;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
export function connectWidgetCallback(id: string, props: WidgetEventProps): void {
|
|
886
|
+
connectWidget("widget-added-" + id, {
|
|
887
|
+
event: "widget-load",
|
|
888
|
+
then: (_e, _w) => {
|
|
889
|
+
const widget = w.get(id) as Widget;
|
|
890
|
+
|
|
891
|
+
if (widget) {
|
|
892
|
+
widget.subscribe({
|
|
893
|
+
event: "click",
|
|
894
|
+
then: (_e, _w) => {
|
|
895
|
+
props.onClick ? props.onClick() : null;
|
|
896
|
+
},
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
widget.subscribe({
|
|
900
|
+
event: "drag",
|
|
901
|
+
then: (_e, _w) => {
|
|
902
|
+
props.onDrag ? props.onDrag() : null;
|
|
903
|
+
},
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
widget.subscribe({
|
|
907
|
+
event: "resize",
|
|
908
|
+
then: (_e, _w) => {
|
|
909
|
+
props.onResize ? props.onResize() : null;
|
|
910
|
+
},
|
|
911
|
+
});
|
|
912
|
+
|
|
913
|
+
widget.subscribe({
|
|
914
|
+
event: "mousedown",
|
|
915
|
+
then: (_e, _w) => {
|
|
916
|
+
props.onMouseDown ? props.onMouseDown() : null;
|
|
917
|
+
},
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
widget.subscribe({
|
|
921
|
+
event: "mouseup",
|
|
922
|
+
then: (_e, _w) => {
|
|
923
|
+
props.onMouseUp ? props.onMouseUp() : null;
|
|
924
|
+
},
|
|
925
|
+
});
|
|
926
|
+
|
|
927
|
+
widget.subscribe({
|
|
928
|
+
event: "mousemove",
|
|
929
|
+
then: (_e, _w) => {
|
|
930
|
+
props.onMouseMove ? props.onMouseMove() : null;
|
|
931
|
+
},
|
|
932
|
+
});
|
|
933
|
+
|
|
934
|
+
widget.subscribe({
|
|
935
|
+
event: "mouseout",
|
|
936
|
+
then: (_e, _w) => {
|
|
937
|
+
props.onMouseOut ? props.onMouseOut() : null;
|
|
938
|
+
},
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
widget.subscribe({
|
|
942
|
+
event: "mouseleave",
|
|
943
|
+
then: (_e, _w) => {
|
|
944
|
+
props.onMouseLeave ? props.onMouseLeave() : null;
|
|
945
|
+
},
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
widget.subscribe({
|
|
949
|
+
event: "wheel",
|
|
950
|
+
then: (_e, _w) => {
|
|
951
|
+
props.onWheel ? props.onWheel() : null;
|
|
952
|
+
},
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
},
|
|
956
|
+
});
|
|
865
957
|
}
|
package/src/ui/checkbox.ui.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
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/container.ui.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { OrientationTypes } from "src/types/orientation.type";
|
|
2
|
-
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
3
|
-
import { UID } from "../core/uid";
|
|
4
|
-
|
|
5
|
-
export type ContainerParams = {
|
|
6
|
-
orientation?: OrientationTypes;
|
|
7
|
-
parent?: Widget | null;
|
|
8
|
-
size?: number | null;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export class Container extends Widget {
|
|
12
|
-
constructor(params: ContainerParams) {
|
|
13
|
-
const { orientation = "horizontal", parent = null, size = null } = params;
|
|
14
|
-
|
|
15
|
-
super(UID(), "div", parent);
|
|
16
|
-
|
|
17
|
-
if (orientation === "horizontal") {
|
|
18
|
-
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
19
|
-
} else {
|
|
20
|
-
this.setAlign(WidgetAlignTypes.VERTICAL);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (size !== null) {
|
|
24
|
-
this.setFixedSize(size);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
this.setType(WidgetTypes.FILL);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function Spacer(): Container {
|
|
32
|
-
return new Container({});
|
|
33
|
-
}
|
package/src/ui/image.ui.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import "./styles/image.css";
|
|
2
|
-
import { Widget, WidgetTypes } from "./widget.ui";
|
|
3
|
-
|
|
4
|
-
export class Image extends Widget {
|
|
5
|
-
imageContainer: Widget;
|
|
6
|
-
image: Widget;
|
|
7
|
-
constructor(id: string, src: string = "", parent: Widget | null = null) {
|
|
8
|
-
super(id, "div", parent);
|
|
9
|
-
|
|
10
|
-
this.imageContainer = new Widget(id + ".imageContainer", "div", this);
|
|
11
|
-
this.imageContainer.addClass("WUIImageContainer");
|
|
12
|
-
|
|
13
|
-
this.image = new Widget(id + ".image", "img", this.imageContainer);
|
|
14
|
-
this.image.setType(WidgetTypes.CUSTOM);
|
|
15
|
-
this.image.getBody().setAttribute("src", src);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
public render(): void {
|
|
19
|
-
super.render();
|
|
20
|
-
|
|
21
|
-
this.imageContainer.setX(0);
|
|
22
|
-
this.imageContainer.setY(0);
|
|
23
|
-
this.imageContainer.setWH(this.getW(), this.getH());
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
public fillWidth(): void {
|
|
27
|
-
this.image.addClass("WUIImageFillWidth");
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
public fillHeight(): void {
|
|
31
|
-
this.image.addClass("WUIImageFillHeight");
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public setAlternateText(text: string): void {
|
|
35
|
-
this.image.getBody().setAttribute("alt", text);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public setImageUrl(url: string): void {
|
|
39
|
-
this.image.getBody().setAttribute("src", url);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public getImageUrl(): string | null {
|
|
43
|
-
return this.image.getBody().getAttribute("src");
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public getAlternateText(): string | null {
|
|
47
|
-
return this.image.getBody().getAttribute("alt");
|
|
48
|
-
}
|
|
49
|
-
}
|
package/src/ui/label.ui.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { Colors } from "./colors.ui";
|
|
2
|
-
import { Widget } from "./widget.ui";
|
|
3
|
-
|
|
4
|
-
export type LabelVariants = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
|
|
5
|
-
|
|
6
|
-
export class Label extends Widget {
|
|
7
|
-
variant: LabelVariants;
|
|
8
|
-
color: Colors;
|
|
9
|
-
text: string;
|
|
10
|
-
|
|
11
|
-
constructor(id: string, variant: LabelVariants = "span", parent: Widget | null = null) {
|
|
12
|
-
super(id, variant, parent);
|
|
13
|
-
|
|
14
|
-
this.variant = variant;
|
|
15
|
-
this.color = "primary";
|
|
16
|
-
this.text = "";
|
|
17
|
-
|
|
18
|
-
this.init();
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
public init(): void {
|
|
22
|
-
super.init();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public centerV(): void {
|
|
26
|
-
this.getBody().style.lineHeight = this.getH() + "px";
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public centerH(): void {
|
|
30
|
-
this.getBody().style.textAlign = "center";
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
public setText(text: string): void {
|
|
34
|
-
this.text = text;
|
|
35
|
-
this.body.innerHTML = text;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public setVariant(variant: LabelVariants = "span"): void {
|
|
39
|
-
this.variant = variant;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
public setColor(color: Colors = "primary"): void {
|
|
43
|
-
this.color = color;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
public getVariant(): LabelVariants {
|
|
47
|
-
return this.variant;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
public getColor(): Colors {
|
|
51
|
-
return this.color;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public getText(): string {
|
|
55
|
-
return this.text;
|
|
56
|
-
}
|
|
57
|
-
}
|
package/src/ui/progressbar.ui.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { Label } from "./label.ui";
|
|
2
|
-
import "./styles/progressbar.css";
|
|
3
|
-
import { Widget } from "./widget.ui";
|
|
4
|
-
|
|
5
|
-
const PROGRESS_BAR_HEIGHT = 40;
|
|
6
|
-
|
|
7
|
-
//icono para el progress bar interactivo humidity_high
|
|
8
|
-
|
|
9
|
-
export class ProgressBar extends Widget {
|
|
10
|
-
private value: number;
|
|
11
|
-
private paddingBar: number;
|
|
12
|
-
|
|
13
|
-
private bar: Widget;
|
|
14
|
-
private lblValue: Label;
|
|
15
|
-
|
|
16
|
-
public constructor(id: string, parent: Widget | null = null) {
|
|
17
|
-
super(id, "div", parent);
|
|
18
|
-
|
|
19
|
-
this.setH(PROGRESS_BAR_HEIGHT);
|
|
20
|
-
|
|
21
|
-
this.paddingBar = 0;
|
|
22
|
-
|
|
23
|
-
this.bar = new Widget(id + ".bar", "div", this);
|
|
24
|
-
this.bar.addClass("WUIProgressBarBar");
|
|
25
|
-
|
|
26
|
-
this.value = 0;
|
|
27
|
-
this.addClass("WUIProgressBarContainer");
|
|
28
|
-
|
|
29
|
-
this.lblValue = new Label(id + ".value", "span", this);
|
|
30
|
-
this.lblValue.setText(this.value + "%");
|
|
31
|
-
|
|
32
|
-
this.lblValue.addClass("WUIProgressBarLabel");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
public setPaddingBar(p: number): void {
|
|
36
|
-
this.paddingBar = p;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public hideLabel(): void {
|
|
40
|
-
this.lblValue.setVisible(false);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
public displayLabel(): void {
|
|
44
|
-
this.lblValue.setVisible(true);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
public render(): void {
|
|
48
|
-
super.render();
|
|
49
|
-
|
|
50
|
-
const padding = this.paddingBar;
|
|
51
|
-
const width = this.getW() - padding;
|
|
52
|
-
const height = this.getH();
|
|
53
|
-
const widthBar = width * (this.value / 100);
|
|
54
|
-
|
|
55
|
-
this.lblValue.setX(width / 2 - this.lblValue.getW() / 2);
|
|
56
|
-
this.lblValue.setY(height / 2 - this.lblValue.getH() / 2);
|
|
57
|
-
this.lblValue.raisteTop();
|
|
58
|
-
|
|
59
|
-
this.bar.setX(padding);
|
|
60
|
-
this.bar.setY(padding);
|
|
61
|
-
this.bar.setW(widthBar);
|
|
62
|
-
this.bar.setH(height - padding * 2);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
public setValue(value: number): void {
|
|
66
|
-
this.value = value;
|
|
67
|
-
this.lblValue.setText(this.value + "%");
|
|
68
|
-
this.render();
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
public getValue(): number {
|
|
72
|
-
return this.value;
|
|
73
|
-
}
|
|
74
|
-
}
|
package/src/ui/radiobutton.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ToggleButton } from "./toggle.ui";
|
|
2
|
-
import { Widget } from "./widget.ui";
|
|
3
|
-
|
|
4
|
-
export class RadioButton extends ToggleButton {
|
|
5
|
-
constructor(id: string, text: string = "", parent: Widget | null = null) {
|
|
6
|
-
super(id, text, "radio_button_unchecked", "radio_button_checked", parent);
|
|
7
|
-
}
|
|
8
|
-
}
|
package/src/ui/switch.ui.ts
DELETED