@trebco/treb 23.1.0 → 23.1.3

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/treb.d.ts CHANGED
@@ -91,6 +91,11 @@ export interface SheetScrollOptions {
91
91
  smooth?: boolean;
92
92
  }
93
93
 
94
+ /**
95
+ * function type used for filtering tables
96
+ */
97
+ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style: Style.Properties) => boolean;
98
+
94
99
  /**
95
100
  * embedded spreadsheet
96
101
  */
@@ -310,9 +315,28 @@ export declare class EmbeddedSpreadsheet {
310
315
  DeleteColumns(start_column?: number, count?: number): void;
311
316
 
312
317
  /**
313
- * sort a table. the cell reference can be anywhere in the table.
314
- * if the reference is an area (range), we're going to look at the
315
- * top-left cell.
318
+ * filter a table. the reference can be the table name, or a cell in the table.
319
+ * if the reference is an area (range), we're going to look at the top-left
320
+ * cell.
321
+ *
322
+ * this method uses a function to filter rows based on cell values. leave the
323
+ * function undefined to show all rows. this is a shortcut for "unfilter".
324
+ *
325
+ * @param column - the column to sort on. values from this column will be
326
+ * passed to the filter function.
327
+ *
328
+ * @param filter - a callback function to filter based on cell values. this
329
+ * will be called with the cell value (formula), the calculated value (if any),
330
+ * and the cell style. return false to hide the row, and true to show the row.
331
+ * if the filter parameter is omitted, all values will be shown.
332
+ *
333
+ */
334
+ FilterTable(reference: RangeReference, column?: number, filter?: TableFilterFunction): void;
335
+
336
+ /**
337
+ * sort a table. the reference can be the table name, or a cell in the table.
338
+ * if the reference is an area (range), we're going to look at the top-left
339
+ * cell.
316
340
  */
317
341
  SortTable(reference: RangeReference, options?: Partial<TableSortOptions>): void;
318
342
 
@@ -896,7 +920,7 @@ export declare namespace Style {
896
920
  locked?: boolean;
897
921
  }
898
922
  }
899
- export declare type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity;
923
+ export type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity;
900
924
 
901
925
  /**
902
926
  * Complex number type
@@ -914,13 +938,13 @@ export interface DimensionedQuantity {
914
938
  * type represents a reference passed in to API functions. it can be an
915
939
  * address object, or a string.
916
940
  */
917
- export declare type AddressReference = string | ICellAddress;
941
+ export type AddressReference = string | ICellAddress;
918
942
 
919
943
  /**
920
944
  * type represents a reference passed in to API functions. it can be an
921
945
  * address object, an area (range) object, or a string.
922
946
  */
923
- export declare type RangeReference = string | ICellAddress | IArea;
947
+ export type RangeReference = string | ICellAddress | IArea;
924
948
  export interface TableSortOptions {
925
949
 
926
950
  /**
@@ -930,13 +954,17 @@ export interface TableSortOptions {
930
954
  */
931
955
  column: number;
932
956
 
933
- /** sort type. defaults to 'text'. */
957
+ /**
958
+ * sort type. defaults to 'auto'. 'auto' looks at the values in the column,
959
+ * and uses text sort if there are more strings, or numeric if there are
960
+ * more numbers. if it's even, sorts as text.
961
+ */
934
962
  type: TableSortType;
935
963
 
936
964
  /** ascending sort. defaults to true. */
937
965
  asc: boolean;
938
966
  }
939
- export declare type TableSortType = 'text' | 'numeric';
967
+ export type TableSortType = 'text' | 'numeric' | 'auto';
940
968
 
941
969
  /**
942
970
  * options for exporting CSV/TSV
@@ -1133,7 +1161,7 @@ export declare type LoadSource = "drag-and-drop" | "local-file" | "network-file"
1133
1161
  * EmbeddedSheetEvent is a discriminated union. Switch on the `type` field
1134
1162
  * of the event.
1135
1163
  */
1136
- export declare type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | DataChangeEvent | SelectionEvent | ResizeEvent;
1164
+ export type EmbeddedSheetEvent = DocumentChangeEvent | DocumentResetEvent | DocumentLoadEvent | DataChangeEvent | SelectionEvent | ResizeEvent;
1137
1165
  export interface ResizeEvent {
1138
1166
  type: 'resize';
1139
1167
  }