• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

humanspeak / svelte-headless-table / 12913219917

22 Jan 2025 04:59PM UTC coverage: 59.766%. First build
12913219917

push

github

jaysin586
Rolling it way back

404 of 483 branches covered (83.64%)

Branch coverage included in aggregate %.

2232 of 3955 new or added lines in 55 files covered. (56.43%)

2616 of 4570 relevant lines covered (57.24%)

34.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/lib/plugins/addGridLayout.ts
NEW
1
import type {
×
NEW
2
        TableAttributes,
×
NEW
3
        TableBodyAttributes,
×
NEW
4
        TableHeadAttributes,
×
NEW
5
} from '../createViewModel.js';
×
NEW
6
import type { DeriveFn, NewTablePropSet, TablePlugin } from '../types/TablePlugin.js';
×
NEW
7
import { derived } from 'svelte/store';
×
8

×
9
export const addGridLayout =
×
NEW
10
        <Item>(): TablePlugin<
×
NEW
11
                Item,
×
NEW
12
                Record<string, never>,
×
NEW
13
                Record<string, never>,
×
NEW
14
                NewTablePropSet<never>
×
NEW
15
        > =>
×
NEW
16
        ({ tableState }) => {
×
NEW
17
                const pluginState = {};
×
18

×
NEW
19
                const deriveTableAttrs: DeriveFn<TableAttributes<Item>> = (attrs) => {
×
NEW
20
                        return derived([attrs, tableState.visibleColumns], ([$attrs, $visibleColumns]) => {
×
NEW
21
                                return {
×
NEW
22
                                        ...$attrs,
×
NEW
23
                                        style: {
×
NEW
24
                                                display: 'grid',
×
NEW
25
                                                'grid-template-columns': `repeat(${$visibleColumns.length}, auto)`,
×
NEW
26
                                        },
×
NEW
27
                                };
×
NEW
28
                        });
×
NEW
29
                };
×
30

×
NEW
31
                const deriveTableHeadAttrs: DeriveFn<TableHeadAttributes<Item>> = (attrs) => {
×
NEW
32
                        return derived(attrs, ($attrs) => {
×
NEW
33
                                return {
×
NEW
34
                                        ...$attrs,
×
NEW
35
                                        style: {
×
NEW
36
                                                display: 'contents',
×
NEW
37
                                        },
×
NEW
38
                                };
×
NEW
39
                        });
×
NEW
40
                };
×
41

×
NEW
42
                const deriveTableBodyAttrs: DeriveFn<TableBodyAttributes<Item>> = (attrs) => {
×
NEW
43
                        return derived(attrs, ($attrs) => {
×
NEW
44
                                return {
×
NEW
45
                                        ...$attrs,
×
NEW
46
                                        style: {
×
NEW
47
                                                display: 'contents',
×
NEW
48
                                        },
×
NEW
49
                                };
×
NEW
50
                        });
×
NEW
51
                };
×
52

×
NEW
53
                return {
×
NEW
54
                        pluginState,
×
NEW
55
                        deriveTableAttrs,
×
NEW
56
                        deriveTableHeadAttrs,
×
NEW
57
                        deriveTableBodyAttrs,
×
NEW
58
                        hooks: {
×
NEW
59
                                'thead.tr': () => {
×
NEW
60
                                        const attrs = derived([], () => {
×
NEW
61
                                                return {
×
NEW
62
                                                        style: {
×
NEW
63
                                                                display: 'contents',
×
NEW
64
                                                        },
×
NEW
65
                                                };
×
NEW
66
                                        });
×
NEW
67
                                        return { attrs };
×
NEW
68
                                },
×
NEW
69
                                'thead.tr.th': (cell) => {
×
NEW
70
                                        const attrs = derived([], () => {
×
NEW
71
                                                return {
×
NEW
72
                                                        style: {
×
NEW
73
                                                                'grid-column': `${cell.colstart + 1} / span ${cell.colspan}`,
×
NEW
74
                                                        },
×
NEW
75
                                                };
×
NEW
76
                                        });
×
NEW
77
                                        return { attrs };
×
NEW
78
                                },
×
NEW
79
                                'tbody.tr': () => {
×
NEW
80
                                        const attrs = derived([], () => {
×
NEW
81
                                                return {
×
NEW
82
                                                        style: {
×
NEW
83
                                                                display: 'contents',
×
NEW
84
                                                        },
×
NEW
85
                                                };
×
NEW
86
                                        });
×
NEW
87
                                        return { attrs };
×
NEW
88
                                },
×
NEW
89
                        },
×
NEW
90
                };
×
NEW
91
        };
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc