@progress/kendo-react-inputs
Version:
React Inputs offer a customizable interface for users to enter and pick different information. KendoReact Input package
9 lines (8 loc) • 1.92 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
;Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react"),i=require("./utils/svg-calc.js"),p=require("./utils/color-parser.js");function S(l){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const r in l)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(l,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>l[r]})}}return e.default=l,Object.freeze(e)}const h=S(b),C=4.5,m=7,f=16;class A extends h.Component{renderSvgCurveLine(){const e=this.props.metrics,r=(a,u,n,t,s)=>{const g=(n+t)/2,v=Object.assign({},this.props.hsva,{s:u/e.width,v:1-g/e.height}),c=p.getContrastFromTwoRGBAs(p.getRGBA(p.getColorFromHSV(v)),p.getRGBA(this.props.backgroundColor||""));return n+.5>t?c<a+1&&c>a-1?g:null:s(c,a)?r(a,u,n,t-(t-n)/2,s):r(a,u,n+(t-n)/2,t,s)},o=(a,u,n=!1)=>{const t=[];for(let s=0;s<=e.width;s+=e.width/u){const g=r(a,s,0,e.height,n?(v,c)=>v<c:(v,c)=>v>c);g!==null&&t.push([s,g])}return t},d=i.bezierCommand(i.controlPoint(i.line));return i.svgPath(o(C,f),d)+i.svgPath(o(C,f,!0),d)+i.svgPath(o(m,f),d)+i.svgPath(o(m,f,!0),d)}shouldComponentUpdate(e){return!(e.hsva.h===this.props.hsva.h&&e.hsva.a===this.props.hsva.a&&this.props.backgroundColor===e.backgroundColor)}render(){return h.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",className:"k-color-contrast-svg",dangerouslySetInnerHTML:{__html:this.renderSvgCurveLine()},style:{position:"absolute",overflow:"visible",pointerEvents:"none",left:0,top:0,zIndex:3}})}}exports.ColorContrastSvg=A;