cedro 0.1.2 → 0.1.4
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.core.ts +5 -20
- package/src/interfaces/widget.interface.ts +6 -1
- package/src/types/orientation.type.ts +1 -0
- package/src/ui/IconButton.ui.ts +37 -29
- package/src/ui/datagrid.ui.ts +216 -0
- package/src/ui/draggable.ui.ts +143 -0
- package/src/ui/index.ts +18 -13
- package/src/ui/menu.ui.ts +4 -5
- package/src/ui/scroll.ui.ts +185 -0
- package/src/ui/select.ui.ts +2 -6
- package/src/ui/styles/datagrid.css +10 -0
- package/src/ui/styles/dialog.css +1 -1
- package/src/ui/styles/draggable.css +9 -0
- package/src/ui/styles/menu.css +1 -1
- package/src/ui/styles/scroll.css +4 -0
- package/src/ui/styles/tabs.css +33 -0
- package/src/ui/tabs.ui.ts +131 -0
- package/src/ui/toolbar.ui.ts +203 -0
- package/src/ui/widget.ui.ts +42 -34
- package/tsconfig.json +4 -1
- package/index.html +0 -13
package/src/ui/widget.ui.ts
CHANGED
|
@@ -42,11 +42,7 @@ export class Widget implements IWidget {
|
|
|
42
42
|
bodyTagName: string;
|
|
43
43
|
body: HTMLElement;
|
|
44
44
|
|
|
45
|
-
constructor(
|
|
46
|
-
id: string,
|
|
47
|
-
bodyTagName: string = "div",
|
|
48
|
-
parent: IWidget | null = null
|
|
49
|
-
) {
|
|
45
|
+
constructor(id: string, bodyTagName: string = "div", parent: IWidget | null = null) {
|
|
50
46
|
this.id = id;
|
|
51
47
|
|
|
52
48
|
this.overflow = false;
|
|
@@ -117,9 +113,43 @@ export class Widget implements IWidget {
|
|
|
117
113
|
});
|
|
118
114
|
});
|
|
119
115
|
|
|
116
|
+
this.body.addEventListener("wheel", (e) => {
|
|
117
|
+
this.subscribers.forEach((callback) => {
|
|
118
|
+
if (callback.event == "wheel") {
|
|
119
|
+
callback.then(e, this);
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
this.body.addEventListener("mouseout", (e) => {
|
|
125
|
+
this.subscribers.forEach((callback) => {
|
|
126
|
+
if (callback.event == "mouseout") {
|
|
127
|
+
callback.then(e, this);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
this.body.addEventListener("mouseleave", (e) => {
|
|
133
|
+
this.subscribers.forEach((callback) => {
|
|
134
|
+
if (callback.event == "mouseleave") {
|
|
135
|
+
callback.then(e, this);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
|
|
120
140
|
this.init();
|
|
121
141
|
|
|
122
142
|
this.getMaxZIndex();
|
|
143
|
+
|
|
144
|
+
window.w.set(this.id, this);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public run(eventId: WUIEvent): void {
|
|
148
|
+
this.subscribers.forEach((callback) => {
|
|
149
|
+
if (callback.event == eventId) {
|
|
150
|
+
callback.then(new Event(eventId), this);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
123
153
|
}
|
|
124
154
|
|
|
125
155
|
public subscribe(cb: WUICallback) {
|
|
@@ -268,10 +298,7 @@ export class Widget implements IWidget {
|
|
|
268
298
|
this.body.style.bottom = "";
|
|
269
299
|
this.body.style.right = "";
|
|
270
300
|
} else {
|
|
271
|
-
if (
|
|
272
|
-
this.type === WidgetTypes.CUSTOM ||
|
|
273
|
-
this.type === WidgetTypes.FILL
|
|
274
|
-
) {
|
|
301
|
+
if (this.type === WidgetTypes.CUSTOM || this.type === WidgetTypes.FILL) {
|
|
275
302
|
this.body.style.position = "absolute";
|
|
276
303
|
this.body.style.overflow = "hidden";
|
|
277
304
|
}
|
|
@@ -461,7 +488,6 @@ export class Widget implements IWidget {
|
|
|
461
488
|
var clientLeft = docElem.clientLeft || body.clientLeft || 0;
|
|
462
489
|
var top = box.top + scrollTop - clientTop;
|
|
463
490
|
var left = box.left + scrollLeft - clientLeft;
|
|
464
|
-
|
|
465
491
|
return { x: Math.round(left), y: Math.round(top) };
|
|
466
492
|
}
|
|
467
493
|
|
|
@@ -629,10 +655,7 @@ export class Widget implements IWidget {
|
|
|
629
655
|
|
|
630
656
|
const padding = this.padding;
|
|
631
657
|
|
|
632
|
-
const size =
|
|
633
|
-
this.align === WidgetAlignTypes.HORIZONTAL
|
|
634
|
-
? this.width
|
|
635
|
-
: this.height;
|
|
658
|
+
const size = this.align === WidgetAlignTypes.HORIZONTAL ? this.width : this.height;
|
|
636
659
|
|
|
637
660
|
let currentPosition = padding;
|
|
638
661
|
|
|
@@ -699,29 +722,17 @@ export class Widget implements IWidget {
|
|
|
699
722
|
child.setX(currentPosition);
|
|
700
723
|
|
|
701
724
|
if (child.type === WidgetTypes.FILL) {
|
|
702
|
-
child.setWH(
|
|
703
|
-
elementSize - padding,
|
|
704
|
-
this.getH() - padding * 2
|
|
705
|
-
);
|
|
725
|
+
child.setWH(elementSize - padding, this.getH() - padding * 2);
|
|
706
726
|
} else {
|
|
707
|
-
child.setWH(
|
|
708
|
-
elementSize - padding,
|
|
709
|
-
this.getH() - padding * 2
|
|
710
|
-
);
|
|
727
|
+
child.setWH(elementSize - padding, this.getH() - padding * 2);
|
|
711
728
|
}
|
|
712
729
|
} else if (this.align === WidgetAlignTypes.VERTICAL) {
|
|
713
730
|
child.setX(padding);
|
|
714
731
|
child.setY(currentPosition);
|
|
715
732
|
if (child.type === WidgetTypes.FILL) {
|
|
716
|
-
child.setWH(
|
|
717
|
-
this.getW() - padding * 2,
|
|
718
|
-
elementSize - padding
|
|
719
|
-
);
|
|
733
|
+
child.setWH(this.getW() - padding * 2, elementSize - padding);
|
|
720
734
|
} else {
|
|
721
|
-
child.setWH(
|
|
722
|
-
this.getW() - padding * 2,
|
|
723
|
-
elementSize - padding
|
|
724
|
-
);
|
|
735
|
+
child.setWH(this.getW() - padding * 2, elementSize - padding);
|
|
725
736
|
}
|
|
726
737
|
}
|
|
727
738
|
currentPosition += elementSize;
|
|
@@ -761,10 +772,7 @@ export class Widget implements IWidget {
|
|
|
761
772
|
return content as HTMLElement;
|
|
762
773
|
}
|
|
763
774
|
|
|
764
|
-
private getMaxZIndex(
|
|
765
|
-
maxZindex: number = 0,
|
|
766
|
-
node: ChildNode | null = null
|
|
767
|
-
): number {
|
|
775
|
+
private getMaxZIndex(maxZindex: number = 0, node: ChildNode | null = null): number {
|
|
768
776
|
const parent = node ? node : document.body;
|
|
769
777
|
|
|
770
778
|
if (parent instanceof HTMLElement) {
|
package/tsconfig.json
CHANGED
package/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="/icon.svg" />
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
-
<title>cedro</title>
|
|
8
|
-
<link rel="stylesheet" href="src/ui/styles/main.css" />
|
|
9
|
-
</head>
|
|
10
|
-
<body>
|
|
11
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
-
</body>
|
|
13
|
-
</html>
|