svelte-tably 1.0.1-next.0 → 1.0.1
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/LICENSE +20 -20
- package/README.md +301 -298
- package/dist/column/Column.svelte +38 -38
- package/dist/expandable/Expandable.svelte +24 -24
- package/dist/panel/Panel.svelte +20 -20
- package/dist/row/Row.svelte +24 -24
- package/dist/table/Table.svelte +1140 -1140
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Svelte Tably
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Svelte Tably
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,299 +1,302 @@
|
|
|
1
|
-
# Svelte Tably
|
|
2
|
-
|
|
3
|
-
Via the amazing capabilities braught to us by Svelte 5 — a performant, dynamic, flexible, feature rich table. It's as simple, or as flexible as you need it to be.
|
|
4
|
-
|
|
5
|
-
Simple example on [Svelte 5 Playground](https://svelte.dev/playground/f79124e8473546d29433a95a68440d6d?version=5.16.0)
|
|
6
|
-
<br>
|
|
7
|
-
Fledged out example on [Svelte 5 Playground](https://svelte.dev/playground/a16d71c97445455e80a55b77ec1cf915?version=5)
|
|
8
|
-
|
|
9
|
-
- [x] Columns
|
|
10
|
-
- [x] Sticky
|
|
11
|
-
- [x] Show/hide
|
|
12
|
-
- [x] Re-order
|
|
13
|
-
- [x] Resize
|
|
14
|
-
- [x] Data manipulation
|
|
15
|
-
- [x] "Virtual" data
|
|
16
|
-
- [x] Sorting
|
|
17
|
-
- [x] Select
|
|
18
|
-
- [x] Filtering
|
|
19
|
-
- [x] Reorderable
|
|
20
|
-
- [x] Statusbar
|
|
21
|
-
- [x] Panels
|
|
22
|
-
- [x] Row context
|
|
23
|
-
- [x] Expandable rows
|
|
24
|
-
- [x] Virtual rendering
|
|
25
|
-
- [x] To CSV
|
|
26
|
-
- [x] Auto: Create columns based on data
|
|
27
|
-
|
|
28
|
-
On top of that, the library API is extensive, so the table can meet your needs.
|
|
29
|
-
|
|
30
|
-
## Usage Notes
|
|
31
|
-
|
|
32
|
-
`bun add -D svelte-tably`
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{#snippet
|
|
57
|
-
|
|
58
|
-
{/snippet}
|
|
59
|
-
{#snippet
|
|
60
|
-
{
|
|
61
|
-
{/snippet}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
{#snippet
|
|
78
|
-
<button ...> <Icon icon='
|
|
79
|
-
{/snippet}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
<Panel
|
|
86
|
-
|
|
87
|
-
</Panel>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
|
100
|
-
|
|
|
101
|
-
| --tably-
|
|
102
|
-
| --tably-
|
|
103
|
-
| --tably-
|
|
104
|
-
| --tably-
|
|
105
|
-
| --tably-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
> [!
|
|
111
|
-
>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
|
|
|
150
|
-
|
|
|
151
|
-
|
|
|
152
|
-
|
|
|
153
|
-
|
|
|
154
|
-
|
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
|
164
|
-
|
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
{#snippet
|
|
184
|
-
...
|
|
185
|
-
{/snippet}
|
|
186
|
-
{#snippet
|
|
187
|
-
...
|
|
188
|
-
{/snippet}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
|
196
|
-
|
|
|
197
|
-
|
|
|
198
|
-
|
|
|
199
|
-
|
|
|
200
|
-
|
|
|
201
|
-
|
|
|
202
|
-
|
|
|
203
|
-
|
|
|
204
|
-
|
|
|
205
|
-
|
|
|
206
|
-
|
|
|
207
|
-
|
|
|
208
|
-
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
{#snippet
|
|
228
|
-
...
|
|
229
|
-
{/snippet}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
|
237
|
-
|
|
|
238
|
-
|
|
|
239
|
-
|
|
|
240
|
-
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
|
271
|
-
|
|
|
272
|
-
|
|
|
273
|
-
|
|
|
274
|
-
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
|
298
|
-
|
|
|
1
|
+
# Svelte Tably
|
|
2
|
+
|
|
3
|
+
Via the amazing capabilities braught to us by Svelte 5 — a performant, dynamic, flexible, feature rich table. It's as simple, or as flexible as you need it to be.
|
|
4
|
+
|
|
5
|
+
Simple example on [Svelte 5 Playground](https://svelte.dev/playground/f79124e8473546d29433a95a68440d6d?version=5.16.0)
|
|
6
|
+
<br>
|
|
7
|
+
Fledged out example on [Svelte 5 Playground](https://svelte.dev/playground/a16d71c97445455e80a55b77ec1cf915?version=5)
|
|
8
|
+
|
|
9
|
+
- [x] Columns
|
|
10
|
+
- [x] Sticky
|
|
11
|
+
- [x] Show/hide
|
|
12
|
+
- [x] Re-order
|
|
13
|
+
- [x] Resize
|
|
14
|
+
- [x] Data manipulation
|
|
15
|
+
- [x] "Virtual" data
|
|
16
|
+
- [x] Sorting
|
|
17
|
+
- [x] Select
|
|
18
|
+
- [x] Filtering
|
|
19
|
+
- [x] Reorderable
|
|
20
|
+
- [x] Statusbar
|
|
21
|
+
- [x] Panels
|
|
22
|
+
- [x] Row context
|
|
23
|
+
- [x] Expandable rows
|
|
24
|
+
- [x] Virtual rendering
|
|
25
|
+
- [x] To CSV
|
|
26
|
+
- [x] Auto: Create columns based on data
|
|
27
|
+
|
|
28
|
+
On top of that, the library API is extensive, so the table can meet your needs.
|
|
29
|
+
|
|
30
|
+
## Usage Notes
|
|
31
|
+
|
|
32
|
+
`bun add -D svelte-tably`
|
|
33
|
+
|
|
34
|
+
> [!NOTE]
|
|
35
|
+
> If you do SSR, set Node version to [20 or higher](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted#browser_compatibility)
|
|
36
|
+
|
|
37
|
+
```html
|
|
38
|
+
<script lang='ts'>
|
|
39
|
+
import Table from 'svelte-tably'
|
|
40
|
+
|
|
41
|
+
const data = $state([
|
|
42
|
+
{ name: 'Giraffe', age: 26, email: 'giraffe@example.com' },
|
|
43
|
+
{ name: 'Shiboo', age: 21, email: 'shiboo@example.com' }
|
|
44
|
+
])
|
|
45
|
+
|
|
46
|
+
let activePanel = $state('columns') as string | undefined
|
|
47
|
+
let selected = $state([]) as typeof data
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<!-- Auto: Generate Columns based on data properties -->
|
|
51
|
+
<Table auto {data} resizeable={false} filters={[...]} />
|
|
52
|
+
|
|
53
|
+
<Table {data} panel={activePanel} select bind:selected>
|
|
54
|
+
{#snippet content({ Column, Panel, Expandable, Row, state, table })}
|
|
55
|
+
<Column id='name' sticky sort value={r => r.name} filter={v => v.includes('Giraffe')}>
|
|
56
|
+
{#snippet header(ctx)}
|
|
57
|
+
Name
|
|
58
|
+
{/snippet}
|
|
59
|
+
{#snippet row(row, ctx)}
|
|
60
|
+
{row.name}
|
|
61
|
+
{/snippet}
|
|
62
|
+
{#snippet statusbar(ctx)}
|
|
63
|
+
{table.data.length}
|
|
64
|
+
{/snippet}
|
|
65
|
+
</Column>
|
|
66
|
+
|
|
67
|
+
<!-- Simplified -->
|
|
68
|
+
<Column id='age' header='Age' value={r => r.age} sort={(a,b) => a - b} />
|
|
69
|
+
|
|
70
|
+
<Expandable click={false}>
|
|
71
|
+
{#snippet content(item, ctx)}
|
|
72
|
+
...
|
|
73
|
+
{/snippet}
|
|
74
|
+
</Expandable>
|
|
75
|
+
|
|
76
|
+
<Row onclick={...} oncontextmenu={...}>
|
|
77
|
+
{#snippet contextHeader()}
|
|
78
|
+
<button ...> <Icon icon='add' /> </button>
|
|
79
|
+
{/snippet}
|
|
80
|
+
{#snippet context(item, ctx)}
|
|
81
|
+
<button ...> <Icon icon='menu' /> </button>
|
|
82
|
+
{/snippet}
|
|
83
|
+
</Row>
|
|
84
|
+
|
|
85
|
+
<Panel id='columns'>
|
|
86
|
+
<!-- Anything you might like -->
|
|
87
|
+
</Panel>
|
|
88
|
+
<Panel ... backdrop={false}>
|
|
89
|
+
...
|
|
90
|
+
</Panel>
|
|
91
|
+
{/snippet}
|
|
92
|
+
</Table>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Styling
|
|
96
|
+
|
|
97
|
+
For quick styling
|
|
98
|
+
|
|
99
|
+
| CSS Variable | Description | Default |
|
|
100
|
+
| - | - | - |
|
|
101
|
+
| --tably-bg | Background color | `hsl(0, 0%, 100%)` |
|
|
102
|
+
| --tably-color | Text color | `hsl(0, 0%, 0%)` |
|
|
103
|
+
| --tably-border | Border for sticky columns and header | `hsl(0, 0%, 90%)` |
|
|
104
|
+
| --tably-border-grid | Border for the table-grid | `hsl(0, 0%, 98%)` |
|
|
105
|
+
| --tably-statusbar | background-color for the statusbar | `hsl(0, 0%, 98%)` |
|
|
106
|
+
| --tably-padding-y | Padding above/below each column | `.5rem` |
|
|
107
|
+
| --tably-padding-x | Padding left of each column | `1rem` |
|
|
108
|
+
| --tably-radius | Table radius | `.25rem` |
|
|
109
|
+
|
|
110
|
+
> [!TIP]
|
|
111
|
+
> For the CSS variables, apply them to `:global(:root) { ... }`
|
|
112
|
+
|
|
113
|
+
> [!NOTE]
|
|
114
|
+
> Advanced styling can be done via `:global(.svelte-tably)`
|
|
115
|
+
> `table > thead > tr > th, table > tbody > tr > td, table > tfoot > tr > td`
|
|
116
|
+
|
|
117
|
+
<br>
|
|
118
|
+
<br>
|
|
119
|
+
|
|
120
|
+
## Components
|
|
121
|
+
|
|
122
|
+
All components except Table are meant to be children of the `Table` component.
|
|
123
|
+
|
|
124
|
+
However, you can safely create a `Component.svelte` and use these components,
|
|
125
|
+
and then provide `<Component/>` as a child to `<Table>`.
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
import Table from 'svelte-tably'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Table
|
|
132
|
+
|
|
133
|
+
The table component.
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<Table auto {data} />
|
|
137
|
+
|
|
138
|
+
<Table {data} ...>
|
|
139
|
+
{#snippet content?({ Column, Row, Expandable, Panel, table })}
|
|
140
|
+
...
|
|
141
|
+
{/snippet}
|
|
142
|
+
</Table>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Where `table` is `TableState<T>` and the rest are typed; `Component<T>`.
|
|
146
|
+
|
|
147
|
+
| Attribute | Description | Type |
|
|
148
|
+
| - | - | - |
|
|
149
|
+
| content? | The contents of the table | `Snippet<[ctx: ContentCtx<T>]>?` |
|
|
150
|
+
| | | |
|
|
151
|
+
| id? | The `#id` for the table | `string` |
|
|
152
|
+
| data | An array of objects for the table | `T[]` |
|
|
153
|
+
| bind:selected? | The currently selected items | `T[]` |
|
|
154
|
+
| bind:panel? | The currently open panel | `string` |
|
|
155
|
+
| filters? | An array of filters applied to the table | `((item: T) => boolean)[]` |
|
|
156
|
+
| reorderable? | Whether the rows can be re-ordered (via [runic-reorder](https://github.com/Refzlund/runic-reorder)) | `boolean` |
|
|
157
|
+
| resizeable? | Whether or not the columns can be resized | `boolean` |
|
|
158
|
+
| select? | Whether ot not the rows items can be selected | `boolean \| SelectOptions<T>` |
|
|
159
|
+
| auto? | Create missing columns automatically? | `boolean` |
|
|
160
|
+
|
|
161
|
+
#### SelectOptions
|
|
162
|
+
|
|
163
|
+
| Properties | Description | Type |
|
|
164
|
+
| - | - | - |
|
|
165
|
+
| show? | When to show the row-select when not selected | `'hover' \| 'always' \| 'never'` |
|
|
166
|
+
| headerSnippet? | Custom snippet for the header select-input | `Snippet<[context: HeaderSelectCtx]>` |
|
|
167
|
+
| rowSnippet? | Custom snippet for the row select-input | `Snippet<[context: RowSelectCtx<T>]>` |
|
|
168
|
+
|
|
169
|
+
<br>
|
|
170
|
+
|
|
171
|
+
### Column
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import { Column } from 'svelte-tably'
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
This component designates a column where options like sorting, filtering etc. are provided.
|
|
178
|
+
|
|
179
|
+
```html
|
|
180
|
+
<Column id='...' header='...' value={row => row.value} />
|
|
181
|
+
|
|
182
|
+
<Column id='...' ...>
|
|
183
|
+
{#snippet header?(ctx: HeaderCtx<T>)}
|
|
184
|
+
...
|
|
185
|
+
{/snippet}
|
|
186
|
+
{#snippet row?(item: T, ctx: RowColumnCtx<T>)}
|
|
187
|
+
...
|
|
188
|
+
{/snippet}
|
|
189
|
+
{#snippet statusbar?(ctx: StatusbarCtx<T>)}
|
|
190
|
+
...
|
|
191
|
+
{/snippet}
|
|
192
|
+
</Column>
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
| Attribute | Description | Type |
|
|
196
|
+
| - | - | - |
|
|
197
|
+
| header? | The header element/contents | `string \| Snippet<[ctx: HeaderCtx<T>]>` |
|
|
198
|
+
| row? | The row element. If not provided, `value: V` will be used. | `Snippet<[item: T, ctx: RowColumnCtx<T, V>]>` |
|
|
199
|
+
| statusbar? | The statusbar element | `Snippet<[ctx: StatusbarCtx<T>]>` |
|
|
200
|
+
| | | |
|
|
201
|
+
| sticky? | Should be sticky by default | `boolean` |
|
|
202
|
+
| show? | Should be visible by default | `boolean` |
|
|
203
|
+
| sortby? | Should sort by this by default | `boolean` |
|
|
204
|
+
| width? | Default width | `number` |
|
|
205
|
+
| value? | The value this column contains | `(item: T) => V` |
|
|
206
|
+
| sort? | A boolean (`localeCompare`) or sorting function | `boolean \| ((a: V, b: V) => number)` |
|
|
207
|
+
| resizeable? | Whether this column is resizeable | `boolean` |
|
|
208
|
+
| filter? | A filter for this columns value | `(item: V) => boolean` |
|
|
209
|
+
| style? | Styling the `td` (row-column) element | `string` |
|
|
210
|
+
| pad? | Apply padding to the child-element of `td`/`th` instead of the column element itself | `'row' \| 'header' \| 'both'` |
|
|
211
|
+
| onclick? | When the column is clicked | `(event: MouseEvent, ctx: RowColumnCtx<T, V>) => void` |
|
|
212
|
+
|
|
213
|
+
<br>
|
|
214
|
+
|
|
215
|
+
### Row
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
import { Row } from 'svelte-tably'
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
This component can add a context-menu on the side of each row, as well as provide event handlers to the row element.
|
|
222
|
+
|
|
223
|
+
```html
|
|
224
|
+
<Row ... />
|
|
225
|
+
|
|
226
|
+
<Row ...>
|
|
227
|
+
{#snippet context?(item: T, ctx: RowCtx<T>)}
|
|
228
|
+
...
|
|
229
|
+
{/snippet}
|
|
230
|
+
{#snippet contextHeader?()}
|
|
231
|
+
...
|
|
232
|
+
{/snippet}
|
|
233
|
+
</Row>
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
| Attribute | Description | Type |
|
|
237
|
+
| - | - | - |
|
|
238
|
+
| context? | A sticky column on the right for each row | `Snippet<[item: T, ctx: RowCtx<T>]>` |
|
|
239
|
+
| contextHeader? | A sticky column on the right for the header | `Snippet<[item: T, ctx: RowCtx<T>]>` |
|
|
240
|
+
| | | |
|
|
241
|
+
| contextOptions? | Options for the Context-column | `ContextOptions<T>` |
|
|
242
|
+
| onclick? | When row is clicked | `(event: MouseEvent, ctx: RowCtx<T>) => void` |
|
|
243
|
+
| oncontextmenu? | When row is right-clicked | `(event: MouseEvent, ctx: RowCtx<T>) => void` |
|
|
244
|
+
|
|
245
|
+
#### ContextOptions
|
|
246
|
+
|
|
247
|
+
| Properties | Description | Type |
|
|
248
|
+
| - | - | - |
|
|
249
|
+
| hover? | Only show when hovering? | `boolean` |
|
|
250
|
+
| width? | The width for the context-column | `string` |
|
|
251
|
+
|
|
252
|
+
<br>
|
|
253
|
+
|
|
254
|
+
### Expandable
|
|
255
|
+
|
|
256
|
+
```ts
|
|
257
|
+
import { Expandable } from 'svelte-tably'
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
This component gives your rows the ability to be expanded.
|
|
261
|
+
|
|
262
|
+
```html
|
|
263
|
+
<Expandable ...>
|
|
264
|
+
{#snippet content(item: T, ctx: RowCtx<T>)}
|
|
265
|
+
...
|
|
266
|
+
{/snippet}
|
|
267
|
+
</Expandable>
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
| Attribute | Description | Type |
|
|
271
|
+
| - | - | - |
|
|
272
|
+
| content | The contents of the expanded row. | `Snippet<[item: T, ctx: RowCtx<T>]>` |
|
|
273
|
+
| | | |
|
|
274
|
+
| slide? | Options for sliding the expanding part | `{ duration?: number, easing?: EasingFunction }` |
|
|
275
|
+
| click? | Whether you can click on a row to expand/collapse it | `boolean` |
|
|
276
|
+
| chevron? | Whether to show the chevron on the left fixed column | `'always' \| 'hover' \| 'never'` |
|
|
277
|
+
| multiple? | Can multiple rows be open at the same time? | `boolean` |
|
|
278
|
+
|
|
279
|
+
<br>
|
|
280
|
+
|
|
281
|
+
### Panel
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
import { Panel } from 'svelte-tably'
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
This component creates a panel that can be opened on the side of the table.
|
|
288
|
+
|
|
289
|
+
```html
|
|
290
|
+
<Panel id='...' ...>
|
|
291
|
+
{#snippet children(ctx: PanelCtx<T>)}
|
|
292
|
+
...
|
|
293
|
+
{/snippet}
|
|
294
|
+
</Panel>
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
| Attribute | Description | Type |
|
|
298
|
+
| - | - | - |
|
|
299
|
+
| children | The contents of the panel | `Snippet<[ctx: PanelCtx<T>]>` |
|
|
300
|
+
| | | |
|
|
301
|
+
| id | The id for the panel that determines whether it's open or closed, from the Table attribute | `string` |
|
|
299
302
|
| backdrop? | Whether there should be a backdrop or not | `boolean` |
|