Skip to content

Commit 2e0e2a9

Browse files
Fixing ts strict stuff
1 parent 4f83ddb commit 2e0e2a9

File tree

5 files changed

+91
-131
lines changed

5 files changed

+91
-131
lines changed

src/plugin/VDrilldownTable.vue

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,17 @@ import {
243243
Column,
244244
DrilldownEvent,
245245
LoadedDrilldown,
246+
SearchProps,
247+
SearchPropCols,
246248
SortItem,
247249
} from '@/types/types';
248250
import {
249251
HeadersSlot,
250252
TfootSlot,
251253
} from './components';
254+
import {
255+
DataTableItem,
256+
} from 'vuetify/dist/vuetify-labs.esm';
252257
253258
254259
@@ -262,58 +267,18 @@ const props = defineProps({ ...AllProps });
262267
263268
// -------------------------------------------------- Table Settings (WIP) //
264269
// Custom Default Props/Options //
265-
const customOptions = {
266-
// calculateWidths: true,
267-
// className: '',
268-
// colors: {
269-
// body: {
270-
// base: '--v-theme-surface',
271-
// bg: '--v-theme-surface',
272-
// text: '--v-theme-on-surface',
273-
// },
274-
// default: {
275-
// base: 'primary',
276-
// bg: 'primary',
277-
// border: null,
278-
// text: 'on-primary',
279-
// },
280-
// footer: {
281-
// bg: '--v-theme-surface',
282-
// text: '--v-theme-on-surface',
283-
// },
284-
// header: {
285-
// bg: 'primary',
286-
// text: 'on-primary',
287-
// },
288-
// percentageChange: 25,
289-
// percentageDirection: 'desc',
290-
// },
291-
debounceDelay: 750,
292-
// drilldownKey: false,
293-
elevation: 1, // * Works
294-
// expandIcon: 'plus-circle',
295-
// expandIconType: 'fas',
296-
// footerRow: false,
297-
// matchHeaderColumnWidths: true,
298-
// parentTableRef: '',
299-
// ref: 'drilldown',
300-
// searchProps: {
301-
// cols: {
302-
// lg: 3,
303-
// md: 6,
304-
// sm: 12,
305-
// xl: 3,
306-
// xs: 12,
307-
// xxl: 2,
308-
// },
309-
// density: 'compact',
310-
// variant: 'underlined',
311-
// },
312-
showSearch: false,
313-
};
270+
// const customOptions = {
271+
// calculateWidths: true,
272+
// className: '',
273+
// expandIcon: 'plus-circle',
274+
// expandIconType: 'fas',
275+
// footerRow: false,
276+
// matchHeaderColumnWidths: true,
277+
// parentTableRef: '',
278+
// ref: 'drilldown',
279+
// };
314280
315281
const loadedDrilldown = ref<LoadedDrilldown>({
316-
...customOptions, // * Custom Props
317282
colors: {
318283
body: {
319284
base: '--v-theme-surface',
@@ -339,8 +304,11 @@ const loadedDrilldown = ref<LoadedDrilldown>({
339304
},
340305
customFilter: () => { }, // ? Needs Testing
341306
customKeyFilter: [], // ? Needs Testing
307+
debounceDelay: 750, // * Custom Prop
342308
// dense: false, // ? Missing in Docs, but is in code base
343-
density: 'compact', // * Works - Missing in Docs
309+
density: 'comfortable', // * Works - Missing in Docs
310+
drilldownKey: '', // * Custom Prop
311+
elevation: 1, // * Custom Prop
344312
expandOnClick: false, // * Works
345313
expanded: [], // ? Needs Testing
346314
// filterKeys: [], // ? Needs Testing
@@ -388,6 +356,7 @@ const loadedDrilldown = ref<LoadedDrilldown>({
388356
},
389357
server: false, // ? Needs Testing. This requires v-data-table-server
390358
showExpand: true, // * Works
359+
showSearch: false, // * Custom Prop
391360
showSelect: false, // * Works
392361
sortBy: [], // * Works
393362
width: '100%', // ! Failed
@@ -423,14 +392,13 @@ onMounted(() => {
423392
424393
// -------------------------------------------------- Table #
425394
const tableClasses = computed<object>(() => {
426-
const baseClass = componentName;
427-
const elevation = loadedDrilldown.value.elevation as string;
395+
const elevation = loadedDrilldown.value.elevation;
428396
429397
const classes = {
430-
[baseClass]: true,
431-
[`${baseClass}--level-${loadedDrilldown.value.level}`]: true,
432-
[`${baseClass}--child`]: props.isDrilldown,
433-
[`elevation-${elevation}`]: parseInt(elevation) > 0,
398+
[`${componentName}`]: true,
399+
[`${componentName}--level-${loadedDrilldown.value.level}`]: true,
400+
[`${componentName}--child`]: props.isDrilldown,
401+
[`elevation-${elevation}`]: parseInt(elevation as string) > 0,
434402
'pb-2': true,
435403
};
436404
@@ -454,7 +422,8 @@ const tableStyles = computed<StyleValue>(() => {
454422
455423
// -------------------------------------------------- Top #
456424
const searchFieldClasses = computed<object>(() => {
457-
const searchCols = loadedDrilldown.value.searchProps.cols;
425+
const searchProps = loadedDrilldown.value.searchProps as SearchProps;
426+
const searchCols = searchProps.cols as SearchPropCols;
458427
459428
const classes = {
460429
[`${componentName}--search-field`]: true,
@@ -501,7 +470,7 @@ function setLoadedDrilldown(): void {
501470
loadedDrilldown.value = useMergeDeep(loadedDrilldown.value, props);
502471
}
503472
504-
function renderCellItem(item: object, column: Column, index: number): unknown {
473+
function renderCellItem(item: DataTableItem, column: Column, index: number): unknown {
505474
return useRenderCellItem(item.raw, column, index);
506475
}
507476
@@ -526,7 +495,7 @@ function drilldownEvent(data: DrilldownEvent): void {
526495
// }
527496
528497
// ? Probably more useful when using server side
529-
function updateItemsPerPage(itemsCount) {
498+
function updateItemsPerPage(itemsCount: number) {
530499
loadedDrilldown.value.itemsPerPage = itemsCount;
531500
532501
return true;

src/plugin/components/HeadersSlot.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
<!-- Column Dynamic Name Header Slot -->
1111
<th
1212
v-if="$slots[`header.${column.key}`]"
13-
:class="headerRowThClasses(column)"
14-
:style="headerRowThStyles(column, true)"
13+
:class="cellClasses(column)"
14+
:style="cellStyles(column, true)"
1515
>
1616
<slot
1717
:column="column"
@@ -22,16 +22,16 @@
2222
<th
2323
v-else-if="column.key === 'data-table-expand'"
2424
class="v-drilldown-table--header-row-th"
25-
:class="headerRowThClasses(column)"
26-
:style="headerRowThStyles(column, true)"
25+
:class="cellClasses(column)"
26+
:style="cellStyles(column, true)"
2727
v-html="renderCell(column /* , index */)"
2828
></th>
2929
<!-- Column Render TH -->
3030
<th
3131
v-else
3232
class="v-drilldown-table--header-row-th"
33-
:class="headerRowThClasses(column)"
34-
:style="headerRowThStyles(column)"
33+
:class="cellClasses(column)"
34+
:style="cellStyles(column)"
3535
v-html="renderCell(column /* , index */)"
3636
></th>
3737
</template>
@@ -68,17 +68,17 @@ const headerRowClasses = (): object => {
6868
6969
7070
// -------------------------------------------------- Header Row TH //
71-
const headerRowThClasses = (column): object => {
71+
const cellClasses = (column: DrilldownTypes.Column): object => {
7272
const classes = {
7373
[`${componentName}--header-row-th-${props.loadedDrilldown.level}`]: true,
74-
[column.cellClass]: column.cellClass,
74+
[`${column.cellClass}`]: column.cellClass,
7575
};
7676
7777
return classes;
7878
};
7979
80-
const headerRowThStyles = (column: { width?: string | number; }, dataTableExpand = false): CSSProperties => {
81-
const headerColors = useGetLevelColors(props.loadedDrilldown, theme, 'header');
80+
const cellStyles = (column: { width?: string | number; }, dataTableExpand = false): CSSProperties => {
81+
const headerColors = useGetLevelColors(props.loadedDrilldown as DrilldownTypes.LoadedDrilldown, theme, 'header');
8282
8383
const styles = {
8484
backgroundColor: headerColors.bg,
@@ -92,12 +92,12 @@ const headerRowThStyles = (column: { width?: string | number; }, dataTableExpand
9292
styles.minWidth = '48px';
9393
}
9494
95-
return styles;
95+
return styles as CSSProperties;
9696
};
9797
9898
// -------------------------------------------------- Render //
9999
function renderCell(column: DrilldownTypes.Column, /* , index */): unknown {
100100
const tempIndex = 0;
101-
return useRenderCell(props.loadedDrilldown, column, tempIndex);
101+
return useRenderCell(props.loadedDrilldown as DrilldownTypes.LoadedDrilldown, column, tempIndex);
102102
}
103103
</script>

src/plugin/components/TfootSlot.vue

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
v-if="$slots.tfoot"
44
name="tfoot"
55
/>
6-
<tfoot v-if="columns.length">
6+
<tfoot v-if="columns?.length">
77
<tr class="v-drilldown-table--footer-row aa">
88
<template
99
v-for="column in columns"
@@ -63,7 +63,7 @@ const props = defineProps({
6363
},
6464
});
6565
66-
const columns = ref([]);
66+
const columns = ref();
6767
const theme = useTheme();
6868
6969
@@ -76,12 +76,12 @@ const cellClasses = (column: DrilldownTypes.Column): object => {
7676
return {
7777
[`${componentName}--footer-row-td`]: true,
7878
[`${componentName}--footer-row-td-${props.loadedDrilldown.level}`]: true,
79-
[column.cellClass]: column.cellClass,
79+
[`${column.cellClass}`]: column.cellClass,
8080
};
8181
};
8282
8383
const cellStyles = (): CSSProperties => {
84-
const headerColors = useGetLevelColors(props.loadedDrilldown, theme, 'header');
84+
const headerColors = useGetLevelColors(props.loadedDrilldown as DrilldownTypes.LoadedDrilldown, theme, 'footer');
8585
8686
const styles = {
8787
backgroundColor: headerColors.bg,
@@ -92,9 +92,8 @@ const cellStyles = (): CSSProperties => {
9292
};
9393
9494
function renderCell(column: DrilldownTypes.Column, /* , index */): unknown {
95-
console.log('renderCell', column);
9695
const tempIndex = 0;
97-
return useRenderCell(props.loadedDrilldown, column, tempIndex);
96+
return useRenderCell(props.loadedDrilldown as DrilldownTypes.LoadedDrilldown, column, tempIndex);
9897
}
9998
10099
</script>

0 commit comments

Comments
 (0)