@oscarpalmer/tabela 0.5.0 → 0.7.0
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/dist/components/body.component.js +2 -2
- package/dist/components/column.component.js +2 -3
- package/dist/components/footer.component.js +1 -2
- package/dist/components/header.component.js +1 -2
- package/dist/components/row.component.js +11 -7
- package/dist/managers/column.manager.js +23 -9
- package/dist/managers/data.manager.js +98 -21
- package/dist/managers/row.manager.js +13 -3
- package/dist/managers/virtualization.manager.js +57 -42
- package/dist/models/body.model.js +0 -0
- package/dist/models/data.model.js +0 -0
- package/dist/models/footer.model.js +0 -0
- package/dist/models/header.model.js +0 -0
- package/dist/models/tabela.model.js +0 -0
- package/dist/models/virtualization.model.js +0 -0
- package/dist/tabela.full.js +370 -457
- package/dist/tabela.js +37 -21
- package/package.json +9 -9
- package/src/components/body.component.ts +5 -8
- package/src/components/column.component.ts +2 -6
- package/src/components/footer.component.ts +3 -9
- package/src/components/header.component.ts +3 -8
- package/src/components/row.component.ts +18 -9
- package/src/managers/column.manager.ts +43 -13
- package/src/managers/data.manager.ts +163 -43
- package/src/managers/row.manager.ts +19 -3
- package/src/managers/virtualization.manager.ts +92 -69
- package/src/models/body.model.ts +4 -0
- package/src/models/data.model.ts +16 -0
- package/src/models/footer.model.ts +5 -0
- package/src/models/header.model.ts +4 -0
- package/src/models/tabela.model.ts +31 -0
- package/src/models/virtualization.model.ts +14 -0
- package/src/tabela.ts +48 -38
- package/types/components/body.component.d.ts +3 -9
- package/types/components/column.component.d.ts +1 -3
- package/types/components/footer.component.d.ts +3 -10
- package/types/components/header.component.d.ts +3 -9
- package/types/components/row.component.d.ts +5 -4
- package/types/managers/column.manager.d.ts +7 -4
- package/types/managers/data.manager.d.ts +16 -21
- package/types/managers/row.manager.d.ts +6 -3
- package/types/managers/virtualization.manager.d.ts +11 -8
- package/types/models/body.model.d.ts +4 -0
- package/types/models/data.model.d.ts +14 -0
- package/types/models/footer.model.d.ts +5 -0
- package/types/models/header.model.d.ts +4 -0
- package/types/models/tabela.model.d.ts +28 -0
- package/types/models/virtualization.model.d.ts +12 -0
- package/types/tabela.d.ts +4 -21
|
@@ -1,52 +1,43 @@
|
|
|
1
1
|
import {on} from '@oscarpalmer/toretto/event';
|
|
2
2
|
import type {RemovableEventListener} from '@oscarpalmer/toretto/models';
|
|
3
3
|
import {removeRow, renderRow, RowComponent} from '../components/row.component';
|
|
4
|
-
import type {
|
|
4
|
+
import type {TabelaComponents, TabelaManagers} from '../models/tabela.model';
|
|
5
|
+
import type {
|
|
6
|
+
VirtualizationPool,
|
|
7
|
+
VirtualizationRange,
|
|
8
|
+
VirtualizationState,
|
|
9
|
+
} from '../models/virtualization.model';
|
|
5
10
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
11
|
+
function getRange(this: VirtualizationManager, down: boolean): VirtualizationRange {
|
|
12
|
+
const {components, managers} = this;
|
|
13
|
+
const {clientHeight, scrollTop} = components.body.elements.group;
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
cells: Record<string, HTMLDivElement[]>;
|
|
13
|
-
rows: HTMLDivElement[];
|
|
14
|
-
};
|
|
15
|
+
const first = Math.floor(scrollTop / managers.row.height);
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const last = Math.min(
|
|
18
|
+
managers.data.values.keys.active?.length ?? managers.data.values.keys.original.length - 1,
|
|
19
|
+
Math.ceil((scrollTop + clientHeight) / managers.row.height) - 1,
|
|
20
|
+
);
|
|
20
21
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
top: number;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function getRange(tabela: Tabela, down: boolean): Range {
|
|
27
|
-
const {components, managers} = tabela;
|
|
28
|
-
const {body} = components;
|
|
29
|
-
const {data, rows} = managers;
|
|
30
|
-
const {clientHeight, scrollTop} = body.elements.group;
|
|
31
|
-
|
|
32
|
-
const first = Math.floor(scrollTop / rows.height);
|
|
33
|
-
const last = Math.min(data.length - 1, Math.ceil((scrollTop + clientHeight) / rows.height) - 1);
|
|
34
|
-
|
|
35
|
-
const before = Math.ceil(clientHeight / rows.height) * (down ? 1 : 2);
|
|
36
|
-
const after = Math.ceil(clientHeight / rows.height) * (down ? 2 : 1);
|
|
22
|
+
const before = Math.ceil(clientHeight / managers.row.height) * (down ? 1 : 2);
|
|
23
|
+
const after = Math.ceil(clientHeight / managers.row.height) * (down ? 2 : 1);
|
|
37
24
|
|
|
38
25
|
const start = Math.max(0, first - before);
|
|
39
|
-
|
|
26
|
+
|
|
27
|
+
const end = Math.min(
|
|
28
|
+
managers.data.values.keys.active?.length ?? managers.data.values.keys.original.length - 1,
|
|
29
|
+
last + after,
|
|
30
|
+
);
|
|
40
31
|
|
|
41
32
|
return {end, start};
|
|
42
33
|
}
|
|
43
34
|
|
|
44
|
-
function onScroll(this:
|
|
35
|
+
function onScroll(this: VirtualizationManager): void {
|
|
45
36
|
if (!this.state.active) {
|
|
46
37
|
requestAnimationFrame(() => {
|
|
47
|
-
const top = this.
|
|
38
|
+
const top = this.components.body.elements.group.scrollTop;
|
|
48
39
|
|
|
49
|
-
this.
|
|
40
|
+
this.update(top > this.state.top);
|
|
50
41
|
|
|
51
42
|
this.state.active = false;
|
|
52
43
|
this.state.top = top;
|
|
@@ -61,90 +52,122 @@ export class VirtualizationManager {
|
|
|
61
52
|
|
|
62
53
|
listener: RemovableEventListener;
|
|
63
54
|
|
|
64
|
-
readonly
|
|
55
|
+
readonly pool: VirtualizationPool = {
|
|
65
56
|
cells: {},
|
|
66
57
|
rows: [],
|
|
67
58
|
};
|
|
68
59
|
|
|
69
|
-
readonly
|
|
60
|
+
readonly state: VirtualizationState = {
|
|
70
61
|
active: false,
|
|
71
62
|
top: 0,
|
|
72
63
|
};
|
|
73
64
|
|
|
74
|
-
readonly
|
|
75
|
-
|
|
76
|
-
constructor(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
manager: this,
|
|
82
|
-
state: this.#state,
|
|
83
|
-
}),
|
|
84
|
-
);
|
|
65
|
+
readonly visible = new Map<number, RowComponent>();
|
|
66
|
+
|
|
67
|
+
constructor(
|
|
68
|
+
public managers: TabelaManagers,
|
|
69
|
+
public components: TabelaComponents,
|
|
70
|
+
) {
|
|
71
|
+
this.listener = on(components.body.elements.group, 'scroll', onScroll.bind(this));
|
|
85
72
|
}
|
|
86
73
|
|
|
87
74
|
destroy(): void {
|
|
88
75
|
this.listener();
|
|
89
76
|
|
|
90
|
-
for (const [index, row] of this
|
|
91
|
-
removeRow(
|
|
77
|
+
for (const [index, row] of this.visible) {
|
|
78
|
+
removeRow(this.pool, row);
|
|
79
|
+
|
|
80
|
+
this.visible.delete(index);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
this.pool.cells = {};
|
|
84
|
+
this.pool.rows = [];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
removeCells(fields: string[]): void {
|
|
88
|
+
const {length} = fields;
|
|
89
|
+
|
|
90
|
+
for (let index = 0; index < length; index += 1) {
|
|
91
|
+
delete this.pool.cells[fields[index]];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const [, row] of this.visible) {
|
|
95
|
+
for (let index = 0; index < length; index += 1) {
|
|
96
|
+
row.cells[fields[index]].innerHTML = '';
|
|
97
|
+
|
|
98
|
+
row.cells[fields[index]].remove();
|
|
92
99
|
|
|
93
|
-
|
|
100
|
+
delete row.cells[fields[index]];
|
|
101
|
+
}
|
|
94
102
|
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
getFragment(): DocumentFragment {
|
|
106
|
+
this.fragment ??= document.createDocumentFragment();
|
|
95
107
|
|
|
96
|
-
this
|
|
97
|
-
|
|
108
|
+
this.fragment.replaceChildren();
|
|
109
|
+
|
|
110
|
+
return this.fragment;
|
|
98
111
|
}
|
|
99
112
|
|
|
100
113
|
update(down: boolean): void {
|
|
101
|
-
const {
|
|
102
|
-
|
|
114
|
+
const {components, managers, pool, visible} = this;
|
|
115
|
+
|
|
116
|
+
components.body.elements.faker.style.height = `${managers.data.size * managers.row.height}px`;
|
|
103
117
|
|
|
104
118
|
const indices = new Set<number>();
|
|
105
|
-
const range = getRange(
|
|
119
|
+
const range = getRange.call(this, down);
|
|
106
120
|
|
|
107
121
|
for (let index = range.start; index <= range.end; index += 1) {
|
|
108
122
|
indices.add(index);
|
|
109
123
|
}
|
|
110
124
|
|
|
111
|
-
|
|
112
|
-
if (!indices.has(index)) {
|
|
113
|
-
this.#visible.delete(index);
|
|
125
|
+
let remove = false;
|
|
114
126
|
|
|
115
|
-
|
|
127
|
+
for (const [index, row] of visible) {
|
|
128
|
+
if (!managers.row.has(row.key) || !indices.has(index)) {
|
|
129
|
+
remove = true;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (remove) {
|
|
133
|
+
visible.delete(index);
|
|
134
|
+
|
|
135
|
+
removeRow(pool, row);
|
|
116
136
|
}
|
|
117
137
|
}
|
|
118
138
|
|
|
119
|
-
|
|
139
|
+
const fragment = this.getFragment();
|
|
120
140
|
|
|
121
|
-
|
|
141
|
+
const keys = managers.data.values.keys.active ?? managers.data.values.keys.original;
|
|
122
142
|
|
|
123
|
-
|
|
124
|
-
tabela.managers.data.values.keys.active ?? tabela.managers.data.values.keys.original;
|
|
143
|
+
let count = 0;
|
|
125
144
|
|
|
126
145
|
for (let index = range.start; index <= range.end; index += 1) {
|
|
127
|
-
if (
|
|
146
|
+
if (visible.has(index)) {
|
|
128
147
|
continue;
|
|
129
148
|
}
|
|
130
149
|
|
|
131
|
-
const row =
|
|
150
|
+
const row = managers.row.get(keys[index]);
|
|
132
151
|
|
|
133
152
|
if (row == null) {
|
|
134
153
|
continue;
|
|
135
154
|
}
|
|
136
155
|
|
|
137
|
-
|
|
156
|
+
count += 1;
|
|
157
|
+
|
|
158
|
+
renderRow(managers, row);
|
|
138
159
|
|
|
139
|
-
|
|
160
|
+
visible.set(index, row);
|
|
140
161
|
|
|
141
162
|
if (row.element != null) {
|
|
142
|
-
row.element.style.transform = `translateY(${index *
|
|
163
|
+
row.element.style.transform = `translateY(${index * managers.row.height}px)`;
|
|
143
164
|
|
|
144
|
-
|
|
165
|
+
fragment.append(row.element);
|
|
145
166
|
}
|
|
146
167
|
}
|
|
147
168
|
|
|
148
|
-
|
|
169
|
+
if (count > 0) {
|
|
170
|
+
components.body.elements.group[down ? 'append' : 'prepend'](fragment);
|
|
171
|
+
}
|
|
149
172
|
}
|
|
150
173
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type {Key, PlainObject} from '@oscarpalmer/atoms/models';
|
|
2
|
+
|
|
3
|
+
export type DataValues = {
|
|
4
|
+
keys: DataValuesKeys;
|
|
5
|
+
objects: DataValuesObjects;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
type DataValuesKeys = {
|
|
9
|
+
active?: Key[];
|
|
10
|
+
original: Key[];
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type DataValuesObjects = {
|
|
14
|
+
array: PlainObject[];
|
|
15
|
+
mapped: Map<Key, PlainObject>;
|
|
16
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type {Key, PlainObject} from '@oscarpalmer/atoms/models';
|
|
2
|
+
import type {BodyComponent} from '../components/body.component';
|
|
3
|
+
import type {FooterComponent} from '../components/footer.component';
|
|
4
|
+
import type {HeaderComponent} from '../components/header.component';
|
|
5
|
+
import type {ColumnManager} from '../managers/column.manager';
|
|
6
|
+
import type {DataManager} from '../managers/data.manager';
|
|
7
|
+
import type {RowManager} from '../managers/row.manager';
|
|
8
|
+
import type {VirtualizationManager} from '../managers/virtualization.manager';
|
|
9
|
+
|
|
10
|
+
export type TabelaComponents = {
|
|
11
|
+
body: BodyComponent;
|
|
12
|
+
footer: FooterComponent;
|
|
13
|
+
header: HeaderComponent;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type TabelaData = {
|
|
17
|
+
add(data: PlainObject[]): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
get(active?: boolean): PlainObject[];
|
|
20
|
+
remove(keys: Key[]): void;
|
|
21
|
+
remove(data: PlainObject[]): void;
|
|
22
|
+
synchronize(data: PlainObject[], remove?: boolean): void;
|
|
23
|
+
update(data: PlainObject[]): void;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export type TabelaManagers = {
|
|
27
|
+
column: ColumnManager;
|
|
28
|
+
data: DataManager;
|
|
29
|
+
row: RowManager;
|
|
30
|
+
virtualization: VirtualizationManager;
|
|
31
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type VirtualizationPool = {
|
|
2
|
+
cells: Record<string, HTMLDivElement[]>;
|
|
3
|
+
rows: HTMLDivElement[];
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
export type VirtualizationRange = {
|
|
7
|
+
end: number;
|
|
8
|
+
start: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type VirtualizationState = {
|
|
12
|
+
active: boolean;
|
|
13
|
+
top: number;
|
|
14
|
+
};
|
package/src/tabela.ts
CHANGED
|
@@ -4,29 +4,37 @@ import {HeaderComponent} from './components/header.component';
|
|
|
4
4
|
import {ColumnManager} from './managers/column.manager';
|
|
5
5
|
import {DataManager} from './managers/data.manager';
|
|
6
6
|
import {RowManager} from './managers/row.manager';
|
|
7
|
+
import {VirtualizationManager} from './managers/virtualization.manager';
|
|
8
|
+
import type {TabelaComponents, TabelaData, TabelaManagers} from './models/tabela.model';
|
|
7
9
|
import type {TabelaOptions} from './models/tabela.options';
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
export class Tabela {
|
|
12
|
+
readonly #components: TabelaComponents = {
|
|
13
|
+
header: undefined as never,
|
|
14
|
+
body: undefined as never,
|
|
15
|
+
footer: undefined as never,
|
|
16
|
+
};
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
#element: HTMLElement;
|
|
19
|
+
|
|
20
|
+
readonly #key: string;
|
|
21
|
+
|
|
22
|
+
readonly #managers: TabelaManagers = {
|
|
23
|
+
column: undefined as never,
|
|
24
|
+
data: undefined as never,
|
|
25
|
+
row: undefined as never,
|
|
26
|
+
virtualization: undefined as never,
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
readonly data: TabelaData;
|
|
30
|
+
|
|
31
|
+
get key(): string {
|
|
32
|
+
return this.#key;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
constructor(element: HTMLElement, options: TabelaOptions) {
|
|
36
|
+
this.#element = element;
|
|
20
37
|
|
|
21
|
-
export class Tabela {
|
|
22
|
-
readonly components: Components;
|
|
23
|
-
readonly key: string;
|
|
24
|
-
readonly managers: Managers;
|
|
25
|
-
|
|
26
|
-
constructor(
|
|
27
|
-
public element: HTMLElement,
|
|
28
|
-
options: TabelaOptions,
|
|
29
|
-
) {
|
|
30
38
|
element.innerHTML = '';
|
|
31
39
|
element.role = 'table';
|
|
32
40
|
|
|
@@ -34,39 +42,41 @@ export class Tabela {
|
|
|
34
42
|
|
|
35
43
|
element.setAttribute('aria-label', options.label);
|
|
36
44
|
|
|
37
|
-
this
|
|
45
|
+
this.#key = options.key;
|
|
38
46
|
|
|
39
|
-
this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
footer: new FooterComponent(this),
|
|
43
|
-
};
|
|
47
|
+
this.#components.header = new HeaderComponent();
|
|
48
|
+
this.#components.body = new BodyComponent();
|
|
49
|
+
this.#components.footer = new FooterComponent();
|
|
44
50
|
|
|
45
|
-
this.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
51
|
+
this.#managers.column = new ColumnManager(this.#managers, this.#components, options.columns);
|
|
52
|
+
this.#managers.data = new DataManager(this.#managers, this.#components, options.key);
|
|
53
|
+
this.#managers.row = new RowManager(this.#managers, options.rowHeight);
|
|
54
|
+
this.#managers.virtualization = new VirtualizationManager(this.#managers, this.#components);
|
|
50
55
|
|
|
51
56
|
element.append(
|
|
52
|
-
this
|
|
53
|
-
this
|
|
54
|
-
this
|
|
57
|
+
this.#components.header.elements.group,
|
|
58
|
+
this.#components.body.elements.group,
|
|
59
|
+
this.#components.footer.elements.group,
|
|
55
60
|
);
|
|
56
61
|
|
|
57
|
-
this
|
|
62
|
+
this.#managers.data.set(options.data);
|
|
63
|
+
|
|
64
|
+
this.data = this.#managers.data.handlers;
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
destroy(): void {
|
|
61
|
-
const
|
|
68
|
+
const components = this.#components;
|
|
69
|
+
const managers = this.#managers;
|
|
70
|
+
const element = this.#element;
|
|
62
71
|
|
|
63
72
|
components.body.destroy();
|
|
64
73
|
components.footer.destroy();
|
|
65
74
|
components.header.destroy();
|
|
66
75
|
|
|
67
|
-
managers.
|
|
76
|
+
managers.column.destroy();
|
|
68
77
|
managers.data.destroy();
|
|
69
|
-
managers.
|
|
78
|
+
managers.row.destroy();
|
|
79
|
+
managers.virtualization.destroy();
|
|
70
80
|
|
|
71
81
|
element.innerHTML = '';
|
|
72
82
|
element.role = '';
|
|
@@ -75,6 +85,6 @@ export class Tabela {
|
|
|
75
85
|
element.removeAttribute('aria-label');
|
|
76
86
|
element.removeAttribute('role');
|
|
77
87
|
|
|
78
|
-
this
|
|
88
|
+
this.#element = undefined as never;
|
|
79
89
|
}
|
|
80
90
|
}
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
type Elements = {
|
|
3
|
-
faker: HTMLDivElement;
|
|
4
|
-
group: HTMLDivElement;
|
|
5
|
-
};
|
|
1
|
+
import type { BodyElements } from '../models/body.model';
|
|
6
2
|
export declare class BodyComponent {
|
|
7
|
-
readonly
|
|
8
|
-
|
|
9
|
-
constructor(tabela: Tabela);
|
|
3
|
+
readonly elements: BodyElements;
|
|
4
|
+
constructor();
|
|
10
5
|
destroy(): void;
|
|
11
6
|
}
|
|
12
|
-
export {};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { TabelaColumn, TabelaColumnOptions } from '../models/column.model';
|
|
2
|
-
import type { Tabela } from '../tabela';
|
|
3
2
|
export declare class ColumnComponent {
|
|
4
|
-
readonly tabela: Tabela;
|
|
5
3
|
readonly element: HTMLDivElement;
|
|
6
4
|
readonly options: TabelaColumn;
|
|
7
|
-
constructor(
|
|
5
|
+
constructor(options: TabelaColumnOptions);
|
|
8
6
|
}
|
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FooterElements } from '../models/footer.model';
|
|
2
2
|
import type { ColumnComponent } from './column.component';
|
|
3
|
-
type Elements = {
|
|
4
|
-
cells: HTMLDivElement[];
|
|
5
|
-
group: HTMLDivElement;
|
|
6
|
-
row: HTMLDivElement;
|
|
7
|
-
};
|
|
8
3
|
export declare class FooterComponent {
|
|
9
|
-
readonly
|
|
10
|
-
|
|
11
|
-
constructor(tabela: Tabela);
|
|
4
|
+
readonly elements: FooterElements;
|
|
5
|
+
constructor();
|
|
12
6
|
destroy(): void;
|
|
13
7
|
update(columns: ColumnComponent[]): void;
|
|
14
8
|
}
|
|
15
|
-
export {};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HeaderElements } from '../models/header.model';
|
|
2
2
|
import type { ColumnComponent } from './column.component';
|
|
3
|
-
type Elements = {
|
|
4
|
-
group: HTMLDivElement;
|
|
5
|
-
row: HTMLDivElement;
|
|
6
|
-
};
|
|
7
3
|
export declare class HeaderComponent {
|
|
8
|
-
readonly
|
|
9
|
-
|
|
10
|
-
constructor(tabela: Tabela);
|
|
4
|
+
readonly elements: HeaderElements;
|
|
5
|
+
constructor();
|
|
11
6
|
destroy(): void;
|
|
12
7
|
update(columns: ColumnComponent[]): void;
|
|
13
8
|
}
|
|
14
|
-
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Key } from '@oscarpalmer/atoms/models';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
export declare function removeRow(
|
|
5
|
-
export declare function renderRow(
|
|
2
|
+
import type { TabelaManagers } from '../models/tabela.model';
|
|
3
|
+
import type { VirtualizationPool } from '../models/virtualization.model';
|
|
4
|
+
export declare function removeRow(pool: VirtualizationPool, row: RowComponent): void;
|
|
5
|
+
export declare function renderRow(managers: TabelaManagers, row: RowComponent): void;
|
|
6
6
|
export declare class RowComponent {
|
|
7
7
|
readonly key: Key;
|
|
8
|
+
cells: Record<string, HTMLDivElement>;
|
|
8
9
|
element: HTMLDivElement | undefined;
|
|
9
10
|
constructor(key: Key);
|
|
10
11
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { ColumnComponent } from '../components/column.component';
|
|
2
2
|
import type { TabelaColumnOptions } from '../models/column.model';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TabelaComponents, TabelaManagers } from '../models/tabela.model';
|
|
4
4
|
export declare class ColumnManager {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
managers: TabelaManagers;
|
|
6
|
+
components: TabelaComponents;
|
|
7
|
+
readonly items: ColumnComponent[];
|
|
8
|
+
constructor(managers: TabelaManagers, components: TabelaComponents, columns: TabelaColumnOptions[]);
|
|
8
9
|
destroy(): void;
|
|
10
|
+
remove(field: string): void;
|
|
11
|
+
remove(fields: string[]): void;
|
|
9
12
|
set(columns: TabelaColumnOptions[]): void;
|
|
10
13
|
}
|
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
import type { Key, PlainObject } from '@oscarpalmer/atoms/models';
|
|
2
|
-
import type {
|
|
3
|
-
import {
|
|
4
|
-
type Keys = {
|
|
5
|
-
active?: Key[];
|
|
6
|
-
original: Key[];
|
|
7
|
-
};
|
|
8
|
-
type Objects = {
|
|
9
|
-
array: PlainObject[];
|
|
10
|
-
mapped: Map<Key, PlainObject>;
|
|
11
|
-
};
|
|
12
|
-
type Values = {
|
|
13
|
-
keys: Keys;
|
|
14
|
-
objects: Objects;
|
|
15
|
-
};
|
|
2
|
+
import type { DataValues } from '../models/data.model';
|
|
3
|
+
import type { TabelaComponents, TabelaData, TabelaManagers } from '../models/tabela.model';
|
|
16
4
|
export declare class DataManager {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
managers: TabelaManagers;
|
|
6
|
+
components: TabelaComponents;
|
|
7
|
+
field: string;
|
|
8
|
+
readonly handlers: TabelaData;
|
|
9
|
+
readonly values: DataValues;
|
|
10
|
+
get size(): number;
|
|
11
|
+
constructor(managers: TabelaManagers, components: TabelaComponents, field: string);
|
|
12
|
+
add(data: PlainObject[], render: boolean): Promise<void>;
|
|
13
|
+
clear(): void;
|
|
22
14
|
destroy(): void;
|
|
23
|
-
|
|
15
|
+
get(active?: boolean): PlainObject[];
|
|
16
|
+
remove(items: Array<Key | PlainObject>, render: boolean): Promise<void>;
|
|
17
|
+
set(data: PlainObject[]): void;
|
|
18
|
+
synchronize(data: PlainObject[], remove?: boolean): Promise<void>;
|
|
19
|
+
update(data: PlainObject[]): Promise<void>;
|
|
24
20
|
}
|
|
25
|
-
export {};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import type { Key } from '@oscarpalmer/atoms/models';
|
|
2
2
|
import { RowComponent } from '../components/row.component';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TabelaManagers } from '../models/tabela.model';
|
|
4
4
|
export declare class RowManager {
|
|
5
|
-
readonly
|
|
5
|
+
readonly managers: TabelaManagers;
|
|
6
6
|
readonly components: Map<Key, RowComponent>;
|
|
7
7
|
readonly height: number;
|
|
8
|
-
constructor(
|
|
8
|
+
constructor(managers: TabelaManagers, rowHeight: number);
|
|
9
9
|
destroy(): void;
|
|
10
10
|
get(key: Key): RowComponent | undefined;
|
|
11
|
+
has(key: Key): boolean;
|
|
12
|
+
remove(key: Key): void;
|
|
13
|
+
update(key: Key): void;
|
|
11
14
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import type { RemovableEventListener } from '@oscarpalmer/toretto/models';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
rows: HTMLDivElement[];
|
|
6
|
-
};
|
|
2
|
+
import { RowComponent } from '../components/row.component';
|
|
3
|
+
import type { TabelaComponents, TabelaManagers } from '../models/tabela.model';
|
|
4
|
+
import type { VirtualizationPool, VirtualizationState } from '../models/virtualization.model';
|
|
7
5
|
export declare class VirtualizationManager {
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
managers: TabelaManagers;
|
|
7
|
+
components: TabelaComponents;
|
|
10
8
|
fragment: DocumentFragment;
|
|
11
9
|
listener: RemovableEventListener;
|
|
12
|
-
|
|
10
|
+
readonly pool: VirtualizationPool;
|
|
11
|
+
readonly state: VirtualizationState;
|
|
12
|
+
readonly visible: Map<number, RowComponent>;
|
|
13
|
+
constructor(managers: TabelaManagers, components: TabelaComponents);
|
|
13
14
|
destroy(): void;
|
|
15
|
+
removeCells(fields: string[]): void;
|
|
16
|
+
getFragment(): DocumentFragment;
|
|
14
17
|
update(down: boolean): void;
|
|
15
18
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Key, PlainObject } from '@oscarpalmer/atoms/models';
|
|
2
|
+
export type DataValues = {
|
|
3
|
+
keys: DataValuesKeys;
|
|
4
|
+
objects: DataValuesObjects;
|
|
5
|
+
};
|
|
6
|
+
type DataValuesKeys = {
|
|
7
|
+
active?: Key[];
|
|
8
|
+
original: Key[];
|
|
9
|
+
};
|
|
10
|
+
type DataValuesObjects = {
|
|
11
|
+
array: PlainObject[];
|
|
12
|
+
mapped: Map<Key, PlainObject>;
|
|
13
|
+
};
|
|
14
|
+
export {};
|