cedro 0.1.9 → 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 -60
- package/src/core/application.core.tsx +110 -11
- package/src/core/themes.core.ts +160 -1
- package/src/core/uid.ts +3 -3
- package/src/interfaces/application.interface.ts +3 -2
- package/src/interfaces/widget.interface.ts +3 -0
- package/src/types/select.item.type.ts +11 -0
- package/src/ui/Icon.ui.tsx +158 -0
- package/src/ui/IconButton.ui.tsx +51 -9
- package/src/ui/{textbox.ui.tsx → Textbox.ui.tsx} +23 -15
- package/src/ui/accordion.ui.tsx +152 -0
- package/src/ui/button.ui.tsx +56 -14
- 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 +9 -13
- package/src/ui/container.ui.tsx +141 -76
- package/src/ui/datagrid.ui.tsx +518 -0
- package/src/ui/dialog.tsx +143 -56
- package/src/ui/hpanel.ui.tsx +37 -11
- package/src/ui/iconButtonMenu.ui.tsx +176 -0
- package/src/ui/image.ui.tsx +123 -112
- package/src/ui/index.ts +8 -8
- package/src/ui/label.ui.tsx +61 -3
- package/src/ui/loading.ui.ts +10 -10
- package/src/ui/menu.ui.ts +2 -2
- package/src/ui/progressbar.ui.tsx +9 -8
- package/src/ui/{radiobutton.tsx → radiobutton.ui.tsx} +9 -13
- 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/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 +2 -1
- 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/switch.ui.tsx +9 -13
- package/src/ui/tabs.ui.tsx +43 -22
- package/src/ui/textarea.ui.tsx +48 -0
- package/src/ui/toolbar.ui.tsx +17 -12
- package/src/ui/valuebar.ui.tsx +11 -13
- package/src/ui/vpanel.ui.tsx +19 -13
- package/src/ui/widget.builder.ts +243 -159
- package/src/ui/widget.collection.ts +24 -2
- package/src/ui/widget.ui.ts +79 -19
- package/src/ui/Icon.ui.ts +0 -64
- package/src/ui/accordion.ui.ts +0 -71
- package/src/ui/buttonColor.ui.ts +0 -24
- package/src/ui/buttonmenu.ui.ts +0 -59
- package/src/ui/datagrid.ui.ts +0 -231
- package/src/ui/iconButtonMenu.ui.ts +0 -59
- package/src/ui/select.ui.ts +0 -73
- package/src/ui/textarea.ui.ts +0 -20
- /package/src/ui/{toggle.ui.ts → toggle.ui.tsx} +0 -0
package/src/ui/button.ui.tsx
CHANGED
|
@@ -2,8 +2,9 @@ import "./styles/button.css";
|
|
|
2
2
|
import "./styles/stackbutton.css";
|
|
3
3
|
import "./styles/vstackbutton.css";
|
|
4
4
|
import { Colors } from "./colors.ui";
|
|
5
|
-
import { Widget, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
6
|
-
import { WidgetProps } from "./widget.builder";
|
|
5
|
+
import { Widget, WidgetTypes, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
6
|
+
import { normalizeWidget, WidgetProps } from "./widget.builder";
|
|
7
|
+
import { UID } from "../core/uid";
|
|
7
8
|
|
|
8
9
|
export type ButonVariants =
|
|
9
10
|
| "contained"
|
|
@@ -27,14 +28,19 @@ export class Button extends Widget {
|
|
|
27
28
|
variant: ButonVariants;
|
|
28
29
|
color: Colors;
|
|
29
30
|
fullWidth: boolean;
|
|
31
|
+
minWidth: boolean;
|
|
30
32
|
size: ButonSizes;
|
|
31
33
|
href: string;
|
|
32
34
|
text: string;
|
|
35
|
+
requiredWidth: number;
|
|
33
36
|
|
|
34
37
|
constructor(id: string, parent: Widget | null = null) {
|
|
35
38
|
super(id, "button", parent);
|
|
36
39
|
|
|
40
|
+
this.requiredWidth = -1;
|
|
41
|
+
|
|
37
42
|
this.fullWidth = false;
|
|
43
|
+
this.minWidth = false;
|
|
38
44
|
//this.setType(WidgetTypes.CUSTOM);
|
|
39
45
|
this.variant = "text";
|
|
40
46
|
this.color = "primary"; //primary";
|
|
@@ -51,32 +57,64 @@ export class Button extends Widget {
|
|
|
51
57
|
this.deleteAllClasses();
|
|
52
58
|
this.addClass(`WUIButton-${this.variant}`);
|
|
53
59
|
this.addClass(`WUIButton-${this.variant}-color-${this.color}`);
|
|
60
|
+
if (this.type === WidgetTypes.FILL) {
|
|
61
|
+
this.addClass("WUINonFreePosition");
|
|
62
|
+
} else if (this.type === WidgetTypes.CUSTOM) {
|
|
63
|
+
this.addClass("WUINonFreePosition");
|
|
64
|
+
} else if (this.type === WidgetTypes.FREE) {
|
|
65
|
+
this.addClass("WUIFixPosition");
|
|
66
|
+
}
|
|
67
|
+
this.updateRequiredWidth();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
protected updateRequiredWidth(): void {
|
|
71
|
+
const div = document.createElement("div");
|
|
72
|
+
div.id = this.id + ".requiredWidth";
|
|
73
|
+
div.innerHTML = this.text;
|
|
74
|
+
div.classList.add(`WUIButton-${this.variant}`);
|
|
75
|
+
div.classList.add(`WUIButton-${this.variant}-color-${this.color}`);
|
|
76
|
+
div.style.position = "absolute";
|
|
77
|
+
div.style.overflow = "hidden";
|
|
78
|
+
document.body.appendChild(div);
|
|
79
|
+
this.requiredWidth = div.clientWidth;
|
|
80
|
+
div.parentNode?.removeChild(div);
|
|
54
81
|
}
|
|
55
82
|
|
|
56
83
|
public init(): void {
|
|
57
84
|
super.init();
|
|
58
85
|
}
|
|
59
86
|
|
|
60
|
-
setText(text: string): void {
|
|
87
|
+
public setText(text: string): void {
|
|
61
88
|
this.text = text;
|
|
62
89
|
this.body.innerHTML = text;
|
|
90
|
+
this.updateRequiredWidth();
|
|
63
91
|
}
|
|
64
92
|
|
|
65
|
-
setVariant(variant: ButonVariants = "contained"): void {
|
|
93
|
+
public setVariant(variant: ButonVariants = "contained"): void {
|
|
66
94
|
this.variant = variant;
|
|
67
95
|
this.configureStyles();
|
|
68
96
|
}
|
|
69
97
|
|
|
70
|
-
setColor(color: Colors = "primary"): void {
|
|
98
|
+
public setColor(color: Colors = "primary"): void {
|
|
71
99
|
this.color = color;
|
|
72
100
|
this.configureStyles();
|
|
73
101
|
}
|
|
74
102
|
|
|
75
|
-
setFullWidth(fullWidth: boolean = false): void {
|
|
103
|
+
public setFullWidth(fullWidth: boolean = false): void {
|
|
76
104
|
this.fullWidth = fullWidth;
|
|
77
105
|
}
|
|
78
106
|
|
|
79
|
-
|
|
107
|
+
public setMinWidth(minWidth: boolean = false): void {
|
|
108
|
+
this.minWidth = minWidth;
|
|
109
|
+
if (this.minWidth) {
|
|
110
|
+
if (this.requiredWidth > 0) {
|
|
111
|
+
console.log("cambiando tamano:", this.requiredWidth, " id:", this.id);
|
|
112
|
+
this.setW(this.requiredWidth);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public setSize(size: ButonSizes = "medium"): void {
|
|
80
118
|
this.size = size;
|
|
81
119
|
}
|
|
82
120
|
|
|
@@ -103,6 +141,10 @@ export class Button extends Widget {
|
|
|
103
141
|
getText(): string {
|
|
104
142
|
return this.text;
|
|
105
143
|
}
|
|
144
|
+
|
|
145
|
+
public getRequiredWidth(): number {
|
|
146
|
+
return this.requiredWidth;
|
|
147
|
+
}
|
|
106
148
|
}
|
|
107
149
|
|
|
108
150
|
export type wButtonProps = WidgetProps & {
|
|
@@ -114,9 +156,13 @@ export type wButtonProps = WidgetProps & {
|
|
|
114
156
|
};
|
|
115
157
|
|
|
116
158
|
export const WButton = (props: wButtonProps) => {
|
|
159
|
+
if (!props.id) {
|
|
160
|
+
props.id = "button." + UID();
|
|
161
|
+
}
|
|
162
|
+
|
|
117
163
|
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
118
164
|
|
|
119
|
-
return (
|
|
165
|
+
return normalizeWidget(
|
|
120
166
|
<button
|
|
121
167
|
id={props.id}
|
|
122
168
|
w-button
|
|
@@ -125,12 +171,8 @@ export const WButton = (props: wButtonProps) => {
|
|
|
125
171
|
w-color={props.color}
|
|
126
172
|
w-width={props.width}
|
|
127
173
|
w-height={props.height}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
w-fixed-size={props.fixedSize}
|
|
131
|
-
w-padding={props.padding}
|
|
132
|
-
w-type={props.type}
|
|
133
|
-
/>
|
|
174
|
+
/>,
|
|
175
|
+
props
|
|
134
176
|
);
|
|
135
177
|
};
|
|
136
178
|
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import "./styles/buttoncolor.css";
|
|
2
|
+
import { Button, wButtonProps } from "./button.ui";
|
|
3
|
+
import { connectWidgetCallback, getOnlyEventProps, Widget } from "./widget.ui";
|
|
4
|
+
import { normalizeWidget } from "./widget.builder";
|
|
5
|
+
import { UID } from "../core/uid";
|
|
6
|
+
|
|
7
|
+
export class ButtonColor extends Button {
|
|
8
|
+
inputColor: Widget;
|
|
9
|
+
constructor(id: string, parent: Widget | null = null) {
|
|
10
|
+
super(id, parent);
|
|
11
|
+
|
|
12
|
+
this.inputColor = new Widget(id + ".inputColor", "input", this);
|
|
13
|
+
this.inputColor.getBody().setAttribute("type", "color");
|
|
14
|
+
this.inputColor.addClass("WUIButtonColorInput");
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public setValue(value: string): void {
|
|
18
|
+
this.inputColor.getBody().setAttribute("value", value);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getValue(): string {
|
|
22
|
+
const value = this.inputColor.getBody().getAttribute("value");
|
|
23
|
+
|
|
24
|
+
return value ? value : "";
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type wButtonColorProps = Omit<wButtonProps, "text"> & {
|
|
29
|
+
value: string;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const WButtonColor = (props: wButtonColorProps) => {
|
|
33
|
+
if (!props.id) {
|
|
34
|
+
props.id = "ButtonColor." + UID();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
38
|
+
|
|
39
|
+
return normalizeWidget(
|
|
40
|
+
<button
|
|
41
|
+
id={props.id}
|
|
42
|
+
w-button-color
|
|
43
|
+
w-value={props.value}
|
|
44
|
+
w-variant={props.variant}
|
|
45
|
+
w-color={props.color}
|
|
46
|
+
w-width={props.width}
|
|
47
|
+
w-height={props.height}
|
|
48
|
+
/>,
|
|
49
|
+
props
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export function createButtonColor(
|
|
54
|
+
id: string,
|
|
55
|
+
content: any,
|
|
56
|
+
parent: Widget | null = null
|
|
57
|
+
): ButtonColor {
|
|
58
|
+
let newButton = new ButtonColor(id, parent);
|
|
59
|
+
|
|
60
|
+
const dataValue = content.getAttribute("w-value");
|
|
61
|
+
const dataVariant = content.getAttribute("w-variant");
|
|
62
|
+
const dataColor = content.getAttribute("w-color");
|
|
63
|
+
const dataWidth = content.getAttribute("w-width");
|
|
64
|
+
const dataHeight = content.getAttribute("w-height");
|
|
65
|
+
|
|
66
|
+
if (dataValue) {
|
|
67
|
+
newButton.setValue(dataValue);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (dataVariant) {
|
|
71
|
+
newButton.setVariant(dataVariant);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (dataColor) {
|
|
75
|
+
newButton.setColor(dataColor);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (dataWidth) {
|
|
79
|
+
newButton.setInitialW(dataWidth);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (dataHeight) {
|
|
83
|
+
newButton.setInitialH(dataHeight);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return newButton;
|
|
87
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { UID } from "../core/uid";
|
|
2
|
+
import { SelectItem } from "../types/select.item.type";
|
|
3
|
+
import { Button, wButtonProps } from "./button.ui";
|
|
4
|
+
import { Menu } from "./menu.ui";
|
|
5
|
+
import { normalizeWidget, WidgetProps } from "./widget.builder";
|
|
6
|
+
import { Widget } from "./widget.ui";
|
|
7
|
+
|
|
8
|
+
export class ButtonMenu extends Button {
|
|
9
|
+
menu: Menu;
|
|
10
|
+
items: Array<SelectItem>;
|
|
11
|
+
selectedItem: SelectItem | null;
|
|
12
|
+
|
|
13
|
+
public constructor(id: string) {
|
|
14
|
+
super(id);
|
|
15
|
+
|
|
16
|
+
this.menu = new Menu(this.id + ".menu", this.id, null);
|
|
17
|
+
|
|
18
|
+
this.items = new Array<SelectItem>();
|
|
19
|
+
this.selectedItem = null;
|
|
20
|
+
|
|
21
|
+
this.subscribe({
|
|
22
|
+
event: "click",
|
|
23
|
+
then: () => {
|
|
24
|
+
this.menu.clearOptions();
|
|
25
|
+
this.items.forEach((item) => {
|
|
26
|
+
this.menu.addOption(item.id, item.icon, item.label);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.menu.wakeUp();
|
|
30
|
+
|
|
31
|
+
if (this.getW() > this.menu.getW()) {
|
|
32
|
+
this.menu.setW(this.getBody().clientWidth);
|
|
33
|
+
console.log("cambiando ancho...");
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/*this.menu.subscribe({
|
|
39
|
+
event: "option-clicked",
|
|
40
|
+
then: (_e, clickedOption) => {
|
|
41
|
+
const option = clickedOption as IconButton;
|
|
42
|
+
|
|
43
|
+
const fintOption = this.items.find((item) => item.id === option.id);
|
|
44
|
+
|
|
45
|
+
if (fintOption) {
|
|
46
|
+
this.selectedItem = fintOption;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const selectedText = this.selectedItem?.label;
|
|
50
|
+
if (selectedText) {
|
|
51
|
+
this.setText(selectedText);
|
|
52
|
+
} else {
|
|
53
|
+
this.setText("");
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
});*/
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public addItem(id: string, label: string, icon: string): void {
|
|
60
|
+
this.items.push(new SelectItem(id, label, icon));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type WButtonMenuProps = WidgetProps &
|
|
65
|
+
wButtonProps & {
|
|
66
|
+
children: any;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type WButtonMenuItemProps = {
|
|
70
|
+
id: string;
|
|
71
|
+
label?: string | null;
|
|
72
|
+
icon?: string | null;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export const WButtonMenu = (props: WButtonMenuProps) => {
|
|
76
|
+
if (!props.id) {
|
|
77
|
+
props.id = "ButtonMenu." + UID();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return normalizeWidget(
|
|
81
|
+
<div
|
|
82
|
+
id={props.id}
|
|
83
|
+
w-button-menu
|
|
84
|
+
w-text={props.text}
|
|
85
|
+
w-variant={props.variant}
|
|
86
|
+
w-color={props.color}
|
|
87
|
+
>
|
|
88
|
+
{props.children}
|
|
89
|
+
</div>,
|
|
90
|
+
props
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export const WButtonMenuItem = (props: WButtonMenuItemProps) => {
|
|
95
|
+
return <div w-button-menu-item id={props.id} w-label={props.label} w-icon={props.icon}></div>;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export function createButtonMenu(
|
|
99
|
+
id: string,
|
|
100
|
+
content: any,
|
|
101
|
+
_parent: Widget | null = null
|
|
102
|
+
): ButtonMenu {
|
|
103
|
+
let newButtonMenu = new ButtonMenu(id);
|
|
104
|
+
|
|
105
|
+
const btnText = content.getAttribute("w-text");
|
|
106
|
+
const btnColor = content.getAttribute("w-color");
|
|
107
|
+
const btnVariant = content.getAttribute("w-variant");
|
|
108
|
+
|
|
109
|
+
if (btnText) {
|
|
110
|
+
newButtonMenu.setText(btnText);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (btnColor) {
|
|
114
|
+
newButtonMenu.setColor(btnColor);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (btnVariant) {
|
|
118
|
+
newButtonMenu.setVariant(btnVariant);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
content.childNodes.forEach((menuItem: HTMLElement, index: number) => {
|
|
122
|
+
if (menuItem.getAttribute("w-button-menu-item") !== null) {
|
|
123
|
+
const itemId = menuItem.getAttribute("id");
|
|
124
|
+
const itemLabel = menuItem.getAttribute("w-label");
|
|
125
|
+
const itemIcon = menuItem.getAttribute("w-icon");
|
|
126
|
+
|
|
127
|
+
if (itemId !== null) {
|
|
128
|
+
newButtonMenu.addItem(itemId, itemLabel || "Unnamed" + index, itemIcon || "");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
return newButtonMenu;
|
|
134
|
+
}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { OrientationTypes } from "src/types/orientation.type";
|
|
2
2
|
import { IconButton } from "./IconButton.ui";
|
|
3
3
|
import { ButonVariants, Button } from "./button.ui";
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
connectWidgetCallback,
|
|
6
|
+
getOnlyEventProps,
|
|
7
|
+
Widget,
|
|
8
|
+
WidgetAlignTypes,
|
|
9
|
+
WidgetTypes,
|
|
10
|
+
} from "./widget.ui";
|
|
11
|
+
import { createWidget, normalizeWidget, WidgetProps } from "./widget.builder";
|
|
12
|
+
import { UID } from "../core/uid";
|
|
5
13
|
|
|
6
14
|
export class ButtonStack extends Widget {
|
|
7
15
|
orientation: OrientationTypes;
|
|
8
16
|
buttons: Map<string, Button | IconButton>;
|
|
9
17
|
activeButton: string | null;
|
|
18
|
+
centeredButtons: boolean;
|
|
10
19
|
constructor(
|
|
11
20
|
id: string,
|
|
12
21
|
orientation: OrientationTypes = "horizontal",
|
|
@@ -14,6 +23,8 @@ export class ButtonStack extends Widget {
|
|
|
14
23
|
) {
|
|
15
24
|
super(id, "div", parent);
|
|
16
25
|
|
|
26
|
+
this.centeredButtons = false;
|
|
27
|
+
|
|
17
28
|
this.orientation = orientation;
|
|
18
29
|
|
|
19
30
|
if (this.orientation === "horizontal") {
|
|
@@ -74,6 +85,9 @@ export class ButtonStack extends Widget {
|
|
|
74
85
|
|
|
75
86
|
public addButton(button: Button | IconButton): void {
|
|
76
87
|
this.buttons.set(button.id, button);
|
|
88
|
+
if (button instanceof IconButton && this.centeredButtons) {
|
|
89
|
+
(button as IconButton).setCenterX(true);
|
|
90
|
+
}
|
|
77
91
|
button.setType(WidgetTypes.FILL);
|
|
78
92
|
button.subscribe({ event: "click", then: () => this.setActive(button.id) });
|
|
79
93
|
this.addChild(button);
|
|
@@ -91,4 +105,56 @@ export class ButtonStack extends Widget {
|
|
|
91
105
|
private thereAreMoreThanTwoButtons(): boolean {
|
|
92
106
|
return this.buttons.size > 2;
|
|
93
107
|
}
|
|
108
|
+
|
|
109
|
+
public setCenteredButtons(centeredButtons: boolean): void {
|
|
110
|
+
this.centeredButtons = centeredButtons;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export type WButtonStackProps = WidgetProps & {
|
|
115
|
+
centerX?: boolean | null;
|
|
116
|
+
children: any;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const WButtonStack = (props: WButtonStackProps) => {
|
|
120
|
+
if (!props.id) {
|
|
121
|
+
props.id = "ButtonStack." + UID();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
125
|
+
|
|
126
|
+
return normalizeWidget(
|
|
127
|
+
<div id={props.id} w-button-stack w-centerX={props.centerX}>
|
|
128
|
+
{props.children}
|
|
129
|
+
</div>,
|
|
130
|
+
props
|
|
131
|
+
);
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export function createButtonStack(
|
|
135
|
+
id: string,
|
|
136
|
+
content: any,
|
|
137
|
+
parent: Widget | null = null
|
|
138
|
+
): ButtonStack {
|
|
139
|
+
const dataOrientation = content.getAttribute("w-orientation")
|
|
140
|
+
? content.getAttribute("w-orientation")
|
|
141
|
+
: "vertical";
|
|
142
|
+
|
|
143
|
+
let newStack = new ButtonStack(id, dataOrientation, parent);
|
|
144
|
+
|
|
145
|
+
if (content.getAttribute("w-centerX")) {
|
|
146
|
+
newStack.setCenteredButtons(true);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
content.childNodes.forEach((item: HTMLElement, _index: number) => {
|
|
150
|
+
if (item.getAttribute("w-button") || item.getAttribute("w-icon-button")) {
|
|
151
|
+
const widget = createWidget(item) as Button;
|
|
152
|
+
|
|
153
|
+
if (widget !== null) {
|
|
154
|
+
newStack.addButton(widget);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
return newStack;
|
|
94
160
|
}
|
package/src/ui/checkbox.ui.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { UID } from "../core/uid";
|
|
1
2
|
import { ToggleButton } from "./toggle.ui";
|
|
2
|
-
import { WidgetProps } from "./widget.builder";
|
|
3
|
+
import { normalizeWidget, WidgetProps } from "./widget.builder";
|
|
3
4
|
import { Widget, connectWidgetCallback, getOnlyEventProps } from "./widget.ui";
|
|
4
5
|
|
|
5
6
|
export class Checkbox extends ToggleButton {
|
|
@@ -14,20 +15,15 @@ export type wCheckboxProps = WidgetProps & {
|
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export const WCheckbox = (props: wCheckboxProps) => {
|
|
18
|
+
if (!props.id) {
|
|
19
|
+
props.id = "Checkbox." + UID();
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
connectWidgetCallback(props.id, getOnlyEventProps(props));
|
|
18
23
|
|
|
19
|
-
return (
|
|
20
|
-
<div
|
|
21
|
-
|
|
22
|
-
w-checkbox
|
|
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
|
-
/>
|
|
24
|
+
return normalizeWidget(
|
|
25
|
+
<div id={props.id} w-checkbox w-text={props.text} w-checked={props.checked} />,
|
|
26
|
+
props
|
|
31
27
|
);
|
|
32
28
|
};
|
|
33
29
|
|