@tanstack/svelte-table 8.0.13 → 8.1.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/build/cjs/svelte-table/src/index.js +14 -18
- package/build/cjs/svelte-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +586 -678
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +595 -691
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +49 -49
- package/build/types/index.d.ts +4 -8
- package/build/umd/index.development.js +597 -693
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +1 -1
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +14 -20
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-table",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.1.1",
|
|
5
5
|
"description": "Headless UI for building powerful tables & datagrids for Svelte.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/table#readme",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"src"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tanstack/table-core": "8.
|
|
37
|
+
"@tanstack/table-core": "8.1.1"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"svelte": "^3.48.0"
|
package/src/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
createTableInstance as coreCreateTableInstance,
|
|
2
|
+
RowData,
|
|
4
3
|
PartialKeys,
|
|
5
|
-
Table,
|
|
6
4
|
TableGenerics,
|
|
5
|
+
createTable,
|
|
7
6
|
TableOptions,
|
|
8
7
|
TableOptionsResolved,
|
|
9
8
|
} from '@tanstack/table-core'
|
|
@@ -47,7 +46,7 @@ function wrapInPlaceholder(content: any) {
|
|
|
47
46
|
return renderComponent(Placeholder, { content })
|
|
48
47
|
}
|
|
49
48
|
|
|
50
|
-
export function
|
|
49
|
+
export function flexRender(component: any, props: any) {
|
|
51
50
|
if (!component) return null
|
|
52
51
|
|
|
53
52
|
if (isSvelteComponent(component)) {
|
|
@@ -67,15 +66,12 @@ export function render(component: any, props: any) {
|
|
|
67
66
|
return wrapInPlaceholder(component)
|
|
68
67
|
}
|
|
69
68
|
|
|
70
|
-
export const createTable = createTableFactory({ render })
|
|
71
|
-
|
|
72
69
|
type ReadableOrVal<T> = T | Readable<T>
|
|
73
70
|
|
|
74
|
-
export function
|
|
75
|
-
|
|
76
|
-
options: ReadableOrVal<TableOptions<TGenerics>>
|
|
71
|
+
export function createSvelteTable<TData extends RowData>(
|
|
72
|
+
options: ReadableOrVal<TableOptions<TData>>
|
|
77
73
|
) {
|
|
78
|
-
let optionsStore: Readable<TableOptions<
|
|
74
|
+
let optionsStore: Readable<TableOptions<TData>>
|
|
79
75
|
|
|
80
76
|
if ('subscribe' in options) {
|
|
81
77
|
optionsStore = options
|
|
@@ -83,23 +79,21 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
83
79
|
optionsStore = readable(options)
|
|
84
80
|
}
|
|
85
81
|
|
|
86
|
-
let resolvedOptions: TableOptionsResolved<
|
|
87
|
-
...table.options,
|
|
82
|
+
let resolvedOptions: TableOptionsResolved<TData> = {
|
|
88
83
|
state: {}, // Dummy state
|
|
89
84
|
onStateChange: () => {}, // noop
|
|
90
|
-
render,
|
|
91
85
|
renderFallbackValue: null,
|
|
92
86
|
...get(optionsStore),
|
|
93
87
|
}
|
|
94
88
|
|
|
95
|
-
let
|
|
89
|
+
let table = createTable(resolvedOptions)
|
|
96
90
|
|
|
97
|
-
let stateStore = writable(/** @type {number} */
|
|
91
|
+
let stateStore = writable(/** @type {number} */ table.initialState)
|
|
98
92
|
// combine stores
|
|
99
93
|
let stateOptionsStore = derived([stateStore, optionsStore], s => s)
|
|
100
|
-
const
|
|
94
|
+
const tableReadable = readable(table, function start(set) {
|
|
101
95
|
const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {
|
|
102
|
-
|
|
96
|
+
table.setOptions(prev => {
|
|
103
97
|
return {
|
|
104
98
|
...prev,
|
|
105
99
|
...options,
|
|
@@ -118,8 +112,8 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
118
112
|
}
|
|
119
113
|
})
|
|
120
114
|
|
|
121
|
-
// it didn't seem to rerender without setting the
|
|
122
|
-
set(
|
|
115
|
+
// it didn't seem to rerender without setting the table
|
|
116
|
+
set(table)
|
|
123
117
|
})
|
|
124
118
|
|
|
125
119
|
return function stop() {
|
|
@@ -127,5 +121,5 @@ export function createTableInstance<TGenerics extends TableGenerics>(
|
|
|
127
121
|
}
|
|
128
122
|
})
|
|
129
123
|
|
|
130
|
-
return
|
|
124
|
+
return tableReadable
|
|
131
125
|
}
|