cedro 0.1.8 → 0.1.9
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.builder.tsx +60 -0
- package/src/core/{application.core.ts → application.core.tsx} +68 -1
- package/src/index.ts +1 -1
- package/src/interfaces/application.interface.ts +7 -1
- package/src/interfaces/widget.interface.ts +3 -1
- package/src/ui/{IconButton.ui.ts → IconButton.ui.tsx} +79 -2
- package/src/ui/{button.ui.ts → button.ui.tsx} +63 -1
- package/src/ui/checkbox.ui.tsx +47 -0
- package/src/ui/container.ui.tsx +76 -0
- package/src/ui/{hpanel.ui.ts → hpanel.ui.tsx} +37 -0
- package/src/ui/image.ui.tsx +112 -0
- package/src/ui/index.ts +1 -1
- package/src/ui/{label.ui.ts → label.ui.tsx} +45 -1
- package/src/ui/progressbar.ui.tsx +134 -0
- package/src/ui/radiobutton.tsx +51 -0
- package/src/ui/styles/hpanel.css +1 -1
- package/src/ui/styles/progressbar.css +1 -1
- package/src/ui/styles/valuebar.css +1 -1
- package/src/ui/styles/vpanel.css +1 -1
- package/src/ui/switch.ui.tsx +46 -0
- package/src/ui/{tabs.ui.ts → tabs.ui.tsx} +86 -1
- package/src/ui/{textbox.ui.ts → textbox.ui.tsx} +54 -1
- package/src/ui/{toolbar.ui.ts → toolbar.ui.tsx} +38 -0
- package/src/ui/{valuebar.ui.ts → valuebar.ui.tsx} +37 -1
- package/src/ui/{vpanel.ui.ts → vpanel.ui.tsx} +37 -0
- package/src/ui/widget.builder.ts +159 -0
- package/src/ui/widget.collection.ts +35 -5
- package/src/ui/widget.ui.ts +107 -15
- package/src/ui/checkbox.ui.ts +0 -8
- package/src/ui/container.ui.ts +0 -38
- package/src/ui/image.ui.ts +0 -49
- package/src/ui/progressbar.ui.ts +0 -74
- package/src/ui/radiobutton.ts +0 -8
- package/src/ui/switch.ui.ts +0 -7
- package/src/ui/widget.builder.ui.tsx +0 -676
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { WidgetProps } from "./widget.builder";
|
|
1
2
|
import { Colors } from "./colors.ui";
|
|
2
|
-
import { Widget } from "./widget.ui";
|
|
3
|
+
import { Widget, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
3
4
|
|
|
4
5
|
export type LabelVariants = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
|
|
5
6
|
|
|
@@ -80,3 +81,46 @@ export class Label extends Widget {
|
|
|
80
81
|
return this.text;
|
|
81
82
|
}
|
|
82
83
|
}
|
|
84
|
+
|
|
85
|
+
export type wLabelProps = WidgetProps & {
|
|
86
|
+
variant?: string | null;
|
|
87
|
+
color?: Colors | null;
|
|
88
|
+
text?: string | null;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const WLabel = (props: wLabelProps) => {
|
|
92
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div
|
|
96
|
+
id={props.id}
|
|
97
|
+
w-label
|
|
98
|
+
w-text={props.text}
|
|
99
|
+
w-variant={props.variant}
|
|
100
|
+
w-color={props.color}
|
|
101
|
+
></div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export function createLabel(id: string, content: any, parent: Widget | null = null): Label {
|
|
106
|
+
const dataText = content.getAttribute("w-text");
|
|
107
|
+
const dataVariant = content.getAttribute("w-variant");
|
|
108
|
+
const dataColor = content.getAttribute("w-color");
|
|
109
|
+
let tag = dataVariant ? dataVariant : "span";
|
|
110
|
+
|
|
111
|
+
let newLabel = new Label(id, tag, parent);
|
|
112
|
+
|
|
113
|
+
if (dataText) {
|
|
114
|
+
newLabel.setText(dataText);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (dataVariant) {
|
|
118
|
+
newLabel.setVariant(dataVariant);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (dataColor) {
|
|
122
|
+
newLabel.setColor(dataColor);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return newLabel;
|
|
126
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Label } from "./label.ui";
|
|
2
|
+
import "./styles/progressbar.css";
|
|
3
|
+
import { WidgetProps } from "./widget.builder";
|
|
4
|
+
import { Widget, WidgetTypes, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
5
|
+
|
|
6
|
+
const PROGRESS_BAR_HEIGHT = 40;
|
|
7
|
+
|
|
8
|
+
//icono para el progress bar interactivo humidity_high
|
|
9
|
+
|
|
10
|
+
export class ProgressBar extends Widget {
|
|
11
|
+
private value: number;
|
|
12
|
+
private paddingBar: number;
|
|
13
|
+
|
|
14
|
+
private bar: Widget;
|
|
15
|
+
private lblValue: Label;
|
|
16
|
+
|
|
17
|
+
public constructor(id: string, parent: Widget | null = null) {
|
|
18
|
+
super(id, "div", parent);
|
|
19
|
+
|
|
20
|
+
this.setH(PROGRESS_BAR_HEIGHT);
|
|
21
|
+
|
|
22
|
+
this.paddingBar = 0;
|
|
23
|
+
|
|
24
|
+
this.bar = new Widget(id + ".bar", "div", this);
|
|
25
|
+
this.bar.addClass("WUIProgressBarBar");
|
|
26
|
+
|
|
27
|
+
this.value = 0;
|
|
28
|
+
this.addClass("WUIProgressBarContainer");
|
|
29
|
+
|
|
30
|
+
this.lblValue = new Label(id + ".value", "span", this);
|
|
31
|
+
this.lblValue.setType(WidgetTypes.CUSTOM);
|
|
32
|
+
this.lblValue.setVCentered(true);
|
|
33
|
+
this.lblValue.setHCentered(true);
|
|
34
|
+
this.lblValue.setText(this.value + "%");
|
|
35
|
+
|
|
36
|
+
this.lblValue.addClass("WUIProgressBarLabel");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public setPaddingBar(p: number): void {
|
|
40
|
+
this.paddingBar = p;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public hideLabel(): void {
|
|
44
|
+
this.lblValue.setVisible(false);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public displayLabel(): void {
|
|
48
|
+
this.lblValue.setVisible(true);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public render(): void {
|
|
52
|
+
super.render();
|
|
53
|
+
|
|
54
|
+
const padding = this.paddingBar;
|
|
55
|
+
const width = this.getW() - padding;
|
|
56
|
+
const height = this.getH();
|
|
57
|
+
const widthBar = width * (this.value / 100);
|
|
58
|
+
|
|
59
|
+
this.lblValue.setX(padding);
|
|
60
|
+
this.lblValue.setY(0);
|
|
61
|
+
this.lblValue.setW(width);
|
|
62
|
+
this.lblValue.setH(height);
|
|
63
|
+
this.lblValue.raisteTop();
|
|
64
|
+
this.lblValue.render();
|
|
65
|
+
|
|
66
|
+
this.bar.setX(padding);
|
|
67
|
+
this.bar.setY(padding);
|
|
68
|
+
this.bar.setW(widthBar);
|
|
69
|
+
this.bar.setH(height - padding * 2);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public setValue(value: number): void {
|
|
73
|
+
this.value = value;
|
|
74
|
+
this.lblValue.setText(this.value + "%");
|
|
75
|
+
this.render();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public getValue(): number {
|
|
79
|
+
return this.value;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type wProgressBarProps = WidgetProps & {
|
|
84
|
+
value: number;
|
|
85
|
+
paddingBar?: number | null;
|
|
86
|
+
hideLabel?: boolean | null;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const WProgressBar = (props: wProgressBarProps) => {
|
|
90
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div
|
|
94
|
+
id={props.id}
|
|
95
|
+
w-progressbar
|
|
96
|
+
w-value={props.value}
|
|
97
|
+
w-padding-bar={props.paddingBar}
|
|
98
|
+
w-hide-label={props.hideLabel}
|
|
99
|
+
w-class={props.classNames}
|
|
100
|
+
w-orientation={props.orientation}
|
|
101
|
+
w-fixed-size={props.fixedSize}
|
|
102
|
+
w-padding={props.padding}
|
|
103
|
+
w-type={props.type}
|
|
104
|
+
></div>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export function createProgressBar(
|
|
109
|
+
id: string,
|
|
110
|
+
content: any,
|
|
111
|
+
parent: Widget | null = null
|
|
112
|
+
): ProgressBar {
|
|
113
|
+
let newProgressBar = new ProgressBar(id, parent);
|
|
114
|
+
|
|
115
|
+
const dataValue = content.getAttribute("w-value");
|
|
116
|
+
const dataPaddingBar = content.getAttribute("w-padding-bar");
|
|
117
|
+
const dataHideLabel = content.getAttribute("w-hide-label");
|
|
118
|
+
|
|
119
|
+
if (dataValue) {
|
|
120
|
+
newProgressBar.setValue(parseInt(dataValue));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (dataPaddingBar) {
|
|
124
|
+
newProgressBar.setPaddingBar(parseInt(dataPaddingBar));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (dataHideLabel !== null) {
|
|
128
|
+
newProgressBar.hideLabel();
|
|
129
|
+
} else {
|
|
130
|
+
newProgressBar.displayLabel();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return newProgressBar;
|
|
134
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ToggleButton } from "./toggle.ui";
|
|
2
|
+
import { WidgetProps } from "./widget.builder";
|
|
3
|
+
import { Widget, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
4
|
+
|
|
5
|
+
export class RadioButton extends ToggleButton {
|
|
6
|
+
constructor(id: string, text: string = "", parent: Widget | null = null) {
|
|
7
|
+
super(id, text, "radio_button_checked", "radio_button_unchecked", parent);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type wRadioButtonProps = WidgetProps & {
|
|
12
|
+
text: string;
|
|
13
|
+
checked?: boolean | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const WRadioButton = (props: wRadioButtonProps) => {
|
|
17
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
id={props.id}
|
|
22
|
+
w-radiobutton
|
|
23
|
+
w-text={props.text}
|
|
24
|
+
w-checked={props.checked}
|
|
25
|
+
w-class={props.classNames}
|
|
26
|
+
w-orientation={props.orientation}
|
|
27
|
+
w-fixed-size={props.fixedSize}
|
|
28
|
+
w-padding={props.padding}
|
|
29
|
+
w-type={props.type}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export function createRadioButton(
|
|
35
|
+
id: string,
|
|
36
|
+
content: any,
|
|
37
|
+
parent: Widget | null = null
|
|
38
|
+
): RadioButton {
|
|
39
|
+
const dataText = content.getAttribute("w-text");
|
|
40
|
+
const dataChecked = content.getAttribute("w-checked");
|
|
41
|
+
|
|
42
|
+
let newRadioButton = new RadioButton(id, dataText, parent);
|
|
43
|
+
|
|
44
|
+
if (dataChecked !== null) {
|
|
45
|
+
newRadioButton.setState(true);
|
|
46
|
+
} else {
|
|
47
|
+
newRadioButton.setState(false);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return newRadioButton;
|
|
51
|
+
}
|
package/src/ui/styles/hpanel.css
CHANGED
package/src/ui/styles/vpanel.css
CHANGED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ToggleButton } from "./toggle.ui";
|
|
2
|
+
import { WidgetProps } from "./widget.builder";
|
|
3
|
+
import { Widget, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
4
|
+
export class Switch extends ToggleButton {
|
|
5
|
+
constructor(id: string, text: string = "", parent: Widget | null = null) {
|
|
6
|
+
super(id, text, "toggle_off", "toggle_on", parent);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export type wSwitchProps = WidgetProps & {
|
|
11
|
+
text: string;
|
|
12
|
+
checked?: boolean | null;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const WSwitch = (props: wSwitchProps) => {
|
|
16
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
id={props.id}
|
|
21
|
+
w-switch
|
|
22
|
+
w-text={props.text}
|
|
23
|
+
w-checked={props.checked}
|
|
24
|
+
w-class={props.classNames}
|
|
25
|
+
w-orientation={props.orientation}
|
|
26
|
+
w-fixed-size={props.fixedSize}
|
|
27
|
+
w-padding={props.padding}
|
|
28
|
+
w-type={props.type}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function createSwitch(id: string, content: any, parent: Widget | null = null): Switch {
|
|
34
|
+
const dataText = content.getAttribute("w-text");
|
|
35
|
+
const dataChecked = content.getAttribute("w-checked");
|
|
36
|
+
|
|
37
|
+
let newSwitch = new Switch(id, dataText, parent);
|
|
38
|
+
|
|
39
|
+
if (dataChecked !== null) {
|
|
40
|
+
newSwitch.setState(true);
|
|
41
|
+
} else {
|
|
42
|
+
newSwitch.setState(false);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return newSwitch;
|
|
46
|
+
}
|
|
@@ -6,6 +6,7 @@ import { Toolbar } from "./toolbar.ui";
|
|
|
6
6
|
import { Label } from "./label.ui";
|
|
7
7
|
import { IconButton } from "./IconButton.ui";
|
|
8
8
|
import { Scroll } from "./scroll.ui";
|
|
9
|
+
import { WidgetProps, createWidget } from "./widget.builder";
|
|
9
10
|
|
|
10
11
|
const TAB_HEADER_SIZE = 40;
|
|
11
12
|
|
|
@@ -164,7 +165,7 @@ export class Tabs extends Widget {
|
|
|
164
165
|
}
|
|
165
166
|
} else {
|
|
166
167
|
if (this.verticalScrollbar) {
|
|
167
|
-
this.verticalScrollbar.
|
|
168
|
+
this.verticalScrollbar.free();
|
|
168
169
|
this.verticalScrollbar = null;
|
|
169
170
|
}
|
|
170
171
|
}
|
|
@@ -180,3 +181,87 @@ export class Tabs extends Widget {
|
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
183
|
}
|
|
184
|
+
|
|
185
|
+
export type TabItemType = "text" | "icon-tab";
|
|
186
|
+
|
|
187
|
+
export type WTabProps = Omit<WidgetProps, "orientation"> & {
|
|
188
|
+
orientation?: OrientationTypes;
|
|
189
|
+
children: any;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
export type WTabItemProps = {
|
|
193
|
+
title?: string | null;
|
|
194
|
+
icon?: string | null;
|
|
195
|
+
type?: TabItemType | null;
|
|
196
|
+
scrollable?: boolean | null;
|
|
197
|
+
children: any;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
export const WTab = (props: WTabProps) => {
|
|
201
|
+
return (
|
|
202
|
+
<div
|
|
203
|
+
id={props.id}
|
|
204
|
+
w-tab
|
|
205
|
+
w-class={props.classNames}
|
|
206
|
+
w-orientation={props.orientation}
|
|
207
|
+
w-fixed-size={props.fixedSize}
|
|
208
|
+
w-padding={props.padding}
|
|
209
|
+
w-type={props.type}
|
|
210
|
+
>
|
|
211
|
+
{props.children}
|
|
212
|
+
</div>
|
|
213
|
+
);
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
export const WTabItem = (props: WTabItemProps) => {
|
|
217
|
+
return (
|
|
218
|
+
<div w-tab-item w-title={props.title} w-icon={props.icon} w-type={props.type}>
|
|
219
|
+
{props.children}
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
export function createTab(id: string, content: any, parent: Widget | null = null): Tabs {
|
|
225
|
+
const dataOrientation = content.getAttribute("w-orientation");
|
|
226
|
+
const dataScrollable = content.getAttribute("w-scrollable") ? true : false;
|
|
227
|
+
|
|
228
|
+
let orientation: OrientationTypes = dataOrientation ? dataOrientation : "horizontal";
|
|
229
|
+
|
|
230
|
+
let newTab = new Tabs(id, parent, orientation);
|
|
231
|
+
|
|
232
|
+
content.childNodes.forEach((tabItem: HTMLElement, index: number) => {
|
|
233
|
+
if (tabItem.getAttribute("w-tab-item") !== null) {
|
|
234
|
+
const tabTitle = tabItem.getAttribute("w-title");
|
|
235
|
+
const tabIcon = tabItem.getAttribute("w-icon");
|
|
236
|
+
const tabType = tabItem.getAttribute("w-type") || "text";
|
|
237
|
+
|
|
238
|
+
if (!tabItem.firstChild) {
|
|
239
|
+
throw new Error("Tab Item must have a content");
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const widget = createWidget(tabItem.firstChild);
|
|
243
|
+
|
|
244
|
+
if (widget !== null) {
|
|
245
|
+
if (tabType === "text") {
|
|
246
|
+
newTab.addTab(
|
|
247
|
+
"Tab.Item." + index,
|
|
248
|
+
tabTitle || "Untitled",
|
|
249
|
+
widget,
|
|
250
|
+
dataScrollable
|
|
251
|
+
);
|
|
252
|
+
} else if (tabType === "icon-tab") {
|
|
253
|
+
newTab.addIconTab(
|
|
254
|
+
"Tab.Item." + index,
|
|
255
|
+
tabIcon || "home",
|
|
256
|
+
widget,
|
|
257
|
+
dataScrollable
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
newTab.setTab("Tab.Item.0");
|
|
265
|
+
|
|
266
|
+
return newTab;
|
|
267
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { WidgetProps } from "./widget.builder";
|
|
1
2
|
import "./styles/textbox.css";
|
|
2
|
-
import { Widget, WidgetTypes } from "./widget.ui";
|
|
3
|
+
import { Widget, WidgetTypes, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
3
4
|
|
|
4
5
|
export type InputTypes =
|
|
5
6
|
| "text"
|
|
@@ -139,3 +140,55 @@ export class Textbox extends Widget {
|
|
|
139
140
|
return this.inputType;
|
|
140
141
|
}
|
|
141
142
|
}
|
|
143
|
+
|
|
144
|
+
export type wTextBoxProps = WidgetProps & {
|
|
145
|
+
title: string;
|
|
146
|
+
inputType?: InputTypes | null;
|
|
147
|
+
width?: number | null;
|
|
148
|
+
height?: number | null;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const WTextbox = (props: wTextBoxProps) => {
|
|
152
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
153
|
+
|
|
154
|
+
return (
|
|
155
|
+
<input
|
|
156
|
+
id={props.id}
|
|
157
|
+
w-textbox
|
|
158
|
+
w-title={props.title}
|
|
159
|
+
w-input-type={props.inputType}
|
|
160
|
+
w-width={props.width}
|
|
161
|
+
w-height={props.height}
|
|
162
|
+
w-class={props.classNames}
|
|
163
|
+
w-orientation={props.orientation}
|
|
164
|
+
w-fixed-size={props.fixedSize}
|
|
165
|
+
w-padding={props.padding}
|
|
166
|
+
w-type={props.type}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export function createTextbox(id: string, content: any, parent: Widget | null = null): Textbox {
|
|
172
|
+
let newTextbox = new Textbox(id, parent);
|
|
173
|
+
|
|
174
|
+
const dataTitle = content.getAttribute("w-title");
|
|
175
|
+
const dataInputType = content.getAttribute("w-input-type");
|
|
176
|
+
const dataWidth = content.getAttribute("w-width");
|
|
177
|
+
const dataHeight = content.getAttribute("w-height");
|
|
178
|
+
|
|
179
|
+
if (dataInputType) {
|
|
180
|
+
newTextbox.setInputType(dataInputType);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (dataWidth) {
|
|
184
|
+
newTextbox.setInitialW(dataWidth);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (dataHeight) {
|
|
188
|
+
newTextbox.setInitialH(dataHeight);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
newTextbox.setTitle(dataTitle);
|
|
192
|
+
|
|
193
|
+
return newTextbox;
|
|
194
|
+
}
|
|
@@ -3,6 +3,7 @@ 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 } from "./widget.builder";
|
|
6
7
|
|
|
7
8
|
export type ToolbarVariants = "contained" | "outlined";
|
|
8
9
|
|
|
@@ -229,3 +230,40 @@ export class Toolbar extends Widget {
|
|
|
229
230
|
}
|
|
230
231
|
}
|
|
231
232
|
}
|
|
233
|
+
|
|
234
|
+
export type ToolbarProps = WidgetProps & {
|
|
235
|
+
children: any;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
export const WToolbar = (props: ToolbarProps) => {
|
|
239
|
+
return (
|
|
240
|
+
<div
|
|
241
|
+
w-toolbar
|
|
242
|
+
w-class={props.classNames}
|
|
243
|
+
w-orientation={props.orientation}
|
|
244
|
+
w-fixed-size={props.fixedSize}
|
|
245
|
+
w-padding={props.padding}
|
|
246
|
+
w-type={props.type}
|
|
247
|
+
>
|
|
248
|
+
{props.children}
|
|
249
|
+
</div>
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
export function createToolbar(id: string, content: any, parent: Widget | null = null): Toolbar {
|
|
254
|
+
const dataOrientation = content.getAttribute("w-orientation");
|
|
255
|
+
|
|
256
|
+
let orientation: OrientationTypes = dataOrientation ? dataOrientation : "horizontal";
|
|
257
|
+
|
|
258
|
+
let newToolbar = new Toolbar(id, parent, orientation);
|
|
259
|
+
|
|
260
|
+
content.childNodes.forEach((item: HTMLElement) => {
|
|
261
|
+
const widget = createWidget(item);
|
|
262
|
+
|
|
263
|
+
if (widget !== null) {
|
|
264
|
+
newToolbar.addItem(widget.id, widget);
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
return newToolbar;
|
|
269
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
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 { WidgetProps } from "./widget.builder";
|
|
5
6
|
|
|
6
7
|
export class ValueBar extends Widget {
|
|
7
8
|
orientation: OrientationTypes;
|
|
@@ -114,3 +115,38 @@ export class ValueBar extends Widget {
|
|
|
114
115
|
}
|
|
115
116
|
}
|
|
116
117
|
}
|
|
118
|
+
|
|
119
|
+
export type wValueBarProps = WidgetProps & {
|
|
120
|
+
value: number;
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const WValueBar = (props: wValueBarProps) => {
|
|
124
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div
|
|
128
|
+
id={props.id}
|
|
129
|
+
w-valuebar
|
|
130
|
+
w-value={props.value}
|
|
131
|
+
w-class={props.classNames}
|
|
132
|
+
w-orientation={props.orientation}
|
|
133
|
+
w-fixed-size={props.fixedSize}
|
|
134
|
+
w-padding={props.padding}
|
|
135
|
+
w-type={props.type}
|
|
136
|
+
></div>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export function createValueBar(id: string, content: any, parent: Widget | null = null): ValueBar {
|
|
141
|
+
const dataOrientation = content.getAttribute("w-orientation");
|
|
142
|
+
const dataValue = content.getAttribute("w-value");
|
|
143
|
+
let orientation: OrientationTypes = dataOrientation ? dataOrientation : "horizontal";
|
|
144
|
+
|
|
145
|
+
let newValueBar = new ValueBar(id, orientation, parent);
|
|
146
|
+
|
|
147
|
+
if (dataValue) {
|
|
148
|
+
newValueBar.setValue(parseInt(dataValue));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return newValueBar;
|
|
152
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Draggable } from "./draggable.ui";
|
|
2
2
|
import "./styles/vpanel.css";
|
|
3
|
+
import { WidgetProps, createWidget } from "./widget.builder";
|
|
3
4
|
import { Widget, WidgetAlignTypes, WidgetTypes } from "./widget.ui";
|
|
4
5
|
|
|
5
6
|
const VPANEL_HANDLER_SIZE = 4;
|
|
@@ -126,3 +127,39 @@ export class VPanel extends Widget {
|
|
|
126
127
|
this.handler.setX(this.getX(true));
|
|
127
128
|
}
|
|
128
129
|
}
|
|
130
|
+
|
|
131
|
+
export type WVPanelProps = WidgetProps & {
|
|
132
|
+
children: any;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export const WVPanel = (props: WVPanelProps) => {
|
|
136
|
+
return (
|
|
137
|
+
<div
|
|
138
|
+
w-vpanel
|
|
139
|
+
w-class={props.classNames}
|
|
140
|
+
w-fixed-size={props.fixedSize}
|
|
141
|
+
w-padding={props.padding}
|
|
142
|
+
w-type={props.type}
|
|
143
|
+
>
|
|
144
|
+
{props.children}
|
|
145
|
+
</div>
|
|
146
|
+
);
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export function createVPanel(id: string, content: any, parent: Widget | null = null): VPanel {
|
|
150
|
+
let newPanel = new VPanel(id, parent);
|
|
151
|
+
|
|
152
|
+
content.childNodes.forEach((item: HTMLElement, index: number) => {
|
|
153
|
+
const widget = createWidget(item);
|
|
154
|
+
|
|
155
|
+
if (widget !== null) {
|
|
156
|
+
if (index === 0) {
|
|
157
|
+
newPanel.setTop(widget, widget.getFixedSize());
|
|
158
|
+
} else if (index === 1) {
|
|
159
|
+
newPanel.setBottom(widget);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
return newPanel;
|
|
165
|
+
}
|