cedro 0.1.3 → 0.1.5
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 +10 -3
- package/src/types/orientation.type.ts +1 -0
- package/src/ui/Icon.ui.ts +3 -9
- package/src/ui/IconButton.ui.ts +39 -3
- package/src/ui/accordion.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 +231 -0
- package/src/ui/draggable.ui.ts +165 -0
- package/src/ui/hpanel.ui.ts +127 -0
- package/src/ui/iconButtonMenu.ui.ts +59 -0
- package/src/ui/index.ts +46 -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 +184 -0
- 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 +36 -0
- package/src/ui/styles/draggable.css +9 -0
- package/src/ui/styles/hpanel.css +12 -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 +4 -0
- package/src/ui/styles/stackbutton.css +205 -0
- package/src/ui/styles/tabs.css +78 -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 +182 -0
- 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 +38 -10
- package/src/ui/valuebar.ui.ts +116 -0
- package/src/ui/vpanel.ui.ts +128 -0
- package/src/ui/widget.ui.ts +63 -4
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import "./styles/datagrid.css";
|
|
2
|
+
import { Label } from "./label.ui";
|
|
3
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
4
|
+
import { Scroll } from "./scroll.ui";
|
|
5
|
+
|
|
6
|
+
const DATA_GRID_HEADER_HEIGHT = 30;
|
|
7
|
+
const DATA_GRID_FOOTER_HEIGHT = 40;
|
|
8
|
+
const DATA_GRID_ROW_HEIGHT = 20;
|
|
9
|
+
const DATA_GRID_MIN_COLUMN_WIDTH = 24;
|
|
10
|
+
|
|
11
|
+
type DataGridColumn = {
|
|
12
|
+
header: string;
|
|
13
|
+
width: number | null;
|
|
14
|
+
handler: (args: any) => void;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export class DataGrid extends Widget {
|
|
18
|
+
headerContainer: Widget;
|
|
19
|
+
dataContainer: Widget;
|
|
20
|
+
footerContainer: Widget;
|
|
21
|
+
data: Array<any>;
|
|
22
|
+
verticalScrollbar: Scroll;
|
|
23
|
+
horizontalScrollbar: Scroll;
|
|
24
|
+
|
|
25
|
+
rowHeight: number;
|
|
26
|
+
|
|
27
|
+
columns: Array<DataGridColumn>;
|
|
28
|
+
|
|
29
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
30
|
+
super(id, "div", parent);
|
|
31
|
+
|
|
32
|
+
this.rowHeight = DATA_GRID_ROW_HEIGHT;
|
|
33
|
+
|
|
34
|
+
this.headerContainer = new Widget(id + ".header", "div");
|
|
35
|
+
this.headerContainer.setType(WidgetTypes.FILL);
|
|
36
|
+
this.headerContainer.setFixedSize(DATA_GRID_HEADER_HEIGHT);
|
|
37
|
+
this.headerContainer.addClass("WUIDataGrid-Header");
|
|
38
|
+
|
|
39
|
+
this.dataContainer = new Widget(id + ".data", "div");
|
|
40
|
+
this.dataContainer.setType(WidgetTypes.FILL);
|
|
41
|
+
|
|
42
|
+
this.footerContainer = new Widget(id + ".footer", "div");
|
|
43
|
+
this.footerContainer.setType(WidgetTypes.FILL);
|
|
44
|
+
this.footerContainer.setFixedSize(DATA_GRID_FOOTER_HEIGHT);
|
|
45
|
+
|
|
46
|
+
this.setType(WidgetTypes.FILL);
|
|
47
|
+
this.setAlign(WidgetAlignTypes.VERTICAL);
|
|
48
|
+
|
|
49
|
+
this.addChild(this.headerContainer);
|
|
50
|
+
this.addChild(this.dataContainer);
|
|
51
|
+
this.addChild(this.footerContainer);
|
|
52
|
+
|
|
53
|
+
this.verticalScrollbar = new Scroll(id + ".VerticalScrollbar", this.dataContainer);
|
|
54
|
+
this.horizontalScrollbar = new Scroll(
|
|
55
|
+
id + ".HorizontalScrollbar",
|
|
56
|
+
this.dataContainer,
|
|
57
|
+
"horizontal"
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
this.columns = new Array<DataGridColumn>();
|
|
61
|
+
|
|
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);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private getFreeWidth(): number {
|
|
76
|
+
let freeW = 0;
|
|
77
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
78
|
+
let width = this.columns[i].width;
|
|
79
|
+
if (width) {
|
|
80
|
+
freeW += width;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
freeW = this.dataContainer.getW() - freeW;
|
|
85
|
+
|
|
86
|
+
if (freeW < DATA_GRID_MIN_COLUMN_WIDTH) {
|
|
87
|
+
freeW = DATA_GRID_MIN_COLUMN_WIDTH;
|
|
88
|
+
}
|
|
89
|
+
return freeW;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private getAllColumnsWidth(): number {
|
|
93
|
+
let returnValue = 0;
|
|
94
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
95
|
+
let width = this.columns[i].width;
|
|
96
|
+
if (width) {
|
|
97
|
+
returnValue += width;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return returnValue;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public init(): void {
|
|
104
|
+
super.init();
|
|
105
|
+
|
|
106
|
+
this.createHeaders();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private createHeaders(): void {
|
|
110
|
+
if (!this.columns) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
115
|
+
const btn = new Label(this.id + "header." + i, "span");
|
|
116
|
+
btn.addClass("WUIDataGrid-HeaderLabel");
|
|
117
|
+
this.headerContainer.addChild(btn);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.buildRows();
|
|
121
|
+
this.renderHeaders();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private renderHeaders(): void {
|
|
125
|
+
if (!this.columns) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let startX = 0;
|
|
130
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
131
|
+
const column = this.columns[i];
|
|
132
|
+
const btn = window.w.get(this.id + "header." + i) as Label;
|
|
133
|
+
const width = column.width ? column.width : this.getFreeWidth();
|
|
134
|
+
btn.setType(WidgetTypes.CUSTOM);
|
|
135
|
+
btn.setX(startX);
|
|
136
|
+
btn.setY(0);
|
|
137
|
+
btn.setW(width);
|
|
138
|
+
btn.setH(DATA_GRID_HEADER_HEIGHT);
|
|
139
|
+
btn.getBody().style.lineHeight = DATA_GRID_HEADER_HEIGHT + "px";
|
|
140
|
+
btn.setText(column.header);
|
|
141
|
+
this.headerContainer.addChild(btn);
|
|
142
|
+
startX += width;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private buildRows(): void {
|
|
147
|
+
let rowY = 0;
|
|
148
|
+
|
|
149
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
150
|
+
const row = new Widget(this.id + ".row." + i, "div");
|
|
151
|
+
|
|
152
|
+
row.setType(WidgetTypes.CUSTOM);
|
|
153
|
+
row.getBody().style.position = "absolute";
|
|
154
|
+
row.getBody().style.overflow = "hidden";
|
|
155
|
+
row.addClass("WUIDataGrid-Row");
|
|
156
|
+
|
|
157
|
+
this.dataContainer.addChild(row);
|
|
158
|
+
|
|
159
|
+
for (let j = 0; j < this.columns.length; j++) {
|
|
160
|
+
const column = this.columns[j];
|
|
161
|
+
const fieldId = this.id + ".row." + i + ".column." + j;
|
|
162
|
+
column.handler({
|
|
163
|
+
data: this.data[i],
|
|
164
|
+
index: i,
|
|
165
|
+
fieldId: fieldId,
|
|
166
|
+
row: row,
|
|
167
|
+
});
|
|
168
|
+
const columnWidget = window.w.get(fieldId) as Widget;
|
|
169
|
+
columnWidget.getBody().style.position = "absolute";
|
|
170
|
+
}
|
|
171
|
+
rowY += this.rowHeight;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private renderRows(): void {
|
|
176
|
+
let rowY = 0;
|
|
177
|
+
|
|
178
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
179
|
+
const row = window.w.get(this.id + ".row." + i) as Widget;
|
|
180
|
+
|
|
181
|
+
row.setX(0);
|
|
182
|
+
row.setY(rowY);
|
|
183
|
+
row.setW(this.getAllColumnsWidth());
|
|
184
|
+
row.setH(this.rowHeight);
|
|
185
|
+
|
|
186
|
+
let widgetX = 0;
|
|
187
|
+
for (let j = 0; j < this.columns.length; j++) {
|
|
188
|
+
const column = this.columns[j];
|
|
189
|
+
const fieldId = this.id + ".row." + i + ".column." + j;
|
|
190
|
+
const columnWidget = window.w.get(fieldId) as Widget;
|
|
191
|
+
columnWidget.setY(0);
|
|
192
|
+
columnWidget.setX(widgetX);
|
|
193
|
+
columnWidget.setH(this.rowHeight);
|
|
194
|
+
if (column.width) {
|
|
195
|
+
columnWidget.setW(column.width);
|
|
196
|
+
} else {
|
|
197
|
+
columnWidget.setW(this.getFreeWidth());
|
|
198
|
+
}
|
|
199
|
+
widgetX += column.width ? column.width : columnWidget.getW();
|
|
200
|
+
}
|
|
201
|
+
rowY += this.rowHeight;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public render(): void {
|
|
206
|
+
super.render();
|
|
207
|
+
this.renderHeaders();
|
|
208
|
+
this.renderRows();
|
|
209
|
+
this.verticalScrollbar.render();
|
|
210
|
+
this.horizontalScrollbar.render();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
public setRowHeight(rowHeight: number): void {
|
|
214
|
+
this.rowHeight = rowHeight;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
public addColumn(header: string, width: number | null, handler: (args: any) => void) {
|
|
218
|
+
this.columns.push({ header, width, handler });
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
public getHeader(index: number): Label {
|
|
222
|
+
return window.w.get(this.id + "header." + index) as Label;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
public setData(data: Array<any>): void {
|
|
226
|
+
this.data = data;
|
|
227
|
+
|
|
228
|
+
this.buildRows();
|
|
229
|
+
this.renderRows();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { OrientationTypes } from "src/types/orientation.type";
|
|
2
|
+
import "./styles/draggable.css";
|
|
3
|
+
import { Widget, WidgetTypes } from "./widget.ui";
|
|
4
|
+
|
|
5
|
+
export type DragOrientation = OrientationTypes | "both";
|
|
6
|
+
|
|
7
|
+
export class Draggable {
|
|
8
|
+
target: Widget;
|
|
9
|
+
background: Widget;
|
|
10
|
+
|
|
11
|
+
dragging: boolean = false;
|
|
12
|
+
dragDistX: number;
|
|
13
|
+
dragDistY: number;
|
|
14
|
+
dragOrientation: DragOrientation;
|
|
15
|
+
|
|
16
|
+
minX: number | null;
|
|
17
|
+
minY: number | null;
|
|
18
|
+
maxX: number | null;
|
|
19
|
+
maxY: number | null;
|
|
20
|
+
|
|
21
|
+
draggingClass: string | null;
|
|
22
|
+
|
|
23
|
+
constructor(widget: Widget, orientation: DragOrientation = "both") {
|
|
24
|
+
this.target = widget;
|
|
25
|
+
|
|
26
|
+
this.background = new Widget(this.target.id + ".Draggable.Background", "div", null);
|
|
27
|
+
this.background.setType(WidgetTypes.CUSTOM);
|
|
28
|
+
this.background.addClass("WUIDraggableBackground");
|
|
29
|
+
|
|
30
|
+
this.draggingClass = null;
|
|
31
|
+
|
|
32
|
+
this.dragDistX = 0;
|
|
33
|
+
this.dragDistY = 0;
|
|
34
|
+
|
|
35
|
+
this.maxX = null;
|
|
36
|
+
this.maxY = null;
|
|
37
|
+
|
|
38
|
+
this.minX = null;
|
|
39
|
+
this.minY = null;
|
|
40
|
+
|
|
41
|
+
this.dragOrientation = orientation;
|
|
42
|
+
|
|
43
|
+
this.target.subscribe({
|
|
44
|
+
event: "mousedown",
|
|
45
|
+
then: (e, _w) => {
|
|
46
|
+
this.startDrag(e as MouseEvent);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
this.background.subscribe({
|
|
51
|
+
event: "mousemove",
|
|
52
|
+
then: (e, _w) => {
|
|
53
|
+
this.draggingTarget(e as MouseEvent);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
this.background.subscribe({
|
|
58
|
+
event: "mouseup",
|
|
59
|
+
then: (_e, _w) => {
|
|
60
|
+
this.endDrag();
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.background.subscribe({
|
|
65
|
+
event: "mouseout",
|
|
66
|
+
then: (_e, _w) => {
|
|
67
|
+
this.endDrag();
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
this.background.subscribe({
|
|
72
|
+
event: "mouseleave",
|
|
73
|
+
then: (_e, _w) => {
|
|
74
|
+
this.endDrag();
|
|
75
|
+
},
|
|
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;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private startDrag(e: MouseEvent): void {
|
|
90
|
+
e.preventDefault();
|
|
91
|
+
const mouseX = e.clientX;
|
|
92
|
+
const mouseY = e.clientY;
|
|
93
|
+
this.dragDistX = Math.abs(this.target.getX() - mouseX);
|
|
94
|
+
this.dragDistY = Math.abs(this.target.getY() - mouseY);
|
|
95
|
+
this.dragging = true;
|
|
96
|
+
this.background.setVisible(true);
|
|
97
|
+
this.background.raisteTop();
|
|
98
|
+
|
|
99
|
+
if (this.draggingClass) {
|
|
100
|
+
this.target.addClass(this.draggingClass);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private draggingTarget(e: MouseEvent): void {
|
|
105
|
+
if (!this.dragging) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
|
|
111
|
+
const mouseX = e.clientX;
|
|
112
|
+
const mouseY = e.clientY;
|
|
113
|
+
|
|
114
|
+
if (this.dragOrientation === "both" || this.dragOrientation === "horizontal") {
|
|
115
|
+
let newX = mouseX - this.dragDistX;
|
|
116
|
+
if (this.maxX != null && newX > this.maxX) {
|
|
117
|
+
newX = this.maxX;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (this.minX != null && newX < this.minX) {
|
|
121
|
+
newX = this.minX;
|
|
122
|
+
}
|
|
123
|
+
this.target.setX(newX);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (this.dragOrientation === "both" || this.dragOrientation === "vertical") {
|
|
127
|
+
let newY = mouseY - this.dragDistY;
|
|
128
|
+
if (this.maxY != null && newY > this.maxY) {
|
|
129
|
+
newY = this.maxY;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (this.minY != null && newY < this.minY) {
|
|
133
|
+
newY = this.minY;
|
|
134
|
+
}
|
|
135
|
+
this.target.setY(newY);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
this.target.run("drag");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private endDrag(): void {
|
|
142
|
+
this.dragging = false;
|
|
143
|
+
this.background.setVisible(false);
|
|
144
|
+
|
|
145
|
+
if (this.draggingClass) {
|
|
146
|
+
this.target.deleteClass(this.draggingClass);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
public setMaxX(x: number | null): void {
|
|
151
|
+
this.maxX = x;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
public setMaxY(y: number | null): void {
|
|
155
|
+
this.maxY = y;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public setMinX(x: number | null): void {
|
|
159
|
+
this.minX = x;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
public setMinY(y: number | null): void {
|
|
163
|
+
this.minY = y;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { Draggable } from "./draggable.ui";
|
|
2
|
+
import "./styles/hpanel.css";
|
|
3
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
4
|
+
|
|
5
|
+
const HPANEL_HANDLER_SIZE = 4;
|
|
6
|
+
|
|
7
|
+
export class HPanel extends Widget {
|
|
8
|
+
leftContent: Widget | null;
|
|
9
|
+
rightContent: Widget | null;
|
|
10
|
+
|
|
11
|
+
leftWidth: number | null;
|
|
12
|
+
rightWidth: number | null;
|
|
13
|
+
|
|
14
|
+
handler: Widget;
|
|
15
|
+
draggable: Draggable;
|
|
16
|
+
|
|
17
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
18
|
+
super(id, "div", parent);
|
|
19
|
+
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
20
|
+
this.setType(WidgetTypes.FILL);
|
|
21
|
+
|
|
22
|
+
this.handler = new Widget(id + ".handler", "div", null);
|
|
23
|
+
this.handler.addClass("WUIHPanelHandler");
|
|
24
|
+
|
|
25
|
+
this.draggable = new Draggable(this.handler, "horizontal");
|
|
26
|
+
this.draggable.setDraggingClass("WUIHPanelDragging");
|
|
27
|
+
this.draggable.setBackgroundCursor("col-resize");
|
|
28
|
+
|
|
29
|
+
this.handler.subscribe({
|
|
30
|
+
event: "drag",
|
|
31
|
+
then: (_e, _w) => {
|
|
32
|
+
this.updateSizeFromHandlerPosition();
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
this.subscribe({
|
|
37
|
+
event: "mousemove",
|
|
38
|
+
then: (e, _w) => {
|
|
39
|
+
this.updateHandlerOpacity(e as MouseEvent);
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
this.leftContent = null;
|
|
44
|
+
this.rightContent = null;
|
|
45
|
+
|
|
46
|
+
this.leftWidth = null;
|
|
47
|
+
this.rightWidth = null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private updateHandlerOpacity(e: MouseEvent): void {
|
|
51
|
+
const handlerX = this.handler.getX();
|
|
52
|
+
const mouseX = e.clientX;
|
|
53
|
+
const umbral = 100; //Distancia donde comienza a aparecer.
|
|
54
|
+
const minDistance = 20; //Distancia a la que toma 100 de opacidad
|
|
55
|
+
const distance = Math.abs(mouseX - handlerX);
|
|
56
|
+
|
|
57
|
+
if (distance < umbral && distance > minDistance) {
|
|
58
|
+
const ratio = 1 - distance / umbral;
|
|
59
|
+
this.handler.getBody().style.opacity = ratio.toString();
|
|
60
|
+
} else if (distance < minDistance) {
|
|
61
|
+
this.handler.getBody().style.opacity = "1";
|
|
62
|
+
} else {
|
|
63
|
+
this.handler.getBody().style.opacity = "0";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
public setLeft(content: Widget, fixWidth: number | null = null): void {
|
|
68
|
+
this.leftContent = content;
|
|
69
|
+
this.leftWidth = fixWidth;
|
|
70
|
+
if (fixWidth !== null) {
|
|
71
|
+
this.rightWidth = null;
|
|
72
|
+
this.leftContent.setFixedSize(fixWidth);
|
|
73
|
+
}
|
|
74
|
+
this.addChild(content);
|
|
75
|
+
|
|
76
|
+
const spacer = new Widget("spacer." + Date.now().toString(), "div", null);
|
|
77
|
+
spacer.setType(WidgetTypes.FILL);
|
|
78
|
+
spacer.setFixedSize(HPANEL_HANDLER_SIZE);
|
|
79
|
+
this.addChild(spacer);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public setRight(content: Widget, fixWidth: number | null = null): void {
|
|
83
|
+
this.rightContent = content;
|
|
84
|
+
this.rightWidth = fixWidth;
|
|
85
|
+
if (fixWidth !== null) {
|
|
86
|
+
this.leftWidth = null;
|
|
87
|
+
this.rightContent.setFixedSize(fixWidth);
|
|
88
|
+
}
|
|
89
|
+
this.addChild(content);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private updateSizeFromHandlerPosition(): void {
|
|
93
|
+
if (this.leftWidth !== null) {
|
|
94
|
+
const leftX = this.leftContent ? this.leftContent.getX(true) : 0;
|
|
95
|
+
this.leftWidth = this.handler.getX() - leftX;
|
|
96
|
+
} else if (this.rightWidth !== null) {
|
|
97
|
+
this.rightWidth = this.getW() - this.handler.getX();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this.render();
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public render(): void {
|
|
104
|
+
super.render();
|
|
105
|
+
this.handler.setW(HPANEL_HANDLER_SIZE);
|
|
106
|
+
this.handler.setH(this.getH());
|
|
107
|
+
|
|
108
|
+
if (this.leftWidth !== null) {
|
|
109
|
+
const leftX = this.leftContent ? this.leftContent.getX(true) : 0;
|
|
110
|
+
this.handler.setX(leftX + this.leftWidth);
|
|
111
|
+
this.leftContent?.setFixedSize(this.leftWidth);
|
|
112
|
+
} else if (this.rightWidth !== null) {
|
|
113
|
+
const rightX = this.rightContent ? this.rightContent.getX(true) : 0;
|
|
114
|
+
this.handler.setX(rightX + this.rightWidth);
|
|
115
|
+
this.rightContent?.setFixedSize(this.rightWidth);
|
|
116
|
+
} else {
|
|
117
|
+
if (this.leftWidth === null) {
|
|
118
|
+
this.leftWidth = this.getW() / 2 - HPANEL_HANDLER_SIZE / 2;
|
|
119
|
+
}
|
|
120
|
+
const leftX = this.leftContent ? this.leftContent.getX(true) : 0;
|
|
121
|
+
this.handler.setX(leftX + this.leftWidth);
|
|
122
|
+
this.leftContent?.setFixedSize(this.leftWidth);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
this.handler.setY(this.getY(true));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { IconButton } from "./IconButton.ui";
|
|
2
|
+
import { Menu } from "./menu.ui";
|
|
3
|
+
import { SelectItem } from "./select.ui";
|
|
4
|
+
|
|
5
|
+
export class IconButtonMenu extends IconButton {
|
|
6
|
+
menu: Menu;
|
|
7
|
+
items: Array<SelectItem>;
|
|
8
|
+
selectedItem: SelectItem | null;
|
|
9
|
+
|
|
10
|
+
public constructor(id: string, icon: string) {
|
|
11
|
+
super(id, icon);
|
|
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
|
+
}
|
package/src/ui/index.ts
CHANGED
|
@@ -1,13 +1,57 @@
|
|
|
1
|
+
import { Accordion } from "./accordion";
|
|
1
2
|
import { Button } from "./button.ui";
|
|
2
|
-
import {
|
|
3
|
+
import { ButtonColor } from "./buttonColor.ui";
|
|
4
|
+
import { ButtonMenu } from "./buttonmenu.ui";
|
|
5
|
+
import { ButtonStack } from "./buttonstack.ui";
|
|
6
|
+
import { Checkbox } from "./checkbox.ui";
|
|
7
|
+
import { WidgetAlignTypes, WidgetTypes, Widget } from "./widget.ui";
|
|
3
8
|
import { Dialog } from "./dialog";
|
|
9
|
+
import { HPanel } from "./hpanel.ui";
|
|
4
10
|
import { Icon } from "./Icon.ui";
|
|
5
11
|
import { IconButton } from "./IconButton.ui";
|
|
6
12
|
import { Label } from "./label.ui";
|
|
7
13
|
import { Menu } from "./menu.ui";
|
|
14
|
+
import { ProgressBar } from "./progressbar.ui";
|
|
8
15
|
import { Select } from "./select.ui";
|
|
16
|
+
import { Switch } from "./switch.ui";
|
|
9
17
|
import { Textbox } from "./textbox.ui";
|
|
18
|
+
import { Tabs } from "./tabs.ui";
|
|
19
|
+
import { TextArea } from "./textarea.ui";
|
|
10
20
|
import { Toolbar } from "./toolbar.ui";
|
|
21
|
+
import { DataGrid } from "./datagrid.ui";
|
|
22
|
+
import { RadioButton } from "./radiobutton";
|
|
23
|
+
import { ValueBar } from "./valuebar.ui";
|
|
24
|
+
import { VPanel } from "./vpanel.ui";
|
|
11
25
|
import { createWidget } from "./widget.builder.ui";
|
|
26
|
+
import { IconButtonMenu } from "./iconButtonMenu.ui";
|
|
12
27
|
|
|
13
|
-
export {
|
|
28
|
+
export {
|
|
29
|
+
Accordion,
|
|
30
|
+
Button,
|
|
31
|
+
ButtonColor,
|
|
32
|
+
ButtonMenu,
|
|
33
|
+
ButtonStack,
|
|
34
|
+
Checkbox,
|
|
35
|
+
Dialog,
|
|
36
|
+
HPanel,
|
|
37
|
+
Icon,
|
|
38
|
+
IconButton,
|
|
39
|
+
IconButtonMenu,
|
|
40
|
+
Label,
|
|
41
|
+
Menu,
|
|
42
|
+
ProgressBar,
|
|
43
|
+
RadioButton,
|
|
44
|
+
Select,
|
|
45
|
+
Switch,
|
|
46
|
+
Tabs,
|
|
47
|
+
TextArea,
|
|
48
|
+
Textbox,
|
|
49
|
+
Toolbar,
|
|
50
|
+
ValueBar,
|
|
51
|
+
VPanel,
|
|
52
|
+
DataGrid,
|
|
53
|
+
Widget,
|
|
54
|
+
WidgetAlignTypes,
|
|
55
|
+
WidgetTypes,
|
|
56
|
+
createWidget,
|
|
57
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "./styles/loading.css";
|
|
2
|
+
import { Widget } from "./widget.ui";
|
|
3
|
+
|
|
4
|
+
export class Loading extends Widget {
|
|
5
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
6
|
+
super(id, "div", parent);
|
|
7
|
+
this.addClass("WUILoading");
|
|
8
|
+
this.setVisible(false);
|
|
9
|
+
}
|
|
10
|
+
}
|