@tanstack/svelte-table 8.0.0-alpha.76 → 8.0.0-alpha.79

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.
@@ -542,7 +542,7 @@ const ColumnSizing = {
542
542
  }
543
543
  }
544
544
 
545
- const startSize = column.getSize();
545
+ const startSize = header.getSize();
546
546
  const columnSizingStart = header ? header.getLeafHeaders().map(d => [d.column.id, d.column.getSize()]) : [[column.id, column.getSize()]];
547
547
  const clientX = isTouchStartEvent(e) ? Math.round(e.touches[0].clientX) : e.clientX;
548
548
 
@@ -2689,8 +2689,10 @@ const Headers = {
2689
2689
  },
2690
2690
  // Header Groups
2691
2691
  getHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right], (allColumns, leafColumns, left, right) => {
2692
- const leftColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2693
- const rightColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2692
+ var _left$map$filter, _right$map$filter;
2693
+
2694
+ const leftColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2695
+ const rightColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2694
2696
  const centerColumns = leafColumns.filter(column => !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id)));
2695
2697
  const headerGroups = buildHeaderGroups(allColumns, [...leftColumns, ...centerColumns, ...rightColumns], instance);
2696
2698
  return headerGroups;
@@ -2714,9 +2716,9 @@ const Headers = {
2714
2716
  }
2715
2717
  }),
2716
2718
  getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2717
- var _left$map$filter;
2719
+ var _left$map$filter2;
2718
2720
 
2719
- const orderedLeafColumns = (_left$map$filter = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter : [];
2721
+ const orderedLeafColumns = (_left$map$filter2 = left == null ? void 0 : left.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _left$map$filter2 : [];
2720
2722
  return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2721
2723
  }, {
2722
2724
  key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
@@ -2727,9 +2729,9 @@ const Headers = {
2727
2729
  }
2728
2730
  }),
2729
2731
  getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2730
- var _right$map$filter;
2732
+ var _right$map$filter2;
2731
2733
 
2732
- const orderedLeafColumns = (_right$map$filter = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter : [];
2734
+ const orderedLeafColumns = (_right$map$filter2 = right == null ? void 0 : right.map(columnId => leafColumns.find(d => d.id === columnId)).filter(Boolean)) != null ? _right$map$filter2 : [];
2733
2735
  return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2734
2736
  }, {
2735
2737
  key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
@@ -4006,18 +4008,46 @@ function renderServer(Comp, props) {
4006
4008
 
4007
4009
  const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
4008
4010
 
4009
- function render(Comp, props) {
4010
- if (!Comp) return null;
4011
+ function isSvelteServerComponent(component) {
4012
+ return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
4013
+ }
4011
4014
 
4012
- if (Comp instanceof Function) {
4013
- let res = Comp(props);
4014
- return res;
4015
+ function isSvelteClientComponent(component) {
4016
+ return component.prototype instanceof SvelteComponent;
4017
+ }
4018
+
4019
+ function isSvelteComponent(component) {
4020
+ if (typeof document === 'undefined') {
4021
+ return isSvelteServerComponent(component);
4015
4022
  } else {
4016
- return renderComponent(Placeholder, {
4017
- content: Comp
4018
- });
4019
- } // return Comp
4023
+ return isSvelteClientComponent(component);
4024
+ }
4025
+ }
4026
+
4027
+ function wrapInPlaceholder(content) {
4028
+ return renderComponent(Placeholder, {
4029
+ content
4030
+ });
4031
+ }
4032
+
4033
+ function render(component, props) {
4034
+ if (!component) return null;
4035
+
4036
+ if (isSvelteComponent(component)) {
4037
+ return renderComponent(component, props);
4038
+ }
4039
+
4040
+ if (typeof component === 'function') {
4041
+ const result = component(props);
4042
+
4043
+ if (isSvelteComponent(result)) {
4044
+ return result;
4045
+ }
4046
+
4047
+ return wrapInPlaceholder(result);
4048
+ }
4020
4049
 
4050
+ return wrapInPlaceholder(component);
4021
4051
  }
4022
4052
  const createTable = createTableFactory({
4023
4053
  render