sveltacular 1.0.30 → 1.0.31
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/tables/cell-renderers.d.ts +17 -17
- package/dist/tables/data-grid-actions-cell.svelte +3 -3
- package/dist/tables/data-grid-actions-cell.svelte.d.ts +7 -7
- package/dist/tables/data-grid-cell.svelte +3 -3
- package/dist/tables/data-grid-cell.svelte.d.ts +6 -6
- package/dist/tables/data-grid-row.svelte +5 -11
- package/dist/tables/data-grid-row.svelte.d.ts +7 -7
- package/dist/tables/data-grid-type-example.svelte +4 -4
- package/dist/tables/data-grid.svelte +11 -7
- package/dist/tables/data-grid.svelte.d.ts +7 -7
- package/dist/tables/table-context.svelte.d.ts +5 -5
- package/dist/tables/table-row.svelte +2 -2
- package/dist/tables/table-row.svelte.d.ts +2 -2
- package/dist/tables/table-selection-cell.svelte +2 -2
- package/dist/tables/table-selection-cell.svelte.d.ts +2 -2
- package/dist/types/data.d.ts +1 -2
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface CellRenderContext<T extends
|
|
1
|
+
import type { PlainObject, ColumnDef, TextColumn, NumberColumn, CurrencyColumn, DateColumn, DateTimeColumn, BooleanColumn, EmailColumn, ArrayColumn, CustomColumn } from '../types/data.js';
|
|
2
|
+
export interface CellRenderContext<T extends PlainObject = PlainObject> {
|
|
3
3
|
row: T;
|
|
4
4
|
column: ColumnDef<T>;
|
|
5
5
|
value: unknown;
|
|
6
6
|
rowIndex: number;
|
|
7
7
|
}
|
|
8
|
-
export declare function getCellValue<T extends
|
|
8
|
+
export declare function getCellValue<T extends PlainObject>(row: T, key: string): unknown;
|
|
9
9
|
export declare function isNullish(value: unknown): value is null | undefined;
|
|
10
10
|
export declare function isEmpty(value: unknown): boolean;
|
|
11
|
-
export declare function formatTextCell<T extends
|
|
12
|
-
export declare function formatNumberCell<T extends
|
|
13
|
-
export declare function formatCurrencyCell<T extends
|
|
14
|
-
export declare function formatDateCell<T extends
|
|
15
|
-
export declare function formatDateTimeCell<T extends
|
|
16
|
-
export declare function formatBooleanCell<T extends
|
|
17
|
-
export declare function formatEmailCell<T extends
|
|
11
|
+
export declare function formatTextCell<T extends PlainObject>(row: T, column: TextColumn<T>): string;
|
|
12
|
+
export declare function formatNumberCell<T extends PlainObject>(row: T, column: NumberColumn<T>): string;
|
|
13
|
+
export declare function formatCurrencyCell<T extends PlainObject>(row: T, column: CurrencyColumn<T>): string;
|
|
14
|
+
export declare function formatDateCell<T extends PlainObject>(row: T, column: DateColumn<T>): string;
|
|
15
|
+
export declare function formatDateTimeCell<T extends PlainObject>(row: T, column: DateTimeColumn<T>): string;
|
|
16
|
+
export declare function formatBooleanCell<T extends PlainObject>(row: T, column: BooleanColumn<T>): string;
|
|
17
|
+
export declare function formatEmailCell<T extends PlainObject>(row: T, column: EmailColumn<T>): string;
|
|
18
18
|
export interface ArrayCellResult {
|
|
19
19
|
items: Array<{
|
|
20
20
|
text: string;
|
|
@@ -22,11 +22,11 @@ export interface ArrayCellResult {
|
|
|
22
22
|
}>;
|
|
23
23
|
separator: 'comma' | 'semicolon' | 'line' | 'pill';
|
|
24
24
|
}
|
|
25
|
-
export declare function formatArrayCell<T extends
|
|
26
|
-
export declare function formatCustomCell<T extends
|
|
27
|
-
export declare function formatCell<T extends
|
|
28
|
-
export declare function getCellLink<T extends
|
|
29
|
-
export declare function getCellAlignment<T extends
|
|
30
|
-
export declare function getCellTypeClass<T extends
|
|
25
|
+
export declare function formatArrayCell<T extends PlainObject>(row: T, column: ArrayColumn<T>): ArrayCellResult;
|
|
26
|
+
export declare function formatCustomCell<T extends PlainObject>(row: T, column: CustomColumn<T>): string;
|
|
27
|
+
export declare function formatCell<T extends PlainObject>(row: T, column: ColumnDef<T>): string;
|
|
28
|
+
export declare function getCellLink<T extends PlainObject>(row: T, column: ColumnDef<T>): string | null;
|
|
29
|
+
export declare function getCellAlignment<T extends PlainObject>(column: ColumnDef<T>): 'left' | 'center' | 'right';
|
|
30
|
+
export declare function getCellTypeClass<T extends PlainObject>(column: ColumnDef<T>): string;
|
|
31
31
|
export declare function compareValues(a: unknown, b: unknown, direction: 'asc' | 'desc'): number;
|
|
32
|
-
export declare function sortRows<T extends
|
|
32
|
+
export declare function sortRows<T extends PlainObject>(rows: T[], column: ColumnDef<T>, direction: 'asc' | 'desc'): T[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends
|
|
2
|
-
import type {
|
|
1
|
+
<script lang="ts" generics="T extends PlainObject">
|
|
2
|
+
import type { PlainObject, RowActions } from '../types/data.js';
|
|
3
3
|
import type { ButtonVariant, FormFieldSizeOptions } from '../types/form.js';
|
|
4
4
|
import TableCell from './table-cell.svelte';
|
|
5
5
|
import Button from '../forms/button/button.svelte';
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
actionButtonSize = 'sm',
|
|
14
14
|
actionAlign = 'center'
|
|
15
15
|
}: {
|
|
16
|
-
actions:
|
|
16
|
+
actions: RowActions<T>;
|
|
17
17
|
row: T;
|
|
18
18
|
actionButtonVariant?: ButtonVariant;
|
|
19
19
|
actionButtonSize?: FormFieldSizeOptions;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PlainObject, RowActions } from '../types/data.js';
|
|
2
2
|
import type { ButtonVariant, FormFieldSizeOptions } from '../types/form.js';
|
|
3
|
-
declare function $$render<T extends
|
|
3
|
+
declare function $$render<T extends PlainObject>(): {
|
|
4
4
|
props: {
|
|
5
|
-
actions:
|
|
5
|
+
actions: RowActions<T>;
|
|
6
6
|
row: T;
|
|
7
7
|
actionButtonVariant?: ButtonVariant;
|
|
8
8
|
actionButtonSize?: FormFieldSizeOptions;
|
|
@@ -13,7 +13,7 @@ declare function $$render<T extends JsonObject>(): {
|
|
|
13
13
|
slots: {};
|
|
14
14
|
events: {};
|
|
15
15
|
};
|
|
16
|
-
declare class __sveltets_Render<T extends
|
|
16
|
+
declare class __sveltets_Render<T extends PlainObject> {
|
|
17
17
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
18
18
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
19
19
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -21,12 +21,12 @@ declare class __sveltets_Render<T extends JsonObject> {
|
|
|
21
21
|
exports(): {};
|
|
22
22
|
}
|
|
23
23
|
interface $$IsomorphicComponent {
|
|
24
|
-
new <T extends
|
|
24
|
+
new <T extends PlainObject>(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']>> & {
|
|
25
25
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
26
26
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
27
|
-
<T extends
|
|
27
|
+
<T extends PlainObject>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
28
28
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
29
29
|
}
|
|
30
30
|
declare const DataGridActionsCell: $$IsomorphicComponent;
|
|
31
|
-
type DataGridActionsCell<T extends
|
|
31
|
+
type DataGridActionsCell<T extends PlainObject> = InstanceType<typeof DataGridActionsCell<T>>;
|
|
32
32
|
export default DataGridActionsCell;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends
|
|
1
|
+
<script lang="ts" generics="T extends PlainObject">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { ColumnDef,
|
|
3
|
+
import type { ColumnDef, PlainObject } from '../types/data.js';
|
|
4
4
|
import TableCell from './table-cell.svelte';
|
|
5
5
|
import Pill from '../generic/pill/pill.svelte';
|
|
6
6
|
import {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
formatArrayCell
|
|
13
13
|
} from './cell-renderers.js';
|
|
14
14
|
|
|
15
|
-
interface CellContext<TRow extends
|
|
15
|
+
interface CellContext<TRow extends PlainObject = PlainObject> {
|
|
16
16
|
row: TRow;
|
|
17
17
|
value: unknown;
|
|
18
18
|
column: ColumnDef<TRow>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { ColumnDef,
|
|
3
|
-
declare function $$render<T extends
|
|
2
|
+
import type { ColumnDef, PlainObject } from '../types/data.js';
|
|
3
|
+
declare function $$render<T extends PlainObject>(): {
|
|
4
4
|
props: {
|
|
5
5
|
row: T;
|
|
6
6
|
column: ColumnDef<T>;
|
|
@@ -18,7 +18,7 @@ declare function $$render<T extends JsonObject>(): {
|
|
|
18
18
|
slots: {};
|
|
19
19
|
events: {};
|
|
20
20
|
};
|
|
21
|
-
declare class __sveltets_Render<T extends
|
|
21
|
+
declare class __sveltets_Render<T extends PlainObject> {
|
|
22
22
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
23
23
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
24
24
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -26,12 +26,12 @@ declare class __sveltets_Render<T extends JsonObject> {
|
|
|
26
26
|
exports(): {};
|
|
27
27
|
}
|
|
28
28
|
interface $$IsomorphicComponent {
|
|
29
|
-
new <T extends
|
|
29
|
+
new <T extends PlainObject>(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']>> & {
|
|
30
30
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
31
31
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
32
|
-
<T extends
|
|
32
|
+
<T extends PlainObject>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
33
33
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
34
34
|
}
|
|
35
35
|
declare const DataGridCell: $$IsomorphicComponent;
|
|
36
|
-
type DataGridCell<T extends
|
|
36
|
+
type DataGridCell<T extends PlainObject> = InstanceType<typeof DataGridCell<T>>;
|
|
37
37
|
export default DataGridCell;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends
|
|
1
|
+
<script lang="ts" generics="T extends PlainObject">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type { ColumnDef,
|
|
3
|
+
import type { ColumnDef, PlainObject, RowActions } from '../types/data.js';
|
|
4
4
|
import type { ButtonVariant, FormFieldSizeOptions } from '../types/form.js';
|
|
5
5
|
import TableRow from './table-row.svelte';
|
|
6
6
|
import TableSelectionCell from './table-selection-cell.svelte';
|
|
7
7
|
import DataGridCell from './data-grid-cell.svelte';
|
|
8
8
|
import DataGridActionsCell from './data-grid-actions-cell.svelte';
|
|
9
9
|
|
|
10
|
-
interface CellContext<TRow extends
|
|
10
|
+
interface CellContext<TRow extends PlainObject = PlainObject> {
|
|
11
11
|
row: TRow;
|
|
12
12
|
value: unknown;
|
|
13
13
|
column: ColumnDef<TRow>;
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
visibleCols: ColumnDef<T>[];
|
|
32
32
|
hasSelectionCol?: boolean;
|
|
33
33
|
hasActionCol?: boolean;
|
|
34
|
-
actions?:
|
|
34
|
+
actions?: RowActions<T>;
|
|
35
35
|
cells?: Record<string, Snippet<[CellContext<T>]>>;
|
|
36
36
|
actionButtonVariant?: ButtonVariant;
|
|
37
37
|
actionButtonSize?: FormFieldSizeOptions;
|
|
@@ -44,13 +44,7 @@
|
|
|
44
44
|
<TableSelectionCell {row} {rowIndex} />
|
|
45
45
|
{/if}
|
|
46
46
|
{#each visibleCols as col}
|
|
47
|
-
<DataGridCell
|
|
48
|
-
{row}
|
|
49
|
-
column={col}
|
|
50
|
-
{rowIndex}
|
|
51
|
-
cellSnippet={cells?.[col.key]}
|
|
52
|
-
width={col.width}
|
|
53
|
-
/>
|
|
47
|
+
<DataGridCell {row} column={col} {rowIndex} cellSnippet={cells?.[col.key]} width={col.width} />
|
|
54
48
|
{/each}
|
|
55
49
|
{#if hasActionCol && actions}
|
|
56
50
|
<DataGridActionsCell {actions} {row} {actionButtonVariant} {actionButtonSize} {actionAlign} />
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { ColumnDef,
|
|
2
|
+
import type { ColumnDef, PlainObject, RowActions } from '../types/data.js';
|
|
3
3
|
import type { ButtonVariant, FormFieldSizeOptions } from '../types/form.js';
|
|
4
|
-
declare function $$render<T extends
|
|
4
|
+
declare function $$render<T extends PlainObject>(): {
|
|
5
5
|
props: {
|
|
6
6
|
row: T;
|
|
7
7
|
rowIndex: number;
|
|
8
8
|
visibleCols: ColumnDef<T>[];
|
|
9
9
|
hasSelectionCol?: boolean;
|
|
10
10
|
hasActionCol?: boolean;
|
|
11
|
-
actions?:
|
|
11
|
+
actions?: RowActions<T>;
|
|
12
12
|
cells?: Record<string, Snippet<[{
|
|
13
13
|
row: T;
|
|
14
14
|
value: unknown;
|
|
@@ -24,7 +24,7 @@ declare function $$render<T extends JsonObject>(): {
|
|
|
24
24
|
slots: {};
|
|
25
25
|
events: {};
|
|
26
26
|
};
|
|
27
|
-
declare class __sveltets_Render<T extends
|
|
27
|
+
declare class __sveltets_Render<T extends PlainObject> {
|
|
28
28
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
29
29
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
30
30
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -32,12 +32,12 @@ declare class __sveltets_Render<T extends JsonObject> {
|
|
|
32
32
|
exports(): {};
|
|
33
33
|
}
|
|
34
34
|
interface $$IsomorphicComponent {
|
|
35
|
-
new <T extends
|
|
35
|
+
new <T extends PlainObject>(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']>> & {
|
|
36
36
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
37
37
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
38
|
-
<T extends
|
|
38
|
+
<T extends PlainObject>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
39
39
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
40
40
|
}
|
|
41
41
|
declare const DataGridRow: $$IsomorphicComponent;
|
|
42
|
-
type DataGridRow<T extends
|
|
42
|
+
type DataGridRow<T extends PlainObject> = InstanceType<typeof DataGridRow<T>>;
|
|
43
43
|
export default DataGridRow;
|
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* It shows how TypeScript will catch errors at compile time.
|
|
5
5
|
*/
|
|
6
6
|
import DataGrid from './data-grid.svelte';
|
|
7
|
-
import type { ColumnDef,
|
|
7
|
+
import type { ColumnDef, PlainObject, RowActions } from '../types/data.js';
|
|
8
8
|
|
|
9
9
|
// Define a strongly-typed interface for our data
|
|
10
|
-
interface Product extends
|
|
10
|
+
interface Product extends PlainObject {
|
|
11
11
|
id: number;
|
|
12
12
|
name: string;
|
|
13
13
|
price: number;
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
];
|
|
58
58
|
|
|
59
59
|
// Type-safe actions with typed row parameter
|
|
60
|
-
const actions:
|
|
60
|
+
const actions: RowActions<Product> = {
|
|
61
61
|
type: 'dropdown',
|
|
62
62
|
items: [
|
|
63
63
|
{
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
|
|
88
88
|
// Type-safe selection handler
|
|
89
89
|
function handleSelectionChange(selectedProducts: Product[]) {
|
|
90
|
-
// selectedProducts is typed as Product[], not
|
|
90
|
+
// selectedProducts is typed as Product[], not PlainObject[]
|
|
91
91
|
selectedProducts.forEach((product) => {
|
|
92
92
|
console.log(`Selected: ${product.name} - $${product.price}`);
|
|
93
93
|
// Full type safety and autocomplete here
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends
|
|
1
|
+
<script lang="ts" generics="T extends PlainObject">
|
|
2
2
|
import TableCell from './table-cell.svelte';
|
|
3
3
|
import TableHeaderCell from './table-header-cell.svelte';
|
|
4
4
|
import TableHeader from './table-header.svelte';
|
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import DataGridRow from './data-grid-row.svelte';
|
|
8
8
|
import type {
|
|
9
9
|
ColumnDef,
|
|
10
|
-
|
|
10
|
+
PlainObject,
|
|
11
11
|
PaginationProperties,
|
|
12
|
-
|
|
12
|
+
RowActions
|
|
13
13
|
} from '../types/data.js';
|
|
14
14
|
import Empty from '../generic/empty/empty.svelte';
|
|
15
15
|
import Icon from '../icons/icon.svelte';
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
type PaginationEvent = (pagination: PaginationProperties) => void;
|
|
25
25
|
|
|
26
|
-
interface CellContext<TRow extends
|
|
26
|
+
interface CellContext<TRow extends PlainObject = PlainObject> {
|
|
27
27
|
row: TRow;
|
|
28
28
|
value: unknown;
|
|
29
29
|
column: ColumnDef<TRow>;
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
rows?: T[];
|
|
57
57
|
cols: ColumnDef<T>[];
|
|
58
58
|
pagination?: PaginationProperties;
|
|
59
|
-
actions?:
|
|
59
|
+
actions?: RowActions<T>;
|
|
60
60
|
stickyHeader?: boolean;
|
|
61
61
|
enableSorting?: boolean;
|
|
62
62
|
selectionMode?: 'none' | 'single' | 'multi';
|
|
@@ -107,9 +107,13 @@
|
|
|
107
107
|
Math.max(1, visibleCols.length) + (hasActionCol ? 1 : 0) + (hasSelectionCol ? 1 : 0)
|
|
108
108
|
);
|
|
109
109
|
let actionButtonVariant: ButtonVariant = $derived.by(() => {
|
|
110
|
-
return (
|
|
110
|
+
return (
|
|
111
|
+
!actions?.variant || actions.variant === 'default' ? 'outline' : actions.variant
|
|
112
|
+
) as ButtonVariant;
|
|
111
113
|
});
|
|
112
|
-
let actionButtonSize: FormFieldSizeOptions = $derived(
|
|
114
|
+
let actionButtonSize: FormFieldSizeOptions = $derived(
|
|
115
|
+
(actions?.size ?? 'sm') as FormFieldSizeOptions
|
|
116
|
+
);
|
|
113
117
|
let actionAlign = $derived(actions?.align ?? 'center');
|
|
114
118
|
|
|
115
119
|
// Track selected count from selection change callbacks
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { ColumnDef,
|
|
1
|
+
import type { ColumnDef, PlainObject, PaginationProperties, RowActions } from '../types/data.js';
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
declare function $$render<T extends
|
|
3
|
+
declare function $$render<T extends PlainObject>(): {
|
|
4
4
|
props: {
|
|
5
5
|
captionSide?: "top" | "bottom";
|
|
6
6
|
captionAlign?: "left" | "center" | "right";
|
|
7
7
|
rows?: T[];
|
|
8
8
|
cols: ColumnDef<T>[];
|
|
9
9
|
pagination?: PaginationProperties;
|
|
10
|
-
actions?:
|
|
10
|
+
actions?: RowActions<T>;
|
|
11
11
|
stickyHeader?: boolean;
|
|
12
12
|
enableSorting?: boolean;
|
|
13
13
|
selectionMode?: "none" | "single" | "multi";
|
|
@@ -32,7 +32,7 @@ declare function $$render<T extends JsonObject>(): {
|
|
|
32
32
|
slots: {};
|
|
33
33
|
events: {};
|
|
34
34
|
};
|
|
35
|
-
declare class __sveltets_Render<T extends
|
|
35
|
+
declare class __sveltets_Render<T extends PlainObject> {
|
|
36
36
|
props(): ReturnType<typeof $$render<T>>['props'];
|
|
37
37
|
events(): ReturnType<typeof $$render<T>>['events'];
|
|
38
38
|
slots(): ReturnType<typeof $$render<T>>['slots'];
|
|
@@ -40,12 +40,12 @@ declare class __sveltets_Render<T extends JsonObject> {
|
|
|
40
40
|
exports(): {};
|
|
41
41
|
}
|
|
42
42
|
interface $$IsomorphicComponent {
|
|
43
|
-
new <T extends
|
|
43
|
+
new <T extends PlainObject>(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']>> & {
|
|
44
44
|
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
45
45
|
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
46
|
-
<T extends
|
|
46
|
+
<T extends PlainObject>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
47
47
|
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
48
48
|
}
|
|
49
49
|
declare const DataGrid: $$IsomorphicComponent;
|
|
50
|
-
type DataGrid<T extends
|
|
50
|
+
type DataGrid<T extends PlainObject> = InstanceType<typeof DataGrid<T>>;
|
|
51
51
|
export default DataGrid;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export interface TableContextConfig<T extends
|
|
1
|
+
import type { PlainObject, SortDirection, SortState } from '../types/data.js';
|
|
2
|
+
export interface TableContextConfig<T extends PlainObject = PlainObject> {
|
|
3
3
|
enableSorting?: boolean;
|
|
4
4
|
selectionMode?: 'none' | 'single' | 'multi';
|
|
5
5
|
rowIdKey?: keyof T & string;
|
|
@@ -7,7 +7,7 @@ export interface TableContextConfig<T extends JsonObject = JsonObject> {
|
|
|
7
7
|
onSelectionChange?: (selectedRowIds: (string | number)[]) => void;
|
|
8
8
|
rows?: T[];
|
|
9
9
|
}
|
|
10
|
-
export declare class TableContext<T extends
|
|
10
|
+
export declare class TableContext<T extends PlainObject = PlainObject> {
|
|
11
11
|
sortColumn: string | null;
|
|
12
12
|
sortDirection: SortDirection;
|
|
13
13
|
selectedIds: Set<string | number>;
|
|
@@ -32,5 +32,5 @@ export declare class TableContext<T extends JsonObject = JsonObject> {
|
|
|
32
32
|
getSelectedCount(): number;
|
|
33
33
|
getSelectedRows(rows: T[]): T[];
|
|
34
34
|
}
|
|
35
|
-
export declare function createTableContext<T extends
|
|
36
|
-
export declare function getTableContext<T extends
|
|
35
|
+
export declare function createTableContext<T extends PlainObject = PlainObject>(config?: TableContextConfig<T>): TableContext<T>;
|
|
36
|
+
export declare function getTableContext<T extends PlainObject = PlainObject>(): TableContext<T> | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import type {
|
|
3
|
+
import type { PlainObject } from '../types/data.js';
|
|
4
4
|
import { getTableContext } from './table-context.svelte.js';
|
|
5
5
|
|
|
6
6
|
let {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
selectable = false
|
|
11
11
|
}: {
|
|
12
12
|
children?: Snippet;
|
|
13
|
-
row?:
|
|
13
|
+
row?: PlainObject;
|
|
14
14
|
rowIndex?: number;
|
|
15
15
|
selectable?: boolean;
|
|
16
16
|
} = $props();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PlainObject } from '../types/data.js';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
children?: Snippet;
|
|
5
|
-
row?:
|
|
5
|
+
row?: PlainObject;
|
|
6
6
|
rowIndex?: number;
|
|
7
7
|
selectable?: boolean;
|
|
8
8
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type {
|
|
2
|
+
import type { PlainObject } from '../types/data.js';
|
|
3
3
|
import { getTableContext } from './table-context.svelte.js';
|
|
4
4
|
import CheckBox from '../forms/check-box/check-box.svelte';
|
|
5
5
|
import RadioBox from '../forms/radio-group/radio-box.svelte';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
row = undefined,
|
|
9
9
|
rowIndex = undefined
|
|
10
10
|
}: {
|
|
11
|
-
row?:
|
|
11
|
+
row?: PlainObject;
|
|
12
12
|
rowIndex?: number;
|
|
13
13
|
} = $props();
|
|
14
14
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PlainObject } from '../types/data.js';
|
|
2
2
|
type $$ComponentProps = {
|
|
3
|
-
row?:
|
|
3
|
+
row?: PlainObject;
|
|
4
4
|
rowIndex?: number;
|
|
5
5
|
};
|
|
6
6
|
declare const TableSelectionCell: import("svelte").Component<$$ComponentProps, {}, "">;
|
package/dist/types/data.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ export type JSONValue = string | number | boolean | null | {
|
|
|
5
5
|
[x: string]: JSONValue;
|
|
6
6
|
} | JSONValue[];
|
|
7
7
|
export type PlainObject = Record<string, any>;
|
|
8
|
-
export type JsonObject = Record<string, JSONValue>;
|
|
9
8
|
interface BaseColumn<T extends PlainObject = PlainObject> {
|
|
10
9
|
key: keyof T & string;
|
|
11
10
|
label: string;
|
|
@@ -102,7 +101,7 @@ export interface DataGridAction<T extends PlainObject = PlainObject> {
|
|
|
102
101
|
href?: (row: T) => string;
|
|
103
102
|
onClick?: (row: T) => unknown;
|
|
104
103
|
}
|
|
105
|
-
export interface
|
|
104
|
+
export interface RowActions<T extends PlainObject = PlainObject> {
|
|
106
105
|
text?: string;
|
|
107
106
|
type?: 'buttons' | 'dropdown';
|
|
108
107
|
variant?: ButtonVariant | 'default';
|