@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
@@ -21,10 +21,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
21
21
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
22
22
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
23
23
  import React, { useEffect, useState } from "react";
24
- import { SketchPicker } from "react-color";
24
+ import SketchPicker from "./SketchPicker/components/sketch";
25
25
  import classnames from "classnames";
26
26
  import { formatRgbaObj, hexToRgba } from "./utils";
27
- import langConfig from './locale';
27
+ import langConfig from "./locale";
28
28
  import { formatMessage } from "../utils";
29
29
  import PropTypes from "prop-types";
30
30
  import "./index.less";
@@ -98,7 +98,6 @@ var ColorPicker = function ColorPicker(_ref) {
98
98
  }, [_value]);
99
99
  //颜色变化触发值改变
100
100
  var onChangeColor = function onChangeColor(colorObj) {
101
- console.log(colorObj, "colorObj");
102
101
  var rgbColor = typeof colorObj.rgb == "string" ? colorObj.rgb : formatRgbaObj(colorObj.rgb);
103
102
  if (colorType === "single") {
104
103
  setColorInfo(_objectSpread(_objectSpread({}, colorInfo), {}, {
@@ -5,28 +5,33 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
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
7
  var Dep = /*#__PURE__*/function () {
8
- // 订阅池
9
- function Dep(name) {
8
+ function Dep() {
10
9
  _classCallCheck(this, Dep);
11
- this.subs = []; //该事件下被订阅对象的集合
10
+ this.subs = []; // 存放所有订阅者
12
11
  }
12
+ // 添加订阅者
13
13
  _createClass(Dep, [{
14
- key: "defined",
15
- value: function defined(watch) {
16
- this.subs.push(watch);
14
+ key: "addSub",
15
+ value: function addSub(watch) {
16
+ if (watch && this.subs.indexOf(watch) < 0) {
17
+ this.subs.push(watch);
18
+ }
17
19
  }
20
+ // 移除订阅者
21
+ }, {
22
+ key: "removeSub",
23
+ value: function removeSub(watch) {
24
+ var index = this.subs.indexOf(watch);
25
+ if (index > -1) {
26
+ this.subs.splice(index, 1);
27
+ }
28
+ }
29
+ // 通知所有订阅者
18
30
  }, {
19
31
  key: "notify",
20
32
  value: function notify() {
21
- //通知订阅者有变化
22
- this.subs.forEach(function (e, i) {
23
- if (typeof e.update === 'function') {
24
- try {
25
- e.update.apply(e); //触发订阅者更新函数
26
- } catch (err) {
27
- console.error(err);
28
- }
29
- }
33
+ this.subs.forEach(function (sub) {
34
+ return sub.update();
30
35
  });
31
36
  }
32
37
  }]);
@@ -35,49 +40,44 @@ var Dep = /*#__PURE__*/function () {
35
40
  var Watch = /*#__PURE__*/function () {
36
41
  function Watch(name, fn) {
37
42
  _classCallCheck(this, Watch);
38
- this.name = name; //订阅消息的名称
39
- this.callBack = fn; //订阅消息发送改变时->订阅者执行的回调函数
43
+ this.name = name;
44
+ this.callBack = fn;
40
45
  }
41
46
  _createClass(Watch, [{
42
- key: "add",
43
- value: function add(dep) {
44
- //将订阅者放入dep订阅池
45
- dep.subs.push(this);
46
- }
47
- }, {
48
47
  key: "update",
49
48
  value: function update() {
50
- //将订阅者更新方法
51
- var cb = this.callBack; //赋值为了不改变函数内调用的this
52
- cb(this.name);
49
+ if (typeof this.callBack === 'function') {
50
+ this.callBack(this.name);
51
+ }
53
52
  }
54
53
  }]);
55
54
  return Watch;
56
55
  }();
57
- function addMethod() {
58
- var historyDep = new Dep();
59
- return function (name) {
60
- if (name === 'historychange') {
61
- return function (name, fn) {
62
- var event = new Watch(name, fn);
63
- historyDep.defined(event);
64
- };
65
- } else if (name === 'pushState') {
66
- var method = history[name];
67
- return function () {
68
- method.apply(history, arguments);
69
- historyDep.notify();
70
- };
71
- } else if (name === 'replaceState') {
72
- var _method = history[name];
73
- return function () {
74
- _method.apply(history, arguments);
75
- historyDep.notify();
76
- };
56
+ var historyDep = new Dep(); // 单例订阅池
57
+
58
+ // 修改history方法
59
+ var modifyHistoryMethod = function modifyHistoryMethod(methodName) {
60
+ var original = history[methodName];
61
+ history[methodName] = function () {
62
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
63
+ args[_key] = arguments[_key];
77
64
  }
65
+ var result = original.apply(this, args);
66
+ historyDep.notify(); // 通知变动
67
+ return result;
68
+ };
69
+ };
70
+
71
+ // 添加订阅者
72
+ window.addHistoryListener = function (name, fn) {
73
+ var watcher = new Watch(name, fn);
74
+ historyDep.addSub(watcher);
75
+ // 返回取消订阅的函数
76
+ return function removeHistoryListener() {
77
+ historyDep.removeSub(watcher);
78
78
  };
79
- }
80
- var addHistoryMethod = new addMethod();
81
- window.addHistoryListener = addHistoryMethod('historychange');
82
- history.pushState = addHistoryMethod('pushState');
83
- history.replaceState = addHistoryMethod('replaceState');
79
+ };
80
+
81
+ // 修改pushState和replaceState以便通知订阅者
82
+ modifyHistoryMethod('pushState');
83
+ modifyHistoryMethod('replaceState');
@@ -56,7 +56,7 @@ var ErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
56
56
  _createClass(ErrorBoundary, [{
57
57
  key: "componentDidMount",
58
58
  value: function componentDidMount() {
59
- window.addHistoryListener('history', this.historyChange);
59
+ this.removeListener = window.addHistoryListener('history', this.historyChange);
60
60
  window.addEventListener('hashchange', this.historyChange);
61
61
  this.timer = setTimeout(function () {
62
62
  localStorage.setItem('ChunkLoadError', '');
@@ -65,8 +65,9 @@ var ErrorBoundary = /*#__PURE__*/function (_React$PureComponent) {
65
65
  }, {
66
66
  key: "componentWillUnmount",
67
67
  value: function componentWillUnmount() {
68
- window.removeEventListener('history', this.historyChange);
68
+ this.removeListener();
69
69
  window.removeEventListener('hashchange', this.historyChange);
70
+ clearTimeout(this.timer);
70
71
  }
71
72
  }, {
72
73
  key: "componentDidCatch",
@@ -16,7 +16,8 @@ var Drag = function Drag(props) {
16
16
  render = props.render,
17
17
  renderColumns = props.renderColumns,
18
18
  dragList = props.dragList,
19
- useDndProvider = props.useDndProvider;
19
+ useDndProvider = props.useDndProvider,
20
+ isHoverSwitching = props.isHoverSwitching;
20
21
  var moveList = function moveList(dragIndex, hoverIndex) {
21
22
  var tmp = checkValue[dragIndex]; //临时储存文件
22
23
  checkValue.splice(dragIndex, 1); //移除拖拽项
@@ -40,7 +41,8 @@ var Drag = function Drag(props) {
40
41
  handleDelete: handleDelete,
41
42
  moveList: moveList,
42
43
  dragList: dragList,
43
- hasPrefixIcon: hasPrefixIcon
44
+ hasPrefixIcon: hasPrefixIcon,
45
+ isHoverSwitching: isHoverSwitching
44
46
  });
45
47
  };
46
48
  return /*#__PURE__*/React.createElement(Fragment, null, useDndProvider ? /*#__PURE__*/React.createElement(DndProvider, {
@@ -1,8 +1,12 @@
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); }
1
2
  import _Icon from "@chaoswise/ui/lib/Icon";
2
3
  import "@chaoswise/ui/lib/Tooltip/index.less";
3
4
  import _Tooltip from "@chaoswise/ui/lib/Tooltip";
4
5
  import _useLocale2 from "@chaoswise/ui/lib/useLocale";
5
6
  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); }
7
+ 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; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
9
+ 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); }
6
10
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
7
11
  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."); }
8
12
  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); }
@@ -14,7 +18,7 @@ import { useDrag, useDrop } from "react-dnd";
14
18
  import classnames from "classnames";
15
19
  import LockSvg from "./assets/LockSvg";
16
20
  import DragSvg from "./assets/DragSvg";
17
- import langConfig from './locale';
21
+ import langConfig from "./locale";
18
22
  import { formatMessage } from "../utils";
19
23
  var DragList = function DragList(_ref) {
20
24
  var index = _ref.index,
@@ -25,7 +29,8 @@ var DragList = function DragList(_ref) {
25
29
  handleDelete = _ref.handleDelete,
26
30
  moveList = _ref.moveList,
27
31
  dragList = _ref.dragList,
28
- hasPrefixIcon = _ref.hasPrefixIcon;
32
+ hasPrefixIcon = _ref.hasPrefixIcon,
33
+ isHoverSwitching = _ref.isHoverSwitching;
29
34
  var title = listItem.title,
30
35
  disabled = listItem.disabled;
31
36
  // 获取当前语言
@@ -43,6 +48,7 @@ var DragList = function DragList(_ref) {
43
48
  var _useDrop = useDrop({
44
49
  accept: "transferDrag",
45
50
  hover: function hover(item) {
51
+ if (!isHoverSwitching) return;
46
52
  //拖拽目标的Index
47
53
  var dragIndex = item.index;
48
54
  //放置目标Index
@@ -53,10 +59,27 @@ var DragList = function DragList(_ref) {
53
59
  }
54
60
  moveList(dragIndex, hoverIndex); //调用方法完成交换
55
61
  item.index = hoverIndex; //重新赋值index,否则会出现无限交换情况
62
+ },
63
+ collect: function collect(monitor) {
64
+ var _ref2 = monitor.getItem() || {},
65
+ dragIndex = _ref2.index;
66
+ if (dragIndex === index) {
67
+ return {};
68
+ }
69
+ return {
70
+ isOver: monitor.isOver(),
71
+ dropClassName: dragIndex < index ? "drop-over-downward" : "drop-over-upward"
72
+ };
73
+ },
74
+ drop: function drop(item) {
75
+ if (isHoverSwitching) return;
76
+ moveList(item.index, index);
56
77
  }
57
78
  }),
58
79
  _useDrop2 = _slicedToArray(_useDrop, 2),
59
- _ = _useDrop2[0],
80
+ _useDrop2$ = _useDrop2[0],
81
+ isOver = _useDrop2$.isOver,
82
+ dropClassName = _useDrop2$.dropClassName,
60
83
  drop = _useDrop2[1];
61
84
  var renderTable = function renderTable(listItem) {
62
85
  return /*#__PURE__*/React.createElement("div", null, renderColumns.map(function (item, index) {
@@ -91,7 +114,7 @@ var DragList = function DragList(_ref) {
91
114
  }
92
115
  } : {};
93
116
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
94
- className: classnames("cw-transfer-right-content-main")
117
+ className: classnames("cw-transfer-right-content-main", _defineProperty({}, dropClassName, isOver && !isHoverSwitching))
95
118
  }, dragProps), renderItemContent));
96
119
  };
97
120
  export default DragList;
@@ -100,7 +100,9 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
100
100
  _props$searchOption = props.searchOption,
101
101
  searchOption = _props$searchOption === void 0 ? {} : _props$searchOption,
102
102
  _props$caseSensitive = props.caseSensitive,
103
- caseSensitive = _props$caseSensitive === void 0 ? false : _props$caseSensitive;
103
+ caseSensitive = _props$caseSensitive === void 0 ? false : _props$caseSensitive,
104
+ _props$isHoverSwitchi = props.isHoverSwitching,
105
+ isHoverSwitching = _props$isHoverSwitchi === void 0 ? true : _props$isHoverSwitchi;
104
106
  var _searchOption$leftSea = searchOption.leftSearchOption,
105
107
  _searchOption$leftSea2 = _searchOption$leftSea === void 0 ? {} : _searchOption$leftSea,
106
108
  _searchOption$leftSea3 = _searchOption$leftSea2.onChange,
@@ -323,10 +325,10 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
323
325
  return newCheckedValue;
324
326
  };
325
327
  var searchCheckedValue = useMemo(function () {
326
- return type === "tree" ? handleRightSearch(saveSearchValueRight).filter(function (i) {
328
+ return type === "tree" && treeSelect === "leafNode" ? handleRightSearch(saveSearchValueRight).filter(function (i) {
327
329
  return Boolean(i.isLeaf);
328
330
  }) : handleRightSearch(saveSearchValueRight);
329
- }, [checkValue, saveSearchValueRight, type]);
331
+ }, [checkValue, saveSearchValueRight, type, treeSelect]);
330
332
  // type为list下全选框按钮的样式统一处理
331
333
  var setListCheckedStyle = function setListCheckedStyle(listCheckedKeys, dataSource) {
332
334
  // 设置列表左侧判断全选状态实际选中的key,重新搜索之后会改变
@@ -719,7 +721,8 @@ var QuickTransfer = /*#__PURE__*/forwardRef(function (props, ref) {
719
721
  renderColumns: renderColumns ? renderColumns : newRenderColumns,
720
722
  dragList: dragList,
721
723
  handlePreviewList: handlePreviewList,
722
- useDndProvider: useDndProvider
724
+ useDndProvider: useDndProvider,
725
+ isHoverSwitching: isHoverSwitching
723
726
  }) : /*#__PURE__*/React.createElement(NoDrag, {
724
727
  checkValue: searchCheckedValue,
725
728
  handleDelete: handleDelete,
@@ -928,6 +931,10 @@ QuickTransfer.propTypes = {
928
931
  * allSelectedTextRender(listCheckedKeys,data)
929
932
  * }
930
933
  */
931
- caseSensitive: PropTypes.bool
934
+ caseSensitive: PropTypes.bool,
935
+ /**
936
+ * 开启拖拽后的交互模式,默认为true(true为悬停即交换,false为鼠标松开再交换)
937
+ */
938
+ isHoverSwitching: PropTypes.bool
932
939
  };
933
940
  export default QuickTransfer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chaoswise/ui",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "description": "公共UI库",
5
5
  "keywords": [
6
6
  "ui",
@@ -102,7 +102,6 @@
102
102
  "rc-tree-cascader": "npm:rc-tree@5.7.12",
103
103
  "rc-util": "^5.20.0",
104
104
  "re-resizable": "^6.9.0",
105
- "react-color": "^2.19.3",
106
105
  "react-custom-scrollbars": "^4.2.1",
107
106
  "react-dnd": "^13.1.1",
108
107
  "react-dnd-html5-backend": "^12.1.1",