svelte-tably 1.0.0-next.10 → 1.0.0-next.12

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/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>