@tanstack/svelte-table 8.0.0-alpha.73 → 8.0.0-alpha.77
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 +38 -9
- package/build/cjs/svelte-table/src/index.js.map +1 -1
- package/build/cjs/table-core/build/esm/index.js +40 -141
- package/build/cjs/table-core/build/esm/index.js.map +1 -1
- package/build/esm/index.js +77 -150
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +48 -42
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +77 -150
- 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 +4 -4
- package/src/index.ts +39 -7
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-table",
|
|
3
3
|
"author": "Tanner Linsley",
|
|
4
|
-
"version": "8.0.0-alpha.
|
|
4
|
+
"version": "8.0.0-alpha.77",
|
|
5
5
|
"description": "Composables for building lightweight, fast and extendable datagrids for Vue",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/tanstack/react-table#readme",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
24
24
|
},
|
|
25
25
|
"module": "build/esm/index.js",
|
|
26
|
-
"main": "build/cjs/index.js",
|
|
27
|
-
"browser": "build/umd/index.production.
|
|
26
|
+
"main": "build/cjs/svelte-table/src/index.js",
|
|
27
|
+
"browser": "build/umd/index.production.js",
|
|
28
28
|
"types": "build/types/index.d.ts",
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=12"
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"src"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@tanstack/table-core": "8.0.0-alpha.
|
|
37
|
+
"@tanstack/table-core": "8.0.0-alpha.76"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {
|
|
40
40
|
"svelte": "^3.48.0"
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
TableOptions,
|
|
8
8
|
} from '@tanstack/table-core'
|
|
9
9
|
import Placeholder from './placeholder.svelte'
|
|
10
|
+
import { SvelteComponent } from 'svelte/internal'
|
|
10
11
|
import { readable, writable, derived, Readable, get } from 'svelte/store'
|
|
11
12
|
import { renderComponent } from './render-component'
|
|
12
13
|
|
|
@@ -14,17 +15,48 @@ export { renderComponent } from './render-component'
|
|
|
14
15
|
|
|
15
16
|
export * from '@tanstack/table-core'
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
function isSvelteServerComponent(component: any) {
|
|
19
|
+
return (
|
|
20
|
+
typeof component === 'object' &&
|
|
21
|
+
typeof component.$$render === 'function' &&
|
|
22
|
+
typeof component.render === 'function'
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isSvelteClientComponent(component: any) {
|
|
27
|
+
return component.prototype instanceof SvelteComponent
|
|
28
|
+
}
|
|
19
29
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
30
|
+
function isSvelteComponent(component: any) {
|
|
31
|
+
if (typeof document === 'undefined') {
|
|
32
|
+
return isSvelteServerComponent(component)
|
|
23
33
|
} else {
|
|
24
|
-
return
|
|
34
|
+
return isSvelteClientComponent(component)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function wrapInPlaceholder(content: any) {
|
|
39
|
+
return renderComponent(Placeholder, { content })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function render(component: any, props: any) {
|
|
43
|
+
if (!component) return null
|
|
44
|
+
|
|
45
|
+
if (isSvelteComponent(component)) {
|
|
46
|
+
return renderComponent(component, props)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (typeof component === 'function') {
|
|
50
|
+
const result = component(props)
|
|
51
|
+
|
|
52
|
+
if (isSvelteComponent(result)) {
|
|
53
|
+
return result
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return wrapInPlaceholder(result)
|
|
25
57
|
}
|
|
26
58
|
|
|
27
|
-
|
|
59
|
+
return wrapInPlaceholder(component)
|
|
28
60
|
}
|
|
29
61
|
|
|
30
62
|
export const createTable = createTableFactory({ render })
|