edvoyui-component-library-test-flight 0.0.164 → 0.0.166

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.
@@ -1,172 +1,189 @@
1
1
  <template>
2
2
  <div>
3
3
  <Transition name="fade" mode="out-in">
4
- <div
5
- v-if="loading"
6
- :class="[
7
- 'overflow-hidden relative z-0 isolate bg-white backdrop-blur transition-colors duration-150 ease-in-out rounded-xl border border-gray-50',
8
- tableHeight
9
- ? tableHeight
10
- : 'h-[calc(100svh-9rem)] max-h-[calc(100svh-9rem)]',
11
- ]"
12
- >
4
+ <template v-if="loading">
5
+ <slot name="loader" :loading="loading" :height="tableHeight">
6
+ <div
7
+ :class="[
8
+ 'overflow-hidden relative z-0 isolate bg-white backdrop-blur transition-colors duration-150 ease-in-out rounded-xl border border-gray-50',
9
+ tableHeight
10
+ ? tableHeight
11
+ : 'h-[calc(100svh-9rem)] max-h-[calc(100svh-9rem)]',
12
+ ]"
13
+ >
14
+ <div
15
+ class="absolute flex items-center z-[calc(infinity)] w-full h-auto pointer-events-none inset-0"
16
+ >
17
+ <EUICircleLoader />
18
+ </div>
19
+ </div>
20
+ </slot>
21
+ </template>
22
+
23
+ <div v-else class="relative w-full mx-auto overflow-hidden">
13
24
  <div
14
- class="absolute flex items-center z-[calc(infinity)] w-full h-auto pointer-events-none inset-0"
25
+ id="dashboard-table"
26
+ :class="[
27
+ 'scrollbar--thin overscroll-auto',
28
+ computedItems.length === 0 ? 'overflow-hidden' : 'overflow-auto',
29
+ tableHeight
30
+ ? tableHeight
31
+ : 'h-[calc(100svh-13rem)] max-h-[calc(100svh-13rem)]',
32
+ ]"
33
+ ref="tableContainer"
34
+ @scroll="handleScroll"
15
35
  >
16
- <EUICircleLoader />
17
- </div>
18
- </div>
19
- <div v-else class="relative w-full mx-auto overflow-hidden">
20
- <div
21
- id="dashboard-table"
22
- :class="['scrollbar--thin overscroll-auto',
23
- computedItems.length === 0 ? 'overflow-hidden' : 'overflow-auto', tableHeight ? tableHeight : 'h-[calc(100svh-13rem)] max-h-[calc(100svh-13rem)]']"
24
- ref="tableContainer"
25
- @scroll="handleScroll"
26
- >
27
- <table class="eui-table">
28
- <thead class="sticky top-0 left-0 z-50 bg-gray-100">
29
- <tr>
30
- <template v-if="checkable">
31
- <th class="checkable">
32
- <EUITableCheckbox
33
- :checked="isAllChecked"
34
- :indeterminate="isIndeterminate"
35
- :disabled="isAllUncheckable"
36
- class="flex justify-center mt-0"
37
- @change="checkAll()"
38
- />
39
- </th>
40
- </template>
41
- <th
42
- v-for="(header, headerIndex) in headers"
43
- :key="`item-${headerIndex}`"
44
- scope="col"
45
- :class="[
46
- 'px-3 py-2 text-gray-600 snap-start snap-always',
47
- isScrolled && headerIndex === 0 ? stickyClass.head : '',
48
- { 'cursor-pointer hover:text-gray-900': header?.sortable },
49
- ]"
50
- :style="
51
- header?.width
52
- ? `min-width:${header.width}px;max-width:${header.width}px;`
53
- : ``
54
- "
55
- @click="sortBy(header, $event)"
56
- >
57
- <div
58
- class="flex items-center gap-2 text-sm font-normal text-current"
59
- >
60
- <slot name="header" :header="header" :index="headerIndex">
61
- {{ capitalizeText(header?.text ?? header.name ?? "") }}
62
- </slot>
63
- <slot name="headerOptionalItem"></slot>
64
- <SortArrow
65
- v-if="header?.sortable"
66
- :class="[
67
- 'transform duration-100 transition-all',
68
- currentSort === header.value
69
- ? 'text-violet-700'
70
- : 'text-gray-900',
71
- sortClass(header),
72
- ]"
73
- />
74
- </div>
75
- </th>
76
- </tr>
77
- </thead>
78
- <tbody>
79
-
80
- <template
81
- v-if="computedItems.length > 0"
82
- v-for="(row, rowIndex) in computedItems"
83
- :key="`table-row-${rowIndex}`"
84
- >
85
- <tr
86
- @mouseenter="
87
- $attrs.mouseenter ? $emit('mouseenter', row, rowIndex) : null
88
- "
89
- @mouseleave="
90
- $attrs.mouseleave ? $emit('mouseleave', row, rowIndex) : null
91
- "
92
- >
36
+ <table class="eui-table">
37
+ <thead class="sticky top-0 left-0 z-50 bg-gray-100">
38
+ <tr>
93
39
  <template v-if="checkable">
94
- <td class="checkable">
40
+ <th class="checkable">
95
41
  <EUITableCheckbox
96
- :disabled="!isRowCheckable(row)"
97
- :checked="isRowChecked(row)"
98
- @change="($event:boolean) => checkRow(row, rowIndex, $event)"
42
+ :checked="isAllChecked"
43
+ :indeterminate="isIndeterminate"
44
+ :disabled="isAllUncheckable"
45
+ class="flex justify-center mt-0"
46
+ @change="checkAll()"
99
47
  />
100
- </td>
48
+ </th>
101
49
  </template>
102
- <td
50
+ <th
103
51
  v-for="(header, headerIndex) in headers"
104
- :key="headerIndex"
52
+ :key="`item-${headerIndex}`"
53
+ scope="col"
105
54
  :class="[
106
- isScrolled && headerIndex === 0 ? stickyClass.body : '',
55
+ 'px-3 py-2 text-gray-600 snap-start snap-always',
56
+ isScrolled && headerIndex === 0 ? stickyClass.head : '',
57
+ { 'cursor-pointer hover:text-gray-900': header?.sortable },
107
58
  ]"
59
+ :style="
60
+ header?.width
61
+ ? `min-width:${header.width}px;max-width:${header.width}px;`
62
+ : ``
63
+ "
64
+ @click="sortBy(header, $event)"
108
65
  >
109
- <slot
110
- :name="`item.${header.value}`"
111
- :row="row"
112
- :rowIndex="rowIndex"
66
+ <div
67
+ class="flex items-center gap-2 text-sm font-normal text-current"
113
68
  >
114
- {{ getValueByPath(row, header?.value) }}
115
- </slot>
116
- </td>
117
- </tr>
118
- <template v-if="tableExpanded">
119
- <slot name="expanded" :row="row" :rowIndex="rowIndex"></slot>
120
- </template>
121
- </template>
122
- <template v-else-if="computedItems.length === 0">
123
- <tr class="norecords">
124
- <td :colspan="checkable === true ? headers.length + 1 : headers.length">
125
- <slot name="no-records">
126
- <div
127
- class="flex items-center justify-center text-xl font-medium text-gray-500 h-[calc(100svh-18rem)] max-w-screen-xl"
128
- >
129
- No matching records found
130
- </div>
69
+ <slot name="header" :header="header" :index="headerIndex">
70
+ {{ capitalizeText(header?.text ?? header.name ?? "") }}
131
71
  </slot>
132
- </td>
72
+ <slot name="headerOptionalItem"></slot>
73
+ <SortArrow
74
+ v-if="header?.sortable"
75
+ :class="[
76
+ 'transform duration-100 transition-all',
77
+ currentSort === header.value
78
+ ? 'text-violet-700'
79
+ : 'text-gray-900',
80
+ sortClass(header),
81
+ ]"
82
+ />
83
+ </div>
84
+ </th>
133
85
  </tr>
134
- </template>
135
- </tbody>
136
- </table>
137
- </div>
138
- <div
139
- class="sticky bottom-0 left-0 z-50 flex items-center justify-between px-2 py-2 bg-gray-100"
140
- >
141
- <slot name="tableCount">
142
- <div class="inline-flex items-center gap-x-10">
143
- <div class="text-sm font-normal text-gray-900">
144
- {{ newCurrentPage }} - {{ limit }} of {{ total }}
145
- </div>
146
- <div class="inline-flex items-center gap-2">
147
- <span class="text-sm font-normal text-gray-900"
148
- >Result per page</span
86
+ </thead>
87
+ <tbody>
88
+ <template
89
+ v-if="computedItems.length > 0"
90
+ v-for="(row, rowIndex) in computedItems"
91
+ :key="`table-row-${rowIndex}`"
149
92
  >
150
- <EUIPageLimit
151
- :page-limit="limit"
152
- @update-limit="changeLimit($event)"
153
- @refetch="searchData($event)"
154
- />
93
+ <tr
94
+ @mouseenter="
95
+ $attrs.mouseenter
96
+ ? $emit('mouseenter', row, rowIndex)
97
+ : null
98
+ "
99
+ @mouseleave="
100
+ $attrs.mouseleave
101
+ ? $emit('mouseleave', row, rowIndex)
102
+ : null
103
+ "
104
+ >
105
+ <template v-if="checkable">
106
+ <td class="checkable">
107
+ <EUITableCheckbox
108
+ :disabled="!isRowCheckable(row)"
109
+ :checked="isRowChecked(row)"
110
+ @change="($event:boolean) => checkRow(row, rowIndex, $event)"
111
+ />
112
+ </td>
113
+ </template>
114
+ <td
115
+ v-for="(header, headerIndex) in headers"
116
+ :key="headerIndex"
117
+ :class="[
118
+ isScrolled && headerIndex === 0 ? stickyClass.body : '',
119
+ ]"
120
+ >
121
+ <slot
122
+ :name="`item.${header.value}`"
123
+ :row="row"
124
+ :rowIndex="rowIndex"
125
+ >
126
+ {{ getValueByPath(row, header?.value) }}
127
+ </slot>
128
+ </td>
129
+ </tr>
130
+ <template v-if="tableExpanded">
131
+ <slot name="expanded" :row="row" :rowIndex="rowIndex"></slot>
132
+ </template>
133
+ </template>
134
+ <template v-else-if="computedItems.length === 0">
135
+ <tr class="norecords">
136
+ <td
137
+ :colspan="
138
+ checkable === true ? headers.length + 1 : headers.length
139
+ "
140
+ >
141
+ <slot name="no-records">
142
+ <div
143
+ class="flex items-center justify-center text-xl font-medium text-gray-500 h-[calc(100svh-18rem)] max-w-screen-xl"
144
+ >
145
+ No matching records found
146
+ </div>
147
+ </slot>
148
+ </td>
149
+ </tr>
150
+ </template>
151
+ </tbody>
152
+ </table>
153
+ </div>
154
+ <div
155
+ class="sticky bottom-0 left-0 z-50 flex items-center justify-between px-2 py-2 bg-gray-100"
156
+ >
157
+ <slot name="tableCount">
158
+ <div class="inline-flex items-center gap-x-10">
159
+ <div class="text-sm font-normal text-gray-900">
160
+ {{ newCurrentPage * limit + 1 }} -
161
+ {{ (newCurrentPage + 1) * limit }} of {{ total }}
162
+ </div>
163
+ <div class="inline-flex items-center gap-2">
164
+ <span class="text-sm font-normal text-gray-900"
165
+ >Result per page</span
166
+ >
167
+ <EUIPageLimit
168
+ :page-limit="limit"
169
+ @update-limit="changeLimit($event)"
170
+ @refetch="searchData($event)"
171
+ />
172
+ </div>
155
173
  </div>
156
- </div>
157
- </slot>
158
- <template v-if="paginated && computedItems.length !== 0">
159
- <slot name="tablepagination">
160
- <EUIPagination
161
- :activePage="newCurrentPage"
162
- :pageLimit="limit"
163
- :totalCount="total"
164
- @change-page="pageChanged($event)"
165
- />
166
174
  </slot>
167
- </template>
175
+ <template v-if="paginated && computedItems.length !== 0">
176
+ <slot name="tablepagination">
177
+ <EUIPagination
178
+ :activePage="newCurrentPage"
179
+ :pageLimit="limit"
180
+ :totalCount="total"
181
+ @change-page="pageChanged($event)"
182
+ />
183
+ </slot>
184
+ </template>
185
+ </div>
168
186
  </div>
169
- </div>
170
187
  </Transition>
171
188
  </div>
172
189
  </template>
@@ -227,7 +244,7 @@ const props = defineProps({
227
244
  tableHeight: {
228
245
  type: String,
229
246
  required: false,
230
- default: ""
247
+ default: "",
231
248
  },
232
249
  tableLoading: { type: Boolean, default: false },
233
250
  });
@@ -248,6 +265,7 @@ const {
248
265
  const currentSort = ref(defaultSort.value);
249
266
  const currentSortDir = ref(defaultSortDirection.value);
250
267
  const newCheckedRows = ref([...checkedRows.value]);
268
+
251
269
  const newCurrentPage = ref(currentPage.value);
252
270
  const limit = ref(props.perPage);
253
271
  const loading = computed(() => props.tableLoading);
@@ -282,7 +300,7 @@ const computedItems = computed(() => {
282
300
  return items;
283
301
  });
284
302
 
285
- const searchData = (_data:any) => {
303
+ const searchData = (_data: any) => {
286
304
  // console.log(_data);
287
305
  };
288
306
 
@@ -305,10 +323,10 @@ const isIndeterminate = computed(() => {
305
323
  });
306
324
 
307
325
  const isAllChecked = computed(() => {
308
- return (
309
- computedItems.value.length > 0 &&
310
- computedItems.value.every(row => newCheckedRows.value.includes(row))
311
- );
326
+ return (
327
+ computedItems.value.length > 0 &&
328
+ computedItems.value.every((row) => newCheckedRows.value.includes(row))
329
+ );
312
330
  });
313
331
 
314
332
  const isAllUncheckable = computed(() => {
@@ -333,7 +351,7 @@ const emit = defineEmits([
333
351
 
334
352
  const changeLimit = (limitData: number) => {
335
353
  limit.value = limitData;
336
- newCurrentPage.value = 1;
354
+ newCurrentPage.value = 0;
337
355
  emit("update:currentPage", newCurrentPage.value);
338
356
  emit("changeLimit", limitData);
339
357
  };
@@ -353,44 +371,44 @@ const sortBy = (header: any, event: any) => {
353
371
  emit("sort", currentSort.value, currentSortDir.value, event);
354
372
  };
355
373
 
356
- const isRowChecked = (row:any) => {
357
- return indexOf(newCheckedRows.value, row) >= 0;
358
- };
374
+ const isRowChecked = (row: any) => {
375
+ return indexOf(newCheckedRows.value, row) >= 0;
376
+ };
359
377
 
360
- const removeCheckedRow = (row:any) => {
361
- const index = indexOf(newCheckedRows.value, row);
362
- if (index >= 0) {
363
- newCheckedRows.value.splice(index, 1);
364
- }
365
- };
378
+ const removeCheckedRow = (row: any) => {
379
+ const index = indexOf(newCheckedRows.value, row);
380
+ if (index >= 0) {
381
+ newCheckedRows.value.splice(index, 1);
382
+ }
383
+ };
366
384
 
367
385
  const checkAll = () => {
368
- if (isAllChecked.value) {
369
- // Uncheck all rows
370
- newCheckedRows.value = []
371
- } else {
372
- // Check all rows
373
- const rowsToCheck = computedItems.value.filter(
374
- row => !newCheckedRows.value.includes(row)
375
- );
376
- newCheckedRows.value.push(...rowsToCheck);
377
- }
378
- emit('check', newCheckedRows.value);
379
- emit("check-all", newCheckedRows.value);
380
- emit("update:checkedRows", newCheckedRows.value);
381
- emit("update:selectedRows", newCheckedRows.value);
386
+ if (isAllChecked.value) {
387
+ // Uncheck all rows
388
+ newCheckedRows.value = [];
389
+ } else {
390
+ // Check all rows
391
+ const rowsToCheck = computedItems.value.filter(
392
+ (row) => !newCheckedRows.value.includes(row)
393
+ );
394
+ newCheckedRows.value.push(...rowsToCheck);
395
+ }
396
+ emit("check", newCheckedRows.value);
397
+ emit("check-all", newCheckedRows.value);
398
+ emit("update:checkedRows", newCheckedRows.value);
399
+ emit("update:selectedRows", newCheckedRows.value);
382
400
  };
383
401
 
384
- const checkRow = (row: any, _rowIndex: number, _event:any) => {
402
+ const checkRow = (row: any, _rowIndex: number, _event: any) => {
385
403
  const isChecked = newCheckedRows.value.includes(row);
386
- if (_event && isChecked) {
387
- removeCheckedRow(row);
388
- } else {
389
- newCheckedRows.value.push(row);
390
- }
391
- emit("check", newCheckedRows.value, row);
392
- emit("update:checkedRows", newCheckedRows.value);
393
- emit("update:selectedRows", newCheckedRows.value);
404
+ if (_event && isChecked) {
405
+ removeCheckedRow(row);
406
+ } else {
407
+ newCheckedRows.value.push(row);
408
+ }
409
+ emit("check", newCheckedRows.value, row);
410
+ emit("update:checkedRows", newCheckedRows.value);
411
+ emit("update:selectedRows", newCheckedRows.value);
394
412
  };
395
413
 
396
414
  // watch
@@ -1,21 +1,25 @@
1
1
  <template>
2
2
  <div>
3
3
  <Transition name="fade" mode="out-in">
4
- <div
5
- v-if="loading"
6
- :class="[
7
- 'overflow-hidden relative z-0 isolate bg-white backdrop-blur transition-colors duration-150 ease-in-out rounded-xl border border-gray-50',
8
- tableHeight
9
- ? tableHeight
10
- : 'h-[calc(100svh-9rem)] max-h-[calc(100svh-9rem)]',
11
- ]"
12
- >
13
- <div
14
- class="absolute flex items-center z-[calc(infinity)] w-full h-auto pointer-events-none inset-0"
15
- >
16
- <EUICircleLoader />
17
- </div>
18
- </div>
4
+ <template v-if="loading">
5
+ <slot name="loader" :loading="loading" :height="tableHeight">
6
+ <div
7
+ :class="[
8
+ 'overflow-hidden relative z-0 isolate bg-white backdrop-blur transition-colors duration-150 ease-in-out rounded-xl border border-gray-50',
9
+ tableHeight
10
+ ? tableHeight
11
+ : 'h-[calc(100svh-9rem)] max-h-[calc(100svh-9rem)]',
12
+ ]"
13
+ >
14
+ <div
15
+ class="absolute flex items-center z-[calc(infinity)] w-full h-auto pointer-events-none inset-0"
16
+ >
17
+ <EUICircleLoader />
18
+ </div>
19
+ </div>
20
+ </slot>
21
+ </template>
22
+
19
23
  <div v-else class="relative w-full mx-auto overflow-hidden">
20
24
  <div
21
25
  id="student-table"
@@ -116,8 +120,12 @@
116
120
  :key="`table-row-${rowIndex}`"
117
121
  >
118
122
  <tr
119
- :id="`row-${rowIndex}`"
120
- :class="activeRowIndex==rowIndex?'!bg-purple-50 !ring-1 !ring-purple-100 !ring-inset':''"
123
+ :id="`row-${rowIndex}`"
124
+ :class="
125
+ activeRowIndex == rowIndex
126
+ ? '!bg-purple-50 !ring-1 !ring-purple-100 !ring-inset'
127
+ : ''
128
+ "
121
129
  @mouseenter="
122
130
  $attrs.mouseenter
123
131
  ? $emit('mouseenter', row, rowIndex)
@@ -130,8 +138,14 @@
130
138
  "
131
139
  >
132
140
  <template v-if="checkable">
133
- <td class="checkable"
134
- :class=" activeRowIndex==rowIndex?'!bg-purple-50 !ring-1 !ring-purple-100 !ring-inset':''">
141
+ <td
142
+ class="checkable"
143
+ :class="
144
+ activeRowIndex == rowIndex
145
+ ? '!bg-purple-50 !ring-1 !ring-purple-100 !ring-inset'
146
+ : ''
147
+ "
148
+ >
135
149
  <EUITableCheckbox
136
150
  :disabled="!isRowCheckable(row)"
137
151
  :checked="isRowChecked(row)"
@@ -146,9 +160,10 @@
146
160
  :key="headerIndex"
147
161
  :class="[
148
162
  isScrolled && headerIndex === 0 ? stickyClass.body : '',
149
- activeRowIndex==rowIndex?'!bg-purple-50 !ring-1 !ring-purple-100 !ring-inset':''
163
+ activeRowIndex == rowIndex
164
+ ? '!bg-purple-50 !ring-1 !ring-purple-100 !ring-inset'
165
+ : '',
150
166
  ]"
151
-
152
167
  >
153
168
  <slot
154
169
  :name="`item.${header?.value}`"
@@ -171,12 +186,12 @@
171
186
  checkable === true ? headers.length + 1 : headers.length
172
187
  "
173
188
  >
174
- <slot name="no-records">
175
- <div
176
- class="flex items-center justify-center text-xl font-medium text-gray-500 h-[calc(100svh-18rem)] max-w-screen-xl"
177
- >
178
- No matching records found
179
- </div>
189
+ <slot name="no-records">
190
+ <div
191
+ class="flex items-center justify-center text-xl font-medium text-gray-500 h-[calc(100svh-18rem)] max-w-screen-xl"
192
+ >
193
+ No matching records found
194
+ </div>
180
195
  </slot>
181
196
  </td>
182
197
  </tr>
@@ -293,7 +308,8 @@ const {
293
308
  search,
294
309
  headers,
295
310
  paginated,
296
- isRowCheckable,activeRowIndex
311
+ isRowCheckable,
312
+ activeRowIndex,
297
313
  } = toRefs(props);
298
314
 
299
315
  const currentSort = ref(defaultSort.value);
@@ -382,7 +398,7 @@ const emit = defineEmits([
382
398
 
383
399
  const changeLimit = (limitData: number) => {
384
400
  limit.value = limitData;
385
- newCurrentPage.value = 1;
401
+ newCurrentPage.value = 0;
386
402
  emit("update:currentPage", newCurrentPage.value);
387
403
  emit("changeLimit", limitData);
388
404
  };
@@ -1,21 +1,25 @@
1
1
  <template>
2
2
  <div>
3
3
  <Transition name="fade" mode="out-in">
4
- <div
5
- v-if="loading"
6
- :class="[
7
- 'overflow-hidden relative z-0 isolate bg-white backdrop-blur transition-colors duration-150 ease-in-out rounded-xl border border-gray-50',
8
- tableHeight
9
- ? tableHeight
10
- : 'h-[calc(100svh-9rem)] max-h-[calc(100svh-9rem)]',
11
- ]"
12
- >
13
- <div
14
- class="absolute flex items-center z-[calc(infinity)] w-full h-auto pointer-events-none inset-0"
15
- >
16
- <EUICircleLoader />
17
- </div>
18
- </div>
4
+ <template v-if="loading">
5
+ <slot name="loader" :loading="loading" :height="tableHeight">
6
+ <div
7
+ :class="[
8
+ 'overflow-hidden relative z-0 isolate bg-white backdrop-blur transition-colors duration-150 ease-in-out rounded-xl border border-gray-50',
9
+ tableHeight
10
+ ? tableHeight
11
+ : 'h-[calc(100svh-9rem)] max-h-[calc(100svh-9rem)]',
12
+ ]"
13
+ >
14
+ <div
15
+ class="absolute flex items-center z-[calc(infinity)] w-full h-auto pointer-events-none inset-0"
16
+ >
17
+ <EUICircleLoader />
18
+ </div>
19
+ </div>
20
+ </slot>
21
+ </template>
22
+
19
23
  <div v-else class="relative w-full mx-auto overflow-hidden">
20
24
  <div
21
25
  id="growth-table"
@@ -397,7 +401,7 @@ const emit = defineEmits([
397
401
 
398
402
  const changeLimit = (limitData: number) => {
399
403
  limit.value = limitData;
400
- newCurrentPage.value = 1;
404
+ newCurrentPage.value = 0;
401
405
  emit("update:currentPage", newCurrentPage.value);
402
406
  emit("changeLimit", limitData);
403
407
  };