@chaoswise/ui 2.3.15 → 2.3.17
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/README.md +1 -1
- package/lib/CWRangePicker/utils/index.js +28 -6
- package/lib/CWTable/CWTable.js +15 -11
- package/lib/FilterDropDown/assets/ShowSvgIcon.js +14 -0
- package/lib/FilterDropDown/index.js +8 -3
- package/lib/Form/FormItem.js +3 -2
- package/lib/QuickTransfer/CheckList.js +54 -0
- package/lib/QuickTransfer/TopicList.js +153 -0
- package/lib/SearchBar/OutSearch.js +2 -1
- package/lib/Watermark/context.js +22 -0
- package/lib/Watermark/index.js +308 -0
- package/lib/Watermark/useClips.js +118 -0
- package/lib/Watermark/useRafDebounce.js +21 -0
- package/lib/Watermark/useWatermark.js +52 -0
- package/lib/Watermark/utils.js +42 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
基于antd3.x根据公司UIUE规范进行二次封装的前端公共组件库,用于统一公司产品风格,提高研发人员开发效率
|
|
6
6
|
|
|
7
7
|
# Features
|
|
8
|
-
#### 1. 包含符合UIUE
|
|
8
|
+
#### 1. 包含符合UIUE设计规范的公共组件,设计规范和使用规范参考[YXD-用户体验设计平台](https://yunzhihui.feishu.cn/wiki/wikcnkFSNhaqVDdYNNH5K6NNy7f)
|
|
9
9
|
#### 2. 支持antd全部组件,引用和使用方法参考[antd官方文档](https://3x.ant.design/docs/react/introduce-cn)
|
|
10
10
|
#### 3. 支持按需加载
|
|
11
11
|
|
|
@@ -297,14 +297,36 @@ export var cloneChangeDate = function cloneChangeDate(currentDate_0, currentDate
|
|
|
297
297
|
cloneCurrentDate_1 = moment();
|
|
298
298
|
switchInitial = true;
|
|
299
299
|
} else {
|
|
300
|
-
// 非极限时间,但是超过最大的时间边界跨度
|
|
301
|
-
// 先将currentDate_0和currentDate_1二者进行相减在这个基础上增加(timeSpanBoundary - 二者相减) / 2 ,左右各增加减少这个数值
|
|
302
|
-
var initialTimeDiff = computeTimeDiff([cloneCurrentDate_0, cloneCurrentDate_1], "s");
|
|
303
|
-
var needChangeTimeDiff = Math.ceil(initialTimeDiff - timeSpanBoundary) / 2;
|
|
304
300
|
var clone0 = currentDate_0.clone();
|
|
305
301
|
var clone1 = currentDate_1.clone();
|
|
306
|
-
|
|
307
|
-
|
|
302
|
+
var initialTimeDiff = computeTimeDiff([clone0, clone1], "s");
|
|
303
|
+
if (timeSpanBoundary > initialTimeDiff) {
|
|
304
|
+
var needChangeTimeDiff = Math.ceil(timeSpanBoundary - initialTimeDiff) / 2;
|
|
305
|
+
cloneCurrentDate_0 = clone0.subtract(moment.duration(needChangeTimeDiff, "s"));
|
|
306
|
+
cloneCurrentDate_1 = clone1.add(moment.duration(needChangeTimeDiff, "s"));
|
|
307
|
+
// 计算最大值的时间差
|
|
308
|
+
var _maxTimeDiff2 = computeTimeDiff([cloneCurrentDate_1, moment()]);
|
|
309
|
+
if (_maxTimeDiff2 <= 0) {
|
|
310
|
+
// 当前时间已经是极限了
|
|
311
|
+
// 已经是极限直接当前时间向前推进timeSpanBoundary即可
|
|
312
|
+
cloneCurrentDate_0 = moment().subtract(moment.duration(timeSpanBoundary, "s"));
|
|
313
|
+
cloneCurrentDate_1 = moment();
|
|
314
|
+
switchInitial = true;
|
|
315
|
+
}
|
|
316
|
+
} else {
|
|
317
|
+
cloneCurrentDate_1 = clone1.add(moment.duration(timeSpanBoundary, "s"));
|
|
318
|
+
var clone = cloneCurrentDate_1.clone();
|
|
319
|
+
cloneCurrentDate_0 = clone.subtract(moment.duration(timeSpanBoundary, "s"));
|
|
320
|
+
// 计算最大值的时间差
|
|
321
|
+
var _maxTimeDiff3 = computeTimeDiff([cloneCurrentDate_1, moment()]);
|
|
322
|
+
if (_maxTimeDiff3 <= 0) {
|
|
323
|
+
// 当前时间已经是极限了
|
|
324
|
+
// 已经是极限直接当前时间向前推进timeSpanBoundary即可
|
|
325
|
+
cloneCurrentDate_0 = moment().subtract(moment.duration(timeSpanBoundary, "s"));
|
|
326
|
+
cloneCurrentDate_1 = moment();
|
|
327
|
+
switchInitial = true;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
308
330
|
}
|
|
309
331
|
} else {
|
|
310
332
|
if (_maxTimeDiff <= 0) {
|
package/lib/CWTable/CWTable.js
CHANGED
|
@@ -239,14 +239,17 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
239
239
|
var resetSortDataSource = function resetSortDataSource() {
|
|
240
240
|
var _dataSource = _toConsumableArray(dataSource);
|
|
241
241
|
if (frontPagination) {
|
|
242
|
-
var
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
var _current = pagination.current,
|
|
243
|
+
_pageSize = pagination.pageSize,
|
|
244
|
+
_total = pagination.total;
|
|
245
|
+
var current = _current || pageInfo.current;
|
|
246
|
+
var pageSize = _pageSize || pageInfo.pageSize;
|
|
247
|
+
var total = _total || dataSource.length;
|
|
245
248
|
_dataSource = _dataSource.slice((current - 1) * pageSize, current * pageSize > total ? total : current * pageSize);
|
|
246
249
|
}
|
|
247
250
|
setFinalDataSource(_dataSource);
|
|
248
251
|
};
|
|
249
|
-
useEffect(resetSortDataSource, [frontPagination, pageInfo.current, pageInfo.pageSize, dataSource]);
|
|
252
|
+
useEffect(resetSortDataSource, [frontPagination, pagination, pageInfo.current, pageInfo.pageSize, dataSource]);
|
|
250
253
|
useEffect(function () {
|
|
251
254
|
if (!autoHeight) {
|
|
252
255
|
return;
|
|
@@ -652,13 +655,14 @@ var CWTable = function CWTable(_ref, ref) {
|
|
|
652
655
|
onShowSizeChange: onShowSizeChange,
|
|
653
656
|
size: size == 'small' ? 'small' : ''
|
|
654
657
|
});
|
|
655
|
-
if (frontPagination) {
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
658
|
+
// if (frontPagination) {
|
|
659
|
+
// return {
|
|
660
|
+
// ...common,
|
|
661
|
+
// current: pageInfo.current,
|
|
662
|
+
// pageSize: pageInfo.pageSize,
|
|
663
|
+
// total: dataSource.length,
|
|
664
|
+
// }
|
|
665
|
+
// }
|
|
662
666
|
return _objectSpread(_objectSpread({}, common), {}, {
|
|
663
667
|
current: current || pageInfo.current,
|
|
664
668
|
pageSize: pageSize || pageInfo.pageSize,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
var SvgShowIcon = function SvgShowIcon(props) {
|
|
4
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: 14,
|
|
7
|
+
height: 14
|
|
8
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
9
|
+
fill: "currentColor",
|
|
10
|
+
fillRule: "evenodd",
|
|
11
|
+
d: "m7.778.922.308.047.036.007a.439.439 0 0 1 .333.277l.02.075.215 1.162c.396.148.768.348 1.111.594l.252.193 1.111-.395a.44.44 0 0 1 .416.068l.064.062.025.029c.408.48.735 1.015.976 1.593l.114.292.012.036c.051.143.025.3-.066.416l-.061.065-.896.765c.028.174.048.35.057.526l.003.11h-.982a3.875 3.875 0 0 0-.02-.266l-.028-.208-.09-.546 1.022-.873a5.208 5.208 0 0 0-.415-.767l-.167-.24-1.27.45-.429-.353a3.844 3.844 0 0 0-.852-.53l-.232-.096-.52-.195-.245-1.326a5.169 5.169 0 0 0-.873-.025l-.29.025-.244 1.328-.518.196a3.814 3.814 0 0 0-.877.472l-.2.153-.429.354-1.277-.454a5.095 5.095 0 0 0-.458.742l-.124.264 1.032.882-.089.547a3.769 3.769 0 0 0-.027 1.038l.027.206.09.547-1.033.882c.117.266.255.523.415.767l.167.239 1.277-.454.43.354c.259.214.543.39.845.529l.23.096.517.198.245 1.33c.182.02.365.03.549.032v.98a6.145 6.145 0 0 1-.705-.044l-.348-.053-.037-.007a.439.439 0 0 1-.332-.277l-.02-.074-.217-1.168a4.754 4.754 0 0 1-1.146-.623l-.207-.161-1.12.398a.44.44 0 0 1-.416-.069l-.064-.061-.025-.03a6.077 6.077 0 0 1-.976-1.592l-.113-.292-.013-.036a.439.439 0 0 1 .066-.417l.062-.064.906-.774a4.786 4.786 0 0 1-.035-1.303l.035-.258-.906-.774a.44.44 0 0 1-.15-.395l.022-.086.013-.036a6.09 6.09 0 0 1 .892-1.64l.197-.245.025-.03a.437.437 0 0 1 .393-.15l.087.021 1.12.398c.325-.268.682-.49 1.063-.664l.29-.12.216-1.168a.438.438 0 0 1 .279-.331l.074-.02.037-.008A6.185 6.185 0 0 1 7.778.922Zm4.833 10.844a.5.5 0 1 1 0 1h-4.5a.5.5 0 1 1 0-1h4.5Zm0-2a.5.5 0 1 1 0 1h-4.5a.5.5 0 1 1 0-1h4.5ZM7 4.457c1.274 0 2.316.99 2.4 2.242l.005.145H8.53a1.522 1.522 0 0 0-.346-.95l-.102-.114A1.52 1.52 0 0 0 7 5.332a1.52 1.52 0 0 0-1.083.448c-.288.29-.448.674-.448 1.083a1.526 1.526 0 0 0 1.38 1.524l.116.005v.877a2.406 2.406 0 0 1-2.366-2.241l-.005-.165A2.406 2.406 0 0 1 7 4.457Zm5.611 3.309a.5.5 0 1 1 0 1h-4.5a.5.5 0 1 1 0-1h4.5Z"
|
|
12
|
+
}));
|
|
13
|
+
};
|
|
14
|
+
export default SvgShowIcon;
|
|
@@ -22,8 +22,10 @@ import classnames from "classnames";
|
|
|
22
22
|
import PropTypes from "prop-types";
|
|
23
23
|
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
24
24
|
import { DndProvider } from "react-dnd";
|
|
25
|
-
import "./index.less";
|
|
26
25
|
import { getLocale } from "./locale";
|
|
26
|
+
import useConfigContext from '../useConfigContext';
|
|
27
|
+
import ShowSvgIcon from './assets/ShowSvgIcon';
|
|
28
|
+
import "./index.less";
|
|
27
29
|
var CheckboxGroup = _Checkbox.Group;
|
|
28
30
|
function FilterDropDown(props) {
|
|
29
31
|
var selectItems = props.selectItems,
|
|
@@ -68,6 +70,9 @@ function FilterDropDown(props) {
|
|
|
68
70
|
_ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
|
|
69
71
|
locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
|
|
70
72
|
var localeObj = getLocale(locale);
|
|
73
|
+
var _useConfigContext = useConfigContext(),
|
|
74
|
+
getPrefixCls = _useConfigContext.getPrefixCls;
|
|
75
|
+
var prefixCls = getPrefixCls();
|
|
71
76
|
useEffect(function () {
|
|
72
77
|
document.addEventListener("click", clickBody);
|
|
73
78
|
return function () {
|
|
@@ -199,8 +204,8 @@ function FilterDropDown(props) {
|
|
|
199
204
|
onClick: toggoleShow,
|
|
200
205
|
ref: addRef
|
|
201
206
|
}, colsFilterTitle ? colsFilterTitle : /*#__PURE__*/React.createElement(_Button, {
|
|
202
|
-
|
|
203
|
-
})), showList && /*#__PURE__*/React.createElement(Fragment, null, isDrag ? /*#__PURE__*/React.createElement(DndProvider, {
|
|
207
|
+
className: "".concat(prefixCls, "-btn-icon-only")
|
|
208
|
+
}, /*#__PURE__*/React.createElement(ShowSvgIcon, null))), showList && /*#__PURE__*/React.createElement(Fragment, null, isDrag ? /*#__PURE__*/React.createElement(DndProvider, {
|
|
204
209
|
backend: HTML5Backend
|
|
205
210
|
}, renderDropdown()) : /*#__PURE__*/React.createElement(Fragment, null, renderDropdown())));
|
|
206
211
|
}
|
package/lib/Form/FormItem.js
CHANGED
|
@@ -5,7 +5,7 @@ import "@chaoswise/ui/lib/Tooltip/index.less";
|
|
|
5
5
|
import _Tooltip from "@chaoswise/ui/lib/Tooltip";
|
|
6
6
|
import "antd/es/typography/style";
|
|
7
7
|
import _Typography from "antd/es/typography";
|
|
8
|
-
var _excluded = ["labelCol", "wrapperCol", "label", "showLabelWidth"];
|
|
8
|
+
var _excluded = ["labelCol", "wrapperCol", "label", "showLabelWidth", "customLabel"];
|
|
9
9
|
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); }
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
@@ -23,6 +23,7 @@ var FormItem = function FormItem(_ref) {
|
|
|
23
23
|
wrapperCol = _ref$wrapperCol === void 0 ? {} : _ref$wrapperCol,
|
|
24
24
|
label = _ref.label,
|
|
25
25
|
showLabelWidth = _ref.showLabelWidth,
|
|
26
|
+
customLabel = _ref.customLabel,
|
|
26
27
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
28
|
return /*#__PURE__*/React.createElement(LayoutContext.Consumer, null, function (layout) {
|
|
28
29
|
var _layout = layout || 'horizontal';
|
|
@@ -42,7 +43,7 @@ var FormItem = function FormItem(_ref) {
|
|
|
42
43
|
flex: 1
|
|
43
44
|
}
|
|
44
45
|
}, wrapperCol),
|
|
45
|
-
label: !label && label !== '' && !showLabelWidth ? label : /*#__PURE__*/React.createElement(_Tooltip, {
|
|
46
|
+
label: customLabel ? customLabel : !label && label !== '' && !showLabelWidth ? label : /*#__PURE__*/React.createElement(_Tooltip, {
|
|
46
47
|
title: label
|
|
47
48
|
}, /*#__PURE__*/React.createElement(_Typography.Paragraph, {
|
|
48
49
|
className: "cw-form-item-typography-label",
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
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); }
|
|
5
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
6
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
7
|
+
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; }
|
|
8
|
+
import React, { Fragment } from 'react';
|
|
9
|
+
import TopicList from './TopicList';
|
|
10
|
+
import { DndProvider } from "react-dnd";
|
|
11
|
+
import { HTML5Backend } from "react-dnd-html5-backend";
|
|
12
|
+
var CheckList = function CheckList(props) {
|
|
13
|
+
var checkValue = props.checkValue,
|
|
14
|
+
handleDelete = props.handleDelete,
|
|
15
|
+
handlePreviewList = props.handlePreviewList,
|
|
16
|
+
type = props.type,
|
|
17
|
+
render = props.render,
|
|
18
|
+
renderColumns = props.renderColumns,
|
|
19
|
+
dragList = props.dragList,
|
|
20
|
+
useDndProvider = props.useDndProvider;
|
|
21
|
+
var moveList = function moveList(dragIndex, hoverIndex) {
|
|
22
|
+
var tmp = checkValue[dragIndex]; //临时储存文件
|
|
23
|
+
checkValue.splice(dragIndex, 1); //移除拖拽项
|
|
24
|
+
checkValue.splice(hoverIndex, 0, tmp); //插入放置项
|
|
25
|
+
handlePreviewList(_toConsumableArray(checkValue)); //更新修改后的列表
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var isLockSort = type === "list" && checkValue.filter(function (item) {
|
|
29
|
+
return item.disabled;
|
|
30
|
+
}).length;
|
|
31
|
+
var renderList = function renderList(item, index) {
|
|
32
|
+
return /*#__PURE__*/React.createElement(TopicList, _extends({
|
|
33
|
+
labelValue: item,
|
|
34
|
+
type: type,
|
|
35
|
+
renderColumns: renderColumns,
|
|
36
|
+
label: item.key,
|
|
37
|
+
value: item.title && item.title,
|
|
38
|
+
index: index,
|
|
39
|
+
render: render,
|
|
40
|
+
key: item.key,
|
|
41
|
+
handleDelete: handleDelete,
|
|
42
|
+
moveList: moveList,
|
|
43
|
+
dragList: dragList,
|
|
44
|
+
useDndProvider: useDndProvider,
|
|
45
|
+
isLockSort: isLockSort
|
|
46
|
+
}, item));
|
|
47
|
+
};
|
|
48
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(DndProvider, {
|
|
49
|
+
backend: HTML5Backend
|
|
50
|
+
}, checkValue.map(function (item, index) {
|
|
51
|
+
return renderList(item, index);
|
|
52
|
+
})));
|
|
53
|
+
};
|
|
54
|
+
export default CheckList;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import _Icon from "@chaoswise/ui/lib/Antd/Icon";
|
|
2
|
+
import "@chaoswise/ui/lib/Tooltip/index.less";
|
|
3
|
+
import _Tooltip from "@chaoswise/ui/lib/Tooltip";
|
|
4
|
+
import _ConfigProvider from "@chaoswise/ui/lib/ConfigProvider";
|
|
5
|
+
var _excluded = ["label", "value", "index", "handleDelete", "labelValue", "moveList", "type", "renderColumns", "render", "dragList", "disabled", "isLockSort"];
|
|
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
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."); }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
15
|
+
import React, { Fragment, useRef } from "react";
|
|
16
|
+
import { useDrag, useDrop } from "react-dnd";
|
|
17
|
+
import classnames from "classnames";
|
|
18
|
+
import { getLocale } from "./locale";
|
|
19
|
+
import LockSvg from "./assets/LockSvg";
|
|
20
|
+
import DragSvg from "./assets/DragSvg";
|
|
21
|
+
var TopicList = function TopicList(_ref) {
|
|
22
|
+
var label = _ref.label,
|
|
23
|
+
value = _ref.value,
|
|
24
|
+
index = _ref.index,
|
|
25
|
+
handleDelete = _ref.handleDelete,
|
|
26
|
+
labelValue = _ref.labelValue,
|
|
27
|
+
moveList = _ref.moveList,
|
|
28
|
+
type = _ref.type,
|
|
29
|
+
renderColumns = _ref.renderColumns,
|
|
30
|
+
render = _ref.render,
|
|
31
|
+
dragList = _ref.dragList,
|
|
32
|
+
disabled = _ref.disabled,
|
|
33
|
+
isLockSort = _ref.isLockSort,
|
|
34
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
35
|
+
// 获取当前语言
|
|
36
|
+
var _ConfigProvider$useLo = _ConfigProvider.useLocale(),
|
|
37
|
+
_ConfigProvider$useLo2 = _ConfigProvider$useLo.locale,
|
|
38
|
+
locale = _ConfigProvider$useLo2 === void 0 ? "zh" : _ConfigProvider$useLo2;
|
|
39
|
+
var localeObj = getLocale(locale);
|
|
40
|
+
var dragRef = useRef(null);
|
|
41
|
+
var _useDrag = useDrag({
|
|
42
|
+
item: {
|
|
43
|
+
type: "child",
|
|
44
|
+
value: value,
|
|
45
|
+
index: index,
|
|
46
|
+
label: label,
|
|
47
|
+
labelValue: labelValue
|
|
48
|
+
}
|
|
49
|
+
}),
|
|
50
|
+
_useDrag2 = _slicedToArray(_useDrag, 2),
|
|
51
|
+
drag = _useDrag2[1];
|
|
52
|
+
var _useDrop = useDrop({
|
|
53
|
+
accept: "child",
|
|
54
|
+
hover: function hover(item, monitor) {
|
|
55
|
+
//拖拽目标的Index
|
|
56
|
+
var dragIndex = item.index;
|
|
57
|
+
//放置目标Index
|
|
58
|
+
var hoverIndex = index;
|
|
59
|
+
// 如果拖拽目标和放置目标相同的话,停止执行
|
|
60
|
+
if (dragIndex === hoverIndex) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
//如果不做以下处理,则卡片移动到另一个卡片上就会进行交换,下方处理使得卡片能够在跨过中心线后进行交换.
|
|
64
|
+
//获取卡片的边框矩形
|
|
65
|
+
// const hoverBoundingRect = dragRef.current.getBoundingClientRect();
|
|
66
|
+
// //获取X轴中点
|
|
67
|
+
// const hoverMiddleY =
|
|
68
|
+
// (hoverBoundingRect.bottom - hoverBoundingRect.top) / 2;
|
|
69
|
+
// //获取拖拽目标偏移量
|
|
70
|
+
// const clientOffset = monitor.getClientOffset();
|
|
71
|
+
// const hoverClientY = clientOffset.y - hoverBoundingRect.top;
|
|
72
|
+
// 从上往下放置
|
|
73
|
+
// if (dragIndex < hoverIndex && hoverClientY < hoverMiddleY) {
|
|
74
|
+
// return;
|
|
75
|
+
// }
|
|
76
|
+
// // 从下往上放置
|
|
77
|
+
// if (dragIndex > hoverIndex && hoverClientY > hoverMiddleY) {
|
|
78
|
+
// return;
|
|
79
|
+
// }
|
|
80
|
+
moveList(dragIndex, hoverIndex); //调用方法完成交换
|
|
81
|
+
item.index = hoverIndex; //重新赋值index,否则会出现无限交换情况
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
collect: function collect(monitor) {
|
|
85
|
+
var _ref2 = monitor.getItem() || {},
|
|
86
|
+
dragIndex = _ref2.index;
|
|
87
|
+
if (dragIndex === index) {
|
|
88
|
+
return {};
|
|
89
|
+
}
|
|
90
|
+
return {
|
|
91
|
+
isOver: monitor.isOver(),
|
|
92
|
+
dropClassName: dragIndex < index ? "drop-over-downward" : "drop-over-upward"
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// drop: (item) => {
|
|
96
|
+
// moveList(item.index, index);
|
|
97
|
+
// },
|
|
98
|
+
}),
|
|
99
|
+
_useDrop2 = _slicedToArray(_useDrop, 2),
|
|
100
|
+
_useDrop2$ = _useDrop2[0],
|
|
101
|
+
isOver = _useDrop2$.isOver,
|
|
102
|
+
dropClassName = _useDrop2$.dropClassName,
|
|
103
|
+
drop = _useDrop2[1];
|
|
104
|
+
var handleDeleted = function handleDeleted(labelValue) {
|
|
105
|
+
handleDelete(labelValue);
|
|
106
|
+
};
|
|
107
|
+
var renderTable = function renderTable(labelValue) {
|
|
108
|
+
return /*#__PURE__*/React.createElement("div", null, renderColumns.map(function (item, index) {
|
|
109
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
110
|
+
style: {
|
|
111
|
+
marginRight: "8px"
|
|
112
|
+
},
|
|
113
|
+
key: index
|
|
114
|
+
}, render(labelValue[item]));
|
|
115
|
+
}));
|
|
116
|
+
};
|
|
117
|
+
var dragProps = dragList && !disabled ? {
|
|
118
|
+
ref: drag(drop(dragRef)),
|
|
119
|
+
style: {
|
|
120
|
+
cursor: "move"
|
|
121
|
+
}
|
|
122
|
+
} : {};
|
|
123
|
+
var listLockSortContent = /*#__PURE__*/React.createElement("div", {
|
|
124
|
+
className: "cw-transfer-right-content-item"
|
|
125
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
126
|
+
className: "cw-transfer-right-content-item-drag-wrapper"
|
|
127
|
+
}, disabled ? /*#__PURE__*/React.createElement(LockSvg, null) : /*#__PURE__*/React.createElement(_Tooltip, {
|
|
128
|
+
title: localeObj["dragAndDrop"]
|
|
129
|
+
}, /*#__PURE__*/React.createElement(DragSvg, null))), /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
className: "cw-transfer-right-content-item-text-wrapper"
|
|
131
|
+
}, render(value)), !disabled && /*#__PURE__*/React.createElement(_Icon, {
|
|
132
|
+
type: "close",
|
|
133
|
+
className: "cw-transfer-right-content-del",
|
|
134
|
+
onClick: function onClick() {
|
|
135
|
+
return handleDeleted(labelValue);
|
|
136
|
+
}
|
|
137
|
+
}));
|
|
138
|
+
var renderItemContent = type == "list" && isLockSort ? listLockSortContent : /*#__PURE__*/React.createElement(Fragment, null, dragList && /*#__PURE__*/React.createElement(_Tooltip, {
|
|
139
|
+
title: localeObj["dragAndDrop"]
|
|
140
|
+
}, /*#__PURE__*/React.createElement(DragSvg, {
|
|
141
|
+
className: "cw-transfer-right-content-drag"
|
|
142
|
+
})), /*#__PURE__*/React.createElement("div", null, type === "table" ? renderTable(labelValue) : render(value)), /*#__PURE__*/React.createElement(_Icon, {
|
|
143
|
+
type: "close",
|
|
144
|
+
className: "cw-transfer-right-content-del",
|
|
145
|
+
onClick: function onClick() {
|
|
146
|
+
return handleDeleted(labelValue);
|
|
147
|
+
}
|
|
148
|
+
}));
|
|
149
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
|
|
150
|
+
className: classnames("cw-transfer-right-content-main")
|
|
151
|
+
}, dragProps), renderItemContent));
|
|
152
|
+
};
|
|
153
|
+
export default TopicList;
|
|
@@ -39,7 +39,8 @@ function OutSearch(_ref) {
|
|
|
39
39
|
return searchContent.map(function (value) {
|
|
40
40
|
return {
|
|
41
41
|
id: typeof value.components === "function" ? value.components(form).props.id : value.components.props.id,
|
|
42
|
-
name: typeof value.components === "function" ? value.components(form).props.name : value.components.props.name
|
|
42
|
+
name: typeof value.components === "function" ? value.components(form).props.name : value.components.props.name,
|
|
43
|
+
disabled: Boolean(value.disabled)
|
|
43
44
|
};
|
|
44
45
|
});
|
|
45
46
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEvent } from 'rc-util';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
function voidFunc() {}
|
|
4
|
+
var WatermarkContext = /*#__PURE__*/React.createContext({
|
|
5
|
+
add: voidFunc,
|
|
6
|
+
remove: voidFunc
|
|
7
|
+
});
|
|
8
|
+
export function usePanelRef(panelSelector) {
|
|
9
|
+
var watermark = React.useContext(WatermarkContext);
|
|
10
|
+
var panelEleRef = React.useRef();
|
|
11
|
+
var panelRef = useEvent(function (ele) {
|
|
12
|
+
if (ele) {
|
|
13
|
+
var innerContentEle = panelSelector ? ele.querySelector(panelSelector) : ele;
|
|
14
|
+
watermark.add(innerContentEle);
|
|
15
|
+
panelEleRef.current = innerContentEle;
|
|
16
|
+
} else {
|
|
17
|
+
watermark.remove(panelEleRef.current);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return panelRef;
|
|
21
|
+
}
|
|
22
|
+
export default WatermarkContext;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
4
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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); }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
import React, { useEffect } from 'react';
|
|
12
|
+
import { useMutateObserver } from '@rc-component/mutate-observer';
|
|
13
|
+
import classNames from 'classnames';
|
|
14
|
+
import WatermarkContext from './context';
|
|
15
|
+
import useClips, { FontGap } from './useClips';
|
|
16
|
+
import useRafDebounce from './useRafDebounce';
|
|
17
|
+
import useWatermark from './useWatermark';
|
|
18
|
+
import { getPixelRatio, reRendering, verifyIsArrayOfNumberType } from './utils';
|
|
19
|
+
import PropTypes from "prop-types";
|
|
20
|
+
/**
|
|
21
|
+
* Only return `next` when size changed.
|
|
22
|
+
* This is only used for elements compare, not a shallow equal!
|
|
23
|
+
*/
|
|
24
|
+
function getSizeDiff(prev, next) {
|
|
25
|
+
return prev.size === next.size ? prev : next;
|
|
26
|
+
}
|
|
27
|
+
var DEFAULT_GAP_X = 100;
|
|
28
|
+
var DEFAULT_GAP_Y = 100;
|
|
29
|
+
var Watermark = function Watermark(props) {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
var _props$zIndex = props.zIndex,
|
|
32
|
+
zIndex = _props$zIndex === void 0 ? 9 : _props$zIndex,
|
|
33
|
+
_props$rotate = props.rotate,
|
|
34
|
+
rotate = _props$rotate === void 0 ? -22 : _props$rotate,
|
|
35
|
+
width = props.width,
|
|
36
|
+
height = props.height,
|
|
37
|
+
image = props.image,
|
|
38
|
+
content = props.content,
|
|
39
|
+
_props$font = props.font,
|
|
40
|
+
font = _props$font === void 0 ? {} : _props$font,
|
|
41
|
+
style = props.style,
|
|
42
|
+
className = props.className,
|
|
43
|
+
rootClassName = props.rootClassName,
|
|
44
|
+
_props$gap = props.gap,
|
|
45
|
+
gap = _props$gap === void 0 ? [DEFAULT_GAP_X, DEFAULT_GAP_Y] : _props$gap,
|
|
46
|
+
offset = props.offset,
|
|
47
|
+
children = props.children,
|
|
48
|
+
_props$inherit = props.inherit,
|
|
49
|
+
inherit = _props$inherit === void 0 ? true : _props$inherit;
|
|
50
|
+
var _font$color = font.color,
|
|
51
|
+
color = _font$color === void 0 ? "rgba(0, 0, 0, 0.15)" : _font$color,
|
|
52
|
+
_font$fontSize = font.fontSize,
|
|
53
|
+
fontSize = _font$fontSize === void 0 ? 16 : _font$fontSize,
|
|
54
|
+
_font$fontWeight = font.fontWeight,
|
|
55
|
+
fontWeight = _font$fontWeight === void 0 ? 'normal' : _font$fontWeight,
|
|
56
|
+
_font$fontStyle = font.fontStyle,
|
|
57
|
+
fontStyle = _font$fontStyle === void 0 ? 'normal' : _font$fontStyle,
|
|
58
|
+
_font$fontFamily = font.fontFamily,
|
|
59
|
+
fontFamily = _font$fontFamily === void 0 ? 'sans-serif' : _font$fontFamily,
|
|
60
|
+
_font$textAlign = font.textAlign,
|
|
61
|
+
textAlign = _font$textAlign === void 0 ? 'center' : _font$textAlign;
|
|
62
|
+
var _gap = _slicedToArray(gap, 2),
|
|
63
|
+
_gap$ = _gap[0],
|
|
64
|
+
gapX = _gap$ === void 0 ? DEFAULT_GAP_X : _gap$,
|
|
65
|
+
_gap$2 = _gap[1],
|
|
66
|
+
gapY = _gap$2 === void 0 ? DEFAULT_GAP_Y : _gap$2;
|
|
67
|
+
var gapXCenter = gapX / 2;
|
|
68
|
+
var gapYCenter = gapY / 2;
|
|
69
|
+
var offsetLeft = (_a = offset === null || offset === void 0 ? void 0 : offset[0]) !== null && _a !== void 0 ? _a : gapXCenter;
|
|
70
|
+
var offsetTop = (_b = offset === null || offset === void 0 ? void 0 : offset[1]) !== null && _b !== void 0 ? _b : gapYCenter;
|
|
71
|
+
var markStyle = React.useMemo(function () {
|
|
72
|
+
var mergedStyle = {
|
|
73
|
+
zIndex: zIndex,
|
|
74
|
+
position: 'absolute',
|
|
75
|
+
left: 0,
|
|
76
|
+
top: 0,
|
|
77
|
+
width: '100%',
|
|
78
|
+
height: '100%',
|
|
79
|
+
pointerEvents: 'none',
|
|
80
|
+
backgroundRepeat: 'repeat'
|
|
81
|
+
};
|
|
82
|
+
/** Calculate the style of the offset */
|
|
83
|
+
var positionLeft = offsetLeft - gapXCenter;
|
|
84
|
+
var positionTop = offsetTop - gapYCenter;
|
|
85
|
+
if (positionLeft > 0) {
|
|
86
|
+
mergedStyle.left = "".concat(positionLeft, "px");
|
|
87
|
+
mergedStyle.width = "calc(100% - ".concat(positionLeft, "px)");
|
|
88
|
+
positionLeft = 0;
|
|
89
|
+
}
|
|
90
|
+
if (positionTop > 0) {
|
|
91
|
+
mergedStyle.top = "".concat(positionTop, "px");
|
|
92
|
+
mergedStyle.height = "calc(100% - ".concat(positionTop, "px)");
|
|
93
|
+
positionTop = 0;
|
|
94
|
+
}
|
|
95
|
+
mergedStyle.backgroundPosition = "".concat(positionLeft, "px ").concat(positionTop, "px");
|
|
96
|
+
return mergedStyle;
|
|
97
|
+
}, [zIndex, offsetLeft, gapXCenter, offsetTop, gapYCenter]);
|
|
98
|
+
var _React$useState = React.useState(),
|
|
99
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
100
|
+
container = _React$useState2[0],
|
|
101
|
+
setContainer = _React$useState2[1];
|
|
102
|
+
// Used for nest case like Modal, Drawer
|
|
103
|
+
var _React$useState3 = React.useState(new Set()),
|
|
104
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
105
|
+
subElements = _React$useState4[0],
|
|
106
|
+
setSubElements = _React$useState4[1];
|
|
107
|
+
// Nest elements should also support watermark
|
|
108
|
+
var targetElements = React.useMemo(function () {
|
|
109
|
+
var list = container ? [container] : [];
|
|
110
|
+
return [].concat(list, _toConsumableArray(Array.from(subElements)));
|
|
111
|
+
}, [container, subElements]);
|
|
112
|
+
// ============================ Content =============================
|
|
113
|
+
/**
|
|
114
|
+
* Get the width and height of the watermark. The default values are as follows
|
|
115
|
+
* Image: [120, 64]; Content: It's calculated by content;
|
|
116
|
+
*/
|
|
117
|
+
var getMarkSize = function getMarkSize(ctx) {
|
|
118
|
+
var defaultWidth = 120;
|
|
119
|
+
var defaultHeight = 64;
|
|
120
|
+
if (!image && ctx.measureText) {
|
|
121
|
+
ctx.font = "".concat(Number(fontSize), "px ").concat(fontFamily);
|
|
122
|
+
var contents = Array.isArray(content) ? content : [content];
|
|
123
|
+
var sizes = contents.map(function (item) {
|
|
124
|
+
var metrics = ctx.measureText(item);
|
|
125
|
+
return [metrics.width, metrics.fontBoundingBoxAscent + metrics.fontBoundingBoxDescent];
|
|
126
|
+
});
|
|
127
|
+
defaultWidth = Math.ceil(Math.max.apply(Math, _toConsumableArray(sizes.map(function (size) {
|
|
128
|
+
return size[0];
|
|
129
|
+
}))));
|
|
130
|
+
defaultHeight = Math.ceil(Math.max.apply(Math, _toConsumableArray(sizes.map(function (size) {
|
|
131
|
+
return size[1];
|
|
132
|
+
})))) * contents.length + (contents.length - 1) * FontGap;
|
|
133
|
+
}
|
|
134
|
+
return [width !== null && width !== void 0 ? width : defaultWidth, height !== null && height !== void 0 ? height : defaultHeight];
|
|
135
|
+
};
|
|
136
|
+
var getClips = useClips();
|
|
137
|
+
var _React$useState5 = React.useState(null),
|
|
138
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
139
|
+
watermarkInfo = _React$useState6[0],
|
|
140
|
+
setWatermarkInfo = _React$useState6[1];
|
|
141
|
+
// Generate new Watermark content
|
|
142
|
+
var renderWatermark = function renderWatermark() {
|
|
143
|
+
var canvas = document.createElement('canvas');
|
|
144
|
+
var ctx = canvas.getContext('2d');
|
|
145
|
+
if (ctx) {
|
|
146
|
+
var ratio = getPixelRatio();
|
|
147
|
+
var _getMarkSize = getMarkSize(ctx),
|
|
148
|
+
_getMarkSize2 = _slicedToArray(_getMarkSize, 2),
|
|
149
|
+
markWidth = _getMarkSize2[0],
|
|
150
|
+
markHeight = _getMarkSize2[1];
|
|
151
|
+
var drawCanvas = function drawCanvas(drawContent) {
|
|
152
|
+
var _getClips = getClips(drawContent || '', rotate, ratio, markWidth, markHeight, {
|
|
153
|
+
color: color,
|
|
154
|
+
fontSize: fontSize,
|
|
155
|
+
fontStyle: fontStyle,
|
|
156
|
+
fontWeight: fontWeight,
|
|
157
|
+
fontFamily: fontFamily,
|
|
158
|
+
textAlign: textAlign
|
|
159
|
+
}, gapX, gapY),
|
|
160
|
+
_getClips2 = _slicedToArray(_getClips, 2),
|
|
161
|
+
nextClips = _getClips2[0],
|
|
162
|
+
clipWidth = _getClips2[1];
|
|
163
|
+
setWatermarkInfo([nextClips, clipWidth]);
|
|
164
|
+
};
|
|
165
|
+
if (image) {
|
|
166
|
+
var img = new Image();
|
|
167
|
+
img.onload = function () {
|
|
168
|
+
drawCanvas(img);
|
|
169
|
+
};
|
|
170
|
+
img.onerror = function () {
|
|
171
|
+
drawCanvas(content);
|
|
172
|
+
};
|
|
173
|
+
img.crossOrigin = 'anonymous';
|
|
174
|
+
img.referrerPolicy = 'no-referrer';
|
|
175
|
+
img.src = image;
|
|
176
|
+
} else {
|
|
177
|
+
drawCanvas(content);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
var syncWatermark = useRafDebounce(renderWatermark);
|
|
182
|
+
// ============================= Effect =============================
|
|
183
|
+
// Append watermark to the container
|
|
184
|
+
var _useWatermark = useWatermark(markStyle),
|
|
185
|
+
_useWatermark2 = _slicedToArray(_useWatermark, 3),
|
|
186
|
+
appendWatermark = _useWatermark2[0],
|
|
187
|
+
removeWatermark = _useWatermark2[1],
|
|
188
|
+
isWatermarkEle = _useWatermark2[2];
|
|
189
|
+
useEffect(function () {
|
|
190
|
+
if (watermarkInfo) {
|
|
191
|
+
targetElements.forEach(function (holder) {
|
|
192
|
+
appendWatermark(watermarkInfo[0], watermarkInfo[1], holder);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
}, [watermarkInfo, targetElements]);
|
|
196
|
+
// ============================ Observe =============================
|
|
197
|
+
var onMutate = function onMutate(mutations) {
|
|
198
|
+
mutations.forEach(function (mutation) {
|
|
199
|
+
if (reRendering(mutation, isWatermarkEle)) {
|
|
200
|
+
syncWatermark();
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
};
|
|
204
|
+
useMutateObserver(targetElements, onMutate);
|
|
205
|
+
useEffect(syncWatermark, [rotate, zIndex, width, height, image, content, color, fontSize, fontWeight, fontStyle, fontFamily, textAlign, gapX, gapY, offsetLeft, offsetTop]);
|
|
206
|
+
// ============================ Context =============================
|
|
207
|
+
var watermarkContext = React.useMemo(function () {
|
|
208
|
+
return {
|
|
209
|
+
add: function add(ele) {
|
|
210
|
+
setSubElements(function (prev) {
|
|
211
|
+
var clone = new Set(prev);
|
|
212
|
+
clone.add(ele);
|
|
213
|
+
return getSizeDiff(prev, clone);
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
remove: function remove(ele) {
|
|
217
|
+
removeWatermark(ele);
|
|
218
|
+
setSubElements(function (prev) {
|
|
219
|
+
var clone = new Set(prev);
|
|
220
|
+
clone["delete"](ele);
|
|
221
|
+
return getSizeDiff(prev, clone);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
}, []);
|
|
226
|
+
// ============================= Render =============================
|
|
227
|
+
var childNode = inherit ? /*#__PURE__*/React.createElement(WatermarkContext.Provider, {
|
|
228
|
+
value: watermarkContext
|
|
229
|
+
}, children) : children;
|
|
230
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
231
|
+
ref: setContainer,
|
|
232
|
+
className: classNames(className, rootClassName),
|
|
233
|
+
style: Object.assign({
|
|
234
|
+
position: 'relative'
|
|
235
|
+
}, style)
|
|
236
|
+
}, childNode);
|
|
237
|
+
};
|
|
238
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
239
|
+
Watermark.displayName = 'Watermark';
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
//默认值
|
|
243
|
+
Watermark.defaultProps = {
|
|
244
|
+
width: 120,
|
|
245
|
+
height: 64,
|
|
246
|
+
inherit: true,
|
|
247
|
+
rotate: -20,
|
|
248
|
+
zIndex: 9,
|
|
249
|
+
font: {
|
|
250
|
+
color: 'rgba(0,0,0,.15)',
|
|
251
|
+
fontSize: 16,
|
|
252
|
+
fontFamily: 'sans-serif',
|
|
253
|
+
fontStyle: 'normal'
|
|
254
|
+
},
|
|
255
|
+
gap: [100, 100],
|
|
256
|
+
offset: [50, 50]
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
//Api
|
|
260
|
+
Watermark.propTypes = {
|
|
261
|
+
/**
|
|
262
|
+
* 宽度,水印的宽度,content 的默认值为自身的宽度
|
|
263
|
+
*/
|
|
264
|
+
width: PropTypes.number,
|
|
265
|
+
/**
|
|
266
|
+
* 水印的高度,content 的默认值为自身的高度
|
|
267
|
+
*/
|
|
268
|
+
height: PropTypes.number,
|
|
269
|
+
/**
|
|
270
|
+
* 是否将水印传导给弹出组件如 Modal、Drawer
|
|
271
|
+
*/
|
|
272
|
+
inherit: PropTypes.bool,
|
|
273
|
+
/**
|
|
274
|
+
* 水印绘制时,旋转的角度,单位 °
|
|
275
|
+
*/
|
|
276
|
+
rotate: PropTypes.number,
|
|
277
|
+
/**
|
|
278
|
+
* 追加的水印元素的 z-index
|
|
279
|
+
*/
|
|
280
|
+
zIndex: PropTypes.number,
|
|
281
|
+
/**
|
|
282
|
+
* 图片源,建议导出 2 倍或 3 倍图,优先级高 (支持 base64 格式)
|
|
283
|
+
*/
|
|
284
|
+
image: PropTypes.string,
|
|
285
|
+
/**
|
|
286
|
+
* 水印文字内容
|
|
287
|
+
*/
|
|
288
|
+
content: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
|
289
|
+
/**
|
|
290
|
+
* 文字样式<br/>
|
|
291
|
+
* color:字体颜色 <br/>
|
|
292
|
+
* fontSize:字体大小 (number) <br/>
|
|
293
|
+
* fontWeight:字体粗细 (normal | light | weight | number) <br/>
|
|
294
|
+
* fontFamily:字体类型 (string)<br/>
|
|
295
|
+
* fontStyle:字体样式 (none | normal | italic | oblique)<br/>
|
|
296
|
+
* textAlign:指定文本对齐方向 <br/>
|
|
297
|
+
*/
|
|
298
|
+
font: PropTypes.object,
|
|
299
|
+
/**
|
|
300
|
+
* gap 水印之间的间距
|
|
301
|
+
*/
|
|
302
|
+
gap: verifyIsArrayOfNumberType,
|
|
303
|
+
/**
|
|
304
|
+
* 水印距离容器左上角的偏移量,默认为 gap/2
|
|
305
|
+
*/
|
|
306
|
+
offset: verifyIsArrayOfNumberType
|
|
307
|
+
};
|
|
308
|
+
export default Watermark;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
export var FontGap = 3;
|
|
8
|
+
function prepareCanvas(width, height) {
|
|
9
|
+
var ratio = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
10
|
+
var canvas = document.createElement('canvas');
|
|
11
|
+
var ctx = canvas.getContext('2d');
|
|
12
|
+
var realWidth = width * ratio;
|
|
13
|
+
var realHeight = height * ratio;
|
|
14
|
+
canvas.setAttribute('width', "".concat(realWidth, "px"));
|
|
15
|
+
canvas.setAttribute('height', "".concat(realHeight, "px"));
|
|
16
|
+
ctx.save();
|
|
17
|
+
return [ctx, canvas, realWidth, realHeight];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Get the clips of text content.
|
|
21
|
+
* This is a lazy hook function since SSR no need this
|
|
22
|
+
*/
|
|
23
|
+
export default function useClips() {
|
|
24
|
+
// Get single clips
|
|
25
|
+
function getClips(content, rotate, ratio, width, height, font, gapX, gapY) {
|
|
26
|
+
// ================= Text / Image =================
|
|
27
|
+
var _prepareCanvas = prepareCanvas(width, height, ratio),
|
|
28
|
+
_prepareCanvas2 = _slicedToArray(_prepareCanvas, 4),
|
|
29
|
+
ctx = _prepareCanvas2[0],
|
|
30
|
+
canvas = _prepareCanvas2[1],
|
|
31
|
+
contentWidth = _prepareCanvas2[2],
|
|
32
|
+
contentHeight = _prepareCanvas2[3];
|
|
33
|
+
if (content instanceof HTMLImageElement) {
|
|
34
|
+
// Image
|
|
35
|
+
ctx.drawImage(content, 0, 0, contentWidth, contentHeight);
|
|
36
|
+
} else {
|
|
37
|
+
// Text
|
|
38
|
+
var color = font.color,
|
|
39
|
+
fontSize = font.fontSize,
|
|
40
|
+
fontStyle = font.fontStyle,
|
|
41
|
+
fontWeight = font.fontWeight,
|
|
42
|
+
fontFamily = font.fontFamily,
|
|
43
|
+
textAlign = font.textAlign;
|
|
44
|
+
var mergedFontSize = Number(fontSize) * ratio;
|
|
45
|
+
ctx.font = "".concat(fontStyle, " normal ").concat(fontWeight, " ").concat(mergedFontSize, "px/").concat(height, "px ").concat(fontFamily);
|
|
46
|
+
ctx.fillStyle = color;
|
|
47
|
+
ctx.textAlign = textAlign;
|
|
48
|
+
ctx.textBaseline = 'top';
|
|
49
|
+
var contents = Array.isArray(content) ? content : [content];
|
|
50
|
+
contents === null || contents === void 0 ? void 0 : contents.forEach(function (item, index) {
|
|
51
|
+
ctx.fillText(item !== null && item !== void 0 ? item : '', contentWidth / 2, index * (mergedFontSize + FontGap * ratio));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// ==================== Rotate ====================
|
|
55
|
+
var angle = Math.PI / 180 * Number(rotate);
|
|
56
|
+
var maxSize = Math.max(width, height);
|
|
57
|
+
var _prepareCanvas3 = prepareCanvas(maxSize, maxSize, ratio),
|
|
58
|
+
_prepareCanvas4 = _slicedToArray(_prepareCanvas3, 3),
|
|
59
|
+
rCtx = _prepareCanvas4[0],
|
|
60
|
+
rCanvas = _prepareCanvas4[1],
|
|
61
|
+
realMaxSize = _prepareCanvas4[2];
|
|
62
|
+
// Copy from `ctx` and rotate
|
|
63
|
+
rCtx.translate(realMaxSize / 2, realMaxSize / 2);
|
|
64
|
+
rCtx.rotate(angle);
|
|
65
|
+
if (contentWidth > 0 && contentHeight > 0) {
|
|
66
|
+
rCtx.drawImage(canvas, -contentWidth / 2, -contentHeight / 2);
|
|
67
|
+
}
|
|
68
|
+
// Get boundary of rotated text
|
|
69
|
+
function getRotatePos(x, y) {
|
|
70
|
+
var targetX = x * Math.cos(angle) - y * Math.sin(angle);
|
|
71
|
+
var targetY = x * Math.sin(angle) + y * Math.cos(angle);
|
|
72
|
+
return [targetX, targetY];
|
|
73
|
+
}
|
|
74
|
+
var left = 0;
|
|
75
|
+
var right = 0;
|
|
76
|
+
var top = 0;
|
|
77
|
+
var bottom = 0;
|
|
78
|
+
var halfWidth = contentWidth / 2;
|
|
79
|
+
var halfHeight = contentHeight / 2;
|
|
80
|
+
var points = [[0 - halfWidth, 0 - halfHeight], [0 + halfWidth, 0 - halfHeight], [0 + halfWidth, 0 + halfHeight], [0 - halfWidth, 0 + halfHeight]];
|
|
81
|
+
points.forEach(function (_ref) {
|
|
82
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
83
|
+
x = _ref2[0],
|
|
84
|
+
y = _ref2[1];
|
|
85
|
+
var _getRotatePos = getRotatePos(x, y),
|
|
86
|
+
_getRotatePos2 = _slicedToArray(_getRotatePos, 2),
|
|
87
|
+
targetX = _getRotatePos2[0],
|
|
88
|
+
targetY = _getRotatePos2[1];
|
|
89
|
+
left = Math.min(left, targetX);
|
|
90
|
+
right = Math.max(right, targetX);
|
|
91
|
+
top = Math.min(top, targetY);
|
|
92
|
+
bottom = Math.max(bottom, targetY);
|
|
93
|
+
});
|
|
94
|
+
var cutLeft = left + realMaxSize / 2;
|
|
95
|
+
var cutTop = top + realMaxSize / 2;
|
|
96
|
+
var cutWidth = right - left;
|
|
97
|
+
var cutHeight = bottom - top;
|
|
98
|
+
// ================ Fill Alternate ================
|
|
99
|
+
var realGapX = gapX * ratio;
|
|
100
|
+
var realGapY = gapY * ratio;
|
|
101
|
+
var filledWidth = (cutWidth + realGapX) * 2;
|
|
102
|
+
var filledHeight = cutHeight + realGapY;
|
|
103
|
+
var _prepareCanvas5 = prepareCanvas(filledWidth, filledHeight),
|
|
104
|
+
_prepareCanvas6 = _slicedToArray(_prepareCanvas5, 2),
|
|
105
|
+
fCtx = _prepareCanvas6[0],
|
|
106
|
+
fCanvas = _prepareCanvas6[1];
|
|
107
|
+
function drawImg() {
|
|
108
|
+
var targetX = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
109
|
+
var targetY = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
110
|
+
fCtx.drawImage(rCanvas, cutLeft, cutTop, cutWidth, cutHeight, targetX, targetY, cutWidth, cutHeight);
|
|
111
|
+
}
|
|
112
|
+
drawImg();
|
|
113
|
+
drawImg(cutWidth + realGapX, -cutHeight / 2 - realGapY / 2);
|
|
114
|
+
drawImg(cutWidth + realGapX, +cutHeight / 2 + realGapY / 2);
|
|
115
|
+
return [fCanvas.toDataURL(), filledWidth / ratio, filledHeight / ratio];
|
|
116
|
+
}
|
|
117
|
+
return getClips;
|
|
118
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import raf from 'rc-util/lib/raf';
|
|
3
|
+
import { useEvent } from 'rc-util';
|
|
4
|
+
/**
|
|
5
|
+
* Callback will only execute last one for each raf
|
|
6
|
+
*/
|
|
7
|
+
export default function useRafDebounce(callback) {
|
|
8
|
+
var executeRef = React.useRef(false);
|
|
9
|
+
var rafRef = React.useRef();
|
|
10
|
+
var wrapperCallback = useEvent(callback);
|
|
11
|
+
return function () {
|
|
12
|
+
if (executeRef.current) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
executeRef.current = true;
|
|
16
|
+
wrapperCallback();
|
|
17
|
+
rafRef.current = raf(function () {
|
|
18
|
+
executeRef.current = false;
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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."); }
|
|
3
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import * as React from 'react';
|
|
8
|
+
import { getStyleStr } from './utils';
|
|
9
|
+
/**
|
|
10
|
+
* Base size of the canvas, 1 for parallel layout and 2 for alternate layout
|
|
11
|
+
* Only alternate layout is currently supported
|
|
12
|
+
*/
|
|
13
|
+
export var BaseSize = 2;
|
|
14
|
+
export var FontGap = 3;
|
|
15
|
+
// Prevent external hidden elements from adding accent styles
|
|
16
|
+
var EmphasizedStyles = {
|
|
17
|
+
visibility: 'visible !important'
|
|
18
|
+
};
|
|
19
|
+
export default function useWatermark(markStyle) {
|
|
20
|
+
var _React$useState = React.useState(function () {
|
|
21
|
+
return new Map();
|
|
22
|
+
}),
|
|
23
|
+
_React$useState2 = _slicedToArray(_React$useState, 1),
|
|
24
|
+
watermarkMap = _React$useState2[0];
|
|
25
|
+
var appendWatermark = function appendWatermark(base64Url, markWidth, container) {
|
|
26
|
+
if (container) {
|
|
27
|
+
if (!watermarkMap.get(container)) {
|
|
28
|
+
var newWatermarkEle = document.createElement('div');
|
|
29
|
+
watermarkMap.set(container, newWatermarkEle);
|
|
30
|
+
}
|
|
31
|
+
var watermarkEle = watermarkMap.get(container);
|
|
32
|
+
watermarkEle.setAttribute('style', getStyleStr(Object.assign(Object.assign(Object.assign({}, markStyle), {
|
|
33
|
+
backgroundImage: "url('".concat(base64Url, "')"),
|
|
34
|
+
backgroundSize: "".concat(Math.floor(markWidth), "px")
|
|
35
|
+
}), EmphasizedStyles)));
|
|
36
|
+
// Prevents using the browser `Hide Element` to hide watermarks
|
|
37
|
+
watermarkEle.removeAttribute('class');
|
|
38
|
+
container.append(watermarkEle);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
var removeWatermark = function removeWatermark(container) {
|
|
42
|
+
var watermarkEle = watermarkMap.get(container);
|
|
43
|
+
if (watermarkEle && container) {
|
|
44
|
+
container.removeChild(watermarkEle);
|
|
45
|
+
}
|
|
46
|
+
watermarkMap["delete"](container);
|
|
47
|
+
};
|
|
48
|
+
var isWatermarkEle = function isWatermarkEle(ele) {
|
|
49
|
+
return Array.from(watermarkMap.values()).includes(ele);
|
|
50
|
+
};
|
|
51
|
+
return [appendWatermark, removeWatermark, isWatermarkEle];
|
|
52
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** converting camel-cased strings to be lowercase and link it with Separato */
|
|
2
|
+
export function toLowercaseSeparator(key) {
|
|
3
|
+
return key.replace(/([A-Z])/g, '-$1').toLowerCase();
|
|
4
|
+
}
|
|
5
|
+
export function getStyleStr(style) {
|
|
6
|
+
return Object.keys(style).map(function (key) {
|
|
7
|
+
return "".concat(toLowercaseSeparator(key), ": ").concat(style[key], ";");
|
|
8
|
+
}).join(' ');
|
|
9
|
+
}
|
|
10
|
+
/** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */
|
|
11
|
+
export function getPixelRatio() {
|
|
12
|
+
return window.devicePixelRatio || 1;
|
|
13
|
+
}
|
|
14
|
+
/** Whether to re-render the watermark */
|
|
15
|
+
export var reRendering = function reRendering(mutation, isWatermarkEle) {
|
|
16
|
+
var flag = false;
|
|
17
|
+
// Whether to delete the watermark node
|
|
18
|
+
if (mutation.removedNodes.length) {
|
|
19
|
+
flag = Array.from(mutation.removedNodes).some(function (node) {
|
|
20
|
+
return isWatermarkEle(node);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// Whether the watermark dom property value has been modified
|
|
24
|
+
if (mutation.type === 'attributes' && isWatermarkEle(mutation.target)) {
|
|
25
|
+
flag = true;
|
|
26
|
+
}
|
|
27
|
+
return flag;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 自定义验证是否是数值类型组成的数组且长度为2
|
|
31
|
+
*/
|
|
32
|
+
export var verifyIsArrayOfNumberType = function verifyIsArrayOfNumberType(props, propName, componentName) {
|
|
33
|
+
if (props[propName] && props[propName].length !== 2) {
|
|
34
|
+
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an array of length 2."));
|
|
35
|
+
}
|
|
36
|
+
if (props[propName] && !Array.isArray(props[propName])) {
|
|
37
|
+
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an array."));
|
|
38
|
+
}
|
|
39
|
+
if (props[propName] && (typeof props[propName][0] !== 'number' || typeof props[propName][1] !== 'number')) {
|
|
40
|
+
return new Error("Invalid prop ".concat(propName, " supplied to ").concat(componentName, ". Expected an array of numbers."));
|
|
41
|
+
}
|
|
42
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chaoswise/ui",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.17",
|
|
4
4
|
"description": "公共UI库",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ui",
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"@formily/antd": "^1.3.17",
|
|
77
77
|
"@formily/antd-components": "^1.3.17",
|
|
78
78
|
"@icon-park/react": "^1.4.2",
|
|
79
|
+
"@rc-component/mutate-observer": "^1.1.0",
|
|
79
80
|
"ant-design-draggable-modal": "0.0.16",
|
|
80
81
|
"antd": "^3.26.19",
|
|
81
82
|
"axios": "^0.21.1",
|
|
@@ -104,14 +105,14 @@
|
|
|
104
105
|
"react-draggable": "^4.4.3",
|
|
105
106
|
"react-infinite-scroller": "^1.2.4",
|
|
106
107
|
"react-intl": "^6.0.5",
|
|
107
|
-
"react-joyride": "
|
|
108
|
+
"react-joyride": "2.3.2",
|
|
108
109
|
"react-resizable": "^3.0.4",
|
|
109
110
|
"react-router-cache-route": "1.11.1",
|
|
110
111
|
"react-select": "^3.2.0",
|
|
111
112
|
"react-viewer": "^3.2.2",
|
|
112
113
|
"resize-observer-polyfill": "^1.5.1",
|
|
113
114
|
"scroll-into-view-if-needed": "^2.2.25",
|
|
114
|
-
"socket.io-client": "
|
|
115
|
+
"socket.io-client": "2.5.0",
|
|
115
116
|
"styled-components": "^5.2.1"
|
|
116
117
|
},
|
|
117
118
|
"author": "cloudwiser",
|
|
@@ -142,5 +143,5 @@
|
|
|
142
143
|
"access": "public"
|
|
143
144
|
},
|
|
144
145
|
"license": "MIT",
|
|
145
|
-
"gitHead": "
|
|
146
|
+
"gitHead": "dbf844ed6b6556903c5aae1176312a47d3c97065"
|
|
146
147
|
}
|