@hpcc-js/html 2.43.0 → 3.1.0

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 (55) hide show
  1. package/dist/index.js +92 -1047
  2. package/dist/index.js.map +7 -1
  3. package/package.json +35 -34
  4. package/src/BreakdownTable.ts +5 -5
  5. package/src/HTMLTooltip.ts +19 -20
  6. package/src/JSXWidget.ts +4 -3
  7. package/src/SimpleTable.ts +1 -2
  8. package/src/StatsTable.ts +3 -3
  9. package/src/StyledTable.ts +15 -15
  10. package/src/TitleBar.ts +5 -2
  11. package/src/VizComponent.tsx +2 -2
  12. package/src/VizInstance.tsx +2 -2
  13. package/src/__package__.ts +2 -2
  14. package/src/index.ts +11 -11
  15. package/src/reactD3.ts +3 -3
  16. package/types/BreakdownTable.d.ts +3 -5
  17. package/types/HTMLTooltip.d.ts +0 -1
  18. package/types/JSXWidget.d.ts +3 -4
  19. package/types/SimpleTable.d.ts +0 -1
  20. package/types/StatsTable.d.ts +1 -2
  21. package/types/StyledTable.d.ts +1 -2
  22. package/types/TitleBar.d.ts +1 -3
  23. package/types/VizComponent.d.ts +3 -3
  24. package/types/VizInstance.d.ts +3 -3
  25. package/types/__package__.d.ts +2 -3
  26. package/types/index.d.ts +11 -12
  27. package/types/reactD3.d.ts +0 -1
  28. package/dist/index.es6.js +0 -1026
  29. package/dist/index.es6.js.map +0 -1
  30. package/dist/index.min.js +0 -2
  31. package/dist/index.min.js.map +0 -1
  32. package/types/BreakdownTable.d.ts.map +0 -1
  33. package/types/HTMLTooltip.d.ts.map +0 -1
  34. package/types/JSXWidget.d.ts.map +0 -1
  35. package/types/SimpleTable.d.ts.map +0 -1
  36. package/types/StatsTable.d.ts.map +0 -1
  37. package/types/StyledTable.d.ts.map +0 -1
  38. package/types/TitleBar.d.ts.map +0 -1
  39. package/types/VizComponent.d.ts.map +0 -1
  40. package/types/VizInstance.d.ts.map +0 -1
  41. package/types/__package__.d.ts.map +0 -1
  42. package/types/index.d.ts.map +0 -1
  43. package/types/reactD3.d.ts.map +0 -1
  44. package/types-3.4/BreakdownTable.d.ts +0 -49
  45. package/types-3.4/HTMLTooltip.d.ts +0 -107
  46. package/types-3.4/JSXWidget.d.ts +0 -9
  47. package/types-3.4/SimpleTable.d.ts +0 -16
  48. package/types-3.4/StatsTable.d.ts +0 -30
  49. package/types-3.4/StyledTable.d.ts +0 -49
  50. package/types-3.4/TitleBar.d.ts +0 -43
  51. package/types-3.4/VizComponent.d.ts +0 -10
  52. package/types-3.4/VizInstance.d.ts +0 -10
  53. package/types-3.4/__package__.d.ts +0 -4
  54. package/types-3.4/index.d.ts +0 -12
  55. package/types-3.4/reactD3.d.ts +0 -31
package/dist/index.es6.js DELETED
@@ -1,1026 +0,0 @@
1
- import { select, HTMLWidget, format } from '@hpcc-js/common';
2
- import { scopedLogger } from '@hpcc-js/util';
3
-
4
- var PKG_NAME = "@hpcc-js/html";
5
- var PKG_VERSION = "2.43.0";
6
- var BUILD_VERSION = "2.106.0";
7
-
8
- /******************************************************************************
9
- Copyright (c) Microsoft Corporation.
10
-
11
- Permission to use, copy, modify, and/or distribute this software for any
12
- purpose with or without fee is hereby granted.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
- PERFORMANCE OF THIS SOFTWARE.
21
- ***************************************************************************** */
22
- /* global Reflect, Promise, SuppressedError, Symbol */
23
-
24
- var extendStatics = function(d, b) {
25
- extendStatics = Object.setPrototypeOf ||
26
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
27
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
28
- return extendStatics(d, b);
29
- };
30
-
31
- function __extends(d, b) {
32
- if (typeof b !== "function" && b !== null)
33
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
34
- extendStatics(d, b);
35
- function __() { this.constructor = d; }
36
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
37
- }
38
-
39
- function __spreadArray(to, from, pack) {
40
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
41
- if (ar || !(i in from)) {
42
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
43
- ar[i] = from[i];
44
- }
45
- }
46
- return to.concat(ar || Array.prototype.slice.call(from));
47
- }
48
-
49
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
50
- var e = new Error(message);
51
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
- };
53
-
54
- var HTMLTooltip = /** @class */ (function (_super) {
55
- __extends(HTMLTooltip, _super);
56
- function HTMLTooltip() {
57
- var _this = _super.call(this) || this;
58
- _this._tooltipHTMLCallback = function (data) { return "<b>_tooltipHTMLCallback is undefined</b>"; };
59
- _this._logger = scopedLogger("html/HTMLTooltip");
60
- _this._closing = false;
61
- _this.visible(false);
62
- return _this;
63
- }
64
- HTMLTooltip.prototype.tooltipHTML = function (_) {
65
- this._tooltipHTMLCallback = _;
66
- return this;
67
- };
68
- HTMLTooltip.prototype.tooltipContent = function (_) {
69
- if (!arguments.length)
70
- return this._contentNode;
71
- this._contentNode = _;
72
- return this;
73
- };
74
- HTMLTooltip.prototype.triggerElement = function (_) {
75
- this._triggerElement = _;
76
- return this;
77
- };
78
- HTMLTooltip.prototype.enter = function (domNode, element) {
79
- _super.prototype.enter.call(this, domNode, element);
80
- var body = select("body");
81
- this._tooltipElement = body.append("div")
82
- .attr("class", "tooltip-div")
83
- .style("z-index", "2147483638")
84
- .style("position", "fixed");
85
- this._arrowElement = body.append("div")
86
- .attr("class", "arrow-div")
87
- .style("z-index", "2147483638")
88
- .style("position", "fixed");
89
- };
90
- HTMLTooltip.prototype.update = function (domNode, element) {
91
- var _this = this;
92
- _super.prototype.update.call(this, domNode, element);
93
- if (this._contentNode !== this._prevContentNode) {
94
- var node = this._tooltipElement.node();
95
- __spreadArray([], node.querySelectorAll("*"), true).map(function (n) { return n.__data__; })
96
- .filter(function (n) { return n; })
97
- .forEach(function (w) {
98
- if (typeof w.target === "function") {
99
- w.target(null);
100
- }
101
- if (typeof w.exit === "function") {
102
- w.exit();
103
- }
104
- });
105
- node.innerHTML = "";
106
- node.appendChild(this._contentNode);
107
- this._prevContentNode = this._contentNode;
108
- }
109
- if (this._contentNode) {
110
- this.onShowContent(this._contentNode);
111
- }
112
- else {
113
- this._tooltipElement
114
- .html(function () {
115
- return _this._tooltipHTMLCallback(_this.data());
116
- });
117
- }
118
- if (this.fitContent()) {
119
- this._tooltipElement
120
- .style("width", "auto")
121
- .style("height", "auto")
122
- .style("padding", "0px")
123
- .style("box-sizing", "content-box");
124
- var rect = this._tooltipElement.node().getBoundingClientRect();
125
- this.tooltipWidth_default(rect.width);
126
- this.tooltipHeight_default(rect.height);
127
- }
128
- this._closing = false;
129
- this._tooltipElement
130
- .style("background-color", this.tooltipColor())
131
- .style("color", this.fontColor())
132
- .style("width", this.tooltipWidth() + "px")
133
- .style("height", this.tooltipHeight() + "px")
134
- .style("opacity", 1)
135
- .style("padding", this.padding() + "px")
136
- .style("pointer-events", this.enablePointerEvents() ? "all" : "none")
137
- .style("box-sizing", "content-box");
138
- this._arrowElement
139
- .style("opacity", 1)
140
- .style("pointer-events", "none");
141
- this.updateTooltipPosition();
142
- };
143
- HTMLTooltip.prototype.onShowContent = function (node) {
144
- };
145
- HTMLTooltip.prototype.updateTooltipPosition = function () {
146
- var bbox = this.calcReferenceBBox();
147
- var direction = this.calcTooltipDirection(bbox);
148
- var box = bbox[direction];
149
- this._tooltipElement
150
- .style("top", box.y + "px")
151
- .style("left", box.x + "px");
152
- this.setArrowPosition(box, direction);
153
- return box;
154
- };
155
- HTMLTooltip.prototype.calcTooltipDirection = function (bbox) {
156
- var directions = Object.keys(bbox);
157
- var defaultDirection = this.direction();
158
- directions.sort(function (a, b) { return a === defaultDirection ? -1 : 1; });
159
- var windowRect = {
160
- top: 0,
161
- left: 0,
162
- width: window.innerWidth,
163
- height: window.innerHeight
164
- };
165
- for (var i = 0; i < directions.length; i++) {
166
- var tooltipRect = {
167
- top: bbox[directions[i]].y,
168
- left: bbox[directions[i]].x,
169
- width: this.tooltipWidth(),
170
- height: this.tooltipHeight()
171
- };
172
- if (this.rectFits(tooltipRect, windowRect)) {
173
- return directions[i];
174
- }
175
- }
176
- this._logger.warning("Tooltip doesn't fit in the window for any of the directions. Defaulting to '".concat(defaultDirection, "'"));
177
- this._logger.debug(windowRect);
178
- this._logger.debug({
179
- top: bbox[defaultDirection].y,
180
- left: bbox[defaultDirection].x,
181
- width: this.tooltipWidth(),
182
- height: this.tooltipHeight()
183
- });
184
- return defaultDirection;
185
- };
186
- HTMLTooltip.prototype.rectFits = function (innerRect, outerRect) {
187
- return (innerRect.top >= outerRect.top &&
188
- innerRect.left >= outerRect.left &&
189
- innerRect.width + innerRect.left <= outerRect.width + outerRect.left &&
190
- innerRect.height + innerRect.top <= outerRect.height + outerRect.top);
191
- };
192
- HTMLTooltip.prototype.setArrowPosition = function (point, direction) {
193
- var top;
194
- var left;
195
- var visibleBorderStyle = "border-top-color";
196
- this._arrowElement
197
- .style("border", "".concat(this.arrowHeight(), "px solid ").concat(this.tooltipColor()))
198
- .style("border-top-color", "transparent")
199
- .style("border-right-color", "transparent")
200
- .style("border-bottom-color", "transparent")
201
- .style("border-left-color", "transparent");
202
- switch (direction) {
203
- case "n":
204
- top = point.y + this.tooltipHeight() + (this.padding() * 2);
205
- left = point.x + (this.tooltipWidth() / 2) - (this.arrowWidth() / 2) + this.padding();
206
- visibleBorderStyle = "border-top-color";
207
- this._arrowElement
208
- .style("border-top-width", "".concat(this.arrowHeight(), "px"))
209
- .style("border-bottom-width", "0px")
210
- .style("border-left-width", "".concat(this.arrowWidth() / 2, "px"))
211
- .style("border-right-width", "".concat(this.arrowWidth() / 2, "px"));
212
- break;
213
- case "s":
214
- top = point.y - this.arrowHeight();
215
- left = point.x + this.padding() + (this.tooltipWidth() / 2) - (this.arrowWidth() / 2);
216
- visibleBorderStyle = "border-bottom-color";
217
- this._arrowElement
218
- .style("border-top-width", "0px")
219
- .style("border-bottom-width", "".concat(this.arrowHeight(), "px"))
220
- .style("border-left-width", "".concat(this.arrowWidth() / 2, "px"))
221
- .style("border-right-width", "".concat(this.arrowWidth() / 2, "px"));
222
- break;
223
- case "e":
224
- top = point.y + (this.tooltipHeight() / 2) + this.padding() - (this.arrowWidth() / 2);
225
- left = point.x - this.arrowHeight();
226
- visibleBorderStyle = "border-right-color";
227
- this._arrowElement
228
- .style("border-top-width", "".concat(this.arrowWidth() / 2, "px"))
229
- .style("border-bottom-width", "".concat(this.arrowWidth() / 2, "px"))
230
- .style("border-left-width", "0px")
231
- .style("border-right-width", "".concat(this.arrowHeight(), "px"));
232
- break;
233
- case "w":
234
- top = point.y + (this.tooltipHeight() / 2) - (this.arrowWidth() / 2) + this.padding();
235
- left = point.x + this.tooltipWidth() + (this.padding() * 2);
236
- visibleBorderStyle = "border-left-color";
237
- this._arrowElement
238
- .style("border-top-width", "".concat(this.arrowWidth() / 2, "px"))
239
- .style("border-bottom-width", "".concat(this.arrowWidth() / 2, "px"))
240
- .style("border-left-width", "".concat(this.arrowHeight(), "px"))
241
- .style("border-right-width", "0px");
242
- break;
243
- }
244
- if (typeof top !== "undefined" && typeof left !== "undefined") {
245
- this._arrowElement
246
- .style("top", top + "px")
247
- .style("left", left + "px")
248
- .style(visibleBorderStyle, this.tooltipColor())
249
- .style("opacity", 1);
250
- }
251
- else {
252
- this._arrowElement
253
- .style("opacity", 0);
254
- }
255
- return point;
256
- };
257
- HTMLTooltip.prototype.getReferenceNode = function () {
258
- if (!this._triggerElement) {
259
- return this.element().node().parentNode.parentNode;
260
- }
261
- return this._triggerElement.node();
262
- };
263
- HTMLTooltip.prototype.calcReferenceBBox = function () {
264
- var node = this.getReferenceNode();
265
- var _a = node.getBoundingClientRect(), top = _a.top, left = _a.left, width = _a.width, height = _a.height;
266
- var wholeW = this.tooltipWidth();
267
- var wholeH = this.tooltipHeight();
268
- var halfW = wholeW / 2;
269
- var halfH = wholeH / 2;
270
- var arrowH = this.arrowHeight();
271
- var p = this.padding();
272
- var p2 = p * 2;
273
- if (this.followCursor() && this._cursorLoc) {
274
- left = this._cursorLoc[0];
275
- top = this._cursorLoc[1];
276
- width = 1;
277
- height = 1;
278
- }
279
- var bbox = {
280
- n: {
281
- x: left + (width / 2) - halfW - p,
282
- y: top - wholeH - arrowH - p2
283
- },
284
- e: {
285
- x: left + width + arrowH,
286
- y: top + (height / 2) - halfH - p
287
- },
288
- s: {
289
- x: left + (width / 2) - halfW - p,
290
- y: top + height + arrowH
291
- },
292
- w: {
293
- x: left - wholeW - arrowH - p2,
294
- y: top + (height / 2) - halfH - p
295
- },
296
- nw: {
297
- x: left - wholeW - p2,
298
- y: top - wholeH - p2
299
- },
300
- ne: {
301
- x: left + width,
302
- y: top - wholeH - p2
303
- },
304
- se: {
305
- x: left + width,
306
- y: top + height
307
- },
308
- sw: {
309
- x: left - wholeW - p2,
310
- y: top + height
311
- }
312
- };
313
- return bbox;
314
- };
315
- HTMLTooltip.prototype.mouseout = function () {
316
- var _this = this;
317
- this._closing = true;
318
- this._tooltipElement.on("mouseover", function () {
319
- _this._closing = false;
320
- });
321
- this._tooltipElement.on("mouseout", function () {
322
- _this.mouseout();
323
- });
324
- setTimeout(function () {
325
- if (_this._closing) {
326
- _this.visible(false);
327
- }
328
- }, this.closeDelay());
329
- };
330
- HTMLTooltip.prototype.visible = function (_) {
331
- if (!arguments.length)
332
- return _super.prototype.visible.call(this);
333
- if (this._arrowElement) {
334
- this._arrowElement.style("visibility", _ ? "visible" : "hidden");
335
- this._tooltipElement.style("visibility", _ ? "visible" : "hidden");
336
- }
337
- _super.prototype.visible.call(this, _);
338
- return this;
339
- };
340
- HTMLTooltip.prototype.exit = function (domNode, element) {
341
- if (this._arrowElement) {
342
- this._arrowElement.remove();
343
- this._tooltipElement.remove();
344
- }
345
- _super.prototype.exit.call(this, domNode, element);
346
- };
347
- return HTMLTooltip;
348
- }(HTMLWidget));
349
- HTMLTooltip.prototype._class += " html_HTMLTooltip";
350
- HTMLTooltip.prototype.publish("fitContent", false, "boolean", "If true, tooltip will grow to fit its html content");
351
- HTMLTooltip.prototype.publish("followCursor", false, "boolean", "If true, tooltip will display relative to cursor location");
352
- HTMLTooltip.prototype.publish("closeDelay", 400, "number", "Number of milliseconds to wait before closing tooltip (cancelled on tooltip mouseover event)");
353
- HTMLTooltip.prototype.publish("direction", "n", "set", "Direction in which to display the tooltip", ["n", "s", "e", "w", "ne", "nw", "se", "sw"]);
354
- HTMLTooltip.prototype.publish("padding", 8, "number", "Padding (pixels)");
355
- HTMLTooltip.prototype.publish("arrowWidth", 16, "number", "Width (or height depending on direction) of the tooltip arrow (pixels)");
356
- HTMLTooltip.prototype.publish("arrowHeight", 8, "number", "Height (or width depending on direction) of the tooltip arrow (pixels)");
357
- HTMLTooltip.prototype.publish("fontColor", "#FFF", "html-color", "The default font color for text in the tooltip");
358
- HTMLTooltip.prototype.publish("tooltipColor", "#000000EE", "html-color", "Background color of the tooltip");
359
- HTMLTooltip.prototype.publish("tooltipWidth", 200, "number", "Width of the tooltip (not including arrow) (pixels)");
360
- HTMLTooltip.prototype.publish("tooltipHeight", 200, "number", "Height of the tooltip (not including arrow) (pixels)");
361
- HTMLTooltip.prototype.publish("enablePointerEvents", false, "boolean", "If true, the 'pointer-events: all' style will be used");
362
-
363
- var SimpleTable = /** @class */ (function (_super) {
364
- __extends(SimpleTable, _super);
365
- function SimpleTable() {
366
- return _super.call(this) || this;
367
- }
368
- SimpleTable.prototype.transformData = function () {
369
- return this.data();
370
- };
371
- SimpleTable.prototype.enter = function (domNode, element) {
372
- _super.prototype.enter.call(this, domNode, element);
373
- this._table = element.append("table");
374
- this._thead = this._table.append("thead");
375
- this._theadRow = this._thead.append("tr");
376
- this._tbody = this._table.append("tbody");
377
- };
378
- SimpleTable.prototype.update = function (domNode, element) {
379
- _super.prototype.update.call(this, domNode, element);
380
- this._table
381
- .style("width", this.autoWidth() ? "auto" : "100%");
382
- var theadTrSelection = this._theadRow.selectAll("th").data(this.columns());
383
- theadTrSelection.enter()
384
- .append("th")
385
- .attr("class", function (n, i) { return "th-".concat(i); })
386
- .merge(theadTrSelection)
387
- .text(function (_d) { return (_d).toString(); });
388
- theadTrSelection.exit().remove();
389
- var trSelection = this._tbody.selectAll("tr").data(this.transformData());
390
- trSelection.enter()
391
- .append("tr")
392
- .merge(trSelection)
393
- .each(function (d) {
394
- var tr = select(this);
395
- var tdSelection = tr.selectAll("td").data(d);
396
- tdSelection.enter()
397
- .append("td")
398
- .attr("class", function (n, i) { return "col-".concat(i); })
399
- .merge(tdSelection)
400
- .text(function (_d) { return (_d).toString(); });
401
- tdSelection.exit().remove();
402
- });
403
- trSelection.exit().remove();
404
- };
405
- return SimpleTable;
406
- }(HTMLWidget));
407
- SimpleTable.prototype._class += " html_SimpleTable";
408
- SimpleTable.prototype.publish("autoWidth", false, "boolean", "If true, table width will be set to 'auto'. If false, the width is set to '100%'");
409
-
410
- var StyledTable = /** @class */ (function (_super) {
411
- __extends(StyledTable, _super);
412
- function StyledTable() {
413
- return _super.call(this) || this;
414
- }
415
- StyledTable.prototype.applyStyleObject = function (selection, styleObject) {
416
- Object.keys(styleObject).forEach(function (styleName) {
417
- selection.style(styleName, styleObject[styleName]);
418
- });
419
- };
420
- StyledTable.prototype.update = function (domNode, element) {
421
- var _this = this;
422
- _super.prototype.update.call(this, domNode, element);
423
- element.selectAll("tr,th,td")
424
- .attr("style", "")
425
- .style("font-family", this.fontFamily())
426
- .style("color", this.fontColor());
427
- this.theadColumnStyles().forEach(function (styleObj, i) {
428
- _this.applyStyleObject(element.select(".th-".concat(i)), styleObj);
429
- });
430
- this.tbodyColumnStyles().forEach(function (styleObj, i) {
431
- _this.applyStyleObject(element.selectAll(".col-".concat(i)), styleObj);
432
- });
433
- var evenRowStylesExist = Object.keys(this.evenRowStyles()).length > 0;
434
- var lastRowStylesExist = Object.keys(this.lastRowStyles()).length > 0;
435
- var tbodyRows = element.selectAll("tbody > tr");
436
- if (evenRowStylesExist) {
437
- var tbodyEvenRows = tbodyRows.select(function (d, i) { return i % 2 ? this : null; });
438
- this.applyStyleObject(tbodyEvenRows, this.evenRowStyles());
439
- }
440
- if (lastRowStylesExist) {
441
- var tbodyLastRow = tbodyRows.select(function (d, i, arr) { return i === arr.length - 1 ? this : null; });
442
- this.applyStyleObject(tbodyLastRow, this.lastRowStyles());
443
- }
444
- };
445
- return StyledTable;
446
- }(SimpleTable));
447
- StyledTable.prototype._class += " html_StyledTable";
448
- StyledTable.prototype.publish("fontFamily", "Verdana", "string", "Base font-family used within the table");
449
- StyledTable.prototype.publish("fontColor", "#333", "string", "Base font color used within the table");
450
- StyledTable.prototype.publish("theadColumnStyles", [], "array", 'Array of objects containing styles for the thead columns (ex: [{"color":"red"},{"color":"blue"}])');
451
- StyledTable.prototype.publish("tbodyColumnStyles", [], "array", 'Array of objects containing styles for the tbody columns (ex: [{"color":"red"},{"color":"blue"}])');
452
- StyledTable.prototype.publish("lastRowStyles", {}, "object", 'Object containing styles for the last row (ex: {"color":"red"})');
453
- StyledTable.prototype.publish("evenRowStyles", {}, "object", 'Object containing styles for even rows (ex: {"background-color":"#AAA"})');
454
-
455
- var BreakdownTable = /** @class */ (function (_super) {
456
- __extends(BreakdownTable, _super);
457
- function BreakdownTable() {
458
- return _super.call(this) || this;
459
- }
460
- BreakdownTable.prototype.transformData = function () {
461
- var rowCount = this.useCalculatedRowCount() ? this.calculateRowCount() : this.rowCount();
462
- return this.breakdownData(rowCount);
463
- };
464
- BreakdownTable.prototype.breakdownData = function (limit) {
465
- var len = this.data().length;
466
- var sum = this.data().reduce(function (acc, row) { return acc + row[1]; }, 0);
467
- var data = [];
468
- var percSum = 0;
469
- this.data().sort(function (a, b) { return a[1] > b[1] ? -1 : 1; });
470
- var hiddenRowCount = len - limit;
471
- var showOther = hiddenRowCount > 0;
472
- this.data()
473
- .filter(function (_, i) { return showOther ? i < limit - 1 : true; })
474
- .forEach(function (row) {
475
- var perc = Math.round((row[1] / sum) * 100);
476
- percSum += perc;
477
- data.push([row[0], perc + "%"]);
478
- });
479
- if (showOther) {
480
- var otherLabel = "".concat(this.otherLabel(), " (").concat(len - limit + 1, ")");
481
- var otherPercentage = "~" + (100 - percSum) + "%";
482
- data.push([otherLabel, otherPercentage]);
483
- }
484
- return data;
485
- };
486
- BreakdownTable.prototype.calculateRowCount = function () {
487
- var theadRowHeight = this.columns().length > 0 ? this.thFontSize() + 5 : 0;
488
- var tbodyRowHeight = this.fontSize() + 5;
489
- var tbodyAvailableHeight = this.height() - theadRowHeight;
490
- var rowCount = Math.floor(tbodyAvailableHeight / tbodyRowHeight);
491
- return rowCount;
492
- };
493
- BreakdownTable.prototype.enter = function (domNode, element) {
494
- var _this = this;
495
- _super.prototype.enter.call(this, domNode, element);
496
- this._tooltip = new HTMLTooltip()
497
- .target(domNode);
498
- this._tooltip
499
- .tooltipHTML(function (data) {
500
- var _a;
501
- var rowCount = _this.useCalculatedRowCount() ? _this.calculateRowCount() : _this.rowCount();
502
- var rowHeight = (_a = Math.max.apply(Math, data.map(function (row) { return _this.textSize(row[0], _this.fontFamily(), _this.fontSize()).height; }))) !== null && _a !== void 0 ? _a : _this.fontSize();
503
- var widestLabel = Math.max.apply(Math, data.map(function (row) { return _this.textSize(row[0], _this.fontFamily(), _this.fontSize()).width; }));
504
- var widestPerc = 30;
505
- var colCount = 2;
506
- var w = colCount * (widestLabel + widestPerc) + (_this._tooltip.padding() * 2);
507
- var h = rowHeight * Math.ceil((data.length - rowCount) / colCount) + (_this._tooltip.padding() * 2);
508
- _this._tooltip.tooltipWidth(w);
509
- _this._tooltip.tooltipHeight(h);
510
- var otherData = _this.breakdownData(_this.data().length).slice(rowCount - 1);
511
- return "<div style=\"\n width: 100%;\n height: 100%;\n font-size: ".concat(_this.fontSize(), "px;\n \">").concat(otherData.map(function (row) {
512
- return "<div style=\"\n float:left;\n width:".concat(Math.floor(99 / colCount), "%;\n \">").concat(row[0], ": ").concat(row[1], "</div>");
513
- }).join(""), "</div>");
514
- });
515
- };
516
- BreakdownTable.prototype.update = function (domNode, element) {
517
- this.theadColumnStyles_default([
518
- {
519
- "color": this.thFirstColor(),
520
- "font-size": this.thFontSize() + "px",
521
- "font-weight": this.thFontWeight(),
522
- "text-align": this.labelAlignment(),
523
- "width": "auto",
524
- "padding": "0px"
525
- },
526
- {
527
- "width": "1%",
528
- "font-size": this.thFontSize() + "px",
529
- "font-weight": this.thFontWeight(),
530
- "text-align": this.percentageAlignment(),
531
- "padding": "0px"
532
- }
533
- ]);
534
- this.tbodyColumnStyles_default([
535
- {
536
- "color": this.topLabelColor(),
537
- "font-size": this.fontSize() + "px",
538
- "font-weight": "normal",
539
- "text-align": this.labelAlignment(),
540
- "width": "auto",
541
- "padding": "0px"
542
- },
543
- {
544
- "color": this.topPercentageColor(),
545
- "font-size": this.fontSize() + "px",
546
- "font-weight": "normal",
547
- "text-align": this.percentageAlignment(),
548
- "width": "1%",
549
- "padding": "0px"
550
- }
551
- ]);
552
- this.lastRowStyles_default([
553
- {
554
- "color": this.otherLabelColor(),
555
- "font-size": this.fontSize() + "px",
556
- "font-weight": this.otherLabelBold() ? "bold" : "normal",
557
- "text-align": this.labelAlignment(),
558
- "width": "auto",
559
- "padding": "0px"
560
- },
561
- {
562
- "color": this.otherLabelColor(),
563
- "font-size": this.fontSize() + "px",
564
- "font-weight": this.otherPercentageBold() ? "bold" : "normal",
565
- "text-align": this.percentageAlignment(),
566
- "width": "1%",
567
- "padding": "0px"
568
- }
569
- ]);
570
- _super.prototype.update.call(this, domNode, element);
571
- var rowCount = this.useCalculatedRowCount() ? this.calculateRowCount() : this.rowCount();
572
- if (rowCount < this.data().length) {
573
- var lastRow_1 = element.select("tbody > tr:last-child");
574
- var context_1 = this;
575
- lastRow_1
576
- .on("mouseout.tooltip", function (d) {
577
- context_1._tooltip._triggerElement = lastRow_1;
578
- context_1._tooltip
579
- .visible(false)
580
- .render();
581
- })
582
- .on("mouseenter.tooltip", function (d) {
583
- context_1._tooltip._triggerElement = lastRow_1;
584
- context_1._tooltip
585
- .direction("n")
586
- .data(context_1.data())
587
- .visible(true)
588
- .render();
589
- });
590
- }
591
- };
592
- return BreakdownTable;
593
- }(StyledTable));
594
- BreakdownTable.prototype._class += " html_BreakdownTable";
595
- BreakdownTable.prototype.publish("useCalculatedRowCount", true, "boolean", "If true, rowCount will be calculated and its default will be overwritten");
596
- BreakdownTable.prototype.publish("rowCount", 5, "number", "Number of total rows to display (including the 'other' row)", undefined, { disable: function (w) { return w.useCalculatedRowCount(); } });
597
- BreakdownTable.prototype.publish("fontSize", 14, "number", "Font size (pixels)");
598
- BreakdownTable.prototype.publish("labelAlignment", "left", "set", "Alignment of the label column text", ["left", "center", "right"]);
599
- BreakdownTable.prototype.publish("percentageAlignment", "center", "set", "Alignment of the percentage column text", ["left", "center", "right"]);
600
- BreakdownTable.prototype.publish("topLabelColor", "#333", "html-color", "Color of displayed 'top' labels");
601
- BreakdownTable.prototype.publish("topPercentageColor", "#1A99D5", "html-color", "Color of displayed 'top' percentages");
602
- BreakdownTable.prototype.publish("topPercentageBold", true, "html-color", "If true, the 'top' percentages will be bold");
603
- BreakdownTable.prototype.publish("otherLabel", "Other", "string", "Label text for the 'other' row");
604
- BreakdownTable.prototype.publish("otherLabelColor", "#AAA", "html-color", "Color of the 'other' label");
605
- BreakdownTable.prototype.publish("otherLabelBold", false, "html-color", "If true, the 'other' label will be bold");
606
- BreakdownTable.prototype.publish("otherPercentageColor", "#AAA", "html-color", "Color of the 'other' percentage");
607
- BreakdownTable.prototype.publish("otherPercentageBold", false, "html-color", "If true, the 'other' percentage will be bold");
608
- BreakdownTable.prototype.publish("thFontWeight", "bold", "string", "Font weight for th elements");
609
- BreakdownTable.prototype.publish("thFontSize", 26, "number", "Font size for th elements");
610
- BreakdownTable.prototype.publish("thFirstColor", "#333", "html-color", "Text color of the first th element");
611
- BreakdownTable.prototype.publish("thLastColor", "#333", "html-color", "Text color of the last th element");
612
-
613
- var n,l$1,u$1,i$1,o$1,r$1,f$1,e$1,c$1,s$1,h$1={},p$1=[],v$1=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,y$1=Array.isArray;function d$1(n,l){for(var u in l)n[u]=l[u];return n}function w$1(n){var l=n.parentNode;l&&l.removeChild(n);}function _$1(l,u,t){var i,o,r,f={};for(r in u)"key"==r?i=u[r]:"ref"==r?o=u[r]:f[r]=u[r];if(arguments.length>2&&(f.children=arguments.length>3?n.call(arguments,2):t),"function"==typeof l&&null!=l.defaultProps)for(r in l.defaultProps)void 0===f[r]&&(f[r]=l.defaultProps[r]);return g(l,f,i,o,null)}function g(n,t,i,o,r){var f={type:n,props:t,key:i,ref:o,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++u$1:r,__i:-1,__u:0};return null==r&&null!=l$1.vnode&&l$1.vnode(f),f}function k$1(n){return n.children}function b(n,l){this.props=n,this.context=l;}function x$1(n,l){if(null==l)return n.__?x$1(n.__,n.__i+1):null;for(var u;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e)return u.__e;return "function"==typeof n.type?x$1(n):null}function C$1(n){var l,u;if(null!=(n=n.__)&&null!=n.__c){for(n.__e=n.__c.base=null,l=0;l<n.__k.length;l++)if(null!=(u=n.__k[l])&&null!=u.__e){n.__e=n.__c.base=u.__e;break}return C$1(n)}}function M(n){(!n.__d&&(n.__d=!0)&&i$1.push(n)&&!P.__r++||o$1!==l$1.debounceRendering)&&((o$1=l$1.debounceRendering)||r$1)(P);}function P(){var n,u,t,o,r,e,c,s;for(i$1.sort(f$1);n=i$1.shift();)n.__d&&(u=i$1.length,o=void 0,e=(r=(t=n).__v).__e,c=[],s=[],t.__P&&((o=d$1({},r)).__v=r.__v+1,l$1.vnode&&l$1.vnode(o),O(t.__P,o,r,t.__n,t.__P.namespaceURI,32&r.__u?[e]:null,c,null==e?x$1(r):e,!!(32&r.__u),s),o.__v=r.__v,o.__.__k[o.__i]=o,j$1(c,o,s),o.__e!=e&&C$1(o)),i$1.length>u&&i$1.sort(f$1));P.__r=0;}function S(n,l,u,t,i,o,r,f,e,c,s){var a,v,y,d,w,_=t&&t.__k||p$1,g=l.length;for(u.__d=e,$(u,l,_),e=u.__d,a=0;a<g;a++)null!=(y=u.__k[a])&&"boolean"!=typeof y&&"function"!=typeof y&&(v=-1===y.__i?h$1:_[y.__i]||h$1,y.__i=a,O(n,y,v,i,o,r,f,e,c,s),d=y.__e,y.ref&&v.ref!=y.ref&&(v.ref&&N(v.ref,null,y),s.push(y.ref,y.__c||d,y)),null==w&&null!=d&&(w=d),65536&y.__u||v.__k===y.__k?(e&&!e.isConnected&&(e=x$1(v)),e=I(y,e,n)):"function"==typeof y.type&&void 0!==y.__d?e=y.__d:d&&(e=d.nextSibling),y.__d=void 0,y.__u&=-196609);u.__d=e,u.__e=w;}function $(n,l,u){var t,i,o,r,f,e=l.length,c=u.length,s=c,a=0;for(n.__k=[],t=0;t<e;t++)r=t+a,null!=(i=n.__k[t]=null==(i=l[t])||"boolean"==typeof i||"function"==typeof i?null:"string"==typeof i||"number"==typeof i||"bigint"==typeof i||i.constructor==String?g(null,i,null,null,null):y$1(i)?g(k$1,{children:i},null,null,null):void 0===i.constructor&&i.__b>0?g(i.type,i.props,i.key,i.ref?i.ref:null,i.__v):i)?(i.__=n,i.__b=n.__b+1,f=L(i,u,r,s),i.__i=f,o=null,-1!==f&&(s--,(o=u[f])&&(o.__u|=131072)),null==o||null===o.__v?(-1==f&&a--,"function"!=typeof i.type&&(i.__u|=65536)):f!==r&&(f===r+1?a++:f>r?s>e-r?a+=f-r:a--:f<r?f==r-1&&(a=f-r):a=0,f!==t+a&&(i.__u|=65536))):(o=u[r])&&null==o.key&&o.__e&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=x$1(o)),V(o,o,!1),u[r]=null,s--);if(s)for(t=0;t<c;t++)null!=(o=u[t])&&0==(131072&o.__u)&&(o.__e==n.__d&&(n.__d=x$1(o)),V(o,o));}function I(n,l,u){var t,i;if("function"==typeof n.type){for(t=n.__k,i=0;t&&i<t.length;i++)t[i]&&(t[i].__=n,l=I(t[i],l,u));return l}n.__e!=l&&(u.insertBefore(n.__e,l||null),l=n.__e);do{l=l&&l.nextSibling;}while(null!=l&&8===l.nodeType);return l}function L(n,l,u,t){var i=n.key,o=n.type,r=u-1,f=u+1,e=l[u];if(null===e||e&&i==e.key&&o===e.type&&0==(131072&e.__u))return u;if(t>(null!=e&&0==(131072&e.__u)?1:0))for(;r>=0||f<l.length;){if(r>=0){if((e=l[r])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return r;r--;}if(f<l.length){if((e=l[f])&&0==(131072&e.__u)&&i==e.key&&o===e.type)return f;f++;}}return -1}function T(n,l,u){"-"===l[0]?n.setProperty(l,null==u?"":u):n[l]=null==u?"":"number"!=typeof u||v$1.test(l)?u:u+"px";}function A(n,l,u,t,i){var o;n:if("style"===l)if("string"==typeof u)n.style.cssText=u;else {if("string"==typeof t&&(n.style.cssText=t=""),t)for(l in t)u&&l in u||T(n.style,l,"");if(u)for(l in u)t&&u[l]===t[l]||T(n.style,l,u[l]);}else if("o"===l[0]&&"n"===l[1])o=l!==(l=l.replace(/(PointerCapture)$|Capture$/i,"$1")),l=l.toLowerCase()in n||"onFocusOut"===l||"onFocusIn"===l?l.toLowerCase().slice(2):l.slice(2),n.l||(n.l={}),n.l[l+o]=u,u?t?u.u=t.u:(u.u=e$1,n.addEventListener(l,o?s$1:c$1,o)):n.removeEventListener(l,o?s$1:c$1,o);else {if("http://www.w3.org/2000/svg"==i)l=l.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!=l&&"height"!=l&&"href"!=l&&"list"!=l&&"form"!=l&&"tabIndex"!=l&&"download"!=l&&"rowSpan"!=l&&"colSpan"!=l&&"role"!=l&&l in n)try{n[l]=null==u?"":u;break n}catch(n){}"function"==typeof u||(null==u||!1===u&&"-"!==l[4]?n.removeAttribute(l):n.setAttribute(l,u));}}function F(n){return function(u){if(this.l){var t=this.l[u.type+n];if(null==u.t)u.t=e$1++;else if(u.t<t.u)return;return t(l$1.event?l$1.event(u):u)}}}function O(n,u,t,i,o,r,f,e,c,s){var a,h,p,v,w,_,g,m,x,C,M,P,$,I,H,L=u.type;if(void 0!==u.constructor)return null;128&t.__u&&(c=!!(32&t.__u),r=[e=u.__e=t.__e]),(a=l$1.__b)&&a(u);n:if("function"==typeof L)try{if(m=u.props,x=(a=L.contextType)&&i[a.__c],C=a?x?x.props.value:a.__:i,t.__c?g=(h=u.__c=t.__c).__=h.__E:("prototype"in L&&L.prototype.render?u.__c=h=new L(m,C):(u.__c=h=new b(m,C),h.constructor=L,h.render=q$1),x&&x.sub(h),h.props=m,h.state||(h.state={}),h.context=C,h.__n=i,p=h.__d=!0,h.__h=[],h._sb=[]),null==h.__s&&(h.__s=h.state),null!=L.getDerivedStateFromProps&&(h.__s==h.state&&(h.__s=d$1({},h.__s)),d$1(h.__s,L.getDerivedStateFromProps(m,h.__s))),v=h.props,w=h.state,h.__v=u,p)null==L.getDerivedStateFromProps&&null!=h.componentWillMount&&h.componentWillMount(),null!=h.componentDidMount&&h.__h.push(h.componentDidMount);else {if(null==L.getDerivedStateFromProps&&m!==v&&null!=h.componentWillReceiveProps&&h.componentWillReceiveProps(m,C),!h.__e&&(null!=h.shouldComponentUpdate&&!1===h.shouldComponentUpdate(m,h.__s,C)||u.__v===t.__v)){for(u.__v!==t.__v&&(h.props=m,h.state=h.__s,h.__d=!1),u.__e=t.__e,u.__k=t.__k,u.__k.forEach(function(n){n&&(n.__=u);}),M=0;M<h._sb.length;M++)h.__h.push(h._sb[M]);h._sb=[],h.__h.length&&f.push(h);break n}null!=h.componentWillUpdate&&h.componentWillUpdate(m,h.__s,C),null!=h.componentDidUpdate&&h.__h.push(function(){h.componentDidUpdate(v,w,_);});}if(h.context=C,h.props=m,h.__P=n,h.__e=!1,P=l$1.__r,$=0,"prototype"in L&&L.prototype.render){for(h.state=h.__s,h.__d=!1,P&&P(u),a=h.render(h.props,h.state,h.context),I=0;I<h._sb.length;I++)h.__h.push(h._sb[I]);h._sb=[];}else do{h.__d=!1,P&&P(u),a=h.render(h.props,h.state,h.context),h.state=h.__s;}while(h.__d&&++$<25);h.state=h.__s,null!=h.getChildContext&&(i=d$1(d$1({},i),h.getChildContext())),p||null==h.getSnapshotBeforeUpdate||(_=h.getSnapshotBeforeUpdate(v,w)),S(n,y$1(H=null!=a&&a.type===k$1&&null==a.key?a.props.children:a)?H:[H],u,t,i,o,r,f,e,c,s),h.base=u.__e,u.__u&=-161,h.__h.length&&f.push(h),g&&(h.__E=h.__=null);}catch(n){u.__v=null,c||null!=r?(u.__e=e,u.__u|=c?160:32,r[r.indexOf(e)]=null):(u.__e=t.__e,u.__k=t.__k),l$1.__e(n,u,t);}else null==r&&u.__v===t.__v?(u.__k=t.__k,u.__e=t.__e):u.__e=z$1(t.__e,u,t,i,o,r,f,c,s);(a=l$1.diffed)&&a(u);}function j$1(n,u,t){u.__d=void 0;for(var i=0;i<t.length;i++)N(t[i],t[++i],t[++i]);l$1.__c&&l$1.__c(u,n),n.some(function(u){try{n=u.__h,u.__h=[],n.some(function(n){n.call(u);});}catch(n){l$1.__e(n,u.__v);}});}function z$1(l,u,t,i,o,r,f,e,c){var s,a,p,v,d,_,g,m=t.props,k=u.props,b=u.type;if("svg"===b?o="http://www.w3.org/2000/svg":"math"===b?o="http://www.w3.org/1998/Math/MathML":o||(o="http://www.w3.org/1999/xhtml"),null!=r)for(s=0;s<r.length;s++)if((d=r[s])&&"setAttribute"in d==!!b&&(b?d.localName===b:3===d.nodeType)){l=d,r[s]=null;break}if(null==l){if(null===b)return document.createTextNode(k);l=document.createElementNS(o,b,k.is&&k),r=null,e=!1;}if(null===b)m===k||e&&l.data===k||(l.data=k);else {if(r=r&&n.call(l.childNodes),m=t.props||h$1,!e&&null!=r)for(m={},s=0;s<l.attributes.length;s++)m[(d=l.attributes[s]).name]=d.value;for(s in m)if(d=m[s],"children"==s);else if("dangerouslySetInnerHTML"==s)p=d;else if("key"!==s&&!(s in k)){if("value"==s&&"defaultValue"in k||"checked"==s&&"defaultChecked"in k)continue;A(l,s,null,d,o);}for(s in k)d=k[s],"children"==s?v=d:"dangerouslySetInnerHTML"==s?a=d:"value"==s?_=d:"checked"==s?g=d:"key"===s||e&&"function"!=typeof d||m[s]===d||A(l,s,d,m[s],o);if(a)e||p&&(a.__html===p.__html||a.__html===l.innerHTML)||(l.innerHTML=a.__html),u.__k=[];else if(p&&(l.innerHTML=""),S(l,y$1(v)?v:[v],u,t,i,"foreignObject"===b?"http://www.w3.org/1999/xhtml":o,r,f,r?r[0]:t.__k&&x$1(t,0),e,c),null!=r)for(s=r.length;s--;)null!=r[s]&&w$1(r[s]);e||(s="value",void 0!==_&&(_!==l[s]||"progress"===b&&!_||"option"===b&&_!==m[s])&&A(l,s,_,m[s],o),s="checked",void 0!==g&&g!==l[s]&&A(l,s,g,m[s],o));}return l}function N(n,u,t){try{"function"==typeof n?n(u):n.current=u;}catch(n){l$1.__e(n,t);}}function V(n,u,t){var i,o;if(l$1.unmount&&l$1.unmount(n),(i=n.ref)&&(i.current&&i.current!==n.__e||N(i,null,u)),null!=(i=n.__c)){if(i.componentWillUnmount)try{i.componentWillUnmount();}catch(n){l$1.__e(n,u);}i.base=i.__P=null;}if(i=n.__k)for(o=0;o<i.length;o++)i[o]&&V(i[o],u,t||"function"!=typeof n.type);t||null==n.__e||w$1(n.__e),n.__c=n.__=n.__e=n.__d=void 0;}function q$1(n,l,u){return this.constructor(n,u)}function B$1(u,t,i){var o,r,f,e;l$1.__&&l$1.__(u,t),r=(o="function"==typeof i)?null:i&&i.__k||t.__k,f=[],e=[],O(t,u=(!o&&i||t).__k=_$1(k$1,null,[u]),r||h$1,h$1,t.namespaceURI,!o&&i?[i]:r?null:t.firstChild?n.call(t.childNodes):null,f,!o&&i?i:r?r.__e:t.firstChild,o,e),j$1(f,u,e);}n=p$1.slice,l$1={__e:function(n,l,u,t){for(var i,o,r;l=l.__;)if((i=l.__c)&&!i.__)try{if((o=i.constructor)&&null!=o.getDerivedStateFromError&&(i.setState(o.getDerivedStateFromError(n)),r=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),r=i.__d),r)return i.__E=i}catch(l){n=l;}throw n}},u$1=0,b.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=d$1({},this.state),"function"==typeof n&&(n=n(d$1({},u),this.props)),n&&d$1(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),M(this));},b.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),M(this));},b.prototype.render=k$1,i$1=[],r$1="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,f$1=function(n,l){return n.__v.__b-l.__v.__b},P.__r=0,e$1=0,c$1=F(!1),s$1=F(!0);
614
-
615
- var r,u,i,f=[],c=[],e=l$1,a=e.__b,v=e.__r,l=e.diffed,m=e.__c,s=e.unmount,d=e.__;function j(){for(var n;n=f.shift();)if(n.__P&&n.__H)try{n.__H.__h.forEach(z),n.__H.__h.forEach(B),n.__H.__h=[];}catch(t){n.__H.__h=[],e.__e(t,n.__v);}}e.__b=function(n){r=null,a&&a(n);},e.__=function(n,t){n&&t.__k&&t.__k.__m&&(n.__m=t.__k.__m),d&&d(n,t);},e.__r=function(n){v&&v(n);var i=(r=n.__c).__H;i&&(u===r?(i.__h=[],r.__h=[],i.__.forEach(function(n){n.__N&&(n.__=n.__N),n.__V=c,n.__N=n.i=void 0;})):(i.__h.forEach(z),i.__h.forEach(B),i.__h=[],0)),u=r;},e.diffed=function(n){l&&l(n);var t=n.__c;t&&t.__H&&(t.__H.__h.length&&(1!==f.push(t)&&i===e.requestAnimationFrame||((i=e.requestAnimationFrame)||w)(j)),t.__H.__.forEach(function(n){n.i&&(n.__H=n.i),n.__V!==c&&(n.__=n.__V),n.i=void 0,n.__V=c;})),u=r=null;},e.__c=function(n,t){t.some(function(n){try{n.__h.forEach(z),n.__h=n.__h.filter(function(n){return !n.__||B(n)});}catch(r){t.some(function(n){n.__h&&(n.__h=[]);}),t=[],e.__e(r,n.__v);}}),m&&m(n,t);},e.unmount=function(n){s&&s(n);var t,r=n.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{z(n);}catch(n){t=n;}}),r.__H=void 0,t&&e.__e(t,r.__v));};var k="function"==typeof requestAnimationFrame;function w(n){var t,r=function(){clearTimeout(u),k&&cancelAnimationFrame(t),setTimeout(n);},u=setTimeout(r,100);k&&(t=requestAnimationFrame(r));}function z(n){var t=r,u=n.__c;"function"==typeof u&&(n.__c=void 0,u()),r=t;}function B(n){var t=r;n.__c=n.__(),r=t;}
616
-
617
- var JSXWidget = /** @class */ (function (_super) {
618
- __extends(JSXWidget, _super);
619
- function JSXWidget() {
620
- return _super !== null && _super.apply(this, arguments) || this;
621
- }
622
- JSXWidget.prototype.jsxRender = function (jsx, domNode) {
623
- this.rootNode = B$1(jsx, domNode, this.rootNode);
624
- };
625
- JSXWidget.Component = b;
626
- JSXWidget.createElement = _$1;
627
- return JSXWidget;
628
- }(HTMLWidget));
629
- JSXWidget.prototype._class += " html_JSXWidget";
630
-
631
- var VNode = /** @class */ (function () {
632
- function VNode(attrs, children) {
633
- this._attrs = attrs;
634
- this._children = children;
635
- }
636
- VNode.prototype.type = function () {
637
- return "div";
638
- };
639
- VNode.prototype.attrs = function () {
640
- return this._attrs;
641
- };
642
- VNode.prototype.attr = function (key) {
643
- return this._attrs[key];
644
- };
645
- VNode.prototype.children = function () {
646
- return this._children;
647
- };
648
- VNode.prototype.update = function (targetElement) {
649
- for (var key in this._attrs) {
650
- targetElement.attr(key, this._attrs[key]);
651
- }
652
- };
653
- VNode.prototype.render = function (targetElement) {
654
- var thisElement = targetElement.selectAll("".concat(targetElement.node().tagName, " > *")).data([this]);
655
- thisElement.exit()
656
- .remove();
657
- return thisElement.enter().append(this.type())
658
- .attr("reactd3", 0)
659
- .merge(thisElement)
660
- .each(function (d) {
661
- var element = select(this);
662
- d.update(element);
663
- d.renderChildren(element);
664
- });
665
- };
666
- VNode.prototype.renderChildren = function (targetElement) {
667
- var thisElement = targetElement.selectAll("".concat(targetElement.node().tagName, " > *")).data(this._children);
668
- thisElement.exit()
669
- .remove();
670
- return thisElement.enter().append(function (d) { return document.createElement(d.type()); })
671
- .attr("reactd3", function (_d, i) { return i; })
672
- .merge(thisElement)
673
- .each(function (d) {
674
- var element = select(this);
675
- d.update(element);
676
- d.renderChildren(element);
677
- });
678
- };
679
- return VNode;
680
- }());
681
- var ConstVNode = /** @class */ (function (_super) {
682
- __extends(ConstVNode, _super);
683
- function ConstVNode(type, attrs, children) {
684
- var _this = _super.call(this, attrs, children) || this;
685
- _this._type = type;
686
- return _this;
687
- }
688
- ConstVNode.prototype.type = function () {
689
- return this._type;
690
- };
691
- return ConstVNode;
692
- }(VNode));
693
- var TextVNode = /** @class */ (function (_super) {
694
- __extends(TextVNode, _super);
695
- function TextVNode(text) {
696
- var _this = _super.call(this, {}, []) || this;
697
- _this._text = text;
698
- return _this;
699
- }
700
- TextVNode.prototype.type = function () {
701
- return "span";
702
- };
703
- TextVNode.prototype.update = function (targetElement) {
704
- _super.prototype.update.call(this, targetElement);
705
- targetElement.text(this._text);
706
- };
707
- return TextVNode;
708
- }(VNode));
709
- function isReactFn(_) {
710
- return typeof _ === "function";
711
- }
712
- function isIVNode(_) {
713
- return _.prototype && _.prototype instanceof VNode;
714
- }
715
- var ReactD3 = /** @class */ (function () {
716
- function ReactD3() {
717
- }
718
- // static createElementXXX(type: string | ReactFn | IVNode, attrs: { [key: string]: string }, ...children: Array<string | VNode>): VNode {
719
- ReactD3.createElement = function (type, attrs) {
720
- var children = [];
721
- for (var _i = 2; _i < arguments.length; _i++) {
722
- children[_i - 2] = arguments[_i];
723
- }
724
- if (isIVNode(type)) {
725
- return new type(attrs);
726
- }
727
- else if (isReactFn(type)) {
728
- return type(attrs);
729
- }
730
- return new ConstVNode(type, attrs, children.map(function (child) {
731
- if (typeof child === "string") {
732
- return new TextVNode(child);
733
- }
734
- return child;
735
- }));
736
- };
737
- ReactD3.render = function (vdom, targetElement) {
738
- vdom.render(targetElement);
739
- };
740
- return ReactD3;
741
- }());
742
-
743
- var VizComponent = /** @class */ (function (_super) {
744
- __extends(VizComponent, _super);
745
- function VizComponent() {
746
- return _super !== null && _super.apply(this, arguments) || this;
747
- }
748
- VizComponent.prototype.refreshProps = function () {
749
- for (var key in this.props) {
750
- if (this.widget[key] && typeof this.widget[key] === "function") {
751
- this.widget[key](this.props[key]);
752
- }
753
- }
754
- };
755
- VizComponent.prototype.componentDidMount = function () {
756
- this.widget = new this.props.type()
757
- .target(this.base);
758
- this.refreshProps();
759
- this.widget
760
- .render();
761
- };
762
- VizComponent.prototype.componentWillUnmount = function () {
763
- this.widget
764
- .target(null)
765
- .render();
766
- };
767
- VizComponent.prototype.render = function () {
768
- return _$1("div", { style: this.props.style });
769
- };
770
- VizComponent.prototype.componentDidUpdate = function () {
771
- this.refreshProps();
772
- this.widget.render();
773
- };
774
- return VizComponent;
775
- }(JSXWidget.Component));
776
-
777
- var VizInstance = /** @class */ (function (_super) {
778
- __extends(VizInstance, _super);
779
- function VizInstance() {
780
- return _super !== null && _super.apply(this, arguments) || this;
781
- }
782
- VizInstance.prototype.refreshProps = function () {
783
- for (var key in this.props) {
784
- if (this.widget[key] && typeof this.widget[key] === "function") {
785
- this.widget[key](this.props[key]);
786
- }
787
- }
788
- };
789
- VizInstance.prototype.componentDidMount = function () {
790
- this.widget = this.props.instance
791
- .target(this.base);
792
- this.refreshProps();
793
- this.widget
794
- .render();
795
- };
796
- VizInstance.prototype.componentWillUnmount = function () {
797
- this.widget
798
- .target(null)
799
- .render();
800
- };
801
- VizInstance.prototype.render = function () {
802
- return _$1("div", { style: this.props.style });
803
- };
804
- VizInstance.prototype.componentDidUpdate = function () {
805
- this.refreshProps();
806
- this.widget.render();
807
- };
808
- return VizInstance;
809
- }(JSXWidget.Component));
810
-
811
- var StatsTable = /** @class */ (function (_super) {
812
- __extends(StatsTable, _super);
813
- function StatsTable() {
814
- return _super !== null && _super.apply(this, arguments) || this;
815
- }
816
- StatsTable.prototype.transformData = function () {
817
- var _this = this;
818
- var totalRow = [["Total", 0, 0]];
819
- var data = this.data();
820
- data.forEach(function (row) {
821
- totalRow[0][1] += row[1];
822
- totalRow[0][2] += row[2];
823
- });
824
- return data
825
- .concat(totalRow)
826
- .map(function (row) {
827
- return [
828
- row[0],
829
- _this.secondColumnFormat_exists() ? format(_this.secondColumnFormat())(row[1]) : row[1],
830
- _this.thirdColumnFormat_exists() ? format(_this.thirdColumnFormat())(row[2]) : row[2]
831
- ];
832
- });
833
- };
834
- StatsTable.prototype.update = function (domNode, element) {
835
- this.tbodyColumnStyles_default([
836
- {
837
- "font-weight": "bold",
838
- "width": this.firstColumnWidth(),
839
- "text-align": "left"
840
- },
841
- {
842
- "width": this.secondColumnWidth(),
843
- "text-align": "right"
844
- },
845
- {
846
- "width": this.thirdColumnWidth(),
847
- "text-align": "right"
848
- }
849
- ]);
850
- this.evenRowStyles_default([
851
- {
852
- "font-weight": "bold",
853
- "width": this.firstColumnWidth(),
854
- "text-align": "left",
855
- "font-color": this.evenRowFontColor(),
856
- "background-color": this.evenRowBackgroundColor()
857
- },
858
- {
859
- "width": this.secondColumnWidth(),
860
- "text-align": "right",
861
- "font-color": this.evenRowFontColor(),
862
- "background-color": this.evenRowBackgroundColor()
863
- },
864
- {
865
- "width": this.thirdColumnWidth(),
866
- "text-align": "right",
867
- "font-color": this.evenRowFontColor(),
868
- "background-color": this.evenRowBackgroundColor()
869
- }
870
- ]);
871
- this.lastRowStyles_default({
872
- "font-weight": "bold"
873
- });
874
- _super.prototype.update.call(this, domNode, element);
875
- };
876
- return StatsTable;
877
- }(StyledTable));
878
- StatsTable.prototype._class += " html_StatsTable";
879
- StatsTable.prototype.publish("labelColor", "#333", "html-color", "Color of the text in the first column");
880
- StatsTable.prototype.publish("primaryValueColor", "#333", "html-color", "Color of the text in the second column");
881
- StatsTable.prototype.publish("secondaryValueColor", "#333", "html-color", "Color of the text in the third column");
882
- StatsTable.prototype.publish("evenRowBackgroundColor", "#333", "html-color", "Background color of the even rows");
883
- StatsTable.prototype.publish("evenRowFontColor", "#333", "html-color", "Font color of the even rows");
884
- StatsTable.prototype.publish("firstColumnWidth", "auto", "string", "CSS style applied as the 'width' for the first column (ex: 40px)");
885
- StatsTable.prototype.publish("secondColumnWidth", "1%", "string", "CSS style applied as the 'width' for the second column (ex: 40px)");
886
- StatsTable.prototype.publish("thirdColumnWidth", "1%", "string", "CSS style applied as the 'width' for the third column (ex: 40px)");
887
- StatsTable.prototype.publish("secondColumnFormat", "$,.0f", "string", "d3-format specifier applied to the second column's values", undefined, { optional: true });
888
- StatsTable.prototype.publish("thirdColumnFormat", null, "string", "d3-format specifier applied to the third column's values", undefined, { optional: true });
889
-
890
- function styleInject(css, ref) {
891
- if ( ref === void 0 ) ref = {};
892
- var insertAt = ref.insertAt;
893
-
894
- if (typeof document === 'undefined') { return; }
895
-
896
- var head = document.head || document.getElementsByTagName('head')[0];
897
- var style = document.createElement('style');
898
- style.type = 'text/css';
899
-
900
- if (insertAt === 'top') {
901
- if (head.firstChild) {
902
- head.insertBefore(style, head.firstChild);
903
- } else {
904
- head.appendChild(style);
905
- }
906
- } else {
907
- head.appendChild(style);
908
- }
909
-
910
- if (style.styleSheet) {
911
- style.styleSheet.cssText = css;
912
- } else {
913
- style.appendChild(document.createTextNode(css));
914
- }
915
- }
916
-
917
- var css_248z = "#wrap{width:100%}#left,#right{padding:5px}#left{background-color:red;display:block;overflow:hidden;text-align:left;text-overflow:ellipsis}#left,#right{white-space:nowrap}#right{background-color:orange;float:right;text-align:right}.html_TitleBar>.main{display:block;width:100%}.html_TitleBar .title{display:block;font-size:20px;font-weight:700;overflow:hidden;padding:4px;text-align:left;text-overflow:ellipsis;white-space:nowrap}.html_TitleBar .icon-bar{float:right;line-height:28px;padding:4px;text-align:right;white-space:nowrap}.html_TitleBar .icon-bar-item,.html_TitleBar .icon-bar-item>div{display:inline}.html_TitleBar .icon-bar a{color:#a9a9a9;padding-bottom:4px;padding-top:4px;text-align:center;transition:all .3s ease}.html_TitleBar .icon-bar a:hover{background-color:#f5f5f5}.html_TitleBar .icon-bar a.selected{background-color:#efe5e5}.html_TitleBar .icon-bar a.spacer{color:none;padding-bottom:0;padding-left:8px;padding-top:2px;text-align:center}.html_TitleBar .icon-bar a.spacer:hover{background-color:transparent}.html_TitleBar .icon-bar .active{background-color:#4caf50}";
918
- styleInject(css_248z);
919
-
920
- var Item = /** @class */ (function (_super) {
921
- __extends(Item, _super);
922
- function Item(owner) {
923
- var _this = _super.call(this) || this;
924
- _this._owner = owner;
925
- _this._tag = "a";
926
- return _this;
927
- }
928
- return Item;
929
- }(HTMLWidget));
930
- var Button = /** @class */ (function (_super) {
931
- __extends(Button, _super);
932
- function Button(owner, icon) {
933
- var _this = _super.call(this, owner) || this;
934
- _this._icon = icon;
935
- return _this;
936
- }
937
- Button.prototype.icon = function () {
938
- return this._icon;
939
- };
940
- Button.prototype.enter = function (domNode, element) {
941
- var _this = this;
942
- _super.prototype.enter.call(this, domNode, element);
943
- element
944
- .attr("href", "#")
945
- .on("click", function (d, idx, groups) { return _this._owner.titleBarClick(_this, d, idx, groups); })
946
- .append("i")
947
- .attr("class", "fa ".concat(this._icon, " fa-lg fa-fw"));
948
- };
949
- return Button;
950
- }(Item));
951
- var ToggleButton = /** @class */ (function (_super) {
952
- __extends(ToggleButton, _super);
953
- function ToggleButton() {
954
- return _super !== null && _super.apply(this, arguments) || this;
955
- }
956
- ToggleButton.prototype.enter = function (domNode, element) {
957
- var _this = this;
958
- element.on("click.sel", function (d, idx, groups) {
959
- _this.selected(!_this.selected());
960
- _this.render();
961
- });
962
- _super.prototype.enter.call(this, domNode, element);
963
- };
964
- ToggleButton.prototype.update = function (domNode, element) {
965
- _super.prototype.update.call(this, domNode, element);
966
- this._element.classed("selected", this.selected());
967
- };
968
- return ToggleButton;
969
- }(Button));
970
- ToggleButton.prototype.publish("selected", false, "boolean");
971
- var Spacer = /** @class */ (function (_super) {
972
- __extends(Spacer, _super);
973
- function Spacer() {
974
- return _super !== null && _super.apply(this, arguments) || this;
975
- }
976
- Spacer.prototype.enter = function (domNode, element) {
977
- _super.prototype.enter.call(this, domNode, element);
978
- element
979
- .attr("class", "spacer")
980
- .attr("href", "#")
981
- .append("i");
982
- };
983
- return Spacer;
984
- }(Item));
985
- var TitleBar = /** @class */ (function (_super) {
986
- __extends(TitleBar, _super);
987
- function TitleBar() {
988
- return _super.call(this) || this;
989
- }
990
- TitleBar.prototype.enter = function (domNode, element) {
991
- _super.prototype.enter.call(this, domNode, element);
992
- this._divMain = element.append("div")
993
- .attr("class", "main");
994
- this._divIconBar = this._divMain.append("div")
995
- .attr("class", "icon-bar");
996
- this._divTitle = this._divMain.append("div")
997
- .attr("class", "title");
998
- };
999
- TitleBar.prototype.update = function (domNode, element) {
1000
- _super.prototype.update.call(this, domNode, element);
1001
- this._divTitle.text(this.title());
1002
- var icons = this._divIconBar.selectAll(".icon-bar-item").data(this.buttons());
1003
- icons.enter().append("div")
1004
- .attr("class", "icon-bar-item")
1005
- .each(function (d) {
1006
- d.target(this);
1007
- })
1008
- .merge(icons)
1009
- .each(function (d) {
1010
- d.render();
1011
- });
1012
- icons.exit()
1013
- .each(function (d) {
1014
- d.target(null);
1015
- })
1016
- .remove();
1017
- icons.order();
1018
- };
1019
- return TitleBar;
1020
- }(JSXWidget));
1021
- TitleBar.prototype._class += " html_TitleBar";
1022
- TitleBar.prototype.publish("title", "", "string");
1023
- TitleBar.prototype.publish("buttons", [], "widgetArray");
1024
-
1025
- export { BUILD_VERSION, BreakdownTable, Button, HTMLTooltip, Item, JSXWidget, PKG_NAME, PKG_VERSION, ReactD3, SimpleTable, Spacer, StatsTable, StyledTable, TitleBar, ToggleButton, VNode, VizComponent, VizInstance };
1026
- //# sourceMappingURL=index.es6.js.map