Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@chayns/colors

Package Overview
Dependencies
Maintainers
4
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@chayns/colors - npm Package Compare versions

Comparing version 1.0.4 to 2.0.0

cjs/converter/converter.test.js.map

18

cjs/converter/hex/hexToRgb255.js

@@ -12,2 +12,8 @@ "use strict";

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function hexToRgb255(hex) {

@@ -19,2 +25,7 @@ if (!(0, _is.isHex)(hex)) {

var components = hex.match(_constants.HEX_REGEX);
if (!(components !== null && components !== void 0 && components[1])) {
return null;
}
var retObj = {

@@ -28,6 +39,9 @@ r: parseInt(components[1].substring(0, 2), 16),

if ((0, _is.isNumber)(a)) {
retObj.a = a;
return _objectSpread(_objectSpread({}, retObj), {}, {
a: a
});
}
return retObj;
}
}
//# sourceMappingURL=hexToRgb255.js.map

3

cjs/converter/hex/normalizeHexString.js

@@ -34,2 +34,3 @@ "use strict";

return null;
}
}
//# sourceMappingURL=normalizeHexString.js.map

@@ -8,8 +8,4 @@ "use strict";

var _checkTransparency = _interopRequireDefault(require("../../utils/checkTransparency"));
var _is = require("../../utils/is");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function componentToHex(c) {

@@ -28,4 +24,13 @@ var hex = Math.round(c).toString(16);

var b = Math.round(rgb.b);
var a = Math.round(rgb.a * 255);
return (0, _checkTransparency["default"])("#".concat(componentToHex(r)).concat(componentToHex(g)).concat(componentToHex(b)).concat(componentToHex(a)), (0, _is.isNumber)(rgb.a));
}
if ('a' in rgb) {
var a = Math.round(rgb.a * 255);
if ((0, _is.isNumber)(rgb.a)) {
return "#".concat(componentToHex(r)).concat(componentToHex(g)).concat(componentToHex(b)).concat(componentToHex(a));
}
}
return "#".concat(componentToHex(r)).concat(componentToHex(g)).concat(componentToHex(b));
}
//# sourceMappingURL=rgb255ToHex.js.map

@@ -8,8 +8,4 @@ "use strict";

var _checkTransparency = _interopRequireDefault(require("../../utils/checkTransparency"));
var _is = require("../../utils/is");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function hslToRgb1(hsl) {

@@ -22,4 +18,3 @@ if (!(0, _is.isHsl)(hsl)) {

s = hsl.s,
l = hsl.l,
a = hsl.a;
l = hsl.l;
var r;

@@ -77,8 +72,17 @@ var g;

return (0, _checkTransparency["default"])({
if ('a' in hsl && (0, _is.isNumber)(hsl.a)) {
return {
r: r,
g: g,
b: b,
a: hsl.a
};
}
return {
r: r,
g: g,
b: b,
a: a
});
}
b: b
};
}
//# sourceMappingURL=hslToRgb1.js.map

@@ -8,8 +8,4 @@ "use strict";

var _checkTransparency = _interopRequireDefault(require("../../utils/checkTransparency"));
var _is = require("../../utils/is");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function rgb1ToHsl(rgb) {

@@ -22,7 +18,6 @@ if (!(0, _is.isRgb1)(rgb)) {

g = rgb.g,
b = rgb.b,
a = rgb.a;
b = rgb.b;
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h;
var h = 0;

@@ -52,8 +47,18 @@ if (max === min) {

var l = (max + min) / 2;
return (0, _checkTransparency["default"])({
if ('a' in rgb && (0, _is.isNumber)(rgb.a)) {
return {
h: h,
s: s,
l: l,
a: rgb.a
};
}
return {
h: h,
s: s,
l: l,
a: a
});
}
l: l
};
}
//# sourceMappingURL=rgb1ToHsl.js.map

@@ -8,8 +8,4 @@ "use strict";

var _checkTransparency = _interopRequireDefault(require("../../utils/checkTransparency"));
var _is = require("../../utils/is");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function hsvToRgb1(hsv) {

@@ -77,8 +73,17 @@ if (!(0, _is.isHsv)(hsv)) {

return (0, _checkTransparency["default"])({
if ('a' in hsv && (0, _is.isNumber)(hsv.a)) {
return {
r: r,
g: g,
b: b,
a: hsv.a
};
}
return {
r: r,
g: g,
b: b,
a: hsv.a
});
}
b: b
};
}
//# sourceMappingURL=hsvToRgb1.js.map

@@ -10,6 +10,2 @@ "use strict";

var _checkTransparency = _interopRequireDefault(require("../../utils/checkTransparency"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function rgb1ToHsv(rgb) {

@@ -25,3 +21,3 @@ if (!(0, _is.isRgb1)(rgb)) {

var min = Math.min(r, g, b);
var h;
var h = 0;

@@ -51,8 +47,18 @@ if (max === min) {

var v = max;
return (0, _checkTransparency["default"])({
if ('a' in rgb && (0, _is.isNumber)(rgb.a)) {
return {
h: h,
s: s,
v: v,
a: rgb.a
};
}
return {
h: h,
s: s,
v: v,
a: rgb.a
});
}
v: v
};
}
//# sourceMappingURL=rgb1ToHsv.js.map

@@ -118,47 +118,120 @@ "use strict";

function rgb255ToHsv(rgb) {
return (0, _rgb1ToHsv["default"])((0, _rgb255ToRgb["default"])(rgb));
var rgb1 = (0, _rgb255ToRgb["default"])(rgb);
if (!rgb1) {
return null;
}
return (0, _rgb1ToHsv["default"])(rgb1);
}
function rgb255ToHsl(rgb) {
return (0, _rgb1ToHsl["default"])((0, _rgb255ToRgb["default"])(rgb));
var rgb1 = (0, _rgb255ToRgb["default"])(rgb);
if (!rgb1) {
return null;
}
return (0, _rgb1ToHsl["default"])(rgb1);
}
function hexToHsv(hex) {
return rgb255ToHsv((0, _hexToRgb["default"])(hex));
var rgb255 = (0, _hexToRgb["default"])(hex);
if (!rgb255) {
return null;
}
return rgb255ToHsv(rgb255);
}
function hexToHsl(hex) {
return rgb255ToHsl((0, _hexToRgb["default"])(hex));
var rgb255 = (0, _hexToRgb["default"])(hex);
if (!rgb255) {
return null;
}
return rgb255ToHsl(rgb255);
}
function hexToRgb1(hex) {
return (0, _rgb255ToRgb["default"])((0, _hexToRgb["default"])(hex));
var rgb255 = (0, _hexToRgb["default"])(hex);
if (!rgb255) {
return null;
}
return (0, _rgb255ToRgb["default"])(rgb255);
}
function rgb1ToHex(rgb1) {
return (0, _rgb255ToHex["default"])((0, _rgb1ToRgb["default"])(rgb1));
var rgb255 = (0, _rgb1ToRgb["default"])(rgb1);
if (!rgb255) {
return null;
}
return (0, _rgb255ToHex["default"])(rgb255);
}
function hslToRgb255(hsl) {
return (0, _rgb1ToRgb["default"])((0, _hslToRgb["default"])(hsl));
var rgb1 = (0, _hslToRgb["default"])(hsl);
if (!rgb1) {
return null;
}
return (0, _rgb1ToRgb["default"])(rgb1);
}
function hslToHex(hsl) {
return (0, _rgb255ToHex["default"])(hslToRgb255(hsl));
var rgb255 = hslToRgb255(hsl);
if (!rgb255) {
return null;
}
return (0, _rgb255ToHex["default"])(rgb255);
}
function hsvToRgb255(hsv) {
return (0, _rgb1ToRgb["default"])((0, _hsvToRgb["default"])(hsv));
var rgb255 = (0, _hsvToRgb["default"])(hsv);
if (!rgb255) {
return null;
}
return (0, _rgb1ToRgb["default"])(rgb255);
}
function hsvToHex(hsv) {
return (0, _rgb255ToHex["default"])(hsvToRgb255(hsv));
var rgb255 = hsvToRgb255(hsv);
if (!rgb255) {
return null;
}
return (0, _rgb255ToHex["default"])(rgb255);
}
function hsvToHsl(hsv) {
return rgb255ToHsl(hsvToRgb255(hsv));
var rgb255 = hsvToRgb255(hsv);
if (!rgb255) {
return null;
}
return rgb255ToHsl(rgb255);
}
function hslToHsv(hsl) {
return rgb255ToHsv(hslToRgb255(hsl));
}
var rgb25 = hslToRgb255(hsl);
if (!rgb25) {
return null;
}
return rgb255ToHsv(rgb25);
}
//# sourceMappingURL=index.js.map

@@ -15,5 +15,10 @@ "use strict";

return "rgb".concat((0, _is.isNumber)(rgb.a) ? 'a' : '', "(").concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b).concat((0, _is.isNumber)(rgb.a) ? ", ".concat(rgb.a.toLocaleString('en-US', {
maximumFractionDigits: 2
})) : '', ")");
}
if ('a' in rgb && (0, _is.isNumber)(rgb.a)) {
return "rgba(".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a.toLocaleString('en-US', {
maximumFractionDigits: 2
}), ")");
}
return "rgb(".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ")");
}
//# sourceMappingURL=getRgb255String.js.map

@@ -23,3 +23,3 @@ "use strict";

if (matches) {
if (matches && matches[1] && matches[2] && matches[3]) {
return (0, _getRgb255String["default"])({

@@ -29,3 +29,3 @@ r: parseInt(matches[1], 10),

b: parseInt(matches[3], 10),
a: parseInt(matches[4], 10)
a: matches[4] ? parseInt(matches[4], 10) : undefined
});

@@ -35,2 +35,3 @@ }

return null;
}
}
//# sourceMappingURL=normalizeRgbString.js.map

@@ -8,8 +8,4 @@ "use strict";

var _checkTransparency = _interopRequireDefault(require("../../utils/checkTransparency"));
var _is = require("../../utils/is");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function rgb1ToRgb255(rgb) {

@@ -20,8 +16,14 @@ if (!(0, _is.isRgb1)(rgb)) {

return (0, _checkTransparency["default"])({
var retVal = {
r: Math.round(rgb.r * 255),
g: Math.round(rgb.g * 255),
b: Math.round(rgb.b * 255),
a: rgb.a
});
}
b: Math.round(rgb.b * 255)
};
if ('a' in rgb && (0, _is.isNumber)(rgb.a)) {
retVal.a = rgb.a;
}
return retVal;
}
//# sourceMappingURL=rgb1ToRgb255.js.map

@@ -8,8 +8,4 @@ "use strict";

var _checkTransparency = _interopRequireDefault(require("../../utils/checkTransparency"));
var _is = require("../../utils/is");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function rgb255ToRgb1(rgb) {

@@ -20,8 +16,14 @@ if (!(0, _is.isRgb255)(rgb)) {

return (0, _checkTransparency["default"])({
var retVal = {
r: rgb.r / 255,
g: rgb.g / 255,
b: rgb.b / 255,
a: rgb.a
});
}
b: rgb.b / 255
};
if ('a' in rgb && (0, _is.isNumber)(rgb.a)) {
retVal.a = rgb.a;
}
return retVal;
}
//# sourceMappingURL=rgb255ToRgb1.js.map

@@ -11,3 +11,3 @@ "use strict";

var _index = require("../converter/index");
var _converter = require("../converter");

@@ -22,4 +22,10 @@ var _constants = require("./constants");

function getColorBrightness(color, newCalculation) {
function getColorBrightness(color) {
var newCalculation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var rgb = (0, _hexToRgb["default"])(color);
if (!rgb) {
return null;
}
var brightnessRgb = Math.max(rgb.r, rgb.g, rgb.b);

@@ -56,4 +62,4 @@ var brightness;

secondaryColor = _ref$secondaryColor === void 0 ? null : _ref$secondaryColor;
var colorData = JSON.parse(JSON.stringify(_constants.colorPalette[colorMode][colorId])); // copy array
// copy array
var colorData = JSON.parse(JSON.stringify(_constants.colorPalette[colorMode][colorId]));
var secondary;

@@ -94,7 +100,9 @@

if (base400Index >= 0) {
var brightness = getColorBrightness(color);
var _hexToHsl$s, _hexToHsl;
var brightness = getColorBrightness(color) || 0;
if (brightness < 50 && colorMode === 1) {
colorData[base400Index] = (0, _lightenDarken.lightenHexColor)(color, (brightness * -1 + 100) * 0.5);
} else if (brightness === 100 && (0, _index.hexToHsl)(color).s < 0.15) {
} else if (brightness === 100 && ((_hexToHsl$s = (_hexToHsl = (0, _converter.hexToHsl)(color)) === null || _hexToHsl === void 0 ? void 0 : _hexToHsl.s) !== null && _hexToHsl$s !== void 0 ? _hexToHsl$s : 0) < 0.15) {
colorData[base400Index] = '#a8a8a8';

@@ -109,3 +117,3 @@ } else {

if (accent400Index >= 0) {
var _brightness = getColorBrightness(color);
var _brightness = getColorBrightness(color) || 0;

@@ -122,7 +130,9 @@ if (_brightness < 50) {

if (secondaryBase400Index >= 0) {
var _brightness2 = getColorBrightness(secondary);
var _hexToHsl$s2, _hexToHsl2;
var _brightness2 = getColorBrightness(secondary) || 0;
if (_brightness2 < 50 && colorMode === 1) {
colorData[secondaryBase400Index] = (0, _lightenDarken.lightenHexColor)(secondary, (_brightness2 * -1 + 100) * 0.5);
} else if (_brightness2 === 100 && (0, _index.hexToHsl)(secondary).s < 15) {
} else if (_brightness2 === 100 && ((_hexToHsl$s2 = (_hexToHsl2 = (0, _converter.hexToHsl)(secondary)) === null || _hexToHsl2 === void 0 ? void 0 : _hexToHsl2.s) !== null && _hexToHsl$s2 !== void 0 ? _hexToHsl$s2 : 0) < 15) {
colorData[secondaryBase400Index] = '#a8a8a8';

@@ -137,3 +147,3 @@ } else {

if (secondaryAccent400Index >= 0) {
var _brightness3 = getColorBrightness(secondary);
var _brightness3 = getColorBrightness(secondary) || 0;

@@ -158,2 +168,3 @@ if (_brightness3 < 50) {

return colorData;
}
}
//# sourceMappingURL=chaynsColors.js.map

@@ -390,2 +390,3 @@ "use strict";

};
exports.colorPalette = colorPalette;
exports.colorPalette = colorPalette;
//# sourceMappingURL=constants.js.map

@@ -95,2 +95,3 @@ "use strict";

var _mix = require("./mix");
var _mix = require("./mix");
//# sourceMappingURL=index.js.map

@@ -15,6 +15,13 @@ "use strict";

var _index = require("../converter/index");
var _converter = require("../converter");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function lightenHslColor(hsl, percent) {
var color = hsl;
var color = _objectSpread({}, hsl);
color.l += percent / 100;

@@ -36,23 +43,60 @@

function lightenRgb255Color(color, percent) {
return (0, _index.hslToRgb255)(lightenHslColor((0, _index.rgb255ToHsl)(color), percent));
var hsl = (0, _converter.rgb255ToHsl)(color);
if (!hsl) {
return null;
}
return (0, _converter.hslToRgb255)(lightenHslColor(hsl, percent));
}
function darkenRgb255Color(color, percent) {
return (0, _index.hslToRgb255)(darkenHslColor((0, _index.rgb255ToHsl)(color), percent));
var hsl = (0, _converter.rgb255ToHsl)(color);
if (!hsl) {
return null;
}
return (0, _converter.hslToRgb255)(darkenHslColor(hsl, percent));
}
function lightenHexColor(color, percent) {
return (0, _index.hslToHex)(lightenHslColor((0, _index.hexToHsl)(color), percent));
var hsl = (0, _converter.hexToHsl)(color);
if (!hsl) {
return null;
}
return (0, _converter.hslToHex)(lightenHslColor(hsl, percent));
}
function darkenHexColor(color, percent) {
return (0, _index.hslToHex)(darkenHslColor((0, _index.hexToHsl)(color), percent));
var hsl = (0, _converter.hexToHsl)(color);
if (!hsl) {
return null;
}
return (0, _converter.hslToHex)(darkenHslColor(hsl, percent));
}
function lightenHsvColor(color, percent) {
return (0, _index.hslToHsv)(lightenHslColor((0, _index.hsvToHsl)(color), percent));
var hsl = (0, _converter.hsvToHsl)(color);
if (!hsl) {
return null;
}
return (0, _converter.hslToHsv)(lightenHslColor(hsl, percent));
}
function darkenHsvColor(color, percent) {
return (0, _index.hslToHsv)(darkenHslColor((0, _index.hsvToHsl)(color), percent));
}
var hsl = (0, _converter.hsvToHsl)(color);
if (!hsl) {
return null;
}
return (0, _converter.hslToHsv)(darkenHslColor(hsl, percent));
}
//# sourceMappingURL=lightenDarken.js.map

@@ -11,3 +11,3 @@ "use strict";

var _index = require("../converter/index");
var _converter = require("../converter");

@@ -25,9 +25,9 @@ var _roundValues = _interopRequireDefault(require("../utils/roundValues"));

var b = weight * color1.b + weightColor2 * color2.b;
var a = null;
var a;
if (color1.a || color2.a) {
a = weight * color1.a + weightColor2 * color2.a;
if ('a' in color1 || 'a' in color2) {
a = weight * ('a' in color1 ? color1.a : 0) + weightColor2 * ('a' in color2 ? color2.a : 0);
}
return (0, _roundValues["default"])((0, _index.checkTransparency)({
var color = (0, _converter.checkTransparency)({
r: r,

@@ -37,15 +37,38 @@ g: g,

a: a
}));
});
return (0, _roundValues["default"])(color);
}
function mixHex(color1, color2, weight) {
return (0, _index.rgb255ToHex)(mixRgb((0, _index.hexToRgb255)(color1), (0, _index.hexToRgb255)(color2), weight));
var color1Rgb255 = (0, _converter.hexToRgb255)(color1);
var color2Rgb255 = (0, _converter.hexToRgb255)(color2);
if (!color1Rgb255 || !color2Rgb255) {
return null;
}
return (0, _converter.rgb255ToHex)(mixRgb(color1Rgb255, color2Rgb255, weight));
}
function mixHsv(color1, color2, weight) {
return (0, _index.rgb1ToHsv)(mixRgb((0, _index.hsvToRgb1)(color1), (0, _index.hsvToRgb1)(color2), weight));
var color1Rgb255 = (0, _converter.hsvToRgb1)(color1);
var color2Rgb255 = (0, _converter.hsvToRgb1)(color2);
if (!color1Rgb255 || !color2Rgb255) {
return null;
}
return (0, _converter.rgb1ToHsv)(mixRgb(color1Rgb255, color2Rgb255, weight));
}
function mixHsl(color1, color2, weight) {
return (0, _index.rgb1ToHsl)(mixRgb((0, _index.hslToRgb1)(color1), (0, _index.hslToRgb1)(color2), weight));
}
var color1Rgb255 = (0, _converter.hslToRgb1)(color1);
var color2Rgb255 = (0, _converter.hslToRgb1)(color2);
if (!color1Rgb255 || !color2Rgb255) {
return null;
}
return (0, _converter.rgb1ToHsl)(mixRgb(color1Rgb255, color2Rgb255, weight));
}
//# sourceMappingURL=mix.js.map

@@ -44,12 +44,12 @@ "use strict";

var _index = require("./converter/index");
var _converter = require("./converter");
Object.keys(_index).forEach(function (key) {
Object.keys(_converter).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _index[key]) return;
if (key in exports && exports[key] === _converter[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _index[key];
return _converter[key];
}

@@ -59,12 +59,12 @@ });

var _index2 = require("./generator/index");
var _generator = require("./generator");
Object.keys(_index2).forEach(function (key) {
Object.keys(_generator).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _index2[key]) return;
if (key in exports && exports[key] === _generator[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _index2[key];
return _generator[key];
}

@@ -74,2 +74,3 @@ });

var _is = require("./utils/is");
var _is = require("./utils/is");
//# sourceMappingURL=index.js.map

@@ -22,2 +22,7 @@ "use strict";

/**
* Removes the transparency part of the color
* @param color
* @param hexTransparency
*/
function checkTransparency(color) {

@@ -39,3 +44,3 @@ var hexTransparency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

if (!(0, _is.isNumber)(color.a)) {
if ('a' in color) {
var a = color.a,

@@ -48,2 +53,3 @@ colorWithoutTransparency = _objectWithoutProperties(color, _excluded);

return color;
}
}
//# sourceMappingURL=checkTransparency.js.map

@@ -12,2 +12,3 @@ "use strict";

var RGB_REGEX = /^(?:rgb|rgba)\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})(?:\s*,\s*(1|0|(?:0?\.[0-9]+)))?\s*\)$/i;
exports.RGB_REGEX = RGB_REGEX;
exports.RGB_REGEX = RGB_REGEX;
//# sourceMappingURL=constants.js.map

@@ -64,2 +64,3 @@ "use strict";

return isObject(value) && isInInterval(value.h, 0, 360) && isInInterval(value.s, 0, 1) && isInInterval(value.v, 0, 1) && (isNullOrUndefined(value.a) || isInInterval(value.a, 0, 1));
}
}
//# sourceMappingURL=is.js.map

@@ -12,8 +12,3 @@ "use strict";

function getRandomRgb255Color() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$transparency = _ref.transparency,
transparency = _ref$transparency === void 0 ? false : _ref$transparency,
_ref$rgb = _ref.rgb1,
rgb1 = _ref$rgb === void 0 ? false : _ref$rgb;
var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
var rgb = {

@@ -33,4 +28,4 @@ r: null,

if (!rgb1 && component !== 'a') {
rgb[component] = Math.round(rgb[component] * 255);
if (component !== 'a') {
rgb[component] = Math.round((rgb[component] || 0) * 255);
}

@@ -44,5 +39,4 @@ }

var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
return (0, _converter.rgb255ToHex)(getRandomRgb255Color({
transparency: transparency
}));
}
return (0, _converter.rgb255ToHex)(getRandomRgb255Color(transparency));
}
//# sourceMappingURL=randomColor.js.map

@@ -10,5 +10,6 @@ "use strict";

var retObj = {};
var keys = Object.keys(obj);
for (var i = 0; i < Object.keys(obj).length; i += 1) {
var key = Object.keys(obj)[i];
for (var i = 0, z = keys.length; i < z; i += 1) {
var key = keys[i];
retObj[key] = Math.round(obj[key]);

@@ -18,2 +19,3 @@ }

return retObj;
}
}
//# sourceMappingURL=roundValues.js.map

@@ -0,1 +1,7 @@

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { HEX_REGEX } from '../../utils/constants';

@@ -9,2 +15,7 @@ import { isHex, isNumber } from '../../utils/is';

var components = hex.match(HEX_REGEX);
if (!(components !== null && components !== void 0 && components[1])) {
return null;
}
var retObj = {

@@ -18,6 +29,9 @@ r: parseInt(components[1].substring(0, 2), 16),

if (isNumber(a)) {
retObj.a = a;
return _objectSpread(_objectSpread({}, retObj), {}, {
a: a
});
}
return retObj;
}
}
//# sourceMappingURL=hexToRgb255.js.map

@@ -25,2 +25,3 @@ import { HEX_REGEX, SHORT_HEX_REGEX } from '../../utils/constants';

return null;
}
}
//# sourceMappingURL=normalizeHexString.js.map

@@ -1,2 +0,1 @@

import checkTransparency from '../../utils/checkTransparency';
import { isNumber, isRgb255 } from '../../utils/is';

@@ -17,4 +16,13 @@

var b = Math.round(rgb.b);
var a = Math.round(rgb.a * 255);
return checkTransparency("#".concat(componentToHex(r)).concat(componentToHex(g)).concat(componentToHex(b)).concat(componentToHex(a)), isNumber(rgb.a));
}
if ('a' in rgb) {
var a = Math.round(rgb.a * 255);
if (isNumber(rgb.a)) {
return "#".concat(componentToHex(r)).concat(componentToHex(g)).concat(componentToHex(b)).concat(componentToHex(a));
}
}
return "#".concat(componentToHex(r)).concat(componentToHex(g)).concat(componentToHex(b));
}
//# sourceMappingURL=rgb255ToHex.js.map

@@ -1,3 +0,2 @@

import checkTransparency from '../../utils/checkTransparency';
import { isHsl } from '../../utils/is';
import { isHsl, isNumber } from '../../utils/is';
export default function hslToRgb1(hsl) {

@@ -10,4 +9,3 @@ if (!isHsl(hsl)) {

s = hsl.s,
l = hsl.l,
a = hsl.a;
l = hsl.l;
var r;

@@ -65,8 +63,17 @@ var g;

return checkTransparency({
if ('a' in hsl && isNumber(hsl.a)) {
return {
r: r,
g: g,
b: b,
a: hsl.a
};
}
return {
r: r,
g: g,
b: b,
a: a
});
}
b: b
};
}
//# sourceMappingURL=hslToRgb1.js.map

@@ -1,3 +0,2 @@

import checkTransparency from '../../utils/checkTransparency';
import { isRgb1 } from '../../utils/is';
import { isNumber, isRgb1 } from '../../utils/is';
export default function rgb1ToHsl(rgb) {

@@ -10,7 +9,6 @@ if (!isRgb1(rgb)) {

g = rgb.g,
b = rgb.b,
a = rgb.a;
b = rgb.b;
var max = Math.max(r, g, b);
var min = Math.min(r, g, b);
var h;
var h = 0;

@@ -40,8 +38,18 @@ if (max === min) {

var l = (max + min) / 2;
return checkTransparency({
if ('a' in rgb && isNumber(rgb.a)) {
return {
h: h,
s: s,
l: l,
a: rgb.a
};
}
return {
h: h,
s: s,
l: l,
a: a
});
}
l: l
};
}
//# sourceMappingURL=rgb1ToHsl.js.map

@@ -1,3 +0,2 @@

import checkTransparency from '../../utils/checkTransparency';
import { isHsv } from '../../utils/is';
import { isHsv, isNumber } from '../../utils/is';
export default function hsvToRgb1(hsv) {

@@ -65,8 +64,17 @@ if (!isHsv(hsv)) {

return checkTransparency({
if ('a' in hsv && isNumber(hsv.a)) {
return {
r: r,
g: g,
b: b,
a: hsv.a
};
}
return {
r: r,
g: g,
b: b,
a: hsv.a
});
}
b: b
};
}
//# sourceMappingURL=hsvToRgb1.js.map

@@ -1,3 +0,2 @@

import { isRgb1 } from '../../utils/is';
import checkTransparency from '../../utils/checkTransparency';
import { isNumber, isRgb1 } from '../../utils/is';
export default function rgb1ToHsv(rgb) {

@@ -13,3 +12,3 @@ if (!isRgb1(rgb)) {

var min = Math.min(r, g, b);
var h;
var h = 0;

@@ -39,8 +38,18 @@ if (max === min) {

var v = max;
return checkTransparency({
if ('a' in rgb && isNumber(rgb.a)) {
return {
h: h,
s: s,
v: v,
a: rgb.a
};
}
return {
h: h,
s: s,
v: v,
a: rgb.a
});
}
v: v
};
}
//# sourceMappingURL=rgb1ToHsv.js.map

@@ -15,49 +15,122 @@ import hexToRgb255 from './hex/hexToRgb255';

function rgb255ToHsv(rgb) {
return rgb1ToHsv(rgb255ToRgb1(rgb));
var rgb1 = rgb255ToRgb1(rgb);
if (!rgb1) {
return null;
}
return rgb1ToHsv(rgb1);
}
function rgb255ToHsl(rgb) {
return rgb1ToHsl(rgb255ToRgb1(rgb));
var rgb1 = rgb255ToRgb1(rgb);
if (!rgb1) {
return null;
}
return rgb1ToHsl(rgb1);
}
function hexToHsv(hex) {
return rgb255ToHsv(hexToRgb255(hex));
var rgb255 = hexToRgb255(hex);
if (!rgb255) {
return null;
}
return rgb255ToHsv(rgb255);
}
function hexToHsl(hex) {
return rgb255ToHsl(hexToRgb255(hex));
var rgb255 = hexToRgb255(hex);
if (!rgb255) {
return null;
}
return rgb255ToHsl(rgb255);
}
function hexToRgb1(hex) {
return rgb255ToRgb1(hexToRgb255(hex));
var rgb255 = hexToRgb255(hex);
if (!rgb255) {
return null;
}
return rgb255ToRgb1(rgb255);
}
function rgb1ToHex(rgb1) {
return rgb255ToHex(rgb1ToRgb255(rgb1));
var rgb255 = rgb1ToRgb255(rgb1);
if (!rgb255) {
return null;
}
return rgb255ToHex(rgb255);
}
function hslToRgb255(hsl) {
return rgb1ToRgb255(hslToRgb1(hsl));
var rgb1 = hslToRgb1(hsl);
if (!rgb1) {
return null;
}
return rgb1ToRgb255(rgb1);
}
function hslToHex(hsl) {
return rgb255ToHex(hslToRgb255(hsl));
var rgb255 = hslToRgb255(hsl);
if (!rgb255) {
return null;
}
return rgb255ToHex(rgb255);
}
function hsvToRgb255(hsv) {
return rgb1ToRgb255(hsvToRgb1(hsv));
var rgb255 = hsvToRgb1(hsv);
if (!rgb255) {
return null;
}
return rgb1ToRgb255(rgb255);
}
function hsvToHex(hsv) {
return rgb255ToHex(hsvToRgb255(hsv));
var rgb255 = hsvToRgb255(hsv);
if (!rgb255) {
return null;
}
return rgb255ToHex(rgb255);
}
function hsvToHsl(hsv) {
return rgb255ToHsl(hsvToRgb255(hsv));
var rgb255 = hsvToRgb255(hsv);
if (!rgb255) {
return null;
}
return rgb255ToHsl(rgb255);
}
function hslToHsv(hsl) {
return rgb255ToHsv(hslToRgb255(hsl));
var rgb25 = hslToRgb255(hsl);
if (!rgb25) {
return null;
}
return rgb255ToHsv(rgb25);
}
export { hexToRgb255, normalizeHexString, rgb255ToHex, hslToRgb1, rgb1ToHsl, hsvToRgb1, rgb1ToHsv, getRgb255String, normalizeRgbString, rgb1ToRgb255, rgb255ToRgb1, checkTransparency, rgb255ToHsv, rgb255ToHsl, hexToHsv, hslToRgb255, hslToHex, hsvToRgb255, hsvToHex, hexToHsl, hexToRgb1, rgb1ToHex, hsvToHsl, hslToHsv };
export { hexToRgb255, normalizeHexString, rgb255ToHex, hslToRgb1, rgb1ToHsl, hsvToRgb1, rgb1ToHsv, getRgb255String, normalizeRgbString, rgb1ToRgb255, rgb255ToRgb1, checkTransparency, rgb255ToHsv, rgb255ToHsl, hexToHsv, hslToRgb255, hslToHex, hsvToRgb255, hsvToHex, hexToHsl, hexToRgb1, rgb1ToHex, hsvToHsl, hslToHsv };
//# sourceMappingURL=index.js.map

@@ -7,5 +7,10 @@ import { isNumber, isRgb255 } from '../../utils/is';

return "rgb".concat(isNumber(rgb.a) ? 'a' : '', "(").concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b).concat(isNumber(rgb.a) ? ", ".concat(rgb.a.toLocaleString('en-US', {
maximumFractionDigits: 2
})) : '', ")");
}
if ('a' in rgb && isNumber(rgb.a)) {
return "rgba(".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ", ").concat(rgb.a.toLocaleString('en-US', {
maximumFractionDigits: 2
}), ")");
}
return "rgb(".concat(rgb.r, ", ").concat(rgb.g, ", ").concat(rgb.b, ")");
}
//# sourceMappingURL=getRgb255String.js.map

@@ -11,3 +11,3 @@ import { RGB_REGEX } from '../../utils/constants';

if (matches) {
if (matches && matches[1] && matches[2] && matches[3]) {
return getRgb255String({

@@ -17,3 +17,3 @@ r: parseInt(matches[1], 10),

b: parseInt(matches[3], 10),
a: parseInt(matches[4], 10)
a: matches[4] ? parseInt(matches[4], 10) : undefined
});

@@ -23,2 +23,3 @@ }

return null;
}
}
//# sourceMappingURL=normalizeRgbString.js.map

@@ -1,3 +0,2 @@

import checkTransparency from '../../utils/checkTransparency';
import { isRgb1 } from '../../utils/is';
import { isNumber, isRgb1 } from '../../utils/is';
export default function rgb1ToRgb255(rgb) {

@@ -8,8 +7,14 @@ if (!isRgb1(rgb)) {

return checkTransparency({
var retVal = {
r: Math.round(rgb.r * 255),
g: Math.round(rgb.g * 255),
b: Math.round(rgb.b * 255),
a: rgb.a
});
}
b: Math.round(rgb.b * 255)
};
if ('a' in rgb && isNumber(rgb.a)) {
retVal.a = rgb.a;
}
return retVal;
}
//# sourceMappingURL=rgb1ToRgb255.js.map

@@ -1,3 +0,2 @@

import checkTransparency from '../../utils/checkTransparency';
import { isRgb255 } from '../../utils/is';
import { isNumber, isRgb255 } from '../../utils/is';
export default function rgb255ToRgb1(rgb) {

@@ -8,8 +7,14 @@ if (!isRgb255(rgb)) {

return checkTransparency({
var retVal = {
r: rgb.r / 255,
g: rgb.g / 255,
b: rgb.b / 255,
a: rgb.a
});
}
b: rgb.b / 255
};
if ('a' in rgb && isNumber(rgb.a)) {
retVal.a = rgb.a;
}
return retVal;
}
//# sourceMappingURL=rgb255ToRgb1.js.map
import { darkenHexColor, lightenHexColor } from './lightenDarken';
import { hexToHsl } from '../converter/index';
import { hexToHsl } from '../converter';
import { colorPalette, specials } from './constants';

@@ -7,4 +7,10 @@ import { mixHex } from './mix';

function getColorBrightness(color, newCalculation) {
function getColorBrightness(color) {
var newCalculation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
var rgb = hexToRgb255(color);
if (!rgb) {
return null;
}
var brightnessRgb = Math.max(rgb.r, rgb.g, rgb.b);

@@ -41,4 +47,4 @@ var brightness;

secondaryColor = _ref$secondaryColor === void 0 ? null : _ref$secondaryColor;
var colorData = JSON.parse(JSON.stringify(colorPalette[colorMode][colorId])); // copy array
// copy array
var colorData = JSON.parse(JSON.stringify(colorPalette[colorMode][colorId]));
var secondary;

@@ -79,7 +85,9 @@

if (base400Index >= 0) {
var brightness = getColorBrightness(color);
var _hexToHsl$s, _hexToHsl;
var brightness = getColorBrightness(color) || 0;
if (brightness < 50 && colorMode === 1) {
colorData[base400Index] = lightenHexColor(color, (brightness * -1 + 100) * 0.5);
} else if (brightness === 100 && hexToHsl(color).s < 0.15) {
} else if (brightness === 100 && ((_hexToHsl$s = (_hexToHsl = hexToHsl(color)) === null || _hexToHsl === void 0 ? void 0 : _hexToHsl.s) !== null && _hexToHsl$s !== void 0 ? _hexToHsl$s : 0) < 0.15) {
colorData[base400Index] = '#a8a8a8';

@@ -94,3 +102,3 @@ } else {

if (accent400Index >= 0) {
var _brightness = getColorBrightness(color);
var _brightness = getColorBrightness(color) || 0;

@@ -107,7 +115,9 @@ if (_brightness < 50) {

if (secondaryBase400Index >= 0) {
var _brightness2 = getColorBrightness(secondary);
var _hexToHsl$s2, _hexToHsl2;
var _brightness2 = getColorBrightness(secondary) || 0;
if (_brightness2 < 50 && colorMode === 1) {
colorData[secondaryBase400Index] = lightenHexColor(secondary, (_brightness2 * -1 + 100) * 0.5);
} else if (_brightness2 === 100 && hexToHsl(secondary).s < 15) {
} else if (_brightness2 === 100 && ((_hexToHsl$s2 = (_hexToHsl2 = hexToHsl(secondary)) === null || _hexToHsl2 === void 0 ? void 0 : _hexToHsl2.s) !== null && _hexToHsl$s2 !== void 0 ? _hexToHsl$s2 : 0) < 15) {
colorData[secondaryBase400Index] = '#a8a8a8';

@@ -122,3 +132,3 @@ } else {

if (secondaryAccent400Index >= 0) {
var _brightness3 = getColorBrightness(secondary);
var _brightness3 = getColorBrightness(secondary) || 0;

@@ -145,2 +155,3 @@ if (_brightness3 < 50) {

export { getColorFromPalette, getAvailableColorList };
export { getColorFromPalette, getAvailableColorList };
//# sourceMappingURL=chaynsColors.js.map

@@ -383,2 +383,3 @@ var specials = {

};
export { colorPalette, specials };
export { colorPalette, specials };
//# sourceMappingURL=constants.js.map

@@ -1,4 +0,4 @@

import { getAvailableColorList, getColorFromPalette } from './chaynsColors';
import { lightenHslColor, lightenHexColor, lightenHsvColor, lightenRgb255Color, darkenHexColor, darkenHslColor, darkenHsvColor, darkenRgb255Color } from './lightenDarken';
import { mixHsv, mixHsl, mixRgb, mixHex } from './mix';
export { getAvailableColorList, getColorFromPalette, lightenHslColor, lightenHexColor, lightenHsvColor, lightenRgb255Color, darkenHexColor, darkenHslColor, darkenHsvColor, darkenRgb255Color, mixHsv, mixHsl, mixRgb, mixHex };
export { getAvailableColorList, getColorFromPalette } from './chaynsColors';
export { lightenHslColor, lightenHexColor, lightenHsvColor, lightenRgb255Color, darkenHexColor, darkenHslColor, darkenHsvColor, darkenRgb255Color } from './lightenDarken';
export { mixHsv, mixHsl, mixRgb, mixHex } from './mix';
//# sourceMappingURL=index.js.map

@@ -1,5 +0,12 @@

import { hexToHsl, hslToHex, hslToHsv, hsvToHsl, hslToRgb255, rgb255ToHsl } from '../converter/index';
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { hexToHsl, hslToHex, hslToHsv, hsvToHsl, hslToRgb255, rgb255ToHsl } from '../converter';
function lightenHslColor(hsl, percent) {
var color = hsl;
var color = _objectSpread({}, hsl);
color.l += percent / 100;

@@ -21,25 +28,62 @@

function lightenRgb255Color(color, percent) {
return hslToRgb255(lightenHslColor(rgb255ToHsl(color), percent));
var hsl = rgb255ToHsl(color);
if (!hsl) {
return null;
}
return hslToRgb255(lightenHslColor(hsl, percent));
}
function darkenRgb255Color(color, percent) {
return hslToRgb255(darkenHslColor(rgb255ToHsl(color), percent));
var hsl = rgb255ToHsl(color);
if (!hsl) {
return null;
}
return hslToRgb255(darkenHslColor(hsl, percent));
}
function lightenHexColor(color, percent) {
return hslToHex(lightenHslColor(hexToHsl(color), percent));
var hsl = hexToHsl(color);
if (!hsl) {
return null;
}
return hslToHex(lightenHslColor(hsl, percent));
}
function darkenHexColor(color, percent) {
return hslToHex(darkenHslColor(hexToHsl(color), percent));
var hsl = hexToHsl(color);
if (!hsl) {
return null;
}
return hslToHex(darkenHslColor(hsl, percent));
}
function lightenHsvColor(color, percent) {
return hslToHsv(lightenHslColor(hsvToHsl(color), percent));
var hsl = hsvToHsl(color);
if (!hsl) {
return null;
}
return hslToHsv(lightenHslColor(hsl, percent));
}
function darkenHsvColor(color, percent) {
return hslToHsv(darkenHslColor(hsvToHsl(color), percent));
var hsl = hsvToHsl(color);
if (!hsl) {
return null;
}
return hslToHsv(darkenHslColor(hsl, percent));
}
export { lightenHslColor, darkenHslColor, lightenRgb255Color, darkenRgb255Color, lightenHexColor, darkenHexColor, lightenHsvColor, darkenHsvColor };
export { lightenHslColor, darkenHslColor, lightenRgb255Color, darkenRgb255Color, lightenHexColor, darkenHexColor, lightenHsvColor, darkenHsvColor };
//# sourceMappingURL=lightenDarken.js.map

@@ -1,2 +0,2 @@

import { checkTransparency, hexToRgb255, rgb255ToHex, rgb1ToHsv, rgb1ToHsl, hslToRgb1, hsvToRgb1 } from '../converter/index';
import { checkTransparency, hexToRgb255, rgb255ToHex, rgb1ToHsv, rgb1ToHsl, hslToRgb1, hsvToRgb1 } from '../converter';
import roundValues from '../utils/roundValues';

@@ -11,9 +11,9 @@

var b = weight * color1.b + weightColor2 * color2.b;
var a = null;
var a;
if (color1.a || color2.a) {
a = weight * color1.a + weightColor2 * color2.a;
if ('a' in color1 || 'a' in color2) {
a = weight * ('a' in color1 ? color1.a : 0) + weightColor2 * ('a' in color2 ? color2.a : 0);
}
return roundValues(checkTransparency({
var color = checkTransparency({
r: r,

@@ -23,17 +23,40 @@ g: g,

a: a
}));
});
return roundValues(color);
}
function mixHex(color1, color2, weight) {
return rgb255ToHex(mixRgb(hexToRgb255(color1), hexToRgb255(color2), weight));
var color1Rgb255 = hexToRgb255(color1);
var color2Rgb255 = hexToRgb255(color2);
if (!color1Rgb255 || !color2Rgb255) {
return null;
}
return rgb255ToHex(mixRgb(color1Rgb255, color2Rgb255, weight));
}
function mixHsv(color1, color2, weight) {
return rgb1ToHsv(mixRgb(hsvToRgb1(color1), hsvToRgb1(color2), weight));
var color1Rgb255 = hsvToRgb1(color1);
var color2Rgb255 = hsvToRgb1(color2);
if (!color1Rgb255 || !color2Rgb255) {
return null;
}
return rgb1ToHsv(mixRgb(color1Rgb255, color2Rgb255, weight));
}
function mixHsl(color1, color2, weight) {
return rgb1ToHsl(mixRgb(hslToRgb1(color1), hslToRgb1(color2), weight));
var color1Rgb255 = hslToRgb1(color1);
var color2Rgb255 = hslToRgb1(color2);
if (!color1Rgb255 || !color2Rgb255) {
return null;
}
return rgb1ToHsl(mixRgb(color1Rgb255, color2Rgb255, weight));
}
export { mixRgb, mixHex, mixHsl, mixHsv };
export { mixRgb, mixHex, mixHsl, mixHsv };
//# sourceMappingURL=mix.js.map

@@ -1,3 +0,4 @@

export * from './converter/index';
export * from './generator/index';
export { isHex, isRgb255, isRgb1, isHsl, isHsv } from './utils/is';
export * from './converter';
export * from './generator';
export { isHex, isRgb255, isRgb1, isHsl, isHsv } from './utils/is';
//# sourceMappingURL=index.js.map

@@ -13,3 +13,9 @@ var _excluded = ["a"];

import { isNumber, isObject, isString } from './is';
import { isObject, isString } from './is';
/**
* Removes the transparency part of the color
* @param color
* @param hexTransparency
*/
export default function checkTransparency(color) {

@@ -31,3 +37,3 @@ var hexTransparency = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;

if (!isNumber(color.a)) {
if ('a' in color) {
var a = color.a,

@@ -40,2 +46,3 @@ colorWithoutTransparency = _objectWithoutProperties(color, _excluded);

return color;
}
}
//# sourceMappingURL=checkTransparency.js.map
export var HEX_REGEX = /^(?:#)?((?:[0-9a-f]{2}){3,4})$/i;
export var SHORT_HEX_REGEX = /^(?:#)?((?:[0-9a-f]){3})$/i;
export var RGB_REGEX = /^(?:rgb|rgba)\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})(?:\s*,\s*(1|0|(?:0?\.[0-9]+)))?\s*\)$/i;
export var RGB_REGEX = /^(?:rgb|rgba)\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})(?:\s*,\s*(1|0|(?:0?\.[0-9]+)))?\s*\)$/i;
//# sourceMappingURL=constants.js.map

@@ -36,2 +36,3 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }

return isObject(value) && isInInterval(value.h, 0, 360) && isInInterval(value.s, 0, 1) && isInInterval(value.v, 0, 1) && (isNullOrUndefined(value.a) || isInInterval(value.a, 0, 1));
}
}
//# sourceMappingURL=is.js.map
import { rgb255ToHex } from '../converter';
function getRandomRgb255Color() {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$transparency = _ref.transparency,
transparency = _ref$transparency === void 0 ? false : _ref$transparency,
_ref$rgb = _ref.rgb1,
rgb1 = _ref$rgb === void 0 ? false : _ref$rgb;
var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : undefined;
var rgb = {

@@ -24,4 +19,4 @@ r: null,

if (!rgb1 && component !== 'a') {
rgb[component] = Math.round(rgb[component] * 255);
if (component !== 'a') {
rgb[component] = Math.round((rgb[component] || 0) * 255);
}

@@ -35,7 +30,6 @@ }

var transparency = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
return rgb255ToHex(getRandomRgb255Color({
transparency: transparency
}));
return rgb255ToHex(getRandomRgb255Color(transparency));
}
export { getRandomHexColor, getRandomRgb255Color };
export { getRandomHexColor, getRandomRgb255Color };
//# sourceMappingURL=randomColor.js.map
export default function roundValues(obj) {
var retObj = {};
var keys = Object.keys(obj);
for (var i = 0; i < Object.keys(obj).length; i += 1) {
var key = Object.keys(obj)[i];
for (var i = 0, z = keys.length; i < z; i += 1) {
var key = keys[i];
retObj[key] = Math.round(obj[key]);

@@ -10,2 +11,3 @@ }

return retObj;
}
}
//# sourceMappingURL=roundValues.js.map
{
"name": "@chayns/colors",
"version": "1.0.4",
"version": "2.0.0",
"description": "JavaScript utility functions for the calculation of colors for chayns",
"main": "cjs/index.js",
"module": "es/index.js",
"types": "lib/index.d.ts",
"scripts": {
"build:cjs": "cross-env NODE_ENV=cjs babel src --out-dir cjs",
"build:es": "cross-env NODE_ENV=es babel src --out-dir es",
"build": "npm run build:cjs && npm run build:es",
"build:cjs": "cross-env NODE_ENV=cjs babel src --out-dir cjs --extensions=.ts,.js --source-maps ",
"build:es": "cross-env NODE_ENV=es babel src --out-dir es --extensions=.ts,.js --source-maps ",
"build:types": "tsc",
"build": "npm run build:types && npm run build:cjs && npm run build:es",
"prepublishOnly": "npm run test && npm run build",

@@ -16,3 +18,3 @@ "start": "npm link && npm run watch",

"test:treeshaking": "npm run build:es && npx treeshake",
"test:eslint": "./node_modules/.bin/eslint src --ext .jsx --ext .js",
"test:eslint": "eslint src --ext .js,.ts",
"watch:cjs": "cross-env NODE_ENV=cjs babel src --watch --out-dir cjs",

@@ -43,3 +45,5 @@ "watch:es": "cross-env NODE_ENV=es babel src --watch --out-dir es",

"@babel/preset-env": "^7.14.4",
"@babel/preset-typescript": "^7.15.0",
"@jest/globals": "^26.6.2",
"@typescript-eslint/parser": "^4.31.2",
"babel-jest": "^26.6.3",

@@ -49,2 +53,3 @@ "cross-env": "^7.0.3",

"eslint-config-airbnb": "^18.2.1",
"eslint-import-resolver-typescript": "^2.5.0",
"eslint-plugin-import": "^2.23.4",

@@ -54,6 +59,7 @@ "eslint-plugin-jsx-a11y": "^6.4.1",

"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-typescript": "^0.14.0",
"jest": "^26.6.3",
"tree-shake": "^1.0.5"
},
"dependencies": {}
"tree-shake": "^1.0.5",
"typescript": "^4.4.3"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc