svelte-tably 1.0.0-next.9 → 1.0.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.
@@ -1,115 +0,0 @@
1
- export type RowCtx<V> = {
2
- readonly value: V;
3
- readonly isHovered: boolean;
4
- readonly index: number;
5
- selected: boolean;
6
- };
7
- export interface ColumnProps<T, V> {
8
- header?: Snippet<[
9
- /**
10
- * Is true when displaying in the header,
11
- * so additional content can be shown if desired,
12
- * so the header snippet can be re-used.
13
- */
14
- header?: boolean
15
- ]>;
16
- row: Snippet<[item: T, row: RowCtx<V>]>;
17
- statusbar?: Snippet;
18
- id: string;
19
- /**
20
- * Is this column sticky by default?
21
- * @default false
22
- */
23
- sticky?: boolean;
24
- /**
25
- * Fixed is like sticky, but in its own category — meant to not be moved/hidden ex. select-boxes
26
- * @default false
27
- */
28
- fixed?: boolean;
29
- /**
30
- * Is this column sorted by default?
31
- * @default false
32
- */
33
- sort?: boolean;
34
- /**
35
- * Is this column visible by default?
36
- * @default true
37
- */
38
- show?: boolean;
39
- /**
40
- * The width of the column in pixels by default
41
- * @default 150
42
- */
43
- width?: number;
44
- /**
45
- * The value of the row. Required for sorting/filtering
46
- * @example row => row.name
47
- */
48
- value?: (item: T) => V;
49
- /**
50
- * Makes the column sortable. Sorts based of a sorting function.
51
- *
52
- * **Important**   `value`-attribute is required adjacent to this.
53
- *
54
- * If `true` uses the default `.sort()` algorithm.
55
- *
56
- * @default false
57
- */
58
- sorting?: boolean | ((a: V, b: V) => number);
59
- /**
60
- * Is this column resizeable?
61
- * Can not be resized if Table is marked as `resizeable={false}`
62
- * @default true
63
- */
64
- resizeable?: boolean;
65
- /**
66
- * Optional: Provide the table it is a part of
67
- */
68
- table?: TableState;
69
- }
70
- export interface ColumnState<T = unknown, V = unknown, C extends ColumnProps<T, V> = ColumnProps<T, V>> {
71
- id: C['id'];
72
- header?: C['header'];
73
- row: C['row'];
74
- statusbar?: C['statusbar'];
75
- fixed?: boolean;
76
- /** Default options for initial table */
77
- defaults: {
78
- sticky?: boolean;
79
- sort?: boolean;
80
- show?: boolean;
81
- width?: number;
82
- };
83
- /** More options */
84
- options: {
85
- value?: C['value'];
86
- sorting?: boolean | ((a: any, b: any) => number);
87
- resizeable: boolean;
88
- };
89
- }
90
- import { type Snippet } from 'svelte';
91
- import { type TableState } from './Table.svelte';
92
- declare class __sveltets_Render<T extends Record<PropertyKey, any>, V> {
93
- props(): ColumnProps<T, V>;
94
- events(): {};
95
- slots(): {};
96
- bindings(): "";
97
- exports(): {};
98
- }
99
- interface $$IsomorphicComponent {
100
- 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']>> & {
101
- $$bindings?: ReturnType<__sveltets_Render<T, V>['bindings']>;
102
- } & ReturnType<__sveltets_Render<T, V>['exports']>;
103
- <T extends Record<PropertyKey, any>, V>(internal: unknown, props: ReturnType<__sveltets_Render<T, V>['props']> & {}): ReturnType<__sveltets_Render<T, V>['exports']>;
104
- z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
105
- }
106
- /**
107
- * This is a description, \
108
- * on how to use this.
109
- *
110
- * @example
111
- * <Component />
112
- */
113
- declare const Column: $$IsomorphicComponent;
114
- type Column<T extends Record<PropertyKey, any>, V> = InstanceType<typeof Column<T, V>>;
115
- export default Column;
package/dist/Panel.svelte DELETED
@@ -1,74 +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 Panel<T extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> {
14
- /** A darkened backdrop? */
15
- backdrop: boolean
16
- content: Snippet<[context: { readonly table: TableState<T>, readonly data: T[] }]>
17
- }
18
-
19
- export class PanelTween {
20
- #tween = new Tween(0, { duration: 300, easing: sineInOut })
21
- current = $derived(this.#tween.current)
22
- transitioning = $state(false)
23
-
24
- /** bind:clientWidth */
25
- width = $state(0)
26
-
27
- set target(value: number) {
28
- this.transitioning = true
29
- this.#tween.set(value).then(() => this.transitioning = false)
30
- }
31
-
32
- constructor(cb: () => string | undefined, added = 0) {
33
- $effect.pre(() => {
34
- this.target = cb() ? this.width + added : 0
35
- })
36
- }
37
- }
38
-
39
- </script>
40
-
41
- <script lang='ts' generics='T extends Record<PropertyKey, unknown>'>
42
-
43
- import { onDestroy, type Snippet } from 'svelte'
44
- import Table, { getTableState, type TableState } from './Table.svelte'
45
- import { Tween } from 'svelte/motion'
46
- import { sineInOut } from 'svelte/easing'
47
-
48
- interface Props {
49
- id: string
50
-
51
- /** A darkened backdrop? */
52
- backdrop?: boolean
53
- children: Snippet<[context: { readonly table: TableState<T>, readonly data: T[] }]>
54
- }
55
-
56
- let {
57
- backdrop = true,
58
- children,
59
- id
60
- }: Props = $props()
61
-
62
- const panel: Panel<T> = $state({
63
- backdrop,
64
- content: children
65
- })
66
-
67
- const table = getTableState()
68
- table.panels[id] = panel
69
-
70
- onDestroy(() => {
71
- delete table.panels[id]
72
- })
73
-
74
- </script>