wimui 0.45.0 → 0.46.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.
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- const e=require("../../../_virtual/_rolldown/runtime.cjs"),t=require("../../../i18n/useWimTranslation.cjs"),n=require("../../../icon/chevron-right.cjs"),r=require("../../media/Icon/Icon.cjs"),i=require("../../../hooks/useMergedRef.cjs"),a=require("../Table/Table.cjs"),o=require("./layoutPivot.cjs"),s=require("./pivot-table.module.cjs");let c=require("react");c=e.__toESM(c,1);let l=require("classnames");l=e.__toESM(l,1);let u=require("react/jsx-runtime");var d=(e,t=[])=>{for(let n of e)n.children?.length&&(t.push(n.key),d(n.children,t));return t},f=c.default.forwardRef(({rows:e,columns:f,getValue:p,rowAxisLabel:m,caption:h,expandedValues:g,defaultExpandedValues:_,onExpandedChange:v,maxHeight:y,stickyHeader:b=!1,stickyRowHeaders:ee=!1,columnSubtotals:x=!1,totalRow:te=!1,totalColumn:S=!1,labels:C,className:w,...T},ne)=>{let{t:re}=t.useWimTranslation(`components`),E=c.default.useId(),D=C?.total??re(`pivottable.total`),O=(0,c.useMemo)(()=>o.layoutPivotColumns(f,{subtotals:x,total:S}),[f,x,S]),[k,A]=(0,c.useState)(()=>_??d(e)),j=g??k,M=(0,c.useMemo)(()=>new Set(j),[j]),N=(0,c.useCallback)(e=>{let t=M.has(e)?j.filter(t=>t!==e):[...j,e];g===void 0&&A(t),v?.(t)},[j,M,g,v]),P=(0,c.useMemo)(()=>o.layoutPivotRows(e,e=>M.has(e)),[e,M]),F=(0,c.useMemo)(()=>d(e).length>0,[e]),I=m!=null&&m!==!1,L=`${E}corner`,ie=e=>`${E}c${e}`,R=e=>`${E}r${e}`,z=`${E}total`,B=(0,c.useMemo)(()=>O.columns.map(e=>e.headerIds.map(e=>`${E}c${e}`).join(` `)),[O,E]),V=c.default.useRef(null),H=c.default.useRef(null),[U,W]=c.default.useState(!1),[G,K]=c.default.useState(!0);c.default.useLayoutEffect(()=>{let e=V.current,t=H.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=()=>{W(e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight);let n=t.rows[0]?.cells[0];K(!n||n.offsetWidth<=e.clientWidth/2)};n();let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[]);let q=i.useMergedRef(ne,H),J=ee&&G,Y=c.default.useRef([]),[ae,oe]=(0,c.useState)([]),X=O.depth;c.default.useLayoutEffect(()=>{if(!b)return;let e=Y.current.slice(0,X),t=()=>{let t=0,n=e.map(e=>{let n=t;return t+=e?.getBoundingClientRect().height??0,n});oe(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,X]);let Z=(e,t=!1)=>b?{top:Math.floor(ae[e]??0),zIndex:10+X-e+ +!!t}:void 0,Q=`${E}caption`,$=h?{"aria-labelledby":Q}:T[`aria-label`]?{"aria-label":T[`aria-label`]}:T[`aria-labelledby`]?{"aria-labelledby":T[`aria-labelledby`]}:null;return(0,u.jsx)(`div`,{ref:V,className:s.default.scroller,style:y===void 0?void 0:{maxHeight:y},tabIndex:U?0:void 0,...U&&$?{role:`region`,...$}:null,children:(0,u.jsxs)(`table`,{ref:q,className:(0,l.default)(`wim-pivot-table`,s.default.root,w),...T,children:[h&&(0,u.jsx)(`caption`,{id:Q,className:s.default.caption,children:h}),(0,u.jsx)(`colgroup`,{}),O.groupSpans.map((e,t)=>(0,u.jsx)(`colgroup`,{span:e},t)),(0,u.jsx)(a.Table.Header,{children:O.headerRows.map((e,t)=>(0,u.jsxs)(`tr`,{ref:e=>{Y.current[t]=e},children:[t===0&&(I?(0,u.jsx)(`th`,{id:L,scope:`col`,rowSpan:O.depth,className:(0,l.default)(s.default.columnHeader,s.default.corner,s.default.bottom,b&&s.default.stickyTop,J&&s.default.stickyLeft),style:Z(0,!0),children:m}):(0,u.jsx)(`td`,{rowSpan:O.depth,className:(0,l.default)(s.default.columnHeader,s.default.bottom,b&&s.default.stickyTop,J&&s.default.stickyLeft),style:Z(0,!0)})),e.map((e,n)=>(0,u.jsx)(`th`,{id:ie(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,l.default)(s.default.columnHeader,e.kind===`group`&&s.default.group,e.reachesBottom&&s.default.bottom,e.startsGroup&&!(J&&n===0)&&s.default.groupStart,b&&s.default.stickyTop),style:Z(t),children:e.kind===`group`||e.kind===`leaf`?e.node?.label:D},e.id))]},t))}),(0,u.jsx)(a.Table.Body,{children:P.map((e,t)=>{let i=[...e.ancestors.map(R),R(t)].join(` `),o=[...I?[L]:[],...e.ancestors.map(R)].join(` `);return(0,u.jsxs)(a.Table.Row,{className:(0,l.default)(e.hasChildren&&s.default.groupRow),children:[(0,u.jsx)(`th`,{id:R(t),scope:`row`,headers:o||void 0,className:(0,l.default)(s.default.rowHeader,J&&s.default.stickyLeft),style:{"--wim-pivot-table-depth":e.depth},children:e.hasChildren?(0,u.jsxs)(`button`,{type:`button`,className:s.default.toggle,"aria-expanded":e.expanded,onClick:()=>N(e.key),children:[(0,u.jsx)(`span`,{className:(0,l.default)(s.default.chevron,e.expanded&&s.default.open),"aria-hidden":`true`,children:(0,u.jsx)(r.Icon,{component:n.default,size:`sm`})}),e.node.label]}):(0,u.jsx)(`span`,{className:(0,l.default)(F&&s.default.leafLabel),children:e.node.label})}),O.columns.map((t,n)=>(0,u.jsx)(a.Table.Cell,{headers:`${i} ${B[n]}`,className:(0,l.default)(s.default.value,t.kind!==`leaf`&&s.default.aggregate,t.startsGroup&&!(J&&n===0)&&s.default.groupStart),children:p(e.key,t.key)},n))]},e.key)})}),te&&(0,u.jsx)(a.Table.Footer,{children:(0,u.jsxs)(a.Table.Row,{className:s.default.totalRow,children:[(0,u.jsx)(`th`,{id:z,scope:`row`,headers:I?L:void 0,className:(0,l.default)(s.default.rowHeader,J&&s.default.stickyLeft),children:(0,u.jsx)(`span`,{className:(0,l.default)(F&&s.default.leafLabel),children:D})}),O.columns.map((e,t)=>(0,u.jsx)(a.Table.Cell,{headers:`${z} ${B[t]}`,className:(0,l.default)(s.default.value,e.startsGroup&&!(J&&t===0)&&s.default.groupStart),children:p(null,e.key)},t))]})})]})})});f.displayName=`PivotTable`,exports.PivotTable=f;
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),p(n.children,t));return t},m=l.default.forwardRef(({rows:e,columns:m,getValue:h,rowAxisLabel:g,caption:_,expandedValues:v,defaultExpandedValues:ne,onExpandedChange:re,maxHeight:ie,stickyHeader:y=!1,stickyRowHeaders:ae=!1,virtualized:b=!1,columnSubtotals:x=!1,totalRow:S=!1,totalColumn:C=!1,labels:oe,className:se,...w},ce)=>{let{t:le}=t.useWimTranslation(`components`),T=l.default.useId(),E=oe?.total??le(`pivottable.total`),D=(0,l.useMemo)(()=>s.layoutPivotColumns(m,{subtotals:x,total:C}),[m,x,C]),[ue,de]=(0,l.useState)(()=>ne??p(e)),O=v??ue,k=(0,l.useMemo)(()=>new Set(O),[O]),fe=(0,l.useCallback)(e=>{let t=k.has(e)?O.filter(t=>t!==e):[...O,e];v===void 0&&de(t),re?.(t)},[O,k,v,re]),A=(0,l.useMemo)(()=>s.layoutPivotRows(e,e=>k.has(e)),[e,k]),j=(0,l.useMemo)(()=>p(e).length>0,[e]),M=g!=null&&g!==!1,N=`${T}corner`,pe=e=>`${T}c${e}`,P=e=>`${T}r${e}`,F=`${T}total`,I=(0,l.useMemo)(()=>D.columns.map(e=>e.headerIds.map(e=>`${T}c${e}`).join(` `)),[D,T]),L=l.default.useRef(null),R=l.default.useRef(null),[z,me]=l.default.useState(!1),[he,ge]=l.default.useState(!0);l.default.useLayoutEffect(()=>{let e=L.current,t=R.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=()=>{me(e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight);let n=t.rows[0]?.cells[0];ge(!n||n.offsetWidth<=e.clientWidth/2)};n();let r=new ResizeObserver(n);return r.observe(e),r.observe(t),()=>r.disconnect()},[]);let _e=a.useMergedRef(ce,R),B=ae&&he,V=l.default.useRef([]),[ve,ye]=(0,l.useState)([]),H=D.depth;l.default.useLayoutEffect(()=>{if(!y)return;let e=V.current.slice(0,H),t=()=>{let t=0,n=e.map(e=>{let n=t;return t+=e?.getBoundingClientRect().height??0,n});ye(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()},[y,H]);let U=l.default.useRef(null),[W,be]=(0,l.useState)(0),[G,xe]=(0,l.useState)(null),[K,q]=(0,l.useState)(null),[J,Se]=(0,l.useState)([]),Ce=l.default.useRef(0),Y=(0,l.useCallback)(()=>{let e=L.current,t=U.current,n=R.current;if(!e||!t||!n)return;let r=t.querySelector(`tr[data-row-index]`)?.getBoundingClientRect().height??0;r>0&&be(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};xe(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-index]`)).reduce((e,t)=>(e[Number(t.dataset.columnIndex)]=t.getBoundingClientRect().width,e),[]),o=Ce.current!==e.clientWidth;Ce.current=e.clientWidth,Se(e=>{let t=o?[]:e,n=a.map((e,n)=>(e||0)>(t[n]??0)+.01?e:t[n]??0);return n.length===e.length&&n.every((t,n)=>t===e[n])?e:n})},[]),X=A.length,we=D.columns.length;l.default.useLayoutEffect(()=>{if(!b||(Y(),typeof ResizeObserver>`u`))return;let e=new ResizeObserver(Y);return L.current&&e.observe(L.current),()=>e.disconnect()},[b,Y,X,we]);let Te=(0,l.useMemo)(()=>new Map(A.map((e,t)=>[e.key,t])),[A]),Ee=(0,l.useMemo)(()=>b?G?s.pivotRowWindow({rowCount:X,rowHeight:W||f,scrollTop:G.scrollTop,viewportHeight:G.height,bodyOffset:G.bodyOffset,overscan:ee,keep:K===null?null:Te.get(K)??null}):s.pivotRowWindow({rowCount:X,rowHeight:f,scrollTop:0,viewportHeight:Math.min(X,te)*f,bodyOffset:0,overscan:0}):null,[b,G,X,W,K,Te]),De=(0,l.useMemo)(()=>new Map(D.columns.map((e,t)=>[e.headerIds[e.headerIds.length-1],t])),[D]),Z=e=>b&&e!==void 0?{"data-column-index":e,style:J[e]?{minWidth:J[e]}:void 0}:null,Q=(e,t=!1)=>y?{top:Math.floor(ve[e]??0),zIndex:10+H-e+ +!!t}:void 0,Oe=`${T}caption`,$=_?{"aria-labelledby":Oe}:w[`aria-label`]?{"aria-label":w[`aria-label`]}:w[`aria-labelledby`]?{"aria-labelledby":w[`aria-labelledby`]}:null,ke=(e,t)=>{let a=b?P(t):[...e.ancestors.map(P),P(t)].join(` `),s=[...M?[N]:[],...b?[]:e.ancestors.map(P)].join(` `);return(0,d.jsxs)(o.Table.Row,{className:(0,u.default)(e.hasChildren&&c.default.groupRow),"data-row-index":b?t:void 0,"data-row-key":b?e.key:void 0,"aria-rowindex":b?H+t+1:void 0,children:[(0,d.jsxs)(`th`,{id:P(t),scope:`row`,headers:s||void 0,className:(0,u.default)(c.default.rowHeader,B&&c.default.stickyLeft),style:{"--wim-pivot-table-depth":e.depth},children:[b&&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:()=>fe(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})]}),D.columns.map((t,n)=>(0,d.jsx)(o.Table.Cell,{headers:`${a} ${I[n]}`,className:(0,u.default)(c.default.value,t.kind!==`leaf`&&c.default.aggregate,t.startsGroup&&!(B&&n===0)&&c.default.groupStart),children:h(e.key,t.key)},n))]},e.key)};return(0,d.jsx)(`div`,{ref:L,className:c.default.scroller,style:ie===void 0?void 0:{maxHeight:ie},tabIndex:z?0:void 0,onScroll:b?Y:void 0,...z&&$?{role:`region`,...$}:null,children:(0,d.jsxs)(`table`,{ref:_e,className:(0,u.default)(`wim-pivot-table`,c.default.root,se),"aria-rowcount":b?H+X+ +!!S:void 0,...w,children:[_&&(0,d.jsx)(`caption`,{id:Oe,className:c.default.caption,children:_}),(0,d.jsx)(`colgroup`,{}),D.groupSpans.map((e,t)=>(0,d.jsx)(`colgroup`,{span:e},t)),(0,d.jsx)(o.Table.Header,{children:D.headerRows.map((e,t)=>(0,d.jsxs)(`tr`,{"aria-rowindex":b?t+1:void 0,ref:e=>{V.current[t]=e},children:[t===0&&(M?(0,d.jsx)(`th`,{id:N,scope:`col`,rowSpan:D.depth,className:(0,u.default)(c.default.columnHeader,c.default.corner,c.default.bottom,y&&c.default.stickyTop,B&&c.default.stickyLeft),...Z(0),style:{...Q(0,!0),...Z(0)?.style},children:g}):(0,d.jsx)(`td`,{rowSpan:D.depth,className:(0,u.default)(c.default.columnHeader,c.default.bottom,y&&c.default.stickyTop,B&&c.default.stickyLeft),...Z(0),style:{...Q(0,!0),...Z(0)?.style}})),e.map((e,n)=>(0,d.jsx)(`th`,{id:pe(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`&&c.default.group,e.reachesBottom&&c.default.bottom,e.startsGroup&&!(B&&n===0)&&c.default.groupStart,y&&c.default.stickyTop),...e.reachesBottom?Z((De.get(e.id)??-1)+1):null,style:{...Q(t),...e.reachesBottom?Z((De.get(e.id)??-1)+1)?.style:null},children:e.kind===`group`||e.kind===`leaf`?e.node?.label:E},e.id))]},t))}),(0,d.jsx)(o.Table.Body,{ref:U,onFocus:b?e=>{let t=e.target.closest(`tr`)?.dataset.rowKey;t!==void 0&&q(t)}:void 0,onBlur:b?e=>{e.currentTarget.contains(e.relatedTarget)||q(null)}:void 0,children:(Ee??[{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:we+1,style:{height:e.count*(W||f)}})},`gap-${t}`):A.slice(e.from,e.to).map((t,n)=>ke(t,e.from+n)))}),S&&(0,d.jsx)(o.Table.Footer,{children:(0,d.jsxs)(o.Table.Row,{className:c.default.totalRow,"aria-rowindex":b?H+X+1:void 0,children:[(0,d.jsx)(`th`,{id:F,scope:`row`,headers:M?N:void 0,className:(0,u.default)(c.default.rowHeader,B&&c.default.stickyLeft),children:(0,d.jsx)(`span`,{className:(0,u.default)(j&&c.default.leafLabel),children:E})}),D.columns.map((e,t)=>(0,d.jsx)(o.Table.Cell,{headers:`${F} ${I[t]}`,className:(0,u.default)(c.default.value,e.startsGroup&&!(B&&t===0)&&c.default.groupStart),children:h(null,e.key)},t))]})})]})})});m.displayName=`PivotTable`,exports.PivotTable=m;
@@ -54,6 +54,12 @@ export type PivotTableProps = Omit<React.ComponentPropsWithoutRef<"table">, "chi
54
54
  * scrolls with the rest, so that the values stay readable.
55
55
  */
56
56
  stickyRowHeaders?: boolean;
57
+ /**
58
+ * Renders only the rows in view (plus a few around them) and keeps the scroll height
59
+ * with empty spacer rows. Use it for tables with hundreds of rows, together with
60
+ * `maxHeight`. Rows must all have the same height, so keep labels and values on one line.
61
+ */
62
+ virtualized?: boolean;
57
63
  /** Adds a subtotal column after the columns of each column group. */
58
64
  columnSubtotals?: boolean;
59
65
  /** Adds a grand total row at the bottom. */
@@ -122,6 +128,12 @@ export declare const PivotTable: React.ForwardRefExoticComponent<Omit<Omit<React
122
128
  * scrolls with the rest, so that the values stay readable.
123
129
  */
124
130
  stickyRowHeaders?: boolean;
131
+ /**
132
+ * Renders only the rows in view (plus a few around them) and keeps the scroll height
133
+ * with empty spacer rows. Use it for tables with hundreds of rows, together with
134
+ * `maxHeight`. Rows must all have the same height, so keep labels and values on one line.
135
+ */
136
+ virtualized?: boolean;
125
137
  /** Adds a subtotal column after the columns of each column group. */
126
138
  columnSubtotals?: boolean;
127
139
  /** Adds a grand total row at the bottom. */
@@ -1,166 +1,259 @@
1
1
  "use client";
2
2
  import { useWimTranslation as e } from "../../../i18n/useWimTranslation.js";
3
- import t from "../../../icon/chevron-right.js";
4
- import { Icon as n } from "../../media/Icon/Icon.js";
5
- import { useMergedRef as r } from "../../../hooks/useMergedRef.js";
6
- import { Table as i } from "../Table/Table.js";
7
- import { layoutPivotColumns as a, layoutPivotRows as o } from "./layoutPivot.js";
8
- import s from "./pivot-table.module.js";
9
- import c, { useCallback as ee, useMemo as l, useState as u } from "react";
10
- import d from "classnames";
11
- import { jsx as f, jsxs as p } from "react/jsx-runtime";
3
+ import { VisuallyHidden as t } from "../../layout/VisuallyHidden/VisuallyHidden.js";
4
+ import n from "../../../icon/chevron-right.js";
5
+ import { Icon as r } from "../../media/Icon/Icon.js";
6
+ import { useMergedRef as i } from "../../../hooks/useMergedRef.js";
7
+ import { Table as a } from "../Table/Table.js";
8
+ import { layoutPivotColumns as o, layoutPivotRows as s, pivotRowWindow as ee } from "./layoutPivot.js";
9
+ import c from "./pivot-table.module.js";
10
+ import l, { useCallback as te, useMemo as u, useState as d } from "react";
11
+ import f from "classnames";
12
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
12
13
  //#region src/components/data-display/PivotTable/PivotTable.tsx
13
- var m = (e, t = []) => {
14
- for (let n of e) n.children?.length && (t.push(n.key), m(n.children, t));
14
+ var h = 40, ne = 8, re = 30, g = (e, t = []) => {
15
+ for (let n of e) n.children?.length && (t.push(n.key), g(n.children, t));
15
16
  return t;
16
- }, h = c.forwardRef(({ rows: h, columns: g, getValue: _, rowAxisLabel: v, caption: y, expandedValues: b, defaultExpandedValues: x, onExpandedChange: S, maxHeight: C, stickyHeader: w = !1, stickyRowHeaders: te = !1, columnSubtotals: T = !1, totalRow: ne = !1, totalColumn: E = !1, labels: D, className: re, ...O }, ie) => {
17
- let { t: k } = e("components"), A = c.useId(), j = D?.total ?? k("pivottable.total"), M = l(() => a(g, {
17
+ }, _ = l.forwardRef(({ rows: _, columns: ie, getValue: ae, rowAxisLabel: v, caption: y, expandedValues: b, defaultExpandedValues: oe, onExpandedChange: x, maxHeight: S, stickyHeader: C = !1, stickyRowHeaders: se = !1, virtualized: w = !1, columnSubtotals: T = !1, totalRow: E = !1, totalColumn: ce = !1, labels: le, className: ue, ...D }, de) => {
18
+ let { t: fe } = e("components"), O = l.useId(), pe = le?.total ?? fe("pivottable.total"), k = u(() => o(ie, {
18
19
  subtotals: T,
19
- total: E
20
+ total: ce
20
21
  }), [
21
- g,
22
+ ie,
22
23
  T,
23
- E
24
- ]), [N, P] = u(() => x ?? m(h)), F = b ?? N, I = l(() => new Set(F), [F]), L = ee((e) => {
25
- let t = I.has(e) ? F.filter((t) => t !== e) : [...F, e];
26
- b === void 0 && P(t), S?.(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);
27
28
  }, [
28
- F,
29
- I,
29
+ A,
30
+ j,
30
31
  b,
31
- S
32
- ]), R = l(() => o(h, (e) => I.has(e)), [h, I]), z = l(() => m(h).length > 0, [h]), B = v != null && v !== !1, V = `${A}corner`, ae = (e) => `${A}c${e}`, H = (e) => `${A}r${e}`, U = `${A}total`, W = l(() => M.columns.map((e) => e.headerIds.map((e) => `${A}c${e}`).join(" ")), [M, A]), G = c.useRef(null), K = c.useRef(null), [q, oe] = c.useState(!1), [se, ce] = c.useState(!0);
33
- c.useLayoutEffect(() => {
34
- let e = G.current, t = K.current;
32
+ x
33
+ ]), M = u(() => s(_, (e) => j.has(e)), [_, j]), N = u(() => g(_).length > 0, [_]), P = v != null && v !== !1, F = `${O}corner`, _e = (e) => `${O}c${e}`, I = (e) => `${O}r${e}`, L = `${O}total`, R = u(() => k.columns.map((e) => e.headerIds.map((e) => `${O}c${e}`).join(" ")), [k, O]), z = l.useRef(null), B = l.useRef(null), [V, ve] = l.useState(!1), [ye, be] = l.useState(!0);
34
+ l.useLayoutEffect(() => {
35
+ let e = z.current, t = B.current;
35
36
  if (!e || !t || typeof ResizeObserver > "u") return;
36
37
  let n = () => {
37
- oe(e.scrollWidth > e.clientWidth || e.scrollHeight > e.clientHeight);
38
+ ve(e.scrollWidth > e.clientWidth || e.scrollHeight > e.clientHeight);
38
39
  let n = t.rows[0]?.cells[0];
39
- ce(!n || n.offsetWidth <= e.clientWidth / 2);
40
+ be(!n || n.offsetWidth <= e.clientWidth / 2);
40
41
  };
41
42
  n();
42
43
  let r = new ResizeObserver(n);
43
44
  return r.observe(e), r.observe(t), () => r.disconnect();
44
45
  }, []);
45
- let le = r(ie, K), J = te && se, Y = c.useRef([]), [ue, de] = u([]), X = M.depth;
46
- c.useLayoutEffect(() => {
47
- if (!w) return;
48
- let e = Y.current.slice(0, X), t = () => {
46
+ let xe = i(de, B), H = se && ye, U = l.useRef([]), [Se, Ce] = d([]), W = k.depth;
47
+ l.useLayoutEffect(() => {
48
+ if (!C) return;
49
+ let e = U.current.slice(0, W), t = () => {
49
50
  let t = 0, n = e.map((e) => {
50
51
  let n = t;
51
52
  return t += e?.getBoundingClientRect().height ?? 0, n;
52
53
  });
53
- de((e) => e.length === n.length && e.every((e, t) => e === n[t]) ? e : n);
54
+ Ce((e) => e.length === n.length && e.every((e, t) => e === n[t]) ? e : n);
54
55
  };
55
56
  if (t(), typeof ResizeObserver > "u") return;
56
57
  let n = new ResizeObserver(t);
57
58
  return e.forEach((e) => e && n.observe(e)), () => n.disconnect();
58
- }, [w, X]);
59
- let Z = (e, t = !1) => w ? {
60
- top: Math.floor(ue[e] ?? 0),
61
- zIndex: 10 + X - e + +!!t
62
- } : void 0, Q = `${A}caption`, $ = y ? { "aria-labelledby": Q } : O["aria-label"] ? { "aria-label": O["aria-label"] } : O["aria-labelledby"] ? { "aria-labelledby": O["aria-labelledby"] } : null;
63
- return /* @__PURE__ */ f("div", {
64
- ref: G,
65
- className: s.scroller,
66
- style: C === void 0 ? void 0 : { maxHeight: C },
67
- tabIndex: q ? 0 : void 0,
68
- ...q && $ ? {
59
+ }, [C, W]);
60
+ let we = l.useRef(null), [G, Te] = d(0), [K, Ee] = d(null), [q, De] = d(null), [Oe, ke] = d([]), Ae = l.useRef(0), J = te(() => {
61
+ let e = z.current, t = we.current, n = B.current;
62
+ if (!e || !t || !n) return;
63
+ let r = t.querySelector("tr[data-row-index]")?.getBoundingClientRect().height ?? 0;
64
+ r > 0 && Te((e) => Math.abs(e - r) < .01 ? e : r);
65
+ let i = {
66
+ scrollTop: e.scrollTop,
67
+ height: e.clientHeight,
68
+ bodyOffset: t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop
69
+ };
70
+ Ee((e) => e && e.scrollTop === i.scrollTop && e.height === i.height && e.bodyOffset === i.bodyOffset ? e : i);
71
+ let a = Array.from(n.querySelectorAll("thead [data-column-index]")).reduce((e, t) => (e[Number(t.dataset.columnIndex)] = t.getBoundingClientRect().width, e), []), o = Ae.current !== e.clientWidth;
72
+ Ae.current = e.clientWidth, ke((e) => {
73
+ let t = o ? [] : e, n = a.map((e, n) => (e || 0) > (t[n] ?? 0) + .01 ? e : t[n] ?? 0);
74
+ return n.length === e.length && n.every((t, n) => t === e[n]) ? e : n;
75
+ });
76
+ }, []), Y = M.length, X = k.columns.length;
77
+ l.useLayoutEffect(() => {
78
+ if (!w || (J(), typeof ResizeObserver > "u")) return;
79
+ let e = new ResizeObserver(J);
80
+ return z.current && e.observe(z.current), () => e.disconnect();
81
+ }, [
82
+ w,
83
+ J,
84
+ Y,
85
+ X
86
+ ]);
87
+ let je = u(() => new Map(M.map((e, t) => [e.key, t])), [M]), Me = u(() => w ? ee(K ? {
88
+ rowCount: Y,
89
+ rowHeight: G || h,
90
+ scrollTop: K.scrollTop,
91
+ viewportHeight: K.height,
92
+ bodyOffset: K.bodyOffset,
93
+ overscan: ne,
94
+ keep: q === null ? null : je.get(q) ?? null
95
+ } : {
96
+ rowCount: Y,
97
+ rowHeight: h,
98
+ scrollTop: 0,
99
+ viewportHeight: Math.min(Y, re) * h,
100
+ bodyOffset: 0,
101
+ overscan: 0
102
+ }) : null, [
103
+ w,
104
+ K,
105
+ Y,
106
+ G,
107
+ q,
108
+ je
109
+ ]), Ne = u(() => new Map(k.columns.map((e, t) => [e.headerIds[e.headerIds.length - 1], t])), [k]), Z = (e) => w && e !== void 0 ? {
110
+ "data-column-index": e,
111
+ style: Oe[e] ? { minWidth: Oe[e] } : void 0
112
+ } : null, Q = (e, t = !1) => C ? {
113
+ top: Math.floor(Se[e] ?? 0),
114
+ zIndex: 10 + W - e + +!!t
115
+ } : void 0, Pe = `${O}caption`, $ = y ? { "aria-labelledby": Pe } : D["aria-label"] ? { "aria-label": D["aria-label"] } : D["aria-labelledby"] ? { "aria-labelledby": D["aria-labelledby"] } : null, Fe = (e, i) => {
116
+ let o = w ? I(i) : [...e.ancestors.map(I), I(i)].join(" "), s = [...P ? [F] : [], ...w ? [] : e.ancestors.map(I)].join(" ");
117
+ return /* @__PURE__ */ m(a.Row, {
118
+ className: f(e.hasChildren && c.groupRow),
119
+ "data-row-index": w ? i : void 0,
120
+ "data-row-key": w ? e.key : void 0,
121
+ "aria-rowindex": w ? W + i + 1 : void 0,
122
+ children: [/* @__PURE__ */ m("th", {
123
+ id: I(i),
124
+ scope: "row",
125
+ headers: s || void 0,
126
+ className: f(c.rowHeader, H && c.stickyLeft),
127
+ style: { "--wim-pivot-table-depth": e.depth },
128
+ children: [w && e.ancestors.length > 0 && /* @__PURE__ */ p(t, { children: e.ancestors.map((e) => /* @__PURE__ */ m(l.Fragment, { children: [M[e].node.label, ", "] }, e)) }), e.hasChildren ? /* @__PURE__ */ m("button", {
129
+ type: "button",
130
+ className: c.toggle,
131
+ "aria-expanded": e.expanded,
132
+ onClick: () => ge(e.key),
133
+ children: [/* @__PURE__ */ p("span", {
134
+ className: f(c.chevron, e.expanded && c.open),
135
+ "aria-hidden": "true",
136
+ children: /* @__PURE__ */ p(r, {
137
+ component: n,
138
+ size: "sm"
139
+ })
140
+ }), e.node.label]
141
+ }) : /* @__PURE__ */ p("span", {
142
+ className: f(N && c.leafLabel),
143
+ children: e.node.label
144
+ })]
145
+ }), k.columns.map((t, n) => /* @__PURE__ */ p(a.Cell, {
146
+ headers: `${o} ${R[n]}`,
147
+ className: f(c.value, t.kind !== "leaf" && c.aggregate, t.startsGroup && !(H && n === 0) && c.groupStart),
148
+ children: ae(e.key, t.key)
149
+ }, n))]
150
+ }, e.key);
151
+ };
152
+ return /* @__PURE__ */ p("div", {
153
+ ref: z,
154
+ className: c.scroller,
155
+ style: S === void 0 ? void 0 : { maxHeight: S },
156
+ tabIndex: V ? 0 : void 0,
157
+ onScroll: w ? J : void 0,
158
+ ...V && $ ? {
69
159
  role: "region",
70
160
  ...$
71
161
  } : null,
72
- children: /* @__PURE__ */ p("table", {
73
- ref: le,
74
- className: d("wim-pivot-table", s.root, re),
75
- ...O,
162
+ children: /* @__PURE__ */ m("table", {
163
+ ref: xe,
164
+ className: f("wim-pivot-table", c.root, ue),
165
+ "aria-rowcount": w ? W + Y + +!!E : void 0,
166
+ ...D,
76
167
  children: [
77
- y && /* @__PURE__ */ f("caption", {
78
- id: Q,
79
- className: s.caption,
168
+ y && /* @__PURE__ */ p("caption", {
169
+ id: Pe,
170
+ className: c.caption,
80
171
  children: y
81
172
  }),
82
- /* @__PURE__ */ f("colgroup", {}),
83
- M.groupSpans.map((e, t) => /* @__PURE__ */ f("colgroup", { span: e }, t)),
84
- /* @__PURE__ */ f(i.Header, { children: M.headerRows.map((e, t) => /* @__PURE__ */ p("tr", {
173
+ /* @__PURE__ */ p("colgroup", {}),
174
+ k.groupSpans.map((e, t) => /* @__PURE__ */ p("colgroup", { span: e }, t)),
175
+ /* @__PURE__ */ p(a.Header, { children: k.headerRows.map((e, t) => /* @__PURE__ */ m("tr", {
176
+ "aria-rowindex": w ? t + 1 : void 0,
85
177
  ref: (e) => {
86
- Y.current[t] = e;
178
+ U.current[t] = e;
87
179
  },
88
- children: [t === 0 && (B ? /* @__PURE__ */ f("th", {
89
- id: V,
180
+ children: [t === 0 && (P ? /* @__PURE__ */ p("th", {
181
+ id: F,
90
182
  scope: "col",
91
- rowSpan: M.depth,
92
- className: d(s.columnHeader, s.corner, s.bottom, w && s.stickyTop, J && s.stickyLeft),
93
- style: Z(0, !0),
183
+ rowSpan: k.depth,
184
+ className: f(c.columnHeader, c.corner, c.bottom, C && c.stickyTop, H && c.stickyLeft),
185
+ ...Z(0),
186
+ style: {
187
+ ...Q(0, !0),
188
+ ...Z(0)?.style
189
+ },
94
190
  children: v
95
- }) : /* @__PURE__ */ f("td", {
96
- rowSpan: M.depth,
97
- className: d(s.columnHeader, s.bottom, w && s.stickyTop, J && s.stickyLeft),
98
- style: Z(0, !0)
99
- })), e.map((e, n) => /* @__PURE__ */ f("th", {
100
- id: ae(e.id),
191
+ }) : /* @__PURE__ */ p("td", {
192
+ rowSpan: k.depth,
193
+ className: f(c.columnHeader, c.bottom, C && c.stickyTop, H && c.stickyLeft),
194
+ ...Z(0),
195
+ style: {
196
+ ...Q(0, !0),
197
+ ...Z(0)?.style
198
+ }
199
+ })), e.map((e, n) => /* @__PURE__ */ p("th", {
200
+ id: _e(e.id),
101
201
  scope: e.kind === "group" && e.topLevel ? "colgroup" : "col",
102
202
  colSpan: e.colSpan > 1 ? e.colSpan : void 0,
103
203
  rowSpan: e.rowSpan > 1 ? e.rowSpan : void 0,
104
- className: d(s.columnHeader, e.kind === "group" && s.group, e.reachesBottom && s.bottom, e.startsGroup && !(J && n === 0) && s.groupStart, w && s.stickyTop),
105
- style: Z(t),
106
- children: e.kind === "group" || e.kind === "leaf" ? e.node?.label : j
204
+ className: f(c.columnHeader, e.kind === "group" && c.group, e.reachesBottom && c.bottom, e.startsGroup && !(H && n === 0) && c.groupStart, C && c.stickyTop),
205
+ ...e.reachesBottom ? Z((Ne.get(e.id) ?? -1) + 1) : null,
206
+ style: {
207
+ ...Q(t),
208
+ ...e.reachesBottom ? Z((Ne.get(e.id) ?? -1) + 1)?.style : null
209
+ },
210
+ children: e.kind === "group" || e.kind === "leaf" ? e.node?.label : pe
107
211
  }, e.id))]
108
212
  }, t)) }),
109
- /* @__PURE__ */ f(i.Body, { children: R.map((e, r) => {
110
- let a = [...e.ancestors.map(H), H(r)].join(" "), o = [...B ? [V] : [], ...e.ancestors.map(H)].join(" ");
111
- return /* @__PURE__ */ p(i.Row, {
112
- className: d(e.hasChildren && s.groupRow),
113
- children: [/* @__PURE__ */ f("th", {
114
- id: H(r),
115
- scope: "row",
116
- headers: o || void 0,
117
- className: d(s.rowHeader, J && s.stickyLeft),
118
- style: { "--wim-pivot-table-depth": e.depth },
119
- children: e.hasChildren ? /* @__PURE__ */ p("button", {
120
- type: "button",
121
- className: s.toggle,
122
- "aria-expanded": e.expanded,
123
- onClick: () => L(e.key),
124
- children: [/* @__PURE__ */ f("span", {
125
- className: d(s.chevron, e.expanded && s.open),
126
- "aria-hidden": "true",
127
- children: /* @__PURE__ */ f(n, {
128
- component: t,
129
- size: "sm"
130
- })
131
- }), e.node.label]
132
- }) : /* @__PURE__ */ f("span", {
133
- className: d(z && s.leafLabel),
134
- children: e.node.label
135
- })
136
- }), M.columns.map((t, n) => /* @__PURE__ */ f(i.Cell, {
137
- headers: `${a} ${W[n]}`,
138
- className: d(s.value, t.kind !== "leaf" && s.aggregate, t.startsGroup && !(J && n === 0) && s.groupStart),
139
- children: _(e.key, t.key)
140
- }, n))]
141
- }, e.key);
142
- }) }),
143
- ne && /* @__PURE__ */ f(i.Footer, { children: /* @__PURE__ */ p(i.Row, {
144
- className: s.totalRow,
145
- children: [/* @__PURE__ */ f("th", {
146
- id: U,
213
+ /* @__PURE__ */ p(a.Body, {
214
+ ref: we,
215
+ onFocus: w ? (e) => {
216
+ let t = e.target.closest("tr")?.dataset.rowKey;
217
+ t !== void 0 && De(t);
218
+ } : void 0,
219
+ onBlur: w ? (e) => {
220
+ e.currentTarget.contains(e.relatedTarget) || De(null);
221
+ } : void 0,
222
+ children: (Me ?? [{
223
+ kind: "rows",
224
+ from: 0,
225
+ to: Y
226
+ }]).map((e, t) => e.kind === "gap" ? /* @__PURE__ */ p("tr", {
227
+ "aria-hidden": "true",
228
+ className: c.gap,
229
+ children: /* @__PURE__ */ p("td", {
230
+ colSpan: X + 1,
231
+ style: { height: e.count * (G || h) }
232
+ })
233
+ }, `gap-${t}`) : M.slice(e.from, e.to).map((t, n) => Fe(t, e.from + n)))
234
+ }),
235
+ E && /* @__PURE__ */ p(a.Footer, { children: /* @__PURE__ */ m(a.Row, {
236
+ className: c.totalRow,
237
+ "aria-rowindex": w ? W + Y + 1 : void 0,
238
+ children: [/* @__PURE__ */ p("th", {
239
+ id: L,
147
240
  scope: "row",
148
- headers: B ? V : void 0,
149
- className: d(s.rowHeader, J && s.stickyLeft),
150
- children: /* @__PURE__ */ f("span", {
151
- className: d(z && s.leafLabel),
152
- children: j
241
+ headers: P ? F : void 0,
242
+ className: f(c.rowHeader, H && c.stickyLeft),
243
+ children: /* @__PURE__ */ p("span", {
244
+ className: f(N && c.leafLabel),
245
+ children: pe
153
246
  })
154
- }), M.columns.map((e, t) => /* @__PURE__ */ f(i.Cell, {
155
- headers: `${U} ${W[t]}`,
156
- className: d(s.value, e.startsGroup && !(J && t === 0) && s.groupStart),
157
- children: _(null, e.key)
247
+ }), k.columns.map((e, t) => /* @__PURE__ */ p(a.Cell, {
248
+ headers: `${L} ${R[t]}`,
249
+ className: f(c.value, e.startsGroup && !(H && t === 0) && c.groupStart),
250
+ children: ae(null, e.key)
158
251
  }, t))]
159
252
  }) })
160
253
  ]
161
254
  })
162
255
  });
163
256
  });
164
- h.displayName = "PivotTable";
257
+ _.displayName = "PivotTable";
165
258
  //#endregion
166
- export { h as PivotTable };
259
+ export { _ as PivotTable };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=e=>!!e.children?.length,t=n=>n.reduce((n,r)=>Math.max(n,1+(e(r)?t(r.children):0)),0);function n(n,r={}){let i=Math.max(1,t(n)),a=Array.from({length:i},()=>[]),o=[],s=[],c=0,l=(e,t,n,r,s,l)=>{let u=c++,d=e?.key??null;a[n].push({id:u,key:d,node:e,kind:t,colSpan:1,rowSpan:i-n,reachesBottom:!0,startsGroup:l,topLevel:s}),o.push({key:d,kind:t,headerIds:[...r,u],startsGroup:l})},u=(t,n,i,o)=>{let s=n===0;if(!e(t))return l(t,`leaf`,n,i,s,o),1;let d={id:c++,key:t.key,node:t,kind:`group`,colSpan:0,rowSpan:1,reachesBottom:!1,startsGroup:o,topLevel:s};a[n].push(d);let f=[...i,d.id],p=0;return t.children.forEach((e,t)=>{p+=u(e,n+1,f,o&&t===0)}),r.subtotals&&(l(t,`subtotal`,n+1,f,!1,!1),p+=1),d.colSpan=p,p};for(let e of n)s.push(u(e,0,[],!0));return r.total&&(l(null,`total`,0,[],!0,!0),s.push(1)),{headerRows:a,columns:o,depth:i,groupSpans:s}}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}exports.layoutPivotColumns=n,exports.layoutPivotRows=r;
2
+ var e=e=>!!e.children?.length,t=n=>n.reduce((n,r)=>Math.max(n,1+(e(r)?t(r.children):0)),0);function n(n,r={}){let i=Math.max(1,t(n)),a=Array.from({length:i},()=>[]),o=[],s=[],c=0,l=(e,t,n,r,s,l)=>{let u=c++,d=e?.key??null;a[n].push({id:u,key:d,node:e,kind:t,colSpan:1,rowSpan:i-n,reachesBottom:!0,startsGroup:l,topLevel:s}),o.push({key:d,kind:t,headerIds:[...r,u],startsGroup:l})},u=(t,n,i,o)=>{let s=n===0;if(!e(t))return l(t,`leaf`,n,i,s,o),1;let d={id:c++,key:t.key,node:t,kind:`group`,colSpan:0,rowSpan:1,reachesBottom:!1,startsGroup:o,topLevel:s};a[n].push(d);let f=[...i,d.id],p=0;return t.children.forEach((e,t)=>{p+=u(e,n+1,f,o&&t===0)}),r.subtotals&&(l(t,`subtotal`,n+1,f,!1,!1),p+=1),d.colSpan=p,p};for(let e of n)s.push(u(e,0,[],!0));return r.total&&(l(null,`total`,0,[],!0,!0),s.push(1)),{headerRows:a,columns:o,depth:i,groupSpans:s}}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;
@@ -65,3 +65,32 @@ export declare function layoutPivotColumns<T extends PivotAxisInput>(nodes: T[],
65
65
  * 折りたたまれたグループは自分の行だけを出し、配下の行は出さない。
66
66
  */
67
67
  export declare function layoutPivotRows<T extends PivotAxisInput>(nodes: T[], isExpanded?: (key: string) => boolean): PivotRow<T>[];
68
+ /** 仮想化したときに描く行の並び。`gap` は、描かない行を 1 つの空の行でまとめた分。 */
69
+ export type PivotRowSegment = {
70
+ kind: "rows";
71
+ from: number;
72
+ to: number;
73
+ } | {
74
+ kind: "gap";
75
+ count: number;
76
+ };
77
+ export type PivotRowWindowInput = {
78
+ rowCount: number;
79
+ /** 1 行の高さ(全行が同じ高さの前提)。0 以下なら全部描く。 */
80
+ rowHeight: number;
81
+ /** スクロールの器の `scrollTop`。 */
82
+ scrollTop: number;
83
+ /** スクロールの器の見えている高さ。 */
84
+ viewportHeight: number;
85
+ /** 器の中身の先頭から、最初の行までの距離(caption と見出しの高さ)。 */
86
+ bodyOffset: number;
87
+ /** 見えている範囲の上下に、余分に描いておく行の数。 */
88
+ overscan: number;
89
+ /** 範囲の外でも描いたままにする行(フォーカスを持つ行)。 */
90
+ keep?: number | null;
91
+ };
92
+ /**
93
+ * 見えている行(と上下の余分)だけを描くための並びを返す。描かない行は `gap` にまとめ、
94
+ * 行の総数ぶんの高さが保たれるようにする。`keep` の行は、範囲の外にあっても 1 行だけ描く。
95
+ */
96
+ export declare function pivotRowWindow(input: PivotRowWindowInput): PivotRowSegment[];
@@ -64,5 +64,33 @@ function r(t, n = () => !0) {
64
64
  };
65
65
  return i(t, 0, []), r;
66
66
  }
67
+ function i(e) {
68
+ let { rowCount: t, rowHeight: n, scrollTop: r, viewportHeight: i, bodyOffset: a, overscan: o, keep: s } = e;
69
+ if (t <= 0) return [];
70
+ if (n <= 0) return [{
71
+ kind: "rows",
72
+ from: 0,
73
+ to: t
74
+ }];
75
+ 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) => {
76
+ e > 0 && f.push({
77
+ kind: "gap",
78
+ count: e
79
+ });
80
+ }, m = s != null && s >= 0 && s < t ? s : null;
81
+ return m !== null && m < u ? (p(m), f.push({
82
+ kind: "rows",
83
+ from: m,
84
+ to: m + 1
85
+ }), p(u - m - 1)) : p(u), f.push({
86
+ kind: "rows",
87
+ from: u,
88
+ to: d
89
+ }), m !== null && m >= d ? (p(m - d), f.push({
90
+ kind: "rows",
91
+ from: m,
92
+ to: m + 1
93
+ }), p(t - m - 1)) : p(t - d), f;
94
+ }
67
95
  //#endregion
68
- export { n as layoutPivotColumns, r as layoutPivotRows };
96
+ export { n as layoutPivotColumns, r as layoutPivotRows, i as pivotRowWindow };
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var e=`_scroller_1xfhj_7`,t=`_root_1xfhj_22`,n=`_caption_1xfhj_34`,r=`_columnHeader_1xfhj_41`,i=`_group_1xfhj_55`,a=`_bottom_1xfhj_62`,o=`_corner_1xfhj_65`,s=`_rowHeader_1xfhj_68`,c=`_toggle_1xfhj_81`,l=`_chevron_1xfhj_100`,u=`_open_1xfhj_116`,d=`_leafLabel_1xfhj_120`,f=`_value_1xfhj_127`,p=`_groupRow_1xfhj_133`,m=`_aggregate_1xfhj_138`,h=`_groupStart_1xfhj_142`,g=`_totalRow_1xfhj_145`,_=`_stickyTop_1xfhj_154`,v=`_stickyLeft_1xfhj_159`,y={scroller:e,root:t,caption:n,columnHeader:r,group:i,bottom:a,corner:o,rowHeader:s,toggle:c,chevron:l,open:u,leafLabel:d,value:f,groupRow:p,aggregate:m,groupStart:h,totalRow:g,stickyTop:_,stickyLeft:v};exports.aggregate=m,exports.bottom=a,exports.caption=n,exports.chevron=l,exports.columnHeader=r,exports.corner=o,exports.default=y,exports.group=i,exports.groupRow=p,exports.groupStart=h,exports.leafLabel=d,exports.open=u,exports.root=t,exports.rowHeader=s,exports.scroller=e,exports.stickyLeft=v,exports.stickyTop=_,exports.toggle=c,exports.totalRow=g,exports.value=f;
2
+ var e=`_scroller_1kzph_7`,t=`_root_1kzph_22`,n=`_caption_1kzph_34`,r=`_columnHeader_1kzph_41`,i=`_group_1kzph_55`,a=`_bottom_1kzph_62`,o=`_corner_1kzph_65`,s=`_rowHeader_1kzph_68`,c=`_toggle_1kzph_83`,l=`_chevron_1kzph_102`,u=`_open_1kzph_118`,d=`_leafLabel_1kzph_122`,f=`_value_1kzph_129`,p=`_groupRow_1kzph_135`,m=`_aggregate_1kzph_140`,h=`_groupStart_1kzph_144`,g=`_totalRow_1kzph_147`,_=`_gap_1kzph_152`,v=`_stickyTop_1kzph_161`,y=`_stickyLeft_1kzph_166`,b={scroller:e,root:t,caption:n,columnHeader:r,group:i,bottom:a,corner:o,rowHeader:s,toggle:c,chevron:l,open:u,leafLabel:d,value:f,groupRow:p,aggregate:m,groupStart:h,totalRow:g,gap:_,stickyTop:v,stickyLeft:y};exports.aggregate=m,exports.bottom=a,exports.caption=n,exports.chevron=l,exports.columnHeader=r,exports.corner=o,exports.default=b,exports.gap=_,exports.group=i,exports.groupRow=p,exports.groupStart=h,exports.leafLabel=d,exports.open=u,exports.root=t,exports.rowHeader=s,exports.scroller=e,exports.stickyLeft=y,exports.stickyTop=v,exports.toggle=c,exports.totalRow=g,exports.value=f;
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  //#region src/components/data-display/PivotTable/pivot-table.module.scss
3
- var e = "_scroller_1xfhj_7", t = "_root_1xfhj_22", n = "_caption_1xfhj_34", r = "_columnHeader_1xfhj_41", i = "_group_1xfhj_55", a = "_bottom_1xfhj_62", o = "_corner_1xfhj_65", s = "_rowHeader_1xfhj_68", c = "_toggle_1xfhj_81", l = "_chevron_1xfhj_100", u = "_open_1xfhj_116", d = "_leafLabel_1xfhj_120", f = "_value_1xfhj_127", p = "_groupRow_1xfhj_133", m = "_aggregate_1xfhj_138", h = "_groupStart_1xfhj_142", g = "_totalRow_1xfhj_145", _ = "_stickyTop_1xfhj_154", v = "_stickyLeft_1xfhj_159", y = {
3
+ var e = "_scroller_1kzph_7", t = "_root_1kzph_22", n = "_caption_1kzph_34", r = "_columnHeader_1kzph_41", i = "_group_1kzph_55", a = "_bottom_1kzph_62", o = "_corner_1kzph_65", s = "_rowHeader_1kzph_68", c = "_toggle_1kzph_83", l = "_chevron_1kzph_102", u = "_open_1kzph_118", d = "_leafLabel_1kzph_122", f = "_value_1kzph_129", p = "_groupRow_1kzph_135", m = "_aggregate_1kzph_140", h = "_groupStart_1kzph_144", g = "_totalRow_1kzph_147", _ = "_gap_1kzph_152", v = "_stickyTop_1kzph_161", y = "_stickyLeft_1kzph_166", b = {
4
4
  scroller: e,
5
5
  root: t,
6
6
  caption: n,
@@ -18,8 +18,9 @@ var e = "_scroller_1xfhj_7", t = "_root_1xfhj_22", n = "_caption_1xfhj_34", r =
18
18
  aggregate: m,
19
19
  groupStart: h,
20
20
  totalRow: g,
21
- stickyTop: _,
22
- stickyLeft: v
21
+ gap: _,
22
+ stickyTop: v,
23
+ stickyLeft: y
23
24
  };
24
25
  //#endregion
25
- export { m as aggregate, a as bottom, n as caption, l as chevron, r as columnHeader, o as corner, y as default, i as group, p as groupRow, h as groupStart, d as leafLabel, u as open, t as root, s as rowHeader, e as scroller, v as stickyLeft, _ as stickyTop, c as toggle, g as totalRow, f as value };
26
+ export { m as aggregate, a as bottom, n as caption, l as chevron, r as columnHeader, o as corner, b as default, _ as gap, i as group, p as groupRow, h as groupStart, d as leafLabel, u as open, t as root, s as rowHeader, e as scroller, y as stickyLeft, v as stickyTop, c as toggle, g as totalRow, f as value };
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## What this is
6
6
 
7
- **wimui** v0.45.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
7
+ **wimui** v0.46.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
8
8
 
9
9
  ## Install & required setup
10
10
 
@@ -2510,6 +2510,9 @@ level stays, stacked in order. Only has an effect together with `maxHeight`.
2510
2510
  - `stickyRowHeaders: boolean` = false — Keeps the row headings in view while the table scrolls sideways. The column is only
2511
2511
  pinned while it takes at most half of the visible width; in a narrower container it
2512
2512
  scrolls with the rest, so that the values stay readable.
2513
+ - `virtualized: boolean` = false — Renders only the rows in view (plus a few around them) and keeps the scroll height
2514
+ with empty spacer rows. Use it for tables with hundreds of rows, together with
2515
+ `maxHeight`. Rows must all have the same height, so keep labels and values on one line.
2513
2516
  - `columnSubtotals: boolean` = false — Adds a subtotal column after the columns of each column group.
2514
2517
  - `totalRow: boolean` = false — Adds a grand total row at the bottom.
2515
2518
  - `totalColumn: boolean` = false — Adds a grand total column at the right edge.
package/dist/llms.txt CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## What this is
6
6
 
7
- **wimui** v0.45.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
7
+ **wimui** v0.46.0 — a React 19 component library: 228 documented components across 10 categories, with design tokens, dark mode, i18n (en/ja/pt-BR) and WAI-ARIA compliant a11y. Peer deps: react ^19, react-dom ^19 (plus optional peers for specific components — see package.json).
8
8
 
9
9
  ## Install & required setup
10
10