@chaoswise/ui 2.3.13 → 2.3.14

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.
@@ -23,7 +23,7 @@
23
23
  @btn-warn-new: @red-6;
24
24
  @btn-warn-hover-new: @red-5;
25
25
  @btn-warn-focus-new: @red-7;
26
- @btn-disabled-primary-color: #97CDFF; // 主要按钮禁用背景色
26
+ @btn-disabled-primary-color: @primary-1; // #97CDFF; // 主要按钮禁用背景色
27
27
  @btn-disabled-group-primary-color: rgba(255, 255, 255, 0.45); // 主要按钮中组合按钮禁用状态下分割线色
28
28
 
29
29
  // Tag
@@ -139,4 +139,6 @@
139
139
  // 配合portal定制主题 -- develop分支需要
140
140
  @portal-header-search-border-color: #d8d8d8;
141
141
  @portal-header-search-bg: #173066;
142
- @portal-header-logo:#fff;
142
+ @portal-header-logo:#fff;
143
+
144
+ @form-back-font: #FFFFFF;
package/lib/Ace/ace.js CHANGED
@@ -11,11 +11,11 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
11
11
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
12
12
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
13
  function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
14
- import PropTypes from "prop-types";
15
- import React from "react";
16
- import { isEqual } from "lodash-es";
14
+ import PropTypes from 'prop-types';
15
+ import React from 'react';
16
+ import { isEqual } from 'lodash-es';
17
17
  import { Range } from '@chaoswise/ace';
18
- import { getAceInstance, editorEvents, debounce, editorOptions } from "./editorOptions";
18
+ import { getAceInstance, editorEvents, debounce, editorOptions } from './editorOptions';
19
19
  var ace = getAceInstance();
20
20
  var ReactAce = /*#__PURE__*/function (_React$Component) {
21
21
  _inherits(ReactAce, _React$Component);
@@ -35,7 +35,7 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
35
35
  value: function isInShadow(node) {
36
36
  var parent = node && node.parentNode;
37
37
  while (parent) {
38
- if (parent.toString() === "[object ShadowRoot]") {
38
+ if (parent.toString() === '[object ShadowRoot]') {
39
39
  return true;
40
40
  }
41
41
  parent = parent.parentNode;
@@ -82,36 +82,36 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
82
82
  if (this.isInShadow(this.refEditor)) {
83
83
  this.editor.renderer.attachToShadowRoot();
84
84
  }
85
- this.editor.getSession().setMode("ace/mode/".concat(mode));
86
- this.editor.setTheme("ace/theme/".concat(theme));
87
- this.editor.setFontSize(typeof fontSize === "number" ? "".concat(fontSize, "px") : fontSize);
88
- this.editor.getSession().setValue(!defaultValue ? value || "" : defaultValue);
85
+ this.editor.getSession().setMode(typeof mode === 'string' ? "ace/mode/".concat(mode) : mode);
86
+ if (theme && theme !== '') this.editor.setTheme("ace/theme/".concat(theme));
87
+ this.editor.setFontSize(typeof fontSize === 'number' ? "".concat(fontSize, "px") : fontSize);
88
+ this.editor.getSession().setValue(!defaultValue ? value || '' : defaultValue);
89
89
  if (this.props.navigateToFileEnd) {
90
90
  this.editor.navigateFileEnd();
91
91
  }
92
92
  this.editor.renderer.setShowGutter(showGutter);
93
93
  this.editor.getSession().setUseWrapMode(wrapEnabled);
94
94
  this.editor.setShowPrintMargin(showPrintMargin);
95
- this.editor.on("focus", this.onFocus);
96
- this.editor.on("blur", this.onBlur);
97
- this.editor.on("copy", this.onCopy);
98
- this.editor.on("paste", this.onPaste);
99
- this.editor.on("change", this.onChange);
100
- this.editor.on("input", this.onInput);
95
+ this.editor.on('focus', this.onFocus);
96
+ this.editor.on('blur', this.onBlur);
97
+ this.editor.on('copy', this.onCopy);
98
+ this.editor.on('paste', this.onPaste);
99
+ this.editor.on('change', this.onChange);
100
+ this.editor.on('input', this.onInput);
101
101
  if (placeholder) {
102
102
  this.updatePlaceholder();
103
103
  }
104
- this.editor.getSession().selection.on("changeSelection", this.onSelectionChange);
105
- this.editor.getSession().selection.on("changeCursor", this.onCursorChange);
104
+ this.editor.getSession().selection.on('changeSelection', this.onSelectionChange);
105
+ this.editor.getSession().selection.on('changeCursor', this.onCursorChange);
106
106
  if (onValidate) {
107
107
  // @ts-ignore types don't include
108
- this.editor.getSession().on("changeAnnotation", function () {
108
+ this.editor.getSession().on('changeAnnotation', function () {
109
109
  // tslint:disable-next-line:no-shadowed-variable
110
110
  var annotations = _this2.editor.getSession().getAnnotations();
111
111
  _this2.props.onValidate(annotations);
112
112
  });
113
113
  }
114
- this.editor.session.on("changeScrollTop", this.onScroll);
114
+ this.editor.session.on('changeScrollTop', this.onScroll);
115
115
  this.editor.getSession().setAnnotations(annotations || []);
116
116
  if (markers && markers.length > 0) {
117
117
  this.handleMarkers(markers);
@@ -129,7 +129,7 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
129
129
  this.handleOptions(this.props);
130
130
  if (Array.isArray(commands)) {
131
131
  commands.forEach(function (command) {
132
- if (typeof command.exec === "string") {
132
+ if (typeof command.exec === 'string') {
133
133
  _this2.editor.commands.bindKey(command.bindKey, command.exec);
134
134
  } else {
135
135
  _this2.editor.commands.addCommand(command);
@@ -137,10 +137,10 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
137
137
  });
138
138
  }
139
139
  if (keyboardHandler) {
140
- this.editor.setKeyboardHandler("ace/keyboard/" + keyboardHandler);
140
+ this.editor.setKeyboardHandler('ace/keyboard/' + keyboardHandler);
141
141
  }
142
142
  if (className) {
143
- this.refEditor.className += " " + className;
143
+ this.refEditor.className += ' ' + className;
144
144
  }
145
145
  if (onLoad) {
146
146
  onLoad(this.editor);
@@ -164,16 +164,17 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
164
164
  }
165
165
  if (nextProps.className !== oldProps.className) {
166
166
  var appliedClasses = this.refEditor.className;
167
- var appliedClassesArray = appliedClasses.trim().split(" ");
168
- var oldClassesArray = oldProps.className.trim().split(" ");
167
+ var appliedClassesArray = appliedClasses.trim().split(' ');
168
+ var oldClassesArray = oldProps.className.trim().split(' ');
169
169
  oldClassesArray.forEach(function (oldClass) {
170
170
  var index = appliedClassesArray.indexOf(oldClass);
171
171
  appliedClassesArray.splice(index, 1);
172
172
  });
173
- this.refEditor.className = " " + nextProps.className + " " + appliedClassesArray.join(" ");
173
+ this.refEditor.className = ' ' + nextProps.className + ' ' + appliedClassesArray.join(' ');
174
174
  }
175
175
  // First process editor value, as it may create a new session (see issue #300)
176
- if (this.editor && nextProps.value != null && this.editor.getValue() !== nextProps.value) {
176
+ var valueChanged = this.editor && nextProps.value != null && this.editor.getValue() !== nextProps.value;
177
+ if (valueChanged) {
177
178
  // editor.setValue is a synchronous function call, change event is emitted before setValue return.
178
179
  this.silent = true;
179
180
  var pos = this.editor.session.selection.toJSON();
@@ -185,20 +186,20 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
185
186
  this.updatePlaceholder();
186
187
  }
187
188
  if (nextProps.mode !== oldProps.mode) {
188
- this.editor.getSession().setMode("ace/mode/" + nextProps.mode);
189
+ this.editor.getSession().setMode(typeof nextProps.mode === 'string' ? "ace/mode/".concat(nextProps.mode) : nextProps.mode);
189
190
  }
190
191
  if (nextProps.theme !== oldProps.theme) {
191
- this.editor.setTheme("ace/theme/" + nextProps.theme);
192
+ this.editor.setTheme('ace/theme/' + nextProps.theme);
192
193
  }
193
194
  if (nextProps.keyboardHandler !== oldProps.keyboardHandler) {
194
195
  if (nextProps.keyboardHandler) {
195
- this.editor.setKeyboardHandler("ace/keyboard/" + nextProps.keyboardHandler);
196
+ this.editor.setKeyboardHandler('ace/keyboard/' + nextProps.keyboardHandler);
196
197
  } else {
197
198
  this.editor.setKeyboardHandler(null);
198
199
  }
199
200
  }
200
201
  if (nextProps.fontSize !== oldProps.fontSize) {
201
- this.editor.setFontSize(typeof nextProps.fontSize === "number" ? "".concat(nextProps.fontSize, "px") : nextProps.fontSize);
202
+ this.editor.setFontSize(typeof nextProps.fontSize === 'number' ? "".concat(nextProps.fontSize, "px") : nextProps.fontSize);
202
203
  }
203
204
  if (nextProps.wrapEnabled !== oldProps.wrapEnabled) {
204
205
  this.editor.getSession().setUseWrapMode(nextProps.wrapEnabled);
@@ -212,7 +213,9 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
212
213
  if (!isEqual(nextProps.setOptions, oldProps.setOptions)) {
213
214
  this.handleOptions(nextProps);
214
215
  }
215
- if (!isEqual(nextProps.annotations, oldProps.annotations)) {
216
+ // if the value or annotations changed, set the annotations
217
+ // changing the value may create a new session which will require annotations to be re-set
218
+ if (valueChanged || !isEqual(nextProps.annotations, oldProps.annotations)) {
216
219
  this.editor.getSession().setAnnotations(nextProps.annotations || []);
217
220
  }
218
221
  if (!isEqual(nextProps.markers, oldProps.markers) && Array.isArray(nextProps.markers)) {
@@ -238,8 +241,10 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
238
241
  }, {
239
242
  key: "componentWillUnmount",
240
243
  value: function componentWillUnmount() {
241
- this.editor.destroy();
242
- this.editor = null;
244
+ if (this.editor) {
245
+ this.editor.destroy();
246
+ this.editor = null;
247
+ }
243
248
  }
244
249
  }, {
245
250
  key: "onChange",
@@ -335,7 +340,7 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
335
340
  // remove background markers except active line marker and selected word marker
336
341
  currentMarkers = this.editor.getSession().getMarkers(false);
337
342
  for (var _i in currentMarkers) {
338
- if (currentMarkers.hasOwnProperty(_i) && currentMarkers[_i].clazz !== "ace_active-line" && currentMarkers[_i].clazz !== "ace_selected-word") {
343
+ if (currentMarkers.hasOwnProperty(_i) && currentMarkers[_i].clazz !== 'ace_active-line' && currentMarkers[_i].clazz !== 'ace_selected-word') {
339
344
  this.editor.getSession().removeMarker(currentMarkers[_i].id);
340
345
  }
341
346
  }
@@ -365,12 +370,12 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
365
370
  editor.renderer.scroller.removeChild(editor.renderer.placeholderNode);
366
371
  editor.renderer.placeholderNode = null;
367
372
  } else if (showPlaceholder && !node) {
368
- node = editor.renderer.placeholderNode = document.createElement("div");
369
- node.textContent = placeholder || "";
370
- node.className = "ace_comment ace_placeholder";
371
- node.style.padding = "0 9px";
372
- node.style.position = "absolute";
373
- node.style.zIndex = "3";
373
+ node = editor.renderer.placeholderNode = document.createElement('div');
374
+ node.textContent = placeholder || '';
375
+ node.className = 'ace_comment ace_placeholder';
376
+ node.style.padding = '0 9px';
377
+ node.style.position = 'absolute';
378
+ node.style.zIndex = '3';
374
379
  editor.renderer.scroller.appendChild(node);
375
380
  } else if (showPlaceholder && node) {
376
381
  node.textContent = placeholder;
@@ -393,7 +398,7 @@ var ReactAce = /*#__PURE__*/function (_React$Component) {
393
398
  width: width,
394
399
  height: height
395
400
  }, style);
396
- return /*#__PURE__*/React.createElement("div", {
401
+ return /*#__PURE__*/React.createElement('div', {
397
402
  ref: this.updateRef,
398
403
  id: name,
399
404
  style: divStyle
@@ -426,7 +431,7 @@ ReactAce.propTypes = {
426
431
  /**
427
432
  * 主题
428
433
  * 亮色可选:chrome | clouds | crimson_editor | dawn | dreamweaver | eclipse | github | iplastic | solarized_light | textmate | tomorrow | xcode | kuroir | katzenmilch | sqlserver
429
- * <br>暗色可选:ambiance | chaos | clouds_midnight | dracula | cobalt | gruvbox | gob | idle_fingers | kr_theme | merbivore
434
+ * <br>暗色可选:ambiance | chaos | clouds_midnight | dracula | cobalt | gruvbox | gob | idle_fingers | kr_theme | merbivore
430
435
  * | merbivore_soft | mono_industrial | monokai | nord_dark | pastel_on_dark | solarized_dark | terminal | tomorrow_night | tomorrow_night_blue | tomorrow_night_bright | tomorrow_night_eighties | twilight | vibrant_ink
431
436
  */
432
437
  theme: PropTypes.string,
@@ -564,12 +569,12 @@ ReactAce.propTypes = {
564
569
  placeholder: PropTypes.string
565
570
  };
566
571
  ReactAce.defaultProps = {
567
- name: "ace-editor",
572
+ name: 'ace-editor',
568
573
  focus: false,
569
- mode: "",
570
- theme: "",
571
- height: "500px",
572
- width: "500px",
574
+ mode: '',
575
+ theme: '',
576
+ height: '500px',
577
+ width: '500px',
573
578
  fontSize: 12,
574
579
  enableSnippets: false,
575
580
  showGutter: true,
@@ -149,8 +149,8 @@
149
149
 
150
150
  &[disabled] {
151
151
  color: @btn-primary-color;
152
- background-color: @btn-disabled-primary-color;
153
- border-color: @btn-disabled-primary-color;
152
+ background-color: @primary-3;
153
+ border-color: @primary-3;
154
154
  }
155
155
  }
156
156
 
@@ -1,14 +1,15 @@
1
1
  @cascader-prefix-cls: ~'@{ant-prefix}-cascader';
2
-
3
- .@{cascader-prefix-cls}-menus {
4
- position: static !important;
5
-
6
- .@{cascader-prefix-cls}-menu {
7
- .@{cascader-prefix-cls}-menu-item {
8
-
9
- .@{cascader-prefix-cls}-menu-item-expand-icon,
10
- .@{cascader-prefix-cls}-menu-item-loading-icon {
11
- position: static;
2
+ .@{cascader-prefix-cls}-dropdown{
3
+ .@{cascader-prefix-cls}-menus {
4
+ position: static !important;
5
+
6
+ .@{cascader-prefix-cls}-menu {
7
+ .@{cascader-prefix-cls}-menu-item {
8
+
9
+ .@{cascader-prefix-cls}-menu-item-expand-icon,
10
+ .@{cascader-prefix-cls}-menu-item-loading-icon {
11
+ position: static;
12
+ }
12
13
  }
13
14
  }
14
15
  }
@@ -26,6 +27,9 @@
26
27
  }
27
28
  }
28
29
  }
30
+ .@{cascader-prefix-cls}-menus.@{cascader-prefix-cls}-menus-hidden{
31
+ display: none;
32
+ }
29
33
  // antd4 :点击空白处浮层不消失问题
30
34
  .@{cascader-prefix-cls}-dropdown.@{ant-prefix}-select-dropdown.@{ant-prefix}-slide-up-leave{
31
35
  display: none !important;
@@ -0,0 +1,300 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
+ import _Dropdown from "@chaoswise/ui/lib/Antd/Dropdown";
3
+ import "@chaoswise/ui/lib/Button/index.less";
4
+ import _Button from "@chaoswise/ui/lib/Button";
5
+ import _Space from "@chaoswise/ui/lib/Space";
6
+ import _Icon from "@chaoswise/ui/lib/Antd/Icon";
7
+ import "@chaoswise/ui/lib/Input/index.less";
8
+ import _Input from "@chaoswise/ui/lib/Input";
9
+ import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
10
+ import "@chaoswise/ui/lib/Tabs/index.less";
11
+ import _Tabs from "@chaoswise/ui/lib/Tabs";
12
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
13
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
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(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
16
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
21
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
+ import React, { useEffect, useState } from "react";
24
+ import { SketchPicker } from "react-color";
25
+ import classnames from "classnames";
26
+ import { formatRgbaObj, hexToRgba } from "./utils";
27
+ import { getLocale } from "./locale";
28
+ import PropTypes from "prop-types";
29
+ import "./index.less";
30
+ var TabPane = _Tabs.TabPane;
31
+ var ColorPicker = function ColorPicker(_ref) {
32
+ var value = _ref.value,
33
+ _ref$onChange = _ref.onChange,
34
+ onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
35
+ showGradient = _ref.showGradient,
36
+ defaultValue = _ref.defaultValue,
37
+ colorRender = _ref.colorRender;
38
+ var _useState = useState("single"),
39
+ _useState2 = _slicedToArray(_useState, 2),
40
+ colorType = _useState2[0],
41
+ setColorType = _useState2[1]; //单色渐变选中key 单色single 渐变gradient
42
+
43
+ var _useState3 = useState({
44
+ color: "rgba(255,255,255,1)",
45
+ //组件单色值rgb格式
46
+ hexColor: "#ffffff",
47
+ //组件单色输入框值
48
+ gradientColorStart: "rgba(255,255,255,1)",
49
+ //渐变色左侧rgb颜色值
50
+ gradientColorEnd: "rgba(255,255,255,1)",
51
+ //渐变色右侧rgb颜色值
52
+ gradientHexColorStart: "#ffffff",
53
+ //渐变色左端点输入框16进制值
54
+ gradientHexColorEnd: "#ffffff" //渐变色右端点输入框16进制值
55
+ }),
56
+ _useState4 = _slicedToArray(_useState3, 2),
57
+ colorInfo = _useState4[0],
58
+ setColorInfo = _useState4[1];
59
+ var _useState5 = useState("l"),
60
+ _useState6 = _slicedToArray(_useState5, 2),
61
+ activeColor = _useState6[0],
62
+ setActiveColor = _useState6[1]; //当前设置的颜色是左侧颜色值还是右侧颜色值
63
+
64
+ var _useState7 = useState(""),
65
+ _useState8 = _slicedToArray(_useState7, 2),
66
+ gradientColorValue = _useState8[0],
67
+ setGradientColorValue = _useState8[1]; //组件渐变色值
68
+
69
+ var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
70
+ _ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
71
+ locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
72
+ var localeObj = getLocale(locale);
73
+ var _value = value || defaultValue;
74
+ useEffect(function () {
75
+ if (_value) {
76
+ var _value$colorType = _value.colorType,
77
+ _colorType = _value$colorType === void 0 ? "single" : _value$colorType,
78
+ _value$color = _value.color,
79
+ color = _value$color === void 0 ? "" : _value$color,
80
+ _value$gradientColorS = _value.gradientColorStart,
81
+ gradientColorStart = _value$gradientColorS === void 0 ? "" : _value$gradientColorS,
82
+ _value$gradientColorE = _value.gradientColorEnd,
83
+ gradientColorEnd = _value$gradientColorE === void 0 ? "" : _value$gradientColorE,
84
+ _value$hexColor = _value.hexColor,
85
+ hexColor = _value$hexColor === void 0 ? "" : _value$hexColor,
86
+ _value$gradientHexCol = _value.gradientHexColorStart,
87
+ gradientHexColorStart = _value$gradientHexCol === void 0 ? "" : _value$gradientHexCol,
88
+ _value$gradientHexCol2 = _value.gradientHexColorEnd,
89
+ gradientHexColorEnd = _value$gradientHexCol2 === void 0 ? "" : _value$gradientHexCol2;
90
+ setColorType(_colorType);
91
+ setColorInfo({
92
+ color: color,
93
+ gradientColorStart: gradientColorStart,
94
+ gradientColorEnd: gradientColorEnd,
95
+ hexColor: hexColor,
96
+ gradientHexColorStart: gradientHexColorStart,
97
+ gradientHexColorEnd: gradientHexColorEnd
98
+ });
99
+ }
100
+ }, [_value]);
101
+
102
+ //颜色变化触发值改变
103
+ var onChangeColor = function onChangeColor(colorObj) {
104
+ console.log(colorObj, "colorObj");
105
+ var rgbColor = typeof colorObj.rgb == "string" ? colorObj.rgb : formatRgbaObj(colorObj.rgb);
106
+ if (colorType === "single") {
107
+ setColorInfo(_objectSpread(_objectSpread({}, colorInfo), {}, {
108
+ color: rgbColor,
109
+ hexColor: colorObj.hex
110
+ }));
111
+ onChange(_objectSpread(_objectSpread({}, colorInfo), {}, {
112
+ color: rgbColor,
113
+ colorType: colorType,
114
+ hexColor: colorObj.hex
115
+ }));
116
+ } else {
117
+ if (activeColor === "l") {
118
+ setColorInfo(_objectSpread(_objectSpread({}, colorInfo), {}, {
119
+ gradientColorStart: rgbColor,
120
+ gradientHexColorStart: colorObj.hex
121
+ }));
122
+ onChange(_objectSpread(_objectSpread({}, colorInfo), {}, {
123
+ gradientColorStart: rgbColor,
124
+ colorType: colorType,
125
+ gradientHexColorStart: colorObj.hex
126
+ }));
127
+ } else {
128
+ setColorInfo(_objectSpread(_objectSpread({}, colorInfo), {}, {
129
+ gradientColorEnd: rgbColor,
130
+ gradientHexColorEnd: colorObj.hex
131
+ }));
132
+ onChange(_objectSpread(_objectSpread({}, colorInfo), {}, {
133
+ gradientColorEnd: rgbColor,
134
+ colorType: colorType,
135
+ gradientHexColorEnd: colorObj.hex
136
+ }));
137
+ }
138
+ }
139
+ };
140
+
141
+ //切换单色渐变tab
142
+ var changeTab = function changeTab(colorType) {
143
+ setColorType(colorType);
144
+ onChange(_objectSpread(_objectSpread({}, colorInfo), {}, {
145
+ colorType: colorType
146
+ }));
147
+ };
148
+
149
+ //颜色输入框
150
+ var onChangeInputColor = function onChangeInputColor(e) {
151
+ //十六进制颜色校验
152
+ var reg = /^#([0-9a-f]{6}){1,2}$/i;
153
+ if (colorType === "single") {
154
+ setColorInfo(_objectSpread(_objectSpread({}, colorInfo), {}, {
155
+ hexColor: e.target.value
156
+ }));
157
+ } else {
158
+ activeColor === "l" ? setColorInfo(_objectSpread(_objectSpread({}, colorInfo), {}, {
159
+ gradientHexColorStart: e.target.value
160
+ })) : setColorInfo(_objectSpread(_objectSpread({}, colorInfo), {}, {
161
+ gradientHexColorEnd: e.target.value
162
+ }));
163
+ }
164
+ if (reg.test(e.target.value)) {
165
+ e.preventDefault();
166
+ onChangeColor({
167
+ rgb: hexToRgba(e.target.value),
168
+ hex: e.target.value
169
+ });
170
+ }
171
+ };
172
+
173
+ //最终渐变色
174
+ useEffect(function () {
175
+ colorInfo && setGradientColorValue("linear-gradient(to right,".concat(colorInfo.gradientColorStart, ",").concat(colorInfo.gradientColorEnd, ")"));
176
+ }, [colorInfo]);
177
+ var menu = /*#__PURE__*/React.createElement("div", {
178
+ className: "color-picker-select-dropdown"
179
+ }, /*#__PURE__*/React.createElement("div", {
180
+ className: "color-picker-dropdown",
181
+ onClick: function onClick(e) {
182
+ e.preventDefault();
183
+ e.stopPropagation();
184
+ }
185
+ }, /*#__PURE__*/React.createElement(_Tabs, {
186
+ activeKey: colorType,
187
+ onChange: changeTab
188
+ }, /*#__PURE__*/React.createElement(TabPane, {
189
+ key: "single",
190
+ tab: localeObj["color-picker-single"]
191
+ }, /*#__PURE__*/React.createElement("div", {
192
+ className: "color-picker"
193
+ }, /*#__PURE__*/React.createElement(_Input, {
194
+ value: colorInfo.hexColor,
195
+ onChange: onChangeInputColor,
196
+ className: "color-picker-input"
197
+ }), /*#__PURE__*/React.createElement(SketchPicker, {
198
+ color: colorInfo.color,
199
+ onChange: onChangeColor
200
+ }))), showGradient && /*#__PURE__*/React.createElement(TabPane, {
201
+ key: "gradient",
202
+ tab: localeObj["color-picker-gradient"]
203
+ }, /*#__PURE__*/React.createElement("div", {
204
+ className: "color-picker"
205
+ }, /*#__PURE__*/React.createElement("div", {
206
+ className: "gradient",
207
+ style: {
208
+ background: gradientColorValue
209
+ }
210
+ }, /*#__PURE__*/React.createElement("div", {
211
+ className: classnames("gradient-l", {
212
+ "gradient-active": activeColor === "l"
213
+ }),
214
+ onClick: function onClick() {
215
+ setActiveColor("l");
216
+ }
217
+ }, /*#__PURE__*/React.createElement("span", {
218
+ className: "gradient-btn",
219
+ style: {
220
+ background: colorInfo.gradientColorStart
221
+ }
222
+ })), /*#__PURE__*/React.createElement("div", {
223
+ className: classnames("gradient-r", {
224
+ "gradient-active": activeColor === "r"
225
+ }),
226
+ onClick: function onClick() {
227
+ setActiveColor("r");
228
+ }
229
+ }, /*#__PURE__*/React.createElement("span", {
230
+ className: "gradient-btn",
231
+ style: {
232
+ background: colorInfo.gradientColorEnd
233
+ }
234
+ }))), /*#__PURE__*/React.createElement(_Input, {
235
+ value: activeColor === "l" ? colorInfo.gradientHexColorStart : colorInfo.gradientHexColorEnd,
236
+ onChange: onChangeInputColor,
237
+ className: "color-picker-input"
238
+ }), /*#__PURE__*/React.createElement(SketchPicker, {
239
+ color: activeColor === "l" ? colorInfo.gradientColorStart : colorInfo.gradientColorEnd,
240
+ onChange: onChangeColor
241
+ }))))));
242
+ return /*#__PURE__*/React.createElement("div", {
243
+ className: "color-picker-select",
244
+ onClick: function onClick(e) {
245
+ e.preventDefault();
246
+ e.stopPropagation();
247
+ }
248
+ }, /*#__PURE__*/React.createElement(_Dropdown, {
249
+ trigger: ["click"],
250
+ overlay: menu
251
+ }, colorRender ? colorRender() : /*#__PURE__*/React.createElement(_Button, null, /*#__PURE__*/React.createElement(_Space, null, /*#__PURE__*/React.createElement("div", {
252
+ className: "color-picker-select-value",
253
+ style: {
254
+ background: colorType === "single" ? colorInfo.color : gradientColorValue
255
+ }
256
+ }), /*#__PURE__*/React.createElement(_Icon, {
257
+ type: "down"
258
+ })))));
259
+ };
260
+ ColorPicker.defaultProps = {
261
+ showGradient: false // 是否显示渐变tab
262
+ };
263
+
264
+ ColorPicker.propTypes = {
265
+ defaultValue: PropTypes.shape({
266
+ color: PropTypes.string,
267
+ colorType: PropTypes.string,
268
+ gradientColorStart: PropTypes.string,
269
+ gradientColorEnd: PropTypes.string,
270
+ gradientHexColorStart: PropTypes.string,
271
+ gradientHexColorEnd: PropTypes.string,
272
+ hexColor: PropTypes.string
273
+ }),
274
+ value: PropTypes.shape({
275
+ color: PropTypes.string,
276
+ colorType: PropTypes.string,
277
+ gradientColorStart: PropTypes.string,
278
+ gradientColorEnd: PropTypes.string,
279
+ gradientHexColorStart: PropTypes.string,
280
+ gradientHexColorEnd: PropTypes.string,
281
+ hexColor: PropTypes.string
282
+ }),
283
+ /**
284
+ * 自定义Dropdown按钮内容
285
+ */
286
+ iconSelectRender: PropTypes.func,
287
+ /**
288
+ * 是否显示渐变tab
289
+ */
290
+ showGradient: PropTypes.bool,
291
+ /**
292
+ * 颜色变化、Tab切换时的回调, (value)={}
293
+ */
294
+ onChange: PropTypes.func,
295
+ /**
296
+ * 自定义Dropdown按钮内容
297
+ */
298
+ colorRender: PropTypes.func
299
+ };
300
+ export default ColorPicker;