@kayord/ui 0.2.1 → 0.2.2
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.
|
@@ -1,30 +1,18 @@
|
|
|
1
|
-
<script>import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { addSortBy, addPagination, addTableFilter, addSelectedRows, addHiddenColumns } from "svelte-headless-table/plugins";
|
|
5
|
-
import { readable } from "svelte/store";
|
|
1
|
+
<script>import { ArrowDown, ArrowUp } from "lucide-svelte";
|
|
2
|
+
import { Button, Skeleton } from "../../..";
|
|
3
|
+
import { Subscribe, Render } from "svelte-headless-table";
|
|
6
4
|
import * as Table from "../../ui/table";
|
|
7
|
-
import { DataTableActions } from "./";
|
|
8
|
-
import { Button } from "../../ui/button";
|
|
9
|
-
import * as DropdownMenu from "../../ui/dropdown-menu";
|
|
10
|
-
import { cn } from "../../../utils";
|
|
11
|
-
import { Input } from "../../ui/input";
|
|
12
|
-
import { ArrowDown, ArrowUp, ArrowUpDown, ChevronDown } from "lucide-svelte";
|
|
13
5
|
import * as Pagination from "../../ui/pagination";
|
|
14
6
|
export let tableViewModel;
|
|
15
7
|
export let title = "";
|
|
16
8
|
export let isLoading = false;
|
|
9
|
+
export let hideHeader = false;
|
|
17
10
|
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates, rows } = tableViewModel;
|
|
18
|
-
$: {
|
|
19
|
-
console.log("TVM", tableViewModel);
|
|
20
|
-
console.log("T", $rows);
|
|
21
|
-
}
|
|
22
11
|
const isSortEnabled = pluginStates.sort != void 0;
|
|
23
12
|
const sortKeys = isSortEnabled ? pluginStates.sort.sortKeys : void 0;
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
$sortKeys && console.log($pageSize, $pageRows.length, $pageCount, $rows.length);
|
|
13
|
+
const isPagingEnabled = pluginStates.page != void 0;
|
|
14
|
+
const pageIndex = isPagingEnabled ? pluginStates.page.pageIndex : void 0;
|
|
15
|
+
const pageSize = isPagingEnabled ? pluginStates.page.pageSize : void 0;
|
|
28
16
|
</script>
|
|
29
17
|
|
|
30
18
|
<div class="w-full">
|
|
@@ -44,34 +32,36 @@ $:
|
|
|
44
32
|
<slot name="subHeader" />
|
|
45
33
|
{/if}
|
|
46
34
|
<Table.Root {...$tableAttrs} class="table-auto">
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
{
|
|
55
|
-
|
|
35
|
+
{#if !hideHeader}
|
|
36
|
+
<Table.Header>
|
|
37
|
+
{#each $headerRows as headerRow}
|
|
38
|
+
<Subscribe rowAttrs={headerRow.attrs()}>
|
|
39
|
+
<Table.Row>
|
|
40
|
+
{#each headerRow.cells as cell (cell.id)}
|
|
41
|
+
<Subscribe attrs={cell.attrs()} let:attrs props={cell.props()} let:props>
|
|
42
|
+
<Table.Head {...attrs}>
|
|
43
|
+
{#if isSortEnabled}
|
|
44
|
+
<Button variant="ghost" on:click={props.sort.toggle}>
|
|
45
|
+
<Render of={cell.render()} />
|
|
46
|
+
{#each $sortKeys as sortKey}
|
|
47
|
+
{#if sortKey?.id === cell.id && sortKey?.order == "desc"}
|
|
48
|
+
<ArrowDown class="ml-2 h-4 w-4" />
|
|
49
|
+
{:else if sortKey?.id === cell.id && sortKey?.order === "asc"}
|
|
50
|
+
<ArrowUp class="ml-2 h-4 w-4" />
|
|
51
|
+
{/if}
|
|
52
|
+
{/each}
|
|
53
|
+
</Button>
|
|
54
|
+
{:else}
|
|
56
55
|
<Render of={cell.render()} />
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
<Render of={cell.render()} />
|
|
67
|
-
{/if}
|
|
68
|
-
</Table.Head>
|
|
69
|
-
</Subscribe>
|
|
70
|
-
{/each}
|
|
71
|
-
</Table.Row>
|
|
72
|
-
</Subscribe>
|
|
73
|
-
{/each}
|
|
74
|
-
</Table.Header>
|
|
56
|
+
{/if}
|
|
57
|
+
</Table.Head>
|
|
58
|
+
</Subscribe>
|
|
59
|
+
{/each}
|
|
60
|
+
</Table.Row>
|
|
61
|
+
</Subscribe>
|
|
62
|
+
{/each}
|
|
63
|
+
</Table.Header>
|
|
64
|
+
{/if}
|
|
75
65
|
<Table.Body {...$tableBodyAttrs}>
|
|
76
66
|
{#if isLoading}
|
|
77
67
|
{#each { length: 5 } as _, i}
|
|
@@ -103,29 +93,31 @@ $:
|
|
|
103
93
|
</Table.Body>
|
|
104
94
|
</Table.Root>
|
|
105
95
|
</div>
|
|
106
|
-
|
|
107
|
-
<Pagination.
|
|
108
|
-
<Pagination.
|
|
109
|
-
<Pagination.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
{#
|
|
113
|
-
|
|
114
|
-
<Pagination.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
<Pagination.
|
|
119
|
-
{page.value}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
<Pagination.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
96
|
+
{#if isPagingEnabled}
|
|
97
|
+
<Pagination.Root count={$rows.length} perPage={$pageSize} let:pages let:currentPage>
|
|
98
|
+
<Pagination.Content>
|
|
99
|
+
<Pagination.Item>
|
|
100
|
+
<Pagination.PrevButton on:click={() => ($pageIndex = $pageIndex - 1)} />
|
|
101
|
+
</Pagination.Item>
|
|
102
|
+
{#each pages as page (page.key)}
|
|
103
|
+
{#if page.type === "ellipsis"}
|
|
104
|
+
<Pagination.Item>
|
|
105
|
+
<Pagination.Ellipsis />
|
|
106
|
+
</Pagination.Item>
|
|
107
|
+
{:else}
|
|
108
|
+
<Pagination.Item>
|
|
109
|
+
<Pagination.Link {page} isActive={currentPage == page.value} on:click={() => ($pageIndex = page.value - 1)}>
|
|
110
|
+
{page.value}
|
|
111
|
+
</Pagination.Link>
|
|
112
|
+
</Pagination.Item>
|
|
113
|
+
{/if}
|
|
114
|
+
{/each}
|
|
115
|
+
<Pagination.Item>
|
|
116
|
+
<Pagination.NextButton on:click={() => ($pageIndex = $pageIndex + 1)} />
|
|
117
|
+
</Pagination.Item>
|
|
118
|
+
</Pagination.Content>
|
|
119
|
+
</Pagination.Root>
|
|
120
|
+
{/if}
|
|
129
121
|
{#if $$slots.footer}
|
|
130
122
|
<div class="rounded-b-md overflow-hidden">
|
|
131
123
|
<slot name="footer" />
|
|
@@ -6,6 +6,7 @@ declare class __sveltets_Render<T extends RowData> {
|
|
|
6
6
|
tableViewModel: TableViewModel<T, import("svelte-headless-table/dist/types/TablePlugin").AnyPlugins>;
|
|
7
7
|
title?: string | undefined;
|
|
8
8
|
isLoading?: boolean | undefined;
|
|
9
|
+
hideHeader?: boolean | undefined;
|
|
9
10
|
};
|
|
10
11
|
events(): {} & {
|
|
11
12
|
[evt: string]: CustomEvent<any>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kayord/ui",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@sveltejs/adapter-auto": "^3.1.0",
|
|
41
41
|
"@sveltejs/kit": "^2.0.6",
|
|
42
42
|
"@sveltejs/package": "^2.2.5",
|
|
43
|
-
"@sveltejs/vite-plugin-svelte": "^3.0.
|
|
43
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.1",
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "^6.17.0",
|
|
45
45
|
"@typescript-eslint/parser": "^6.17.0",
|
|
46
46
|
"autoprefixer": "^10.4.16",
|