@tanstack/svelte-table 8.0.0-alpha.74 → 8.0.0-alpha.78

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.
@@ -2669,7 +2669,7 @@ var drawChart = (function (exports) {
2669
2669
  </script>
2670
2670
  <script>
2671
2671
  /*<!--*/
2672
- const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"0ced-163"},{"name":"svelte-table/src","children":[{"uid":"0ced-165","name":"placeholder.svelte"},{"uid":"0ced-167","name":"render-component.ts"},{"uid":"0ced-169","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"0ced-163":{"renderedLength":139334,"gzipLength":23814,"brotliLength":0,"mainUid":"0ced-162"},"0ced-165":{"renderedLength":925,"gzipLength":444,"brotliLength":0,"mainUid":"0ced-164"},"0ced-167":{"renderedLength":1365,"gzipLength":519,"brotliLength":0,"mainUid":"0ced-166"},"0ced-169":{"renderedLength":1958,"gzipLength":709,"brotliLength":0,"mainUid":"0ced-168"}},"nodeMetas":{"0ced-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"0ced-163"},"imported":[],"importedBy":[{"uid":"0ced-168"}]},"0ced-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"0ced-165"},"imported":[{"uid":"0ced-171"}],"importedBy":[{"uid":"0ced-168"}]},"0ced-166":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"0ced-167"},"imported":[{"uid":"0ced-171"}],"importedBy":[{"uid":"0ced-168"}]},"0ced-168":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"0ced-169"},"imported":[{"uid":"0ced-162"},{"uid":"0ced-164"},{"uid":"0ced-170"},{"uid":"0ced-166"}],"importedBy":[],"isEntry":true},"0ced-170":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"0ced-168"}],"isExternal":true},"0ced-171":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"0ced-164"},{"uid":"0ced-166"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2672
+ const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"name":"packages","children":[{"name":"table-core/build/esm/index.js","uid":"e8ea-163"},{"name":"svelte-table/src","children":[{"uid":"e8ea-165","name":"placeholder.svelte"},{"uid":"e8ea-167","name":"render-component.ts"},{"uid":"e8ea-169","name":"index.ts"}]}]}]}],"isRoot":true},"nodeParts":{"e8ea-163":{"renderedLength":139811,"gzipLength":23896,"brotliLength":0,"mainUid":"e8ea-162"},"e8ea-165":{"renderedLength":925,"gzipLength":444,"brotliLength":0,"mainUid":"e8ea-164"},"e8ea-167":{"renderedLength":1365,"gzipLength":519,"brotliLength":0,"mainUid":"e8ea-166"},"e8ea-169":{"renderedLength":2729,"gzipLength":868,"brotliLength":0,"mainUid":"e8ea-168"}},"nodeMetas":{"e8ea-162":{"id":"/packages/table-core/build/esm/index.js","moduleParts":{"index.production.js":"e8ea-163"},"imported":[],"importedBy":[{"uid":"e8ea-168"}]},"e8ea-164":{"id":"/packages/svelte-table/src/placeholder.svelte","moduleParts":{"index.production.js":"e8ea-165"},"imported":[{"uid":"e8ea-170"}],"importedBy":[{"uid":"e8ea-168"}]},"e8ea-166":{"id":"/packages/svelte-table/src/render-component.ts","moduleParts":{"index.production.js":"e8ea-167"},"imported":[{"uid":"e8ea-170"}],"importedBy":[{"uid":"e8ea-168"}]},"e8ea-168":{"id":"/packages/svelte-table/src/index.ts","moduleParts":{"index.production.js":"e8ea-169"},"imported":[{"uid":"e8ea-162"},{"uid":"e8ea-164"},{"uid":"e8ea-170"},{"uid":"e8ea-171"},{"uid":"e8ea-166"}],"importedBy":[],"isEntry":true},"e8ea-170":{"id":"svelte/internal","moduleParts":{},"imported":[],"importedBy":[{"uid":"e8ea-168"},{"uid":"e8ea-164"},{"uid":"e8ea-166"}],"isExternal":true},"e8ea-171":{"id":"svelte/store","moduleParts":{},"imported":[],"importedBy":[{"uid":"e8ea-168"}],"isExternal":true}},"env":{"rollup":"2.70.2"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
2673
2673
 
2674
2674
  const run = () => {
2675
2675
  const width = window.innerWidth;
@@ -11,21 +11,21 @@
11
11
  "children": [
12
12
  {
13
13
  "name": "table-core/build/esm/index.js",
14
- "uid": "0ced-173"
14
+ "uid": "e8ea-173"
15
15
  },
16
16
  {
17
17
  "name": "svelte-table/src",
18
18
  "children": [
19
19
  {
20
- "uid": "0ced-175",
20
+ "uid": "e8ea-175",
21
21
  "name": "placeholder.svelte"
22
22
  },
23
23
  {
24
- "uid": "0ced-177",
24
+ "uid": "e8ea-177",
25
25
  "name": "render-component.ts"
26
26
  },
27
27
  {
28
- "uid": "0ced-179",
28
+ "uid": "e8ea-179",
29
29
  "name": "index.ts"
30
30
  }
31
31
  ]
@@ -38,119 +38,125 @@
38
38
  "isRoot": true
39
39
  },
40
40
  "nodeParts": {
41
- "0ced-173": {
42
- "renderedLength": 139334,
43
- "gzipLength": 23814,
41
+ "e8ea-173": {
42
+ "renderedLength": 139811,
43
+ "gzipLength": 23896,
44
44
  "brotliLength": 0,
45
- "mainUid": "0ced-172"
45
+ "mainUid": "e8ea-172"
46
46
  },
47
- "0ced-175": {
47
+ "e8ea-175": {
48
48
  "renderedLength": 925,
49
49
  "gzipLength": 444,
50
50
  "brotliLength": 0,
51
- "mainUid": "0ced-174"
51
+ "mainUid": "e8ea-174"
52
52
  },
53
- "0ced-177": {
53
+ "e8ea-177": {
54
54
  "renderedLength": 1365,
55
55
  "gzipLength": 519,
56
56
  "brotliLength": 0,
57
- "mainUid": "0ced-176"
57
+ "mainUid": "e8ea-176"
58
58
  },
59
- "0ced-179": {
60
- "renderedLength": 1958,
61
- "gzipLength": 709,
59
+ "e8ea-179": {
60
+ "renderedLength": 2729,
61
+ "gzipLength": 868,
62
62
  "brotliLength": 0,
63
- "mainUid": "0ced-178"
63
+ "mainUid": "e8ea-178"
64
64
  }
65
65
  },
66
66
  "nodeMetas": {
67
- "0ced-172": {
67
+ "e8ea-172": {
68
68
  "id": "/packages/table-core/build/esm/index.js",
69
69
  "moduleParts": {
70
- "index.production.js": "0ced-173"
70
+ "index.production.js": "e8ea-173"
71
71
  },
72
72
  "imported": [],
73
73
  "importedBy": [
74
74
  {
75
- "uid": "0ced-178"
75
+ "uid": "e8ea-178"
76
76
  }
77
77
  ]
78
78
  },
79
- "0ced-174": {
79
+ "e8ea-174": {
80
80
  "id": "/packages/svelte-table/src/placeholder.svelte",
81
81
  "moduleParts": {
82
- "index.production.js": "0ced-175"
82
+ "index.production.js": "e8ea-175"
83
83
  },
84
84
  "imported": [
85
85
  {
86
- "uid": "0ced-181"
86
+ "uid": "e8ea-180"
87
87
  }
88
88
  ],
89
89
  "importedBy": [
90
90
  {
91
- "uid": "0ced-178"
91
+ "uid": "e8ea-178"
92
92
  }
93
93
  ]
94
94
  },
95
- "0ced-176": {
95
+ "e8ea-176": {
96
96
  "id": "/packages/svelte-table/src/render-component.ts",
97
97
  "moduleParts": {
98
- "index.production.js": "0ced-177"
98
+ "index.production.js": "e8ea-177"
99
99
  },
100
100
  "imported": [
101
101
  {
102
- "uid": "0ced-181"
102
+ "uid": "e8ea-180"
103
103
  }
104
104
  ],
105
105
  "importedBy": [
106
106
  {
107
- "uid": "0ced-178"
107
+ "uid": "e8ea-178"
108
108
  }
109
109
  ]
110
110
  },
111
- "0ced-178": {
111
+ "e8ea-178": {
112
112
  "id": "/packages/svelte-table/src/index.ts",
113
113
  "moduleParts": {
114
- "index.production.js": "0ced-179"
114
+ "index.production.js": "e8ea-179"
115
115
  },
116
116
  "imported": [
117
117
  {
118
- "uid": "0ced-172"
118
+ "uid": "e8ea-172"
119
119
  },
120
120
  {
121
- "uid": "0ced-174"
121
+ "uid": "e8ea-174"
122
122
  },
123
123
  {
124
- "uid": "0ced-180"
124
+ "uid": "e8ea-180"
125
125
  },
126
126
  {
127
- "uid": "0ced-176"
127
+ "uid": "e8ea-181"
128
+ },
129
+ {
130
+ "uid": "e8ea-176"
128
131
  }
129
132
  ],
130
133
  "importedBy": [],
131
134
  "isEntry": true
132
135
  },
133
- "0ced-180": {
134
- "id": "svelte/store",
136
+ "e8ea-180": {
137
+ "id": "svelte/internal",
135
138
  "moduleParts": {},
136
139
  "imported": [],
137
140
  "importedBy": [
138
141
  {
139
- "uid": "0ced-178"
142
+ "uid": "e8ea-178"
143
+ },
144
+ {
145
+ "uid": "e8ea-174"
146
+ },
147
+ {
148
+ "uid": "e8ea-176"
140
149
  }
141
150
  ],
142
151
  "isExternal": true
143
152
  },
144
- "0ced-181": {
145
- "id": "svelte/internal",
153
+ "e8ea-181": {
154
+ "id": "svelte/store",
146
155
  "moduleParts": {},
147
156
  "imported": [],
148
157
  "importedBy": [
149
158
  {
150
- "uid": "0ced-174"
151
- },
152
- {
153
- "uid": "0ced-176"
159
+ "uid": "e8ea-178"
154
160
  }
155
161
  ],
156
162
  "isExternal": true
@@ -2,7 +2,7 @@ import { PartialKeys, Table, TableGenerics, TableOptions } from '@tanstack/table
2
2
  import { Readable } from 'svelte/store';
3
3
  export { renderComponent } from './render-component';
4
4
  export * from '@tanstack/table-core';
5
- export declare function render(Comp: any, props: any): any;
5
+ export declare function render(component: any, props: any): any;
6
6
  export declare const createTable: () => Table<{
7
7
  Renderer: typeof render;
8
8
  Rendered: any;
@@ -2684,8 +2684,10 @@
2684
2684
  },
2685
2685
  // Header Groups
2686
2686
  getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2687
- const leftColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2688
- const rightColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2687
+ var _left$map$filter, _right$map$filter;
2688
+
2689
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2690
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2689
2691
  const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2690
2692
  const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2691
2693
  return headerGroups;
@@ -2709,8 +2711,10 @@
2709
2711
  }
2710
2712
  }),
2711
2713
  getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2712
- leafColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2713
- return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
2714
+ var _left$map$filter2;
2715
+
2716
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2717
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2714
2718
  }, {
2715
2719
  key: 'getLeftHeaderGroups',
2716
2720
  debug: () => {
@@ -2720,8 +2724,10 @@
2720
2724
  }
2721
2725
  }),
2722
2726
  getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2723
- leafColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2724
- return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
2727
+ var _right$map$filter2;
2728
+
2729
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2730
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2725
2731
  }, {
2726
2732
  key: 'getRightHeaderGroups',
2727
2733
  debug: () => {
@@ -3997,18 +4003,46 @@
3997
4003
 
3998
4004
  const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
3999
4005
 
4000
- function render(Comp, props) {
4001
- if (!Comp) return null;
4006
+ function isSvelteServerComponent(component) {
4007
+ return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
4008
+ }
4009
+
4010
+ function isSvelteClientComponent(component) {
4011
+ return component.prototype instanceof internal.SvelteComponent;
4012
+ }
4002
4013
 
4003
- if (Comp instanceof Function) {
4004
- let res = Comp(props);
4005
- return res;
4014
+ function isSvelteComponent(component) {
4015
+ if (typeof document === 'undefined') {
4016
+ return isSvelteServerComponent(component);
4006
4017
  } else {
4007
- return renderComponent(Placeholder, {
4008
- content: Comp
4009
- });
4010
- } // return Comp
4018
+ return isSvelteClientComponent(component);
4019
+ }
4020
+ }
4021
+
4022
+ function wrapInPlaceholder(content) {
4023
+ return renderComponent(Placeholder, {
4024
+ content
4025
+ });
4026
+ }
4027
+
4028
+ function render(component, props) {
4029
+ if (!component) return null;
4030
+
4031
+ if (isSvelteComponent(component)) {
4032
+ return renderComponent(component, props);
4033
+ }
4034
+
4035
+ if (typeof component === 'function') {
4036
+ const result = component(props);
4037
+
4038
+ if (isSvelteComponent(result)) {
4039
+ return result;
4040
+ }
4041
+
4042
+ return wrapInPlaceholder(result);
4043
+ }
4011
4044
 
4045
+ return wrapInPlaceholder(component);
4012
4046
  }
4013
4047
  const createTable = createTableFactory({
4014
4048
  render