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

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.
@@ -12,7 +12,8 @@
12
12
 
13
13
  export interface TableState<T extends Record<PropertyKey, any> = Record<PropertyKey, any>> {
14
14
  columns: Record<string, TColumn<T, unknown>>
15
- panels: Record<string, TPanel>
15
+ panels: Record<string, TPanel<T>>
16
+ selected: T[] | null
16
17
  sortby?: string
17
18
  positions: {
18
19
  sticky: string[]
@@ -20,7 +21,10 @@
20
21
  hidden: string[]
21
22
  toggle(key: string): void
22
23
  }
24
+ readonly resizeable: boolean
23
25
  readonly data: T[]
26
+ /** Rows become anchors */
27
+ readonly href?: (item: T) => string
24
28
  addColumn(key: string, options: TColumn<T, unknown>): void
25
29
  removeColumn(key: string): void
26
30
  }
@@ -38,13 +42,23 @@
38
42
  import Panel, { PanelTween, type Panel as TPanel } from './Panel.svelte'
39
43
  import { fly } from 'svelte/transition'
40
44
  import { sineInOut } from 'svelte/easing'
45
+ import { get } from 'svelte/store'
46
+ import { on } from 'svelte/events'
47
+ import { ka_GE } from '@faker-js/faker'
41
48
 
42
49
  interface Props {
43
- content: Snippet<[context: { Column: typeof Column<T>, Panel: typeof Panel, readonly state: TableState<T>, readonly data: T[] }]>
50
+ content: Snippet<[context: { Column: typeof Column<T>, Panel: typeof Panel, readonly table: TableState<T>, readonly data: T[] }]>
44
51
 
45
52
  panel?: string
46
53
  data?: T[]
47
54
  id?: string
55
+ href?: (item: T) => string
56
+ /**
57
+ * Can you change the width of the columns?
58
+ * @default true
59
+ */
60
+ resizeable?: boolean
61
+ selectable?: 'hover' | 'always' | 'never'
48
62
  }
49
63
 
50
64
  let {
@@ -52,10 +66,13 @@
52
66
 
53
67
  panel = $bindable(),
54
68
  data: _data = [],
55
- id = Array.from({length: 12}, () => String.fromCharCode(Math.floor(Math.random() * 26) + 97)).join('')
69
+ id = Array.from({length: 12}, () => String.fromCharCode(Math.floor(Math.random() * 26) + 97)).join(''),
70
+ href,
71
+ resizeable = true,
72
+ selectable = 'never'
56
73
  }: Props = $props()
57
74
 
58
- const data = $derived(_data.toSorted())
75
+ const data = $derived([..._data])
59
76
 
60
77
  const elements = $state({}) as Record<'headers' | 'statusbar' | 'rows', HTMLElement>
61
78
 
@@ -64,36 +81,34 @@
64
81
  let scrollTop = $state(0)
65
82
  let viewportHeight = $state(0)
66
83
 
67
- let _heightPerItem = 24
68
- let renderItemLength = $derived(Math.ceil(Math.max(30, viewportHeight / (_heightPerItem / 3))))
69
-
70
84
  let heightPerItem = $derived.by(() => {
71
85
  data
72
86
  if(!elements.rows)
73
87
  return 8
74
88
  const result = elements.rows.scrollHeight / elements.rows.childNodes.length
75
- _heightPerItem = result
76
89
  return result
77
90
  })
78
91
 
92
+ let renderItemLength = $derived(Math.ceil(Math.max(30, (viewportHeight / heightPerItem) * 2)))
93
+
94
+ const spacing = () => viewportHeight / 2
79
95
  let virtualTop = $derived.by(() => {
80
- let spacing = untrack(() => (renderItemLength/3)) * heightPerItem
81
- let scroll = scrollTop - spacing
96
+ let scroll = scrollTop - spacing()
82
97
  let virtualTop = Math.max(scroll, 0)
83
98
  virtualTop -= virtualTop % heightPerItem
84
99
  return virtualTop
85
100
  })
86
101
  let virtualBottom = $derived.by(() => {
87
- const virtualBottom = (heightPerItem * data.length) - virtualTop
88
- return virtualBottom
102
+ const virtualBottom = (heightPerItem * data.length) - virtualTop - spacing() * 4
103
+ return Math.max(virtualBottom, 0)
89
104
  })
90
-
91
105
  /** The area of data that is rendered */
92
106
  const area = $derived.by(() => {
93
107
  const index = (virtualTop / heightPerItem) || 0
108
+ const end = index + untrack(() => renderItemLength)
94
109
  return data.slice(
95
110
  index,
96
- index + untrack(() => renderItemLength)
111
+ end
97
112
  )
98
113
  })
99
114
  // * --- Virtualization --- *
@@ -101,6 +116,7 @@
101
116
 
102
117
  const table: TableState<T> = $state({
103
118
  columns: {},
119
+ selected: selectable === 'never' ? null : [],
104
120
  panels: {},
105
121
  positions: {
106
122
  sticky: [],
@@ -113,9 +129,15 @@
113
129
  table.positions.hidden.push(key)
114
130
  }
115
131
  },
132
+ get href() {
133
+ return href
134
+ },
116
135
  get data() {
117
136
  return data
118
137
  },
138
+ get resizeable() {
139
+ return resizeable
140
+ },
119
141
  addColumn(key, column) {
120
142
  table.columns[key] = column
121
143
 
@@ -144,28 +166,60 @@
144
166
 
145
167
  const panelTween = new PanelTween(() => panel, 24)
146
168
 
169
+ let hoveredRow: T | null = $state(null)
170
+
147
171
  /** Order of columns */
148
- const columns = $derived([...table.positions.sticky, ...table.positions.scroll].filter(key => !table.positions.hidden.includes(key)))
172
+ const notHidden = (key: string) => !table.positions.hidden.includes(key)
173
+ const sticky = $derived(table.positions.sticky.filter(notHidden))
174
+ const scrolled = $derived(table.positions.scroll.filter(notHidden))
175
+ const columns = $derived([...sticky, ...scrolled])
149
176
 
150
177
  /** Width of each column */
151
- const widths = $state({}) as Record<string, number>
178
+ const columnWidths = $state({}) as Record<string, number>
179
+
180
+ const getWidth = (key: string, def: number = 150) => columnWidths[key] || table.columns[key]?.defaults.width || def
152
181
 
153
182
  /** grid-template-columns for widths */
154
- const style = $derived(`
155
- #${id} > .headers, #${id} > .content > .rows > .row, #${id} > .statusbar, #${id} > .content > .virtual.bottom {
156
- grid-template-columns: ${columns.map((key, i, arr) => i === arr.length - 1 ? `minmax(${widths[key] || 150}px, 1fr)` : `${widths[key] || 150}px`).join(' ')};
183
+ const style = $derived.by(() => {
184
+ const templateColumns = `
185
+ #${id} > .headers,
186
+ #${id} > .content > .rows > .row,
187
+ #${id} > .statusbar,
188
+ #${id} > .content > .virtual.bottom {
189
+ grid-template-columns: ${
190
+ columns.map((key, i, arr) => {
191
+ const width = getWidth(key)
192
+ if(i === arr.length - 1)
193
+ return `minmax(${width}px, 1fr)`
194
+ return `${width}px`
195
+ }).join(' ')
196
+ };
197
+ }
198
+ `
199
+
200
+ let sum = 0
201
+ const stickyLeft = sticky.map((key, i, arr) => {
202
+ sum += getWidth(arr[i - 1], i === 0 ? 0 : undefined)
203
+ return `
204
+ #${id} .column.sticky[data-column='${key}'] {
205
+ left: ${sum}px;
157
206
  }
158
- `)
207
+ `
208
+ }).join('')
159
209
 
160
- const observer = typeof MutationObserver === 'undefined' ? undefined : new MutationObserver(mutations => {
161
- const target = mutations[0].target as HTMLDivElement
162
- widths[target.getAttribute('data-column')!] = parseFloat(target.style.width)
210
+ return templateColumns + stickyLeft
163
211
  })
164
-
165
- function observe(node: HTMLDivElement, isHeader = false) {
212
+
213
+ function observeColumnWidth(node: HTMLDivElement, isHeader = false) {
166
214
  if(!isHeader) return
167
- observer?.observe(node, {attributes: true})
168
- return { destroy: () => observer?.disconnect() }
215
+
216
+ const key = node.getAttribute('data-column')!
217
+ node.style.width = getWidth(key) + 'px'
218
+
219
+ const observer = new MutationObserver(() => columnWidths[key] = parseFloat(node.style.width))
220
+
221
+ observer.observe(node, {attributes: true})
222
+ return { destroy: () => observer.disconnect() }
169
223
  }
170
224
 
171
225
  function onscroll(event: Event) {
@@ -179,6 +233,10 @@
179
233
  elements.statusbar.scrollLeft = target.scrollLeft
180
234
  }
181
235
 
236
+ export {
237
+ table as state
238
+ }
239
+
182
240
  </script>
183
241
  <!---------------------------------------------------->
184
242
 
@@ -194,8 +252,13 @@
194
252
  {#each table.positions.sticky as column, i (column)}
195
253
  {#if !table.positions.hidden.includes(column)}
196
254
  {@const args = arg ? arg(column) : []}
197
- {@const props = isHeader ? { 'data-column': column } : {}}
198
- <div class='column sticky' {...props} use:observe={isHeader} class:border={i == table.positions.sticky.length - 1}>
255
+ <div
256
+ class='column sticky'
257
+ use:observeColumnWidth={isHeader}
258
+ data-column={column}
259
+ class:resizeable={table.columns[column].options.resizeable && table.resizeable}
260
+ class:border={i == table.positions.sticky.length - 1}
261
+ >
199
262
  {@render renderable(column)?.(args[0], args[1])}
200
263
  </div>
201
264
  {/if}
@@ -203,8 +266,12 @@
203
266
  {#each table.positions.scroll as column, i (column)}
204
267
  {#if !table.positions.hidden.includes(column)}
205
268
  {@const args = arg ? arg(column) : []}
206
- {@const props = isHeader ? { 'data-column': column } : {}}
207
- <div class='column' {...props} use:observe={isHeader}>
269
+ <div
270
+ class='column'
271
+ data-column={column}
272
+ use:observeColumnWidth={isHeader}
273
+ class:resizeable={table.columns[column].options.resizeable && table.resizeable}
274
+ >
208
275
  {@render renderable(column)?.(args[0], args[1])}
209
276
  </div>
210
277
  {/if}
@@ -214,7 +281,7 @@
214
281
  <div id={id} class='table svelte-tably'>
215
282
 
216
283
  <div class='headers' bind:this={elements.headers}>
217
- {@render columnsSnippet((column) => table.columns[column]?.header, null, true)}
284
+ {@render columnsSnippet((column) => table.columns[column]?.header, () => [true], true)}
218
285
  </div>
219
286
 
220
287
  <div class='content' {onscroll} bind:clientHeight={viewportHeight}>
@@ -222,15 +289,36 @@
222
289
 
223
290
  <div class='rows' bind:this={elements.rows}>
224
291
  {#each area as item, i (item)}
225
- <div class='row'>
292
+ {@const props = table.href ? { href: table.href(item) } : {}}
293
+ <!-- note: <svelte:element this={table.href ? 'a' : 'div'}> will break the virtualization for some reason -->
294
+ <a
295
+ class='row'
296
+ {...props}
297
+ onpointerenter={() => hoveredRow = item}
298
+ onpointerleave={() => hoveredRow = null}
299
+ onclickcapture={e => !table.href && e.preventDefault()}
300
+ >
301
+ {#if table.selected && (((selectable === 'hover' && hoveredRow === item) || selectable === 'always') || table.selected.includes(item))}
302
+ <div class='select' class:hover={selectable === 'hover'}>
303
+ <input type='checkbox' bind:checked={
304
+ () => table.selected!.includes(item),
305
+ (value) => value ? table.selected!.push(item) : table.selected!.splice(table.selected!.indexOf(item), 1)
306
+ }>
307
+ </div>
308
+ {/if}
309
+
226
310
  {@render columnsSnippet(
227
311
  (column) => table.columns[column]!.row,
228
312
  (column) => {
229
313
  const col = table.columns[column]!
230
- return [item, col.options.value ? col.options.value(item) : undefined]
314
+ return [item, {
315
+ get index() { return _data.indexOf(item) },
316
+ get value() { return col.options.value ? col.options.value(item) : undefined },
317
+ get isHovered() { return hoveredRow === item }
318
+ }]
231
319
  }
232
320
  )}
233
- </div>
321
+ </a>
234
322
  {/each}
235
323
  </div>
236
324
  <div class='virtual bottom' style='height: {virtualBottom}px'>
@@ -250,7 +338,7 @@
250
338
  in:fly={{ x: 100, easing: sineInOut, duration:300 }}
251
339
  out:fly={{ x:100, duration:200, easing: sineInOut }}
252
340
  >
253
- {@render table.panels[panel].content()}
341
+ {@render table.panels[panel].content({ get table() { return table }, get data() { return data } })}
254
342
  </div>
255
343
  {/if}
256
344
  </div>
@@ -264,12 +352,44 @@
264
352
  </div>
265
353
 
266
354
 
267
- {@render content?.({ Column, Panel, get state() { return table }, get data() { return data } })}
355
+ {@render content?.({ Column, Panel, get table() { return table }, get data() { return data } })}
268
356
 
269
357
 
270
358
 
271
359
  <!---------------------------------------------------->
272
360
  <style>
361
+
362
+ .row {
363
+ > .select {
364
+ display: block;
365
+ position: absolute;
366
+ z-index: 3;
367
+ opacity: 1;
368
+ left: 2px;
369
+ overflow: visible;
370
+ background-color: transparent;
371
+ transition: .15s ease;
372
+ > input {
373
+ width: 18px;
374
+ height: 18px;
375
+ border-radius: 1rem;
376
+ cursor: pointer;
377
+ }
378
+
379
+ &.hover {
380
+ @starting-style {
381
+ opacity: 0;
382
+ left: -2px;
383
+ }
384
+ }
385
+ }
386
+ }
387
+
388
+
389
+ a.row {
390
+ color: inherit;
391
+ text-decoration: inherit;
392
+ }
273
393
 
274
394
  .table, .table * {
275
395
  box-sizing: border-box;
@@ -304,15 +424,10 @@
304
424
  .table {
305
425
  color: var(--tably-color, hsl(0, 0%, 0%));
306
426
  background-color: var(--tably-bg, hsl(0, 0%, 100%));
307
-
308
- --tably-padding-x: 1rem;
309
- --tably-padding-y: .5rem;
310
- --tably-radius: .25rem;
311
427
  }
312
428
 
313
429
  .sticky {
314
430
  position: sticky;
315
- left: 0px;
316
431
  /* right: 100px; */
317
432
  z-index: 1;
318
433
  }
@@ -323,9 +438,12 @@
323
438
 
324
439
  .headers > .column {
325
440
  border-right: 1px solid var(--tably-border, hsl(0, 0%, 90%));
326
- resize: horizontal;
327
441
  overflow: hidden;
328
- padding: var(--tably-padding-y) 0;
442
+ padding: var(--tably-padding-y, .5rem) 0;
443
+
444
+ &.resizeable {
445
+ resize: horizontal;
446
+ }
329
447
  }
330
448
 
331
449
  .table {
@@ -378,39 +496,41 @@
378
496
  .statusbar {
379
497
  grid-area: statusbar;
380
498
  overflow: hidden;
499
+ background-color: var(--tably-statusbar, hsl(0, 0%, 98%));
381
500
  }
382
501
 
383
502
  .statusbar > .column {
384
503
  border-top: 1px solid var(--tably-border, hsl(0, 0%, 90%));
385
- padding: calc(var(--tably-padding-y) / 2) 0;
504
+ padding: calc(var(--tably-padding-y, .5rem) / 2) 0;
386
505
  }
387
506
 
388
507
  .headers, .row, .statusbar {
508
+ position: relative;
389
509
  display: grid;
390
510
  width: 100%;
391
511
  height: 100%;
392
512
 
393
513
  & > .column {
394
514
  display: flex;
395
- padding-left: var(--tably-padding-x);
515
+ padding-left: var(--tably-padding-x, 1rem);
396
516
  overflow: hidden;
397
517
  }
398
518
 
399
519
  & > *:last-child {
400
520
  width: 100%;
401
- padding-right: var(--tably-padding-x);
521
+ padding-right: var(--tably-padding-x, 1rem);
402
522
  }
403
523
  }
404
524
 
405
525
  .row:first-child > * {
406
- padding-top: calc(var(--tably-padding-y) + calc(var(--tably-padding-y) / 2));
526
+ padding-top: calc(var(--tably-padding-y, .5rem) + calc(var(--tably-padding-y, .5rem) / 2));
407
527
  }
408
528
  .row:last-child > * {
409
- padding-bottom: calc(var(--tably-padding-y) + calc(var(--tably-padding-y) / 2));
529
+ padding-bottom: calc(var(--tably-padding-y, .5rem) + calc(var(--tably-padding-y, .5rem) / 2));
410
530
  }
411
531
 
412
532
  .row > * {
413
- padding: calc(var(--tably-padding-y) / 2) 0;
533
+ padding: calc(var(--tably-padding-y, .5rem) / 2) 0;
414
534
  }
415
535
 
416
536
  .panel {
@@ -429,7 +549,7 @@
429
549
  right: 0;
430
550
  width: min-content;
431
551
  overflow: auto;
432
- padding: var(--tably-padding-y) 0;
552
+ padding: var(--tably-padding-y, .5rem) 0;
433
553
  }
434
554
  }
435
555
 
@@ -1,7 +1,8 @@
1
1
  import { SvelteComponent } from "svelte";
2
2
  export interface TableState<T extends Record<PropertyKey, any> = Record<PropertyKey, any>> {
3
3
  columns: Record<string, TColumn<T, unknown>>;
4
- panels: Record<string, TPanel>;
4
+ panels: Record<string, TPanel<T>>;
5
+ selected: T[] | null;
5
6
  sortby?: string;
6
7
  positions: {
7
8
  sticky: string[];
@@ -9,7 +10,10 @@ export interface TableState<T extends Record<PropertyKey, any> = Record<Property
9
10
  hidden: string[];
10
11
  toggle(key: string): void;
11
12
  };
13
+ readonly resizeable: boolean;
12
14
  readonly data: T[];
15
+ /** Rows become anchors */
16
+ readonly href?: (item: T) => string;
13
17
  addColumn(key: string, options: TColumn<T, unknown>): void;
14
18
  removeColumn(key: string): void;
15
19
  }
@@ -22,53 +26,68 @@ declare class __sveltets_Render<T extends Record<PropertyKey, unknown>> {
22
26
  content: Snippet<[context: {
23
27
  Column: {
24
28
  (internal: unknown, props: {
25
- header: Column<T_1, V>["header"];
29
+ header?: Column<T_1, V>["header"];
26
30
  row: Column<T_1, V>["row"];
27
31
  statusbar?: Column<T_1, V>["statusbar"];
28
32
  id: string;
29
33
  sticky?: boolean;
30
34
  sort?: boolean;
31
35
  show?: boolean;
36
+ width?: number;
32
37
  value?: Column<T_1, V>["options"]["value"];
33
38
  sorting?: Column<T_1, V>["options"]["sorting"];
39
+ resizeable?: boolean;
34
40
  }): {};
35
41
  new (options: import("svelte").ComponentConstructorOptions<{
36
- header: Column<T_1, V>["header"];
42
+ header?: Column<T_1, V>["header"];
37
43
  row: Column<T_1, V>["row"];
38
44
  statusbar?: Column<T_1, V>["statusbar"];
39
45
  id: string;
40
46
  sticky?: boolean;
41
47
  sort?: boolean;
42
48
  show?: boolean;
49
+ width?: number;
43
50
  value?: Column<T_1, V>["options"]["value"];
44
51
  sorting?: Column<T_1, V>["options"]["sorting"];
52
+ resizeable?: boolean;
45
53
  }>): SvelteComponent<{
46
- header: Column<T_1, V>["header"];
54
+ header?: Column<T_1, V>["header"];
47
55
  row: Column<T_1, V>["row"];
48
56
  statusbar?: Column<T_1, V>["statusbar"];
49
57
  id: string;
50
58
  sticky?: boolean;
51
59
  sort?: boolean;
52
60
  show?: boolean;
61
+ width?: number;
53
62
  value?: Column<T_1, V>["options"]["value"];
54
63
  sorting?: Column<T_1, V>["options"]["sorting"];
64
+ resizeable?: boolean;
55
65
  }, {}, {}> & {
56
66
  $$bindings?: ReturnType<() => "">;
57
67
  };
58
68
  z_$$bindings?: ReturnType<() => "">;
59
69
  };
60
70
  Panel: typeof Panel;
61
- readonly state: TableState<T>;
71
+ readonly table: TableState<T>;
62
72
  readonly data: T[];
63
73
  }]>;
64
74
  panel?: string;
65
75
  data?: T[] | undefined;
66
76
  id?: string;
77
+ href?: ((item: T) => string) | undefined;
78
+ /**
79
+ * Can you change the width of the columns?
80
+ * @default true
81
+ */
82
+ resizeable?: boolean;
83
+ selectable?: "hover" | "always" | "never";
67
84
  };
68
85
  events(): {};
69
86
  slots(): {};
70
87
  bindings(): "panel";
71
- exports(): {};
88
+ exports(): {
89
+ state: TableState<T>;
90
+ };
72
91
  }
73
92
  interface $$IsomorphicComponent {
74
93
  new <T extends Record<PropertyKey, unknown>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T>['props']>, ReturnType<__sveltets_Render<T>['events']>, ReturnType<__sveltets_Render<T>['slots']>> & {
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- import { Table } from './Table/index.js';
2
- export default Table;
1
+ export { default as default } from './Table.svelte';
2
+ export { default as Panel } from './Panel.svelte';
3
+ export { default as Column } from './Column.svelte';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
- import { Table } from './Table/index.js';
2
- export default Table;
1
+ export { default as default } from './Table.svelte';
2
+ export { default as Panel } from './Panel.svelte';
3
+ export { default as Column } from './Column.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-tably",
3
- "version": "1.0.0-next.5",
3
+ "version": "1.0.0-next.7",
4
4
  "repository": "github:refzlund/svelte-tably",
5
5
  "homepage": "https://github.com/Refzlund/svelte-tably",
6
6
  "bugs": {
@@ -11,7 +11,9 @@
11
11
  "@sveltejs/kit": "^2.9.0",
12
12
  "@sveltejs/package": "^2.0.0",
13
13
  "@sveltejs/vite-plugin-svelte": "^5.0.0",
14
+ "floating-runes": "^1.0.0",
14
15
  "publint": "^0.2.0",
16
+ "runic-reorder": "^1.0.0-next.1",
15
17
  "svelte": "^5.0.0",
16
18
  "svelte-check": "^4.0.0",
17
19
  "typescript": "^5.0.0",
@@ -1,31 +0,0 @@
1
- export interface Panel {
2
- /** A darkened backdrop? */
3
- backdrop: boolean;
4
- content: Snippet;
5
- }
6
- export declare class PanelTween {
7
- #private;
8
- current: number;
9
- transitioning: boolean;
10
- /** bind:clientWidth */
11
- width: number;
12
- set target(value: number);
13
- constructor(cb: () => string | undefined, added?: number);
14
- }
15
- import { type Snippet } from 'svelte';
16
- interface Props {
17
- id: string;
18
- /** A darkened backdrop? */
19
- backdrop?: boolean;
20
- children: Snippet;
21
- }
22
- /**
23
- * This is a description, \
24
- * on how to use this.
25
- *
26
- * @example
27
- * <Component />
28
- */
29
- declare const Panel: import("svelte").Component<Props, {}, "">;
30
- type Panel = ReturnType<typeof Panel>;
31
- export default Panel;
@@ -1 +0,0 @@
1
- export { default as Table } from './Table.svelte';
@@ -1 +0,0 @@
1
- export { default as Table } from './Table.svelte';
@@ -1,33 +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 lang="ts">
12
- import type { Snippet } from 'svelte'
13
- import { getTableState, type ColumnOptions } from '../Table.svelte'
14
-
15
- interface Props {
16
- [key: string]: Snippet<[options: ColumnOptions]>
17
- }
18
-
19
- let headers: Props = $props()
20
- const table = getTableState()
21
-
22
- let keys = [] as string[]
23
-
24
- $effect.pre(() => {
25
- keys.forEach((key) => delete table.columns[key].header)
26
- keys = []
27
-
28
- for (const [key, value] of Object.entries(headers)) {
29
- table.updateColumn(key, { header: value })
30
- keys.push(key)
31
- }
32
- })
33
- </script>
@@ -1,15 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- import { type ColumnOptions } from '../Table.svelte';
3
- interface Props {
4
- [key: string]: Snippet<[options: ColumnOptions]>;
5
- }
6
- /**
7
- * This is a description, \
8
- * on how to use this.
9
- *
10
- * @example
11
- * <Component />
12
- */
13
- declare const Headers: import("svelte").Component<Props, {}, "">;
14
- type Headers = ReturnType<typeof Headers>;
15
- export default Headers;
@@ -1,25 +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 lang='ts'>
12
-
13
- import type { Snippet } from 'svelte'
14
- import { getTableState, type TableState } from './Table.svelte'
15
-
16
- interface Props {
17
- [key: string]: Snippet<[table: TableState]>
18
- }
19
-
20
- let panels: Props = $props()
21
-
22
- getTableState().panels = panels
23
-
24
- </script>
25
- <!---------------------------------------------------->
@@ -1,15 +0,0 @@
1
- import type { Snippet } from 'svelte';
2
- import { type TableState } from './Table.svelte';
3
- interface Props {
4
- [key: string]: Snippet<[table: TableState]>;
5
- }
6
- /**
7
- * This is a description, \
8
- * on how to use this.
9
- *
10
- * @example
11
- * <Component />
12
- */
13
- declare const Panels: import("svelte").Component<Props, {}, "">;
14
- type Panels = ReturnType<typeof Panels>;
15
- export default Panels;