cedro 0.1.2 → 0.1.4
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 +5 -20
- package/src/interfaces/widget.interface.ts +6 -1
- package/src/types/orientation.type.ts +1 -0
- package/src/ui/IconButton.ui.ts +37 -29
- package/src/ui/datagrid.ui.ts +216 -0
- package/src/ui/draggable.ui.ts +143 -0
- package/src/ui/index.ts +18 -13
- package/src/ui/menu.ui.ts +4 -5
- package/src/ui/scroll.ui.ts +185 -0
- package/src/ui/select.ui.ts +2 -6
- package/src/ui/styles/datagrid.css +10 -0
- package/src/ui/styles/dialog.css +1 -1
- package/src/ui/styles/draggable.css +9 -0
- package/src/ui/styles/menu.css +1 -1
- package/src/ui/styles/scroll.css +4 -0
- package/src/ui/styles/tabs.css +33 -0
- package/src/ui/tabs.ui.ts +131 -0
- package/src/ui/toolbar.ui.ts +203 -0
- package/src/ui/widget.ui.ts +42 -34
- package/tsconfig.json +4 -1
- package/index.html +0 -13
package/package.json
CHANGED
|
@@ -50,6 +50,7 @@ class WApplication implements IApplication {
|
|
|
50
50
|
|
|
51
51
|
window.addEventListener("load", () => {
|
|
52
52
|
this.screen.updateSize();
|
|
53
|
+
this.getRoot().resize();
|
|
53
54
|
});
|
|
54
55
|
|
|
55
56
|
this.alertDialog = new Dialog("Dialog.alert", null);
|
|
@@ -58,11 +59,7 @@ class WApplication implements IApplication {
|
|
|
58
59
|
this.theme.load();
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
alert(
|
|
62
|
-
msg: string,
|
|
63
|
-
onOk: () => void = () => {},
|
|
64
|
-
onCancell: () => void = () => {}
|
|
65
|
-
): void {
|
|
62
|
+
alert(msg: string, onOk: () => void = () => {}, onCancell: () => void = () => {}): void {
|
|
66
63
|
const mesageLabel = new Label("alert.label", "span");
|
|
67
64
|
|
|
68
65
|
mesageLabel.setType(WidgetTypes.FILL);
|
|
@@ -80,11 +77,7 @@ class WApplication implements IApplication {
|
|
|
80
77
|
this.alertDialog.show();
|
|
81
78
|
}
|
|
82
79
|
|
|
83
|
-
confirm(
|
|
84
|
-
msg: string,
|
|
85
|
-
onOk: () => void = () => {},
|
|
86
|
-
onCancell: () => void = () => {}
|
|
87
|
-
): void {
|
|
80
|
+
confirm(msg: string, onOk: () => void = () => {}, onCancell: () => void = () => {}): void {
|
|
88
81
|
const mesageLabel = new Label("alert.label", "span");
|
|
89
82
|
|
|
90
83
|
mesageLabel.setType(WidgetTypes.FILL);
|
|
@@ -123,12 +116,7 @@ class WApplication implements IApplication {
|
|
|
123
116
|
this.root.render();
|
|
124
117
|
}
|
|
125
118
|
|
|
126
|
-
addMediaQuery(
|
|
127
|
-
query: string,
|
|
128
|
-
minWidth: number,
|
|
129
|
-
maxWidth: number,
|
|
130
|
-
cb: (app: IApplication) => void
|
|
131
|
-
): void {
|
|
119
|
+
addMediaQuery(query: string, minWidth: number, maxWidth: number, cb: (app: IApplication) => void): void {
|
|
132
120
|
this.mediaQueries.set(query, { minWidth, maxWidth, cb });
|
|
133
121
|
}
|
|
134
122
|
|
|
@@ -145,10 +133,7 @@ class WApplication implements IApplication {
|
|
|
145
133
|
|
|
146
134
|
for (let query of app.mediaQueries.entries()) {
|
|
147
135
|
const { minWidth, maxWidth, cb } = query[1];
|
|
148
|
-
if (
|
|
149
|
-
minWidth <= app.screen.dimensions.x &&
|
|
150
|
-
maxWidth > app.screen.dimensions.x
|
|
151
|
-
) {
|
|
136
|
+
if (minWidth <= app.screen.dimensions.x && maxWidth > app.screen.dimensions.x) {
|
|
152
137
|
cb(this as IApplication);
|
|
153
138
|
//break; quite el break para dar soporte a mas de un media quiery del mismo tipo.
|
|
154
139
|
}
|
|
@@ -7,7 +7,11 @@ export type WUIEvent =
|
|
|
7
7
|
| "mousedown"
|
|
8
8
|
| "mouseup"
|
|
9
9
|
| "mousemove"
|
|
10
|
-
| "
|
|
10
|
+
| "mouseout"
|
|
11
|
+
| "mouseleave"
|
|
12
|
+
| "option-clicked"
|
|
13
|
+
| "wheel"
|
|
14
|
+
| "drag";
|
|
11
15
|
|
|
12
16
|
export type WUICallback = {
|
|
13
17
|
event: WUIEvent;
|
|
@@ -48,6 +52,7 @@ export interface IWidget {
|
|
|
48
52
|
|
|
49
53
|
subscribe: (cb: WUICallback) => void;
|
|
50
54
|
unsubscribe: (event: WUIEvent) => void;
|
|
55
|
+
run(eventId: WUIEvent): void;
|
|
51
56
|
|
|
52
57
|
setPadding(p: number): void;
|
|
53
58
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type OrientationTypes = "horizontal" | "vertical";
|
package/src/ui/IconButton.ui.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./styles/button.css";
|
|
2
|
-
import { Widget, WidgetTypes } from "./widget.ui";
|
|
2
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
3
3
|
import { Button } from "./button.ui";
|
|
4
4
|
import { Icon } from "./Icon.ui";
|
|
5
5
|
import { Label } from "./label.ui";
|
|
@@ -8,19 +8,13 @@ export class IconButton extends Button {
|
|
|
8
8
|
icon: Icon;
|
|
9
9
|
label: Label;
|
|
10
10
|
|
|
11
|
-
constructor(
|
|
12
|
-
id: string,
|
|
13
|
-
icon: string = "dark_mode",
|
|
14
|
-
parent: Widget | null = null
|
|
15
|
-
) {
|
|
11
|
+
constructor(id: string, icon: string = "dark_mode", parent: Widget | null = null) {
|
|
16
12
|
super(id, parent);
|
|
17
13
|
|
|
14
|
+
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
18
15
|
this.icon = new Icon(id + ".icon", icon, undefined, this);
|
|
19
16
|
this.label = new Label(id + ".label", undefined, this);
|
|
20
17
|
|
|
21
|
-
this.icon.setType(WidgetTypes.FREE);
|
|
22
|
-
this.label.setType(WidgetTypes.FREE);
|
|
23
|
-
|
|
24
18
|
this.init();
|
|
25
19
|
}
|
|
26
20
|
|
|
@@ -28,35 +22,49 @@ export class IconButton extends Button {
|
|
|
28
22
|
super.init();
|
|
29
23
|
}
|
|
30
24
|
|
|
25
|
+
public onlyIcon(): boolean {
|
|
26
|
+
if (this.label.getText().length > 0) return false;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
|
|
31
30
|
public render(): void {
|
|
32
31
|
super.render();
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const iconWidth = 24;
|
|
34
|
+
const padding = 5;
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (this.onlyIcon()) {
|
|
37
|
+
this.icon.getBody().style.position = "absolute";
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
const startX = this.getBody().clientWidth / 2 - iconWidth / 2;
|
|
40
|
+
const startY = this.getH() / 2 - iconWidth / 2;
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
this.icon.setX(startX);
|
|
43
|
+
this.icon.setY(startY);
|
|
44
|
+
} else {
|
|
45
|
+
this.label.getBody().style.position = "absolute";
|
|
46
|
+
this.icon.getBody().style.position = "absolute";
|
|
47
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const labelHeight = this.label.getBody().clientHeight;
|
|
49
|
+
|
|
50
|
+
const startX = padding; //this.getBody().clientWidth / 2 - (iconWidth + labelWidth) / 2;
|
|
51
|
+
const startLabelX = startX + iconWidth + padding;
|
|
52
|
+
const startY = this.getH() / 2 - iconWidth / 2;
|
|
53
|
+
const startLabelY = this.getH() / 2 - labelHeight / 2;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
if (startX < 0 || startY < 0) {
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
this.render();
|
|
58
|
+
}, 500);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
57
61
|
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
this.icon.setX(startX);
|
|
63
|
+
this.label.setX(startLabelX + padding);
|
|
64
|
+
|
|
65
|
+
this.icon.setY(startY);
|
|
66
|
+
this.label.setY(startLabelY);
|
|
67
|
+
}
|
|
60
68
|
}
|
|
61
69
|
|
|
62
70
|
public setText(text: string): void {
|
|
@@ -0,0 +1,216 @@
|
|
|
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(id + ".HorizontalScrollbar", this.dataContainer, "horizontal");
|
|
55
|
+
|
|
56
|
+
this.columns = new Array<DataGridColumn>();
|
|
57
|
+
|
|
58
|
+
this.data = new Array<any>();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private getFreeWidth(): number {
|
|
62
|
+
let freeW = 0;
|
|
63
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
64
|
+
let width = this.columns[i].width;
|
|
65
|
+
if (width) {
|
|
66
|
+
freeW += width;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
freeW = this.dataContainer.getW() - freeW;
|
|
71
|
+
|
|
72
|
+
if (freeW < DATA_GRID_MIN_COLUMN_WIDTH) {
|
|
73
|
+
freeW = DATA_GRID_MIN_COLUMN_WIDTH;
|
|
74
|
+
}
|
|
75
|
+
return freeW;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private getAllColumnsWidth(): number {
|
|
79
|
+
let returnValue = 0;
|
|
80
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
81
|
+
let width = this.columns[i].width;
|
|
82
|
+
if (width) {
|
|
83
|
+
returnValue += width;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return returnValue;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public init(): void {
|
|
90
|
+
super.init();
|
|
91
|
+
|
|
92
|
+
this.createHeaders();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
private createHeaders(): void {
|
|
96
|
+
if (!this.columns) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
101
|
+
const btn = new Label(this.id + "header." + i, "span");
|
|
102
|
+
btn.addClass("WUIDataGrid-HeaderLabel");
|
|
103
|
+
this.headerContainer.addChild(btn);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
this.buildRows();
|
|
107
|
+
this.renderHeaders();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private renderHeaders(): void {
|
|
111
|
+
if (!this.columns) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
let startX = 0;
|
|
116
|
+
for (let i = 0; i < this.columns.length; i++) {
|
|
117
|
+
const column = this.columns[i];
|
|
118
|
+
const btn = window.w.get(this.id + "header." + i) as Label;
|
|
119
|
+
const width = column.width ? column.width : this.getFreeWidth();
|
|
120
|
+
btn.setType(WidgetTypes.CUSTOM);
|
|
121
|
+
btn.setX(startX);
|
|
122
|
+
btn.setY(0);
|
|
123
|
+
btn.setW(width);
|
|
124
|
+
btn.setH(DATA_GRID_HEADER_HEIGHT);
|
|
125
|
+
btn.getBody().style.lineHeight = DATA_GRID_HEADER_HEIGHT + "px";
|
|
126
|
+
btn.setText(column.header);
|
|
127
|
+
this.headerContainer.addChild(btn);
|
|
128
|
+
startX += width;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private buildRows(): void {
|
|
133
|
+
let rowY = 0;
|
|
134
|
+
|
|
135
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
136
|
+
const row = new Widget(this.id + ".row." + i, "div");
|
|
137
|
+
|
|
138
|
+
row.setType(WidgetTypes.CUSTOM);
|
|
139
|
+
row.getBody().style.position = "absolute";
|
|
140
|
+
row.getBody().style.overflow = "hidden";
|
|
141
|
+
|
|
142
|
+
this.dataContainer.addChild(row);
|
|
143
|
+
|
|
144
|
+
for (let j = 0; j < this.columns.length; j++) {
|
|
145
|
+
const column = this.columns[j];
|
|
146
|
+
const fieldId = this.id + ".row." + i + ".column." + j;
|
|
147
|
+
column.handler({
|
|
148
|
+
data: this.data[i],
|
|
149
|
+
index: i,
|
|
150
|
+
fieldId: fieldId,
|
|
151
|
+
row: row,
|
|
152
|
+
});
|
|
153
|
+
const columnWidget = window.w.get(fieldId) as Widget;
|
|
154
|
+
columnWidget.getBody().style.position = "absolute";
|
|
155
|
+
}
|
|
156
|
+
rowY += this.rowHeight;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
private renderRows(): void {
|
|
161
|
+
let rowY = 0;
|
|
162
|
+
|
|
163
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
164
|
+
const row = window.w.get(this.id + ".row." + i) as Widget;
|
|
165
|
+
|
|
166
|
+
row.setX(0);
|
|
167
|
+
row.setY(rowY);
|
|
168
|
+
row.setW(this.getAllColumnsWidth());
|
|
169
|
+
row.setH(this.rowHeight);
|
|
170
|
+
|
|
171
|
+
let widgetX = 0;
|
|
172
|
+
for (let j = 0; j < this.columns.length; j++) {
|
|
173
|
+
const column = this.columns[j];
|
|
174
|
+
const fieldId = this.id + ".row." + i + ".column." + j;
|
|
175
|
+
const columnWidget = window.w.get(fieldId) as Widget;
|
|
176
|
+
columnWidget.setY(0);
|
|
177
|
+
columnWidget.setX(widgetX);
|
|
178
|
+
columnWidget.setH(this.rowHeight);
|
|
179
|
+
if (column.width) {
|
|
180
|
+
columnWidget.setW(column.width);
|
|
181
|
+
} else {
|
|
182
|
+
columnWidget.setW(this.getFreeWidth());
|
|
183
|
+
}
|
|
184
|
+
widgetX += column.width ? column.width : columnWidget.getW();
|
|
185
|
+
}
|
|
186
|
+
rowY += this.rowHeight;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public render(): void {
|
|
191
|
+
super.render();
|
|
192
|
+
this.renderHeaders();
|
|
193
|
+
this.renderRows();
|
|
194
|
+
this.verticalScrollbar.render();
|
|
195
|
+
this.horizontalScrollbar.render();
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public setRowHeight(rowHeight: number): void {
|
|
199
|
+
this.rowHeight = rowHeight;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
public addColumn(header: string, width: number | null, handler: (args: any) => void) {
|
|
203
|
+
this.columns.push({ header, width, handler });
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
public getHeader(index: number): Label {
|
|
207
|
+
return window.w.get(this.id + "header." + index) as Label;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
public setData(data: Array<any>): void {
|
|
211
|
+
this.data = data;
|
|
212
|
+
|
|
213
|
+
this.buildRows();
|
|
214
|
+
this.renderRows();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
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
|
+
constructor(widget: Widget, orientation: DragOrientation = "both") {
|
|
22
|
+
this.target = widget;
|
|
23
|
+
|
|
24
|
+
this.background = new Widget(this.target.id + ".Draggable.Background", "div", null);
|
|
25
|
+
this.background.setType(WidgetTypes.CUSTOM);
|
|
26
|
+
this.background.addClass("WUIDraggableBackground");
|
|
27
|
+
|
|
28
|
+
this.dragDistX = 0;
|
|
29
|
+
this.dragDistY = 0;
|
|
30
|
+
|
|
31
|
+
this.maxX = null;
|
|
32
|
+
this.maxY = null;
|
|
33
|
+
|
|
34
|
+
this.minX = null;
|
|
35
|
+
this.minY = null;
|
|
36
|
+
|
|
37
|
+
this.dragOrientation = orientation;
|
|
38
|
+
|
|
39
|
+
this.target.subscribe({
|
|
40
|
+
event: "mousedown",
|
|
41
|
+
then: (e, _w) => {
|
|
42
|
+
this.startDrag(e as MouseEvent);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
this.background.subscribe({
|
|
47
|
+
event: "mousemove",
|
|
48
|
+
then: (e, _w) => {
|
|
49
|
+
this.draggingTarget(e as MouseEvent);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
this.background.subscribe({
|
|
54
|
+
event: "mouseup",
|
|
55
|
+
then: (_e, _w) => {
|
|
56
|
+
this.endDrag();
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
this.background.subscribe({
|
|
61
|
+
event: "mouseout",
|
|
62
|
+
then: (_e, _w) => {
|
|
63
|
+
this.endDrag();
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
this.background.subscribe({
|
|
68
|
+
event: "mouseleave",
|
|
69
|
+
then: (_e, _w) => {
|
|
70
|
+
this.endDrag();
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
private startDrag(e: MouseEvent): void {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
const mouseX = e.clientX;
|
|
78
|
+
const mouseY = e.clientY;
|
|
79
|
+
this.dragDistX = Math.abs(this.target.getX() - mouseX);
|
|
80
|
+
this.dragDistY = Math.abs(this.target.getY() - mouseY);
|
|
81
|
+
this.dragging = true;
|
|
82
|
+
this.background.setVisible(true);
|
|
83
|
+
this.background.raisteTop();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private draggingTarget(e: MouseEvent): void {
|
|
87
|
+
if (!this.dragging) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
e.preventDefault();
|
|
92
|
+
|
|
93
|
+
const mouseX = e.clientX;
|
|
94
|
+
const mouseY = e.clientY;
|
|
95
|
+
|
|
96
|
+
if (this.dragOrientation === "both" || this.dragOrientation === "horizontal") {
|
|
97
|
+
let newX = mouseX - this.dragDistX;
|
|
98
|
+
if (this.maxX != null && newX > this.maxX) {
|
|
99
|
+
newX = this.maxX;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (this.minX != null && newX < this.minX) {
|
|
103
|
+
newX = this.minX;
|
|
104
|
+
}
|
|
105
|
+
this.target.setX(newX);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (this.dragOrientation === "both" || this.dragOrientation === "vertical") {
|
|
109
|
+
let newY = mouseY - this.dragDistY;
|
|
110
|
+
if (this.maxY != null && newY > this.maxY) {
|
|
111
|
+
newY = this.maxY;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (this.minY != null && newY < this.minY) {
|
|
115
|
+
newY = this.minY;
|
|
116
|
+
}
|
|
117
|
+
this.target.setY(newY);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
this.target.run("drag");
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private endDrag(): void {
|
|
124
|
+
this.dragging = false;
|
|
125
|
+
this.background.setVisible(false);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public setMaxX(x: number | null): void {
|
|
129
|
+
this.maxX = x;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
public setMaxY(y: number | null): void {
|
|
133
|
+
this.maxY = y;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
public setMinX(x: number | null): void {
|
|
137
|
+
this.minX = x;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
public setMinY(y: number | null): void {
|
|
141
|
+
this.minY = y;
|
|
142
|
+
}
|
|
143
|
+
}
|
package/src/ui/index.ts
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { Button } from "./button.ui"
|
|
2
|
-
import { Widget } from "./widget.ui"
|
|
3
|
-
import { Dialog } from "./dialog"
|
|
4
|
-
import { Icon } from "./Icon.ui"
|
|
5
|
-
import { IconButton } from "./IconButton.ui"
|
|
6
|
-
import { Label } from "./label.ui"
|
|
7
|
-
import { Menu } from "./menu.ui"
|
|
8
|
-
import { Select } from "./select.ui"
|
|
9
|
-
import { Textbox } from "./textbox.ui"
|
|
10
|
-
import {
|
|
1
|
+
import { Button } from "./button.ui";
|
|
2
|
+
import { Widget } from "./widget.ui";
|
|
3
|
+
import { Dialog } from "./dialog";
|
|
4
|
+
import { Icon } from "./Icon.ui";
|
|
5
|
+
import { IconButton } from "./IconButton.ui";
|
|
6
|
+
import { Label } from "./label.ui";
|
|
7
|
+
import { Menu } from "./menu.ui";
|
|
8
|
+
import { Select } from "./select.ui";
|
|
9
|
+
import { Textbox } from "./textbox.ui";
|
|
10
|
+
import { Tabs } from "./tabs.ui";
|
|
11
|
+
import { Toolbar } from "./toolbar.ui";
|
|
12
|
+
import { DataGrid } from "./datagrid.ui";
|
|
13
|
+
import { createWidget } from "./widget.builder.ui";
|
|
11
14
|
|
|
12
|
-
|
|
13
|
-
export{
|
|
15
|
+
export {
|
|
14
16
|
Button,
|
|
15
17
|
Widget,
|
|
16
18
|
Dialog,
|
|
@@ -19,6 +21,9 @@ export{
|
|
|
19
21
|
Label,
|
|
20
22
|
Menu,
|
|
21
23
|
Select,
|
|
24
|
+
Tabs,
|
|
22
25
|
Textbox,
|
|
26
|
+
Toolbar,
|
|
27
|
+
DataGrid,
|
|
23
28
|
createWidget,
|
|
24
|
-
}
|
|
29
|
+
};
|
package/src/ui/menu.ui.ts
CHANGED
|
@@ -10,11 +10,7 @@ export class Menu extends Widget {
|
|
|
10
10
|
triggeredBy: IWidget | null;
|
|
11
11
|
triggeredBySearchCode: any;
|
|
12
12
|
withCalculation: boolean;
|
|
13
|
-
constructor(
|
|
14
|
-
id: string,
|
|
15
|
-
trigeredById: string | null,
|
|
16
|
-
parent: IWidget | null = null
|
|
17
|
-
) {
|
|
13
|
+
constructor(id: string, trigeredById: string | null, parent: IWidget | null = null) {
|
|
18
14
|
super(id, "div", parent);
|
|
19
15
|
|
|
20
16
|
this.background = new Widget(this.id + ".background", "div", null);
|
|
@@ -39,6 +35,7 @@ export class Menu extends Widget {
|
|
|
39
35
|
clearInterval(this.triggeredBySearchCode);
|
|
40
36
|
return;
|
|
41
37
|
}
|
|
38
|
+
|
|
42
39
|
if (window.w.get(this.triggeredById)) {
|
|
43
40
|
this.triggeredBy = window.w.get(this.triggeredById) as IWidget;
|
|
44
41
|
|
|
@@ -61,6 +58,7 @@ export class Menu extends Widget {
|
|
|
61
58
|
}
|
|
62
59
|
|
|
63
60
|
public close(): void {
|
|
61
|
+
this.deleteClass("WUIMenuTransparent");
|
|
64
62
|
this.deleteClass("WUIMenuVisible");
|
|
65
63
|
this.addClass("WUIMenuHidden");
|
|
66
64
|
this.background.setVisible(false);
|
|
@@ -96,6 +94,7 @@ export class Menu extends Widget {
|
|
|
96
94
|
for (const [, dataOption] of this.options) {
|
|
97
95
|
const option = dataOption as IconButton;
|
|
98
96
|
option.addClass("WUIMenuOptions100w");
|
|
97
|
+
option.render();
|
|
99
98
|
}
|
|
100
99
|
this.deleteClass("WUIMenuTransparent");
|
|
101
100
|
this.addClass("WUIMenuHidden");
|