UNPKG

@devgateway/dvz-ui-react

Version:

A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.

2 lines (1 loc) 2.02 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),n=require("react"),p=require("react-dom/client"),c=require("d3"),h=require("./Tooltip.js"),d=require("./Utils.js");function u(o){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(o){for(const t in o)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(o,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>o[t]})}}return e.default=o,Object.freeze(e)}const i=u(c);let f=class extends n.Component{constructor(){super(),this.loadJSON=this.loadJSON.bind(this),this.create=this.create.bind(this),this.createLayer=this.createLayer.bind(this),this.loadJSON=this.loadJSON.bind(this),this.showToolTip=this.showToolTip.bind(this),this.moveToolTip=this.moveToolTip.bind(this),this.gRef=n.createRef(),this.state={json:null}}loadJSON(e){return d.loadJSON(e)}createLayer(e){alert("please implement createLayer")}applyInitialTransform(){const{editing:e,initialPosition:t,width:s,height:a}=this.props;i.select(this.gRef.current).attr("transform",`translate(${t.x},${t.y}) scale(${t.k})`)}create(){const{file:e}=this.props;this.state.json?this.createLayer(this.state.json):this.loadJSON(e).then(t=>{this.createLayer(t)})}showToolTip(e,t,s,a){if(t){const l=i.select("body").append("div").attr("class","d3MapTooltip").style("position","absolute").html("").style("left",window.event.pageX+15+"px").style("top",window.event.pageY-50+"px");p.createRoot(l._groups[0][0]).render(r.jsx(h.default,{intl:this.props.intl,tooltip:e,data:t,tooltipEnableMarkdown:!1}))}}moveToolTip(e){i.select(".d3MapTooltip").style("left",window.event.pageX+15+"px").style("top",window.event.pageY-50+"px")}hiddenToolTip(e){i.selectAll(".d3MapTooltip").remove()}componentDidMount(){this.props.zoom&&this.gRef.current&&this.applyInitialTransform(),this.create()}render(){const{name:e,height:t,width:s}=this.props;return r.jsx("g",{className:"layer",ref:this.gRef})}};exports.default=f;