Skip to content

Commit ae7be4e

Browse files
committed
Add AFL data; lint fixes
1 parent 625c969 commit ae7be4e

File tree

6 files changed

+89536
-15
lines changed

6 files changed

+89536
-15
lines changed

TODO

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
- Extract out context menu
22
- Extract out cell content
3-
- Lift cell component to top level?
3+
- Lift cell component to top level?
4+
- Column auto-sizing
5+
- Fix reactivity in Basic Usage story

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@
5858
"solid-js": "^1.6.0"
5959
},
6060
"devDependencies": {
61+
"@storybook/addon-a11y": "^10.2.7",
6162
"@storybook/addon-docs": "10.2.7",
6263
"@testing-library/jest-dom": "^6.9.1",
6364
"@types/node": "^25.2.1",
65+
"@types/papaparse": "^5.5.2",
6466
"@typescript-eslint/eslint-plugin": "^8.54.0",
6567
"@typescript-eslint/parser": "^8.54.0",
6668
"concurrently": "^9.2.1",
@@ -81,8 +83,7 @@
8183
"vite": "^7.3.1",
8284
"vite-plugin-solid": "^2.11.10",
8385
"vite-tsconfig-paths": "^6.0.5",
84-
"vitest": "^4.0.18",
85-
"@storybook/addon-a11y": "^10.2.7"
86+
"vitest": "^4.0.18"
8687
},
8788
"keywords": [
8889
"solid"
@@ -96,6 +97,7 @@
9697
"@kobalte/core": "^0.13.11",
9798
"@tanstack/solid-virtual": "^3.13.18",
9899
"clsx": "^2.1.1",
100+
"papaparse": "^5.5.3",
99101
"radashi": "^12.7.1"
100102
}
101103
}

pnpm-lock.yaml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/lib/clipboard.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ export async function pasteTableFromClipboard(): Promise<string[][] | null> {
4343
return parseTextTable(text)
4444
}
4545
}
46-
} catch (e) {
46+
} catch (_err) {
4747
// Ignore error, try readText
4848
}
4949

5050
try {
5151
const text = await navigator.clipboard.readText()
5252
return parseTextTable(text)
53-
} catch (e) {
54-
console.error('Failed to read clipboard', e)
53+
} catch (_err) {
54+
// console.error('Failed to read clipboard', e)
5555
return null
5656
}
5757
}

src/stories/Table.stories.tsx

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
import { createSignal } from 'solid-js'
1+
import { createSignal, onMount } from 'solid-js'
22
import type { Meta, StoryObj } from 'storybook-solidjs-vite'
33
import { fn } from 'storybook/test'
44
import { ActiveRange, Table } from 'src'
5+
import Papa from 'papaparse'
56

67
const meta = {
78
args: {
8-
columns: ['A', 'B', 'C', 'D', 'E'],
9-
numRows: 10,
109
accentColor: '#de3b84',
1110
setCellValue: fn(),
1211
},
1312
render: props => {
1413
const [activeRange, setActiveRange] = createSignal<ActiveRange>()
1514
const [widths, setWidths] = createSignal(new Map<string, number>())
1615

16+
const [data, setData] = createSignal<Record<string, unknown>[]>(props.data ?? [])
17+
18+
onMount(() => {
19+
if (!props.url) return
20+
fetch(props.url)
21+
.then(resp => (resp.ok ? resp.text() : ''))
22+
.then(raw => {
23+
const parsed = Papa.parse<Record<string, unknown>>(raw, {
24+
header: true,
25+
skipEmptyLines: true,
26+
})
27+
setData(parsed.data)
28+
})
29+
})
30+
1731
return (
1832
<div
1933
style={{
@@ -24,8 +38,11 @@ const meta = {
2438
}}
2539
>
2640
<Table
27-
{...props}
28-
getCellValue={(row, col) => `${col}${row}`}
41+
columns={Object.keys(data()[0] ?? {})}
42+
numRows={data().length}
43+
getCellValue={(row, col) => data()[row]![col]!}
44+
// getCellValue={(row, col) => `${col}${row}`}
45+
setCellValue={props.setCellValue}
2946
activeRange={activeRange()}
3047
setActiveRange={setActiveRange}
3148
getColumnSize={col => widths().get(col)}
@@ -38,16 +55,27 @@ const meta = {
3855
)
3956
},
4057
} satisfies Meta<{
41-
columns: string[]
42-
numRows: number
58+
data?: Record<string, unknown>[]
59+
url?: string
4360
accentColor: string
44-
setCellValue: (row: number, column: string, value: string) => void
61+
setCellValue: (row: number, column: string, value: unknown) => void
4562
}>
4663

4764
export default meta
4865

4966
type Story = StoryObj<typeof meta>
5067

5168
export const BasicUsage = {
52-
args: {},
69+
args: {
70+
data: [
71+
{ A: 1, B: 2, C: 3 },
72+
{ A: 4, B: 5, C: 6 },
73+
],
74+
},
75+
} satisfies Story
76+
77+
export const MediumSizedTable = {
78+
args: {
79+
url: new URL('/src/stories/stats.csv', import.meta.url),
80+
},
5381
} satisfies Story

0 commit comments

Comments
 (0)