simple-table-core 2.6.5 → 2.6.7

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.
Files changed (45) hide show
  1. package/dist/Animate-6dc785ab.js +2 -0
  2. package/dist/Animate-6dc785ab.js.map +1 -0
  3. package/dist/{DatePicker-e6470cae.js → DatePicker-f0d8a106.js} +2 -2
  4. package/dist/DatePicker-f0d8a106.js.map +1 -0
  5. package/dist/cjs/Animate-a380c5a3.js +2 -0
  6. package/dist/cjs/Animate-a380c5a3.js.map +1 -0
  7. package/dist/cjs/{DatePicker-1cf6e858.js → DatePicker-8df3046a.js} +2 -2
  8. package/dist/cjs/DatePicker-8df3046a.js.map +1 -0
  9. package/dist/cjs/components/simple-table/RenderCells.d.ts +3 -1
  10. package/dist/cjs/components/simple-table/TableCell.d.ts +1 -1
  11. package/dist/cjs/components/simple-table/TableRow.d.ts +3 -1
  12. package/dist/cjs/components/simple-table/TableSection.d.ts +3 -0
  13. package/dist/cjs/context/TableContext.d.ts +8 -2
  14. package/dist/cjs/hooks/resizeCoalescing.d.ts +18 -0
  15. package/dist/cjs/index-3314cbd8.js +2 -0
  16. package/dist/cjs/index-3314cbd8.js.map +1 -0
  17. package/dist/cjs/index.js +1 -1
  18. package/dist/cjs/types/TableCellProps.d.ts +6 -0
  19. package/dist/cjs/utils/cellScrollUtils.d.ts +0 -6
  20. package/dist/cjs/utils/columnUtils.d.ts +13 -0
  21. package/dist/cjs/utils/columnVirtualizationUtils.d.ts +86 -0
  22. package/dist/components/simple-table/RenderCells.d.ts +3 -1
  23. package/dist/components/simple-table/TableCell.d.ts +1 -1
  24. package/dist/components/simple-table/TableRow.d.ts +3 -1
  25. package/dist/components/simple-table/TableSection.d.ts +3 -0
  26. package/dist/context/TableContext.d.ts +8 -2
  27. package/dist/hooks/resizeCoalescing.d.ts +18 -0
  28. package/dist/index-0c9bc958.js +2 -0
  29. package/dist/index-0c9bc958.js.map +1 -0
  30. package/dist/index.es.js +1 -1
  31. package/dist/types/TableCellProps.d.ts +6 -0
  32. package/dist/utils/cellScrollUtils.d.ts +0 -6
  33. package/dist/utils/columnUtils.d.ts +13 -0
  34. package/dist/utils/columnVirtualizationUtils.d.ts +86 -0
  35. package/package.json +1 -1
  36. package/dist/Animate-b61353fd.js +0 -2
  37. package/dist/Animate-b61353fd.js.map +0 -1
  38. package/dist/DatePicker-e6470cae.js.map +0 -1
  39. package/dist/cjs/Animate-30972772.js +0 -2
  40. package/dist/cjs/Animate-30972772.js.map +0 -1
  41. package/dist/cjs/DatePicker-1cf6e858.js.map +0 -1
  42. package/dist/cjs/index-3774ef93.js +0 -2
  43. package/dist/cjs/index-3774ef93.js.map +0 -1
  44. package/dist/index-7f257ce7.js +0 -2
  45. package/dist/index-7f257ce7.js.map +0 -1
@@ -0,0 +1,86 @@
1
+ import HeaderObject, { Accessor } from "../types/HeaderObject";
2
+ import { Pinned } from "../types/Pinned";
3
+ /**
4
+ * Column virtualization for the horizontally-scrollable (main) section.
5
+ *
6
+ * This mirrors the row virtualization approach (cumulative position map + binary
7
+ * search + asymmetric overscan) but for columns. The algorithm is ported from the
8
+ * `main` branch's `columnVirtualizationUtils.ts`; the integration differs: instead of
9
+ * recomputing CSS grid offsets, v2 keeps the full `grid-template-columns` track list
10
+ * and places each rendered cell into its real track via `grid-column`, so the leaf
11
+ * order here must match the grid produced by `createGridTemplateColumns`. That is
12
+ * guaranteed by deriving the leaf list from the shared `flattenColumnsForGrid`.
13
+ */
14
+ /**
15
+ * Precomputed cumulative width data for O(1) column position lookups and
16
+ * O(log n) viewport calculations (analogous to CumulativeHeightMap for rows).
17
+ */
18
+ export interface CumulativeWidthMap {
19
+ /** Left pixel position of each leaf column (index i -> left of column i) */
20
+ columnLeftPositions: number[];
21
+ /** Total nominal width of all leaf columns combined */
22
+ totalWidth: number;
23
+ /** Ordered leaf headers, 1:1 with the section's grid tracks */
24
+ leafHeaders: HeaderObject[];
25
+ }
26
+ /**
27
+ * Resolve a header's column width to pixels for position math.
28
+ *
29
+ * Only fixed widths (number or "Npx") are exact. fr/%/minmax/auto layouts can't be
30
+ * resolved without measuring the DOM, so we fall back to the column's numeric
31
+ * minWidth or a sensible default. This only affects which columns are *selected* for
32
+ * the window (mitigated by overscan); placement stays correct because cells are
33
+ * positioned by their real grid track via `grid-column`.
34
+ */
35
+ export declare const getColumnWidthInPixels: (header: HeaderObject) => number;
36
+ /**
37
+ * Build a cumulative width map for a section's headers. The leaf order matches the
38
+ * grid tracks created by `createGridTemplateColumns` (both use `flattenColumnsForGrid`).
39
+ */
40
+ export declare const buildCumulativeWidthMap: ({ headers, collapsedHeaders, }: {
41
+ headers: HeaderObject[];
42
+ collapsedHeaders?: Set<string> | undefined;
43
+ }) => CumulativeWidthMap;
44
+ /**
45
+ * Find the leaf column index at a given horizontal scroll position using binary
46
+ * search. Returns the index of the column that contains (or is closest to) the
47
+ * position. Analogous to `findRowAtScrollPosition` for rows.
48
+ */
49
+ export declare const findColumnAtScrollPosition: (scrollLeft: number, widthMap: CumulativeWidthMap) => number;
50
+ /**
51
+ * Calculate the visible leaf columns for the viewport, with an overscan buffer.
52
+ * Returns the [startIndex, endIndex) range into the section's leaf array plus the
53
+ * leaf header objects in that range. Analogous to `getViewportCalculations` for rows.
54
+ */
55
+ export declare const getVisibleColumns: ({ scrollLeft, viewportWidth, bufferColumnCount, scrollDirection, widthMap, }: {
56
+ scrollLeft: number;
57
+ viewportWidth: number;
58
+ bufferColumnCount: number;
59
+ scrollDirection?: "left" | "right" | "none" | undefined;
60
+ widthMap: CumulativeWidthMap;
61
+ }) => {
62
+ startIndex: number;
63
+ endIndex: number;
64
+ columns: HeaderObject[];
65
+ };
66
+ /**
67
+ * Build the set of leaf accessors that should render for the current horizontal
68
+ * viewport, plus a map from accessor to its grid track index (0-based) so cells can
69
+ * be placed with `grid-column: <index + 1>`. Pinned sections never virtualize, so
70
+ * callers pass `null` to disable windowing.
71
+ */
72
+ export interface ColumnWindow {
73
+ /** Leaf accessors currently within the viewport (+overscan) */
74
+ visibleAccessors: Set<Accessor>;
75
+ /** Leaf accessor -> 0-based grid track index within the section */
76
+ trackIndexByAccessor: Map<Accessor, number>;
77
+ }
78
+ export declare const buildColumnWindow: ({ headers, collapsedHeaders, scrollLeft, viewportWidth, bufferColumnCount, scrollDirection, pinned, }: {
79
+ headers: HeaderObject[];
80
+ collapsedHeaders?: Set<string> | undefined;
81
+ scrollLeft: number;
82
+ viewportWidth: number;
83
+ bufferColumnCount: number;
84
+ scrollDirection?: "left" | "right" | "none" | undefined;
85
+ pinned?: Pinned | undefined;
86
+ }) => ColumnWindow | null;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.6.5",
2
+ "version": "2.6.7",
3
3
  "main": "dist/cjs/index.js",
4
4
  "module": "dist/index.es.js",
5
5
  "types": "dist/index.d.ts",
@@ -1,2 +0,0 @@
1
- import{_ as n,u as i,a as t,c as e,b as o,A as a,d as r,f as l,R as d}from"./index-7f257ce7.js";import{jsx as u}from"react/jsx-runtime";import{useRef as f,useMemo as s,useLayoutEffect as v}from"react";var m=function(m){var p=m.children,h=m.id,c=m.parentRef,M=m.tableRow,Y=n(m,["children","id","parentRef","tableRow"]),C=i(),g=C.allowAnimations,x=C.isResizing,R=C.isScrolling,b=C.rowHeight,j=f(null),A=f(null),B=t(R),w=t(x),_=s(function(){return e(b)},[b]);return v(function(){var n,i,t,e;if(g&&j.current&&!x){var u=j.current.getBoundingClientRect(),f=A.current;if(!R)if(!B||R)if(!w||x){if(A.current=u,f){var s=u.x-f.x,v=u.y-f.y;if((Math.abs(s)>=50||Math.abs(v)>5)&&(Math.abs(s)>5||Math.abs(v)>5)){var m=o(o({},a.ROW_REORDER),{onComplete:function(){j.current&&(j.current.style.zIndex="",j.current.style.position="",j.current.style.top="")}}),p=null===(n=null==c?void 0:c.current)||void 0===n?void 0:n.scrollTop,h=null===(i=null==c?void 0:c.current)||void 0===i?void 0:i.clientHeight,Y=null===(t=null==c?void 0:c.current)||void 0===t?void 0:t.scrollHeight;if(void 0!==p&&void 0!==h&&void 0!==Y){var C=_*(b+d),k=p-C,q=p+h+C,y=f.y>k&&q>f.y,z=u.y>k&&q>u.y,D=p>u.y,E=null!==(e=null==M?void 0:M.position)&&void 0!==e?e:0,F=.6*b,G=function(n,i,t){return Math.min(900,Math.max(100,100+80*Math.log10(Math.max(1,Math.min(Math.abs(n-i),Math.abs(n-t))))))};if(y&&!z&&u.y>p+h){var H=G(u.y,p,p+h);return void r({element:j.current,options:{startY:f.y,endY:p+h+H+E%15*F*2.5+E%7*.4*b,finalY:u.y,duration:m.duration,easing:m.easing,onComplete:m.onComplete}})}if(y&&!z&&D)return H=G(u.y,p,p+h),void r({element:j.current,options:{startY:f.y,endY:p-H-E%15*F*2.5-E%7*.4*b,finalY:u.y,duration:m.duration,easing:m.easing,onComplete:m.onComplete}});if(!y&&z&&f.y>p+h)return H=G(f.y,p,p+h),void r({element:j.current,options:{startY:p+h+H+E%10*F*1,endY:u.y,duration:m.duration,easing:m.easing,onComplete:m.onComplete}});if(!y&&z&&p>f.y)return H=G(f.y,p,p+h),void r({element:j.current,options:{startY:p-H-E%10*F*1,endY:u.y,duration:m.duration,easing:m.easing,onComplete:m.onComplete}})}l({element:j.current,fromBounds:f,toBounds:u,finalConfig:m})}}}else A.current=u;else A.current=u}},[g,_,x,R,c,B,w,b,null==M?void 0:M.position,M]),u("div",o({ref:j,"data-animate-id":h,id:h+""},Y,{children:p}))};m.displayName="Animate";export{m as Animate,m as default};
2
- //# sourceMappingURL=Animate-b61353fd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Animate-b61353fd.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePicker-e6470cae.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- "use strict";var n=require("./index-3774ef93.js"),e=require("react/jsx-runtime"),i=require("react"),t=function(t){var o=t.children,r=t.id,a=t.parentRef,l=t.tableRow,d=n.__rest(t,["children","id","parentRef","tableRow"]),u=n.useTableContext(),v=u.allowAnimations,f=u.isResizing,s=u.isScrolling,m=u.rowHeight,h=i.useRef(null),p=i.useRef(null),M=n.usePrevious(s),c=n.usePrevious(f),Y=i.useMemo(function(){return n.calculateBufferRowCount(m)},[m]);return i.useLayoutEffect(function(){var e,i,t,o;if(v&&h.current&&!f){var r=h.current.getBoundingClientRect(),d=p.current;if(!s)if(!M||s)if(!c||f){if(p.current=r,d){var u=r.x-d.x,C=r.y-d.y;if((Math.abs(u)>=50||Math.abs(C)>5)&&(Math.abs(u)>5||Math.abs(C)>5)){var g=n.__assign(n.__assign({},n.ANIMATION_CONFIGS.ROW_REORDER),{onComplete:function(){h.current&&(h.current.style.zIndex="",h.current.style.position="",h.current.style.top="")}}),x=null===(e=null==a?void 0:a.current)||void 0===e?void 0:e.scrollTop,q=null===(i=null==a?void 0:a.current)||void 0===i?void 0:i.clientHeight,j=null===(t=null==a?void 0:a.current)||void 0===t?void 0:t.scrollHeight;if(void 0!==x&&void 0!==q&&void 0!==j){var B=Y*(m+n.ROW_SEPARATOR_WIDTH),R=x-B,b=x+q+B,w=d.y>R&&b>d.y,A=r.y>R&&b>r.y,k=x>r.y,y=null!==(o=null==l?void 0:l.position)&&void 0!==o?o:0,z=.6*m,D=function(n,e,i){return Math.min(900,Math.max(100,100+80*Math.log10(Math.max(1,Math.min(Math.abs(n-e),Math.abs(n-i))))))};if(w&&!A&&r.y>x+q){var E=D(r.y,x,x+q);return void n.animateWithCustomCoordinates({element:h.current,options:{startY:d.y,endY:x+q+E+y%15*z*2.5+y%7*.4*m,finalY:r.y,duration:g.duration,easing:g.easing,onComplete:g.onComplete}})}if(w&&!A&&k)return E=D(r.y,x,x+q),void n.animateWithCustomCoordinates({element:h.current,options:{startY:d.y,endY:x-E-y%15*z*2.5-y%7*.4*m,finalY:r.y,duration:g.duration,easing:g.easing,onComplete:g.onComplete}});if(!w&&A&&d.y>x+q)return E=D(d.y,x,x+q),void n.animateWithCustomCoordinates({element:h.current,options:{startY:x+q+E+y%10*z*1,endY:r.y,duration:g.duration,easing:g.easing,onComplete:g.onComplete}});if(!w&&A&&x>d.y)return E=D(d.y,x,x+q),void n.animateWithCustomCoordinates({element:h.current,options:{startY:x-E-y%10*z*1,endY:r.y,duration:g.duration,easing:g.easing,onComplete:g.onComplete}})}n.flipElement({element:h.current,fromBounds:d,toBounds:r,finalConfig:g})}}}else p.current=r;else p.current=r}},[v,Y,f,s,a,M,c,m,null==l?void 0:l.position,l]),e.jsx("div",n.__assign({ref:h,"data-animate-id":r,id:r+""},d,{children:o}))};t.displayName="Animate",exports.Animate=t,exports.default=t;
2
- //# sourceMappingURL=Animate-30972772.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Animate-30972772.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"DatePicker-1cf6e858.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}