diff --git a/docs/config.json b/docs/config.json index 95c0ad6acb..e2393b7fdc 100644 --- a/docs/config.json +++ b/docs/config.json @@ -434,6 +434,10 @@ "to": "framework/svelte/examples/column-visibility", "label": "Column Visibility" }, + { + "to": "framework/svelte/examples/filtering", + "label": "Filtering" + }, { "to": "framework/svelte/examples/sorting", "label": "Sorting" diff --git a/examples/svelte/filtering/.gitignore b/examples/svelte/filtering/.gitignore new file mode 100644 index 0000000000..91c18232e2 --- /dev/null +++ b/examples/svelte/filtering/.gitignore @@ -0,0 +1,8 @@ +node_modules +.DS_Store +dist +dist-ssr +*.local + +src/**/*.d.ts +src/**/*.map \ No newline at end of file diff --git a/examples/svelte/filtering/README.md b/examples/svelte/filtering/README.md new file mode 100644 index 0000000000..b168d3c4b1 --- /dev/null +++ b/examples/svelte/filtering/README.md @@ -0,0 +1,6 @@ +# Example + +To run this example: + +- `npm install` or `yarn` +- `npm run start` or `yarn start` diff --git a/examples/svelte/filtering/index.html b/examples/svelte/filtering/index.html new file mode 100644 index 0000000000..6ab1dd7e51 --- /dev/null +++ b/examples/svelte/filtering/index.html @@ -0,0 +1,14 @@ + + +
+ + +|
+ {#if !header.isPlaceholder}
+ |
+ {/each}
+
|---|
|
+ |
+ {/each}
+
"globalFilter": "{$table.getState().globalFilter}"
\ No newline at end of file
diff --git a/examples/svelte/filtering/src/index.css b/examples/svelte/filtering/src/index.css
new file mode 100644
index 0000000000..43c09e0f6b
--- /dev/null
+++ b/examples/svelte/filtering/src/index.css
@@ -0,0 +1,26 @@
+html {
+ font-family: sans-serif;
+ font-size: 14px;
+}
+
+table {
+ border: 1px solid lightgray;
+}
+
+tbody {
+ border-bottom: 1px solid lightgray;
+}
+
+th {
+ border-bottom: 1px solid lightgray;
+ border-right: 1px solid lightgray;
+ padding: 2px 4px;
+}
+
+tfoot {
+ color: gray;
+}
+
+tfoot th {
+ font-weight: normal;
+}
diff --git a/examples/svelte/filtering/src/main.ts b/examples/svelte/filtering/src/main.ts
new file mode 100644
index 0000000000..4a5606b9a2
--- /dev/null
+++ b/examples/svelte/filtering/src/main.ts
@@ -0,0 +1,8 @@
+// @ts-ignore
+import App from './App.svelte'
+
+const app = new App({
+ target: document.getElementById('root')!,
+})
+
+export default app
diff --git a/examples/svelte/filtering/src/makeData.ts b/examples/svelte/filtering/src/makeData.ts
new file mode 100644
index 0000000000..331dd1eb19
--- /dev/null
+++ b/examples/svelte/filtering/src/makeData.ts
@@ -0,0 +1,48 @@
+import { faker } from '@faker-js/faker'
+
+export type Person = {
+ firstName: string
+ lastName: string
+ age: number
+ visits: number
+ progress: number
+ status: 'relationship' | 'complicated' | 'single'
+ subRows?: Person[]
+}
+
+const range = (len: number) => {
+ const arr: number[] = []
+ for (let i = 0; i < len; i++) {
+ arr.push(i)
+ }
+ return arr
+}
+
+const newPerson = (): Person => {
+ return {
+ firstName: faker.person.firstName(),
+ lastName: faker.person.lastName(),
+ age: faker.number.int(40),
+ visits: faker.number.int(1000),
+ progress: faker.number.int(100),
+ status: faker.helpers.shuffle