|
2 | 2 | import type { Table } from '$lib/olap-engine';
|
3 | 3 |
|
4 | 4 | import SearchBar from '$lib/components/SearchBar.svelte';
|
5 |
| - import TableC from '$lib/icons/Table.svelte'; |
6 |
| - import { filter } from './utils'; |
| 5 | + import { buildTree, filter } from './utils'; |
| 6 | + import Tree from './Tree.svelte'; |
7 | 7 |
|
8 | 8 | type Props = {
|
9 | 9 | tables?: Table[];
|
|
13 | 13 |
|
14 | 14 | let search = $state<string>('');
|
15 | 15 | const filtered = $derived(filter(tables, search));
|
| 16 | + const tree = $derived(buildTree(filtered)); |
16 | 17 | </script>
|
17 | 18 |
|
18 | 19 | <SearchBar bind:value={search} />
|
19 |
| -<article> |
20 |
| - {#each filtered as source, i (source.name)} |
21 |
| - <details open={i === 0}> |
22 |
| - <summary> |
23 |
| - <TableC size={15} stroke="#ccc" style="flex-shrink: 0;" /> |
24 |
| - <h3>{source.name}</h3> |
25 |
| - </summary> |
26 |
| - <ul> |
27 |
| - {#each source.columns ?? [] as column} |
28 |
| - <li> |
29 |
| - <span>{column.name}</span> |
30 |
| - <span>{column.type.replace(/Nullable\((.*)\)/i, '$1')}</span> |
31 |
| - </li> |
32 |
| - {/each} |
33 |
| - </ul> |
34 |
| - </details> |
35 |
| - {/each} |
36 |
| -</article> |
37 | 20 |
|
38 |
| -<style> |
39 |
| - article { |
40 |
| - font-family: monospace; |
41 |
| - font-size: 10px; |
42 |
| - flex: 1; |
43 |
| - overflow-y: auto; |
44 |
| - } |
45 |
| -
|
46 |
| - details { |
47 |
| - width: 100%; |
48 |
| -
|
49 |
| - details ~ & { |
50 |
| - margin-top: 12px; |
51 |
| - } |
52 |
| - } |
53 |
| -
|
54 |
| - summary { |
55 |
| - cursor: pointer; |
56 |
| - user-select: none; |
57 |
| - -webkit-user-select: none; |
58 |
| - display: flex; |
59 |
| - align-items: center; |
60 |
| - gap: 5px; |
61 |
| -
|
62 |
| - padding: 3px 0px; |
63 |
| - border-radius: 3px; |
64 |
| -
|
65 |
| - &::-webkit-details-marker { |
66 |
| - display: none; |
67 |
| - } |
68 |
| -
|
69 |
| - & > h3 { |
70 |
| - flex-shrink: 1; |
71 |
| -
|
72 |
| - text-overflow: ellipsis; |
73 |
| - white-space: nowrap; |
74 |
| - overflow: hidden; |
75 |
| - } |
76 |
| - } |
77 |
| -
|
78 |
| - h3 { |
79 |
| - color: hsl(0deg 0% 90%); |
80 |
| - font-size: 11px; |
81 |
| - font-weight: 500; |
82 |
| - margin: 0; |
83 |
| - } |
84 |
| -
|
85 |
| - ul { |
86 |
| - /* Reset */ |
87 |
| - list-style: none; |
88 |
| - margin: 0; |
89 |
| - padding: 0; |
90 |
| -
|
91 |
| - /* Stack */ |
92 |
| - display: flex; |
93 |
| - flex-direction: column; |
94 |
| - gap: 5px; |
95 |
| -
|
96 |
| - /* Custom style */ |
97 |
| - padding: 12px 0; |
98 |
| - color: hsl(0deg 0% 75%); |
99 |
| -
|
100 |
| - & > li { |
101 |
| - display: flex; |
102 |
| - align-items: center; |
103 |
| -
|
104 |
| - & > span:first-of-type { |
105 |
| - flex-grow: 1; |
106 |
| - } |
107 |
| -
|
108 |
| - & > span:last-of-type { |
109 |
| - font-size: 8px; |
110 |
| - font-weight: 500; |
111 |
| - padding: 2px; |
112 |
| - border-radius: 3px; |
113 |
| - background-color: hsl(0deg 0% 10%); |
114 |
| - color: hsl(0deg 0% 75%); |
115 |
| - text-align: center; |
116 |
| - flex-shrink: 1; |
117 |
| -
|
118 |
| - text-overflow: ellipsis; |
119 |
| - white-space: nowrap; |
120 |
| - overflow: hidden; |
121 |
| - } |
122 |
| - } |
123 |
| -
|
124 |
| - &:last-of-type { |
125 |
| - padding-bottom: 0; |
126 |
| - } |
127 |
| - } |
128 |
| -</style> |
| 21 | +{#each tree as node} |
| 22 | + <Tree {node} /> |
| 23 | +{/each} |
0 commit comments