svelte-tably 1.0.0-next.1 → 1.0.0-next.11
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 +63 -43
- package/dist/Column.svelte +174 -0
- package/dist/Column.svelte.d.ts +121 -0
- package/dist/{Table/Panel.svelte → Panel.svelte} +14 -13
- package/dist/{Table/Table.svelte.d.ts → Panel.svelte.d.ts} +27 -23
- package/dist/Table.svelte +977 -0
- package/dist/Table.svelte.d.ts +107 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -1
- package/dist/trigger.svelte.d.ts +10 -0
- package/dist/trigger.svelte.js +27 -0
- package/package.json +3 -1
- package/dist/Table/Column.svelte +0 -98
- package/dist/Table/Column.svelte.d.ts +0 -50
- package/dist/Table/Panel.svelte.d.ts +0 -31
- package/dist/Table/Table.svelte +0 -352
- package/dist/Table/index.d.ts +0 -12
- package/dist/Table/index.js +0 -31
- package/dist/prototype/Headers.svelte +0 -33
- package/dist/prototype/Headers.svelte.d.ts +0 -15
- package/dist/prototype/Panels.svelte +0 -25
- package/dist/prototype/Panels.svelte.d.ts +0 -15
- package/dist/prototype/Rows.svelte +0 -35
- package/dist/prototype/Rows.svelte.d.ts +0 -27
- package/dist/prototype/Statusbar.svelte +0 -35
- package/dist/prototype/Statusbar.svelte.d.ts +0 -13
- package/dist/prototype/Table.svelte +0 -336
- package/dist/prototype/Table.svelte.d.ts +0 -51
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
export interface TableState<T extends Record<PropertyKey, any> = Record<PropertyKey, any>> {
|
|
3
|
+
columns: Record<string, ColumnState<T>>;
|
|
4
|
+
panels: Record<string, TPanel<T>>;
|
|
5
|
+
selected: T[] | null;
|
|
6
|
+
sortby?: string;
|
|
7
|
+
sortReverse: boolean;
|
|
8
|
+
positions: {
|
|
9
|
+
sticky: string[];
|
|
10
|
+
scroll: string[];
|
|
11
|
+
hidden: string[];
|
|
12
|
+
toggle(key: string): void;
|
|
13
|
+
};
|
|
14
|
+
readonly resizeable: boolean;
|
|
15
|
+
readonly data: T[];
|
|
16
|
+
/** Rows become anchors */
|
|
17
|
+
readonly href?: (item: T) => string;
|
|
18
|
+
addColumn(key: string, options: ColumnState<T>): void;
|
|
19
|
+
removeColumn(key: string): void;
|
|
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
|
+
};
|
|
37
|
+
import { type Snippet } from 'svelte';
|
|
38
|
+
import { type ColumnProps, type RowCtx, type ColumnState } from './Column.svelte';
|
|
39
|
+
import Panel, { type Panel as TPanel } from './Panel.svelte';
|
|
40
|
+
declare class __sveltets_Render<T extends Record<PropertyKey, unknown>> {
|
|
41
|
+
props(): {
|
|
42
|
+
content: Snippet<[context: {
|
|
43
|
+
Column: {
|
|
44
|
+
<V>(internal: unknown, props: ColumnProps<T, V>): {};
|
|
45
|
+
new <V>(options: import("svelte").ComponentConstructorOptions<ColumnProps<T, V>>): SvelteComponent<ColumnProps<T, V>, {}, {}> & {
|
|
46
|
+
$$bindings?: ReturnType<() => "">;
|
|
47
|
+
} & {};
|
|
48
|
+
};
|
|
49
|
+
Panel: typeof Panel;
|
|
50
|
+
readonly table: TableState<T>;
|
|
51
|
+
readonly data: T[];
|
|
52
|
+
}]>;
|
|
53
|
+
panel?: string;
|
|
54
|
+
data?: T[] | undefined;
|
|
55
|
+
id?: string;
|
|
56
|
+
href?: ((item: T) => string) | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Can you change the width of the columns?
|
|
59
|
+
* @default true
|
|
60
|
+
*/
|
|
61
|
+
resizeable?: boolean;
|
|
62
|
+
filters?: ((item: T) => boolean)[] | undefined;
|
|
63
|
+
selected?: T[] | undefined;
|
|
64
|
+
select?: boolean | {
|
|
65
|
+
/**
|
|
66
|
+
* The style, in which the selection is shown
|
|
67
|
+
*
|
|
68
|
+
* NOTE: If using `edge` | 'side', "show" will always be `hover`. This is due to
|
|
69
|
+
* an inconsistency/limitation of matching the scroll between the selection div and the rows.
|
|
70
|
+
*
|
|
71
|
+
* @default 'column'
|
|
72
|
+
*/
|
|
73
|
+
style?: "column";
|
|
74
|
+
/**
|
|
75
|
+
* When to show the row-select, when not selected?
|
|
76
|
+
* @default 'hover'
|
|
77
|
+
*/
|
|
78
|
+
show?: "hover" | "always" | "never";
|
|
79
|
+
/**
|
|
80
|
+
* Custom snippet
|
|
81
|
+
*/
|
|
82
|
+
headerSnippet?: Snippet<[context: HeaderSelectCtx]>;
|
|
83
|
+
rowSnippet?: Snippet<[context: RowSelectCtx<T>]> | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
};
|
|
86
|
+
events(): {};
|
|
87
|
+
slots(): {};
|
|
88
|
+
bindings(): "selected" | "panel";
|
|
89
|
+
exports(): {};
|
|
90
|
+
}
|
|
91
|
+
interface $$IsomorphicComponent {
|
|
92
|
+
new <T extends Record<PropertyKey, unknown>>(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']>> & {
|
|
93
|
+
$$bindings?: ReturnType<__sveltets_Render<T>['bindings']>;
|
|
94
|
+
} & ReturnType<__sveltets_Render<T>['exports']>;
|
|
95
|
+
<T extends Record<PropertyKey, unknown>>(internal: unknown, props: ReturnType<__sveltets_Render<T>['props']> & {}): ReturnType<__sveltets_Render<T>['exports']>;
|
|
96
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* This is a description, \
|
|
100
|
+
* on how to use this.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* <Component />
|
|
104
|
+
*/
|
|
105
|
+
declare const Table: $$IsomorphicComponent;
|
|
106
|
+
type Table<T extends Record<PropertyKey, unknown>> = InstanceType<typeof Table<T>>;
|
|
107
|
+
export default Table;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "svelte-tably",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.11",
|
|
4
4
|
"repository": "github:refzlund/svelte-tably",
|
|
5
5
|
"homepage": "https://github.com/Refzlund/svelte-tably",
|
|
6
6
|
"bugs": {
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"@sveltejs/kit": "^2.9.0",
|
|
12
12
|
"@sveltejs/package": "^2.0.0",
|
|
13
13
|
"@sveltejs/vite-plugin-svelte": "^5.0.0",
|
|
14
|
+
"floating-runes": "^1.0.0",
|
|
14
15
|
"publint": "^0.2.0",
|
|
16
|
+
"runic-reorder": "^1.0.0-next.1",
|
|
15
17
|
"svelte": "^5.0.0",
|
|
16
18
|
"svelte-check": "^4.0.0",
|
|
17
19
|
"typescript": "^5.0.0",
|
package/dist/Table/Column.svelte
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
<!-- @component
|
|
2
|
-
|
|
3
|
-
This is a description, \
|
|
4
|
-
on how to use this.
|
|
5
|
-
|
|
6
|
-
@example
|
|
7
|
-
<Component />
|
|
8
|
-
|
|
9
|
-
-->
|
|
10
|
-
|
|
11
|
-
<script module lang='ts'>
|
|
12
|
-
|
|
13
|
-
export interface Column<T = unknown, V = unknown> {
|
|
14
|
-
header: Snippet
|
|
15
|
-
row: Snippet<[item: T, value?: V]>
|
|
16
|
-
statusbar?: Snippet<[data: T[]]>
|
|
17
|
-
|
|
18
|
-
/** Default options for initial table */
|
|
19
|
-
defaults: {
|
|
20
|
-
sticky?: boolean
|
|
21
|
-
sort?: boolean
|
|
22
|
-
show?: boolean
|
|
23
|
-
}
|
|
24
|
-
/** More options */
|
|
25
|
-
options: {
|
|
26
|
-
value?: (item: T) => V
|
|
27
|
-
sorting?: unknown extends V ? (a: T, b: T) => number : (a: V, b: V) => number
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
</script>
|
|
32
|
-
|
|
33
|
-
<script lang='ts' generics='T extends Record<PropertyKey, any>, V'>
|
|
34
|
-
|
|
35
|
-
import { onDestroy, type Snippet } from 'svelte'
|
|
36
|
-
import { getTableState } from './Table.svelte'
|
|
37
|
-
|
|
38
|
-
interface Props {
|
|
39
|
-
header: Column<T, V>['header']
|
|
40
|
-
row: Column<T, V>['row']
|
|
41
|
-
statusbar?: Column<T, V>['statusbar']
|
|
42
|
-
|
|
43
|
-
// options
|
|
44
|
-
sticky?: boolean
|
|
45
|
-
sort?: boolean
|
|
46
|
-
show?: boolean
|
|
47
|
-
value?: Column<T, V>['options']['value']
|
|
48
|
-
sorting?: Column<T, V>['options']['sorting']
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let {
|
|
52
|
-
header, row, statusbar,
|
|
53
|
-
|
|
54
|
-
sticky = false,
|
|
55
|
-
sort = false,
|
|
56
|
-
show = true,
|
|
57
|
-
|
|
58
|
-
value, sorting,
|
|
59
|
-
|
|
60
|
-
...rest
|
|
61
|
-
}: Props = $props()
|
|
62
|
-
const key = (rest as unknown as { __key: string }).__key
|
|
63
|
-
|
|
64
|
-
const column: Column<T, V> = $state({
|
|
65
|
-
header,
|
|
66
|
-
row,
|
|
67
|
-
statusbar,
|
|
68
|
-
defaults: {
|
|
69
|
-
sticky,
|
|
70
|
-
sort,
|
|
71
|
-
show
|
|
72
|
-
},
|
|
73
|
-
options: {
|
|
74
|
-
value,
|
|
75
|
-
sorting
|
|
76
|
-
}
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
const table = getTableState()
|
|
80
|
-
table.addColumn(key, column as Column)
|
|
81
|
-
|
|
82
|
-
onDestroy(() => {
|
|
83
|
-
table.removeColumn(key)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
</script>
|
|
87
|
-
<!---------------------------------------------------->
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
<!---------------------------------------------------->
|
|
94
|
-
<style>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
</style>
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export interface Column<T = unknown, V = unknown> {
|
|
2
|
-
header: Snippet;
|
|
3
|
-
row: Snippet<[item: T, value?: V]>;
|
|
4
|
-
statusbar?: Snippet<[data: T[]]>;
|
|
5
|
-
/** Default options for initial table */
|
|
6
|
-
defaults: {
|
|
7
|
-
sticky?: boolean;
|
|
8
|
-
sort?: boolean;
|
|
9
|
-
show?: boolean;
|
|
10
|
-
};
|
|
11
|
-
/** More options */
|
|
12
|
-
options: {
|
|
13
|
-
value?: (item: T) => V;
|
|
14
|
-
sorting?: unknown extends V ? (a: T, b: T) => number : (a: V, b: V) => number;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
import { type Snippet } from 'svelte';
|
|
18
|
-
declare class __sveltets_Render<T extends Record<PropertyKey, any>, V> {
|
|
19
|
-
props(): {
|
|
20
|
-
header: Column<T_1, V_1>["header"];
|
|
21
|
-
row: Column<T_1, V_1>["row"];
|
|
22
|
-
statusbar?: Column<T_1, V_1>["statusbar"];
|
|
23
|
-
sticky?: boolean;
|
|
24
|
-
sort?: boolean;
|
|
25
|
-
show?: boolean;
|
|
26
|
-
value?: Column<T_1, V_1>["options"]["value"];
|
|
27
|
-
sorting?: Column<T_1, V_1>["options"]["sorting"];
|
|
28
|
-
};
|
|
29
|
-
events(): {};
|
|
30
|
-
slots(): {};
|
|
31
|
-
bindings(): "";
|
|
32
|
-
exports(): {};
|
|
33
|
-
}
|
|
34
|
-
interface $$IsomorphicComponent {
|
|
35
|
-
new <T extends Record<PropertyKey, any>, V>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, V>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, V>['props']>, ReturnType<__sveltets_Render<T, V>['events']>, ReturnType<__sveltets_Render<T, V>['slots']>> & {
|
|
36
|
-
$$bindings?: ReturnType<__sveltets_Render<T, V>['bindings']>;
|
|
37
|
-
} & ReturnType<__sveltets_Render<T, V>['exports']>;
|
|
38
|
-
<T extends Record<PropertyKey, any>, V>(internal: unknown, props: ReturnType<__sveltets_Render<T, V>['props']> & {}): ReturnType<__sveltets_Render<T, V>['exports']>;
|
|
39
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* This is a description, \
|
|
43
|
-
* on how to use this.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* <Component />
|
|
47
|
-
*/
|
|
48
|
-
declare const Column: $$IsomorphicComponent;
|
|
49
|
-
type Column<T extends Record<PropertyKey, any>, V> = InstanceType<typeof Column<T, V>>;
|
|
50
|
-
export default Column;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export interface Panel {
|
|
2
|
-
/** A darkened backdrop? */
|
|
3
|
-
backdrop: boolean;
|
|
4
|
-
content: Snippet<[table: TableState]>;
|
|
5
|
-
}
|
|
6
|
-
export declare class PanelTween {
|
|
7
|
-
#private;
|
|
8
|
-
current: number;
|
|
9
|
-
transitioning: boolean;
|
|
10
|
-
/** bind:clientWidth */
|
|
11
|
-
width: number;
|
|
12
|
-
set target(value: number);
|
|
13
|
-
constructor(cb: () => string | undefined);
|
|
14
|
-
}
|
|
15
|
-
import { type Snippet } from 'svelte';
|
|
16
|
-
import { type TableState } from './Table.svelte';
|
|
17
|
-
interface Props {
|
|
18
|
-
/** A darkened backdrop? */
|
|
19
|
-
backdrop?: boolean;
|
|
20
|
-
children: Snippet<[table: TableState]>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* This is a description, \
|
|
24
|
-
* on how to use this.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* <Component />
|
|
28
|
-
*/
|
|
29
|
-
declare const Panel: import("svelte").Component<Props, {}, "">;
|
|
30
|
-
type Panel = ReturnType<typeof Panel>;
|
|
31
|
-
export default Panel;
|