@itrocks/table 0.0.13 → 0.0.14
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/column-reorder.d.ts +1 -1
- package/edit/lock.d.ts +1 -1
- package/edit/move.d.ts +2 -2
- package/edit-freeze/hide.d.ts +2 -2
- package/edit-freeze/scroll.d.ts +1 -1
- package/edit.d.ts +2 -2
- package/freeze/inherit-border.d.ts +1 -1
- package/freeze.d.ts +1 -1
- package/package.json +2 -3
- package/table.d.ts +1 -1
- package/fix.d.ts +0 -27
- package/fix.js +0 -191
package/column-reorder.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from '../../plugin/plugin.js';
|
|
2
2
|
import { HTMLTableFreezeElement } from './freeze.js';
|
|
3
3
|
import { Table } from './table.js';
|
|
4
4
|
export declare class TableColumnReorder extends Plugin<Table> {
|
package/edit/lock.d.ts
CHANGED
package/edit/move.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTMLEditableElement } from '
|
|
2
|
-
import { Plugin } from '
|
|
1
|
+
import { HTMLEditableElement } from '../../../contenteditable/contenteditable.js';
|
|
2
|
+
import { Plugin } from '../../../plugin/plugin.js';
|
|
3
3
|
import { TableEdit } from '../edit.js';
|
|
4
4
|
import { Table } from '../table.js';
|
|
5
5
|
export declare class TableEditMove extends Plugin<Table> {
|
package/edit-freeze/hide.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTMLEditableElement } from '
|
|
2
|
-
import { Plugin } from '
|
|
1
|
+
import { HTMLEditableElement } from '../../../contenteditable/contenteditable.js';
|
|
2
|
+
import { Plugin } from '../../../plugin/plugin.js';
|
|
3
3
|
import { TableEdit } from '../edit.js';
|
|
4
4
|
import { TableFreeze } from '../freeze.js';
|
|
5
5
|
import { Table } from '../table.js';
|
package/edit-freeze/scroll.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from '../../../plugin/plugin.js';
|
|
2
2
|
import { TableFreeze } from '../freeze.js';
|
|
3
3
|
import { Table } from '../table.js';
|
|
4
4
|
export declare class TableEditFreezeScroll extends Plugin<Table> {
|
package/edit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTMLEditableElement } from '
|
|
2
|
-
import { Plugin } from '
|
|
1
|
+
import { HTMLEditableElement } from '../../contenteditable/contenteditable.js';
|
|
2
|
+
import { Plugin } from '../../plugin/plugin.js';
|
|
3
3
|
import { Table } from './table.js';
|
|
4
4
|
export declare class RangeCopy {
|
|
5
5
|
commonAncestorContainer: Node;
|
package/freeze.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -45,10 +45,9 @@
|
|
|
45
45
|
"url": "git+https://github.com/itrocks-ts/table.git"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
|
-
"build": "tsc && sass --no-source-map demo:demo"
|
|
49
|
-
"prepare": "prepare-module"
|
|
48
|
+
"build": "tsc && sass --no-source-map demo:demo && ../prepare-module/prepare-module.js"
|
|
50
49
|
},
|
|
51
50
|
"type": "module",
|
|
52
51
|
"types": "./table.d.ts",
|
|
53
|
-
"version": "0.0.
|
|
52
|
+
"version": "0.0.14"
|
|
54
53
|
}
|
package/table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HasPlugins, Options as PluginOptions } from '
|
|
1
|
+
import { HasPlugins, Options as PluginOptions } from '../../plugin/plugin.js';
|
|
2
2
|
export declare function applyStyleSheets(): void;
|
|
3
3
|
export declare function garbageCollector(): void;
|
|
4
4
|
export declare function getTables(): Table[];
|
package/fix.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import Plugin from '../node_modules/@itrocks/plugin/plugin.js';
|
|
2
|
-
import { HTMLTableFixElement, Table } from './table.js';
|
|
3
|
-
interface FullIndex {
|
|
4
|
-
column: string;
|
|
5
|
-
corner: string;
|
|
6
|
-
row: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class FixTable extends Plugin<Table> {
|
|
9
|
-
columns: NodeListOf<HTMLTableFixElement>;
|
|
10
|
-
full?: FullIndex;
|
|
11
|
-
leftColumnCount: number;
|
|
12
|
-
rightColumnCount: number;
|
|
13
|
-
zIndex: string;
|
|
14
|
-
constructor(table: Table);
|
|
15
|
-
init(): void;
|
|
16
|
-
closestScrollable(element: Element): HTMLElement | (Window & typeof globalThis) | undefined;
|
|
17
|
-
protected countLeftColumns(): number;
|
|
18
|
-
protected countRightColumns(): number;
|
|
19
|
-
protected fixFootRows(): void;
|
|
20
|
-
protected fixHeadRows(): void;
|
|
21
|
-
protected fixLeftColumns(): void;
|
|
22
|
-
protected fixRightColumns(): void;
|
|
23
|
-
protected getColumns(): NodeListOf<HTMLTableFixElement>;
|
|
24
|
-
position(position: number, _counter: number, _colCell: HTMLTableFixElement, _side: 'bottom' | 'left' | 'right' | 'top'): string;
|
|
25
|
-
visibleInnerRect(): DOMRect;
|
|
26
|
-
}
|
|
27
|
-
export default FixTable;
|
package/fix.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import Plugin from '../plugin/plugin.js';
|
|
2
|
-
export class FixTable extends Plugin {
|
|
3
|
-
columns;
|
|
4
|
-
full;
|
|
5
|
-
leftColumnCount;
|
|
6
|
-
rightColumnCount;
|
|
7
|
-
zIndex = '1';
|
|
8
|
-
constructor(table) {
|
|
9
|
-
super(table);
|
|
10
|
-
this.columns = this.getColumns();
|
|
11
|
-
this.leftColumnCount = this.countLeftColumns();
|
|
12
|
-
this.rightColumnCount = this.countRightColumns();
|
|
13
|
-
}
|
|
14
|
-
init() {
|
|
15
|
-
this.fixFootRows();
|
|
16
|
-
this.fixHeadRows();
|
|
17
|
-
this.fixLeftColumns();
|
|
18
|
-
this.fixRightColumns();
|
|
19
|
-
}
|
|
20
|
-
closestScrollable(element) {
|
|
21
|
-
let parent = element.closest('table')?.parentElement;
|
|
22
|
-
while (parent && (parent.scrollHeight <= parent.clientHeight)) {
|
|
23
|
-
parent = parent.parentElement;
|
|
24
|
-
}
|
|
25
|
-
return parent ? ((parent instanceof HTMLHtmlElement) ? window : parent) : undefined;
|
|
26
|
-
}
|
|
27
|
-
countLeftColumns() {
|
|
28
|
-
let count = 0;
|
|
29
|
-
while ((count < this.columns.length - 1) && (this.columns[count].dataset.fix !== undefined)) {
|
|
30
|
-
count++;
|
|
31
|
-
}
|
|
32
|
-
return count;
|
|
33
|
-
}
|
|
34
|
-
countRightColumns() {
|
|
35
|
-
let count = this.columns.length - 1;
|
|
36
|
-
while ((count > 0) && (this.columns[count].dataset.fix !== undefined)) {
|
|
37
|
-
count--;
|
|
38
|
-
}
|
|
39
|
-
return this.columns.length - 1 - count;
|
|
40
|
-
}
|
|
41
|
-
fixFootRows() {
|
|
42
|
-
const table = this.of;
|
|
43
|
-
if (!table.element.tFoot?.rows.length)
|
|
44
|
-
return;
|
|
45
|
-
let counter = 1, bottom = .0, previousBottom = table.element.getBoundingClientRect().bottom;
|
|
46
|
-
for (const row of Array.from(table.element.tFoot.querySelectorAll(':scope > tr')).reverse()) {
|
|
47
|
-
const actualBottom = row.getBoundingClientRect().bottom;
|
|
48
|
-
bottom += previousBottom - actualBottom;
|
|
49
|
-
previousBottom = actualBottom;
|
|
50
|
-
table.styleSheet.push(`
|
|
51
|
-
${table.selector} > tfoot > tr:nth-last-child(${counter}) > * {
|
|
52
|
-
bottom: ${this.position(bottom, counter, row.firstElementChild, 'bottom')};
|
|
53
|
-
}
|
|
54
|
-
`);
|
|
55
|
-
counter++;
|
|
56
|
-
}
|
|
57
|
-
const zIndex = this.full ? `z-index: ${this.full.row};` : '';
|
|
58
|
-
table.styleSheet.push(`
|
|
59
|
-
${table.selector} > tfoot > tr > * {
|
|
60
|
-
position: sticky;
|
|
61
|
-
${zIndex}
|
|
62
|
-
}
|
|
63
|
-
`);
|
|
64
|
-
}
|
|
65
|
-
fixHeadRows() {
|
|
66
|
-
const table = this.of;
|
|
67
|
-
if (!table.element.tHead?.rows.length)
|
|
68
|
-
return;
|
|
69
|
-
let counter = 1, top = .0, previousTop = table.element.getBoundingClientRect().top;
|
|
70
|
-
table.element.tHead.querySelectorAll(':scope > tr').forEach(row => {
|
|
71
|
-
const actualTop = row.getBoundingClientRect().top;
|
|
72
|
-
top += actualTop - previousTop;
|
|
73
|
-
previousTop = actualTop;
|
|
74
|
-
table.styleSheet.push(`
|
|
75
|
-
${table.selector} > thead > tr:nth-child(${counter}) > * {
|
|
76
|
-
top: ${this.position(top, counter, row.firstElementChild, 'top')};
|
|
77
|
-
}
|
|
78
|
-
`);
|
|
79
|
-
counter++;
|
|
80
|
-
});
|
|
81
|
-
const zIndex = this.full ? `z-index: ${this.full.row};` : '';
|
|
82
|
-
table.styleSheet.push(`
|
|
83
|
-
${table.selector} > thead > tr > * {
|
|
84
|
-
position: sticky;
|
|
85
|
-
${zIndex}
|
|
86
|
-
}
|
|
87
|
-
`);
|
|
88
|
-
}
|
|
89
|
-
fixLeftColumns() {
|
|
90
|
-
if (!this.leftColumnCount)
|
|
91
|
-
return;
|
|
92
|
-
const table = this.of;
|
|
93
|
-
const bodySel = [];
|
|
94
|
-
const cornerSel = [];
|
|
95
|
-
let counter = 1, left = .0, previousLeft = table.element.getBoundingClientRect().left;
|
|
96
|
-
for (const colCell of Array.from(this.columns).toSpliced(this.leftColumnCount)) {
|
|
97
|
-
const actualLeft = colCell.getBoundingClientRect().left;
|
|
98
|
-
left += actualLeft - previousLeft;
|
|
99
|
-
previousLeft = actualLeft;
|
|
100
|
-
table.styleSheet.push(`
|
|
101
|
-
${table.selector} > * > tr > :nth-child(${counter}) {
|
|
102
|
-
left: ${this.position(left, counter, colCell, 'left')};
|
|
103
|
-
}
|
|
104
|
-
`);
|
|
105
|
-
bodySel.push(`${table.selector} > tbody > tr > :nth-child(${counter})`);
|
|
106
|
-
cornerSel.push(`${table.selector} > tfoot > tr > :nth-child(${counter})`);
|
|
107
|
-
cornerSel.push(`${table.selector} > thead > tr > :nth-child(${counter})`);
|
|
108
|
-
counter++;
|
|
109
|
-
}
|
|
110
|
-
const zIndex = this.full ? `z-index: ${this.full.column};` : '';
|
|
111
|
-
const zIndexValue = this.full ? this.full.corner : this.zIndex;
|
|
112
|
-
table.styleSheet.push(`
|
|
113
|
-
${bodySel.join(', ')} {
|
|
114
|
-
position: sticky;
|
|
115
|
-
${zIndex}
|
|
116
|
-
}
|
|
117
|
-
${cornerSel.join(', ')} {
|
|
118
|
-
z-index: ${zIndexValue};
|
|
119
|
-
}
|
|
120
|
-
`);
|
|
121
|
-
}
|
|
122
|
-
fixRightColumns() {
|
|
123
|
-
if (!this.rightColumnCount)
|
|
124
|
-
return;
|
|
125
|
-
const table = this.of;
|
|
126
|
-
const bodySel = [];
|
|
127
|
-
const cornerSel = [];
|
|
128
|
-
let counter = 1, right = .0, previousRight = table.element.getBoundingClientRect().right;
|
|
129
|
-
for (const colCell of Array.from(this.columns).reverse().toSpliced(this.rightColumnCount)) {
|
|
130
|
-
const actualRight = colCell.getBoundingClientRect().right;
|
|
131
|
-
right += previousRight - actualRight;
|
|
132
|
-
previousRight = actualRight;
|
|
133
|
-
table.styleSheet.push(`
|
|
134
|
-
${table.selector} > * > tr > :nth-last-child(${counter}) {
|
|
135
|
-
right: ${this.position(right, counter, colCell, 'right')};
|
|
136
|
-
}
|
|
137
|
-
`);
|
|
138
|
-
bodySel.push(`${table.selector} > tbody > tr > :nth-last-child(${counter})`);
|
|
139
|
-
if (this.full) {
|
|
140
|
-
cornerSel.push(`${table.selector} > tfoot > tr > :nth-last-child(${counter})`);
|
|
141
|
-
}
|
|
142
|
-
cornerSel.push(`${table.selector} > thead > tr > :nth-last-child(${counter})`);
|
|
143
|
-
counter++;
|
|
144
|
-
}
|
|
145
|
-
const zIndex = this.full ? `z-index: ${this.full.column};` : '';
|
|
146
|
-
const zIndexValue = this.full ? this.full.corner : this.zIndex;
|
|
147
|
-
table.styleSheet.push(`
|
|
148
|
-
${bodySel.join(', ')} {
|
|
149
|
-
position: sticky;
|
|
150
|
-
${zIndex}
|
|
151
|
-
}
|
|
152
|
-
${cornerSel.join(', ')} {
|
|
153
|
-
z-index: ${zIndexValue};
|
|
154
|
-
}
|
|
155
|
-
`);
|
|
156
|
-
}
|
|
157
|
-
getColumns() {
|
|
158
|
-
if (this.columns)
|
|
159
|
-
return this.columns;
|
|
160
|
-
const table = this.of;
|
|
161
|
-
let columns = table.element.querySelectorAll(':scope > colgroup > col');
|
|
162
|
-
if (!columns.length) {
|
|
163
|
-
columns = table.element.querySelectorAll(':scope > thead > tr:first-child > *');
|
|
164
|
-
if (!columns.length) {
|
|
165
|
-
columns = table.element.querySelectorAll(':scope > tbody > tr:first-child > *');
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return columns;
|
|
169
|
-
}
|
|
170
|
-
position(position, _counter, _colCell, _side) {
|
|
171
|
-
return `${position}px`;
|
|
172
|
-
}
|
|
173
|
-
visibleInnerRect() {
|
|
174
|
-
const tableElement = this.of.element;
|
|
175
|
-
const rect = tableElement.getBoundingClientRect();
|
|
176
|
-
if (this.leftColumnCount) {
|
|
177
|
-
rect.x = this.columns[this.leftColumnCount - 1].getBoundingClientRect().right;
|
|
178
|
-
}
|
|
179
|
-
if (tableElement.tHead?.lastElementChild?.firstElementChild) {
|
|
180
|
-
rect.y = tableElement.tHead.lastElementChild.firstElementChild.getBoundingClientRect().bottom;
|
|
181
|
-
}
|
|
182
|
-
if (this.rightColumnCount) {
|
|
183
|
-
rect.width = this.columns[this.columns.length - this.rightColumnCount].getBoundingClientRect().left - rect.x + 1;
|
|
184
|
-
}
|
|
185
|
-
if (tableElement.tFoot?.firstElementChild?.firstElementChild) {
|
|
186
|
-
rect.height = tableElement.tFoot.firstElementChild.firstElementChild.getBoundingClientRect().top - rect.y + 1;
|
|
187
|
-
}
|
|
188
|
-
return rect;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
export default FixTable;
|