simple-table-core 2.6.3 → 2.6.6
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/dist/Animate-98c6e3ff.js +2 -0
- package/dist/Animate-98c6e3ff.js.map +1 -0
- package/dist/{DatePicker-f7a6a949.js → DatePicker-775f504e.js} +2 -2
- package/dist/DatePicker-775f504e.js.map +1 -0
- package/dist/cjs/Animate-07698e17.js +2 -0
- package/dist/cjs/Animate-07698e17.js.map +1 -0
- package/dist/cjs/{DatePicker-8be26322.js → DatePicker-d48eb4c4.js} +2 -2
- package/dist/cjs/DatePicker-d48eb4c4.js.map +1 -0
- package/dist/cjs/components/simple-table/RenderCells.d.ts +3 -1
- package/dist/cjs/components/simple-table/TableCell.d.ts +1 -1
- package/dist/cjs/components/simple-table/TableRow.d.ts +3 -1
- package/dist/cjs/components/simple-table/TableSection.d.ts +3 -0
- package/dist/cjs/context/TableContext.d.ts +8 -2
- package/dist/cjs/hooks/useKeyboardNavigation.d.ts +3 -3
- package/dist/cjs/index-709627ca.js +2 -0
- package/dist/cjs/index-709627ca.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/types/TableCellProps.d.ts +6 -0
- package/dist/cjs/utils/cellScrollUtils.d.ts +0 -6
- package/dist/cjs/utils/columnUtils.d.ts +13 -0
- package/dist/cjs/utils/columnVirtualizationUtils.d.ts +86 -0
- package/dist/components/simple-table/RenderCells.d.ts +3 -1
- package/dist/components/simple-table/TableCell.d.ts +1 -1
- package/dist/components/simple-table/TableRow.d.ts +3 -1
- package/dist/components/simple-table/TableSection.d.ts +3 -0
- package/dist/context/TableContext.d.ts +8 -2
- package/dist/hooks/useKeyboardNavigation.d.ts +3 -3
- package/dist/index-586682e1.js +2 -0
- package/dist/index-586682e1.js.map +1 -0
- package/dist/index.es.js +1 -1
- package/dist/types/TableCellProps.d.ts +6 -0
- package/dist/utils/cellScrollUtils.d.ts +0 -6
- package/dist/utils/columnUtils.d.ts +13 -0
- package/dist/utils/columnVirtualizationUtils.d.ts +86 -0
- package/package.json +1 -1
- package/dist/Animate-60695947.js +0 -2
- package/dist/Animate-60695947.js.map +0 -1
- package/dist/DatePicker-f7a6a949.js.map +0 -1
- package/dist/cjs/Animate-5abc33cc.js +0 -2
- package/dist/cjs/Animate-5abc33cc.js.map +0 -1
- package/dist/cjs/DatePicker-8be26322.js.map +0 -1
- package/dist/cjs/index-1fd4e5b3.js +0 -2
- package/dist/cjs/index-1fd4e5b3.js.map +0 -1
- package/dist/index-b46195cc.js +0 -2
- package/dist/index-b46195cc.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
package/dist/Animate-60695947.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{_ as n,u as i,a as t,c as o,b as e,A as a,d as r,f as l,R as d}from"./index-b46195cc.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,b=C.isResizing,x=C.isScrolling,R=C.rowHeight,j=f(null),A=f(null),B=t(x),w=t(b),_=s(function(){return o(R)},[R]);return v(function(){var n,i,t,o;if(g&&j.current&&!b){var u=j.current.getBoundingClientRect(),f=A.current;if(!x)if(!B||x)if(!w||b){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=e(e({},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=_*(R+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!==(o=null==M?void 0:M.position)&&void 0!==o?o:0,F=.6*R,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*R,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*R,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,_,b,x,c,B,w,R,null==M?void 0:M.position,M]),u("div",e({ref:j,"data-animate-id":h,id:h+""},Y,{children:p}))};m.displayName="Animate";export{m as Animate,m as default};
|
|
2
|
-
//# sourceMappingURL=Animate-60695947.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Animate-60695947.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker-f7a6a949.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";var n=require("./index-1fd4e5b3.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,b=null===(t=null==a?void 0:a.current)||void 0===t?void 0:t.scrollHeight;if(void 0!==x&&void 0!==q&&void 0!==b){var j=Y*(m+n.ROW_SEPARATOR_WIDTH),B=x-j,R=x+q+j,w=d.y>B&&R>d.y,A=r.y>B&&R>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-5abc33cc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Animate-5abc33cc.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker-8be26322.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|