venus-design 0.8.5 → 0.8.7

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.
@@ -30,10 +30,12 @@ var SelectApprovalUser = function SelectApprovalUser(props) {
30
30
  }
31
31
  }
32
32
  } else {
33
- for (var _i = 10; _i < 36; _i++) {
34
- children.push( /*#__PURE__*/React.createElement(Option, {
35
- key: _i.toString(36) + _i
36
- }, _i.toString(36) + _i));
33
+ if (process.env.DUMI_APP_BUILD_ENV === 'development') {
34
+ for (var _i = 10; _i < 36; _i++) {
35
+ children.push( /*#__PURE__*/React.createElement(Option, {
36
+ key: _i.toString(36) + _i
37
+ }, _i.toString(36) + _i));
38
+ }
37
39
  }
38
40
  }
39
41
  var isRole = function isRole(value) {
@@ -55,7 +55,7 @@ export interface UltimateSearchProps<T> {
55
55
  export declare const createUltimateSearchNews: <T extends Record<string, any>>(config: UltimateSearchProps<T>) => ProColumns<T>;
56
56
  export declare const createUltimateSearch: <T extends Record<string, any>>(column: ProColumns<T>, dataIndex?: string, title?: string, socketSearch?: boolean, searchType?: 'flat' | 'tree', showHistory?: boolean, theme?: ThemeType) => ProColumns<T>;
57
57
  declare const _default: {
58
- createUltimateSearch: <T extends Record<string, any>>(column: ProColumns<T>, dataIndex?: string, title?: string | undefined, socketSearch?: boolean, searchType?: "tree" | "flat", showHistory?: boolean, theme?: ThemeType) => ProColumns<T>;
58
+ createUltimateSearch: <T extends Record<string, any>>(column: ProColumns<T>, dataIndex?: string, title?: string | undefined, socketSearch?: boolean, searchType?: "flat" | "tree", showHistory?: boolean, theme?: ThemeType) => ProColumns<T>;
59
59
  createUltimateFilter: ({ dataIndex, title, dataSource, options, showSearch, showHistory, theme }: UltimateFilterProps) => Partial<ColumnType<any>>;
60
60
  createUltimateSearchNews: <T_1 extends Record<string, any>>(config: UltimateSearchProps<T_1>) => ProColumns<T_1>;
61
61
  };
@@ -50,12 +50,13 @@ var VenusDesignTable = function VenusDesignTable(props) {
50
50
  });
51
51
  }
52
52
  }
53
- _context.next = 4;
53
+ params = _objectSpread(_objectSpread({}, params), props.params);
54
+ _context.next = 5;
54
55
  return LoadingDesignTableData(params, url.toLowerCase(), props.item.serverUrlId);
55
- case 4:
56
+ case 5:
56
57
  res = _context.sent;
57
58
  if (!(res && res.success)) {
58
- _context.next = 14;
59
+ _context.next = 15;
59
60
  break;
60
61
  }
61
62
  data = res.data || {};
@@ -64,9 +65,9 @@ var VenusDesignTable = function VenusDesignTable(props) {
64
65
  pageData.page = data.current;
65
66
  pageData.success = true;
66
67
  return _context.abrupt("return", pageData);
67
- case 14:
68
- return _context.abrupt("return", pageData);
69
68
  case 15:
69
+ return _context.abrupt("return", pageData);
70
+ case 16:
70
71
  case "end":
71
72
  return _context.stop();
72
73
  }
@@ -2,4 +2,4 @@
2
2
  * 渲染页面
3
3
  * @param item
4
4
  */
5
- export declare const renderFormDesign: (item: [], id: string, type: string, height: any) => any[];
5
+ export declare const renderFormDesign: (item: [], id: string, params: any, type: string, height: any) => any[];
@@ -4,14 +4,14 @@ import { VENUS_DESIGN_TYPE } from "./staticAttr";
4
4
  * 渲染页面
5
5
  * @param item
6
6
  */
7
- export var renderFormDesign = function renderFormDesign(item, id, type, height) {
7
+ export var renderFormDesign = function renderFormDesign(item, id, params, type, height) {
8
8
  var comList = [];
9
9
  for (var i = 0; i < item.length; i++) {
10
10
  //@ts-ignore
11
11
  var handleFormItemType = VENUS_DESIGN_TYPE[item[i].type] || function () {
12
12
  return {};
13
13
  };
14
- var component = handleFormItemType(item[i], {
14
+ var component = handleFormItemType(item[i], params, {
15
15
  id: id || "-1",
16
16
  type: type
17
17
  }, height);
@@ -4,6 +4,7 @@ interface VenusDesignComType {
4
4
  id?: string;
5
5
  type?: "view" | "render";
6
6
  height?: any;
7
+ params?: any;
7
8
  }
8
9
  /**
9
10
  * 表单设计渲染
@@ -50,6 +50,6 @@ var VenusDesignCom = function VenusDesignCom(props) {
50
50
  style: {
51
51
  height: props.height || "100%"
52
52
  }
53
- }, items.length > 0 ? renderFormDesign(items, props.id || "-1", props.type || "render", props.height || winHeight) : null));
53
+ }, items.length > 0 ? renderFormDesign(items, props.id || "-1", props.params, props.type || "render", props.height || winHeight) : null));
54
54
  };
55
55
  export default VenusDesignCom;
@@ -6,24 +6,27 @@ import VenusDesignDetail from "./components/Detail";
6
6
  * 表单项的类型
7
7
  */
8
8
  export var VENUS_DESIGN_TYPE = {
9
- "form": function form(item, conf, height) {
9
+ "form": function form(item, conf, params, height) {
10
10
  return /*#__PURE__*/React.createElement(VenusDesignForm, {
11
11
  item: item,
12
12
  conf: conf,
13
+ params: params,
13
14
  height: height
14
15
  });
15
16
  },
16
- "grid": function grid(item, conf, height) {
17
+ "grid": function grid(item, conf, params, height) {
17
18
  return /*#__PURE__*/React.createElement(VenusDesignTable, {
18
19
  item: item,
19
20
  conf: conf,
21
+ params: params,
20
22
  height: height
21
23
  });
22
24
  },
23
- "detail": function detail(item, conf, height) {
25
+ "detail": function detail(item, conf, params, height) {
24
26
  return /*#__PURE__*/React.createElement(VenusDesignDetail, {
25
27
  item: item,
26
28
  conf: conf,
29
+ params: params,
27
30
  height: height
28
31
  });
29
32
  }
@@ -127,6 +127,8 @@ export default class Context {
127
127
  history: History;
128
128
  config: Config;
129
129
  drawTime: number;
130
+ pickedRowIndex: number;
131
+ placeholderIndex: number;
130
132
  constructor(containerOptions: containerElementOptions, options: EVirtTableOptions);
131
133
  setConfig(config: Config): void;
132
134
  setItemValueByEditor(rowKey: string, key: string, value: any, history?: boolean, reDraw?: boolean, checkReadonly?: boolean): void;
@@ -22,6 +22,7 @@ import Config from "./Config";
22
22
  import Icons from "./Icons";
23
23
  import EventTable from "./EventTable";
24
24
  var Context = /*#__PURE__*/function () {
25
+ // 空位所在索引
25
26
  function Context(containerOptions, options) {
26
27
  _classCallCheck(this, Context);
27
28
  _defineProperty(this, "eventBus", void 0);
@@ -141,6 +142,9 @@ var Context = /*#__PURE__*/function () {
141
142
  _defineProperty(this, "history", void 0);
142
143
  _defineProperty(this, "config", void 0);
143
144
  _defineProperty(this, "drawTime", 0);
145
+ _defineProperty(this, "pickedRowIndex", -1);
146
+ // -1 表示没有抓起
147
+ _defineProperty(this, "placeholderIndex", -1);
144
148
  var containerElement = containerOptions.containerElement,
145
149
  stageElement = containerOptions.stageElement,
146
150
  canvasElement = containerOptions.canvasElement,
@@ -3,18 +3,23 @@ export default class DragGhost {
3
3
  private ctx;
4
4
  private dragIndex;
5
5
  private ghostEl;
6
- private lineEl;
7
- private placeholderIndex;
6
+ private animId;
7
+ private startTime;
8
+ private startX;
9
+ private startY;
10
+ private targetX;
11
+ private targetY;
8
12
  private flatData;
9
- private dragRow;
10
- private readonly PLACEHOLDER;
11
13
  constructor(ctx: Context);
12
14
  private onMouseDown;
13
15
  private createGhost;
14
- private createLine;
16
+ private lastMoveTime;
17
+ private slideTimer;
18
+ private hasMoved;
15
19
  private onMouseMove;
16
20
  private onMouseUp;
17
- private commitData;
18
- private showLineAt;
21
+ private animateBounce;
22
+ private easeOutBack;
23
+ private cleanup;
19
24
  private getCellFromEvent;
20
25
  }
@@ -1,7 +1,11 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
2
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ 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
5
  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
6
  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; }
7
+ 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; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
5
9
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
6
10
  function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
7
11
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
@@ -14,63 +18,114 @@ var DragGhost = /*#__PURE__*/function () {
14
18
  _classCallCheck(this, DragGhost);
15
19
  _defineProperty(this, "ctx", void 0);
16
20
  _defineProperty(this, "dragIndex", -1);
17
- // 被拖行的原始索引
18
21
  _defineProperty(this, "ghostEl", null);
19
- _defineProperty(this, "lineEl", null);
20
- /* 空位逻辑 */
21
- _defineProperty(this, "placeholderIndex", -1);
22
- // -1:无空位
22
+ /* 动画相关 */
23
+ _defineProperty(this, "animId", 0);
24
+ _defineProperty(this, "startTime", 0);
25
+ _defineProperty(this, "startX", 0);
26
+ _defineProperty(this, "startY", 0);
27
+ _defineProperty(this, "targetX", 0);
28
+ _defineProperty(this, "targetY", 0);
23
29
  _defineProperty(this, "flatData", []);
24
- // 当前扁平数据(含占位符)
25
- _defineProperty(this, "dragRow", null);
26
- // 被拖行的副本
27
- _defineProperty(this, "PLACEHOLDER", Symbol.for('DRAGGING'));
28
- /* ---------- 4. 鼠标移动:空位实时推/顶 ---------- */
30
+ _defineProperty(this, "lastMoveTime", 0);
31
+ _defineProperty(this, "slideTimer", 0);
32
+ _defineProperty(this, "hasMoved", false);
33
+ // 第一次放行
29
34
  _defineProperty(this, "onMouseMove", function (e) {
30
35
  if (!_this.ghostEl) return;
31
36
  e.preventDefault();
32
37
 
33
- /* 4.1 幽灵行跟随鼠标 */
34
- _this.ghostEl.style.left = "".concat(e.clientX + 10, "px");
35
- _this.ghostEl.style.top = "".concat(e.clientY - 10, "px");
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;
36
43
 
37
- /* 4.2 计算插入点 */
38
- var canvasY = e.clientY - _this.ctx.containerElement.getBoundingClientRect().top + _this.ctx.scrollY;
39
- var insertIndex = _this.flatData.length;
40
- for (var i = 0; i < _this.flatData.length; i++) {
41
- var _this$ctx$database$ge = _this.ctx.database.getPositionForRowIndex(i),
42
- top = _this$ctx$database$ge.top,
43
- height = _this$ctx$database$ge.height;
44
- if (canvasY < top + height / 2) {
45
- insertIndex = i;
46
- break;
47
- }
48
- }
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
49
 
50
- /* 4.3 空位移到 insertIndex */
51
- if (insertIndex !== _this.placeholderIndex) {
52
- _this.flatData.splice(_this.placeholderIndex, 1);
53
- _this.flatData.splice(insertIndex, 0, _this.PLACEHOLDER);
54
- _this.placeholderIndex = insertIndex;
55
- _this.commitData(); // 重绘 看到“顶/推”动画
50
+ /* 3. 死区交换逻辑(不变) */
51
+ var rect = _this.ctx.containerElement.getBoundingClientRect();
52
+ 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;
56
62
  }
63
+ var oldIndex = _this.ctx.placeholderIndex;
64
+ if (insertIndex === oldIndex) return;
65
+
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');
57
79
 
58
- /* 4.4 蓝线 */
59
- _this.showLineAt(canvasY);
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;
87
+
88
+ /* ★ 立即更新 renderRows 引用 + 重绘 */
89
+ _this.ctx.database.setData(_this.flatData);
90
+ _this.ctx.body.renderRows = _this.ctx.body.renderRows.slice(); // 新引用
91
+ _this.ctx.emit('draw');
60
92
  });
61
- /* ---------- 5. 抬起:把占位符换回被拖行 ---------- */
93
+ /* ---------- 松手 ---------- */
62
94
  _defineProperty(this, "onMouseUp", function () {
63
- var _this$ghostEl, _this$lineEl;
64
- if (_this.placeholderIndex !== -1) {
65
- _this.flatData.splice(_this.placeholderIndex, 1, _this.dragRow);
66
- _this.commitData();
95
+ if (!_this.ghostEl) return;
96
+ var targetRow = _this.ctx.body.renderRows.find(function (r) {
97
+ return r.rowIndex === _this.ctx.placeholderIndex;
98
+ });
99
+ if (!targetRow) {
100
+ _this.cleanup();
101
+ return;
102
+ }
103
+ var rect = _this.ctx.containerElement.getBoundingClientRect();
104
+ _this.targetX = rect.left + targetRow.cells[0].drawX;
105
+ _this.targetY = rect.top + targetRow.cells[0].drawY;
106
+ var ghost = _this.ghostEl;
107
+ _this.startX = parseFloat(ghost.style.left);
108
+ _this.startY = parseFloat(ghost.style.top);
109
+ _this.startTime = performance.now();
110
+ _this.animId = requestAnimationFrame(_this.animateBounce);
111
+ });
112
+ /* ---------- 回弹动画 ---------- */
113
+ _defineProperty(this, "animateBounce", function (now) {
114
+ var duration = 250;
115
+ var t = Math.min((now - _this.startTime) / duration, 1);
116
+ var eased = _this.easeOutBack(t);
117
+ var ghost = _this.ghostEl;
118
+ var curLeft = _this.startX + (_this.targetX - _this.startX) * eased;
119
+ var curTop = _this.startY + (_this.targetY - _this.startY) * eased;
120
+ var scale = 1 - (1 - eased) * 0.15;
121
+ ghost.style.left = "".concat(curLeft, "px");
122
+ ghost.style.top = "".concat(curTop, "px");
123
+ ghost.style.transform = "scale(".concat(scale, ")");
124
+ if (t < 1) {
125
+ _this.animId = requestAnimationFrame(_this.animateBounce);
126
+ } else {
127
+ _this.cleanup();
67
128
  }
68
- _this.placeholderIndex = -1;
69
- (_this$ghostEl = _this.ghostEl) === null || _this$ghostEl === void 0 || _this$ghostEl.remove();
70
- (_this$lineEl = _this.lineEl) === null || _this$lineEl === void 0 || _this$lineEl.remove();
71
- _this.ghostEl = null;
72
- _this.lineEl = null;
73
- document.removeEventListener('mousemove', _this.onMouseMove);
74
129
  });
75
130
  this.ctx = ctx;
76
131
  this.ctx.on('mousedown', function (e) {
@@ -78,11 +133,12 @@ var DragGhost = /*#__PURE__*/function () {
78
133
  });
79
134
  }
80
135
 
81
- /* ---------- 1. 启动拖拽 ---------- */
136
+ /* ---------- 抓起 ---------- */
82
137
  _createClass(DragGhost, [{
83
138
  key: "onMouseDown",
84
139
  value: function onMouseDown(e) {
85
- var _this2 = this;
140
+ var _this2 = this,
141
+ _row$cells$find;
86
142
  if (e.button !== 0) return;
87
143
  var cell = this.getCellFromEvent(e);
88
144
  if (!cell || cell.type !== 'drag-handle') return;
@@ -92,14 +148,14 @@ var DragGhost = /*#__PURE__*/function () {
92
148
  return _this2.ctx.database.getRowKeyByItem(r) === cell.rowKey;
93
149
  });
94
150
  if (this.dragIndex === -1) return;
95
-
96
- /* 把被拖行拿出来留副本,原位置插入占位符 后面行往上顶 */
97
- this.dragRow = this.flatData.splice(this.dragIndex, 1)[0];
98
- this.flatData.splice(this.dragIndex, 0, this.PLACEHOLDER);
99
- this.placeholderIndex = this.dragIndex;
100
- this.commitData();
101
- this.createGhost(cell, this.dragRow);
102
- this.createLine();
151
+ var row = this.ctx.body.renderRows.find(function (r) {
152
+ return r.rowIndex === cell.rowIndex;
153
+ });
154
+ var nameCell = (_row$cells$find = row === null || row === void 0 ? void 0 : row.cells.find(function (c) {
155
+ return c.column.key === 'name';
156
+ })) !== null && _row$cells$find !== void 0 ? _row$cells$find : cell;
157
+ this.createGhost(nameCell);
158
+ this.ctx.placeholderIndex = this.dragIndex;
103
159
  document.addEventListener('mousemove', this.onMouseMove, {
104
160
  passive: false
105
161
  });
@@ -108,78 +164,58 @@ var DragGhost = /*#__PURE__*/function () {
108
164
  });
109
165
  }
110
166
 
111
- /* ---------- 2. 幽灵行 ---------- */
167
+ /* ---------- 创建幽灵行 ---------- */
112
168
  }, {
113
169
  key: "createGhost",
114
- value: function createGhost(cell, dragRow) {
170
+ value: function createGhost(sourceCell) {
115
171
  var rect = this.ctx.containerElement.getBoundingClientRect();
116
172
  this.ghostEl = document.createElement('div');
117
- this.ghostEl.innerText = cell.getText() || ' ';
173
+ this.ghostEl.innerText = sourceCell.displayText || sourceCell.getText() || ' ';
118
174
  Object.assign(this.ghostEl.style, {
119
175
  position: 'absolute',
120
- left: "".concat(rect.left + cell.drawX, "px"),
121
- top: "".concat(rect.top + cell.drawY, "px"),
122
- width: "".concat(cell.width, "px"),
123
- height: "".concat(cell.height, "px"),
124
- background: 'rgba(33,150,243,0.25)',
125
- border: '2px solid #2196F3',
126
- borderRadius: '4px',
176
+ left: "".concat(rect.left + sourceCell.drawX, "px"),
177
+ top: "".concat(rect.top + sourceCell.drawY, "px"),
178
+ width: "".concat(sourceCell.width, "px"),
179
+ height: "".concat(sourceCell.height, "px"),
180
+ background: '#fff',
181
+ border: '1px solid #e0e0e0',
182
+ borderRadius: '8px',
183
+ boxShadow: '0 4px 12px rgba(0,0,0,.15)',
127
184
  pointerEvents: 'none',
128
185
  zIndex: '2000',
129
186
  display: 'flex',
130
187
  alignItems: 'center',
131
- paddingLeft: '8px',
132
- fontSize: '12px',
188
+ paddingLeft: '12px',
189
+ fontSize: '14px',
133
190
  color: '#333',
134
- transition: 'none'
191
+ transform: 'scale(1)',
192
+ willChange: 'transform, left, top'
135
193
  });
136
194
  document.body.appendChild(this.ghostEl);
137
195
  }
138
-
139
- /* ---------- 3. 蓝线 ---------- */
140
- }, {
141
- key: "createLine",
142
- value: function createLine() {
143
- this.lineEl = document.createElement('div');
144
- Object.assign(this.lineEl.style, {
145
- position: 'absolute',
146
- height: '3px',
147
- background: '#2196F3',
148
- borderRadius: '2px',
149
- zIndex: '2001',
150
- pointerEvents: 'none',
151
- display: 'none'
152
- });
153
- document.body.appendChild(this.lineEl);
154
- }
155
196
  }, {
156
- key: "commitData",
157
- value: /* ---------- 6. 提交数据 & 重绘 ---------- */
158
- function commitData() {
159
- var _this3 = this;
160
- //@ts-ignore
161
- this.ctx.database.data = this.flatData.filter(function (r) {
162
- return r !== _this3.PLACEHOLDER;
163
- });
164
- this.ctx.database.init(false);
165
- //@ts-ignore
166
- this.ctx.emit('rowOrderChange', this.ctx.database.data);
167
- this.ctx.emit('draw');
197
+ key: "easeOutBack",
198
+ value: /* 弹性缓动 */
199
+ function easeOutBack(t) {
200
+ var c1 = 1.70158,
201
+ c3 = c1 + 1;
202
+ return 1 + c3 * Math.pow(t - 1, 3) + c1 * Math.pow(t - 1, 2);
168
203
  }
169
204
 
170
- /* ---------- 7. 蓝线 ---------- */
205
+ /* ---------- 清理 ---------- */
171
206
  }, {
172
- key: "showLineAt",
173
- value: function showLineAt(y) {
174
- if (!this.lineEl) return;
175
- var rect = this.ctx.containerElement.getBoundingClientRect();
176
- this.lineEl.style.left = "".concat(rect.left, "px");
177
- this.lineEl.style.top = "".concat(rect.top + y - this.ctx.scrollY, "px");
178
- this.lineEl.style.width = "".concat(this.ctx.stageWidth, "px");
179
- this.lineEl.style.display = 'block';
207
+ key: "cleanup",
208
+ value: function cleanup() {
209
+ var _this$ghostEl;
210
+ cancelAnimationFrame(this.animId);
211
+ (_this$ghostEl = this.ghostEl) === null || _this$ghostEl === void 0 || _this$ghostEl.remove();
212
+ this.ghostEl = null;
213
+ this.ctx.pickedRowIndex = -1;
214
+ this.ctx.placeholderIndex = -1;
215
+ document.removeEventListener('mousemove', this.onMouseMove);
180
216
  }
181
217
 
182
- /* ---------- 8. 工具:根据鼠标坐标拿到单元格 ---------- */
218
+ /* ---------- 工具 ---------- */
183
219
  }, {
184
220
  key: "getCellFromEvent",
185
221
  value: function getCellFromEvent(e) {
@@ -196,9 +232,7 @@ var DragGhost = /*#__PURE__*/function () {
196
232
  try {
197
233
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
198
234
  var c = _step2.value;
199
- if (offsetX >= c.drawX && offsetX <= c.drawX + c.width && offsetY >= c.drawY && offsetY <= c.drawY + c.height) {
200
- return c;
201
- }
235
+ if (offsetX >= c.drawX && offsetX <= c.drawX + c.width && offsetY >= c.drawY && offsetY <= c.drawY + c.height) return c;
202
236
  }
203
237
  } catch (err) {
204
238
  _iterator2.e(err);
@@ -16,6 +16,9 @@ export default class Row {
16
16
  rowType: RowType;
17
17
  data: any;
18
18
  calculatedHeight: number;
19
+ private slideOffsetY;
20
+ /** 对外暴露:设置本次动画的偏移量 */
21
+ setSlideOffset(dy: number): void;
19
22
  constructor(ctx: Context, rowIndex: number, x: number | undefined, y: number | undefined, width: number | undefined, height: number | undefined, data: any, rowType?: RowType);
20
23
  update(): void;
21
24
  updateCalculatedHeight(): void;
@@ -35,6 +35,8 @@ var Row = /*#__PURE__*/function () {
35
35
  _defineProperty(this, "rowType", 'body');
36
36
  _defineProperty(this, "data", void 0);
37
37
  _defineProperty(this, "calculatedHeight", -1);
38
+ /* Row.ts 新增 */
39
+ _defineProperty(this, "slideOffsetY", 0);
38
40
  this.ctx = ctx;
39
41
  this.x = x;
40
42
  this.y = y;
@@ -47,6 +49,17 @@ var Row = /*#__PURE__*/function () {
47
49
  this.update();
48
50
  }
49
51
  _createClass(Row, [{
52
+ key: "setSlideOffset",
53
+ value:
54
+ // 像素偏移
55
+
56
+ /** 对外暴露:设置本次动画的偏移量 */
57
+ function setSlideOffset(dy) {
58
+ this.slideOffsetY = dy;
59
+ // 标记用途
60
+ this.data._slideOffset = dy;
61
+ }
62
+ }, {
50
63
  key: "update",
51
64
  value: function update() {
52
65
  var _this = this;
@@ -83,16 +96,35 @@ var Row = /*#__PURE__*/function () {
83
96
  }, {
84
97
  key: "drawCenter",
85
98
  value: function drawCenter() {
86
- this.noFixedCells.forEach(function (cell) {
87
- cell.draw();
99
+ if (this.slideOffsetY !== 0) this.ctx.paint.save();
100
+ if (this.slideOffsetY !== 0) this.ctx.paint.translate(0, this.slideOffsetY);
101
+ this.noFixedCells.forEach(function (c) {
102
+ return c.draw();
88
103
  });
104
+ if (this.slideOffsetY !== 0) this.ctx.paint.restore();
89
105
  }
90
106
  }, {
91
107
  key: "drawFixed",
92
108
  value: function drawFixed() {
93
- this.fixedCells.forEach(function (cell) {
94
- cell.draw();
95
- });
109
+ /* 抓起动画 */
110
+ if (this.data._dragging) {
111
+ this.ctx.paint.drawRect(this.x, this.y - this.ctx.scrollY, this.width, this.height, {
112
+ fillColor: this.ctx.config.BODY_BG_COLOR,
113
+ borderColor: this.ctx.config.BORDER_COLOR
114
+ });
115
+ return; // 跳过内容
116
+ }
117
+ var isPicked = this.ctx.pickedRowIndex === this.rowIndex;
118
+ if (isPicked) {
119
+ this.ctx.paint.save();
120
+ //@ts-ignore
121
+ this.ctx.paint.scale(0.95, 0.95);
122
+ this.ctx.paint.translate(0, -2);
123
+ }
124
+ // ===== 原有绘制代码 =====
125
+ if (isPicked) {
126
+ this.ctx.paint.restore();
127
+ }
96
128
  }
97
129
  }, {
98
130
  key: "drawContainer",
@@ -271,4 +271,33 @@
271
271
  .e-virt-table-filter-panel .ev-date-foot {
272
272
  margin-top: 8px;
273
273
  text-align: right;
274
- }
274
+ }
275
+ .e-virt-table-row-slide {
276
+ transition: transform 0.25s ease-out;
277
+ transform: translateY(var(--slide-dy));
278
+ }
279
+ /* 幽灵行 */
280
+ .drag-ghost {
281
+ position: fixed;
282
+ pointer-events: none;
283
+ z-index: 2000;
284
+ background: #f0f7ff;
285
+ border: 1px solid #d0d7de;
286
+ border-radius: 6px;
287
+ box-shadow: 0 4px 12px rgba(0,0,0,.15);
288
+ display: flex;
289
+ align-items: center;
290
+ padding-left: 12px;
291
+ font-size: 14px;
292
+ color: #333;
293
+ transition: none; /* 跟随鼠标时不插值 */
294
+ }
295
+ .drag-ghost.bounce-out {
296
+ transition: transform .2s ease-out, opacity .2s ease-out;
297
+ transform: scale(0.95) !important;
298
+ opacity: 0;
299
+ }
300
+
301
+ /* 普通行在拖拽中的平移 */
302
+ .row-shift-up { transform: translateY(-100%); }
303
+ .row-shift-down { transform: translateY(100%); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venus-design",
3
- "version": "0.8.5",
3
+ "version": "0.8.7",
4
4
  "description": "venus all compoments",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",