@tanstack/svelte-table 8.17.3 → 9.0.0-alpha.0
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/dist/global.d.ts +1 -0
- package/dist/index.js +94 -0
- package/dist/placeholder.d.ts +4 -0
- package/dist/placeholder.js +8 -0
- package/dist/placeholder.svelte +5 -0
- package/dist/placeholder.svelte.d.ts +23 -0
- package/dist/render-component.js +48 -0
- package/package.json +13 -18
- package/build/lib/index.esm.js +0 -206
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js +0 -116
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -206
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/placeholder.d.ts +0 -3
- package/build/lib/placeholder.js +0 -24
- package/build/lib/placeholder.js.map +0 -1
- package/build/lib/placeholder.svelte.js +0 -61
- package/build/lib/placeholder.svelte.js.map +0 -1
- package/build/lib/render-component.js +0 -66
- package/build/lib/render-component.js.map +0 -1
- package/build/umd/index.development.js +0 -3776
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -22
- package/build/umd/index.production.js.map +0 -1
- /package/{build/lib → dist}/index.d.ts +0 -0
- /package/{build/lib → dist}/render-component.d.ts +0 -0
package/dist/global.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { createTable, } from '@tanstack/table-core';
|
|
2
|
+
import Placeholder from './placeholder';
|
|
3
|
+
import { SvelteComponent } from 'svelte/internal';
|
|
4
|
+
import { readable, writable, derived, get } from 'svelte/store';
|
|
5
|
+
import { renderComponent } from './render-component';
|
|
6
|
+
export { renderComponent } from './render-component';
|
|
7
|
+
export * from '@tanstack/table-core';
|
|
8
|
+
function isSvelteServerComponent(component) {
|
|
9
|
+
return (typeof component === 'object' &&
|
|
10
|
+
typeof component.$$render === 'function' &&
|
|
11
|
+
typeof component.render === 'function');
|
|
12
|
+
}
|
|
13
|
+
function isSvelteClientComponent(component) {
|
|
14
|
+
let isHMR = '__SVELTE_HMR' in window;
|
|
15
|
+
return (component.prototype instanceof SvelteComponent ||
|
|
16
|
+
(isHMR &&
|
|
17
|
+
component.name?.startsWith('Proxy<') &&
|
|
18
|
+
component.name?.endsWith('>')));
|
|
19
|
+
}
|
|
20
|
+
function isSvelteComponent(component) {
|
|
21
|
+
if (typeof document === 'undefined') {
|
|
22
|
+
return isSvelteServerComponent(component);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
return isSvelteClientComponent(component);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function wrapInPlaceholder(content) {
|
|
29
|
+
return renderComponent(Placeholder, { content });
|
|
30
|
+
}
|
|
31
|
+
export function flexRender(component, props) {
|
|
32
|
+
if (!component)
|
|
33
|
+
return null;
|
|
34
|
+
if (isSvelteComponent(component)) {
|
|
35
|
+
return renderComponent(component, props);
|
|
36
|
+
}
|
|
37
|
+
if (typeof component === 'function') {
|
|
38
|
+
const result = component(props);
|
|
39
|
+
if (result === null || result === undefined)
|
|
40
|
+
return null;
|
|
41
|
+
if (isSvelteComponent(result)) {
|
|
42
|
+
return renderComponent(result, props);
|
|
43
|
+
}
|
|
44
|
+
return wrapInPlaceholder(result);
|
|
45
|
+
}
|
|
46
|
+
return wrapInPlaceholder(component);
|
|
47
|
+
}
|
|
48
|
+
export function createSvelteTable(options) {
|
|
49
|
+
let optionsStore;
|
|
50
|
+
if ('subscribe' in options) {
|
|
51
|
+
optionsStore = options;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
optionsStore = readable(options);
|
|
55
|
+
}
|
|
56
|
+
let resolvedOptions = {
|
|
57
|
+
state: {}, // Dummy state
|
|
58
|
+
onStateChange: () => { }, // noop
|
|
59
|
+
renderFallbackValue: null,
|
|
60
|
+
...get(optionsStore),
|
|
61
|
+
};
|
|
62
|
+
let table = createTable(resolvedOptions);
|
|
63
|
+
let stateStore = writable(/** @type {number} */ table.initialState);
|
|
64
|
+
// combine stores
|
|
65
|
+
let stateOptionsStore = derived([stateStore, optionsStore], s => s);
|
|
66
|
+
const tableReadable = readable(table, function start(set) {
|
|
67
|
+
const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {
|
|
68
|
+
table.setOptions(prev => {
|
|
69
|
+
return {
|
|
70
|
+
...prev,
|
|
71
|
+
...options,
|
|
72
|
+
state: { ...state, ...options.state },
|
|
73
|
+
// Similarly, we'll maintain both our internal state and any user-provided
|
|
74
|
+
// state.
|
|
75
|
+
onStateChange: updater => {
|
|
76
|
+
if (updater instanceof Function) {
|
|
77
|
+
stateStore.update(updater);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
stateStore.set(updater);
|
|
81
|
+
}
|
|
82
|
+
resolvedOptions.onStateChange?.(updater);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
// it didn't seem to rerender without setting the table
|
|
87
|
+
set(table);
|
|
88
|
+
});
|
|
89
|
+
return function stop() {
|
|
90
|
+
unsubscribe();
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
return tableReadable;
|
|
94
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { create_ssr_component, escape } from 'svelte/internal';
|
|
2
|
+
import PlaceholderClient from './placeholder.svelte';
|
|
3
|
+
const PlaceholderServer = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
4
|
+
return `${escape($$props.content)}`;
|
|
5
|
+
});
|
|
6
|
+
export default typeof document === 'undefined'
|
|
7
|
+
? PlaceholderServer
|
|
8
|
+
: PlaceholderClient;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @typedef {typeof __propDef.props} PlaceholderProps */
|
|
2
|
+
/** @typedef {typeof __propDef.events} PlaceholderEvents */
|
|
3
|
+
/** @typedef {typeof __propDef.slots} PlaceholderSlots */
|
|
4
|
+
export default class Placeholder extends SvelteComponentTyped<{
|
|
5
|
+
content: any;
|
|
6
|
+
}, {
|
|
7
|
+
[evt: string]: CustomEvent<any>;
|
|
8
|
+
}, {}> {
|
|
9
|
+
}
|
|
10
|
+
export type PlaceholderProps = typeof __propDef.props;
|
|
11
|
+
export type PlaceholderEvents = typeof __propDef.events;
|
|
12
|
+
export type PlaceholderSlots = typeof __propDef.slots;
|
|
13
|
+
import { SvelteComponentTyped } from "svelte";
|
|
14
|
+
declare const __propDef: {
|
|
15
|
+
props: {
|
|
16
|
+
content: any;
|
|
17
|
+
};
|
|
18
|
+
events: {
|
|
19
|
+
[evt: string]: CustomEvent<any>;
|
|
20
|
+
};
|
|
21
|
+
slots: {};
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SvelteComponent, claim_component, create_component, destroy_component, init, mount_component, noop, safe_not_equal, transition_in, transition_out, create_ssr_component, validate_component, } from 'svelte/internal';
|
|
2
|
+
function create_fragment(ctx, Comp, props) {
|
|
3
|
+
let c;
|
|
4
|
+
let current;
|
|
5
|
+
c = new Comp({ props, $$inline: true });
|
|
6
|
+
return {
|
|
7
|
+
c() {
|
|
8
|
+
create_component(c.$$.fragment);
|
|
9
|
+
},
|
|
10
|
+
l(nodes) {
|
|
11
|
+
claim_component(c.$$.fragment, nodes);
|
|
12
|
+
},
|
|
13
|
+
m(target, anchor) {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
mount_component(c, target, anchor);
|
|
16
|
+
current = true;
|
|
17
|
+
},
|
|
18
|
+
p: noop,
|
|
19
|
+
i(local) {
|
|
20
|
+
if (current)
|
|
21
|
+
return;
|
|
22
|
+
transition_in(c.$$.fragment, local);
|
|
23
|
+
current = true;
|
|
24
|
+
},
|
|
25
|
+
o(local) {
|
|
26
|
+
transition_out(c.$$.fragment, local);
|
|
27
|
+
current = false;
|
|
28
|
+
},
|
|
29
|
+
d(detaching) {
|
|
30
|
+
destroy_component(c, detaching);
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function renderClient(Comp, props) {
|
|
35
|
+
return class WrapperComp extends SvelteComponent {
|
|
36
|
+
constructor(options) {
|
|
37
|
+
super();
|
|
38
|
+
init(this, options, null, (ctx) => create_fragment(ctx, Comp, props), safe_not_equal, {}, undefined);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function renderServer(Comp, props) {
|
|
43
|
+
const WrapperComp = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
44
|
+
return `${validate_component(Comp, 'TableComponent').$$render($$result, props, {}, {})}`;
|
|
45
|
+
});
|
|
46
|
+
return WrapperComp;
|
|
47
|
+
}
|
|
48
|
+
export const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-table",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-alpha.0",
|
|
4
4
|
"description": "Headless UI for building powerful tables & datagrids for Svelte.",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,15 +20,15 @@
|
|
|
20
20
|
"svelte-table",
|
|
21
21
|
"datagrid"
|
|
22
22
|
],
|
|
23
|
-
"type": "
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
23
|
+
"type": "module",
|
|
24
|
+
"types": "dist/index.d.ts",
|
|
25
|
+
"module": "dist/index.js",
|
|
26
|
+
"svelte": "./dist/index.js",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
|
-
"types": "./
|
|
30
|
-
"
|
|
31
|
-
"
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"svelte": "./dist/index.js",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./package.json": "./package.json"
|
|
34
34
|
},
|
|
@@ -36,24 +36,19 @@
|
|
|
36
36
|
"node": ">=12"
|
|
37
37
|
},
|
|
38
38
|
"files": [
|
|
39
|
-
"
|
|
40
|
-
"build/umd/*",
|
|
39
|
+
"dist",
|
|
41
40
|
"src"
|
|
42
41
|
],
|
|
43
42
|
"dependencies": {
|
|
44
|
-
"@tanstack/table-core": "
|
|
43
|
+
"@tanstack/table-core": "9.0.0-alpha.0"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
46
|
+
"@sveltejs/package": "^2.3.1",
|
|
47
|
+
"@sveltejs/vite-plugin-svelte": "^3.1.0",
|
|
47
48
|
"svelte": "^3.59.2"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
51
|
"svelte": "^4.0.0 || ^3.49.0"
|
|
51
52
|
},
|
|
52
|
-
"scripts": {
|
|
53
|
-
"clean": "rimraf ./build",
|
|
54
|
-
"test:types": "tsc --noEmit",
|
|
55
|
-
"build": "pnpm build:rollup && pnpm build:types",
|
|
56
|
-
"build:rollup": "rollup --config rollup.config.mjs",
|
|
57
|
-
"build:types": "tsc --emitDeclarationOnly"
|
|
58
|
-
}
|
|
53
|
+
"scripts": {}
|
|
59
54
|
}
|
package/build/lib/index.esm.js
DELETED
|
@@ -1,206 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* svelte-table
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
import { createTable } from '@tanstack/table-core';
|
|
12
|
-
export * from '@tanstack/table-core';
|
|
13
|
-
import { SvelteComponent, init, safe_not_equal, text, claim_text, insert_hydration, set_data, noop, detach, create_ssr_component, escape, validate_component, create_component, claim_component, mount_component, transition_in, transition_out, destroy_component } from 'svelte/internal';
|
|
14
|
-
import 'svelte/internal/disclose-version';
|
|
15
|
-
import { readable, get, writable, derived } from 'svelte/store';
|
|
16
|
-
|
|
17
|
-
/* src/placeholder.svelte generated by Svelte v4.2.15 */
|
|
18
|
-
|
|
19
|
-
function create_fragment$1(ctx) {
|
|
20
|
-
let t;
|
|
21
|
-
|
|
22
|
-
return {
|
|
23
|
-
c() {
|
|
24
|
-
t = text(/*content*/ ctx[0]);
|
|
25
|
-
},
|
|
26
|
-
l(nodes) {
|
|
27
|
-
t = claim_text(nodes, /*content*/ ctx[0]);
|
|
28
|
-
},
|
|
29
|
-
m(target, anchor) {
|
|
30
|
-
insert_hydration(target, t, anchor);
|
|
31
|
-
},
|
|
32
|
-
p(ctx, [dirty]) {
|
|
33
|
-
if (dirty & /*content*/ 1) set_data(t, /*content*/ ctx[0]);
|
|
34
|
-
},
|
|
35
|
-
i: noop,
|
|
36
|
-
o: noop,
|
|
37
|
-
d(detaching) {
|
|
38
|
-
if (detaching) {
|
|
39
|
-
detach(t);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function instance($$self, $$props, $$invalidate) {
|
|
46
|
-
let { content } = $$props;
|
|
47
|
-
|
|
48
|
-
$$self.$$set = $$props => {
|
|
49
|
-
if ('content' in $$props) $$invalidate(0, content = $$props.content);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
return [content];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
let Placeholder$1 = class Placeholder extends SvelteComponent {
|
|
56
|
-
constructor(options) {
|
|
57
|
-
super();
|
|
58
|
-
init(this, options, instance, create_fragment$1, safe_not_equal, { content: 0 });
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const PlaceholderServer = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
63
|
-
return `${escape($$props.content)}`;
|
|
64
|
-
});
|
|
65
|
-
var Placeholder = typeof document === 'undefined' ? PlaceholderServer : Placeholder$1;
|
|
66
|
-
|
|
67
|
-
function create_fragment(ctx, Comp, props) {
|
|
68
|
-
let c;
|
|
69
|
-
let current;
|
|
70
|
-
c = new Comp({
|
|
71
|
-
props,
|
|
72
|
-
$$inline: true
|
|
73
|
-
});
|
|
74
|
-
return {
|
|
75
|
-
c() {
|
|
76
|
-
create_component(c.$$.fragment);
|
|
77
|
-
},
|
|
78
|
-
l(nodes) {
|
|
79
|
-
claim_component(c.$$.fragment, nodes);
|
|
80
|
-
},
|
|
81
|
-
m(target, anchor) {
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
mount_component(c, target, anchor);
|
|
84
|
-
current = true;
|
|
85
|
-
},
|
|
86
|
-
p: noop,
|
|
87
|
-
i(local) {
|
|
88
|
-
if (current) return;
|
|
89
|
-
transition_in(c.$$.fragment, local);
|
|
90
|
-
current = true;
|
|
91
|
-
},
|
|
92
|
-
o(local) {
|
|
93
|
-
transition_out(c.$$.fragment, local);
|
|
94
|
-
current = false;
|
|
95
|
-
},
|
|
96
|
-
d(detaching) {
|
|
97
|
-
destroy_component(c, detaching);
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function renderClient(Comp, props) {
|
|
102
|
-
return class WrapperComp extends SvelteComponent {
|
|
103
|
-
constructor(options) {
|
|
104
|
-
super();
|
|
105
|
-
init(this, options, null, ctx => create_fragment(ctx, Comp, props), safe_not_equal, {}, undefined);
|
|
106
|
-
}
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
function renderServer(Comp, props) {
|
|
110
|
-
const WrapperComp = create_ssr_component(($$result, $$props, $$bindings, slots) => {
|
|
111
|
-
return `${validate_component(Comp, 'TableComponent').$$render($$result, props, {}, {})}`;
|
|
112
|
-
});
|
|
113
|
-
return WrapperComp;
|
|
114
|
-
}
|
|
115
|
-
const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
|
|
116
|
-
|
|
117
|
-
function isSvelteServerComponent(component) {
|
|
118
|
-
return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
|
|
119
|
-
}
|
|
120
|
-
function isSvelteClientComponent(component) {
|
|
121
|
-
var _component$name, _component$name2;
|
|
122
|
-
let isHMR = ('__SVELTE_HMR' in window);
|
|
123
|
-
return component.prototype instanceof SvelteComponent || isHMR && ((_component$name = component.name) == null ? void 0 : _component$name.startsWith('Proxy<')) && ((_component$name2 = component.name) == null ? void 0 : _component$name2.endsWith('>'));
|
|
124
|
-
}
|
|
125
|
-
function isSvelteComponent(component) {
|
|
126
|
-
if (typeof document === 'undefined') {
|
|
127
|
-
return isSvelteServerComponent(component);
|
|
128
|
-
} else {
|
|
129
|
-
return isSvelteClientComponent(component);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
function wrapInPlaceholder(content) {
|
|
133
|
-
return renderComponent(Placeholder, {
|
|
134
|
-
content
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
function flexRender(component, props) {
|
|
138
|
-
if (!component) return null;
|
|
139
|
-
if (isSvelteComponent(component)) {
|
|
140
|
-
return renderComponent(component, props);
|
|
141
|
-
}
|
|
142
|
-
if (typeof component === 'function') {
|
|
143
|
-
const result = component(props);
|
|
144
|
-
if (result === null || result === undefined) return null;
|
|
145
|
-
if (isSvelteComponent(result)) {
|
|
146
|
-
return renderComponent(result, props);
|
|
147
|
-
}
|
|
148
|
-
return wrapInPlaceholder(result);
|
|
149
|
-
}
|
|
150
|
-
return wrapInPlaceholder(component);
|
|
151
|
-
}
|
|
152
|
-
function createSvelteTable(options) {
|
|
153
|
-
let optionsStore;
|
|
154
|
-
if ('subscribe' in options) {
|
|
155
|
-
optionsStore = options;
|
|
156
|
-
} else {
|
|
157
|
-
optionsStore = readable(options);
|
|
158
|
-
}
|
|
159
|
-
let resolvedOptions = {
|
|
160
|
-
state: {},
|
|
161
|
-
// Dummy state
|
|
162
|
-
onStateChange: () => {},
|
|
163
|
-
// noop
|
|
164
|
-
renderFallbackValue: null,
|
|
165
|
-
...get(optionsStore)
|
|
166
|
-
};
|
|
167
|
-
let table = createTable(resolvedOptions);
|
|
168
|
-
let stateStore = writable( /** @type {number} */table.initialState);
|
|
169
|
-
// combine stores
|
|
170
|
-
let stateOptionsStore = derived([stateStore, optionsStore], s => s);
|
|
171
|
-
const tableReadable = readable(table, function start(set) {
|
|
172
|
-
const unsubscribe = stateOptionsStore.subscribe(_ref => {
|
|
173
|
-
let [state, options] = _ref;
|
|
174
|
-
table.setOptions(prev => {
|
|
175
|
-
return {
|
|
176
|
-
...prev,
|
|
177
|
-
...options,
|
|
178
|
-
state: {
|
|
179
|
-
...state,
|
|
180
|
-
...options.state
|
|
181
|
-
},
|
|
182
|
-
// Similarly, we'll maintain both our internal state and any user-provided
|
|
183
|
-
// state.
|
|
184
|
-
onStateChange: updater => {
|
|
185
|
-
if (updater instanceof Function) {
|
|
186
|
-
stateStore.update(updater);
|
|
187
|
-
} else {
|
|
188
|
-
stateStore.set(updater);
|
|
189
|
-
}
|
|
190
|
-
resolvedOptions.onStateChange == null || resolvedOptions.onStateChange(updater);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
// it didn't seem to rerender without setting the table
|
|
196
|
-
set(table);
|
|
197
|
-
});
|
|
198
|
-
return function stop() {
|
|
199
|
-
unsubscribe();
|
|
200
|
-
};
|
|
201
|
-
});
|
|
202
|
-
return tableReadable;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export { createSvelteTable, flexRender, renderComponent };
|
|
206
|
-
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/placeholder.svelte","../../src/placeholder.ts","../../src/render-component.ts","../../src/index.ts"],"sourcesContent":["<script>\n export let content\n</script>\n\n{content}\n","import type { SvelteComponentDev } from 'svelte/internal'\nimport { create_ssr_component, escape } from 'svelte/internal'\nimport PlaceholderClient from './placeholder.svelte'\n\ntype X = typeof PlaceholderClient\n\nconst PlaceholderServer = create_ssr_component(\n ($$result: any, $$props: any, $$bindings: any, slots: any) => {\n return `${escape($$props.content)}`\n }\n) as any as typeof SvelteComponentDev\n\nexport default typeof document === 'undefined'\n ? PlaceholderServer\n : PlaceholderClient\n","import type { ComponentType, ComponentProps } from 'svelte'\nimport {\n SvelteComponent,\n claim_component,\n create_component,\n destroy_component,\n init,\n mount_component,\n noop,\n safe_not_equal,\n transition_in,\n transition_out,\n create_ssr_component,\n validate_component,\n} from 'svelte/internal'\n\nfunction create_fragment(ctx: any, Comp: any, props: any) {\n let c: any\n let current: any\n c = new Comp({ props, $$inline: true })\n\n return {\n c() {\n create_component(c.$$.fragment)\n },\n l(nodes: any) {\n claim_component(c.$$.fragment, nodes)\n },\n m(target: any, anchor: any) {\n // @ts-ignore\n mount_component(c, target, anchor)\n current = true\n },\n p: noop,\n i(local: any) {\n if (current) return\n transition_in(c.$$.fragment, local)\n current = true\n },\n o(local: any) {\n transition_out(c.$$.fragment, local)\n current = false\n },\n d(detaching: any) {\n destroy_component(c, detaching)\n },\n }\n}\n\nfunction renderClient<T>(\n Comp: T,\n props: T extends ComponentType<infer C> ? ComponentProps<C> : any\n) {\n return class WrapperComp extends SvelteComponent {\n constructor(options: any) {\n super()\n init(\n this,\n options,\n null,\n (ctx: any) => create_fragment(ctx, Comp, props),\n safe_not_equal,\n {},\n undefined\n )\n }\n } as ComponentType\n}\n\nfunction renderServer<T>(\n Comp: T,\n props: T extends ComponentType<infer C> ? ComponentProps<C> : any\n) {\n const WrapperComp = create_ssr_component(\n ($$result: any, $$props: any, $$bindings: any, slots: any) => {\n return `${validate_component(Comp, 'TableComponent').$$render(\n $$result,\n props,\n {},\n {}\n )}`\n }\n )\n\n return WrapperComp as unknown as ComponentType\n}\n\nexport const renderComponent =\n typeof window === 'undefined' ? renderServer : renderClient\n","import {\n RowData,\n createTable,\n TableOptions,\n TableOptionsResolved,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder'\nimport type { ComponentType } from 'svelte'\nimport { SvelteComponent } from 'svelte/internal'\nimport { readable, writable, derived, Readable, get } from 'svelte/store'\nimport { renderComponent } from './render-component'\n\nexport { renderComponent } from './render-component'\n\nexport * from '@tanstack/table-core'\n\nfunction isSvelteServerComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$render === 'function' &&\n typeof component.render === 'function'\n )\n}\n\nfunction isSvelteClientComponent(component: any) {\n let isHMR = '__SVELTE_HMR' in window\n\n return (\n component.prototype instanceof SvelteComponent ||\n (isHMR &&\n component.name?.startsWith('Proxy<') &&\n component.name?.endsWith('>'))\n )\n}\n\nfunction isSvelteComponent(component: any) {\n if (typeof document === 'undefined') {\n return isSvelteServerComponent(component)\n } else {\n return isSvelteClientComponent(component)\n }\n}\n\nfunction wrapInPlaceholder(content: any) {\n return renderComponent(Placeholder, { content })\n}\n\nexport function flexRender(component: any, props: any): ComponentType | null {\n if (!component) return null\n\n if (isSvelteComponent(component)) {\n return renderComponent(component, props)\n }\n\n if (typeof component === 'function') {\n const result = component(props)\n if (result === null || result === undefined) return null\n\n if (isSvelteComponent(result)) {\n return renderComponent(result, props)\n }\n\n return wrapInPlaceholder(result)\n }\n\n return wrapInPlaceholder(component)\n}\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createSvelteTable<TData extends RowData>(\n options: ReadableOrVal<TableOptions<TData>>\n) {\n let optionsStore: Readable<TableOptions<TData>>\n\n if ('subscribe' in options) {\n optionsStore = options\n } else {\n optionsStore = readable(options)\n }\n\n let resolvedOptions: TableOptionsResolved<TData> = {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n ...get(optionsStore),\n }\n\n let table = createTable(resolvedOptions)\n\n let stateStore = writable(/** @type {number} */ table.initialState)\n // combine stores\n let stateOptionsStore = derived([stateStore, optionsStore], s => s)\n const tableReadable = readable(table, function start(set) {\n const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {\n table.setOptions(prev => {\n return {\n ...prev,\n ...options,\n state: { ...state, ...options.state },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n if (updater instanceof Function) {\n stateStore.update(updater)\n } else {\n stateStore.set(updater)\n }\n\n resolvedOptions.onStateChange?.(updater)\n },\n }\n })\n\n // it didn't seem to rerender without setting the table\n set(table)\n })\n\n return function stop() {\n unsubscribe()\n }\n })\n\n return tableReadable\n}\n"],"names":["PlaceholderServer","create_ssr_component","$$result","$$props","$$bindings","slots","escape","content","document","PlaceholderClient","create_fragment","ctx","Comp","props","c","current","$$inline","create_component","$$","fragment","l","nodes","claim_component","m","target","anchor","mount_component","p","noop","i","local","transition_in","o","transition_out","d","detaching","destroy_component","renderClient","WrapperComp","SvelteComponent","constructor","options","init","safe_not_equal","undefined","renderServer","validate_component","$$render","renderComponent","window","isSvelteServerComponent","component","render","isSvelteClientComponent","_component$name","_component$name2","isHMR","prototype","name","startsWith","endsWith","isSvelteComponent","wrapInPlaceholder","Placeholder","flexRender","result","createSvelteTable","optionsStore","readable","resolvedOptions","state","onStateChange","renderFallbackValue","get","table","createTable","stateStore","writable","initialState","stateOptionsStore","derived","s","tableReadable","start","set","unsubscribe","subscribe","_ref","setOptions","prev","updater","Function","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;wBAIC,GAAO,CAAA,CAAA,CAAA,CAAA,CAAA;;;qCAAP,GAAO,CAAA,CAAA,CAAA,CAAA,CAAA;;;;;;sDAAP,GAAO,CAAA,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;OAHK,OAAO,EAAA,GAAA,OAAA,CAAA;;;;;;;;;;;;;;;;ACKpB,MAAMA,iBAAiB,GAAGC,oBAAoB,CAC5C,CAACC,QAAa,EAAEC,OAAY,EAAEC,UAAe,EAAEC,KAAU,KAAK;AAC5D,EAAA,OAAQ,GAAEC,MAAM,CAACH,OAAO,CAACI,OAAO,CAAE,CAAC,CAAA,CAAA;AACrC,CACF,CAAqC,CAAA;AAErC,kBAAe,OAAOC,QAAQ,KAAK,WAAW,GAC1CR,iBAAiB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A,UAAU,CAACgB,MAAM,CAACF,OAAO,CAAC,CAAA;AAC5B,aAAC,MAAM;AACLd,cAAAA,UAAU,CAACQ,GAAG,CAACM,OAAO,CAAC,CAAA;AACzB,aAAA;YAEArB,eAAe,CAACE,aAAa,IAA7BF,IAAAA,IAAAA,eAAe,CAACE,aAAa,CAAGmB,OAAO,CAAC,CAAA;AAC1C,WAAA;SACD,CAAA;AACH,OAAC,CAAC,CAAA;;AAEF;MACAN,GAAG,CAACV,KAAK,CAAC,CAAA;AACZ,KAAC,CAAC,CAAA;IAEF,OAAO,SAASmB,IAAIA,GAAG;AACrBR,MAAAA,WAAW,EAAE,CAAA;KACd,CAAA;AACH,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOH,aAAa,CAAA;AACtB;;;;"}
|
package/build/lib/index.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* svelte-table
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
var tableCore = require('@tanstack/table-core');
|
|
14
|
-
var placeholder = require('./placeholder.js');
|
|
15
|
-
var internal = require('svelte/internal');
|
|
16
|
-
var store = require('svelte/store');
|
|
17
|
-
var renderComponent = require('./render-component.js');
|
|
18
|
-
|
|
19
|
-
function isSvelteServerComponent(component) {
|
|
20
|
-
return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
|
|
21
|
-
}
|
|
22
|
-
function isSvelteClientComponent(component) {
|
|
23
|
-
var _component$name, _component$name2;
|
|
24
|
-
let isHMR = ('__SVELTE_HMR' in window);
|
|
25
|
-
return component.prototype instanceof internal.SvelteComponent || isHMR && ((_component$name = component.name) == null ? void 0 : _component$name.startsWith('Proxy<')) && ((_component$name2 = component.name) == null ? void 0 : _component$name2.endsWith('>'));
|
|
26
|
-
}
|
|
27
|
-
function isSvelteComponent(component) {
|
|
28
|
-
if (typeof document === 'undefined') {
|
|
29
|
-
return isSvelteServerComponent(component);
|
|
30
|
-
} else {
|
|
31
|
-
return isSvelteClientComponent(component);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
function wrapInPlaceholder(content) {
|
|
35
|
-
return renderComponent.renderComponent(placeholder.default, {
|
|
36
|
-
content
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
function flexRender(component, props) {
|
|
40
|
-
if (!component) return null;
|
|
41
|
-
if (isSvelteComponent(component)) {
|
|
42
|
-
return renderComponent.renderComponent(component, props);
|
|
43
|
-
}
|
|
44
|
-
if (typeof component === 'function') {
|
|
45
|
-
const result = component(props);
|
|
46
|
-
if (result === null || result === undefined) return null;
|
|
47
|
-
if (isSvelteComponent(result)) {
|
|
48
|
-
return renderComponent.renderComponent(result, props);
|
|
49
|
-
}
|
|
50
|
-
return wrapInPlaceholder(result);
|
|
51
|
-
}
|
|
52
|
-
return wrapInPlaceholder(component);
|
|
53
|
-
}
|
|
54
|
-
function createSvelteTable(options) {
|
|
55
|
-
let optionsStore;
|
|
56
|
-
if ('subscribe' in options) {
|
|
57
|
-
optionsStore = options;
|
|
58
|
-
} else {
|
|
59
|
-
optionsStore = store.readable(options);
|
|
60
|
-
}
|
|
61
|
-
let resolvedOptions = {
|
|
62
|
-
state: {},
|
|
63
|
-
// Dummy state
|
|
64
|
-
onStateChange: () => {},
|
|
65
|
-
// noop
|
|
66
|
-
renderFallbackValue: null,
|
|
67
|
-
...store.get(optionsStore)
|
|
68
|
-
};
|
|
69
|
-
let table = tableCore.createTable(resolvedOptions);
|
|
70
|
-
let stateStore = store.writable( /** @type {number} */table.initialState);
|
|
71
|
-
// combine stores
|
|
72
|
-
let stateOptionsStore = store.derived([stateStore, optionsStore], s => s);
|
|
73
|
-
const tableReadable = store.readable(table, function start(set) {
|
|
74
|
-
const unsubscribe = stateOptionsStore.subscribe(_ref => {
|
|
75
|
-
let [state, options] = _ref;
|
|
76
|
-
table.setOptions(prev => {
|
|
77
|
-
return {
|
|
78
|
-
...prev,
|
|
79
|
-
...options,
|
|
80
|
-
state: {
|
|
81
|
-
...state,
|
|
82
|
-
...options.state
|
|
83
|
-
},
|
|
84
|
-
// Similarly, we'll maintain both our internal state and any user-provided
|
|
85
|
-
// state.
|
|
86
|
-
onStateChange: updater => {
|
|
87
|
-
if (updater instanceof Function) {
|
|
88
|
-
stateStore.update(updater);
|
|
89
|
-
} else {
|
|
90
|
-
stateStore.set(updater);
|
|
91
|
-
}
|
|
92
|
-
resolvedOptions.onStateChange == null || resolvedOptions.onStateChange(updater);
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// it didn't seem to rerender without setting the table
|
|
98
|
-
set(table);
|
|
99
|
-
});
|
|
100
|
-
return function stop() {
|
|
101
|
-
unsubscribe();
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
return tableReadable;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
exports.renderComponent = renderComponent.renderComponent;
|
|
108
|
-
exports.createSvelteTable = createSvelteTable;
|
|
109
|
-
exports.flexRender = flexRender;
|
|
110
|
-
Object.keys(tableCore).forEach(function (k) {
|
|
111
|
-
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
112
|
-
enumerable: true,
|
|
113
|
-
get: function () { return tableCore[k]; }
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
//# sourceMappingURL=index.js.map
|
package/build/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n RowData,\n createTable,\n TableOptions,\n TableOptionsResolved,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder'\nimport type { ComponentType } from 'svelte'\nimport { SvelteComponent } from 'svelte/internal'\nimport { readable, writable, derived, Readable, get } from 'svelte/store'\nimport { renderComponent } from './render-component'\n\nexport { renderComponent } from './render-component'\n\nexport * from '@tanstack/table-core'\n\nfunction isSvelteServerComponent(component: any) {\n return (\n typeof component === 'object' &&\n typeof component.$$render === 'function' &&\n typeof component.render === 'function'\n )\n}\n\nfunction isSvelteClientComponent(component: any) {\n let isHMR = '__SVELTE_HMR' in window\n\n return (\n component.prototype instanceof SvelteComponent ||\n (isHMR &&\n component.name?.startsWith('Proxy<') &&\n component.name?.endsWith('>'))\n )\n}\n\nfunction isSvelteComponent(component: any) {\n if (typeof document === 'undefined') {\n return isSvelteServerComponent(component)\n } else {\n return isSvelteClientComponent(component)\n }\n}\n\nfunction wrapInPlaceholder(content: any) {\n return renderComponent(Placeholder, { content })\n}\n\nexport function flexRender(component: any, props: any): ComponentType | null {\n if (!component) return null\n\n if (isSvelteComponent(component)) {\n return renderComponent(component, props)\n }\n\n if (typeof component === 'function') {\n const result = component(props)\n if (result === null || result === undefined) return null\n\n if (isSvelteComponent(result)) {\n return renderComponent(result, props)\n }\n\n return wrapInPlaceholder(result)\n }\n\n return wrapInPlaceholder(component)\n}\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createSvelteTable<TData extends RowData>(\n options: ReadableOrVal<TableOptions<TData>>\n) {\n let optionsStore: Readable<TableOptions<TData>>\n\n if ('subscribe' in options) {\n optionsStore = options\n } else {\n optionsStore = readable(options)\n }\n\n let resolvedOptions: TableOptionsResolved<TData> = {\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n renderFallbackValue: null,\n ...get(optionsStore),\n }\n\n let table = createTable(resolvedOptions)\n\n let stateStore = writable(/** @type {number} */ table.initialState)\n // combine stores\n let stateOptionsStore = derived([stateStore, optionsStore], s => s)\n const tableReadable = readable(table, function start(set) {\n const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {\n table.setOptions(prev => {\n return {\n ...prev,\n ...options,\n state: { ...state, ...options.state },\n // Similarly, we'll maintain both our internal state and any user-provided\n // state.\n onStateChange: updater => {\n if (updater instanceof Function) {\n stateStore.update(updater)\n } else {\n stateStore.set(updater)\n }\n\n resolvedOptions.onStateChange?.(updater)\n },\n }\n })\n\n // it didn't seem to rerender without setting the table\n set(table)\n })\n\n return function stop() {\n unsubscribe()\n }\n })\n\n return tableReadable\n}\n"],"names":["isSvelteServerComponent","component","$$render","render","isSvelteClientComponent","_component$name","_component$name2","isHMR","window","prototype","SvelteComponent","name","startsWith","endsWith","isSvelteComponent","document","wrapInPlaceholder","content","renderComponent","Placeholder","flexRender","props","result","undefined","createSvelteTable","options","optionsStore","readable","resolvedOptions","state","onStateChange","renderFallbackValue","get","table","createTable","stateStore","writable","initialState","stateOptionsStore","derived","s","tableReadable","start","set","unsubscribe","subscribe","_ref","setOptions","prev","updater","Function","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;AAgBA,SAASA,uBAAuBA,CAACC,SAAc,EAAE;AAC/C,EAAA,OACE,OAAOA,SAAS,KAAK,QAAQ,IAC7B,OAAOA,SAAS,CAACC,QAAQ,KAAK,UAAU,IACxC,OAAOD,SAAS,CAACE,MAAM,KAAK,UAAU,CAAA;AAE1C,CAAA;AAEA,SAASC,uBAAuBA,CAACH,SAAc,EAAE;EAAA,IAAAI,eAAA,EAAAC,gBAAA,CAAA;AAC/C,EAAA,IAAIC,KAAK,IAAG,cAAc,IAAIC,MAAM,CAAA,CAAA;AAEpC,EAAA,OACEP,SAAS,CAACQ,SAAS,YAAYC,wBAAe,IAC7CH,KAAK,KAAAF,CAAAA,eAAA,GACJJ,SAAS,CAACU,IAAI,qBAAdN,eAAA,CAAgBO,UAAU,CAAC,QAAQ,CAAC,CAAAN,KAAAA,CAAAA,gBAAA,GACpCL,SAAS,CAACU,IAAI,KAAA,IAAA,GAAA,KAAA,CAAA,GAAdL,gBAAA,CAAgBO,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAA;AAEpC,CAAA;AAEA,SAAS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