@hpcc-js/common 3.6.3 → 3.6.5

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 (54) hide show
  1. package/LICENSE +43 -43
  2. package/README.md +59 -59
  3. package/dist/index.js +1 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.umd.cjs +1 -1
  6. package/dist/index.umd.cjs.map +1 -1
  7. package/package.json +4 -4
  8. package/src/CanvasWidget.ts +31 -31
  9. package/src/Class.ts +72 -72
  10. package/src/Database.ts +860 -860
  11. package/src/Entity.ts +235 -235
  12. package/src/EntityCard.ts +66 -66
  13. package/src/EntityPin.ts +103 -103
  14. package/src/EntityRect.css +15 -15
  15. package/src/EntityRect.ts +254 -254
  16. package/src/EntityVertex.ts +86 -86
  17. package/src/FAChar.css +2 -2
  18. package/src/FAChar.ts +89 -89
  19. package/src/HTMLWidget.ts +191 -191
  20. package/src/IList.ts +4 -4
  21. package/src/IMenu.ts +5 -5
  22. package/src/Icon.css +9 -9
  23. package/src/Icon.ts +176 -176
  24. package/src/Image.ts +104 -104
  25. package/src/List.css +13 -13
  26. package/src/List.ts +102 -102
  27. package/src/Menu.css +23 -23
  28. package/src/Menu.ts +139 -139
  29. package/src/Palette.ts +341 -341
  30. package/src/Platform.ts +125 -125
  31. package/src/ProgressBar.ts +115 -115
  32. package/src/PropertyExt.ts +770 -770
  33. package/src/ResizeSurface.css +39 -39
  34. package/src/ResizeSurface.ts +225 -225
  35. package/src/SVGWidget.ts +583 -583
  36. package/src/SVGZoomWidget.css +12 -12
  37. package/src/SVGZoomWidget.ts +427 -427
  38. package/src/Shape.css +3 -3
  39. package/src/Shape.ts +186 -186
  40. package/src/Surface.css +35 -35
  41. package/src/Surface.ts +364 -364
  42. package/src/Text.css +4 -4
  43. package/src/Text.ts +131 -131
  44. package/src/TextBox.css +4 -4
  45. package/src/TextBox.ts +183 -183
  46. package/src/TitleBar.css +114 -114
  47. package/src/TitleBar.ts +407 -407
  48. package/src/Transition.ts +45 -45
  49. package/src/Utility.ts +839 -839
  50. package/src/Widget.css +8 -8
  51. package/src/Widget.ts +731 -731
  52. package/src/WidgetArray.ts +15 -15
  53. package/src/__package__.ts +3 -3
  54. package/src/index.ts +55 -55
package/src/Surface.ts CHANGED
@@ -1,364 +1,364 @@
1
- import { select as d3Select } from "d3-selection";
2
- import "d3-transition";
3
- import { Icon } from "./Icon.ts";
4
- import { Menu } from "./Menu.ts";
5
- import { Shape } from "./Shape.ts";
6
- import { SVGWidget } from "./SVGWidget.ts";
7
- import { Text } from "./Text.ts";
8
-
9
- import "../src/Surface.css";
10
-
11
- export class Surface extends SVGWidget {
12
- _origMenuParam;
13
- _origShowContent;
14
-
15
- protected _iconWidget;
16
- protected _containerWidget;
17
- protected _titleRectWidget;
18
- protected _textWidget;
19
- _menuWidget;
20
- protected _surfaceButtons;
21
-
22
- protected _clipRect;
23
- protected buttonContainer;
24
-
25
- constructor() {
26
- super();
27
-
28
- this._iconWidget = new Icon()
29
- .faChar("\uf07b")
30
- .paddingPercent(50)
31
- ;
32
- this._containerWidget = new Shape()
33
- .class("container")
34
- .shape("rect")
35
- ;
36
- this._titleRectWidget = new Shape()
37
- .class("title")
38
- .shape("rect")
39
- ;
40
- this._textWidget = new Text()
41
- .class("title")
42
- ;
43
- this._menuWidget = new Menu()
44
- .paddingPercent(0)
45
- ;
46
- const context = this;
47
- this._menuWidget.preShowMenu = function () {
48
- if (context.content() && context.content().hasOverlay()) {
49
- context.content().visible(false);
50
- }
51
- };
52
- this._menuWidget.postHideMenu = function () {
53
- if (context.content() && context.content().hasOverlay()) {
54
- context.content().visible(true);
55
- }
56
- };
57
-
58
- this._surfaceButtons = [];
59
- }
60
-
61
- enter(_domNode, _element) {
62
- super.enter(_domNode, _element);
63
- const element = _element.append("g").attr("class", "frame");
64
- const domNode = element.node();
65
- this._clipRect = element.append("defs").append("clipPath")
66
- .attr("id", this.id() + "_clip")
67
- .append("rect")
68
- .attr("x", 0)
69
- .attr("y", 0)
70
- .attr("width", this._size.width)
71
- .attr("height", this._size.height)
72
- ;
73
- this._titleRectWidget
74
- .target(domNode)
75
- .render()
76
- .display(this.showTitle() && this.showIcon())
77
- ;
78
- this._iconWidget
79
- .target(domNode)
80
- .render()
81
- ;
82
- this._menuWidget
83
- .target(_domNode)
84
- ;
85
- this._textWidget
86
- .target(domNode)
87
- ;
88
- this._containerWidget
89
- .target(domNode)
90
- ;
91
- this.buttonContainer = d3Select(this._target).append("div").attr("class", "svg-button-container");
92
- }
93
-
94
- update(domNode, element) {
95
- super.update(domNode, element);
96
- const context = this;
97
-
98
- let width = this.width() - 1;
99
- const height = this.height() - 1;
100
-
101
- this._iconWidget
102
- .display(this.showTitle() && this.showIcon())
103
- .shape(this.icon_shape())
104
- .render()
105
- ;
106
- this._menuWidget
107
- .render()
108
- ;
109
- this._textWidget
110
- .text(this.title())
111
- .display(this.showTitle())
112
- .render()
113
- ;
114
-
115
- const surfaceButtons = this.buttonContainer.selectAll(".surface-button").data(this.buttonAnnotations());
116
- surfaceButtons.enter().append("button").attr("class", "surface-button")
117
- .each(function (button, idx) {
118
- const el = context._surfaceButtons[idx] = d3Select(this)
119
- .attr("class", "surface-button " + (button.class ? button.class : ""))
120
- .attr("id", button.id)
121
- .style("padding", button.padding)
122
- .style("width", button.width)
123
- .style("height", button.height)
124
- .style("cursor", "pointer")
125
- .on("click", function (d) { context.click(d); });
126
- if (button.font === "FontAwesome") {
127
- el
128
- .append("i")
129
- .attr("class", "fa")
130
- .text(function () { return button.label; });
131
- } else {
132
- el
133
- .text(function () { return button.label; });
134
- }
135
- })
136
- ;
137
- surfaceButtons.exit()
138
- .each(function (_d, idx) {
139
- const element2 = d3Select(this);
140
- delete context._surfaceButtons[idx];
141
- element2.remove();
142
- })
143
- ;
144
-
145
- const buttonClientHeight = this.showTitle() ? Math.max.apply(null, this._surfaceButtons.map(function (d) { return d.node().offsetHeight; })) : 0;
146
- const iconClientSize = this.showTitle() && this.showIcon() ? this._iconWidget.getBBox(true) : { width: 0, height: 0 };
147
- const textClientSize = this._textWidget.getBBox(true);
148
- const menuClientSize = this._menuWidget.getBBox(true);
149
- const _titleRegionHeight = Math.max(iconClientSize.height, textClientSize.height, menuClientSize.height, buttonClientHeight);
150
- const titleRegionHeight = this.showTitle() ? _titleRegionHeight : 0;
151
- const yTitle = (-height + _titleRegionHeight) / 2;
152
-
153
- const titleTextHeight = this.showTitle() ? Math.max(textClientSize.height, menuClientSize.height, buttonClientHeight) : 0;
154
- const titleTextWidth = this.showTitle() ? textClientSize.width + menuClientSize.width : 0;
155
- if (titleTextWidth > width) {
156
- width = titleTextWidth;
157
- }
158
-
159
- const topMargin = titleRegionHeight <= titleTextHeight ? 0 : (titleRegionHeight - titleTextHeight) / 2;
160
- const leftMargin = topMargin;
161
-
162
- this._titleRectWidget
163
- .pos({ x: leftMargin, y: yTitle })
164
- .width(width - leftMargin * 2)
165
- .height(titleTextHeight)
166
- .display(this.showTitle())
167
- .render()
168
- ;
169
- this._iconWidget
170
- .move({ x: -width / 2 + iconClientSize.width / 2, y: yTitle })
171
- ;
172
- this._menuWidget
173
- .move({ x: width / 2 - menuClientSize.width / 2 - this.menuPadding(), y: yTitle })
174
- ;
175
- this._textWidget
176
- .move({ x: (iconClientSize.width / 2 - menuClientSize.width / 2) / 2, y: yTitle })
177
- ;
178
-
179
- const xPos = context._titleRectWidget.node().getBoundingClientRect().left + (context._size.width - leftMargin * 2) - context.buttonGutter() - this.buttonContainer.node().offsetWidth;
180
- const yPos = context._titleRectWidget.node().getBoundingClientRect().top + ((titleTextHeight - this.buttonContainer.node().offsetHeight) / 2);
181
- if (!isNaN(xPos)) {
182
- this.buttonContainer.style("left", xPos + "px");
183
- }
184
- if (!isNaN(yPos)) {
185
- this.buttonContainer.style("top", yPos + "px");
186
- }
187
-
188
- if (this.showTitle()) {
189
- this._containerWidget
190
- .pos({ x: leftMargin / 2, y: titleRegionHeight / 2 - topMargin / 2 })
191
- .width(width - leftMargin)
192
- .height(height - titleRegionHeight + topMargin)
193
- .render()
194
- ;
195
- } else {
196
- this._containerWidget
197
- .pos({ x: 0, y: 0 })
198
- .width(width)
199
- .height(height)
200
- .render()
201
- ;
202
- }
203
-
204
- if (this.showContent()) {
205
- const xOffset = leftMargin;
206
- const yOffset = titleRegionHeight - topMargin;
207
-
208
- const content = element.selectAll(".content").data(this.content() ? [this.content()] : [], function (d) { return d._id; });
209
- content.enter().append("g")
210
- .attr("class", "content")
211
- .attr("clip-path", "url(#" + this.id() + "_clip)")
212
- .each(function (d) {
213
- d.target(this);
214
- })
215
- .merge(content)
216
- .attr("transform", "translate(" + (leftMargin / 2) + ", " + (titleRegionHeight / 2 - topMargin / 2) + ")")
217
- .each(function (d) {
218
- const padding = {
219
- left: 0,
220
- top: 0,
221
- right: 1,
222
- bottom: 1
223
- };
224
- d
225
- .resize({
226
- width: width - xOffset - (padding.left + padding.right),
227
- height: height - yOffset - (padding.top + padding.bottom)
228
- })
229
- ;
230
- })
231
- ;
232
- if (this.content()) {
233
- this._clipRect
234
- .attr("x", -(width - xOffset) / 2)
235
- .attr("y", -(height - yOffset) / 2)
236
- .attr("width", width - xOffset)
237
- .attr("height", height - yOffset)
238
- ;
239
- }
240
- content.exit().transition()
241
- .each(function (d) { d.target(null); })
242
- .remove()
243
- ;
244
- }
245
-
246
- if (this._menuWidget.element() && this._menuWidget.element().node() && this._menuWidget.element().node().parentNode) {
247
- this._menuWidget.element().node().parentNode.appendChild(this._menuWidget.element().node()); // Make sure menu is on top (Z-Order POV)
248
- }
249
- }
250
-
251
- exit(domNode, element) {
252
- this._titleRectWidget
253
- .target(null)
254
- ;
255
- this._iconWidget
256
- .target(null)
257
- ;
258
- this._menuWidget
259
- .target(null)
260
- ;
261
- this._textWidget
262
- .target(null)
263
- ;
264
- this._containerWidget
265
- .target(null)
266
- ;
267
- if (this.content()) {
268
- this.content().target(null);
269
- }
270
- super.exit(domNode, element);
271
- }
272
-
273
- intersection(pointA, pointB) {
274
- const hits = [];
275
- const i1 = this._iconWidget.intersection(pointA, pointB, this._pos);
276
- if (i1) {
277
- hits.push({ i: i1, d: this.distance(i1, pointB) });
278
- }
279
- const i2 = this._titleRectWidget.intersection(pointA, pointB);
280
- if (i2) {
281
- hits.push({ i: i2, d: this.distance(i2, pointB) });
282
- }
283
- const i3 = this._containerWidget.intersection(pointA, pointB);
284
- if (i3) {
285
- hits.push({ i: i3, d: this.distance(i3, pointB) });
286
- }
287
- let nearest = null;
288
- hits.forEach(function (item) {
289
- if (nearest === null || nearest.d > item.d) {
290
- nearest = item;
291
- }
292
- });
293
- return nearest && nearest.i ? nearest.i : null;
294
- }
295
-
296
- click(d) {
297
- }
298
-
299
- }
300
- Surface.prototype._class += " common_Surface";
301
-
302
- export interface Surface {
303
- showTitle(): boolean;
304
- showTitle(_: boolean): this;
305
- title(): string;
306
- title(_: string): this;
307
- titleFontSize(): string;
308
- titleFontSize(_: string): this;
309
- showIcon(): boolean;
310
- showIcon(_: boolean): this;
311
- icon_faChar(): string;
312
- icon_faChar(_: string): this;
313
- icon_shape(): string;
314
- icon_shape(_: string): this;
315
- content(): any;
316
- content(_: any): this;
317
- buttonAnnotations(): any[];
318
- buttonAnnotations(_: any[]): this;
319
- buttonGutter(): number;
320
- buttonGutter(_: number): this;
321
- showContent(): boolean;
322
- showContent(_: boolean): this;
323
- menu(): any[];
324
- menu(_: any[]): this;
325
- menuPadding(): number;
326
- menuPadding(_: number): this;
327
- }
328
-
329
- Surface.prototype.publish("showTitle", true, "boolean", "Show Title", null, { tags: ["Basic"] });
330
- Surface.prototype.publish("title", "", "string", "Title", null, { tags: ["Basic"] });
331
- Surface.prototype.publishProxy("titleFontSize", "_textWidget", "fontSize");
332
- Surface.prototype.publish("showIcon", true, "boolean", "Show Title", null, { tags: ["Advanced"] });
333
- Surface.prototype.publishProxy("icon_faChar", "_iconWidget", "faChar");
334
- Surface.prototype.publishProxy("icon_shape", "_iconWidget", "shape");
335
-
336
- Surface.prototype.publish("content", null, "widget", "Content", null, { tags: ["Private"] });
337
-
338
- Surface.prototype.publish("buttonAnnotations", [], "array", "Button Array", null, { tags: ["Intermediate"] });
339
- Surface.prototype.publish("buttonGutter", 25, "number", "Space Between Menu and Buttons", null, { tags: ["Intermediate"] });
340
-
341
- Surface.prototype.publish("showContent", true, "boolean", "Show Content", null, { tags: ["Intermediate"] });
342
- Surface.prototype.publish("menu", [], "array", "Menu List Data", null, { tags: ["Intermediate"] });
343
- Surface.prototype.publish("menuPadding", 2, "number", "Menu Padding", null, { tags: ["Advanced"] });
344
-
345
- Surface.prototype._origMenuParam = Surface.prototype.menu;
346
- Surface.prototype.menu = function (this: Surface, _?) {
347
- Surface.prototype._origMenuParam.apply(this, arguments);
348
- if (arguments.length) {
349
- this._menuWidget.data(_);
350
- return this;
351
- }
352
- return this._menuWidget.data();
353
- };
354
-
355
- Surface.prototype._origShowContent = Surface.prototype.showContent;
356
- Surface.prototype.showContent = function (_?) {
357
- const retVal = Surface.prototype._origShowContent.apply(this, arguments);
358
- if (arguments.length) {
359
- if (this.content()) {
360
- this.content().visible(this.showContent());
361
- }
362
- }
363
- return retVal;
364
- };
1
+ import { select as d3Select } from "d3-selection";
2
+ import "d3-transition";
3
+ import { Icon } from "./Icon.ts";
4
+ import { Menu } from "./Menu.ts";
5
+ import { Shape } from "./Shape.ts";
6
+ import { SVGWidget } from "./SVGWidget.ts";
7
+ import { Text } from "./Text.ts";
8
+
9
+ import "../src/Surface.css";
10
+
11
+ export class Surface extends SVGWidget {
12
+ _origMenuParam;
13
+ _origShowContent;
14
+
15
+ protected _iconWidget;
16
+ protected _containerWidget;
17
+ protected _titleRectWidget;
18
+ protected _textWidget;
19
+ _menuWidget;
20
+ protected _surfaceButtons;
21
+
22
+ protected _clipRect;
23
+ protected buttonContainer;
24
+
25
+ constructor() {
26
+ super();
27
+
28
+ this._iconWidget = new Icon()
29
+ .faChar("\uf07b")
30
+ .paddingPercent(50)
31
+ ;
32
+ this._containerWidget = new Shape()
33
+ .class("container")
34
+ .shape("rect")
35
+ ;
36
+ this._titleRectWidget = new Shape()
37
+ .class("title")
38
+ .shape("rect")
39
+ ;
40
+ this._textWidget = new Text()
41
+ .class("title")
42
+ ;
43
+ this._menuWidget = new Menu()
44
+ .paddingPercent(0)
45
+ ;
46
+ const context = this;
47
+ this._menuWidget.preShowMenu = function () {
48
+ if (context.content() && context.content().hasOverlay()) {
49
+ context.content().visible(false);
50
+ }
51
+ };
52
+ this._menuWidget.postHideMenu = function () {
53
+ if (context.content() && context.content().hasOverlay()) {
54
+ context.content().visible(true);
55
+ }
56
+ };
57
+
58
+ this._surfaceButtons = [];
59
+ }
60
+
61
+ enter(_domNode, _element) {
62
+ super.enter(_domNode, _element);
63
+ const element = _element.append("g").attr("class", "frame");
64
+ const domNode = element.node();
65
+ this._clipRect = element.append("defs").append("clipPath")
66
+ .attr("id", this.id() + "_clip")
67
+ .append("rect")
68
+ .attr("x", 0)
69
+ .attr("y", 0)
70
+ .attr("width", this._size.width)
71
+ .attr("height", this._size.height)
72
+ ;
73
+ this._titleRectWidget
74
+ .target(domNode)
75
+ .render()
76
+ .display(this.showTitle() && this.showIcon())
77
+ ;
78
+ this._iconWidget
79
+ .target(domNode)
80
+ .render()
81
+ ;
82
+ this._menuWidget
83
+ .target(_domNode)
84
+ ;
85
+ this._textWidget
86
+ .target(domNode)
87
+ ;
88
+ this._containerWidget
89
+ .target(domNode)
90
+ ;
91
+ this.buttonContainer = d3Select(this._target).append("div").attr("class", "svg-button-container");
92
+ }
93
+
94
+ update(domNode, element) {
95
+ super.update(domNode, element);
96
+ const context = this;
97
+
98
+ let width = this.width() - 1;
99
+ const height = this.height() - 1;
100
+
101
+ this._iconWidget
102
+ .display(this.showTitle() && this.showIcon())
103
+ .shape(this.icon_shape())
104
+ .render()
105
+ ;
106
+ this._menuWidget
107
+ .render()
108
+ ;
109
+ this._textWidget
110
+ .text(this.title())
111
+ .display(this.showTitle())
112
+ .render()
113
+ ;
114
+
115
+ const surfaceButtons = this.buttonContainer.selectAll(".surface-button").data(this.buttonAnnotations());
116
+ surfaceButtons.enter().append("button").attr("class", "surface-button")
117
+ .each(function (button, idx) {
118
+ const el = context._surfaceButtons[idx] = d3Select(this)
119
+ .attr("class", "surface-button " + (button.class ? button.class : ""))
120
+ .attr("id", button.id)
121
+ .style("padding", button.padding)
122
+ .style("width", button.width)
123
+ .style("height", button.height)
124
+ .style("cursor", "pointer")
125
+ .on("click", function (d) { context.click(d); });
126
+ if (button.font === "FontAwesome") {
127
+ el
128
+ .append("i")
129
+ .attr("class", "fa")
130
+ .text(function () { return button.label; });
131
+ } else {
132
+ el
133
+ .text(function () { return button.label; });
134
+ }
135
+ })
136
+ ;
137
+ surfaceButtons.exit()
138
+ .each(function (_d, idx) {
139
+ const element2 = d3Select(this);
140
+ delete context._surfaceButtons[idx];
141
+ element2.remove();
142
+ })
143
+ ;
144
+
145
+ const buttonClientHeight = this.showTitle() ? Math.max.apply(null, this._surfaceButtons.map(function (d) { return d.node().offsetHeight; })) : 0;
146
+ const iconClientSize = this.showTitle() && this.showIcon() ? this._iconWidget.getBBox(true) : { width: 0, height: 0 };
147
+ const textClientSize = this._textWidget.getBBox(true);
148
+ const menuClientSize = this._menuWidget.getBBox(true);
149
+ const _titleRegionHeight = Math.max(iconClientSize.height, textClientSize.height, menuClientSize.height, buttonClientHeight);
150
+ const titleRegionHeight = this.showTitle() ? _titleRegionHeight : 0;
151
+ const yTitle = (-height + _titleRegionHeight) / 2;
152
+
153
+ const titleTextHeight = this.showTitle() ? Math.max(textClientSize.height, menuClientSize.height, buttonClientHeight) : 0;
154
+ const titleTextWidth = this.showTitle() ? textClientSize.width + menuClientSize.width : 0;
155
+ if (titleTextWidth > width) {
156
+ width = titleTextWidth;
157
+ }
158
+
159
+ const topMargin = titleRegionHeight <= titleTextHeight ? 0 : (titleRegionHeight - titleTextHeight) / 2;
160
+ const leftMargin = topMargin;
161
+
162
+ this._titleRectWidget
163
+ .pos({ x: leftMargin, y: yTitle })
164
+ .width(width - leftMargin * 2)
165
+ .height(titleTextHeight)
166
+ .display(this.showTitle())
167
+ .render()
168
+ ;
169
+ this._iconWidget
170
+ .move({ x: -width / 2 + iconClientSize.width / 2, y: yTitle })
171
+ ;
172
+ this._menuWidget
173
+ .move({ x: width / 2 - menuClientSize.width / 2 - this.menuPadding(), y: yTitle })
174
+ ;
175
+ this._textWidget
176
+ .move({ x: (iconClientSize.width / 2 - menuClientSize.width / 2) / 2, y: yTitle })
177
+ ;
178
+
179
+ const xPos = context._titleRectWidget.node().getBoundingClientRect().left + (context._size.width - leftMargin * 2) - context.buttonGutter() - this.buttonContainer.node().offsetWidth;
180
+ const yPos = context._titleRectWidget.node().getBoundingClientRect().top + ((titleTextHeight - this.buttonContainer.node().offsetHeight) / 2);
181
+ if (!isNaN(xPos)) {
182
+ this.buttonContainer.style("left", xPos + "px");
183
+ }
184
+ if (!isNaN(yPos)) {
185
+ this.buttonContainer.style("top", yPos + "px");
186
+ }
187
+
188
+ if (this.showTitle()) {
189
+ this._containerWidget
190
+ .pos({ x: leftMargin / 2, y: titleRegionHeight / 2 - topMargin / 2 })
191
+ .width(width - leftMargin)
192
+ .height(height - titleRegionHeight + topMargin)
193
+ .render()
194
+ ;
195
+ } else {
196
+ this._containerWidget
197
+ .pos({ x: 0, y: 0 })
198
+ .width(width)
199
+ .height(height)
200
+ .render()
201
+ ;
202
+ }
203
+
204
+ if (this.showContent()) {
205
+ const xOffset = leftMargin;
206
+ const yOffset = titleRegionHeight - topMargin;
207
+
208
+ const content = element.selectAll(".content").data(this.content() ? [this.content()] : [], function (d) { return d._id; });
209
+ content.enter().append("g")
210
+ .attr("class", "content")
211
+ .attr("clip-path", "url(#" + this.id() + "_clip)")
212
+ .each(function (d) {
213
+ d.target(this);
214
+ })
215
+ .merge(content)
216
+ .attr("transform", "translate(" + (leftMargin / 2) + ", " + (titleRegionHeight / 2 - topMargin / 2) + ")")
217
+ .each(function (d) {
218
+ const padding = {
219
+ left: 0,
220
+ top: 0,
221
+ right: 1,
222
+ bottom: 1
223
+ };
224
+ d
225
+ .resize({
226
+ width: width - xOffset - (padding.left + padding.right),
227
+ height: height - yOffset - (padding.top + padding.bottom)
228
+ })
229
+ ;
230
+ })
231
+ ;
232
+ if (this.content()) {
233
+ this._clipRect
234
+ .attr("x", -(width - xOffset) / 2)
235
+ .attr("y", -(height - yOffset) / 2)
236
+ .attr("width", width - xOffset)
237
+ .attr("height", height - yOffset)
238
+ ;
239
+ }
240
+ content.exit().transition()
241
+ .each(function (d) { d.target(null); })
242
+ .remove()
243
+ ;
244
+ }
245
+
246
+ if (this._menuWidget.element() && this._menuWidget.element().node() && this._menuWidget.element().node().parentNode) {
247
+ this._menuWidget.element().node().parentNode.appendChild(this._menuWidget.element().node()); // Make sure menu is on top (Z-Order POV)
248
+ }
249
+ }
250
+
251
+ exit(domNode, element) {
252
+ this._titleRectWidget
253
+ .target(null)
254
+ ;
255
+ this._iconWidget
256
+ .target(null)
257
+ ;
258
+ this._menuWidget
259
+ .target(null)
260
+ ;
261
+ this._textWidget
262
+ .target(null)
263
+ ;
264
+ this._containerWidget
265
+ .target(null)
266
+ ;
267
+ if (this.content()) {
268
+ this.content().target(null);
269
+ }
270
+ super.exit(domNode, element);
271
+ }
272
+
273
+ intersection(pointA, pointB) {
274
+ const hits = [];
275
+ const i1 = this._iconWidget.intersection(pointA, pointB, this._pos);
276
+ if (i1) {
277
+ hits.push({ i: i1, d: this.distance(i1, pointB) });
278
+ }
279
+ const i2 = this._titleRectWidget.intersection(pointA, pointB);
280
+ if (i2) {
281
+ hits.push({ i: i2, d: this.distance(i2, pointB) });
282
+ }
283
+ const i3 = this._containerWidget.intersection(pointA, pointB);
284
+ if (i3) {
285
+ hits.push({ i: i3, d: this.distance(i3, pointB) });
286
+ }
287
+ let nearest = null;
288
+ hits.forEach(function (item) {
289
+ if (nearest === null || nearest.d > item.d) {
290
+ nearest = item;
291
+ }
292
+ });
293
+ return nearest && nearest.i ? nearest.i : null;
294
+ }
295
+
296
+ click(d) {
297
+ }
298
+
299
+ }
300
+ Surface.prototype._class += " common_Surface";
301
+
302
+ export interface Surface {
303
+ showTitle(): boolean;
304
+ showTitle(_: boolean): this;
305
+ title(): string;
306
+ title(_: string): this;
307
+ titleFontSize(): string;
308
+ titleFontSize(_: string): this;
309
+ showIcon(): boolean;
310
+ showIcon(_: boolean): this;
311
+ icon_faChar(): string;
312
+ icon_faChar(_: string): this;
313
+ icon_shape(): string;
314
+ icon_shape(_: string): this;
315
+ content(): any;
316
+ content(_: any): this;
317
+ buttonAnnotations(): any[];
318
+ buttonAnnotations(_: any[]): this;
319
+ buttonGutter(): number;
320
+ buttonGutter(_: number): this;
321
+ showContent(): boolean;
322
+ showContent(_: boolean): this;
323
+ menu(): any[];
324
+ menu(_: any[]): this;
325
+ menuPadding(): number;
326
+ menuPadding(_: number): this;
327
+ }
328
+
329
+ Surface.prototype.publish("showTitle", true, "boolean", "Show Title", null, { tags: ["Basic"] });
330
+ Surface.prototype.publish("title", "", "string", "Title", null, { tags: ["Basic"] });
331
+ Surface.prototype.publishProxy("titleFontSize", "_textWidget", "fontSize");
332
+ Surface.prototype.publish("showIcon", true, "boolean", "Show Title", null, { tags: ["Advanced"] });
333
+ Surface.prototype.publishProxy("icon_faChar", "_iconWidget", "faChar");
334
+ Surface.prototype.publishProxy("icon_shape", "_iconWidget", "shape");
335
+
336
+ Surface.prototype.publish("content", null, "widget", "Content", null, { tags: ["Private"] });
337
+
338
+ Surface.prototype.publish("buttonAnnotations", [], "array", "Button Array", null, { tags: ["Intermediate"] });
339
+ Surface.prototype.publish("buttonGutter", 25, "number", "Space Between Menu and Buttons", null, { tags: ["Intermediate"] });
340
+
341
+ Surface.prototype.publish("showContent", true, "boolean", "Show Content", null, { tags: ["Intermediate"] });
342
+ Surface.prototype.publish("menu", [], "array", "Menu List Data", null, { tags: ["Intermediate"] });
343
+ Surface.prototype.publish("menuPadding", 2, "number", "Menu Padding", null, { tags: ["Advanced"] });
344
+
345
+ Surface.prototype._origMenuParam = Surface.prototype.menu;
346
+ Surface.prototype.menu = function (this: Surface, _?) {
347
+ Surface.prototype._origMenuParam.apply(this, arguments);
348
+ if (arguments.length) {
349
+ this._menuWidget.data(_);
350
+ return this;
351
+ }
352
+ return this._menuWidget.data();
353
+ };
354
+
355
+ Surface.prototype._origShowContent = Surface.prototype.showContent;
356
+ Surface.prototype.showContent = function (_?) {
357
+ const retVal = Surface.prototype._origShowContent.apply(this, arguments);
358
+ if (arguments.length) {
359
+ if (this.content()) {
360
+ this.content().visible(this.showContent());
361
+ }
362
+ }
363
+ return retVal;
364
+ };