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

@irojs/iro-core

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@irojs/iro-core - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

5

dist/color.d.ts

@@ -25,3 +25,6 @@ export interface ColorChanges {

}
export declare type IroColorValue = IroColor | HsvColor | RgbColor | HslColor | string;
export interface KelvinColor {
kelvin: number;
}
export declare type IroColorValue = IroColor | HsvColor | RgbColor | HslColor | KelvinColor | string;
export declare class IroColor {

@@ -28,0 +31,0 @@ private $;

1

dist/colorPickerOptions.d.ts

@@ -14,2 +14,3 @@ import { IroColorValue } from './color';

handleRadius?: number;
activeHandleRadius?: number;
handleSvg?: string;

@@ -16,0 +17,0 @@ handleProps?: any;

@@ -150,8 +150,10 @@ function _defineProperties(target, props) {

this.hsv = value.hsv;
} else if (typeof value === 'object' && 'r' in value && 'g' in value && 'b' in value) {
} else if ('r' in value && 'g' in value && 'b' in value) {
this.rgb = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'v' in value) {
} else if ('h' in value && 's' in value && 'v' in value) {
this.hsv = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'l' in value) {
} else if ('h' in value && 's' in value && 'l' in value) {
this.hsl = value;
} else if ('kelvin' in value) {
this.kelvin = value.kelvin;
}

@@ -939,13 +941,50 @@ } else {

var TAU = Math.PI * 2; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
var mod = function mod(a, n) {
return (a % n + n) % n;
}; // distance between points (x, y) and (0, 0)
var dist = function dist(x, y) {
return Math.sqrt(x * x + y * y);
};
/**
* @param props - wheel props
* @internal
*/
function getHandleRange(props) {
return props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
}
/**
* Returns true if point (x, y) lands inside the wheel
* @param props - wheel props
* @param x
* @param y
*/
function isInputInsideWheel(props, x, y) {
var _getWheelDimensions = getWheelDimensions(props),
cx = _getWheelDimensions.cx,
cy = _getWheelDimensions.cy;
var r = props.width / 2;
return dist(cx - x, cy - y) < r;
}
/**
* @desc Get the point as the center of the wheel
* @param props - wheel props
*/
function getWheelDimensions(props) {
var rad = props.width / 2;
var r = props.width / 2;
return {
width: props.width,
radius: rad - props.borderWidth,
cx: rad,
cy: rad
radius: r - props.borderWidth,
cx: r,
cy: r
};

@@ -966,6 +1005,4 @@ }

else if (invert && wheelDirection === 'anticlockwise') angle = wheelAngle + 180 - angle; // anticlockwise (input handling)
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
return (angle % 360 + 360) % 360;
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle;
return mod(angle, 360);
}

@@ -981,8 +1018,8 @@ /**

var _getWheelDimensions = getWheelDimensions(props),
cx = _getWheelDimensions.cx,
cy = _getWheelDimensions.cy;
var _getWheelDimensions2 = getWheelDimensions(props),
cx = _getWheelDimensions2.cx,
cy = _getWheelDimensions2.cy;
var handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
var handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (Math.PI / 180);
var handleRange = getHandleRange(props);
var handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (TAU / 360);
var handleDist = hsv.s / 100 * handleRange;

@@ -1003,14 +1040,14 @@ var direction = props.wheelDirection === 'clockwise' ? -1 : 1;

function getWheelValueFromInput(props, x, y) {
var _getWheelDimensions2 = getWheelDimensions(props),
cx = _getWheelDimensions2.cx,
cy = _getWheelDimensions2.cy;
var _getWheelDimensions3 = getWheelDimensions(props),
cx = _getWheelDimensions3.cx,
cy = _getWheelDimensions3.cy;
var handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
var handleRange = getHandleRange(props);
x = cx - x;
y = cy - y; // Calculate the hue by converting the angle to radians
var hue = translateWheelAngle(props, Math.atan2(-y, -x) * (180 / Math.PI)); // Find the point's distance from the center of the wheel
var hue = translateWheelAngle(props, Math.atan2(-y, -x) * (360 / TAU)); // Find the point's distance from the center of the wheel
// This is used to show the saturation level
var handleDist = Math.min(Math.sqrt(x * x + y * y), handleRange);
var handleDist = Math.min(dist(x, y), handleRange);
return {

@@ -1199,2 +1236,3 @@ h: Math.round(hue),

handleRadius: 8,
activeHandleRadius: null,
handleSvg: null,

@@ -1213,3 +1251,3 @@ handleProps: {

export { IroColor, cssBorderStyles, cssGradient, cssValue, getBoxDimensions, getBoxGradients, getBoxHandlePosition, getBoxStyles, getBoxValueFromInput, getCurrentSliderValue, getHandleAtPoint, getSliderDimensions, getSliderGradient, getSliderGradientCoords, getSliderHandlePosition, getSliderStyles, getSliderValueFromInput, getSvgArcPath, getWheelDimensions, getWheelHandlePosition, getWheelValueFromInput, iroColorPickerOptionDefaults, resolveSvgUrl, sliderDefaultOptions, translateWheelAngle };
export { IroColor, cssBorderStyles, cssGradient, cssValue, getBoxDimensions, getBoxGradients, getBoxHandlePosition, getBoxStyles, getBoxValueFromInput, getCurrentSliderValue, getHandleAtPoint, getSliderDimensions, getSliderGradient, getSliderGradientCoords, getSliderHandlePosition, getSliderStyles, getSliderValueFromInput, getSvgArcPath, getWheelDimensions, getWheelHandlePosition, getWheelValueFromInput, iroColorPickerOptionDefaults, isInputInsideWheel, resolveSvgUrl, sliderDefaultOptions, translateWheelAngle };
//# sourceMappingURL=iro-core.es.js.map

@@ -150,8 +150,10 @@ function _defineProperties(target, props) {

this.hsv = value.hsv;
} else if (typeof value === 'object' && 'r' in value && 'g' in value && 'b' in value) {
} else if ('r' in value && 'g' in value && 'b' in value) {
this.rgb = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'v' in value) {
} else if ('h' in value && 's' in value && 'v' in value) {
this.hsv = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'l' in value) {
} else if ('h' in value && 's' in value && 'l' in value) {
this.hsl = value;
} else if ('kelvin' in value) {
this.kelvin = value.kelvin;
}

@@ -939,13 +941,50 @@ } else {

var TAU = Math.PI * 2; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
var mod = function mod(a, n) {
return (a % n + n) % n;
}; // distance between points (x, y) and (0, 0)
var dist = function dist(x, y) {
return Math.sqrt(x * x + y * y);
};
/**
* @param props - wheel props
* @internal
*/
function getHandleRange(props) {
return props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
}
/**
* Returns true if point (x, y) lands inside the wheel
* @param props - wheel props
* @param x
* @param y
*/
function isInputInsideWheel(props, x, y) {
var _getWheelDimensions = getWheelDimensions(props),
cx = _getWheelDimensions.cx,
cy = _getWheelDimensions.cy;
var r = props.width / 2;
return dist(cx - x, cy - y) < r;
}
/**
* @desc Get the point as the center of the wheel
* @param props - wheel props
*/
function getWheelDimensions(props) {
var rad = props.width / 2;
var r = props.width / 2;
return {
width: props.width,
radius: rad - props.borderWidth,
cx: rad,
cy: rad
radius: r - props.borderWidth,
cx: r,
cy: r
};

@@ -966,6 +1005,4 @@ }

else if (invert && wheelDirection === 'anticlockwise') angle = wheelAngle + 180 - angle; // anticlockwise (input handling)
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
return (angle % 360 + 360) % 360;
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle;
return mod(angle, 360);
}

@@ -981,8 +1018,8 @@ /**

var _getWheelDimensions = getWheelDimensions(props),
cx = _getWheelDimensions.cx,
cy = _getWheelDimensions.cy;
var _getWheelDimensions2 = getWheelDimensions(props),
cx = _getWheelDimensions2.cx,
cy = _getWheelDimensions2.cy;
var handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
var handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (Math.PI / 180);
var handleRange = getHandleRange(props);
var handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (TAU / 360);
var handleDist = hsv.s / 100 * handleRange;

@@ -1003,14 +1040,14 @@ var direction = props.wheelDirection === 'clockwise' ? -1 : 1;

function getWheelValueFromInput(props, x, y) {
var _getWheelDimensions2 = getWheelDimensions(props),
cx = _getWheelDimensions2.cx,
cy = _getWheelDimensions2.cy;
var _getWheelDimensions3 = getWheelDimensions(props),
cx = _getWheelDimensions3.cx,
cy = _getWheelDimensions3.cy;
var handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
var handleRange = getHandleRange(props);
x = cx - x;
y = cy - y; // Calculate the hue by converting the angle to radians
var hue = translateWheelAngle(props, Math.atan2(-y, -x) * (180 / Math.PI)); // Find the point's distance from the center of the wheel
var hue = translateWheelAngle(props, Math.atan2(-y, -x) * (360 / TAU)); // Find the point's distance from the center of the wheel
// This is used to show the saturation level
var handleDist = Math.min(Math.sqrt(x * x + y * y), handleRange);
var handleDist = Math.min(dist(x, y), handleRange);
return {

@@ -1199,2 +1236,3 @@ h: Math.round(hue),

handleRadius: 8,
activeHandleRadius: null,
handleSvg: null,

@@ -1235,2 +1273,3 @@ handleProps: {

exports.iroColorPickerOptionDefaults = iroColorPickerOptionDefaults;
exports.isInputInsideWheel = isInputInsideWheel;
exports.resolveSvgUrl = resolveSvgUrl;

@@ -1237,0 +1276,0 @@ exports.sliderDefaultOptions = sliderDefaultOptions;

@@ -132,8 +132,10 @@ function _extends() {

this.hsv = value.hsv;
} else if (typeof value === 'object' && 'r' in value && 'g' in value && 'b' in value) {
} else if ('r' in value && 'g' in value && 'b' in value) {
this.rgb = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'v' in value) {
} else if ('h' in value && 's' in value && 'v' in value) {
this.hsv = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'l' in value) {
} else if ('h' in value && 's' in value && 'l' in value) {
this.hsl = value;
} else if ('kelvin' in value) {
this.kelvin = value.kelvin;
}

@@ -927,13 +929,46 @@ } else {

const TAU = Math.PI * 2; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
const mod = (a, n) => (a % n + n) % n; // distance between points (x, y) and (0, 0)
const dist = (x, y) => Math.sqrt(x * x + y * y);
/**
* @param props - wheel props
* @internal
*/
function getHandleRange(props) {
return props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
}
/**
* Returns true if point (x, y) lands inside the wheel
* @param props - wheel props
* @param x
* @param y
*/
function isInputInsideWheel(props, x, y) {
const {
cx,
cy
} = getWheelDimensions(props);
const r = props.width / 2;
return dist(cx - x, cy - y) < r;
}
/**
* @desc Get the point as the center of the wheel
* @param props - wheel props
*/
function getWheelDimensions(props) {
const rad = props.width / 2;
const r = props.width / 2;
return {
width: props.width,
radius: rad - props.borderWidth,
cx: rad,
cy: rad
radius: r - props.borderWidth,
cx: r,
cy: r
};

@@ -954,6 +989,4 @@ }

else if (invert && wheelDirection === 'anticlockwise') angle = wheelAngle + 180 - angle; // anticlockwise (input handling)
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
return (angle % 360 + 360) % 360;
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle;
return mod(angle, 360);
}

@@ -972,4 +1005,4 @@ /**

} = getWheelDimensions(props);
const handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
const handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (Math.PI / 180);
const handleRange = getHandleRange(props);
const handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (TAU / 360);
const handleDist = hsv.s / 100 * handleRange;

@@ -994,10 +1027,10 @@ const direction = props.wheelDirection === 'clockwise' ? -1 : 1;

} = getWheelDimensions(props);
const handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
const handleRange = getHandleRange(props);
x = cx - x;
y = cy - y; // Calculate the hue by converting the angle to radians
const hue = translateWheelAngle(props, Math.atan2(-y, -x) * (180 / Math.PI)); // Find the point's distance from the center of the wheel
const hue = translateWheelAngle(props, Math.atan2(-y, -x) * (360 / TAU)); // Find the point's distance from the center of the wheel
// This is used to show the saturation level
const handleDist = Math.min(Math.sqrt(x * x + y * y), handleRange);
const handleDist = Math.min(dist(x, y), handleRange);
return {

@@ -1184,2 +1217,3 @@ h: Math.round(hue),

handleRadius: 8,
activeHandleRadius: null,
handleSvg: null,

@@ -1198,3 +1232,3 @@ handleProps: {

export { IroColor, cssBorderStyles, cssGradient, cssValue, getBoxDimensions, getBoxGradients, getBoxHandlePosition, getBoxStyles, getBoxValueFromInput, getCurrentSliderValue, getHandleAtPoint, getSliderDimensions, getSliderGradient, getSliderGradientCoords, getSliderHandlePosition, getSliderStyles, getSliderValueFromInput, getSvgArcPath, getWheelDimensions, getWheelHandlePosition, getWheelValueFromInput, iroColorPickerOptionDefaults, resolveSvgUrl, sliderDefaultOptions, translateWheelAngle };
export { IroColor, cssBorderStyles, cssGradient, cssValue, getBoxDimensions, getBoxGradients, getBoxHandlePosition, getBoxStyles, getBoxValueFromInput, getCurrentSliderValue, getHandleAtPoint, getSliderDimensions, getSliderGradient, getSliderGradientCoords, getSliderHandlePosition, getSliderStyles, getSliderValueFromInput, getSvgArcPath, getWheelDimensions, getWheelHandlePosition, getWheelValueFromInput, iroColorPickerOptionDefaults, isInputInsideWheel, resolveSvgUrl, sliderDefaultOptions, translateWheelAngle };
//# sourceMappingURL=iro-core.modern.js.map

@@ -155,8 +155,10 @@ (function (global, factory) {

this.hsv = value.hsv;
} else if (typeof value === 'object' && 'r' in value && 'g' in value && 'b' in value) {
} else if ('r' in value && 'g' in value && 'b' in value) {
this.rgb = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'v' in value) {
} else if ('h' in value && 's' in value && 'v' in value) {
this.hsv = value;
} else if (typeof value === 'object' && 'h' in value && 's' in value && 'l' in value) {
} else if ('h' in value && 's' in value && 'l' in value) {
this.hsl = value;
} else if ('kelvin' in value) {
this.kelvin = value.kelvin;
}

@@ -944,13 +946,50 @@ } else {

var TAU = Math.PI * 2; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
var mod = function mod(a, n) {
return (a % n + n) % n;
}; // distance between points (x, y) and (0, 0)
var dist = function dist(x, y) {
return Math.sqrt(x * x + y * y);
};
/**
* @param props - wheel props
* @internal
*/
function getHandleRange(props) {
return props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
}
/**
* Returns true if point (x, y) lands inside the wheel
* @param props - wheel props
* @param x
* @param y
*/
function isInputInsideWheel(props, x, y) {
var _getWheelDimensions = getWheelDimensions(props),
cx = _getWheelDimensions.cx,
cy = _getWheelDimensions.cy;
var r = props.width / 2;
return dist(cx - x, cy - y) < r;
}
/**
* @desc Get the point as the center of the wheel
* @param props - wheel props
*/
function getWheelDimensions(props) {
var rad = props.width / 2;
var r = props.width / 2;
return {
width: props.width,
radius: rad - props.borderWidth,
cx: rad,
cy: rad
radius: r - props.borderWidth,
cx: r,
cy: r
};

@@ -971,6 +1010,4 @@ }

else if (invert && wheelDirection === 'anticlockwise') angle = wheelAngle + 180 - angle; // anticlockwise (input handling)
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle; // javascript's modulo operator doesn't produce positive numbers with negative input
// https://dev.to/maurobringolf/a-neat-trick-to-compute-modulo-of-negative-numbers-111e
return (angle % 360 + 360) % 360;
else if (wheelDirection === 'anticlockwise') angle = wheelAngle - angle;
return mod(angle, 360);
}

@@ -986,8 +1023,8 @@ /**

var _getWheelDimensions = getWheelDimensions(props),
cx = _getWheelDimensions.cx,
cy = _getWheelDimensions.cy;
var _getWheelDimensions2 = getWheelDimensions(props),
cx = _getWheelDimensions2.cx,
cy = _getWheelDimensions2.cy;
var handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
var handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (Math.PI / 180);
var handleRange = getHandleRange(props);
var handleAngle = (180 + translateWheelAngle(props, hsv.h, true)) * (TAU / 360);
var handleDist = hsv.s / 100 * handleRange;

@@ -1008,14 +1045,14 @@ var direction = props.wheelDirection === 'clockwise' ? -1 : 1;

function getWheelValueFromInput(props, x, y) {
var _getWheelDimensions2 = getWheelDimensions(props),
cx = _getWheelDimensions2.cx,
cy = _getWheelDimensions2.cy;
var _getWheelDimensions3 = getWheelDimensions(props),
cx = _getWheelDimensions3.cx,
cy = _getWheelDimensions3.cy;
var handleRange = props.width / 2 - props.padding - props.handleRadius - props.borderWidth;
var handleRange = getHandleRange(props);
x = cx - x;
y = cy - y; // Calculate the hue by converting the angle to radians
var hue = translateWheelAngle(props, Math.atan2(-y, -x) * (180 / Math.PI)); // Find the point's distance from the center of the wheel
var hue = translateWheelAngle(props, Math.atan2(-y, -x) * (360 / TAU)); // Find the point's distance from the center of the wheel
// This is used to show the saturation level
var handleDist = Math.min(Math.sqrt(x * x + y * y), handleRange);
var handleDist = Math.min(dist(x, y), handleRange);
return {

@@ -1204,2 +1241,3 @@ h: Math.round(hue),

handleRadius: 8,
activeHandleRadius: null,
handleSvg: null,

@@ -1240,2 +1278,3 @@ handleProps: {

exports.iroColorPickerOptionDefaults = iroColorPickerOptionDefaults;
exports.isInputInsideWheel = isInputInsideWheel;
exports.resolveSvgUrl = resolveSvgUrl;

@@ -1242,0 +1281,0 @@ exports.sliderDefaultOptions = sliderDefaultOptions;

@@ -7,2 +7,9 @@ import { IroColorPickerOptions } from './colorPickerOptions';

/**
* Returns true if point (x, y) lands inside the wheel
* @param props - wheel props
* @param x
* @param y
*/
export declare function isInputInsideWheel(props: Partial<WheelProps>, x: number, y: number): boolean;
/**
* @desc Get the point as the center of the wheel

@@ -9,0 +16,0 @@ * @param props - wheel props

{
"name": "@irojs/iro-core",
"version": "1.1.0",
"version": "1.2.0",
"description": "Core functionality for iro.js",

@@ -5,0 +5,0 @@ "source": "src/index.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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