wimui 0.46.0 → 0.47.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/components/data-display/PivotTable/PivotTable.cjs +1 -1
- package/dist/components/data-display/PivotTable/PivotTable.d.ts +40 -17
- package/dist/components/data-display/PivotTable/PivotTable.js +178 -152
- package/dist/components/data-display/PivotTable/layoutPivot.cjs +1 -1
- package/dist/components/data-display/PivotTable/layoutPivot.d.ts +5 -0
- package/dist/components/data-display/PivotTable/layoutPivot.js +48 -26
- package/dist/components/data-display/PivotTable/pivot-table.module.cjs +1 -1
- package/dist/components/data-display/PivotTable/pivot-table.module.js +13 -11
- package/dist/llms-full.txt +12 -6
- package/dist/llms.txt +1 -1
- package/dist/styles.css +1 -1
- package/dist/wimui.umd.css +1 -1
- package/dist/wimui.umd.js +5 -5
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../../../icon/chevron-right.cjs"),i=require("../../media/Icon/Icon.cjs"),a=require("../../../hooks/useMergedRef.cjs"),o=require("../Table/Table.cjs"),s=require("./layoutPivot.cjs"),c=require("./pivot-table.module.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("classnames");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f=40,ee=8,te=30,p=(e,t=[])=>{for(let n of e)n.children?.length&&(t.push(n.key),
|
|
2
|
+
const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../layout/VisuallyHidden/VisuallyHidden.cjs"),r=require("../../../icon/chevron-right.cjs"),i=require("../../media/Icon/Icon.cjs"),a=require("../../../hooks/useMergedRef.cjs"),o=require("../Table/Table.cjs"),s=require("./layoutPivot.cjs"),c=require("./pivot-table.module.cjs");let l=require("react");l=e.__toESM(l,1);let u=require("classnames");u=e.__toESM(u,1);let d=require("react/jsx-runtime");var f=40,ee=8,te=30,p=`corner`,m=(e,t=[])=>{for(let n of e)n.children?.length&&(t.push(n.key),m(n.children,t));return t},ne=(e,t,n,r)=>{let[i,a]=(0,l.useState)(()=>n??m(e)),o=t??i,s=(0,l.useMemo)(()=>new Set(o),[o]);return[s,(0,l.useCallback)(e=>{let n=s.has(e)?o.filter(t=>t!==e):[...o,e];t===void 0&&a(n),r?.(n)},[o,s,t,r])]},h=l.default.forwardRef(({rows:e,columns:h,getValue:g,rowAxisLabel:_,caption:v,expandedRowValues:re,defaultExpandedRowValues:ie,onExpandedRowChange:ae,expandedColumnValues:oe,defaultExpandedColumnValues:se,onExpandedColumnChange:ce,maxHeight:y,stickyHeader:b=!1,stickyRowHeaders:le=!1,virtualized:x=!1,columnSubtotals:S=!1,totalRow:C=!1,totalColumn:ue=!1,labels:de,className:fe,...w},pe)=>{let{t:me}=t.useWimTranslation(`components`),T=l.default.useId(),E=de?.total??me(`pivottable.total`),[D,he]=ne(e,re,ie,ae),[O,ge]=ne(h,oe,se,ce),k=(0,l.useMemo)(()=>s.layoutPivotColumns(h,{subtotals:S,total:ue,isExpanded:e=>O.has(e)}),[h,S,ue,O]),A=(0,l.useMemo)(()=>s.layoutPivotRows(e,e=>D.has(e)),[e,D]),j=(0,l.useMemo)(()=>m(e).length>0,[e]),M=(0,l.useMemo)(()=>m(h).length>0,[h]),N=_!=null&&_!==!1,P=`${T}corner`,_e=e=>`${T}c${e}`,F=e=>`${T}r${e}`,I=`${T}total`,L=(0,l.useMemo)(()=>k.columns.map(e=>e.headerIds.map(e=>`${T}c${e}`).join(` `)),[k,T]),R=l.default.useRef(null),z=l.default.useRef(null),[B,ve]=l.default.useState(!1),[ye,be]=l.default.useState(!0);l.default.useLayoutEffect(()=>{let e=R.current,t=z.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=()=>{ve(e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight);let n=t.rows[0]?.cells[0];be(!n||n.offsetWidth<=e.clientWidth/2)};n();let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[]);let xe=a.useMergedRef(pe,z),V=le&&ye,H=l.default.useRef([]),[Se,Ce]=(0,l.useState)([]),U=k.depth;l.default.useLayoutEffect(()=>{if(!b)return;let e=H.current.slice(0,U),t=()=>{let t=0,n=e.map(e=>{let n=t;return t+=e?.getBoundingClientRect().height??0,n});Ce(e=>e.length===n.length&&e.every((e,t)=>e===n[t])?e:n)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return e.forEach(e=>e&&n.observe(e)),()=>n.disconnect()},[b,U]);let W=l.default.useRef(null),[G,we]=(0,l.useState)(0),[K,Te]=(0,l.useState)(null),[q,Ee]=(0,l.useState)(null),[De,Oe]=(0,l.useState)({}),J=l.default.useRef(0),Y=(0,l.useCallback)(()=>{let e=R.current,t=W.current,n=z.current;if(!e||!t||!n)return;let r=t.querySelector(`tr[data-row-index]`)?.getBoundingClientRect().height??0;r>0&&we(e=>Math.abs(e-r)<.01?e:r);let i={scrollTop:e.scrollTop,height:e.clientHeight,bodyOffset:t.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop};Te(e=>e&&e.scrollTop===i.scrollTop&&e.height===i.height&&e.bodyOffset===i.bodyOffset?e:i);let a=Array.from(n.querySelectorAll(`thead [data-column-key]`)).map(e=>[e.dataset.columnKey,e.getBoundingClientRect().width]),o=J.current!==e.clientWidth;J.current=e.clientWidth,Oe(e=>{let t=o?{}:{...e};for(let[e,n]of a)(n||0)>(t[e]??0)+.01&&(t[e]=n);let n=Object.keys(t);return n.length===Object.keys(e).length&&n.every(n=>t[n]===e[n])?e:t})},[]),X=A.length,ke=k.columns.length,Z=(0,l.useMemo)(()=>k.columns.map(e=>`${e.kind}:${e.key??``}`),[k]),Ae=Z.join(`|`);l.default.useLayoutEffect(()=>{if(!x||(Y(),typeof ResizeObserver>`u`))return;let e=new ResizeObserver(Y);return R.current&&e.observe(R.current),()=>e.disconnect()},[x,Y,X,Ae]);let je=(0,l.useMemo)(()=>new Map(A.map((e,t)=>[e.key,t])),[A]),Me=(0,l.useMemo)(()=>x?K?s.pivotRowWindow({rowCount:X,rowHeight:G||f,scrollTop:K.scrollTop,viewportHeight:K.height,bodyOffset:K.bodyOffset,overscan:ee,keep:q===null?null:je.get(q)??null}):s.pivotRowWindow({rowCount:X,rowHeight:f,scrollTop:0,viewportHeight:Math.min(X,te)*f,bodyOffset:0,overscan:0}):null,[x,K,X,G,q,je]),Ne=(0,l.useMemo)(()=>new Map(k.columns.map((e,t)=>[e.headerIds[e.headerIds.length-1],Z[t]])),[k,Z]),Q=e=>x&&e!==void 0?{"data-column-key":e,style:De[e]?{minWidth:De[e]}:void 0}:null,$=(e,t=!1)=>b?{top:Math.floor(Se[e]??0),zIndex:10+U-e+ +!!t}:void 0,Pe=`${T}caption`,Fe=v?{"aria-labelledby":Pe}:w[`aria-label`]?{"aria-label":w[`aria-label`]}:w[`aria-labelledby`]?{"aria-labelledby":w[`aria-labelledby`]}:null,Ie=(e,t)=>{let a=x?F(t):[...e.ancestors.map(F),F(t)].join(` `),s=[...N?[P]:[],...x?[]:e.ancestors.map(F)].join(` `);return(0,d.jsxs)(o.Table.Row,{className:(0,u.default)(e.hasChildren&&c.default.groupRow),"data-row-index":x?t:void 0,"data-row-key":x?e.key:void 0,"aria-rowindex":x?U+t+1:void 0,children:[(0,d.jsxs)(`th`,{id:F(t),scope:`row`,headers:s||void 0,className:(0,u.default)(c.default.rowHeader,V&&c.default.stickyLeft),style:{"--wim-pivot-table-depth":e.depth},children:[x&&e.ancestors.length>0&&(0,d.jsx)(n.VisuallyHidden,{children:e.ancestors.map(e=>(0,d.jsxs)(l.default.Fragment,{children:[A[e].node.label,`, `]},e))}),e.hasChildren?(0,d.jsxs)(`button`,{type:`button`,className:c.default.toggle,"aria-expanded":e.expanded,onClick:()=>he(e.key),children:[(0,d.jsx)(`span`,{className:(0,u.default)(c.default.chevron,e.expanded&&c.default.open),"aria-hidden":`true`,children:(0,d.jsx)(i.Icon,{component:r.default,size:`sm`})}),e.node.label]}):(0,d.jsx)(`span`,{className:(0,u.default)(j&&c.default.leafLabel),children:e.node.label})]}),k.columns.map((t,n)=>(0,d.jsx)(o.Table.Cell,{headers:`${a} ${L[n]}`,className:(0,u.default)(c.default.value,t.kind!==`leaf`&&c.default.aggregate,t.startsGroup&&!(V&&n===0)&&c.default.groupStart),children:g(e.key,t.key)},n))]},e.key)};return(0,d.jsx)(`div`,{ref:R,className:c.default.scroller,style:y===void 0?void 0:{maxHeight:y},tabIndex:B?0:void 0,onScroll:x?Y:void 0,...B&&Fe?{role:`region`,...Fe}:null,children:(0,d.jsxs)(`table`,{ref:xe,className:(0,u.default)(`wim-pivot-table`,c.default.root,fe),"aria-rowcount":x?U+X+ +!!C:void 0,...w,children:[v&&(0,d.jsx)(`caption`,{id:Pe,className:c.default.caption,children:v}),(0,d.jsx)(`colgroup`,{}),k.groupSpans.map((e,t)=>(0,d.jsx)(`colgroup`,{span:e},t)),(0,d.jsx)(o.Table.Header,{children:k.headerRows.map((e,t)=>(0,d.jsxs)(`tr`,{"aria-rowindex":x?t+1:void 0,ref:e=>{H.current[t]=e},children:[t===0&&(N?(0,d.jsx)(`th`,{id:P,scope:`col`,rowSpan:k.depth,className:(0,u.default)(c.default.columnHeader,c.default.corner,c.default.bottom,b&&c.default.stickyTop,V&&c.default.stickyLeft),...Q(p),style:{...$(0,!0),...Q(p)?.style},children:(0,d.jsx)(`span`,{className:(0,u.default)(M&&c.default.columnLeafLabel),children:_})}):(0,d.jsx)(`td`,{rowSpan:k.depth,className:(0,u.default)(c.default.columnHeader,c.default.bottom,b&&c.default.stickyTop,V&&c.default.stickyLeft),...Q(p),style:{...$(0,!0),...Q(p)?.style}})),e.map((e,n)=>(0,d.jsx)(`th`,{id:_e(e.id),scope:e.kind===`group`&&e.topLevel?`colgroup`:`col`,colSpan:e.colSpan>1?e.colSpan:void 0,rowSpan:e.rowSpan>1?e.rowSpan:void 0,className:(0,u.default)(c.default.columnHeader,e.kind===`group`&&e.expanded&&c.default.group,e.reachesBottom&&c.default.bottom,e.startsGroup&&!(V&&n===0)&&c.default.groupStart,b&&c.default.stickyTop),...e.reachesBottom?Q(Ne.get(e.id)):null,style:{...$(t),...e.reachesBottom?Q(Ne.get(e.id))?.style:null},children:e.kind===`group`?(0,d.jsxs)(`button`,{type:`button`,className:(0,u.default)(c.default.toggle,c.default.columnToggle),"aria-expanded":e.expanded,onClick:()=>ge(e.key),children:[(0,d.jsx)(`span`,{className:(0,u.default)(c.default.chevron,e.expanded&&c.default.open),"aria-hidden":`true`,children:(0,d.jsx)(i.Icon,{component:r.default,size:`sm`})}),e.node?.label]}):(0,d.jsx)(`span`,{className:(0,u.default)(M&&c.default.columnLeafLabel),children:e.kind===`leaf`?e.node?.label:E})},`${e.kind}:${e.key??``}`))]},t))}),(0,d.jsx)(o.Table.Body,{ref:W,onFocus:x?e=>{let t=e.target.closest(`tr`)?.dataset.rowKey;t!==void 0&&Ee(t)}:void 0,onBlur:x?e=>{e.currentTarget.contains(e.relatedTarget)||Ee(null)}:void 0,children:(Me??[{kind:`rows`,from:0,to:X}]).map((e,t)=>e.kind===`gap`?(0,d.jsx)(`tr`,{"aria-hidden":`true`,className:c.default.gap,children:(0,d.jsx)(`td`,{colSpan:ke+1,style:{height:e.count*(G||f)}})},`gap-${t}`):A.slice(e.from,e.to).map((t,n)=>Ie(t,e.from+n)))}),C&&(0,d.jsx)(o.Table.Footer,{children:(0,d.jsxs)(o.Table.Row,{className:c.default.totalRow,"aria-rowindex":x?U+X+1:void 0,children:[(0,d.jsx)(`th`,{id:I,scope:`row`,headers:N?P:void 0,className:(0,u.default)(c.default.rowHeader,V&&c.default.stickyLeft),children:(0,d.jsx)(`span`,{className:(0,u.default)(j&&c.default.leafLabel),children:E})}),k.columns.map((e,t)=>(0,d.jsx)(o.Table.Cell,{headers:`${I} ${L[t]}`,className:(0,u.default)(c.default.value,e.startsGroup&&!(V&&t===0)&&c.default.groupStart),children:g(null,e.key)},t))]})})]})})});h.displayName=`PivotTable`,exports.PivotTable=h;
|
|
@@ -3,8 +3,8 @@ export type PivotTableAxisNode = {
|
|
|
3
3
|
/** Unique within its axis. Passed back to `getValue`. */
|
|
4
4
|
key: string;
|
|
5
5
|
/**
|
|
6
|
-
* Heading shown for this row or column.
|
|
7
|
-
*
|
|
6
|
+
* Heading shown for this row or column. The label of a group is drawn inside its
|
|
7
|
+
* expand / collapse button, so it must not contain links or other controls.
|
|
8
8
|
*/
|
|
9
9
|
label: React.ReactNode;
|
|
10
10
|
/** Nested headings. A node with children is a group; its own value is the subtotal. */
|
|
@@ -22,7 +22,9 @@ export type PivotTableProps = Omit<React.ComponentPropsWithoutRef<"table">, "chi
|
|
|
22
22
|
/**
|
|
23
23
|
* Returns the content of one cell. The component does not aggregate: a group key asks
|
|
24
24
|
* for that group's subtotal and `null` asks for the grand total of that axis. Return
|
|
25
|
-
* `null` or `undefined` for an empty cell.
|
|
25
|
+
* `null` or `undefined` for an empty cell. Group keys are asked on both axes: a row
|
|
26
|
+
* group for its own row, a column group for its subtotal column and for the single
|
|
27
|
+
* column it leaves when it is collapsed.
|
|
26
28
|
*/
|
|
27
29
|
getValue: (rowKey: string | null, columnKey: string | null) => React.ReactNode;
|
|
28
30
|
/** Heading of the row axis, shown in the top-left corner. */
|
|
@@ -33,11 +35,20 @@ export type PivotTableProps = Omit<React.ComponentPropsWithoutRef<"table">, "chi
|
|
|
33
35
|
* Keys of the expanded row groups (controlled). A group that is not listed shows only
|
|
34
36
|
* its own row, which carries its subtotal.
|
|
35
37
|
*/
|
|
36
|
-
|
|
38
|
+
expandedRowValues?: string[];
|
|
37
39
|
/** Row groups expanded on first render (uncontrolled). Defaults to every group. */
|
|
38
|
-
|
|
39
|
-
/** Called with the new list of expanded row groups when a group is expanded or collapsed. */
|
|
40
|
-
|
|
40
|
+
defaultExpandedRowValues?: string[];
|
|
41
|
+
/** Called with the new list of expanded row groups when a row group is expanded or collapsed. */
|
|
42
|
+
onExpandedRowChange?: (values: string[]) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Keys of the expanded column groups (controlled). A group that is not listed shows a
|
|
45
|
+
* single column, which carries its subtotal: `getValue` receives the group's key.
|
|
46
|
+
*/
|
|
47
|
+
expandedColumnValues?: string[];
|
|
48
|
+
/** Column groups expanded on first render (uncontrolled). Defaults to every group. */
|
|
49
|
+
defaultExpandedColumnValues?: string[];
|
|
50
|
+
/** Called with the new list of expanded column groups when a column group is expanded or collapsed. */
|
|
51
|
+
onExpandedColumnChange?: (values: string[]) => void;
|
|
41
52
|
/**
|
|
42
53
|
* Maximum height of the table (a number is px). Past it the table scrolls vertically
|
|
43
54
|
* inside its own box.
|
|
@@ -60,7 +71,7 @@ export type PivotTableProps = Omit<React.ComponentPropsWithoutRef<"table">, "chi
|
|
|
60
71
|
* `maxHeight`. Rows must all have the same height, so keep labels and values on one line.
|
|
61
72
|
*/
|
|
62
73
|
virtualized?: boolean;
|
|
63
|
-
/** Adds a subtotal column after the columns of each column group. */
|
|
74
|
+
/** Adds a subtotal column after the columns of each expanded column group. */
|
|
64
75
|
columnSubtotals?: boolean;
|
|
65
76
|
/** Adds a grand total row at the bottom. */
|
|
66
77
|
totalRow?: boolean;
|
|
@@ -74,9 +85,10 @@ export type PivotTableProps = Omit<React.ComponentPropsWithoutRef<"table">, "chi
|
|
|
74
85
|
* headings, subtotals and grand totals. It only draws: grouping and summing stay with the
|
|
75
86
|
* caller, who answers `getValue(rowKey, columnKey)` for every cell.
|
|
76
87
|
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* the plain label when a cell
|
|
88
|
+
* Groups on both axes can be collapsed with the button in their heading (Enter or Space):
|
|
89
|
+
* a row group to its subtotal row, a column group to a single subtotal column. The button
|
|
90
|
+
* is named by the group label, so the heading still reads as the plain label when a cell
|
|
91
|
+
* announces it.
|
|
80
92
|
*
|
|
81
93
|
* Every cell lists the headings it belongs to in its `headers` attribute, so a screen
|
|
82
94
|
* reader announces the full row path and column path of a value.
|
|
@@ -96,7 +108,9 @@ export declare const PivotTable: React.ForwardRefExoticComponent<Omit<Omit<React
|
|
|
96
108
|
/**
|
|
97
109
|
* Returns the content of one cell. The component does not aggregate: a group key asks
|
|
98
110
|
* for that group's subtotal and `null` asks for the grand total of that axis. Return
|
|
99
|
-
* `null` or `undefined` for an empty cell.
|
|
111
|
+
* `null` or `undefined` for an empty cell. Group keys are asked on both axes: a row
|
|
112
|
+
* group for its own row, a column group for its subtotal column and for the single
|
|
113
|
+
* column it leaves when it is collapsed.
|
|
100
114
|
*/
|
|
101
115
|
getValue: (rowKey: string | null, columnKey: string | null) => React.ReactNode;
|
|
102
116
|
/** Heading of the row axis, shown in the top-left corner. */
|
|
@@ -107,11 +121,20 @@ export declare const PivotTable: React.ForwardRefExoticComponent<Omit<Omit<React
|
|
|
107
121
|
* Keys of the expanded row groups (controlled). A group that is not listed shows only
|
|
108
122
|
* its own row, which carries its subtotal.
|
|
109
123
|
*/
|
|
110
|
-
|
|
124
|
+
expandedRowValues?: string[];
|
|
111
125
|
/** Row groups expanded on first render (uncontrolled). Defaults to every group. */
|
|
112
|
-
|
|
113
|
-
/** Called with the new list of expanded row groups when a group is expanded or collapsed. */
|
|
114
|
-
|
|
126
|
+
defaultExpandedRowValues?: string[];
|
|
127
|
+
/** Called with the new list of expanded row groups when a row group is expanded or collapsed. */
|
|
128
|
+
onExpandedRowChange?: (values: string[]) => void;
|
|
129
|
+
/**
|
|
130
|
+
* Keys of the expanded column groups (controlled). A group that is not listed shows a
|
|
131
|
+
* single column, which carries its subtotal: `getValue` receives the group's key.
|
|
132
|
+
*/
|
|
133
|
+
expandedColumnValues?: string[];
|
|
134
|
+
/** Column groups expanded on first render (uncontrolled). Defaults to every group. */
|
|
135
|
+
defaultExpandedColumnValues?: string[];
|
|
136
|
+
/** Called with the new list of expanded column groups when a column group is expanded or collapsed. */
|
|
137
|
+
onExpandedColumnChange?: (values: string[]) => void;
|
|
115
138
|
/**
|
|
116
139
|
* Maximum height of the table (a number is px). Past it the table scrolls vertically
|
|
117
140
|
* inside its own box.
|
|
@@ -134,7 +157,7 @@ export declare const PivotTable: React.ForwardRefExoticComponent<Omit<Omit<React
|
|
|
134
157
|
* `maxHeight`. Rows must all have the same height, so keep labels and values on one line.
|
|
135
158
|
*/
|
|
136
159
|
virtualized?: boolean;
|
|
137
|
-
/** Adds a subtotal column after the columns of each column group. */
|
|
160
|
+
/** Adds a subtotal column after the columns of each expanded column group. */
|
|
138
161
|
columnSubtotals?: boolean;
|
|
139
162
|
/** Adds a grand total row at the bottom. */
|
|
140
163
|
totalRow?: boolean;
|
|
@@ -7,253 +7,279 @@ import { useMergedRef as i } from "../../../hooks/useMergedRef.js";
|
|
|
7
7
|
import { Table as a } from "../Table/Table.js";
|
|
8
8
|
import { layoutPivotColumns as o, layoutPivotRows as s, pivotRowWindow as ee } from "./layoutPivot.js";
|
|
9
9
|
import c from "./pivot-table.module.js";
|
|
10
|
-
import l, { useCallback as
|
|
11
|
-
import
|
|
12
|
-
import { jsx as
|
|
10
|
+
import l, { useCallback as u, useMemo as d, useState as f } from "react";
|
|
11
|
+
import p from "classnames";
|
|
12
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
13
13
|
//#region src/components/data-display/PivotTable/PivotTable.tsx
|
|
14
|
-
var
|
|
15
|
-
for (let n of e) n.children?.length && (t.push(n.key),
|
|
14
|
+
var g = 40, te = 8, ne = 30, _ = "corner", v = (e, t = []) => {
|
|
15
|
+
for (let n of e) n.children?.length && (t.push(n.key), v(n.children, t));
|
|
16
16
|
return t;
|
|
17
|
-
},
|
|
18
|
-
let
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
ie,
|
|
23
|
-
T,
|
|
24
|
-
ce
|
|
25
|
-
]), [me, he] = d(() => oe ?? g(_)), A = b ?? me, j = u(() => new Set(A), [A]), ge = te((e) => {
|
|
26
|
-
let t = j.has(e) ? A.filter((t) => t !== e) : [...A, e];
|
|
27
|
-
b === void 0 && he(t), x?.(t);
|
|
17
|
+
}, re = (e, t, n, r) => {
|
|
18
|
+
let [i, a] = f(() => n ?? v(e)), o = t ?? i, s = d(() => new Set(o), [o]);
|
|
19
|
+
return [s, u((e) => {
|
|
20
|
+
let n = s.has(e) ? o.filter((t) => t !== e) : [...o, e];
|
|
21
|
+
t === void 0 && a(n), r?.(n);
|
|
28
22
|
}, [
|
|
29
|
-
|
|
30
|
-
|
|
23
|
+
o,
|
|
24
|
+
s,
|
|
25
|
+
t,
|
|
26
|
+
r
|
|
27
|
+
])];
|
|
28
|
+
}, y = l.forwardRef(({ rows: y, columns: b, getValue: x, rowAxisLabel: S, caption: C, expandedRowValues: ie, defaultExpandedRowValues: ae, onExpandedRowChange: oe, expandedColumnValues: se, defaultExpandedColumnValues: ce, onExpandedColumnChange: le, maxHeight: ue, stickyHeader: w = !1, stickyRowHeaders: de = !1, virtualized: T = !1, columnSubtotals: fe = !1, totalRow: pe = !1, totalColumn: me = !1, labels: he, className: ge, ...E }, _e) => {
|
|
29
|
+
let { t: ve } = e("components"), D = l.useId(), O = he?.total ?? ve("pivottable.total"), [k, ye] = re(y, ie, ae, oe), [A, be] = re(b, se, ce, le), j = d(() => o(b, {
|
|
30
|
+
subtotals: fe,
|
|
31
|
+
total: me,
|
|
32
|
+
isExpanded: (e) => A.has(e)
|
|
33
|
+
}), [
|
|
31
34
|
b,
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
fe,
|
|
36
|
+
me,
|
|
37
|
+
A
|
|
38
|
+
]), M = d(() => s(y, (e) => k.has(e)), [y, k]), N = d(() => v(y).length > 0, [y]), P = d(() => v(b).length > 0, [b]), F = S != null && S !== !1, I = `${D}corner`, xe = (e) => `${D}c${e}`, L = (e) => `${D}r${e}`, R = `${D}total`, z = d(() => j.columns.map((e) => e.headerIds.map((e) => `${D}c${e}`).join(" ")), [j, D]), B = l.useRef(null), V = l.useRef(null), [Se, Ce] = l.useState(!1), [we, Te] = l.useState(!0);
|
|
34
39
|
l.useLayoutEffect(() => {
|
|
35
|
-
let e =
|
|
40
|
+
let e = B.current, t = V.current;
|
|
36
41
|
if (!e || !t || typeof ResizeObserver > "u") return;
|
|
37
42
|
let n = () => {
|
|
38
|
-
|
|
43
|
+
Ce(e.scrollWidth > e.clientWidth || e.scrollHeight > e.clientHeight);
|
|
39
44
|
let n = t.rows[0]?.cells[0];
|
|
40
|
-
|
|
45
|
+
Te(!n || n.offsetWidth <= e.clientWidth / 2);
|
|
41
46
|
};
|
|
42
47
|
n();
|
|
43
48
|
let r = new ResizeObserver(n);
|
|
44
49
|
return r.observe(e), r.observe(t), () => r.disconnect();
|
|
45
50
|
}, []);
|
|
46
|
-
let
|
|
51
|
+
let Ee = i(_e, V), H = de && we, De = l.useRef([]), [Oe, ke] = f([]), U = j.depth;
|
|
47
52
|
l.useLayoutEffect(() => {
|
|
48
|
-
if (!
|
|
49
|
-
let e =
|
|
53
|
+
if (!w) return;
|
|
54
|
+
let e = De.current.slice(0, U), t = () => {
|
|
50
55
|
let t = 0, n = e.map((e) => {
|
|
51
56
|
let n = t;
|
|
52
57
|
return t += e?.getBoundingClientRect().height ?? 0, n;
|
|
53
58
|
});
|
|
54
|
-
|
|
59
|
+
ke((e) => e.length === n.length && e.every((e, t) => e === n[t]) ? e : n);
|
|
55
60
|
};
|
|
56
61
|
if (t(), typeof ResizeObserver > "u") return;
|
|
57
62
|
let n = new ResizeObserver(t);
|
|
58
63
|
return e.forEach((e) => e && n.observe(e)), () => n.disconnect();
|
|
59
|
-
}, [
|
|
60
|
-
let
|
|
61
|
-
let e =
|
|
64
|
+
}, [w, U]);
|
|
65
|
+
let Ae = l.useRef(null), [W, je] = f(0), [G, Me] = f(null), [K, Ne] = f(null), [Pe, Fe] = f({}), Ie = l.useRef(0), q = u(() => {
|
|
66
|
+
let e = B.current, t = Ae.current, n = V.current;
|
|
62
67
|
if (!e || !t || !n) return;
|
|
63
68
|
let r = t.querySelector("tr[data-row-index]")?.getBoundingClientRect().height ?? 0;
|
|
64
|
-
r > 0 &&
|
|
69
|
+
r > 0 && je((e) => Math.abs(e - r) < .01 ? e : r);
|
|
65
70
|
let i = {
|
|
66
71
|
scrollTop: e.scrollTop,
|
|
67
72
|
height: e.clientHeight,
|
|
68
73
|
bodyOffset: t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop
|
|
69
74
|
};
|
|
70
|
-
|
|
71
|
-
let a = Array.from(n.querySelectorAll("thead [data-column-
|
|
72
|
-
|
|
73
|
-
let t = o ?
|
|
74
|
-
|
|
75
|
+
Me((e) => e && e.scrollTop === i.scrollTop && e.height === i.height && e.bodyOffset === i.bodyOffset ? e : i);
|
|
76
|
+
let a = Array.from(n.querySelectorAll("thead [data-column-key]")).map((e) => [e.dataset.columnKey, e.getBoundingClientRect().width]), o = Ie.current !== e.clientWidth;
|
|
77
|
+
Ie.current = e.clientWidth, Fe((e) => {
|
|
78
|
+
let t = o ? {} : { ...e };
|
|
79
|
+
for (let [e, n] of a) (n || 0) > (t[e] ?? 0) + .01 && (t[e] = n);
|
|
80
|
+
let n = Object.keys(t);
|
|
81
|
+
return n.length === Object.keys(e).length && n.every((n) => t[n] === e[n]) ? e : t;
|
|
75
82
|
});
|
|
76
|
-
}, []),
|
|
83
|
+
}, []), J = M.length, Le = j.columns.length, Y = d(() => j.columns.map((e) => `${e.kind}:${e.key ?? ""}`), [j]), Re = Y.join("|");
|
|
77
84
|
l.useLayoutEffect(() => {
|
|
78
|
-
if (!
|
|
79
|
-
let e = new ResizeObserver(
|
|
80
|
-
return
|
|
85
|
+
if (!T || (q(), typeof ResizeObserver > "u")) return;
|
|
86
|
+
let e = new ResizeObserver(q);
|
|
87
|
+
return B.current && e.observe(B.current), () => e.disconnect();
|
|
81
88
|
}, [
|
|
82
|
-
|
|
89
|
+
T,
|
|
90
|
+
q,
|
|
83
91
|
J,
|
|
84
|
-
|
|
85
|
-
X
|
|
92
|
+
Re
|
|
86
93
|
]);
|
|
87
|
-
let
|
|
88
|
-
rowCount:
|
|
89
|
-
rowHeight:
|
|
90
|
-
scrollTop:
|
|
91
|
-
viewportHeight:
|
|
92
|
-
bodyOffset:
|
|
93
|
-
overscan:
|
|
94
|
-
keep:
|
|
94
|
+
let ze = d(() => new Map(M.map((e, t) => [e.key, t])), [M]), Be = d(() => T ? ee(G ? {
|
|
95
|
+
rowCount: J,
|
|
96
|
+
rowHeight: W || g,
|
|
97
|
+
scrollTop: G.scrollTop,
|
|
98
|
+
viewportHeight: G.height,
|
|
99
|
+
bodyOffset: G.bodyOffset,
|
|
100
|
+
overscan: te,
|
|
101
|
+
keep: K === null ? null : ze.get(K) ?? null
|
|
95
102
|
} : {
|
|
96
|
-
rowCount:
|
|
97
|
-
rowHeight:
|
|
103
|
+
rowCount: J,
|
|
104
|
+
rowHeight: g,
|
|
98
105
|
scrollTop: 0,
|
|
99
|
-
viewportHeight: Math.min(
|
|
106
|
+
viewportHeight: Math.min(J, ne) * g,
|
|
100
107
|
bodyOffset: 0,
|
|
101
108
|
overscan: 0
|
|
102
109
|
}) : null, [
|
|
103
|
-
|
|
104
|
-
K,
|
|
105
|
-
Y,
|
|
110
|
+
T,
|
|
106
111
|
G,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
"
|
|
122
|
-
|
|
123
|
-
|
|
112
|
+
J,
|
|
113
|
+
W,
|
|
114
|
+
K,
|
|
115
|
+
ze
|
|
116
|
+
]), X = d(() => new Map(j.columns.map((e, t) => [e.headerIds[e.headerIds.length - 1], Y[t]])), [j, Y]), Z = (e) => T && e !== void 0 ? {
|
|
117
|
+
"data-column-key": e,
|
|
118
|
+
style: Pe[e] ? { minWidth: Pe[e] } : void 0
|
|
119
|
+
} : null, Q = (e, t = !1) => w ? {
|
|
120
|
+
top: Math.floor(Oe[e] ?? 0),
|
|
121
|
+
zIndex: 10 + U - e + +!!t
|
|
122
|
+
} : void 0, Ve = `${D}caption`, $ = C ? { "aria-labelledby": Ve } : E["aria-label"] ? { "aria-label": E["aria-label"] } : E["aria-labelledby"] ? { "aria-labelledby": E["aria-labelledby"] } : null, He = (e, i) => {
|
|
123
|
+
let o = T ? L(i) : [...e.ancestors.map(L), L(i)].join(" "), s = [...F ? [I] : [], ...T ? [] : e.ancestors.map(L)].join(" ");
|
|
124
|
+
return /* @__PURE__ */ h(a.Row, {
|
|
125
|
+
className: p(e.hasChildren && c.groupRow),
|
|
126
|
+
"data-row-index": T ? i : void 0,
|
|
127
|
+
"data-row-key": T ? e.key : void 0,
|
|
128
|
+
"aria-rowindex": T ? U + i + 1 : void 0,
|
|
129
|
+
children: [/* @__PURE__ */ h("th", {
|
|
130
|
+
id: L(i),
|
|
124
131
|
scope: "row",
|
|
125
132
|
headers: s || void 0,
|
|
126
|
-
className:
|
|
133
|
+
className: p(c.rowHeader, H && c.stickyLeft),
|
|
127
134
|
style: { "--wim-pivot-table-depth": e.depth },
|
|
128
|
-
children: [
|
|
135
|
+
children: [T && e.ancestors.length > 0 && /* @__PURE__ */ m(t, { children: e.ancestors.map((e) => /* @__PURE__ */ h(l.Fragment, { children: [M[e].node.label, ", "] }, e)) }), e.hasChildren ? /* @__PURE__ */ h("button", {
|
|
129
136
|
type: "button",
|
|
130
137
|
className: c.toggle,
|
|
131
138
|
"aria-expanded": e.expanded,
|
|
132
|
-
onClick: () =>
|
|
133
|
-
children: [/* @__PURE__ */
|
|
134
|
-
className:
|
|
139
|
+
onClick: () => ye(e.key),
|
|
140
|
+
children: [/* @__PURE__ */ m("span", {
|
|
141
|
+
className: p(c.chevron, e.expanded && c.open),
|
|
135
142
|
"aria-hidden": "true",
|
|
136
|
-
children: /* @__PURE__ */
|
|
143
|
+
children: /* @__PURE__ */ m(r, {
|
|
137
144
|
component: n,
|
|
138
145
|
size: "sm"
|
|
139
146
|
})
|
|
140
147
|
}), e.node.label]
|
|
141
|
-
}) : /* @__PURE__ */
|
|
142
|
-
className:
|
|
148
|
+
}) : /* @__PURE__ */ m("span", {
|
|
149
|
+
className: p(N && c.leafLabel),
|
|
143
150
|
children: e.node.label
|
|
144
151
|
})]
|
|
145
|
-
}),
|
|
146
|
-
headers: `${o} ${
|
|
147
|
-
className:
|
|
148
|
-
children:
|
|
152
|
+
}), j.columns.map((t, n) => /* @__PURE__ */ m(a.Cell, {
|
|
153
|
+
headers: `${o} ${z[n]}`,
|
|
154
|
+
className: p(c.value, t.kind !== "leaf" && c.aggregate, t.startsGroup && !(H && n === 0) && c.groupStart),
|
|
155
|
+
children: x(e.key, t.key)
|
|
149
156
|
}, n))]
|
|
150
157
|
}, e.key);
|
|
151
158
|
};
|
|
152
|
-
return /* @__PURE__ */
|
|
153
|
-
ref:
|
|
159
|
+
return /* @__PURE__ */ m("div", {
|
|
160
|
+
ref: B,
|
|
154
161
|
className: c.scroller,
|
|
155
|
-
style:
|
|
156
|
-
tabIndex:
|
|
157
|
-
onScroll:
|
|
158
|
-
...
|
|
162
|
+
style: ue === void 0 ? void 0 : { maxHeight: ue },
|
|
163
|
+
tabIndex: Se ? 0 : void 0,
|
|
164
|
+
onScroll: T ? q : void 0,
|
|
165
|
+
...Se && $ ? {
|
|
159
166
|
role: "region",
|
|
160
167
|
...$
|
|
161
168
|
} : null,
|
|
162
|
-
children: /* @__PURE__ */
|
|
163
|
-
ref:
|
|
164
|
-
className:
|
|
165
|
-
"aria-rowcount":
|
|
166
|
-
...
|
|
169
|
+
children: /* @__PURE__ */ h("table", {
|
|
170
|
+
ref: Ee,
|
|
171
|
+
className: p("wim-pivot-table", c.root, ge),
|
|
172
|
+
"aria-rowcount": T ? U + J + +!!pe : void 0,
|
|
173
|
+
...E,
|
|
167
174
|
children: [
|
|
168
|
-
|
|
169
|
-
id:
|
|
175
|
+
C && /* @__PURE__ */ m("caption", {
|
|
176
|
+
id: Ve,
|
|
170
177
|
className: c.caption,
|
|
171
|
-
children:
|
|
178
|
+
children: C
|
|
172
179
|
}),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
|
|
175
|
-
/* @__PURE__ */
|
|
176
|
-
"aria-rowindex":
|
|
180
|
+
/* @__PURE__ */ m("colgroup", {}),
|
|
181
|
+
j.groupSpans.map((e, t) => /* @__PURE__ */ m("colgroup", { span: e }, t)),
|
|
182
|
+
/* @__PURE__ */ m(a.Header, { children: j.headerRows.map((e, t) => /* @__PURE__ */ h("tr", {
|
|
183
|
+
"aria-rowindex": T ? t + 1 : void 0,
|
|
177
184
|
ref: (e) => {
|
|
178
|
-
|
|
185
|
+
De.current[t] = e;
|
|
179
186
|
},
|
|
180
|
-
children: [t === 0 && (
|
|
181
|
-
id:
|
|
187
|
+
children: [t === 0 && (F ? /* @__PURE__ */ m("th", {
|
|
188
|
+
id: I,
|
|
182
189
|
scope: "col",
|
|
183
|
-
rowSpan:
|
|
184
|
-
className:
|
|
185
|
-
...Z(
|
|
190
|
+
rowSpan: j.depth,
|
|
191
|
+
className: p(c.columnHeader, c.corner, c.bottom, w && c.stickyTop, H && c.stickyLeft),
|
|
192
|
+
...Z(_),
|
|
186
193
|
style: {
|
|
187
194
|
...Q(0, !0),
|
|
188
|
-
...Z(
|
|
195
|
+
...Z(_)?.style
|
|
189
196
|
},
|
|
190
|
-
children:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
197
|
+
children: /* @__PURE__ */ m("span", {
|
|
198
|
+
className: p(P && c.columnLeafLabel),
|
|
199
|
+
children: S
|
|
200
|
+
})
|
|
201
|
+
}) : /* @__PURE__ */ m("td", {
|
|
202
|
+
rowSpan: j.depth,
|
|
203
|
+
className: p(c.columnHeader, c.bottom, w && c.stickyTop, H && c.stickyLeft),
|
|
204
|
+
...Z(_),
|
|
195
205
|
style: {
|
|
196
206
|
...Q(0, !0),
|
|
197
|
-
...Z(
|
|
207
|
+
...Z(_)?.style
|
|
198
208
|
}
|
|
199
|
-
})), e.map((e,
|
|
200
|
-
id:
|
|
209
|
+
})), e.map((e, i) => /* @__PURE__ */ m("th", {
|
|
210
|
+
id: xe(e.id),
|
|
201
211
|
scope: e.kind === "group" && e.topLevel ? "colgroup" : "col",
|
|
202
212
|
colSpan: e.colSpan > 1 ? e.colSpan : void 0,
|
|
203
213
|
rowSpan: e.rowSpan > 1 ? e.rowSpan : void 0,
|
|
204
|
-
className:
|
|
205
|
-
...e.reachesBottom ? Z(
|
|
214
|
+
className: p(c.columnHeader, e.kind === "group" && e.expanded && c.group, e.reachesBottom && c.bottom, e.startsGroup && !(H && i === 0) && c.groupStart, w && c.stickyTop),
|
|
215
|
+
...e.reachesBottom ? Z(X.get(e.id)) : null,
|
|
206
216
|
style: {
|
|
207
217
|
...Q(t),
|
|
208
|
-
...e.reachesBottom ? Z(
|
|
218
|
+
...e.reachesBottom ? Z(X.get(e.id))?.style : null
|
|
209
219
|
},
|
|
210
|
-
children: e.kind === "group"
|
|
211
|
-
|
|
220
|
+
children: e.kind === "group" ? /* @__PURE__ */ h("button", {
|
|
221
|
+
type: "button",
|
|
222
|
+
className: p(c.toggle, c.columnToggle),
|
|
223
|
+
"aria-expanded": e.expanded,
|
|
224
|
+
onClick: () => be(e.key),
|
|
225
|
+
children: [/* @__PURE__ */ m("span", {
|
|
226
|
+
className: p(c.chevron, e.expanded && c.open),
|
|
227
|
+
"aria-hidden": "true",
|
|
228
|
+
children: /* @__PURE__ */ m(r, {
|
|
229
|
+
component: n,
|
|
230
|
+
size: "sm"
|
|
231
|
+
})
|
|
232
|
+
}), e.node?.label]
|
|
233
|
+
}) : /* @__PURE__ */ m("span", {
|
|
234
|
+
className: p(P && c.columnLeafLabel),
|
|
235
|
+
children: e.kind === "leaf" ? e.node?.label : O
|
|
236
|
+
})
|
|
237
|
+
}, `${e.kind}:${e.key ?? ""}`))]
|
|
212
238
|
}, t)) }),
|
|
213
|
-
/* @__PURE__ */
|
|
214
|
-
ref:
|
|
215
|
-
onFocus:
|
|
239
|
+
/* @__PURE__ */ m(a.Body, {
|
|
240
|
+
ref: Ae,
|
|
241
|
+
onFocus: T ? (e) => {
|
|
216
242
|
let t = e.target.closest("tr")?.dataset.rowKey;
|
|
217
|
-
t !== void 0 &&
|
|
243
|
+
t !== void 0 && Ne(t);
|
|
218
244
|
} : void 0,
|
|
219
|
-
onBlur:
|
|
220
|
-
e.currentTarget.contains(e.relatedTarget) ||
|
|
245
|
+
onBlur: T ? (e) => {
|
|
246
|
+
e.currentTarget.contains(e.relatedTarget) || Ne(null);
|
|
221
247
|
} : void 0,
|
|
222
|
-
children: (
|
|
248
|
+
children: (Be ?? [{
|
|
223
249
|
kind: "rows",
|
|
224
250
|
from: 0,
|
|
225
|
-
to:
|
|
226
|
-
}]).map((e, t) => e.kind === "gap" ? /* @__PURE__ */
|
|
251
|
+
to: J
|
|
252
|
+
}]).map((e, t) => e.kind === "gap" ? /* @__PURE__ */ m("tr", {
|
|
227
253
|
"aria-hidden": "true",
|
|
228
254
|
className: c.gap,
|
|
229
|
-
children: /* @__PURE__ */
|
|
230
|
-
colSpan:
|
|
231
|
-
style: { height: e.count * (
|
|
255
|
+
children: /* @__PURE__ */ m("td", {
|
|
256
|
+
colSpan: Le + 1,
|
|
257
|
+
style: { height: e.count * (W || g) }
|
|
232
258
|
})
|
|
233
|
-
}, `gap-${t}`) : M.slice(e.from, e.to).map((t, n) =>
|
|
259
|
+
}, `gap-${t}`) : M.slice(e.from, e.to).map((t, n) => He(t, e.from + n)))
|
|
234
260
|
}),
|
|
235
|
-
|
|
261
|
+
pe && /* @__PURE__ */ m(a.Footer, { children: /* @__PURE__ */ h(a.Row, {
|
|
236
262
|
className: c.totalRow,
|
|
237
|
-
"aria-rowindex":
|
|
238
|
-
children: [/* @__PURE__ */
|
|
239
|
-
id:
|
|
263
|
+
"aria-rowindex": T ? U + J + 1 : void 0,
|
|
264
|
+
children: [/* @__PURE__ */ m("th", {
|
|
265
|
+
id: R,
|
|
240
266
|
scope: "row",
|
|
241
|
-
headers:
|
|
242
|
-
className:
|
|
243
|
-
children: /* @__PURE__ */
|
|
244
|
-
className:
|
|
245
|
-
children:
|
|
267
|
+
headers: F ? I : void 0,
|
|
268
|
+
className: p(c.rowHeader, H && c.stickyLeft),
|
|
269
|
+
children: /* @__PURE__ */ m("span", {
|
|
270
|
+
className: p(N && c.leafLabel),
|
|
271
|
+
children: O
|
|
246
272
|
})
|
|
247
|
-
}),
|
|
248
|
-
headers: `${
|
|
249
|
-
className:
|
|
250
|
-
children:
|
|
273
|
+
}), j.columns.map((e, t) => /* @__PURE__ */ m(a.Cell, {
|
|
274
|
+
headers: `${R} ${z[t]}`,
|
|
275
|
+
className: p(c.value, e.startsGroup && !(H && t === 0) && c.groupStart),
|
|
276
|
+
children: x(null, e.key)
|
|
251
277
|
}, t))]
|
|
252
278
|
}) })
|
|
253
279
|
]
|
|
254
280
|
})
|
|
255
281
|
});
|
|
256
282
|
});
|
|
257
|
-
|
|
283
|
+
y.displayName = "PivotTable";
|
|
258
284
|
//#endregion
|
|
259
|
-
export {
|
|
285
|
+
export { y as PivotTable };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var e=e=>!!e.children?.length,t=n=>n.reduce((n,
|
|
2
|
+
var e=e=>!!e.children?.length,t=(n,r)=>n.reduce((n,i)=>Math.max(n,1+(e(i)&&r(i.key)?t(i.children,r):0)),0);function n(n,r={}){let i=r.isExpanded??(()=>!0),a=Math.max(1,t(n,i)),o=Array.from({length:a},()=>[]),s=[],c=[],l=0,u=(e,t,n,r,i,c)=>{let u=l++,d=e?.key??null;o[n].push({id:u,key:d,node:e,kind:t,colSpan:1,rowSpan:a-n,reachesBottom:!0,startsGroup:c,topLevel:i,expanded:!1}),s.push({key:d,kind:t,headerIds:[...r,u],startsGroup:c})},d=(t,n,c,f)=>{let p=n===0;if(!e(t))return u(t,`leaf`,n,c,p,f),1;if(!i(t.key)){let e=l++;return o[n].push({id:e,key:t.key,node:t,kind:`group`,colSpan:1,rowSpan:a-n,reachesBottom:!0,startsGroup:f,topLevel:p,expanded:!1}),s.push({key:t.key,kind:`subtotal`,headerIds:[...c,e],startsGroup:f}),1}let m={id:l++,key:t.key,node:t,kind:`group`,colSpan:0,rowSpan:1,reachesBottom:!1,startsGroup:f,topLevel:p,expanded:!0};o[n].push(m);let h=[...c,m.id],g=0;return t.children.forEach((e,t)=>{g+=d(e,n+1,h,f&&t===0)}),r.subtotals&&(u(t,`subtotal`,n+1,h,!1,!1),g+=1),m.colSpan=g,g};for(let e of n)c.push(d(e,0,[],!0));return r.total&&(u(null,`total`,0,[],!0,!0),c.push(1)),{headerRows:o,columns:s,depth:a,groupSpans:c}}function r(t,n=()=>!0){let r=[],i=(t,a,o)=>{for(let s of t){let t=r.length,c=e(s),l=c&&n(s.key);r.push({key:s.key,node:s,depth:a,hasChildren:c,expanded:l,ancestors:o}),l&&i(s.children,a+1,[...o,t])}};return i(t,0,[]),r}function i(e){let{rowCount:t,rowHeight:n,scrollTop:r,viewportHeight:i,bodyOffset:a,overscan:o,keep:s}=e;if(t<=0)return[];if(n<=0)return[{kind:`rows`,from:0,to:t}];let c=(e,t,n)=>Math.min(Math.max(e,t),n),l=r-a,u=c(Math.floor(l/n)-o,0,t-1),d=c(Math.ceil((l+i)/n)+o,u+1,t),f=[],p=e=>{e>0&&f.push({kind:`gap`,count:e})},m=s!=null&&s>=0&&s<t?s:null;return m!==null&&m<u?(p(m),f.push({kind:`rows`,from:m,to:m+1}),p(u-m-1)):p(u),f.push({kind:`rows`,from:u,to:d}),m!==null&&m>=d?(p(m-d),f.push({kind:`rows`,from:m,to:m+1}),p(t-m-1)):p(t-d),f}exports.layoutPivotColumns=n,exports.layoutPivotRows=r,exports.pivotRowWindow=i;
|