@kayord/ui 1.0.11 → 1.0.12
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.
- package/dist/components/custom/data-table/DataTable.svelte +41 -1
- package/dist/components/custom/data-table/index.d.ts +1 -0
- package/dist/components/custom/data-table/shad-table.svelte.js +3 -0
- package/dist/components/custom/data-table/types.d.ts +6 -0
- package/dist/components/custom/data-table/types.js +1 -0
- package/package.json +2 -2
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
import DataTableHeader from "./DataTableHeader.svelte";
|
|
13
13
|
import VisibilitySelect from "./VisibilitySelect.svelte";
|
|
14
14
|
import DataTableFooter from "./DataTableFooter.svelte";
|
|
15
|
-
import { goto } from "$app/navigation";
|
|
15
|
+
import { beforeNavigate, goto } from "$app/navigation";
|
|
16
16
|
import {
|
|
17
17
|
decodeColumnFilters,
|
|
18
18
|
decodeGlobalFilter,
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
decodeSorting,
|
|
21
21
|
encodeTableState,
|
|
22
22
|
} from "./table-search-params";
|
|
23
|
+
import { de } from "zod/v4/locales";
|
|
23
24
|
|
|
24
25
|
interface Props<T> {
|
|
25
26
|
table: TableType<T>;
|
|
@@ -57,6 +58,45 @@
|
|
|
57
58
|
|
|
58
59
|
const tableStore = new TableStore();
|
|
59
60
|
const isPaginationEnabled = table.options.getPaginationRowModel !== undefined;
|
|
61
|
+
|
|
62
|
+
// Load Default Values from Page Params
|
|
63
|
+
onMount(() => {
|
|
64
|
+
if (table.options.useURLSearchParams) {
|
|
65
|
+
table.setPageIndex(decodePageIndex());
|
|
66
|
+
table.setSorting(decodeSorting());
|
|
67
|
+
table.setGlobalFilter(decodeGlobalFilter());
|
|
68
|
+
table.setColumnFilters(decodeColumnFilters());
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// Reset pageIndex
|
|
73
|
+
beforeNavigate((navigation) => {
|
|
74
|
+
if (table.options.useURLSearchParams) {
|
|
75
|
+
if (Number(navigation.to?.url.searchParams.get("page") ?? "0") > 0) {
|
|
76
|
+
if (
|
|
77
|
+
navigation.from?.url.searchParams.get("sort") != navigation.to?.url.searchParams.get("sort") ||
|
|
78
|
+
navigation.from?.url.searchParams.get("globalFilter") !=
|
|
79
|
+
navigation.to?.url.searchParams.get("globalFilter") ||
|
|
80
|
+
navigation.from?.url.searchParams.get("columnFilters") != navigation.to?.url.searchParams.get("columnFilters")
|
|
81
|
+
) {
|
|
82
|
+
table.resetPageIndex();
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Set URL Page Params
|
|
89
|
+
$effect(() => {
|
|
90
|
+
if (table.options.useURLSearchParams) {
|
|
91
|
+
const params = encodeTableState(table.getState());
|
|
92
|
+
goto(params, {
|
|
93
|
+
replaceState: true,
|
|
94
|
+
keepFocus: true,
|
|
95
|
+
noScroll: true,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
|
|
60
100
|
let end: HTMLElement | undefined = $state();
|
|
61
101
|
</script>
|
|
62
102
|
|
|
@@ -2,3 +2,4 @@ export { default as DataTable } from "./DataTable.svelte";
|
|
|
2
2
|
export { createShadTable } from "./shad-table.svelte";
|
|
3
3
|
export { max, min, sum, uniqueCount } from "./data-table-utils";
|
|
4
4
|
export { decodeColumnFilters, decodeGlobalFilter, decodePageIndex, decodeSorting, decodeTableState, encodeColumnFilters, encodeGlobalFilter, encodePageIndex, encodeSorting, encodeTableState, } from "./table-search-params";
|
|
5
|
+
export type { CustomColumnMeta, CustomOptions } from "./types";
|
|
@@ -9,6 +9,9 @@ export function createShadTable(shadOptions) {
|
|
|
9
9
|
if ((shadOptions.enablePaging ?? true) == false) {
|
|
10
10
|
shadOptions.manualPagination = true;
|
|
11
11
|
}
|
|
12
|
+
if (shadOptions.useURLSearchParams) {
|
|
13
|
+
shadOptions.autoResetPageIndex = false;
|
|
14
|
+
}
|
|
12
15
|
const options = shadOptions;
|
|
13
16
|
// Features
|
|
14
17
|
// Sorting
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kayord/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.12",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@lucide/svelte": "^0.523.0",
|
|
51
51
|
"@sveltejs/adapter-auto": "^6.0.1",
|
|
52
|
-
"@sveltejs/kit": "^2.22.
|
|
52
|
+
"@sveltejs/kit": "^2.22.2",
|
|
53
53
|
"@sveltejs/package": "^2.3.12",
|
|
54
54
|
"@sveltejs/vite-plugin-svelte": "^5.1.0",
|
|
55
55
|
"@tailwindcss/vite": "^4.1.10",
|