dlt-for-react 2.1.11 → 2.2.1
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 +4 -1
- package/assets/components/HqUeditor/images/anchor.gif +0 -0
- package/assets/components/HqUeditor/images/arrow.png +0 -0
- package/assets/components/HqUeditor/images/arrow_down.png +0 -0
- package/assets/components/HqUeditor/images/arrow_up.png +0 -0
- package/assets/components/HqUeditor/images/button-bg.gif +0 -0
- package/assets/components/HqUeditor/images/cancelbutton.gif +0 -0
- package/assets/components/HqUeditor/images/charts.png +0 -0
- package/assets/components/HqUeditor/images/cursor_h.gif +0 -0
- package/assets/components/HqUeditor/images/cursor_h.png +0 -0
- package/assets/components/HqUeditor/images/cursor_v.gif +0 -0
- package/assets/components/HqUeditor/images/cursor_v.png +0 -0
- package/assets/components/HqUeditor/images/dialog-title-bg.png +0 -0
- package/assets/components/HqUeditor/images/filescan.png +0 -0
- package/assets/components/HqUeditor/images/highlighted.gif +0 -0
- package/assets/components/HqUeditor/images/icons-all.gif +0 -0
- package/assets/components/HqUeditor/images/icons.gif +0 -0
- package/assets/components/HqUeditor/images/icons.png +0 -0
- package/assets/components/HqUeditor/images/loaderror.png +0 -0
- package/assets/components/HqUeditor/images/loading.gif +0 -0
- package/assets/components/HqUeditor/images/lock.gif +0 -0
- package/assets/components/HqUeditor/images/neweditor-tab-bg.png +0 -0
- package/assets/components/HqUeditor/images/pagebreak.gif +0 -0
- package/assets/components/HqUeditor/images/scale.png +0 -0
- package/assets/components/HqUeditor/images/sortable.png +0 -0
- package/assets/components/HqUeditor/images/spacer.gif +0 -0
- package/assets/components/HqUeditor/images/sparator_v.png +0 -0
- package/assets/components/HqUeditor/images/table-cell-align.png +0 -0
- package/assets/components/HqUeditor/images/tangram-colorpicker.png +0 -0
- package/assets/components/HqUeditor/images/toolbar_bg.png +0 -0
- package/assets/components/HqUeditor/images/unhighlighted.gif +0 -0
- package/assets/components/HqUeditor/images/upload.png +0 -0
- package/assets/components/HqUeditor/images/videologo.gif +0 -0
- package/assets/components/HqUeditor/images/word.gif +0 -0
- package/assets/components/HqUeditor/images/wordpaste.png +0 -0
- package/assets/components/HqUeditor/ueditor/index.html +175 -0
- package/assets/components/HqUeditor/ueditor/lang/en/en.js +684 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/addimage.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/alldeletebtnupskin.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/background.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/button.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/copy.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/deletedisable.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/deleteenable.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/listbackground.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/localimage.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/music.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/rotateleftdisable.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/rotateleftenable.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/rotaterightdisable.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/rotaterightenable.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/en/images/upload.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/zh-cn/images/copy.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/zh-cn/images/localimage.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/zh-cn/images/music.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/zh-cn/images/upload.png +0 -0
- package/assets/components/HqUeditor/ueditor/lang/zh-cn/zh-cn.js +669 -0
- package/assets/components/HqUeditor/ueditor/themes/default/css/ueditor.css +1898 -0
- package/assets/components/HqUeditor/ueditor/themes/default/css/ueditor.min.css +1843 -0
- package/assets/components/HqUeditor/ueditor/themes/default/dialogbase.css +100 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/anchor.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/arrow.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/arrow_down.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/arrow_up.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/button-bg.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/cancelbutton.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/charts.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/cursor_h.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/cursor_h.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/cursor_v.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/cursor_v.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/dialog-title-bg.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/filescan.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/highlighted.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/icons-all.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/icons.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/icons.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/loaderror.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/loading.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/lock.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/neweditor-tab-bg.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/pagebreak.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/scale.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/sortable.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/spacer.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/sparator_v.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/table-cell-align.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/tangram-colorpicker.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/toolbar_bg.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/unhighlighted.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/upload.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/videologo.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/word.gif +0 -0
- package/assets/components/HqUeditor/ueditor/themes/default/images/wordpaste.png +0 -0
- package/assets/components/HqUeditor/ueditor/themes/iframe.css +1 -0
- package/assets/components/HqUeditor/ueditor/ueditor.all.js +29582 -0
- package/assets/components/HqUeditor/ueditor/ueditor.all.min.js +1 -0
- package/assets/components/HqUeditor/ueditor/ueditor.config.js +586 -0
- package/assets/components/HqUeditor/ueditor/ueditor.parse.js +1022 -0
- package/assets/components/HqUeditor/ueditor/ueditor.parse.min.js +7 -0
- package/assets/components/HqUeditor/ueditor.css +1898 -0
- package/assets/components/HqUeditor/ueditor.min.css +1843 -0
- package/assets/css/HqTimeRange/index.less +7 -0
- package/lib/components/HqCheckButton/index.js +32 -32
- package/lib/components/HqPrint/index.js +51 -0
- package/lib/components/HqTimeRange/index.js +1 -1
- package/lib/components/HqUeditor/file/EditForm.js +297 -0
- package/lib/components/HqUeditor/file/index.js +150 -0
- package/lib/components/HqUeditor/img/EditForm.js +310 -0
- package/lib/components/HqUeditor/img/index.js +150 -0
- package/lib/components/HqUeditor/index.js +239 -0
- package/lib/components/HqUeditor/link/EditForm.js +121 -0
- package/lib/components/HqUeditor/link/index.js +163 -0
- package/lib/components/KyTable/index.js +5 -4
- package/lib/components/KyUpload/index.js +165 -172
- package/lib/index.js +9 -0
- package/lib/utils/common.js +3 -9
- package/lib/utils/createUuid.js +40 -0
- package/lib/utils/getLoginUser.js +10 -0
- package/lib/utils/getSize.js +27 -0
- package/package.json +2 -1
- package/lib/components/NHSelector/ListSort/index.js +0 -411
- package/lib/components/NHSelector/index.js +0 -636
- package/lib/components/NHSelector/resultview/index.js +0 -408
- package/lib/components/NHSelector/selectormodal/index.js +0 -303
- package/lib/components/NHSelector/table/index.js +0 -784
- package/lib/components/NHSelector/tree/index.js +0 -554
- /package/assets/{HqCheckButton → css/HqCheckButton}/index.less +0 -0
package/lib/index.js
CHANGED
|
@@ -409,6 +409,15 @@ Object.defineProperty(exports, 'HqTimeRange', {
|
|
|
409
409
|
}
|
|
410
410
|
});
|
|
411
411
|
|
|
412
|
+
var _HqPrint = require('./components/HqPrint');
|
|
413
|
+
|
|
414
|
+
Object.defineProperty(exports, 'HqPrint', {
|
|
415
|
+
enumerable: true,
|
|
416
|
+
get: function get() {
|
|
417
|
+
return _interopRequireDefault(_HqPrint).default;
|
|
418
|
+
}
|
|
419
|
+
});
|
|
420
|
+
|
|
412
421
|
var _equalsObj = require('./utils/equalsObj.js');
|
|
413
422
|
|
|
414
423
|
Object.defineProperty(exports, 'equalsObj', {
|
package/lib/utils/common.js
CHANGED
|
@@ -591,21 +591,15 @@ var isEqual = exports.isEqual = function isEqual(a, b) {
|
|
|
591
591
|
};
|
|
592
592
|
|
|
593
593
|
/*******
|
|
594
|
-
* @description:
|
|
595
|
-
* 在判断参数是否为空时,希望把null,undefined,{},[],"",NaN这六类都判定为空
|
|
594
|
+
* @description: 校验空值参数:将 ''|null|undefined|NaN|[]|{} 判断为空
|
|
596
595
|
* @author: 琴时
|
|
597
596
|
* @param {*} params [需要校验的参数]
|
|
598
597
|
* @return {Boolean} [空:true,非空:false]
|
|
599
598
|
*/
|
|
600
599
|
var isEmpty = exports.isEmpty = function isEmpty(params) {
|
|
601
|
-
/* 检验字符串类型:空字符串/字符串null/字符串undefined/字符串{}/字符串[]==>也判断为空 */
|
|
602
|
-
var array = ['', 'null', 'undefined', '{}', '[]'];
|
|
603
|
-
if (array.some(function (str) {
|
|
604
|
-
return params === str;
|
|
605
|
-
})) return true;
|
|
606
600
|
if (params === 0 || params === 1) return false; //过滤0/1
|
|
607
|
-
if (!Boolean(params)) return true; //校验undefined/null/NaN
|
|
608
|
-
|
|
601
|
+
if (!Boolean(params)) return true; //校验''/undefined/null/NaN
|
|
602
|
+
if (IsType('String', params) && params.trim() === '') return true; //校验多空格空字符串
|
|
609
603
|
if (IsType('Array', params) && params.length === 0) return true; //检验空数组[]
|
|
610
604
|
if (IsType('Object', params) && (0, _keys2.default)(params).length === 0) return true; //检验空对象{}
|
|
611
605
|
return false; //非空
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
//获取UUID
|
|
7
|
+
var createUuid = function createUuid() {
|
|
8
|
+
var len = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 32;
|
|
9
|
+
var radix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;
|
|
10
|
+
|
|
11
|
+
var chars = '0123456789abcdefghijklmnopqrstuvwxyz'.split('');
|
|
12
|
+
var uuid = [],
|
|
13
|
+
i;
|
|
14
|
+
radix = radix || chars.length;
|
|
15
|
+
|
|
16
|
+
if (len) {
|
|
17
|
+
// Compact form
|
|
18
|
+
for (i = 0; i < len; i++) {
|
|
19
|
+
uuid[i] = chars[0 | Math.random() * radix];
|
|
20
|
+
}
|
|
21
|
+
} else {
|
|
22
|
+
// rfc4122, version 4 form
|
|
23
|
+
var r;
|
|
24
|
+
|
|
25
|
+
// rfc4122 requires these characters
|
|
26
|
+
uuid[8] = uuid[13] = uuid[18] = uuid[23] = '-';
|
|
27
|
+
uuid[14] = '4';
|
|
28
|
+
|
|
29
|
+
// Fill in random data. At i==19 set the high bits of clock sequence as
|
|
30
|
+
// per rfc4122, sec. 4.1.5
|
|
31
|
+
for (i = 0; i < 36; i++) {
|
|
32
|
+
if (!uuid[i]) {
|
|
33
|
+
r = 0 | Math.random() * 16;
|
|
34
|
+
uuid[i] = chars[i == 19 ? r & 0x3 | 0x8 : r];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return uuid.join('');
|
|
39
|
+
};
|
|
40
|
+
exports.default = createUuid;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var getLoginUser = function getLoginUser(auth) {
|
|
7
|
+
var loginUser = sessionStorage.getItem('userLogin') ? JSON.parse(sessionStorage.getItem('userLogin')) : { authorization: {}, menus: [] };
|
|
8
|
+
return loginUser;
|
|
9
|
+
};
|
|
10
|
+
exports.default = getLoginUser;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var getSize = function getSize() {
|
|
7
|
+
var setting = sessionStorage.getItem('setting');
|
|
8
|
+
var breadcrumbHeight = 0; //面包屑高度
|
|
9
|
+
if (setting) {
|
|
10
|
+
// 存在布局配置
|
|
11
|
+
var _JSON$parse = JSON.parse(setting),
|
|
12
|
+
layout = _JSON$parse.layout;
|
|
13
|
+
|
|
14
|
+
breadcrumbHeight = layout === 'mixmenu' ? 40 : 0; //若是混合布局 contentH高度需要减去面包屑高度
|
|
15
|
+
}
|
|
16
|
+
var windowW = void 0,
|
|
17
|
+
windowH = void 0,
|
|
18
|
+
contentH = void 0,
|
|
19
|
+
scrollT = void 0;
|
|
20
|
+
windowH = window.innerHeight;
|
|
21
|
+
windowW = window.innerWidth;
|
|
22
|
+
scrollT = document.documentElement.scrollTop || document.body.scrollTop;
|
|
23
|
+
contentH = windowH - 65 - breadcrumbHeight;
|
|
24
|
+
return { windowW: windowW, windowH: windowH, contentH: contentH, scrollT: scrollT };
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.default = getSize;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dlt-for-react",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "dlt for react",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"react-file-viewer": "^1.2.1",
|
|
85
85
|
"react-pdf-js": "^5.1.0",
|
|
86
86
|
"react-resizable": "^3.0.5",
|
|
87
|
+
"react-to-print": "^2.15.1",
|
|
87
88
|
"react-viewer": "^3.2.2",
|
|
88
89
|
"store2": "^2.14.3",
|
|
89
90
|
"urlencode": "^1.1.0"
|
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = undefined;
|
|
7
|
-
|
|
8
|
-
var _extends2 = require('babel-runtime/helpers/extends');
|
|
9
|
-
|
|
10
|
-
var _extends3 = _interopRequireDefault(_extends2);
|
|
11
|
-
|
|
12
|
-
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
|
|
13
|
-
|
|
14
|
-
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
|
|
15
|
-
|
|
16
|
-
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
|
|
17
|
-
|
|
18
|
-
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
|
|
19
|
-
|
|
20
|
-
var _createClass2 = require('babel-runtime/helpers/createClass');
|
|
21
|
-
|
|
22
|
-
var _createClass3 = _interopRequireDefault(_createClass2);
|
|
23
|
-
|
|
24
|
-
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
|
|
25
|
-
|
|
26
|
-
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
|
|
27
|
-
|
|
28
|
-
var _inherits2 = require('babel-runtime/helpers/inherits');
|
|
29
|
-
|
|
30
|
-
var _inherits3 = _interopRequireDefault(_inherits2);
|
|
31
|
-
|
|
32
|
-
var _react = require('react');
|
|
33
|
-
|
|
34
|
-
var _react2 = _interopRequireDefault(_react);
|
|
35
|
-
|
|
36
|
-
var _reactDom = require('react-dom');
|
|
37
|
-
|
|
38
|
-
var _reactDom2 = _interopRequireDefault(_reactDom);
|
|
39
|
-
|
|
40
|
-
var _rcTweenOne = require('rc-tween-one');
|
|
41
|
-
|
|
42
|
-
var _rcTweenOne2 = _interopRequireDefault(_rcTweenOne);
|
|
43
|
-
|
|
44
|
-
var _rcQueueAnim = require('rc-queue-anim');
|
|
45
|
-
|
|
46
|
-
var _rcQueueAnim2 = _interopRequireDefault(_rcQueueAnim);
|
|
47
|
-
|
|
48
|
-
var _propTypes = require('prop-types');
|
|
49
|
-
|
|
50
|
-
var _propTypes2 = _interopRequireDefault(_propTypes);
|
|
51
|
-
|
|
52
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
53
|
-
|
|
54
|
-
function toArrayChildren(children) {
|
|
55
|
-
var ret = [];
|
|
56
|
-
_react2.default.Children.forEach(children, function (c) {
|
|
57
|
-
ret.push(c);
|
|
58
|
-
});
|
|
59
|
-
return ret;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function findChildInChildrenByKey(children, key) {
|
|
63
|
-
var ret = null;
|
|
64
|
-
if (children) {
|
|
65
|
-
children.forEach(function (c) {
|
|
66
|
-
if (ret || !c) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
if (c.key === key) {
|
|
70
|
-
ret = c;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return ret;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function mergeChildren(prev, next) {
|
|
78
|
-
var ret = [];
|
|
79
|
-
// 保存更改后的顺序,新增的在新增时的位置插入。
|
|
80
|
-
prev.forEach(function (c) {
|
|
81
|
-
if (!c) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
var newChild = findChildInChildrenByKey(next, c.key);
|
|
85
|
-
if (newChild) {
|
|
86
|
-
ret.push(newChild);
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
next.forEach(function (c, i) {
|
|
91
|
-
if (!c) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
var newChild = findChildInChildrenByKey(prev, c.key);
|
|
95
|
-
if (!newChild) {
|
|
96
|
-
ret.splice(i, 0, c);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
return ret;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
var ListSort = function (_React$Component) {
|
|
103
|
-
(0, _inherits3.default)(ListSort, _React$Component);
|
|
104
|
-
|
|
105
|
-
function ListSort(props) {
|
|
106
|
-
(0, _classCallCheck3.default)(this, ListSort);
|
|
107
|
-
|
|
108
|
-
var _this = (0, _possibleConstructorReturn3.default)(this, (ListSort.__proto__ || (0, _getPrototypeOf2.default)(ListSort)).call(this, props));
|
|
109
|
-
|
|
110
|
-
_this.onMouseDown = function (i, e) {
|
|
111
|
-
if (_this.isDrage) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
var rect = _this.dom.getBoundingClientRect();
|
|
115
|
-
var mouseX = e.touches === undefined ? e.clientX : e.touches[0].clientX;
|
|
116
|
-
//如果是点击在了右边20px的访问之内,不能进行推拖拉排序
|
|
117
|
-
if (mouseX + 20 > rect.x + rect.width) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
document.body.style.overflow = 'hidden';
|
|
121
|
-
_this.props.onEventChange(e, 'down');
|
|
122
|
-
var style = {
|
|
123
|
-
height: rect.height + 'px',
|
|
124
|
-
userSelect: 'none',
|
|
125
|
-
WebkitUserSelect: 'none',
|
|
126
|
-
MozUserSelect: 'none',
|
|
127
|
-
MsUserSelect: 'none'
|
|
128
|
-
};
|
|
129
|
-
_this.children = Array.prototype.slice.call(_this.dom.children);
|
|
130
|
-
_this.childStyle = [];
|
|
131
|
-
var childStyle = _this.children.map(function (item, ii) {
|
|
132
|
-
var cItem = _this.children[ii + 1];
|
|
133
|
-
var marginHeight = void 0;
|
|
134
|
-
var marginWidth = void 0;
|
|
135
|
-
if (cItem) {
|
|
136
|
-
marginHeight = cItem.offsetTop - item.offsetTop - item.clientHeight;
|
|
137
|
-
marginWidth = cItem.offsetLeft - item.offsetLeft - item.clientWidth;
|
|
138
|
-
} else {
|
|
139
|
-
var parentHeight = item.parentNode.clientHeight - parseFloat(getComputedStyle(item.parentNode).getPropertyValue('padding-bottom'));
|
|
140
|
-
var parentWidth = item.parentNode.clientWidth - parseFloat(getComputedStyle(item.parentNode).getPropertyValue('padding-right'));
|
|
141
|
-
marginHeight = parentHeight - item.offsetTop - item.clientHeight;
|
|
142
|
-
marginWidth = parentWidth - item.offsetLeft - item.clientWidth;
|
|
143
|
-
}
|
|
144
|
-
var d = {
|
|
145
|
-
width: item.clientWidth,
|
|
146
|
-
height: item.clientHeight,
|
|
147
|
-
top: item.offsetTop,
|
|
148
|
-
left: item.offsetLeft,
|
|
149
|
-
margin: 'auto',
|
|
150
|
-
marginHeight: marginHeight,
|
|
151
|
-
marginWidth: marginWidth,
|
|
152
|
-
position: 'absolute',
|
|
153
|
-
zIndex: ii === i ? 1 : 0
|
|
154
|
-
};
|
|
155
|
-
_this.childStyle.push((0, _extends3.default)({}, d));
|
|
156
|
-
return d;
|
|
157
|
-
});
|
|
158
|
-
var animation = _this.children.map(function (item, ii) {
|
|
159
|
-
return i === ii && (!_this.props.dragClassName ? { scale: 1.2, boxShadow: '0 10px 10px rgba(0,0,0,0.15)' } : null) || null;
|
|
160
|
-
});
|
|
161
|
-
_this.index = i;
|
|
162
|
-
_this.swapIndex = i;
|
|
163
|
-
_this.mouseXY = {
|
|
164
|
-
startX: e.touches === undefined ? e.clientX : e.touches[0].clientX,
|
|
165
|
-
startY: e.touches === undefined ? e.clientY : e.touches[0].clientY,
|
|
166
|
-
top: childStyle[i].top,
|
|
167
|
-
left: childStyle[i].left
|
|
168
|
-
};
|
|
169
|
-
if (_this.props.dragClassName) {
|
|
170
|
-
_this.listDom = e.currentTarget;
|
|
171
|
-
_this.listDom.className = _this.listDom.className.replace(_this.props.dragClassName, '').trim() + ' ' + _this.props.dragClassName;
|
|
172
|
-
}
|
|
173
|
-
_this.isDrage = true;
|
|
174
|
-
_this.setState({
|
|
175
|
-
style: style,
|
|
176
|
-
childStyle: childStyle,
|
|
177
|
-
animation: animation
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
_this.onMouseUp = function (e) {
|
|
182
|
-
if (!_this.mouseXY) {
|
|
183
|
-
return;
|
|
184
|
-
}
|
|
185
|
-
_this.mouseXY = null;
|
|
186
|
-
document.body.style.overflow = null;
|
|
187
|
-
_this.props.onEventChange(e, 'up');
|
|
188
|
-
var animation = _this.state.animation.map(function (item, i) {
|
|
189
|
-
if (_this.index === i) {
|
|
190
|
-
var animate = {};
|
|
191
|
-
var height = 0;
|
|
192
|
-
if (_this.props.animType === 'y') {
|
|
193
|
-
if (_this.swapIndex > _this.index) {
|
|
194
|
-
var start = _this.index + 1;
|
|
195
|
-
var end = _this.swapIndex + 1;
|
|
196
|
-
_this.childStyle.slice(start, end).forEach(function (_item) {
|
|
197
|
-
height += _item.height + _item.marginHeight;
|
|
198
|
-
});
|
|
199
|
-
animate.top = height + _this.childStyle[_this.index].top;
|
|
200
|
-
} else {
|
|
201
|
-
animate.top = _this.childStyle[_this.swapIndex].top;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
var dragScale = !_this.props.dragClassName && {
|
|
205
|
-
scale: 1,
|
|
206
|
-
boxShadow: '0 0px 0px rgba(0,0,0,0)'
|
|
207
|
-
};
|
|
208
|
-
return (0, _extends3.default)({}, dragScale, animate, {
|
|
209
|
-
onComplete: function onComplete() {
|
|
210
|
-
var children = _this.sortArray(_this.state.children, _this.swapIndex, _this.index);
|
|
211
|
-
var callbackBool = _this.index !== _this.swapIndex;
|
|
212
|
-
_this.index = null;
|
|
213
|
-
_this.childStyle = [];
|
|
214
|
-
_this.swapIndex = null;
|
|
215
|
-
_this.setState({
|
|
216
|
-
style: {},
|
|
217
|
-
childStyle: [],
|
|
218
|
-
children: children,
|
|
219
|
-
animation: []
|
|
220
|
-
}, function () {
|
|
221
|
-
_this.isDrage = false;
|
|
222
|
-
if (callbackBool) {
|
|
223
|
-
_this.props.onChange(children);
|
|
224
|
-
}
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
return item;
|
|
230
|
-
});
|
|
231
|
-
if (_this.props.dragClassName) {
|
|
232
|
-
_this.listDom.className = '' + _this.listDom.className.replace(_this.props.dragClassName, '').trim();
|
|
233
|
-
}
|
|
234
|
-
_this.setState({ animation: animation });
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
_this.onMouseMove = function (e) {
|
|
238
|
-
if (!_this.mouseXY) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
_this.mouseXY.x = e.touches === undefined ? e.clientX : e.touches[0].clientX;
|
|
242
|
-
_this.mouseXY.y = e.touches === undefined ? e.clientY : e.touches[0].clientY;
|
|
243
|
-
var childStyle = _this.state.childStyle;
|
|
244
|
-
var animation = _this.state.animation;
|
|
245
|
-
|
|
246
|
-
if (_this.props.animType === 'x') {
|
|
247
|
-
// 懒得写现在没用。。。做成组件后加
|
|
248
|
-
childStyle[_this.index].left = _this.mouseXY.x - _this.mouseXY.startX + _this.mouseXY.left;
|
|
249
|
-
} else {
|
|
250
|
-
childStyle[_this.index].top = _this.mouseXY.y - _this.mouseXY.startY + _this.mouseXY.top;
|
|
251
|
-
_this.swapIndex = childStyle[_this.index].top < _this.childStyle[_this.index].top ? 0 : _this.index;
|
|
252
|
-
_this.swapIndex = childStyle[_this.index].top > _this.childStyle[_this.index].top + _this.childStyle[_this.index].height ? childStyle.length - 1 : _this.swapIndex;
|
|
253
|
-
|
|
254
|
-
var top = childStyle[_this.index].top;
|
|
255
|
-
_this.childStyle.forEach(function (item, i) {
|
|
256
|
-
var cTop = item.top;
|
|
257
|
-
var cHeight = item.height + item.marginHeight;
|
|
258
|
-
if (top > cTop && top < cTop + cHeight) {
|
|
259
|
-
_this.swapIndex = i;
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
animation = animation.map(function (item, i) {
|
|
263
|
-
// 到顶端
|
|
264
|
-
var height = _this.childStyle[_this.index].height;
|
|
265
|
-
if (_this.index < _this.swapIndex) {
|
|
266
|
-
if (i > _this.index && i <= _this.swapIndex && _this.swapIndex !== _this.index) {
|
|
267
|
-
var start = _this.index + 1;
|
|
268
|
-
var end = i;
|
|
269
|
-
height = 0;
|
|
270
|
-
_this.childStyle.slice(start, end).forEach(function (_item) {
|
|
271
|
-
height += _item.height + _item.marginHeight;
|
|
272
|
-
});
|
|
273
|
-
return { top: _this.childStyle[_this.index].top + height };
|
|
274
|
-
} else if ((i > _this.swapIndex || _this.swapIndex === _this.index) && i !== _this.index) {
|
|
275
|
-
return { top: _this.childStyle[i].top };
|
|
276
|
-
}
|
|
277
|
-
} else if (_this.index > _this.swapIndex) {
|
|
278
|
-
if (i < _this.index && i >= _this.swapIndex && _this.swapIndex !== _this.index) {
|
|
279
|
-
height = _this.childStyle[_this.index].height + _this.childStyle[_this.index].marginHeight;
|
|
280
|
-
return { top: _this.childStyle[i].top + height };
|
|
281
|
-
} else if ((i < _this.swapIndex || _this.swapIndex === _this.index) && i !== _this.index) {
|
|
282
|
-
return { top: _this.childStyle[i].top };
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
if (i !== _this.index) {
|
|
286
|
-
return { top: _this.childStyle[i].top };
|
|
287
|
-
}
|
|
288
|
-
if (item == null) {
|
|
289
|
-
return {};
|
|
290
|
-
}
|
|
291
|
-
return item;
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
_this.setState({ childStyle: childStyle, animation: animation });
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
_this.getChildren = function (item, i) {
|
|
298
|
-
var onMouseDown = _this.onMouseDown.bind(_this, i);
|
|
299
|
-
var style = (0, _extends3.default)({}, _this.state.childStyle[i]);
|
|
300
|
-
return _react2.default.createElement(_rcTweenOne2.default, (0, _extends3.default)({}, item.props, {
|
|
301
|
-
onMouseDown: onMouseDown,
|
|
302
|
-
onTouchStart: onMouseDown,
|
|
303
|
-
style: (0, _extends3.default)({}, item.style, style),
|
|
304
|
-
key: item.key,
|
|
305
|
-
animation: _this.state.animation[i],
|
|
306
|
-
component: item.type
|
|
307
|
-
}));
|
|
308
|
-
};
|
|
309
|
-
|
|
310
|
-
_this.sortArray = function (_array, nextNum, num) {
|
|
311
|
-
var current = _array[num];
|
|
312
|
-
var array = _array.map(function (item) {
|
|
313
|
-
return item;
|
|
314
|
-
});
|
|
315
|
-
array.splice(num, 1);
|
|
316
|
-
array.splice(nextNum, 0, current);
|
|
317
|
-
return array;
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
_this.state = {
|
|
321
|
-
children: _this.props.children,
|
|
322
|
-
style: {},
|
|
323
|
-
childStyle: [],
|
|
324
|
-
animation: []
|
|
325
|
-
};
|
|
326
|
-
_this.index = null;
|
|
327
|
-
_this.swapIndex = null;
|
|
328
|
-
_this.mouseXY = null;
|
|
329
|
-
_this.childStyle = [];
|
|
330
|
-
_this.children = [];
|
|
331
|
-
_this.isDrage = false;
|
|
332
|
-
return _this;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
(0, _createClass3.default)(ListSort, [{
|
|
336
|
-
key: 'componentDidMount',
|
|
337
|
-
value: function componentDidMount() {
|
|
338
|
-
this.dom = _reactDom2.default.findDOMNode(this);
|
|
339
|
-
|
|
340
|
-
if (window.addEventListener) {
|
|
341
|
-
window.addEventListener('mousemove', this.onMouseMove);
|
|
342
|
-
window.addEventListener('touchmove', this.onMouseMove);
|
|
343
|
-
window.addEventListener('mouseup', this.onMouseUp);
|
|
344
|
-
window.addEventListener('touchend', this.onMouseUp);
|
|
345
|
-
} else {
|
|
346
|
-
window.attachEvent('onmousemove', this.onMouseMove);
|
|
347
|
-
window.attachEvent('ontouchmove', this.onMouseMove);
|
|
348
|
-
window.attachEvent('onmouseup', this.onMouseUp);
|
|
349
|
-
window.attachEvent('ontouchend', this.onMouseUp);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
}, {
|
|
353
|
-
key: 'UNSAFE_componentWillReceiveProps',
|
|
354
|
-
value: function UNSAFE_componentWillReceiveProps(nextProps) {
|
|
355
|
-
var currentChildren = this.state.children;
|
|
356
|
-
var nextChildren = nextProps.children;
|
|
357
|
-
var newChildren = mergeChildren(currentChildren, nextChildren);
|
|
358
|
-
this.setState({ children: newChildren });
|
|
359
|
-
}
|
|
360
|
-
}, {
|
|
361
|
-
key: 'componentWillUnmount',
|
|
362
|
-
value: function componentWillUnmount() {
|
|
363
|
-
if (window.addEventListener) {
|
|
364
|
-
window.removeEventListener('mousemove', this.onMouseMove);
|
|
365
|
-
window.removeEventListener('touchmove', this.onMouseMove);
|
|
366
|
-
window.removeEventListener('mouseup', this.onMouseUp);
|
|
367
|
-
window.removeEventListener('touchend', this.onMouseUp);
|
|
368
|
-
} else {
|
|
369
|
-
window.detachEvent('onmousemove', this.onMouseMove);
|
|
370
|
-
window.detachEvent('ontouchmove', this.onMouseMove);
|
|
371
|
-
window.detachEvent('onmouseup', this.onMouseUp);
|
|
372
|
-
window.detachEvent('ontouchend', this.onMouseUp);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
}, {
|
|
376
|
-
key: 'render',
|
|
377
|
-
value: function render() {
|
|
378
|
-
var childrenToRender = toArrayChildren(this.state.children).map(this.getChildren);
|
|
379
|
-
var props = (0, _extends3.default)({}, this.props);
|
|
380
|
-
['component', 'animType', 'dragClassName', 'appearAnim', 'onEventChange'].forEach(function (key) {
|
|
381
|
-
return delete props[key];
|
|
382
|
-
});
|
|
383
|
-
if (this.props.appearAnim) {
|
|
384
|
-
return _react2.default.createElement(_rcQueueAnim2.default, (0, _extends3.default)({}, props, this.props.appearAnim, {
|
|
385
|
-
style: (0, _extends3.default)({}, this.state.style)
|
|
386
|
-
}), childrenToRender);
|
|
387
|
-
}
|
|
388
|
-
return _react2.default.createElement(this.props.component, (0, _extends3.default)({}, props, {
|
|
389
|
-
style: (0, _extends3.default)({}, this.state.style)
|
|
390
|
-
}), childrenToRender);
|
|
391
|
-
}
|
|
392
|
-
}]);
|
|
393
|
-
return ListSort;
|
|
394
|
-
}(_react2.default.Component);
|
|
395
|
-
|
|
396
|
-
ListSort.propTypes = {
|
|
397
|
-
component: _propTypes2.default.any,
|
|
398
|
-
children: _propTypes2.default.any,
|
|
399
|
-
animType: _propTypes2.default.string,
|
|
400
|
-
onChange: _propTypes2.default.any,
|
|
401
|
-
dragClassName: _propTypes2.default.string,
|
|
402
|
-
appearAnim: _propTypes2.default.object,
|
|
403
|
-
onEventChange: _propTypes2.default.any
|
|
404
|
-
};
|
|
405
|
-
ListSort.defaultProps = {
|
|
406
|
-
component: 'div',
|
|
407
|
-
animType: 'y',
|
|
408
|
-
onChange: function onChange() {},
|
|
409
|
-
onEventChange: function onEventChange() {}
|
|
410
|
-
};
|
|
411
|
-
exports.default = ListSort;
|