@kayord/ui 0.4.1 → 0.4.3
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 +8 -3
- package/dist/components/custom/data-table/DataTable.svelte.d.ts +2 -1
- package/dist/components/custom/data-table/DataTableCheckbox.svelte +4 -1
- package/package.json +1 -1
- package/dist/components/custom/data-table/DataTableCheckbox.svelte.d.ts +0 -17
|
@@ -11,6 +11,7 @@ export let hideHeader = false;
|
|
|
11
11
|
export let noDataMessage = "No Data";
|
|
12
12
|
export let serverItemCount = void 0;
|
|
13
13
|
export let rowAction = void 0;
|
|
14
|
+
export let showSelected = true;
|
|
14
15
|
const { headerRows, pageRows, tableAttrs, tableBodyAttrs, pluginStates, rows, flatColumns } = tableViewModel;
|
|
15
16
|
const isSortEnabled = pluginStates.sort != void 0;
|
|
16
17
|
const sortKeys = isSortEnabled ? pluginStates.sort.sortKeys : void 0;
|
|
@@ -19,6 +20,10 @@ const pageIndex = isPagingEnabled ? pluginStates.page.pageIndex : void 0;
|
|
|
19
20
|
const pageSize = isPagingEnabled ? pluginStates.page.pageSize : void 0;
|
|
20
21
|
const isSelectEnabled = pluginStates.select != void 0;
|
|
21
22
|
const selectedDataIds = isSelectEnabled ? pluginStates.select.selectedDataIds : void 0;
|
|
23
|
+
const getOriginalData = (id) => {
|
|
24
|
+
const data = $pageRows[id];
|
|
25
|
+
return data.original;
|
|
26
|
+
};
|
|
22
27
|
</script>
|
|
23
28
|
|
|
24
29
|
<div class="w-full">
|
|
@@ -100,7 +105,7 @@ const selectedDataIds = isSelectEnabled ? pluginStates.select.selectedDataIds :
|
|
|
100
105
|
{...rowAttrs}
|
|
101
106
|
data-state={!isSelectEnabled ? false : $selectedDataIds[row.id] && "selected"}
|
|
102
107
|
class={rowAction == undefined ? "" : "hover:cursor-pointer"}
|
|
103
|
-
on:click={rowAction}
|
|
108
|
+
on:click={() => (rowAction != undefined ? rowAction(getOriginalData(row.id)) : undefined)}
|
|
104
109
|
>
|
|
105
110
|
{#each row.cells as cell (cell.id)}
|
|
106
111
|
<Subscribe attrs={cell.attrs()} let:attrs>
|
|
@@ -121,10 +126,10 @@ const selectedDataIds = isSelectEnabled ? pluginStates.select.selectedDataIds :
|
|
|
121
126
|
</span>
|
|
122
127
|
{/if}
|
|
123
128
|
</div>
|
|
124
|
-
{#if isSelectEnabled}
|
|
129
|
+
{#if isSelectEnabled && showSelected}
|
|
125
130
|
<div class="flex-1 text-sm text-muted-foreground ml-4">
|
|
126
131
|
{Object.keys($selectedDataIds).length} of{" "}
|
|
127
|
-
{$rows.length} row(s) selected.
|
|
132
|
+
{serverItemCount ?? $rows.length} row(s) selected.
|
|
128
133
|
</div>
|
|
129
134
|
{/if}
|
|
130
135
|
{#if isPagingEnabled}
|
|
@@ -9,7 +9,8 @@ declare class __sveltets_Render<T extends RowData> {
|
|
|
9
9
|
hideHeader?: boolean | undefined;
|
|
10
10
|
noDataMessage?: string | undefined;
|
|
11
11
|
serverItemCount?: number | undefined;
|
|
12
|
-
rowAction?: (() => void) | undefined;
|
|
12
|
+
rowAction?: ((row: T | undefined) => void) | undefined;
|
|
13
|
+
showSelected?: boolean | undefined;
|
|
13
14
|
};
|
|
14
15
|
events(): {} & {
|
|
15
16
|
[evt: string]: CustomEvent<any>;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<script>import { Checkbox } from "../../ui/checkbox";
|
|
2
|
+
import { cn } from "../../../utils";
|
|
3
|
+
let className = void 0;
|
|
4
|
+
export { className as class };
|
|
2
5
|
export let checked;
|
|
3
6
|
</script>
|
|
4
7
|
|
|
5
|
-
<Checkbox bind:checked={$checked} />
|
|
8
|
+
<Checkbox bind:checked={$checked} class={cn(className)} />
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SvelteComponent } from "svelte";
|
|
2
|
-
import type { Writable } from "svelte/store";
|
|
3
|
-
declare const __propDef: {
|
|
4
|
-
props: {
|
|
5
|
-
checked: Writable<boolean>;
|
|
6
|
-
};
|
|
7
|
-
events: {
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
};
|
|
10
|
-
slots: {};
|
|
11
|
-
};
|
|
12
|
-
export type DataTableCheckboxProps = typeof __propDef.props;
|
|
13
|
-
export type DataTableCheckboxEvents = typeof __propDef.events;
|
|
14
|
-
export type DataTableCheckboxSlots = typeof __propDef.slots;
|
|
15
|
-
export default class DataTableCheckbox extends SvelteComponent<DataTableCheckboxProps, DataTableCheckboxEvents, DataTableCheckboxSlots> {
|
|
16
|
-
}
|
|
17
|
-
export {};
|