@visactor/vtable 1.3.2-alpha.0 → 1.3.2-alpha.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.
- package/cjs/PivotChart.d.ts +1 -0
- package/cjs/PivotChart.js +4 -0
- package/cjs/PivotChart.js.map +1 -1
- package/cjs/components/axis/axis.js +3 -2
- package/cjs/components/axis/axis.js.map +1 -1
- package/cjs/components/empty-tip/empty-tip.js +2 -2
- package/cjs/components/empty-tip/empty-tip.js.map +1 -1
- package/cjs/components/legend/discrete-legend/discrete-legend.js +2 -1
- package/cjs/components/legend/discrete-legend/discrete-legend.js.map +1 -1
- package/cjs/core/BaseTable.d.ts +4 -2
- package/cjs/core/BaseTable.js +54 -170
- package/cjs/core/BaseTable.js.map +1 -1
- package/cjs/core/FouseInput.d.ts +1 -0
- package/cjs/core/FouseInput.js +5 -2
- package/cjs/core/FouseInput.js.map +1 -1
- package/cjs/core/utils/get-cell-position.d.ts +42 -0
- package/cjs/core/utils/get-cell-position.js +206 -0
- package/cjs/core/utils/get-cell-position.js.map +1 -0
- package/cjs/dataset/dataset.d.ts +0 -2
- package/cjs/dataset/dataset.js +7 -8
- package/cjs/dataset/dataset.js.map +1 -1
- package/cjs/event/event.js +2 -1
- package/cjs/event/event.js.map +1 -1
- package/cjs/event/listener/container-dom.js +1 -1
- package/cjs/event/listener/container-dom.js.map +1 -1
- package/cjs/event/util.js +2 -2
- package/cjs/event/util.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/layout/pivot-header-layout.js +37 -57
- package/cjs/layout/pivot-header-layout.js.map +1 -1
- package/cjs/scenegraph/debug-tool/debug-tool.js +4 -1
- package/cjs/scenegraph/debug-tool/debug-tool.js.map +1 -1
- package/cjs/scenegraph/graphic/chart.d.ts +1 -0
- package/cjs/scenegraph/graphic/chart.js +34 -20
- package/cjs/scenegraph/graphic/chart.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/chart-render-helper.js +20 -8
- package/cjs/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
- package/cjs/scenegraph/graphic/contributions/chart-render.d.ts +2 -1
- package/cjs/scenegraph/graphic/contributions/chart-render.js +40 -24
- package/cjs/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/cjs/scenegraph/group-creater/cell-type/chart-cell.js +2 -1
- package/cjs/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
- package/cjs/scenegraph/refresh-node/update-chart.d.ts +1 -0
- package/cjs/scenegraph/refresh-node/update-chart.js +9 -2
- package/cjs/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/cjs/scenegraph/scenegraph.js +10 -4
- package/cjs/scenegraph/scenegraph.js.map +1 -1
- package/cjs/ts-types/base-table.d.ts +14 -1
- package/cjs/ts-types/base-table.js.map +1 -1
- package/cjs/vrender.js.map +1 -1
- package/dist/vtable.js +511 -443
- package/dist/vtable.min.js +2 -2
- package/es/PivotChart.d.ts +1 -0
- package/es/PivotChart.js +5 -2
- package/es/PivotChart.js.map +1 -1
- package/es/components/axis/axis.js +3 -1
- package/es/components/axis/axis.js.map +1 -1
- package/es/components/empty-tip/empty-tip.js +2 -2
- package/es/components/empty-tip/empty-tip.js.map +1 -1
- package/es/components/legend/discrete-legend/discrete-legend.js +2 -1
- package/es/components/legend/discrete-legend/discrete-legend.js.map +1 -1
- package/es/core/BaseTable.d.ts +4 -2
- package/es/core/BaseTable.js +55 -169
- package/es/core/BaseTable.js.map +1 -1
- package/es/core/FouseInput.d.ts +1 -0
- package/es/core/FouseInput.js +5 -2
- package/es/core/FouseInput.js.map +1 -1
- package/es/core/utils/get-cell-position.d.ts +42 -0
- package/es/core/utils/get-cell-position.js +194 -0
- package/es/core/utils/get-cell-position.js.map +1 -0
- package/es/dataset/dataset.d.ts +0 -2
- package/es/dataset/dataset.js +7 -8
- package/es/dataset/dataset.js.map +1 -1
- package/es/event/event.js +2 -1
- package/es/event/event.js.map +1 -1
- package/es/event/listener/container-dom.js +1 -1
- package/es/event/listener/container-dom.js.map +1 -1
- package/es/event/util.js +2 -2
- package/es/event/util.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/layout/pivot-header-layout.js +36 -56
- package/es/layout/pivot-header-layout.js.map +1 -1
- package/es/scenegraph/debug-tool/debug-tool.js +4 -1
- package/es/scenegraph/debug-tool/debug-tool.js.map +1 -1
- package/es/scenegraph/graphic/chart.d.ts +1 -0
- package/es/scenegraph/graphic/chart.js +33 -21
- package/es/scenegraph/graphic/chart.js.map +1 -1
- package/es/scenegraph/graphic/contributions/chart-render-helper.js +20 -8
- package/es/scenegraph/graphic/contributions/chart-render-helper.js.map +1 -1
- package/es/scenegraph/graphic/contributions/chart-render.d.ts +2 -1
- package/es/scenegraph/graphic/contributions/chart-render.js +41 -25
- package/es/scenegraph/graphic/contributions/chart-render.js.map +1 -1
- package/es/scenegraph/group-creater/cell-type/chart-cell.js +2 -1
- package/es/scenegraph/group-creater/cell-type/chart-cell.js.map +1 -1
- package/es/scenegraph/refresh-node/update-chart.d.ts +1 -0
- package/es/scenegraph/refresh-node/update-chart.js +6 -0
- package/es/scenegraph/refresh-node/update-chart.js.map +1 -1
- package/es/scenegraph/scenegraph.js +10 -4
- package/es/scenegraph/scenegraph.js.map +1 -1
- package/es/ts-types/base-table.d.ts +14 -1
- package/es/ts-types/base-table.js.map +1 -1
- package/es/vrender.js.map +1 -1
- package/package.json +2 -2
package/cjs/core/FouseInput.d.ts
CHANGED
package/cjs/core/FouseInput.js
CHANGED
|
@@ -14,7 +14,7 @@ class FocusInput extends EventTarget {
|
|
|
14
14
|
div.classList.add("input-container");
|
|
15
15
|
const input = this._input = document.createElement("input");
|
|
16
16
|
div.appendChild(input), input.classList.add("table-focus-control"), input.dataset.vtable = "vtable",
|
|
17
|
-
input.readOnly = !0, parentElement.appendChild(div);
|
|
17
|
+
input.readOnly = !0, parentElement.appendChild(div), this._container = div;
|
|
18
18
|
}
|
|
19
19
|
focus() {
|
|
20
20
|
this._input.focus({
|
|
@@ -31,7 +31,10 @@ class FocusInput extends EventTarget {
|
|
|
31
31
|
get input() {
|
|
32
32
|
return this._input;
|
|
33
33
|
}
|
|
34
|
-
release() {
|
|
34
|
+
release() {
|
|
35
|
+
var _a;
|
|
36
|
+
null === (_a = this._container.parentElement) || void 0 === _a || _a.removeChild(this._container);
|
|
37
|
+
}
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
exports.FocusInput = FocusInput;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/FouseInput.ts"],"names":[],"mappings":";;;AAEA,sCAAmC;AAEnC,MAAa,UAAW,SAAQ,WAAW;
|
|
1
|
+
{"version":3,"sources":["../src/core/FouseInput.ts"],"names":[],"mappings":";;;AAEA,sCAAmC;AAEnC,MAAa,UAAW,SAAQ,WAAW;IAIzC,YAAY,KAAgB,EAAE,aAA0B;QACtD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;QACpB,IAAI,SAAG,CAAC,IAAI,KAAK,MAAM,EAAE;YACvB,OAAO;SACR;QACD,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE1C,GAAG,CAAC,KAAK,CAAC,OAAO,GAAG,GAAG,CAAC;QACxB,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,QAAQ,CAAC;QAC9B,GAAG,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC;QACjC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QACrC,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9D,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,CAAC,SAAS,CAAC,GAAG,CA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gCA+CC","file":"FouseInput.js","sourcesContent":["import type { BaseTable } from '../core';\nimport type { Rect } from '../tools/Rect';\nimport { Env } from '../tools/env';\n\nexport class FocusInput extends EventTarget {\n private _container: HTMLDivElement;\n private _table: BaseTable;\n private _input: HTMLInputElement;\n constructor(table: BaseTable, parentElement: HTMLElement) {\n super();\n this._table = table;\n if (Env.mode === 'node') {\n return;\n }\n const div = document.createElement('div'); //再加一层 C360插件逻辑中用的window.getSelection()来判断的滚动\n // div.style.position = 'fixed';//定位不能使用fixed 在父级transform非none的时候 都会有问题\n div.style.opacity = '0';\n div.dataset.vtable = 'vtable'; //这里不能变 C360取元素的依据\n div.style.pointerEvents = 'none';\n div.classList.add('input-container');\n const input = (this._input = document.createElement('input'));\n div.appendChild(input);\n input.classList.add('table-focus-control');\n input.dataset.vtable = 'vtable';\n input.readOnly = true;\n parentElement.appendChild(div);\n this._container = div;\n }\n\n focus(): void {\n this._input.focus({ preventScroll: true });\n }\n setFocusRect(rect: Rect, value: string): void {\n const input = this._input;\n input.value = value;\n // input.focus({ preventScroll: true });\n input.select();\n const top = rect.top - this._table.scrollTop;\n const left = rect.left - this._table.scrollLeft;\n input.style.top = `${top.toFixed()}px`;\n input.style.left = `${left.toFixed()}px`;\n input.style.width = `${rect.width.toFixed()}px`;\n input.style.height = `${rect.height.toFixed()}px`;\n }\n get input(): HTMLInputElement {\n return this._input;\n }\n release(): void {\n // document.removeChild(this._input);\n this._container.parentElement?.removeChild(this._container);\n }\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CellAddressWithBound } from '../../ts-types';
|
|
2
|
+
import type { BaseTableAPI } from '../../ts-types/base-table';
|
|
3
|
+
export declare function getRowAt(absoluteY: number, _this: BaseTableAPI): {
|
|
4
|
+
top: number;
|
|
5
|
+
row: number;
|
|
6
|
+
bottom: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
export declare function getColAt(absoluteX: number, _this: BaseTableAPI): {
|
|
10
|
+
left: number;
|
|
11
|
+
col: number;
|
|
12
|
+
right: number;
|
|
13
|
+
width: number;
|
|
14
|
+
};
|
|
15
|
+
export declare function getCellAt(absoluteX: number, absoluteY: number, _this: BaseTableAPI): CellAddressWithBound;
|
|
16
|
+
export declare function getTargetColAt(absoluteX: number, _this: BaseTableAPI): {
|
|
17
|
+
col: number;
|
|
18
|
+
left: number;
|
|
19
|
+
right: number;
|
|
20
|
+
width: number;
|
|
21
|
+
} | null;
|
|
22
|
+
export declare function getTargetRowAt(absoluteY: number, _this: BaseTableAPI): {
|
|
23
|
+
row: number;
|
|
24
|
+
top: number;
|
|
25
|
+
bottom: number;
|
|
26
|
+
height: number;
|
|
27
|
+
} | null;
|
|
28
|
+
export declare function getTargetColAtConsiderRightFrozen(absoluteX: number, isConsider: boolean, _this: BaseTableAPI): {
|
|
29
|
+
col: number;
|
|
30
|
+
left: number;
|
|
31
|
+
right: number;
|
|
32
|
+
width: number;
|
|
33
|
+
} | null;
|
|
34
|
+
export declare function getTargetRowAtConsiderBottomFrozen(absoluteY: number, isConsider: boolean, _this: BaseTableAPI): {
|
|
35
|
+
row: number;
|
|
36
|
+
top: number;
|
|
37
|
+
bottom: number;
|
|
38
|
+
height: number;
|
|
39
|
+
} | null;
|
|
40
|
+
export declare function computeTargetRowByY(absoluteY: number, _this: BaseTableAPI): number;
|
|
41
|
+
export declare function computeTargetColByX(absoluteX: number, _this: BaseTableAPI): number;
|
|
42
|
+
export declare function getCellAtRelativePosition(x: number, y: number, _this: BaseTableAPI): CellAddressWithBound;
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
}), exports.getCellAtRelativePosition = exports.computeTargetColByX = exports.computeTargetRowByY = exports.getTargetRowAtConsiderBottomFrozen = exports.getTargetColAtConsiderRightFrozen = exports.getTargetRowAt = exports.getTargetColAt = exports.getCellAt = exports.getColAt = exports.getRowAt = void 0;
|
|
6
|
+
|
|
7
|
+
const tableHelper_1 = require("../tableHelper");
|
|
8
|
+
|
|
9
|
+
function getRowAt(absoluteY, _this) {
|
|
10
|
+
const frozen = (0, tableHelper_1._getTargetFrozenRowAt)(_this, absoluteY);
|
|
11
|
+
if (frozen) return frozen;
|
|
12
|
+
let row = getTargetRowAt(absoluteY, _this);
|
|
13
|
+
return row || (row = {
|
|
14
|
+
top: -1,
|
|
15
|
+
row: -1,
|
|
16
|
+
bottom: -1,
|
|
17
|
+
height: -1
|
|
18
|
+
}), row;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getColAt(absoluteX, _this) {
|
|
22
|
+
const frozen = (0, tableHelper_1._getTargetFrozenColAt)(_this, absoluteX);
|
|
23
|
+
if (frozen) return frozen;
|
|
24
|
+
let col = getTargetColAt(absoluteX, _this);
|
|
25
|
+
return col || (col = {
|
|
26
|
+
left: -1,
|
|
27
|
+
col: -1,
|
|
28
|
+
right: -1,
|
|
29
|
+
width: 1
|
|
30
|
+
}), col;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getCellAt(absoluteX, absoluteY, _this) {
|
|
34
|
+
const rowInfo = getRowAt(absoluteY, _this), {row: row, top: top, bottom: bottom, height: height} = rowInfo, colInfo = getColAt(absoluteX, _this), {col: col, left: left, right: right, width: width} = colInfo;
|
|
35
|
+
return {
|
|
36
|
+
row: row,
|
|
37
|
+
col: col,
|
|
38
|
+
rect: {
|
|
39
|
+
left: left,
|
|
40
|
+
right: right,
|
|
41
|
+
top: top,
|
|
42
|
+
bottom: bottom,
|
|
43
|
+
width: width,
|
|
44
|
+
height: height
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function getTargetColAt(absoluteX, _this) {
|
|
50
|
+
if (0 === absoluteX) return {
|
|
51
|
+
left: 0,
|
|
52
|
+
col: 0,
|
|
53
|
+
right: 0,
|
|
54
|
+
width: 0
|
|
55
|
+
};
|
|
56
|
+
const candCol = computeTargetColByX(absoluteX, _this), right = _this.getColsWidth(0, candCol);
|
|
57
|
+
return absoluteX >= right ? ((startCol, startRight) => {
|
|
58
|
+
let left = startRight - _this.getColWidth(startCol);
|
|
59
|
+
const {colCount: colCount} = _this.internalProps;
|
|
60
|
+
for (let col = startCol; col < colCount; col++) {
|
|
61
|
+
const width = _this.getColWidth(col), right = left + width;
|
|
62
|
+
if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) return {
|
|
63
|
+
left: left,
|
|
64
|
+
col: col,
|
|
65
|
+
right: right,
|
|
66
|
+
width: width
|
|
67
|
+
};
|
|
68
|
+
left = right;
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
})(candCol, right) : ((startCol, startRight) => {
|
|
72
|
+
let right = startRight;
|
|
73
|
+
for (let col = startCol; col >= 0; col--) {
|
|
74
|
+
const width = _this.getColWidth(col), left = right - width;
|
|
75
|
+
if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) return {
|
|
76
|
+
left: left,
|
|
77
|
+
col: col,
|
|
78
|
+
right: right,
|
|
79
|
+
width: width
|
|
80
|
+
};
|
|
81
|
+
right = left;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
})(candCol, right);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function getTargetRowAt(absoluteY, _this) {
|
|
88
|
+
if (0 === absoluteY) return {
|
|
89
|
+
top: 0,
|
|
90
|
+
row: 0,
|
|
91
|
+
bottom: 0,
|
|
92
|
+
height: 0
|
|
93
|
+
};
|
|
94
|
+
const candRow = computeTargetRowByY(absoluteY, _this), bottom = _this.getRowsHeight(0, candRow);
|
|
95
|
+
return absoluteY >= bottom ? ((startRow, startBottom) => {
|
|
96
|
+
let top = startBottom - _this.getRowHeight(startRow);
|
|
97
|
+
const {rowCount: rowCount} = _this.internalProps;
|
|
98
|
+
for (let row = startRow; row < rowCount; row++) {
|
|
99
|
+
const height = _this.getRowHeight(row), bottom = top + height;
|
|
100
|
+
if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) return {
|
|
101
|
+
top: top,
|
|
102
|
+
row: row,
|
|
103
|
+
bottom: bottom,
|
|
104
|
+
height: height
|
|
105
|
+
};
|
|
106
|
+
top = bottom;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
})(candRow, bottom) : ((startRow, startBottom) => {
|
|
110
|
+
let bottom = startBottom;
|
|
111
|
+
for (let row = startRow; row >= 0; row--) {
|
|
112
|
+
const height = _this.getRowHeight(row), top = bottom - height;
|
|
113
|
+
if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) return {
|
|
114
|
+
top: top,
|
|
115
|
+
row: row,
|
|
116
|
+
bottom: bottom,
|
|
117
|
+
height: height
|
|
118
|
+
};
|
|
119
|
+
bottom = top;
|
|
120
|
+
}
|
|
121
|
+
return null;
|
|
122
|
+
})(candRow, bottom);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function getTargetColAtConsiderRightFrozen(absoluteX, isConsider, _this) {
|
|
126
|
+
if (0 === absoluteX) return {
|
|
127
|
+
left: 0,
|
|
128
|
+
col: 0,
|
|
129
|
+
right: 0,
|
|
130
|
+
width: 0
|
|
131
|
+
};
|
|
132
|
+
if (isConsider && absoluteX > _this.tableNoFrameWidth - _this.getRightFrozenColsWidth() && absoluteX < _this.tableNoFrameWidth) for (let i = 0; i < _this.rightFrozenColCount; i++) if (absoluteX > _this.tableNoFrameWidth - _this.getColsWidth(_this.colCount - i - 1, _this.colCount - 1)) return {
|
|
133
|
+
col: _this.colCount - i - 1,
|
|
134
|
+
left: void 0,
|
|
135
|
+
right: void 0,
|
|
136
|
+
width: void 0
|
|
137
|
+
};
|
|
138
|
+
return getTargetColAt(absoluteX, _this);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function getTargetRowAtConsiderBottomFrozen(absoluteY, isConsider, _this) {
|
|
142
|
+
if (0 === absoluteY) return {
|
|
143
|
+
top: 0,
|
|
144
|
+
row: 0,
|
|
145
|
+
bottom: 0,
|
|
146
|
+
height: 0
|
|
147
|
+
};
|
|
148
|
+
if (isConsider && absoluteY > _this.tableNoFrameHeight - _this.getBottomFrozenRowsHeight() && absoluteY < _this.tableNoFrameHeight) for (let i = 0; i < _this.rightFrozenColCount; i++) if (absoluteY > _this.tableNoFrameHeight - _this.getRowsHeight(_this.rowCount - i - 1, _this.rowCount - 1)) return {
|
|
149
|
+
row: _this.rowCount - i - 1,
|
|
150
|
+
top: void 0,
|
|
151
|
+
bottom: void 0,
|
|
152
|
+
height: void 0
|
|
153
|
+
};
|
|
154
|
+
return getTargetRowAt(absoluteY, _this);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function computeTargetRowByY(absoluteY, _this) {
|
|
158
|
+
let defaultRowHeight = _this.internalProps.defaultRowHeight;
|
|
159
|
+
return _this._rowRangeHeightsMap.get("$0$" + (_this.rowCount - 1)) && (defaultRowHeight = _this._rowRangeHeightsMap.get("$0$" + (_this.rowCount - 1)) / _this.rowCount),
|
|
160
|
+
Math.min(Math.ceil(absoluteY / defaultRowHeight), _this.rowCount - 1);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function computeTargetColByX(absoluteX, _this) {
|
|
164
|
+
if (_this._colRangeWidthsMap.get("$0$" + (_this.colCount - 1))) {
|
|
165
|
+
let startCol = 0, endCol = _this.colCount - 1;
|
|
166
|
+
for (;endCol - startCol > 1; ) {
|
|
167
|
+
const midCol = Math.floor((startCol + endCol) / 2);
|
|
168
|
+
if (absoluteX < _this._colRangeWidthsMap.get(`$0$${midCol}`)) endCol = midCol; else {
|
|
169
|
+
if (!(absoluteX > _this._colRangeWidthsMap.get(`$0$${midCol}`))) return midCol;
|
|
170
|
+
startCol = midCol;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return endCol;
|
|
174
|
+
}
|
|
175
|
+
return Math.min(Math.ceil(absoluteX / _this.internalProps.defaultColWidth), _this.colCount - 1);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function getCellAtRelativePosition(x, y, _this) {
|
|
179
|
+
x -= _this.tableX;
|
|
180
|
+
let bottomFrozen = !1;
|
|
181
|
+
(y -= _this.tableY) > _this.tableNoFrameHeight - _this.getBottomFrozenRowsHeight() && y < _this.tableNoFrameHeight && (bottomFrozen = !0);
|
|
182
|
+
let rightFrozen = !1;
|
|
183
|
+
x > _this.tableNoFrameWidth - _this.getRightFrozenColsWidth() && x < _this.tableNoFrameWidth && (rightFrozen = !0);
|
|
184
|
+
const colInfo = getTargetColAtConsiderRightFrozen(rightFrozen ? x : x + _this.scrollLeft, rightFrozen, _this), rowInfo = getTargetRowAtConsiderBottomFrozen(bottomFrozen ? y : y + _this.scrollTop, bottomFrozen, _this);
|
|
185
|
+
if (!colInfo || !rowInfo) return;
|
|
186
|
+
const {row: row, top: top, bottom: bottom, height: height} = rowInfo, {col: col, left: left, right: right, width: width} = colInfo;
|
|
187
|
+
return {
|
|
188
|
+
row: row,
|
|
189
|
+
col: col,
|
|
190
|
+
rect: {
|
|
191
|
+
left: left,
|
|
192
|
+
right: right,
|
|
193
|
+
top: top,
|
|
194
|
+
bottom: bottom,
|
|
195
|
+
width: width,
|
|
196
|
+
height: height
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
exports.getRowAt = getRowAt, exports.getColAt = getColAt, exports.getCellAt = getCellAt,
|
|
202
|
+
exports.getTargetColAt = getTargetColAt, exports.getTargetRowAt = getTargetRowAt,
|
|
203
|
+
exports.getTargetColAtConsiderRightFrozen = getTargetColAtConsiderRightFrozen, exports.getTargetRowAtConsiderBottomFrozen = getTargetRowAtConsiderBottomFrozen,
|
|
204
|
+
exports.computeTargetRowByY = computeTargetRowByY, exports.computeTargetColByX = computeTargetColByX,
|
|
205
|
+
exports.getCellAtRelativePosition = getCellAtRelativePosition;
|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;QACH,GAAG;QACH,IAAI;KACL,CAAC;AACJ,CAAC;AApCD,8DAoCC","file":"get-cell-position.js","sourcesContent":["import type { CellAddressWithBound } from '../../ts-types';\nimport type { BaseTableAPI } from '../../ts-types/base-table';\nimport { _getTargetFrozenColAt, _getTargetFrozenRowAt } from '../tableHelper';\n\n/**\n * 根据y值计算所在行\n * @param absoluteY\n * @returns\n */\nexport function getRowAt(\n absoluteY: number,\n _this: BaseTableAPI\n): { top: number; row: number; bottom: number; height: number } {\n const frozen = _getTargetFrozenRowAt(_this, absoluteY);\n if (frozen) {\n return frozen;\n }\n let row = getTargetRowAt(absoluteY, _this);\n if (!row) {\n row = {\n top: -1,\n row: -1,\n bottom: -1,\n height: -1\n };\n }\n return row;\n}\n/**\n * 根据x值计算所在列\n * @param absoluteX\n * @returns\n */\nexport function getColAt(\n absoluteX: number,\n _this: BaseTableAPI\n): { left: number; col: number; right: number; width: number } {\n const frozen = _getTargetFrozenColAt(_this, absoluteX);\n if (frozen) {\n return frozen;\n }\n let col = getTargetColAt(absoluteX, _this);\n if (!col) {\n col = {\n left: -1,\n col: -1,\n right: -1,\n width: 1\n };\n }\n return col;\n}\n/**\n * 根据坐标值获取行列位置,index和rect范围\n * @param absoluteX\n * @param absoluteY\n * @returns\n */\nexport function getCellAt(absoluteX: number, absoluteY: number, _this: BaseTableAPI): CellAddressWithBound {\n const rowInfo = getRowAt(absoluteY, _this);\n const { row, top, bottom, height } = rowInfo;\n const colInfo = getColAt(absoluteX, _this);\n const { col, left, right, width } = colInfo;\n const rect = {\n left,\n right,\n top,\n bottom,\n width,\n height\n };\n return {\n row,\n col,\n rect\n };\n}\n\n/**\n * 根据x获取该位置所处列值\n * @param table\n * @param absoluteX\n * @returns\n */\nexport function getTargetColAt(\n absoluteX: number,\n _this: BaseTableAPI\n): { col: number; left: number; right: number; width: number } | null {\n if (absoluteX === 0) {\n return { left: 0, col: 0, right: 0, width: 0 };\n }\n const findBefore = (\n startCol: number,\n startRight: number\n ): {\n left: number;\n col: number;\n right: number;\n width: number;\n } | null => {\n let right = startRight;\n for (let col = startCol; col >= 0; col--) {\n const width = _this.getColWidth(col);\n const left = right - width;\n if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) {\n return {\n left,\n col,\n right,\n width\n };\n }\n right = left;\n }\n return null;\n };\n const findAfter = (\n startCol: number,\n startRight: number\n ): {\n left: number;\n col: number;\n right: number;\n width: number;\n } | null => {\n let left = startRight - _this.getColWidth(startCol);\n const { colCount } = _this.internalProps;\n for (let col = startCol; col < colCount; col++) {\n const width = _this.getColWidth(col);\n const right = left + width;\n if (Math.round(left) <= Math.round(absoluteX) && Math.round(absoluteX) < Math.round(right)) {\n return {\n left,\n col,\n right,\n width\n };\n }\n left = right;\n }\n return null;\n };\n //计算这个位置处是第几行\n const candCol = computeTargetColByX(absoluteX, _this);\n const right = _this.getColsWidth(0, candCol);\n if (absoluteX >= right) {\n return findAfter(candCol, right);\n }\n return findBefore(candCol, right);\n}\n/**\n * 根据y获取该位置所处行值\n * @param table\n * @param absoluteX\n * @returns\n */\nexport function getTargetRowAt(\n absoluteY: number,\n _this: BaseTableAPI\n): { row: number; top: number; bottom: number; height: number } | null {\n if (absoluteY === 0) {\n return { top: 0, row: 0, bottom: 0, height: 0 };\n }\n\n const findBefore = (\n startRow: number,\n startBottom: number\n ): {\n top: number;\n row: number;\n bottom: number;\n height: number;\n } | null => {\n let bottom = startBottom;\n for (let row = startRow; row >= 0; row--) {\n const height = _this.getRowHeight(row);\n const top = bottom - height;\n if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) {\n return {\n top,\n row,\n bottom,\n height\n };\n }\n bottom = top;\n }\n return null;\n };\n const findAfter = (\n startRow: number,\n startBottom: number\n ): {\n top: number;\n row: number;\n bottom: number;\n height: number;\n } | null => {\n let top = startBottom - _this.getRowHeight(startRow);\n const { rowCount } = _this.internalProps;\n for (let row = startRow; row < rowCount; row++) {\n const height = _this.getRowHeight(row);\n const bottom = top + height;\n if (Math.round(top) <= Math.round(absoluteY) && Math.round(absoluteY) < Math.round(bottom)) {\n return {\n top,\n row,\n bottom,\n height\n };\n }\n top = bottom;\n }\n return null;\n };\n // const candRow = Math.min(\n // Math.ceil(absoluteY / this.internalProps.defaultRowHeight),\n // this.rowCount - 1\n // );\n //计算这个位置处是第几行\n const candRow = computeTargetRowByY(absoluteY, _this);\n const bottom = _this.getRowsHeight(0, candRow);\n if (absoluteY >= bottom) {\n return findAfter(candRow, bottom);\n }\n return findBefore(candRow, bottom);\n}\n\n/**\n * 根据x获取该位置所处列值\n * @param table\n * @param absoluteX\n * @returns\n */\nexport function getTargetColAtConsiderRightFrozen(\n absoluteX: number,\n isConsider: boolean,\n _this: BaseTableAPI\n): { col: number; left: number; right: number; width: number } | null {\n if (absoluteX === 0) {\n return { left: 0, col: 0, right: 0, width: 0 };\n }\n if (\n isConsider &&\n absoluteX > _this.tableNoFrameWidth - _this.getRightFrozenColsWidth() &&\n absoluteX < _this.tableNoFrameWidth\n ) {\n for (let i = 0; i < _this.rightFrozenColCount; i++) {\n if (absoluteX > _this.tableNoFrameWidth - _this.getColsWidth(_this.colCount - i - 1, _this.colCount - 1)) {\n return {\n col: _this.colCount - i - 1,\n left: undefined,\n right: undefined,\n width: undefined\n };\n }\n }\n }\n return getTargetColAt(absoluteX, _this);\n}\n\n/**\n * 根据y获取该位置所处行值\n * @param table\n * @param absoluteX\n * @returns\n */\nexport function getTargetRowAtConsiderBottomFrozen(\n absoluteY: number,\n isConsider: boolean,\n _this: BaseTableAPI\n): { row: number; top: number; bottom: number; height: number } | null {\n if (absoluteY === 0) {\n return { top: 0, row: 0, bottom: 0, height: 0 };\n }\n if (\n isConsider &&\n absoluteY > _this.tableNoFrameHeight - _this.getBottomFrozenRowsHeight() &&\n absoluteY < _this.tableNoFrameHeight\n ) {\n for (let i = 0; i < _this.rightFrozenColCount; i++) {\n if (absoluteY > _this.tableNoFrameHeight - _this.getRowsHeight(_this.rowCount - i - 1, _this.rowCount - 1)) {\n return {\n row: _this.rowCount - i - 1,\n top: undefined,\n bottom: undefined,\n height: undefined\n };\n }\n }\n }\n return getTargetRowAt(absoluteY, _this);\n}\n\n/**\n * 根据y值(包括了scroll的)计算所在行\n * @param this\n * @param absoluteY 左边y值,包含了scroll滚动距离\n * @returns\n */\nexport function computeTargetRowByY(absoluteY: number, _this: BaseTableAPI): number {\n let defaultRowHeight = _this.internalProps.defaultRowHeight;\n\n //使用二分法计算出row\n if (_this._rowRangeHeightsMap.get(`$0$${_this.rowCount - 1}`)) {\n defaultRowHeight = _this._rowRangeHeightsMap.get(`$0$${_this.rowCount - 1}`) / _this.rowCount;\n // let startRow = 0;\n // let endRow = this.rowCount - 1;\n // while (endRow - startRow > 1) {\n // const midRow = Math.floor((startRow + endRow) / 2);\n // if (absoluteY < this._rowRangeHeightsMap.get(`$0$${midRow}`)) {\n // endRow = midRow;\n // } else if (absoluteY > this._rowRangeHeightsMap.get(`$0$${midRow}`)) {\n // startRow = midRow;\n // } else {\n // return midRow;\n // }\n // }\n // return endRow;\n }\n //否则使用defaultRowHeight大约计算一个row\n return Math.min(Math.ceil(absoluteY / defaultRowHeight), _this.rowCount - 1);\n}\n/**\n * 根据x值(包括了scroll的)计算所在列 主要借助colRangeWidthsMap缓存来提高计算效率\n * @param this\n * @param absoluteX 左边x值,包含了scroll滚动距离\n * @returns\n */\nexport function computeTargetColByX(absoluteX: number, _this: BaseTableAPI): number {\n //使用二分法计算出col\n if (_this._colRangeWidthsMap.get(`$0$${_this.colCount - 1}`)) {\n let startCol = 0;\n let endCol = _this.colCount - 1;\n while (endCol - startCol > 1) {\n const midCol = Math.floor((startCol + endCol) / 2);\n if (absoluteX < _this._colRangeWidthsMap.get(`$0$${midCol}`)) {\n endCol = midCol;\n } else if (absoluteX > _this._colRangeWidthsMap.get(`$0$${midCol}`)) {\n startCol = midCol;\n } else {\n return midCol;\n }\n }\n return endCol;\n }\n //否则使用defaultColWidth大约计算一个col\n return Math.min(Math.ceil(absoluteX / _this.internalProps.defaultColWidth), _this.colCount - 1);\n}\n\n// 获取屏幕坐标对应的单元格信息,考虑滚动\nexport function getCellAtRelativePosition(x: number, y: number, _this: BaseTableAPI): CellAddressWithBound {\n // table border and outer component\n x -= _this.tableX;\n y -= _this.tableY;\n\n // bottom frozen\n let bottomFrozen = false;\n if (y > _this.tableNoFrameHeight - _this.getBottomFrozenRowsHeight() && y < _this.tableNoFrameHeight) {\n bottomFrozen = true;\n }\n // right frozen\n let rightFrozen = false;\n if (x > _this.tableNoFrameWidth - _this.getRightFrozenColsWidth() && x < _this.tableNoFrameWidth) {\n rightFrozen = true;\n }\n\n const colInfo = getTargetColAtConsiderRightFrozen(rightFrozen ? x : x + _this.scrollLeft, rightFrozen, _this);\n const rowInfo = getTargetRowAtConsiderBottomFrozen(bottomFrozen ? y : y + _this.scrollTop, bottomFrozen, _this);\n if (!colInfo || !rowInfo) {\n return undefined;\n }\n const { row, top, bottom, height } = rowInfo;\n const { col, left, right, width } = colInfo;\n const rect = {\n left,\n right,\n top,\n bottom,\n width,\n height\n };\n return {\n row,\n col,\n rect\n };\n}\n"]}
|
package/cjs/dataset/dataset.d.ts
CHANGED
|
@@ -41,9 +41,7 @@ export declare class Dataset {
|
|
|
41
41
|
collectedValues: Record<string, Record<string, CollectedValue>>;
|
|
42
42
|
cacheCollectedValues: Record<string, Record<string, CollectedValue>>;
|
|
43
43
|
rows: string[];
|
|
44
|
-
rowsHasValue: boolean[];
|
|
45
44
|
columns: string[];
|
|
46
|
-
columnsHasValue: boolean[];
|
|
47
45
|
indicatorKeys: string[];
|
|
48
46
|
customRowTree?: IHeaderTreeDefine[];
|
|
49
47
|
customColTree?: IHeaderTreeDefine[];
|
package/cjs/dataset/dataset.js
CHANGED
|
@@ -43,8 +43,7 @@ class Dataset {
|
|
|
43
43
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
44
44
|
if (this.records = records, this.collectedValues = {}, this.cacheCollectedValues = {},
|
|
45
45
|
this.totalRecordsTree = {}, this.tree = {}, this.colFlatKeys = {}, this.rowFlatKeys = {},
|
|
46
|
-
this.colKeys = [], this.rowKeys = [],
|
|
47
|
-
records) {
|
|
46
|
+
this.colKeys = [], this.rowKeys = [], records) {
|
|
48
47
|
this.records = records;
|
|
49
48
|
"undefined" != typeof window && window.performance.now();
|
|
50
49
|
this.processRecords(), this.processCollectedValuesWithSumBy(), this.generateCollectedValuesSortRule(),
|
|
@@ -54,8 +53,8 @@ class Dataset {
|
|
|
54
53
|
"undefined" != typeof window && window.performance.now(), "undefined" != typeof window && window.performance.now();
|
|
55
54
|
this.sortKeys();
|
|
56
55
|
"undefined" != typeof window && window.performance.now(), "undefined" != typeof window && window.performance.now();
|
|
57
|
-
this.customRowTree ? this.rowHeaderTree = this.customRowTree : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows
|
|
58
|
-
this.customColTree ? this.colHeaderTree = this.customColTree : this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns
|
|
56
|
+
this.customRowTree ? this.rowHeaderTree = this.customRowTree : "tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_g = null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotalsOnTop) && void 0 !== _g && _g, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k),
|
|
57
|
+
this.customColTree ? this.colHeaderTree = this.customColTree : this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns, this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t);
|
|
59
58
|
"undefined" != typeof window && window.performance.now();
|
|
60
59
|
(null === (_u = this.dataConfig) || void 0 === _u ? void 0 : _u.isPivotChart) && this.cacheDeminsionCollectedValues();
|
|
61
60
|
}
|
|
@@ -162,7 +161,7 @@ class Dataset {
|
|
|
162
161
|
let isToTalRecord = !1;
|
|
163
162
|
for (let l = 0, len1 = this.rows.length; l < len1; l++) {
|
|
164
163
|
const rowAttr = this.rows[l];
|
|
165
|
-
if (rowAttr in record)
|
|
164
|
+
if (rowAttr in record) rowKey.push(record[rowAttr]); else if (rowAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
|
|
166
165
|
if ((null === (_d = null === (_c = null === (_b = this.dataConfig) || void 0 === _b ? void 0 : _b.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) && 0 === l && !this.rows.find((rk => rk in record))) {
|
|
167
166
|
rowKey.push(this.rowGrandTotalLabel), isToTalRecord = !0;
|
|
168
167
|
break;
|
|
@@ -175,7 +174,7 @@ class Dataset {
|
|
|
175
174
|
}
|
|
176
175
|
for (let n = 0, len2 = this.columns.length; n < len2; n++) {
|
|
177
176
|
const colAttr = this.columns[n];
|
|
178
|
-
if (colAttr in record)
|
|
177
|
+
if (colAttr in record) colKey.push(record[colAttr]); else if (colAttr !== global_1.IndicatorDimensionKeyPlaceholder) {
|
|
179
178
|
if ((null === (_o = null === (_m = null === (_l = this.dataConfig) || void 0 === _l ? void 0 : _l.totals) || void 0 === _m ? void 0 : _m.column) || void 0 === _o ? void 0 : _o.showGrandTotals) && 0 === n && !this.columns.find((ck => ck in record))) {
|
|
180
179
|
colKey.push(this.colGrandTotalLabel), isToTalRecord = !0;
|
|
181
180
|
break;
|
|
@@ -225,8 +224,8 @@ class Dataset {
|
|
|
225
224
|
}
|
|
226
225
|
updateSortRules(sortRules) {
|
|
227
226
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
228
|
-
this.sorted = !1, this.sortRules = sortRules, this.sortKeys(), this.customRowTree || ("tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows
|
|
229
|
-
this.customColTree || (this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns
|
|
227
|
+
this.sorted = !1, this.sortRules = sortRules, this.sortKeys(), this.customRowTree || ("tree" === this.rowHierarchyType ? this.rowHeaderTree = this.ArrToTree1(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, (null === (_b = null === (_a = this.totals) || void 0 === _a ? void 0 : _a.row) || void 0 === _b ? void 0 : _b.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel) : this.rowHeaderTree = this.ArrToTree(this.rowKeys, this.rows, this.indicatorsAsCol ? void 0 : this.indicators, this.rowsIsTotal, (null === (_d = null === (_c = this.totals) || void 0 === _c ? void 0 : _c.row) || void 0 === _d ? void 0 : _d.showGrandTotals) || this.indicatorsAsCol && 0 === this.rows.length, this.rowGrandTotalLabel, this.rowSubTotalLabel, null !== (_g = null === (_f = null === (_e = this.totals) || void 0 === _e ? void 0 : _e.row) || void 0 === _f ? void 0 : _f.showGrandTotalsOnTop) && void 0 !== _g && _g, null !== (_k = null === (_j = null === (_h = this.totals) || void 0 === _h ? void 0 : _h.row) || void 0 === _j ? void 0 : _j.showSubTotalsOnTop) && void 0 !== _k && _k)),
|
|
228
|
+
this.customColTree || (this.colHeaderTree = this.ArrToTree(this.colKeys, this.columns, this.indicatorsAsCol ? this.indicators : void 0, this.colsIsTotal, (null === (_m = null === (_l = this.totals) || void 0 === _l ? void 0 : _l.column) || void 0 === _m ? void 0 : _m.showGrandTotals) || !this.indicatorsAsCol && 0 === this.columns.length, this.colGrandTotalLabel, this.colSubTotalLabel, null !== (_q = null === (_p = null === (_o = this.totals) || void 0 === _o ? void 0 : _o.column) || void 0 === _p ? void 0 : _p.showGrandTotalsOnLeft) && void 0 !== _q && _q, null !== (_t = null === (_s = null === (_r = this.totals) || void 0 === _r ? void 0 : _r.column) || void 0 === _s ? void 0 : _s.showSubTotalsOnLeft) && void 0 !== _t && _t));
|
|
230
229
|
}
|
|
231
230
|
updateFilterRules(filterRules, isResetTree = !1) {
|
|
232
231
|
var _a;
|