svelte-tably 1.0.0-next.5 → 1.0.0-next.6

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 CHANGED
@@ -65,7 +65,7 @@ A high performant dynamic table
65
65
  <Panel id='columns'>
66
66
  <!-- Anything you might like -->
67
67
  </Panel>
68
- <Panel ...>
68
+ <Panel ... backdrop={false}>
69
69
  ...
70
70
  </Panel>
71
71
  {/snippet}
@@ -81,6 +81,7 @@ For quick styling
81
81
  | --tably-bg | background-color | `hsl(0, 0%, 100%)` |
82
82
  | --tably-color | color | `hsl(0, 0%, 0%)` |
83
83
  | --tably-border | border | `hsl(0, 0%, 90%)` |
84
+ | --tably-statusbar | background-color for the statusbar | `hsl(0, 0%, 98%)` |
84
85
  | --tably-padding-y | Padding above/below each column | `.5rem` |
85
86
  | --tably-padding-x | Padding left of each column | `1rem` |
86
87
  | --tably-radius | Table radius | `.25rem` |
@@ -11,8 +11,19 @@
11
11
  <script module lang='ts'>
12
12
 
13
13
  export interface Column<T = unknown, V = unknown> {
14
- header: Snippet
15
- row: Snippet<[item: T, value?: V]>
14
+ header?: Snippet<[
15
+ /**
16
+ * Is true when displaying in the header,
17
+ * so additional content can be shown if desired,
18
+ * so the header snippet can be re-used.
19
+ */
20
+ header?: boolean
21
+ ]>
22
+ row: Snippet<[item: T, row: {
23
+ readonly value: V
24
+ readonly isHovered: boolean
25
+ readonly index: number
26
+ }]>
16
27
  statusbar?: Snippet
17
28
 
18
29
  /** Default options for initial table */
@@ -20,11 +31,13 @@
20
31
  sticky?: boolean
21
32
  sort?: boolean
22
33
  show?: boolean
34
+ width?: number
23
35
  }
24
36
  /** More options */
25
37
  options: {
26
38
  value?: (item: T) => V
27
39
  sorting?: unknown extends V ? (a: T, b: T) => number : (a: V, b: V) => number
40
+ resizeable: boolean
28
41
  }
29
42
  }
30
43
 
@@ -36,7 +49,7 @@
36
49
  import { getTableState } from './Table.svelte'
37
50
 
38
51
  interface Props {
39
- header: Column<T, V>['header']
52
+ header?: Column<T, V>['header']
40
53
  row: Column<T, V>['row']
41
54
  statusbar?: Column<T, V>['statusbar']
42
55
 
@@ -46,8 +59,11 @@
46
59
  sticky?: boolean
47
60
  sort?: boolean
48
61
  show?: boolean
62
+ width?: number
49
63
  value?: Column<T, V>['options']['value']
50
64
  sorting?: Column<T, V>['options']['sorting']
65
+ /** @default true */
66
+ resizeable?: boolean
51
67
  }
52
68
 
53
69
  let {
@@ -56,7 +72,9 @@
56
72
  sticky = false,
57
73
  sort = false,
58
74
  show = true,
59
-
75
+ width,
76
+
77
+ resizeable = true,
60
78
  value, sorting
61
79
  }: Props = $props()
62
80
 
@@ -67,11 +85,13 @@
67
85
  defaults: {
68
86
  sticky,
69
87
  sort,
70
- show
88
+ show,
89
+ width
71
90
  },
72
91
  options: {
73
92
  value,
74
- sorting
93
+ sorting,
94
+ resizeable
75
95
  }
76
96
  })
77
97
 
@@ -82,16 +102,4 @@
82
102
  table.removeColumn(id)
83
103
  })
84
104
 
85
- </script>
86
- <!---------------------------------------------------->
87
-
88
-
89
-
90
-
91
-
92
- <!---------------------------------------------------->
93
- <style>
94
-
95
-
96
-
97
- </style>
105
+ </script>
@@ -1,31 +1,50 @@
1
1
  export interface Column<T = unknown, V = unknown> {
2
- header: Snippet;
3
- row: Snippet<[item: T, value?: V]>;
2
+ header?: Snippet<[
3
+ /**
4
+ * Is true when displaying in the header,
5
+ * so additional content can be shown if desired,
6
+ * so the header snippet can be re-used.
7
+ */
8
+ header?: boolean
9
+ ]>;
10
+ row: Snippet<[
11
+ item: T,
12
+ row: {
13
+ readonly value: V;
14
+ readonly isHovered: boolean;
15
+ readonly index: number;
16
+ }
17
+ ]>;
4
18
  statusbar?: Snippet;
5
19
  /** Default options for initial table */
6
20
  defaults: {
7
21
  sticky?: boolean;
8
22
  sort?: boolean;
9
23
  show?: boolean;
24
+ width?: number;
10
25
  };
11
26
  /** More options */
12
27
  options: {
13
28
  value?: (item: T) => V;
14
29
  sorting?: unknown extends V ? (a: T, b: T) => number : (a: V, b: V) => number;
30
+ resizeable: boolean;
15
31
  };
16
32
  }
17
33
  import { type Snippet } from 'svelte';
18
34
  declare class __sveltets_Render<T extends Record<PropertyKey, any>, V = unknown> {
19
35
  props(): {
20
- header: Column<T_1, V_1>["header"];
36
+ header?: Column<T_1, V_1>["header"];
21
37
  row: Column<T_1, V_1>["row"];
22
38
  statusbar?: Column<T_1, V_1>["statusbar"];
23
39
  id: string;
24
40
  sticky?: boolean;
25
41
  sort?: boolean;
26
42
  show?: boolean;
43
+ width?: number;
27
44
  value?: Column<T_1, V_1>["options"]["value"];
28
45
  sorting?: Column<T_1, V_1>["options"]["sorting"];
46
+ /** @default true */
47
+ resizeable?: boolean;
29
48
  };
30
49
  events(): {};
31
50
  slots(): {};
@@ -10,10 +10,10 @@
10
10
 
11
11
  <script module lang='ts'>
12
12
 
13
- export interface Panel {
13
+ export interface Panel<T extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> {
14
14
  /** A darkened backdrop? */
15
15
  backdrop: boolean
16
- content: Snippet
16
+ content: Snippet<[context: { readonly table: TableState<T>, readonly data: T[] }]>
17
17
  }
18
18
 
19
19
  export class PanelTween {
@@ -38,10 +38,10 @@
38
38
 
39
39
  </script>
40
40
 
41
- <script lang='ts'>
41
+ <script lang='ts' generics='T extends Record<PropertyKey, unknown>'>
42
42
 
43
43
  import { onDestroy, type Snippet } from 'svelte'
44
- import { getTableState, type TableState } from './Table.svelte'
44
+ import Table, { getTableState, type TableState } from './Table.svelte'
45
45
  import { Tween } from 'svelte/motion'
46
46
  import { sineInOut } from 'svelte/easing'
47
47
 
@@ -50,7 +50,7 @@
50
50
 
51
51
  /** A darkened backdrop? */
52
52
  backdrop?: boolean
53
- children: Snippet
53
+ children: Snippet<[context: { readonly table: TableState<T>, readonly data: T[] }]>
54
54
  }
55
55
 
56
56
  let {
@@ -59,7 +59,7 @@
59
59
  id
60
60
  }: Props = $props()
61
61
 
62
- const panel: Panel = $state({
62
+ const panel: Panel<T> = $state({
63
63
  backdrop,
64
64
  content: children
65
65
  })
@@ -1,35 +1,35 @@
1
- export interface ColumnOptions {
2
- sticky(): ColumnOptions;
1
+ export interface Panel<T extends Record<PropertyKey, unknown> = Record<PropertyKey, unknown>> {
2
+ /** A darkened backdrop? */
3
+ backdrop: boolean;
4
+ content: Snippet<[context: {
5
+ readonly table: TableState<T>;
6
+ readonly data: T[];
7
+ }]>;
3
8
  }
4
- interface Column<T = unknown> {
5
- header?: Snippet<[options: ColumnOptions]>;
6
- row?: Snippet<[data: T]>;
7
- statusbar?: Snippet<[data: T[]]>;
8
- defaults?: {
9
- sticky?: boolean;
10
- };
11
- }
12
- export interface TableState<T = unknown> {
13
- columns: Record<string, Column<T>>;
14
- order: {
15
- sticky: string[];
16
- scroll: string[];
17
- };
18
- panels: Record<string, Snippet<[table: TableState]>>;
19
- readonly data: T[];
20
- updateColumn(key: string, options: Column<T>): void;
9
+ export declare class PanelTween {
10
+ #private;
11
+ current: number;
12
+ transitioning: boolean;
13
+ /** bind:clientWidth */
14
+ width: number;
15
+ set target(value: number);
16
+ constructor(cb: () => string | undefined, added?: number);
21
17
  }
22
- export declare function getTableState<T>(): TableState<T>;
23
18
  import { type Snippet } from 'svelte';
19
+ import { type TableState } from './Table.svelte';
24
20
  declare class __sveltets_Render<T extends Record<PropertyKey, unknown>> {
25
21
  props(): {
26
- children?: Snippet;
27
- data: T[];
28
- panel?: string;
22
+ id: string;
23
+ /** A darkened backdrop? */
24
+ backdrop?: boolean;
25
+ children: Snippet<[context: {
26
+ readonly table: TableState<T>;
27
+ readonly data: T[];
28
+ }]>;
29
29
  };
30
30
  events(): {};
31
31
  slots(): {};
32
- bindings(): "panel";
32
+ bindings(): "";
33
33
  exports(): {};
34
34
  }
35
35
  interface $$IsomorphicComponent {
@@ -46,6 +46,6 @@ interface $$IsomorphicComponent {
46
46
  * @example
47
47
  * <Component />
48
48
  */
49
- declare const Table: $$IsomorphicComponent;
50
- type Table<T extends Record<PropertyKey, unknown>> = InstanceType<typeof Table<T>>;
51
- export default Table;
49
+ declare const Panel: $$IsomorphicComponent;
50
+ type Panel<T extends Record<PropertyKey, unknown>> = InstanceType<typeof Panel<T>>;
51
+ export default Panel;