venus-design 0.8.5 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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
  };
@@ -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,
@@ -4,17 +4,14 @@ export default class DragGhost {
4
4
  private dragIndex;
5
5
  private ghostEl;
6
6
  private lineEl;
7
- private placeholderIndex;
8
- private flatData;
9
7
  private dragRow;
10
- private readonly PLACEHOLDER;
8
+ private flatData;
11
9
  constructor(ctx: Context);
12
10
  private onMouseDown;
13
11
  private createGhost;
14
12
  private createLine;
15
13
  private onMouseMove;
16
14
  private onMouseUp;
17
- private commitData;
18
15
  private showLineAt;
19
16
  private getCellFromEvent;
20
17
  }
@@ -14,27 +14,21 @@ var DragGhost = /*#__PURE__*/function () {
14
14
  _classCallCheck(this, DragGhost);
15
15
  _defineProperty(this, "ctx", void 0);
16
16
  _defineProperty(this, "dragIndex", -1);
17
- // 被拖行的原始索引
18
17
  _defineProperty(this, "ghostEl", null);
19
18
  _defineProperty(this, "lineEl", null);
20
- /* 空位逻辑 */
21
- _defineProperty(this, "placeholderIndex", -1);
22
- // -1:无空位
23
- _defineProperty(this, "flatData", []);
24
- // 当前扁平数据(含占位符)
19
+ /* 飞书拖拽:用“标记位”代替占位符,序号永不错位 */
25
20
  _defineProperty(this, "dragRow", null);
26
- // 被拖行的副本
27
- _defineProperty(this, "PLACEHOLDER", Symbol.for('DRAGGING'));
28
- /* ---------- 4. 鼠标移动:空位实时推/顶 ---------- */
21
+ _defineProperty(this, "flatData", []);
22
+ /* ---------- 鼠标移动:只移动“标记” ---------- */
29
23
  _defineProperty(this, "onMouseMove", function (e) {
30
24
  if (!_this.ghostEl) return;
31
25
  e.preventDefault();
32
26
 
33
- /* 4.1 幽灵行跟随鼠标 */
34
- _this.ghostEl.style.left = "".concat(e.clientX + 10, "px");
35
- _this.ghostEl.style.top = "".concat(e.clientY - 10, "px");
27
+ /* 幽灵行跟随鼠标 */
28
+ _this.ghostEl.style.left = "".concat(e.clientX + 12, "px");
29
+ _this.ghostEl.style.top = "".concat(e.clientY - 12, "px");
36
30
 
37
- /* 4.2 计算插入点 */
31
+ /* 计算插入索引(用完整数据长度) */
38
32
  var canvasY = e.clientY - _this.ctx.containerElement.getBoundingClientRect().top + _this.ctx.scrollY;
39
33
  var insertIndex = _this.flatData.length;
40
34
  for (var i = 0; i < _this.flatData.length; i++) {
@@ -47,29 +41,42 @@ var DragGhost = /*#__PURE__*/function () {
47
41
  }
48
42
  }
49
43
 
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(); // 重绘 → 看到“顶/推”动画
44
+ /* 把“_dragging”标记换到新位置 */
45
+ if (insertIndex !== _this.ctx.placeholderIndex) {
46
+ /* 把标记换到新位置 */
47
+ var oldItem = _this.flatData[_this.ctx.placeholderIndex];
48
+ var newItem = _this.flatData[insertIndex];
49
+ if (oldItem) oldItem._dragging = false;
50
+ if (newItem) newItem._dragging = true;
51
+ _this.ctx.placeholderIndex = insertIndex;
52
+ _this.ctx.emit('draw'); // 重绘 → 空位平滑推/顶
56
53
  }
57
-
58
- /* 4.4 蓝线 */
59
54
  _this.showLineAt(canvasY);
60
55
  });
61
- /* ---------- 5. 抬起:把占位符换回被拖行 ---------- */
56
+ /* ---------- 抬起 ---------- */
62
57
  _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();
58
+ /* 幽灵行消失动画 */
59
+ if (_this.ghostEl) {
60
+ _this.ghostEl.style.transform = 'scale(0.9)';
61
+ _this.ghostEl.style.opacity = '0';
67
62
  }
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;
63
+
64
+ /* 清标记 */
65
+ if (_this.ctx.placeholderIndex !== -1) {
66
+ _this.flatData[_this.ctx.placeholderIndex]._dragging = false;
67
+ }
68
+ _this.ctx.pickedRowIndex = -1;
69
+ _this.ctx.placeholderIndex = -1;
70
+ var item = _this.flatData[_this.ctx.placeholderIndex];
71
+ if (item) item._dragging = false;
72
+ _this.ctx.emit('draw');
73
+ setTimeout(function () {
74
+ var _this$ghostEl, _this$lineEl;
75
+ (_this$ghostEl = _this.ghostEl) === null || _this$ghostEl === void 0 || _this$ghostEl.remove();
76
+ (_this$lineEl = _this.lineEl) === null || _this$lineEl === void 0 || _this$lineEl.remove();
77
+ _this.ghostEl = null;
78
+ _this.lineEl = null;
79
+ }, 250);
73
80
  document.removeEventListener('mousemove', _this.onMouseMove);
74
81
  });
75
82
  this.ctx = ctx;
@@ -78,7 +85,7 @@ var DragGhost = /*#__PURE__*/function () {
78
85
  });
79
86
  }
80
87
 
81
- /* ---------- 1. 启动拖拽 ---------- */
88
+ /* ---------- 抓起 ---------- */
82
89
  _createClass(DragGhost, [{
83
90
  key: "onMouseDown",
84
91
  value: function onMouseDown(e) {
@@ -93,12 +100,14 @@ var DragGhost = /*#__PURE__*/function () {
93
100
  });
94
101
  if (this.dragIndex === -1) return;
95
102
 
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);
103
+ /* 1. 打标记 2. 不删数据 3. 立即重绘 渲染层跳过内容但留高度 */
104
+ this.dragRow = this.flatData[this.dragIndex];
105
+ var target = this.flatData[this.dragIndex];
106
+ if (!target) return; // ✅防错退出
107
+ this.dragRow = target;
108
+ target._dragging = true;
109
+ this.ctx.emit('draw');
110
+ this.createGhost(cell);
102
111
  this.createLine();
103
112
  document.addEventListener('mousemove', this.onMouseMove, {
104
113
  passive: false
@@ -108,10 +117,10 @@ var DragGhost = /*#__PURE__*/function () {
108
117
  });
109
118
  }
110
119
 
111
- /* ---------- 2. 幽灵行 ---------- */
120
+ /* ---------- 幽灵行 ---------- */
112
121
  }, {
113
122
  key: "createGhost",
114
- value: function createGhost(cell, dragRow) {
123
+ value: function createGhost(cell) {
115
124
  var rect = this.ctx.containerElement.getBoundingClientRect();
116
125
  this.ghostEl = document.createElement('div');
117
126
  this.ghostEl.innerText = cell.getText() || ' ';
@@ -121,30 +130,32 @@ var DragGhost = /*#__PURE__*/function () {
121
130
  top: "".concat(rect.top + cell.drawY, "px"),
122
131
  width: "".concat(cell.width, "px"),
123
132
  height: "".concat(cell.height, "px"),
124
- background: 'rgba(33,150,243,0.25)',
125
- border: '2px solid #2196F3',
126
- borderRadius: '4px',
133
+ background: '#fff',
134
+ border: '1px solid #e0e0e0',
135
+ borderRadius: '8px',
136
+ boxShadow: '0 4px 12px rgba(0,0,0,0.15)',
127
137
  pointerEvents: 'none',
128
138
  zIndex: '2000',
129
139
  display: 'flex',
130
140
  alignItems: 'center',
131
- paddingLeft: '8px',
132
- fontSize: '12px',
141
+ paddingLeft: '12px',
142
+ fontSize: '14px',
133
143
  color: '#333',
134
- transition: 'none'
144
+ transform: 'scale(1)',
145
+ transition: 'transform 0.25s ease-out'
135
146
  });
136
147
  document.body.appendChild(this.ghostEl);
137
148
  }
138
149
 
139
- /* ---------- 3. 蓝线 ---------- */
150
+ /* ---------- 蓝线 ---------- */
140
151
  }, {
141
152
  key: "createLine",
142
153
  value: function createLine() {
143
154
  this.lineEl = document.createElement('div');
144
155
  Object.assign(this.lineEl.style, {
145
156
  position: 'absolute',
146
- height: '3px',
147
- background: '#2196F3',
157
+ height: '2px',
158
+ background: '#3370ff',
148
159
  borderRadius: '2px',
149
160
  zIndex: '2001',
150
161
  pointerEvents: 'none',
@@ -152,25 +163,10 @@ var DragGhost = /*#__PURE__*/function () {
152
163
  });
153
164
  document.body.appendChild(this.lineEl);
154
165
  }
155
- }, {
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');
168
- }
169
-
170
- /* ---------- 7. 蓝线 ---------- */
171
166
  }, {
172
167
  key: "showLineAt",
173
- value: function showLineAt(y) {
168
+ value: /* ---------- 蓝线 ---------- */
169
+ function showLineAt(y) {
174
170
  if (!this.lineEl) return;
175
171
  var rect = this.ctx.containerElement.getBoundingClientRect();
176
172
  this.lineEl.style.left = "".concat(rect.left, "px");
@@ -179,7 +175,7 @@ var DragGhost = /*#__PURE__*/function () {
179
175
  this.lineEl.style.display = 'block';
180
176
  }
181
177
 
182
- /* ---------- 8. 工具:根据鼠标坐标拿到单元格 ---------- */
178
+ /* ---------- 工具 ---------- */
183
179
  }, {
184
180
  key: "getCellFromEvent",
185
181
  value: function getCellFromEvent(e) {
@@ -83,6 +83,13 @@ var Row = /*#__PURE__*/function () {
83
83
  }, {
84
84
  key: "drawCenter",
85
85
  value: function drawCenter() {
86
+ if (this.data._dragging) {
87
+ this.ctx.paint.drawRect(this.x, this.y - this.ctx.scrollY, this.width, this.height, {
88
+ fillColor: this.ctx.config.BODY_BG_COLOR,
89
+ borderColor: this.ctx.config.BORDER_COLOR
90
+ });
91
+ return; // 跳过内容
92
+ }
86
93
  this.noFixedCells.forEach(function (cell) {
87
94
  cell.draw();
88
95
  });
@@ -90,9 +97,25 @@ var Row = /*#__PURE__*/function () {
90
97
  }, {
91
98
  key: "drawFixed",
92
99
  value: function drawFixed() {
93
- this.fixedCells.forEach(function (cell) {
94
- cell.draw();
95
- });
100
+ /* 抓起动画 */
101
+ if (this.data._dragging) {
102
+ this.ctx.paint.drawRect(this.x, this.y - this.ctx.scrollY, this.width, this.height, {
103
+ fillColor: this.ctx.config.BODY_BG_COLOR,
104
+ borderColor: this.ctx.config.BORDER_COLOR
105
+ });
106
+ return; // 跳过内容
107
+ }
108
+ var isPicked = this.ctx.pickedRowIndex === this.rowIndex;
109
+ if (isPicked) {
110
+ this.ctx.paint.save();
111
+ //@ts-ignore
112
+ this.ctx.paint.scale(0.95, 0.95);
113
+ this.ctx.paint.translate(0, -2);
114
+ }
115
+ // ===== 原有绘制代码 =====
116
+ if (isPicked) {
117
+ this.ctx.paint.restore();
118
+ }
96
119
  }
97
120
  }, {
98
121
  key: "drawContainer",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "venus-design",
3
- "version": "0.8.5",
3
+ "version": "0.8.6",
4
4
  "description": "venus all compoments",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",