|
1 | 1 | <script lang="ts"> |
2 | 2 | import type { HTMLAttributes } from 'svelte/elements'; |
3 | 3 |
|
| 4 | + import { type ClassNameValue, twMerge as merge } from 'tailwind-merge'; |
| 5 | +
|
4 | 6 | import SkeletonTable from '$lib/holocene/skeleton/table.svelte'; |
5 | 7 | import Table from '$lib/holocene/table/table.svelte'; |
6 | 8 |
|
7 | 9 | type Item = $$Generic; |
8 | 10 |
|
9 | | - interface $$Props extends HTMLAttributes<HTMLTableElement> { |
| 11 | + interface $$Props extends Omit<HTMLAttributes<HTMLTableElement>, 'class'> { |
10 | 12 | visibleItems: Item[]; |
11 | 13 | loading?: boolean; |
12 | 14 | updating?: boolean; |
13 | 15 | maxHeight?: string; |
14 | 16 | fixed?: boolean; |
| 17 | + class?: ClassNameValue; |
15 | 18 | } |
16 | 19 |
|
17 | 20 | export let visibleItems: Item[]; |
|
20 | 23 | export let maxHeight = ''; |
21 | 24 | export let fixed = false; |
22 | 25 |
|
| 26 | + let className: ClassNameValue = ''; |
| 27 | + export { className as class }; |
| 28 | +
|
23 | 29 | let tableContainer: HTMLDivElement; |
24 | 30 |
|
25 | 31 | $: tableOffset = tableContainer?.offsetTop |
26 | | - ? tableContainer?.offsetTop + 32 |
| 32 | + ? tableContainer.offsetTop + 32 |
27 | 33 | : 0; |
28 | 34 | </script> |
29 | 35 |
|
30 | 36 | <div |
31 | | - class="paginated-table-wrapper" |
| 37 | + class={merge( |
| 38 | + 'surface-primary min-h-[154px] grow overflow-auto border border-subtle', |
| 39 | + className, |
| 40 | + )} |
32 | 41 | bind:this={tableContainer} |
33 | 42 | style="max-height: {maxHeight || `calc(100vh - ${tableOffset}px)`}" |
34 | 43 | > |
|
45 | 54 | <slot /> |
46 | 55 | </Table> |
47 | 56 | {#if visibleItems.length} |
48 | | - <div class="paginated-table-controls"> |
| 57 | + <div |
| 58 | + class="surface-primary sticky bottom-0 left-0 flex w-full grow items-center justify-between gap-2 border-t border-subtle px-4 py-2" |
| 59 | + > |
49 | 60 | <slot name="actions-start" /> |
50 | 61 | <slot name="actions-center" /> |
51 | 62 | <slot name="actions-end" /> |
|
55 | 66 | {/if} |
56 | 67 | {/if} |
57 | 68 | </div> |
58 | | - |
59 | | -<style lang="postcss"> |
60 | | - .paginated-table-wrapper { |
61 | | - @apply surface-primary min-h-[154px] grow overflow-auto border border-subtle; |
62 | | - } |
63 | | -
|
64 | | - .paginated-table-controls { |
65 | | - @apply surface-primary sticky bottom-0 left-0 flex w-full grow items-center justify-between gap-2 border-t border-subtle px-4 py-2; |
66 | | - } |
67 | | -</style> |
|
0 commit comments