e-virt-table 0.0.3
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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/index.cjs.js +14 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +5422 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +14 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/lib/Autofill.d.ts +20 -0
- package/dist/lib/Autofill.js +185 -0
- package/dist/lib/Autofill.js.map +1 -0
- package/dist/lib/BaseCell.d.ts +22 -0
- package/dist/lib/BaseCell.js +111 -0
- package/dist/lib/BaseCell.js.map +1 -0
- package/dist/lib/Body.d.ts +29 -0
- package/dist/lib/Body.js +382 -0
- package/dist/lib/Body.js.map +1 -0
- package/dist/lib/Cell.d.ts +101 -0
- package/dist/lib/Cell.js +943 -0
- package/dist/lib/Cell.js.map +1 -0
- package/dist/lib/CellHeader.d.ts +64 -0
- package/dist/lib/CellHeader.js +355 -0
- package/dist/lib/CellHeader.js.map +1 -0
- package/dist/lib/Config.d.ts +106 -0
- package/dist/lib/Config.js +617 -0
- package/dist/lib/Config.js.map +1 -0
- package/dist/lib/Context.d.ts +123 -0
- package/dist/lib/Context.js +419 -0
- package/dist/lib/Context.js.map +1 -0
- package/dist/lib/Database.d.ts +228 -0
- package/dist/lib/Database.js +931 -0
- package/dist/lib/Database.js.map +1 -0
- package/dist/lib/EVirtTable.d.ts +61 -0
- package/dist/lib/EVirtTable.js +321 -0
- package/dist/lib/EVirtTable.js.map +1 -0
- package/dist/lib/Editor.d.ts +16 -0
- package/dist/lib/Editor.js +251 -0
- package/dist/lib/Editor.js.map +1 -0
- package/dist/lib/Empty.d.ts +7 -0
- package/dist/lib/Empty.js +45 -0
- package/dist/lib/Empty.js.map +1 -0
- package/dist/lib/EventBrowser.d.ts +17 -0
- package/dist/lib/EventBrowser.js +79 -0
- package/dist/lib/EventBrowser.js.map +1 -0
- package/dist/lib/EventBus.d.ts +12 -0
- package/dist/lib/EventBus.js +58 -0
- package/dist/lib/EventBus.js.map +1 -0
- package/dist/lib/EventTable.d.ts +26 -0
- package/dist/lib/EventTable.js +358 -0
- package/dist/lib/EventTable.js.map +1 -0
- package/dist/lib/Footer.d.ts +17 -0
- package/dist/lib/Footer.js +138 -0
- package/dist/lib/Footer.js.map +1 -0
- package/dist/lib/Header.d.ts +37 -0
- package/dist/lib/Header.js +482 -0
- package/dist/lib/Header.js.map +1 -0
- package/dist/lib/History.d.ts +27 -0
- package/dist/lib/History.js +106 -0
- package/dist/lib/History.js.map +1 -0
- package/dist/lib/Icons.d.ts +15 -0
- package/dist/lib/Icons.js +145 -0
- package/dist/lib/Icons.js.map +1 -0
- package/dist/lib/Overlayer.d.ts +10 -0
- package/dist/lib/Overlayer.js +267 -0
- package/dist/lib/Overlayer.js.map +1 -0
- package/dist/lib/Paint.d.ts +65 -0
- package/dist/lib/Paint.js +223 -0
- package/dist/lib/Paint.js.map +1 -0
- package/dist/lib/Row.d.ts +22 -0
- package/dist/lib/Row.js +125 -0
- package/dist/lib/Row.js.map +1 -0
- package/dist/lib/Scroller.d.ts +20 -0
- package/dist/lib/Scroller.js +448 -0
- package/dist/lib/Scroller.js.map +1 -0
- package/dist/lib/Selector.d.ts +38 -0
- package/dist/lib/Selector.js +532 -0
- package/dist/lib/Selector.js.map +1 -0
- package/dist/lib/Tooltip.d.ts +13 -0
- package/dist/lib/Tooltip.js +204 -0
- package/dist/lib/Tooltip.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.js +4 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/types.d.ts +160 -0
- package/dist/lib/types.js +2 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/util.d.ts +15 -0
- package/dist/lib/util.js +113 -0
- package/dist/lib/util.js.map +1 -0
- package/package.json +37 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type Context from "./Context";
|
|
2
|
+
export default class Autofill {
|
|
3
|
+
private ctx;
|
|
4
|
+
constructor(ctx: Context);
|
|
5
|
+
private init;
|
|
6
|
+
/**
|
|
7
|
+
* 是否在填充
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
private isAutofillIng;
|
|
11
|
+
private setMousedown;
|
|
12
|
+
private setMouseUp;
|
|
13
|
+
private setAutofill;
|
|
14
|
+
/**
|
|
15
|
+
* 填充数据
|
|
16
|
+
*/
|
|
17
|
+
private autofillData;
|
|
18
|
+
private mouseenter;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export default class Autofill {
|
|
2
|
+
constructor(ctx) {
|
|
3
|
+
Object.defineProperty(this, "ctx", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: void 0
|
|
8
|
+
});
|
|
9
|
+
this.ctx = ctx;
|
|
10
|
+
this.init();
|
|
11
|
+
}
|
|
12
|
+
init() {
|
|
13
|
+
this.ctx.on("cellMouseenter", (cell, e) => {
|
|
14
|
+
if (this.ctx.target.style.cursor === "crosshair") {
|
|
15
|
+
this.ctx.target.style.cursor = "default";
|
|
16
|
+
}
|
|
17
|
+
const { xArr, yArr } = this.ctx.selector;
|
|
18
|
+
const maxX = xArr[1];
|
|
19
|
+
const maxY = yArr[1];
|
|
20
|
+
const { colIndex, rowIndex, drawX, drawY, width, height } = cell;
|
|
21
|
+
// 绘制自动填充点
|
|
22
|
+
if (this.ctx.config.ENABLE_AUTOFILL &&
|
|
23
|
+
colIndex === maxX &&
|
|
24
|
+
rowIndex === maxY) {
|
|
25
|
+
const pointWh = 6;
|
|
26
|
+
const pointX = drawX + width - pointWh;
|
|
27
|
+
const pointY = drawY + height - pointWh;
|
|
28
|
+
if (e.offsetX > pointX && e.offsetY > pointY) {
|
|
29
|
+
// 引进到点
|
|
30
|
+
this.ctx.target.style.cursor = "crosshair";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
this.mouseenter(cell);
|
|
34
|
+
});
|
|
35
|
+
this.ctx.on("cellMousedown", () => {
|
|
36
|
+
if (this.ctx.target.style.cursor === "crosshair") {
|
|
37
|
+
this.setMousedown();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
this.ctx.on("mouseup", () => {
|
|
41
|
+
this.setMouseUp();
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 是否在填充
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
isAutofillIng() {
|
|
49
|
+
const { xArr, yArr } = this.ctx.selector;
|
|
50
|
+
// 两个相等
|
|
51
|
+
if (JSON.stringify(this.ctx.autofill.xArr) === JSON.stringify(xArr) &&
|
|
52
|
+
JSON.stringify(this.ctx.autofill.yArr) === JSON.stringify(yArr)) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
setMousedown() {
|
|
58
|
+
this.ctx.autofill.enable = true;
|
|
59
|
+
this.ctx.autofillMove = true;
|
|
60
|
+
}
|
|
61
|
+
setMouseUp() {
|
|
62
|
+
if (!this.ctx.autofill.enable) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const isAutofillIng = this.isAutofillIng();
|
|
66
|
+
if (isAutofillIng) {
|
|
67
|
+
this.autofillData();
|
|
68
|
+
}
|
|
69
|
+
this.ctx.autofill.enable = false;
|
|
70
|
+
this.ctx.autofillMove = false;
|
|
71
|
+
this.ctx.autofill.xArr = [-1, -1];
|
|
72
|
+
this.ctx.autofill.yArr = [-1, -1];
|
|
73
|
+
}
|
|
74
|
+
setAutofill(xArr, yArr) {
|
|
75
|
+
const { ENABLE_AUTOFILL, ENABLE_SELECTOR_SPAN_COL, ENABLE_SELECTOR_SPAN_ROW, } = this.ctx.config;
|
|
76
|
+
if (!ENABLE_AUTOFILL) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
let _xArr = xArr;
|
|
80
|
+
let _yArr = yArr;
|
|
81
|
+
if (!ENABLE_SELECTOR_SPAN_ROW) {
|
|
82
|
+
const [rowstart] = _yArr;
|
|
83
|
+
_yArr = [rowstart, rowstart];
|
|
84
|
+
}
|
|
85
|
+
if (!ENABLE_SELECTOR_SPAN_COL) {
|
|
86
|
+
const [colstart] = _xArr;
|
|
87
|
+
_xArr = [colstart, colstart];
|
|
88
|
+
}
|
|
89
|
+
// 减少渲染
|
|
90
|
+
if (JSON.stringify(this.ctx.autofill.xArr) !== JSON.stringify(_xArr) ||
|
|
91
|
+
JSON.stringify(this.ctx.autofill.yArr) !== JSON.stringify(_yArr)) {
|
|
92
|
+
this.ctx.autofill.xArr = _xArr;
|
|
93
|
+
this.ctx.autofill.yArr = _yArr;
|
|
94
|
+
this.ctx.emit("setAutofill", this.ctx.autofill);
|
|
95
|
+
this.ctx.emit("draw");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* 填充数据
|
|
100
|
+
*/
|
|
101
|
+
autofillData() {
|
|
102
|
+
const rowKeyList = new Set();
|
|
103
|
+
const selector = this.ctx.getSelectedData();
|
|
104
|
+
// 存复制赋值的位置,用于剔除填充
|
|
105
|
+
const selectorIndexMap = new Map();
|
|
106
|
+
for (let ri = 0; ri <= selector.yArr[1] - selector.yArr[0]; ri++) {
|
|
107
|
+
for (let ci = 0; ci <= selector.xArr[1] - selector.xArr[0]; ci++) {
|
|
108
|
+
const rowIndex = ri + selector.yArr[0];
|
|
109
|
+
const colIndex = ci + selector.xArr[0];
|
|
110
|
+
selectorIndexMap.set(`${rowIndex}-${colIndex}`, true);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
const { value } = selector;
|
|
114
|
+
const xStep = value[0].length;
|
|
115
|
+
const yStep = value.length;
|
|
116
|
+
const xArr = this.ctx.autofill.xArr;
|
|
117
|
+
const yArr = this.ctx.autofill.yArr;
|
|
118
|
+
let changeList = [];
|
|
119
|
+
for (let ri = 0; ri <= yArr[1] - yArr[0]; ri++) {
|
|
120
|
+
for (let ci = 0; ci <= xArr[1] - xArr[0]; ci++) {
|
|
121
|
+
const colIndex = ci + xArr[0];
|
|
122
|
+
const rowIndex = ri + yArr[0];
|
|
123
|
+
const val = value[ri % yStep][ci % xStep];
|
|
124
|
+
const itemValue = this.ctx.database.getItemValueForRowIndexAndColIndex(rowIndex, colIndex);
|
|
125
|
+
const selectorIndexKey = `${rowIndex}-${colIndex}`;
|
|
126
|
+
if (itemValue && !selectorIndexMap.has(selectorIndexKey)) {
|
|
127
|
+
const { rowKey, key } = itemValue;
|
|
128
|
+
// 只读就跳过
|
|
129
|
+
if (!this.ctx.database.getReadonly(rowKey, key)) {
|
|
130
|
+
rowKeyList.add(rowKey);
|
|
131
|
+
changeList.push({
|
|
132
|
+
rowKey,
|
|
133
|
+
key,
|
|
134
|
+
value: val,
|
|
135
|
+
row: {},
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
// 没有变化就返回
|
|
142
|
+
if (!changeList.length) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
// 批量设置数据,并记录历史
|
|
146
|
+
this.ctx.database.batchSetItemValue(changeList, true);
|
|
147
|
+
let rows = [];
|
|
148
|
+
rowKeyList.forEach((rowKey) => {
|
|
149
|
+
rows.push(this.ctx.database.getRowDataItemForRowKey(rowKey));
|
|
150
|
+
});
|
|
151
|
+
this.ctx.emit("autofillChange", changeList, rows);
|
|
152
|
+
// 设置选择器为填充位置
|
|
153
|
+
this.ctx.selector.xArr = this.ctx.autofill.xArr;
|
|
154
|
+
this.ctx.selector.yArr = this.ctx.autofill.yArr;
|
|
155
|
+
this.ctx.emit("draw");
|
|
156
|
+
}
|
|
157
|
+
mouseenter(cell) {
|
|
158
|
+
if (["index", "selection", "index-selection"].includes(cell.type)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const { selector, autofill } = this.ctx;
|
|
162
|
+
if (this.ctx.mousedown && selector.enable && autofill.enable) {
|
|
163
|
+
const { rowIndex, colIndex } = cell;
|
|
164
|
+
const xArr = selector.xArr.slice();
|
|
165
|
+
const yArr = selector.yArr.slice();
|
|
166
|
+
if (rowIndex >= selector.yArr[0] && rowIndex <= selector.yArr[1]) {
|
|
167
|
+
if (colIndex > selector.xArr[1]) {
|
|
168
|
+
xArr.splice(1, 1, colIndex);
|
|
169
|
+
}
|
|
170
|
+
else if (colIndex < selector.xArr[0]) {
|
|
171
|
+
xArr.splice(0, 1, colIndex);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
else if (rowIndex > selector.yArr[1]) {
|
|
175
|
+
yArr.splice(1, 1, rowIndex);
|
|
176
|
+
}
|
|
177
|
+
else if (rowIndex < selector.yArr[0]) {
|
|
178
|
+
yArr.splice(0, 1, rowIndex);
|
|
179
|
+
}
|
|
180
|
+
this.setAutofill(xArr, yArr);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
destroy() { }
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=Autofill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Autofill.js","sourceRoot":"","sources":["../../src/Autofill.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAE3B,YAAY,GAAY;QADhB;;;;;WAAa;QAEnB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IACO,IAAI;QACV,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;YACxC,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBACjD,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,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AE,CAAC;gBACjE,IAAI,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;oBAChC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;gBAC9B,CAAC;qBAAM,IAAI,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;oBACvC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;gBAC9B,CAAC;YACH,CAAC;iBAAM,IAAI,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;YAC9B,CAAC;iBAAM,IAAI,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC;YAC9B,CAAC;YACD,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,OAAO,KAAI,CAAC;CACb"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Context from "./Context";
|
|
2
|
+
import { CellType, Fixed } from "./types";
|
|
3
|
+
export default class BaseCell {
|
|
4
|
+
ctx: Context;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
fixed?: Fixed;
|
|
10
|
+
cellType: CellType;
|
|
11
|
+
constructor(ctx: Context, x: number, y: number, width: number, height: number, fixed: Fixed, cellType: CellType);
|
|
12
|
+
isHorizontalVisible(): boolean;
|
|
13
|
+
isVerticalVisible(): boolean;
|
|
14
|
+
getDrawX(): number;
|
|
15
|
+
getDrawY(): number;
|
|
16
|
+
getLeftFixedX(): number;
|
|
17
|
+
/**
|
|
18
|
+
* RightFixed时相对StageX
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
getRightFixedX(): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export default class BaseCell {
|
|
2
|
+
constructor(ctx, x, y, width, height, fixed, cellType) {
|
|
3
|
+
Object.defineProperty(this, "ctx", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: void 0
|
|
8
|
+
});
|
|
9
|
+
Object.defineProperty(this, "x", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: 0
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(this, "y", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
configurable: true,
|
|
18
|
+
writable: true,
|
|
19
|
+
value: 0
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(this, "width", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
configurable: true,
|
|
24
|
+
writable: true,
|
|
25
|
+
value: 0
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(this, "height", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
configurable: true,
|
|
30
|
+
writable: true,
|
|
31
|
+
value: 0
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(this, "fixed", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
writable: true,
|
|
37
|
+
value: void 0
|
|
38
|
+
});
|
|
39
|
+
Object.defineProperty(this, "cellType", {
|
|
40
|
+
enumerable: true,
|
|
41
|
+
configurable: true,
|
|
42
|
+
writable: true,
|
|
43
|
+
value: void 0
|
|
44
|
+
});
|
|
45
|
+
this.ctx = ctx;
|
|
46
|
+
this.x = x;
|
|
47
|
+
this.y = y;
|
|
48
|
+
this.width = width;
|
|
49
|
+
this.height = height;
|
|
50
|
+
this.fixed = fixed;
|
|
51
|
+
this.cellType = cellType;
|
|
52
|
+
}
|
|
53
|
+
isHorizontalVisible() {
|
|
54
|
+
if (this.fixed) {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
const { target, fixedLeftWidth, scrollX, fixedRightWidth } = this.ctx;
|
|
58
|
+
const offsetWidth = target.width;
|
|
59
|
+
return !(this.x + this.width - fixedLeftWidth - scrollX <= 0 ||
|
|
60
|
+
this.x - scrollX >= offsetWidth - fixedRightWidth);
|
|
61
|
+
}
|
|
62
|
+
isVerticalVisible() {
|
|
63
|
+
const { target, scrollY } = this.ctx;
|
|
64
|
+
const offsetHeight = target.height;
|
|
65
|
+
return !(this.y + this.height - scrollY <= 0 || this.y - scrollY >= offsetHeight);
|
|
66
|
+
}
|
|
67
|
+
getDrawX() {
|
|
68
|
+
if (this.fixed === "left") {
|
|
69
|
+
return this.x;
|
|
70
|
+
}
|
|
71
|
+
if (this.fixed === "right") {
|
|
72
|
+
// 可见区域宽度 -到右边界的距离即(表头宽度 - x坐标)
|
|
73
|
+
const x = this.ctx.header.visibleWidth - (this.ctx.header.width - this.x);
|
|
74
|
+
return x + 1; // +1是为了避免右边界的线被覆盖
|
|
75
|
+
}
|
|
76
|
+
return this.x - this.ctx.scrollX;
|
|
77
|
+
}
|
|
78
|
+
getDrawY() {
|
|
79
|
+
if (this.cellType === "header") {
|
|
80
|
+
return this.y;
|
|
81
|
+
}
|
|
82
|
+
// footer固定时
|
|
83
|
+
if (this.cellType === "footer" && this.ctx.config.FOOTER_FIXED) {
|
|
84
|
+
return this.y;
|
|
85
|
+
}
|
|
86
|
+
return this.y - this.ctx.scrollY;
|
|
87
|
+
}
|
|
88
|
+
getLeftFixedX() {
|
|
89
|
+
return this.x - this.ctx.scrollX;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* RightFixed时相对StageX
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
getRightFixedX() {
|
|
96
|
+
// const { SCROLLER_TRACK_SIZE } = this.grid.config;
|
|
97
|
+
// if (!this.grid.header) {
|
|
98
|
+
// return 0;
|
|
99
|
+
// }
|
|
100
|
+
// return (
|
|
101
|
+
// this.grid.header.width -
|
|
102
|
+
// this.x -
|
|
103
|
+
// this.grid.layer.x() -
|
|
104
|
+
// (this.grid.header.width - this.x) +
|
|
105
|
+
// this.grid.stage.width() -
|
|
106
|
+
// SCROLLER_TRACK_SIZE -
|
|
107
|
+
// (this.grid.header.width - this.x)
|
|
108
|
+
// );
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=BaseCell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseCell.js","sourceRoot":"","sources":["../../src/BaseCell.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAQ3B,YACE,GAAY,EACZ,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc,EACd,KAAY,EACZ,QAAkB;QAdpB;;;;;WAAa;QACb;;;;mBAAI,CAAC;WAAC;QACN;;;;mBAAI,CAAC;WAAC;QACN;;;;mBAAQ,CAAC;WAAC;QACV;;;;mBAAS,CAAC;WAAC;QACX;;;;;WAAc;QACd;;;;;WAAmB;QAUjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IACD,mBAAmB;QACjB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,eAA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AAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAC/D,OAAO,IAAI,CAAC,CAAC,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IACnC,CAAC;IACD,aAAa;QACX,OAAO,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;IACnC,CAAC;IACD;;;OAGG;IACH,cAAc;QACZ,oDAAoD;QACpD,2BAA2B;QAC3B,cAAc;QACd,IAAI;QACJ,WAAW;QACX,6BAA6B;QAC7B,aAAa;QACb,0BAA0B;QAC1B,wCAAwC;QACxC,8BAA8B;QAC9B,0BAA0B;QAC1B,sCAAsC;QACtC,KAAK;IACP,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type Context from './Context';
|
|
2
|
+
export default class Body {
|
|
3
|
+
private resizeTarget;
|
|
4
|
+
private isMouseDown;
|
|
5
|
+
private resizeDiff;
|
|
6
|
+
private offsetY;
|
|
7
|
+
private ctx;
|
|
8
|
+
private x;
|
|
9
|
+
private y;
|
|
10
|
+
private width;
|
|
11
|
+
private height;
|
|
12
|
+
private headIndex;
|
|
13
|
+
private tailIndex;
|
|
14
|
+
private isResizing;
|
|
15
|
+
private renderRows;
|
|
16
|
+
private visibleRows;
|
|
17
|
+
private visibleHeight;
|
|
18
|
+
private visibleWidth;
|
|
19
|
+
private data;
|
|
20
|
+
constructor(ctx: Context);
|
|
21
|
+
private init;
|
|
22
|
+
private initResizeRow;
|
|
23
|
+
private resizeRow;
|
|
24
|
+
private drawTipLine;
|
|
25
|
+
private drawFiexShadow;
|
|
26
|
+
private binarySearch;
|
|
27
|
+
update(): void;
|
|
28
|
+
draw(): void;
|
|
29
|
+
}
|