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,10 +1,9 @@
|
|
|
1
1
|
import Navigo from "navigo";
|
|
2
2
|
import { IScreen } from "./screen.interface";
|
|
3
|
-
import { IWidget } from "./widget.interface";
|
|
3
|
+
import { IWidget, WUICallback, WUIEvent } from "./widget.interface";
|
|
4
4
|
import { Dialog } from "../ui/dialog";
|
|
5
5
|
import { Seo } from "../core/seo";
|
|
6
6
|
import { ThemeManager } from "../core/themes.core";
|
|
7
|
-
import { Vector2D } from "src/types/vector2d.type";
|
|
8
7
|
|
|
9
8
|
export interface IScreenSize {
|
|
10
9
|
minWidth: number;
|
|
@@ -26,10 +25,18 @@ export interface IApplication {
|
|
|
26
25
|
confirmDialog: Dialog;
|
|
27
26
|
mediaQueries: Map<string, IScreenSize>;
|
|
28
27
|
|
|
28
|
+
subscribers: Map<string, WUICallback>;
|
|
29
|
+
|
|
29
30
|
theme: ThemeManager;
|
|
30
31
|
|
|
32
|
+
loadedModule: any;
|
|
33
|
+
|
|
31
34
|
attachWidget(guest: IWidget, host: IWidget): void;
|
|
32
35
|
|
|
36
|
+
subscribe: (cb: WUICallback) => void;
|
|
37
|
+
unsubscribe: (event: WUIEvent) => void;
|
|
38
|
+
run(eventId: WUIEvent): void;
|
|
39
|
+
|
|
33
40
|
addMediaQuery(
|
|
34
41
|
query: string,
|
|
35
42
|
minWidth: number,
|
|
@@ -42,7 +49,7 @@ export interface IApplication {
|
|
|
42
49
|
getRoot(): IWidget;
|
|
43
50
|
|
|
44
51
|
confirm(msg: string): void;
|
|
45
|
-
alert(msg: string): void;
|
|
52
|
+
alert(title: string, msg: string): void;
|
|
46
53
|
|
|
47
54
|
showLoading(): void;
|
|
48
55
|
hideLoading(): void;
|
|
@@ -2,6 +2,8 @@ import { WidgetAlignTypes, WidgetTypes } from "../ui/widget.ui";
|
|
|
2
2
|
import { Vector2D } from "../types/vector2d.type";
|
|
3
3
|
|
|
4
4
|
export type WUIEvent =
|
|
5
|
+
| "widget-load"
|
|
6
|
+
| "load"
|
|
5
7
|
| "click"
|
|
6
8
|
| "resize"
|
|
7
9
|
| "mousedown"
|
|
@@ -11,11 +13,13 @@ export type WUIEvent =
|
|
|
11
13
|
| "mouseleave"
|
|
12
14
|
| "option-clicked"
|
|
13
15
|
| "wheel"
|
|
16
|
+
| "render"
|
|
17
|
+
| "scroll"
|
|
14
18
|
| "drag";
|
|
15
19
|
|
|
16
20
|
export type WUICallback = {
|
|
17
21
|
event: WUIEvent;
|
|
18
|
-
then: (event: Event, wuie: IWidget) => void;
|
|
22
|
+
then: (event: Event, wuie: IWidget | null) => void;
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
export interface IWidget {
|
|
@@ -109,6 +113,7 @@ export interface IWidget {
|
|
|
109
113
|
getOverflow(): boolean;
|
|
110
114
|
|
|
111
115
|
addChild(child: IWidget | null): void;
|
|
116
|
+
populate(): void;
|
|
112
117
|
disableSelection(): void;
|
|
113
118
|
display(): void;
|
|
114
119
|
enableSelection(): void;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import "./styles/icon.css";
|
|
2
|
+
import { Colors } from "./colors.ui";
|
|
3
|
+
import { normalizeWidget, WidgetProps } from "./widget.builder";
|
|
4
|
+
import { connectWidgetCallback, getOnlyEventProps, Widget } from "./widget.ui";
|
|
5
|
+
import { UID } from "../core/uid";
|
|
6
|
+
|
|
7
|
+
export type IconVariants = "Filled" | "Outlined" | "Round" | "Sharp" | "Two Tone";
|
|
8
|
+
export type IconSizes = "small" | "medium" | "large" | "xlarge";
|
|
9
|
+
|
|
10
|
+
const iconSizesMap = {
|
|
11
|
+
small: "md-18",
|
|
12
|
+
medium: "md-24",
|
|
13
|
+
large: "md-36",
|
|
14
|
+
xlarge: "md-48",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const iconPixelSizesMap = {
|
|
18
|
+
small: "18px",
|
|
19
|
+
medium: "24px",
|
|
20
|
+
large: "36px",
|
|
21
|
+
xlarge: "48px",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export class Icon extends Widget {
|
|
25
|
+
variant: IconVariants;
|
|
26
|
+
color: Colors | null = null;
|
|
27
|
+
iconSize: IconSizes = "medium";
|
|
28
|
+
icon: string;
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
id: string,
|
|
32
|
+
icon: string,
|
|
33
|
+
variant: IconVariants = "Filled",
|
|
34
|
+
parent: Widget | null = null
|
|
35
|
+
) {
|
|
36
|
+
super(id, "span", parent);
|
|
37
|
+
|
|
38
|
+
this.variant = variant;
|
|
39
|
+
this.setColor("primary");
|
|
40
|
+
this.icon = icon;
|
|
41
|
+
|
|
42
|
+
this.setIconSize("medium");
|
|
43
|
+
|
|
44
|
+
if (this.variant === "Filled") {
|
|
45
|
+
this.addClass("material-icons");
|
|
46
|
+
} else {
|
|
47
|
+
this.addClass(
|
|
48
|
+
"material-icons-" + this.variant.toString().replace(" ", "-").toLowerCase()
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
this.setIcon(icon);
|
|
53
|
+
|
|
54
|
+
this.init();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public init(): void {
|
|
58
|
+
super.init();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public setIconSize(size: IconSizes = "medium"): void {
|
|
62
|
+
if (this.iconSize !== size) {
|
|
63
|
+
this.deleteClass(iconSizesMap[this.iconSize]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.iconSize = size;
|
|
67
|
+
this.addClass(iconSizesMap[size]);
|
|
68
|
+
|
|
69
|
+
this.body.style.fontSize = iconPixelSizesMap[size];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public setIcon(icon: string): void {
|
|
73
|
+
this.icon = icon;
|
|
74
|
+
this.body.innerHTML = icon;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
public setVariant(variant: IconVariants = "Filled"): void {
|
|
78
|
+
this.variant = variant;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public setColor(color: Colors = "primary"): void {
|
|
82
|
+
if (this.color !== color) {
|
|
83
|
+
this.deleteClass("WUI-icon-color-" + this.color);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.addClass("WUI-icon-color-" + color);
|
|
87
|
+
|
|
88
|
+
this.color = color;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public getVariant(): IconVariants {
|
|
92
|
+
return this.variant;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public getColor(): Colors {
|
|
96
|
+
return this.color || "primary";
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public getIcon(): string {
|
|
100
|
+
return this.icon;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
public getIconSize(): IconSizes {
|
|
104
|
+
return this.iconSize;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public getRequiredWidth(): number {
|
|
108
|
+
const sizeString = iconPixelSizesMap[this.iconSize];
|
|
109
|
+
const size = parseInt(sizeString.split("px")[0]);
|
|
110
|
+
return size;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type wIconProps = WidgetProps & {
|
|
115
|
+
icon: string;
|
|
116
|
+
variant?: IconVariants | null;
|
|
117
|
+
color?: Colors | null;
|
|
118
|
+
size?: IconSizes | null;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const WIcon = (props: wIconProps) => {
|
|
122
|
+
if (!props.id) {
|
|
123
|
+
props.id = "Icon." + UID();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
127
|
+
|
|
128
|
+
return normalizeWidget(
|
|
129
|
+
<div
|
|
130
|
+
id={props.id}
|
|
131
|
+
w-icon
|
|
132
|
+
w-icon-name={props.icon}
|
|
133
|
+
w-variant={props.variant}
|
|
134
|
+
w-color={props.color}
|
|
135
|
+
w-size={props.size}
|
|
136
|
+
></div>,
|
|
137
|
+
props
|
|
138
|
+
);
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export function createIcon(id: string, content: any, parent: Widget | null = null): Icon {
|
|
142
|
+
const dataIcon = content.getAttribute("w-icon-name");
|
|
143
|
+
const dataVariant = content.getAttribute("w-variant") || "Filled";
|
|
144
|
+
const dataColor = content.getAttribute("w-color") || "primary";
|
|
145
|
+
const dataSize = content.getAttribute("w-size") || "medium";
|
|
146
|
+
|
|
147
|
+
let newIcon = new Icon(id, dataIcon, dataVariant, parent);
|
|
148
|
+
|
|
149
|
+
if (dataColor) {
|
|
150
|
+
newIcon.setColor(dataColor);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (dataSize) {
|
|
154
|
+
newIcon.setIconSize(dataSize);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return newIcon;
|
|
158
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import "./styles/button.css";
|
|
2
|
+
import {
|
|
3
|
+
Widget,
|
|
4
|
+
WidgetAlignTypes,
|
|
5
|
+
WidgetTypes,
|
|
6
|
+
connectWidgetCallback,
|
|
7
|
+
getOnlyEventProps,
|
|
8
|
+
} from "./widget.ui";
|
|
9
|
+
import { Button, wButtonProps } from "./button.ui";
|
|
10
|
+
import { Icon } from "./Icon.ui";
|
|
11
|
+
import { Label } from "./label.ui";
|
|
12
|
+
import { normalizeWidget } from "./widget.builder";
|
|
13
|
+
import { UID } from "../core/uid";
|
|
14
|
+
|
|
15
|
+
export class IconButton extends Button {
|
|
16
|
+
icon: Icon;
|
|
17
|
+
label: Label;
|
|
18
|
+
|
|
19
|
+
showIcon: boolean;
|
|
20
|
+
showText: boolean;
|
|
21
|
+
centerX: boolean;
|
|
22
|
+
|
|
23
|
+
constructor(id: string, icon: string = "dark_mode", parent: Widget | null = null) {
|
|
24
|
+
super(id, parent);
|
|
25
|
+
|
|
26
|
+
this.centerX = false;
|
|
27
|
+
|
|
28
|
+
this.setAlign(WidgetAlignTypes.HORIZONTAL);
|
|
29
|
+
this.icon = new Icon(id + ".icon", icon, undefined, this);
|
|
30
|
+
this.label = new Label(id + ".label", undefined, this);
|
|
31
|
+
|
|
32
|
+
this.showIcon = true;
|
|
33
|
+
this.showText = true;
|
|
34
|
+
|
|
35
|
+
this.init();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected updateRequiredWidth(): void {
|
|
39
|
+
if (!this.label) return;
|
|
40
|
+
if (!this.icon) return;
|
|
41
|
+
|
|
42
|
+
const labelWidth = this.label.getRequiredWidth();
|
|
43
|
+
const iconWith = this.icon.getRequiredWidth();
|
|
44
|
+
|
|
45
|
+
this.requiredWidth = labelWidth + iconWith + 70;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public displayIcon(): void {
|
|
49
|
+
this.showIcon = true;
|
|
50
|
+
this.icon.setVisible(true);
|
|
51
|
+
this.render();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public hideIcon(): void {
|
|
55
|
+
this.showIcon = false;
|
|
56
|
+
this.icon.setVisible(false);
|
|
57
|
+
this.render();
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public displayText(): void {
|
|
61
|
+
this.showText = true;
|
|
62
|
+
this.label.setVisible(true);
|
|
63
|
+
this.render();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public hideText(): void {
|
|
67
|
+
this.showText = false;
|
|
68
|
+
this.label.setVisible(false);
|
|
69
|
+
this.render();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public init(): void {
|
|
73
|
+
super.init();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public onlyIcon(): boolean {
|
|
77
|
+
if (this.label.getText().length > 0) return false;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
public render(): void {
|
|
82
|
+
super.render();
|
|
83
|
+
|
|
84
|
+
const labelWidth = this.label.getRequiredWidth();
|
|
85
|
+
const iconWidth = this.icon.getRequiredWidth();
|
|
86
|
+
const padding = 5;
|
|
87
|
+
|
|
88
|
+
if (this.onlyIcon()) {
|
|
89
|
+
this.icon.getBody().style.position = "absolute";
|
|
90
|
+
|
|
91
|
+
const startX = this.getBody().clientWidth / 2 - iconWidth / 2;
|
|
92
|
+
const startY = this.getH() / 2 - this.icon.getH() / 2;
|
|
93
|
+
|
|
94
|
+
this.icon.setX(startX);
|
|
95
|
+
this.icon.setY(startY);
|
|
96
|
+
} else {
|
|
97
|
+
this.label.getBody().style.position = "absolute";
|
|
98
|
+
this.icon.getBody().style.position = "absolute";
|
|
99
|
+
|
|
100
|
+
const availableWidth = this.getW() - padding * 5; //Doble padding a la derecha e izquierda y uno de separacion entre label y icon.
|
|
101
|
+
const requiredWidth = labelWidth + iconWidth + padding * 5;
|
|
102
|
+
|
|
103
|
+
const labelHeight = this.label.getBody().clientHeight;
|
|
104
|
+
|
|
105
|
+
let startX = availableWidth / 2 - (iconWidth + padding + labelWidth) / 2;
|
|
106
|
+
|
|
107
|
+
if (availableWidth < requiredWidth) {
|
|
108
|
+
startX = padding * 2;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (!this.centerX) {
|
|
112
|
+
startX = padding * 2;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const startLabelX = startX + iconWidth + padding;
|
|
116
|
+
|
|
117
|
+
let startY = this.getH() / 2 - iconWidth / 2;
|
|
118
|
+
let startLabelY = this.getH() / 2 - labelHeight / 2;
|
|
119
|
+
|
|
120
|
+
if (this.getType() !== WidgetTypes.FILL) {
|
|
121
|
+
startY = this.getH() / 2 - this.icon.getH() / 2;
|
|
122
|
+
this.label.getBody().style.lineHeight = this.getH() + "px";
|
|
123
|
+
startLabelY = this.getH() / 2 - this.label.getH() / 2;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (startX < 0 || startY < 0) {
|
|
127
|
+
setTimeout(() => {
|
|
128
|
+
this.render();
|
|
129
|
+
}, 500);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.icon.setX(startX);
|
|
134
|
+
this.label.setX(startLabelX + padding);
|
|
135
|
+
|
|
136
|
+
this.icon.setY(startY);
|
|
137
|
+
this.label.setY(startLabelY);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
public setText(text: string): void {
|
|
142
|
+
//super.setText(text);
|
|
143
|
+
this.label.setText(text);
|
|
144
|
+
this.updateRequiredWidth();
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public setIcon(icon: string): void {
|
|
148
|
+
this.icon.setIcon(icon);
|
|
149
|
+
this.updateRequiredWidth();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
public setCenterX(centerX: boolean): void {
|
|
153
|
+
this.centerX = centerX;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export type wIconButtonProps = Omit<wButtonProps, "text"> & {
|
|
158
|
+
icon?: string | null;
|
|
159
|
+
text?: string | null;
|
|
160
|
+
onlyIcon?: boolean | null;
|
|
161
|
+
centerX?: boolean | null;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export const WIconButton = (props: wIconButtonProps) => {
|
|
165
|
+
if (!props.id) {
|
|
166
|
+
props.id = "IconButton." + UID();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
170
|
+
|
|
171
|
+
return normalizeWidget(
|
|
172
|
+
<button
|
|
173
|
+
id={props.id}
|
|
174
|
+
w-icon-button
|
|
175
|
+
w-icon={props.icon}
|
|
176
|
+
w-text={props.text}
|
|
177
|
+
w-only-icon={props.onlyIcon}
|
|
178
|
+
w-variant={props.variant}
|
|
179
|
+
w-color={props.color}
|
|
180
|
+
w-width={props.width}
|
|
181
|
+
w-height={props.height}
|
|
182
|
+
w-center-x={props.centerX}
|
|
183
|
+
/>,
|
|
184
|
+
props
|
|
185
|
+
);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
export function createIconButton(
|
|
189
|
+
id: string,
|
|
190
|
+
content: any,
|
|
191
|
+
parent: Widget | null = null
|
|
192
|
+
): IconButton {
|
|
193
|
+
const dataIcon = content.getAttribute("w-icon");
|
|
194
|
+
const dataText = content.getAttribute("w-text");
|
|
195
|
+
const dataVariant = content.getAttribute("w-variant");
|
|
196
|
+
const dataColor = content.getAttribute("w-color");
|
|
197
|
+
const dataWidth = content.getAttribute("w-width");
|
|
198
|
+
const dataHeight = content.getAttribute("w-height");
|
|
199
|
+
const dataOnlyIcon = content.getAttribute("w-only-icon");
|
|
200
|
+
const dataCenterX = content.getAttribute("w-center-x");
|
|
201
|
+
|
|
202
|
+
let newIconButton = new IconButton(id, dataIcon, parent);
|
|
203
|
+
|
|
204
|
+
if (dataText) {
|
|
205
|
+
newIconButton.setText(dataText);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (dataVariant) {
|
|
209
|
+
newIconButton.setVariant(dataVariant);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (dataColor) {
|
|
213
|
+
newIconButton.setColor(dataColor);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (dataWidth) {
|
|
217
|
+
newIconButton.setInitialW(dataWidth);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (dataHeight) {
|
|
221
|
+
newIconButton.setInitialH(dataHeight);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (dataOnlyIcon) {
|
|
225
|
+
newIconButton.onlyIcon();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (dataCenterX) {
|
|
229
|
+
newIconButton.setCenterX(true);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return newIconButton;
|
|
233
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { normalizeWidget, 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";
|
|
4
|
+
import { UID } from "../core/uid";
|
|
3
5
|
|
|
4
6
|
export type InputTypes =
|
|
5
7
|
| "text"
|
|
@@ -52,7 +54,7 @@ export class Textbox extends Widget {
|
|
|
52
54
|
this.getBody().style.overflow = "";
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
getValue(): string {
|
|
57
|
+
public getValue(): string {
|
|
56
58
|
const value = (this.input.getBody() as HTMLInputElement).value;
|
|
57
59
|
|
|
58
60
|
if (value) return value;
|
|
@@ -60,7 +62,7 @@ export class Textbox extends Widget {
|
|
|
60
62
|
return "";
|
|
61
63
|
}
|
|
62
64
|
|
|
63
|
-
setValue(value: string): void {
|
|
65
|
+
public setValue(value: string): void {
|
|
64
66
|
(this.input.getBody() as HTMLInputElement).value = value;
|
|
65
67
|
this.positionLabel();
|
|
66
68
|
}
|
|
@@ -113,17 +115,17 @@ export class Textbox extends Widget {
|
|
|
113
115
|
super.render();
|
|
114
116
|
}
|
|
115
117
|
|
|
116
|
-
setTitle(title: string): void {
|
|
118
|
+
public setTitle(title: string): void {
|
|
117
119
|
this.title = title;
|
|
118
120
|
this.label.getBody().innerHTML = this.title;
|
|
119
121
|
}
|
|
120
122
|
|
|
121
|
-
setInputType(type: InputTypes): void {
|
|
123
|
+
public setInputType(type: InputTypes): void {
|
|
122
124
|
this.inputType = type;
|
|
123
125
|
this.input.getBody().setAttribute("type", this.inputType);
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
getTitle(): string {
|
|
128
|
+
public getTitle(): string {
|
|
127
129
|
return this.title;
|
|
128
130
|
}
|
|
129
131
|
|
|
@@ -131,11 +133,70 @@ export class Textbox extends Widget {
|
|
|
131
133
|
return this.label;
|
|
132
134
|
}*/
|
|
133
135
|
|
|
134
|
-
getInput(): Widget {
|
|
136
|
+
public getInput(): Widget {
|
|
135
137
|
return this.input;
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
getInputType(): string {
|
|
140
|
+
public getInputType(): string {
|
|
139
141
|
return this.inputType;
|
|
140
142
|
}
|
|
141
143
|
}
|
|
144
|
+
|
|
145
|
+
export type wTextBoxProps = WidgetProps & {
|
|
146
|
+
title: string;
|
|
147
|
+
inputType?: InputTypes | null;
|
|
148
|
+
width?: number | null;
|
|
149
|
+
height?: number | null;
|
|
150
|
+
value?: string | null;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const WTextbox = (props: wTextBoxProps) => {
|
|
154
|
+
if (!props.id) {
|
|
155
|
+
props.id = "Textbox." + UID();
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
159
|
+
|
|
160
|
+
return normalizeWidget(
|
|
161
|
+
<input
|
|
162
|
+
id={props.id}
|
|
163
|
+
w-textbox
|
|
164
|
+
w-title={props.title}
|
|
165
|
+
w-value={props.value}
|
|
166
|
+
w-input-type={props.inputType}
|
|
167
|
+
w-width={props.width}
|
|
168
|
+
w-height={props.height}
|
|
169
|
+
/>,
|
|
170
|
+
props
|
|
171
|
+
);
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export function createTextbox(id: string, content: any, parent: Widget | null = null): Textbox {
|
|
175
|
+
let newTextbox = new Textbox(id, parent);
|
|
176
|
+
|
|
177
|
+
const dataTitle = content.getAttribute("w-title");
|
|
178
|
+
const dataValue = content.getAttribute("w-value");
|
|
179
|
+
const dataInputType = content.getAttribute("w-input-type");
|
|
180
|
+
const dataWidth = content.getAttribute("w-width");
|
|
181
|
+
const dataHeight = content.getAttribute("w-height");
|
|
182
|
+
|
|
183
|
+
if (dataInputType) {
|
|
184
|
+
newTextbox.setInputType(dataInputType);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (dataWidth) {
|
|
188
|
+
newTextbox.setInitialW(dataWidth);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
if (dataHeight) {
|
|
192
|
+
newTextbox.setInitialH(dataHeight);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
if (dataValue) {
|
|
196
|
+
newTextbox.setValue(dataValue);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
newTextbox.setTitle(dataTitle);
|
|
200
|
+
|
|
201
|
+
return newTextbox;
|
|
202
|
+
}
|