@tanstack/svelte-table 8.0.0-alpha.67
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/_virtual/_rollupPluginBabelHelpers.js +61 -0
- package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/cjs/index.js +107 -0
- package/build/cjs/index.js.map +1 -0
- package/build/cjs/placeholder.svelte.js +58 -0
- package/build/cjs/placeholder.svelte.js.map +1 -0
- package/build/cjs/render-component.js +79 -0
- package/build/cjs/render-component.js.map +1 -0
- package/build/esm/index.js +235 -0
- package/build/esm/index.js.map +1 -0
- package/build/stats-html.html +2689 -0
- package/build/stats-react.json +182 -0
- package/build/types/index.d.ts +11 -0
- package/build/types/render-component.d.ts +3 -0
- package/build/umd/index.development.js +249 -0
- package/build/umd/index.development.js.map +1 -0
- package/build/umd/index.production.js +12 -0
- package/build/umd/index.production.js.map +1 -0
- package/package.json +42 -0
- package/src/global.d.ts +1 -0
- package/src/index.ts +105 -0
- package/src/placeholder.svelte +5 -0
- package/src/render-component.ts +78 -0
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 2,
|
|
3
|
+
"tree": {
|
|
4
|
+
"name": "root",
|
|
5
|
+
"children": [
|
|
6
|
+
{
|
|
7
|
+
"name": "index.production.js",
|
|
8
|
+
"children": [
|
|
9
|
+
{
|
|
10
|
+
"uid": "ed1d-176",
|
|
11
|
+
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "packages/svelte-table/src",
|
|
15
|
+
"children": [
|
|
16
|
+
{
|
|
17
|
+
"uid": "ed1d-178",
|
|
18
|
+
"name": "placeholder.svelte"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"uid": "ed1d-180",
|
|
22
|
+
"name": "render-component.ts"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"uid": "ed1d-182",
|
|
26
|
+
"name": "index.ts"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
"isRoot": true
|
|
34
|
+
},
|
|
35
|
+
"nodeParts": {
|
|
36
|
+
"ed1d-176": {
|
|
37
|
+
"renderedLength": 1010,
|
|
38
|
+
"gzipLength": 437,
|
|
39
|
+
"brotliLength": 0,
|
|
40
|
+
"mainUid": "ed1d-175"
|
|
41
|
+
},
|
|
42
|
+
"ed1d-178": {
|
|
43
|
+
"renderedLength": 925,
|
|
44
|
+
"gzipLength": 444,
|
|
45
|
+
"brotliLength": 0,
|
|
46
|
+
"mainUid": "ed1d-177"
|
|
47
|
+
},
|
|
48
|
+
"ed1d-180": {
|
|
49
|
+
"renderedLength": 1682,
|
|
50
|
+
"gzipLength": 621,
|
|
51
|
+
"brotliLength": 0,
|
|
52
|
+
"mainUid": "ed1d-179"
|
|
53
|
+
},
|
|
54
|
+
"ed1d-182": {
|
|
55
|
+
"renderedLength": 2182,
|
|
56
|
+
"gzipLength": 776,
|
|
57
|
+
"brotliLength": 0,
|
|
58
|
+
"mainUid": "ed1d-181"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"nodeMetas": {
|
|
62
|
+
"ed1d-175": {
|
|
63
|
+
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
64
|
+
"moduleParts": {
|
|
65
|
+
"index.production.js": "ed1d-176"
|
|
66
|
+
},
|
|
67
|
+
"imported": [],
|
|
68
|
+
"importedBy": [
|
|
69
|
+
{
|
|
70
|
+
"uid": "ed1d-181"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"uid": "ed1d-179"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"ed1d-177": {
|
|
78
|
+
"id": "/packages/svelte-table/src/placeholder.svelte",
|
|
79
|
+
"moduleParts": {
|
|
80
|
+
"index.production.js": "ed1d-178"
|
|
81
|
+
},
|
|
82
|
+
"imported": [
|
|
83
|
+
{
|
|
84
|
+
"uid": "ed1d-185"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"importedBy": [
|
|
88
|
+
{
|
|
89
|
+
"uid": "ed1d-181"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"ed1d-179": {
|
|
94
|
+
"id": "/packages/svelte-table/src/render-component.ts",
|
|
95
|
+
"moduleParts": {
|
|
96
|
+
"index.production.js": "ed1d-180"
|
|
97
|
+
},
|
|
98
|
+
"imported": [
|
|
99
|
+
{
|
|
100
|
+
"uid": "ed1d-175"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"uid": "ed1d-185"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"importedBy": [
|
|
107
|
+
{
|
|
108
|
+
"uid": "ed1d-181"
|
|
109
|
+
}
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"ed1d-181": {
|
|
113
|
+
"id": "/packages/svelte-table/src/index.ts",
|
|
114
|
+
"moduleParts": {
|
|
115
|
+
"index.production.js": "ed1d-182"
|
|
116
|
+
},
|
|
117
|
+
"imported": [
|
|
118
|
+
{
|
|
119
|
+
"uid": "ed1d-175"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"uid": "ed1d-183"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"uid": "ed1d-177"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"uid": "ed1d-184"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"uid": "ed1d-179"
|
|
132
|
+
}
|
|
133
|
+
],
|
|
134
|
+
"importedBy": [],
|
|
135
|
+
"isEntry": true
|
|
136
|
+
},
|
|
137
|
+
"ed1d-183": {
|
|
138
|
+
"id": "@tanstack/table-core",
|
|
139
|
+
"moduleParts": {},
|
|
140
|
+
"imported": [],
|
|
141
|
+
"importedBy": [
|
|
142
|
+
{
|
|
143
|
+
"uid": "ed1d-181"
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"isExternal": true
|
|
147
|
+
},
|
|
148
|
+
"ed1d-184": {
|
|
149
|
+
"id": "svelte/store",
|
|
150
|
+
"moduleParts": {},
|
|
151
|
+
"imported": [],
|
|
152
|
+
"importedBy": [
|
|
153
|
+
{
|
|
154
|
+
"uid": "ed1d-181"
|
|
155
|
+
}
|
|
156
|
+
],
|
|
157
|
+
"isExternal": true
|
|
158
|
+
},
|
|
159
|
+
"ed1d-185": {
|
|
160
|
+
"id": "svelte/internal",
|
|
161
|
+
"moduleParts": {},
|
|
162
|
+
"imported": [],
|
|
163
|
+
"importedBy": [
|
|
164
|
+
{
|
|
165
|
+
"uid": "ed1d-177"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"uid": "ed1d-179"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
"isExternal": true
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"env": {
|
|
175
|
+
"rollup": "2.70.2"
|
|
176
|
+
},
|
|
177
|
+
"options": {
|
|
178
|
+
"gzip": true,
|
|
179
|
+
"brotli": false,
|
|
180
|
+
"sourcemap": false
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PartialKeys, Table, TableGenerics, TableOptions } from '@tanstack/table-core';
|
|
2
|
+
import { Readable } from 'svelte/store';
|
|
3
|
+
export { renderComponent } from './render-component';
|
|
4
|
+
export * from '@tanstack/table-core';
|
|
5
|
+
export declare function render(Comp: any, props: any): any;
|
|
6
|
+
export declare const createTable: () => Table<{
|
|
7
|
+
Renderer: typeof render;
|
|
8
|
+
Rendered: any;
|
|
9
|
+
}>;
|
|
10
|
+
declare type ReadableOrVal<T> = T | Readable<T>;
|
|
11
|
+
export declare function createTableInstance<TGenerics extends TableGenerics>(table: Table<TGenerics>, options: ReadableOrVal<PartialKeys<Omit<TableOptions<TGenerics>, 'render'>, 'state' | 'onStateChange'>>): Readable<import("@tanstack/table-core").TableInstance<TGenerics>>;
|
|
@@ -0,0 +1,249 @@
|
|
|
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
|
+
(function (global, factory) {
|
|
12
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tanstack/table-core'), require('svelte/internal'), require('svelte/store')) :
|
|
13
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tanstack/table-core', 'svelte/internal', 'svelte/store'], factory) :
|
|
14
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.SvelteTable = {}, global.TableCore, global.SvelteInternal, global.SvelteStore));
|
|
15
|
+
})(this, (function (exports, tableCore, internal, store) { 'use strict';
|
|
16
|
+
|
|
17
|
+
function _extends() {
|
|
18
|
+
_extends = Object.assign || function (target) {
|
|
19
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
20
|
+
var source = arguments[i];
|
|
21
|
+
|
|
22
|
+
for (var key in source) {
|
|
23
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
24
|
+
target[key] = source[key];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return target;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return _extends.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function _inheritsLoose(subClass, superClass) {
|
|
36
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
37
|
+
subClass.prototype.constructor = subClass;
|
|
38
|
+
|
|
39
|
+
_setPrototypeOf(subClass, superClass);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function _setPrototypeOf(o, p) {
|
|
43
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
44
|
+
o.__proto__ = p;
|
|
45
|
+
return o;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return _setPrototypeOf(o, p);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function _assertThisInitialized(self) {
|
|
52
|
+
if (self === void 0) {
|
|
53
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return self;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* packages/svelte-table/src/placeholder.svelte generated by Svelte v3.48.0 */
|
|
60
|
+
|
|
61
|
+
function create_fragment$1(ctx) {
|
|
62
|
+
let t;
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
c() {
|
|
66
|
+
t = internal.text(/*content*/ ctx[0]);
|
|
67
|
+
},
|
|
68
|
+
m(target, anchor) {
|
|
69
|
+
internal.insert(target, t, anchor);
|
|
70
|
+
},
|
|
71
|
+
p(ctx, [dirty]) {
|
|
72
|
+
if (dirty & /*content*/ 1) internal.set_data(t, /*content*/ ctx[0]);
|
|
73
|
+
},
|
|
74
|
+
i: internal.noop,
|
|
75
|
+
o: internal.noop,
|
|
76
|
+
d(detaching) {
|
|
77
|
+
if (detaching) internal.detach(t);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function instance($$self, $$props, $$invalidate) {
|
|
83
|
+
let { content } = $$props;
|
|
84
|
+
|
|
85
|
+
$$self.$$set = $$props => {
|
|
86
|
+
if ('content' in $$props) $$invalidate(0, content = $$props.content);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return [content];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
class Placeholder extends internal.SvelteComponent {
|
|
93
|
+
constructor(options) {
|
|
94
|
+
super();
|
|
95
|
+
internal.init(this, options, instance, create_fragment$1, internal.safe_not_equal, { content: 0 });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function create_fragment(ctx, Comp, props) {
|
|
100
|
+
var _c;
|
|
101
|
+
|
|
102
|
+
var current;
|
|
103
|
+
_c = new Comp({
|
|
104
|
+
props: props,
|
|
105
|
+
$$inline: true
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
c: function c() {
|
|
109
|
+
internal.create_component(_c.$$.fragment);
|
|
110
|
+
},
|
|
111
|
+
m: function m(target, anchor) {
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
internal.mount_component(_c, target, anchor);
|
|
114
|
+
current = true;
|
|
115
|
+
},
|
|
116
|
+
p: internal.noop,
|
|
117
|
+
i: function i(local) {
|
|
118
|
+
if (current) return;
|
|
119
|
+
internal.transition_in(_c.$$.fragment, local);
|
|
120
|
+
current = true;
|
|
121
|
+
},
|
|
122
|
+
o: function o(local) {
|
|
123
|
+
internal.transition_out(_c.$$.fragment, local);
|
|
124
|
+
current = false;
|
|
125
|
+
},
|
|
126
|
+
d: function d(detaching) {
|
|
127
|
+
internal.destroy_component(_c, detaching);
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function renderClient(Comp, props) {
|
|
133
|
+
return /*#__PURE__*/function (_SvelteComponent) {
|
|
134
|
+
_inheritsLoose(WrapperComp, _SvelteComponent);
|
|
135
|
+
|
|
136
|
+
function WrapperComp(options) {
|
|
137
|
+
var _this;
|
|
138
|
+
|
|
139
|
+
_this = _SvelteComponent.call(this) || this;
|
|
140
|
+
internal.init(_assertThisInitialized(_this), options, null, function (ctx) {
|
|
141
|
+
return create_fragment(ctx, Comp, props);
|
|
142
|
+
}, internal.safe_not_equal, {}, undefined);
|
|
143
|
+
return _this;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return WrapperComp;
|
|
147
|
+
}(internal.SvelteComponent);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function renderServer(Comp, props) {
|
|
151
|
+
var WrapperComp = internal.create_ssr_component(function ($$result, $$props, $$bindings, slots) {
|
|
152
|
+
return "" + internal.validate_component(Comp, 'Comp').$$render($$result, props, {}, {});
|
|
153
|
+
});
|
|
154
|
+
return WrapperComp;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
var renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
|
|
158
|
+
|
|
159
|
+
function render(Comp, props) {
|
|
160
|
+
if (!Comp) return null;
|
|
161
|
+
|
|
162
|
+
if (Comp instanceof Function) {
|
|
163
|
+
var res = Comp(props);
|
|
164
|
+
return res;
|
|
165
|
+
} else {
|
|
166
|
+
return renderComponent(Placeholder, {
|
|
167
|
+
content: Comp
|
|
168
|
+
});
|
|
169
|
+
} // return Comp
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
var createTable = tableCore.createTableFactory({
|
|
173
|
+
render: render
|
|
174
|
+
});
|
|
175
|
+
function createTableInstance(table, options) {
|
|
176
|
+
var optionsStore;
|
|
177
|
+
|
|
178
|
+
if ('subscribe' in options) {
|
|
179
|
+
optionsStore = options;
|
|
180
|
+
} else {
|
|
181
|
+
optionsStore = store.readable(options);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
var resolvedOptions = _extends({}, table.options, {
|
|
185
|
+
state: {},
|
|
186
|
+
// Dummy state
|
|
187
|
+
onStateChange: function onStateChange() {},
|
|
188
|
+
// noop
|
|
189
|
+
render: render
|
|
190
|
+
}, store.get(optionsStore));
|
|
191
|
+
|
|
192
|
+
var instance = tableCore.createTableInstance(resolvedOptions); // beforeUpdate(() => {
|
|
193
|
+
// instance.willUpdate()
|
|
194
|
+
// })
|
|
195
|
+
|
|
196
|
+
var stateStore = store.writable(
|
|
197
|
+
/** @type {number} */
|
|
198
|
+
instance.initialState); // combine stores
|
|
199
|
+
|
|
200
|
+
var stateOptionsStore = store.derived([stateStore, optionsStore], function (s) {
|
|
201
|
+
return s;
|
|
202
|
+
});
|
|
203
|
+
var instanceReadable = store.readable(instance, function start(set) {
|
|
204
|
+
var unsubscribe = stateOptionsStore.subscribe(function (_ref) {
|
|
205
|
+
var state = _ref[0],
|
|
206
|
+
options = _ref[1];
|
|
207
|
+
instance.setOptions(function (prev) {
|
|
208
|
+
return _extends({}, prev, options, {
|
|
209
|
+
state: _extends({}, state, options.state),
|
|
210
|
+
// Similarly, we'll maintain both our internal state and any user-provided
|
|
211
|
+
// state.
|
|
212
|
+
onStateChange: function onStateChange(updater) {
|
|
213
|
+
console.log('STATE CHANGE');
|
|
214
|
+
|
|
215
|
+
if (updater instanceof Function) {
|
|
216
|
+
stateStore.update(updater);
|
|
217
|
+
} else {
|
|
218
|
+
stateStore.set(updater);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
resolvedOptions.onStateChange == null ? void 0 : resolvedOptions.onStateChange(updater);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}); // it didn't seem to rerender without setting the instance
|
|
225
|
+
|
|
226
|
+
set(instance);
|
|
227
|
+
});
|
|
228
|
+
return function stop() {
|
|
229
|
+
unsubscribe();
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
return instanceReadable;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
exports.createTable = createTable;
|
|
236
|
+
exports.createTableInstance = createTableInstance;
|
|
237
|
+
exports.render = render;
|
|
238
|
+
exports.renderComponent = renderComponent;
|
|
239
|
+
Object.keys(tableCore).forEach(function (k) {
|
|
240
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
get: function () { return tableCore[k]; }
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
247
|
+
|
|
248
|
+
}));
|
|
249
|
+
//# sourceMappingURL=index.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.development.js","sources":["../../src/placeholder.svelte","../../src/render-component.ts","../../src/index.ts"],"sourcesContent":["<script>\nexport let content;\n</script>\n\n{content}","import {\n SvelteComponent,\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 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(Comp: any, props: any): any {\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 }\n}\n\nfunction renderServer(Comp: any, props: any) {\n const WrapperComp = create_ssr_component(\n ($$result: any, $$props: any, $$bindings: any, slots: any) => {\n return `${validate_component(Comp, 'Comp').$$render(\n $$result,\n props,\n {},\n {}\n )}`\n }\n )\n\n return WrapperComp\n}\n\nexport const renderComponent =\n typeof window === 'undefined' ? renderServer : renderClient\n","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\nexport function render(Comp: any, props: any) {\n if (!Comp) return null\n\n if (Comp instanceof Function) {\n let res = Comp(props)\n return res\n } else {\n return renderComponent(Placeholder, { content: Comp })\n }\n\n // return Comp\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 // beforeUpdate(() => {\n // instance.willUpdate()\n // })\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 console.log('STATE CHANGE')\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":["create_fragment","ctx","Comp","props","c","current","$$inline","create_component","$$","fragment","m","target","anchor","mount_component","p","noop","i","local","transition_in","o","transition_out","d","detaching","destroy_component","renderClient","options","init","safe_not_equal","undefined","SvelteComponent","renderServer","WrapperComp","create_ssr_component","$$result","$$props","$$bindings","slots","validate_component","$$render","renderComponent","window","render","Function","res","Placeholder","content","createTable","createTableFactory","createTableInstance","table","optionsStore","readable","resolvedOptions","state","onStateChange","get","instance","coreCreateTableInstance","stateStore","writable","initialState","stateOptionsStore","derived","s","instanceReadable","start","set","unsubscribe","subscribe","setOptions","prev","updater","console","log","update","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mCAIC,GAAO,CAAA,CAAA,CAAA,CAAA,CAAA;;;;;;iEAAP,GAAO,CAAA,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;SAHG,OAAO,EAAA,GAAA,OAAA,CAAA;;;;;;;;;;;;;;;;ECalB,SAASA,eAAT,CAAyBC,GAAzB,EAAmCC,IAAnC,EAA8CC,KAA9C,EAA0D;EACxD,EAAA,IAAIC,EAAJ,CAAA;;EACA,EAAA,IAAIC,OAAJ,CAAA;EACAD,EAAAA,EAAC,GAAG,IAAIF,IAAJ,CAAS;EAAEC,IAAAA,KAAK,EAALA,KAAF;EAASG,IAAAA,QAAQ,EAAE,IAAA;EAAnB,GAAT,CAAJ,CAAA;EAEA,EAAO,OAAA;EACLF,IAAAA,CADK,EACD,SAAA,CAAA,GAAA;EACFG,MAAAA,yBAAgB,CAACH,EAAC,CAACI,EAAF,CAAKC,QAAN,CAAhB,CAAA;EACD,KAHI;EAILC,IAAAA,CAJK,EAAA,SAAA,CAAA,CAIHC,MAJG,EAIUC,MAJV,EAIuB;EAC1B;EACAC,MAAAA,wBAAe,CAACT,EAAD,EAAIO,MAAJ,EAAYC,MAAZ,CAAf,CAAA;EACAP,MAAAA,OAAO,GAAG,IAAV,CAAA;EACD,KARI;EASLS,IAAAA,CAAC,EAAEC,aATE;EAULC,IAAAA,CAVK,EAUHC,SAAAA,CAAAA,CAAAA,KAVG,EAUS;EACZ,MAAA,IAAIZ,OAAJ,EAAa,OAAA;EACba,MAAAA,sBAAa,CAACd,EAAC,CAACI,EAAF,CAAKC,QAAN,EAAgBQ,KAAhB,CAAb,CAAA;EACAZ,MAAAA,OAAO,GAAG,IAAV,CAAA;EACD,KAdI;EAeLc,IAAAA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,aAFD,MAEO;EACLb,cAAAA,UAAU,CAACQ,GAAX,CAAeK,OAAf,CAAA,CAAA;EACD,aAAA;;EAEDnB,YAAAA,eAAe,CAACE,aAAhB,IAAA,IAAA,GAAA,KAAA,CAAA,GAAAF,eAAe,CAACE,aAAhB,CAAgCiB,OAAhC,CAAA,CAAA;EACD,WAAA;EAfH,SAAA,CAAA,CAAA;EAiBD,OAlBD,EADoE;;EAsBpEL,MAAAA,GAAG,CAACV,QAAD,CAAH,CAAA;EACD,KAvBmB,CAApB,CAAA;EAyBA,IAAO,OAAA,SAASmB,IAAT,GAAgB;EACrBR,MAAAA,WAAW,EAAA,CAAA;EACZ,KAFD,CAAA;EAGD,GA7BgC,CAAjC,CAAA;EA+BA,EAAA,OAAOH,gBAAP,CAAA;EACD;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/table-core"),require("svelte/internal"),require("svelte/store")):"function"==typeof define&&define.amd?define(["exports","@tanstack/table-core","svelte/internal","svelte/store"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).SvelteTable={},e.TableCore,e.SvelteInternal,e.SvelteStore)}(this,(function(e,t,n,o){"use strict";function r(){return r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r.apply(this,arguments)}function i(e,t){return i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},i(e,t)}function a(e){let t;return{c(){t=n.text(e[0])},m(e,o){n.insert(e,t,o)},p(e,[o]){1&o&&n.set_data(t,e[0])},i:n.noop,o:n.noop,d(e){e&&n.detach(t)}}}function c(e,t,n){let{content:o}=t;return e.$$set=e=>{"content"in e&&n(0,o=e.content)},[o]}class u extends n.SvelteComponent{constructor(e){super(),n.init(this,e,c,a,n.safe_not_equal,{content:0})}}var s="undefined"==typeof window?function(e,t){return n.create_ssr_component((function(o,r,i,a){return""+n.validate_component(e,"Comp").$$render(o,t,{},{})}))}:function(e,t){return function(o){var r,a;function c(r){var i;return i=o.call(this)||this,n.init(function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(i),r,null,(function(o){return function(e,t,o){var r,i;return r=new t({props:o,$$inline:!0}),{c:function(){n.create_component(r.$$.fragment)},m:function(e,t){n.mount_component(r,e,t),i=!0},p:n.noop,i:function(e){i||(n.transition_in(r.$$.fragment,e),i=!0)},o:function(e){n.transition_out(r.$$.fragment,e),i=!1},d:function(e){n.destroy_component(r,e)}}}(0,e,t)}),n.safe_not_equal,{},void 0),i}return a=o,(r=c).prototype=Object.create(a.prototype),r.prototype.constructor=r,i(r,a),c}(n.SvelteComponent)};function f(e,t){return e?e instanceof Function?e(t):s(u,{content:e}):null}var l=t.createTableFactory({render:f});e.createTable=l,e.createTableInstance=function(e,n){var i;i="subscribe"in n?n:o.readable(n);var a=r({},e.options,{state:{},onStateChange:function(){},render:f},o.get(i)),c=t.createTableInstance(a),u=o.writable(c.initialState),s=o.derived([u,i],(function(e){return e})),l=o.readable(c,(function(e){var t=s.subscribe((function(t){var n=t[0],o=t[1];c.setOptions((function(e){return r({},e,o,{state:r({},n,o.state),onStateChange:function(e){console.log("STATE CHANGE"),e instanceof Function?u.update(e):u.set(e),null==a.onStateChange||a.onStateChange(e)}})})),e(c)}));return function(){t()}}));return l},e.render=f,e.renderComponent=s,Object.keys(t).forEach((function(n){"default"===n||e.hasOwnProperty(n)||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})})),Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
12
|
+
//# sourceMappingURL=index.production.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.production.js","sources":["../../src/placeholder.svelte","../../src/render-component.ts","../../src/index.ts"],"sourcesContent":["<script>\nexport let content;\n</script>\n\n{content}","import {\n SvelteComponent,\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 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(Comp: any, props: any): any {\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 }\n}\n\nfunction renderServer(Comp: any, props: any) {\n const WrapperComp = create_ssr_component(\n ($$result: any, $$props: any, $$bindings: any, slots: any) => {\n return `${validate_component(Comp, 'Comp').$$render(\n $$result,\n props,\n {},\n {}\n )}`\n }\n )\n\n return WrapperComp\n}\n\nexport const renderComponent =\n typeof window === 'undefined' ? renderServer : renderClient\n","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\nexport function render(Comp: any, props: any) {\n if (!Comp) return null\n\n if (Comp instanceof Function) {\n let res = Comp(props)\n return res\n } else {\n return renderComponent(Placeholder, { content: Comp })\n }\n\n // return Comp\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 // beforeUpdate(() => {\n // instance.willUpdate()\n // })\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 console.log('STATE CHANGE')\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":["ctx","content","$$props","renderComponent","window","Comp","props","create_ssr_component","$$result","$$bindings","slots","validate_component","$$render","_SvelteComponent","WrapperComp","options","_this","call","this","init","c","current","$$inline","create_component","$$","fragment","m","target","anchor","mount_component","p","noop","i","local","transition_in","o","transition_out","d","detaching","destroy_component","create_fragment","safe_not_equal","undefined","SvelteComponent","render","Function","Placeholder","createTable","createTableFactory","table","optionsStore","readable","resolvedOptions","_extends","state","onStateChange","get","instance","coreCreateTableInstance","stateStore","writable","initialState","stateOptionsStore","derived","s","instanceReadable","set","unsubscribe","subscribe","_ref","setOptions","prev","updater","console","log","update"],"mappings":";;;;;;;;;;owBAICA,EAAO,wDAAPA,EAAO,2EAHGC,GAAOC,oKC2ELC,IAAAA,EACO,oBAAXC,OAhBT,SAAsBC,EAAWC,GAY/B,OAXoBC,EAAAA,sBAClB,SAACC,EAAeN,EAAcO,EAAiBC,GAC7C,MAAA,GAAUC,EAAAA,mBAAmBN,EAAM,QAAQO,SACzCJ,EACAF,EACA,GACA,QAxBR,SAAsBD,EAAWC,GAC/B,OAAA,SAAAO,WACE,SAAAC,EAAYC,GAAc,IAAAC,EAAA,OACxBA,EAAAH,EAAAI,KAAAC,OAAAA,KACAC,EAAIA,8HAEFJ,CAAAA,GAAAA,EACA,MACA,SAACf,GAAD,OAtCR,SAAyBA,EAAUK,EAAWC,GAC5C,IAAIc,EACAC,EAGG,OAFPD,EAAI,IAAIf,EAAK,CAAEC,MAAAA,EAAOgB,UAAU,IAEzB,CACLF,EAAI,WACFG,EAAAA,iBAAiBH,EAAEI,GAAGC,WAExBC,EAJK,SAIHC,EAAaC,GAEbC,EAAAA,gBAAgBT,EAAGO,EAAQC,GAC3BP,GAAU,GAEZS,EAAGC,EATEA,KAULC,EAAEC,SAAAA,GACIZ,IACJa,EAAAA,cAAcd,EAAEI,GAAGC,SAAUQ,GAC7BZ,GAAU,IAEZc,EAAEF,SAAAA,GACAG,EAAAA,eAAehB,EAAEI,GAAGC,SAAUQ,GAC9BZ,GAAU,GAEZgB,EAAEC,SAAAA,GACAC,oBAAkBnB,EAAGkB,KAaLE,CAAgBxC,EAAKK,EAAMC,KACzCmC,EALEA,eAMF,QACAC,GATsB1B,EAD5B,SAAAH,KAAAC,yEAAAA,EAAA,CAAiC6B,EAAjCA,kBC7BK,SAASC,EAAOvC,EAAWC,GAChC,OAAKD,EAEDA,aAAgBwC,SACRxC,EAAKC,GAGRH,EAAgB2C,EAAa,CAAE7C,QAASI,IAN/B,KAYP0C,IAAAA,EAAcC,EAAAA,mBAAmB,CAAEJ,OAAAA,0CAIzC,SACLK,EACAlC,GAOA,IAAImC,EAQFA,EADE,cAAenC,EACFA,EAEAoC,EAAAA,SAASpC,GAG1B,IAAIqC,EAAwCC,EAAA,GACvCJ,EAAMlC,QADiC,CAE1CuC,MAAO,GACPC,cAAe,aACfX,OAAAA,GACGY,EAAGA,IAACN,IAGLO,EAAWC,sBAAwBN,GAMnCO,EAAaC,EAAQA,SAAuBH,EAASI,cAErDC,EAAoBC,EAAAA,QAAQ,CAACJ,EAAYT,IAAe,SAAAc,GAAC,OAAIA,KAC3DC,EAAmBd,EAAQA,SAACM,GAAU,SAAeS,GACzD,IAAMC,EAAcL,EAAkBM,WAAU,SAAsBC,GAAA,IAApBf,EAAoBe,EAAA,GAAbtD,EAAasD,EAAA,GACpEZ,EAASa,YAAW,SAAAC,GAEbA,OAAAA,EAAAA,GAAAA,EACAxD,EAFL,CAGEuC,MAAYA,EAAAA,GAAAA,EAAUvC,EAAQuC,OAG9BC,cAAe,SAAAiB,GACbC,QAAQC,IAAI,gBACRF,aAAmB3B,SACrBc,EAAWgB,OAAOH,GAElBb,EAAWO,IAAIM,GAGjB,MAAApB,EAAgBG,eAAhBH,EAAgBG,cAAgBiB,SAMtCN,EAAIT,MAGC,OAAA,WACLU,QAIJ,OAAOF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tanstack/svelte-table",
|
|
3
|
+
"author": "Tanner Linsley",
|
|
4
|
+
"version": "8.0.0-alpha.67",
|
|
5
|
+
"description": "Composables for building lightweight, fast and extendable datagrids for Vue",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/tanstack/react-table#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/tanstack/react-table.git"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"svelte",
|
|
17
|
+
"table",
|
|
18
|
+
"svelte-table",
|
|
19
|
+
"datagrid"
|
|
20
|
+
],
|
|
21
|
+
"funding": {
|
|
22
|
+
"type": "github",
|
|
23
|
+
"url": "https://github.com/sponsors/tannerlinsley"
|
|
24
|
+
},
|
|
25
|
+
"module": "build/esm/index.js",
|
|
26
|
+
"main": "build/cjs/index.js",
|
|
27
|
+
"browser": "build/umd/index.production.min.js",
|
|
28
|
+
"types": "build/types/index.d.ts",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=12"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"build",
|
|
34
|
+
"src"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@tanstack/table-core": "8.0.0-alpha.67"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"svelte": "^3.48.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="svelte" />
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTableFactory,
|
|
3
|
+
createTableInstance as coreCreateTableInstance,
|
|
4
|
+
PartialKeys,
|
|
5
|
+
Table,
|
|
6
|
+
TableGenerics,
|
|
7
|
+
TableOptions,
|
|
8
|
+
} from '@tanstack/table-core'
|
|
9
|
+
import Placeholder from './placeholder.svelte'
|
|
10
|
+
import { readable, writable, derived, Readable, get } from 'svelte/store'
|
|
11
|
+
import { renderComponent } from './render-component'
|
|
12
|
+
|
|
13
|
+
export { renderComponent } from './render-component'
|
|
14
|
+
|
|
15
|
+
export * from '@tanstack/table-core'
|
|
16
|
+
|
|
17
|
+
export function render(Comp: any, props: any) {
|
|
18
|
+
if (!Comp) return null
|
|
19
|
+
|
|
20
|
+
if (Comp instanceof Function) {
|
|
21
|
+
let res = Comp(props)
|
|
22
|
+
return res
|
|
23
|
+
} else {
|
|
24
|
+
return renderComponent(Placeholder, { content: Comp })
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// return Comp
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const createTable = createTableFactory({ render })
|
|
31
|
+
|
|
32
|
+
type ReadableOrVal<T> = T | Readable<T>
|
|
33
|
+
|
|
34
|
+
export function createTableInstance<TGenerics extends TableGenerics>(
|
|
35
|
+
table: Table<TGenerics>,
|
|
36
|
+
options: ReadableOrVal<
|
|
37
|
+
PartialKeys<
|
|
38
|
+
Omit<TableOptions<TGenerics>, 'render'>,
|
|
39
|
+
'state' | 'onStateChange'
|
|
40
|
+
>
|
|
41
|
+
>
|
|
42
|
+
) {
|
|
43
|
+
let optionsStore: Readable<
|
|
44
|
+
PartialKeys<
|
|
45
|
+
Omit<TableOptions<TGenerics>, 'render'>,
|
|
46
|
+
'state' | 'onStateChange'
|
|
47
|
+
>
|
|
48
|
+
>
|
|
49
|
+
|
|
50
|
+
if ('subscribe' in options) {
|
|
51
|
+
optionsStore = options
|
|
52
|
+
} else {
|
|
53
|
+
optionsStore = readable(options)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let resolvedOptions: TableOptions<TGenerics> = {
|
|
57
|
+
...table.options,
|
|
58
|
+
state: {}, // Dummy state
|
|
59
|
+
onStateChange: () => {}, // noop
|
|
60
|
+
render,
|
|
61
|
+
...get(optionsStore),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let instance = coreCreateTableInstance(resolvedOptions)
|
|
65
|
+
|
|
66
|
+
// beforeUpdate(() => {
|
|
67
|
+
// instance.willUpdate()
|
|
68
|
+
// })
|
|
69
|
+
|
|
70
|
+
let stateStore = writable(/** @type {number} */ instance.initialState)
|
|
71
|
+
// combine stores
|
|
72
|
+
let stateOptionsStore = derived([stateStore, optionsStore], s => s)
|
|
73
|
+
const instanceReadable = readable(instance, function start(set) {
|
|
74
|
+
const unsubscribe = stateOptionsStore.subscribe(([state, options]) => {
|
|
75
|
+
instance.setOptions(prev => {
|
|
76
|
+
return {
|
|
77
|
+
...prev,
|
|
78
|
+
...options,
|
|
79
|
+
state: { ...state, ...options.state },
|
|
80
|
+
// Similarly, we'll maintain both our internal state and any user-provided
|
|
81
|
+
// state.
|
|
82
|
+
onStateChange: updater => {
|
|
83
|
+
console.log('STATE CHANGE')
|
|
84
|
+
if (updater instanceof Function) {
|
|
85
|
+
stateStore.update(updater)
|
|
86
|
+
} else {
|
|
87
|
+
stateStore.set(updater)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
resolvedOptions.onStateChange?.(updater)
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
// it didn't seem to rerender without setting the instance
|
|
96
|
+
set(instance)
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
return function stop() {
|
|
100
|
+
unsubscribe()
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
return instanceReadable
|
|
105
|
+
}
|