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
package/README.md
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="https://raw.githubusercontent.com/hdrdevs/cedro/main/public/cedro-logo.svg" alt="Cedro" width="170">
|
|
3
|
+
<h1>cedro</h1>
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
**Don't use this library. "cedro" is on development.**
|
|
5
|
+
</div>
|
|
6
|
+
<h6>Javascript library to build user interfece based on widgets.</h6>
|
|
6
7
|
|
|
7
8
|
## Getting Started
|
|
8
9
|
|
|
@@ -14,3 +15,5 @@ npx degit hdrdevs/vite-cedro#main my-app-name
|
|
|
14
15
|
npm install
|
|
15
16
|
npm run dev
|
|
16
17
|
```
|
|
18
|
+
|
|
19
|
+
⚠️ **Warning:** Don't use this library. "cedro" is on development.
|
|
Binary file
|
package/dist/fangio.jpg
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cedro",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@types/node": "^20.4.4",
|
|
@@ -11,8 +11,10 @@
|
|
|
11
11
|
"@oothkoo/seo-js": "1.0.5",
|
|
12
12
|
"@types/color": "3.0.3",
|
|
13
13
|
"@types/react": "18.2.17",
|
|
14
|
+
"html-entities": "^2.5.2",
|
|
14
15
|
"color": "4.2.3",
|
|
15
|
-
"
|
|
16
|
+
"glob": "^11.0.0",
|
|
17
|
+
"material-icons": "1.13.12",
|
|
16
18
|
"navigo": "8.11.1"
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//import { createWidget } from "src/ui/builder/widget.builder";
|
|
2
|
+
import { Widget, WidgetAlignTypes } from "../ui";
|
|
3
|
+
import { createWidget } from "../ui/widget.builder";
|
|
4
|
+
import Application, { ApplicationProps } from "./application.core";
|
|
5
|
+
import { decode } from "html-entities";
|
|
6
|
+
|
|
7
|
+
function getApplicationProps(content: any): ApplicationProps {
|
|
8
|
+
let props: ApplicationProps = {
|
|
9
|
+
title: content.title,
|
|
10
|
+
padding: 0,
|
|
11
|
+
theme: null,
|
|
12
|
+
orientation: null,
|
|
13
|
+
children: null,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
if (content.getAttribute("w-title") !== null) {
|
|
17
|
+
props.title = content.getAttribute("w-title");
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (content.getAttribute("w-padding") !== null) {
|
|
21
|
+
props.padding = parseInt(content.getAttribute("w-padding"));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (content.getAttribute("w-orientation") !== null) {
|
|
25
|
+
props.orientation = content.getAttribute("w-orientation");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (content.getAttribute("w-theme") !== null) {
|
|
29
|
+
props.theme = content.getAttribute("w-theme");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return props;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function createApplication(content: any): Application {
|
|
36
|
+
const appProps = getApplicationProps(content);
|
|
37
|
+
const newApp = new Application(appProps.title);
|
|
38
|
+
|
|
39
|
+
if (appProps.padding) {
|
|
40
|
+
newApp.getRoot().setPadding(appProps.padding);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (appProps.orientation) {
|
|
44
|
+
if (appProps.orientation === "horizontal") {
|
|
45
|
+
newApp.getRoot().setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
46
|
+
} else {
|
|
47
|
+
newApp.getRoot().setAlign(WidgetAlignTypes.VERTICAL);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (appProps.theme) {
|
|
52
|
+
newApp.theme.setTheme(appProps.theme);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
content.childNodes.forEach((item: HTMLElement) => {
|
|
56
|
+
if (item.getAttribute("w-widget-collection")) {
|
|
57
|
+
item.childNodes.forEach((ietmWidget: any) => {
|
|
58
|
+
const appWidgets = createWidget(ietmWidget);
|
|
59
|
+
|
|
60
|
+
if (appWidgets !== null) {
|
|
61
|
+
newApp.getRoot().addChild(appWidgets);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
} else if (item.getAttribute("w-routes")) {
|
|
65
|
+
newApp.setRouterHostId(item.getAttribute("w-host-id"));
|
|
66
|
+
item.childNodes.forEach((ietmRoute: any) => {
|
|
67
|
+
if (ietmRoute.getAttribute("w-route-path") && ietmRoute.getAttribute("href")) {
|
|
68
|
+
newApp.router.on(decode(ietmRoute.getAttribute("href")), () => {
|
|
69
|
+
const url = decode(ietmRoute.getAttribute("href"));
|
|
70
|
+
const timestamp = new Date().getTime();
|
|
71
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
72
|
+
|
|
73
|
+
const pathDev = ".." + url + "?ts=" + timestamp;
|
|
74
|
+
|
|
75
|
+
const pathProduction = `../../assets${decode(
|
|
76
|
+
ietmRoute.getAttribute("href")
|
|
77
|
+
)}/index.js?ts=${timestamp}`;
|
|
78
|
+
|
|
79
|
+
const path = isProduction ? pathProduction : pathDev;
|
|
80
|
+
|
|
81
|
+
import(/*@vite-ignore*/ path).then((module) => {
|
|
82
|
+
newApp.clearLoadedModule();
|
|
83
|
+
newApp.setLoadedModule(module.default);
|
|
84
|
+
const host = w.get(newApp.getRouterHostId());
|
|
85
|
+
if (host) {
|
|
86
|
+
newApp.attachWidget(newApp.getLoadedModule() as Widget, host);
|
|
87
|
+
}
|
|
88
|
+
newApp.hideLoading();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const loadCss = async () => {
|
|
92
|
+
try {
|
|
93
|
+
const timestamp = new Date().getTime();
|
|
94
|
+
const cssName = "../../assets" + url + "/style.css?ts=" + timestamp;
|
|
95
|
+
|
|
96
|
+
// Crear un elemento <link> para cargar el CSS
|
|
97
|
+
const link = document.createElement("link");
|
|
98
|
+
link.rel = "stylesheet";
|
|
99
|
+
link.href = cssName;
|
|
100
|
+
document.head.appendChild(link);
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.log(error);
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
if (isProduction) loadCss();
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
newApp.router.resolve();
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
appConnections.forEach((cb) => {
|
|
115
|
+
newApp.subscribe(cb);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
appConnections = [];
|
|
119
|
+
|
|
120
|
+
return newApp;
|
|
121
|
+
}
|
|
@@ -9,20 +9,34 @@ import "material-icons/iconfont/material-icons.css";
|
|
|
9
9
|
import { Widget, WidgetAlignTypes, WidgetTypes } from "../ui/widget.ui";
|
|
10
10
|
import { Screen } from "./screeen.core";
|
|
11
11
|
import { IApplication, IScreenSize } from "../interfaces/application.interface";
|
|
12
|
-
import { IWidget } from "../interfaces/widget.interface";
|
|
12
|
+
import { IWidget, WUICallback, WUIEvent } from "../interfaces/widget.interface";
|
|
13
13
|
import Navigo from "navigo";
|
|
14
14
|
import { Dialog } from "../ui/dialog";
|
|
15
15
|
import { Label } from "../ui/label.ui";
|
|
16
16
|
import { Seo } from "./seo";
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
CedroLightTheme,
|
|
19
|
+
CedroDarkTheme,
|
|
20
|
+
DarkTheme,
|
|
21
|
+
LightTheme,
|
|
22
|
+
ThemeManager,
|
|
23
|
+
} from "./themes.core";
|
|
18
24
|
import { Loading } from "../ui/loading.ui";
|
|
25
|
+
import { OrientationTypes } from "../types/orientation.type";
|
|
26
|
+
|
|
27
|
+
declare global {
|
|
28
|
+
var appConnections: Array<WUICallback>;
|
|
29
|
+
}
|
|
19
30
|
|
|
20
31
|
class WApplication implements IApplication {
|
|
21
32
|
seo: Seo;
|
|
22
33
|
|
|
34
|
+
subscribers: Map<string, WUICallback>;
|
|
35
|
+
|
|
23
36
|
screen: Screen;
|
|
24
37
|
root: Widget;
|
|
25
38
|
router: Navigo;
|
|
39
|
+
routerHostId: string;
|
|
26
40
|
|
|
27
41
|
alertDialog: Dialog;
|
|
28
42
|
confirmDialog: Dialog;
|
|
@@ -32,19 +46,27 @@ class WApplication implements IApplication {
|
|
|
32
46
|
|
|
33
47
|
theme: ThemeManager;
|
|
34
48
|
|
|
49
|
+
loadedModule: any;
|
|
50
|
+
|
|
35
51
|
constructor(title: string) {
|
|
36
52
|
this.seo = new Seo(title);
|
|
37
53
|
|
|
54
|
+
this.subscribers = new Map<string, WUICallback>();
|
|
55
|
+
|
|
38
56
|
this.root = new Widget("root");
|
|
57
|
+
|
|
39
58
|
this.root.setType(WidgetTypes.FILL);
|
|
40
59
|
this.screen = new Screen();
|
|
41
60
|
this.router = new Navigo("/");
|
|
61
|
+
this.routerHostId = this.getRoot().id;
|
|
42
62
|
|
|
43
63
|
this.mediaQueries = new Map<string, IScreenSize>();
|
|
44
64
|
|
|
45
65
|
this.theme = new ThemeManager();
|
|
46
66
|
this.theme.add(LightTheme);
|
|
47
67
|
this.theme.add(DarkTheme);
|
|
68
|
+
this.theme.add(CedroDarkTheme);
|
|
69
|
+
this.theme.add(CedroLightTheme);
|
|
48
70
|
|
|
49
71
|
this.screen.onResize(() => {
|
|
50
72
|
this.getRoot().resize();
|
|
@@ -53,6 +75,13 @@ class WApplication implements IApplication {
|
|
|
53
75
|
window.addEventListener("load", () => {
|
|
54
76
|
this.screen.updateSize();
|
|
55
77
|
this.getRoot().resize();
|
|
78
|
+
this.run("load");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
window.addEventListener("resize", () => {
|
|
82
|
+
this.screen.updateSize();
|
|
83
|
+
this.getRoot().resize();
|
|
84
|
+
this.run("resize");
|
|
56
85
|
});
|
|
57
86
|
|
|
58
87
|
this.alertDialog = new Dialog("Dialog.alert", null);
|
|
@@ -63,13 +92,64 @@ class WApplication implements IApplication {
|
|
|
63
92
|
this.theme.load();
|
|
64
93
|
}
|
|
65
94
|
|
|
66
|
-
|
|
95
|
+
public setLoadedModule(module: any): void {
|
|
96
|
+
this.loadedModule = module;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public getLoadedModule(): any {
|
|
100
|
+
return this.loadedModule;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public clearLoadedModule(): void {
|
|
104
|
+
this.loadedModule = null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public setRouterHostId(id: string | null): void {
|
|
108
|
+
if (!id) {
|
|
109
|
+
this.routerHostId = this.getRoot().id;
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
this.routerHostId = id;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public getRouterHostId(): string {
|
|
116
|
+
return this.routerHostId;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public run(eventId: WUIEvent): void {
|
|
120
|
+
this.subscribers.forEach((callback) => {
|
|
121
|
+
if (callback.event == eventId) {
|
|
122
|
+
callback.then(new Event(eventId), null);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
public subscribe(cb: WUICallback) {
|
|
128
|
+
const randomId =
|
|
129
|
+
Math.random().toString(36).substring(2, 15) +
|
|
130
|
+
Math.random().toString(36).substring(2, 15);
|
|
131
|
+
|
|
132
|
+
this.subscribers.set(`${randomId}.${cb.event}`, cb);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
public unsubscribe(event: WUIEvent) {
|
|
136
|
+
this.subscribers.delete(`${event}`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public alert(
|
|
140
|
+
title: string = "",
|
|
141
|
+
msg: string,
|
|
142
|
+
onOk: () => void = () => {},
|
|
143
|
+
onCancell: () => void = () => {}
|
|
144
|
+
): void {
|
|
67
145
|
const mesageLabel = new Label("alert.label", "span");
|
|
68
146
|
|
|
69
147
|
mesageLabel.setType(WidgetTypes.FILL);
|
|
70
148
|
mesageLabel.setAlign(WidgetAlignTypes.VERTICAL);
|
|
71
149
|
mesageLabel.setText(msg);
|
|
72
150
|
|
|
151
|
+
this.alertDialog.titleBar.setText(title);
|
|
152
|
+
|
|
73
153
|
this.alertDialog.setOkCallback({ event: "click", then: onOk });
|
|
74
154
|
this.alertDialog.setCancellCallback({
|
|
75
155
|
event: "click",
|
|
@@ -81,7 +161,11 @@ class WApplication implements IApplication {
|
|
|
81
161
|
this.alertDialog.show();
|
|
82
162
|
}
|
|
83
163
|
|
|
84
|
-
confirm(
|
|
164
|
+
public confirm(
|
|
165
|
+
msg: string,
|
|
166
|
+
onOk: () => void = () => {},
|
|
167
|
+
onCancell: () => void = () => {}
|
|
168
|
+
): void {
|
|
85
169
|
const mesageLabel = new Label("alert.label", "span");
|
|
86
170
|
|
|
87
171
|
mesageLabel.setType(WidgetTypes.FILL);
|
|
@@ -99,10 +183,16 @@ class WApplication implements IApplication {
|
|
|
99
183
|
this.confirmDialog.show();
|
|
100
184
|
}
|
|
101
185
|
|
|
102
|
-
attachWidget(guest: IWidget, host: IWidget): void {
|
|
186
|
+
public attachWidget(guest: IWidget, host: IWidget): void {
|
|
103
187
|
if (!host) {
|
|
104
188
|
console.log("guest:", guest);
|
|
189
|
+
return;
|
|
105
190
|
}
|
|
191
|
+
|
|
192
|
+
if (!guest) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
106
196
|
for (const child of host.getBody().childNodes) {
|
|
107
197
|
child.parentNode?.removeChild(child);
|
|
108
198
|
}
|
|
@@ -114,13 +204,14 @@ class WApplication implements IApplication {
|
|
|
114
204
|
host.removeAllChilds();
|
|
115
205
|
|
|
116
206
|
host.addChild(guest);
|
|
207
|
+
guest.populate(); //tiene que recorrer todos los widgets hijos en forma recursiva e ir agregandolos a window.w
|
|
117
208
|
guest.setParent(host);
|
|
118
209
|
guest.render();
|
|
119
210
|
this.root.resize();
|
|
120
211
|
this.root.render();
|
|
121
212
|
}
|
|
122
213
|
|
|
123
|
-
addMediaQuery(
|
|
214
|
+
public addMediaQuery(
|
|
124
215
|
query: string,
|
|
125
216
|
minWidth: number,
|
|
126
217
|
maxWidth: number,
|
|
@@ -134,7 +225,7 @@ class WApplication implements IApplication {
|
|
|
134
225
|
*
|
|
135
226
|
* @return {void} This function does not return a value.
|
|
136
227
|
*/
|
|
137
|
-
init(): void {
|
|
228
|
+
public init(): void {
|
|
138
229
|
this.root.subscribe({
|
|
139
230
|
event: "resize",
|
|
140
231
|
then: () => {
|
|
@@ -151,6 +242,7 @@ class WApplication implements IApplication {
|
|
|
151
242
|
});
|
|
152
243
|
|
|
153
244
|
this.root.render();
|
|
245
|
+
this.seo.setTitle(this.seo.getTitle());
|
|
154
246
|
}
|
|
155
247
|
|
|
156
248
|
/**
|
|
@@ -158,7 +250,7 @@ class WApplication implements IApplication {
|
|
|
158
250
|
*
|
|
159
251
|
* @return {Widget} The root widget of the application.
|
|
160
252
|
*/
|
|
161
|
-
getRoot(): Widget {
|
|
253
|
+
public getRoot(): Widget {
|
|
162
254
|
return this.root;
|
|
163
255
|
}
|
|
164
256
|
|
|
@@ -168,7 +260,7 @@ class WApplication implements IApplication {
|
|
|
168
260
|
* @param {Widget} root - The root widget to set.
|
|
169
261
|
* @return {void}
|
|
170
262
|
*/
|
|
171
|
-
setRoot(root: Widget): void {
|
|
263
|
+
public setRoot(root: Widget): void {
|
|
172
264
|
this.root = root;
|
|
173
265
|
}
|
|
174
266
|
|
|
@@ -180,6 +272,80 @@ class WApplication implements IApplication {
|
|
|
180
272
|
public hideLoading(): void {
|
|
181
273
|
this.loading.setVisible(false);
|
|
182
274
|
}
|
|
275
|
+
|
|
276
|
+
public goTo(path: string): void {
|
|
277
|
+
this.router.navigate(path);
|
|
278
|
+
}
|
|
183
279
|
}
|
|
184
280
|
|
|
281
|
+
export const initApplicationConnections = () => {
|
|
282
|
+
if (!window.appConnections) {
|
|
283
|
+
window.appConnections = new Array<WUICallback>();
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
export const connectApplication = (cb: WUICallback) => {
|
|
287
|
+
initApplicationConnections();
|
|
288
|
+
window.appConnections.push(cb);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
export type ApplicationProps = {
|
|
292
|
+
title: string;
|
|
293
|
+
padding?: number | null;
|
|
294
|
+
orientation?: OrientationTypes | null;
|
|
295
|
+
theme?: string | null;
|
|
296
|
+
children: any;
|
|
297
|
+
onResize?: (args: any) => void;
|
|
298
|
+
onLoad?: (args: any) => void;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export const Application = (props: ApplicationProps) => {
|
|
302
|
+
if (props.onLoad) {
|
|
303
|
+
connectApplication({ event: "load", then: props.onLoad });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (props.onResize) {
|
|
307
|
+
connectApplication({ event: "resize", then: props.onResize });
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
<div
|
|
312
|
+
title={props.title}
|
|
313
|
+
w-padding={props.padding}
|
|
314
|
+
w-orientation={props.orientation}
|
|
315
|
+
w-theme={props.theme}
|
|
316
|
+
>
|
|
317
|
+
{props.children}
|
|
318
|
+
</div>
|
|
319
|
+
);
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
export type WidgetsProps = {
|
|
323
|
+
children: any;
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const Widgets = (props: WidgetsProps) => {
|
|
327
|
+
return <div w-widget-collection>{props.children}</div>;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export type RoutesProps = {
|
|
331
|
+
hostId: string;
|
|
332
|
+
children: any;
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
export const Routes = (props: RoutesProps) => {
|
|
336
|
+
return (
|
|
337
|
+
<div w-routes w-host-id={props.hostId}>
|
|
338
|
+
{props.children}
|
|
339
|
+
</div>
|
|
340
|
+
);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export type RouteProps = {
|
|
344
|
+
src: string;
|
|
345
|
+
};
|
|
346
|
+
|
|
347
|
+
export const Route = (props: RouteProps) => {
|
|
348
|
+
return <a w-route-path href={props.src}></a>;
|
|
349
|
+
};
|
|
350
|
+
|
|
185
351
|
export default WApplication;
|
package/src/core/themes.core.ts
CHANGED
|
@@ -16,12 +16,15 @@ export class Theme implements ITheme {
|
|
|
16
16
|
|
|
17
17
|
export const LightTheme = new Theme("light");
|
|
18
18
|
export const DarkTheme = new Theme("dark");
|
|
19
|
+
export const CedroDarkTheme = new Theme("cedro-dark");
|
|
20
|
+
export const CedroLightTheme = new Theme("cedro");
|
|
19
21
|
|
|
20
22
|
LightTheme.add("--palette-text-primary", "rgba(0, 0, 0, 0.87)")
|
|
21
23
|
.add("--palette-text-secondary", "rgba(0, 0, 0, 0.6)")
|
|
22
24
|
.add("--palette-text-disabled", "rgba(0, 0, 0, 0.38)")
|
|
23
25
|
.add("--palette-background-default", "#ffffff")
|
|
24
26
|
.add("--palette-background-paper", "#ffffff")
|
|
27
|
+
.add("--palette-background-light", "#f5f5f5")
|
|
25
28
|
.add("--palette-action-active", "rgba(0, 0, 0, 0.54)")
|
|
26
29
|
.add("--palette-action-disabled", "rgba(0, 0, 0, 0.26)")
|
|
27
30
|
.add("--palette-action-hover", "#f5f5f5")
|
|
@@ -37,7 +40,7 @@ LightTheme.add("--palette-text-primary", "rgba(0, 0, 0, 0.87)")
|
|
|
37
40
|
|
|
38
41
|
.add("--palette-primary-main", "#90caf9")
|
|
39
42
|
.add("--palette-primary-dark", "#42a5f5")
|
|
40
|
-
.add("--palette-primary-light", "#
|
|
43
|
+
.add("--palette-primary-light", "#90caf9")
|
|
41
44
|
|
|
42
45
|
.add("--palette-primary-text-main", "#2a3b49")
|
|
43
46
|
.add("--palette-primary-text-dark", "#133048")
|
|
@@ -99,6 +102,7 @@ DarkTheme.add("--palette-text-primary", "#cdd0d3")
|
|
|
99
102
|
|
|
100
103
|
.add("--palette-background-default", "#121212")
|
|
101
104
|
.add("--palette-background-paper", "#121212")
|
|
105
|
+
.add("--palette-background-light", "rgba(255, 255, 255, 0.02)")
|
|
102
106
|
|
|
103
107
|
.add("--palette-action-active", "#ffffff")
|
|
104
108
|
.add("--palette-action-disabled", "rgba(255, 255, 255, 0.3)")
|
|
@@ -170,6 +174,161 @@ DarkTheme.add("--palette-text-primary", "#cdd0d3")
|
|
|
170
174
|
.add("--palette-success-text-dark", "#263b27")
|
|
171
175
|
.add("--palette-success-text-light", "#c3ddc5");
|
|
172
176
|
|
|
177
|
+
CedroDarkTheme.add("--palette-text-primary", "#d3d0c8")
|
|
178
|
+
.add("--palette-text-secondary", "#a6a29a")
|
|
179
|
+
.add("--palette-text-disabled", "rgba(80, 81, 82, 0.5)")
|
|
180
|
+
|
|
181
|
+
.add("--palette-background-default", "#655349")
|
|
182
|
+
.add("--palette-background-paper", "#56473e")
|
|
183
|
+
.add("--palette-background-light", "#6d5a4e")
|
|
184
|
+
|
|
185
|
+
.add("--palette-action-active", "#655447")
|
|
186
|
+
.add("--palette-action-disabled", "rgba(39, 32, 27, 0.3)")
|
|
187
|
+
.add("--palette-action-hover", "#56473e")
|
|
188
|
+
.add("--palette-action-selected", "rgba(255, 255, 255, 0.16)")
|
|
189
|
+
.add("--palette-action-disabled-bg", "rgba(255, 255, 255, 0.12)")
|
|
190
|
+
|
|
191
|
+
.add("--palette-divider", "rgba(255, 255, 255, 0.12)")
|
|
192
|
+
|
|
193
|
+
.add("--palette-link", "#ffa500")
|
|
194
|
+
.add("--palette-link-hover", "#c07e06")
|
|
195
|
+
|
|
196
|
+
/*PRIMARY*/
|
|
197
|
+
.add("--palette-primary-main", "#f9ca90")
|
|
198
|
+
.add("--palette-primary-dark", "#da9f56")
|
|
199
|
+
.add("--palette-primary-light", "#fcd09a")
|
|
200
|
+
|
|
201
|
+
.add("--palette-primary-text-main", "#2a3b49")
|
|
202
|
+
.add("--palette-primary-text-dark", "#133048")
|
|
203
|
+
.add("--palette-primary-text-light", "#43474b")
|
|
204
|
+
|
|
205
|
+
/*SECONDARY*/
|
|
206
|
+
|
|
207
|
+
.add("--palette-secondary-main", "#ce93d8")
|
|
208
|
+
.add("--palette-secondary-dark", "#ab47bc")
|
|
209
|
+
.add("--palette-secondary-light", "#f3e5f5")
|
|
210
|
+
|
|
211
|
+
.add("--palette-secondary-text-main", "#3d2b40")
|
|
212
|
+
.add("--palette-secondary-text-dark", "#e6c8eb")
|
|
213
|
+
.add("--palette-secondary-text-light", "#484348")
|
|
214
|
+
|
|
215
|
+
/*ERROR*/
|
|
216
|
+
|
|
217
|
+
.add("--palette-error-main", "#9e5656")
|
|
218
|
+
.add("--palette-error-dark", "#d32f2f")
|
|
219
|
+
.add("--palette-error-light", "#e57373")
|
|
220
|
+
|
|
221
|
+
.add("--palette-error-text-main", "#fbc7c3")
|
|
222
|
+
.add("--palette-error-text-dark", "#f1c1c1")
|
|
223
|
+
.add("--palette-error-text-light", "#432222")
|
|
224
|
+
|
|
225
|
+
/*WARNING*/
|
|
226
|
+
|
|
227
|
+
.add("--palette-warning-main", "#ffa726")
|
|
228
|
+
.add("--palette-warning-dark", "#ffb74d")
|
|
229
|
+
.add("--palette-warning-light", "#f57c00")
|
|
230
|
+
|
|
231
|
+
.add("--palette-warning-text-main", "#4b310b")
|
|
232
|
+
.add("--palette-warning-text-dark", "#4b3616")
|
|
233
|
+
.add("--palette-warning-text-light", "#482400")
|
|
234
|
+
|
|
235
|
+
/*INFO*/
|
|
236
|
+
|
|
237
|
+
.add("--palette-info-main", "#29b6f6")
|
|
238
|
+
.add("--palette-info-dark", "#4fc3f7")
|
|
239
|
+
.add("--palette-info-light", "#0288d1")
|
|
240
|
+
|
|
241
|
+
.add("--palette-info-text-main", "#0c3649")
|
|
242
|
+
.add("--palette-info-text-dark", "#173949")
|
|
243
|
+
.add("--palette-info-text-light", "#b3dbf1")
|
|
244
|
+
|
|
245
|
+
/*SUCCESS*/
|
|
246
|
+
|
|
247
|
+
.add("--palette-success-main", "#599062")
|
|
248
|
+
.add("--palette-success-dark", "#81c784")
|
|
249
|
+
.add("--palette-success-light", "#388e3c")
|
|
250
|
+
|
|
251
|
+
.add("--palette-success-text-main", "#1e371f")
|
|
252
|
+
.add("--palette-success-text-dark", "#263b27")
|
|
253
|
+
.add("--palette-success-text-light", "#c3ddc5");
|
|
254
|
+
|
|
255
|
+
CedroLightTheme.add("--palette-text-primary", "#4f3e2e")
|
|
256
|
+
.add("--palette-text-secondary", "rgba(0, 0, 0, 0.6)")
|
|
257
|
+
.add("--palette-text-disabled", "rgba(0, 0, 0, 0.38)")
|
|
258
|
+
.add("--palette-background-default", "#ffffff")
|
|
259
|
+
.add("--palette-background-paper", "#ffffff")
|
|
260
|
+
.add("--palette-background-light", "rgba(250, 243, 235, 0.5)")
|
|
261
|
+
.add("--palette-action-active", "rgba(0, 0, 0, 0.54)")
|
|
262
|
+
.add("--palette-action-disabled", "#ffe2ba")
|
|
263
|
+
.add("--palette-action-hover", "#f5f5f5")
|
|
264
|
+
.add("--palette-action-selected", "rgba(0, 0, 0, 0.08)")
|
|
265
|
+
.add("--palette-action-disabled-bg", "rgba(0, 0, 0, 0.12)")
|
|
266
|
+
|
|
267
|
+
.add("--palette-divider", "#ffe2ba")
|
|
268
|
+
|
|
269
|
+
.add("--palette-link", "#1d79ee")
|
|
270
|
+
.add("--palette-link-hover", "#3393f2")
|
|
271
|
+
|
|
272
|
+
/*PRIMARY*/
|
|
273
|
+
|
|
274
|
+
.add("--palette-primary-main", "#baf990")
|
|
275
|
+
.add("--palette-primary-dark", "#9bce79")
|
|
276
|
+
.add("--palette-primary-light", "#d1ffb2")
|
|
277
|
+
|
|
278
|
+
.add("--palette-primary-text-main", "#2a3b49")
|
|
279
|
+
.add("--palette-primary-text-dark", "#133048")
|
|
280
|
+
.add("--palette-primary-text-light", "#43474b")
|
|
281
|
+
|
|
282
|
+
/*SECONDARY*/
|
|
283
|
+
|
|
284
|
+
.add("--palette-secondary-main", "#ce93d8")
|
|
285
|
+
.add("--palette-secondary-dark", "#ab47bc")
|
|
286
|
+
.add("--palette-secondary-light", "#f3e5f5")
|
|
287
|
+
|
|
288
|
+
.add("--palette-secondary-text-main", "#3d2b40")
|
|
289
|
+
.add("--palette-secondary-text-dark", "#e6c8eb")
|
|
290
|
+
.add("--palette-secondary-text-light", "#484348")
|
|
291
|
+
|
|
292
|
+
/*ERROR*/
|
|
293
|
+
|
|
294
|
+
.add("--palette-error-main", "#f44336")
|
|
295
|
+
.add("--palette-error-dark", "#d32f2f")
|
|
296
|
+
.add("--palette-error-light", "#e57373")
|
|
297
|
+
|
|
298
|
+
.add("--palette-error-text-main", "#fbc7c3")
|
|
299
|
+
.add("--palette-error-text-dark", "#f1c1c1")
|
|
300
|
+
.add("--palette-error-text-light", "#432222")
|
|
301
|
+
|
|
302
|
+
/*WARNING*/
|
|
303
|
+
|
|
304
|
+
.add("--palette-warning-main", "#ffa726")
|
|
305
|
+
.add("--palette-warning-dark", "#ffb74d")
|
|
306
|
+
.add("--palette-warning-light", "#f57c00")
|
|
307
|
+
|
|
308
|
+
.add("--palette-warning-text-main", "#4b310b")
|
|
309
|
+
.add("--palette-warning-text-dark", "#4b3616")
|
|
310
|
+
.add("--palette-warning-text-light", "#482400")
|
|
311
|
+
|
|
312
|
+
/*INFO*/
|
|
313
|
+
|
|
314
|
+
.add("--palette-info-main", "#29b6f6")
|
|
315
|
+
.add("--palette-info-dark", "#4fc3f7")
|
|
316
|
+
.add("--palette-info-light", "#0288d1")
|
|
317
|
+
|
|
318
|
+
.add("--palette-info-text-main", "#0c3649")
|
|
319
|
+
.add("--palette-info-text-dark", "#173949")
|
|
320
|
+
.add("--palette-info-text-light", "#b3dbf1")
|
|
321
|
+
|
|
322
|
+
/*SUCCESS*/
|
|
323
|
+
|
|
324
|
+
.add("--palette-success-main", "#66bb6a")
|
|
325
|
+
.add("--palette-success-dark", "#81c784")
|
|
326
|
+
.add("--palette-success-light", "#388e3c")
|
|
327
|
+
|
|
328
|
+
.add("--palette-success-text-main", "#1e371f")
|
|
329
|
+
.add("--palette-success-text-dark", "#263b27")
|
|
330
|
+
.add("--palette-success-text-light", "#c3ddc5");
|
|
331
|
+
|
|
173
332
|
export class ThemeManager implements IThemeManager {
|
|
174
333
|
themes: ITheme[];
|
|
175
334
|
current: ITheme | null;
|
package/src/core/uid.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function UID(): string {
|
|
2
|
-
return "w-uid-" + Date.now().toString(36) + "-" + Math.random().toString(36);
|
|
3
|
-
}
|
|
1
|
+
export function UID(): string {
|
|
2
|
+
return "w-uid-" + Date.now().toString(36) + "-" + Math.random().toString(36);
|
|
3
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,7 @@ import Application from "./core/application.core";
|
|
|
2
2
|
import { DOMcreateElement, DOMcreateFragment } from "./core/jsxsupport";
|
|
3
3
|
import { Widget, WidgetTypes, WidgetAlignTypes } from "./ui/widget.ui";
|
|
4
4
|
import { initWidgetCollection } from "./ui/widget.collection";
|
|
5
|
-
import { createWidget } from "./ui/widget.builder
|
|
5
|
+
import { createWidget } from "./ui/widget.builder";
|
|
6
6
|
|
|
7
7
|
initWidgetCollection();
|
|
8
8
|
|