New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@palette/color-picker

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@palette/color-picker - npm Package Compare versions

Comparing version

to
0.1.4

2

lib/_subcomponents/color/values.js

@@ -14,4 +14,2 @@ "use strict";

var _tinycolor = _interopRequireDefault(require("tinycolor2"));
var _dimension = _interopRequireDefault(require("../inputs/dimension"));

@@ -18,0 +16,0 @@

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

var _mousetrap = _interopRequireDefault(require("mousetrap"));
var _nanoid = _interopRequireDefault(require("nanoid"));

@@ -100,35 +98,6 @@

_createClass(Dimension, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
var key = new _mousetrap.default(this.elem);
var step = this.props.step || 1;
key.bind('up', function () {
_this2.nudgeValue(step);
return false;
});
key.bind('down', function () {
_this2.nudgeValue(-step);
return false;
});
key.bind('shift+up', function () {
_this2.nudgeValue(step * 10);
return false;
});
key.bind('shift+down', function () {
_this2.nudgeValue(step * -10);
return false;
});
}
}, {
key: "render",
value: function render() {
var _this3 = this;
var _this2 = this;
var id = (0, _nanoid.default)();
var mods = {

@@ -140,3 +109,3 @@ 'is-disabled': this.props.disabled

ref: function ref(node) {
return _this3.elem = node;
return _this2.elem = node;
}

@@ -147,3 +116,3 @@ }, React.createElement("span", {

type: "number",
id: id,
id: (0, _nanoid.default)(),
onChange: this.handleChange,

@@ -150,0 +119,0 @@ onBlur: this.handleChange,

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

var _mousetrap = _interopRequireDefault(require("mousetrap"));
var _nanoid = _interopRequireDefault(require("nanoid"));

@@ -99,33 +97,5 @@

_createClass(Range, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
var key = new _mousetrap.default(this.elem);
var step = this.props.step || 1;
key.bind(['up', 'right'], function () {
_this2.nudgeValue(1);
return false;
});
key.bind(['down', 'left'], function () {
_this2.nudgeValue(-1);
return false;
});
key.bind(['shift+up', 'shift+right'], function () {
_this2.nudgeValue(10);
return false;
});
key.bind(['shift+down', 'shift+left'], function () {
_this2.nudgeValue(-10);
return false;
});
}
}, {
key: "render",
value: function render() {
var _this3 = this;
var _this2 = this;

@@ -138,3 +108,3 @@ var mods = {

ref: function ref(node) {
return _this3.elem = node;
return _this2.elem = node;
}

@@ -141,0 +111,0 @@ }, React.createElement("span", {

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

var _mousetrap = _interopRequireDefault(require("mousetrap"));
var _nanoid = _interopRequireDefault(require("nanoid"));

@@ -84,66 +82,5 @@

_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "onBlur", function (e) {
var vals = _this.getParsedValues(e.target.value); // this.setState({ value: vals.value})
_this.props.update ? _this.props.update(_this.state.value) : null;
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "nudgeValues", function (evt, nudge) {
var vals = _this.getParsedValues(_this.state.value);
var selectedValue = _this.getSelectedValue(evt, vals);
vals[selectedValue]['value'] += nudge;
var newThing = '';
vals.forEach(function (val) {
return newThing += val['value'] + val['units'];
});
_this.setState({
value: newThing
});
evt.target.setSelectionRange(vals[selectedValue]['sourceIndex'], vals[selectedValue]['sourceIndex'] + vals[selectedValue]['length']);
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getSelectedValue", function (evt, values) {
var caretPos = evt.target.selectionStart;
var selectedValue = 0;
for (var i = 0; i < values.length; i++) {
if (caretPos >= values[i].sourceIndex && caretPos <= values[i].sourceIndex + values[i].length) {
selectedValue = i;
}
}
return selectedValue;
});
_defineProperty(_assertThisInitialized(_assertThisInitialized(_this)), "getParsedValues", function (values) {
var parsedValue = (0, _postcssValueParser.default)(values);
var valStore = [];
parsedValue.nodes.forEach(function (node) {
valStore.push(node);
var currentValStore = valStore[valStore.length - 1];
currentValStore['units'] = '';
currentValStore['selected'] = false;
currentValStore['length'] = currentValStore['value'].length;
if (node.type == 'word') {
var cssDimension = (0, _parseCssDimension.default)(node.value);
var cssUnit = '';
if (cssDimension && cssDimension.unit) {
cssUnit = cssDimension.unit;
} else if (_this.props.fallbackUnits) {
cssUnit = _this.props.fallbackUnits;
}
currentValStore['value'] = cssDimension.value;
currentValStore['units'] = cssUnit;
} else {}
});
return valStore;
});
_this.state = {

@@ -157,32 +94,5 @@ value: _this.props.value || '',

_createClass(Text, [{
key: "componentDidMount",
value: function componentDidMount() {
var _this2 = this;
var key = new _mousetrap.default(this.elem);
key.bind('up', function () {
_this2.nudgeValues(event, 1);
return false;
});
key.bind('shift+up', function () {
_this2.nudgeValues(event, 10);
return false;
});
key.bind('down', function () {
_this2.nudgeValues(event, -1);
return false;
});
key.bind('shift+down', function () {
_this2.nudgeValues(event, -10);
return false;
});
}
}, {
key: "render",
value: function render() {
var _this3 = this;
var _this2 = this;

@@ -193,5 +103,5 @@ var mods = {

return React.createElement("label", {
className: "Text ".concat(this.props.prefix ? 'Text--has-prefix' : null),
className: "Text ".concat(this.props.prefix ? 'Text--has-prefix' : ''),
ref: function ref(node) {
return _this3.elem = node;
return _this2.elem = node;
}

@@ -198,0 +108,0 @@ }, React.createElement("div", {

3

package.json
{
"name": "@palette/color-picker",
"version": "0.1.3",
"version": "0.1.4",
"description": "",

@@ -49,3 +49,2 @@ "main": "lib/index.js",

"dependencies": {
"mousetrap": "^1.6.2",
"nanoid": "^1.1.0",

@@ -52,0 +51,0 @@ "prop-types": "^15.6.2",