@r2digisolutions/ui 0.27.3 → 0.28.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.
- package/dist/components/container/DataTableShell/DataTableShell.svelte +631 -0
- package/dist/components/container/DataTableShell/DataTableShell.svelte.d.ts +48 -0
- package/dist/components/container/DataTableShell/components/AdvancedFiltersBuilder.svelte +311 -0
- package/dist/components/container/DataTableShell/components/AdvancedFiltersBuilder.svelte.d.ts +7 -0
- package/dist/components/container/DataTableShell/components/ColumnVisibilityMenu.svelte +112 -0
- package/dist/components/container/DataTableShell/components/ColumnVisibilityMenu.svelte.d.ts +8 -0
- package/dist/components/container/DataTableShell/components/ContextMenu.svelte +70 -0
- package/dist/components/container/DataTableShell/components/ContextMenu.svelte.d.ts +30 -0
- package/dist/components/container/DataTableShell/components/DataTableFiltersSidebar.svelte +0 -0
- package/dist/components/container/DataTableShell/components/DataTableFiltersSidebar.svelte.d.ts +26 -0
- package/dist/components/container/DataTableShell/components/DataTableFooter.svelte +36 -0
- package/dist/components/container/DataTableShell/components/DataTableFooter.svelte.d.ts +18 -0
- package/dist/components/container/DataTableShell/components/DataTableToolbar.svelte +822 -0
- package/dist/components/container/DataTableShell/components/DataTableToolbar.svelte.d.ts +30 -0
- package/dist/components/container/DataTableShell/components/Pagination.svelte +117 -0
- package/dist/components/container/DataTableShell/components/Pagination.svelte.d.ts +28 -0
- package/dist/components/container/DataTableShell/components/Submenu.svelte +109 -0
- package/dist/components/container/DataTableShell/components/Submenu.svelte.d.ts +30 -0
- package/dist/components/container/DataTableShell/components/Toolbar.svelte +0 -0
- package/dist/components/container/DataTableShell/components/Toolbar.svelte.d.ts +26 -0
- package/dist/components/container/DataTableShell/core/DataTableController.svelte.d.ts +54 -0
- package/dist/components/container/DataTableShell/core/DataTableController.svelte.js +148 -0
- package/dist/components/container/DataTableShell/core/DataTableEngine.svelte.d.ts +68 -0
- package/dist/components/container/DataTableShell/core/DataTableEngine.svelte.js +319 -0
- package/dist/components/container/DataTableShell/core/DataTableInternal.svelte.d.ts +68 -0
- package/dist/components/container/DataTableShell/core/DataTableInternal.svelte.js +396 -0
- package/dist/components/container/DataTableShell/core/context.d.ts +3 -0
- package/dist/components/container/DataTableShell/core/context.js +12 -0
- package/dist/components/container/DataTableShell/core/filters-types.d.ts +14 -0
- package/dist/components/container/DataTableShell/core/filters-types.js +1 -0
- package/dist/components/container/DataTableShell/core/types.d.ts +60 -0
- package/dist/components/container/DataTableShell/core/types.js +1 -0
- package/dist/components/container/index.d.ts +3 -1
- package/dist/components/container/index.js +3 -1
- package/package.json +13 -13
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
density: 'comfortable' | 'compact';
|
|
3
|
+
viewMode: 'list' | 'grid';
|
|
4
|
+
onDensityChange?: (d: 'comfortable' | 'compact') => void;
|
|
5
|
+
onViewModeChange?: (m: 'list' | 'grid') => void;
|
|
6
|
+
}
|
|
7
|
+
declare function $$render<T>(): {
|
|
8
|
+
props: Props;
|
|
9
|
+
exports: {};
|
|
10
|
+
bindings: "";
|
|
11
|
+
slots: {};
|
|
12
|
+
events: {};
|
|
13
|
+
};
|
|
14
|
+
declare class __sveltets_Render<T> {
|
|
15
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
16
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
17
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
18
|
+
bindings(): "";
|
|
19
|
+
exports(): {};
|
|
20
|
+
}
|
|
21
|
+
interface $$IsomorphicComponent {
|
|
22
|
+
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
23
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
24
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
25
|
+
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
26
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
27
|
+
}
|
|
28
|
+
declare const DataTableToolbar: $$IsomorphicComponent;
|
|
29
|
+
type DataTableToolbar<T> = InstanceType<typeof DataTableToolbar<T>>;
|
|
30
|
+
export default DataTableToolbar;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<script lang="ts" generics="T">
|
|
2
|
+
import { ChevronLeft } from 'lucide-svelte';
|
|
3
|
+
import type { DataTableController } from '../core/DataTableController.svelte';
|
|
4
|
+
|
|
5
|
+
interface Props<T> {
|
|
6
|
+
controller: DataTableController<T>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { controller }: Props<T> = $props();
|
|
10
|
+
|
|
11
|
+
const pageWindow = 5;
|
|
12
|
+
|
|
13
|
+
const pages = $derived.by(() => {
|
|
14
|
+
const total = controller.totalPages;
|
|
15
|
+
const current = controller.page;
|
|
16
|
+
if (total <= 1) return [1];
|
|
17
|
+
const half = Math.floor(pageWindow / 2);
|
|
18
|
+
let start = Math.max(1, current - half);
|
|
19
|
+
let end = Math.min(total, start + pageWindow - 1);
|
|
20
|
+
if (end - start + 1 < pageWindow) {
|
|
21
|
+
start = Math.max(1, end - pageWindow + 1);
|
|
22
|
+
}
|
|
23
|
+
const arr: number[] = [];
|
|
24
|
+
for (let i = start; i <= end; i++) arr.push(i);
|
|
25
|
+
return arr;
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<div
|
|
30
|
+
class="flex items-center justify-between gap-3 text-[11px] text-neutral-400 md:text-neutral-600"
|
|
31
|
+
>
|
|
32
|
+
<div class="flex items-center gap-2">
|
|
33
|
+
<span>
|
|
34
|
+
Mostrando
|
|
35
|
+
<span class="font-semibold text-neutral-100 md:text-neutral-900 dark:md:text-neutral-50">
|
|
36
|
+
{controller.currentRows.length}
|
|
37
|
+
</span>
|
|
38
|
+
de
|
|
39
|
+
<span class="font-semibold text-neutral-100 md:text-neutral-900 dark:md:text-neutral-50">
|
|
40
|
+
{controller.totalFilteredRows}
|
|
41
|
+
</span>
|
|
42
|
+
resultados
|
|
43
|
+
</span>
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
<div class="flex items-center gap-2">
|
|
47
|
+
<button
|
|
48
|
+
type="button"
|
|
49
|
+
class="inline-flex h-7 items-center rounded-full border border-neutral-600/70 bg-neutral-950/80 px-2 text-[11px] text-neutral-300 disabled:opacity-40 md:bg-white/90 md:text-neutral-700 dark:md:bg-neutral-900 dark:md:text-neutral-100"
|
|
50
|
+
onclick={() => controller.setPage(controller.page - 1)}
|
|
51
|
+
disabled={controller.page <= 1}
|
|
52
|
+
>
|
|
53
|
+
<ChevronLeft class="h-3 w-3" />
|
|
54
|
+
</button>
|
|
55
|
+
|
|
56
|
+
<div class="flex items-center gap-1">
|
|
57
|
+
{#if pages[0] > 1}
|
|
58
|
+
<button
|
|
59
|
+
type="button"
|
|
60
|
+
class="h-7 min-w-[1.75rem] rounded-full border border-neutral-600/70 bg-neutral-950/80 px-2 text-[11px] text-neutral-300 hover:border-purple-500/70 hover:text-purple-300 md:bg-white/90 md:text-neutral-700 md:hover:text-purple-600 dark:md:bg-neutral-900 dark:md:text-neutral-100"
|
|
61
|
+
onclick={() => controller.setPage(1)}
|
|
62
|
+
>
|
|
63
|
+
1
|
|
64
|
+
</button>
|
|
65
|
+
<span class="px-1 text-[10px] text-neutral-500">…</span>
|
|
66
|
+
{/if}
|
|
67
|
+
|
|
68
|
+
{#each pages as page}
|
|
69
|
+
<button
|
|
70
|
+
type="button"
|
|
71
|
+
class={`h-7 min-w-[1.75rem] rounded-full px-2 text-[11px] ${
|
|
72
|
+
page === controller.page
|
|
73
|
+
? 'bg-purple-500 text-white shadow-sm'
|
|
74
|
+
: 'border border-neutral-600/70 bg-neutral-950/80 text-neutral-300 hover:border-purple-500/70 hover:text-purple-300 md:bg-white/90 md:text-neutral-700 md:hover:text-purple-600 dark:md:bg-neutral-900 dark:md:text-neutral-100'
|
|
75
|
+
}`}
|
|
76
|
+
onclick={() => controller.setPage(page)}
|
|
77
|
+
>
|
|
78
|
+
{page}
|
|
79
|
+
</button>
|
|
80
|
+
{/each}
|
|
81
|
+
|
|
82
|
+
{#if pages[pages.length - 1] < controller.totalPages}
|
|
83
|
+
<span class="px-1 text-[10px] text-neutral-500">…</span>
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
class="h-7 min-w-[1.75rem] rounded-full border border-neutral-600/70 bg-neutral-950/80 px-2 text-[11px] text-neutral-300 hover:border-purple-500/70 hover:text-purple-300 md:bg-white/90 md:text-neutral-700 md:hover:text-purple-600 dark:md:bg-neutral-900 dark:md:text-neutral-100"
|
|
87
|
+
onclick={() => controller.setPage(controller.totalPages)}
|
|
88
|
+
>
|
|
89
|
+
{controller.totalPages}
|
|
90
|
+
</button>
|
|
91
|
+
{/if}
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
class="inline-flex h-7 items-center rounded-full border border-neutral-600/70 bg-neutral-950/80 px-2 text-[11px] text-neutral-300 disabled:opacity-40 md:bg-white/90 md:text-neutral-700 dark:md:bg-neutral-900 dark:md:text-neutral-100"
|
|
97
|
+
onclick={() => controller.setPage(controller.page + 1)}
|
|
98
|
+
disabled={controller.page >= controller.totalPages}
|
|
99
|
+
>
|
|
100
|
+
›
|
|
101
|
+
</button>
|
|
102
|
+
|
|
103
|
+
<select
|
|
104
|
+
class="rounded-2xl border border-neutral-200/80 bg-white/70 px-2 py-1 text-[11px] text-neutral-700 shadow-sm dark:border-neutral-700/80 dark:bg-neutral-900/80 dark:text-neutral-100"
|
|
105
|
+
onchange={(e) => {
|
|
106
|
+
const value = Number((e.currentTarget as HTMLSelectElement).value);
|
|
107
|
+
controller.setPageSize(value);
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{#each [10, 20, 50, 100] as size}
|
|
111
|
+
<option value={size} selected={size === controller.pageSize}>
|
|
112
|
+
{size} / página
|
|
113
|
+
</option>
|
|
114
|
+
{/each}
|
|
115
|
+
</select>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DataTableController } from '../core/DataTableController.svelte';
|
|
2
|
+
interface Props<T> {
|
|
3
|
+
controller: DataTableController<T>;
|
|
4
|
+
}
|
|
5
|
+
declare function $$render<T>(): {
|
|
6
|
+
props: Props<T>;
|
|
7
|
+
exports: {};
|
|
8
|
+
bindings: "";
|
|
9
|
+
slots: {};
|
|
10
|
+
events: {};
|
|
11
|
+
};
|
|
12
|
+
declare class __sveltets_Render<T> {
|
|
13
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
14
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
15
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
16
|
+
bindings(): "";
|
|
17
|
+
exports(): {};
|
|
18
|
+
}
|
|
19
|
+
interface $$IsomorphicComponent {
|
|
20
|
+
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
21
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
22
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
23
|
+
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
24
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
25
|
+
}
|
|
26
|
+
declare const Pagination: $$IsomorphicComponent;
|
|
27
|
+
type Pagination<T> = InstanceType<typeof Pagination<T>>;
|
|
28
|
+
export default Pagination;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<script lang="ts" generics="T">
|
|
2
|
+
import { ChevronRight } from 'lucide-svelte';
|
|
3
|
+
import type { AnyAction } from '../core/types.js';
|
|
4
|
+
|
|
5
|
+
let active = $state(false);
|
|
6
|
+
let popoverEl: HTMLDivElement | null = null;
|
|
7
|
+
let anchorEl: HTMLButtonElement | null = null;
|
|
8
|
+
|
|
9
|
+
interface SubmenuProps<T> {
|
|
10
|
+
action: AnyAction<T>;
|
|
11
|
+
row: T;
|
|
12
|
+
onClose: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { action, row, onClose }: SubmenuProps<T> = $props();
|
|
16
|
+
|
|
17
|
+
function openSubmenu(event: MouseEvent) {
|
|
18
|
+
event.preventDefault();
|
|
19
|
+
event.stopPropagation();
|
|
20
|
+
if (!popoverEl || !anchorEl) return;
|
|
21
|
+
|
|
22
|
+
popoverEl.style.position = 'fixed';
|
|
23
|
+
popoverEl.showPopover();
|
|
24
|
+
active = true;
|
|
25
|
+
|
|
26
|
+
const aRect = anchorEl.getBoundingClientRect();
|
|
27
|
+
const pRect = popoverEl.getBoundingClientRect();
|
|
28
|
+
const margin = 8;
|
|
29
|
+
|
|
30
|
+
let left = aRect.right + 4;
|
|
31
|
+
let top = aRect.top;
|
|
32
|
+
|
|
33
|
+
if (left + pRect.width + margin > window.innerWidth) {
|
|
34
|
+
left = aRect.left - pRect.width - 4;
|
|
35
|
+
}
|
|
36
|
+
if (top + pRect.height + margin > window.innerHeight) {
|
|
37
|
+
top = Math.max(margin, window.innerHeight - pRect.height - margin);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
popoverEl.style.left = `${left}px`;
|
|
41
|
+
popoverEl.style.top = `${top}px`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function closeSubmenu() {
|
|
45
|
+
active = false;
|
|
46
|
+
popoverEl?.hidePopover();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function handleChildClick(child: AnyAction<T>) {
|
|
50
|
+
if (child.onClick) {
|
|
51
|
+
child.onClick(row);
|
|
52
|
+
}
|
|
53
|
+
onClose();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function isHidden(action: AnyAction<T>, r: any) {
|
|
57
|
+
return typeof action.hidden === 'function' ? action.hidden(r) : false;
|
|
58
|
+
}
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<button
|
|
62
|
+
bind:this={anchorEl}
|
|
63
|
+
type="button"
|
|
64
|
+
onclick={openSubmenu}
|
|
65
|
+
class="ml-1 flex h-5 w-5 items-center justify-center rounded-full text-neutral-400 hover:bg-neutral-200/80 hover:text-neutral-800 dark:text-neutral-500 dark:hover:bg-neutral-700/80 dark:hover:text-neutral-100"
|
|
66
|
+
>
|
|
67
|
+
<ChevronRight class="h-3 w-3" />
|
|
68
|
+
</button>
|
|
69
|
+
|
|
70
|
+
<div
|
|
71
|
+
bind:this={popoverEl}
|
|
72
|
+
popover="manual"
|
|
73
|
+
data-context-host="true"
|
|
74
|
+
class="z-[1400] max-w-xs min-w-[180px] rounded-2xl border border-neutral-200/80 bg-neutral-50/98 p-1 text-[11px] text-neutral-900 shadow-[0_18px_55px_rgba(15,23,42,0.70)] backdrop-blur-2xl dark:border-neutral-700/80 dark:bg-neutral-900/98 dark:text-neutral-50"
|
|
75
|
+
onbeforetoggle={(e) => {
|
|
76
|
+
if ((e as any).newState === 'closed') active = false;
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{#each action.children ?? [] as childRaw, j}
|
|
80
|
+
{@const child = childRaw as AnyAction}
|
|
81
|
+
{#if !isHidden(child, row)}
|
|
82
|
+
{@const label = typeof child.label === 'function' ? child.label(row) : child.label}
|
|
83
|
+
<button
|
|
84
|
+
type="button"
|
|
85
|
+
onclick={() => handleChildClick(child)}
|
|
86
|
+
class={`flex w-full items-center justify-between gap-2 rounded-2xl px-2.5 py-1.5 text-[11px] ${
|
|
87
|
+
child.danger
|
|
88
|
+
? 'text-red-600 hover:bg-red-50 dark:text-red-300 dark:hover:bg-red-900/40'
|
|
89
|
+
: 'text-neutral-800 hover:bg-neutral-100/90 dark:text-neutral-100 dark:hover:bg-neutral-800/80'
|
|
90
|
+
}`}
|
|
91
|
+
>
|
|
92
|
+
<div class="flex items-center gap-2">
|
|
93
|
+
{#if child.icon}
|
|
94
|
+
{@const Icon = typeof child.icon === 'function' ? child.icon(row) : child.icon}
|
|
95
|
+
<Icon
|
|
96
|
+
class="h-3.5 w-3.5 text-neutral-400 group-hover:text-neutral-700 dark:text-neutral-500 dark:group-hover:text-neutral-100"
|
|
97
|
+
/>
|
|
98
|
+
{/if}
|
|
99
|
+
<span class="line-clamp-1 text-left">
|
|
100
|
+
{label}
|
|
101
|
+
</span>
|
|
102
|
+
</div>
|
|
103
|
+
</button>
|
|
104
|
+
{/if}
|
|
105
|
+
{#if j < (action.children?.length ?? 0) - 1}
|
|
106
|
+
<div class="mx-1 my-0.5 h-px bg-neutral-200/70 dark:bg-neutral-800/70"></div>
|
|
107
|
+
{/if}
|
|
108
|
+
{/each}
|
|
109
|
+
</div>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { AnyAction } from '../core/types.js';
|
|
2
|
+
interface SubmenuProps<T> {
|
|
3
|
+
action: AnyAction<T>;
|
|
4
|
+
row: T;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
}
|
|
7
|
+
declare function $$render<T>(): {
|
|
8
|
+
props: SubmenuProps<T>;
|
|
9
|
+
exports: {};
|
|
10
|
+
bindings: "";
|
|
11
|
+
slots: {};
|
|
12
|
+
events: {};
|
|
13
|
+
};
|
|
14
|
+
declare class __sveltets_Render<T> {
|
|
15
|
+
props(): ReturnType<typeof $$render<T>>['props'];
|
|
16
|
+
events(): ReturnType<typeof $$render<T>>['events'];
|
|
17
|
+
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
18
|
+
bindings(): "";
|
|
19
|
+
exports(): {};
|
|
20
|
+
}
|
|
21
|
+
interface $$IsomorphicComponent {
|
|
22
|
+
new <T>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
|
|
23
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
24
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
25
|
+
<T>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
26
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
27
|
+
}
|
|
28
|
+
declare const Submenu: $$IsomorphicComponent;
|
|
29
|
+
type Submenu<T> = InstanceType<typeof Submenu<T>>;
|
|
30
|
+
export default Submenu;
|
|
File without changes
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default Toolbar;
|
|
2
|
+
type Toolbar = SvelteComponent<{
|
|
3
|
+
[x: string]: never;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const Toolbar: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { DataTableOptions, SortDirection } from './DataTableEngine.svelte';
|
|
2
|
+
import type { QueryStructure } from './filters-types.js';
|
|
3
|
+
export declare class DataTableController<T> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(options: DataTableOptions<T>);
|
|
6
|
+
get options(): DataTableOptions<T>;
|
|
7
|
+
get rows(): T[];
|
|
8
|
+
get processedRows(): T[];
|
|
9
|
+
get currentRows(): T[];
|
|
10
|
+
get allColumns(): import("./types.js").ColumnDef<T>[];
|
|
11
|
+
get visibleColumns(): import("./types.js").ColumnDef<T>[];
|
|
12
|
+
get mainColumns(): import("./types.js").ColumnDef<T>[];
|
|
13
|
+
get overflowColumns(): import("./types.js").ColumnDef<T>[];
|
|
14
|
+
get loading(): boolean;
|
|
15
|
+
get page(): number;
|
|
16
|
+
get pageSize(): number;
|
|
17
|
+
get totalPages(): number;
|
|
18
|
+
get totalRows(): number;
|
|
19
|
+
get totalFilteredRows(): number;
|
|
20
|
+
get sortColumn(): keyof T | null;
|
|
21
|
+
get sortDirection(): SortDirection | null;
|
|
22
|
+
get sort(): {
|
|
23
|
+
columnId: keyof T;
|
|
24
|
+
direction: SortDirection;
|
|
25
|
+
} | null;
|
|
26
|
+
get search(): string;
|
|
27
|
+
get selectedIds(): Set<string>;
|
|
28
|
+
get selectedCount(): number;
|
|
29
|
+
get multiSelect(): boolean;
|
|
30
|
+
get allVisibleSelected(): boolean;
|
|
31
|
+
get someVisibleSelected(): boolean;
|
|
32
|
+
get isAllPageSelected(): boolean;
|
|
33
|
+
get query(): QueryStructure | null;
|
|
34
|
+
getRowId(row: T, index: number): string;
|
|
35
|
+
setRows(rows: T[]): this;
|
|
36
|
+
setLoading(v: boolean): void;
|
|
37
|
+
setSearch(term: string): void;
|
|
38
|
+
setQuery(q: QueryStructure | null): void;
|
|
39
|
+
setSort(columnId: keyof T | null, direction?: SortDirection): void;
|
|
40
|
+
toggleSort(columnId: keyof T): void;
|
|
41
|
+
setPage(page: number): void;
|
|
42
|
+
setPageSize(size: number): void;
|
|
43
|
+
clearSelection(): void;
|
|
44
|
+
toggleRowSelection(id: string): void;
|
|
45
|
+
selectAllVisible(): void;
|
|
46
|
+
unselectAllVisible(): void;
|
|
47
|
+
selectAllCurrentPage(): void;
|
|
48
|
+
unselectAllCurrentPage(): void;
|
|
49
|
+
isRowSelected(id: string): boolean;
|
|
50
|
+
setColumnHidden(id: keyof T, hidden: boolean): void;
|
|
51
|
+
resizeColumn(id: keyof T, width: number): void;
|
|
52
|
+
getColumnWidth(id: keyof T): number;
|
|
53
|
+
resetLayout(): void;
|
|
54
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { DataTableEngine as Engine } from './DataTableEngine.svelte';
|
|
2
|
+
export class DataTableController {
|
|
3
|
+
#engine;
|
|
4
|
+
#query = null;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.#engine = new Engine(options);
|
|
7
|
+
}
|
|
8
|
+
get options() {
|
|
9
|
+
return this.#engine.options;
|
|
10
|
+
}
|
|
11
|
+
get rows() {
|
|
12
|
+
return this.#engine.rows;
|
|
13
|
+
}
|
|
14
|
+
get processedRows() {
|
|
15
|
+
return this.#engine.processedRows;
|
|
16
|
+
}
|
|
17
|
+
get currentRows() {
|
|
18
|
+
return this.#engine.currentPageRows;
|
|
19
|
+
}
|
|
20
|
+
get allColumns() {
|
|
21
|
+
return this.#engine.allColumns;
|
|
22
|
+
}
|
|
23
|
+
get visibleColumns() {
|
|
24
|
+
return this.#engine.visibleColumns;
|
|
25
|
+
}
|
|
26
|
+
get mainColumns() {
|
|
27
|
+
return this.#engine.mainColumns;
|
|
28
|
+
}
|
|
29
|
+
get overflowColumns() {
|
|
30
|
+
return this.#engine.overflowColumns;
|
|
31
|
+
}
|
|
32
|
+
get loading() {
|
|
33
|
+
return this.#engine.loading;
|
|
34
|
+
}
|
|
35
|
+
get page() {
|
|
36
|
+
return this.#engine.page;
|
|
37
|
+
}
|
|
38
|
+
get pageSize() {
|
|
39
|
+
return this.#engine.pageSize;
|
|
40
|
+
}
|
|
41
|
+
get totalPages() {
|
|
42
|
+
return this.#engine.totalPages;
|
|
43
|
+
}
|
|
44
|
+
get totalRows() {
|
|
45
|
+
return this.#engine.totalRows;
|
|
46
|
+
}
|
|
47
|
+
get totalFilteredRows() {
|
|
48
|
+
return this.#engine.totalFilteredRows;
|
|
49
|
+
}
|
|
50
|
+
get sortColumn() {
|
|
51
|
+
return this.#engine.sortColumn;
|
|
52
|
+
}
|
|
53
|
+
get sortDirection() {
|
|
54
|
+
return this.#engine.sortColumn ? this.#engine.sortDirection : null;
|
|
55
|
+
}
|
|
56
|
+
get sort() {
|
|
57
|
+
return this.#engine.sortColumn
|
|
58
|
+
? { columnId: this.#engine.sortColumn, direction: this.#engine.sortDirection }
|
|
59
|
+
: null;
|
|
60
|
+
}
|
|
61
|
+
get search() {
|
|
62
|
+
return this.#engine.search;
|
|
63
|
+
}
|
|
64
|
+
get selectedIds() {
|
|
65
|
+
return this.#engine.selectedIds;
|
|
66
|
+
}
|
|
67
|
+
get selectedCount() {
|
|
68
|
+
return this.#engine.selectedCount;
|
|
69
|
+
}
|
|
70
|
+
get multiSelect() {
|
|
71
|
+
return !!this.#engine.options.multiSelect;
|
|
72
|
+
}
|
|
73
|
+
get allVisibleSelected() {
|
|
74
|
+
return this.#engine.allVisibleSelected;
|
|
75
|
+
}
|
|
76
|
+
get someVisibleSelected() {
|
|
77
|
+
return this.#engine.someVisibleSelected;
|
|
78
|
+
}
|
|
79
|
+
get isAllPageSelected() {
|
|
80
|
+
return this.#engine.isAllPageSelected;
|
|
81
|
+
}
|
|
82
|
+
get query() {
|
|
83
|
+
return this.#query;
|
|
84
|
+
}
|
|
85
|
+
getRowId(row, index) {
|
|
86
|
+
return this.#engine.getRowId(row, index);
|
|
87
|
+
}
|
|
88
|
+
setRows(rows) {
|
|
89
|
+
this.#engine.setRows(rows);
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
setLoading(v) {
|
|
93
|
+
this.#engine.setLoading(v);
|
|
94
|
+
}
|
|
95
|
+
setSearch(term) {
|
|
96
|
+
this.#engine.setSearch(term);
|
|
97
|
+
}
|
|
98
|
+
setQuery(q) {
|
|
99
|
+
this.#query = q;
|
|
100
|
+
this.#engine.setQuery(q);
|
|
101
|
+
}
|
|
102
|
+
setSort(columnId, direction = 'asc') {
|
|
103
|
+
this.#engine.setSort(columnId, direction);
|
|
104
|
+
}
|
|
105
|
+
toggleSort(columnId) {
|
|
106
|
+
this.#engine.toggleSort(columnId);
|
|
107
|
+
}
|
|
108
|
+
setPage(page) {
|
|
109
|
+
this.#engine.setPage(page);
|
|
110
|
+
}
|
|
111
|
+
setPageSize(size) {
|
|
112
|
+
this.#engine.setPageSize(size);
|
|
113
|
+
}
|
|
114
|
+
clearSelection() {
|
|
115
|
+
this.#engine.clearSelection();
|
|
116
|
+
}
|
|
117
|
+
toggleRowSelection(id) {
|
|
118
|
+
this.#engine.toggleRowSelection(id);
|
|
119
|
+
}
|
|
120
|
+
selectAllVisible() {
|
|
121
|
+
this.#engine.selectAllVisible();
|
|
122
|
+
}
|
|
123
|
+
unselectAllVisible() {
|
|
124
|
+
this.#engine.unselectAllVisible();
|
|
125
|
+
}
|
|
126
|
+
selectAllCurrentPage() {
|
|
127
|
+
this.#engine.selectAllCurrentPage();
|
|
128
|
+
}
|
|
129
|
+
unselectAllCurrentPage() {
|
|
130
|
+
this.#engine.unselectAllCurrentPage();
|
|
131
|
+
}
|
|
132
|
+
isRowSelected(id) {
|
|
133
|
+
return this.#engine.selectedIds.has(id);
|
|
134
|
+
}
|
|
135
|
+
setColumnHidden(id, hidden) {
|
|
136
|
+
this.#engine.setColumnHidden(id, hidden);
|
|
137
|
+
}
|
|
138
|
+
resizeColumn(id, width) {
|
|
139
|
+
this.#engine.resizeColumn(id, width);
|
|
140
|
+
}
|
|
141
|
+
getColumnWidth(id) {
|
|
142
|
+
return this.#engine.getColumnWidth(id);
|
|
143
|
+
}
|
|
144
|
+
resetLayout() {
|
|
145
|
+
this.#engine.resetLayout();
|
|
146
|
+
this.#query = null;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
2
|
+
import type { QueryStructure } from './filters-types.js';
|
|
3
|
+
import type { ColumnDef } from './types.js';
|
|
4
|
+
export type SortDirection = 'asc' | 'desc';
|
|
5
|
+
export type DataTableMode = 'pagination' | 'infinite';
|
|
6
|
+
type ColumnState<T> = {
|
|
7
|
+
id: keyof T;
|
|
8
|
+
visible: boolean;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
width?: number;
|
|
11
|
+
minWidth?: number;
|
|
12
|
+
defaultWidth?: number;
|
|
13
|
+
};
|
|
14
|
+
export interface DataTableOptions<T> {
|
|
15
|
+
mode: DataTableMode;
|
|
16
|
+
columns: ColumnDef<T>[];
|
|
17
|
+
pageSize?: number;
|
|
18
|
+
maxVisibleColumns?: number;
|
|
19
|
+
multiSelect?: boolean;
|
|
20
|
+
getRowId?: (row: T, index: number) => string;
|
|
21
|
+
}
|
|
22
|
+
export declare class DataTableEngine<T> {
|
|
23
|
+
options: DataTableOptions<T>;
|
|
24
|
+
rows: T[];
|
|
25
|
+
loading: boolean;
|
|
26
|
+
search: string;
|
|
27
|
+
query: QueryStructure | null;
|
|
28
|
+
sortColumn: keyof T | null;
|
|
29
|
+
sortDirection: SortDirection;
|
|
30
|
+
page: number;
|
|
31
|
+
pageSize: number;
|
|
32
|
+
columnState: ColumnState<T>[];
|
|
33
|
+
selectedIds: SvelteSet<string>;
|
|
34
|
+
allColumns: ColumnDef<T>[];
|
|
35
|
+
visibleColumns: ColumnDef<T>[];
|
|
36
|
+
mainColumns: ColumnDef<T>[];
|
|
37
|
+
overflowColumns: ColumnDef<T>[];
|
|
38
|
+
processedRows: T[];
|
|
39
|
+
totalRows: number;
|
|
40
|
+
totalFilteredRows: number;
|
|
41
|
+
totalPages: number;
|
|
42
|
+
currentPageRows: T[];
|
|
43
|
+
selectedCount: number;
|
|
44
|
+
allVisibleSelected: boolean;
|
|
45
|
+
someVisibleSelected: boolean;
|
|
46
|
+
isAllPageSelected: boolean;
|
|
47
|
+
constructor(options: DataTableOptions<T>);
|
|
48
|
+
getRowId(row: T, index: number): string;
|
|
49
|
+
setRows(rows: T[]): void;
|
|
50
|
+
setLoading(v: boolean): void;
|
|
51
|
+
setSearch(term: string): void;
|
|
52
|
+
setQuery(q: QueryStructure | null): void;
|
|
53
|
+
setSort(columnId: keyof T | null, direction?: SortDirection): void;
|
|
54
|
+
toggleSort(columnId: keyof T): void;
|
|
55
|
+
setPage(page: number): void;
|
|
56
|
+
setPageSize(size: number): void;
|
|
57
|
+
clearSelection(): void;
|
|
58
|
+
toggleRowSelection(id: string): void;
|
|
59
|
+
selectAllVisible(): void;
|
|
60
|
+
unselectAllVisible(): void;
|
|
61
|
+
selectAllCurrentPage(): void;
|
|
62
|
+
unselectAllCurrentPage(): void;
|
|
63
|
+
setColumnHidden(id: keyof T, hidden: boolean): void;
|
|
64
|
+
resizeColumn(id: keyof T, width: number): void;
|
|
65
|
+
resetLayout(): void;
|
|
66
|
+
getColumnWidth(id: keyof T): number;
|
|
67
|
+
}
|
|
68
|
+
export {};
|