@oscarpalmer/tabela 0.8.0 → 0.10.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 -15
- package/dist/components/footer.component.js +3 -3
- package/dist/components/header.component.js +2 -2
- package/dist/components/row.component.js +13 -4
- package/dist/helpers/dom.helpers.js +5 -10
- package/dist/helpers/misc.helpers.js +7 -0
- package/dist/helpers/style.helper.js +6 -0
- package/dist/managers/column.manager.js +7 -2
- package/dist/managers/data.manager.js +6 -4
- package/dist/managers/event.manager.js +6 -2
- package/dist/managers/filter.manager.js +92 -0
- package/dist/managers/{virtualization.manager.js → render.manager.js} +28 -22
- package/dist/managers/row.manager.js +9 -2
- package/dist/managers/selection.manager.js +191 -0
- package/dist/managers/sort.manager.js +17 -6
- package/dist/models/render.model.js +0 -0
- package/dist/tabela.full.js +1253 -105
- package/dist/tabela.js +19 -6
- package/package.json +1 -1
- package/src/components/body.component.ts +4 -21
- package/src/components/footer.component.ts +3 -3
- package/src/components/header.component.ts +2 -2
- package/src/components/row.component.ts +22 -7
- package/src/helpers/dom.helpers.ts +3 -10
- package/src/helpers/misc.helpers.ts +15 -0
- package/src/helpers/style.helper.ts +6 -0
- package/src/managers/column.manager.ts +9 -1
- package/src/managers/data.manager.ts +9 -5
- package/src/managers/event.manager.ts +10 -3
- package/src/managers/filter.manager.ts +154 -0
- package/src/managers/{virtualization.manager.ts → render.manager.ts} +36 -31
- package/src/managers/row.manager.ts +16 -2
- package/src/managers/selection.manager.ts +338 -0
- package/src/managers/sort.manager.ts +35 -16
- package/src/models/filter.model.ts +17 -0
- package/src/models/{virtualization.model.ts → render.model.ts} +3 -3
- package/src/models/sort.model.ts +1 -1
- package/src/models/tabela.model.ts +22 -2
- package/src/tabela.ts +28 -6
- package/types/components/row.component.d.ts +2 -2
- package/types/helpers/dom.helpers.d.ts +1 -1
- package/types/helpers/misc.helpers.d.ts +2 -0
- package/types/helpers/style.helper.d.ts +1 -0
- package/types/managers/data.manager.d.ts +1 -1
- package/types/managers/event.manager.d.ts +1 -1
- package/types/managers/filter.manager.d.ts +19 -0
- package/types/managers/{virtualization.manager.d.ts → render.manager.d.ts} +6 -6
- package/types/managers/selection.manager.d.ts +19 -0
- package/types/managers/sort.manager.d.ts +5 -2
- package/types/models/filter.model.d.ts +6 -0
- package/types/models/{virtualization.model.d.ts → render.model.d.ts} +3 -3
- package/types/models/sort.model.d.ts +1 -1
- package/types/models/tabela.model.d.ts +20 -2
- package/types/tabela.d.ts +3 -1
- /package/dist/models/{virtualization.model.js → filter.model.js} +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FilterItem } from '../models/filter.model';
|
|
2
|
+
import type { TabelaManagers } from '../models/tabela.model';
|
|
3
|
+
export declare class FilterManager {
|
|
4
|
+
readonly managers: TabelaManagers;
|
|
5
|
+
handlers: Readonly<{
|
|
6
|
+
add: (item: FilterItem) => void;
|
|
7
|
+
clear: () => void;
|
|
8
|
+
remove: (value: string | FilterItem) => void;
|
|
9
|
+
set: (items: FilterItem[]) => void;
|
|
10
|
+
}>;
|
|
11
|
+
items: Record<string, FilterItem[]>;
|
|
12
|
+
constructor(managers: TabelaManagers);
|
|
13
|
+
add(item: FilterItem): void;
|
|
14
|
+
clear(): void;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
filter(): void;
|
|
17
|
+
remove(value: string | FilterItem): void;
|
|
18
|
+
set(items: FilterItem[]): void;
|
|
19
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import type { Key } from '@oscarpalmer/atoms/models';
|
|
1
2
|
import type { RemovableEventListener } from '@oscarpalmer/toretto/models';
|
|
2
|
-
import {
|
|
3
|
+
import type { RenderElementPool, RenderState } from '../models/render.model';
|
|
3
4
|
import type { TabelaComponents, TabelaManagers } from '../models/tabela.model';
|
|
4
|
-
|
|
5
|
-
export declare class VirtualizationManager {
|
|
5
|
+
export declare class RenderManager {
|
|
6
6
|
managers: TabelaManagers;
|
|
7
7
|
components: TabelaComponents;
|
|
8
8
|
fragment: DocumentFragment;
|
|
9
9
|
listener: RemovableEventListener;
|
|
10
|
-
readonly pool:
|
|
11
|
-
readonly state:
|
|
12
|
-
|
|
10
|
+
readonly pool: RenderElementPool;
|
|
11
|
+
readonly state: RenderState;
|
|
12
|
+
visible: Map<number, Key>;
|
|
13
13
|
constructor(managers: TabelaManagers, components: TabelaComponents);
|
|
14
14
|
destroy(): void;
|
|
15
15
|
removeCells(fields: string[]): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Key } from '@oscarpalmer/atoms/models';
|
|
2
|
+
import type { TabelaManagers, TabelaSelection } from '../models/tabela.model';
|
|
3
|
+
export declare class SelectionManager {
|
|
4
|
+
element: HTMLElement;
|
|
5
|
+
readonly managers: TabelaManagers;
|
|
6
|
+
handlers: Readonly<TabelaSelection>;
|
|
7
|
+
items: Set<Key>;
|
|
8
|
+
last: Key | undefined;
|
|
9
|
+
constructor(element: HTMLElement, managers: TabelaManagers);
|
|
10
|
+
clear(): void;
|
|
11
|
+
deselect(keys: Key[]): void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
handle(event: MouseEvent, target: HTMLElement): void;
|
|
14
|
+
range(from: Key | HTMLElement, to: Key | HTMLElement): void;
|
|
15
|
+
select(keys: Key[]): void;
|
|
16
|
+
set(keys: Key[]): void;
|
|
17
|
+
toggle(): void;
|
|
18
|
+
update(removed: Key[]): void;
|
|
19
|
+
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
import { type ArrayKeySorter } from '@oscarpalmer/atoms/array';
|
|
2
|
+
import type { PlainObject } from '@oscarpalmer/atoms/models';
|
|
1
3
|
import type { SortDirection, SortItem } from '../models/sort.model';
|
|
2
4
|
import type { TabelaManagers } from '../models/tabela.model';
|
|
3
5
|
export declare class SortManager {
|
|
4
6
|
readonly managers: TabelaManagers;
|
|
5
|
-
|
|
7
|
+
handlers: Readonly<{
|
|
6
8
|
add: (field: string, direction: SortDirection | undefined) => void;
|
|
7
9
|
flip: (field: string) => void;
|
|
8
10
|
clear: () => void;
|
|
9
11
|
remove: (field: string) => void;
|
|
10
12
|
set: (items: SortItem[]) => void;
|
|
11
13
|
}>;
|
|
12
|
-
readonly items:
|
|
14
|
+
readonly items: ArrayKeySorter<PlainObject>[];
|
|
13
15
|
constructor(managers: TabelaManagers);
|
|
14
16
|
add(field: string, direction?: SortDirection): void;
|
|
15
17
|
addOrSet(event: MouseEvent, field: string): void;
|
|
16
18
|
clear(): void;
|
|
19
|
+
destroy(): void;
|
|
17
20
|
flip(field: string): void;
|
|
18
21
|
remove(field: string): void;
|
|
19
22
|
removeOrClear(event: MouseEvent, field: string): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type FilterComparison = 'contains' | 'ends-with' | 'equals' | 'greater-than' | 'greater-than-or-equal' | 'less-than' | 'less-than-or-equal' | 'not-contains' | 'not-equals' | 'starts-with';
|
|
2
|
+
export type FilterItem = {
|
|
3
|
+
comparison: FilterComparison;
|
|
4
|
+
field: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type RenderElementPool = {
|
|
2
2
|
cells: Record<string, HTMLDivElement[]>;
|
|
3
3
|
rows: HTMLDivElement[];
|
|
4
4
|
};
|
|
5
|
-
export type
|
|
5
|
+
export type RenderRange = {
|
|
6
6
|
end: number;
|
|
7
7
|
start: number;
|
|
8
8
|
};
|
|
9
|
-
export type
|
|
9
|
+
export type RenderState = {
|
|
10
10
|
active: boolean;
|
|
11
11
|
top: number;
|
|
12
12
|
};
|
|
@@ -5,9 +5,12 @@ import type { HeaderComponent } from '../components/header.component';
|
|
|
5
5
|
import type { ColumnManager } from '../managers/column.manager';
|
|
6
6
|
import type { DataManager } from '../managers/data.manager';
|
|
7
7
|
import type { EventManager } from '../managers/event.manager';
|
|
8
|
+
import type { FilterManager } from '../managers/filter.manager';
|
|
9
|
+
import type { RenderManager } from '../managers/render.manager';
|
|
8
10
|
import type { RowManager } from '../managers/row.manager';
|
|
11
|
+
import type { SelectionManager } from '../managers/selection.manager';
|
|
9
12
|
import type { SortManager } from '../managers/sort.manager';
|
|
10
|
-
import type {
|
|
13
|
+
import type { FilterItem } from './filter.model';
|
|
11
14
|
import type { SortDirection, SortItem } from './sort.model';
|
|
12
15
|
export type TabelaComponents = {
|
|
13
16
|
body: BodyComponent;
|
|
@@ -23,13 +26,28 @@ export type TabelaData = {
|
|
|
23
26
|
synchronize(data: PlainObject[], remove?: boolean): void;
|
|
24
27
|
update(data: PlainObject[]): void;
|
|
25
28
|
};
|
|
29
|
+
export type TabelaFilter = {
|
|
30
|
+
add(item: FilterItem): void;
|
|
31
|
+
clear(): void;
|
|
32
|
+
remove(field: string): void;
|
|
33
|
+
remove(item: FilterItem): void;
|
|
34
|
+
set(items: FilterItem[]): void;
|
|
35
|
+
};
|
|
26
36
|
export type TabelaManagers = {
|
|
27
37
|
column: ColumnManager;
|
|
28
38
|
data: DataManager;
|
|
29
39
|
event: EventManager;
|
|
40
|
+
filter: FilterManager;
|
|
30
41
|
row: RowManager;
|
|
42
|
+
selection: SelectionManager;
|
|
31
43
|
sort: SortManager;
|
|
32
|
-
|
|
44
|
+
render: RenderManager;
|
|
45
|
+
};
|
|
46
|
+
export type TabelaSelection = {
|
|
47
|
+
clear(): void;
|
|
48
|
+
deselect(keys: Key[]): void;
|
|
49
|
+
select(keys: Key[]): void;
|
|
50
|
+
toggle(): void;
|
|
33
51
|
};
|
|
34
52
|
export type TabelaSort = {
|
|
35
53
|
add(field: string, direction?: SortDirection): void;
|
package/types/tabela.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { TabelaData, TabelaSort } from './models/tabela.model';
|
|
1
|
+
import type { TabelaData, TabelaFilter, TabelaSelection, TabelaSort } from './models/tabela.model';
|
|
2
2
|
import type { TabelaOptions } from './models/tabela.options';
|
|
3
3
|
export declare class Tabela {
|
|
4
4
|
#private;
|
|
5
5
|
readonly data: TabelaData;
|
|
6
|
+
readonly filter: TabelaFilter;
|
|
7
|
+
readonly selection: TabelaSelection;
|
|
6
8
|
readonly sort: TabelaSort;
|
|
7
9
|
get key(): string;
|
|
8
10
|
constructor(element: HTMLElement, options: TabelaOptions);
|
|
File without changes
|