|
17 | 17 | :item-title="loadedDrilldown.itemTitle" |
18 | 18 | :item-value="loadedDrilldown.itemValue" |
19 | 19 | :items="loadedDrilldown.items" |
| 20 | + :items-length="loadedDrilldown.itemsLength" |
20 | 21 | :items-per-page="loadedDrilldown.itemsPerPage" |
21 | | - :loading="loadedDrilldown.loading" |
22 | | - :loading-text="loadedDrilldown.loadingText" |
23 | 22 | :multi-sort="loadedDrilldown.multiSort" |
24 | 23 | :must-sort="loadedDrilldown.mustSort" |
25 | 24 | :no-filter="loadedDrilldown.noFilter" |
|
80 | 79 | </template> |
81 | 80 |
|
82 | 81 | <!-- ================================================== Headers Slot --> |
83 | | - <!-- ! The headers slot is currently missing the `props` --> |
| 82 | + <!-- // ! The headers slot is currently missing the `props` --> |
84 | 83 | <template #headers> |
85 | | - <tr |
86 | | - class="v-drilldown-table--header-row" |
87 | | - :class="headerRowClasses" |
88 | | - > |
89 | | - <template |
90 | | - v-for="column in loadedDrilldown.headers" |
91 | | - :key="column" |
92 | | - > |
93 | | - <!-- Column TH Slot --> |
94 | | - <slot |
95 | | - v-if="$slots.header" |
96 | | - :column="column" |
97 | | - name="header" |
98 | | - /> |
99 | | - <!-- Column Dynamic Name Header Slot --> |
100 | | - <slot |
101 | | - v-else-if="$slots[`header.${column.key}`]" |
102 | | - :column="column" |
103 | | - :name="`header.${column.key}`" |
104 | | - /> |
105 | | - <!-- Column Render `data-table-expand` --> |
106 | | - <th |
107 | | - v-else-if="column.key === 'data-table-expand'" |
108 | | - class="v-drilldown-table--header-row-th" |
109 | | - :class="headerRowThClasses(column)" |
110 | | - :style="headerRowThStyles(column, true)" |
111 | | - v-html="renderCellHeader(column /* , index */)" |
112 | | - ></th> |
113 | | - <!-- Column Render TH --> |
114 | | - <th |
115 | | - v-else |
116 | | - class="v-drilldown-table--header-row-th" |
117 | | - :class="headerRowThClasses(column)" |
118 | | - :style="headerRowThStyles(column)" |
119 | | - v-html="renderCellHeader(column /* , index */)" |
120 | | - ></th> |
121 | | - </template> |
122 | | - </tr> |
| 84 | + <HeadersSlot :loadedDrilldown="loadedDrilldown" /> |
123 | 85 | </template> |
124 | 86 |
|
| 87 | + |
125 | 88 | <!-- ================================================== Row Item Slot --> |
126 | 89 | <template #item="{ columns, index, isExpanded, item, toggleExpand }"> |
127 | 90 | <tr> |
|
150 | 113 | </v-icon> |
151 | 114 |
|
152 | 115 | </td> |
153 | | - <!-- Item Slot --> |
154 | | - <slot |
155 | | - v-else-if="$slots.cell" |
156 | | - :class="column.cellClass" |
157 | | - :column="column" |
158 | | - :index="index" |
159 | | - :item="item" |
160 | | - name="item" |
161 | | - :value="item.raw[column.key]" |
162 | | - /> |
163 | 116 | <!-- Dynamic Name Item Slot --> |
164 | 117 | <slot |
165 | 118 | v-else-if="$slots[`item.${column.key}`]" |
|
179 | 132 | </tr> |
180 | 133 | </template> |
181 | 134 |
|
| 135 | + |
182 | 136 | <!-- ================================================== Data Table Expand Slot --> |
183 | | - <!-- @update:expanded="updateExpanded" --> |
184 | 137 | <template #[`item.data-table-expand`]="{ |
185 | 138 | columns, |
186 | 139 | index, |
|
208 | 161 |
|
209 | 162 | </template> |
210 | 163 |
|
| 164 | + |
211 | 165 | <!-- ================================================== Expanded Row Slot --> |
212 | 166 | <template #expanded-row="{ columns, item }"> |
213 | 167 | <tr> |
|
244 | 198 | </template> |
245 | 199 |
|
246 | 200 | <!-- ! This also does not pass rollup bundle --> |
247 | | - <template |
| 201 | + <!-- <template |
248 | 202 | v-for="slot in Object.keys(slots)" |
249 | 203 | v-slot:[`${slot}`]="scope" |
250 | 204 | > |
251 | 205 | <slot |
252 | 206 | :name="slot" |
253 | 207 | v-bind="scope" |
254 | 208 | ></slot> |
255 | | - </template> |
| 209 | + </template> --> |
256 | 210 | </VDrilldownTable> |
257 | 211 | </td> |
258 | 212 | </tr> |
259 | 213 | </template> |
260 | 214 |
|
261 | 215 |
|
| 216 | + <!-- ================================================== tfoot Slot --> |
| 217 | + <!-- // ! The headers slot is currently missing the `props` --> |
| 218 | + <template #tfoot> |
| 219 | + <TfootSlot :loadedDrilldown="loadedDrilldown" /> |
| 220 | + </template> |
| 221 | + |
262 | 222 |
|
263 | 223 | <!-- ================================================== Footer Prepend Slot --> |
264 | 224 | <template #[`footer.prepend`]> |
|
273 | 233 | <script setup lang="ts"> |
274 | 234 | import { useTheme } from 'vuetify'; |
275 | 235 | import { |
276 | | - CSSProperties, |
277 | 236 | computed, |
278 | | - // onBeforeMount, |
279 | 237 | onMounted, |
280 | 238 | ref, |
281 | 239 | StyleValue, |
282 | 240 | useSlots, |
283 | 241 | watch, |
284 | 242 | } from 'vue'; |
| 243 | +import { componentName } from './utils/globals'; |
285 | 244 | import { AllProps } from './utils/props'; |
286 | 245 | import { useGetLevelColors } from './composables/levelColors'; |
287 | 246 | import { |
288 | | - useConvertToUnit, |
289 | 247 | useDrilldownDebounce, |
290 | | - useRenderCellHeader, |
291 | 248 | useRenderCellItem, |
292 | 249 | useMergeDeep, |
293 | 250 | } from './composables/helpers'; |
294 | 251 | import { |
| 252 | + Column, |
295 | 253 | DrilldownEvent, |
296 | 254 | LoadedDrilldown, |
297 | 255 | SortItem, |
298 | 256 | } from '@/types/types'; |
| 257 | +import { |
| 258 | + HeadersSlot, |
| 259 | + TfootSlot, |
| 260 | +} from './components'; |
299 | 261 |
|
300 | 262 |
|
301 | 263 |
|
@@ -378,7 +340,7 @@ const loadedDrilldown = ref<LoadedDrilldown>({ |
378 | 340 | text: '--v-theme-on-surface', |
379 | 341 | }, |
380 | 342 | header: { |
381 | | - bg: 'orange', |
| 343 | + bg: 'primary', |
382 | 344 | text: 'on-primary', |
383 | 345 | }, |
384 | 346 | percentageChange: 25, |
@@ -407,10 +369,11 @@ const loadedDrilldown = ref<LoadedDrilldown>({ |
407 | 369 | itemTitle: 'title', // * Works, but is weird |
408 | 370 | itemValue: 'id', // * Works, but is weird |
409 | 371 | items: [], // * Works |
| 372 | + itemsLength: 0, |
410 | 373 | itemsPerPage: 10, // * Works |
411 | 374 | // ! Not working yet `loading` & `loadingText`: https://github.com/vuetifyjs/vuetify/issues/16811 // |
412 | | - loading: false, |
413 | | - loadingText: 'Loading...', |
| 375 | + // loading: false, |
| 376 | + // loadingText: 'Loading...', |
414 | 377 | modelValue: [], // ? Needs Testing |
415 | 378 | multiSort: false, // * Works |
416 | 379 | mustSort: false, // * Works |
@@ -442,7 +405,6 @@ const loadedDrilldown = ref<LoadedDrilldown>({ |
442 | 405 |
|
443 | 406 |
|
444 | 407 | // -------------------------------------------------- Data // |
445 | | -const componentName = 'v-drilldown-table'; |
446 | 408 | const parentTableRef = ref<string>(''); |
447 | 409 | const levelSearch = ref<string>(''); |
448 | 410 | const theme = useTheme(); |
@@ -516,44 +478,6 @@ const searchFieldClasses = computed<object>(() => { |
516 | 478 | return classes; |
517 | 479 | }); |
518 | 480 |
|
519 | | -// -------------------------------------------------- Header # |
520 | | -const headerRowClasses = computed<string>(() => { |
521 | | - const classes = `${componentName}--header-row-${loadedDrilldown.value.level}`; |
522 | | -
|
523 | | - return classes; |
524 | | -}); |
525 | | -
|
526 | | -// TODO: Add column type |
527 | | -const headerRowThClasses = (column): object => { |
528 | | - const classes = { |
529 | | - [`${componentName}--header-row-th-${loadedDrilldown.value.level}`]: true, |
530 | | - [column.cellClass]: column.cellClass, |
531 | | - }; |
532 | | -
|
533 | | - return classes; |
534 | | -}; |
535 | | -
|
536 | | -const headerRowThStyles = (column: { width?: string | number; }, dataTableExpand = false): CSSProperties => { |
537 | | - const headerColors = useGetLevelColors(loadedDrilldown.value, theme, 'header'); |
538 | | -
|
539 | | - const styles = { |
540 | | - backgroundColor: headerColors.bg, |
541 | | - color: headerColors.text, |
542 | | - minWidth: column.width ? useConvertToUnit(column.width) : 'auto', |
543 | | - width: column.width ? useConvertToUnit(column.width) : 'auto', |
544 | | - }; |
545 | | -
|
546 | | - if (dataTableExpand && !column.width) { |
547 | | - styles.width = '48px'; |
548 | | - styles.minWidth = '48px'; |
549 | | - } |
550 | | -
|
551 | | - return styles; |
552 | | -}; |
553 | | -
|
554 | | -
|
555 | | -// -------------------------------------------------- Footer TBD # |
556 | | -
|
557 | 481 |
|
558 | 482 | // -------------------------------------------------- Methods # |
559 | 483 | function setLoadedDrilldown(): void { |
@@ -586,17 +510,12 @@ function setLoadedDrilldown(): void { |
586 | 510 | loadedDrilldown.value = useMergeDeep(loadedDrilldown.value, props); |
587 | 511 | } |
588 | 512 |
|
589 | | -function renderCellHeader(column, /* , index */): unknown { |
590 | | - // TODO: This needs to be updated once Vuetify fixes the header slot // |
591 | | - const tempIndex = 0; |
592 | | - return useRenderCellHeader(loadedDrilldown.value, column, tempIndex); |
593 | | -} |
594 | | -
|
595 | | -function renderCellItem(item, column, index): unknown { |
| 513 | +function renderCellItem(item: object, column: Column, index: number): unknown { |
596 | 514 | return useRenderCellItem(item.raw, column, index); |
597 | 515 | } |
598 | 516 |
|
599 | 517 |
|
| 518 | +
|
600 | 519 | // ------------------------- Table Events // |
601 | 520 | function drilldownEvent(data: DrilldownEvent): void { |
602 | 521 | // console.log('1 ---------------------------------------- drilldownEvent', { data }); |
|
0 commit comments