@hakit/components
Version:
A series of components to work with @hakit/core
3 lines (2 loc) • 2.17 kB
JavaScript
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("../../../emotion-react-jsx-runtime.browser.esm-CgJouFLh.cjs"),f=require("../../../emotion-styled-base.browser.esm-D0rcP917.cjs"),c=require("react"),p=require("@emotion/react"),d=require("./constants.js");function g(){return"You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."}const m=(n,e,o,s)=>{const i=(n-o)/2+o,r=(e-s)/2+s;return[i,r]},v=n=>{if(!n.length)return"";let e,o;const s=0,i=1;let r="",a=n.filter(Boolean)[0];r+=`M ${a[s]},${a[i]}`;for(const h of n)e=h,o=m(a[s],a[i],e[s],e[i]),r+=` ${o[s]},${o[i]}`,r+=` Q${e[s]},${e[i]}`,a=e;return r+=` ${e[s]},${e[i]}`,r},S=f.createStyled("svg",process.env.NODE_ENV==="production"?{target:"esztfdy0"}:{target:"esztfdy0",label:"SVGWrapper"})(process.env.NODE_ENV==="production"?{name:"lth4tv",styles:"display:flex;width:100%;.fill{opacity:0.1;}"}:{name:"lth4tv",styles:"display:flex;width:100%;.fill{opacity:0.1;}",toString:g});function _({coordinates:n,strokeWidth:e=5,cssStyles:o,className:s,...i}){const[r,a]=c.useState(void 0);c.useEffect(()=>{if(n){const u=v(n);a(u)}},[n]);const l=c.useRef(`svg-${Math.random().toString(36).substr(2,9)}`).current;return t.jsx(S,{className:`${s??""} svg-graph`,width:"100%",height:"100%",viewBox:`0 0 ${d.SVG_WIDTH} ${d.SVG_HEIGHT}`,css:p.css(o??"",";"+(process.env.NODE_ENV==="production"?"":";label:SvgGraph;")),...i,children:t.jsx("g",{children:r&&n?t.jsxs(t.Fragment,{children:[t.jsx("mask",{id:`${l}-fill`,children:t.jsx("path",{className:"fill",fill:"white",d:`${r} L 500, 100 L 0, 100 z`})}),t.jsx("rect",{height:"100%",width:"100%",fill:"var(--ha-A400)",mask:`url(#${l}-fill)`}),t.jsx("mask",{id:`${l}-line`,children:t.jsx("path",{fill:"none",stroke:"var(--ha-A100)",strokeWidth:e,strokeLinecap:"round",strokeLinejoin:"round",d:r})}),t.jsx("rect",{height:"100%",width:"100%",fill:"var(--ha-A400)",mask:`url(#${l}-line)`})]}):t.jsx(t.Fragment,{})})})}exports.SvgGraph=_;
//# sourceMappingURL=index.js.map