@tanstack/svelte-table 8.0.0-alpha.76 → 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/esm/index.js +37 -9
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +46 -40
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +37 -9
- 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 +1 -1
- package/src/index.ts +39 -7
|
@@ -14,21 +14,50 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
14
14
|
|
|
15
15
|
var index = require('../../table-core/build/esm/index.js');
|
|
16
16
|
var placeholder = require('./placeholder.svelte.js');
|
|
17
|
+
var internal = require('svelte/internal');
|
|
17
18
|
var store = require('svelte/store');
|
|
18
19
|
var renderComponent = require('./render-component.js');
|
|
19
20
|
|
|
20
|
-
function
|
|
21
|
-
|
|
21
|
+
function isSvelteServerComponent(component) {
|
|
22
|
+
return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function isSvelteClientComponent(component) {
|
|
26
|
+
return component.prototype instanceof internal.SvelteComponent;
|
|
27
|
+
}
|
|
22
28
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return
|
|
29
|
+
function isSvelteComponent(component) {
|
|
30
|
+
if (typeof document === 'undefined') {
|
|
31
|
+
return isSvelteServerComponent(component);
|
|
26
32
|
} else {
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
return isSvelteClientComponent(component);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function wrapInPlaceholder(content) {
|
|
38
|
+
return renderComponent.renderComponent(placeholder["default"], {
|
|
39
|
+
content
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function render(component, props) {
|
|
44
|
+
if (!component) return null;
|
|
45
|
+
|
|
46
|
+
if (isSvelteComponent(component)) {
|
|
47
|
+
return renderComponent.renderComponent(component, props);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (typeof component === 'function') {
|
|
51
|
+
const result = component(props);
|
|
52
|
+
|
|
53
|
+
if (isSvelteComponent(result)) {
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return wrapInPlaceholder(result);
|
|
58
|
+
}
|
|
31
59
|
|
|
60
|
+
return wrapInPlaceholder(component);
|
|
32
61
|
}
|
|
33
62
|
const createTable = index.createTableFactory({
|
|
34
63
|
render
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n createTableFactory,\n createTableInstance as coreCreateTableInstance,\n PartialKeys,\n Table,\n TableGenerics,\n TableOptions,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder.svelte'\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\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":["import {\n createTableFactory,\n createTableInstance as coreCreateTableInstance,\n PartialKeys,\n Table,\n TableGenerics,\n TableOptions,\n} from '@tanstack/table-core'\nimport Placeholder from './placeholder.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 return component.prototype instanceof SvelteComponent\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 render(component: any, props: any) {\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\n if (isSvelteComponent(result)) {\n return result\n }\n\n return wrapInPlaceholder(result)\n }\n\n return wrapInPlaceholder(component)\n}\n\nexport const createTable = createTableFactory({ render })\n\ntype ReadableOrVal<T> = T | Readable<T>\n\nexport function createTableInstance<TGenerics extends TableGenerics>(\n table: Table<TGenerics>,\n options: ReadableOrVal<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n) {\n let optionsStore: Readable<\n PartialKeys<\n Omit<TableOptions<TGenerics>, 'render'>,\n 'state' | 'onStateChange'\n >\n >\n\n if ('subscribe' in options) {\n optionsStore = options\n } else {\n optionsStore = readable(options)\n }\n\n let resolvedOptions: TableOptions<TGenerics> = {\n ...table.options,\n state: {}, // Dummy state\n onStateChange: () => {}, // noop\n render,\n ...get(optionsStore),\n }\n\n let instance = coreCreateTableInstance(resolvedOptions)\n\n let stateStore = writable(/** @type {number} */ instance.initialState)\n // combine stores\n let stateOptionsStore = derived([stateStore, optionsStore], s => s)\n const instanceReadable = readable(instance, function start(set) {\n const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {\n instance.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 instance\n set(instance)\n })\n\n return function stop() {\n unsubscribe()\n }\n })\n\n return instanceReadable\n}\n"],"names":["isSvelteServerComponent","component","$$render","render","isSvelteClientComponent","prototype","SvelteComponent","isSvelteComponent","document","wrapInPlaceholder","content","renderComponent","Placeholder","props","result","createTable","createTableFactory","createTableInstance","table","options","optionsStore","readable","resolvedOptions","state","onStateChange","get","instance","coreCreateTableInstance","stateStore","writable","initialState","stateOptionsStore","derived","s","instanceReadable","start","set","unsubscribe","subscribe","setOptions","prev","updater","Function","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiBA,SAASA,uBAAT,CAAiCC,SAAjC,EAAiD;AAC/C,EAAA,OACE,OAAOA,SAAP,KAAqB,QAArB,IACA,OAAOA,SAAS,CAACC,QAAjB,KAA8B,UAD9B,IAEA,OAAOD,SAAS,CAACE,MAAjB,KAA4B,UAH9B,CAAA;AAKD,CAAA;;AAED,SAASC,uBAAT,CAAiCH,SAAjC,EAAiD;AAC/C,EAAA,OAAOA,SAAS,CAACI,SAAV,YAA+BC,wBAAtC,CAAA;AACD,CAAA;;AAED,SAASC,iBAAT,CAA2BN,SAA3B,EAA2C;AACzC,EAAA,IAAI,OAAOO,QAAP,KAAoB,WAAxB,EAAqC;AACnC,IAAOR,OAAAA,uBAAuB,CAACC,SAAD,CAA9B,CAAA;AACD,GAFD,MAEO;AACL,IAAOG,OAAAA,uBAAuB,CAACH,SAAD,CAA9B,CAAA;AACD,GAAA;AACF,CAAA;;AAED,SAASQ,iBAAT,CAA2BC,OAA3B,EAAyC;AACvC,EAAOC,OAAAA,+BAAe,CAACC,sBAAD,EAAc;AAAEF,IAAAA,OAAAA;AAAF,GAAd,CAAtB,CAAA;AACD,CAAA;;AAEM,SAASP,MAAT,CAAgBF,SAAhB,EAAgCY,KAAhC,EAA4C;AACjD,EAAA,IAAI,CAACZ,SAAL,EAAgB,OAAO,IAAP,CAAA;;AAEhB,EAAA,IAAIM,iBAAiB,CAACN,SAAD,CAArB,EAAkC;AAChC,IAAA,OAAOU,+BAAe,CAACV,SAAD,EAAYY,KAA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
|
4006
4006
|
|
|
4007
4007
|
const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
|
|
4008
4008
|
|
|
4009
|
-
function
|
|
4010
|
-
|
|
4009
|
+
function isSvelteServerComponent(component) {
|
|
4010
|
+
return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
function isSvelteClientComponent(component) {
|
|
4014
|
+
return component.prototype instanceof SvelteComponent;
|
|
4015
|
+
}
|
|
4011
4016
|
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
return
|
|
4017
|
+
function isSvelteComponent(component) {
|
|
4018
|
+
if (typeof document === 'undefined') {
|
|
4019
|
+
return isSvelteServerComponent(component);
|
|
4015
4020
|
} else {
|
|
4016
|
-
return
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4021
|
+
return isSvelteClientComponent(component);
|
|
4022
|
+
}
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
function wrapInPlaceholder(content) {
|
|
4026
|
+
return renderComponent(Placeholder, {
|
|
4027
|
+
content
|
|
4028
|
+
});
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
function render(component, props) {
|
|
4032
|
+
if (!component) return null;
|
|
4033
|
+
|
|
4034
|
+
if (isSvelteComponent(component)) {
|
|
4035
|
+
return renderComponent(component, props);
|
|
4036
|
+
}
|
|
4037
|
+
|
|
4038
|
+
if (typeof component === 'function') {
|
|
4039
|
+
const result = component(props);
|
|
4040
|
+
|
|
4041
|
+
if (isSvelteComponent(result)) {
|
|
4042
|
+
return result;
|
|
4043
|
+
}
|
|
4044
|
+
|
|
4045
|
+
return wrapInPlaceholder(result);
|
|
4046
|
+
}
|
|
4020
4047
|
|
|
4048
|
+
return wrapInPlaceholder(component);
|
|
4021
4049
|
}
|
|
4022
4050
|
const createTable = createTableFactory({
|
|
4023
4051
|
render
|