@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.
Files changed (30) hide show
  1. package/lib/Affix/index.js +3 -0
  2. package/lib/CWMessage/MessageContent/TabList/index.js +3 -3
  3. package/lib/CWMessage/MessageContent/index.js +6 -6
  4. package/lib/CWMessage/index.js +72 -92
  5. package/lib/ColorPicker/SketchPicker/components/common/Alpha.js +133 -0
  6. package/lib/ColorPicker/SketchPicker/components/common/Checkboard.js +40 -0
  7. package/lib/ColorPicker/SketchPicker/components/common/ColorWrap.js +80 -0
  8. package/lib/ColorPicker/SketchPicker/components/common/EditableInput.js +172 -0
  9. package/lib/ColorPicker/SketchPicker/components/common/Hue.js +118 -0
  10. package/lib/ColorPicker/SketchPicker/components/common/Raised.js +91 -0
  11. package/lib/ColorPicker/SketchPicker/components/common/Saturation.js +139 -0
  12. package/lib/ColorPicker/SketchPicker/components/common/Swatch.js +62 -0
  13. package/lib/ColorPicker/SketchPicker/components/common/index.js +8 -0
  14. package/lib/ColorPicker/SketchPicker/components/sketch/SketchFields.js +148 -0
  15. package/lib/ColorPicker/SketchPicker/components/sketch/SketchPresetColors.js +72 -0
  16. package/lib/ColorPicker/SketchPicker/components/sketch/index.js +160 -0
  17. package/lib/ColorPicker/SketchPicker/helpers/alpha.js +46 -0
  18. package/lib/ColorPicker/SketchPicker/helpers/checkboard.js +29 -0
  19. package/lib/ColorPicker/SketchPicker/helpers/color.js +86 -0
  20. package/lib/ColorPicker/SketchPicker/helpers/hue.js +48 -0
  21. package/lib/ColorPicker/SketchPicker/helpers/index.js +2 -0
  22. package/lib/ColorPicker/SketchPicker/helpers/interaction.js +55 -0
  23. package/lib/ColorPicker/SketchPicker/helpers/saturation.js +28 -0
  24. package/lib/ColorPicker/index.js +2 -3
  25. package/lib/ErrorBoundary/history.js +51 -51
  26. package/lib/ErrorBoundary/index.js +3 -2
  27. package/lib/QuickTransfer/Drag.js +4 -2
  28. package/lib/QuickTransfer/DragList.js +27 -4
  29. package/lib/QuickTransfer/index.js +12 -5
  30. package/package.json +1 -2
@@ -0,0 +1,3 @@
1
+ import "antd/es/affix/style";
2
+ import _Affix from "antd/es/affix";
3
+ export default _Affix;
@@ -13,7 +13,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
13
13
  import React from "react";
14
14
  import moment from "moment";
15
15
  import { readInnerMessageApi } from "../../service";
16
- import langConfig from '../../locale';
16
+ import langConfig from "../../locale";
17
17
  import { formatMessage } from "../../../utils";
18
18
  import "./index.less";
19
19
  var TabList = function TabList(props) {
@@ -63,9 +63,9 @@ var TabList = function TabList(props) {
63
63
  return _regeneratorRuntime().wrap(function _callee$(_context) {
64
64
  while (1) switch (_context.prev = _context.next) {
65
65
  case 0:
66
- resRequestApi = _readInnerMessageApi ? _readInnerMessageApi(params) : readInnerMessageApi(params, gatewayPrefix);
66
+ resRequestApi = _readInnerMessageApi || readInnerMessageApi;
67
67
  _context.next = 3;
68
- return resRequestApi;
68
+ return resRequestApi(params, gatewayPrefix);
69
69
  case 3:
70
70
  res = _context.sent;
71
71
  if (res.status == "success") {
@@ -89,9 +89,9 @@ var MessageContent = function MessageContent(props) {
89
89
  return _regeneratorRuntime().wrap(function _callee$(_context) {
90
90
  while (1) switch (_context.prev = _context.next) {
91
91
  case 0:
92
- resRequestApi = _getMessageTypeApi ? _getMessageTypeApi() : getMessageTypeApi(gatewayPrefix);
92
+ resRequestApi = _getMessageTypeApi || getMessageTypeApi;
93
93
  _context.next = 3;
94
- return resRequestApi;
94
+ return resRequestApi(gatewayPrefix);
95
95
  case 3:
96
96
  res = _context.sent;
97
97
  if (res && res.status == "success") {
@@ -123,9 +123,9 @@ var MessageContent = function MessageContent(props) {
123
123
  case 0:
124
124
  setLoading(true);
125
125
  conditionsRef.current = _objectSpread(_objectSpread({}, conditionsRef.current), params);
126
- resRequestApi = _getMessageListApi ? _getMessageListApi(conditionsRef.current) : getMessageListApi(conditionsRef.current, gatewayPrefix);
126
+ resRequestApi = _getMessageListApi || getMessageListApi;
127
127
  _context2.next = 5;
128
- return resRequestApi;
128
+ return resRequestApi(conditionsRef.current, gatewayPrefix);
129
129
  case 5:
130
130
  res = _context2.sent;
131
131
  if (res && res.status == "success") {
@@ -151,9 +151,9 @@ var MessageContent = function MessageContent(props) {
151
151
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
152
152
  while (1) switch (_context3.prev = _context3.next) {
153
153
  case 0:
154
- resRequestApi = _getMessageUnreadCountApi ? _getMessageUnreadCountApi() : getMessageUnreadCountApi(gatewayPrefix);
154
+ resRequestApi = _getMessageUnreadCountApi || getMessageUnreadCountApi;
155
155
  _context3.next = 3;
156
- return resRequestApi;
156
+ return resRequestApi(gatewayPrefix);
157
157
  case 3:
158
158
  res = _context3.sent;
159
159
  if (res && res.status == "success") {
@@ -91,6 +91,8 @@ function Message(props) {
91
91
  setTotal = _useState6[1];
92
92
  // 保存消息配置
93
93
  var messageOptionRef = useRef({});
94
+ // 获取socket信息
95
+ var socketConnectInfo = useRef();
94
96
  // 分页配置初始化
95
97
  var _useState7 = useState({
96
98
  current: 1,
@@ -113,6 +115,11 @@ function Message(props) {
113
115
  top: headerHeight,
114
116
  maxCount: 1
115
117
  });
118
+ return function () {
119
+ if (socketConnectInfo.current) {
120
+ socketConnectInfo.current.disconnect && socketConnectInfo.current.disconnect();
121
+ }
122
+ };
116
123
  }, []);
117
124
  useEffect(function () {
118
125
  setPageInfo(function (pre) {
@@ -152,9 +159,9 @@ function Message(props) {
152
159
  userMessageId: id,
153
160
  clientType: "BROWSER"
154
161
  };
155
- resRequestApi = _getMessageDetailApi ? _getMessageDetailApi(params) : getMessageDetailApi(params, gatewayPrefix);
162
+ resRequestApi = _getMessageDetailApi || getMessageDetailApi;
156
163
  _context.next = 4;
157
- return resRequestApi;
164
+ return resRequestApi(params, gatewayPrefix);
158
165
  case 4:
159
166
  res = _context.sent;
160
167
  if (res && res.status == "success") {
@@ -190,24 +197,13 @@ function Message(props) {
190
197
  }();
191
198
  var readInnerMessage = /*#__PURE__*/function () {
192
199
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(params) {
193
- var resRequestApi, res;
200
+ var resRequestApi;
194
201
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
195
202
  while (1) switch (_context2.prev = _context2.next) {
196
203
  case 0:
197
- resRequestApi = _readInnerMessageApi ? _readInnerMessageApi(params) : readInnerMessageApi(params, gatewayPrefix);
198
- _context2.next = 3;
199
- return resRequestApi;
200
- case 3:
201
- res = _context2.sent;
202
- if (res.status == "success") {
203
- // if (pageInfo.current > 1 && dataSource.length === 1) {
204
- // let _params = { current: pageInfo.current - 1 };
205
- // setPageInfo((pre) => ({ ...pre, current: pre.current - 1 }));
206
- // conditionsRef.current = { ...conditionsRef.current, ..._params };
207
- // }
208
- // 已读消息
209
- }
210
- case 5:
204
+ resRequestApi = _readInnerMessageApi || readInnerMessageApi;
205
+ resRequestApi(params, gatewayPrefix);
206
+ case 2:
211
207
  case "end":
212
208
  return _context2.stop();
213
209
  }
@@ -217,19 +213,47 @@ function Message(props) {
217
213
  return _ref3.apply(this, arguments);
218
214
  };
219
215
  }();
216
+ var getSocketPostMessage = function getSocketPostMessage(data) {
217
+ var _JSON$parse = JSON.parse(data),
218
+ count = _JSON$parse.count,
219
+ message = _JSON$parse.message;
220
+ var _ref4 = count || {},
221
+ _ref4$total = _ref4.total,
222
+ total = _ref4$total === void 0 ? 0 : _ref4$total;
223
+ setMessageTotal(total);
224
+ onSocketChange(JSON.parse(data));
225
+ if (message) {
226
+ var noticeMessage = message.noticeMessage;
227
+ if (noticeMessage) {
228
+ var userMessageId = noticeMessage.id,
229
+ type = noticeMessage.type;
230
+ if (userMessageId) {
231
+ var _ref5 = messageOptionRef.current[type] || {},
232
+ enable = _ref5.enable,
233
+ mode = _ref5.mode,
234
+ _ref5$time = _ref5.time,
235
+ time = _ref5$time === void 0 ? 5 : _ref5$time;
236
+ if (enable) {
237
+ openNotification(time, userMessageId);
238
+ }
239
+ }
240
+ }
241
+ }
242
+ };
220
243
  var connectSocket = /*#__PURE__*/function () {
221
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
244
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
222
245
  var resRequestApi, res, finalOrigin, socket;
223
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
224
- while (1) switch (_context5.prev = _context5.next) {
246
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
247
+ while (1) switch (_context3.prev = _context3.next) {
225
248
  case 0:
226
- resRequestApi = _getSessionId ? _getSessionId() : getSessionId(gatewayPrefix);
227
- _context5.next = 3;
228
- return resRequestApi;
249
+ // 获取sessionId
250
+ resRequestApi = _getSessionId || getSessionId;
251
+ _context3.next = 3;
252
+ return resRequestApi(gatewayPrefix);
229
253
  case 3:
230
- res = _context5.sent;
254
+ res = _context3.sent;
231
255
  if (res && res.status == "success") {
232
- finalOrigin = socketOrigin ? socketOrigin : "ws://".concat(window.location.host);
256
+ finalOrigin = socketOrigin || "ws://".concat(window.location.host); // 连接到后端socket服务器
233
257
  socket = io(finalOrigin, {
234
258
  transports: ["websocket"],
235
259
  path: "".concat(socketPathPrefix, "/message/socket.io"),
@@ -237,95 +261,51 @@ function Message(props) {
237
261
  sessionId: res.data,
238
262
  clientType: "BROWSER"
239
263
  }
240
- });
241
- socket.on("push", /*#__PURE__*/function () {
242
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(data) {
243
- var _JSON$parse, count, message, _ref6, _ref6$total, total, noticeMessage, userMessageId, type, _ref7, enable, mode, _ref7$time, time;
244
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
245
- while (1) switch (_context3.prev = _context3.next) {
246
- case 0:
247
- _JSON$parse = JSON.parse(data), count = _JSON$parse.count, message = _JSON$parse.message;
248
- _ref6 = count || {}, _ref6$total = _ref6.total, total = _ref6$total === void 0 ? 0 : _ref6$total;
249
- setMessageTotal(total);
250
- onSocketChange(JSON.parse(data));
251
- if (message) {
252
- noticeMessage = message.noticeMessage;
253
- if (noticeMessage) {
254
- userMessageId = noticeMessage.id, type = noticeMessage.type;
255
- if (userMessageId) {
256
- _ref7 = messageOptionRef.current[type] || {}, enable = _ref7.enable, mode = _ref7.mode, _ref7$time = _ref7.time, time = _ref7$time === void 0 ? 5 : _ref7$time;
257
- if (enable) {
258
- openNotification(time, userMessageId);
259
- }
260
- }
261
- }
262
- }
263
- case 5:
264
- case "end":
265
- return _context3.stop();
266
- }
267
- }, _callee3);
268
- }));
269
- return function (_x4) {
270
- return _ref5.apply(this, arguments);
271
- };
272
- }());
264
+ }); // 记录socket连接信息,用于关闭socket连接
265
+ socketConnectInfo.current = socket;
266
+ // 监听从服务器传来的消息
267
+ socket.on("push", getSocketPostMessage);
273
268
  // socket重连
274
- socket.on("reconnect_attempt", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
275
- var res;
276
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
277
- while (1) switch (_context4.prev = _context4.next) {
278
- case 0:
279
- _context4.next = 2;
280
- return resRequestApi;
281
- case 2:
282
- res = _context4.sent;
283
- if (res && res.status == "success") {
284
- socket.io.opts.query = {
285
- sessionId: res.data,
286
- clientType: "BROWSER"
287
- };
288
- }
289
- case 4:
290
- case "end":
291
- return _context4.stop();
292
- }
293
- }, _callee4);
294
- })));
269
+ socket.on("reconnect_attempt", function () {
270
+ socket.io.opts.query = {
271
+ sessionId: res.data,
272
+ clientType: "BROWSER"
273
+ };
274
+ });
295
275
  }
296
276
  case 5:
297
277
  case "end":
298
- return _context5.stop();
278
+ return _context3.stop();
299
279
  }
300
- }, _callee5);
280
+ }, _callee3);
301
281
  }));
302
282
  return function connectSocket() {
303
- return _ref4.apply(this, arguments);
283
+ return _ref6.apply(this, arguments);
304
284
  };
305
285
  }();
306
286
  var getMessageQuerySettings = /*#__PURE__*/function () {
307
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
287
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
308
288
  var resRequestApi, res, data;
309
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
310
- while (1) switch (_context6.prev = _context6.next) {
289
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
290
+ while (1) switch (_context4.prev = _context4.next) {
311
291
  case 0:
312
- resRequestApi = _getMessageQuerySettingsApi ? _getMessageQuerySettingsApi() : getMessageQuerySettingsApi(gatewayPrefix);
313
- _context6.next = 3;
314
- return resRequestApi;
292
+ resRequestApi = _getMessageQuerySettingsApi || getMessageQuerySettingsApi;
293
+ _context4.next = 3;
294
+ return resRequestApi(gatewayPrefix);
315
295
  case 3:
316
- res = _context6.sent;
296
+ res = _context4.sent;
317
297
  if (res && res.status === "success") {
318
298
  data = res.data;
319
299
  messageOptionRef.current = data || {};
320
300
  }
321
301
  case 5:
322
302
  case "end":
323
- return _context6.stop();
303
+ return _context4.stop();
324
304
  }
325
- }, _callee6);
305
+ }, _callee4);
326
306
  }));
327
307
  return function getMessageQuerySettings() {
328
- return _ref9.apply(this, arguments);
308
+ return _ref7.apply(this, arguments);
329
309
  };
330
310
  }();
331
311
  return /*#__PURE__*/React.createElement("div", {
@@ -0,0 +1,133 @@
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 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; }
3
+ 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; }
4
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
5
+ 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); } }
6
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
7
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
+ 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); }
9
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
10
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
11
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
+ 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); }
13
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
+ 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; }
15
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
+ 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); }
17
+ import React, { Component, PureComponent } from 'react';
18
+ import reactCSS from 'reactcss';
19
+ import * as alpha from '../../helpers/alpha';
20
+ import Checkboard from './Checkboard';
21
+ export var Alpha = /*#__PURE__*/function (_ref) {
22
+ _inherits(Alpha, _ref);
23
+ function Alpha() {
24
+ var _this;
25
+ _classCallCheck(this, Alpha);
26
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
+ args[_key] = arguments[_key];
28
+ }
29
+ _this = _callSuper(this, Alpha, [].concat(args));
30
+ _defineProperty(_assertThisInitialized(_this), "handleChange", function (e) {
31
+ var change = alpha.calculateChange(e, _this.props.hsl, _this.props.direction, _this.props.a, _this.container);
32
+ change && typeof _this.props.onChange === 'function' && _this.props.onChange(change, e);
33
+ });
34
+ _defineProperty(_assertThisInitialized(_this), "handleMouseDown", function (e) {
35
+ _this.handleChange(e);
36
+ window.addEventListener('mousemove', _this.handleChange);
37
+ window.addEventListener('mouseup', _this.handleMouseUp);
38
+ });
39
+ _defineProperty(_assertThisInitialized(_this), "handleMouseUp", function () {
40
+ _this.unbindEventListeners();
41
+ });
42
+ _defineProperty(_assertThisInitialized(_this), "unbindEventListeners", function () {
43
+ window.removeEventListener('mousemove', _this.handleChange);
44
+ window.removeEventListener('mouseup', _this.handleMouseUp);
45
+ });
46
+ return _this;
47
+ }
48
+ _createClass(Alpha, [{
49
+ key: "componentWillUnmount",
50
+ value: function componentWillUnmount() {
51
+ this.unbindEventListeners();
52
+ }
53
+ }, {
54
+ key: "render",
55
+ value: function render() {
56
+ var _this2 = this;
57
+ var rgb = this.props.rgb;
58
+ var styles = reactCSS({
59
+ 'default': {
60
+ alpha: {
61
+ absolute: '0px 0px 0px 0px',
62
+ borderRadius: this.props.radius
63
+ },
64
+ checkboard: {
65
+ absolute: '0px 0px 0px 0px',
66
+ overflow: 'hidden',
67
+ borderRadius: this.props.radius
68
+ },
69
+ gradient: {
70
+ absolute: '0px 0px 0px 0px',
71
+ background: "linear-gradient(to right, rgba(".concat(rgb.r, ",").concat(rgb.g, ",").concat(rgb.b, ", 0) 0%,\n rgba(").concat(rgb.r, ",").concat(rgb.g, ",").concat(rgb.b, ", 1) 100%)"),
72
+ boxShadow: this.props.shadow,
73
+ borderRadius: this.props.radius
74
+ },
75
+ container: {
76
+ position: 'relative',
77
+ height: '100%',
78
+ margin: '0 3px'
79
+ },
80
+ pointer: {
81
+ position: 'absolute',
82
+ left: "".concat(rgb.a * 100, "%")
83
+ },
84
+ slider: {
85
+ width: '4px',
86
+ borderRadius: '1px',
87
+ height: '8px',
88
+ boxShadow: '0 0 2px rgba(0, 0, 0, .6)',
89
+ background: '#fff',
90
+ marginTop: '1px',
91
+ transform: 'translateX(-2px)'
92
+ }
93
+ },
94
+ 'vertical': {
95
+ gradient: {
96
+ background: "linear-gradient(to bottom, rgba(".concat(rgb.r, ",").concat(rgb.g, ",").concat(rgb.b, ", 0) 0%,\n rgba(").concat(rgb.r, ",").concat(rgb.g, ",").concat(rgb.b, ", 1) 100%)")
97
+ },
98
+ pointer: {
99
+ left: 0,
100
+ top: "".concat(rgb.a * 100, "%")
101
+ }
102
+ },
103
+ 'overwrite': _objectSpread({}, this.props.style)
104
+ }, {
105
+ vertical: this.props.direction === 'vertical',
106
+ overwrite: true
107
+ });
108
+ return /*#__PURE__*/React.createElement("div", {
109
+ style: styles.alpha
110
+ }, /*#__PURE__*/React.createElement("div", {
111
+ style: styles.checkboard
112
+ }, /*#__PURE__*/React.createElement(Checkboard, {
113
+ renderers: this.props.renderers
114
+ })), /*#__PURE__*/React.createElement("div", {
115
+ style: styles.gradient
116
+ }), /*#__PURE__*/React.createElement("div", {
117
+ style: styles.container,
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("div", {
125
+ style: styles.pointer
126
+ }, this.props.pointer ? /*#__PURE__*/React.createElement(this.props.pointer, this.props) : /*#__PURE__*/React.createElement("div", {
127
+ style: styles.slider
128
+ }))));
129
+ }
130
+ }]);
131
+ return Alpha;
132
+ }(PureComponent || Component);
133
+ export default Alpha;
@@ -0,0 +1,40 @@
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 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; }
3
+ 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; }
4
+ 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; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ import React, { isValidElement } from 'react';
8
+ import reactCSS from 'reactcss';
9
+ import * as checkboard from '../../helpers/checkboard';
10
+ export var Checkboard = function Checkboard(_ref) {
11
+ var white = _ref.white,
12
+ grey = _ref.grey,
13
+ size = _ref.size,
14
+ renderers = _ref.renderers,
15
+ borderRadius = _ref.borderRadius,
16
+ boxShadow = _ref.boxShadow,
17
+ children = _ref.children;
18
+ var styles = reactCSS({
19
+ 'default': {
20
+ grid: {
21
+ borderRadius: borderRadius,
22
+ boxShadow: boxShadow,
23
+ absolute: '0px 0px 0px 0px',
24
+ background: "url(".concat(checkboard.get(white, grey, size, renderers.canvas), ") center left")
25
+ }
26
+ }
27
+ });
28
+ return /*#__PURE__*/isValidElement(children) ? /*#__PURE__*/React.cloneElement(children, _objectSpread(_objectSpread({}, children.props), {}, {
29
+ style: _objectSpread(_objectSpread({}, children.props.style), styles.grid)
30
+ })) : /*#__PURE__*/React.createElement("div", {
31
+ style: styles.grid
32
+ });
33
+ };
34
+ Checkboard.defaultProps = {
35
+ size: 8,
36
+ white: 'transparent',
37
+ grey: 'rgba(0,0,0,.08)',
38
+ renderers: {}
39
+ };
40
+ export default Checkboard;
@@ -0,0 +1,80 @@
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
+ 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); } }
7
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
8
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
9
+ 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); }
10
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
11
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
12
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
13
+ 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); }
14
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
15
+ 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; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ 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); }
18
+ import React, { Component, PureComponent } from 'react';
19
+ import debounce from 'lodash/debounce';
20
+ import * as color from '../../helpers/color';
21
+ export var ColorWrap = function ColorWrap(Picker) {
22
+ var ColorPicker = /*#__PURE__*/function (_ref) {
23
+ _inherits(ColorPicker, _ref);
24
+ function ColorPicker(props) {
25
+ var _this;
26
+ _classCallCheck(this, ColorPicker);
27
+ _this = _callSuper(this, ColorPicker);
28
+ // static getDerivedStateFromProps(nextProps, state) {
29
+ // return {
30
+ // ...color.toState(nextProps.color, state.oldHue),
31
+ // }
32
+ // }
33
+ _defineProperty(_assertThisInitialized(_this), "handleChange", function (data, event) {
34
+ var isValidColor = color.simpleCheckForValidColor(data);
35
+ if (isValidColor) {
36
+ var colors = color.toState(data, data.h || _this.state.oldHue);
37
+ _this.setState(colors);
38
+ _this.props.onChangeComplete && _this.debounce(_this.props.onChangeComplete, colors, event);
39
+ _this.props.onChange && _this.props.onChange(colors, event);
40
+ }
41
+ });
42
+ _defineProperty(_assertThisInitialized(_this), "handleSwatchHover", function (data, event) {
43
+ var isValidColor = color.simpleCheckForValidColor(data);
44
+ if (isValidColor) {
45
+ var colors = color.toState(data, data.h || _this.state.oldHue);
46
+ _this.props.onSwatchHover && _this.props.onSwatchHover(colors, event);
47
+ }
48
+ });
49
+ _this.state = _objectSpread({}, color.toState(props.color, 0));
50
+ _this.debounce = debounce(function (fn, data, event) {
51
+ fn(data, event);
52
+ }, 100);
53
+ return _this;
54
+ }
55
+ _createClass(ColorPicker, [{
56
+ key: "render",
57
+ value: function render() {
58
+ var optionalEvents = {};
59
+ if (this.props.onSwatchHover) {
60
+ optionalEvents.onSwatchHover = this.handleSwatchHover;
61
+ }
62
+ return /*#__PURE__*/React.createElement(Picker, _extends({}, this.props, this.state, {
63
+ onChange: this.handleChange
64
+ }, optionalEvents));
65
+ }
66
+ }]);
67
+ return ColorPicker;
68
+ }(PureComponent || Component);
69
+ ColorPicker.propTypes = _objectSpread({}, Picker.propTypes);
70
+ ColorPicker.defaultProps = _objectSpread(_objectSpread({}, Picker.defaultProps), {}, {
71
+ color: {
72
+ h: 250,
73
+ s: 0.50,
74
+ l: 0.20,
75
+ a: 1
76
+ }
77
+ });
78
+ return ColorPicker;
79
+ };
80
+ export default ColorWrap;