svelte-tably 1.0.0-next.7 → 1.0.0-next.9
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/README.md +5 -3
- package/dist/Column.svelte +110 -51
- package/dist/Column.svelte.d.ts +75 -30
- package/dist/Table.svelte +604 -258
- package/dist/Table.svelte.d.ts +51 -47
- package/dist/trigger.svelte.d.ts +10 -0
- package/dist/trigger.svelte.js +27 -0
- package/package.json +1 -1
package/dist/Table.svelte.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SvelteComponent } from "svelte";
|
|
2
2
|
export interface TableState<T extends Record<PropertyKey, any> = Record<PropertyKey, any>> {
|
|
3
|
-
columns: Record<string,
|
|
3
|
+
columns: Record<string, ColumnState<T>>;
|
|
4
4
|
panels: Record<string, TPanel<T>>;
|
|
5
5
|
selected: T[] | null;
|
|
6
6
|
sortby?: string;
|
|
7
|
+
sortReverse: boolean;
|
|
7
8
|
positions: {
|
|
8
9
|
sticky: string[];
|
|
9
10
|
scroll: string[];
|
|
@@ -14,58 +15,36 @@ export interface TableState<T extends Record<PropertyKey, any> = Record<Property
|
|
|
14
15
|
readonly data: T[];
|
|
15
16
|
/** Rows become anchors */
|
|
16
17
|
readonly href?: (item: T) => string;
|
|
17
|
-
addColumn(key: string, options:
|
|
18
|
+
addColumn(key: string, options: ColumnState<T>): void;
|
|
18
19
|
removeColumn(key: string): void;
|
|
19
20
|
}
|
|
20
21
|
export declare function getTableState<T extends Record<PropertyKey, any> = Record<PropertyKey, any>>(): TableState<T>;
|
|
22
|
+
export type HeaderSelectCtx<T = any> = {
|
|
23
|
+
isSelected: boolean;
|
|
24
|
+
/** The list of selected items */
|
|
25
|
+
readonly selected: T[];
|
|
26
|
+
/**
|
|
27
|
+
* See [MDN :indeterminate](https://developer.mozilla.org/en-US/docs/Web/CSS/:indeterminate)
|
|
28
|
+
*/
|
|
29
|
+
readonly indeterminate: boolean;
|
|
30
|
+
};
|
|
31
|
+
export type RowSelectCtx<T = any> = {
|
|
32
|
+
readonly item: T;
|
|
33
|
+
readonly row: RowCtx<unknown>;
|
|
34
|
+
data: T[];
|
|
35
|
+
isSelected: boolean;
|
|
36
|
+
};
|
|
21
37
|
import { type Snippet } from 'svelte';
|
|
22
|
-
import
|
|
38
|
+
import { type ColumnProps, type RowCtx, type ColumnState } from './Column.svelte';
|
|
23
39
|
import Panel, { type Panel as TPanel } from './Panel.svelte';
|
|
24
40
|
declare class __sveltets_Render<T extends Record<PropertyKey, unknown>> {
|
|
25
41
|
props(): {
|
|
26
42
|
content: Snippet<[context: {
|
|
27
43
|
Column: {
|
|
28
|
-
(internal: unknown, props: {
|
|
29
|
-
|
|
30
|
-
row: Column<T_1, V>["row"];
|
|
31
|
-
statusbar?: Column<T_1, V>["statusbar"];
|
|
32
|
-
id: string;
|
|
33
|
-
sticky?: boolean;
|
|
34
|
-
sort?: boolean;
|
|
35
|
-
show?: boolean;
|
|
36
|
-
width?: number;
|
|
37
|
-
value?: Column<T_1, V>["options"]["value"];
|
|
38
|
-
sorting?: Column<T_1, V>["options"]["sorting"];
|
|
39
|
-
resizeable?: boolean;
|
|
40
|
-
}): {};
|
|
41
|
-
new (options: import("svelte").ComponentConstructorOptions<{
|
|
42
|
-
header?: Column<T_1, V>["header"];
|
|
43
|
-
row: Column<T_1, V>["row"];
|
|
44
|
-
statusbar?: Column<T_1, V>["statusbar"];
|
|
45
|
-
id: string;
|
|
46
|
-
sticky?: boolean;
|
|
47
|
-
sort?: boolean;
|
|
48
|
-
show?: boolean;
|
|
49
|
-
width?: number;
|
|
50
|
-
value?: Column<T_1, V>["options"]["value"];
|
|
51
|
-
sorting?: Column<T_1, V>["options"]["sorting"];
|
|
52
|
-
resizeable?: boolean;
|
|
53
|
-
}>): SvelteComponent<{
|
|
54
|
-
header?: Column<T_1, V>["header"];
|
|
55
|
-
row: Column<T_1, V>["row"];
|
|
56
|
-
statusbar?: Column<T_1, V>["statusbar"];
|
|
57
|
-
id: string;
|
|
58
|
-
sticky?: boolean;
|
|
59
|
-
sort?: boolean;
|
|
60
|
-
show?: boolean;
|
|
61
|
-
width?: number;
|
|
62
|
-
value?: Column<T_1, V>["options"]["value"];
|
|
63
|
-
sorting?: Column<T_1, V>["options"]["sorting"];
|
|
64
|
-
resizeable?: boolean;
|
|
65
|
-
}, {}, {}> & {
|
|
44
|
+
<V>(internal: unknown, props: ColumnProps<T, V>): {};
|
|
45
|
+
new <V>(options: import("svelte").ComponentConstructorOptions<ColumnProps<T, V>>): SvelteComponent<ColumnProps<T, V>, {}, {}> & {
|
|
66
46
|
$$bindings?: ReturnType<() => "">;
|
|
67
|
-
};
|
|
68
|
-
z_$$bindings?: ReturnType<() => "">;
|
|
47
|
+
} & {};
|
|
69
48
|
};
|
|
70
49
|
Panel: typeof Panel;
|
|
71
50
|
readonly table: TableState<T>;
|
|
@@ -78,15 +57,40 @@ declare class __sveltets_Render<T extends Record<PropertyKey, unknown>> {
|
|
|
78
57
|
/**
|
|
79
58
|
* Can you change the width of the columns?
|
|
80
59
|
* @default true
|
|
81
|
-
|
|
60
|
+
*/
|
|
82
61
|
resizeable?: boolean;
|
|
83
|
-
|
|
62
|
+
selected?: T[] | undefined;
|
|
63
|
+
select?: boolean | {
|
|
64
|
+
/**
|
|
65
|
+
* The style, in which the selection is shown
|
|
66
|
+
*
|
|
67
|
+
* NOTE: If using `edge` | 'side', "show" will always be `hover`. This is due to
|
|
68
|
+
* an inconsistency/limitation of matching the scroll between the selection div and the rows.
|
|
69
|
+
*
|
|
70
|
+
* @default 'column'
|
|
71
|
+
*/
|
|
72
|
+
style?: "column";
|
|
73
|
+
/**
|
|
74
|
+
* When to show the row-select, when not selected?
|
|
75
|
+
* @default 'hover'
|
|
76
|
+
*/
|
|
77
|
+
show?: "hover" | "always" | "never";
|
|
78
|
+
/**
|
|
79
|
+
* Custom snippet
|
|
80
|
+
*/
|
|
81
|
+
headerSnippet?: Snippet<[context: HeaderSelectCtx]>;
|
|
82
|
+
rowSnippet?: Snippet<[context: RowSelectCtx<T>]> | undefined;
|
|
83
|
+
} | undefined;
|
|
84
84
|
};
|
|
85
85
|
events(): {};
|
|
86
86
|
slots(): {};
|
|
87
|
-
bindings(): "panel";
|
|
87
|
+
bindings(): "selected" | "panel";
|
|
88
88
|
exports(): {
|
|
89
|
-
|
|
89
|
+
selected: T[];
|
|
90
|
+
positions: TableState<T_1>["positions"];
|
|
91
|
+
data: T[];
|
|
92
|
+
href: ((item: T) => string) | undefined;
|
|
93
|
+
columns: Record<string, ColumnState<T, unknown, ColumnProps<T, unknown>>>;
|
|
90
94
|
};
|
|
91
95
|
}
|
|
92
96
|
interface $$IsomorphicComponent {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Trigger<T> {
|
|
2
|
+
#private;
|
|
3
|
+
constructor();
|
|
4
|
+
trigger(value?: T): void;
|
|
5
|
+
onTrigger<E extends HTMLElement>(node: E, fn: (node: E, value?: T) => void): {
|
|
6
|
+
destroy: () => boolean;
|
|
7
|
+
};
|
|
8
|
+
/** Subscribe to the trigger; returns the value if any. */
|
|
9
|
+
get current(): T | undefined;
|
|
10
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createSubscriber } from 'svelte/reactivity';
|
|
2
|
+
export class Trigger {
|
|
3
|
+
#subscribe;
|
|
4
|
+
#update = () => { };
|
|
5
|
+
#subscribers = new Set();
|
|
6
|
+
#value;
|
|
7
|
+
constructor() {
|
|
8
|
+
this.#subscribe = createSubscriber(update => this.#update = update);
|
|
9
|
+
}
|
|
10
|
+
trigger(value) {
|
|
11
|
+
this.#value = value;
|
|
12
|
+
this.#update();
|
|
13
|
+
this.#subscribers.forEach(fn => fn(value));
|
|
14
|
+
}
|
|
15
|
+
onTrigger(node, fn) {
|
|
16
|
+
const f = (value) => fn(node, value);
|
|
17
|
+
this.#subscribers.add(f);
|
|
18
|
+
return {
|
|
19
|
+
destroy: () => this.#subscribers.delete(f)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Subscribe to the trigger; returns the value if any. */
|
|
23
|
+
get current() {
|
|
24
|
+
this.#subscribe();
|
|
25
|
+
return this.#value;
|
|
26
|
+
}
|
|
27
|
+
}
|