@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.
@@ -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,8 +2716,10 @@ const Headers = {
2714
2716
  }
2715
2717
  }),
2716
2718
  getLeftHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left], (allColumns, leafColumns, left) => {
2717
- leafColumns = leafColumns.filter(column => left == null ? void 0 : left.includes(column.id));
2718
- return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
2719
+ var _left$map$filter2;
2720
+
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 : [];
2722
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'left');
2719
2723
  }, {
2720
2724
  key: process.env.NODE_ENV === 'development' && 'getLeftHeaderGroups',
2721
2725
  debug: () => {
@@ -2725,8 +2729,10 @@ const Headers = {
2725
2729
  }
2726
2730
  }),
2727
2731
  getRightHeaderGroups: memo(() => [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right], (allColumns, leafColumns, right) => {
2728
- leafColumns = leafColumns.filter(column => right == null ? void 0 : right.includes(column.id));
2729
- return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
2732
+ var _right$map$filter2;
2733
+
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 : [];
2735
+ return buildHeaderGroups(allColumns, orderedLeafColumns, instance, 'right');
2730
2736
  }, {
2731
2737
  key: process.env.NODE_ENV === 'development' && 'getRightHeaderGroups',
2732
2738
  debug: () => {
@@ -4002,18 +4008,46 @@ function renderServer(Comp, props) {
4002
4008
 
4003
4009
  const renderComponent = typeof window === 'undefined' ? renderServer : renderClient;
4004
4010
 
4005
- function render(Comp, props) {
4006
- if (!Comp) return null;
4011
+ function isSvelteServerComponent(component) {
4012
+ return typeof component === 'object' && typeof component.$$render === 'function' && typeof component.render === 'function';
4013
+ }
4014
+
4015
+ function isSvelteClientComponent(component) {
4016
+ return component.prototype instanceof SvelteComponent;
4017
+ }
4007
4018
 
4008
- if (Comp instanceof Function) {
4009
- let res = Comp(props);
4010
- return res;
4019
+ function isSvelteComponent(component) {
4020
+ if (typeof document === 'undefined') {
4021
+ return isSvelteServerComponent(component);
4011
4022
  } else {
4012
- return renderComponent(Placeholder, {
4013
- content: Comp
4014
- });
4015
- } // 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
+ }
4016
4049
 
4050
+ return wrapInPlaceholder(component);
4017
4051
  }
4018
4052
  const createTable = createTableFactory({
4019
4053
  render