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
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
.WUITextArea {
|
|
2
|
-
outline: none;
|
|
3
|
-
/*border-collapse: collapse;*/
|
|
4
|
-
border: 2px solid var(--palette-action-disabled);
|
|
5
|
-
border-radius: 4px;
|
|
6
|
-
box-sizing: border-box;
|
|
7
|
-
font-size: 1rem;
|
|
8
|
-
padding-left: 20px;
|
|
9
|
-
z-index: 1000;
|
|
10
|
-
background-color: var(--palette-background-default);
|
|
11
|
-
color: var(--palette-text-primary);
|
|
12
|
-
overflow-y: auto;
|
|
13
|
-
}
|
|
1
|
+
.WUITextArea {
|
|
2
|
+
outline: none;
|
|
3
|
+
/*border-collapse: collapse;*/
|
|
4
|
+
border: 2px solid var(--palette-action-disabled);
|
|
5
|
+
border-radius: 4px;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
font-size: 1rem;
|
|
8
|
+
padding-left: 20px;
|
|
9
|
+
z-index: 1000;
|
|
10
|
+
background-color: var(--palette-background-default);
|
|
11
|
+
color: var(--palette-text-primary);
|
|
12
|
+
overflow-y: auto;
|
|
13
|
+
}
|
package/src/ui/styles/vpanel.css
CHANGED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { UID } from "../core/uid";
|
|
2
|
+
import { ToggleButton } from "./toggle.ui";
|
|
3
|
+
import { normalizeWidget, WidgetProps } from "./widget.builder";
|
|
4
|
+
import { Widget, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
5
|
+
export class Switch extends ToggleButton {
|
|
6
|
+
constructor(id: string, text: string = "", parent: Widget | null = null) {
|
|
7
|
+
super(id, text, "toggle_off", "toggle_on", parent);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type wSwitchProps = WidgetProps & {
|
|
12
|
+
text: string;
|
|
13
|
+
checked?: boolean | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const WSwitch = (props: wSwitchProps) => {
|
|
17
|
+
if (!props.id) {
|
|
18
|
+
props.id = "Switch." + UID();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
22
|
+
|
|
23
|
+
return normalizeWidget(
|
|
24
|
+
<div id={props.id} w-switch w-text={props.text} w-checked={props.checked} />,
|
|
25
|
+
props
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function createSwitch(id: string, content: any, parent: Widget | null = null): Switch {
|
|
30
|
+
const dataText = content.getAttribute("w-text");
|
|
31
|
+
const dataChecked = content.getAttribute("w-checked");
|
|
32
|
+
|
|
33
|
+
let newSwitch = new Switch(id, dataText, parent);
|
|
34
|
+
|
|
35
|
+
if (dataChecked !== null) {
|
|
36
|
+
newSwitch.setState(true);
|
|
37
|
+
} else {
|
|
38
|
+
newSwitch.setState(false);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return newSwitch;
|
|
42
|
+
}
|
|
@@ -4,8 +4,10 @@ import { OrientationTypes } from "src/types/orientation.type";
|
|
|
4
4
|
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
5
5
|
import { Toolbar } from "./toolbar.ui";
|
|
6
6
|
import { Label } from "./label.ui";
|
|
7
|
-
import {
|
|
7
|
+
import { Icon } from "./Icon.ui";
|
|
8
8
|
import { Scroll } from "./scroll.ui";
|
|
9
|
+
import { WidgetProps, createWidget, normalizeWidget } from "./widget.builder";
|
|
10
|
+
import { UID } from "../core/uid";
|
|
9
11
|
|
|
10
12
|
const TAB_HEADER_SIZE = 40;
|
|
11
13
|
|
|
@@ -34,14 +36,15 @@ export class Tabs extends Widget {
|
|
|
34
36
|
|
|
35
37
|
this.content = new Widget(id + ".content", "div");
|
|
36
38
|
this.content.setType(WidgetTypes.FILL);
|
|
37
|
-
this.content.addClass("WUITabContainer");
|
|
38
39
|
|
|
39
40
|
this.setType(WidgetTypes.FILL);
|
|
40
41
|
|
|
41
42
|
if (this.orientation === "horizontal") {
|
|
42
43
|
this.setAlign(WidgetAlignTypes.VERTICAL);
|
|
44
|
+
this.content.addClass("WUITabContainer-horizontal");
|
|
43
45
|
} else {
|
|
44
46
|
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
47
|
+
this.content.addClass("WUITabContainer-vertical");
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
this.items = new Map<string, TabItem>();
|
|
@@ -59,7 +62,11 @@ export class Tabs extends Widget {
|
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
public setOrientation(orientation: OrientationTypes) {
|
|
65
|
+
if (this.orientation !== orientation) {
|
|
66
|
+
this.content.deleteClass("WUITabContainer-" + this.orientation);
|
|
67
|
+
}
|
|
62
68
|
this.orientation = orientation;
|
|
69
|
+
this.content.addClass("WUITabContainer-" + this.orientation);
|
|
63
70
|
}
|
|
64
71
|
|
|
65
72
|
public addTab(id: string, title: string, content: Widget, scrollable: boolean = false) {
|
|
@@ -97,9 +104,19 @@ export class Tabs extends Widget {
|
|
|
97
104
|
this.items.set(id, { title: icon, content });
|
|
98
105
|
this.itemsScrollable.set(id, scrollable);
|
|
99
106
|
|
|
100
|
-
const itemControl = new
|
|
101
|
-
|
|
102
|
-
|
|
107
|
+
const itemControl = new Icon(id + ".itemControl", icon);
|
|
108
|
+
|
|
109
|
+
if (this.orientation === "horizontal") {
|
|
110
|
+
itemControl.setH(TAB_HEADER_SIZE);
|
|
111
|
+
itemControl.getBody().style.lineHeight = TAB_HEADER_SIZE + "px";
|
|
112
|
+
} else if (this.orientation === "vertical") {
|
|
113
|
+
itemControl.getBody().style.writingMode = "vertical-rl";
|
|
114
|
+
itemControl.getBody().style.transform = "scale(-1,-1)";
|
|
115
|
+
itemControl.getBody().style.paddingTop = "12px";
|
|
116
|
+
itemControl.getBody().style.paddingBottom = "12px";
|
|
117
|
+
itemControl.getBody().style.paddingRight = "10px";
|
|
118
|
+
itemControl.setW(TAB_HEADER_SIZE);
|
|
119
|
+
}
|
|
103
120
|
|
|
104
121
|
itemControl.subscribe({
|
|
105
122
|
event: "click",
|
|
@@ -124,7 +141,7 @@ export class Tabs extends Widget {
|
|
|
124
141
|
ctrlTab.deleteClass("WUITabControlActive");
|
|
125
142
|
ctrlTab.addClass("WUITabControl");
|
|
126
143
|
} else if (this.orientation === "vertical") {
|
|
127
|
-
if (ctrlTab instanceof
|
|
144
|
+
if (ctrlTab instanceof Icon) {
|
|
128
145
|
ctrlTab.deleteClass("WUITabControlActiveIcon_VL");
|
|
129
146
|
} else if (ctrlTab instanceof Label) {
|
|
130
147
|
ctrlTab.deleteClass("WUITabControlActive_VL");
|
|
@@ -138,7 +155,7 @@ export class Tabs extends Widget {
|
|
|
138
155
|
if (this.orientation === "horizontal") {
|
|
139
156
|
ctrlTab.addClass("WUITabControlActive");
|
|
140
157
|
} else if (this.orientation === "vertical") {
|
|
141
|
-
if (ctrlTab instanceof
|
|
158
|
+
if (ctrlTab instanceof Icon) {
|
|
142
159
|
ctrlTab.addClass("WUITabControlActiveIcon_VL");
|
|
143
160
|
} else if (ctrlTab instanceof Label) {
|
|
144
161
|
ctrlTab.addClass("WUITabControlActive_VL");
|
|
@@ -164,7 +181,7 @@ export class Tabs extends Widget {
|
|
|
164
181
|
}
|
|
165
182
|
} else {
|
|
166
183
|
if (this.verticalScrollbar) {
|
|
167
|
-
this.verticalScrollbar.
|
|
184
|
+
this.verticalScrollbar.free();
|
|
168
185
|
this.verticalScrollbar = null;
|
|
169
186
|
}
|
|
170
187
|
}
|
|
@@ -180,3 +197,92 @@ export class Tabs extends Widget {
|
|
|
180
197
|
}
|
|
181
198
|
}
|
|
182
199
|
}
|
|
200
|
+
|
|
201
|
+
export type TabItemType = "text" | "icon-tab";
|
|
202
|
+
|
|
203
|
+
export type WTabProps = Omit<WidgetProps, "orientation"> & {
|
|
204
|
+
orientation?: OrientationTypes;
|
|
205
|
+
selectedTab?: number | null;
|
|
206
|
+
children: any;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export type WTabItemProps = {
|
|
210
|
+
title?: string | null;
|
|
211
|
+
icon?: string | null;
|
|
212
|
+
type?: TabItemType | null;
|
|
213
|
+
scrollable?: boolean | null;
|
|
214
|
+
children: any;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
export const WTab = (props: WTabProps) => {
|
|
218
|
+
if (!props.id) {
|
|
219
|
+
props.id = "Tabs." + UID();
|
|
220
|
+
}
|
|
221
|
+
return normalizeWidget(
|
|
222
|
+
<div id={props.id} w-tab w-class={props.classNames} w-selected-tab={props.selectedTab}>
|
|
223
|
+
{props.children}
|
|
224
|
+
</div>,
|
|
225
|
+
props
|
|
226
|
+
);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
export const WTabItem = (props: WTabItemProps) => {
|
|
230
|
+
return (
|
|
231
|
+
<div w-tab-item w-title={props.title} w-icon={props.icon} w-type={props.type}>
|
|
232
|
+
{props.children}
|
|
233
|
+
</div>
|
|
234
|
+
);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export function createTab(id: string, content: any, parent: Widget | null = null): Tabs {
|
|
238
|
+
const dataOrientation = content.getAttribute("w-orientation");
|
|
239
|
+
const dataScrollable = content.getAttribute("w-scrollable") ? true : false;
|
|
240
|
+
const dataSelectedTab = content.getAttribute("w-selected-tab");
|
|
241
|
+
|
|
242
|
+
let orientation: OrientationTypes = dataOrientation ? dataOrientation : "horizontal";
|
|
243
|
+
|
|
244
|
+
let newTab = new Tabs(id, parent, orientation);
|
|
245
|
+
|
|
246
|
+
content.childNodes.forEach((tabItem: HTMLElement, index: number) => {
|
|
247
|
+
if (tabItem.getAttribute("w-tab-item") !== null) {
|
|
248
|
+
const tabTitle = tabItem.getAttribute("w-title");
|
|
249
|
+
const tabIcon = tabItem.getAttribute("w-icon");
|
|
250
|
+
const tabType = tabItem.getAttribute("w-type") || "text";
|
|
251
|
+
|
|
252
|
+
if (!tabItem.firstChild) {
|
|
253
|
+
throw new Error("Tab Item must have a content");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
const widget = createWidget(tabItem.firstChild);
|
|
257
|
+
|
|
258
|
+
if (widget !== null) {
|
|
259
|
+
if (tabType === "text") {
|
|
260
|
+
newTab.addTab(
|
|
261
|
+
newTab.id + ".Item." + index,
|
|
262
|
+
tabTitle || "Untitled",
|
|
263
|
+
widget,
|
|
264
|
+
dataScrollable
|
|
265
|
+
);
|
|
266
|
+
} else if (tabType === "icon-tab") {
|
|
267
|
+
newTab.addIconTab(
|
|
268
|
+
newTab.id + ".Item." + index,
|
|
269
|
+
tabIcon || "home",
|
|
270
|
+
widget,
|
|
271
|
+
dataScrollable
|
|
272
|
+
);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
if (dataSelectedTab !== null) {
|
|
279
|
+
const selectedTab = parseInt(dataSelectedTab);
|
|
280
|
+
if (selectedTab < newTab.items.size) {
|
|
281
|
+
newTab.setTab(newTab.id + ".Item." + selectedTab);
|
|
282
|
+
}
|
|
283
|
+
} else {
|
|
284
|
+
newTab.setTab(newTab.id + ".Item.0");
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return newTab;
|
|
288
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { UID } from "../core/uid";
|
|
2
|
+
import "./styles/textarea.css";
|
|
3
|
+
import { normalizeWidget, WidgetProps } from "./widget.builder";
|
|
4
|
+
import { connectWidgetCallback, getOnlyEventProps, Widget } from "./widget.ui";
|
|
5
|
+
|
|
6
|
+
export class TextArea extends Widget {
|
|
7
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
8
|
+
super(id, "textarea", parent);
|
|
9
|
+
|
|
10
|
+
this.addClass("WUITextArea");
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public setText(text: string): void {
|
|
14
|
+
const textArea = this.getBody() as HTMLTextAreaElement;
|
|
15
|
+
textArea.value = text;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
public getText(): string {
|
|
19
|
+
const textArea = this.getBody() as HTMLTextAreaElement;
|
|
20
|
+
return textArea.value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type wTextareaProps = WidgetProps & {
|
|
25
|
+
text: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const WTextarea = (props: wTextareaProps) => {
|
|
29
|
+
if (!props.id) {
|
|
30
|
+
props.id = "Textarea." + UID();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
34
|
+
|
|
35
|
+
return normalizeWidget(<div id={props.id} w-textarea w-text={props.text}></div>, props);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export function createTextarea(id: string, content: any, parent: Widget | null = null): TextArea {
|
|
39
|
+
let newTextarea = new TextArea(id, parent);
|
|
40
|
+
|
|
41
|
+
const dataText = content.getAttribute("w-text");
|
|
42
|
+
|
|
43
|
+
if (dataText) {
|
|
44
|
+
newTextarea.setText(dataText);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return newTextarea;
|
|
48
|
+
}
|
|
@@ -3,6 +3,8 @@ import { IWidget } from "src/interfaces/widget.interface";
|
|
|
3
3
|
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
4
4
|
import { IconButton } from "./IconButton.ui";
|
|
5
5
|
import { OrientationTypes } from "src/types/orientation.type";
|
|
6
|
+
import { WidgetProps, createWidget, normalizeWidget } from "./widget.builder";
|
|
7
|
+
import { UID } from "../core/uid";
|
|
6
8
|
|
|
7
9
|
export type ToolbarVariants = "contained" | "outlined";
|
|
8
10
|
|
|
@@ -38,7 +40,7 @@ export class Toolbar extends Widget {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
this.setType(WidgetTypes.FILL);
|
|
41
|
-
this.setFixedSize(TOOLBAR_SIZE);
|
|
43
|
+
//this.setFixedSize(TOOLBAR_SIZE);
|
|
42
44
|
this.addClass("WUIToolbar-" + this.variant);
|
|
43
45
|
|
|
44
46
|
this.itemsContainer = new Widget(this.id + ".itemsContainer", "div", this);
|
|
@@ -229,3 +231,44 @@ export class Toolbar extends Widget {
|
|
|
229
231
|
}
|
|
230
232
|
}
|
|
231
233
|
}
|
|
234
|
+
|
|
235
|
+
export type ToolbarProps = WidgetProps & {
|
|
236
|
+
variant?: ToolbarVariants;
|
|
237
|
+
children: any;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
export const WToolbar = (props: ToolbarProps) => {
|
|
241
|
+
if (!props.id) {
|
|
242
|
+
props.id = "Toolbar." + UID();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return normalizeWidget(
|
|
246
|
+
<div w-toolbar id={props.id} w-variant={props.variant}>
|
|
247
|
+
{props.children}
|
|
248
|
+
</div>,
|
|
249
|
+
props
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export function createToolbar(id: string, content: any, parent: Widget | null = null): Toolbar {
|
|
254
|
+
const dataOrientation = content.getAttribute("w-orientation");
|
|
255
|
+
const dataVariant = content.getAttribute("w-variant");
|
|
256
|
+
|
|
257
|
+
let orientation: OrientationTypes = dataOrientation ? dataOrientation : "horizontal";
|
|
258
|
+
|
|
259
|
+
let newToolbar = new Toolbar(id, parent, orientation);
|
|
260
|
+
|
|
261
|
+
if (dataVariant) {
|
|
262
|
+
newToolbar.setVariant(dataVariant);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
content.childNodes.forEach((item: HTMLElement) => {
|
|
266
|
+
const widget = createWidget(item);
|
|
267
|
+
|
|
268
|
+
if (widget !== null) {
|
|
269
|
+
newToolbar.addItem(widget.id, widget);
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
return newToolbar;
|
|
274
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import "./styles/valuebar.css";
|
|
2
2
|
import { OrientationTypes } from "src/types/orientation.type";
|
|
3
|
-
import { Widget } from "./widget.ui";
|
|
3
|
+
import { Widget, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
4
4
|
import { Draggable } from "./draggable.ui";
|
|
5
|
+
import { normalizeWidget, WidgetProps } from "./widget.builder";
|
|
6
|
+
import { UID } from "../core/uid";
|
|
5
7
|
|
|
6
8
|
export class ValueBar extends Widget {
|
|
7
9
|
orientation: OrientationTypes;
|
|
@@ -48,6 +50,10 @@ export class ValueBar extends Widget {
|
|
|
48
50
|
this.render();
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
public getValue(): number {
|
|
54
|
+
return this.value;
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
public updateValueFromHandlerPosition(): void {
|
|
52
58
|
if (this.orientation === "horizontal") {
|
|
53
59
|
const maxX = this.draggable.maxX ? this.draggable.maxX : 1;
|
|
@@ -114,3 +120,31 @@ export class ValueBar extends Widget {
|
|
|
114
120
|
}
|
|
115
121
|
}
|
|
116
122
|
}
|
|
123
|
+
|
|
124
|
+
export type wValueBarProps = WidgetProps & {
|
|
125
|
+
value: number;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export const WValueBar = (props: wValueBarProps) => {
|
|
129
|
+
if (!props.id) {
|
|
130
|
+
props.id = "ValueBar." + UID();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
134
|
+
|
|
135
|
+
return normalizeWidget(<div id={props.id} w-valuebar w-value={props.value}></div>, props);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
export function createValueBar(id: string, content: any, parent: Widget | null = null): ValueBar {
|
|
139
|
+
const dataOrientation = content.getAttribute("w-orientation");
|
|
140
|
+
const dataValue = content.getAttribute("w-value");
|
|
141
|
+
let orientation: OrientationTypes = dataOrientation ? dataOrientation : "horizontal";
|
|
142
|
+
|
|
143
|
+
let newValueBar = new ValueBar(id, orientation, parent);
|
|
144
|
+
|
|
145
|
+
if (dataValue) {
|
|
146
|
+
newValueBar.setValue(parseInt(dataValue));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return newValueBar;
|
|
150
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { Draggable } from "./draggable.ui";
|
|
2
2
|
import "./styles/vpanel.css";
|
|
3
|
-
import {
|
|
3
|
+
import { WidgetProps, createWidget, normalizeWidget } from "./widget.builder";
|
|
4
|
+
import {
|
|
5
|
+
connectWidgetCallback,
|
|
6
|
+
getOnlyEventProps,
|
|
7
|
+
Widget,
|
|
8
|
+
WidgetAlignTypes,
|
|
9
|
+
WidgetTypes,
|
|
10
|
+
} from "./widget.ui";
|
|
4
11
|
|
|
5
12
|
const VPANEL_HANDLER_SIZE = 4;
|
|
6
13
|
|
|
@@ -125,4 +132,40 @@ export class VPanel extends Widget {
|
|
|
125
132
|
|
|
126
133
|
this.handler.setX(this.getX(true));
|
|
127
134
|
}
|
|
135
|
+
|
|
136
|
+
public free(): void {
|
|
137
|
+
this.handler.free();
|
|
138
|
+
this.topContent?.free();
|
|
139
|
+
this.bottomContent?.free();
|
|
140
|
+
//this.draggable.free();
|
|
141
|
+
super.free();
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export type WVPanelProps = WidgetProps & {
|
|
146
|
+
children: any;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export const WVPanel = (props: WVPanelProps) => {
|
|
150
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
151
|
+
|
|
152
|
+
return normalizeWidget(<div w-vpanel>{props.children}</div>, props);
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export function createVPanel(id: string, content: any, parent: Widget | null = null): VPanel {
|
|
156
|
+
let newPanel = new VPanel(id, parent);
|
|
157
|
+
|
|
158
|
+
content.childNodes.forEach((item: HTMLElement, index: number) => {
|
|
159
|
+
const widget = createWidget(item);
|
|
160
|
+
|
|
161
|
+
if (widget !== null) {
|
|
162
|
+
if (index === 0) {
|
|
163
|
+
newPanel.setTop(widget, widget.getFixedSize());
|
|
164
|
+
} else if (index === 1) {
|
|
165
|
+
newPanel.setBottom(widget);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
return newPanel;
|
|
128
171
|
}
|