svelte-tably 1.0.2-next.1 → 1.1.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,39 +1,39 @@
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 function getDefaultHeader<T extends AnyRecord,V>(title: string) {
14
- return (
15
- (anchor: Comment) => snippetLiteral(defaultHeader)(anchor, () => title)
16
- ) as unknown as () => any
17
- }
18
-
19
- </script>
20
-
21
- <script lang='ts'>
22
-
23
- import { fromProps, snippetLiteral, type AnyRecord } from '../utility.svelte.js'
24
- import { ColumnState, type ColumnProps, type HeaderCtx, type ColumnSnippets } from './column-state.svelte.js'
25
-
26
- type T = $$Generic<Record<PropertyKey, any>>
27
- type V = $$Generic
28
-
29
- let {...props}: ColumnProps<T, V> = $props()
30
- const properties = fromProps(props)
31
-
32
- new ColumnState<T, V>(properties)
33
-
34
- </script>
35
-
36
-
37
- {#snippet defaultHeader(title: string)}
38
- {title}
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 function getDefaultHeader<T, V>(title: string) {
14
+ return (
15
+ (anchor: Comment) => snippetLiteral(defaultHeader)(anchor, () => title)
16
+ ) as unknown as () => any
17
+ }
18
+
19
+ </script>
20
+
21
+ <script lang='ts'>
22
+
23
+ import { fromProps, snippetLiteral } from '../utility.svelte.js'
24
+ import { ColumnState, type ColumnProps, type HeaderCtx, type ColumnSnippets } from './column-state.svelte.js'
25
+
26
+ type T = $$Generic<Record<PropertyKey, any>>
27
+ type V = $$Generic
28
+
29
+ let {...props}: ColumnProps<T, V> = $props()
30
+ const properties = fromProps(props)
31
+
32
+ new ColumnState<T, V>(properties)
33
+
34
+ </script>
35
+
36
+
37
+ {#snippet defaultHeader(title: string)}
38
+ {title}
39
39
  {/snippet}
@@ -1,5 +1,4 @@
1
- export declare function getDefaultHeader<T extends AnyRecord, V>(title: string): () => any;
2
- import { type AnyRecord } from '../utility.svelte.js';
1
+ export declare function getDefaultHeader<T, V>(title: string): () => any;
3
2
  import { type HeaderCtx } from './column-state.svelte.js';
4
3
  declare class __sveltets_Render<T extends Record<PropertyKey, any>, V> {
5
4
  props(): {
@@ -1,7 +1,6 @@
1
1
  import { type Snippet } from 'svelte';
2
2
  import { TableState, type RowCtx } from '../table/table-state.svelte.js';
3
- import { type AnyRecord } from '../utility.svelte.js';
4
- export type ColumnProps<T extends AnyRecord, V> = ({
3
+ export type ColumnProps<T, V> = ({
5
4
  id: string;
6
5
  table?: TableState<T>;
7
6
  } & ColumnSnippets<T, V> & ColumnDefaults<T> & ColumnOptions<T, V>) extends infer K ? {
@@ -16,14 +15,14 @@ export interface HeaderCtx<T> {
16
15
  */
17
16
  readonly header?: boolean;
18
17
  }
19
- export interface RowColumnCtx<T extends AnyRecord, V> extends RowCtx<T> {
18
+ export interface RowColumnCtx<T, V> extends RowCtx<T> {
20
19
  readonly value: V;
21
20
  readonly columnHovered: boolean;
22
21
  }
23
- export type StatusbarCtx<T extends AnyRecord> = {
22
+ export type StatusbarCtx<T> = {
24
23
  readonly data: T[];
25
24
  };
26
- export type ColumnSnippets<T extends AnyRecord, V> = {
25
+ export type ColumnSnippets<T, V> = {
27
26
  header?: Snippet<[ctx: HeaderCtx<T>]> | string;
28
27
  row?: Snippet<[item: T, ctx: RowColumnCtx<T, V>]>;
29
28
  statusbar?: Snippet<[ctx: StatusbarCtx<T>]>;
@@ -50,7 +49,7 @@ type ColumnDefaults<T> = {
50
49
  */
51
50
  width?: number;
52
51
  };
53
- type ColumnOptions<T extends AnyRecord, V> = {
52
+ type ColumnOptions<T, V> = {
54
53
  /**
55
54
  * Fixed is like sticky, but in its own category — meant to not be moved/hidden ex. select-boxes
56
55
  * @default false
@@ -95,7 +94,7 @@ type ColumnOptions<T extends AnyRecord, V> = {
95
94
  */
96
95
  pad?: 'row' | 'header' | 'both';
97
96
  };
98
- export declare class ColumnState<T extends AnyRecord = any, V = any> {
97
+ export declare class ColumnState<T = any, V = any> {
99
98
  #private;
100
99
  id: string;
101
100
  /**
@@ -1,24 +1,24 @@
1
- <!-- @component
2
-
3
- This is a description, \
4
- on how to use this.
5
-
6
- @example
7
- <Component />
8
-
9
- -->
10
-
11
- <script lang='ts'>
12
-
13
- import { ExpandableState, type ExpandableProps } from './expandable-state.svelte.js'
14
- import type { AnyRecord } from '../utility.svelte.js'
15
- import { fromProps } from '../utility.svelte.js'
16
-
17
- type T = $$Generic<AnyRecord>
18
-
19
- let { ...restProps }: ExpandableProps<T> = $props()
20
-
21
- const properties = fromProps(restProps)
22
- new ExpandableState<T>(properties)
23
-
24
- </script>
1
+ <!-- @component
2
+
3
+ This is a description, \
4
+ on how to use this.
5
+
6
+ @example
7
+ <Component />
8
+
9
+ -->
10
+
11
+ <script lang='ts'>
12
+
13
+ import { ExpandableState, type ExpandableProps } from './expandable-state.svelte.js'
14
+ import type { AnyRecord } from '../utility.svelte.js'
15
+ import { fromProps } from '../utility.svelte.js'
16
+
17
+ type T = $$Generic<AnyRecord>
18
+
19
+ let { ...restProps }: ExpandableProps<T> = $props()
20
+
21
+ const properties = fromProps(restProps)
22
+ new ExpandableState<T>(properties)
23
+
24
+ </script>
@@ -1,8 +1,7 @@
1
1
  import { type RowCtx } from '../table/table-state.svelte.js';
2
- import type { AnyRecord } from '../utility.svelte.js';
3
2
  import type { Snippet } from 'svelte';
4
3
  import type { EasingFunction } from 'svelte/transition';
5
- export interface ExpandableProps<T extends AnyRecord> {
4
+ export interface ExpandableProps<T> {
6
5
  content: Snippet<[item: T, ctx: RowCtx<T>]>;
7
6
  /**
8
7
  * How many ms to slide open?
@@ -30,7 +29,7 @@ export interface ExpandableProps<T extends AnyRecord> {
30
29
  */
31
30
  multiple?: boolean;
32
31
  }
33
- export declare class ExpandableState<T extends AnyRecord> {
32
+ export declare class ExpandableState<T> {
34
33
  #private;
35
34
  snippets: {
36
35
  content: Snippet<[item: T, ctx: RowCtx<T>]>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,10 @@
1
- export { default as default } from './table/Table.svelte';
1
+ import Table from './table/Table.svelte';
2
+ import type { TableState, TableProps } from './table/table-state.svelte.js';
3
+ declare namespace Table {
4
+ type State<T = unknown> = TableState<T>;
5
+ type Props<T = unknown> = TableProps<T>;
6
+ }
7
+ export default Table;
2
8
  export { default as Panel } from './panel/Panel.svelte';
3
9
  export { default as Column } from './column/Column.svelte';
4
10
  export { default as Row } from './row/Row.svelte';
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
- export { default as default } from './table/Table.svelte';
1
+ import Table from './table/Table.svelte';
2
+ export default Table;
2
3
  export { default as Panel } from './panel/Panel.svelte';
3
4
  export { default as Column } from './column/Column.svelte';
4
5
  export { default as Row } from './row/Row.svelte';
@@ -1,21 +1,21 @@
1
- <!-- @component
2
-
3
- This is a description, \
4
- on how to use this.
5
-
6
- @example
7
- <Component />
8
-
9
- -->
10
-
11
- <script lang='ts' generics='T extends Record<PropertyKey, unknown>'>
12
-
13
- import { PanelState, type PanelProps } from './panel-state.svelte.js'
14
- import { fromProps } from '../utility.svelte.js'
15
-
16
- let {...props}: PanelProps<T> = $props()
17
- const properties = fromProps(props)
18
-
19
- new PanelState<T>(properties)
20
-
1
+ <!-- @component
2
+
3
+ This is a description, \
4
+ on how to use this.
5
+
6
+ @example
7
+ <Component />
8
+
9
+ -->
10
+
11
+ <script lang='ts' generics='T extends Record<PropertyKey, unknown>'>
12
+
13
+ import { PanelState, type PanelProps } from './panel-state.svelte.js'
14
+ import { fromProps } from '../utility.svelte.js'
15
+
16
+ let {...props}: PanelProps<T> = $props()
17
+ const properties = fromProps(props)
18
+
19
+ new PanelState<T>(properties)
20
+
21
21
  </script>
@@ -1,7 +1,6 @@
1
1
  import { TableState } from '../table/table-state.svelte.js';
2
- import { type AnyRecord } from '../utility.svelte.js';
3
2
  import type { Snippet } from 'svelte';
4
- export type PanelProps<T extends AnyRecord> = {
3
+ export type PanelProps<T> = {
5
4
  id: string;
6
5
  /**
7
6
  * A darkened backdrop?
@@ -11,11 +10,11 @@ export type PanelProps<T extends AnyRecord> = {
11
10
  table?: TableState<T>;
12
11
  children: Snippet<[ctx: PanelCtx<T>]>;
13
12
  };
14
- export type PanelCtx<T extends AnyRecord> = {
13
+ export type PanelCtx<T> = {
15
14
  readonly table: TableState<T>;
16
15
  readonly data: T[];
17
16
  };
18
- export declare class PanelState<T extends AnyRecord> {
17
+ export declare class PanelState<T> {
19
18
  #private;
20
19
  table: TableState<T>;
21
20
  id: string;
@@ -1,24 +1,24 @@
1
- <!-- @component
2
-
3
- This is a description, \
4
- on how to use this.
5
-
6
- @example
7
- <Component />
8
-
9
- -->
10
-
11
- <script lang='ts'>
12
-
13
- import { RowState, type RowProps } from './row-state.svelte.js'
14
- import type { AnyRecord } from '../utility.svelte.js'
15
- import { fromProps } from '../utility.svelte.js'
16
-
17
- type T = $$Generic<AnyRecord>
18
-
19
- let { ...restProps }: RowProps<T> = $props()
20
-
21
- const properties = fromProps(restProps)
22
- new RowState<T>(properties)
23
-
24
- </script>
1
+ <!-- @component
2
+
3
+ This is a description, \
4
+ on how to use this.
5
+
6
+ @example
7
+ <Component />
8
+
9
+ -->
10
+
11
+ <script lang='ts'>
12
+
13
+ import { RowState, type RowProps } from './row-state.svelte.js'
14
+ import type { AnyRecord } from '../utility.svelte.js'
15
+ import { fromProps } from '../utility.svelte.js'
16
+
17
+ type T = $$Generic<AnyRecord>
18
+
19
+ let { ...restProps }: RowProps<T> = $props()
20
+
21
+ const properties = fromProps(restProps)
22
+ new RowState<T>(properties)
23
+
24
+ </script>
@@ -1,7 +1,6 @@
1
1
  import { type RowCtx } from '../table/table-state.svelte.js';
2
- import type { AnyRecord } from '../utility.svelte.js';
3
2
  import type { Snippet } from 'svelte';
4
- type ContextOptions<T extends AnyRecord> = {
3
+ type ContextOptions<T> = {
5
4
  /**
6
5
  * Only show when hovering the row?
7
6
  * @default true
@@ -12,7 +11,7 @@ type ContextOptions<T extends AnyRecord> = {
12
11
  */
13
12
  width?: string;
14
13
  };
15
- export interface RowProps<T extends AnyRecord> {
14
+ export interface RowProps<T> {
16
15
  /**
17
16
  * A sticky context column on the right of each table
18
17
  */
@@ -22,7 +21,7 @@ export interface RowProps<T extends AnyRecord> {
22
21
  onclick?: (event: MouseEvent, ctx: RowCtx<T>) => void;
23
22
  oncontextmenu?: (event: MouseEvent, ctx: RowCtx<T>) => void;
24
23
  }
25
- export declare class RowState<T extends AnyRecord> {
24
+ export declare class RowState<T> {
26
25
  #private;
27
26
  snippets: {
28
27
  context: Snippet<[item: T, ctx: RowCtx<T>]> | undefined;