@oscarpalmer/tabela 0.13.0 → 0.15.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.d.mts +10 -1
- package/dist/components/body.component.mjs +8 -6
- package/dist/components/column.component.d.mts +15 -1
- package/dist/components/column.component.mjs +12 -10
- package/dist/components/footer.component.d.mts +12 -1
- package/dist/components/footer.component.mjs +6 -6
- package/dist/components/group.component.d.mts +19 -1
- package/dist/components/group.component.mjs +17 -11
- package/dist/components/header.component.d.mts +12 -1
- package/dist/components/header.component.mjs +5 -5
- package/dist/components/row.component.d.mts +14 -1
- package/dist/components/row.component.mjs +21 -17
- package/dist/helpers/dom.helpers.d.mts +3 -3
- package/dist/helpers/dom.helpers.mjs +12 -11
- package/dist/helpers/misc.helpers.d.mts +7 -1
- package/dist/helpers/misc.helpers.mjs +12 -1
- package/dist/index.d.mts +1 -1
- package/dist/managers/column.manager.d.mts +16 -1
- package/dist/managers/column.manager.mjs +7 -7
- package/dist/managers/data.manager.d.mts +26 -1
- package/dist/managers/data.manager.mjs +122 -88
- package/dist/managers/event.manager.d.mts +17 -1
- package/dist/managers/event.manager.mjs +35 -10
- package/dist/managers/filter.manager.d.mts +17 -1
- package/dist/managers/filter.manager.mjs +43 -35
- package/dist/managers/group.manager.d.mts +26 -1
- package/dist/managers/group.manager.mjs +36 -16
- package/dist/managers/navigation.manager.d.mts +15 -2
- package/dist/managers/navigation.manager.mjs +38 -34
- package/dist/managers/render.manager.d.mts +18 -1
- package/dist/managers/render.manager.mjs +44 -31
- package/dist/managers/row.manager.d.mts +18 -1
- package/dist/managers/row.manager.mjs +1 -1
- package/dist/managers/selection.manager.d.mts +22 -1
- package/dist/managers/selection.manager.mjs +26 -23
- package/dist/managers/sort.manager.d.mts +22 -1
- package/dist/managers/sort.manager.mjs +71 -49
- package/dist/managers/style.manager.d.mts +8 -1
- package/dist/managers/style.manager.mjs +57 -25
- package/dist/models/body.model.d.mts +6 -1
- package/dist/models/column.model.d.mts +13 -2
- package/dist/models/data.model.d.mts +28 -2
- package/dist/models/dom.model.d.mts +19 -0
- package/dist/models/dom.model.mjs +19 -0
- package/dist/models/event.model.d.mts +99 -0
- package/dist/models/event.model.mjs +53 -0
- package/dist/models/filter.model.d.mts +26 -2
- package/dist/models/filter.model.mjs +13 -1
- package/dist/models/footer.model.d.mts +7 -1
- package/dist/models/group.model.d.mts +19 -2
- package/dist/models/group.model.mjs +5 -1
- package/dist/models/header.model.d.mts +6 -1
- package/dist/models/render.model.d.mts +22 -2
- package/dist/models/selection.model.d.mts +11 -1
- package/dist/models/sort.model.d.mts +19 -2
- package/dist/models/sort.model.mjs +5 -1
- package/dist/models/style.model.d.mts +27 -21
- package/dist/models/style.model.mjs +27 -21
- package/dist/models/tabela.model.d.mts +45 -1
- package/dist/models/tabela.options.d.mts +13 -1
- package/dist/tabela.d.mts +9 -8
- package/dist/tabela.full.mjs +1083 -574
- package/dist/tabela.mjs +19 -19
- package/package.json +2 -4
- package/src/components/body.component.ts +10 -7
- package/src/components/column.component.ts +20 -16
- package/src/components/footer.component.ts +7 -10
- package/src/components/group.component.ts +39 -13
- package/src/components/header.component.ts +6 -5
- package/src/components/row.component.ts +27 -19
- package/src/helpers/dom.helpers.ts +18 -22
- package/src/helpers/misc.helpers.ts +17 -0
- package/src/managers/column.manager.ts +9 -9
- package/src/managers/data.manager.ts +196 -107
- package/src/managers/event.manager.ts +69 -12
- package/src/managers/filter.manager.ts +70 -41
- package/src/managers/group.manager.ts +60 -18
- package/src/managers/navigation.manager.ts +46 -49
- package/src/managers/render.manager.ts +60 -34
- package/src/managers/row.manager.ts +1 -1
- package/src/managers/selection.manager.ts +37 -35
- package/src/managers/sort.manager.ts +114 -72
- package/src/managers/style.manager.ts +73 -25
- package/src/models/column.model.ts +4 -8
- package/src/models/data.model.ts +13 -14
- package/src/models/dom.model.ts +31 -0
- package/src/models/event.model.ts +175 -0
- package/src/models/filter.model.ts +22 -2
- package/src/models/group.model.ts +13 -0
- package/src/models/render.model.ts +6 -0
- package/src/models/sort.model.ts +11 -5
- package/src/models/style.model.ts +32 -20
- package/src/models/tabela.model.ts +1 -0
- package/src/tabela.ts +26 -24
- package/dist/body.component-_VDOpJhV.d.mts +0 -10
- package/dist/body.model-2iwsovAV.d.mts +0 -7
- package/dist/column.component-Bx46r3JI.d.mts +0 -16
- package/dist/column.model-D-aw4EU4.d.mts +0 -16
- package/dist/filter.model-7ukJrtil.d.mts +0 -16
- package/dist/footer.component-Curiab8j.d.mts +0 -12
- package/dist/footer.model-DhqoS6ds.d.mts +0 -8
- package/dist/group.component-Cq1YYbfJ.d.mts +0 -285
- package/dist/group.model-BsKFwHbt.d.mts +0 -10
- package/dist/header.component-BjjlpZIg.d.mts +0 -12
- package/dist/header.model-DN_KzUCV.d.mts +0 -7
- package/dist/selection.model-rwQe9fco.d.mts +0 -12
- package/dist/sort.model-CauImaLu.d.mts +0 -15
- package/dist/tabela.options-RkZvfptB.d.mts +0 -14
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import type {Key, PlainObject} from '@oscarpalmer/atoms/models';
|
|
2
|
+
import type {TabelaFilterItem} from './filter.model';
|
|
3
|
+
import type {TabelaGroup, TabelaGroupToggle} from './group.model';
|
|
4
|
+
import type {TabelaSortItem} from './sort.model';
|
|
5
|
+
|
|
6
|
+
export type EventDataAdd = (data: PlainObject[]) => void;
|
|
7
|
+
|
|
8
|
+
export type EventDataClear = () => void;
|
|
9
|
+
|
|
10
|
+
export type EventDataFiltered = (data: PlainObject[]) => void;
|
|
11
|
+
|
|
12
|
+
export type EventDataRemove = (data: PlainObject[]) => void;
|
|
13
|
+
|
|
14
|
+
export type EventDataSorted = (data: PlainObject[]) => void;
|
|
15
|
+
|
|
16
|
+
export type EventDataSynchronize = (data: {
|
|
17
|
+
added: PlainObject[];
|
|
18
|
+
removed: PlainObject[];
|
|
19
|
+
updated: PlainObject[];
|
|
20
|
+
}) => void;
|
|
21
|
+
|
|
22
|
+
export type EventDataUpdate = (data: PlainObject[]) => void;
|
|
23
|
+
|
|
24
|
+
export type EventFilterAdd = (filters: TabelaFilterItem[]) => void;
|
|
25
|
+
|
|
26
|
+
export type EventFilterClear = () => void;
|
|
27
|
+
|
|
28
|
+
export type EventFilterRemove = (filters: TabelaFilterItem[]) => void;
|
|
29
|
+
|
|
30
|
+
export type EventGroupAdd = (groups: TabelaGroup[]) => void;
|
|
31
|
+
|
|
32
|
+
export type EventGroupClear = () => void;
|
|
33
|
+
|
|
34
|
+
export type EventGroupRemove = (groups: TabelaGroup[]) => void;
|
|
35
|
+
|
|
36
|
+
export type EventGroupToggle = (event: TabelaGroupToggle) => void;
|
|
37
|
+
|
|
38
|
+
export type EventGroupUpdate = (groups: TabelaGroup[]) => void;
|
|
39
|
+
|
|
40
|
+
export type EventMap = {
|
|
41
|
+
'data:add': EventDataAdd;
|
|
42
|
+
'data:clear': EventDataClear;
|
|
43
|
+
'data:filtered': EventDataFiltered;
|
|
44
|
+
'data:remove': EventDataRemove;
|
|
45
|
+
'data:sorted': EventDataSorted;
|
|
46
|
+
'data:synchronize': EventDataSynchronize;
|
|
47
|
+
'data:update': EventDataUpdate;
|
|
48
|
+
'filter:add': EventFilterAdd;
|
|
49
|
+
'filter:clear': EventFilterClear;
|
|
50
|
+
'filter:remove': EventFilterRemove;
|
|
51
|
+
'group:add': EventGroupAdd;
|
|
52
|
+
'group:clear': EventGroupClear;
|
|
53
|
+
'group:remove': EventGroupRemove;
|
|
54
|
+
'group:toggle': EventGroupToggle;
|
|
55
|
+
'group:update': EventGroupUpdate;
|
|
56
|
+
'navigation:active': EventNavigationActive;
|
|
57
|
+
'render:begin': EventRenderBegin;
|
|
58
|
+
'render:end': EventRenderEnd;
|
|
59
|
+
'selection:add': EventSelectionAdd;
|
|
60
|
+
'selection:clear': EventSelectionClear;
|
|
61
|
+
'selection:remove': EventSelectionRemove;
|
|
62
|
+
'selection:toggle': EventSelectionToggle;
|
|
63
|
+
'sort:add': EventSortAdd;
|
|
64
|
+
'sort:clear': EventSortClear;
|
|
65
|
+
'sort:flip': EventSortFlip;
|
|
66
|
+
'sort:remove': EventSortRemove;
|
|
67
|
+
'sort:set': EventSortSet;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export type EventName = keyof EventMap;
|
|
71
|
+
|
|
72
|
+
export type EventNavigationActive = (active: Key | null) => void;
|
|
73
|
+
|
|
74
|
+
export type EventRenderBegin = () => void;
|
|
75
|
+
|
|
76
|
+
export type EventRenderEnd = () => void;
|
|
77
|
+
|
|
78
|
+
export type EventSelectionAdd = (keys: Key[]) => void;
|
|
79
|
+
|
|
80
|
+
export type EventSelectionClear = () => void;
|
|
81
|
+
|
|
82
|
+
export type EventSelectionRemove = (keys: Key[]) => void;
|
|
83
|
+
|
|
84
|
+
export type EventSelectionToggle = (keys: Key[]) => void;
|
|
85
|
+
|
|
86
|
+
export type EventSortAdd = (sorters: TabelaSortItem[]) => void;
|
|
87
|
+
|
|
88
|
+
export type EventSortClear = () => void;
|
|
89
|
+
|
|
90
|
+
export type EventSortFlip = (sorters: TabelaSortItem[]) => void;
|
|
91
|
+
|
|
92
|
+
export type EventSortRemove = (sorters: TabelaSortItem[]) => void;
|
|
93
|
+
|
|
94
|
+
export type EventSortSet = (sorters: {added: TabelaSortItem[]; removed: TabelaSortItem[]}) => void;
|
|
95
|
+
|
|
96
|
+
export type Events = Partial<{
|
|
97
|
+
[Name in EventName]: Set<EventMap[Name]>;
|
|
98
|
+
}>;
|
|
99
|
+
|
|
100
|
+
export type TabelaEvents = {
|
|
101
|
+
subscribe<Name extends EventName>(name: Name, callback: EventMap[Name]): void;
|
|
102
|
+
unsubscribe<Name extends EventName>(name: Name, callback: EventMap[Name]): void;
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const EVENT_BODY = 'body';
|
|
106
|
+
|
|
107
|
+
export const EVENT_DATA_ADD = 'data:add';
|
|
108
|
+
|
|
109
|
+
export const EVENT_DATA_CLEAR = 'data:clear';
|
|
110
|
+
|
|
111
|
+
export const EVENT_DATA_FILTERED = 'data:filtered';
|
|
112
|
+
|
|
113
|
+
export const EVENT_DATA_REMOVE = 'data:remove';
|
|
114
|
+
|
|
115
|
+
export const EVENT_DATA_SORTED = 'data:sorted';
|
|
116
|
+
|
|
117
|
+
export const EVENT_DATA_SYNCHRONIZE = 'data:synchronize';
|
|
118
|
+
|
|
119
|
+
export const EVENT_DATA_UPDATE = 'data:update';
|
|
120
|
+
|
|
121
|
+
export const EVENT_GROUP = 'group';
|
|
122
|
+
|
|
123
|
+
export const EVENT_GROUP_ADD = 'group:add';
|
|
124
|
+
|
|
125
|
+
export const EVENT_GROUP_CLEAR = 'group:clear';
|
|
126
|
+
|
|
127
|
+
export const EVENT_GROUP_REMOVE = 'group:remove';
|
|
128
|
+
|
|
129
|
+
export const EVENT_GROUP_TOGGLE = 'group:toggle';
|
|
130
|
+
|
|
131
|
+
export const EVENT_GROUP_UPDATE = 'group:update';
|
|
132
|
+
|
|
133
|
+
export const EVENT_HEADING = 'heading';
|
|
134
|
+
|
|
135
|
+
export const EVENT_ROW = 'row';
|
|
136
|
+
|
|
137
|
+
export const EVENT_SORT_ADD = 'sort:add';
|
|
138
|
+
|
|
139
|
+
export const EVENT_SORT_CLEAR = 'sort:clear';
|
|
140
|
+
|
|
141
|
+
export const EVENT_SORT_FLIP = 'sort:flip';
|
|
142
|
+
|
|
143
|
+
export const EVENT_SORT_REMOVE = 'sort:remove';
|
|
144
|
+
|
|
145
|
+
export const EVENT_SORT_SET = 'sort:set';
|
|
146
|
+
|
|
147
|
+
export const EVENTS_NAMES = new Set<EventName>([
|
|
148
|
+
EVENT_DATA_ADD,
|
|
149
|
+
EVENT_DATA_CLEAR,
|
|
150
|
+
EVENT_DATA_FILTERED,
|
|
151
|
+
EVENT_DATA_REMOVE,
|
|
152
|
+
EVENT_DATA_SORTED,
|
|
153
|
+
EVENT_DATA_SYNCHRONIZE,
|
|
154
|
+
EVENT_DATA_UPDATE,
|
|
155
|
+
'filter:add',
|
|
156
|
+
'filter:clear',
|
|
157
|
+
'filter:remove',
|
|
158
|
+
EVENT_GROUP_ADD,
|
|
159
|
+
EVENT_GROUP_CLEAR,
|
|
160
|
+
EVENT_GROUP_REMOVE,
|
|
161
|
+
EVENT_GROUP_TOGGLE,
|
|
162
|
+
EVENT_GROUP_UPDATE,
|
|
163
|
+
'navigation:active',
|
|
164
|
+
'render:begin',
|
|
165
|
+
'render:end',
|
|
166
|
+
'selection:add',
|
|
167
|
+
'selection:clear',
|
|
168
|
+
'selection:remove',
|
|
169
|
+
'selection:toggle',
|
|
170
|
+
EVENT_SORT_ADD,
|
|
171
|
+
EVENT_SORT_CLEAR,
|
|
172
|
+
EVENT_SORT_FLIP,
|
|
173
|
+
EVENT_SORT_REMOVE,
|
|
174
|
+
EVENT_SORT_SET,
|
|
175
|
+
] as const) satisfies ReadonlySet<EventName>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type TabelaFilter = {
|
|
2
2
|
add(item: TabelaFilterItem): void;
|
|
3
3
|
clear(): void;
|
|
4
|
-
remove(
|
|
4
|
+
remove(key: string): void;
|
|
5
5
|
remove(item: TabelaFilterItem): void;
|
|
6
6
|
set(items: TabelaFilterItem[]): void;
|
|
7
7
|
};
|
|
@@ -20,6 +20,26 @@ export type TabelaFilterComparison =
|
|
|
20
20
|
|
|
21
21
|
export type TabelaFilterItem = {
|
|
22
22
|
comparison: TabelaFilterComparison;
|
|
23
|
-
|
|
23
|
+
key: string;
|
|
24
24
|
value: unknown;
|
|
25
25
|
};
|
|
26
|
+
|
|
27
|
+
export const FILTER_CONTAINS: TabelaFilterComparison = 'contains';
|
|
28
|
+
|
|
29
|
+
export const FILTER_ENDS_WITH: TabelaFilterComparison = 'ends-with';
|
|
30
|
+
|
|
31
|
+
export const FILTER_EQUALS: TabelaFilterComparison = 'equals';
|
|
32
|
+
|
|
33
|
+
export const FILTER_GREATER_THAN: TabelaFilterComparison = 'greater-than';
|
|
34
|
+
|
|
35
|
+
export const FILTER_GREATER_THAN_OR_EQUAL: TabelaFilterComparison = 'greater-than-or-equal';
|
|
36
|
+
|
|
37
|
+
export const FILTER_LESS_THAN: TabelaFilterComparison = 'less-than';
|
|
38
|
+
|
|
39
|
+
export const FILTER_LESS_THAN_OR_EQUAL: TabelaFilterComparison = 'less-than-or-equal';
|
|
40
|
+
|
|
41
|
+
export const FILTER_NOT_CONTAINS: TabelaFilterComparison = 'not-contains';
|
|
42
|
+
|
|
43
|
+
export const FILTER_NOT_EQUALS: TabelaFilterComparison = 'not-equals';
|
|
44
|
+
|
|
45
|
+
export const FILTER_STARTS_WITH: TabelaFilterComparison = 'starts-with';
|
|
@@ -4,5 +4,18 @@ export type GroupValue = {
|
|
|
4
4
|
};
|
|
5
5
|
|
|
6
6
|
export type TabelaGroup = {
|
|
7
|
+
value: unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type TabelaGroupHandlers = {
|
|
7
11
|
set(group?: string): void;
|
|
8
12
|
};
|
|
13
|
+
|
|
14
|
+
export type TabelaGroupToggle = {
|
|
15
|
+
collapsed: TabelaGroup[];
|
|
16
|
+
expanded: TabelaGroup[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const GROUP_KEY_EXPRESSION = /^group:(.+)$/;
|
|
20
|
+
|
|
21
|
+
export const GROUP_KEY_PREFIX = 'group:';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type {Key} from '@oscarpalmer/atoms/models';
|
|
1
2
|
import type {State} from './tabela.model';
|
|
2
3
|
|
|
3
4
|
export type RenderElementPool = {
|
|
@@ -14,3 +15,8 @@ export type RenderState = {
|
|
|
14
15
|
active: boolean;
|
|
15
16
|
top: number;
|
|
16
17
|
} & State;
|
|
18
|
+
|
|
19
|
+
export type RenderVisible = {
|
|
20
|
+
indiced: Map<number, Key>;
|
|
21
|
+
keys: Set<Key>;
|
|
22
|
+
};
|
package/src/models/sort.model.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import type {SortDirection} from '@oscarpalmer/atoms/array';
|
|
2
|
+
|
|
1
3
|
export type TabelaSort = {
|
|
2
|
-
add(
|
|
4
|
+
add(key: string, direction?: TabelaSortDirection): void;
|
|
3
5
|
clear(): void;
|
|
4
|
-
flip(
|
|
5
|
-
remove(
|
|
6
|
+
flip(key: string): void;
|
|
7
|
+
remove(key: string): void;
|
|
6
8
|
set(items: TabelaSortItem[]): void;
|
|
7
9
|
};
|
|
8
10
|
|
|
9
|
-
export type TabelaSortDirection =
|
|
11
|
+
export type TabelaSortDirection = SortDirection;
|
|
10
12
|
|
|
11
13
|
export type TabelaSortItem = {
|
|
12
14
|
direction: TabelaSortDirection;
|
|
13
|
-
|
|
15
|
+
key: string;
|
|
14
16
|
};
|
|
17
|
+
|
|
18
|
+
export const SORT_ASCENDING: TabelaSortDirection = 'ascending';
|
|
19
|
+
|
|
20
|
+
export const SORT_DESCENDING: TabelaSortDirection = 'descending';
|
|
@@ -1,39 +1,51 @@
|
|
|
1
|
-
export const
|
|
1
|
+
export const CSS_BUTTON = 'tabela__button';
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const CSS_BUTTON_GROUP = 'tabela__button--group';
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const CSS_CELL = 'tabela__cell';
|
|
6
6
|
|
|
7
|
-
export const
|
|
7
|
+
export const CSS_CELL_BODY = 'tabela__cell--body';
|
|
8
8
|
|
|
9
|
-
export const
|
|
9
|
+
export const CSS_CELL_FOOTER = 'tabela__cell--footer';
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const CSS_CELL_GROUP = 'tabela__cell--group';
|
|
12
12
|
|
|
13
|
-
export const
|
|
13
|
+
export const CSS_FAKER = 'tabela__faker';
|
|
14
14
|
|
|
15
|
-
export const
|
|
15
|
+
export const CSS_GROUP = 'tabela__group';
|
|
16
16
|
|
|
17
|
-
export const
|
|
17
|
+
export const CSS_GROUP_SELECTED = 'tabela__group__selected';
|
|
18
18
|
|
|
19
|
-
export const
|
|
19
|
+
export const CSS_GROUP_TOTAL = 'tabela__group__total';
|
|
20
20
|
|
|
21
|
-
export const
|
|
21
|
+
export const CSS_HEADING = 'tabela__heading';
|
|
22
22
|
|
|
23
|
-
export const
|
|
23
|
+
export const CSS_HEADING_CONTENT = 'tabela__heading__content';
|
|
24
24
|
|
|
25
|
-
export const
|
|
25
|
+
export const CSS_HEADING_SORTER = 'tabela__heading__sorter';
|
|
26
26
|
|
|
27
|
-
export const
|
|
27
|
+
export const CSS_ROW = 'tabela__row';
|
|
28
28
|
|
|
29
|
-
export const
|
|
29
|
+
export const CSS_ROW_BODY = 'tabela__row--body';
|
|
30
30
|
|
|
31
|
-
export const
|
|
31
|
+
export const CSS_ROW_FOOTER = 'tabela__row--footer';
|
|
32
32
|
|
|
33
|
-
export const
|
|
33
|
+
export const CSS_ROW_GROUP = 'tabela__row--group tabela__group';
|
|
34
34
|
|
|
35
|
-
export const
|
|
35
|
+
export const CSS_ROW_HEADER = 'tabela__row--header';
|
|
36
36
|
|
|
37
|
-
export const
|
|
37
|
+
export const CSS_ROW_SELECTED = 'tabela__row--selected';
|
|
38
38
|
|
|
39
|
-
export const
|
|
39
|
+
export const CSS_ROWGROUP = 'tabela__rowgroup';
|
|
40
|
+
|
|
41
|
+
export const CSS_ROWGROUP_BODY = 'tabela__rowgroup--body';
|
|
42
|
+
|
|
43
|
+
export const CSS_ROWGROUP_FOOTER = 'tabela__rowgroup--footer';
|
|
44
|
+
|
|
45
|
+
export const CSS_ROWGROUP_HEADER = 'tabela__rowgroup--header';
|
|
46
|
+
|
|
47
|
+
export const CSS_SELECTION = 'tabela__selection';
|
|
48
|
+
|
|
49
|
+
export const CSS_TABLE = 'tabela__table';
|
|
50
|
+
|
|
51
|
+
export const CSS_WRAPPER = 'tabela';
|
package/src/tabela.ts
CHANGED
|
@@ -14,11 +14,13 @@ import {SelectionManager} from './managers/selection.manager';
|
|
|
14
14
|
import {SortManager} from './managers/sort.manager';
|
|
15
15
|
import {StyleManager} from './managers/style.manager';
|
|
16
16
|
import type {TabelaData} from './models/data.model';
|
|
17
|
+
import {ARIA_LABEL, ATTRIBUTE_ROLE, ELEMENT_DIV, ROLE_TABLE} from './models/dom.model';
|
|
18
|
+
import type {TabelaEvents} from './models/event.model';
|
|
17
19
|
import type {TabelaFilter} from './models/filter.model';
|
|
18
|
-
import type {
|
|
20
|
+
import type {TabelaGroupHandlers} from './models/group.model';
|
|
19
21
|
import type {TabelaSelection} from './models/selection.model';
|
|
20
22
|
import type {TabelaSort} from './models/sort.model';
|
|
21
|
-
import {
|
|
23
|
+
import {CSS_TABLE, CSS_WRAPPER} from './models/style.model';
|
|
22
24
|
import type {Components, Managers, State} from './models/tabela.model';
|
|
23
25
|
import type {TabelaOptions} from './models/tabela.options';
|
|
24
26
|
|
|
@@ -29,8 +31,6 @@ export class Tabela {
|
|
|
29
31
|
|
|
30
32
|
#id = getId();
|
|
31
33
|
|
|
32
|
-
#table: HTMLElement;
|
|
33
|
-
|
|
34
34
|
#key: string;
|
|
35
35
|
|
|
36
36
|
#managers: Managers = {
|
|
@@ -47,47 +47,45 @@ export class Tabela {
|
|
|
47
47
|
style: undefined as never,
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
+
#prefix = `tabela_${this.#id}_`;
|
|
51
|
+
|
|
50
52
|
#state: State;
|
|
51
53
|
|
|
54
|
+
#table: HTMLElement;
|
|
55
|
+
|
|
52
56
|
readonly data: TabelaData;
|
|
53
57
|
|
|
58
|
+
readonly events: TabelaEvents;
|
|
59
|
+
|
|
54
60
|
readonly filter: TabelaFilter;
|
|
55
61
|
|
|
56
|
-
readonly group:
|
|
62
|
+
readonly group: TabelaGroupHandlers;
|
|
57
63
|
|
|
58
64
|
readonly selection: TabelaSelection;
|
|
59
65
|
|
|
60
66
|
readonly sort: TabelaSort;
|
|
61
67
|
|
|
62
|
-
get key(): string {
|
|
63
|
-
return this.#key;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
68
|
constructor(element: HTMLElement, options: TabelaOptions) {
|
|
67
69
|
this.#element = element;
|
|
68
70
|
|
|
69
71
|
element.innerHTML = '';
|
|
70
72
|
|
|
71
|
-
element.classList.add(
|
|
73
|
+
element.classList.add(CSS_WRAPPER);
|
|
72
74
|
|
|
73
75
|
this.#table = createElement(
|
|
74
|
-
|
|
76
|
+
ELEMENT_DIV,
|
|
75
77
|
{
|
|
76
|
-
className:
|
|
77
|
-
role:
|
|
78
|
+
className: CSS_TABLE,
|
|
79
|
+
role: ROLE_TABLE,
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
|
-
|
|
82
|
+
[ARIA_LABEL]: options.label,
|
|
81
83
|
},
|
|
82
84
|
);
|
|
83
85
|
|
|
84
86
|
this.#key = options.key;
|
|
85
87
|
|
|
86
|
-
this.#components = {
|
|
87
|
-
body: new BodyComponent(),
|
|
88
|
-
footer: new FooterComponent(),
|
|
89
|
-
header: new HeaderComponent(),
|
|
90
|
-
};
|
|
88
|
+
this.#components = {} as never;
|
|
91
89
|
|
|
92
90
|
this.#state = {
|
|
93
91
|
options,
|
|
@@ -96,8 +94,13 @@ export class Tabela {
|
|
|
96
94
|
id: this.#id,
|
|
97
95
|
key: this.#key,
|
|
98
96
|
managers: this.#managers,
|
|
97
|
+
prefix: this.#prefix,
|
|
99
98
|
};
|
|
100
99
|
|
|
100
|
+
this.#components.body = new BodyComponent(this.#state);
|
|
101
|
+
this.#components.footer = new FooterComponent(this.#state);
|
|
102
|
+
this.#components.header = new HeaderComponent(this.#state);
|
|
103
|
+
|
|
101
104
|
this.#managers.column = new ColumnManager(this.#state);
|
|
102
105
|
this.#managers.data = new DataManager(this.#state);
|
|
103
106
|
this.#managers.event = new EventManager(this.#state);
|
|
@@ -121,6 +124,7 @@ export class Tabela {
|
|
|
121
124
|
this.#managers.data.set(options.data);
|
|
122
125
|
|
|
123
126
|
this.data = this.#managers.data.handlers;
|
|
127
|
+
this.events = this.#managers.event.handlers;
|
|
124
128
|
this.filter = this.#managers.filter.handlers;
|
|
125
129
|
this.group = this.#managers.group.handlers;
|
|
126
130
|
this.selection = this.#managers.selection.handlers;
|
|
@@ -149,14 +153,12 @@ export class Tabela {
|
|
|
149
153
|
managers.sort.destroy();
|
|
150
154
|
|
|
151
155
|
element.innerHTML = '';
|
|
152
|
-
|
|
153
156
|
table.innerHTML = '';
|
|
154
|
-
table.role = '';
|
|
155
157
|
|
|
156
|
-
element.classList.remove(
|
|
158
|
+
element.classList.remove(CSS_WRAPPER);
|
|
157
159
|
|
|
158
|
-
table.removeAttribute(
|
|
159
|
-
table.removeAttribute(
|
|
160
|
+
table.removeAttribute(ARIA_LABEL);
|
|
161
|
+
table.removeAttribute(ATTRIBUTE_ROLE);
|
|
160
162
|
|
|
161
163
|
this.#state.components = undefined as never;
|
|
162
164
|
this.#state.managers = undefined as never;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { t as BodyElements } from "./body.model-2iwsovAV.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/components/body.component.d.ts
|
|
4
|
-
declare class BodyComponent {
|
|
5
|
-
readonly elements: BodyElements;
|
|
6
|
-
constructor();
|
|
7
|
-
destroy(): void;
|
|
8
|
-
}
|
|
9
|
-
//#endregion
|
|
10
|
-
export { BodyComponent as t };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { n as TabelaColumn, t as Column } from "./column.model-D-aw4EU4.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/components/column.component.d.ts
|
|
4
|
-
declare class ColumnComponent {
|
|
5
|
-
elements: ColumnElements;
|
|
6
|
-
options: Column;
|
|
7
|
-
constructor(column: TabelaColumn);
|
|
8
|
-
destroy(): void;
|
|
9
|
-
}
|
|
10
|
-
type ColumnElements = {
|
|
11
|
-
content: HTMLDivElement;
|
|
12
|
-
sorter: HTMLDivElement;
|
|
13
|
-
wrapper: HTMLDivElement;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { ColumnComponent as t };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/models/column.model.d.ts
|
|
2
|
-
type Column = {
|
|
3
|
-
field: string;
|
|
4
|
-
title: string;
|
|
5
|
-
type: TabelaColumnType;
|
|
6
|
-
width: number;
|
|
7
|
-
};
|
|
8
|
-
type TabelaColumn = {
|
|
9
|
-
field: string;
|
|
10
|
-
title: string;
|
|
11
|
-
type: TabelaColumnType;
|
|
12
|
-
width?: number;
|
|
13
|
-
};
|
|
14
|
-
type TabelaColumnType = 'boolean' | 'date' | 'date-time' | 'number' | 'string' | 'time';
|
|
15
|
-
//#endregion
|
|
16
|
-
export { TabelaColumn as n, TabelaColumnType as r, Column as t };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//#region src/models/filter.model.d.ts
|
|
2
|
-
type TabelaFilter = {
|
|
3
|
-
add(item: TabelaFilterItem): void;
|
|
4
|
-
clear(): void;
|
|
5
|
-
remove(field: string): void;
|
|
6
|
-
remove(item: TabelaFilterItem): void;
|
|
7
|
-
set(items: TabelaFilterItem[]): void;
|
|
8
|
-
};
|
|
9
|
-
type TabelaFilterComparison = 'contains' | 'ends-with' | 'equals' | 'greater-than' | 'greater-than-or-equal' | 'less-than' | 'less-than-or-equal' | 'not-contains' | 'not-equals' | 'starts-with';
|
|
10
|
-
type TabelaFilterItem = {
|
|
11
|
-
comparison: TabelaFilterComparison;
|
|
12
|
-
field: string;
|
|
13
|
-
value: unknown;
|
|
14
|
-
};
|
|
15
|
-
//#endregion
|
|
16
|
-
export { TabelaFilterComparison as n, TabelaFilterItem as r, TabelaFilter as t };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { t as ColumnComponent } from "./column.component-Bx46r3JI.mjs";
|
|
2
|
-
import { t as FooterElements } from "./footer.model-DhqoS6ds.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/components/footer.component.d.ts
|
|
5
|
-
declare class FooterComponent {
|
|
6
|
-
readonly elements: FooterElements;
|
|
7
|
-
constructor();
|
|
8
|
-
destroy(): void;
|
|
9
|
-
update(columns: ColumnComponent[]): void;
|
|
10
|
-
}
|
|
11
|
-
//#endregion
|
|
12
|
-
export { FooterComponent as t };
|