@hpcc-js/layout 2.51.3 → 2.51.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/src/Surface.ts CHANGED
@@ -1,176 +1,176 @@
1
- import { HTMLWidget, Widget } from "@hpcc-js/common";
2
- import { select as d3Select } from "d3-selection";
3
-
4
- import "../src/Surface.css";
5
-
6
- export class Surface extends HTMLWidget {
7
- _surfaceButtons;
8
-
9
- constructor() {
10
- super();
11
-
12
- this._tag = "div";
13
- this._surfaceButtons = [];
14
- }
15
-
16
- widgetSize(titleDiv, widgetDiv) {
17
- let width = this.clientWidth();
18
- let height = this.clientHeight();
19
- if (this.title()) {
20
- height -= this.calcHeight(titleDiv);
21
- }
22
- height -= this.calcFrameHeight(widgetDiv);
23
- width -= this.calcFrameWidth(widgetDiv);
24
- return { width, height };
25
- }
26
-
27
- enter(domNode, element) {
28
- super.enter(domNode, element);
29
- }
30
-
31
- update(domNode, element2) {
32
- super.update(domNode, element2);
33
- const context = this;
34
-
35
- element2
36
- .classed("shadow2", this.surfaceShadow())
37
- .style("border-width", this.surfaceBorderWidth_exists() ? this.surfaceBorderWidth() + "px" : null)
38
- .style("border-color", this.surfaceBorderColor())
39
- .style("border-radius", this.surfaceBorderRadius_exists() ? this.surfaceBorderRadius() + "px" : null)
40
- .style("background-color", this.surfaceBackgroundColor())
41
- ;
42
-
43
- const titles = element2.selectAll(".surfaceTitle").data(this.title() ? [this.title()] : []);
44
- titles.enter().insert("h3", "div")
45
- .attr("class", "surfaceTitle")
46
- .merge(titles)
47
- .text(function (d) { return d; })
48
- .style("text-align", this.surfaceTitleAlignment())
49
- .style("color", this.surfaceTitleFontColor())
50
- .style("font-size", this.surfaceTitleFontSize_exists() ? this.surfaceTitleFontSize() + "px" : null)
51
- .style("font-family", this.surfaceTitleFontFamily())
52
- .style("font-weight", this.surfaceTitleFontBold() ? "bold" : "normal")
53
- .style("background-color", this.surfaceTitleBackgroundColor())
54
- .style("padding", this.surfaceTitlePadding_exists() ? this.surfaceTitlePadding() + "px" : null)
55
- .style("title", this.altText_exists() ? this.altText() : null)
56
- ;
57
- titles.exit().remove();
58
-
59
- const surfaceTitle = element2.select(".surfaceTitle");
60
-
61
- const surfaceButtons = surfaceTitle.append("div").attr("class", "html-button-container").selectAll(".surface-button").data(this.buttonAnnotations());
62
- surfaceButtons.enter().append("button").classed("surface-button", true)
63
- .each(function (button, idx) {
64
- const el = context._surfaceButtons[idx] = d3Select(this)
65
- .attr("class", "surface-button" + (button.class ? " " + button.class : ""))
66
- .attr("id", button.id)
67
- .style("padding", button.padding)
68
- .style("width", button.width)
69
- .style("height", button.height)
70
- .style("cursor", "pointer");
71
- if (button.font === "FontAwesome") {
72
- el
73
- .style("background", "transparent")
74
- .style("border", "none")
75
- .on("click", function (d) { context.click(d); })
76
- .append("i")
77
- .attr("class", "fa")
78
- .text(function () { return button.label; });
79
- } else {
80
- el
81
- .text(function () { return button.label; })
82
- .on("click", function (d) { context.click(d); });
83
- }
84
- })
85
- ;
86
- surfaceButtons.exit()
87
- .each(function (_d, idx) {
88
- const element = d3Select(this);
89
- delete context._surfaceButtons[idx];
90
- element.remove();
91
- })
92
- ;
93
- const widgets = element2.selectAll("#" + this._id + " > .surfaceWidget").data(this.widget() ? [this.widget()] : [], function (d) { return d._id; });
94
-
95
- widgets.enter().append("div")
96
- .attr("class", "surfaceWidget")
97
- .each(function (d) {
98
- d3Select(context.element().node().parentElement).classed("content-icon content-icon-" + (d.classID().split("_")[1]), true);
99
- d.target(this);
100
- })
101
- .merge(widgets)
102
- .style("padding", this.surfacePadding_exists() ? this.surfacePadding() + "px" : null)
103
- .each(function (d) {
104
- const widgetSize = context.widgetSize(element2.select("h3"), d3Select(this));
105
- if (widgetSize.width < 0) widgetSize.width = 0;
106
- if (widgetSize.height < 0) widgetSize.height = 0;
107
- d
108
- .resize({ width: widgetSize.width, height: widgetSize.height })
109
- ;
110
- })
111
- ;
112
- widgets.exit().each(function (d) {
113
- d.target(null);
114
- }).remove();
115
- }
116
-
117
- exit(domNode, element) {
118
- if (this.widget()) {
119
- this.widget().target(null);
120
- }
121
- super.exit(domNode, element);
122
- }
123
-
124
- title: { (): string; (_: string): Surface; };
125
- altText: { (): string; (_: string): Surface; };
126
- altText_exists: () => boolean;
127
- surfaceTitlePadding: { (): number; (_: number): Surface; };
128
- surfaceTitlePadding_exists: () => boolean;
129
- surfaceTitleFontSize: { (): number; (_: number): Surface; };
130
- surfaceTitleFontSize_exists: () => boolean;
131
- surfaceTitleFontColor: { (): string; (_: string): Surface; };
132
- surfaceTitleFontFamily: { (): string; (_: string): Surface; };
133
- surfaceTitleFontBold: { (): boolean; (_: boolean): Surface; };
134
- surfaceTitleBackgroundColor: { (): string; (_: string): Surface; };
135
- surfaceTitleAlignment: { (): string; (_: string): Surface; };
136
-
137
- surfaceShadow: { (): boolean; (_: boolean): Surface; };
138
- surfacePadding: { (): string; (_: string): Surface; };
139
- surfacePadding_exists: () => boolean;
140
- surfaceBackgroundColor: { (): string; (_: string): Surface; };
141
- surfaceBorderWidth: { (): number; (_: number): Surface; };
142
- surfaceBorderWidth_exists: () => boolean;
143
- surfaceBorderColor: { (): string; (_: string): Surface; };
144
- surfaceBorderRadius: { (): number; (_: number): Surface; };
145
- surfaceBorderRadius_exists: () => boolean;
146
-
147
- buttonAnnotations: { (): any[]; (_: any[]): Surface; };
148
-
149
- widget: { (): Widget; (_: Widget): Surface; };
150
-
151
- // Events ---
152
- click(obj) {
153
- }
154
- }
155
- Surface.prototype._class += " layout_Surface";
156
-
157
- Surface.prototype.publish("title", "", "string", "Title", null, { tags: ["Intermediate"] });
158
- Surface.prototype.publish("altText", null, "string", "Alt text", null, { optional: true });
159
- Surface.prototype.publish("surfaceTitlePadding", null, "number", "Title Padding (px)", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
160
- Surface.prototype.publish("surfaceTitleFontSize", null, "number", "Title Font Size (px)", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
161
- Surface.prototype.publish("surfaceTitleFontColor", null, "html-color", "Title Font Color", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
162
- Surface.prototype.publish("surfaceTitleFontFamily", null, "string", "Title Font Family", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
163
- Surface.prototype.publish("surfaceTitleFontBold", true, "boolean", "Enable Bold Title Font", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
164
- Surface.prototype.publish("surfaceTitleBackgroundColor", null, "html-color", "Title Background Color", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
165
- Surface.prototype.publish("surfaceTitleAlignment", "center", "set", "Title Alignment", ["left", "right", "center"], { tags: ["Basic"], disable: (w: any) => !w.title() });
166
-
167
- Surface.prototype.publish("surfaceShadow", false, "boolean", "3D Shadow");
168
- Surface.prototype.publish("surfacePadding", null, "string", "Surface Padding (px)", null, { tags: ["Intermediate"] });
169
- Surface.prototype.publish("surfaceBackgroundColor", null, "html-color", "Surface Background Color", null, { tags: ["Advanced"] });
170
- Surface.prototype.publish("surfaceBorderWidth", null, "number", "Surface Border Width (px)", null, { tags: ["Advanced"] });
171
- Surface.prototype.publish("surfaceBorderColor", null, "html-color", "Surface Border Color", null, { tags: ["Advanced"] });
172
- Surface.prototype.publish("surfaceBorderRadius", null, "number", "Surface Border Radius (px)", null, { tags: ["Advanced"] });
173
-
174
- Surface.prototype.publish("buttonAnnotations", [], "array", "Button Array", null, { tags: ["Private"] });
175
-
176
- Surface.prototype.publish("widget", null, "widget", "Widget", null, { tags: ["Basic"] });
1
+ import { HTMLWidget, Widget } from "@hpcc-js/common";
2
+ import { select as d3Select } from "d3-selection";
3
+
4
+ import "../src/Surface.css";
5
+
6
+ export class Surface extends HTMLWidget {
7
+ _surfaceButtons;
8
+
9
+ constructor() {
10
+ super();
11
+
12
+ this._tag = "div";
13
+ this._surfaceButtons = [];
14
+ }
15
+
16
+ widgetSize(titleDiv, widgetDiv) {
17
+ let width = this.clientWidth();
18
+ let height = this.clientHeight();
19
+ if (this.title()) {
20
+ height -= this.calcHeight(titleDiv);
21
+ }
22
+ height -= this.calcFrameHeight(widgetDiv);
23
+ width -= this.calcFrameWidth(widgetDiv);
24
+ return { width, height };
25
+ }
26
+
27
+ enter(domNode, element) {
28
+ super.enter(domNode, element);
29
+ }
30
+
31
+ update(domNode, element2) {
32
+ super.update(domNode, element2);
33
+ const context = this;
34
+
35
+ element2
36
+ .classed("shadow2", this.surfaceShadow())
37
+ .style("border-width", this.surfaceBorderWidth_exists() ? this.surfaceBorderWidth() + "px" : null)
38
+ .style("border-color", this.surfaceBorderColor())
39
+ .style("border-radius", this.surfaceBorderRadius_exists() ? this.surfaceBorderRadius() + "px" : null)
40
+ .style("background-color", this.surfaceBackgroundColor())
41
+ ;
42
+
43
+ const titles = element2.selectAll(".surfaceTitle").data(this.title() ? [this.title()] : []);
44
+ titles.enter().insert("h3", "div")
45
+ .attr("class", "surfaceTitle")
46
+ .merge(titles)
47
+ .text(function (d) { return d; })
48
+ .style("text-align", this.surfaceTitleAlignment())
49
+ .style("color", this.surfaceTitleFontColor())
50
+ .style("font-size", this.surfaceTitleFontSize_exists() ? this.surfaceTitleFontSize() + "px" : null)
51
+ .style("font-family", this.surfaceTitleFontFamily())
52
+ .style("font-weight", this.surfaceTitleFontBold() ? "bold" : "normal")
53
+ .style("background-color", this.surfaceTitleBackgroundColor())
54
+ .style("padding", this.surfaceTitlePadding_exists() ? this.surfaceTitlePadding() + "px" : null)
55
+ .style("title", this.altText_exists() ? this.altText() : null)
56
+ ;
57
+ titles.exit().remove();
58
+
59
+ const surfaceTitle = element2.select(".surfaceTitle");
60
+
61
+ const surfaceButtons = surfaceTitle.append("div").attr("class", "html-button-container").selectAll(".surface-button").data(this.buttonAnnotations());
62
+ surfaceButtons.enter().append("button").classed("surface-button", true)
63
+ .each(function (button, idx) {
64
+ const el = context._surfaceButtons[idx] = d3Select(this)
65
+ .attr("class", "surface-button" + (button.class ? " " + button.class : ""))
66
+ .attr("id", button.id)
67
+ .style("padding", button.padding)
68
+ .style("width", button.width)
69
+ .style("height", button.height)
70
+ .style("cursor", "pointer");
71
+ if (button.font === "FontAwesome") {
72
+ el
73
+ .style("background", "transparent")
74
+ .style("border", "none")
75
+ .on("click", function (d) { context.click(d); })
76
+ .append("i")
77
+ .attr("class", "fa")
78
+ .text(function () { return button.label; });
79
+ } else {
80
+ el
81
+ .text(function () { return button.label; })
82
+ .on("click", function (d) { context.click(d); });
83
+ }
84
+ })
85
+ ;
86
+ surfaceButtons.exit()
87
+ .each(function (_d, idx) {
88
+ const element = d3Select(this);
89
+ delete context._surfaceButtons[idx];
90
+ element.remove();
91
+ })
92
+ ;
93
+ const widgets = element2.selectAll("#" + this._id + " > .surfaceWidget").data(this.widget() ? [this.widget()] : [], function (d) { return d._id; });
94
+
95
+ widgets.enter().append("div")
96
+ .attr("class", "surfaceWidget")
97
+ .each(function (d) {
98
+ d3Select(context.element().node().parentElement).classed("content-icon content-icon-" + (d.classID().split("_")[1]), true);
99
+ d.target(this);
100
+ })
101
+ .merge(widgets)
102
+ .style("padding", this.surfacePadding_exists() ? this.surfacePadding() + "px" : null)
103
+ .each(function (d) {
104
+ const widgetSize = context.widgetSize(element2.select("h3"), d3Select(this));
105
+ if (widgetSize.width < 0) widgetSize.width = 0;
106
+ if (widgetSize.height < 0) widgetSize.height = 0;
107
+ d
108
+ .resize({ width: widgetSize.width, height: widgetSize.height })
109
+ ;
110
+ })
111
+ ;
112
+ widgets.exit().each(function (d) {
113
+ d.target(null);
114
+ }).remove();
115
+ }
116
+
117
+ exit(domNode, element) {
118
+ if (this.widget()) {
119
+ this.widget().target(null);
120
+ }
121
+ super.exit(domNode, element);
122
+ }
123
+
124
+ title: { (): string; (_: string): Surface; };
125
+ altText: { (): string; (_: string): Surface; };
126
+ altText_exists: () => boolean;
127
+ surfaceTitlePadding: { (): number; (_: number): Surface; };
128
+ surfaceTitlePadding_exists: () => boolean;
129
+ surfaceTitleFontSize: { (): number; (_: number): Surface; };
130
+ surfaceTitleFontSize_exists: () => boolean;
131
+ surfaceTitleFontColor: { (): string; (_: string): Surface; };
132
+ surfaceTitleFontFamily: { (): string; (_: string): Surface; };
133
+ surfaceTitleFontBold: { (): boolean; (_: boolean): Surface; };
134
+ surfaceTitleBackgroundColor: { (): string; (_: string): Surface; };
135
+ surfaceTitleAlignment: { (): string; (_: string): Surface; };
136
+
137
+ surfaceShadow: { (): boolean; (_: boolean): Surface; };
138
+ surfacePadding: { (): string; (_: string): Surface; };
139
+ surfacePadding_exists: () => boolean;
140
+ surfaceBackgroundColor: { (): string; (_: string): Surface; };
141
+ surfaceBorderWidth: { (): number; (_: number): Surface; };
142
+ surfaceBorderWidth_exists: () => boolean;
143
+ surfaceBorderColor: { (): string; (_: string): Surface; };
144
+ surfaceBorderRadius: { (): number; (_: number): Surface; };
145
+ surfaceBorderRadius_exists: () => boolean;
146
+
147
+ buttonAnnotations: { (): any[]; (_: any[]): Surface; };
148
+
149
+ widget: { (): Widget; (_: Widget): Surface; };
150
+
151
+ // Events ---
152
+ click(obj) {
153
+ }
154
+ }
155
+ Surface.prototype._class += " layout_Surface";
156
+
157
+ Surface.prototype.publish("title", "", "string", "Title", null, { tags: ["Intermediate"] });
158
+ Surface.prototype.publish("altText", null, "string", "Alt text", null, { optional: true });
159
+ Surface.prototype.publish("surfaceTitlePadding", null, "number", "Title Padding (px)", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
160
+ Surface.prototype.publish("surfaceTitleFontSize", null, "number", "Title Font Size (px)", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
161
+ Surface.prototype.publish("surfaceTitleFontColor", null, "html-color", "Title Font Color", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
162
+ Surface.prototype.publish("surfaceTitleFontFamily", null, "string", "Title Font Family", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
163
+ Surface.prototype.publish("surfaceTitleFontBold", true, "boolean", "Enable Bold Title Font", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
164
+ Surface.prototype.publish("surfaceTitleBackgroundColor", null, "html-color", "Title Background Color", null, { tags: ["Advanced"], disable: (w: any) => !w.title() });
165
+ Surface.prototype.publish("surfaceTitleAlignment", "center", "set", "Title Alignment", ["left", "right", "center"], { tags: ["Basic"], disable: (w: any) => !w.title() });
166
+
167
+ Surface.prototype.publish("surfaceShadow", false, "boolean", "3D Shadow");
168
+ Surface.prototype.publish("surfacePadding", null, "string", "Surface Padding (px)", null, { tags: ["Intermediate"] });
169
+ Surface.prototype.publish("surfaceBackgroundColor", null, "html-color", "Surface Background Color", null, { tags: ["Advanced"] });
170
+ Surface.prototype.publish("surfaceBorderWidth", null, "number", "Surface Border Width (px)", null, { tags: ["Advanced"] });
171
+ Surface.prototype.publish("surfaceBorderColor", null, "html-color", "Surface Border Color", null, { tags: ["Advanced"] });
172
+ Surface.prototype.publish("surfaceBorderRadius", null, "number", "Surface Border Radius (px)", null, { tags: ["Advanced"] });
173
+
174
+ Surface.prototype.publish("buttonAnnotations", [], "array", "Button Array", null, { tags: ["Private"] });
175
+
176
+ Surface.prototype.publish("widget", null, "widget", "Widget", null, { tags: ["Basic"] });
package/src/Tabbed.css CHANGED
@@ -1,23 +1,23 @@
1
- .layout_Tabbed .tab-button {
2
- position: relative;
3
- top: 1px;
4
- display: inline-block;
5
- border-left: 1px solid #ddd;
6
- border-top: 1px solid #ddd;
7
- border-right: 1px solid #ddd;
8
- background-color: transparent;
9
- margin-right: 4px;
10
- padding: 2px;
11
- padding-bottom: 4px;
12
- background-color: #ccc;
13
- }
14
-
15
- .layout_Tabbed .tab-button.active {
16
- background-color: white;
17
- z-index:999;
18
- }
19
- .layout_Tabbed .on_bottom .tab-button {
20
- border-bottom: 1px solid #ddd;
21
- border-top: none;
22
- top: -1px;
1
+ .layout_Tabbed .tab-button {
2
+ position: relative;
3
+ top: 1px;
4
+ display: inline-block;
5
+ border-left: 1px solid #ddd;
6
+ border-top: 1px solid #ddd;
7
+ border-right: 1px solid #ddd;
8
+ background-color: transparent;
9
+ margin-right: 4px;
10
+ padding: 2px;
11
+ padding-bottom: 4px;
12
+ background-color: #ccc;
13
+ }
14
+
15
+ .layout_Tabbed .tab-button.active {
16
+ background-color: white;
17
+ z-index:999;
18
+ }
19
+ .layout_Tabbed .on_bottom .tab-button {
20
+ border-bottom: 1px solid #ddd;
21
+ border-top: none;
22
+ top: -1px;
23
23
  }