@sheetxl/primitives 0.8.0-beta.5 → 0.8.0-beta.7

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
  /**
2
- * @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.5
2
+ * @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.7
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.5
2
+ * @license @sheetxl/primitives - Primitives - Base types for SheetXL functions. - v0.8.0-beta.7
3
3
  *
4
4
  * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
5
  * License: The license can be found at https://www.sheetxl.com/license.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sheetxl/primitives",
3
3
  "description": "Primitives - Base types for SheetXL functions.",
4
- "version": "0.8.0-beta.5",
4
+ "version": "0.8.0-beta.7",
5
5
  "license": "SEE LICENSE IN <LICENSE>",
6
6
  "type": "module",
7
7
  "exports": {
@@ -66,7 +66,7 @@ export declare class StubbedFormulaContext implements IFormulaContext {
66
66
  /** @inheritdoc IFormulaContext.formatResults */
67
67
  formatResults(numFmt: string): void;
68
68
  /** @inheritdoc IFormulaContext.filterHidden */
69
- filterHidden(range: IRange, axes?: IRange.AxisSelection): IRange;
69
+ filterHidden(range: IRange, options?: IFormulaContext.FilterHiddenOptions): IRange;
70
70
  /** @inheritdoc IFormulaContext.filterTotals */
71
71
  filterTotals(range: IRange): IRange;
72
72
  /** @inheritdoc IFormulaContext.getFunction */
@@ -225,7 +225,7 @@ export declare class ScopedFormulaContext implements IFormulaContext {
225
225
  /** @inheritdoc IFormulaContext.formatResults */
226
226
  formatResults(numFmt: string): void;
227
227
  /** @inheritdoc IFormulaContext.filterHidden */
228
- filterHidden(range: IRange, axes?: IRange.AxisSelection): IRange;
228
+ filterHidden(range: IRange, options?: IFormulaContext.FilterHiddenOptions): IRange;
229
229
  /** @inheritdoc IFormulaContext.filterTotals */
230
230
  filterTotals(range: IRange): IRange;
231
231
  /** @inheritdoc IFormulaContext.getFunction */
@@ -219,16 +219,30 @@ export interface IFormulaContext {
219
219
  */
220
220
  getSheetIndex(sheet?: string | IReferenceRange): number;
221
221
  /**
222
- * Returns a copy of a range with hidden rows or columns removed.
222
+ * Returns a range as it reads without its hidden rows or columns.
223
223
  *
224
224
  * @param range The range to filter.
225
- * @param axes Which axis to filter on. Default is `IRange.AxisSelection.Row`.
226
- * @returns A new range without the hidden rows or columns.
225
+ * @param options See {@link IFormulaContext.FilterHiddenOptions}.
226
+ * @returns `range` itself when nothing in it is hidden; otherwise the same range reading with
227
+ * the hidden rows or columns skipped ({@link IRange.IteratorOptions.processRowSkip}).
227
228
  *
228
229
  * @remarks
229
230
  * Use this for functions that ignore hidden data, such as `SUBTOTAL`.
231
+ *
232
+ * Nothing is copied. The shape of `range` is kept, and a reference stays a reference: a hidden
233
+ * cell is not visited and reads as empty, so every position still means the cell it meant, and
234
+ * an aggregate that ignores blanks ignores it. A computed array has no rows or columns to hide
235
+ * and is returned as it is.
236
+ *
237
+ * A hidden row is a hidden row, whoever hid it: a filter and the user leave the same mark, and
238
+ * nothing here tells them apart. What a filter adds is a state of the range's SHEET, which
239
+ * {@link IFormulaContext.FilterHiddenOptions.onlyWhileFiltered} reads.
240
+ *
241
+ * A formula that calls `SUBTOTAL` or `AGGREGATE` is recalculated when a row or column is hidden
242
+ * or shown, and when a filter is set or cleared. One that reaches this only through a custom
243
+ * function is not: it reads the state when it is next calculated.
230
244
  */
231
- filterHidden(range: IRange, axes?: IRange.AxisSelection): IRange;
245
+ filterHidden(range: IRange, options?: IFormulaContext.FilterHiddenOptions): IRange;
232
246
  /**
233
247
  * Returns a copy of a range with any cell whose formula is a nested total removed.
234
248
  *
@@ -566,6 +580,28 @@ export interface IFormulaContext {
566
580
  * {@link IFormulaContext}
567
581
  */
568
582
  export declare namespace IFormulaContext {
583
+ /**
584
+ * Options for {@link IFormulaContext.filterHidden}.
585
+ */
586
+ interface FilterHiddenOptions {
587
+ /**
588
+ * Which axis to filter on.
589
+ * @defaultValue `IRange.AxisSelection.Row`
590
+ */
591
+ axes?: IRange.AxisSelection;
592
+ /**
593
+ * Skip the hidden rows or columns only while the range's sheet is filtered: while some
594
+ * AutoFilter or table on that sheet holds a condition, whether or not it hides a row. Until
595
+ * then `range` is returned as it is, hidden rows included.
596
+ *
597
+ * @remarks
598
+ * This is `SUBTOTAL` 1-11 (Excel: they "include manually hidden rows", which is what an
599
+ * unfiltered sheet reads as). `SUBTOTAL` 101-111 and `AGGREGATE` leave it off and skip
600
+ * always.
601
+ * @defaultValue false
602
+ */
603
+ onlyWhileFiltered?: boolean;
604
+ }
569
605
  /**
570
606
  * Options for {@link IFormulaContext.parseAsNumber}.
571
607
  */
@@ -787,6 +787,24 @@ export declare namespace IRange {
787
787
  * If passing a large bound care must be taken.
788
788
  */
789
789
  includeEmpty?: boolean;
790
+ /**
791
+ * Skips rows of the range: given the next row that would be read, answers the row to read
792
+ * instead - the same row when it is read, or the next one that is (the previous, when
793
+ * `reverse`).
794
+ *
795
+ * @param index The 0-based row about to be read.
796
+ * @param reverse Whether the read runs from the last row back.
797
+ * @returns The row to read, at or past `index`.
798
+ *
799
+ * @remarks
800
+ * A skipped cell is not visited, reads as empty and is left out of the statistics; the shape
801
+ * of the range is unchanged. `SUBTOTAL` reads a range this way when it skips hidden rows.
802
+ */
803
+ processRowSkip?: (index: number, reverse?: boolean) => number;
804
+ /**
805
+ * Skips columns of the range, as {@link processRowSkip} skips rows.
806
+ */
807
+ processColumnSkip?: (index: number, reverse?: boolean) => number;
790
808
  /**
791
809
  * Useful for callback functions that want a this.
792
810
  */
@@ -160,7 +160,8 @@ export interface IRangeStats {
160
160
  *
161
161
  * - Every requested type (all types when omitted) is present with an explicit count —
162
162
  * a `0` is a fact about the range, a missing key would be ambiguous.
163
- * - Blanks report under {@link ScalarType.Null}: total cells minus non-empty values.
163
+ * - Blanks report under {@link ScalarType.Null}: total cells minus non-empty values. A cell the
164
+ * range skips ({@link IRange.IteratorOptions.processRowSkip}) is not a blank; it is not counted.
164
165
  * - Never throws on error values — errors are population here, not faults — regardless of
165
166
  * the `onError` iterator policy the stats were created with.
166
167
  */