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.
Files changed (79) hide show
  1. package/README.md +7 -4
  2. package/dist/cedro-logo.png +0 -0
  3. package/dist/fangio.jpg +0 -0
  4. package/package.json +4 -2
  5. package/src/core/application.builder.tsx +121 -0
  6. package/src/core/{application.core.ts → application.core.tsx} +175 -9
  7. package/src/core/themes.core.ts +160 -1
  8. package/src/core/uid.ts +3 -3
  9. package/src/index.ts +1 -1
  10. package/src/interfaces/application.interface.ts +10 -3
  11. package/src/interfaces/widget.interface.ts +6 -1
  12. package/src/types/select.item.type.ts +11 -0
  13. package/src/ui/Icon.ui.tsx +158 -0
  14. package/src/ui/IconButton.ui.tsx +233 -0
  15. package/src/ui/{textbox.ui.ts → Textbox.ui.tsx} +69 -8
  16. package/src/ui/accordion.ui.tsx +152 -0
  17. package/src/ui/button.ui.tsx +209 -0
  18. package/src/ui/buttonColor.ui.tsx +87 -0
  19. package/src/ui/buttonmenu.ui.tsx +134 -0
  20. package/src/ui/{buttonstack.ui.ts → buttonstack.ui.tsx} +67 -1
  21. package/src/ui/checkbox.ui.tsx +43 -0
  22. package/src/ui/container.ui.tsx +141 -0
  23. package/src/ui/datagrid.ui.tsx +518 -0
  24. package/src/ui/dialog.tsx +143 -56
  25. package/src/ui/{hpanel.ui.ts → hpanel.ui.tsx} +64 -1
  26. package/src/ui/iconButtonMenu.ui.tsx +176 -0
  27. package/src/ui/image.ui.tsx +123 -0
  28. package/src/ui/index.ts +9 -9
  29. package/src/ui/label.ui.tsx +184 -0
  30. package/src/ui/loading.ui.ts +10 -10
  31. package/src/ui/menu.ui.ts +2 -2
  32. package/src/ui/progressbar.ui.tsx +135 -0
  33. package/src/ui/radiobutton.ui.tsx +47 -0
  34. package/src/ui/scroll.ui.ts +13 -12
  35. package/src/ui/select.ui.tsx +143 -0
  36. package/src/ui/styles/button.css +114 -32
  37. package/src/ui/styles/buttoncolor.css +8 -8
  38. package/src/ui/styles/container.css +29 -0
  39. package/src/ui/styles/hpanel.css +1 -1
  40. package/src/ui/styles/icon.css +29 -0
  41. package/src/ui/styles/image.css +19 -19
  42. package/src/ui/styles/label.css +63 -0
  43. package/src/ui/styles/loading.css +12 -12
  44. package/src/ui/styles/main.css +5 -0
  45. package/src/ui/styles/progressbar.css +3 -2
  46. package/src/ui/styles/select.css +13 -0
  47. package/src/ui/styles/stackbutton.css +36 -0
  48. package/src/ui/styles/tabs.css +5 -7
  49. package/src/ui/styles/textarea.css +13 -13
  50. package/src/ui/styles/valuebar.css +1 -1
  51. package/src/ui/styles/vpanel.css +1 -1
  52. package/src/ui/switch.ui.tsx +42 -0
  53. package/src/ui/{tabs.ui.ts → tabs.ui.tsx} +114 -8
  54. package/src/ui/textarea.ui.tsx +48 -0
  55. package/src/ui/{toolbar.ui.ts → toolbar.ui.tsx} +44 -1
  56. package/src/ui/{valuebar.ui.ts → valuebar.ui.tsx} +35 -1
  57. package/src/ui/{vpanel.ui.ts → vpanel.ui.tsx} +44 -1
  58. package/src/ui/widget.builder.ts +243 -0
  59. package/src/ui/widget.collection.ts +57 -5
  60. package/src/ui/widget.ui.ts +176 -24
  61. package/src/ui/Icon.ui.ts +0 -64
  62. package/src/ui/IconButton.ui.ts +0 -114
  63. package/src/ui/accordion.ui.ts +0 -71
  64. package/src/ui/button.ui.ts +0 -105
  65. package/src/ui/buttonColor.ui.ts +0 -24
  66. package/src/ui/buttonmenu.ui.ts +0 -59
  67. package/src/ui/checkbox.ui.ts +0 -8
  68. package/src/ui/container.ui.ts +0 -38
  69. package/src/ui/datagrid.ui.ts +0 -231
  70. package/src/ui/iconButtonMenu.ui.ts +0 -59
  71. package/src/ui/image.ui.ts +0 -49
  72. package/src/ui/label.ui.ts +0 -82
  73. package/src/ui/progressbar.ui.ts +0 -74
  74. package/src/ui/radiobutton.ts +0 -8
  75. package/src/ui/select.ui.ts +0 -73
  76. package/src/ui/switch.ui.ts +0 -7
  77. package/src/ui/textarea.ui.ts +0 -20
  78. package/src/ui/widget.builder.ui.tsx +0 -676
  79. /package/src/ui/{toggle.ui.ts → toggle.ui.tsx} +0 -0
@@ -1,59 +0,0 @@
1
- import { IconButton } from "./IconButton.ui";
2
- import { Menu } from "./menu.ui";
3
- import { SelectItem } from "./select.ui";
4
-
5
- export class IconButtonMenu extends IconButton {
6
- menu: Menu;
7
- items: Array<SelectItem>;
8
- selectedItem: SelectItem | null;
9
-
10
- public constructor(id: string, icon: string) {
11
- super(id, icon);
12
-
13
- this.menu = new Menu(this.id + ".menu", this.id, null);
14
-
15
- this.items = new Array<SelectItem>();
16
- this.selectedItem = null;
17
-
18
- this.subscribe({
19
- event: "click",
20
- then: () => {
21
- this.menu.clearOptions();
22
- this.items.forEach((item) => {
23
- this.menu.addOption(item.id, item.icon, item.label);
24
- });
25
-
26
- this.menu.wakeUp();
27
-
28
- if (this.getW() > this.menu.getW()) {
29
- this.menu.setW(this.getBody().clientWidth);
30
- console.log("cambiando ancho...");
31
- }
32
- },
33
- });
34
-
35
- /*this.menu.subscribe({
36
- event: "option-clicked",
37
- then: (_e, clickedOption) => {
38
- const option = clickedOption as IconButton;
39
-
40
- const fintOption = this.items.find((item) => item.id === option.id);
41
-
42
- if (fintOption) {
43
- this.selectedItem = fintOption;
44
- }
45
-
46
- const selectedText = this.selectedItem?.label;
47
- if (selectedText) {
48
- this.setText(selectedText);
49
- } else {
50
- this.setText("");
51
- }
52
- },
53
- });*/
54
- }
55
-
56
- public addItem(id: string, label: string, icon: string): void {
57
- this.items.push(new SelectItem(id, label, icon));
58
- }
59
- }
@@ -1,49 +0,0 @@
1
- import "./styles/image.css";
2
- import { Widget, WidgetTypes } from "./widget.ui";
3
-
4
- export class Image extends Widget {
5
- imageContainer: Widget;
6
- image: Widget;
7
- constructor(id: string, src: string = "", parent: Widget | null = null) {
8
- super(id, "div", parent);
9
-
10
- this.imageContainer = new Widget(id + ".imageContainer", "div", this);
11
- this.imageContainer.addClass("WUIImageContainer");
12
-
13
- this.image = new Widget(id + ".image", "img", this.imageContainer);
14
- this.image.setType(WidgetTypes.CUSTOM);
15
- this.image.getBody().setAttribute("src", src);
16
- }
17
-
18
- public render(): void {
19
- super.render();
20
-
21
- this.imageContainer.setX(0);
22
- this.imageContainer.setY(0);
23
- this.imageContainer.setWH(this.getW(), this.getH());
24
- }
25
-
26
- public fillWidth(): void {
27
- this.image.addClass("WUIImageFillWidth");
28
- }
29
-
30
- public fillHeight(): void {
31
- this.image.addClass("WUIImageFillHeight");
32
- }
33
-
34
- public setAlternateText(text: string): void {
35
- this.image.getBody().setAttribute("alt", text);
36
- }
37
-
38
- public setImageUrl(url: string): void {
39
- this.image.getBody().setAttribute("src", url);
40
- }
41
-
42
- public getImageUrl(): string | null {
43
- return this.image.getBody().getAttribute("src");
44
- }
45
-
46
- public getAlternateText(): string | null {
47
- return this.image.getBody().getAttribute("alt");
48
- }
49
- }
@@ -1,82 +0,0 @@
1
- import { Colors } from "./colors.ui";
2
- import { Widget } from "./widget.ui";
3
-
4
- export type LabelVariants = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "span";
5
-
6
- export class Label extends Widget {
7
- variant: LabelVariants;
8
- color: Colors;
9
- text: string;
10
-
11
- isHCentered: boolean;
12
- isVCentered: boolean;
13
-
14
- constructor(id: string, variant: LabelVariants = "span", parent: Widget | null = null) {
15
- super(id, variant, parent);
16
-
17
- this.isHCentered = false;
18
- this.isVCentered = false;
19
-
20
- this.variant = variant;
21
- this.color = "primary";
22
- this.text = "";
23
-
24
- this.init();
25
- }
26
-
27
- public init(): void {
28
- super.init();
29
- }
30
-
31
- public setHCentered(isHCentered: boolean = true): void {
32
- this.isHCentered = isHCentered;
33
- }
34
-
35
- public setVCentered(isVCentered: boolean = true): void {
36
- this.isVCentered = isVCentered;
37
- }
38
-
39
- public render(): void {
40
- super.render();
41
-
42
- if (this.isHCentered) {
43
- this.centerH();
44
- }
45
- if (this.isVCentered) {
46
- this.centerV();
47
- }
48
- }
49
-
50
- private centerV(): void {
51
- this.getBody().style.lineHeight = this.getH() + "px";
52
- }
53
-
54
- private centerH(): void {
55
- this.getBody().style.textAlign = "center";
56
- }
57
-
58
- public setText(text: string): void {
59
- this.text = text;
60
- this.body.innerHTML = text;
61
- }
62
-
63
- public setVariant(variant: LabelVariants = "span"): void {
64
- this.variant = variant;
65
- }
66
-
67
- public setColor(color: Colors = "primary"): void {
68
- this.color = color;
69
- }
70
-
71
- public getVariant(): LabelVariants {
72
- return this.variant;
73
- }
74
-
75
- public getColor(): Colors {
76
- return this.color;
77
- }
78
-
79
- public getText(): string {
80
- return this.text;
81
- }
82
- }
@@ -1,74 +0,0 @@
1
- import { Label } from "./label.ui";
2
- import "./styles/progressbar.css";
3
- import { Widget } from "./widget.ui";
4
-
5
- const PROGRESS_BAR_HEIGHT = 40;
6
-
7
- //icono para el progress bar interactivo humidity_high
8
-
9
- export class ProgressBar extends Widget {
10
- private value: number;
11
- private paddingBar: number;
12
-
13
- private bar: Widget;
14
- private lblValue: Label;
15
-
16
- public constructor(id: string, parent: Widget | null = null) {
17
- super(id, "div", parent);
18
-
19
- this.setH(PROGRESS_BAR_HEIGHT);
20
-
21
- this.paddingBar = 0;
22
-
23
- this.bar = new Widget(id + ".bar", "div", this);
24
- this.bar.addClass("WUIProgressBarBar");
25
-
26
- this.value = 0;
27
- this.addClass("WUIProgressBarContainer");
28
-
29
- this.lblValue = new Label(id + ".value", "span", this);
30
- this.lblValue.setText(this.value + "%");
31
-
32
- this.lblValue.addClass("WUIProgressBarLabel");
33
- }
34
-
35
- public setPaddingBar(p: number): void {
36
- this.paddingBar = p;
37
- }
38
-
39
- public hideLabel(): void {
40
- this.lblValue.setVisible(false);
41
- }
42
-
43
- public displayLabel(): void {
44
- this.lblValue.setVisible(true);
45
- }
46
-
47
- public render(): void {
48
- super.render();
49
-
50
- const padding = this.paddingBar;
51
- const width = this.getW() - padding;
52
- const height = this.getH();
53
- const widthBar = width * (this.value / 100);
54
-
55
- this.lblValue.setX(width / 2 - this.lblValue.getW() / 2);
56
- this.lblValue.setY(height / 2 - this.lblValue.getH() / 2);
57
- this.lblValue.raisteTop();
58
-
59
- this.bar.setX(padding);
60
- this.bar.setY(padding);
61
- this.bar.setW(widthBar);
62
- this.bar.setH(height - padding * 2);
63
- }
64
-
65
- public setValue(value: number): void {
66
- this.value = value;
67
- this.lblValue.setText(this.value + "%");
68
- this.render();
69
- }
70
-
71
- public getValue(): number {
72
- return this.value;
73
- }
74
- }
@@ -1,8 +0,0 @@
1
- import { ToggleButton } from "./toggle.ui";
2
- import { Widget } from "./widget.ui";
3
-
4
- export class RadioButton extends ToggleButton {
5
- constructor(id: string, text: string = "", parent: Widget | null = null) {
6
- super(id, text, "radio_button_unchecked", "radio_button_checked", parent);
7
- }
8
- }
@@ -1,73 +0,0 @@
1
- import { IconButton } from "./IconButton.ui";
2
- import { Menu } from "./menu.ui";
3
- import { Textbox } from "./textbox.ui";
4
- import { Widget } from "./widget.ui";
5
-
6
- export class SelectItem {
7
- id: string;
8
- label: string;
9
- icon: string;
10
-
11
- constructor(id: string, label: string, icon: string) {
12
- this.id = id;
13
- this.label = label;
14
- this.icon = icon;
15
- }
16
- }
17
-
18
- export class Select extends Textbox {
19
- menu: Menu;
20
-
21
- items: SelectItem[];
22
-
23
- selectedItem: SelectItem | null;
24
-
25
- constructor(id: string, parent: Widget | null = null) {
26
- super(id, parent);
27
- this.menu = new Menu(this.id + ".menu", this.id, null);
28
- this.items = [];
29
- this.selectedItem = null;
30
- this.subscribe({
31
- event: "click",
32
- then: () => {
33
- this.menu.clearOptions();
34
- this.items.forEach((item) => {
35
- this.menu.addOption(item.id, item.icon, item.label);
36
- });
37
-
38
- this.menu.wakeUp();
39
-
40
- console.log(this.getBody().clientWidth, this.menu.getBody().clientWidth);
41
-
42
- if (this.getBody().clientWidth > this.menu.getBody().clientWidth) {
43
- this.menu.setW(this.getBody().clientWidth);
44
- this.menu.resize();
45
- }
46
- },
47
- });
48
-
49
- this.menu.subscribe({
50
- event: "option-clicked",
51
- then: (_e, clickedOption) => {
52
- const option = clickedOption as IconButton;
53
-
54
- const fintOption = this.items.find((item) => item.id === option.id);
55
-
56
- if (fintOption) {
57
- this.selectedItem = fintOption;
58
- }
59
-
60
- const selectedText = this.selectedItem?.label;
61
- if (selectedText) {
62
- this.setValue(selectedText);
63
- } else {
64
- this.setValue("");
65
- }
66
- },
67
- });
68
- }
69
-
70
- addItem(id: string, label: string, icon: string) {
71
- this.items.push(new SelectItem(id, label, icon));
72
- }
73
- }
@@ -1,7 +0,0 @@
1
- import { ToggleButton } from "./toggle.ui";
2
- import { Widget } from "./widget.ui";
3
- export class Switch extends ToggleButton {
4
- constructor(id: string, text: string = "", parent: Widget | null = null) {
5
- super(id, text, "toggle_off", "toggle_on", parent);
6
- }
7
- }
@@ -1,20 +0,0 @@
1
- import "./styles/textarea.css";
2
- import { Widget } from "./widget.ui";
3
-
4
- export class TextArea extends Widget {
5
- constructor(id: string, parent: Widget | null = null) {
6
- super(id, "textarea", parent);
7
-
8
- this.addClass("WUITextArea");
9
- }
10
-
11
- public setText(text: string): void {
12
- const textArea = this.getBody() as HTMLTextAreaElement;
13
- textArea.value = text;
14
- }
15
-
16
- public getText(): string {
17
- const textArea = this.getBody() as HTMLTextAreaElement;
18
- return textArea.value;
19
- }
20
- }