svelte-tably 1.0.0 → 1.0.1
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/LICENSE +20 -20
- package/README.md +301 -298
- package/dist/column/Column.svelte +38 -40
- package/dist/column/Column.svelte.d.ts +22 -3
- package/dist/column/column-state.svelte.d.ts +138 -0
- package/dist/column/{column.svelte.js → column-state.svelte.js} +1 -1
- package/dist/expandable/Expandable.svelte +24 -24
- package/dist/expandable/Expandable.svelte.d.ts +2 -1
- package/dist/expandable/expandable-state.svelte.d.ts +48 -0
- package/dist/expandable/{expandable.svelte.js → expandable-state.svelte.js} +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/panel/Panel.svelte +20 -20
- package/dist/panel/Panel.svelte.d.ts +2 -1
- package/dist/panel/panel-state.svelte.d.ts +25 -0
- package/dist/panel/{panel.svelte.js → panel-state.svelte.js} +1 -1
- package/dist/row/Row.svelte +24 -24
- package/dist/row/Row.svelte.d.ts +2 -1
- package/dist/row/row-state.svelte.d.ts +43 -0
- package/dist/row/{row.svelte.js → row-state.svelte.js} +1 -1
- package/dist/table/Table.svelte +1140 -1139
- package/dist/table/Table.svelte.d.ts +94 -2
- package/dist/table/data.svelte.d.ts +1 -1
- package/dist/table/table-state.svelte.d.ts +107 -0
- package/dist/table/{table.svelte.js → table-state.svelte.js} +2 -2
- package/dist/table/virtualization.svelte.d.ts +1 -1
- package/dist/utility.svelte.d.ts +3 -0
- package/dist/utility.svelte.js +3 -0
- package/package.json +8 -13
|
@@ -1,8 +1,100 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
import { TableState, type TableProps } from './table-state.svelte.js';
|
|
4
|
+
import { type RowColumnCtx } from '../column/column-state.svelte.js';
|
|
1
5
|
declare class __sveltets_Render<T extends Record<PropertyKey, unknown>> {
|
|
2
|
-
props():
|
|
6
|
+
props(): TableProps<T> & {
|
|
7
|
+
content?: Snippet<[context: {
|
|
8
|
+
Column: {
|
|
9
|
+
<V>(internal: unknown, props: {
|
|
10
|
+
id: string;
|
|
11
|
+
table?: TableState<T> | undefined;
|
|
12
|
+
header?: string | Snippet<[ctx: import("../column/column-state.svelte.js").HeaderCtx<T>]> | undefined;
|
|
13
|
+
row?: Snippet<[item: T, ctx: RowColumnCtx<T, V>]> | undefined;
|
|
14
|
+
statusbar?: Snippet<[ctx: import("../column/column-state.svelte.js").StatusbarCtx<T>]> | undefined;
|
|
15
|
+
sticky?: boolean | undefined;
|
|
16
|
+
show?: boolean | undefined;
|
|
17
|
+
sortby?: boolean | undefined;
|
|
18
|
+
width?: number | undefined;
|
|
19
|
+
fixed?: boolean | undefined;
|
|
20
|
+
value?: ((item: T) => V) | undefined;
|
|
21
|
+
sort?: boolean | ((a: V, b: V) => number) | undefined;
|
|
22
|
+
resizeable?: boolean | undefined;
|
|
23
|
+
filter?: ((value: V) => boolean) | undefined;
|
|
24
|
+
style?: string | undefined;
|
|
25
|
+
class?: string | undefined;
|
|
26
|
+
onclick?: ((event: MouseEvent, rowColumnCtx: RowColumnCtx<T, V>) => void) | undefined;
|
|
27
|
+
pad?: "row" | "header" | "both" | undefined;
|
|
28
|
+
}): {};
|
|
29
|
+
new <V>(options: import("svelte").ComponentConstructorOptions<{
|
|
30
|
+
id: string;
|
|
31
|
+
table?: TableState<T> | undefined;
|
|
32
|
+
header?: string | Snippet<[ctx: import("../column/column-state.svelte.js").HeaderCtx<T>]> | undefined;
|
|
33
|
+
row?: Snippet<[item: T, ctx: RowColumnCtx<T, V>]> | undefined;
|
|
34
|
+
statusbar?: Snippet<[ctx: import("../column/column-state.svelte.js").StatusbarCtx<T>]> | undefined;
|
|
35
|
+
sticky?: boolean | undefined;
|
|
36
|
+
show?: boolean | undefined;
|
|
37
|
+
sortby?: boolean | undefined;
|
|
38
|
+
width?: number | undefined;
|
|
39
|
+
fixed?: boolean | undefined;
|
|
40
|
+
value?: ((item: T) => V) | undefined;
|
|
41
|
+
sort?: boolean | ((a: V, b: V) => number) | undefined;
|
|
42
|
+
resizeable?: boolean | undefined;
|
|
43
|
+
filter?: ((value: V) => boolean) | undefined;
|
|
44
|
+
style?: string | undefined;
|
|
45
|
+
class?: string | undefined;
|
|
46
|
+
onclick?: ((event: MouseEvent, rowColumnCtx: RowColumnCtx<T, V>) => void) | undefined;
|
|
47
|
+
pad?: "row" | "header" | "both" | undefined;
|
|
48
|
+
}>): SvelteComponent<{
|
|
49
|
+
id: string;
|
|
50
|
+
table?: TableState<T> | undefined;
|
|
51
|
+
header?: string | Snippet<[ctx: import("../column/column-state.svelte.js").HeaderCtx<T>]> | undefined;
|
|
52
|
+
row?: Snippet<[item: T, ctx: RowColumnCtx<T, V>]> | undefined;
|
|
53
|
+
statusbar?: Snippet<[ctx: import("../column/column-state.svelte.js").StatusbarCtx<T>]> | undefined;
|
|
54
|
+
sticky?: boolean | undefined;
|
|
55
|
+
show?: boolean | undefined;
|
|
56
|
+
sortby?: boolean | undefined;
|
|
57
|
+
width?: number | undefined;
|
|
58
|
+
fixed?: boolean | undefined;
|
|
59
|
+
value?: ((item: T) => V) | undefined;
|
|
60
|
+
sort?: boolean | ((a: V, b: V) => number) | undefined;
|
|
61
|
+
resizeable?: boolean | undefined;
|
|
62
|
+
filter?: ((value: V) => boolean) | undefined;
|
|
63
|
+
style?: string | undefined;
|
|
64
|
+
class?: string | undefined;
|
|
65
|
+
onclick?: ((event: MouseEvent, rowColumnCtx: RowColumnCtx<T, V>) => void) | undefined;
|
|
66
|
+
pad?: "row" | "header" | "both" | undefined;
|
|
67
|
+
}, {}, {}> & {
|
|
68
|
+
$$bindings?: ReturnType<() => "">;
|
|
69
|
+
} & {};
|
|
70
|
+
};
|
|
71
|
+
Panel: {
|
|
72
|
+
(internal: unknown, props: import("../index.js").PanelProps<T>): {};
|
|
73
|
+
new (options: import("svelte").ComponentConstructorOptions<import("../index.js").PanelProps<T>>): SvelteComponent<import("../index.js").PanelProps<T>, {}, {}> & {
|
|
74
|
+
$$bindings?: ReturnType<() => "">;
|
|
75
|
+
};
|
|
76
|
+
z_$$bindings?: ReturnType<() => "">;
|
|
77
|
+
};
|
|
78
|
+
Expandable: {
|
|
79
|
+
(internal: unknown, props: import("../index.js").ExpandableProps<T>): {};
|
|
80
|
+
new (options: import("svelte").ComponentConstructorOptions<import("../index.js").ExpandableProps<T>>): SvelteComponent<import("../index.js").ExpandableProps<T>, {}, {}> & {
|
|
81
|
+
$$bindings?: ReturnType<() => "">;
|
|
82
|
+
};
|
|
83
|
+
z_$$bindings?: ReturnType<() => "">;
|
|
84
|
+
};
|
|
85
|
+
Row: {
|
|
86
|
+
(internal: unknown, props: import("../index.js").RowProps<T>): {};
|
|
87
|
+
new (options: import("svelte").ComponentConstructorOptions<import("../index.js").RowProps<T>>): SvelteComponent<import("../index.js").RowProps<T>, {}, {}> & {
|
|
88
|
+
$$bindings?: ReturnType<() => "">;
|
|
89
|
+
};
|
|
90
|
+
z_$$bindings?: ReturnType<() => "">;
|
|
91
|
+
};
|
|
92
|
+
readonly table: TableState<T>;
|
|
93
|
+
}]> | undefined;
|
|
94
|
+
};
|
|
3
95
|
events(): {};
|
|
4
96
|
slots(): {};
|
|
5
|
-
bindings(): "
|
|
97
|
+
bindings(): "selected" | "panel" | "data";
|
|
6
98
|
exports(): {
|
|
7
99
|
toCSV: (opts?: {
|
|
8
100
|
/** Semi-colons as separator? */
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { type Snippet } from 'svelte';
|
|
2
|
+
import { ColumnState, type RowColumnCtx } from '../column/column-state.svelte.js';
|
|
3
|
+
import { PanelState } from '../panel/panel-state.svelte.js';
|
|
4
|
+
import { Data } from './data.svelte.js';
|
|
5
|
+
import { type AnyRecord } from '../utility.svelte.js';
|
|
6
|
+
import type { ExpandableState } from '../expandable/expandable-state.svelte.js';
|
|
7
|
+
import type { ItemState } from 'runic-reorder';
|
|
8
|
+
import type { RowState } from '../row/row-state.svelte.js';
|
|
9
|
+
export type HeaderSelectCtx<T extends AnyRecord = any> = {
|
|
10
|
+
isSelected: boolean;
|
|
11
|
+
/** The list of selected items */
|
|
12
|
+
readonly selected: T[];
|
|
13
|
+
/**
|
|
14
|
+
* See [MDN :indeterminate](https://developer.mozilla.org/en-US/docs/Web/CSS/:indeterminate)
|
|
15
|
+
*/
|
|
16
|
+
readonly indeterminate: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type RowSelectCtx<T extends AnyRecord = any> = {
|
|
19
|
+
readonly item: T;
|
|
20
|
+
readonly row: RowColumnCtx<T, unknown>;
|
|
21
|
+
data: T[];
|
|
22
|
+
isSelected: boolean;
|
|
23
|
+
};
|
|
24
|
+
export interface RowCtx<T extends AnyRecord> {
|
|
25
|
+
readonly rowHovered: boolean;
|
|
26
|
+
readonly index: number;
|
|
27
|
+
readonly itemState: ItemState<T> | undefined;
|
|
28
|
+
selected: boolean;
|
|
29
|
+
expanded: boolean;
|
|
30
|
+
}
|
|
31
|
+
type SelectOptions<T extends AnyRecord> = {
|
|
32
|
+
/**
|
|
33
|
+
* The style, in which the selection is shown
|
|
34
|
+
*
|
|
35
|
+
* NOTE: If using `edge` | 'side', "show" will always be `hover`. This is due to
|
|
36
|
+
* an inconsistency/limitation of matching the scroll between the selection div and the rows.
|
|
37
|
+
*
|
|
38
|
+
* @default 'column'
|
|
39
|
+
*/
|
|
40
|
+
style?: 'column';
|
|
41
|
+
/**
|
|
42
|
+
* When to show the row-select, when not selected?
|
|
43
|
+
* @default 'hover'
|
|
44
|
+
*/
|
|
45
|
+
show?: 'hover' | 'always' | 'never';
|
|
46
|
+
/**
|
|
47
|
+
* Custom snippet
|
|
48
|
+
*/
|
|
49
|
+
headerSnippet?: Snippet<[context: HeaderSelectCtx]>;
|
|
50
|
+
rowSnippet?: Snippet<[context: RowSelectCtx<T>]>;
|
|
51
|
+
};
|
|
52
|
+
export type TableProps<T extends AnyRecord> = {
|
|
53
|
+
id?: string;
|
|
54
|
+
data: T[];
|
|
55
|
+
selected?: T[];
|
|
56
|
+
/** Current visible panel */
|
|
57
|
+
panel?: string;
|
|
58
|
+
filters?: ((item: T) => boolean)[];
|
|
59
|
+
/**
|
|
60
|
+
* **For a reorderable table, the data is mutated when reordered.**
|
|
61
|
+
*
|
|
62
|
+
* Reorderable tables cannot
|
|
63
|
+
* - Be filtered
|
|
64
|
+
* - Be sorted
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
reorderable?: boolean;
|
|
68
|
+
/** Whether columns in this table can be resized */
|
|
69
|
+
resizeable?: boolean;
|
|
70
|
+
/** Whether to enable selection */
|
|
71
|
+
select?: boolean | SelectOptions<T>;
|
|
72
|
+
/** Create missing columns automatically. */
|
|
73
|
+
auto?: boolean;
|
|
74
|
+
};
|
|
75
|
+
export declare class TableState<T extends AnyRecord> {
|
|
76
|
+
#private;
|
|
77
|
+
id: string;
|
|
78
|
+
dataState: Data<T>;
|
|
79
|
+
data: T[];
|
|
80
|
+
columns: Record<string, ColumnState<T, any>>;
|
|
81
|
+
panels: Record<string, PanelState<T>>;
|
|
82
|
+
expandable: undefined | ExpandableState<T>;
|
|
83
|
+
row: undefined | RowState<T>;
|
|
84
|
+
/** Currently selected items */
|
|
85
|
+
get selected(): T[];
|
|
86
|
+
set selected(items: T[]);
|
|
87
|
+
/** Column positions based on column ids */
|
|
88
|
+
positions: {
|
|
89
|
+
fixed: ColumnState<T, any>[];
|
|
90
|
+
sticky: ColumnState<T, any>[];
|
|
91
|
+
scroll: ColumnState<T, any>[];
|
|
92
|
+
hidden: ColumnState<T, any>[];
|
|
93
|
+
};
|
|
94
|
+
/** Primarily externally managed options */
|
|
95
|
+
options: {
|
|
96
|
+
panel: string | undefined;
|
|
97
|
+
filters: boolean | ((item: T) => boolean)[];
|
|
98
|
+
resizeable: boolean;
|
|
99
|
+
reorderable: boolean;
|
|
100
|
+
select: boolean | SelectOptions<T>;
|
|
101
|
+
auto: boolean;
|
|
102
|
+
};
|
|
103
|
+
add(state: ColumnState<T, any> | PanelState<T>): (() => void) | undefined;
|
|
104
|
+
static getContext<T extends AnyRecord>(): TableState<T> | undefined;
|
|
105
|
+
constructor(tableProps: TableProps<T>);
|
|
106
|
+
}
|
|
107
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
|
-
import { ColumnState } from '../column/column.svelte.js';
|
|
3
|
-
import { PanelState } from '../panel/panel.svelte.js';
|
|
2
|
+
import { ColumnState } from '../column/column-state.svelte.js';
|
|
3
|
+
import { PanelState } from '../panel/panel-state.svelte.js';
|
|
4
4
|
import { Data } from './data.svelte.js';
|
|
5
5
|
export class TableState {
|
|
6
6
|
#props = {};
|
package/dist/utility.svelte.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Snippet } from 'svelte';
|
|
1
2
|
export type Simplify<T> = T extends infer V ? {
|
|
2
3
|
[K in keyof V]: V[K];
|
|
3
4
|
} : never;
|
|
@@ -18,4 +19,6 @@ export declare function assignDescriptors<T extends AnyRecord, B extends AnyReco
|
|
|
18
19
|
export declare function capitalize(str: string): string;
|
|
19
20
|
/** Split words when going from lower case to uppercase; `someWords-split` -> `some Word Split...` */
|
|
20
21
|
export declare function segmentize(str: string): string;
|
|
22
|
+
type SnippetLiteralProperties<K extends unknown[], Result extends (() => unknown)[] = []> = K extends [infer First, ...infer Rest] ? SnippetLiteralProperties<Rest, [...Result, () => First]> : Result;
|
|
23
|
+
export declare function snippetLiteral<K extends unknown[]>(snippet: Snippet<K>): ((anchor: Comment, ...args: SnippetLiteralProperties<K>) => ReturnType<typeof snippet>);
|
|
21
24
|
export {};
|
package/dist/utility.svelte.js
CHANGED
package/package.json
CHANGED
|
@@ -1,35 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tably",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "A high performant dynamic table for Svelte 5",
|
|
5
|
+
"license": "MIT",
|
|
4
6
|
"repository": {
|
|
5
7
|
"type": "git",
|
|
6
8
|
"url": "git+https://github.com/Refzlund/svelte-tably.git"
|
|
7
9
|
},
|
|
8
|
-
"license": "MIT",
|
|
9
10
|
"bugs": {
|
|
10
11
|
"url": "https://github.com/Refzlund/svelte-tably/issues"
|
|
11
12
|
},
|
|
12
13
|
"files": [
|
|
13
|
-
"dist"
|
|
14
|
-
"!dist/**/*.test.*",
|
|
15
|
-
"!dist/**/*.spec.*"
|
|
16
|
-
],
|
|
17
|
-
"sideEffects": [
|
|
18
|
-
"**/*.css"
|
|
14
|
+
"dist"
|
|
19
15
|
],
|
|
20
|
-
"svelte": "./dist/index.js",
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
16
|
"type": "module",
|
|
23
17
|
"exports": {
|
|
24
18
|
".": {
|
|
25
19
|
"types": "./dist/index.d.ts",
|
|
26
|
-
"default": "./dist/index.js"
|
|
20
|
+
"default": "./dist/index.js",
|
|
21
|
+
"svelte": "./dist/index.js"
|
|
27
22
|
}
|
|
28
23
|
},
|
|
29
24
|
"dependencies": {
|
|
30
|
-
"runic-reorder": "^1
|
|
25
|
+
"runic-reorder": "^1"
|
|
31
26
|
},
|
|
32
27
|
"peerDependencies": {
|
|
33
|
-
"svelte": "^5
|
|
28
|
+
"svelte": "^5"
|
|
34
29
|
}
|
|
35
30
|
}
|