@hpcc-js/html 3.1.0 → 3.2.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.
- package/dist/index.js +653 -88
- package/dist/index.js.map +1 -7
- package/dist/index.umd.cjs +10 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +14 -17
- package/src/JSXWidget.ts +2 -3
- package/src/VizComponent.tsx +0 -1
- package/src/VizInstance.tsx +0 -1
- package/src/__package__.ts +2 -2
- package/types/JSXWidget.d.ts +1 -1
- package/types/VizComponent.d.ts +1 -2
- package/types/VizInstance.d.ts +1 -2
- package/types/__package__.d.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -1,93 +1,658 @@
|
|
|
1
|
-
var B=Object.defineProperty;var s=(n,t)=>B(n,"name",{value:t,configurable:!0});var K="@hpcc-js/html",q="3.1.0",Q="3.2.0";import{HTMLWidget as D,select as I}from"@hpcc-js/common";import{scopedLogger as P}from"@hpcc-js/util";var c=class extends D{static{s(this,"HTMLTooltip")}_triggerElement;_contentNode;_prevContentNode;_tooltipElement;_arrowElement;_tooltipHTMLCallback=s(t=>"<b>_tooltipHTMLCallback is undefined</b>","_tooltipHTMLCallback");_logger=P("html/HTMLTooltip");constructor(){super(),this.visible(!1)}tooltipHTML(t){return this._tooltipHTMLCallback=t,this}tooltipContent(t){return arguments.length?(this._contentNode=t,this):this._contentNode}triggerElement(t){return this._triggerElement=t,this}enter(t,e){super.enter(t,e);let o=I("body");this._tooltipElement=o.append("div").attr("class","tooltip-div").style("z-index","2147483638").style("position","fixed"),this._arrowElement=o.append("div").attr("class","arrow-div").style("z-index","2147483638").style("position","fixed")}update(t,e){if(super.update(t,e),this._contentNode!==this._prevContentNode){let o=this._tooltipElement.node();[...o.querySelectorAll("*")].map(i=>i.__data__).filter(i=>i).forEach(i=>{typeof i.target=="function"&&i.target(null),typeof i.exit=="function"&&i.exit()}),o.innerHTML="",o.appendChild(this._contentNode),this._prevContentNode=this._contentNode}if(this._contentNode?this.onShowContent(this._contentNode):this._tooltipElement.html(()=>this._tooltipHTMLCallback(this.data())),this.fitContent()){this._tooltipElement.style("width","auto").style("height","auto").style("padding","0px").style("box-sizing","content-box");let o=this._tooltipElement.node().getBoundingClientRect();this.tooltipWidth_default(o.width),this.tooltipHeight_default(o.height)}this._closing=!1,this._tooltipElement.style("background-color",this.tooltipColor()).style("color",this.fontColor()).style("width",this.tooltipWidth()+"px").style("height",this.tooltipHeight()+"px").style("opacity",1).style("padding",this.padding()+"px").style("pointer-events",this.enablePointerEvents()?"all":"none").style("box-sizing","content-box"),this._arrowElement.style("opacity",1).style("pointer-events","none"),this.updateTooltipPosition()}onShowContent(t){}updateTooltipPosition(){let t=this.calcReferenceBBox(),e=this.calcTooltipDirection(t),o=t[e];return this._tooltipElement.style("top",o.y+"px").style("left",o.x+"px"),this.setArrowPosition(o,e),o}calcTooltipDirection(t){let e=Object.keys(t),o=this.direction();e.sort((r,l)=>r===o?-1:1);let i={top:0,left:0,width:window.innerWidth,height:window.innerHeight};for(let r=0;r<e.length;r++){let l={top:t[e[r]].y,left:t[e[r]].x,width:this.tooltipWidth(),height:this.tooltipHeight()};if(this.rectFits(l,i))return e[r]}return this._logger.warning(`Tooltip doesn't fit in the window for any of the directions. Defaulting to '${o}'`),this._logger.debug(i),this._logger.debug({top:t[o].y,left:t[o].x,width:this.tooltipWidth(),height:this.tooltipHeight()}),o}rectFits(t,e){return t.top>=e.top&&t.left>=e.left&&t.width+t.left<=e.width+e.left&&t.height+t.top<=e.height+e.top}setArrowPosition(t,e){let o,i,r="border-top-color";switch(this._arrowElement.style("border",`${this.arrowHeight()}px solid ${this.tooltipColor()}`).style("border-top-color","transparent").style("border-right-color","transparent").style("border-bottom-color","transparent").style("border-left-color","transparent"),e){case"n":o=t.y+this.tooltipHeight()+this.padding()*2,i=t.x+this.tooltipWidth()/2-this.arrowWidth()/2+this.padding(),r="border-top-color",this._arrowElement.style("border-top-width",`${this.arrowHeight()}px`).style("border-bottom-width","0px").style("border-left-width",`${this.arrowWidth()/2}px`).style("border-right-width",`${this.arrowWidth()/2}px`);break;case"s":o=t.y-this.arrowHeight(),i=t.x+this.padding()+this.tooltipWidth()/2-this.arrowWidth()/2,r="border-bottom-color",this._arrowElement.style("border-top-width","0px").style("border-bottom-width",`${this.arrowHeight()}px`).style("border-left-width",`${this.arrowWidth()/2}px`).style("border-right-width",`${this.arrowWidth()/2}px`);break;case"e":o=t.y+this.tooltipHeight()/2+this.padding()-this.arrowWidth()/2,i=t.x-this.arrowHeight(),r="border-right-color",this._arrowElement.style("border-top-width",`${this.arrowWidth()/2}px`).style("border-bottom-width",`${this.arrowWidth()/2}px`).style("border-left-width","0px").style("border-right-width",`${this.arrowHeight()}px`);break;case"w":o=t.y+this.tooltipHeight()/2-this.arrowWidth()/2+this.padding(),i=t.x+this.tooltipWidth()+this.padding()*2,r="border-left-color",this._arrowElement.style("border-top-width",`${this.arrowWidth()/2}px`).style("border-bottom-width",`${this.arrowWidth()/2}px`).style("border-left-width",`${this.arrowHeight()}px`).style("border-right-width","0px");break}return typeof o<"u"&&typeof i<"u"?this._arrowElement.style("top",o+"px").style("left",i+"px").style(r,this.tooltipColor()).style("opacity",1):this._arrowElement.style("opacity",0),t}getReferenceNode(){return this._triggerElement?this._triggerElement.node():this.element().node().parentNode.parentNode}_cursorLoc;calcReferenceBBox(){let t=this.getReferenceNode(),{top:e,left:o,width:i,height:r}=t.getBoundingClientRect(),l=this.tooltipWidth(),p=this.tooltipHeight(),h=l/2,d=p/2,f=this.arrowHeight(),b=this.padding(),u=b*2;return this.followCursor()&&this._cursorLoc&&(o=this._cursorLoc[0],e=this._cursorLoc[1],i=1,r=1),{n:{x:o+i/2-h-b,y:e-p-f-u},e:{x:o+i+f,y:e+r/2-d-b},s:{x:o+i/2-h-b,y:e+r+f},w:{x:o-l-f-u,y:e+r/2-d-b},nw:{x:o-l-u,y:e-p-u},ne:{x:o+i,y:e-p-u},se:{x:o+i,y:e+r},sw:{x:o-l-u,y:e+r}}}_closing=!1;mouseout(){this._closing=!0,this._tooltipElement.on("mouseover",()=>{this._closing=!1}),this._tooltipElement.on("mouseout",()=>{this.mouseout()}),setTimeout(()=>{this._closing&&this.visible(!1)},this.closeDelay())}visible(t){return arguments.length?(this._arrowElement&&(this._arrowElement.style("visibility",t?"visible":"hidden"),this._tooltipElement.style("visibility",t?"visible":"hidden")),super.visible(t),this):super.visible()}exit(t,e){this._arrowElement&&(this._arrowElement.remove(),this._tooltipElement.remove()),super.exit(t,e)}};c.prototype._class+=" html_HTMLTooltip";c.prototype.publish("fitContent",!1,"boolean","If true, tooltip will grow to fit its html content");c.prototype.publish("followCursor",!1,"boolean","If true, tooltip will display relative to cursor location");c.prototype.publish("closeDelay",400,"number","Number of milliseconds to wait before closing tooltip (cancelled on tooltip mouseover event)");c.prototype.publish("direction","n","set","Direction in which to display the tooltip",["n","s","e","w","ne","nw","se","sw"]);c.prototype.publish("padding",8,"number","Padding (pixels)");c.prototype.publish("arrowWidth",16,"number","Width (or height depending on direction) of the tooltip arrow (pixels)");c.prototype.publish("arrowHeight",8,"number","Height (or width depending on direction) of the tooltip arrow (pixels)");c.prototype.publish("fontColor","#FFF","html-color","The default font color for text in the tooltip");c.prototype.publish("tooltipColor","#000000EE","html-color","Background color of the tooltip");c.prototype.publish("tooltipWidth",200,"number","Width of the tooltip (not including arrow) (pixels)");c.prototype.publish("tooltipHeight",200,"number","Height of the tooltip (not including arrow) (pixels)");c.prototype.publish("enablePointerEvents",!1,"boolean","If true, the 'pointer-events: all' style will be used");import{HTMLWidget as N,select as M}from"@hpcc-js/common";var w=class extends N{static{s(this,"SimpleTable")}_table;_tbody;_thead;_theadRow;constructor(){super()}transformData(){return this.data()}enter(t,e){super.enter(t,e),this._table=e.append("table"),this._thead=this._table.append("thead"),this._theadRow=this._thead.append("tr"),this._tbody=this._table.append("tbody")}update(t,e){super.update(t,e),this._table.style("width",this.autoWidth()?"auto":"100%");let o=this._theadRow.selectAll("th").data(this.columns());o.enter().append("th").attr("class",(r,l)=>`th-${l}`).merge(o).text(r=>r.toString()),o.exit().remove();let i=this._tbody.selectAll("tr").data(this.transformData());i.enter().append("tr").merge(i).each(function(r){let p=M(this).selectAll("td").data(r);p.enter().append("td").attr("class",(h,d)=>`col-${d}`).merge(p).text(h=>h.toString()),p.exit().remove()}),i.exit().remove()}};w.prototype._class+=" html_SimpleTable";w.prototype.publish("autoWidth",!1,"boolean","If true, table width will be set to 'auto'. If false, the width is set to '100%'");var g=class extends w{static{s(this,"StyledTable")}constructor(){super()}applyStyleObject(t,e){Object.keys(e).forEach(o=>{t.style(o,e[o])})}update(t,e){super.update(t,e),e.selectAll("tr,th,td").attr("style","").style("font-family",this.fontFamily()).style("color",this.fontColor()),this.theadColumnStyles().forEach((l,p)=>{this.applyStyleObject(e.select(`.th-${p}`),l)}),this.tbodyColumnStyles().forEach((l,p)=>{this.applyStyleObject(e.selectAll(`.col-${p}`),l)});let o=Object.keys(this.evenRowStyles()).length>0,i=Object.keys(this.lastRowStyles()).length>0,r=e.selectAll("tbody > tr");if(o){let l=r.select(function(p,h){return h%2?this:null});this.applyStyleObject(l,this.evenRowStyles())}if(i){let l=r.select(function(p,h,d){return h===d.length-1?this:null});this.applyStyleObject(l,this.lastRowStyles())}}};g.prototype._class+=" html_StyledTable";g.prototype.publish("fontFamily","Verdana","string","Base font-family used within the table");g.prototype.publish("fontColor","#333","string","Base font color used within the table");g.prototype.publish("theadColumnStyles",[],"array",'Array of objects containing styles for the thead columns (ex: [{"color":"red"},{"color":"blue"}])');g.prototype.publish("tbodyColumnStyles",[],"array",'Array of objects containing styles for the tbody columns (ex: [{"color":"red"},{"color":"blue"}])');g.prototype.publish("lastRowStyles",{},"object",'Object containing styles for the last row (ex: {"color":"red"})');g.prototype.publish("evenRowStyles",{},"object",'Object containing styles for even rows (ex: {"background-color":"#AAA"})');var a=class extends g{static{s(this,"BreakdownTable")}_tooltip;constructor(){super()}transformData(){let t=this.useCalculatedRowCount()?this.calculateRowCount():this.rowCount();return this.breakdownData(t)}breakdownData(t){let e=this.data().length,o=this.data().reduce((h,d)=>h+d[1],0),i=[],r=0;this.data().sort((h,d)=>h[1]>d[1]?-1:1);let p=e-t>0;if(this.data().filter((h,d)=>p?d<t-1:!0).forEach(h=>{let d=Math.round(h[1]/o*100);r+=d,i.push([h[0],d+"%"])}),p){let h=`${this.otherLabel()} (${e-t+1})`,d="~"+(100-r)+"%";i.push([h,d])}return i}calculateRowCount(){let t=this.columns().length>0?this.thFontSize()+5:0,e=this.fontSize()+5,o=this.height()-t;return Math.floor(o/e)}enter(t,e){super.enter(t,e),this._tooltip=new c().target(t),this._tooltip.tooltipHTML(o=>{let i=this.useCalculatedRowCount()?this.calculateRowCount():this.rowCount(),r=Math.max(...o.map(u=>this.textSize(u[0],this.fontFamily(),this.fontSize()).height))??this.fontSize(),l=Math.max(...o.map(u=>this.textSize(u[0],this.fontFamily(),this.fontSize()).width)),p=30,h=2,d=h*(l+p)+this._tooltip.padding()*2,f=r*Math.ceil((o.length-i)/h)+this._tooltip.padding()*2;this._tooltip.tooltipWidth(d),this._tooltip.tooltipHeight(f);let b=this.breakdownData(this.data().length).slice(i-1);return`<div style="
|
|
1
|
+
(function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode("#wrap{width:100%}#left,#right{padding:5px}#left{background-color:red;text-align:left;display:block;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}#right{background-color:orange;float:right;text-align:right;white-space:nowrap}.html_TitleBar>.main{width:100%;display:block}.html_TitleBar .title{padding:4px;text-align:left;display:block;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;font-size:20px;font-weight:700}.html_TitleBar .icon-bar{padding:4px;float:right;text-align:right;white-space:nowrap;line-height:28px}.html_TitleBar .icon-bar-item{display:inline}.html_TitleBar .icon-bar-item>div{display:inline}.html_TitleBar .icon-bar a{text-align:center;padding-top:4px;padding-bottom:4px;transition:all .3s ease;color:#a9a9a9}.html_TitleBar .icon-bar a:hover{background-color:#f5f5f5}.html_TitleBar .icon-bar a.selected{background-color:#efe5e5}.html_TitleBar .icon-bar a.spacer{text-align:center;padding-top:2px;padding-left:8px;padding-bottom:0;color:none}.html_TitleBar .icon-bar a.spacer:hover{background-color:transparent}.html_TitleBar .icon-bar .active{background-color:#4caf50}")),document.head.appendChild(t)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
|
|
5
|
+
import { HTMLWidget, select, format } from "@hpcc-js/common";
|
|
6
|
+
import { scopedLogger } from "@hpcc-js/util";
|
|
7
|
+
import { React } from "@hpcc-js/react";
|
|
8
|
+
const PKG_NAME = "@hpcc-js/html", PKG_VERSION = "3.1.1", BUILD_VERSION = "3.2.1";
|
|
9
|
+
class HTMLTooltip extends HTMLWidget {
|
|
10
|
+
constructor() {
|
|
11
|
+
super();
|
|
12
|
+
__publicField(this, "_triggerElement");
|
|
13
|
+
__publicField(this, "_contentNode");
|
|
14
|
+
__publicField(this, "_prevContentNode");
|
|
15
|
+
__publicField(this, "_tooltipElement");
|
|
16
|
+
__publicField(this, "_arrowElement");
|
|
17
|
+
__publicField(this, "_tooltipHTMLCallback", (data) => "<b>_tooltipHTMLCallback is undefined</b>");
|
|
18
|
+
__publicField(this, "_logger", scopedLogger("html/HTMLTooltip"));
|
|
19
|
+
__publicField(this, "_cursorLoc");
|
|
20
|
+
__publicField(this, "_closing", !1);
|
|
21
|
+
this.visible(!1);
|
|
22
|
+
}
|
|
23
|
+
tooltipHTML(_) {
|
|
24
|
+
return this._tooltipHTMLCallback = _, this;
|
|
25
|
+
}
|
|
26
|
+
tooltipContent(_) {
|
|
27
|
+
return arguments.length ? (this._contentNode = _, this) : this._contentNode;
|
|
28
|
+
}
|
|
29
|
+
triggerElement(_) {
|
|
30
|
+
return this._triggerElement = _, this;
|
|
31
|
+
}
|
|
32
|
+
enter(domNode, element) {
|
|
33
|
+
super.enter(domNode, element);
|
|
34
|
+
const body = select("body");
|
|
35
|
+
this._tooltipElement = body.append("div").attr("class", "tooltip-div").style("z-index", "2147483638").style("position", "fixed"), this._arrowElement = body.append("div").attr("class", "arrow-div").style("z-index", "2147483638").style("position", "fixed");
|
|
36
|
+
}
|
|
37
|
+
update(domNode, element) {
|
|
38
|
+
if (super.update(domNode, element), this._contentNode !== this._prevContentNode) {
|
|
39
|
+
const node = this._tooltipElement.node();
|
|
40
|
+
[...node.querySelectorAll("*")].map((n) => n.__data__).filter((n) => n).forEach((w) => {
|
|
41
|
+
typeof w.target == "function" && w.target(null), typeof w.exit == "function" && w.exit();
|
|
42
|
+
}), node.innerHTML = "", node.appendChild(this._contentNode), this._prevContentNode = this._contentNode;
|
|
43
|
+
}
|
|
44
|
+
if (this._contentNode ? this.onShowContent(this._contentNode) : this._tooltipElement.html(() => this._tooltipHTMLCallback(this.data())), this.fitContent()) {
|
|
45
|
+
this._tooltipElement.style("width", "auto").style("height", "auto").style("padding", "0px").style("box-sizing", "content-box");
|
|
46
|
+
const rect = this._tooltipElement.node().getBoundingClientRect();
|
|
47
|
+
this.tooltipWidth_default(rect.width), this.tooltipHeight_default(rect.height);
|
|
48
|
+
}
|
|
49
|
+
this._closing = !1, this._tooltipElement.style("background-color", this.tooltipColor()).style("color", this.fontColor()).style("width", this.tooltipWidth() + "px").style("height", this.tooltipHeight() + "px").style("opacity", 1).style("padding", this.padding() + "px").style("pointer-events", this.enablePointerEvents() ? "all" : "none").style("box-sizing", "content-box"), this._arrowElement.style("opacity", 1).style("pointer-events", "none"), this.updateTooltipPosition();
|
|
50
|
+
}
|
|
51
|
+
onShowContent(node) {
|
|
52
|
+
}
|
|
53
|
+
updateTooltipPosition() {
|
|
54
|
+
const bbox = this.calcReferenceBBox(), direction = this.calcTooltipDirection(bbox), box = bbox[direction];
|
|
55
|
+
return this._tooltipElement.style("top", box.y + "px").style("left", box.x + "px"), this.setArrowPosition(box, direction), box;
|
|
56
|
+
}
|
|
57
|
+
calcTooltipDirection(bbox) {
|
|
58
|
+
const directions = Object.keys(bbox), defaultDirection = this.direction();
|
|
59
|
+
directions.sort((a, b) => a === defaultDirection ? -1 : 1);
|
|
60
|
+
const windowRect = {
|
|
61
|
+
top: 0,
|
|
62
|
+
left: 0,
|
|
63
|
+
width: window.innerWidth,
|
|
64
|
+
height: window.innerHeight
|
|
65
|
+
};
|
|
66
|
+
for (let i = 0; i < directions.length; i++) {
|
|
67
|
+
const tooltipRect = {
|
|
68
|
+
top: bbox[directions[i]].y,
|
|
69
|
+
left: bbox[directions[i]].x,
|
|
70
|
+
width: this.tooltipWidth(),
|
|
71
|
+
height: this.tooltipHeight()
|
|
72
|
+
};
|
|
73
|
+
if (this.rectFits(tooltipRect, windowRect))
|
|
74
|
+
return directions[i];
|
|
75
|
+
}
|
|
76
|
+
return this._logger.warning(`Tooltip doesn't fit in the window for any of the directions. Defaulting to '${defaultDirection}'`), this._logger.debug(windowRect), this._logger.debug({
|
|
77
|
+
top: bbox[defaultDirection].y,
|
|
78
|
+
left: bbox[defaultDirection].x,
|
|
79
|
+
width: this.tooltipWidth(),
|
|
80
|
+
height: this.tooltipHeight()
|
|
81
|
+
}), defaultDirection;
|
|
82
|
+
}
|
|
83
|
+
rectFits(innerRect, outerRect) {
|
|
84
|
+
return innerRect.top >= outerRect.top && innerRect.left >= outerRect.left && innerRect.width + innerRect.left <= outerRect.width + outerRect.left && innerRect.height + innerRect.top <= outerRect.height + outerRect.top;
|
|
85
|
+
}
|
|
86
|
+
setArrowPosition(point, direction) {
|
|
87
|
+
let top, left, visibleBorderStyle = "border-top-color";
|
|
88
|
+
switch (this._arrowElement.style("border", `${this.arrowHeight()}px solid ${this.tooltipColor()}`).style("border-top-color", "transparent").style("border-right-color", "transparent").style("border-bottom-color", "transparent").style("border-left-color", "transparent"), direction) {
|
|
89
|
+
case "n":
|
|
90
|
+
top = point.y + this.tooltipHeight() + this.padding() * 2, left = point.x + this.tooltipWidth() / 2 - this.arrowWidth() / 2 + this.padding(), visibleBorderStyle = "border-top-color", this._arrowElement.style("border-top-width", `${this.arrowHeight()}px`).style("border-bottom-width", "0px").style("border-left-width", `${this.arrowWidth() / 2}px`).style("border-right-width", `${this.arrowWidth() / 2}px`);
|
|
91
|
+
break;
|
|
92
|
+
case "s":
|
|
93
|
+
top = point.y - this.arrowHeight(), left = point.x + this.padding() + this.tooltipWidth() / 2 - this.arrowWidth() / 2, visibleBorderStyle = "border-bottom-color", this._arrowElement.style("border-top-width", "0px").style("border-bottom-width", `${this.arrowHeight()}px`).style("border-left-width", `${this.arrowWidth() / 2}px`).style("border-right-width", `${this.arrowWidth() / 2}px`);
|
|
94
|
+
break;
|
|
95
|
+
case "e":
|
|
96
|
+
top = point.y + this.tooltipHeight() / 2 + this.padding() - this.arrowWidth() / 2, left = point.x - this.arrowHeight(), visibleBorderStyle = "border-right-color", this._arrowElement.style("border-top-width", `${this.arrowWidth() / 2}px`).style("border-bottom-width", `${this.arrowWidth() / 2}px`).style("border-left-width", "0px").style("border-right-width", `${this.arrowHeight()}px`);
|
|
97
|
+
break;
|
|
98
|
+
case "w":
|
|
99
|
+
top = point.y + this.tooltipHeight() / 2 - this.arrowWidth() / 2 + this.padding(), left = point.x + this.tooltipWidth() + this.padding() * 2, visibleBorderStyle = "border-left-color", this._arrowElement.style("border-top-width", `${this.arrowWidth() / 2}px`).style("border-bottom-width", `${this.arrowWidth() / 2}px`).style("border-left-width", `${this.arrowHeight()}px`).style("border-right-width", "0px");
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
return typeof top < "u" && typeof left < "u" ? this._arrowElement.style("top", top + "px").style("left", left + "px").style(visibleBorderStyle, this.tooltipColor()).style("opacity", 1) : this._arrowElement.style("opacity", 0), point;
|
|
103
|
+
}
|
|
104
|
+
getReferenceNode() {
|
|
105
|
+
return this._triggerElement ? this._triggerElement.node() : this.element().node().parentNode.parentNode;
|
|
106
|
+
}
|
|
107
|
+
calcReferenceBBox() {
|
|
108
|
+
const node = this.getReferenceNode();
|
|
109
|
+
let { top, left, width, height } = node.getBoundingClientRect();
|
|
110
|
+
const wholeW = this.tooltipWidth(), wholeH = this.tooltipHeight(), halfW = wholeW / 2, halfH = wholeH / 2, arrowH = this.arrowHeight(), p = this.padding(), p2 = p * 2;
|
|
111
|
+
return this.followCursor() && this._cursorLoc && (left = this._cursorLoc[0], top = this._cursorLoc[1], width = 1, height = 1), {
|
|
112
|
+
n: {
|
|
113
|
+
x: left + width / 2 - halfW - p,
|
|
114
|
+
y: top - wholeH - arrowH - p2
|
|
115
|
+
},
|
|
116
|
+
e: {
|
|
117
|
+
x: left + width + arrowH,
|
|
118
|
+
y: top + height / 2 - halfH - p
|
|
119
|
+
},
|
|
120
|
+
s: {
|
|
121
|
+
x: left + width / 2 - halfW - p,
|
|
122
|
+
y: top + height + arrowH
|
|
123
|
+
},
|
|
124
|
+
w: {
|
|
125
|
+
x: left - wholeW - arrowH - p2,
|
|
126
|
+
y: top + height / 2 - halfH - p
|
|
127
|
+
},
|
|
128
|
+
nw: {
|
|
129
|
+
x: left - wholeW - p2,
|
|
130
|
+
y: top - wholeH - p2
|
|
131
|
+
},
|
|
132
|
+
ne: {
|
|
133
|
+
x: left + width,
|
|
134
|
+
y: top - wholeH - p2
|
|
135
|
+
},
|
|
136
|
+
se: {
|
|
137
|
+
x: left + width,
|
|
138
|
+
y: top + height
|
|
139
|
+
},
|
|
140
|
+
sw: {
|
|
141
|
+
x: left - wholeW - p2,
|
|
142
|
+
y: top + height
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
mouseout() {
|
|
147
|
+
this._closing = !0, this._tooltipElement.on("mouseover", () => {
|
|
148
|
+
this._closing = !1;
|
|
149
|
+
}), this._tooltipElement.on("mouseout", () => {
|
|
150
|
+
this.mouseout();
|
|
151
|
+
}), setTimeout(() => {
|
|
152
|
+
this._closing && this.visible(!1);
|
|
153
|
+
}, this.closeDelay());
|
|
154
|
+
}
|
|
155
|
+
visible(_) {
|
|
156
|
+
return arguments.length ? (this._arrowElement && (this._arrowElement.style("visibility", _ ? "visible" : "hidden"), this._tooltipElement.style("visibility", _ ? "visible" : "hidden")), super.visible(_), this) : super.visible();
|
|
157
|
+
}
|
|
158
|
+
exit(domNode, element) {
|
|
159
|
+
this._arrowElement && (this._arrowElement.remove(), this._tooltipElement.remove()), super.exit(domNode, element);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
HTMLTooltip.prototype._class += " html_HTMLTooltip";
|
|
163
|
+
HTMLTooltip.prototype.publish("fitContent", !1, "boolean", "If true, tooltip will grow to fit its html content");
|
|
164
|
+
HTMLTooltip.prototype.publish("followCursor", !1, "boolean", "If true, tooltip will display relative to cursor location");
|
|
165
|
+
HTMLTooltip.prototype.publish("closeDelay", 400, "number", "Number of milliseconds to wait before closing tooltip (cancelled on tooltip mouseover event)");
|
|
166
|
+
HTMLTooltip.prototype.publish("direction", "n", "set", "Direction in which to display the tooltip", ["n", "s", "e", "w", "ne", "nw", "se", "sw"]);
|
|
167
|
+
HTMLTooltip.prototype.publish("padding", 8, "number", "Padding (pixels)");
|
|
168
|
+
HTMLTooltip.prototype.publish("arrowWidth", 16, "number", "Width (or height depending on direction) of the tooltip arrow (pixels)");
|
|
169
|
+
HTMLTooltip.prototype.publish("arrowHeight", 8, "number", "Height (or width depending on direction) of the tooltip arrow (pixels)");
|
|
170
|
+
HTMLTooltip.prototype.publish("fontColor", "#FFF", "html-color", "The default font color for text in the tooltip");
|
|
171
|
+
HTMLTooltip.prototype.publish("tooltipColor", "#000000EE", "html-color", "Background color of the tooltip");
|
|
172
|
+
HTMLTooltip.prototype.publish("tooltipWidth", 200, "number", "Width of the tooltip (not including arrow) (pixels)");
|
|
173
|
+
HTMLTooltip.prototype.publish("tooltipHeight", 200, "number", "Height of the tooltip (not including arrow) (pixels)");
|
|
174
|
+
HTMLTooltip.prototype.publish("enablePointerEvents", !1, "boolean", "If true, the 'pointer-events: all' style will be used");
|
|
175
|
+
class SimpleTable extends HTMLWidget {
|
|
176
|
+
constructor() {
|
|
177
|
+
super();
|
|
178
|
+
__publicField(this, "_table");
|
|
179
|
+
__publicField(this, "_tbody");
|
|
180
|
+
__publicField(this, "_thead");
|
|
181
|
+
__publicField(this, "_theadRow");
|
|
182
|
+
}
|
|
183
|
+
transformData() {
|
|
184
|
+
return this.data();
|
|
185
|
+
}
|
|
186
|
+
enter(domNode, element) {
|
|
187
|
+
super.enter(domNode, element), this._table = element.append("table"), this._thead = this._table.append("thead"), this._theadRow = this._thead.append("tr"), this._tbody = this._table.append("tbody");
|
|
188
|
+
}
|
|
189
|
+
update(domNode, element) {
|
|
190
|
+
super.update(domNode, element), this._table.style("width", this.autoWidth() ? "auto" : "100%");
|
|
191
|
+
const theadTrSelection = this._theadRow.selectAll("th").data(this.columns());
|
|
192
|
+
theadTrSelection.enter().append("th").attr("class", (n, i) => `th-${i}`).merge(theadTrSelection).text((_d) => _d.toString()), theadTrSelection.exit().remove();
|
|
193
|
+
const trSelection = this._tbody.selectAll("tr").data(this.transformData());
|
|
194
|
+
trSelection.enter().append("tr").merge(trSelection).each(function(d) {
|
|
195
|
+
const tdSelection = select(this).selectAll("td").data(d);
|
|
196
|
+
tdSelection.enter().append("td").attr("class", (n, i) => `col-${i}`).merge(tdSelection).text((_d) => _d.toString()), tdSelection.exit().remove();
|
|
197
|
+
}), trSelection.exit().remove();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
SimpleTable.prototype._class += " html_SimpleTable";
|
|
201
|
+
SimpleTable.prototype.publish("autoWidth", !1, "boolean", "If true, table width will be set to 'auto'. If false, the width is set to '100%'");
|
|
202
|
+
class StyledTable extends SimpleTable {
|
|
203
|
+
constructor() {
|
|
204
|
+
super();
|
|
205
|
+
}
|
|
206
|
+
applyStyleObject(selection, styleObject) {
|
|
207
|
+
Object.keys(styleObject).forEach((styleName) => {
|
|
208
|
+
selection.style(styleName, styleObject[styleName]);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
update(domNode, element) {
|
|
212
|
+
super.update(domNode, element), element.selectAll("tr,th,td").attr("style", "").style("font-family", this.fontFamily()).style("color", this.fontColor()), this.theadColumnStyles().forEach((styleObj, i) => {
|
|
213
|
+
this.applyStyleObject(element.select(`.th-${i}`), styleObj);
|
|
214
|
+
}), this.tbodyColumnStyles().forEach((styleObj, i) => {
|
|
215
|
+
this.applyStyleObject(element.selectAll(`.col-${i}`), styleObj);
|
|
216
|
+
});
|
|
217
|
+
const evenRowStylesExist = Object.keys(this.evenRowStyles()).length > 0, lastRowStylesExist = Object.keys(this.lastRowStyles()).length > 0, tbodyRows = element.selectAll("tbody > tr");
|
|
218
|
+
if (evenRowStylesExist) {
|
|
219
|
+
const tbodyEvenRows = tbodyRows.select(function(d, i) {
|
|
220
|
+
return i % 2 ? this : null;
|
|
221
|
+
});
|
|
222
|
+
this.applyStyleObject(tbodyEvenRows, this.evenRowStyles());
|
|
223
|
+
}
|
|
224
|
+
if (lastRowStylesExist) {
|
|
225
|
+
const tbodyLastRow = tbodyRows.select(function(d, i, arr) {
|
|
226
|
+
return i === arr.length - 1 ? this : null;
|
|
227
|
+
});
|
|
228
|
+
this.applyStyleObject(tbodyLastRow, this.lastRowStyles());
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
StyledTable.prototype._class += " html_StyledTable";
|
|
233
|
+
StyledTable.prototype.publish("fontFamily", "Verdana", "string", "Base font-family used within the table");
|
|
234
|
+
StyledTable.prototype.publish("fontColor", "#333", "string", "Base font color used within the table");
|
|
235
|
+
StyledTable.prototype.publish("theadColumnStyles", [], "array", 'Array of objects containing styles for the thead columns (ex: [{"color":"red"},{"color":"blue"}])');
|
|
236
|
+
StyledTable.prototype.publish("tbodyColumnStyles", [], "array", 'Array of objects containing styles for the tbody columns (ex: [{"color":"red"},{"color":"blue"}])');
|
|
237
|
+
StyledTable.prototype.publish("lastRowStyles", {}, "object", 'Object containing styles for the last row (ex: {"color":"red"})');
|
|
238
|
+
StyledTable.prototype.publish("evenRowStyles", {}, "object", 'Object containing styles for even rows (ex: {"background-color":"#AAA"})');
|
|
239
|
+
class BreakdownTable extends StyledTable {
|
|
240
|
+
constructor() {
|
|
241
|
+
super();
|
|
242
|
+
// protected _table;
|
|
243
|
+
// protected _tbody;
|
|
244
|
+
__publicField(this, "_tooltip");
|
|
245
|
+
}
|
|
246
|
+
transformData() {
|
|
247
|
+
const rowCount = this.useCalculatedRowCount() ? this.calculateRowCount() : this.rowCount();
|
|
248
|
+
return this.breakdownData(rowCount);
|
|
249
|
+
}
|
|
250
|
+
breakdownData(limit) {
|
|
251
|
+
const len = this.data().length, sum = this.data().reduce((acc, row) => acc + row[1], 0), data = [];
|
|
252
|
+
let percSum = 0;
|
|
253
|
+
this.data().sort((a, b) => a[1] > b[1] ? -1 : 1);
|
|
254
|
+
const showOther = len - limit > 0;
|
|
255
|
+
if (this.data().filter((_, i) => showOther ? i < limit - 1 : !0).forEach((row) => {
|
|
256
|
+
const perc = Math.round(row[1] / sum * 100);
|
|
257
|
+
percSum += perc, data.push([row[0], perc + "%"]);
|
|
258
|
+
}), showOther) {
|
|
259
|
+
const otherLabel = `${this.otherLabel()} (${len - limit + 1})`, otherPercentage = "~" + (100 - percSum) + "%";
|
|
260
|
+
data.push([otherLabel, otherPercentage]);
|
|
261
|
+
}
|
|
262
|
+
return data;
|
|
263
|
+
}
|
|
264
|
+
calculateRowCount() {
|
|
265
|
+
const theadRowHeight = this.columns().length > 0 ? this.thFontSize() + 5 : 0, tbodyRowHeight = this.fontSize() + 5, tbodyAvailableHeight = this.height() - theadRowHeight;
|
|
266
|
+
return Math.floor(tbodyAvailableHeight / tbodyRowHeight);
|
|
267
|
+
}
|
|
268
|
+
enter(domNode, element) {
|
|
269
|
+
super.enter(domNode, element), this._tooltip = new HTMLTooltip().target(domNode), this._tooltip.tooltipHTML((data) => {
|
|
270
|
+
const rowCount = this.useCalculatedRowCount() ? this.calculateRowCount() : this.rowCount(), rowHeight = Math.max(...data.map((row) => this.textSize(row[0], this.fontFamily(), this.fontSize()).height)) ?? this.fontSize(), widestLabel = Math.max(...data.map((row) => this.textSize(row[0], this.fontFamily(), this.fontSize()).width)), widestPerc = 30, colCount = 2, w = colCount * (widestLabel + widestPerc) + this._tooltip.padding() * 2, h = rowHeight * Math.ceil((data.length - rowCount) / colCount) + this._tooltip.padding() * 2;
|
|
271
|
+
this._tooltip.tooltipWidth(w), this._tooltip.tooltipHeight(h);
|
|
272
|
+
const otherData = this.breakdownData(this.data().length).slice(rowCount - 1);
|
|
273
|
+
return `<div style="
|
|
2
274
|
width: 100%;
|
|
3
275
|
height: 100%;
|
|
4
276
|
font-size: ${this.fontSize()}px;
|
|
5
|
-
">${
|
|
277
|
+
">${otherData.map(
|
|
278
|
+
(row) => `<div style="
|
|
6
279
|
float:left;
|
|
7
|
-
width:${Math.floor(99/
|
|
8
|
-
">${
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
.
|
|
91
|
-
|
|
92
|
-
|
|
280
|
+
width:${Math.floor(99 / colCount)}%;
|
|
281
|
+
">${row[0]}: ${row[1]}</div>`
|
|
282
|
+
).join("")}</div>`;
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
update(domNode, element) {
|
|
286
|
+
if (this.theadColumnStyles_default([
|
|
287
|
+
{
|
|
288
|
+
color: this.thFirstColor(),
|
|
289
|
+
"font-size": this.thFontSize() + "px",
|
|
290
|
+
"font-weight": this.thFontWeight(),
|
|
291
|
+
"text-align": this.labelAlignment(),
|
|
292
|
+
width: "auto",
|
|
293
|
+
padding: "0px"
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
width: "1%",
|
|
297
|
+
"font-size": this.thFontSize() + "px",
|
|
298
|
+
"font-weight": this.thFontWeight(),
|
|
299
|
+
"text-align": this.percentageAlignment(),
|
|
300
|
+
padding: "0px"
|
|
301
|
+
}
|
|
302
|
+
]), this.tbodyColumnStyles_default([
|
|
303
|
+
{
|
|
304
|
+
color: this.topLabelColor(),
|
|
305
|
+
"font-size": this.fontSize() + "px",
|
|
306
|
+
"font-weight": "normal",
|
|
307
|
+
"text-align": this.labelAlignment(),
|
|
308
|
+
width: "auto",
|
|
309
|
+
padding: "0px"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
color: this.topPercentageColor(),
|
|
313
|
+
"font-size": this.fontSize() + "px",
|
|
314
|
+
"font-weight": "normal",
|
|
315
|
+
"text-align": this.percentageAlignment(),
|
|
316
|
+
width: "1%",
|
|
317
|
+
padding: "0px"
|
|
318
|
+
}
|
|
319
|
+
]), this.lastRowStyles_default([
|
|
320
|
+
{
|
|
321
|
+
color: this.otherLabelColor(),
|
|
322
|
+
"font-size": this.fontSize() + "px",
|
|
323
|
+
"font-weight": this.otherLabelBold() ? "bold" : "normal",
|
|
324
|
+
"text-align": this.labelAlignment(),
|
|
325
|
+
width: "auto",
|
|
326
|
+
padding: "0px"
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
color: this.otherLabelColor(),
|
|
330
|
+
"font-size": this.fontSize() + "px",
|
|
331
|
+
"font-weight": this.otherPercentageBold() ? "bold" : "normal",
|
|
332
|
+
"text-align": this.percentageAlignment(),
|
|
333
|
+
width: "1%",
|
|
334
|
+
padding: "0px"
|
|
335
|
+
}
|
|
336
|
+
]), super.update(domNode, element), (this.useCalculatedRowCount() ? this.calculateRowCount() : this.rowCount()) < this.data().length) {
|
|
337
|
+
const lastRow = element.select("tbody > tr:last-child"), context = this;
|
|
338
|
+
lastRow.on("mouseout.tooltip", (d) => {
|
|
339
|
+
context._tooltip._triggerElement = lastRow, context._tooltip.visible(!1).render();
|
|
340
|
+
}).on("mouseenter.tooltip", (d) => {
|
|
341
|
+
context._tooltip._triggerElement = lastRow, context._tooltip.direction("n").data(context.data()).visible(!0).render();
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
BreakdownTable.prototype._class += " html_BreakdownTable";
|
|
347
|
+
BreakdownTable.prototype.publish("useCalculatedRowCount", !0, "boolean", "If true, rowCount will be calculated and its default will be overwritten");
|
|
348
|
+
BreakdownTable.prototype.publish("rowCount", 5, "number", "Number of total rows to display (including the 'other' row)", void 0, { disable: (w) => w.useCalculatedRowCount() });
|
|
349
|
+
BreakdownTable.prototype.publish("fontSize", 14, "number", "Font size (pixels)");
|
|
350
|
+
BreakdownTable.prototype.publish("labelAlignment", "left", "set", "Alignment of the label column text", ["left", "center", "right"]);
|
|
351
|
+
BreakdownTable.prototype.publish("percentageAlignment", "center", "set", "Alignment of the percentage column text", ["left", "center", "right"]);
|
|
352
|
+
BreakdownTable.prototype.publish("topLabelColor", "#333", "html-color", "Color of displayed 'top' labels");
|
|
353
|
+
BreakdownTable.prototype.publish("topPercentageColor", "#1A99D5", "html-color", "Color of displayed 'top' percentages");
|
|
354
|
+
BreakdownTable.prototype.publish("topPercentageBold", !0, "html-color", "If true, the 'top' percentages will be bold");
|
|
355
|
+
BreakdownTable.prototype.publish("otherLabel", "Other", "string", "Label text for the 'other' row");
|
|
356
|
+
BreakdownTable.prototype.publish("otherLabelColor", "#AAA", "html-color", "Color of the 'other' label");
|
|
357
|
+
BreakdownTable.prototype.publish("otherLabelBold", !1, "html-color", "If true, the 'other' label will be bold");
|
|
358
|
+
BreakdownTable.prototype.publish("otherPercentageColor", "#AAA", "html-color", "Color of the 'other' percentage");
|
|
359
|
+
BreakdownTable.prototype.publish("otherPercentageBold", !1, "html-color", "If true, the 'other' percentage will be bold");
|
|
360
|
+
BreakdownTable.prototype.publish("thFontWeight", "bold", "string", "Font weight for th elements");
|
|
361
|
+
BreakdownTable.prototype.publish("thFontSize", 26, "number", "Font size for th elements");
|
|
362
|
+
BreakdownTable.prototype.publish("thFirstColor", "#333", "html-color", "Text color of the first th element");
|
|
363
|
+
BreakdownTable.prototype.publish("thLastColor", "#333", "html-color", "Text color of the last th element");
|
|
364
|
+
class JSXWidget extends HTMLWidget {
|
|
365
|
+
constructor() {
|
|
366
|
+
super(...arguments);
|
|
367
|
+
__publicField(this, "rootNode");
|
|
368
|
+
}
|
|
369
|
+
jsxRender(jsx, domNode) {
|
|
370
|
+
this.rootNode = React.render(jsx, domNode, this.rootNode);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
__publicField(JSXWidget, "Component", React.Component), __publicField(JSXWidget, "createElement", React.createElement);
|
|
374
|
+
JSXWidget.prototype._class += " html_JSXWidget";
|
|
375
|
+
class VNode {
|
|
376
|
+
constructor(attrs, children) {
|
|
377
|
+
__publicField(this, "_attrs");
|
|
378
|
+
__publicField(this, "_children");
|
|
379
|
+
this._attrs = attrs, this._children = children;
|
|
380
|
+
}
|
|
381
|
+
type() {
|
|
382
|
+
return "div";
|
|
383
|
+
}
|
|
384
|
+
attrs() {
|
|
385
|
+
return this._attrs;
|
|
386
|
+
}
|
|
387
|
+
attr(key) {
|
|
388
|
+
return this._attrs[key];
|
|
389
|
+
}
|
|
390
|
+
children() {
|
|
391
|
+
return this._children;
|
|
392
|
+
}
|
|
393
|
+
update(targetElement) {
|
|
394
|
+
for (const key in this._attrs)
|
|
395
|
+
targetElement.attr(key, this._attrs[key]);
|
|
396
|
+
}
|
|
397
|
+
render(targetElement) {
|
|
398
|
+
const thisElement = targetElement.selectAll(`${targetElement.node().tagName} > *`).data([this]);
|
|
399
|
+
return thisElement.exit().remove(), thisElement.enter().append(this.type()).attr("reactd3", 0).merge(thisElement).each(function(d) {
|
|
400
|
+
const element = select(this);
|
|
401
|
+
d.update(element), d.renderChildren(element);
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
renderChildren(targetElement) {
|
|
405
|
+
const thisElement = targetElement.selectAll(`${targetElement.node().tagName} > *`).data(this._children);
|
|
406
|
+
return thisElement.exit().remove(), thisElement.enter().append((d) => document.createElement(d.type())).attr("reactd3", (_d, i) => i).merge(thisElement).each(function(d) {
|
|
407
|
+
const element = select(this);
|
|
408
|
+
d.update(element), d.renderChildren(element);
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
class ConstVNode extends VNode {
|
|
413
|
+
constructor(type, attrs, children) {
|
|
414
|
+
super(attrs, children);
|
|
415
|
+
__publicField(this, "_type");
|
|
416
|
+
this._type = type;
|
|
417
|
+
}
|
|
418
|
+
type() {
|
|
419
|
+
return this._type;
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
class TextVNode extends VNode {
|
|
423
|
+
constructor(text) {
|
|
424
|
+
super({}, []);
|
|
425
|
+
__publicField(this, "_text");
|
|
426
|
+
this._text = text;
|
|
427
|
+
}
|
|
428
|
+
type() {
|
|
429
|
+
return "span";
|
|
430
|
+
}
|
|
431
|
+
update(targetElement) {
|
|
432
|
+
super.update(targetElement), targetElement.text(this._text);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
function isReactFn(_) {
|
|
436
|
+
return typeof _ == "function";
|
|
437
|
+
}
|
|
438
|
+
function isIVNode(_) {
|
|
439
|
+
return _.prototype && _.prototype instanceof VNode;
|
|
440
|
+
}
|
|
441
|
+
class ReactD3 {
|
|
442
|
+
// static createElementXXX(type: string | ReactFn | IVNode, attrs: { [key: string]: string }, ...children: Array<string | VNode>): VNode {
|
|
443
|
+
static createElement(type, attrs, ...children) {
|
|
444
|
+
return isIVNode(type) ? new type(attrs) : isReactFn(type) ? type(attrs) : new ConstVNode(type, attrs, children.map((child) => typeof child == "string" ? new TextVNode(child) : child));
|
|
445
|
+
}
|
|
446
|
+
static render(vdom, targetElement) {
|
|
447
|
+
vdom.render(targetElement);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
var l;
|
|
451
|
+
l = { __e: function(n, l2, u2, t) {
|
|
452
|
+
for (var i, o, r; l2 = l2.__; ) if ((i = l2.__c) && !i.__) try {
|
|
453
|
+
if ((o = i.constructor) && o.getDerivedStateFromError != null && (i.setState(o.getDerivedStateFromError(n)), r = i.__d), i.componentDidCatch != null && (i.componentDidCatch(n, t || {}), r = i.__d), r) return i.__E = i;
|
|
454
|
+
} catch (l3) {
|
|
455
|
+
n = l3;
|
|
456
|
+
}
|
|
457
|
+
throw n;
|
|
458
|
+
} }, typeof Promise == "function" && Promise.prototype.then.bind(Promise.resolve());
|
|
459
|
+
var f = 0;
|
|
460
|
+
function u(e, t, n, o, i, u2) {
|
|
461
|
+
t || (t = {});
|
|
462
|
+
var a, l$1 = t;
|
|
463
|
+
"ref" in t && (a = t.ref, delete t.ref);
|
|
464
|
+
var p = { type: e, props: l$1, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --f, __i: -1, __u: 0, __source: i, __self: u2 };
|
|
465
|
+
return l.vnode && l.vnode(p), p;
|
|
466
|
+
}
|
|
467
|
+
class VizComponent extends JSXWidget.Component {
|
|
468
|
+
constructor() {
|
|
469
|
+
super(...arguments);
|
|
470
|
+
__publicField(this, "widget");
|
|
471
|
+
}
|
|
472
|
+
refreshProps() {
|
|
473
|
+
for (const key in this.props)
|
|
474
|
+
this.widget[key] && typeof this.widget[key] == "function" && this.widget[key](this.props[key]);
|
|
475
|
+
}
|
|
476
|
+
componentDidMount() {
|
|
477
|
+
this.widget = new this.props.type().target(this.base), this.refreshProps(), this.widget.render();
|
|
478
|
+
}
|
|
479
|
+
componentWillUnmount() {
|
|
480
|
+
this.widget.target(null).render();
|
|
481
|
+
}
|
|
482
|
+
render() {
|
|
483
|
+
return /* @__PURE__ */ u("div", { style: this.props.style });
|
|
484
|
+
}
|
|
485
|
+
componentDidUpdate() {
|
|
486
|
+
this.refreshProps(), this.widget.render();
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
class VizInstance extends JSXWidget.Component {
|
|
490
|
+
constructor() {
|
|
491
|
+
super(...arguments);
|
|
492
|
+
__publicField(this, "widget");
|
|
493
|
+
}
|
|
494
|
+
refreshProps() {
|
|
495
|
+
for (const key in this.props)
|
|
496
|
+
this.widget[key] && typeof this.widget[key] == "function" && this.widget[key](this.props[key]);
|
|
497
|
+
}
|
|
498
|
+
componentDidMount() {
|
|
499
|
+
this.widget = this.props.instance.target(this.base), this.refreshProps(), this.widget.render();
|
|
500
|
+
}
|
|
501
|
+
componentWillUnmount() {
|
|
502
|
+
this.widget.target(null).render();
|
|
503
|
+
}
|
|
504
|
+
render() {
|
|
505
|
+
return /* @__PURE__ */ u("div", { style: this.props.style });
|
|
506
|
+
}
|
|
507
|
+
componentDidUpdate() {
|
|
508
|
+
this.refreshProps(), this.widget.render();
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
class StatsTable extends StyledTable {
|
|
512
|
+
transformData() {
|
|
513
|
+
const totalRow = [["Total", 0, 0]], data = this.data();
|
|
514
|
+
return data.forEach((row) => {
|
|
515
|
+
totalRow[0][1] += row[1], totalRow[0][2] += row[2];
|
|
516
|
+
}), data.concat(totalRow).map((row) => [
|
|
517
|
+
row[0],
|
|
518
|
+
this.secondColumnFormat_exists() ? format(this.secondColumnFormat())(row[1]) : row[1],
|
|
519
|
+
this.thirdColumnFormat_exists() ? format(this.thirdColumnFormat())(row[2]) : row[2]
|
|
520
|
+
]);
|
|
521
|
+
}
|
|
522
|
+
update(domNode, element) {
|
|
523
|
+
this.tbodyColumnStyles_default([
|
|
524
|
+
{
|
|
525
|
+
"font-weight": "bold",
|
|
526
|
+
width: this.firstColumnWidth(),
|
|
527
|
+
"text-align": "left"
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
width: this.secondColumnWidth(),
|
|
531
|
+
"text-align": "right"
|
|
532
|
+
},
|
|
533
|
+
{
|
|
534
|
+
width: this.thirdColumnWidth(),
|
|
535
|
+
"text-align": "right"
|
|
536
|
+
}
|
|
537
|
+
]), this.evenRowStyles_default([
|
|
538
|
+
{
|
|
539
|
+
"font-weight": "bold",
|
|
540
|
+
width: this.firstColumnWidth(),
|
|
541
|
+
"text-align": "left",
|
|
542
|
+
"font-color": this.evenRowFontColor(),
|
|
543
|
+
"background-color": this.evenRowBackgroundColor()
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
width: this.secondColumnWidth(),
|
|
547
|
+
"text-align": "right",
|
|
548
|
+
"font-color": this.evenRowFontColor(),
|
|
549
|
+
"background-color": this.evenRowBackgroundColor()
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
width: this.thirdColumnWidth(),
|
|
553
|
+
"text-align": "right",
|
|
554
|
+
"font-color": this.evenRowFontColor(),
|
|
555
|
+
"background-color": this.evenRowBackgroundColor()
|
|
556
|
+
}
|
|
557
|
+
]), this.lastRowStyles_default({
|
|
558
|
+
"font-weight": "bold"
|
|
559
|
+
}), super.update(domNode, element);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
StatsTable.prototype._class += " html_StatsTable";
|
|
563
|
+
StatsTable.prototype.publish("labelColor", "#333", "html-color", "Color of the text in the first column");
|
|
564
|
+
StatsTable.prototype.publish("primaryValueColor", "#333", "html-color", "Color of the text in the second column");
|
|
565
|
+
StatsTable.prototype.publish("secondaryValueColor", "#333", "html-color", "Color of the text in the third column");
|
|
566
|
+
StatsTable.prototype.publish("evenRowBackgroundColor", "#333", "html-color", "Background color of the even rows");
|
|
567
|
+
StatsTable.prototype.publish("evenRowFontColor", "#333", "html-color", "Font color of the even rows");
|
|
568
|
+
StatsTable.prototype.publish("firstColumnWidth", "auto", "string", "CSS style applied as the 'width' for the first column (ex: 40px)");
|
|
569
|
+
StatsTable.prototype.publish("secondColumnWidth", "1%", "string", "CSS style applied as the 'width' for the second column (ex: 40px)");
|
|
570
|
+
StatsTable.prototype.publish("thirdColumnWidth", "1%", "string", "CSS style applied as the 'width' for the third column (ex: 40px)");
|
|
571
|
+
StatsTable.prototype.publish("secondColumnFormat", "$,.0f", "string", "d3-format specifier applied to the second column's values", void 0, { optional: !0 });
|
|
572
|
+
StatsTable.prototype.publish("thirdColumnFormat", null, "string", "d3-format specifier applied to the third column's values", void 0, { optional: !0 });
|
|
573
|
+
class Item extends HTMLWidget {
|
|
574
|
+
constructor(owner) {
|
|
575
|
+
super();
|
|
576
|
+
__publicField(this, "_owner");
|
|
577
|
+
this._owner = owner, this._tag = "a";
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
Item.prototype._class += " html_Item";
|
|
581
|
+
class Button extends Item {
|
|
582
|
+
constructor(owner, icon) {
|
|
583
|
+
super(owner);
|
|
584
|
+
__publicField(this, "_icon");
|
|
585
|
+
this._icon = icon;
|
|
586
|
+
}
|
|
587
|
+
icon() {
|
|
588
|
+
return this._icon;
|
|
589
|
+
}
|
|
590
|
+
enter(domNode, element) {
|
|
591
|
+
super.enter(domNode, element), element.attr("href", "#").on("click", (d, idx, groups) => this._owner.titleBarClick(this, d, idx, groups)).append("i").attr("class", `fa ${this._icon} fa-lg fa-fw`);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
Button.prototype._class += " html_Button";
|
|
595
|
+
class ToggleButton extends Button {
|
|
596
|
+
enter(domNode, element) {
|
|
597
|
+
element.on("click.sel", (d, idx, groups) => {
|
|
598
|
+
this.selected(!this.selected()), this.render();
|
|
599
|
+
}), super.enter(domNode, element);
|
|
600
|
+
}
|
|
601
|
+
update(domNode, element) {
|
|
602
|
+
super.update(domNode, element), this._element.classed("selected", this.selected());
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
ToggleButton.prototype._class += " html_ToggleButton";
|
|
606
|
+
ToggleButton.prototype.publish("selected", !1, "boolean");
|
|
607
|
+
class Spacer extends Item {
|
|
608
|
+
enter(domNode, element) {
|
|
609
|
+
super.enter(domNode, element), element.attr("class", "spacer").attr("href", "#").append("i");
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
Spacer.prototype._class += " html_Spacer";
|
|
613
|
+
class TitleBar extends JSXWidget {
|
|
614
|
+
constructor() {
|
|
615
|
+
super();
|
|
616
|
+
__publicField(this, "_divMain");
|
|
617
|
+
__publicField(this, "_divIconBar");
|
|
618
|
+
__publicField(this, "_divTitle");
|
|
619
|
+
}
|
|
620
|
+
enter(domNode, element) {
|
|
621
|
+
super.enter(domNode, element), this._divMain = element.append("div").attr("class", "main"), this._divIconBar = this._divMain.append("div").attr("class", "icon-bar"), this._divTitle = this._divMain.append("div").attr("class", "title");
|
|
622
|
+
}
|
|
623
|
+
update(domNode, element) {
|
|
624
|
+
super.update(domNode, element), this._divTitle.text(this.title());
|
|
625
|
+
const icons = this._divIconBar.selectAll(".icon-bar-item").data(this.buttons());
|
|
626
|
+
icons.enter().append("div").attr("class", "icon-bar-item").each(function(d) {
|
|
627
|
+
d.target(this);
|
|
628
|
+
}).merge(icons).each(function(d) {
|
|
629
|
+
d.render();
|
|
630
|
+
}), icons.exit().each(function(d) {
|
|
631
|
+
d.target(null);
|
|
632
|
+
}).remove(), icons.order();
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
TitleBar.prototype._class += " html_TitleBar";
|
|
636
|
+
TitleBar.prototype.publish("title", "", "string");
|
|
637
|
+
TitleBar.prototype.publish("buttons", [], "widgetArray");
|
|
638
|
+
export {
|
|
639
|
+
BUILD_VERSION,
|
|
640
|
+
BreakdownTable,
|
|
641
|
+
Button,
|
|
642
|
+
HTMLTooltip,
|
|
643
|
+
Item,
|
|
644
|
+
JSXWidget,
|
|
645
|
+
PKG_NAME,
|
|
646
|
+
PKG_VERSION,
|
|
647
|
+
ReactD3,
|
|
648
|
+
SimpleTable,
|
|
649
|
+
Spacer,
|
|
650
|
+
StatsTable,
|
|
651
|
+
StyledTable,
|
|
652
|
+
TitleBar,
|
|
653
|
+
ToggleButton,
|
|
654
|
+
VNode,
|
|
655
|
+
VizComponent,
|
|
656
|
+
VizInstance
|
|
657
|
+
};
|
|
93
658
|
//# sourceMappingURL=index.js.map
|