virtua 0.52.0 → 0.52.1

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,5 +1,5 @@
1
1
  import { ReactElement, ReactNode, Ref } from 'react';
2
- import { VGridAxis, VGridCell, VGridSize, VGridSpan, VGridScrollToIndexOpts } from '../core/index.js';
2
+ import { GridAxis, GridCell as GridCellType, GridSize, GridSpan, GridScrollToIndexOpts } from '../core/index.js';
3
3
  import { ViewportComponentAttributes } from './types.js';
4
4
  /**
5
5
  * Methods of {@link VGrid}.
@@ -61,9 +61,9 @@ export interface VGridHandle {
61
61
  getColSize(index: number): number;
62
62
  /**
63
63
  * Scroll to the cell specified by the indexes. The cell is not hidden behind the rows and the columns sticking over it.
64
- * @param opts the indexes of the cell and the options. See {@link VGridScrollToIndexOpts}.
64
+ * @param opts the indexes of the cell and the options. See {@link GridScrollToIndexOpts}.
65
65
  */
66
- scrollToIndex(opts: VGridScrollToIndexOpts): void;
66
+ scrollToIndex(opts: GridScrollToIndexOpts): void;
67
67
  /**
68
68
  * Scroll to the given offsets from the top/start of the scroll container.
69
69
  * @param offset the offsets. The axis whose offset is omitted is not scrolled.
@@ -91,23 +91,23 @@ export interface VGridProps<R = number, C = number> extends Omit<ViewportCompone
91
91
  * @param col the item of {@link VGridProps.cols} at the column of the cell, or the column index if {@link VGridProps.cols} is a number
92
92
  * @param cell the row index and the column index of the cell
93
93
  */
94
- children: (row: R, col: C, cell: Readonly<VGridCell>) => ReactNode;
94
+ children: (row: R, col: C, cell: Readonly<GridCellType>) => ReactNode;
95
95
  /**
96
- * The rows of the grid. See {@link VGridAxis} for the accepted values.
96
+ * The rows of the grid. See {@link GridAxis} for the accepted values.
97
97
  */
98
- rows: VGridAxis<R>;
98
+ rows: GridAxis<R>;
99
99
  /**
100
- * The columns of the grid. See {@link VGridAxis} for the accepted values.
100
+ * The columns of the grid. See {@link GridAxis} for the accepted values.
101
101
  */
102
- cols: VGridAxis<C>;
102
+ cols: GridAxis<C>;
103
103
  /**
104
- * The heights of the rows. See {@link VGridSize} for the accepted values.
104
+ * The heights of the rows. See {@link GridSize} for the accepted values.
105
105
  */
106
- rowHeight: NoInfer<VGridSize<R>>;
106
+ rowHeight: GridSize<R>;
107
107
  /**
108
- * The widths of the columns. See {@link VGridSize} for the accepted values.
108
+ * The widths of the columns. See {@link GridSize} for the accepted values.
109
109
  */
110
- colWidth: NoInfer<VGridSize<C>>;
110
+ colWidth: GridSize<C>;
111
111
  /**
112
112
  * The number of the leading rows pinned to the start, which are the column headers (`role="columnheader"`).
113
113
  *
@@ -143,15 +143,15 @@ export interface VGridProps<R = number, C = number> extends Omit<ViewportCompone
143
143
  */
144
144
  footerCols?: number;
145
145
  /**
146
- * Cells merged over multiple rows and/or columns. See {@link VGridSpan} for the accepted values.
146
+ * Cells merged over multiple rows and/or columns. See {@link GridSpan} for the accepted values.
147
147
  *
148
148
  * The cell at the origin is stretched over the merged area, and the other cells in it are not rendered. Spans must not overlap each other or cross the boundaries of the pinned rows/columns or the sections. A spanning cell is not measured for `"auto"` sizes on the axes it spans, and doesn't enlarge those tracks.
149
149
  */
150
- spans?: readonly VGridSpan[];
150
+ spans?: readonly GridSpan[];
151
151
  /**
152
152
  * List of cells that should be always mounted, even when off screen.
153
153
  */
154
- keepMounted?: readonly VGridCell[];
154
+ keepMounted?: readonly GridCellType[];
155
155
  /**
156
156
  * Extra space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank cells in fast scrolling.
157
157
  * @defaultValue 200
@@ -165,7 +165,7 @@ export interface VGridProps<R = number, C = number> extends Omit<ViewportCompone
165
165
  /**
166
166
  * The header cell of the sorted column or row, and the sort order (`aria-sort`).
167
167
  */
168
- ariaSort?: VGridCell & {
168
+ ariaSort?: GridCellType & {
169
169
  order: "ascending" | "descending" | "other";
170
170
  };
171
171
  /**
@@ -6,5 +6,5 @@ export { WindowVirtualizer } from './WindowVirtualizer.js';
6
6
  export type { WindowVirtualizerProps, WindowVirtualizerHandle, } from './WindowVirtualizer.js';
7
7
  export { VGrid } from './VGrid.js';
8
8
  export type { VGridProps, VGridHandle } from './VGrid.js';
9
- export type { VGridSize, VGridSpan } from '../core/index.js';
9
+ export type { GridSize, GridSpan } from '../core/index.js';
10
10
  export type * from './types.js';
@@ -1,5 +1,5 @@
1
1
  import { JSX } from 'solid-js';
2
- import { VGridScrollToIndexOpts, VGridAxis, VGridCell, VGridSize, VGridSpan } from '../core/index.js';
2
+ import { GridScrollToIndexOpts, GridAxis, GridCell as GridCellType, GridSize, GridSpan } from '../core/index.js';
3
3
  import { ViewportComponentAttributes } from './types.js';
4
4
  /**
5
5
  * Methods of {@link VGrid}.
@@ -61,9 +61,9 @@ export interface VGridHandle {
61
61
  getColSize(index: number): number;
62
62
  /**
63
63
  * Scroll to the cell specified by the indexes. The cell is not hidden behind the rows and the columns sticking over it.
64
- * @param opts the indexes of the cell and the options. See {@link VGridScrollToIndexOpts}.
64
+ * @param opts the indexes of the cell and the options. See {@link GridScrollToIndexOpts}.
65
65
  */
66
- scrollToIndex(opts: VGridScrollToIndexOpts): void;
66
+ scrollToIndex(opts: GridScrollToIndexOpts): void;
67
67
  /**
68
68
  * Scroll to the given offsets from the top/start of the scroll container.
69
69
  * @param offset the offsets. The axis whose offset is omitted is not scrolled.
@@ -95,23 +95,23 @@ export interface VGridProps<R = number, C = number> extends Omit<ViewportCompone
95
95
  * @param col the item of {@link VGridProps.cols} at the column of the cell, or the column index if {@link VGridProps.cols} is a number
96
96
  * @param cell the row index and the column index of the cell
97
97
  */
98
- children: (row: R, col: C, cell: Readonly<VGridCell>) => JSX.Element;
98
+ children: (row: R, col: C, cell: Readonly<GridCellType>) => JSX.Element;
99
99
  /**
100
- * The rows of the grid. See {@link VGridAxis} for the accepted values.
100
+ * The rows of the grid. See {@link GridAxis} for the accepted values.
101
101
  */
102
- rows: VGridAxis<R>;
102
+ rows: GridAxis<R>;
103
103
  /**
104
- * The columns of the grid. See {@link VGridAxis} for the accepted values.
104
+ * The columns of the grid. See {@link GridAxis} for the accepted values.
105
105
  */
106
- cols: VGridAxis<C>;
106
+ cols: GridAxis<C>;
107
107
  /**
108
- * The heights of the rows. See {@link VGridSize} for the accepted values.
108
+ * The heights of the rows. See {@link GridSize} for the accepted values.
109
109
  */
110
- rowHeight: NoInfer<VGridSize<R>>;
110
+ rowHeight: GridSize<R>;
111
111
  /**
112
- * The widths of the columns. See {@link VGridSize} for the accepted values.
112
+ * The widths of the columns. See {@link GridSize} for the accepted values.
113
113
  */
114
- colWidth: NoInfer<VGridSize<C>>;
114
+ colWidth: GridSize<C>;
115
115
  /**
116
116
  * The number of the leading rows pinned to the start, which are the column headers (`role="columnheader"`).
117
117
  *
@@ -147,15 +147,15 @@ export interface VGridProps<R = number, C = number> extends Omit<ViewportCompone
147
147
  */
148
148
  footerCols?: number;
149
149
  /**
150
- * Cells merged over multiple rows and/or columns. See {@link VGridSpan} for the accepted values.
150
+ * Cells merged over multiple rows and/or columns. See {@link GridSpan} for the accepted values.
151
151
  *
152
152
  * The cell at the origin is stretched over the merged area, and the other cells in it are not rendered. Spans must not overlap each other or cross the boundaries of the pinned rows/columns or the sections. A spanning cell is not measured for `"auto"` sizes on the axes it spans, and doesn't enlarge those tracks.
153
153
  */
154
- spans?: readonly VGridSpan[];
154
+ spans?: readonly GridSpan[];
155
155
  /**
156
156
  * List of cells that should be always mounted, even when off screen.
157
157
  */
158
- keepMounted?: readonly VGridCell[];
158
+ keepMounted?: readonly GridCellType[];
159
159
  /**
160
160
  * Extra space in pixels to render before/after the viewport. The minimum value is 0. Lower value will give better performance but you can increase to avoid showing blank cells in fast scrolling.
161
161
  * @defaultValue 200
@@ -169,7 +169,7 @@ export interface VGridProps<R = number, C = number> extends Omit<ViewportCompone
169
169
  /**
170
170
  * The header cell of the sorted column or row, and the sort order (`aria-sort`).
171
171
  */
172
- ariaSort?: VGridCell & {
172
+ ariaSort?: GridCellType & {
173
173
  order: "ascending" | "descending" | "other";
174
174
  };
175
175
  /**
@@ -808,49 +808,51 @@ exports.VGrid = r => {
808
808
  let h = 0, _ = !e.D(r) && null, k = r + 1, T = !1;
809
809
  for (let e = 0; e < Z; e++) {
810
810
  const o = Y[e], l = o < x, c = o >= z, a = c || o >= I && o <= q, g = F.get(f + o);
811
- if (g ? g.rowIndex !== r || g.colIndex !== o : !(i && a || n || u || l)) continue;
812
- const w = g ? C(g, v) : r + 1, S = g ? L(g, m) : o + 1, y = w - r > 1, b = S - o > 1, R = y || b, M = R ? w - r : void 0, O = R ? S - o : void 0;
813
- let W, E;
814
- k = s(k, w);
815
- const H = l ? t.$(o) : null, j = c ? t.l() - t.$(S - 1) - t.v(S - 1) : null;
816
- !1 !== _ || y || (W = r, _ = !0), !1 !== N[e] || b || (E = o, N[e] = !0);
817
- const B = n ? "columnheader" : o === A && (l || u) ? "rowheader" : "cell", D = "cell" !== B && $ && $.rowIndex === r && $.colIndex === o ? $.order : void 0;
818
- let P;
819
- if (d) {
820
- for (;h < d.length && d[h].$e < o; ) h++;
821
- h < d.length && (P = d[h]);
822
- }
823
- if (!P || P.$e !== o || P.we !== M || P.Se !== O || P.Te !== H || P.Re !== j || P.fe !== W || P.ge !== E || P.me !== B || P.xe !== D) {
824
- const e = {
825
- contain: "layout style",
826
- display: "grid",
827
- gridArea: R ? "1/l" + o + "/l" + w + "/l" + S : "1/l" + o
828
- };
829
- y && (e.height = "0px", e.minHeight = "100%", e.zIndex = 1), b && (e.width = "0px",
830
- e.minWidth = "100%"), (l || c) && (l ? e.insetInlineStart = H + "px" : e.insetInlineEnd = j + "px",
831
- e.position = "sticky", e.zIndex = 2), P = {
832
- $e: o,
833
- we: M,
834
- Se: O,
835
- fe: W,
836
- ge: E,
837
- me: B,
838
- xe: D,
839
- ve: e,
840
- Te: H,
841
- Re: j
842
- }, T = !0;
811
+ if (g ? g.rowIndex === r && g.colIndex === o : i && a || n || u || l) {
812
+ const i = g ? C(g, v) : r + 1, a = g ? L(g, m) : o + 1, f = i - r > 1, w = a - o > 1, S = f || w, x = S ? i - r : void 0, z = S ? a - o : void 0;
813
+ let y, b;
814
+ k = s(k, i);
815
+ const I = l ? t.$(o) : null, R = c ? t.l() - t.$(a - 1) - t.v(a - 1) : null;
816
+ !1 !== _ || f || (y = r, _ = !0), !1 !== N[e] || w || (b = o, N[e] = !0);
817
+ const M = n ? "columnheader" : o === A && (l || u) ? "rowheader" : "cell", O = "cell" !== M && $ && $.rowIndex === r && $.colIndex === o ? $.order : void 0;
818
+ let W;
819
+ if (d) {
820
+ for (;h < d.length && d[h].$e < o; ) h++;
821
+ h < d.length && (W = d[h]);
822
+ }
823
+ if (!W || W.$e !== o || W.we !== x || W.Se !== z || W.Te !== I || W.Re !== R || W.fe !== y || W.ge !== b || W.me !== M || W.xe !== O) {
824
+ const e = {
825
+ contain: "layout style",
826
+ display: "grid",
827
+ gridArea: S ? "1/l" + o + "/l" + i + "/l" + a : "1/l" + o
828
+ };
829
+ f && (e.height = "0px", e.minHeight = "100%", e.zIndex = 1), w && (e.width = "0px",
830
+ e.minWidth = "100%"), (l || c) && (l ? e.insetInlineStart = I + "px" : e.insetInlineEnd = R + "px",
831
+ e.position = "sticky", e.zIndex = 2), W = {
832
+ $e: o,
833
+ we: x,
834
+ Se: z,
835
+ fe: y,
836
+ ge: b,
837
+ me: M,
838
+ xe: O,
839
+ ve: e,
840
+ Te: I,
841
+ Re: R
842
+ }, T = !0;
843
+ }
844
+ p.push(W);
843
845
  }
844
- p.push(P);
845
846
  }
846
- if (Q.push(_), !p.length) continue;
847
- const M = g && !T && g.ze.length === p.length && g.Me === a ? g : {
848
- be: r,
849
- ze: p,
850
- ve: E(r, k, a, "top", 3),
851
- Me: a
852
- };
853
- oe.set(r, M), re.push(M);
847
+ if (Q.push(_), p.length) {
848
+ const e = g && !T && g.ze.length === p.length && g.Me === a ? g : {
849
+ be: r,
850
+ ze: p,
851
+ ve: E(r, k, a, "top", 3),
852
+ Me: a
853
+ };
854
+ oe.set(r, e), re.push(e);
855
+ }
854
856
  }
855
857
  return _.set(e, oe), {
856
858
  Oe: W(e, X, Q, u(G), "max-content", v),