Skip to content

Commit 631886b

Browse files
authoredFeb 23, 2024··
chore: add and configure size-limit (#5370)
* chore: add and configure size-limit * format * fix new svelte example
1 parent 0d36056 commit 631886b

File tree

5 files changed

+446
-37
lines changed

5 files changed

+446
-37
lines changed
 

‎examples/svelte/filtering/src/App.svelte

+38-29
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,26 @@
11
<script lang="ts">
2-
import './index.css';
3-
import { writable } from 'svelte/store';
2+
import './index.css'
3+
import { writable } from 'svelte/store'
44
5-
import './index.css';
5+
import './index.css'
66
77
import {
88
createSvelteTable,
99
flexRender,
1010
getCoreRowModel,
11-
getFilteredRowModel,
12-
getPaginationRowModel,
13-
type FilterFn
14-
} from '@tanstack/svelte-table';
11+
getFilteredRowModel,
12+
getPaginationRowModel,
13+
} from '@tanstack/svelte-table'
1514
16-
import { type RankingInfo, rankItem } from '@tanstack/match-sorter-utils';
15+
import type {
16+
ColumnDef,
17+
TableOptions,
18+
FilterFn,
19+
} from '@tanstack/svelte-table'
1720
18-
import { makeData, type Person } from './makeData';
21+
import { rankItem } from '@tanstack/match-sorter-utils'
1922
20-
declare module '@tanstack/table-core' {
21-
interface FilterFns {
22-
fuzzy: FilterFn<unknown>;
23-
}
24-
interface FilterMeta {
25-
itemRank: RankingInfo;
26-
}
27-
}
23+
import { makeData, type Person } from './makeData'
2824
2925
let globalFilter = ''
3026
@@ -39,18 +35,20 @@ import './index.css';
3935
return itemRank.passed
4036
}
4137
38+
let columns: ColumnDef<Person>[] = [
39+
{
40+
accessorFn: row => `${row.firstName} ${row.lastName}`,
41+
id: 'fullName',
42+
header: 'Name',
43+
cell: info => info.getValue(),
44+
footer: props => props.column.id,
45+
filterFn: 'fuzzy',
46+
},
47+
]
48+
4249
const options = writable<TableOptions<any>>({
4350
data: makeData(25),
44-
columns: [
45-
{
46-
accessorFn: (row) => `${row.firstName} ${row.lastName}`,
47-
id: 'fullName',
48-
header: 'Name',
49-
cell: (info) => info.getValue(),
50-
footer: (props) => props.column.id,
51-
filterFn: 'fuzzy',
52-
},
53-
],
51+
columns,
5452
filterFns: {
5553
fuzzy: fuzzyFilter,
5654
},
@@ -62,8 +60,19 @@ import './index.css';
6260
})
6361
6462
const table = createSvelteTable(options)
63+
64+
const handleKeyUp = (e: any) => {
65+
$table.setGlobalFilter(String(e?.target?.value))
66+
}
6567
</script>
66-
<input type="text" placeholder="Global filter" class="border w-full p-1" bind:value={globalFilter} on:keyup={(e) => $table.setGlobalFilter(String(e.target.value))} />
68+
69+
<input
70+
type="text"
71+
placeholder="Global filter"
72+
class="border w-full p-1"
73+
bind:value={globalFilter}
74+
on:keyup={handleKeyUp}
75+
/>
6776
<div class="h-2" />
6877
<table class="w-full">
6978
<thead>
@@ -99,4 +108,4 @@ import './index.css';
99108
</tbody>
100109
</table>
101110
<div class="h-2" />
102-
<pre>"globalFilter": "{$table.getState().globalFilter}"</pre>
111+
<pre>"globalFilter": "{$table.getState().globalFilter}"</pre>

‎examples/svelte/filtering/src/main.ts

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
// @ts-ignore
22
import App from './App.svelte'
33

4+
import type { FilterFn } from '@tanstack/svelte-table'
5+
6+
import type { RankingInfo } from '@tanstack/match-sorter-utils'
7+
8+
declare module '@tanstack/svelte-table' {
9+
interface FilterFns {
10+
fuzzy: FilterFn<unknown>
11+
}
12+
interface FilterMeta {
13+
itemRank: RankingInfo
14+
}
15+
}
16+
417
const app = new App({
518
target: document.getElementById('root')!,
619
})

‎knip.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"$schema": "https://unpkg.com/knip@4/schema.json",
3+
"ignoreDependencies": ["size-limit", "@size-limit/preset-small-lib"],
34
"ignoreWorkspaces": ["examples/**"],
45
"workspaces": {
56
"packages/match-sorter-utils": {

‎package.json

+15-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "table",
3+
"namespace": "@tanstack",
34
"private": true,
45
"repository": "https://github.com/tanstack/table.git",
56
"packageManager": "pnpm@8.12.1",
@@ -16,8 +17,8 @@
1617
"test:lib:dev": "pnpm test:lib && nx watch --all -- pnpm test:lib",
1718
"test:types": "nx affected --targets=test:types --exclude=examples/**",
1819
"test:knip": "knip",
19-
"build": "nx affected --targets=build --exclude=examples/**",
20-
"build:all": "nx run-many --targets=build --exclude=examples/**",
20+
"build": "nx affected --targets=build --exclude=examples/** && size-limit",
21+
"build:all": "nx run-many --targets=build --exclude=examples/** && size-limit",
2122
"watch": "pnpm run build:all && nx watch --all -- pnpm run build:all",
2223
"dev": "pnpm run watch",
2324
"prettier": "prettier --ignore-unknown '**/*'",
@@ -31,7 +32,16 @@
3132
"test:sherif"
3233
]
3334
},
34-
"namespace": "@tanstack",
35+
"size-limit": [
36+
{
37+
"path": "packages/table-core/build/lib/index.js",
38+
"limit": "16 KB"
39+
},
40+
{
41+
"path": "packages/table-core/build/lib/index.mjs",
42+
"limit": "15 KB"
43+
}
44+
],
3545
"devDependencies": {
3646
"@babel/core": "^7.23.7",
3747
"@babel/preset-env": "^7.23.8",
@@ -43,6 +53,7 @@
4353
"@rollup/plugin-node-resolve": "^15.2.3",
4454
"@rollup/plugin-replace": "^5.0.5",
4555
"@rollup/plugin-terser": "^0.4.4",
56+
"@size-limit/preset-small-lib": "^11.0.2",
4657
"@tanstack/config": "^0.4.2",
4758
"@testing-library/jest-dom": "^6.2.0",
4859
"@testing-library/react": "^14.1.2",
@@ -63,6 +74,7 @@
6374
"rollup-plugin-svelte": "^7.1.6",
6475
"rollup-plugin-visualizer": "^5.12.0",
6576
"sherif": "^0.7.0",
77+
"size-limit": "^11.0.2",
6678
"svelte": "^4.2.8",
6779
"typescript": "5.3.3",
6880
"vitest": "^1.2.0"

‎pnpm-lock.yaml

+379-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
Please sign in to comment.