darabos commited on
Commit
bdf2455
·
1 Parent(s): dc3ebef

Use Tabulator for tables.

Browse files
web/package-lock.json CHANGED
@@ -15,7 +15,8 @@
15
  "bootstrap": "^5.3.3",
16
  "echarts": "^5.5.0",
17
  "fuse.js": "^7.0.0",
18
- "svelte-echarts": "^1.0.0-rc1"
 
19
  },
20
  "devDependencies": {
21
  "@sveltejs/vite-plugin-svelte": "^3.0.2",
@@ -2118,6 +2119,11 @@
2118
  }
2119
  }
2120
  },
 
 
 
 
 
2121
  "node_modules/to-regex-range": {
2122
  "version": "5.0.1",
2123
  "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
@@ -3860,6 +3866,11 @@
3860
  "strip-indent": "^3.0.0"
3861
  }
3862
  },
 
 
 
 
 
3863
  "to-regex-range": {
3864
  "version": "5.0.1",
3865
  "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
 
15
  "bootstrap": "^5.3.3",
16
  "echarts": "^5.5.0",
17
  "fuse.js": "^7.0.0",
18
+ "svelte-echarts": "^1.0.0-rc1",
19
+ "tabulator-tables": "^6.2.1"
20
  },
21
  "devDependencies": {
22
  "@sveltejs/vite-plugin-svelte": "^3.0.2",
 
2119
  }
2120
  }
2121
  },
2122
+ "node_modules/tabulator-tables": {
2123
+ "version": "6.2.1",
2124
+ "resolved": "https://registry.npmjs.org/tabulator-tables/-/tabulator-tables-6.2.1.tgz",
2125
+ "integrity": "sha512-iCyLUzE9xEesEWqHDzNgShr6fpIIsRXnvTSDxiEti3sVbVYwlRt5HTBnXsl8bxY+4p64Rxxdlk9jT3voNLcIZQ=="
2126
+ },
2127
  "node_modules/to-regex-range": {
2128
  "version": "5.0.1",
2129
  "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
 
3866
  "strip-indent": "^3.0.0"
3867
  }
3868
  },
3869
+ "tabulator-tables": {
3870
+ "version": "6.2.1",
3871
+ "resolved": "https://registry.npmjs.org/tabulator-tables/-/tabulator-tables-6.2.1.tgz",
3872
+ "integrity": "sha512-iCyLUzE9xEesEWqHDzNgShr6fpIIsRXnvTSDxiEti3sVbVYwlRt5HTBnXsl8bxY+4p64Rxxdlk9jT3voNLcIZQ=="
3873
+ },
3874
  "to-regex-range": {
3875
  "version": "5.0.1",
3876
  "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
web/package.json CHANGED
@@ -28,6 +28,7 @@
28
  "bootstrap": "^5.3.3",
29
  "echarts": "^5.5.0",
30
  "fuse.js": "^7.0.0",
31
- "svelte-echarts": "^1.0.0-rc1"
 
32
  }
33
  }
 
28
  "bootstrap": "^5.3.3",
29
  "echarts": "^5.5.0",
30
  "fuse.js": "^7.0.0",
31
+ "svelte-echarts": "^1.0.0-rc1",
32
+ "tabulator-tables": "^6.2.1"
33
  }
34
  }
web/src/NodeWithTableView.svelte CHANGED
@@ -2,6 +2,7 @@
2
  import { type NodeProps } from '@xyflow/svelte';
3
  import { Tabulator } from 'tabulator-tables';
4
  import LynxKiteNode from './LynxKiteNode.svelte';
 
5
  type $$Props = NodeProps;
6
  export let data: $$Props['data'];
7
  const open = {};
@@ -13,24 +14,7 @@
13
  {#each Object.entries(data.view.dataframes) as [name, df]}
14
  {#if !single}<div class="df-head" on:click={() => open[name] = !open[name]}>{name}</div>{/if}
15
  {#if single || open[name]}
16
- <table class="table table-striped">
17
- <thead>
18
- <tr>
19
- {#each df.columns as column}
20
- <th>{column}</th>
21
- {/each}
22
- </tr>
23
- </thead>
24
- <tbody>
25
- {#each df.data as row}
26
- <tr>
27
- {#each row as cell}
28
- <td><div class="text-truncate">{cell}</div></td>
29
- {/each}
30
- </tr>
31
- {/each}
32
- </tbody>
33
- </table>
34
  {/if}
35
  {/each}
36
  {#each Object.entries(data.view.others || {}) as [name, o]}
 
2
  import { type NodeProps } from '@xyflow/svelte';
3
  import { Tabulator } from 'tabulator-tables';
4
  import LynxKiteNode from './LynxKiteNode.svelte';
5
+ import Table from './Table.svelte';
6
  type $$Props = NodeProps;
7
  export let data: $$Props['data'];
8
  const open = {};
 
14
  {#each Object.entries(data.view.dataframes) as [name, df]}
15
  {#if !single}<div class="df-head" on:click={() => open[name] = !open[name]}>{name}</div>{/if}
16
  {#if single || open[name]}
17
+ <Table columns={df.columns} data={df.data} />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  {/if}
19
  {/each}
20
  {#each Object.entries(data.view.others || {}) as [name, o]}
web/src/Table.svelte ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script>
2
+ import {TabulatorFull as Tabulator} from 'tabulator-tables';
3
+ import {onMount} from 'svelte';
4
+
5
+ export let data, columns;
6
+
7
+ let tableComponent;
8
+ let tab;
9
+
10
+ onMount(() => {
11
+ console.log(data, columns);
12
+ // The rows in the data are arrays, but Tabulator expects objects.
13
+ const objs = [];
14
+ for (const row of data) {
15
+ const obj = {};
16
+ for (let i = 0; i < columns.length; i++) {
17
+ obj[columns[i]] = row[i];
18
+ }
19
+ objs.push(obj);
20
+ }
21
+ tab = new Tabulator(tableComponent, {
22
+ data: objs,
23
+ columns: columns.map(c => ({title: c, field: c, widthGrow: 1})),
24
+ height: '311px',
25
+ reactiveData: true,
26
+ layout: "fitColumns",
27
+ });
28
+ });
29
+ </script>
30
+
31
+ <div bind:this={tableComponent}></div>
web/src/app.scss CHANGED
@@ -1,6 +1,7 @@
1
  // Import all of Bootstrap's CSS
2
  $form-select-indicator-color: oklch(90% 0.01 55);
3
  @import "bootstrap/scss/bootstrap";
 
4
  :root {
5
  --bs-border-color: oklch(90% 0.01 55);
6
  }
 
1
  // Import all of Bootstrap's CSS
2
  $form-select-indicator-color: oklch(90% 0.01 55);
3
  @import "bootstrap/scss/bootstrap";
4
+ @import "tabulator-tables";
5
  :root {
6
  --bs-border-color: oklch(90% 0.01 55);
7
  }