@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) • 2.13 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 a=require("@progress/kendo-drawing"),r=require("./misc.js"),m=(t,o,n=!0)=>{if(["hex","rgba"].indexOf(o)===-1)throw new Error(`Unsupported color output format '${o}'. The available options are 'hex' or 'rgba'.`);if(!r.isPresent(t))return;const s=a.parseColor(t.trim(),n);if(r.isPresent(s))return o==="hex"?s.toCss():s.toCssRgba()},p=(t,o=!0)=>{const n=a.parseColor(t,o);return r.isPresent(n)?n.toHSV():{}},C=(t,o=!0)=>{const n=a.parseColor(t,o);return r.isPresent(n)?n.toBytes():{}},B=t=>{const o=r.fitIntoBounds(t.h,0,359.9),n=r.fitIntoBounds(t.s,0,1),e=r.fitIntoBounds(t.v,0,1),s=r.fitIntoBounds(t.a,0,1);return a.Color.fromHSV(o,n,e,s).toCssRgba()},I=t=>B({h:t,s:1,v:1,a:1}),h=t=>{const o=r.fitIntoBounds(t.r,0,255),n=r.fitIntoBounds(t.g,0,255),e=r.fitIntoBounds(t.b,0,255),s=r.fitIntoBounds(t.a,0,1);return a.Color.fromBytes(o,n,e,s).toCssRgba()},i=(t,o)=>{const n=r.fitIntoBounds(t.r,0,255),e=r.fitIntoBounds(t.g,0,255),s=r.fitIntoBounds(t.b,0,255),u=r.fitIntoBounds(t.a,0,1),d=r.fitIntoBounds(o.r,0,255),f=r.fitIntoBounds(o.g,0,255),l=r.fitIntoBounds(o.b,0,255);return{r:Math.round((1-u)*d+u*n),g:Math.round((1-u)*f+u*e),b:Math.round((1-u)*l+u*s)}},c=t=>{const o=[t.r||0,t.g||0,t.b||0].map(function(n){return n/=255,n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)});return o[0]*.2126+o[1]*.7152+o[2]*.0722},g=(t,o)=>{const n=Math.max(t,o),e=Math.min(t,o);return(n+.05)/(e+.05)},R=(t,o)=>g(c(i(t,o)),c(i(o,{r:0,g:0,b:0,a:1})));exports.getColorFromHSV=B;exports.getColorFromHue=I;exports.getColorFromRGBA=h;exports.getContrast=g;exports.getContrastFromTwoRGBAs=R;exports.getHSV=p;exports.getLuminance=c;exports.getRGBA=C;exports.getRGBFromRGBA=i;exports.parseColor=m;