@oscarpalmer/tabela 0.13.0 → 0.14.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.
Files changed (131) hide show
  1. package/dist/components/{body.component.mjs → body.component.js} +3 -6
  2. package/dist/components/{column.component.mjs → column.component.js} +5 -8
  3. package/dist/components/{footer.component.mjs → footer.component.js} +4 -7
  4. package/dist/components/group.component.js +28 -0
  5. package/dist/components/{header.component.mjs → header.component.js} +3 -6
  6. package/dist/components/{row.component.mjs → row.component.js} +7 -11
  7. package/dist/helpers/{dom.helpers.mjs → dom.helpers.js} +9 -13
  8. package/dist/helpers/{misc.helpers.mjs → misc.helpers.js} +1 -3
  9. package/dist/helpers/style.helper.js +6 -0
  10. package/dist/{index.mjs → index.js} +1 -3
  11. package/dist/managers/{column.manager.mjs → column.manager.js} +1 -6
  12. package/dist/managers/data.manager.js +181 -0
  13. package/dist/managers/{event.manager.mjs → event.manager.js} +8 -9
  14. package/dist/managers/{filter.manager.mjs → filter.manager.js} +14 -23
  15. package/dist/managers/group.manager.js +46 -0
  16. package/dist/managers/{navigation.manager.mjs → navigation.manager.js} +24 -27
  17. package/dist/managers/{render.manager.mjs → render.manager.js} +26 -35
  18. package/dist/managers/{row.manager.mjs → row.manager.js} +11 -18
  19. package/dist/managers/{selection.manager.mjs → selection.manager.js} +28 -32
  20. package/dist/managers/{sort.manager.mjs → sort.manager.js} +9 -12
  21. package/dist/models/body.model.js +0 -0
  22. package/dist/models/column.model.js +0 -0
  23. package/dist/models/data.model.js +0 -0
  24. package/dist/models/filter.model.js +0 -0
  25. package/dist/models/footer.model.js +0 -0
  26. package/dist/models/group.model.js +0 -0
  27. package/dist/models/header.model.js +0 -0
  28. package/dist/models/render.model.js +0 -0
  29. package/dist/models/selection.model.js +0 -0
  30. package/dist/models/sort.model.js +0 -0
  31. package/dist/models/tabela.model.js +0 -0
  32. package/dist/models/tabela.options.js +0 -0
  33. package/dist/{tabela.full.mjs → tabela.full.js} +860 -1049
  34. package/dist/tabela.js +105 -0
  35. package/package.json +1 -1
  36. package/src/components/body.component.ts +10 -7
  37. package/src/components/column.component.ts +19 -15
  38. package/src/components/footer.component.ts +7 -10
  39. package/src/components/group.component.ts +34 -12
  40. package/src/components/header.component.ts +6 -5
  41. package/src/components/row.component.ts +27 -19
  42. package/src/helpers/dom.helpers.ts +18 -22
  43. package/src/helpers/misc.helpers.ts +5 -0
  44. package/src/managers/data.manager.ts +80 -77
  45. package/src/managers/event.manager.ts +21 -10
  46. package/src/managers/filter.manager.ts +34 -21
  47. package/src/managers/group.manager.ts +18 -9
  48. package/src/managers/navigation.manager.ts +46 -49
  49. package/src/managers/render.manager.ts +34 -21
  50. package/src/managers/row.manager.ts +1 -1
  51. package/src/managers/selection.manager.ts +37 -35
  52. package/src/managers/sort.manager.ts +47 -34
  53. package/src/managers/style.manager.ts +40 -25
  54. package/src/models/column.model.ts +2 -6
  55. package/src/models/data.model.ts +7 -8
  56. package/src/models/dom.model.ts +33 -0
  57. package/src/models/event.model.ts +7 -0
  58. package/src/models/filter.model.ts +20 -0
  59. package/src/models/group.model.ts +4 -0
  60. package/src/models/sort.model.ts +4 -0
  61. package/src/models/style.model.ts +32 -20
  62. package/src/models/tabela.model.ts +1 -0
  63. package/src/tabela.ts +20 -22
  64. package/dist/body.component-_VDOpJhV.d.mts +0 -10
  65. package/dist/body.model-2iwsovAV.d.mts +0 -7
  66. package/dist/column.component-Bx46r3JI.d.mts +0 -16
  67. package/dist/column.model-D-aw4EU4.d.mts +0 -16
  68. package/dist/components/body.component.d.mts +0 -2
  69. package/dist/components/column.component.d.mts +0 -2
  70. package/dist/components/footer.component.d.mts +0 -2
  71. package/dist/components/group.component.d.mts +0 -2
  72. package/dist/components/group.component.mjs +0 -51
  73. package/dist/components/header.component.d.mts +0 -2
  74. package/dist/components/row.component.d.mts +0 -2
  75. package/dist/filter.model-7ukJrtil.d.mts +0 -16
  76. package/dist/footer.component-Curiab8j.d.mts +0 -12
  77. package/dist/footer.model-DhqoS6ds.d.mts +0 -8
  78. package/dist/group.component-Cq1YYbfJ.d.mts +0 -285
  79. package/dist/group.model-BsKFwHbt.d.mts +0 -10
  80. package/dist/header.component-BjjlpZIg.d.mts +0 -12
  81. package/dist/header.model-DN_KzUCV.d.mts +0 -7
  82. package/dist/helpers/dom.helpers.d.mts +0 -12
  83. package/dist/helpers/misc.helpers.d.mts +0 -6
  84. package/dist/helpers/style.helper.d.mts +0 -6
  85. package/dist/helpers/style.helper.mjs +0 -8
  86. package/dist/index.d.mts +0 -7
  87. package/dist/managers/column.manager.d.mts +0 -2
  88. package/dist/managers/data.manager.d.mts +0 -2
  89. package/dist/managers/data.manager.mjs +0 -222
  90. package/dist/managers/event.manager.d.mts +0 -2
  91. package/dist/managers/filter.manager.d.mts +0 -2
  92. package/dist/managers/group.manager.d.mts +0 -2
  93. package/dist/managers/group.manager.mjs +0 -73
  94. package/dist/managers/navigation.manager.d.mts +0 -2
  95. package/dist/managers/render.manager.d.mts +0 -2
  96. package/dist/managers/row.manager.d.mts +0 -2
  97. package/dist/managers/selection.manager.d.mts +0 -2
  98. package/dist/managers/sort.manager.d.mts +0 -2
  99. package/dist/managers/style.manager.d.mts +0 -2
  100. package/dist/managers/style.manager.mjs +0 -149
  101. package/dist/models/body.model.d.mts +0 -2
  102. package/dist/models/body.model.mjs +0 -1
  103. package/dist/models/column.model.d.mts +0 -2
  104. package/dist/models/column.model.mjs +0 -1
  105. package/dist/models/data.model.d.mts +0 -2
  106. package/dist/models/data.model.mjs +0 -1
  107. package/dist/models/filter.model.d.mts +0 -2
  108. package/dist/models/filter.model.mjs +0 -1
  109. package/dist/models/footer.model.d.mts +0 -2
  110. package/dist/models/footer.model.mjs +0 -1
  111. package/dist/models/group.model.d.mts +0 -2
  112. package/dist/models/group.model.mjs +0 -1
  113. package/dist/models/header.model.d.mts +0 -2
  114. package/dist/models/header.model.mjs +0 -1
  115. package/dist/models/render.model.d.mts +0 -2
  116. package/dist/models/render.model.mjs +0 -1
  117. package/dist/models/selection.model.d.mts +0 -2
  118. package/dist/models/selection.model.mjs +0 -1
  119. package/dist/models/sort.model.d.mts +0 -2
  120. package/dist/models/sort.model.mjs +0 -1
  121. package/dist/models/style.model.d.mts +0 -23
  122. package/dist/models/style.model.mjs +0 -23
  123. package/dist/models/tabela.model.d.mts +0 -2
  124. package/dist/models/tabela.model.mjs +0 -1
  125. package/dist/models/tabela.options.d.mts +0 -2
  126. package/dist/models/tabela.options.mjs +0 -1
  127. package/dist/selection.model-rwQe9fco.d.mts +0 -12
  128. package/dist/sort.model-CauImaLu.d.mts +0 -15
  129. package/dist/tabela.d.mts +0 -21
  130. package/dist/tabela.mjs +0 -126
  131. package/dist/tabela.options-RkZvfptB.d.mts +0 -14
@@ -1,3 +1,18 @@
1
+ import {
2
+ CSS_BUTTON,
3
+ CSS_CELL,
4
+ CSS_CELL_FOOTER,
5
+ CSS_CELL_GROUP,
6
+ CSS_HEADING,
7
+ CSS_ROW,
8
+ CSS_ROW_SELECTED,
9
+ CSS_ROWGROUP_BODY,
10
+ CSS_ROWGROUP_FOOTER,
11
+ CSS_ROWGROUP_HEADER,
12
+ CSS_SELECTION,
13
+ CSS_TABLE,
14
+ CSS_WRAPPER,
15
+ } from '../models/style.model';
1
16
  import type {State} from '../models/tabela.model';
2
17
 
3
18
  export class StyleManager {
@@ -19,14 +34,14 @@ export class StyleManager {
19
34
  const styling = //css
20
35
  `/** Table */
21
36
 
22
- :where(.tabela) {
37
+ :where(.${CSS_WRAPPER}) {
23
38
  flex: 1;
24
39
  position: relative;
25
40
  background-color: var(--oui-absolute);
26
41
  border: 1px solid grey;
27
42
  }
28
43
 
29
- :where(.tabela__table) {
44
+ :where(.${CSS_TABLE}) {
30
45
  min-height: 24em;
31
46
  display: flex;
32
47
  flex-flow: column nowrap;
@@ -38,69 +53,69 @@ const styling = //css
38
53
 
39
54
  /** Row group */
40
55
 
41
- :where(.tabela__rowgroup--header),
42
- :where(.tabela__rowgroup--footer) {
56
+ :where(.${CSS_ROWGROUP_HEADER}),
57
+ :where(.${CSS_ROWGROUP_FOOTER}) {
43
58
  background-color: white;
44
59
  position: sticky;
45
60
  left: 0;
46
61
  z-index: 10;
47
62
  }
48
63
 
49
- :where(.tabela__rowgroup--header) {
64
+ :where(.${CSS_ROWGROUP_HEADER}) {
50
65
  top: 0;
51
66
  }
52
67
 
53
- :where(.tabela__rowgroup--footer) {
68
+ :where(.${CSS_ROWGROUP_FOOTER}) {
54
69
  bottom: 0;
55
70
  }
56
71
 
57
- :where(.tabela__rowgroup--body) {
72
+ :where(.${CSS_ROWGROUP_BODY}) {
58
73
  display: flex;
59
74
  flex-flow: column nowrap;
60
75
  flex: 1;
61
76
  }
62
77
 
63
- :where(.tabela__rowgroup--body:focus) {
78
+ :where(.${CSS_ROWGROUP_BODY}:focus) {
64
79
  outline: none;
65
80
  }
66
81
 
67
- :where(.tabela:has(.tabela__rowgroup--body:focus-visible)) {
82
+ :where(.${CSS_WRAPPER}:has(.${CSS_ROWGROUP_BODY}:focus-visible)) {
68
83
  outline: 2px solid var(--oui-blue-6);
69
84
  outline-offset: 2px;
70
85
  }
71
86
 
72
87
  /** Row */
73
88
 
74
- :where(.tabela__row) {
89
+ :where(.${CSS_ROW}) {
75
90
  width: 100%;
76
91
  display: flex;
77
92
  flex-flow: row nowrap;
78
93
  }
79
94
 
80
- :where(.tabela__row:last-child .tabela__cell) {
95
+ :where(.${CSS_ROW}:last-child .${CSS_CELL}) {
81
96
  border-bottom-width: 0;
82
97
  }
83
98
 
84
- :where(.tabela__row--body),
85
- :where(.tabela__row--group) {
99
+ :where(.${CSS_ROW}--body),
100
+ :where(.${CSS_ROW}--group) {
86
101
  flex: 1;
87
102
  position: absolute;
88
103
  }
89
104
 
90
- :where(.tabela__row--selected) {
105
+ :where(.${CSS_ROW_SELECTED}) {
91
106
  background-color: var(--oui-blue-1);
92
107
  color: var(--oui-blue-9);
93
108
  }
94
109
 
95
- :where(.tabela:has(.tabela__rowgroup--body:focus-visible) .tabela__row[data-active="true"]) {
110
+ :where(.${CSS_WRAPPER}:has(.${CSS_ROWGROUP_BODY}:focus-visible) .${CSS_ROW}[data-active="true"]) {
96
111
  outline: 2px solid var(--oui-blue-6);
97
112
  outline-offset: 2px;
98
113
  }
99
114
 
100
115
  /** Cells */
101
116
 
102
- :where(.tabela__cell),
103
- :where(.tabela__heading) {
117
+ :where(.${CSS_CELL}),
118
+ :where(.${CSS_HEADING}) {
104
119
  padding: 0.5em;
105
120
  border-color: gray;
106
121
  border-style: solid;
@@ -108,24 +123,24 @@ const styling = //css
108
123
  line-height: 1;
109
124
  }
110
125
 
111
- :where(.tabela__row .tabela__cell:last-child),
112
- :where(.tabela__row .tabela__heading:last-child) {
126
+ :where(.${CSS_WRAPPER} .${CSS_CELL}:last-child),
127
+ :where(.${CSS_ROW} .${CSS_HEADING}:last-child) {
113
128
  flex: 1;
114
129
  border-right-width: 0;
115
130
  }
116
131
 
117
- :where(.tabela__cell) {
132
+ :where(.${CSS_CELL}) {
118
133
  overflow: hidden;
119
134
  text-overflow: ellipsis;
120
135
  white-space: nowrap;
121
136
  }
122
137
 
123
- :where(.tabela__cell--footer) {
138
+ :where(.${CSS_CELL_FOOTER}) {
124
139
  border-top-width: 1px;
125
140
  border-bottom-width: 0;
126
141
  }
127
142
 
128
- :where(.tabela__cell--group) {
143
+ :where(.${CSS_CELL_GROUP}) {
129
144
  padding: 0;
130
145
  display: flex;
131
146
  flex-flow: row nowrap;
@@ -133,18 +148,18 @@ const styling = //css
133
148
  gap: 0.5em;
134
149
  }
135
150
 
136
- :where(.tabela__cell--group .tabela__button) {
151
+ :where(.${CSS_CELL_GROUP} .${CSS_BUTTON}) {
137
152
  margin: 0 0 0 .25rem;
138
153
  }
139
154
 
140
155
  /** Misc. */
141
156
 
142
- :where(.tabela__button) {
157
+ :where(.${CSS_BUTTON}) {
143
158
  font-size: .75rem;
144
159
  font-weight: bold;
145
160
  }
146
161
 
147
- :where(.tabela__selection) {
162
+ :where(.${CSS_SELECTION}) {
148
163
  background-color: color-mix(in oklch, var(--oui-blue-6), transparent);
149
164
  border: 1px solid var(--oui-blue-6);
150
165
  border-radius: .25rem;
@@ -1,15 +1,11 @@
1
1
  export type Column = {
2
2
  field: string;
3
- title: string;
4
- type: TabelaColumnType;
3
+ label: string;
5
4
  width: number;
6
5
  };
7
6
 
8
7
  export type TabelaColumn = {
9
8
  field: string;
10
- title: string;
11
- type: TabelaColumnType;
9
+ label: string;
12
10
  width?: number;
13
11
  };
14
-
15
- export type TabelaColumnType = 'boolean' | 'date' | 'date-time' | 'number' | 'string' | 'time';
@@ -1,21 +1,20 @@
1
1
  import type {Key, PlainObject} from '@oscarpalmer/atoms/models';
2
- import type {GroupComponent} from '../components/group.component';
3
2
  import type {State} from './tabela.model';
4
3
 
5
- export type DataItem = GroupComponent | Key;
6
-
7
- type DataItems = {
8
- active?: Array<DataItem>;
9
- original: Array<DataItem>;
4
+ type DataKeys = {
5
+ active?: Key[];
6
+ original: Key[];
10
7
  };
11
8
 
12
9
  export type DataState = {
13
- items: DataItems;
10
+ keys: DataKeys;
14
11
  values: DataValues;
15
12
  } & State;
16
13
 
14
+ export type DataValue = string | PlainObject;
15
+
17
16
  type DataValues = {
18
- array: Array<GroupComponent | PlainObject>;
17
+ array: DataValue[];
19
18
  mapped: Map<Key, PlainObject>;
20
19
  };
21
20
 
@@ -0,0 +1,33 @@
1
+ export const ARIA_ACTIVEDESCENDANT = 'aria-activedescendant';
2
+
3
+ export const ARIA_LABEL = 'aria-label';
4
+
5
+ export const ARIA_SELECTED = 'aria-selected';
6
+
7
+ export const ARIA_SORT = 'aria-sort';
8
+
9
+ export const ATTRIBUTE_DATA_ACTIVE = 'data-active';
10
+
11
+ export const ATTRIBUTE_DATA_EVENT = 'data-event';
12
+
13
+ export const ATTRIBUTE_DATA_FIELD = 'data-field';
14
+
15
+ export const ATTRIBUTE_DATA_KEY = 'data-key';
16
+
17
+ export const ATTRIBUTE_DATA_SORT_DIRECTION = 'data-sort-direction';
18
+
19
+ export const ATTRIBUTE_DATA_SORT_POSITION = 'data-sort-position';
20
+
21
+ export const ATTRIBUTE_ROLE = 'role';
22
+
23
+ export const ELEMENT_DIV = 'div';
24
+
25
+ export const ROLE_CELL = 'cell';
26
+
27
+ export const ROLE_COLUMNHEADER = 'columnheader';
28
+
29
+ export const ROLE_ROW = 'row';
30
+
31
+ export const ROLE_ROWGROUP = 'rowgroup';
32
+
33
+ export const ROLE_TABLE = 'table';
@@ -0,0 +1,7 @@
1
+ export const EVENT_BODY = 'body';
2
+
3
+ export const EVENT_GROUP = 'group';
4
+
5
+ export const EVENT_HEADING = 'heading';
6
+
7
+ export const EVENT_ROW = 'row';
@@ -23,3 +23,23 @@ export type TabelaFilterItem = {
23
23
  field: 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';
@@ -6,3 +6,7 @@ export type GroupValue = {
6
6
  export type TabelaGroup = {
7
7
  set(group?: string): void;
8
8
  };
9
+
10
+ export const GROUP_KEY_EXPRESSION = /^group:(.+)$/;
11
+
12
+ export const GROUP_KEY_PREFIX = 'group:';
@@ -12,3 +12,7 @@ export type TabelaSortItem = {
12
12
  direction: TabelaSortDirection;
13
13
  field: string;
14
14
  };
15
+
16
+ export const SORT_ASCENDING: TabelaSortDirection = 'ascending';
17
+
18
+ export const SORT_DESCENDING: TabelaSortDirection = 'descending';
@@ -1,39 +1,51 @@
1
- export const CSS_TABELA = 'tabela';
1
+ export const CSS_BUTTON = 'tabela__button';
2
2
 
3
- export const CSS_TABELA_CELL = 'tabela__cell';
3
+ export const CSS_BUTTON_GROUP = 'tabela__button--group';
4
4
 
5
- export const CSS_TABELA_CELL_BODY = 'tabela__cell--body';
5
+ export const CSS_CELL = 'tabela__cell';
6
6
 
7
- export const CSS_TABELA_CELL_FOOTER = 'tabela__cell--footer';
7
+ export const CSS_CELL_BODY = 'tabela__cell--body';
8
8
 
9
- export const CSS_TABELA_FAKER = 'tabela__faker';
9
+ export const CSS_CELL_FOOTER = 'tabela__cell--footer';
10
10
 
11
- export const CSS_TABELA_HEADING = 'tabela__heading';
11
+ export const CSS_CELL_GROUP = 'tabela__cell--group';
12
12
 
13
- export const CSS_TABELA_HEADING_CONTENT = 'tabela__heading__content';
13
+ export const CSS_FAKER = 'tabela__faker';
14
14
 
15
- export const CSS_TABELA_HEADING_SORTER = 'tabela__heading__sorter';
15
+ export const CSS_GROUP = 'tabela__group';
16
16
 
17
- export const CSS_TABELA_ROW = 'tabela__row';
17
+ export const CSS_GROUP_SELECTED = 'tabela__group__selected';
18
18
 
19
- export const CSS_TABELA_ROW_BODY = 'tabela__row--body';
19
+ export const CSS_GROUP_TOTAL = 'tabela__group__total';
20
20
 
21
- export const CSS_TABELA_ROW_FOOTER = 'tabela__row--footer';
21
+ export const CSS_HEADING = 'tabela__heading';
22
22
 
23
- export const CSS_TABELA_ROW_GROUP = 'tabela__row--group tabela__group';
23
+ export const CSS_HEADING_CONTENT = 'tabela__heading__content';
24
24
 
25
- export const CSS_TABELA_ROW_HEADER = 'tabela__row--header';
25
+ export const CSS_HEADING_SORTER = 'tabela__heading__sorter';
26
26
 
27
- export const CSS_TABELA_ROW_SELECTED = 'tabela__row--selected';
27
+ export const CSS_ROW = 'tabela__row';
28
28
 
29
- export const CSS_TABELA_ROWGROUP = 'tabela__rowgroup';
29
+ export const CSS_ROW_BODY = 'tabela__row--body';
30
30
 
31
- export const CSS_TABELA_ROWGROUP_BODY = 'tabela__rowgroup--body';
31
+ export const CSS_ROW_FOOTER = 'tabela__row--footer';
32
32
 
33
- export const CSS_TABELA_ROWGROUP_FOOTER = 'tabela__rowgroup--footer';
33
+ export const CSS_ROW_GROUP = 'tabela__row--group tabela__group';
34
34
 
35
- export const CSS_TABELA_ROWGROUP_HEADER = 'tabela__rowgroup--header';
35
+ export const CSS_ROW_HEADER = 'tabela__row--header';
36
36
 
37
- export const CSS_TABELA_SELECTION = 'tabela__selection';
37
+ export const CSS_ROW_SELECTED = 'tabela__row--selected';
38
38
 
39
- export const CSS_TABELA_TABLE = 'tabela__table';
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';
@@ -40,5 +40,6 @@ export type State = {
40
40
  id: number;
41
41
  key: string;
42
42
  managers: Managers;
43
+ prefix: string;
43
44
  options: TabelaOptions;
44
45
  };
package/src/tabela.ts CHANGED
@@ -14,11 +14,12 @@ 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';
17
18
  import type {TabelaFilter} from './models/filter.model';
18
19
  import type {TabelaGroup} from './models/group.model';
19
20
  import type {TabelaSelection} from './models/selection.model';
20
21
  import type {TabelaSort} from './models/sort.model';
21
- import {CSS_TABELA, CSS_TABELA_TABLE} from './models/style.model';
22
+ import {CSS_TABLE, CSS_WRAPPER} from './models/style.model';
22
23
  import type {Components, Managers, State} from './models/tabela.model';
23
24
  import type {TabelaOptions} from './models/tabela.options';
24
25
 
@@ -29,8 +30,6 @@ export class Tabela {
29
30
 
30
31
  #id = getId();
31
32
 
32
- #table: HTMLElement;
33
-
34
33
  #key: string;
35
34
 
36
35
  #managers: Managers = {
@@ -47,8 +46,12 @@ export class Tabela {
47
46
  style: undefined as never,
48
47
  };
49
48
 
49
+ #prefix = `tabela_${this.#id}_`;
50
+
50
51
  #state: State;
51
52
 
53
+ #table: HTMLElement;
54
+
52
55
  readonly data: TabelaData;
53
56
 
54
57
  readonly filter: TabelaFilter;
@@ -59,35 +62,27 @@ export class Tabela {
59
62
 
60
63
  readonly sort: TabelaSort;
61
64
 
62
- get key(): string {
63
- return this.#key;
64
- }
65
-
66
65
  constructor(element: HTMLElement, options: TabelaOptions) {
67
66
  this.#element = element;
68
67
 
69
68
  element.innerHTML = '';
70
69
 
71
- element.classList.add(CSS_TABELA);
70
+ element.classList.add(CSS_WRAPPER);
72
71
 
73
72
  this.#table = createElement(
74
- 'div',
73
+ ELEMENT_DIV,
75
74
  {
76
- className: CSS_TABELA_TABLE,
77
- role: 'table',
75
+ className: CSS_TABLE,
76
+ role: ROLE_TABLE,
78
77
  },
79
78
  {
80
- 'aria-label': options.label,
79
+ [ARIA_LABEL]: options.label,
81
80
  },
82
81
  );
83
82
 
84
83
  this.#key = options.key;
85
84
 
86
- this.#components = {
87
- body: new BodyComponent(),
88
- footer: new FooterComponent(),
89
- header: new HeaderComponent(),
90
- };
85
+ this.#components = {} as never;
91
86
 
92
87
  this.#state = {
93
88
  options,
@@ -96,8 +91,13 @@ export class Tabela {
96
91
  id: this.#id,
97
92
  key: this.#key,
98
93
  managers: this.#managers,
94
+ prefix: this.#prefix,
99
95
  };
100
96
 
97
+ this.#components.body = new BodyComponent(this.#state);
98
+ this.#components.footer = new FooterComponent(this.#state);
99
+ this.#components.header = new HeaderComponent(this.#state);
100
+
101
101
  this.#managers.column = new ColumnManager(this.#state);
102
102
  this.#managers.data = new DataManager(this.#state);
103
103
  this.#managers.event = new EventManager(this.#state);
@@ -149,14 +149,12 @@ export class Tabela {
149
149
  managers.sort.destroy();
150
150
 
151
151
  element.innerHTML = '';
152
-
153
152
  table.innerHTML = '';
154
- table.role = '';
155
153
 
156
- element.classList.remove(CSS_TABELA);
154
+ element.classList.remove(CSS_WRAPPER);
157
155
 
158
- table.removeAttribute('aria-label');
159
- table.removeAttribute('role');
156
+ table.removeAttribute(ARIA_LABEL);
157
+ table.removeAttribute(ATTRIBUTE_ROLE);
160
158
 
161
159
  this.#state.components = undefined as never;
162
160
  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,7 +0,0 @@
1
- //#region src/models/body.model.d.ts
2
- type BodyElements = {
3
- faker: HTMLDivElement;
4
- group: HTMLDivElement;
5
- };
6
- //#endregion
7
- export { BodyElements 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,2 +0,0 @@
1
- import { t as BodyComponent } from "../body.component-_VDOpJhV.mjs";
2
- export { BodyComponent };
@@ -1,2 +0,0 @@
1
- import { t as ColumnComponent } from "../column.component-Bx46r3JI.mjs";
2
- export { ColumnComponent };
@@ -1,2 +0,0 @@
1
- import { t as FooterComponent } from "../footer.component-Curiab8j.mjs";
2
- export { FooterComponent };
@@ -1,2 +0,0 @@
1
- import { i as updateGroup, n as removeGroup, r as renderGroup, t as GroupComponent } from "../group.component-Cq1YYbfJ.mjs";
2
- export { GroupComponent, removeGroup, renderGroup, updateGroup };
@@ -1,51 +0,0 @@
1
- import { CSS_TABELA_ROW, CSS_TABELA_ROW_GROUP } from "../models/style.model.mjs";
2
- import { createElement } from "../helpers/dom.helpers.mjs";
3
- import { getString } from "@oscarpalmer/atoms/string";
4
- //#region src/components/group.component.ts
5
- var GroupComponent = class {
6
- element;
7
- expanded = true;
8
- filtered = 0;
9
- key;
10
- selected = 0;
11
- total = 0;
12
- value;
13
- constructor(label, value) {
14
- this.label = label;
15
- const stringified = getString(value);
16
- this.key = `group:${stringified}`;
17
- this.value = {
18
- stringified,
19
- original: value
20
- };
21
- }
22
- };
23
- function removeGroup(group) {
24
- if (group.element == null) return;
25
- group.element.innerHTML = "";
26
- group.element.remove();
27
- }
28
- function renderGroup(state, component) {
29
- component.element ??= createElement("div", {
30
- className: `${CSS_TABELA_ROW} ${CSS_TABELA_ROW_GROUP}`,
31
- innerHTML: `<div class="tabela__cell tabela__cell--group" role="cell">
32
- <button class="tabela__button tabela__button--group" data-event="group" data-key="tabela_${state.id}_${component.key}" type="button">
33
- <span aria-hidden="true"></span>
34
- <span>Open/close</span>
35
- </button>
36
- <p>${component.label}</p>
37
- <span class="tabela__group__total">${component.total}</span>
38
- <span class="tabela__group__selected">${component.selected === 0 ? "" : component.selected}</span>
39
- </div>`,
40
- role: "row"
41
- }, {}, { height: `${state.options.rowHeight}px` });
42
- }
43
- function updateGroup(state, component) {
44
- if (component.element == null) return;
45
- const selected = component.element.querySelector(".tabela__group__selected");
46
- const total = component.element.querySelector(".tabela__group__total");
47
- if (selected != null) selected.textContent = component.selected === 0 ? "" : String(component.selected);
48
- if (total != null) total.textContent = String(component.total);
49
- }
50
- //#endregion
51
- export { GroupComponent, removeGroup, renderGroup, updateGroup };
@@ -1,2 +0,0 @@
1
- import { t as HeaderComponent } from "../header.component-BjjlpZIg.mjs";
2
- export { HeaderComponent };
@@ -1,2 +0,0 @@
1
- import { h as renderRow, m as removeRow, p as RowComponent } from "../group.component-Cq1YYbfJ.mjs";
2
- export { RowComponent, removeRow, renderRow };
@@ -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 };
@@ -1,8 +0,0 @@
1
- //#region src/models/footer.model.d.ts
2
- type FooterElements = {
3
- cells: HTMLDivElement[];
4
- group: HTMLDivElement;
5
- row: HTMLDivElement;
6
- };
7
- //#endregion
8
- export { FooterElements as t };