@kayord/ui 1.0.10 → 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.d.ts +1 -2
- package/dist/components/custom/data-table/shad-table.svelte.js +3 -4
- package/dist/components/custom/data-table/types.d.ts +6 -0
- package/dist/components/custom/data-table/types.js +1 -0
- package/dist/components/ui/avatar/avatar.svelte +7 -1
- package/dist/components/ui/avatar/avatar.svelte.d.ts +1 -1
- package/package.json +3 -3
|
@@ -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";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { type RowData, type RowModel, type Table, type TableOptions
|
|
1
|
+
import { type RowData, type RowModel, type Table, type TableOptions } from "@tanstack/table-core";
|
|
2
2
|
interface ShadTableOptions<TData extends RowData> extends Omit<TableOptions<TData>, "getCoreRowModel"> {
|
|
3
3
|
getCoreRowModel?: (table: Table<any>) => () => RowModel<any>;
|
|
4
4
|
enablePaging?: boolean;
|
|
5
5
|
enableVisibility?: boolean;
|
|
6
6
|
enableRowSelectionUI?: boolean;
|
|
7
|
-
defaultState?: Partial<TableState>;
|
|
8
7
|
}
|
|
9
8
|
export declare function createShadTable<TData extends RowData>(shadOptions: ShadTableOptions<TData>): Table<TData>;
|
|
10
9
|
export {};
|
|
@@ -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
|
|
@@ -176,10 +179,6 @@ export function createShadTable(shadOptions) {
|
|
|
176
179
|
}, options);
|
|
177
180
|
const table = createTable(resolvedOptions);
|
|
178
181
|
let state = $state(table.initialState);
|
|
179
|
-
// DefaultState
|
|
180
|
-
if (shadOptions.defaultState) {
|
|
181
|
-
state = { ...state, ...shadOptions.defaultState };
|
|
182
|
-
}
|
|
183
182
|
const updateOptions = (table, state) => {
|
|
184
183
|
table.setOptions((prev) => {
|
|
185
184
|
return mergeObjects(prev, options, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
import { Avatar as AvatarPrimitive } from "bits-ui";
|
|
3
3
|
import { cn } from "../../../utils.js";
|
|
4
4
|
|
|
5
|
-
let {
|
|
5
|
+
let {
|
|
6
|
+
ref = $bindable(null),
|
|
7
|
+
loadingStatus = $bindable("loading"),
|
|
8
|
+
class: className,
|
|
9
|
+
...restProps
|
|
10
|
+
}: AvatarPrimitive.RootProps = $props();
|
|
6
11
|
</script>
|
|
7
12
|
|
|
8
13
|
<AvatarPrimitive.Root
|
|
9
14
|
bind:ref
|
|
15
|
+
bind:loadingStatus
|
|
10
16
|
data-slot="avatar"
|
|
11
17
|
class={cn("relative flex size-8 shrink-0 overflow-hidden rounded-full", className)}
|
|
12
18
|
{...restProps}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Avatar as AvatarPrimitive } from "bits-ui";
|
|
2
|
-
declare const Avatar: import("svelte").Component<AvatarPrimitive.RootProps, {}, "ref">;
|
|
2
|
+
declare const Avatar: import("svelte").Component<AvatarPrimitive.RootProps, {}, "ref" | "loadingStatus">;
|
|
3
3
|
type Avatar = ReturnType<typeof Avatar>;
|
|
4
4
|
export default Avatar;
|
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,8 +49,8 @@
|
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@lucide/svelte": "^0.523.0",
|
|
51
51
|
"@sveltejs/adapter-auto": "^6.0.1",
|
|
52
|
-
"@sveltejs/kit": "^2.22.
|
|
53
|
-
"@sveltejs/package": "^2.3.
|
|
52
|
+
"@sveltejs/kit": "^2.22.2",
|
|
53
|
+
"@sveltejs/package": "^2.3.12",
|
|
54
54
|
"@sveltejs/vite-plugin-svelte": "^5.1.0",
|
|
55
55
|
"@tailwindcss/vite": "^4.1.10",
|
|
56
56
|
"@testing-library/jest-dom": "^6.6.3",
|