@chaoswise/ui 2.5.4 → 2.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Affix/index.js +3 -0
- package/lib/CWMessage/MessageContent/TabList/index.js +3 -3
- package/lib/CWMessage/MessageContent/index.js +6 -6
- package/lib/CWMessage/index.js +72 -92
- package/lib/ColorPicker/SketchPicker/components/common/Alpha.js +133 -0
- package/lib/ColorPicker/SketchPicker/components/common/Checkboard.js +40 -0
- package/lib/ColorPicker/SketchPicker/components/common/ColorWrap.js +80 -0
- package/lib/ColorPicker/SketchPicker/components/common/EditableInput.js +172 -0
- package/lib/ColorPicker/SketchPicker/components/common/Hue.js +118 -0
- package/lib/ColorPicker/SketchPicker/components/common/Raised.js +91 -0
- package/lib/ColorPicker/SketchPicker/components/common/Saturation.js +139 -0
- package/lib/ColorPicker/SketchPicker/components/common/Swatch.js +62 -0
- package/lib/ColorPicker/SketchPicker/components/common/index.js +8 -0
- package/lib/ColorPicker/SketchPicker/components/sketch/SketchFields.js +148 -0
- package/lib/ColorPicker/SketchPicker/components/sketch/SketchPresetColors.js +72 -0
- package/lib/ColorPicker/SketchPicker/components/sketch/index.js +160 -0
- package/lib/ColorPicker/SketchPicker/helpers/alpha.js +46 -0
- package/lib/ColorPicker/SketchPicker/helpers/checkboard.js +29 -0
- package/lib/ColorPicker/SketchPicker/helpers/color.js +86 -0
- package/lib/ColorPicker/SketchPicker/helpers/hue.js +48 -0
- package/lib/ColorPicker/SketchPicker/helpers/index.js +2 -0
- package/lib/ColorPicker/SketchPicker/helpers/interaction.js +55 -0
- package/lib/ColorPicker/SketchPicker/helpers/saturation.js +28 -0
- package/lib/ColorPicker/index.js +2 -3
- package/lib/ErrorBoundary/history.js +51 -51
- package/lib/ErrorBoundary/index.js +3 -2
- package/lib/QuickTransfer/Drag.js +4 -2
- package/lib/QuickTransfer/DragList.js +27 -4
- package/lib/QuickTransfer/index.js +12 -5
- package/package.json +1 -2
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
6
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
7
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import React, { Component, PureComponent } from 'react';
|
|
16
|
+
import reactCSS from 'reactcss';
|
|
17
|
+
var DEFAULT_ARROW_OFFSET = 1;
|
|
18
|
+
var UP_KEY_CODE = 38;
|
|
19
|
+
var DOWN_KEY_CODE = 40;
|
|
20
|
+
var VALID_KEY_CODES = [UP_KEY_CODE, DOWN_KEY_CODE];
|
|
21
|
+
var isValidKeyCode = function isValidKeyCode(keyCode) {
|
|
22
|
+
return VALID_KEY_CODES.indexOf(keyCode) > -1;
|
|
23
|
+
};
|
|
24
|
+
var getNumberValue = function getNumberValue(value) {
|
|
25
|
+
return Number(String(value).replace(/%/g, ''));
|
|
26
|
+
};
|
|
27
|
+
var idCounter = 1;
|
|
28
|
+
export var EditableInput = /*#__PURE__*/function (_ref) {
|
|
29
|
+
_inherits(EditableInput, _ref);
|
|
30
|
+
function EditableInput(props) {
|
|
31
|
+
var _this;
|
|
32
|
+
_classCallCheck(this, EditableInput);
|
|
33
|
+
_this = _callSuper(this, EditableInput);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "handleBlur", function () {
|
|
35
|
+
if (_this.state.blurValue) {
|
|
36
|
+
_this.setState({
|
|
37
|
+
value: _this.state.blurValue,
|
|
38
|
+
blurValue: null
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function (e) {
|
|
43
|
+
_this.setUpdatedValue(e.target.value, e);
|
|
44
|
+
});
|
|
45
|
+
_defineProperty(_assertThisInitialized(_this), "handleKeyDown", function (e) {
|
|
46
|
+
// In case `e.target.value` is a percentage remove the `%` character
|
|
47
|
+
// and update accordingly with a percentage
|
|
48
|
+
// https://github.com/casesandberg/react-color/issues/383
|
|
49
|
+
var value = getNumberValue(e.target.value);
|
|
50
|
+
if (!isNaN(value) && isValidKeyCode(e.keyCode)) {
|
|
51
|
+
var offset = _this.getArrowOffset();
|
|
52
|
+
var updatedValue = e.keyCode === UP_KEY_CODE ? value + offset : value - offset;
|
|
53
|
+
_this.setUpdatedValue(updatedValue, e);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
_defineProperty(_assertThisInitialized(_this), "handleDrag", function (e) {
|
|
57
|
+
if (_this.props.dragLabel) {
|
|
58
|
+
var newValue = Math.round(_this.props.value + e.movementX);
|
|
59
|
+
if (newValue >= 0 && newValue <= _this.props.dragMax) {
|
|
60
|
+
_this.props.onChange && _this.props.onChange(_this.getValueObjectWithLabel(newValue), e);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseDown", function (e) {
|
|
65
|
+
if (_this.props.dragLabel) {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
_this.handleDrag(e);
|
|
68
|
+
window.addEventListener('mousemove', _this.handleDrag);
|
|
69
|
+
window.addEventListener('mouseup', _this.handleMouseUp);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseUp", function () {
|
|
73
|
+
_this.unbindEventListeners();
|
|
74
|
+
});
|
|
75
|
+
_defineProperty(_assertThisInitialized(_this), "unbindEventListeners", function () {
|
|
76
|
+
window.removeEventListener('mousemove', _this.handleDrag);
|
|
77
|
+
window.removeEventListener('mouseup', _this.handleMouseUp);
|
|
78
|
+
});
|
|
79
|
+
_this.state = {
|
|
80
|
+
value: String(props.value).toUpperCase(),
|
|
81
|
+
blurValue: String(props.value).toUpperCase()
|
|
82
|
+
};
|
|
83
|
+
_this.inputId = "rc-editable-input-".concat(idCounter++);
|
|
84
|
+
return _this;
|
|
85
|
+
}
|
|
86
|
+
_createClass(EditableInput, [{
|
|
87
|
+
key: "componentDidUpdate",
|
|
88
|
+
value: function componentDidUpdate(prevProps, prevState) {
|
|
89
|
+
if (this.props.value !== this.state.value && (prevProps.value !== this.props.value || prevState.value !== this.state.value)) {
|
|
90
|
+
if (this.input === document.activeElement) {
|
|
91
|
+
this.setState({
|
|
92
|
+
blurValue: String(this.props.value).toUpperCase()
|
|
93
|
+
});
|
|
94
|
+
} else {
|
|
95
|
+
this.setState({
|
|
96
|
+
value: String(this.props.value).toUpperCase(),
|
|
97
|
+
blurValue: !this.state.blurValue && String(this.props.value).toUpperCase()
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}, {
|
|
103
|
+
key: "componentWillUnmount",
|
|
104
|
+
value: function componentWillUnmount() {
|
|
105
|
+
this.unbindEventListeners();
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
key: "getValueObjectWithLabel",
|
|
109
|
+
value: function getValueObjectWithLabel(value) {
|
|
110
|
+
return _defineProperty({}, this.props.label, value);
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "getArrowOffset",
|
|
114
|
+
value: function getArrowOffset() {
|
|
115
|
+
return this.props.arrowOffset || DEFAULT_ARROW_OFFSET;
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "setUpdatedValue",
|
|
119
|
+
value: function setUpdatedValue(value, e) {
|
|
120
|
+
var onChangeValue = this.props.label ? this.getValueObjectWithLabel(value) : value;
|
|
121
|
+
this.props.onChange && this.props.onChange(onChangeValue, e);
|
|
122
|
+
this.setState({
|
|
123
|
+
value: value
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "render",
|
|
128
|
+
value: function render() {
|
|
129
|
+
var _this2 = this;
|
|
130
|
+
var styles = reactCSS({
|
|
131
|
+
'default': {
|
|
132
|
+
wrap: {
|
|
133
|
+
position: 'relative'
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
'user-override': {
|
|
137
|
+
wrap: this.props.style && this.props.style.wrap ? this.props.style.wrap : {},
|
|
138
|
+
input: this.props.style && this.props.style.input ? this.props.style.input : {},
|
|
139
|
+
label: this.props.style && this.props.style.label ? this.props.style.label : {}
|
|
140
|
+
},
|
|
141
|
+
'dragLabel-true': {
|
|
142
|
+
label: {
|
|
143
|
+
cursor: 'ew-resize'
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
'user-override': true
|
|
148
|
+
}, this.props);
|
|
149
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
150
|
+
style: styles.wrap
|
|
151
|
+
}, /*#__PURE__*/React.createElement("input", {
|
|
152
|
+
id: this.inputId,
|
|
153
|
+
style: styles.input,
|
|
154
|
+
ref: function ref(input) {
|
|
155
|
+
return _this2.input = input;
|
|
156
|
+
},
|
|
157
|
+
value: this.state.value,
|
|
158
|
+
onKeyDown: this.handleKeyDown,
|
|
159
|
+
onChange: this.handleChange,
|
|
160
|
+
onBlur: this.handleBlur,
|
|
161
|
+
placeholder: this.props.placeholder,
|
|
162
|
+
spellCheck: "false"
|
|
163
|
+
}), this.props.label && !this.props.hideLabel ? /*#__PURE__*/React.createElement("label", {
|
|
164
|
+
htmlFor: this.inputId,
|
|
165
|
+
style: styles.label,
|
|
166
|
+
onMouseDown: this.handleMouseDown
|
|
167
|
+
}, this.props.label) : null);
|
|
168
|
+
}
|
|
169
|
+
}]);
|
|
170
|
+
return EditableInput;
|
|
171
|
+
}(PureComponent || Component);
|
|
172
|
+
export default EditableInput;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
6
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
7
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import React, { Component, PureComponent } from "react";
|
|
16
|
+
import reactCSS from "reactcss";
|
|
17
|
+
import * as hue from "../../helpers/hue";
|
|
18
|
+
import { floor, round } from "@chaoswise/utils";
|
|
19
|
+
export var Hue = /*#__PURE__*/function (_ref) {
|
|
20
|
+
_inherits(Hue, _ref);
|
|
21
|
+
function Hue() {
|
|
22
|
+
var _this;
|
|
23
|
+
_classCallCheck(this, Hue);
|
|
24
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
25
|
+
args[_key] = arguments[_key];
|
|
26
|
+
}
|
|
27
|
+
_this = _callSuper(this, Hue, [].concat(args));
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function (e) {
|
|
29
|
+
var change = hue.calculateChange(e, _this.props.direction, _this.props.hsl, _this.container);
|
|
30
|
+
change && typeof _this.props.onChange === "function" && _this.props.onChange(change, e);
|
|
31
|
+
});
|
|
32
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseDown", function (e) {
|
|
33
|
+
_this.handleChange(e);
|
|
34
|
+
window.addEventListener("mousemove", _this.handleChange);
|
|
35
|
+
window.addEventListener("mouseup", _this.handleMouseUp);
|
|
36
|
+
});
|
|
37
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseUp", function () {
|
|
38
|
+
_this.unbindEventListeners();
|
|
39
|
+
});
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
_createClass(Hue, [{
|
|
43
|
+
key: "componentWillUnmount",
|
|
44
|
+
value: function componentWillUnmount() {
|
|
45
|
+
this.unbindEventListeners();
|
|
46
|
+
}
|
|
47
|
+
}, {
|
|
48
|
+
key: "unbindEventListeners",
|
|
49
|
+
value: function unbindEventListeners() {
|
|
50
|
+
window.removeEventListener("mousemove", this.handleChange);
|
|
51
|
+
window.removeEventListener("mouseup", this.handleMouseUp);
|
|
52
|
+
}
|
|
53
|
+
}, {
|
|
54
|
+
key: "render",
|
|
55
|
+
value: function render() {
|
|
56
|
+
var _this2 = this;
|
|
57
|
+
var _this$props$direction = this.props.direction,
|
|
58
|
+
direction = _this$props$direction === void 0 ? "horizontal" : _this$props$direction;
|
|
59
|
+
var leftValue = this.props.hsl.h * 100 / 360;
|
|
60
|
+
var resLeft = floor(leftValue) === 0 ? 0 : round(leftValue);
|
|
61
|
+
var styles = reactCSS({
|
|
62
|
+
"default": {
|
|
63
|
+
hue: {
|
|
64
|
+
absolute: "0px 0px 0px 0px",
|
|
65
|
+
borderRadius: this.props.radius,
|
|
66
|
+
boxShadow: this.props.shadow
|
|
67
|
+
},
|
|
68
|
+
container: {
|
|
69
|
+
margin: "0 3px",
|
|
70
|
+
position: "relative",
|
|
71
|
+
height: "100%",
|
|
72
|
+
borderRadius: this.props.radius
|
|
73
|
+
},
|
|
74
|
+
pointer: {
|
|
75
|
+
position: "absolute",
|
|
76
|
+
left: "".concat(resLeft, "%")
|
|
77
|
+
},
|
|
78
|
+
slider: {
|
|
79
|
+
marginTop: "1px",
|
|
80
|
+
width: "4px",
|
|
81
|
+
borderRadius: "1px",
|
|
82
|
+
height: "8px",
|
|
83
|
+
boxShadow: "0 0 2px rgba(0, 0, 0, .6)",
|
|
84
|
+
background: "#fff",
|
|
85
|
+
transform: "translateX(-2px)"
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
vertical: {
|
|
89
|
+
pointer: {
|
|
90
|
+
left: "0px",
|
|
91
|
+
top: "".concat(-(this.props.hsl.h * 100 / 360) + 100, "%")
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
vertical: direction === "vertical"
|
|
96
|
+
});
|
|
97
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
98
|
+
style: styles.hue,
|
|
99
|
+
className: "hue-".concat(direction, "-custom")
|
|
100
|
+
}, /*#__PURE__*/React.createElement("style", null, "\n .hue-horizontal-custom {\n background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0\n 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n background: -webkit-linear-gradient(to right, #f00 0%, #ff0\n 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n }\n\n .hue-vertical {\n background: linear-gradient(to top, #f00 0%, #ff0 17%, #0f0 33%,\n #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n background: -webkit-linear-gradient(to top, #f00 0%, #ff0 17%,\n #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\n }\n "), /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
className: "hue-".concat(direction),
|
|
102
|
+
style: styles.container,
|
|
103
|
+
ref: function ref(container) {
|
|
104
|
+
return _this2.container = container;
|
|
105
|
+
},
|
|
106
|
+
onMouseDown: this.handleMouseDown,
|
|
107
|
+
onTouchMove: this.handleChange,
|
|
108
|
+
onTouchStart: this.handleChange
|
|
109
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
style: styles.pointer
|
|
111
|
+
}, this.props.pointer ? /*#__PURE__*/React.createElement(this.props.pointer, this.props) : /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
style: styles.slider
|
|
113
|
+
}))));
|
|
114
|
+
}
|
|
115
|
+
}]);
|
|
116
|
+
return Hue;
|
|
117
|
+
}(PureComponent || Component);
|
|
118
|
+
export default Hue;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import reactCSS from 'reactcss';
|
|
4
|
+
import merge from 'lodash/merge';
|
|
5
|
+
export var Raised = function Raised(_ref) {
|
|
6
|
+
var zDepth = _ref.zDepth,
|
|
7
|
+
radius = _ref.radius,
|
|
8
|
+
background = _ref.background,
|
|
9
|
+
children = _ref.children,
|
|
10
|
+
_ref$styles = _ref.styles,
|
|
11
|
+
passedStyles = _ref$styles === void 0 ? {} : _ref$styles;
|
|
12
|
+
var styles = reactCSS(merge({
|
|
13
|
+
'default': {
|
|
14
|
+
wrap: {
|
|
15
|
+
position: 'relative',
|
|
16
|
+
display: 'inline-block'
|
|
17
|
+
},
|
|
18
|
+
content: {
|
|
19
|
+
position: 'relative'
|
|
20
|
+
},
|
|
21
|
+
bg: {
|
|
22
|
+
absolute: '0px 0px 0px 0px',
|
|
23
|
+
boxShadow: "0 ".concat(zDepth, "px ").concat(zDepth * 4, "px rgba(0,0,0,.24)"),
|
|
24
|
+
borderRadius: radius,
|
|
25
|
+
background: background
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
'zDepth-0': {
|
|
29
|
+
bg: {
|
|
30
|
+
boxShadow: 'none'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
'zDepth-1': {
|
|
34
|
+
bg: {
|
|
35
|
+
boxShadow: '0 2px 10px rgba(0,0,0,.12), 0 2px 5px rgba(0,0,0,.16)'
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
'zDepth-2': {
|
|
39
|
+
bg: {
|
|
40
|
+
boxShadow: '0 6px 20px rgba(0,0,0,.19), 0 8px 17px rgba(0,0,0,.2)'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
'zDepth-3': {
|
|
44
|
+
bg: {
|
|
45
|
+
boxShadow: '0 17px 50px rgba(0,0,0,.19), 0 12px 15px rgba(0,0,0,.24)'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
'zDepth-4': {
|
|
49
|
+
bg: {
|
|
50
|
+
boxShadow: '0 25px 55px rgba(0,0,0,.21), 0 16px 28px rgba(0,0,0,.22)'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
'zDepth-5': {
|
|
54
|
+
bg: {
|
|
55
|
+
boxShadow: '0 40px 77px rgba(0,0,0,.22), 0 27px 24px rgba(0,0,0,.2)'
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
'square': {
|
|
59
|
+
bg: {
|
|
60
|
+
borderRadius: '0'
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
'circle': {
|
|
64
|
+
bg: {
|
|
65
|
+
borderRadius: '50%'
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, passedStyles), {
|
|
69
|
+
'zDepth-1': zDepth === 1
|
|
70
|
+
});
|
|
71
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
72
|
+
style: styles.wrap
|
|
73
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
style: styles.bg
|
|
75
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
style: styles.content
|
|
77
|
+
}, children));
|
|
78
|
+
};
|
|
79
|
+
Raised.propTypes = {
|
|
80
|
+
background: PropTypes.string,
|
|
81
|
+
zDepth: PropTypes.oneOf([0, 1, 2, 3, 4, 5]),
|
|
82
|
+
radius: PropTypes.number,
|
|
83
|
+
styles: PropTypes.object
|
|
84
|
+
};
|
|
85
|
+
Raised.defaultProps = {
|
|
86
|
+
background: '#fff',
|
|
87
|
+
zDepth: 1,
|
|
88
|
+
radius: 2,
|
|
89
|
+
styles: {}
|
|
90
|
+
};
|
|
91
|
+
export default Raised;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
6
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
7
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
8
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
9
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
10
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
11
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
import React, { Component, PureComponent } from 'react';
|
|
16
|
+
import reactCSS from 'reactcss';
|
|
17
|
+
import throttle from 'lodash/throttle';
|
|
18
|
+
import * as saturation from '../../helpers/saturation';
|
|
19
|
+
export var Saturation = /*#__PURE__*/function (_ref) {
|
|
20
|
+
_inherits(Saturation, _ref);
|
|
21
|
+
function Saturation(props) {
|
|
22
|
+
var _this;
|
|
23
|
+
_classCallCheck(this, Saturation);
|
|
24
|
+
_this = _callSuper(this, Saturation, [props]);
|
|
25
|
+
_defineProperty(_assertThisInitialized(_this), "handleChange", function (e) {
|
|
26
|
+
typeof _this.props.onChange === 'function' && _this.throttle(_this.props.onChange, saturation.calculateChange(e, _this.props.hsl, _this.container), e);
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseDown", function (e) {
|
|
29
|
+
_this.handleChange(e);
|
|
30
|
+
var renderWindow = _this.getContainerRenderWindow();
|
|
31
|
+
renderWindow.addEventListener('mousemove', _this.handleChange);
|
|
32
|
+
renderWindow.addEventListener('mouseup', _this.handleMouseUp);
|
|
33
|
+
});
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "handleMouseUp", function () {
|
|
35
|
+
_this.unbindEventListeners();
|
|
36
|
+
});
|
|
37
|
+
_this.throttle = throttle(function (fn, data, e) {
|
|
38
|
+
fn(data, e);
|
|
39
|
+
}, 50);
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
_createClass(Saturation, [{
|
|
43
|
+
key: "componentWillUnmount",
|
|
44
|
+
value: function componentWillUnmount() {
|
|
45
|
+
this.throttle.cancel();
|
|
46
|
+
this.unbindEventListeners();
|
|
47
|
+
}
|
|
48
|
+
}, {
|
|
49
|
+
key: "getContainerRenderWindow",
|
|
50
|
+
value: function getContainerRenderWindow() {
|
|
51
|
+
var container = this.container;
|
|
52
|
+
var renderWindow = window;
|
|
53
|
+
while (!renderWindow.document.contains(container) && renderWindow.parent !== renderWindow) {
|
|
54
|
+
renderWindow = renderWindow.parent;
|
|
55
|
+
}
|
|
56
|
+
return renderWindow;
|
|
57
|
+
}
|
|
58
|
+
}, {
|
|
59
|
+
key: "unbindEventListeners",
|
|
60
|
+
value: function unbindEventListeners() {
|
|
61
|
+
var renderWindow = this.getContainerRenderWindow();
|
|
62
|
+
renderWindow.removeEventListener('mousemove', this.handleChange);
|
|
63
|
+
renderWindow.removeEventListener('mouseup', this.handleMouseUp);
|
|
64
|
+
}
|
|
65
|
+
}, {
|
|
66
|
+
key: "render",
|
|
67
|
+
value: function render() {
|
|
68
|
+
var _this2 = this;
|
|
69
|
+
var _ref2 = this.props.style || {},
|
|
70
|
+
color = _ref2.color,
|
|
71
|
+
white = _ref2.white,
|
|
72
|
+
black = _ref2.black,
|
|
73
|
+
pointer = _ref2.pointer,
|
|
74
|
+
circle = _ref2.circle;
|
|
75
|
+
var styles = reactCSS({
|
|
76
|
+
'default': {
|
|
77
|
+
color: {
|
|
78
|
+
absolute: '0px 0px 0px 0px',
|
|
79
|
+
background: "hsl(".concat(this.props.hsl.h, ",100%, 50%)"),
|
|
80
|
+
borderRadius: this.props.radius
|
|
81
|
+
},
|
|
82
|
+
white: {
|
|
83
|
+
absolute: '0px 0px 0px 0px',
|
|
84
|
+
borderRadius: this.props.radius
|
|
85
|
+
},
|
|
86
|
+
black: {
|
|
87
|
+
absolute: '0px 0px 0px 0px',
|
|
88
|
+
boxShadow: this.props.shadow,
|
|
89
|
+
borderRadius: this.props.radius
|
|
90
|
+
},
|
|
91
|
+
pointer: {
|
|
92
|
+
position: 'absolute',
|
|
93
|
+
top: "".concat(-(this.props.hsv.v * 100) + 100, "%"),
|
|
94
|
+
left: "".concat(this.props.hsv.s * 100, "%"),
|
|
95
|
+
cursor: 'default'
|
|
96
|
+
},
|
|
97
|
+
circle: {
|
|
98
|
+
width: '4px',
|
|
99
|
+
height: '4px',
|
|
100
|
+
boxShadow: "0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0,0,0,.3),\n 0 0 1px 2px rgba(0,0,0,.4)",
|
|
101
|
+
borderRadius: '50%',
|
|
102
|
+
cursor: 'hand',
|
|
103
|
+
transform: 'translate(-2px, -2px)'
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
'custom': {
|
|
107
|
+
color: color,
|
|
108
|
+
white: white,
|
|
109
|
+
black: black,
|
|
110
|
+
pointer: pointer,
|
|
111
|
+
circle: circle
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
'custom': !!this.props.style
|
|
115
|
+
});
|
|
116
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
117
|
+
style: styles.color,
|
|
118
|
+
ref: function ref(container) {
|
|
119
|
+
return _this2.container = container;
|
|
120
|
+
},
|
|
121
|
+
onMouseDown: this.handleMouseDown,
|
|
122
|
+
onTouchMove: this.handleChange,
|
|
123
|
+
onTouchStart: this.handleChange
|
|
124
|
+
}, /*#__PURE__*/React.createElement("style", null, "\n .saturation-white {\n background: -webkit-linear-gradient(to right, #fff, rgba(255,255,255,0));\n background: linear-gradient(to right, #fff, rgba(255,255,255,0));\n }\n .saturation-black {\n background: -webkit-linear-gradient(to top, #000, rgba(0,0,0,0));\n background: linear-gradient(to top, #000, rgba(0,0,0,0));\n }\n "), /*#__PURE__*/React.createElement("div", {
|
|
125
|
+
style: styles.white,
|
|
126
|
+
className: "saturation-white"
|
|
127
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
128
|
+
style: styles.black,
|
|
129
|
+
className: "saturation-black"
|
|
130
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
131
|
+
style: styles.pointer
|
|
132
|
+
}, this.props.pointer ? /*#__PURE__*/React.createElement(this.props.pointer, this.props) : /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
style: styles.circle
|
|
134
|
+
}))));
|
|
135
|
+
}
|
|
136
|
+
}]);
|
|
137
|
+
return Saturation;
|
|
138
|
+
}(PureComponent || Component);
|
|
139
|
+
export default Saturation;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import reactCSS from 'reactcss';
|
|
10
|
+
import { handleFocus } from '../../helpers/interaction';
|
|
11
|
+
import Checkboard from './Checkboard';
|
|
12
|
+
var ENTER = 13;
|
|
13
|
+
export var Swatch = function Swatch(_ref) {
|
|
14
|
+
var color = _ref.color,
|
|
15
|
+
style = _ref.style,
|
|
16
|
+
_ref$onClick = _ref.onClick,
|
|
17
|
+
onClick = _ref$onClick === void 0 ? function () {} : _ref$onClick,
|
|
18
|
+
onHover = _ref.onHover,
|
|
19
|
+
_ref$title = _ref.title,
|
|
20
|
+
title = _ref$title === void 0 ? color : _ref$title,
|
|
21
|
+
children = _ref.children,
|
|
22
|
+
focus = _ref.focus,
|
|
23
|
+
_ref$focusStyle = _ref.focusStyle,
|
|
24
|
+
focusStyle = _ref$focusStyle === void 0 ? {} : _ref$focusStyle;
|
|
25
|
+
var transparent = color === 'transparent';
|
|
26
|
+
var styles = reactCSS({
|
|
27
|
+
"default": {
|
|
28
|
+
swatch: _objectSpread(_objectSpread({
|
|
29
|
+
background: color,
|
|
30
|
+
height: '100%',
|
|
31
|
+
width: '100%',
|
|
32
|
+
cursor: 'pointer',
|
|
33
|
+
position: 'relative',
|
|
34
|
+
outline: 'none'
|
|
35
|
+
}, style), focus ? focusStyle : {})
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
var handleClick = function handleClick(e) {
|
|
39
|
+
return onClick(color, e);
|
|
40
|
+
};
|
|
41
|
+
var handleKeyDown = function handleKeyDown(e) {
|
|
42
|
+
return e.keyCode === ENTER && onClick(color, e);
|
|
43
|
+
};
|
|
44
|
+
var handleHover = function handleHover(e) {
|
|
45
|
+
return onHover(color, e);
|
|
46
|
+
};
|
|
47
|
+
var optionalEvents = {};
|
|
48
|
+
if (onHover) {
|
|
49
|
+
optionalEvents.onMouseOver = handleHover;
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/React.createElement("div", _extends({
|
|
52
|
+
style: styles.swatch,
|
|
53
|
+
onClick: handleClick,
|
|
54
|
+
title: title,
|
|
55
|
+
tabIndex: 0,
|
|
56
|
+
onKeyDown: handleKeyDown
|
|
57
|
+
}, optionalEvents), children, transparent && /*#__PURE__*/React.createElement(Checkboard, {
|
|
58
|
+
borderRadius: styles.swatch.borderRadius,
|
|
59
|
+
boxShadow: "inset 0 0 0 1px rgba(0,0,0,0.1)"
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
export default handleFocus(Swatch);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as Alpha } from './Alpha';
|
|
2
|
+
export { default as Checkboard } from './Checkboard';
|
|
3
|
+
export { default as EditableInput } from './EditableInput';
|
|
4
|
+
export { default as Hue } from './Hue';
|
|
5
|
+
export { default as Raised } from './Raised';
|
|
6
|
+
export { default as Saturation } from './Saturation';
|
|
7
|
+
export { default as ColorWrap } from './ColorWrap';
|
|
8
|
+
export { default as Swatch } from './Swatch';
|