venus-design 0.9.1 → 0.9.2

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.
@@ -27,7 +27,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
27
27
  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; }
28
28
  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; } }
29
29
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
30
- import React, { useState, useImperativeHandle } from 'react';
30
+ import React, { useState, useImperativeHandle, useEffect } from 'react';
31
31
  import SelectRoleAndUser from "./components/SelectRoleAndUser";
32
32
  import { StyleProvider, legacyLogicalPropertiesTransformer } from "@ant-design/cssinjs";
33
33
  import { startData, findByOptionCode, findByUserid, SubmitDataStatus, updateProcessInstance } from "./service";
@@ -316,12 +316,16 @@ export default /*#__PURE__*/React.forwardRef(function (props, ref) {
316
316
  addFn: addFn
317
317
  };
318
318
  });
319
+ useEffect(function () {
320
+ if (userdata && (userdata === null || userdata === void 0 ? void 0 : userdata.length) > 0) {
321
+ setVisible(true);
322
+ }
323
+ }, [userdata]);
319
324
  var addFn = /*#__PURE__*/function () {
320
325
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(record, code, name) {
321
326
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
322
327
  while (1) switch (_context3.prev = _context3.next) {
323
328
  case 0:
324
- setVisible(true);
325
329
  setrecord(record);
326
330
  if (record.actionId != undefined) {
327
331
  setActionId(record.actionId);
@@ -332,7 +336,7 @@ export default /*#__PURE__*/React.forwardRef(function (props, ref) {
332
336
  setisReturn(true);
333
337
  }
334
338
  findByOption(record, code, name);
335
- case 5:
339
+ case 4:
336
340
  case "end":
337
341
  return _context3.stop();
338
342
  }
@@ -8,11 +8,6 @@ export declare const defaultConfig: {
8
8
  HEADER_BG_COLOR: string;
9
9
  ENABLE_EDIT_SINGLE_CLICK: boolean;
10
10
  HEIGHT: number;
11
- ENABLE_KEYBOARD: boolean;
12
- HIGHLIGHT_HOVER_ROW: boolean;
13
- HIGHLIGHT_HOVER_ROW_COLOR: string;
14
- HIGHLIGHT_SELECTED_ROW: boolean;
15
- HIGHLIGHT_SELECTED_ROW_COLOR: string;
16
11
  TREE_INDENT: number;
17
12
  HEADER_CELL_STYLE_METHOD: ({ column }: any) => {
18
13
  color: string;
@@ -19,16 +19,11 @@ export var defaultConfig = {
19
19
  //单击进入编辑
20
20
  HEIGHT: 300,
21
21
  // 高度
22
- ENABLE_KEYBOARD: true,
23
- // 开启键盘操作
24
- HIGHLIGHT_HOVER_ROW: true,
25
- // 开启行悬停高亮
26
- HIGHLIGHT_HOVER_ROW_COLOR: "#eeeeeeff",
27
- //悬停高亮颜色
28
- HIGHLIGHT_SELECTED_ROW: true,
29
- // 开启选中行高亮
30
- HIGHLIGHT_SELECTED_ROW_COLOR: "#d5f2ffff",
31
- //选中高亮颜色
22
+ //ENABLE_KEYBOARD: true, // 开启键盘操作
23
+ //HIGHLIGHT_HOVER_ROW:true, // 开启行悬停高亮
24
+ //HIGHLIGHT_HOVER_ROW_COLOR:"#eeeeeeff",//悬停高亮颜色
25
+ //HIGHLIGHT_SELECTED_ROW:true, // 开启选中行高亮
26
+ //HIGHLIGHT_SELECTED_ROW_COLOR:"#d5f2ffff",//选中高亮颜色
32
27
  TREE_INDENT: 5,
33
28
  // 默认树形缩进宽度
34
29
  // 列头单元格样式方法
@@ -11,11 +11,14 @@ export default class DragGhost {
11
11
  private targetY;
12
12
  private flatData;
13
13
  constructor(ctx: Context);
14
+ private lastSwapIndex;
15
+ private throttleSwap;
14
16
  private onMouseDown;
15
17
  private createGhost;
16
18
  private lastMoveTime;
17
19
  private slideTimer;
18
20
  private hasMoved;
21
+ private slideRow;
19
22
  private onMouseMove;
20
23
  private onMouseUp;
21
24
  private animateBounce;
@@ -12,6 +12,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
12
12
  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; }
13
13
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
14
14
  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); }
15
+ import { throttle } from 'lodash';
15
16
  var DragGhost = /*#__PURE__*/function () {
16
17
  function DragGhost(ctx) {
17
18
  var _this = this;
@@ -27,68 +28,71 @@ var DragGhost = /*#__PURE__*/function () {
27
28
  _defineProperty(this, "targetX", 0);
28
29
  _defineProperty(this, "targetY", 0);
29
30
  _defineProperty(this, "flatData", []);
31
+ _defineProperty(this, "lastSwapIndex", -1);
32
+ // 防止重复交换
33
+ _defineProperty(this, "throttleSwap", throttle(function (newIndex) {
34
+ if (newIndex === _this.dragIndex || newIndex === _this.lastSwapIndex) return;
35
+ var oldIndex = _this.dragIndex;
36
+
37
+ // 数据交换
38
+ var _this$flatData$splice = _this.flatData.splice(oldIndex, 1),
39
+ _this$flatData$splice2 = _slicedToArray(_this$flatData$splice, 1),
40
+ moved = _this$flatData$splice2[0];
41
+ _this.flatData.splice(newIndex, 0, moved);
42
+
43
+ // 动画偏移
44
+ var direction = newIndex > oldIndex ? -1 : 1;
45
+ var affectedRows = _this.ctx.body.renderRows.slice(Math.min(oldIndex, newIndex), Math.max(oldIndex, newIndex) + 1);
46
+ affectedRows.forEach(function (row, i) {
47
+ var offset = direction * row.height;
48
+ row.setSlideOffset(i === 0 ? offset : -offset); // 被交换的行反向偏移
49
+ });
50
+
51
+ // 更新索引
52
+ _this.ctx.placeholderIndex = newIndex;
53
+ _this.dragIndex = newIndex;
54
+ _this.lastSwapIndex = newIndex;
55
+
56
+ // 同步数据
57
+ _this.ctx.database.setData(_this.flatData);
58
+ _this.ctx.emit('draw');
59
+
60
+ // 动画结束后清除偏移
61
+ setTimeout(function () {
62
+ affectedRows.forEach(function (row) {
63
+ return row.setSlideOffset(0);
64
+ });
65
+ _this.ctx.emit('draw');
66
+ }, 250); // 与 CSS transition 时间一致
67
+ }, 150));
30
68
  _defineProperty(this, "lastMoveTime", 0);
31
69
  _defineProperty(this, "slideTimer", 0);
32
70
  _defineProperty(this, "hasMoved", false);
33
71
  // ★ 第一次放行
72
+ /* === 新增:实时滑动相关的两行 === */
73
+ _defineProperty(this, "slideRow", null);
74
+ // ← 指向正在被拖的那一行
34
75
  _defineProperty(this, "onMouseMove", function (e) {
35
76
  if (!_this.ghostEl) return;
36
77
  e.preventDefault();
37
-
38
- /* 1. 16ms 节流,但第一次必放行 */
39
- var now = performance.now();
40
- if (_this.hasMoved && now - _this.lastMoveTime < 16) return;
41
- _this.lastMoveTime = now;
42
- _this.hasMoved = true;
43
-
44
- /* 2. 幽灵行跟随(不变) */
45
- var curX = e.clientX + 12;
46
- var curY = e.clientY - 12;
47
- _this.ghostEl.style.left = "".concat(curX, "px");
48
- _this.ghostEl.style.top = "".concat(curY, "px");
49
-
50
- /* 3. 死区交换逻辑(不变) */
51
78
  var rect = _this.ctx.containerElement.getBoundingClientRect();
52
79
  var mouseY = e.clientY - rect.top + _this.ctx.scrollY;
53
- var deadBand = 8;
54
- var insertIndex = _this.ctx.placeholderIndex;
55
- if (_this.ctx.placeholderIndex < _this.flatData.length - 1) {
56
- var next = _this.ctx.database.getPositionForRowIndex(_this.ctx.placeholderIndex + 1);
57
- if (mouseY >= next.top + deadBand) insertIndex = _this.ctx.placeholderIndex + 1;
58
- }
59
- if (_this.ctx.placeholderIndex > 0) {
60
- var curr = _this.ctx.database.getPositionForRowIndex(_this.ctx.placeholderIndex);
61
- if (mouseY <= curr.top + curr.height - deadBand) insertIndex = _this.ctx.placeholderIndex - 1;
62
- }
63
- var oldIndex = _this.ctx.placeholderIndex;
64
- if (insertIndex === oldIndex) return;
65
80
 
66
- /* 4. 清旧动画 + 滑动(150ms) */
67
- if (_this.slideTimer) clearTimeout(_this.slideTimer);
68
- var oldRow = _this.ctx.body.renderRows.find(function (r) {
69
- return r.rowIndex === oldIndex;
70
- });
71
- var newRow = _this.ctx.body.renderRows.find(function (r) {
72
- return r.rowIndex === insertIndex;
73
- });
74
- if (!oldRow || !newRow) return;
75
- var dy = newRow.y - oldRow.y;
76
- oldRow.setSlideOffset(dy);
77
- newRow.setSlideOffset(-dy);
78
- _this.ctx.emit('draw');
79
-
80
- /* 数据交换 */
81
- var _this$flatData$splice = _this.flatData.splice(oldIndex, 1),
82
- _this$flatData$splice2 = _slicedToArray(_this$flatData$splice, 1),
83
- movedRow = _this$flatData$splice2[0];
84
- _this.flatData.splice(insertIndex, 0, movedRow);
85
- _this.ctx.placeholderIndex = insertIndex;
86
- _this.dragIndex = insertIndex;
81
+ // 幽灵行跟随鼠标
82
+ _this.ghostEl.style.top = "".concat(e.clientY - 12, "px");
83
+ _this.ghostEl.style.left = "".concat(e.clientX + 12, "px");
87
84
 
88
- /* ★ 立即更新 renderRows 引用 + 重绘 */
89
- _this.ctx.database.setData(_this.flatData);
90
- _this.ctx.body.renderRows = _this.ctx.body.renderRows.slice(); // 新引用
91
- _this.ctx.emit('draw');
85
+ // 找到目标行索引
86
+ var targetIndex = 0;
87
+ for (var i = 0; i < _this.flatData.length; i++) {
88
+ var pos = _this.ctx.database.getPositionForRowIndex(i);
89
+ if (mouseY >= pos.top + pos.height / 2) {
90
+ targetIndex = i;
91
+ } else {
92
+ break;
93
+ }
94
+ }
95
+ _this.throttleSwap(targetIndex);
92
96
  });
93
97
  /* ---------- 松手 ---------- */
94
98
  _defineProperty(this, "onMouseUp", function () {
@@ -132,11 +136,13 @@ var DragGhost = /*#__PURE__*/function () {
132
136
  return _this.onMouseDown(e);
133
137
  });
134
138
  }
135
-
136
- /* ---------- 抓起 ---------- */
137
139
  _createClass(DragGhost, [{
138
140
  key: "onMouseDown",
139
- value: function onMouseDown(e) {
141
+ value:
142
+ // 节流 150ms
143
+
144
+ /* ---------- 抓起 ---------- */
145
+ function onMouseDown(e) {
140
146
  var _this2 = this,
141
147
  _row$cells$find;
142
148
  if (e.button !== 0) return;
@@ -154,6 +160,10 @@ var DragGhost = /*#__PURE__*/function () {
154
160
  var nameCell = (_row$cells$find = row === null || row === void 0 ? void 0 : row.cells.find(function (c) {
155
161
  return c.column.key === 'name';
156
162
  })) !== null && _row$cells$find !== void 0 ? _row$cells$find : cell;
163
+ if (row) {
164
+ row.data._dragging = true; // 打标记
165
+ this.slideRow = row; // 保存引用
166
+ }
157
167
  this.createGhost(nameCell);
158
168
  this.ctx.placeholderIndex = this.dragIndex;
159
169
  document.addEventListener('mousemove', this.onMouseMove, {
@@ -210,9 +220,14 @@ var DragGhost = /*#__PURE__*/function () {
210
220
  cancelAnimationFrame(this.animId);
211
221
  (_this$ghostEl = this.ghostEl) === null || _this$ghostEl === void 0 || _this$ghostEl.remove();
212
222
  this.ghostEl = null;
213
- this.ctx.pickedRowIndex = -1;
214
- this.ctx.placeholderIndex = -1;
223
+
224
+ /* === 清理拖拽样式标记 === */
225
+ if (this.slideRow) {
226
+ delete this.slideRow.data._dragging;
227
+ this.slideRow = null;
228
+ }
215
229
  document.removeEventListener('mousemove', this.onMouseMove);
230
+ this.dragIndex = -1;
216
231
  }
217
232
 
218
233
  /* ---------- 工具 ---------- */
@@ -96,6 +96,14 @@ var Row = /*#__PURE__*/function () {
96
96
  }, {
97
97
  key: "drawCenter",
98
98
  value: function drawCenter() {
99
+ if (this.data._dragging) {
100
+ this.ctx.paint.drawRect(this.x, this.y - this.ctx.scrollY, this.width, this.height, {
101
+ fillColor: 'rgba(24,144,255,0.08)',
102
+ borderColor: '#1890ff',
103
+ borderWidth: 1,
104
+ radius: 6
105
+ });
106
+ }
99
107
  if (this.slideOffsetY !== 0) this.ctx.paint.save();
100
108
  if (this.slideOffsetY !== 0) this.ctx.paint.translate(0, this.slideOffsetY);
101
109
  this.noFixedCells.forEach(function (c) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venus-design",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "venus all compoments",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",