UNPKG

@progress/kendo-react-inputs

Version:

React Inputs offer a customizable interface for users to enter and pick different information. KendoReact Input package

64 lines (63 loc) 2.16 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ import * as h from "react"; import { svgPath as p, bezierCommand as f, controlPoint as A, line as b } from "./utils/svg-calc.mjs"; import { getContrastFromTwoRGBAs as S, getRGBA as m, getColorFromHSV as T } from "./utils/color-parser.mjs"; const C = 4.5, g = 7, v = 16; class w extends h.Component { renderSvgCurveLine() { const t = this.props.metrics, d = (o, i, r, e, s) => { const a = (r + e) / 2, l = Object.assign({}, this.props.hsva, { s: i / t.width, v: 1 - a / t.height }), n = S( m(T(l)), m(this.props.backgroundColor || "") ); return r + 0.5 > e ? n < o + 1 && n > o - 1 ? a : null : s(n, o) ? d(o, i, r, e - (e - r) / 2, s) : d(o, i, r + (e - r) / 2, e, s); }, u = (o, i, r = !1) => { const e = []; for (let s = 0; s <= t.width; s += t.width / i) { const a = d( o, s, 0, t.height, r ? (l, n) => l < n : (l, n) => l > n ); a !== null && e.push([s, a]); } return e; }, c = f(A(b)); return p(u(C, v), c) + p(u(C, v, !0), c) + p(u(g, v), c) + p(u(g, v, !0), c); } shouldComponentUpdate(t) { return !(t.hsva.h === this.props.hsva.h && t.hsva.a === this.props.hsva.a && this.props.backgroundColor === t.backgroundColor); } render() { return /* @__PURE__ */ 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 } } ); } } export { w as ColorContrastSvg };