cedro 0.1.8 → 0.1.10
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/README.md +7 -4
- package/dist/cedro-logo.png +0 -0
- package/dist/fangio.jpg +0 -0
- package/package.json +4 -2
- package/src/core/application.builder.tsx +121 -0
- package/src/core/{application.core.ts → application.core.tsx} +175 -9
- package/src/core/themes.core.ts +160 -1
- package/src/core/uid.ts +3 -3
- package/src/index.ts +1 -1
- package/src/interfaces/application.interface.ts +10 -3
- package/src/interfaces/widget.interface.ts +6 -1
- package/src/types/select.item.type.ts +11 -0
- package/src/ui/Icon.ui.tsx +158 -0
- package/src/ui/IconButton.ui.tsx +233 -0
- package/src/ui/{textbox.ui.ts → Textbox.ui.tsx} +69 -8
- package/src/ui/accordion.ui.tsx +152 -0
- package/src/ui/button.ui.tsx +209 -0
- package/src/ui/buttonColor.ui.tsx +87 -0
- package/src/ui/buttonmenu.ui.tsx +134 -0
- package/src/ui/{buttonstack.ui.ts → buttonstack.ui.tsx} +67 -1
- package/src/ui/checkbox.ui.tsx +43 -0
- package/src/ui/container.ui.tsx +141 -0
- package/src/ui/datagrid.ui.tsx +518 -0
- package/src/ui/dialog.tsx +143 -56
- package/src/ui/{hpanel.ui.ts → hpanel.ui.tsx} +64 -1
- package/src/ui/iconButtonMenu.ui.tsx +176 -0
- package/src/ui/image.ui.tsx +123 -0
- package/src/ui/index.ts +9 -9
- package/src/ui/label.ui.tsx +184 -0
- package/src/ui/loading.ui.ts +10 -10
- package/src/ui/menu.ui.ts +2 -2
- package/src/ui/progressbar.ui.tsx +135 -0
- package/src/ui/radiobutton.ui.tsx +47 -0
- package/src/ui/scroll.ui.ts +13 -12
- package/src/ui/select.ui.tsx +143 -0
- package/src/ui/styles/button.css +114 -32
- package/src/ui/styles/buttoncolor.css +8 -8
- package/src/ui/styles/container.css +29 -0
- package/src/ui/styles/hpanel.css +1 -1
- package/src/ui/styles/icon.css +29 -0
- package/src/ui/styles/image.css +19 -19
- package/src/ui/styles/label.css +63 -0
- package/src/ui/styles/loading.css +12 -12
- package/src/ui/styles/main.css +5 -0
- package/src/ui/styles/progressbar.css +3 -2
- package/src/ui/styles/select.css +13 -0
- package/src/ui/styles/stackbutton.css +36 -0
- package/src/ui/styles/tabs.css +5 -7
- package/src/ui/styles/textarea.css +13 -13
- package/src/ui/styles/valuebar.css +1 -1
- package/src/ui/styles/vpanel.css +1 -1
- package/src/ui/switch.ui.tsx +42 -0
- package/src/ui/{tabs.ui.ts → tabs.ui.tsx} +114 -8
- package/src/ui/textarea.ui.tsx +48 -0
- package/src/ui/{toolbar.ui.ts → toolbar.ui.tsx} +44 -1
- package/src/ui/{valuebar.ui.ts → valuebar.ui.tsx} +35 -1
- package/src/ui/{vpanel.ui.ts → vpanel.ui.tsx} +44 -1
- package/src/ui/widget.builder.ts +243 -0
- package/src/ui/widget.collection.ts +57 -5
- package/src/ui/widget.ui.ts +176 -24
- package/src/ui/Icon.ui.ts +0 -64
- package/src/ui/IconButton.ui.ts +0 -114
- package/src/ui/accordion.ui.ts +0 -71
- package/src/ui/button.ui.ts +0 -105
- package/src/ui/buttonColor.ui.ts +0 -24
- package/src/ui/buttonmenu.ui.ts +0 -59
- package/src/ui/checkbox.ui.ts +0 -8
- package/src/ui/container.ui.ts +0 -38
- package/src/ui/datagrid.ui.ts +0 -231
- package/src/ui/iconButtonMenu.ui.ts +0 -59
- package/src/ui/image.ui.ts +0 -49
- package/src/ui/label.ui.ts +0 -82
- package/src/ui/progressbar.ui.ts +0 -74
- package/src/ui/radiobutton.ts +0 -8
- package/src/ui/select.ui.ts +0 -73
- package/src/ui/switch.ui.ts +0 -7
- package/src/ui/textarea.ui.ts +0 -20
- package/src/ui/widget.builder.ui.tsx +0 -676
- /package/src/ui/{toggle.ui.ts → toggle.ui.tsx} +0 -0
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import { UID } from "../core/uid";
|
|
2
|
+
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
3
|
+
import { addNewWidget } from "./widget.collection";
|
|
4
|
+
import { createTextbox } from "./Textbox.ui";
|
|
5
|
+
import { createButton } from "./button.ui";
|
|
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.ui";
|
|
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
|
+
import { Accordion, createAccordion } from "./accordion.ui";
|
|
21
|
+
import { createButtonStack } from "./buttonstack.ui";
|
|
22
|
+
import { createButtonColor } from "./buttonColor.ui";
|
|
23
|
+
import { createButtonMenu } from "./buttonmenu.ui";
|
|
24
|
+
import { createIconButtonMenu } from "./iconButtonMenu.ui";
|
|
25
|
+
import { createIcon } from "./Icon.ui";
|
|
26
|
+
import { createTextarea } from "./textarea.ui";
|
|
27
|
+
import { createSelect } from "./select.ui";
|
|
28
|
+
import { createDialog, Dialog } from "./dialog";
|
|
29
|
+
import { createDataGrid, DataGrid } from "./datagrid.ui";
|
|
30
|
+
|
|
31
|
+
export type WidgetEventProps = {
|
|
32
|
+
onClick?: (args: any) => {} | void;
|
|
33
|
+
onResize?: (args: any) => {} | void;
|
|
34
|
+
onMouseDown?: (args: any) => {} | void;
|
|
35
|
+
onMouseUp?: (args: any) => {} | void;
|
|
36
|
+
onMouseMove?: (args: any) => {} | void;
|
|
37
|
+
onMouseOut?: (args: any) => {} | void;
|
|
38
|
+
onMouseLeave?: (args: any) => {} | void;
|
|
39
|
+
onWheel?: (args: any) => {} | void;
|
|
40
|
+
onDrag?: (args: any) => {} | void;
|
|
41
|
+
onRender?: (args: any) => {} | void;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type WidgetProps = {
|
|
45
|
+
id?: string | null;
|
|
46
|
+
type?: WidgetTypes | null;
|
|
47
|
+
padding?: number | null;
|
|
48
|
+
classNames?: string | null;
|
|
49
|
+
fixedSize?: number | null;
|
|
50
|
+
orientation?: OrientationTypes | null;
|
|
51
|
+
hidden?: boolean | null;
|
|
52
|
+
} & WidgetEventProps;
|
|
53
|
+
|
|
54
|
+
export function createWidget(
|
|
55
|
+
content: any,
|
|
56
|
+
parent: Widget | null = null,
|
|
57
|
+
freedom: boolean = false
|
|
58
|
+
): Widget | null {
|
|
59
|
+
if (!content.tagName) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let widget: Widget | null = null;
|
|
64
|
+
let widgetProps: WidgetProps = {
|
|
65
|
+
id: content.id ? content.id : UID(),
|
|
66
|
+
type:
|
|
67
|
+
content.getAttribute("w-type") === null
|
|
68
|
+
? WidgetTypes.FILL
|
|
69
|
+
: parseInt(content.getAttribute("w-type")),
|
|
70
|
+
orientation:
|
|
71
|
+
content.getAttribute("w-orientation") === null
|
|
72
|
+
? "horizontal"
|
|
73
|
+
: content.getAttribute("w-orientation"),
|
|
74
|
+
hidden: content.getAttribute("w-hidden") !== null ? true : false,
|
|
75
|
+
padding:
|
|
76
|
+
content.getAttribute("w-padding") === null
|
|
77
|
+
? 0
|
|
78
|
+
: parseInt(content.getAttribute("w-padding")),
|
|
79
|
+
fixedSize:
|
|
80
|
+
content.getAttribute("w-fixed-size") === null
|
|
81
|
+
? null
|
|
82
|
+
: parseInt(content.getAttribute("w-fixed-size")),
|
|
83
|
+
classNames:
|
|
84
|
+
content.getAttribute("w-classes") === null ? null : content.getAttribute("w-classes"),
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
if (!widgetProps.id) {
|
|
88
|
+
widgetProps.id = UID();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (content.getAttribute("w-textbox")) {
|
|
92
|
+
widget = createTextbox(widgetProps.id, content, parent);
|
|
93
|
+
} else if (content.getAttribute("w-textarea")) {
|
|
94
|
+
widget = createTextarea(widgetProps.id, content, parent);
|
|
95
|
+
} else if (content.getAttribute("w-button")) {
|
|
96
|
+
widget = createButton(widgetProps.id, content, parent);
|
|
97
|
+
} else if (content.getAttribute("w-icon-button")) {
|
|
98
|
+
widget = createIconButton(widgetProps.id, content, parent);
|
|
99
|
+
} else if (content.getAttribute("w-button-stack")) {
|
|
100
|
+
widget = createButtonStack(widgetProps.id, content, parent);
|
|
101
|
+
} else if (content.getAttribute("w-button-color")) {
|
|
102
|
+
widget = createButtonColor(widgetProps.id, content, parent);
|
|
103
|
+
} else if (content.getAttribute("w-button-menu")) {
|
|
104
|
+
widget = createButtonMenu(widgetProps.id, content, parent);
|
|
105
|
+
} else if (content.getAttribute("w-icon-button-menu")) {
|
|
106
|
+
widget = createIconButtonMenu(widgetProps.id, content, parent);
|
|
107
|
+
} else if (content.getAttribute("w-label")) {
|
|
108
|
+
widget = createLabel(widgetProps.id, content, parent);
|
|
109
|
+
} else if (content.getAttribute("w-image")) {
|
|
110
|
+
widget = createImage(widgetProps.id, content, parent);
|
|
111
|
+
} else if (content.getAttribute("w-icon")) {
|
|
112
|
+
widget = createIcon(widgetProps.id, content, parent);
|
|
113
|
+
} else if (content.getAttribute("w-checkbox")) {
|
|
114
|
+
widget = createCheckbox(widgetProps.id, content, parent);
|
|
115
|
+
} else if (content.getAttribute("w-radiobutton")) {
|
|
116
|
+
widget = createRadioButton(widgetProps.id, content, parent);
|
|
117
|
+
} else if (content.getAttribute("w-switch")) {
|
|
118
|
+
widget = createSwitch(widgetProps.id, content, parent);
|
|
119
|
+
} else if (content.getAttribute("w-toolbar")) {
|
|
120
|
+
widget = createToolbar(widgetProps.id, content, parent);
|
|
121
|
+
} else if (content.getAttribute("w-progressbar")) {
|
|
122
|
+
widget = createProgressBar(widgetProps.id, content, parent);
|
|
123
|
+
} else if (content.getAttribute("w-valuebar")) {
|
|
124
|
+
widget = createValueBar(widgetProps.id, content, parent);
|
|
125
|
+
} else if (content.getAttribute("w-tab")) {
|
|
126
|
+
widget = createTab(widgetProps.id, content, parent);
|
|
127
|
+
} else if (content.getAttribute("w-accordion")) {
|
|
128
|
+
widget = createAccordion(widgetProps.id, content, parent);
|
|
129
|
+
} else if (content.getAttribute("w-vpanel")) {
|
|
130
|
+
widget = createVPanel(widgetProps.id, content, parent);
|
|
131
|
+
} else if (content.getAttribute("w-hpanel")) {
|
|
132
|
+
widget = createHPanel(widgetProps.id, content, parent);
|
|
133
|
+
} else if (content.getAttribute("w-container")) {
|
|
134
|
+
widget = createContainer(content, parent);
|
|
135
|
+
} else if (content.getAttribute("w-select")) {
|
|
136
|
+
widget = createSelect(widgetProps.id, content, parent);
|
|
137
|
+
} else if (content.getAttribute("w-dialog")) {
|
|
138
|
+
widget = createDialog(widgetProps.id, content, null);
|
|
139
|
+
} else if (content.getAttribute("w-data-grid")) {
|
|
140
|
+
widget = createDataGrid(widgetProps.id, content, parent);
|
|
141
|
+
} else {
|
|
142
|
+
widget = new Widget(widgetProps.id, content.tagName, parent);
|
|
143
|
+
|
|
144
|
+
if (widgetProps.type === WidgetTypes.FREE) {
|
|
145
|
+
freedom = true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
content.getAttributeNames().forEach((key: string) => {
|
|
149
|
+
if (widget) widget.getBody().setAttribute(key, content.getAttribute(key));
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
(content as HTMLElement).childNodes.forEach((child) => {
|
|
153
|
+
if (child.hasChildNodes() == true) {
|
|
154
|
+
createWidget(child, widget, freedom);
|
|
155
|
+
} else {
|
|
156
|
+
if (widget) widget.getBody().appendChild(child);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (widget) {
|
|
162
|
+
if (!freedom && widgetProps.type) {
|
|
163
|
+
widget.setType(widgetProps.type);
|
|
164
|
+
} else {
|
|
165
|
+
widget.setType(WidgetTypes.FREE);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (widget instanceof Dialog) {
|
|
169
|
+
widget.setType(WidgetTypes.CUSTOM);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (
|
|
173
|
+
widgetProps.orientation &&
|
|
174
|
+
!(widget instanceof VPanel) &&
|
|
175
|
+
!(widget instanceof HPanel) &&
|
|
176
|
+
!(widget instanceof Dialog) &&
|
|
177
|
+
!(widget instanceof DataGrid) &&
|
|
178
|
+
!(widget instanceof Tabs)
|
|
179
|
+
) {
|
|
180
|
+
if (widgetProps.orientation === "vertical") {
|
|
181
|
+
widget.setAlign(WidgetAlignTypes.VERTICAL);
|
|
182
|
+
} else {
|
|
183
|
+
widget.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (widget instanceof Accordion) {
|
|
188
|
+
widget.setAlign(WidgetAlignTypes.VERTICAL);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (widget instanceof DataGrid) {
|
|
192
|
+
widget.setAlign(WidgetAlignTypes.VERTICAL);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (widgetProps.padding) widget.setPadding(widgetProps.padding);
|
|
196
|
+
if (widgetProps.fixedSize) widget.setFixedSize(widgetProps.fixedSize);
|
|
197
|
+
|
|
198
|
+
if (widgetProps.classNames) {
|
|
199
|
+
const clases = widgetProps.classNames.split(" ");
|
|
200
|
+
for (const clase of clases) {
|
|
201
|
+
widget.addClass(clase);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (widgetProps.hidden) {
|
|
206
|
+
widget.setVisible(false);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
addNewWidget(widgetProps.id, widget);
|
|
210
|
+
|
|
211
|
+
return widget;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function normalizeWidget(widget: any, props: WidgetProps) {
|
|
218
|
+
if (props.fixedSize !== undefined) {
|
|
219
|
+
widget.setAttribute("w-fixed-size", props.fixedSize);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (props.padding !== undefined) {
|
|
223
|
+
widget.setAttribute("w-padding", props.padding);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (props.type !== undefined) {
|
|
227
|
+
widget.setAttribute("w-type", props.type);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (props.hidden !== undefined) {
|
|
231
|
+
widget.setAttribute("w-hidden", props.hidden);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (props.classNames !== undefined) {
|
|
235
|
+
widget.setAttribute("w-classes", props.classNames);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (props.orientation !== undefined) {
|
|
239
|
+
widget.setAttribute("w-orientation", props.orientation);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
return widget;
|
|
243
|
+
}
|
|
@@ -1,19 +1,71 @@
|
|
|
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>;
|
|
14
|
+
var widgetCustomConnections: Map<string, WUICallback>;
|
|
9
15
|
}
|
|
10
16
|
|
|
11
17
|
export const initWidgetCollection = () => {
|
|
12
|
-
|
|
13
|
-
if(!window.w) {
|
|
18
|
+
if (!window.w) {
|
|
14
19
|
window.w = new Map<string, IWidget>();
|
|
15
20
|
w = window.w;
|
|
16
21
|
}
|
|
17
|
-
|
|
18
|
-
}
|
|
19
22
|
|
|
23
|
+
initWidgetConnections();
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const initWidgetConnections = () => {
|
|
27
|
+
if (!window.widgetConnections) {
|
|
28
|
+
window.widgetConnections = new Map<string, WUICallback>();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!window.widgetCustomConnections) {
|
|
32
|
+
window.widgetCustomConnections = new Map<string, WUICallback>();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const addNewWidget = (id: string, widget: IWidget) => {
|
|
37
|
+
initWidgetCollection();
|
|
38
|
+
if (!w.get(id)) w.set(id, widget);
|
|
39
|
+
setTimeout(() => {
|
|
40
|
+
run("widget-added-" + id);
|
|
41
|
+
runCustom("widget-custom-added-" + id);
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export const connectWidget = (id: string, callback: WUICallback) => {
|
|
46
|
+
initWidgetConnections();
|
|
47
|
+
widgetConnections.set(id, callback);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const connectCustomWidget = (id: string, callback: WUICallback) => {
|
|
51
|
+
initWidgetConnections();
|
|
52
|
+
widgetCustomConnections.set(id, callback);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const run = (eventId: string) => {
|
|
56
|
+
for (const [key, value] of widgetConnections.entries()) {
|
|
57
|
+
if (key == eventId) {
|
|
58
|
+
value.then(new Event(eventId), null);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
widgetConnections.delete(eventId);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const runCustom = (eventId: string) => {
|
|
65
|
+
for (const [key, value] of widgetCustomConnections.entries()) {
|
|
66
|
+
if (key == eventId) {
|
|
67
|
+
value.then(new Event(eventId), null);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
widgetCustomConnections.delete(eventId);
|
|
71
|
+
};
|
package/src/ui/widget.ui.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { UID } from "../core/uid";
|
|
1
2
|
import { IWidget, WUIEvent, WUICallback } from "../interfaces/widget.interface";
|
|
2
3
|
import { Vector2D } from "../types/vector2d.type";
|
|
4
|
+
import { WidgetEventProps, WidgetProps } from "./widget.builder";
|
|
5
|
+
import { addNewWidget, connectWidget } from "./widget.collection";
|
|
3
6
|
|
|
4
7
|
export enum WidgetTypes {
|
|
5
8
|
FILL = 1,
|
|
@@ -42,8 +45,12 @@ export class Widget implements IWidget {
|
|
|
42
45
|
bodyTagName: string;
|
|
43
46
|
body: HTMLElement;
|
|
44
47
|
|
|
45
|
-
constructor(
|
|
46
|
-
|
|
48
|
+
constructor(
|
|
49
|
+
id: string | null = "",
|
|
50
|
+
bodyTagName: string = "div",
|
|
51
|
+
parent: IWidget | null = null
|
|
52
|
+
) {
|
|
53
|
+
this.id = id ? id : UID();
|
|
47
54
|
|
|
48
55
|
this.overflow = false;
|
|
49
56
|
|
|
@@ -141,14 +148,7 @@ export class Widget implements IWidget {
|
|
|
141
148
|
|
|
142
149
|
this.getMaxZIndex();
|
|
143
150
|
|
|
144
|
-
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
public dispose(): void {
|
|
148
|
-
this.removeAllChilds();
|
|
149
|
-
const body = this.getBody();
|
|
150
|
-
const parent = body.parentNode;
|
|
151
|
-
parent?.removeChild(body);
|
|
151
|
+
addNewWidget(this.id, this);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
public run(eventId: WUIEvent): void {
|
|
@@ -294,9 +294,8 @@ export class Widget implements IWidget {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
if (freeStyle) {
|
|
297
|
-
|
|
297
|
+
this.deleteClass("WUINonFreePosition");
|
|
298
298
|
this.addClass("WUIFixPosition");
|
|
299
|
-
//this.body.style.overflow = "auto";
|
|
300
299
|
this.body.style.left = "";
|
|
301
300
|
this.body.style.top = "";
|
|
302
301
|
this.body.style.width = "";
|
|
@@ -306,8 +305,10 @@ export class Widget implements IWidget {
|
|
|
306
305
|
this.body.style.right = "";
|
|
307
306
|
} else {
|
|
308
307
|
if (this.type === WidgetTypes.CUSTOM || this.type === WidgetTypes.FILL) {
|
|
309
|
-
this.body.style.position = "absolute";
|
|
310
|
-
this.body.style.overflow = "hidden";
|
|
308
|
+
// this.body.style.position = "absolute";
|
|
309
|
+
// this.body.style.overflow = "hidden";
|
|
310
|
+
this.deleteClass("WUIFixPosition");
|
|
311
|
+
this.addClass("WUINonFreePosition");
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
314
|
|
|
@@ -367,6 +368,8 @@ export class Widget implements IWidget {
|
|
|
367
368
|
this.parent = parent;
|
|
368
369
|
this.parent?.body.appendChild(this.body);
|
|
369
370
|
|
|
371
|
+
this.setType(this.type); //TODO: revisar, se coloca para tratar de que reconozca al padre como freestyle en caso de serlo.
|
|
372
|
+
|
|
370
373
|
//this.parent?.addChild(this);
|
|
371
374
|
}
|
|
372
375
|
|
|
@@ -601,6 +604,7 @@ export class Widget implements IWidget {
|
|
|
601
604
|
public addChild(child: IWidget | null = null): void {
|
|
602
605
|
if (!child) return;
|
|
603
606
|
this.childs.push(child);
|
|
607
|
+
|
|
604
608
|
child.setParent(this);
|
|
605
609
|
|
|
606
610
|
child.init();
|
|
@@ -608,6 +612,17 @@ export class Widget implements IWidget {
|
|
|
608
612
|
child.render();*/
|
|
609
613
|
}
|
|
610
614
|
|
|
615
|
+
public populate(): void {
|
|
616
|
+
//se agrega a si mismo a window.w y a sus hijos.
|
|
617
|
+
if (!window.w.get(this.id)) {
|
|
618
|
+
window.w.set(this.id, this);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
for (const child of this.childs) {
|
|
622
|
+
child.populate();
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
611
626
|
/**
|
|
612
627
|
* Disables the selection feature.
|
|
613
628
|
*
|
|
@@ -643,9 +658,25 @@ export class Widget implements IWidget {
|
|
|
643
658
|
* @return {type} description of return value
|
|
644
659
|
*/
|
|
645
660
|
public init(): void {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
661
|
+
let freeStyle = false;
|
|
662
|
+
|
|
663
|
+
if (this.type === WidgetTypes.FREE) {
|
|
664
|
+
freeStyle = true;
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
const parent = this.getParent();
|
|
668
|
+
|
|
669
|
+
if (parent) {
|
|
670
|
+
if (parent.type === WidgetTypes.FREE) {
|
|
671
|
+
freeStyle = true;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
if (!freeStyle) {
|
|
676
|
+
this.deleteClass("WUIFixPosition");
|
|
677
|
+
this.addClass("WUINonFreePosition");
|
|
678
|
+
// this.body.style.position = "absolute";
|
|
679
|
+
// this.body.style.overflow = "hidden";
|
|
649
680
|
}
|
|
650
681
|
|
|
651
682
|
this.initPosition();
|
|
@@ -763,6 +794,12 @@ export class Widget implements IWidget {
|
|
|
763
794
|
currentPosition += elementSize;
|
|
764
795
|
child.render();
|
|
765
796
|
}
|
|
797
|
+
|
|
798
|
+
this.subscribers.forEach((callback) => {
|
|
799
|
+
if (callback.event == "render") {
|
|
800
|
+
callback.then(new Event("render"), this);
|
|
801
|
+
}
|
|
802
|
+
});
|
|
766
803
|
}
|
|
767
804
|
|
|
768
805
|
/**
|
|
@@ -792,7 +829,7 @@ export class Widget implements IWidget {
|
|
|
792
829
|
this.setVisible(!this.visible);
|
|
793
830
|
}
|
|
794
831
|
|
|
795
|
-
renderHTML(content: any): HTMLElement {
|
|
832
|
+
public renderHTML(content: any): HTMLElement {
|
|
796
833
|
this.body.appendChild(content);
|
|
797
834
|
return content as HTMLElement;
|
|
798
835
|
}
|
|
@@ -813,15 +850,15 @@ export class Widget implements IWidget {
|
|
|
813
850
|
return maxZindex;
|
|
814
851
|
}
|
|
815
852
|
|
|
816
|
-
setZIndex(zIndex: number): void {
|
|
853
|
+
public setZIndex(zIndex: number): void {
|
|
817
854
|
this.getBody().style.zIndex = `${zIndex}`;
|
|
818
855
|
}
|
|
819
856
|
|
|
820
|
-
raisteTop(): void {
|
|
857
|
+
public raisteTop(): void {
|
|
821
858
|
this.setZIndex(this.getMaxZIndex() + 1);
|
|
822
859
|
}
|
|
823
860
|
|
|
824
|
-
raiseBottom(): void {
|
|
861
|
+
public raiseBottom(): void {
|
|
825
862
|
this.setZIndex(0);
|
|
826
863
|
}
|
|
827
864
|
|
|
@@ -831,7 +868,7 @@ export class Widget implements IWidget {
|
|
|
831
868
|
* @param {IWidget} guest - The widget to attach.
|
|
832
869
|
* @return {void} This function does not return anything.
|
|
833
870
|
*/
|
|
834
|
-
attachWidget(guest: IWidget): void {
|
|
871
|
+
public attachWidget(guest: IWidget): void {
|
|
835
872
|
this.removeAllChilds();
|
|
836
873
|
this.addChild(guest);
|
|
837
874
|
guest.setParent(this);
|
|
@@ -845,7 +882,7 @@ export class Widget implements IWidget {
|
|
|
845
882
|
*
|
|
846
883
|
* @return {void} No return value.
|
|
847
884
|
*/
|
|
848
|
-
removeAllChilds(): void {
|
|
885
|
+
public removeAllChilds(): void {
|
|
849
886
|
while (this.getBody().childNodes.length > 0) {
|
|
850
887
|
const child = this.getBody().firstChild;
|
|
851
888
|
if (child) this.getBody().removeChild(child);
|
|
@@ -854,12 +891,127 @@ export class Widget implements IWidget {
|
|
|
854
891
|
this.childs = [];
|
|
855
892
|
}
|
|
856
893
|
|
|
857
|
-
free(): void {
|
|
894
|
+
public free(): void {
|
|
858
895
|
if (this.childs) {
|
|
859
896
|
for (const child of this.childs) {
|
|
860
897
|
child.free();
|
|
861
898
|
}
|
|
862
899
|
}
|
|
900
|
+
|
|
863
901
|
window.w.delete(this.id);
|
|
902
|
+
|
|
903
|
+
const body = this.getBody();
|
|
904
|
+
const parent = body.parentNode;
|
|
905
|
+
if (!parent && !body) return;
|
|
906
|
+
parent?.removeChild(body);
|
|
864
907
|
}
|
|
908
|
+
|
|
909
|
+
public dispose(): void {
|
|
910
|
+
this.removeAllChilds();
|
|
911
|
+
const body = this.getBody();
|
|
912
|
+
const parent = body.parentNode;
|
|
913
|
+
parent?.removeChild(body);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
export function getOnlyEventProps(props: WidgetProps): WidgetEventProps {
|
|
918
|
+
const eventProps = {
|
|
919
|
+
onClick: props.onClick,
|
|
920
|
+
onDrag: props.onDrag,
|
|
921
|
+
onResize: props.onResize,
|
|
922
|
+
onMouseDown: props.onMouseDown,
|
|
923
|
+
onMouseUp: props.onMouseUp,
|
|
924
|
+
onMouseMove: props.onMouseMove,
|
|
925
|
+
onMouseOut: props.onMouseOut,
|
|
926
|
+
onMouseLeave: props.onMouseLeave,
|
|
927
|
+
onWheel: props.onWheel,
|
|
928
|
+
onRender: props.onRender,
|
|
929
|
+
};
|
|
930
|
+
|
|
931
|
+
return eventProps;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
export function connectWidgetCallback(
|
|
935
|
+
id: string | null | undefined,
|
|
936
|
+
props: WidgetEventProps
|
|
937
|
+
): void {
|
|
938
|
+
if (!id) return;
|
|
939
|
+
connectWidget("widget-added-" + id, {
|
|
940
|
+
event: "widget-load",
|
|
941
|
+
then: (_e, _w) => {
|
|
942
|
+
const widget = w.get(id) as Widget;
|
|
943
|
+
|
|
944
|
+
if (widget) {
|
|
945
|
+
widget.subscribe({
|
|
946
|
+
event: "click",
|
|
947
|
+
then: (_e, _w) => {
|
|
948
|
+
props.onClick ? props.onClick({}) : null;
|
|
949
|
+
},
|
|
950
|
+
});
|
|
951
|
+
|
|
952
|
+
widget.subscribe({
|
|
953
|
+
event: "drag",
|
|
954
|
+
then: (_e, _w) => {
|
|
955
|
+
props.onDrag ? props.onDrag({}) : null;
|
|
956
|
+
},
|
|
957
|
+
});
|
|
958
|
+
|
|
959
|
+
widget.subscribe({
|
|
960
|
+
event: "resize",
|
|
961
|
+
then: (_e, _w) => {
|
|
962
|
+
props.onResize ? props.onResize({}) : null;
|
|
963
|
+
},
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
widget.subscribe({
|
|
967
|
+
event: "mousedown",
|
|
968
|
+
then: (_e, _w) => {
|
|
969
|
+
props.onMouseDown ? props.onMouseDown({}) : null;
|
|
970
|
+
},
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
widget.subscribe({
|
|
974
|
+
event: "mouseup",
|
|
975
|
+
then: (_e, _w) => {
|
|
976
|
+
props.onMouseUp ? props.onMouseUp({}) : null;
|
|
977
|
+
},
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
widget.subscribe({
|
|
981
|
+
event: "mousemove",
|
|
982
|
+
then: (_e, _w) => {
|
|
983
|
+
props.onMouseMove ? props.onMouseMove({}) : null;
|
|
984
|
+
},
|
|
985
|
+
});
|
|
986
|
+
|
|
987
|
+
widget.subscribe({
|
|
988
|
+
event: "mouseout",
|
|
989
|
+
then: (_e, _w) => {
|
|
990
|
+
props.onMouseOut ? props.onMouseOut({}) : null;
|
|
991
|
+
},
|
|
992
|
+
});
|
|
993
|
+
|
|
994
|
+
widget.subscribe({
|
|
995
|
+
event: "mouseleave",
|
|
996
|
+
then: (_e, _w) => {
|
|
997
|
+
props.onMouseLeave ? props.onMouseLeave({}) : null;
|
|
998
|
+
},
|
|
999
|
+
});
|
|
1000
|
+
|
|
1001
|
+
widget.subscribe({
|
|
1002
|
+
event: "wheel",
|
|
1003
|
+
then: (_e, _w) => {
|
|
1004
|
+
props.onWheel ? props.onWheel({}) : null;
|
|
1005
|
+
},
|
|
1006
|
+
});
|
|
1007
|
+
|
|
1008
|
+
widget.subscribe({
|
|
1009
|
+
event: "render",
|
|
1010
|
+
then: (_e, _w) => {
|
|
1011
|
+
props.onRender ? props.onRender({}) : null;
|
|
1012
|
+
},
|
|
1013
|
+
});
|
|
1014
|
+
}
|
|
1015
|
+
},
|
|
1016
|
+
});
|
|
865
1017
|
}
|
package/src/ui/Icon.ui.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Colors } from "./colors.ui";
|
|
2
|
-
import { Widget } from "./widget.ui";
|
|
3
|
-
|
|
4
|
-
export type IconVariants = "Filled" | "Outlined" | "Round" | "Sharp" | "Two Tone";
|
|
5
|
-
|
|
6
|
-
export class Icon extends Widget {
|
|
7
|
-
variant: IconVariants;
|
|
8
|
-
color: Colors;
|
|
9
|
-
icon: string;
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
-
id: string,
|
|
13
|
-
icon: string,
|
|
14
|
-
variant: IconVariants = "Filled",
|
|
15
|
-
parent: Widget | null = null
|
|
16
|
-
) {
|
|
17
|
-
super(id, "span", parent);
|
|
18
|
-
|
|
19
|
-
this.variant = variant;
|
|
20
|
-
this.color = "primary";
|
|
21
|
-
this.icon = icon;
|
|
22
|
-
|
|
23
|
-
if (this.variant === "Filled") {
|
|
24
|
-
this.addClass("material-icons");
|
|
25
|
-
} else {
|
|
26
|
-
this.addClass(
|
|
27
|
-
"material-icons-" + this.variant.toString().replace(" ", "-").toLowerCase()
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
this.setIcon(icon);
|
|
32
|
-
|
|
33
|
-
this.init();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public init(): void {
|
|
37
|
-
super.init();
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
setIcon(icon: string): void {
|
|
41
|
-
this.icon = icon;
|
|
42
|
-
this.body.innerHTML = icon;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
setVariant(variant: IconVariants = "Filled"): void {
|
|
46
|
-
this.variant = variant;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
setColor(color: Colors = "primary"): void {
|
|
50
|
-
this.color = color;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getVariant(): IconVariants {
|
|
54
|
-
return this.variant;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
getColor(): Colors {
|
|
58
|
-
return this.color;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
getIcon(): string {
|
|
62
|
-
return this.icon;
|
|
63
|
-
}
|
|
64
|
-
}
|