@tanstack/svelte-table 9.0.0-beta.7 → 9.0.0-beta.70

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.
Files changed (48) hide show
  1. package/README.md +5 -1
  2. package/dist/FlexRender.svelte +15 -1
  3. package/dist/createTable.svelte.d.ts +26 -36
  4. package/dist/createTable.svelte.js +27 -32
  5. package/dist/createTableHook.svelte.d.ts +51 -18
  6. package/dist/createTableHook.svelte.js +18 -10
  7. package/dist/experimental-worker-plugin.d.ts +1 -0
  8. package/dist/experimental-worker-plugin.js +1 -0
  9. package/dist/index.d.ts +1 -2
  10. package/dist/index.js +0 -1
  11. package/dist/reactivity.svelte.d.ts +3 -1
  12. package/dist/reactivity.svelte.js +6 -1
  13. package/dist/render-component.js +4 -0
  14. package/package.json +16 -9
  15. package/skills/create-table-hook/SKILL.md +168 -0
  16. package/skills/getting-started/SKILL.md +172 -0
  17. package/skills/migrate-v8-to-v9/SKILL.md +201 -0
  18. package/skills/table-state/SKILL.md +262 -0
  19. package/skills/with-tanstack-query/SKILL.md +149 -0
  20. package/skills/with-tanstack-virtual/SKILL.md +150 -0
  21. package/dist/subscribe.d.ts +0 -24
  22. package/dist/subscribe.js +0 -4
  23. package/skills/svelte/client-to-server/SKILL.md +0 -238
  24. package/skills/svelte/compose-with-tanstack-form/SKILL.md +0 -295
  25. package/skills/svelte/compose-with-tanstack-pacer/SKILL.md +0 -176
  26. package/skills/svelte/compose-with-tanstack-query/SKILL.md +0 -299
  27. package/skills/svelte/compose-with-tanstack-store/SKILL.md +0 -277
  28. package/skills/svelte/compose-with-tanstack-virtual/SKILL.md +0 -286
  29. package/skills/svelte/getting-started/SKILL.md +0 -340
  30. package/skills/svelte/migrate-v8-to-v9/SKILL.md +0 -256
  31. package/skills/svelte/production-readiness/SKILL.md +0 -256
  32. package/skills/svelte/table-state/SKILL.md +0 -441
  33. package/src/AppCell.svelte +0 -13
  34. package/src/AppHeader.svelte +0 -13
  35. package/src/AppTable.svelte +0 -11
  36. package/src/FlexRender.svelte +0 -103
  37. package/src/context-keys.ts +0 -3
  38. package/src/createTable.svelte.ts +0 -137
  39. package/src/createTableHook.svelte.ts +0 -639
  40. package/src/createTableState.svelte.ts +0 -30
  41. package/src/flex-render.ts +0 -3
  42. package/src/global.d.ts +0 -1
  43. package/src/index.ts +0 -21
  44. package/src/merge-objects.ts +0 -79
  45. package/src/reactivity.svelte.ts +0 -118
  46. package/src/render-component.ts +0 -107
  47. package/src/static-functions.ts +0 -1
  48. package/src/subscribe.ts +0 -46
@@ -1,639 +0,0 @@
1
- import { getContext, setContext } from 'svelte'
2
- import { createColumnHelper as coreCreateColumnHelper } from '@tanstack/table-core'
3
- import { createTable } from './createTable.svelte'
4
- import { mergeObjects } from './merge-objects'
5
- import {
6
- cellContextKey,
7
- headerContextKey,
8
- tableContextKey,
9
- } from './context-keys.js'
10
- import AppTableSvelte from './AppTable.svelte'
11
- import AppCellSvelte from './AppCell.svelte'
12
- import AppHeaderSvelte from './AppHeader.svelte'
13
- import FlexRenderSvelte from './FlexRender.svelte'
14
- import type { SvelteTable } from './createTable.svelte'
15
- import type { Component, Snippet } from 'svelte'
16
- import type {
17
- AccessorFn,
18
- AccessorFnColumnDef,
19
- AccessorKeyColumnDef,
20
- Cell,
21
- CellContext,
22
- CellData,
23
- Column,
24
- ColumnDef,
25
- DeepKeys,
26
- DeepValue,
27
- DisplayColumnDef,
28
- GroupColumnDef,
29
- Header,
30
- IdentifiedColumnDef,
31
- NoInfer,
32
- Row,
33
- RowData,
34
- Table,
35
- TableFeatures,
36
- TableOptions,
37
- TableState,
38
- } from '@tanstack/table-core'
39
-
40
- export type ComponentType<T extends Record<string, any>> = Component<T>
41
-
42
- // =============================================================================
43
- // Enhanced Context Types with Pre-bound Components
44
- // =============================================================================
45
-
46
- /**
47
- * Enhanced CellContext with pre-bound cell components.
48
- * The `cell` property includes the registered cellComponents.
49
- */
50
- export type AppCellContext<
51
- TFeatures extends TableFeatures,
52
- TData extends RowData,
53
- TValue extends CellData,
54
- TCellComponents extends Record<string, ComponentType<any>>,
55
- > = {
56
- cell: Cell<TFeatures, TData, TValue> &
57
- TCellComponents & { FlexRender: typeof FlexRenderSvelte }
58
- column: Column<TFeatures, TData, TValue>
59
- getValue: CellContext<TFeatures, TData, TValue>['getValue']
60
- renderValue: CellContext<TFeatures, TData, TValue>['renderValue']
61
- row: Row<TFeatures, TData>
62
- table: Table<TFeatures, TData>
63
- }
64
-
65
- /**
66
- * Enhanced HeaderContext with pre-bound header components.
67
- * The `header` property includes the registered headerComponents.
68
- */
69
- export type AppHeaderContext<
70
- TFeatures extends TableFeatures,
71
- TData extends RowData,
72
- TValue extends CellData,
73
- THeaderComponents extends Record<string, ComponentType<any>>,
74
- > = {
75
- column: Column<TFeatures, TData, TValue>
76
- header: Header<TFeatures, TData, TValue> &
77
- THeaderComponents & { FlexRender: typeof FlexRenderSvelte }
78
- table: Table<TFeatures, TData>
79
- }
80
-
81
- // =============================================================================
82
- // Enhanced Column Definition Types
83
- // =============================================================================
84
-
85
- /**
86
- * Template type for column definitions that can be a string or a function.
87
- */
88
- export type AppColumnDefTemplate<TProps extends object> =
89
- | string
90
- | ((props: TProps) => any)
91
-
92
- /**
93
- * Enhanced column definition base with pre-bound components in cell/header/footer contexts.
94
- */
95
- export type AppColumnDefBase<
96
- TFeatures extends TableFeatures,
97
- TData extends RowData,
98
- TValue extends CellData,
99
- TCellComponents extends Record<string, ComponentType<any>>,
100
- THeaderComponents extends Record<string, ComponentType<any>>,
101
- > = Omit<
102
- IdentifiedColumnDef<TFeatures, TData, TValue>,
103
- 'cell' | 'header' | 'footer'
104
- > & {
105
- cell?: AppColumnDefTemplate<
106
- AppCellContext<TFeatures, TData, TValue, TCellComponents>
107
- >
108
- header?: AppColumnDefTemplate<
109
- AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>
110
- >
111
- footer?: AppColumnDefTemplate<
112
- AppHeaderContext<TFeatures, TData, TValue, THeaderComponents>
113
- >
114
- }
115
-
116
- /**
117
- * Enhanced display column definition with pre-bound components.
118
- */
119
- export type AppDisplayColumnDef<
120
- TFeatures extends TableFeatures,
121
- TData extends RowData,
122
- TCellComponents extends Record<string, ComponentType<any>>,
123
- THeaderComponents extends Record<string, ComponentType<any>>,
124
- > = Omit<
125
- DisplayColumnDef<TFeatures, TData, unknown>,
126
- 'cell' | 'header' | 'footer'
127
- > & {
128
- cell?: AppColumnDefTemplate<
129
- AppCellContext<TFeatures, TData, unknown, TCellComponents>
130
- >
131
- header?: AppColumnDefTemplate<
132
- AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>
133
- >
134
- footer?: AppColumnDefTemplate<
135
- AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>
136
- >
137
- }
138
-
139
- /**
140
- * Enhanced group column definition with pre-bound components.
141
- */
142
- export type AppGroupColumnDef<
143
- TFeatures extends TableFeatures,
144
- TData extends RowData,
145
- TCellComponents extends Record<string, ComponentType<any>>,
146
- THeaderComponents extends Record<string, ComponentType<any>>,
147
- > = Omit<
148
- GroupColumnDef<TFeatures, TData, unknown>,
149
- 'cell' | 'header' | 'footer' | 'columns'
150
- > & {
151
- cell?: AppColumnDefTemplate<
152
- AppCellContext<TFeatures, TData, unknown, TCellComponents>
153
- >
154
- header?: AppColumnDefTemplate<
155
- AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>
156
- >
157
- footer?: AppColumnDefTemplate<
158
- AppHeaderContext<TFeatures, TData, unknown, THeaderComponents>
159
- >
160
- columns?: Array<ColumnDef<TFeatures, TData, unknown>>
161
- }
162
-
163
- // =============================================================================
164
- // Enhanced Column Helper Type
165
- // =============================================================================
166
-
167
- /**
168
- * Enhanced column helper with pre-bound components in cell/header/footer contexts.
169
- * This enables TypeScript to know about the registered components when defining columns.
170
- */
171
- export type AppColumnHelper<
172
- TFeatures extends TableFeatures,
173
- TData extends RowData,
174
- TCellComponents extends Record<string, ComponentType<any>>,
175
- THeaderComponents extends Record<string, ComponentType<any>>,
176
- > = {
177
- /**
178
- * Creates a data column definition with an accessor key or function.
179
- * The cell, header, and footer contexts include pre-bound components.
180
- */
181
- accessor: <
182
- TAccessor extends AccessorFn<TData> | DeepKeys<TData>,
183
- TValue extends TAccessor extends AccessorFn<TData, infer TReturn>
184
- ? TReturn
185
- : TAccessor extends DeepKeys<TData>
186
- ? DeepValue<TData, TAccessor>
187
- : never,
188
- >(
189
- accessor: TAccessor,
190
- column: TAccessor extends AccessorFn<TData>
191
- ? AppColumnDefBase<
192
- TFeatures,
193
- TData,
194
- TValue,
195
- TCellComponents,
196
- THeaderComponents
197
- > & { id: string }
198
- : AppColumnDefBase<
199
- TFeatures,
200
- TData,
201
- TValue,
202
- TCellComponents,
203
- THeaderComponents
204
- >,
205
- ) => TAccessor extends AccessorFn<TData>
206
- ? AccessorFnColumnDef<TFeatures, TData, TValue>
207
- : AccessorKeyColumnDef<TFeatures, TData, TValue>
208
-
209
- /**
210
- * Wraps an array of column definitions to preserve each column's individual TValue type.
211
- */
212
- columns: <TColumns extends ReadonlyArray<ColumnDef<TFeatures, TData, any>>>(
213
- columns: [...TColumns],
214
- ) => Array<ColumnDef<TFeatures, TData, any>> & [...TColumns]
215
-
216
- /**
217
- * Creates a display column definition for non-data columns.
218
- * The cell, header, and footer contexts include pre-bound components.
219
- */
220
- display: (
221
- column: AppDisplayColumnDef<
222
- TFeatures,
223
- TData,
224
- TCellComponents,
225
- THeaderComponents
226
- >,
227
- ) => DisplayColumnDef<TFeatures, TData, unknown>
228
-
229
- /**
230
- * Creates a group column definition with nested child columns.
231
- * The cell, header, and footer contexts include pre-bound components.
232
- */
233
- group: (
234
- column: AppGroupColumnDef<
235
- TFeatures,
236
- TData,
237
- TCellComponents,
238
- THeaderComponents
239
- >,
240
- ) => GroupColumnDef<TFeatures, TData, unknown>
241
- }
242
-
243
- // =============================================================================
244
- // CreateTableHook Options
245
- // =============================================================================
246
-
247
- /**
248
- * Options for creating a table hook with pre-bound components and default table options.
249
- * Extends all TableOptions except 'columns' | 'data' | 'store' | 'state' | 'initialState'.
250
- */
251
- export type CreateTableHookOptions<
252
- TFeatures extends TableFeatures,
253
- TTableComponents extends Record<string, ComponentType<any>>,
254
- TCellComponents extends Record<string, ComponentType<any>>,
255
- THeaderComponents extends Record<string, ComponentType<any>>,
256
- > = Omit<
257
- TableOptions<TFeatures, any>,
258
- 'columns' | 'data' | 'store' | 'state' | 'initialState'
259
- > & {
260
- /**
261
- * Table-level components that need access to the table instance.
262
- * These are available directly on the table object returned by createAppTable.
263
- * Use `useTableContext()` inside these components.
264
- * @example { PaginationControls, GlobalFilter, RowCount }
265
- */
266
- tableComponents?: TTableComponents
267
- /**
268
- * Cell-level components that need access to the cell instance.
269
- * These are available on the cell object passed to AppCell's children.
270
- * Use `useCellContext()` inside these components.
271
- * @example { TextCell, NumberCell, DateCell, CurrencyCell }
272
- */
273
- cellComponents?: TCellComponents
274
- /**
275
- * Header-level components that need access to the header instance.
276
- * These are available on the header object passed to AppHeader/AppFooter's children.
277
- * Use `useHeaderContext()` inside these components.
278
- * @example { SortIndicator, ColumnFilter, ResizeHandle }
279
- */
280
- headerComponents?: THeaderComponents
281
- }
282
-
283
- // =============================================================================
284
- // Extended Table Type
285
- // =============================================================================
286
-
287
- /**
288
- * Extended table API returned by createAppTable with all App wrapper components.
289
- */
290
- export type AppSvelteTable<
291
- TFeatures extends TableFeatures,
292
- TData extends RowData,
293
- TSelected,
294
- TTableComponents extends Record<string, ComponentType<any>>,
295
- TCellComponents extends Record<string, ComponentType<any>>,
296
- THeaderComponents extends Record<string, ComponentType<any>>,
297
- > = SvelteTable<TFeatures, TData, TSelected> &
298
- NoInfer<TTableComponents> & {
299
- /**
300
- * Root wrapper component that provides table context.
301
- * @example
302
- * ```svelte
303
- * <table.AppTable>
304
- * <table>...</table>
305
- * </table.AppTable>
306
- * ```
307
- */
308
- AppTable: Component<{ children: Snippet }>
309
- /**
310
- * Wraps a cell and provides cell context with pre-bound cellComponents.
311
- * @example
312
- * ```svelte
313
- * <table.AppCell cell={cell}>
314
- * {#snippet children(c)}
315
- * <td><c.TextCell /></td>
316
- * {/snippet}
317
- * </table.AppCell>
318
- * ```
319
- */
320
- AppCell: Component<{
321
- cell: Cell<TFeatures, TData, any>
322
- children: Snippet<
323
- [
324
- Cell<TFeatures, TData, any> &
325
- NoInfer<TCellComponents> & { FlexRender: typeof FlexRenderSvelte },
326
- ]
327
- >
328
- }>
329
- /**
330
- * Wraps a header and provides header context with pre-bound headerComponents.
331
- * @example
332
- * ```svelte
333
- * <table.AppHeader header={header}>
334
- * {#snippet children(h)}
335
- * <th><h.SortIndicator /></th>
336
- * {/snippet}
337
- * </table.AppHeader>
338
- * ```
339
- */
340
- AppHeader: Component<{
341
- header: Header<TFeatures, TData, any>
342
- children: Snippet<
343
- [
344
- Header<TFeatures, TData, any> &
345
- NoInfer<THeaderComponents> & {
346
- FlexRender: typeof FlexRenderSvelte
347
- },
348
- ]
349
- >
350
- }>
351
- /**
352
- * Wraps a footer and provides header context with pre-bound headerComponents.
353
- * @example
354
- * ```svelte
355
- * <table.AppFooter header={footer}>
356
- * {#snippet children(f)}
357
- * <td><f.FlexRender /></td>
358
- * {/snippet}
359
- * </table.AppFooter>
360
- * ```
361
- */
362
- AppFooter: Component<{
363
- header: Header<TFeatures, TData, any>
364
- children: Snippet<
365
- [
366
- Header<TFeatures, TData, any> &
367
- NoInfer<THeaderComponents> & {
368
- FlexRender: typeof FlexRenderSvelte
369
- },
370
- ]
371
- >
372
- }>
373
- /**
374
- * Convenience FlexRender component attached to the table instance.
375
- */
376
- FlexRender: typeof FlexRenderSvelte
377
- }
378
-
379
- // =============================================================================
380
- // createTableHook Factory
381
- // =============================================================================
382
-
383
- /**
384
- * Creates a custom table hook with pre-bound components for composition.
385
- *
386
- * This is the table equivalent of TanStack Form's `createFormHook`. It allows you to:
387
- * - Define features, row models, and default options once, shared across all tables
388
- * - Register reusable table, cell, and header components
389
- * - Access table/cell/header instances via context in those components
390
- * - Get a `createAppTable` hook that returns an extended table with App wrapper components
391
- * - Get a `createAppColumnHelper` function pre-bound to your features
392
- *
393
- * @example
394
- * ```ts
395
- * // hooks/table.ts
396
- * export const {
397
- * createAppTable,
398
- * createAppColumnHelper,
399
- * useTableContext,
400
- * useCellContext,
401
- * useHeaderContext,
402
- * } = createTableHook({
403
- * features: tableFeatures({
404
- * rowPaginationFeature,
405
- * rowSortingFeature,
406
- * columnFilteringFeature,
407
- * }),
408
- * rowModels: {
409
- * paginatedRowModel: createPaginatedRowModel(),
410
- * sortedRowModel: createSortedRowModel(sortFns),
411
- * filteredRowModel: createFilteredRowModel(filterFns),
412
- * },
413
- * tableComponents: { PaginationControls, RowCount },
414
- * cellComponents: { TextCell, NumberCell },
415
- * headerComponents: { SortIndicator, ColumnFilter },
416
- * })
417
- * ```
418
- */
419
- export function createTableHook<
420
- TFeatures extends TableFeatures,
421
- const TTableComponents extends Record<string, ComponentType<any>>,
422
- const TCellComponents extends Record<string, ComponentType<any>>,
423
- const THeaderComponents extends Record<string, ComponentType<any>>,
424
- >({
425
- tableComponents,
426
- cellComponents,
427
- headerComponents,
428
- ...defaultTableOptions
429
- }: CreateTableHookOptions<
430
- TFeatures,
431
- TTableComponents,
432
- TCellComponents,
433
- THeaderComponents
434
- >) {
435
- /**
436
- * Create a column helper pre-bound to the features and components configured in this table hook.
437
- * The cell, header, and footer contexts include pre-bound components (e.g., `cell.TextCell`).
438
- */
439
- function createAppColumnHelper<TData extends RowData>(): AppColumnHelper<
440
- TFeatures,
441
- TData,
442
- TCellComponents,
443
- THeaderComponents
444
- > {
445
- return coreCreateColumnHelper<TFeatures, TData>() as AppColumnHelper<
446
- TFeatures,
447
- TData,
448
- TCellComponents,
449
- THeaderComponents
450
- >
451
- }
452
-
453
- /**
454
- * Access the table instance from within an `AppTable` wrapper.
455
- * Use this in custom `tableComponents` passed to `createTableHook`.
456
- * TFeatures is already known from the createTableHook call.
457
- */
458
- function useTableContext<TData extends RowData = RowData>(): SvelteTable<
459
- TFeatures,
460
- TData
461
- > {
462
- const table = getContext(tableContextKey)
463
-
464
- if (!table) {
465
- throw new Error(
466
- '`useTableContext` must be used within an `AppTable` component. ' +
467
- 'Make sure your component is wrapped with `<table.AppTable>...</table.AppTable>`.',
468
- )
469
- }
470
-
471
- return table as SvelteTable<TFeatures, TData>
472
- }
473
-
474
- /**
475
- * Access the cell instance from within an `AppCell` wrapper.
476
- * Use this in custom `cellComponents` passed to `createTableHook`.
477
- * TFeatures is already known from the createTableHook call.
478
- */
479
- function useCellContext<TValue extends CellData = CellData>(): Cell<
480
- TFeatures,
481
- any,
482
- TValue
483
- > {
484
- const cell = getContext(cellContextKey)
485
-
486
- if (!cell) {
487
- throw new Error(
488
- '`useCellContext` must be used within an `AppCell` component. ' +
489
- 'Make sure your component is wrapped with `<table.AppCell cell={cell}>...</table.AppCell>`.',
490
- )
491
- }
492
-
493
- return cell as Cell<TFeatures, any, TValue>
494
- }
495
-
496
- /**
497
- * Access the header instance from within an `AppHeader` or `AppFooter` wrapper.
498
- * Use this in custom `headerComponents` passed to `createTableHook`.
499
- * TFeatures is already known from the createTableHook call.
500
- */
501
- function useHeaderContext<TValue extends CellData = CellData>(): Header<
502
- TFeatures,
503
- any,
504
- TValue
505
- > {
506
- const header = getContext(headerContextKey)
507
-
508
- if (!header) {
509
- throw new Error(
510
- '`useHeaderContext` must be used within an `AppHeader` or `AppFooter` component.',
511
- )
512
- }
513
-
514
- return header as Header<TFeatures, any, TValue>
515
- }
516
-
517
- /**
518
- * Enhanced createTable hook that returns a table with App wrapper components
519
- * and pre-bound tableComponents attached directly to the table object.
520
- *
521
- * Default options from createTableHook are automatically merged with
522
- * the options passed here. Options passed here take precedence.
523
- *
524
- * TFeatures is already known from the createTableHook call; TData is inferred from the data prop.
525
- */
526
- function createAppTable<
527
- TData extends RowData,
528
- TSelected = TableState<TFeatures>,
529
- >(
530
- tableOptions: Omit<
531
- TableOptions<TFeatures, TData>,
532
- 'features' | 'rowModels'
533
- >,
534
- selector?: (state: TableState<TFeatures>) => TSelected,
535
- ): AppSvelteTable<
536
- TFeatures,
537
- TData,
538
- TSelected,
539
- TTableComponents,
540
- TCellComponents,
541
- THeaderComponents
542
- > {
543
- // Merge default options with provided options (provided takes precedence)
544
- const mergedTableOptions = mergeObjects(
545
- defaultTableOptions,
546
- tableOptions,
547
- ) as TableOptions<TFeatures, TData>
548
-
549
- const table = createTable<TFeatures, TData, TSelected>(
550
- mergedTableOptions,
551
- selector,
552
- )
553
-
554
- // Build cellComponents with FlexRender included
555
- const cellComponentsWithFlexRender = {
556
- FlexRender: FlexRenderSvelte,
557
- ...(cellComponents ?? {}),
558
- }
559
-
560
- // Build headerComponents with FlexRender included
561
- const headerComponentsWithFlexRender = {
562
- FlexRender: FlexRenderSvelte,
563
- ...(headerComponents ?? {}),
564
- }
565
-
566
- // Create wrapper components using the svelte-form (internal, props) => pattern.
567
- // setContext is called in the closure — this runs during component
568
- // initialization, so Svelte's context API works correctly.
569
- // With keyed {#each} blocks, components are recreated on reorder,
570
- // so context is always fresh.
571
- const AppTable = ((internal: any, props: any) => {
572
- setContext(tableContextKey, table)
573
- return AppTableSvelte(internal, { ...props })
574
- }) as Component<{ children: Snippet }>
575
-
576
- const AppCell = ((internal: any, { children, cell, ...rest }: any) => {
577
- setContext(cellContextKey, cell)
578
- return AppCellSvelte(internal, {
579
- cell,
580
- cellComponents: cellComponentsWithFlexRender,
581
- children,
582
- })
583
- }) as Component<{
584
- cell: Cell<TFeatures, TData, any>
585
- children: Snippet<[any]>
586
- }>
587
-
588
- const AppHeader = ((internal: any, { children, header, ...rest }: any) => {
589
- setContext(headerContextKey, header)
590
- return AppHeaderSvelte(internal, {
591
- header,
592
- headerComponents: headerComponentsWithFlexRender,
593
- children,
594
- })
595
- }) as Component<{
596
- header: Header<TFeatures, TData, any>
597
- children: Snippet<[any]>
598
- }>
599
-
600
- // AppFooter reuses AppHeaderSvelte (footers use Header type in table-core)
601
- const AppFooter = ((internal: any, { children, header, ...rest }: any) => {
602
- setContext(headerContextKey, header)
603
- return AppHeaderSvelte(internal, {
604
- header,
605
- headerComponents: headerComponentsWithFlexRender,
606
- children,
607
- })
608
- }) as Component<{
609
- header: Header<TFeatures, TData, any>
610
- children: Snippet<[any]>
611
- }>
612
-
613
- // Combine everything into the extended table API
614
- return Object.assign(table, {
615
- AppTable,
616
- AppCell,
617
- AppHeader,
618
- AppFooter,
619
- FlexRender: FlexRenderSvelte,
620
- ...(tableComponents ?? {}),
621
- }) as AppSvelteTable<
622
- TFeatures,
623
- TData,
624
- TSelected,
625
- TTableComponents,
626
- TCellComponents,
627
- THeaderComponents
628
- >
629
- }
630
-
631
- return {
632
- appFeatures: defaultTableOptions.features as TFeatures,
633
- createAppColumnHelper,
634
- createAppTable,
635
- useTableContext,
636
- useCellContext,
637
- useHeaderContext,
638
- }
639
- }
@@ -1,30 +0,0 @@
1
- import type { Updater } from '@tanstack/table-core'
2
-
3
- /**
4
- * Creates a small Svelte 5 state holder that accepts TanStack Table updaters.
5
- *
6
- * This is useful when a table state slice should be owned outside the table
7
- * with `$state`, but still needs to accept both value and functional updater
8
- * forms from `on[State]Change` callbacks.
9
- *
10
- * @example
11
- * ```ts
12
- * const [pagination, setPagination] = createTableState({
13
- * pageIndex: 0,
14
- * pageSize: 10,
15
- * })
16
- * ```
17
- */
18
- export function createTableState<TState>(
19
- initialValue: TState,
20
- ): [() => TState, (updater: Updater<TState>) => void] {
21
- let value = $state(initialValue)
22
-
23
- return [
24
- () => value,
25
- (updater: Updater<TState>) => {
26
- if (updater instanceof Function) value = updater(value)
27
- else value = updater
28
- },
29
- ]
30
- }
@@ -1,3 +0,0 @@
1
- /// <reference types="svelte" />
2
-
3
- export { default as FlexRender } from './FlexRender.svelte'
package/src/global.d.ts DELETED
@@ -1 +0,0 @@
1
- /// <reference types="svelte" />
package/src/index.ts DELETED
@@ -1,21 +0,0 @@
1
- export * from '@tanstack/table-core'
2
-
3
- export { createTable } from './createTable.svelte'
4
- export type { SvelteTable } from './createTable.svelte'
5
- export { createTableHook } from './createTableHook.svelte'
6
- export type {
7
- AppCellContext,
8
- AppColumnDefBase,
9
- AppColumnDefTemplate,
10
- AppColumnHelper,
11
- AppDisplayColumnDef,
12
- AppGroupColumnDef,
13
- AppHeaderContext,
14
- AppSvelteTable,
15
- ComponentType,
16
- CreateTableHookOptions,
17
- } from './createTableHook.svelte'
18
- export { createTableState } from './createTableState.svelte'
19
- export { default as FlexRender } from './FlexRender.svelte'
20
- export { subscribeTable, type SubscribeSource } from './subscribe'
21
- export { renderComponent, renderSnippet } from './render-component'