libey-ng-component-library 0.0.32 → 0.0.34

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 (69) hide show
  1. package/karma.conf.js +44 -0
  2. package/ng-package.json +13 -0
  3. package/package.json +17 -24
  4. package/src/lib/cpm-indicator/libey-ng-cpm-indicator.component.css +216 -0
  5. package/src/lib/cpm-indicator/libey-ng-cpm-indicator.component.html +201 -0
  6. package/src/lib/cpm-indicator/libey-ng-cpm-indicator.component.spec.ts +25 -0
  7. package/src/lib/cpm-indicator/libey-ng-cpm-indicator.component.ts +203 -0
  8. package/src/lib/cpm-indicator/libey-ng-cpm-indicator.module.ts +19 -0
  9. package/src/lib/icons/icons.component.css +9 -0
  10. package/src/lib/icons/icons.module.ts +16 -0
  11. package/src/lib/icons/libey-ng-icons/libey-ng-icons.component.html +1831 -0
  12. package/src/lib/icons/libey-ng-icons/libey-ng-icons.component.ts +36 -0
  13. package/src/lib/libey-ng-component-library.component.spec.ts +25 -0
  14. package/src/lib/libey-ng-component-library.component.ts +20 -0
  15. package/src/lib/libey-ng-component-library.module.ts +32 -0
  16. package/src/lib/libey-ng-component-library.service.spec.ts +16 -0
  17. package/src/lib/libey-ng-component-library.service.ts +9 -0
  18. package/src/lib/signature/libey-ng-signature/libey-ng-signature.component.css +7 -0
  19. package/src/lib/signature/libey-ng-signature/libey-ng-signature.component.html +41 -0
  20. package/src/lib/signature/libey-ng-signature/libey-ng-signature.component.spec.ts +25 -0
  21. package/src/lib/signature/libey-ng-signature/libey-ng-signature.component.ts +214 -0
  22. package/src/lib/signature/libey-ng-signature.module.ts +30 -0
  23. package/src/lib/table/directives/libey-column.directive.ts +29 -0
  24. package/src/lib/table/libey-ng-table.component.css +249 -0
  25. package/src/lib/table/libey-ng-table.component.html +122 -0
  26. package/src/lib/table/libey-ng-table.component.ts +234 -0
  27. package/src/lib/table/libey-ng-table.module.ts +13 -0
  28. package/{public-api.d.ts → src/public-api.ts} +4 -0
  29. package/src/test.ts +28 -0
  30. package/src/utils/CpmIndicator/cpm-indicator-types.ts +63 -0
  31. package/src/utils/SigWeb/SigWeb.ts +1906 -0
  32. package/tsconfig.lib.json +20 -0
  33. package/tsconfig.lib.prod.json +10 -0
  34. package/tsconfig.spec.json +17 -0
  35. package/bundles/libey-ng-component-library.umd.js +0 -2497
  36. package/bundles/libey-ng-component-library.umd.js.map +0 -1
  37. package/esm2015/lib/cpm-indicator/libey-ng-cpm-indicator.component.js +0 -193
  38. package/esm2015/lib/cpm-indicator/libey-ng-cpm-indicator.module.js +0 -26
  39. package/esm2015/lib/icons/icons.module.js +0 -26
  40. package/esm2015/lib/icons/libey-ng-icons/libey-ng-icons.component.js +0 -52
  41. package/esm2015/lib/libey-ng-component-library.component.js +0 -26
  42. package/esm2015/lib/libey-ng-component-library.module.js +0 -60
  43. package/esm2015/lib/libey-ng-component-library.service.js +0 -14
  44. package/esm2015/lib/signature/libey-ng-signature/libey-ng-signature.component.js +0 -197
  45. package/esm2015/lib/signature/libey-ng-signature.module.js +0 -57
  46. package/esm2015/lib/table/directives/libey-column.directive.js +0 -56
  47. package/esm2015/lib/table/libey-ng-table.component.js +0 -229
  48. package/esm2015/lib/table/libey-ng-table.module.js +0 -21
  49. package/esm2015/libey-ng-component-library.js +0 -5
  50. package/esm2015/public-api.js +0 -23
  51. package/esm2015/utils/CpmIndicator/cpm-indicator-types.js +0 -25
  52. package/esm2015/utils/SigWeb/SigWeb.js +0 -1442
  53. package/fesm2015/libey-ng-component-library.js +0 -2393
  54. package/fesm2015/libey-ng-component-library.js.map +0 -1
  55. package/lib/cpm-indicator/libey-ng-cpm-indicator.component.d.ts +0 -66
  56. package/lib/cpm-indicator/libey-ng-cpm-indicator.module.d.ts +0 -8
  57. package/lib/icons/icons.module.d.ts +0 -8
  58. package/lib/icons/libey-ng-icons/libey-ng-icons.component.d.ts +0 -19
  59. package/lib/libey-ng-component-library.component.d.ts +0 -8
  60. package/lib/libey-ng-component-library.module.d.ts +0 -13
  61. package/lib/libey-ng-component-library.service.d.ts +0 -6
  62. package/lib/signature/libey-ng-signature/libey-ng-signature.component.d.ts +0 -40
  63. package/lib/signature/libey-ng-signature.module.d.ts +0 -13
  64. package/lib/table/directives/libey-column.directive.d.ts +0 -23
  65. package/lib/table/libey-ng-table.component.d.ts +0 -63
  66. package/lib/table/libey-ng-table.module.d.ts +0 -10
  67. package/libey-ng-component-library.d.ts +0 -5
  68. package/utils/CpmIndicator/cpm-indicator-types.d.ts +0 -40
  69. package/utils/SigWeb/SigWeb.d.ts +0 -219
@@ -0,0 +1,249 @@
1
+ .libey-table {
2
+ table {
3
+ font-size: 1.077rem;
4
+ width: 100%;
5
+ border-collapse: separate;
6
+ border-spacing: 0;
7
+ table-layout: fixed;
8
+ }
9
+
10
+ .table-container {
11
+ width: 100%;
12
+ overflow-x: auto;
13
+ }
14
+ td, th {
15
+ height: 30px;
16
+ text-align: left;
17
+ position: relative;
18
+ overflow: hidden;
19
+ vertical-align: middle;
20
+ }
21
+ th {
22
+ padding: 0rem 1rem;
23
+ }
24
+ /* NO FUNCIONA PARA ICONOS DE "NO SE PRESENTÓ" */
25
+ /* td lib-libey-ng-icons {
26
+ height: 30px;
27
+ } */
28
+ th {
29
+ font-weight: 400;
30
+ color: #1087E8;
31
+ border-top: 0.077rem solid #D6DEE5;
32
+ background-color: #EEF5FC;
33
+ border-right: 0.077rem solid #fff;
34
+ }
35
+ th:last-child {
36
+ border-right: 0.077rem solid #D6DEE5;
37
+ }
38
+ td {
39
+ vertical-align: middle;
40
+ border-bottom: 0.077rem solid #D6DEE5;
41
+ border-style: none none solid none;
42
+ text-transform: uppercase;
43
+ padding: 0.2rem 1rem;
44
+ line-height: normal;
45
+ }
46
+
47
+ tr td:last-child {
48
+ border-right: 0.077rem solid #D6DEE5;
49
+ }
50
+ tr td:first-child {
51
+ border-left: 0.077rem solid #D6DEE5;
52
+ }
53
+
54
+ th.sortable {
55
+ cursor: pointer;
56
+ }
57
+
58
+ .th-fixed{
59
+ position: sticky !important;
60
+ top: 0 !important;
61
+ z-index: 1 !important;
62
+ }
63
+
64
+ .th-fixed::after {
65
+ content: '';
66
+ position: absolute;
67
+ left: 0;
68
+ bottom: 0;
69
+ width: 100%;
70
+ }
71
+
72
+ .table-actions {
73
+ margin-bottom: 0.769rem;
74
+ display: flex;
75
+ justify-content: space-between;
76
+ }
77
+ .table-pagination {
78
+ margin-top: 0.769rem;
79
+ display: flex;
80
+ justify-content: space-between;
81
+ }
82
+ .pagination-controls {
83
+ border-radius: 0.769rem;
84
+ justify-content: space-between;
85
+ border: 0.077rem solid #D6DEE5;
86
+ padding: 0 1.154rem;
87
+ display: flex;
88
+ align-items: center;
89
+ margin-top: 0.769rem;
90
+ gap: 0.385rem;
91
+ height: 2.308rem;
92
+ }
93
+ button {
94
+ font-size: 1.077rem;
95
+ border: 0.077rem solid transparent;
96
+ border-radius: 0.308rem;
97
+ cursor: pointer;
98
+ min-width: 1.692rem;
99
+ margin: 0.077rem;
100
+ justify-content: center;
101
+ height: 1.692rem;
102
+ background-color: transparent;
103
+ padding: 0 0.231rem;
104
+ display: flex;
105
+ justify-content: center;
106
+ align-items: center;
107
+ }
108
+ button.active {
109
+ border: 0.077rem solid #38E8C6;
110
+ background-color: #38E8C6;
111
+ font-weight: 600;
112
+ color: #FFF;
113
+ }
114
+ button:disabled {
115
+ cursor: default;
116
+ }
117
+
118
+ button:hover.numbers {
119
+ border: 0.077rem solid #38E8C6 !important;
120
+ border-radius: 0.308rem;
121
+ }
122
+
123
+ tr:first-child th:first-child {
124
+ border-top-left-radius: 0.769rem;
125
+ border-left: 0.077rem solid #D6DEE5;
126
+ }
127
+ tr:first-child th:last-child {
128
+ border-top-right-radius: 0.769rem;
129
+ border-right: 0.077rem solid #D6DEE5;
130
+ }
131
+
132
+ tr:last-child td:first-child {
133
+ border-bottom-left-radius: 0.769rem;
134
+ }
135
+ tr:last-child td:last-child {
136
+ border-bottom-right-radius: 0.769rem;
137
+ }
138
+
139
+ .d-align-center {
140
+ display: flex !important;
141
+ align-items: center !important;
142
+ }
143
+
144
+ .me-20px{
145
+ margin-right: 1.538rem;
146
+ }
147
+
148
+ /* BOTONES GENERALES */
149
+
150
+
151
+ /* ICONOS DE PAGINACION */
152
+ .icon-first-page {
153
+ background-repeat: no-repeat;
154
+ display: block;
155
+ width: 0.923rem;
156
+ height: 0.769rem;
157
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10.0922 0.292893C10.4827 -0.0976311 11.1159 -0.0976311 11.5064 0.292893C11.8969 0.683417 11.8969 1.31658 11.5064 1.70711L8.21353 5L11.5064 8.29289C11.8969 8.68342 11.8969 9.31658 11.5064 9.70711C11.1159 10.0976 10.4827 10.0976 10.0922 9.70711L6.09221 5.70711C5.70169 5.31658 5.70169 4.68342 6.09221 4.29289L10.0922 0.292893ZM4.49211 0.292893C4.88264 -0.0976311 5.5158 -0.0976311 5.90633 0.292893C6.29685 0.683417 6.29685 1.31658 5.90633 1.70711L2.61343 5L5.90633 8.29289C6.29685 8.68342 6.29685 9.31658 5.90633 9.70711C5.5158 10.0976 4.88264 10.0976 4.49211 9.70711L0.492111 5.70711C0.101587 5.31658 0.101587 4.68342 0.492111 4.29289L4.49211 0.292893Z' fill='%2338E8C6'/%3E%3C/svg%3E%0A");
158
+ }
159
+ button:disabled .icon-first-page {
160
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10.0922 0.292893C10.4827 -0.0976311 11.1159 -0.0976311 11.5064 0.292893C11.8969 0.683417 11.8969 1.31658 11.5064 1.70711L8.21353 5L11.5064 8.29289C11.8969 8.68342 11.8969 9.31658 11.5064 9.70711C11.1159 10.0976 10.4827 10.0976 10.0922 9.70711L6.09221 5.70711C5.70169 5.31658 5.70169 4.68342 6.09221 4.29289L10.0922 0.292893ZM4.49211 0.292893C4.88264 -0.0976311 5.5158 -0.0976311 5.90633 0.292893C6.29685 0.683417 6.29685 1.31658 5.90633 1.70711L2.61343 5L5.90633 8.29289C6.29685 8.68342 6.29685 9.31658 5.90633 9.70711C5.5158 10.0976 4.88264 10.0976 4.49211 9.70711L0.492111 5.70711C0.101587 5.31658 0.101587 4.68342 0.492111 4.29289L4.49211 0.292893Z' fill='%23D0D0D0'/%3E%3C/svg%3E%0A");
161
+ }
162
+
163
+ .icon-previous-page {
164
+ background-repeat: no-repeat;
165
+ display: block;
166
+ width: 0.538rem;
167
+ height: 0.769rem;
168
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 7 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M5.90681 0.292893C6.29734 0.683417 6.29734 1.31658 5.90681 1.70711L2.61392 5L5.90681 8.29289C6.29734 8.68342 6.29734 9.31658 5.90681 9.70711C5.51629 10.0976 4.88312 10.0976 4.4926 9.70711L0.4926 5.70711C0.102076 5.31658 0.102076 4.68342 0.4926 4.29289L4.4926 0.292893C4.88312 -0.0976311 5.51629 -0.0976311 5.90681 0.292893Z' fill='%2338E8C6'/%3E%3C/svg%3E%0A");
169
+ }
170
+ button:disabled .icon-previous-page {
171
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 7 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M5.90681 0.292893C6.29734 0.683417 6.29734 1.31658 5.90681 1.70711L2.61392 5L5.90681 8.29289C6.29734 8.68342 6.29734 9.31658 5.90681 9.70711C5.51629 10.0976 4.88312 10.0976 4.4926 9.70711L0.4926 5.70711C0.102076 5.31658 0.102076 4.68342 0.4926 4.29289L4.4926 0.292893C4.88312 -0.0976311 5.51629 -0.0976311 5.90681 0.292893Z' fill='%23D0D0D0'/%3E%3C/svg%3E%0A");
172
+ }
173
+
174
+ .icon-next-page {
175
+ background-repeat: no-repeat;
176
+ display: block;
177
+ width: 0.538rem;
178
+ height: 0.769rem;
179
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 7 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0.4926 0.292893C0.102076 0.683417 0.102076 1.31658 0.4926 1.70711L3.78549 5L0.4926 8.29289C0.102076 8.68342 0.102076 9.31658 0.4926 9.70711C0.883124 10.0976 1.51629 10.0976 1.90681 9.70711L5.90681 5.70711C6.29734 5.31658 6.29734 4.68342 5.90681 4.29289L1.90681 0.292893C1.51629 -0.0976311 0.883124 -0.0976311 0.4926 0.292893Z' fill='%2338E8C6'/%3E%3C/svg%3E%0A");
180
+ }
181
+ button:disabled .icon-next-page {
182
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 7 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0.4926 0.292893C0.102076 0.683417 0.102076 1.31658 0.4926 1.70711L3.78549 5L0.4926 8.29289C0.102076 8.68342 0.102076 9.31658 0.4926 9.70711C0.883124 10.0976 1.51629 10.0976 1.90681 9.70711L5.90681 5.70711C6.29734 5.31658 6.29734 4.68342 5.90681 4.29289L1.90681 0.292893C1.51629 -0.0976311 0.883124 -0.0976311 0.4926 0.292893Z' fill='%23D0D0D0'/%3E%3C/svg%3E%0A");
183
+ }
184
+
185
+ .icon-last-page {
186
+ background-repeat: no-repeat;
187
+ display: block;
188
+ width: 0.923rem;
189
+ height: 0.769rem;
190
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M2.10701 0.292893C1.71648 -0.0976311 1.08332 -0.0976311 0.692796 0.292893C0.302271 0.683417 0.302271 1.31658 0.692796 1.70711L3.98569 5L0.692796 8.29289C0.302271 8.68342 0.302271 9.31658 0.692796 9.70711C1.08332 10.0976 1.71648 10.0976 2.10701 9.70711L6.10701 5.70711C6.49753 5.31658 6.49753 4.68342 6.10701 4.29289L2.10701 0.292893ZM7.70711 0.292893C7.31658 -0.0976311 6.68342 -0.0976311 6.29289 0.292893C5.90237 0.683417 5.90237 1.31658 6.29289 1.70711L9.58579 5L6.29289 8.29289C5.90237 8.68342 5.90237 9.31658 6.29289 9.70711C6.68342 10.0976 7.31658 10.0976 7.70711 9.70711L11.7071 5.70711C12.0976 5.31658 12.0976 4.68342 11.7071 4.29289L7.70711 0.292893Z' fill='%2338E8C6'/%3E%3C/svg%3E%0A");
191
+ }
192
+ button:disabled .icon-last-page {
193
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 12 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M2.10701 0.292893C1.71648 -0.0976311 1.08332 -0.0976311 0.692796 0.292893C0.302271 0.683417 0.302271 1.31658 0.692796 1.70711L3.98569 5L0.692796 8.29289C0.302271 8.68342 0.302271 9.31658 0.692796 9.70711C1.08332 10.0976 1.71648 10.0976 2.10701 9.70711L6.10701 5.70711C6.49753 5.31658 6.49753 4.68342 6.10701 4.29289L2.10701 0.292893ZM7.70711 0.292893C7.31658 -0.0976311 6.68342 -0.0976311 6.29289 0.292893C5.90237 0.683417 5.90237 1.31658 6.29289 1.70711L9.58579 5L6.29289 8.29289C5.90237 8.68342 5.90237 9.31658 6.29289 9.70711C6.68342 10.0976 7.31658 10.0976 7.70711 9.70711L11.7071 5.70711C12.0976 5.31658 12.0976 4.68342 11.7071 4.29289L7.70711 0.292893Z' fill='%23D0D0D0'/%3E%3C/svg%3E%0A");
194
+ }
195
+
196
+ .resize-handle {
197
+ position: absolute;
198
+ right: 0;
199
+ top: 0;
200
+ bottom: 0;
201
+ width: 0.385rem;
202
+ cursor: col-resize;
203
+ background-color: transparent;
204
+ }
205
+
206
+ /* DISEÑO SCROLL */
207
+ ::-webkit-scrollbar {
208
+ width: 0.7rem;
209
+ height: 0.7rem;
210
+ }
211
+
212
+ ::-webkit-scrollbar-thumb {
213
+ background-color: #d9d9d9 !important; /* color of the scroll thumb */
214
+ border-radius: 1.538rem !important; /* roundness of the scroll thumb */
215
+ border: 0.231rem solid #d9d9d9 !important; /* creates padding around scroll thumb */
216
+ }
217
+
218
+ /* ICONOS */
219
+ .icon-arrow-up {
220
+ background-repeat: no-repeat;
221
+ display: block;
222
+ width: 0.923rem;
223
+ height: 0.615rem;
224
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 19 10' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M0.347794 9.61517C0.825615 10.1134 1.6169 10.13 2.11517 9.65221L9.07106 2.98186L16.0269 9.65221C16.5252 10.13 17.3165 10.1134 17.7943 9.61517C18.2721 9.11689 18.2556 8.32561 17.7573 7.84779L9.93623 0.347793C9.45266 -0.115931 8.68946 -0.115931 8.20589 0.347793L0.38483 7.84779C-0.113445 8.32561 -0.130027 9.11689 0.347794 9.61517Z' fill='%23224051'/%3E%3C/svg%3E%0A");
225
+ }
226
+
227
+ .icon-arrow-down {
228
+ background-repeat: no-repeat;
229
+ display: block;
230
+ width: 0.923rem;
231
+ height: 0.615rem;
232
+ background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 18 11' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M17.6234 0.387653C17.1213 -0.129218 16.3073 -0.129218 15.8051 0.387653L9 7.39295L2.19485 0.387652C1.69275 -0.129219 0.878679 -0.129219 0.376577 0.387651C-0.125527 0.904522 -0.125527 1.74253 0.376577 2.25941L8.09086 10.2006C8.59296 10.7175 9.40703 10.7175 9.90914 10.2006L17.6234 2.25941C18.1255 1.74254 18.1255 0.904523 17.6234 0.387653Z' fill='%23224051'/%3E%3C/svg%3E%0A");
233
+ }
234
+
235
+ .text-center {
236
+ text-align: center !important;
237
+ }
238
+
239
+ .cursor-pointer{
240
+ cursor: pointer;
241
+ }
242
+ }
243
+
244
+ button:disabled svg path {
245
+ fill: #ABBED1 !important;
246
+ }
247
+ button:disabled svg rect {
248
+ fill: transparent !important;
249
+ }
@@ -0,0 +1,122 @@
1
+ <div class="table-container" #tableContainer [style.height]="height == null ? 'auto':(height + 'px')">
2
+ <!-- <table cdkDropList (cdkDropListDropped)="drop($event)"> -->
3
+ <table #table [ngClass]="class">
4
+ <thead>
5
+ <tr>
6
+ <th *ngIf="expandable" [ngClass]="headerfixed == true ? 'th-fixed':''" style="width: 25px;"></th>
7
+ <ng-container *ngFor="let column of columns; let i = index">
8
+ <th *ngIf="column.view" [style.width]="column.width ? (column.width + 'px') : 'auto'"
9
+ [ngClass]="headerfixed == true ? (column.classHeader + ' th-fixed'): column.classHeader">
10
+ <!-- Custom header template -->
11
+ <ng-container *ngIf="column.headerTemplate; else defaultHeader">
12
+ <ng-container [ngTemplateOutlet]="column.headerTemplate"
13
+ [ngTemplateOutletContext]="{ column: column, index: i }">
14
+ </ng-container>
15
+ </ng-container>
16
+ <ng-template #defaultHeader>
17
+ <span style="white-space: nowrap;">{{ column.header }}</span>
18
+ </ng-template>
19
+ <div class="resize-handle" (mousedown)="onResizeStart(i, $event)"></div>
20
+ </th>
21
+ </ng-container>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <ng-container *ngIf="_data.length == 0">
26
+ <tr>
27
+ <td [colSpan]="expandable ? (columns.length + 1) : (columns.length)" class="text-center">
28
+ No existen datos disponibles
29
+ </td>
30
+ </tr>
31
+ </ng-container>
32
+ <ng-container *ngIf="paginatedData.length != 0">
33
+ <ng-container *ngFor="let item of paginatedData; let a = index">
34
+ <tr>
35
+ <td *ngIf="expandable">
36
+ <button (click)="toggleRow(a)">
37
+ <i [ngClass]="rowExpandable[a] ? 'icon-arrow-up':'icon-arrow-down'"></i>
38
+ </button>
39
+ </td>
40
+ <ng-container *ngFor="let column of columns; let i = index">
41
+ <td
42
+ *ngIf="column.view && (column.isRowspan && column.rowspan(item) > 0)"
43
+ [attr.rowspan]="column.rowspan(item)"
44
+ [ngClass]="column.class" (click)="toggleRowDetail(i, a, column, item)" [class]="column.expandable ? 'cursor-pointer': ''">
45
+ <ng-container
46
+ [ngTemplateOutlet]="detailTd"
47
+ [ngTemplateOutletContext]="{item:item, column:column, indexData:a, indexColumn:i}">
48
+ </ng-container>
49
+ </td>
50
+ <td
51
+ *ngIf="column.view && column.isRowspan != true"
52
+ [ngClass]="column.class" (click)="toggleRowDetail(i, a, column, item)" [class]="column.expandable ? 'cursor-pointer': ''">
53
+ <ng-container
54
+ [ngTemplateOutlet]="detailTd"
55
+ [ngTemplateOutletContext]="{item:item, column:column, indexData:a, indexColumn:i}">
56
+ </ng-container>
57
+ </td>
58
+ </ng-container>
59
+ </tr>
60
+ <ng-container *ngIf="viewRowExpandableDetail(a)">
61
+ <ng-container *ngTemplateOutlet="findRowExpandableDetail(a); context: { $implicit: item }"></ng-container>
62
+ </ng-container>
63
+ <tr *ngIf="rowExpandable[a]">
64
+ <td [attr.colspan]="columns.length + (expandable ? 1 : 0)">
65
+ <ng-container [ngTemplateOutlet]="childTableTemplate"
66
+ [ngTemplateOutletContext]="{ parentRow: item }">
67
+ </ng-container>
68
+ </td>
69
+ </tr>
70
+ </ng-container>
71
+ </ng-container>
72
+ </tbody>
73
+ </table>
74
+ </div>
75
+ <div *ngIf="viewPaginate && _data.length != 0" class="pagination-controls">
76
+ <div class="d-align-center">
77
+ <label class="lbl-footer me-20px"># Registros: {{this.totalSize}}</label>
78
+ <label class="lbl-footer"># Filas: {{this.pageSize}}</label>
79
+ </div>
80
+ <div class="d-align-center">
81
+ <button (click)="goToPage(1)" [disabled]="currentPage === 1">
82
+ <i class="icon-first-page"></i>
83
+ </button>
84
+ <button (click)="goToPage(currentPage - 1)" [disabled]="currentPage === 1">
85
+ <i class="icon-previous-page"></i>
86
+ </button>
87
+ <ng-container *ngFor="let page of pageRange()">
88
+ <button class="numbers"
89
+ (click)="goToPage(page)"
90
+ [class.active]="currentPage === page"
91
+ [disabled]="currentPage === page">
92
+ {{ page }}
93
+ </button>
94
+ </ng-container>
95
+ <button (click)="goToPage(currentPage + 1)" [disabled]="currentPage === totalPages">
96
+ <i class="icon-next-page"></i>
97
+ </button>
98
+ <button (click)="goToPage(totalPages)" [disabled]="currentPage === totalPages">
99
+ <i class="icon-last-page"></i>
100
+ </button>
101
+ </div>
102
+ </div>
103
+ <ng-template #detailTd let-item="item" let-column="column" let-indexData="indexData" let-indexColumn="indexColumn">
104
+ <ng-container *ngIf="column.getCellTemplate(); else defaultCell">
105
+ <div style="display: flex; justify-content: space-between; white-space: nowrap; align-items: center;">
106
+ <ng-container [ngTemplateOutlet]="column.getCellTemplate()"
107
+ [ngTemplateOutletContext]="{ $implicit: item, column: column, index: indexData }">
108
+ </ng-container>
109
+ <button *ngIf="column.expandable">
110
+ <i [ngClass]="existRowExpandableDetail(indexColumn, indexData) ? 'icon-arrow-up':'icon-arrow-down'"></i>
111
+ </button>
112
+ </div>
113
+ </ng-container>
114
+ <ng-template #defaultCell>
115
+ <div style="display: flex; justify-content: space-between; white-space: nowrap; align-items: center;">
116
+ {{ getCellValue(item, column) }}
117
+ <button *ngIf="column.expandable">
118
+ <i [ngClass]="existRowExpandableDetail(indexColumn, indexData) ? 'icon-arrow-up':'icon-arrow-down'"></i>
119
+ </button>
120
+ </div>
121
+ </ng-template>
122
+ </ng-template>
@@ -0,0 +1,234 @@
1
+ import { AfterViewInit, ChangeDetectorRef, Component, ContentChildren, ElementRef, EventEmitter, Input, OnChanges, OnInit, Output, QueryList, SimpleChanges, TemplateRef, ViewChild, ViewEncapsulation } from '@angular/core';
2
+ import { LibeyColumnDirective } from './directives/libey-column.directive';
3
+ interface IDataKey {
4
+ key: number;
5
+ dataKey: number;
6
+ childTableTemplate: TemplateRef<any>;
7
+ data: any[];
8
+ autoClose: boolean;
9
+ }
10
+
11
+ class DataKey implements IDataKey {
12
+ key: number;
13
+ dataKey: number;
14
+ childTableTemplate: TemplateRef<any>;
15
+ data: any[];
16
+ autoClose: boolean;
17
+ rowspan: number;
18
+ }
19
+
20
+ @Component({
21
+ selector: 'libey-ng-table',
22
+ templateUrl: './libey-ng-table.component.html',
23
+ styleUrls: ['./libey-ng-table.component.css'],
24
+ encapsulation: ViewEncapsulation.None
25
+ })
26
+
27
+ export class LibeyNgTableComponent implements OnInit, AfterViewInit, OnChanges {
28
+ @Input() set data(value: any[]) {
29
+ this._data = value;
30
+ }
31
+ get data(): any[] {
32
+ return this._data;
33
+ }
34
+ @Input() pageSize: number = 10;
35
+ @Input() totalSize: number = 0;
36
+ @Input() maxPageButtons: number = 5;
37
+ @Input() height: number;
38
+ @Input() expandable: boolean = false;
39
+ @Input() viewPaginate: boolean = true;
40
+ @Input() childTableTemplate!: TemplateRef<any>;
41
+ @Input() headerfixed: boolean = false;
42
+ @Input() class: string;
43
+ @Input() internalPagination: boolean = true;
44
+ @Input() currentPage: number = 1;
45
+ @Output() pageChange = new EventEmitter<number>();
46
+
47
+ @ContentChildren(LibeyColumnDirective) columns!: QueryList<LibeyColumnDirective>;
48
+
49
+ rowExpandable: boolean[] = [];
50
+ rowExpandableDetail: IDataKey[] = [];
51
+ paginatedData: any[] = [];
52
+ _data: any[] = [];
53
+ columnWidths: number[] = [];
54
+ resizingColumnIndex: number | null = null;
55
+ startX: number = 0;
56
+ startWidth: number = 0;
57
+ @ViewChild('tableContainer') tableContainer!: ElementRef;
58
+ @ViewChild('table') tableElement!: ElementRef;
59
+ constructor(private cdr: ChangeDetectorRef) {}
60
+ ngOnChanges(changes: SimpleChanges): void {
61
+ if(changes.data && changes.data.previousValue){
62
+ changes.data.currentValue.forEach((value, index) => {
63
+ var findData = this.rowExpandableDetail.find(x => x.dataKey == index);
64
+ if(findData != null)
65
+ findData.autoClose = value.autoClose;
66
+ });
67
+ this._data = changes.data.currentValue;
68
+ this.updatePaginatedData();
69
+ if(this.columns){
70
+ this.initializeExpandedRows();
71
+ }
72
+ }
73
+ }
74
+ ngOnInit(): void {
75
+ this.updatePaginatedData();
76
+ }
77
+ ngAfterViewInit() {
78
+ this.initializeColumnWidths();
79
+ this.initializeExpandedRows();
80
+ // this.adjustTableWidth()
81
+ this.cdr.detectChanges();
82
+ }
83
+
84
+ private initializeExpandedRows(): void {
85
+ this.columns.forEach((column, columnIndex) => {
86
+ if(column.expandable){
87
+ this.paginatedData.forEach((item, rowIndex) => {
88
+ if(column.expandedByDefault(item) && !this.existRowExpandableDetail(columnIndex, rowIndex)){
89
+ var entry = new DataKey();
90
+ entry.key = columnIndex;
91
+ entry.dataKey = rowIndex;
92
+ entry.childTableTemplate = column.childTableTemplate;
93
+ entry.autoClose = column.isAutoClose(item);
94
+ this.rowExpandableDetail.push(entry);
95
+ }
96
+ });
97
+ }
98
+ });
99
+ }
100
+
101
+ initializeColumnWidths() {
102
+ var padding = 31
103
+ var widthDefault = 150
104
+ this.columnWidths = this.columns.map(column => column.width);
105
+ const containerWidth = this.tableContainer.nativeElement.offsetWidth;
106
+ const autoColumns = this.columns.filter(column => column.width == null);
107
+ const totalFixedWidth = this.columns.reduce((sum, column) =>
108
+ column.width != null ? (sum + this.getWidthValue(column.width)) : sum, 0);
109
+ const remainingWidth = containerWidth - (totalFixedWidth + (((this.columns.length - autoColumns.length) * padding)+ (this.expandable ? 61 : 0)));
110
+
111
+ if (autoColumns.length > 0) {
112
+ var autoColumnWidth = 0;
113
+ if(remainingWidth < widthDefault)
114
+ autoColumnWidth = widthDefault;
115
+ else
116
+ autoColumnWidth = Math.max(0, remainingWidth / autoColumns.length);
117
+ autoColumns.forEach(column => column.width = autoColumnWidth- padding);
118
+ }
119
+ this.columnWidths = this.columns.map(column => column.width);
120
+ }
121
+ // adjustTableWidth() {
122
+ // const totalWidth = this.columns.reduce((sum, column) => sum + this.getWidthValue(column.width), 0);
123
+ // this.tableElement.nativeElement.style.width = `${totalWidth}px`;
124
+ // }
125
+ getWidthValue(width: number): number {
126
+ return width === null ? 100 : width;
127
+ }
128
+
129
+ get totalPages(): number {
130
+ return Math.ceil(this.totalSize / this.pageSize);
131
+ }
132
+
133
+ getCellValue(item: any, column: LibeyColumnDirective): string {
134
+ const value = this.getNestedValue(item, column.property);
135
+ if (Array.isArray(value) && column.arrayMap) {
136
+ return value.map(v => this.getNestedValue(v, column.arrayMap!)).join(', ');
137
+ }
138
+ return value;
139
+ }
140
+
141
+ private getNestedValue(obj: any, path: string): any {
142
+ return path.split('.').reduce((o, key) => {
143
+ if (o && typeof o === 'object' && key in o) {
144
+ return o[key];
145
+ }
146
+ return undefined;
147
+ }, obj);
148
+ }
149
+
150
+ private updatePaginatedData(): void {
151
+ if(this.viewPaginate && this.internalPagination){
152
+ const start = (this.currentPage - 1) * this.pageSize;
153
+ const end = start + this.pageSize;
154
+ this.paginatedData = this.data.slice(start, end);
155
+ }else{
156
+ this.paginatedData = this.data;
157
+ }
158
+ }
159
+ pageRange(): number[] {
160
+ const start = Math.max(1, this.currentPage - Math.floor(this.maxPageButtons / 2));
161
+ const end = Math.min(this.totalPages, start + this.maxPageButtons - 1);
162
+ const startPreFinish = end - this.maxPageButtons + 1;
163
+ const startFinish = startPreFinish < 1 ? 1 : startPreFinish;
164
+ return Array.from({length: end - startFinish + 1}, (_, i) => startFinish + i);
165
+ }
166
+ goToPage(page: number): void {
167
+ this.currentPage = Math.max(1, Math.min(page, this.totalPages));
168
+ if(this.internalPagination){
169
+ this.updatePaginatedData();
170
+ }else{
171
+ this.pageChange.emit(this.currentPage);
172
+ }
173
+ }
174
+ // hasChildren(row: any): boolean{
175
+ // return Array.isArray(row.child) && row.child.length > 0;
176
+ // }
177
+ toggleRow(index: number){
178
+ this.rowExpandable[index] = !this.rowExpandable[index];
179
+ }
180
+ toggleRowDetail(key: number, indexData: number, column: LibeyColumnDirective, data: any){
181
+ if(column.expandable){
182
+ var exist = this.rowExpandableDetail.find(x => x.key == key && x.dataKey == indexData);
183
+ if(exist == null){
184
+ this.rowExpandableDetail = this.rowExpandableDetail.filter(x => (x.key != key || x.dataKey != indexData) && x.autoClose == false);
185
+ var item = new DataKey();
186
+ item.key = key;
187
+ item.dataKey = indexData;
188
+ item.childTableTemplate = column.childTableTemplate;
189
+ item.autoClose = column.isAutoClose(data);
190
+ this.rowExpandableDetail.push(item);
191
+ }else{
192
+ this.rowExpandableDetail = this.rowExpandableDetail.filter(x => x.key != key || x.dataKey != indexData);
193
+ }
194
+ }
195
+ }
196
+ getChildren(fila: any): any[] {
197
+ return fila.hijos || [];
198
+ }
199
+ onResizeStart(index: number, event: MouseEvent) {
200
+ this.resizingColumnIndex = index;
201
+ this.startX = event.pageX;
202
+ this.startWidth = this.columnWidths[index];
203
+ document.addEventListener('mousemove', this.onResizeMove);
204
+ document.addEventListener('mouseup', this.onResizeEnd);
205
+ }
206
+ onResizeMove = (event: MouseEvent) => {
207
+ if (this.resizingColumnIndex !== null) {
208
+ const diff = event.pageX - this.startX;
209
+ this.columnWidths[this.resizingColumnIndex] = Math.max(this.startWidth + diff, 50);
210
+
211
+ }
212
+ }
213
+ onResizeEnd = () => {
214
+ this.resizingColumnIndex = null;
215
+ document.removeEventListener('mousemove', this.onResizeMove);
216
+ document.removeEventListener('mouseup', this.onResizeEnd);
217
+ }
218
+ existRowExpandableDetail(key: number, indexData: number) : boolean{
219
+ return this.rowExpandableDetail.filter(x => x.key == key && x.dataKey == indexData).length > 0;
220
+ }
221
+ viewRowExpandableDetail(indexData: number) :boolean{
222
+ return this.rowExpandableDetail.filter(x => x.dataKey == indexData).length > 0;
223
+ }
224
+ findRowExpandableDetail(indexData: number) :TemplateRef<any>{
225
+ var find = this.rowExpandableDetail.find(x => x.dataKey == indexData);
226
+ if(find)
227
+ return find.childTableTemplate;
228
+ else
229
+ return null;
230
+ }
231
+ getRowSpan(column: LibeyColumnDirective, data: any){
232
+ return column.rowspan(data);
233
+ }
234
+ }
@@ -0,0 +1,13 @@
1
+ // table.module.ts
2
+ import { NgModule } from '@angular/core';
3
+ import { CommonModule } from '@angular/common';
4
+ import { LibeyColumnDirective } from './directives/libey-column.directive';
5
+ import { FormsModule } from '@angular/forms';
6
+ import { LibeyNgTableComponent } from './libey-ng-table.component';
7
+
8
+ @NgModule({
9
+ declarations: [LibeyNgTableComponent, LibeyColumnDirective],
10
+ imports: [CommonModule,FormsModule],
11
+ exports: [LibeyNgTableComponent, LibeyColumnDirective]
12
+ })
13
+ export class LibeyNgTableModule { }
@@ -1,3 +1,7 @@
1
+ /*
2
+ * Public API Surface of libey-ng-component-library
3
+ */
4
+
1
5
  export * from './lib/libey-ng-component-library.service';
2
6
  export * from './lib/libey-ng-component-library.component';
3
7
  export * from './lib/libey-ng-component-library.module';
package/src/test.ts ADDED
@@ -0,0 +1,28 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js';
4
+ import 'zone.js/testing';
5
+ import { getTestBed } from '@angular/core/testing';
6
+ import {
7
+ BrowserDynamicTestingModule,
8
+ platformBrowserDynamicTesting
9
+ } from '@angular/platform-browser-dynamic/testing';
10
+
11
+ declare const require: {
12
+ context(path: string, deep?: boolean, filter?: RegExp): {
13
+ keys(): string[];
14
+ <T>(id: string): T;
15
+ };
16
+ };
17
+
18
+ // First, initialize the Angular testing environment.
19
+ getTestBed().initTestEnvironment(
20
+ BrowserDynamicTestingModule,
21
+ platformBrowserDynamicTesting(),
22
+ { teardown: { destroyAfterEach: true }},
23
+ );
24
+
25
+ // Then we find all the tests.
26
+ const context = require.context('./', true, /\.spec\.ts$/);
27
+ // And load the modules.
28
+ context.keys().map(context);