@kayord/ui 0.15.7 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,10 +12,10 @@
12
12
  import { cn } from "../../../utils";
13
13
  import { tableStore } from "./table.svelte";
14
14
  import DataTableHeader from "./DataTableHeader.svelte";
15
+ import type { ShadTable } from "./shad-table.svelte";
15
16
 
16
17
  interface Props<T> {
17
- table: TableType<T>;
18
- columns: ColumnDef<T>[];
18
+ tableState: ShadTable<T>;
19
19
  isLoading?: boolean;
20
20
  header?: Snippet;
21
21
  subHeader?: Snippet;
@@ -32,8 +32,7 @@
32
32
  }
33
33
 
34
34
  let {
35
- table = $bindable(),
36
- columns,
35
+ tableState = $bindable(),
37
36
  isLoading = false,
38
37
  header,
39
38
  subHeader,
@@ -49,8 +48,8 @@
49
48
  disableUISorting = false,
50
49
  }: Props<T> = $props();
51
50
 
52
- const isPaginationEnabled = table.options.getPaginationRowModel !== undefined;
53
- const enableRowSelection = table.options.enableRowSelection;
51
+ const isPaginationEnabled = tableState.table.options.getPaginationRowModel !== undefined;
52
+ const enableRowSelection = tableState.table.options.enableRowSelection;
54
53
 
55
54
  if (enableRowSelection) {
56
55
  const rowSelectionColumn: ColumnDef<T> = {
@@ -58,8 +57,8 @@
58
57
  // cell: (info) => "[]",
59
58
  header: () =>
60
59
  renderComponent(DataTableCheckbox, {
61
- checked: table.getIsAllPageRowsSelected(),
62
- onCheckedChange: () => table.toggleAllPageRowsSelected(),
60
+ checked: tableState.table.getIsAllPageRowsSelected(),
61
+ onCheckedChange: () => tableState.table.toggleAllPageRowsSelected(),
63
62
  }),
64
63
  cell: (r) =>
65
64
  renderComponent(DataTableCheckbox, {
@@ -69,7 +68,7 @@
69
68
  enableResizing: false,
70
69
  enableSorting: false,
71
70
  };
72
- columns.unshift(rowSelectionColumn);
71
+ tableState.columns.unshift(rowSelectionColumn);
73
72
  }
74
73
  </script>
75
74
 
@@ -97,7 +96,7 @@
97
96
  {/if}
98
97
  {#if enableVisibility}
99
98
  <div>
100
- <VisibilitySelect bind:table />
99
+ <VisibilitySelect bind:tableState />
101
100
  </div>
102
101
  {/if}
103
102
  {#if enableFullscreen}
@@ -124,10 +123,10 @@
124
123
  <Table.Root class="table-auto">
125
124
  {#if !hideHeader}
126
125
  <Table.Header>
127
- {#each table.getHeaderGroups() as headerGroup, headerGroupIndex}
126
+ {#each tableState.table.getHeaderGroups() as headerGroup, headerGroupIndex}
128
127
  <Table.Row>
129
128
  {#each headerGroup.headers as header, headerIndex}
130
- <DataTableHeader {headerGroupIndex} {headerIndex} bind:table {disableUISorting} />
129
+ <DataTableHeader {headerGroupIndex} {headerIndex} bind:tableState {disableUISorting} />
131
130
  {/each}
132
131
  </Table.Row>
133
132
  {/each}
@@ -135,10 +134,10 @@
135
134
  {/if}
136
135
 
137
136
  <Table.Body>
138
- {#if isLoading && table.getRowModel().rows.length == 0}
137
+ {#if isLoading && tableState.table.getRowModel().rows.length == 0}
139
138
  {#each { length: 5 } as _, i}
140
139
  <Table.Row>
141
- {#each columns as _cell}
140
+ {#each tableState.columns as _cell}
142
141
  <Table.Cell>
143
142
  <Skeleton class="h-4" />
144
143
  </Table.Cell>
@@ -146,14 +145,14 @@
146
145
  </Table.Row>
147
146
  {/each}
148
147
  {:else}
149
- {#if table.getRowModel().rows.length == 0}
148
+ {#if tableState.table.getRowModel().rows.length == 0}
150
149
  <Table.Row>
151
- <Table.Cell colspan={table.getAllColumns().length}>
150
+ <Table.Cell colspan={tableState.table.getAllColumns().length}>
152
151
  <div class="text-center">{noDataMessage}</div>
153
152
  </Table.Cell>
154
153
  </Table.Row>
155
154
  {/if}
156
- {#each table.getRowModel().rows as row}
155
+ {#each tableState.table.getRowModel().rows as row}
157
156
  <Table.Row data-state={row.getIsSelected() && "selected"}>
158
157
  {#each row.getVisibleCells() as cell}
159
158
  <Table.Cell
@@ -174,7 +173,7 @@
174
173
  {/if}
175
174
  </div>
176
175
  {#if isPaginationEnabled}
177
- <Pagination bind:table />
176
+ <Pagination bind:tableState />
178
177
  {/if}
179
178
 
180
179
  {#if footer}
@@ -1,8 +1,7 @@
1
- import { type ColumnDef, type Table as TableType } from "@tanstack/table-core";
2
1
  import type { Snippet } from "svelte";
2
+ import type { ShadTable } from "./shad-table.svelte";
3
3
  interface Props<T> {
4
- table: TableType<T>;
5
- columns: ColumnDef<T>[];
4
+ tableState: ShadTable<T>;
6
5
  isLoading?: boolean;
7
6
  header?: Snippet;
8
7
  subHeader?: Snippet;
@@ -21,7 +20,7 @@ declare class __sveltets_Render<T> {
21
20
  props(): Props<T>;
22
21
  events(): {};
23
22
  slots(): {};
24
- bindings(): "table";
23
+ bindings(): "tableState";
25
24
  exports(): {};
26
25
  }
27
26
  interface $$IsomorphicComponent {
@@ -2,19 +2,22 @@
2
2
  import { FlexRender, Table } from "../../..";
3
3
  import { type Header, type Table as TypeType } from "@tanstack/table-core";
4
4
  import { ArrowUpDownIcon, ArrowDownIcon, ArrowUpIcon } from "@lucide/svelte";
5
+ import type { ShadTable } from "./shad-table.svelte";
5
6
 
6
7
  interface Props<T> {
7
8
  headerGroupIndex: number;
8
9
  headerIndex: number;
9
- table: TypeType<T>;
10
+ tableState: ShadTable<T>;
10
11
  disableUISorting?: boolean;
11
12
  }
12
13
 
13
- let { headerGroupIndex, headerIndex, table = $bindable(), disableUISorting = false }: Props<T> = $props();
14
+ let { headerGroupIndex, headerIndex, tableState = $bindable(), disableUISorting = false }: Props<T> = $props();
14
15
 
15
- const isSortingEnabled = $derived(table.options.getSortedRowModel !== undefined && disableUISorting !== true);
16
+ const isSortingEnabled = $derived(
17
+ tableState.table.options.getSortedRowModel !== undefined && disableUISorting !== true
18
+ );
16
19
 
17
- const header = table.getHeaderGroups()[headerGroupIndex].headers[headerIndex];
20
+ const header = tableState.table.getHeaderGroups()[headerGroupIndex].headers[headerIndex];
18
21
  </script>
19
22
 
20
23
  <Table.Head
@@ -1,15 +1,15 @@
1
- import { type Table as TypeType } from "@tanstack/table-core";
1
+ import type { ShadTable } from "./shad-table.svelte";
2
2
  interface Props<T> {
3
3
  headerGroupIndex: number;
4
4
  headerIndex: number;
5
- table: TypeType<T>;
5
+ tableState: ShadTable<T>;
6
6
  disableUISorting?: boolean;
7
7
  }
8
8
  declare class __sveltets_Render<T> {
9
9
  props(): Props<T>;
10
10
  events(): {};
11
11
  slots(): {};
12
- bindings(): "table";
12
+ bindings(): "tableState";
13
13
  exports(): {};
14
14
  }
15
15
  interface $$IsomorphicComponent {
@@ -5,22 +5,23 @@
5
5
  import DoubleArrowLeft from "@lucide/svelte/icons/arrow-left";
6
6
  import DoubleArrowRight from "@lucide/svelte/icons/arrow-right";
7
7
  import { Select, Button } from "../../..";
8
+ import type { ShadTable } from "./shad-table.svelte";
8
9
 
9
10
  interface Props<T> {
10
- table: Table<T>;
11
+ tableState: ShadTable<T>;
11
12
  canChangePageSize?: boolean;
12
13
  }
13
14
 
14
- let { table = $bindable(), canChangePageSize = false }: Props<T> = $props();
15
+ let { tableState = $bindable(), canChangePageSize = false }: Props<T> = $props();
15
16
 
16
- let value = $state(table.getState().pagination.pageSize.toString());
17
+ let value = $state(tableState.table.getState().pagination.pageSize.toString());
17
18
  </script>
18
19
 
19
20
  <div class="flex items-center justify-between py-2">
20
21
  <div class="text-muted-foreground flex-1 text-sm">
21
- {#if table.options.enableRowSelection}
22
- {table.getFilteredSelectedRowModel().rows.length} of
23
- {table.getFilteredRowModel().rows.length} row(s) selected.
22
+ {#if tableState.table.options.enableRowSelection}
23
+ {tableState.table.getFilteredSelectedRowModel().rows.length} of
24
+ {tableState.table.getFilteredRowModel().rows.length} row(s) selected.
24
25
  {/if}
25
26
  </div>
26
27
  <div class="flex items-center space-x-6 lg:space-x-8">
@@ -31,7 +32,7 @@
31
32
  type="single"
32
33
  bind:value
33
34
  onValueChange={(value) => {
34
- table.setPageSize(Number(value));
35
+ tableState.table.setPageSize(Number(value));
35
36
  }}
36
37
  >
37
38
  <Select.Trigger class="h-8 w-[70px]">Select page size</Select.Trigger>
@@ -46,15 +47,15 @@
46
47
  {/if}
47
48
  </div>
48
49
  <div class="flex w-[100px] items-center justify-center text-sm font-medium">
49
- Page {table.getState().pagination.pageIndex + 1} of
50
- {table.getPageCount()}
50
+ Page {tableState.table.getState().pagination.pageIndex + 1} of
51
+ {tableState.table.getPageCount()}
51
52
  </div>
52
53
  <div class="flex items-center space-x-2">
53
54
  <Button
54
55
  variant="outline"
55
56
  class="hidden size-8 p-0 lg:flex"
56
- onclick={() => table.setPageIndex(0)}
57
- disabled={!table.getCanPreviousPage()}
57
+ onclick={() => tableState.table.setPageIndex(0)}
58
+ disabled={!tableState.table.getCanPreviousPage()}
58
59
  >
59
60
  <span class="sr-only">Go to first page</span>
60
61
  <DoubleArrowLeft class="size-4" />
@@ -62,21 +63,26 @@
62
63
  <Button
63
64
  variant="outline"
64
65
  class="size-8 p-0"
65
- onclick={() => table.previousPage()}
66
- disabled={!table.getCanPreviousPage()}
66
+ onclick={() => tableState.table.previousPage()}
67
+ disabled={!tableState.table.getCanPreviousPage()}
67
68
  >
68
69
  <span class="sr-only">Go to previous page</span>
69
70
  <ChevronLeft class="size-4" />
70
71
  </Button>
71
- <Button variant="outline" class="size-8 p-0" onclick={() => table.nextPage()} disabled={!table.getCanNextPage()}>
72
+ <Button
73
+ variant="outline"
74
+ class="size-8 p-0"
75
+ onclick={() => tableState.table.nextPage()}
76
+ disabled={!tableState.table.getCanNextPage()}
77
+ >
72
78
  <span class="sr-only">Go to next page</span>
73
79
  <ChevronRight class="size-4" />
74
80
  </Button>
75
81
  <Button
76
82
  variant="outline"
77
83
  class="hidden size-8 p-0 lg:flex"
78
- onclick={() => table.setPageIndex(table.getPageCount() - 1)}
79
- disabled={!table.getCanNextPage()}
84
+ onclick={() => tableState.table.setPageIndex(tableState.table.getPageCount() - 1)}
85
+ disabled={!tableState.table.getCanNextPage()}
80
86
  >
81
87
  <span class="sr-only">Go to last page</span>
82
88
  <DoubleArrowRight class="size-4" />
@@ -1,13 +1,13 @@
1
- import type { Table } from "@tanstack/table-core";
1
+ import type { ShadTable } from "./shad-table.svelte";
2
2
  interface Props<T> {
3
- table: Table<T>;
3
+ tableState: ShadTable<T>;
4
4
  canChangePageSize?: boolean;
5
5
  }
6
6
  declare class __sveltets_Render<T> {
7
7
  props(): Props<T>;
8
8
  events(): {};
9
9
  slots(): {};
10
- bindings(): "table";
10
+ bindings(): "tableState";
11
11
  exports(): {};
12
12
  }
13
13
  interface $$IsomorphicComponent {
@@ -2,13 +2,13 @@
2
2
  import * as DropdownMenu from "../../ui/dropdown-menu";
3
3
  import { Button } from "../../ui/button";
4
4
  import { Settings2Icon } from "@lucide/svelte";
5
- import type { Table } from "@tanstack/table-core";
5
+ import type { ShadTable } from "./shad-table.svelte";
6
6
 
7
7
  interface Props<T> {
8
- table: Table<T>;
8
+ tableState: ShadTable<T>;
9
9
  }
10
10
 
11
- let { table = $bindable() }: Props<T> = $props();
11
+ let { tableState = $bindable() }: Props<T> = $props();
12
12
  </script>
13
13
 
14
14
  <DropdownMenu.Root>
@@ -20,7 +20,7 @@
20
20
  <DropdownMenu.Content>
21
21
  <DropdownMenu.Label>Toggle columns</DropdownMenu.Label>
22
22
  <DropdownMenu.Separator />
23
- {#each table.getAllLeafColumns() as column}
23
+ {#each tableState.table.getAllLeafColumns() as column}
24
24
  <DropdownMenu.CheckboxItem checked={column.getIsVisible()} onCheckedChange={() => column.toggleVisibility()}>
25
25
  {column.id}
26
26
  </DropdownMenu.CheckboxItem>
@@ -1,12 +1,12 @@
1
- import type { Table } from "@tanstack/table-core";
1
+ import type { ShadTable } from "./shad-table.svelte";
2
2
  interface Props<T> {
3
- table: Table<T>;
3
+ tableState: ShadTable<T>;
4
4
  }
5
5
  declare class __sveltets_Render<T> {
6
6
  props(): Props<T>;
7
7
  events(): {};
8
8
  slots(): {};
9
- bindings(): "table";
9
+ bindings(): "tableState";
10
10
  exports(): {};
11
11
  }
12
12
  interface $$IsomorphicComponent {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kayord/ui",
3
3
  "private": false,
4
- "version": "0.15.7",
4
+ "version": "0.16.0",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -47,30 +47,30 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@lucide/svelte": "^0.483.0",
50
- "@sveltejs/adapter-auto": "^4.0.0",
51
- "@sveltejs/kit": "^2.20.1",
50
+ "@sveltejs/adapter-auto": "^5.0.0",
51
+ "@sveltejs/kit": "^2.20.2",
52
52
  "@sveltejs/package": "^2.3.10",
53
53
  "@sveltejs/vite-plugin-svelte": "^5.0.3",
54
- "@tailwindcss/vite": "^4.0.14",
54
+ "@tailwindcss/vite": "^4.0.15",
55
55
  "@testing-library/jest-dom": "^6.6.3",
56
56
  "@testing-library/svelte": "^5.2.7",
57
- "@typescript-eslint/eslint-plugin": "^8.26.1",
58
- "@typescript-eslint/parser": "^8.26.1",
59
- "eslint": "^9.22.0",
57
+ "@typescript-eslint/eslint-plugin": "^8.28.0",
58
+ "@typescript-eslint/parser": "^8.28.0",
59
+ "eslint": "^9.23.0",
60
60
  "eslint-config-prettier": "^10.1.1",
61
- "eslint-plugin-svelte": "^3.3.2",
61
+ "eslint-plugin-svelte": "^3.3.3",
62
62
  "happy-dom": "^17.4.4",
63
63
  "prettier": "^3.5.3",
64
64
  "prettier-plugin-svelte": "^3.3.3",
65
65
  "prettier-plugin-tailwindcss": "^0.6.11",
66
66
  "publint": "^0.3.9",
67
- "svelte": "^5.23.2",
67
+ "svelte": "^5.25.3",
68
68
  "svelte-check": "^4.1.5",
69
- "tailwindcss": "^4.0.14",
69
+ "tailwindcss": "^4.0.15",
70
70
  "tslib": "^2.8.1",
71
71
  "tw-animate-css": "1.2.4",
72
72
  "typescript": "^5.8.2",
73
- "vite": "^6.2.2",
73
+ "vite": "^6.2.3",
74
74
  "vitest": "^3.0.9",
75
75
  "zod": "^3.24.2"
76
76
  },
@@ -78,7 +78,7 @@
78
78
  "types": "./dist/index.d.ts",
79
79
  "main": "./dist/index.js",
80
80
  "type": "module",
81
- "packageManager": "pnpm@10.6.3+sha512.bb45e34d50a9a76e858a95837301bfb6bd6d35aea2c5d52094fa497a467c43f5c440103ce2511e9e0a2f89c3d6071baac3358fc68ac6fb75e2ceb3d2736065e6",
81
+ "packageManager": "pnpm@10.6.5+sha512.cdf928fca20832cd59ec53826492b7dc25dc524d4370b6b4adbf65803d32efaa6c1c88147c0ae4e8d579a6c9eec715757b50d4fa35eea179d868eada4ed043af",
82
82
  "scripts": {
83
83
  "dev": "vite dev",
84
84
  "build": "vite build && npm run package",