@hpcc-js/layout 3.5.10 → 3.5.12
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/LICENSE +43 -43
- package/README.md +83 -83
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +1 -1
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +11 -9
- package/src/AbsoluteSurface.css +8 -8
- package/src/AbsoluteSurface.ts +93 -93
- package/src/Accordion.css +101 -101
- package/src/Accordion.ts +146 -146
- package/src/Border.css +148 -148
- package/src/Border.ts +636 -636
- package/src/Border2.css +22 -22
- package/src/Border2.ts +391 -391
- package/src/Carousel.css +7 -7
- package/src/Carousel.ts +100 -100
- package/src/Cell.css +10 -10
- package/src/Cell.ts +94 -94
- package/src/ChartPanel.css +7 -7
- package/src/ChartPanel.ts +635 -635
- package/src/FlexGrid.css +8 -8
- package/src/FlexGrid.ts +140 -140
- package/src/Grid.css +89 -89
- package/src/Grid.ts +576 -576
- package/src/HorizontalList.ts +15 -15
- package/src/Layered.css +11 -11
- package/src/Layered.ts +132 -132
- package/src/Legend.ts +516 -516
- package/src/Modal.css +50 -50
- package/src/Modal.ts +289 -289
- package/src/Popup.ts +120 -120
- package/src/Surface.css +104 -104
- package/src/Surface.ts +223 -223
- package/src/Tabbed.css +23 -23
- package/src/Tabbed.ts +165 -165
- package/src/Toolbar.css +33 -33
- package/src/Toolbar.ts +127 -127
- package/src/VerticalList.ts +15 -15
- package/src/__package__.ts +3 -3
- package/src/index.ts +20 -20
package/src/Tabbed.ts
CHANGED
|
@@ -1,165 +1,165 @@
|
|
|
1
|
-
import { HTMLWidget, Text, Widget } from "@hpcc-js/common";
|
|
2
|
-
import { select as d3Select } from "d3-selection";
|
|
3
|
-
import { Surface } from "./Surface.ts";
|
|
4
|
-
|
|
5
|
-
import "../src/Tabbed.css";
|
|
6
|
-
|
|
7
|
-
export class Tabbed extends HTMLWidget {
|
|
8
|
-
_tabContainer;
|
|
9
|
-
_contentContainer;
|
|
10
|
-
|
|
11
|
-
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
|
|
14
|
-
this._tag = "div";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
clearTabs() {
|
|
18
|
-
this.labels([]);
|
|
19
|
-
this.widgets([]);
|
|
20
|
-
return this;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
addTab(widget, label, isActive?, callback?) {
|
|
24
|
-
const widgetSize = widget.size();
|
|
25
|
-
if (widgetSize.width === 0 && widgetSize.height === 0) {
|
|
26
|
-
widget.size({ width: "100%", height: "100%" });
|
|
27
|
-
}
|
|
28
|
-
const labels = this.labels();
|
|
29
|
-
const widgets = this.widgets();
|
|
30
|
-
if (isActive) {
|
|
31
|
-
this.activeTabIdx(this.widgets().length);
|
|
32
|
-
}
|
|
33
|
-
labels.push(label);
|
|
34
|
-
const surface = new Surface().widget(widget ? widget : new Text().text("No widget defined for tab"));
|
|
35
|
-
widgets.push(surface);
|
|
36
|
-
this.labels(labels);
|
|
37
|
-
this.widgets(widgets);
|
|
38
|
-
if (callback) {
|
|
39
|
-
callback(surface);
|
|
40
|
-
}
|
|
41
|
-
return this;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
widgetSize(widgetDiv) {
|
|
45
|
-
const width = this.clientWidth();
|
|
46
|
-
let height = this.clientHeight();
|
|
47
|
-
|
|
48
|
-
const tcBox = this._tabContainer.node().getBoundingClientRect();
|
|
49
|
-
if (typeof (tcBox.height) !== "undefined") {
|
|
50
|
-
height -= tcBox.height;
|
|
51
|
-
}
|
|
52
|
-
return { width, height };
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
enter(domNode, element) {
|
|
56
|
-
super.enter(domNode, element);
|
|
57
|
-
this._tabContainer = element.append("div");
|
|
58
|
-
this._contentContainer = element.append("div");
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
update(domNode, element) {
|
|
62
|
-
super.update(domNode, element);
|
|
63
|
-
const context = this;
|
|
64
|
-
|
|
65
|
-
element.style("padding", this.surfacePadding_exists() ? this.surfacePadding() + "px" : null);
|
|
66
|
-
|
|
67
|
-
const tabs = this._tabContainer.selectAll(".tab-button.id" + this.id()).data(this.showTabs() ? this.labels() : [], function (d) { return d; });
|
|
68
|
-
tabs.enter().append("span")
|
|
69
|
-
.attr("class", "tab-button id" + this.id())
|
|
70
|
-
.style("cursor", "pointer")
|
|
71
|
-
.on("click", function (d, idx) {
|
|
72
|
-
context.click(context.widgets()[idx].widget(), d, idx);
|
|
73
|
-
context
|
|
74
|
-
.activeTabIdx(idx)
|
|
75
|
-
.render()
|
|
76
|
-
;
|
|
77
|
-
}).merge(tabs)
|
|
78
|
-
.classed("active", function (d, idx) { return context.activeTabIdx() === idx; })
|
|
79
|
-
.text(function (d) { return d; })
|
|
80
|
-
;
|
|
81
|
-
tabs.exit().remove();
|
|
82
|
-
|
|
83
|
-
const content = this._contentContainer.selectAll(".tab-content.id" + this.id()).data(this.widgets(), function (d) { return d.id(); });
|
|
84
|
-
content.enter().append("div")
|
|
85
|
-
.attr("class", "tab-content id" + this.id())
|
|
86
|
-
.each(function (widget, idx) {
|
|
87
|
-
widget.target(this);
|
|
88
|
-
}).merge(content)
|
|
89
|
-
.classed("active", function (d, idx) { return context.activeTabIdx() === idx; })
|
|
90
|
-
.style("display", function (d, idx) { return context.activeTabIdx() === idx ? "block" : "none"; })
|
|
91
|
-
.each(function (surface, idx) {
|
|
92
|
-
surface.visible(context.activeTabIdx() === idx);
|
|
93
|
-
if (context.activeTabIdx() === idx) {
|
|
94
|
-
const wSize = context.widgetSize(d3Select(this));
|
|
95
|
-
surface
|
|
96
|
-
.surfaceBorderWidth(context.showTabs() ? null : 0)
|
|
97
|
-
.surfacePadding(context.showTabs() ? null : 0)
|
|
98
|
-
.resize(wSize)
|
|
99
|
-
;
|
|
100
|
-
}
|
|
101
|
-
})
|
|
102
|
-
;
|
|
103
|
-
content.exit()
|
|
104
|
-
.each(function (widget, idx) {
|
|
105
|
-
widget
|
|
106
|
-
.target(null)
|
|
107
|
-
;
|
|
108
|
-
})
|
|
109
|
-
.remove();
|
|
110
|
-
|
|
111
|
-
switch (this.tabLocation()) {
|
|
112
|
-
case "bottom":
|
|
113
|
-
this._tabContainer
|
|
114
|
-
.attr("class", "on_bottom")
|
|
115
|
-
.style("top", (this._contentContainer.node().offsetHeight + this.surfacePadding()) + "px")
|
|
116
|
-
.style("position", "absolute")
|
|
117
|
-
;
|
|
118
|
-
this._contentContainer
|
|
119
|
-
.style("top", this.surfacePadding_exists() ? this.surfacePadding() + "px" : null)
|
|
120
|
-
.style("position", "absolute")
|
|
121
|
-
;
|
|
122
|
-
break;
|
|
123
|
-
default:
|
|
124
|
-
this._tabContainer
|
|
125
|
-
.attr("class", "on_top")
|
|
126
|
-
.style("top", null)
|
|
127
|
-
.style("position", "relative")
|
|
128
|
-
;
|
|
129
|
-
this._contentContainer
|
|
130
|
-
.style("top", (this._tabContainer.node().offsetHeight + this.surfacePadding()) + "px")
|
|
131
|
-
.style("position", "absolute")
|
|
132
|
-
;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
click(widget, column, idx) {
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
Tabbed.prototype._class += " layout_Tabbed";
|
|
141
|
-
|
|
142
|
-
export interface Tabbed {
|
|
143
|
-
showTabs(): boolean;
|
|
144
|
-
showTabs(_: boolean): this;
|
|
145
|
-
surfacePadding(): number;
|
|
146
|
-
surfacePadding(_: number): this;
|
|
147
|
-
surfacePadding_exists(): boolean;
|
|
148
|
-
activeTabIdx(): number;
|
|
149
|
-
activeTabIdx(_: number): this;
|
|
150
|
-
|
|
151
|
-
labels(): string[];
|
|
152
|
-
labels(_: string[]): this;
|
|
153
|
-
tabLocation(): "top" | "bottom";
|
|
154
|
-
tabLocation(_: "top" | "bottom"): this;
|
|
155
|
-
widgets(): any[];
|
|
156
|
-
widgets(_: any[]): this;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
Tabbed.prototype.publish("showTabs", true, "boolean", "Show Tabs", null, {});
|
|
160
|
-
Tabbed.prototype.publish("surfacePadding", 4, "number", "Padding");
|
|
161
|
-
Tabbed.prototype.publish("activeTabIdx", 0, "number", "Index of active tab", null, {});
|
|
162
|
-
|
|
163
|
-
Tabbed.prototype.publish("labels", [], "array", "Array of tab labels sharing an index with ", null, { tags: ["Private"] });
|
|
164
|
-
Tabbed.prototype.publish("tabLocation", "top", "set", "Position the tabs at the bottom of the widget", ["top", "bottom"], { tags: ["Private"] });
|
|
165
|
-
Tabbed.prototype.publish("widgets", [], "widgetArray", "widgets", null, { tags: ["Private"] });
|
|
1
|
+
import { HTMLWidget, Text, Widget } from "@hpcc-js/common";
|
|
2
|
+
import { select as d3Select } from "d3-selection";
|
|
3
|
+
import { Surface } from "./Surface.ts";
|
|
4
|
+
|
|
5
|
+
import "../src/Tabbed.css";
|
|
6
|
+
|
|
7
|
+
export class Tabbed extends HTMLWidget {
|
|
8
|
+
_tabContainer;
|
|
9
|
+
_contentContainer;
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this._tag = "div";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
clearTabs() {
|
|
18
|
+
this.labels([]);
|
|
19
|
+
this.widgets([]);
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
addTab(widget, label, isActive?, callback?) {
|
|
24
|
+
const widgetSize = widget.size();
|
|
25
|
+
if (widgetSize.width === 0 && widgetSize.height === 0) {
|
|
26
|
+
widget.size({ width: "100%", height: "100%" });
|
|
27
|
+
}
|
|
28
|
+
const labels = this.labels();
|
|
29
|
+
const widgets = this.widgets();
|
|
30
|
+
if (isActive) {
|
|
31
|
+
this.activeTabIdx(this.widgets().length);
|
|
32
|
+
}
|
|
33
|
+
labels.push(label);
|
|
34
|
+
const surface = new Surface().widget(widget ? widget : new Text().text("No widget defined for tab"));
|
|
35
|
+
widgets.push(surface);
|
|
36
|
+
this.labels(labels);
|
|
37
|
+
this.widgets(widgets);
|
|
38
|
+
if (callback) {
|
|
39
|
+
callback(surface);
|
|
40
|
+
}
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
widgetSize(widgetDiv) {
|
|
45
|
+
const width = this.clientWidth();
|
|
46
|
+
let height = this.clientHeight();
|
|
47
|
+
|
|
48
|
+
const tcBox = this._tabContainer.node().getBoundingClientRect();
|
|
49
|
+
if (typeof (tcBox.height) !== "undefined") {
|
|
50
|
+
height -= tcBox.height;
|
|
51
|
+
}
|
|
52
|
+
return { width, height };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
enter(domNode, element) {
|
|
56
|
+
super.enter(domNode, element);
|
|
57
|
+
this._tabContainer = element.append("div");
|
|
58
|
+
this._contentContainer = element.append("div");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
update(domNode, element) {
|
|
62
|
+
super.update(domNode, element);
|
|
63
|
+
const context = this;
|
|
64
|
+
|
|
65
|
+
element.style("padding", this.surfacePadding_exists() ? this.surfacePadding() + "px" : null);
|
|
66
|
+
|
|
67
|
+
const tabs = this._tabContainer.selectAll(".tab-button.id" + this.id()).data(this.showTabs() ? this.labels() : [], function (d) { return d; });
|
|
68
|
+
tabs.enter().append("span")
|
|
69
|
+
.attr("class", "tab-button id" + this.id())
|
|
70
|
+
.style("cursor", "pointer")
|
|
71
|
+
.on("click", function (d, idx) {
|
|
72
|
+
context.click(context.widgets()[idx].widget(), d, idx);
|
|
73
|
+
context
|
|
74
|
+
.activeTabIdx(idx)
|
|
75
|
+
.render()
|
|
76
|
+
;
|
|
77
|
+
}).merge(tabs)
|
|
78
|
+
.classed("active", function (d, idx) { return context.activeTabIdx() === idx; })
|
|
79
|
+
.text(function (d) { return d; })
|
|
80
|
+
;
|
|
81
|
+
tabs.exit().remove();
|
|
82
|
+
|
|
83
|
+
const content = this._contentContainer.selectAll(".tab-content.id" + this.id()).data(this.widgets(), function (d) { return d.id(); });
|
|
84
|
+
content.enter().append("div")
|
|
85
|
+
.attr("class", "tab-content id" + this.id())
|
|
86
|
+
.each(function (widget, idx) {
|
|
87
|
+
widget.target(this);
|
|
88
|
+
}).merge(content)
|
|
89
|
+
.classed("active", function (d, idx) { return context.activeTabIdx() === idx; })
|
|
90
|
+
.style("display", function (d, idx) { return context.activeTabIdx() === idx ? "block" : "none"; })
|
|
91
|
+
.each(function (surface, idx) {
|
|
92
|
+
surface.visible(context.activeTabIdx() === idx);
|
|
93
|
+
if (context.activeTabIdx() === idx) {
|
|
94
|
+
const wSize = context.widgetSize(d3Select(this));
|
|
95
|
+
surface
|
|
96
|
+
.surfaceBorderWidth(context.showTabs() ? null : 0)
|
|
97
|
+
.surfacePadding(context.showTabs() ? null : 0)
|
|
98
|
+
.resize(wSize)
|
|
99
|
+
;
|
|
100
|
+
}
|
|
101
|
+
})
|
|
102
|
+
;
|
|
103
|
+
content.exit()
|
|
104
|
+
.each(function (widget, idx) {
|
|
105
|
+
widget
|
|
106
|
+
.target(null)
|
|
107
|
+
;
|
|
108
|
+
})
|
|
109
|
+
.remove();
|
|
110
|
+
|
|
111
|
+
switch (this.tabLocation()) {
|
|
112
|
+
case "bottom":
|
|
113
|
+
this._tabContainer
|
|
114
|
+
.attr("class", "on_bottom")
|
|
115
|
+
.style("top", (this._contentContainer.node().offsetHeight + this.surfacePadding()) + "px")
|
|
116
|
+
.style("position", "absolute")
|
|
117
|
+
;
|
|
118
|
+
this._contentContainer
|
|
119
|
+
.style("top", this.surfacePadding_exists() ? this.surfacePadding() + "px" : null)
|
|
120
|
+
.style("position", "absolute")
|
|
121
|
+
;
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
this._tabContainer
|
|
125
|
+
.attr("class", "on_top")
|
|
126
|
+
.style("top", null)
|
|
127
|
+
.style("position", "relative")
|
|
128
|
+
;
|
|
129
|
+
this._contentContainer
|
|
130
|
+
.style("top", (this._tabContainer.node().offsetHeight + this.surfacePadding()) + "px")
|
|
131
|
+
.style("position", "absolute")
|
|
132
|
+
;
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
click(widget, column, idx) {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
Tabbed.prototype._class += " layout_Tabbed";
|
|
141
|
+
|
|
142
|
+
export interface Tabbed {
|
|
143
|
+
showTabs(): boolean;
|
|
144
|
+
showTabs(_: boolean): this;
|
|
145
|
+
surfacePadding(): number;
|
|
146
|
+
surfacePadding(_: number): this;
|
|
147
|
+
surfacePadding_exists(): boolean;
|
|
148
|
+
activeTabIdx(): number;
|
|
149
|
+
activeTabIdx(_: number): this;
|
|
150
|
+
|
|
151
|
+
labels(): string[];
|
|
152
|
+
labels(_: string[]): this;
|
|
153
|
+
tabLocation(): "top" | "bottom";
|
|
154
|
+
tabLocation(_: "top" | "bottom"): this;
|
|
155
|
+
widgets(): any[];
|
|
156
|
+
widgets(_: any[]): this;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
Tabbed.prototype.publish("showTabs", true, "boolean", "Show Tabs", null, {});
|
|
160
|
+
Tabbed.prototype.publish("surfacePadding", 4, "number", "Padding");
|
|
161
|
+
Tabbed.prototype.publish("activeTabIdx", 0, "number", "Index of active tab", null, {});
|
|
162
|
+
|
|
163
|
+
Tabbed.prototype.publish("labels", [], "array", "Array of tab labels sharing an index with ", null, { tags: ["Private"] });
|
|
164
|
+
Tabbed.prototype.publish("tabLocation", "top", "set", "Position the tabs at the bottom of the widget", ["top", "bottom"], { tags: ["Private"] });
|
|
165
|
+
Tabbed.prototype.publish("widgets", [], "widgetArray", "widgets", null, { tags: ["Private"] });
|
package/src/Toolbar.css
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
.layout_Toolbar {
|
|
2
|
-
height: 100%;
|
|
3
|
-
background-color: #dddddd;
|
|
4
|
-
white-space: nowrap;
|
|
5
|
-
overflow: hidden;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.layout_Toolbar .toolbar-title {
|
|
9
|
-
display: inline-block;
|
|
10
|
-
position: relative;
|
|
11
|
-
top: 50%;
|
|
12
|
-
transform: translateY(-50%);
|
|
13
|
-
-ms-transform: translateY(-50%);
|
|
14
|
-
|
|
15
|
-
margin-left: 4px;
|
|
16
|
-
font-weight: bold;
|
|
17
|
-
text-overflow: ellipsis;
|
|
18
|
-
white-space: nowrap;
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.layout_Toolbar .toolbar-title span {}
|
|
23
|
-
|
|
24
|
-
.layout_Toolbar .toolbar-child {
|
|
25
|
-
position: relative;
|
|
26
|
-
top: 50%;
|
|
27
|
-
transform: translateY(-50%);
|
|
28
|
-
-ms-transform: translateY(-50%);
|
|
29
|
-
|
|
30
|
-
float: right;
|
|
31
|
-
margin-left: 4px;
|
|
32
|
-
margin-right: 4px;
|
|
33
|
-
line-height: 16px;
|
|
1
|
+
.layout_Toolbar {
|
|
2
|
+
height: 100%;
|
|
3
|
+
background-color: #dddddd;
|
|
4
|
+
white-space: nowrap;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.layout_Toolbar .toolbar-title {
|
|
9
|
+
display: inline-block;
|
|
10
|
+
position: relative;
|
|
11
|
+
top: 50%;
|
|
12
|
+
transform: translateY(-50%);
|
|
13
|
+
-ms-transform: translateY(-50%);
|
|
14
|
+
|
|
15
|
+
margin-left: 4px;
|
|
16
|
+
font-weight: bold;
|
|
17
|
+
text-overflow: ellipsis;
|
|
18
|
+
white-space: nowrap;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.layout_Toolbar .toolbar-title span {}
|
|
23
|
+
|
|
24
|
+
.layout_Toolbar .toolbar-child {
|
|
25
|
+
position: relative;
|
|
26
|
+
top: 50%;
|
|
27
|
+
transform: translateY(-50%);
|
|
28
|
+
-ms-transform: translateY(-50%);
|
|
29
|
+
|
|
30
|
+
float: right;
|
|
31
|
+
margin-left: 4px;
|
|
32
|
+
margin-right: 4px;
|
|
33
|
+
line-height: 16px;
|
|
34
34
|
}
|
package/src/Toolbar.ts
CHANGED
|
@@ -1,127 +1,127 @@
|
|
|
1
|
-
import { HTMLWidget, Widget } from "@hpcc-js/common";
|
|
2
|
-
import { select as d3Select } from "d3-selection";
|
|
3
|
-
|
|
4
|
-
import "../src/Toolbar.css";
|
|
5
|
-
|
|
6
|
-
export class Toolbar extends HTMLWidget {
|
|
7
|
-
|
|
8
|
-
constructor() {
|
|
9
|
-
super();
|
|
10
|
-
this._tag = "div";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
enter(domNode, element) {
|
|
14
|
-
super.enter(domNode, element);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
update(domNode, element) {
|
|
18
|
-
super.update(domNode, element);
|
|
19
|
-
const context = this;
|
|
20
|
-
|
|
21
|
-
element
|
|
22
|
-
.attr("title", context.title())
|
|
23
|
-
.style("background-color", this.backgroundColor())
|
|
24
|
-
;
|
|
25
|
-
|
|
26
|
-
const title = element.selectAll("div.toolbar-title")
|
|
27
|
-
.data(this.title() ? [this.title()] : []);
|
|
28
|
-
title.enter().append("div")
|
|
29
|
-
.classed("toolbar-title", true)
|
|
30
|
-
.append("span")
|
|
31
|
-
;
|
|
32
|
-
title.selectAll("div.toolbar-title > span")
|
|
33
|
-
.style("font-size", this.fontSize_exists() ? this.fontSize() + "px" : null)
|
|
34
|
-
.style("color", this.fontColor_exists() ? this.fontColor() : null)
|
|
35
|
-
.style("font-family", this.fontFamily_exists() ? this.fontFamily() : null)
|
|
36
|
-
.style("font-weight", this.fontBold_exists() ? (this.fontBold() ? "bold" : "normal") : null)
|
|
37
|
-
.style("background-color", this.backgroundColor_exists() ? this.backgroundColor() : null)
|
|
38
|
-
.text(context.title())
|
|
39
|
-
;
|
|
40
|
-
title.exit().remove();
|
|
41
|
-
|
|
42
|
-
const childWidgets = element.selectAll("div.toolbar-child")
|
|
43
|
-
.data(this.widgets() !== null ? this.widgets() : [], function (d) { return d.id(); });
|
|
44
|
-
|
|
45
|
-
childWidgets.enter().insert("div", "div.toolbar-title")
|
|
46
|
-
.each(function (d, i) {
|
|
47
|
-
const widgetClass = context.widgetClasses()[i] ? context.widgetClasses()[i] + " toolbar-child" : "toolbar-child";
|
|
48
|
-
d3Select(this).classed(widgetClass, true);
|
|
49
|
-
d.target(this);
|
|
50
|
-
});
|
|
51
|
-
childWidgets.exit().each(function (d) {
|
|
52
|
-
d.target(null);
|
|
53
|
-
}).remove();
|
|
54
|
-
childWidgets.order();
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
render(callback?: (w: Widget) => void): this {
|
|
58
|
-
const context = this;
|
|
59
|
-
return super.render(function (w) {
|
|
60
|
-
const toolbarBBox = context.element().node().getBoundingClientRect();
|
|
61
|
-
let minX = toolbarBBox.left + toolbarBBox.width;
|
|
62
|
-
context.element().selectAll("div.toolbar-child")
|
|
63
|
-
.each(function (d, i) {
|
|
64
|
-
const childBBox = this.getBoundingClientRect();
|
|
65
|
-
if (minX > childBBox.left)
|
|
66
|
-
minX = childBBox.left;
|
|
67
|
-
})
|
|
68
|
-
;
|
|
69
|
-
context.element().select(".toolbar-title")
|
|
70
|
-
.style("width", (minX - toolbarBBox.left - 4) + "px")
|
|
71
|
-
;
|
|
72
|
-
if (callback) {
|
|
73
|
-
callback(w);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
exit(domNode, element) {
|
|
79
|
-
this.widgets().forEach(function (w) {
|
|
80
|
-
w.target(null);
|
|
81
|
-
});
|
|
82
|
-
super.exit(domNode, element);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
Toolbar.prototype._class += " layout_Toolbar";
|
|
86
|
-
|
|
87
|
-
export interface Toolbar {
|
|
88
|
-
title(): string;
|
|
89
|
-
title(_: string): this;
|
|
90
|
-
|
|
91
|
-
fontSize(): number;
|
|
92
|
-
fontSize(_: number): this;
|
|
93
|
-
fontSize_exists(): boolean;
|
|
94
|
-
fontColor(): string;
|
|
95
|
-
fontColor(_: string): this;
|
|
96
|
-
fontColor_exists(): boolean;
|
|
97
|
-
fontFamily(): string;
|
|
98
|
-
fontFamily(_: string): this;
|
|
99
|
-
fontFamily_exists(): boolean;
|
|
100
|
-
fontBold(): boolean;
|
|
101
|
-
fontBold(_: boolean): this;
|
|
102
|
-
fontBold_exists(): boolean;
|
|
103
|
-
backgroundColor(): string;
|
|
104
|
-
backgroundColor(_: string): this;
|
|
105
|
-
backgroundColor_exists(): boolean;
|
|
106
|
-
|
|
107
|
-
responsive(): boolean;
|
|
108
|
-
responsive(_: boolean): this;
|
|
109
|
-
|
|
110
|
-
widgets(): any[];
|
|
111
|
-
widgets(_: any[]): this;
|
|
112
|
-
widgetClasses(): string[];
|
|
113
|
-
widgetClasses(_: string[]): this;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
Toolbar.prototype.publish("title", "", "string", "Title", null, { tags: ["Intermediate"] });
|
|
117
|
-
|
|
118
|
-
Toolbar.prototype.publish("fontSize", null, "number", "Title Font Size (px)", null, { tags: ["Advanced"], optional: true });
|
|
119
|
-
Toolbar.prototype.publish("fontColor", null, "html-color", "Title Font Color", null, { tags: ["Advanced"], optional: true });
|
|
120
|
-
Toolbar.prototype.publish("fontFamily", null, "string", "Title Font Family", null, { tags: ["Advanced"], optional: true });
|
|
121
|
-
Toolbar.prototype.publish("fontBold", true, "boolean", "Enable Bold Title Font", null, { tags: ["Advanced"], optional: true });
|
|
122
|
-
Toolbar.prototype.publish("backgroundColor", null, "html-color", "Background Color", null, { tags: ["Intermediate"], optional: true });
|
|
123
|
-
|
|
124
|
-
Toolbar.prototype.publish("responsive", true, "boolean", "Adapts to pixel width", null, { tags: ["Basic"] });
|
|
125
|
-
|
|
126
|
-
Toolbar.prototype.publish("widgets", [], "widgetArray", "Child widgets of the toolbar", null, { tags: ["Basic"] });
|
|
127
|
-
Toolbar.prototype.publish("widgetClasses", [], "array", "Array of Html Element classes to be assigned to the child widgets (shares index with widgets param)", null, { tags: ["Basic"] });
|
|
1
|
+
import { HTMLWidget, Widget } from "@hpcc-js/common";
|
|
2
|
+
import { select as d3Select } from "d3-selection";
|
|
3
|
+
|
|
4
|
+
import "../src/Toolbar.css";
|
|
5
|
+
|
|
6
|
+
export class Toolbar extends HTMLWidget {
|
|
7
|
+
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
this._tag = "div";
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
enter(domNode, element) {
|
|
14
|
+
super.enter(domNode, element);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
update(domNode, element) {
|
|
18
|
+
super.update(domNode, element);
|
|
19
|
+
const context = this;
|
|
20
|
+
|
|
21
|
+
element
|
|
22
|
+
.attr("title", context.title())
|
|
23
|
+
.style("background-color", this.backgroundColor())
|
|
24
|
+
;
|
|
25
|
+
|
|
26
|
+
const title = element.selectAll("div.toolbar-title")
|
|
27
|
+
.data(this.title() ? [this.title()] : []);
|
|
28
|
+
title.enter().append("div")
|
|
29
|
+
.classed("toolbar-title", true)
|
|
30
|
+
.append("span")
|
|
31
|
+
;
|
|
32
|
+
title.selectAll("div.toolbar-title > span")
|
|
33
|
+
.style("font-size", this.fontSize_exists() ? this.fontSize() + "px" : null)
|
|
34
|
+
.style("color", this.fontColor_exists() ? this.fontColor() : null)
|
|
35
|
+
.style("font-family", this.fontFamily_exists() ? this.fontFamily() : null)
|
|
36
|
+
.style("font-weight", this.fontBold_exists() ? (this.fontBold() ? "bold" : "normal") : null)
|
|
37
|
+
.style("background-color", this.backgroundColor_exists() ? this.backgroundColor() : null)
|
|
38
|
+
.text(context.title())
|
|
39
|
+
;
|
|
40
|
+
title.exit().remove();
|
|
41
|
+
|
|
42
|
+
const childWidgets = element.selectAll("div.toolbar-child")
|
|
43
|
+
.data(this.widgets() !== null ? this.widgets() : [], function (d) { return d.id(); });
|
|
44
|
+
|
|
45
|
+
childWidgets.enter().insert("div", "div.toolbar-title")
|
|
46
|
+
.each(function (d, i) {
|
|
47
|
+
const widgetClass = context.widgetClasses()[i] ? context.widgetClasses()[i] + " toolbar-child" : "toolbar-child";
|
|
48
|
+
d3Select(this).classed(widgetClass, true);
|
|
49
|
+
d.target(this);
|
|
50
|
+
});
|
|
51
|
+
childWidgets.exit().each(function (d) {
|
|
52
|
+
d.target(null);
|
|
53
|
+
}).remove();
|
|
54
|
+
childWidgets.order();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
render(callback?: (w: Widget) => void): this {
|
|
58
|
+
const context = this;
|
|
59
|
+
return super.render(function (w) {
|
|
60
|
+
const toolbarBBox = context.element().node().getBoundingClientRect();
|
|
61
|
+
let minX = toolbarBBox.left + toolbarBBox.width;
|
|
62
|
+
context.element().selectAll("div.toolbar-child")
|
|
63
|
+
.each(function (d, i) {
|
|
64
|
+
const childBBox = this.getBoundingClientRect();
|
|
65
|
+
if (minX > childBBox.left)
|
|
66
|
+
minX = childBBox.left;
|
|
67
|
+
})
|
|
68
|
+
;
|
|
69
|
+
context.element().select(".toolbar-title")
|
|
70
|
+
.style("width", (minX - toolbarBBox.left - 4) + "px")
|
|
71
|
+
;
|
|
72
|
+
if (callback) {
|
|
73
|
+
callback(w);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
exit(domNode, element) {
|
|
79
|
+
this.widgets().forEach(function (w) {
|
|
80
|
+
w.target(null);
|
|
81
|
+
});
|
|
82
|
+
super.exit(domNode, element);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
Toolbar.prototype._class += " layout_Toolbar";
|
|
86
|
+
|
|
87
|
+
export interface Toolbar {
|
|
88
|
+
title(): string;
|
|
89
|
+
title(_: string): this;
|
|
90
|
+
|
|
91
|
+
fontSize(): number;
|
|
92
|
+
fontSize(_: number): this;
|
|
93
|
+
fontSize_exists(): boolean;
|
|
94
|
+
fontColor(): string;
|
|
95
|
+
fontColor(_: string): this;
|
|
96
|
+
fontColor_exists(): boolean;
|
|
97
|
+
fontFamily(): string;
|
|
98
|
+
fontFamily(_: string): this;
|
|
99
|
+
fontFamily_exists(): boolean;
|
|
100
|
+
fontBold(): boolean;
|
|
101
|
+
fontBold(_: boolean): this;
|
|
102
|
+
fontBold_exists(): boolean;
|
|
103
|
+
backgroundColor(): string;
|
|
104
|
+
backgroundColor(_: string): this;
|
|
105
|
+
backgroundColor_exists(): boolean;
|
|
106
|
+
|
|
107
|
+
responsive(): boolean;
|
|
108
|
+
responsive(_: boolean): this;
|
|
109
|
+
|
|
110
|
+
widgets(): any[];
|
|
111
|
+
widgets(_: any[]): this;
|
|
112
|
+
widgetClasses(): string[];
|
|
113
|
+
widgetClasses(_: string[]): this;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
Toolbar.prototype.publish("title", "", "string", "Title", null, { tags: ["Intermediate"] });
|
|
117
|
+
|
|
118
|
+
Toolbar.prototype.publish("fontSize", null, "number", "Title Font Size (px)", null, { tags: ["Advanced"], optional: true });
|
|
119
|
+
Toolbar.prototype.publish("fontColor", null, "html-color", "Title Font Color", null, { tags: ["Advanced"], optional: true });
|
|
120
|
+
Toolbar.prototype.publish("fontFamily", null, "string", "Title Font Family", null, { tags: ["Advanced"], optional: true });
|
|
121
|
+
Toolbar.prototype.publish("fontBold", true, "boolean", "Enable Bold Title Font", null, { tags: ["Advanced"], optional: true });
|
|
122
|
+
Toolbar.prototype.publish("backgroundColor", null, "html-color", "Background Color", null, { tags: ["Intermediate"], optional: true });
|
|
123
|
+
|
|
124
|
+
Toolbar.prototype.publish("responsive", true, "boolean", "Adapts to pixel width", null, { tags: ["Basic"] });
|
|
125
|
+
|
|
126
|
+
Toolbar.prototype.publish("widgets", [], "widgetArray", "Child widgets of the toolbar", null, { tags: ["Basic"] });
|
|
127
|
+
Toolbar.prototype.publish("widgetClasses", [], "array", "Array of Html Element classes to be assigned to the child widgets (shares index with widgets param)", null, { tags: ["Basic"] });
|