@ishibashi0112/spreadsheet-grid-core 0.39.0 → 0.40.0
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/controllers/clipboardController.cjs +2 -2
- package/dist/controllers/clipboardController.js +54 -47
- package/dist/controllers/keyboardController.cjs +1 -1
- package/dist/controllers/keyboardController.js +10 -4
- package/dist/engine/gridApi.cjs +1 -1
- package/dist/engine/gridApi.d.ts +6 -0
- package/dist/engine/gridApi.js +75 -56
- package/dist/engine/rowPipeline.cjs +1 -1
- package/dist/engine/rowPipeline.d.ts +11 -2
- package/dist/engine/rowPipeline.js +49 -37
- package/dist/engine/verticalLayout.cjs +1 -1
- package/dist/engine/verticalLayout.d.ts +4 -0
- package/dist/engine/verticalLayout.js +40 -28
- package/dist/logic/exportCsv.cjs +2 -2
- package/dist/logic/exportCsv.d.ts +4 -1
- package/dist/logic/exportCsv.js +16 -11
- package/dist/logic/exportData.cjs +1 -1
- package/dist/logic/exportData.d.ts +3 -1
- package/dist/logic/exportData.js +29 -13
- package/dist/logic/labelRows.cjs +1 -0
- package/dist/logic/labelRows.d.ts +45 -0
- package/dist/logic/labelRows.js +157 -0
- package/dist/logic/verticalGeometry.cjs +1 -1
- package/dist/logic/verticalGeometry.d.ts +5 -0
- package/dist/logic/verticalGeometry.js +39 -5
- package/dist/model/gridTypes.core.d.ts +34 -0
- package/dist/model/gridTypes.unbound.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=15e6,t=5e4,n=(e,t,n,r)=>e&&t&&n>0&&n<=r,r=1<<20,i=(e,t)=>({rowCount:e,rowTop:e=>e*t,rowsHeight:(e,n)=>(n-e+1)*t,totalBodyHeight:e*t,rowAtContentY:n=>Math.min(Math.max(Math.floor(n/t),0),Math.max(e-1,0)),cellHeight:()=>t,detailHeight:()=>0}),a=(e,t)=>{let n=t.filter(t=>t.height>0&&t.index>=0&&t.index<e.rowCount).sort((e,t)=>e.index-t.index),r=n.length,i=new Float64Array(r),a=new Float64Array(r+1);for(let e=0;e<r;e+=1)i[e]=n[e].index,a[e+1]=a[e]+n[e].height;let o=a[r],{rowCount:s}=e,c=e=>{let t=0,n=r;for(;t<n;){let r=t+n>>>1;i[r]<e?t=r+1:n=r}return t},l=t=>{let n=Math.min(Math.max(t,0),s);return(n===s?e.totalBodyHeight:e.rowTop(n))+a[c(n)]};return{rowCount:s,rowTop:l,rowsHeight:(e,t)=>l(t+1)-l(e),totalBodyHeight:e.totalBodyHeight+o,rowAtContentY:e=>{if(s<=0||e<=0)return 0;let t=0,n=s-1;for(;t<n;){let r=t+n+1>>>1;l(r)<=e?t=r:n=r-1}return t},cellHeight:t=>e.cellHeight(t),detailHeight:e=>{let t=c(e);return t<r&&i[t]===e?a[t+1]-a[t]:0}}},o=(e,t,n,r)=>{if(r<n)return null;let i=Math.max(e,n),a=Math.min(t,r);return i>a?null:{start:i,end:a}},
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=15e6,t=5e4,n=(e,t,n,r)=>e&&t&&n>0&&n<=r,r=1<<20,i=(e,t)=>({rowCount:e,rowTop:e=>e*t,rowsHeight:(e,n)=>(n-e+1)*t,totalBodyHeight:e*t,rowAtContentY:n=>Math.min(Math.max(Math.floor(n/t),0),Math.max(e-1,0)),cellHeight:()=>t,detailHeight:()=>0}),a=(e,t)=>{let n=t.filter(t=>t.height>0&&t.index>=0&&t.index<e.rowCount).sort((e,t)=>e.index-t.index),r=n.length,i=new Float64Array(r),a=new Float64Array(r+1);for(let e=0;e<r;e+=1)i[e]=n[e].index,a[e+1]=a[e]+n[e].height;let o=a[r],{rowCount:s}=e,c=e=>{let t=0,n=r;for(;t<n;){let r=t+n>>>1;i[r]<e?t=r+1:n=r}return t},l=t=>{let n=Math.min(Math.max(t,0),s);return(n===s?e.totalBodyHeight:e.rowTop(n))+a[c(n)]};return{rowCount:s,rowTop:l,rowsHeight:(e,t)=>l(t+1)-l(e),totalBodyHeight:e.totalBodyHeight+o,rowAtContentY:e=>{if(s<=0||e<=0)return 0;let t=0,n=s-1;for(;t<n;){let r=t+n+1>>>1;l(r)<=e?t=r:n=r-1}return t},cellHeight:t=>e.cellHeight(t),detailHeight:e=>{let t=c(e);return t<r&&i[t]===e?a[t+1]-a[t]:0}}},o=(e,t)=>{let{rowCount:n}=e,r=t.filter(e=>e.index>=0&&e.index<n&&e.height>=0).sort((e,t)=>e.index-t.index),i=r.length,a=new Float64Array(i),o=new Float64Array(i),s=new Float64Array(i+1);for(let t=0;t<i;t+=1)a[t]=r[t].index,o[t]=r[t].height,s[t+1]=s[t]+(r[t].height-e.cellHeight(r[t].index));let c=s[i],l=e=>{let t=0,n=i;for(;t<n;){let r=t+n>>>1;a[r]<e?t=r+1:n=r}return t},u=t=>{let r=Math.min(Math.max(t,0),n);return(r===n?e.totalBodyHeight:e.rowTop(r))+s[l(r)]};return{rowCount:n,rowTop:u,rowsHeight:(e,t)=>u(t+1)-u(e),totalBodyHeight:e.totalBodyHeight+c,rowAtContentY:e=>{if(n<=0||e<=0)return 0;let t=0,r=n-1;for(;t<r;){let n=t+r+1>>>1;u(n)<=e?t=n:r=n-1}return t},cellHeight:t=>{let n=l(t);return n<i&&a[n]===t?o[n]:e.cellHeight(t)},detailHeight:t=>e.detailHeight(t)}},s=(e,t,n,r)=>{if(r<n)return null;let i=Math.max(e,n),a=Math.min(t,r);return i>a?null:{start:i,end:a}},c=(e,t)=>e*t,l=(e,t)=>t===1?e:e/t,u=(e,t,n,r)=>{let i=t*(1-n);return r.rowAtContentY(e-i)},d=({rowCount:e,rowHeight:t,headerHeight:n,viewportHeight:i,scrollTop:a,overscan:o,maxBodyPx:s})=>{let c=e*t,l=Math.min(c,s),u=Math.max(n+c-i,0),d=Math.max(n+l-i,0),f=d>0&&c>l?u/d:1,p=Math.min(Math.max(a,0),d),m=p*f,h=Math.ceil(i/t)+1,g=Math.floor(m/t),_=Math.max(g-o,0),v=Math.min(g+h+o,e),y=f===1?0:Math.floor(_*t/r)*r,b=p-m+y,x=[],S=new Set;for(let e=_;e<v;e+=1)x.push({index:e,start:n+e*t-y}),S.add(e);return{physicalBodyHeight:l,logicalBodyHeight:c,scaleFactor:f,translateY:b,windowBaseOffsetPx:y,rows:x,rowIndexSet:S}},f=({headerHeight:e,viewportHeight:t,scrollTop:n,overscan:r},i)=>{let a=i.rowCount,o=i.totalBodyHeight,s=o,c=Math.max(e+o-t,0),l=Math.min(Math.max(n,0),c),u=i.rowAtContentY(l),d=i.rowAtContentY(l+t),f=Math.max(u-r,0),p=Math.min(d+r+1,a),m=[],h=new Set;for(let t=f;t<p;t+=1){let n={index:t,start:e+i.rowTop(t),size:i.cellHeight(t)},r=i.detailHeight(t);r>0&&(n.detailSize=r),m.push(n),h.add(t)}return{physicalBodyHeight:s,logicalBodyHeight:o,scaleFactor:1,translateY:0,windowBaseOffsetPx:0,rows:m,rowIndexSet:h}};exports.AUTO_HEIGHT_MAX_ROWS=t,exports.MAX_BODY_PX=e,exports.WINDOW_BASE_CHUNK_PX=r,exports.clientYToRowIndex=u,exports.clipRowRangeToWindow=s,exports.computeAutoHeightVerticalGeometry=f,exports.computeVerticalGeometry=d,exports.createDetailRowMetrics=a,exports.createRowHeightOverrideMetrics=o,exports.createUniformRowMetrics=i,exports.logicalToPhysicalScrollTop=l,exports.physicalToLogicalScrollTop=c,exports.shouldUseAutoHeight=n;
|
|
@@ -41,6 +41,11 @@ export type DetailRowExtra = {
|
|
|
41
41
|
height: number;
|
|
42
42
|
};
|
|
43
43
|
export declare const createDetailRowMetrics: (base: RowMetrics, extras: readonly DetailRowExtra[]) => RowMetrics;
|
|
44
|
+
export type RowHeightOverride = {
|
|
45
|
+
index: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
export declare const createRowHeightOverrideMetrics: (base: RowMetrics, overrides: readonly RowHeightOverride[]) => RowMetrics;
|
|
44
49
|
export declare const clipRowRangeToWindow: (selStartRow: number, selEndRow: number, windowFirstRow: number, windowLastRow: number) => {
|
|
45
50
|
start: number;
|
|
46
51
|
end: number;
|
|
@@ -41,17 +41,51 @@ var e = 15e6, t = 5e4, n = (e, t, n, r) => e && t && n > 0 && n <= r, r = 1 << 2
|
|
|
41
41
|
return t < r && i[t] === e ? a[t + 1] - a[t] : 0;
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
}, o = (e, t
|
|
44
|
+
}, o = (e, t) => {
|
|
45
|
+
let { rowCount: n } = e, r = t.filter((e) => e.index >= 0 && e.index < n && e.height >= 0).sort((e, t) => e.index - t.index), i = r.length, a = new Float64Array(i), o = new Float64Array(i), s = new Float64Array(i + 1);
|
|
46
|
+
for (let t = 0; t < i; t += 1) a[t] = r[t].index, o[t] = r[t].height, s[t + 1] = s[t] + (r[t].height - e.cellHeight(r[t].index));
|
|
47
|
+
let c = s[i], l = (e) => {
|
|
48
|
+
let t = 0, n = i;
|
|
49
|
+
for (; t < n;) {
|
|
50
|
+
let r = t + n >>> 1;
|
|
51
|
+
a[r] < e ? t = r + 1 : n = r;
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
}, u = (t) => {
|
|
55
|
+
let r = Math.min(Math.max(t, 0), n);
|
|
56
|
+
return (r === n ? e.totalBodyHeight : e.rowTop(r)) + s[l(r)];
|
|
57
|
+
};
|
|
58
|
+
return {
|
|
59
|
+
rowCount: n,
|
|
60
|
+
rowTop: u,
|
|
61
|
+
rowsHeight: (e, t) => u(t + 1) - u(e),
|
|
62
|
+
totalBodyHeight: e.totalBodyHeight + c,
|
|
63
|
+
rowAtContentY: (e) => {
|
|
64
|
+
if (n <= 0 || e <= 0) return 0;
|
|
65
|
+
let t = 0, r = n - 1;
|
|
66
|
+
for (; t < r;) {
|
|
67
|
+
let n = t + r + 1 >>> 1;
|
|
68
|
+
u(n) <= e ? t = n : r = n - 1;
|
|
69
|
+
}
|
|
70
|
+
return t;
|
|
71
|
+
},
|
|
72
|
+
cellHeight: (t) => {
|
|
73
|
+
let n = l(t);
|
|
74
|
+
return n < i && a[n] === t ? o[n] : e.cellHeight(t);
|
|
75
|
+
},
|
|
76
|
+
detailHeight: (t) => e.detailHeight(t)
|
|
77
|
+
};
|
|
78
|
+
}, s = (e, t, n, r) => {
|
|
45
79
|
if (r < n) return null;
|
|
46
80
|
let i = Math.max(e, n), a = Math.min(t, r);
|
|
47
81
|
return i > a ? null : {
|
|
48
82
|
start: i,
|
|
49
83
|
end: a
|
|
50
84
|
};
|
|
51
|
-
},
|
|
85
|
+
}, c = (e, t) => e * t, l = (e, t) => t === 1 ? e : e / t, u = (e, t, n, r) => {
|
|
52
86
|
let i = t * (1 - n);
|
|
53
87
|
return r.rowAtContentY(e - i);
|
|
54
|
-
},
|
|
88
|
+
}, d = ({ rowCount: e, rowHeight: t, headerHeight: n, viewportHeight: i, scrollTop: a, overscan: o, maxBodyPx: s }) => {
|
|
55
89
|
let c = e * t, l = Math.min(c, s), u = Math.max(n + c - i, 0), d = Math.max(n + l - i, 0), f = d > 0 && c > l ? u / d : 1, p = Math.min(Math.max(a, 0), d), m = p * f, h = Math.ceil(i / t) + 1, g = Math.floor(m / t), _ = Math.max(g - o, 0), v = Math.min(g + h + o, e), y = f === 1 ? 0 : Math.floor(_ * t / r) * r, b = p - m + y, x = [], S = /* @__PURE__ */ new Set();
|
|
56
90
|
for (let e = _; e < v; e += 1) x.push({
|
|
57
91
|
index: e,
|
|
@@ -66,7 +100,7 @@ var e = 15e6, t = 5e4, n = (e, t, n, r) => e && t && n > 0 && n <= r, r = 1 << 2
|
|
|
66
100
|
rows: x,
|
|
67
101
|
rowIndexSet: S
|
|
68
102
|
};
|
|
69
|
-
},
|
|
103
|
+
}, f = ({ headerHeight: e, viewportHeight: t, scrollTop: n, overscan: r }, i) => {
|
|
70
104
|
let a = i.rowCount, o = i.totalBodyHeight, s = o, c = Math.max(e + o - t, 0), l = Math.min(Math.max(n, 0), c), u = i.rowAtContentY(l), d = i.rowAtContentY(l + t), f = Math.max(u - r, 0), p = Math.min(d + r + 1, a), m = [], h = /* @__PURE__ */ new Set();
|
|
71
105
|
for (let t = f; t < p; t += 1) {
|
|
72
106
|
let n = {
|
|
@@ -87,4 +121,4 @@ var e = 15e6, t = 5e4, n = (e, t, n, r) => e && t && n > 0 && n <= r, r = 1 << 2
|
|
|
87
121
|
};
|
|
88
122
|
};
|
|
89
123
|
//#endregion
|
|
90
|
-
export { t as AUTO_HEIGHT_MAX_ROWS, e as MAX_BODY_PX, r as WINDOW_BASE_CHUNK_PX,
|
|
124
|
+
export { t as AUTO_HEIGHT_MAX_ROWS, e as MAX_BODY_PX, r as WINDOW_BASE_CHUNK_PX, u as clientYToRowIndex, s as clipRowRangeToWindow, f as computeAutoHeightVerticalGeometry, d as computeVerticalGeometry, a as createDetailRowMetrics, o as createRowHeightOverrideMetrics, i as createUniformRowMetrics, l as logicalToPhysicalScrollTop, c as physicalToLogicalScrollTop, n as shouldUseAutoHeight };
|
|
@@ -9,6 +9,7 @@ export type RowModel<T> = {
|
|
|
9
9
|
getSourceIndex: (viewIndex: number) => number;
|
|
10
10
|
getRowKey: (viewIndex: number) => GridRowKey;
|
|
11
11
|
getGroupRow?: (viewIndex: number) => GridGroupRow | undefined;
|
|
12
|
+
getLabelRow?: (viewIndex: number) => GridLabelRow<T> | undefined;
|
|
12
13
|
};
|
|
13
14
|
export type ServerSideQuery = {
|
|
14
15
|
globalText?: string;
|
|
@@ -253,6 +254,33 @@ export type DetailRowOptions<T, F extends GridFrameworkTypes = GridFrameworkType
|
|
|
253
254
|
showToggleColumn?: boolean;
|
|
254
255
|
className?: GridSlotProps<F>;
|
|
255
256
|
};
|
|
257
|
+
export type LabelRowSortMode = 'section' | 'follow' | 'hide';
|
|
258
|
+
export type GridLabelRow<T> = {
|
|
259
|
+
kind: 'label';
|
|
260
|
+
row: T;
|
|
261
|
+
sourceIndex: number;
|
|
262
|
+
label: string;
|
|
263
|
+
sectionRowCount: number | undefined;
|
|
264
|
+
};
|
|
265
|
+
export type LabelRowRenderContext<T> = {
|
|
266
|
+
row: T;
|
|
267
|
+
rowKey: GridRowKey;
|
|
268
|
+
rowIndex: number;
|
|
269
|
+
sourceRowIndex: number;
|
|
270
|
+
label: string;
|
|
271
|
+
sectionRowCount: number | undefined;
|
|
272
|
+
};
|
|
273
|
+
export type LabelRowOptions<T, F extends GridFrameworkTypes = GridFrameworkTypes> = {
|
|
274
|
+
isLabelRow: (row: T, sourceIndex: number) => boolean;
|
|
275
|
+
getLabel: (row: T) => string;
|
|
276
|
+
render?: (ctx: LabelRowRenderContext<T>) => F['node'];
|
|
277
|
+
height?: number | ((row: T) => number);
|
|
278
|
+
className?: GridSlotProps<F> | ((row: T) => GridSlotProps<F> | undefined);
|
|
279
|
+
sticky?: boolean;
|
|
280
|
+
sortMode?: LabelRowSortMode;
|
|
281
|
+
keepEmptySections?: boolean;
|
|
282
|
+
exportText?: (row: T) => string | ReadonlyArray<string | number | null | undefined>;
|
|
283
|
+
};
|
|
256
284
|
export type RowDragContext = {
|
|
257
285
|
rowKey: GridRowKey;
|
|
258
286
|
sourceRowIndex: number;
|
|
@@ -560,6 +588,8 @@ export type GridClassNames<F extends GridFrameworkTypes = GridFrameworkTypes> =
|
|
|
560
588
|
groupCell?: GridSlotProps<F>;
|
|
561
589
|
detailBand?: GridSlotProps<F>;
|
|
562
590
|
detailCard?: GridSlotProps<F>;
|
|
591
|
+
labelRow?: GridSlotProps<F>;
|
|
592
|
+
labelRowContent?: GridSlotProps<F>;
|
|
563
593
|
popover?: GridSlotProps<F>;
|
|
564
594
|
menuItem?: GridSlotProps<F>;
|
|
565
595
|
tooltip?: GridSlotProps<F>;
|
|
@@ -603,9 +633,11 @@ export type CsvExportOptions = {
|
|
|
603
633
|
includeHeaders?: boolean;
|
|
604
634
|
delimiter?: string;
|
|
605
635
|
bom?: boolean;
|
|
636
|
+
includeLabelRows?: boolean;
|
|
606
637
|
};
|
|
607
638
|
export type GridExportOptions = {
|
|
608
639
|
scope?: CsvExportScope;
|
|
640
|
+
includeLabelRows?: boolean;
|
|
609
641
|
};
|
|
610
642
|
export type GridExportCell = {
|
|
611
643
|
value: unknown;
|
|
@@ -617,6 +649,7 @@ export type GridExportData = {
|
|
|
617
649
|
title: string;
|
|
618
650
|
}[];
|
|
619
651
|
rows: GridExportCell[][];
|
|
652
|
+
rowKinds?: Array<'data' | 'label'>;
|
|
620
653
|
};
|
|
621
654
|
export type GridColumnState = {
|
|
622
655
|
key: string;
|
|
@@ -787,6 +820,7 @@ export type SpreadsheetGridProps<T, F extends GridFrameworkTypes = GridFramework
|
|
|
787
820
|
getRowClassName?: (row: T, rowIndex: number, ctx: RowStyleContext<T>) => GridSlotProps<F> | undefined;
|
|
788
821
|
detailRow?: DetailRowOptions<T, F>;
|
|
789
822
|
onExpandedDetailRowKeysChange?: (keys: GridRowKey[]) => void;
|
|
823
|
+
labelRow?: LabelRowOptions<T, F>;
|
|
790
824
|
enableRowDrag?: boolean;
|
|
791
825
|
isRowDraggable?: (row: T, ctx: RowDragContext) => boolean;
|
|
792
826
|
onRowMove?: (params: RowMoveParams<T>) => void;
|
|
@@ -6,6 +6,7 @@ export type UnboundGridTypes = {
|
|
|
6
6
|
};
|
|
7
7
|
export type CellRenderContext<T> = Core.CellRenderContext<T, UnboundGridTypes>;
|
|
8
8
|
export type DetailRowOptions<T> = Core.DetailRowOptions<T, UnboundGridTypes>;
|
|
9
|
+
export type LabelRowOptions<T> = Core.LabelRowOptions<T, UnboundGridTypes>;
|
|
9
10
|
export type CellStyleContext<T> = Core.CellStyleContext<T, UnboundGridTypes>;
|
|
10
11
|
export type HeaderRenderContext<T> = Core.HeaderRenderContext<T, UnboundGridTypes>;
|
|
11
12
|
export type CellValueFormatterParams<T> = Core.CellValueFormatterParams<T, UnboundGridTypes>;
|
package/package.json
CHANGED