@trebco/treb 26.0.5 → 27.0.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.
Files changed (50) hide show
  1. package/dist/treb-spreadsheet.mjs +13 -13
  2. package/dist/treb.d.ts +150 -337
  3. package/esbuild-utils.mjs +1 -1
  4. package/package.json +3 -3
  5. package/treb-base-types/src/cell.ts +3 -3
  6. package/treb-base-types/src/cells.ts +33 -15
  7. package/treb-base-types/src/color.ts +21 -21
  8. package/treb-base-types/src/import.ts +2 -2
  9. package/treb-base-types/src/style.ts +150 -288
  10. package/treb-base-types/src/table.ts +3 -2
  11. package/treb-base-types/src/theme.ts +18 -18
  12. package/treb-base-types/src/value-type.ts +20 -1
  13. package/treb-calculator/src/calculator.ts +4 -4
  14. package/treb-calculator/src/functions/checkbox.ts +8 -8
  15. package/treb-calculator/src/functions/sparkline.ts +25 -25
  16. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +10 -10
  17. package/treb-embed/src/embedded-spreadsheet.ts +15 -15
  18. package/treb-embed/src/selection-state.ts +2 -2
  19. package/treb-embed/src/toolbar-message.ts +3 -3
  20. package/treb-embed/src/types.ts +4 -4
  21. package/treb-embed/style/autocomplete.scss +1 -1
  22. package/treb-embed/style/dialog.scss +1 -1
  23. package/treb-embed/style/dropdown-select.scss +1 -1
  24. package/treb-embed/style/formula-bar.scss +1 -1
  25. package/treb-embed/style/grid.scss +1 -1
  26. package/treb-embed/style/layout.scss +13 -2
  27. package/treb-embed/style/mouse-mask.scss +1 -1
  28. package/treb-embed/style/note.scss +1 -1
  29. package/treb-embed/style/overlay-editor.scss +1 -1
  30. package/treb-embed/style/spinner.scss +1 -1
  31. package/treb-embed/style/tab-bar.scss +1 -1
  32. package/treb-embed/style/table.scss +1 -1
  33. package/treb-embed/style/theme-defaults.scss +1 -1
  34. package/treb-embed/style/toolbar.scss +1 -1
  35. package/treb-embed/style/tooltip.scss +1 -1
  36. package/treb-embed/style/treb-icons.scss +1 -1
  37. package/treb-embed/style/treb-spreadsheet-element.scss +1 -0
  38. package/treb-export/src/export2.ts +6 -6
  39. package/treb-export/src/workbook-style2.ts +19 -19
  40. package/treb-grid/src/editors/overlay_editor.ts +4 -4
  41. package/treb-grid/src/render/tile_renderer.ts +15 -14
  42. package/treb-grid/src/types/annotation.ts +9 -6
  43. package/treb-grid/src/types/clipboard_data.ts +2 -2
  44. package/treb-grid/src/types/data_model.ts +2 -2
  45. package/treb-grid/src/types/grid.ts +9 -7
  46. package/treb-grid/src/types/grid_base.ts +9 -9
  47. package/treb-grid/src/types/grid_command.ts +3 -3
  48. package/treb-grid/src/types/grid_selection.ts +26 -1
  49. package/treb-grid/src/types/sheet.ts +66 -63
  50. package/treb-grid/src/types/sheet_types.ts +17 -10
package/dist/treb.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- /*! API v26.0. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
1
+ /*! API v27.0. Copyright 2018-2023 trebco, llc. All rights reserved. LGPL: https://treb.app/license */
2
2
 
3
3
  /**
4
4
  * add our tag to the map
@@ -806,7 +806,7 @@ export declare class EmbeddedSpreadsheet {
806
806
  *
807
807
  * @public
808
808
  */
809
- ApplyStyle(range?: RangeReference, style?: Style.Properties, delta?: boolean): void;
809
+ ApplyStyle(range?: RangeReference, style?: CellStyle, delta?: boolean): void;
810
810
 
811
811
  /**
812
812
  * Remove a named range (removes the name, not the range).
@@ -865,7 +865,7 @@ export declare class EmbeddedSpreadsheet {
865
865
  * @param apply_theme - include theme defaults when returning style
866
866
  *
867
867
  */
868
- GetStyle(range?: RangeReference, apply_theme?: boolean): Style.Properties | Style.Properties[][] | undefined;
868
+ GetStyle(range?: RangeReference, apply_theme?: boolean): CellStyle | CellStyle[][] | undefined;
869
869
 
870
870
  /**
871
871
  * Set data in range.
@@ -964,7 +964,7 @@ export interface SheetScrollOptions {
964
964
  /**
965
965
  * function type used for filtering tables
966
966
  */
967
- export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style: Style.Properties) => boolean;
967
+ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue, style: CellStyle) => boolean;
968
968
  export interface FreezePane {
969
969
  rows: number;
970
970
  columns: number;
@@ -1052,110 +1052,113 @@ export interface IRectangle {
1052
1052
  width: number;
1053
1053
  height: number;
1054
1054
  }
1055
- export declare namespace Style {
1056
1055
 
1057
- /**
1058
- * horizontal align constants
1059
- */ type HorizontalAlign = "" | "left" | "center" | "right";
1056
+ /**
1057
+ * style properties applied to a single cell, row, column, or sheet.
1058
+ * when rendering a cell, we composite all styles that might apply.
1059
+ */
1060
+ export interface CellStyle {
1060
1061
 
1061
- /**
1062
- * vertical align constants
1063
- */ type VerticalAlign = "" | "top" | "bottom" | "middle";
1062
+ /** horizontal align defaults to left */
1063
+ horizontal_align?: HorizontalAlign;
1064
1064
 
1065
- /** composite font size */
1066
- interface FontSize {
1067
- unit: 'pt' | 'px' | 'em' | '%';
1068
- value: number;
1069
- }
1065
+ /** vertical align defaults to bottom */
1066
+ vertical_align?: VerticalAlign;
1070
1067
 
1071
- /**
1072
- * color is either a theme color (theme index plus tint), or CSS text
1073
- */
1074
- interface Color {
1075
- theme?: number;
1076
- tint?: number;
1077
- text?: string;
1068
+ /** representation for NaN */
1069
+ nan?: string;
1078
1070
 
1079
- /** @deprecated */
1080
- none?: boolean;
1081
- }
1071
+ /** number format, either a symbolic name like "General" or a format string */
1072
+ number_format?: string;
1073
+
1074
+ /** wrap text */
1075
+ wrap?: boolean;
1082
1076
 
1083
1077
  /**
1084
- * style properties applied to a cell.
1078
+ * font size. we recommend using relative font sizes (either % or em)
1079
+ * which will be relative to the theme font size.
1085
1080
  */
1086
- interface Properties {
1087
-
1088
- /** horizontal align defaults to left */
1089
- horizontal_align?: HorizontalAlign;
1081
+ font_size?: FontSize;
1090
1082
 
1091
- /** vertical align defaults to bottom */
1092
- vertical_align?: VerticalAlign;
1083
+ /** font face. this can be a comma-delimited list, like CSS */
1084
+ font_face?: string;
1093
1085
 
1094
- /** representation for NaN */
1095
- nan?: string;
1086
+ /** flag */
1087
+ bold?: boolean;
1096
1088
 
1097
- /** number format, either a symbolic name like "General" or a format string */
1098
- number_format?: string;
1089
+ /** flag */
1090
+ italic?: boolean;
1099
1091
 
1100
- /** wrap text */
1101
- wrap?: boolean;
1092
+ /** flag */
1093
+ underline?: boolean;
1102
1094
 
1103
- /**
1104
- * font size. we recommend using relative font sizes (either % or em)
1105
- * which will be relative to the theme font size.
1106
- */
1107
- font_size?: FontSize;
1095
+ /** flag */
1096
+ strike?: boolean;
1108
1097
 
1109
- /** font face. this can be a comma-delimited list, like CSS */
1110
- font_face?: string;
1098
+ /** border weight */
1099
+ border_top?: number;
1111
1100
 
1112
- /** flag */
1113
- bold?: boolean;
1101
+ /** border weight */
1102
+ border_right?: number;
1114
1103
 
1115
- /** flag */
1116
- italic?: boolean;
1104
+ /** border weight */
1105
+ border_left?: number;
1117
1106
 
1118
- /** flag */
1119
- underline?: boolean;
1107
+ /** border weight */
1108
+ border_bottom?: number;
1120
1109
 
1121
- /** flag */
1122
- strike?: boolean;
1110
+ /** text color */
1111
+ text?: Color;
1123
1112
 
1124
- /** border weight */
1125
- border_top?: number;
1113
+ /** background color */
1114
+ fill?: Color;
1126
1115
 
1127
- /** border weight */
1128
- border_right?: number;
1116
+ /** border color */
1117
+ border_top_fill?: Color;
1129
1118
 
1130
- /** border weight */
1131
- border_left?: number;
1119
+ /** border color */
1120
+ border_left_fill?: Color;
1132
1121
 
1133
- /** border weight */
1134
- border_bottom?: number;
1122
+ /** border color */
1123
+ border_right_fill?: Color;
1135
1124
 
1136
- /** text color */
1137
- text?: Color;
1125
+ /** border color */
1126
+ border_bottom_fill?: Color;
1138
1127
 
1139
- /** background color */
1140
- fill?: Color;
1128
+ /**
1129
+ * cell is locked for editing
1130
+ */
1131
+ locked?: boolean;
1132
+ }
1141
1133
 
1142
- /** border color */
1143
- border_top_fill?: Color;
1134
+ /** horizontal align constants for cell style */
1135
+ export type HorizontalAlign = '' | 'left' | 'center' | 'right';
1144
1136
 
1145
- /** border color */
1146
- border_left_fill?: Color;
1137
+ /** vertical align constants for cell style */
1138
+ export type VerticalAlign = '' | 'top' | 'bottom' | 'middle';
1147
1139
 
1148
- /** border color */
1149
- border_right_fill?: Color;
1140
+ /**
1141
+ * font size for cell style. we generally prefer relative sizes
1142
+ * (percent or em) because they are relative to the default theme
1143
+ * size, which might be different on different platforms.
1144
+ */
1145
+ export interface FontSize {
1146
+ unit: 'pt' | 'px' | 'em' | '%';
1147
+ value: number;
1148
+ }
1150
1149
 
1151
- /** border color */
1152
- border_bottom_fill?: Color;
1150
+ /**
1151
+ * color for cell style. color is used for foreground, background and
1152
+ * borders in the cell style. can be either a theme color (theme index
1153
+ * plus tint), or CSS text.
1154
+ */
1155
+ export interface Color {
1156
+ theme?: number;
1157
+ tint?: number;
1158
+ text?: string;
1153
1159
 
1154
- /**
1155
- * cell is locked for editing
1156
- */
1157
- locked?: boolean;
1158
- }
1160
+ /** @deprecated */
1161
+ none?: boolean;
1159
1162
  }
1160
1163
  export type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity;
1161
1164
 
@@ -1171,51 +1174,30 @@ export interface DimensionedQuantity {
1171
1174
  unit: string;
1172
1175
  }
1173
1176
 
1174
- /**
1175
- * this is the list of value types. internally, we use an enum. I don't
1176
- * want to change that, at least not at the moment, but that presents a
1177
- * problem for exporting types.
1178
- *
1179
- * we'll switch to string types for import/export, although we still support
1180
- * importing the old numeric enum types for backwards compatibility.
1181
- */
1182
- export declare const ValueTypeList: readonly [
1183
- "undefined",
1184
- "formula",
1185
- "string",
1186
- "number",
1187
- "boolean",
1188
- "object",
1189
- "error",
1190
- "complex",
1191
- "array",
1192
- "dimensioned_quantity"
1193
- ];
1194
-
1195
1177
  /**
1196
1178
  * composite styling for tables.
1197
1179
  */
1198
1180
  export interface TableTheme {
1199
1181
 
1200
1182
  /** the first row in a table, showing column titles. */
1201
- header?: Style.Properties;
1183
+ header?: CellStyle;
1202
1184
 
1203
1185
  /**
1204
1186
  * odd rows in the table. we count the title row as zero, so
1205
1187
  * the first row in the table containing data is 1, hence odd.
1206
1188
  */
1207
- odd?: Style.Properties;
1189
+ odd?: CellStyle;
1208
1190
 
1209
1191
  /**
1210
1192
  * even rows in the table.
1211
1193
  */
1212
- even?: Style.Properties;
1194
+ even?: CellStyle;
1213
1195
 
1214
1196
  /**
1215
1197
  * styling for the totals row, if included. this will be the last
1216
1198
  * row in the table.
1217
1199
  */
1218
- total?: Style.Properties;
1200
+ total?: CellStyle;
1219
1201
  }
1220
1202
 
1221
1203
  /**
@@ -1251,10 +1233,10 @@ export interface TableSortOptions {
1251
1233
  export type TableSortType = 'text' | 'numeric' | 'auto';
1252
1234
 
1253
1235
  /**
1254
- * we're not exporting this type in the public API because there are so many
1255
- * nested types that aren't used anywhere else (in public functions).
1256
- *
1257
- * I would like to do it, though, that `any` looks bad in the public API.
1236
+ * this is the document type used by TREB. it has a lot of small variations
1237
+ * for historical reasons and backwards compatibility. usually it's preferable
1238
+ * to let TREB create and manage these documents rather than creating them
1239
+ * manually.
1258
1240
  */
1259
1241
  export interface TREBDocument {
1260
1242
 
@@ -1408,7 +1390,7 @@ export interface SerializedSheet {
1408
1390
  data: SerializedCellData;
1409
1391
 
1410
1392
  /** top-level sheet style, if any */
1411
- sheet_style: Style.Properties;
1393
+ sheet_style: CellStyle;
1412
1394
 
1413
1395
  /** row count */
1414
1396
  rows: number;
@@ -1419,37 +1401,32 @@ export interface SerializedSheet {
1419
1401
  /**
1420
1402
  * cell styles is for empty cells that have styling
1421
1403
  */
1422
- cell_styles: Array<{
1423
- row: number;
1424
- column: number;
1425
- ref: number;
1426
- rows?: number;
1427
- }>;
1404
+ cell_styles: CellStyleRecord[];
1428
1405
 
1429
1406
  /**
1430
1407
  * @deprecated use `styles` instead
1431
1408
  */
1432
- cell_style_refs?: Style.Properties[];
1409
+ cell_style_refs?: CellStyle[];
1433
1410
 
1434
1411
  /**
1435
1412
  * new implementation
1436
1413
  */
1437
- styles?: Style.Properties[];
1414
+ styles?: CellStyle[];
1438
1415
 
1439
1416
  /**
1440
1417
  * per-row styles
1441
1418
  */
1442
- row_style: Record<number, Style.Properties | number>;
1419
+ row_style: Record<number, CellStyle | number>;
1443
1420
 
1444
1421
  /**
1445
1422
  * per-column styles
1446
1423
  */
1447
- column_style: Record<number, Style.Properties | number>;
1424
+ column_style: Record<number, CellStyle | number>;
1448
1425
 
1449
1426
  /**
1450
1427
  * @deprecated no one uses this anymore and it's weird
1451
1428
  */
1452
- row_pattern?: Style.Properties[];
1429
+ row_pattern?: CellStyle[];
1453
1430
 
1454
1431
  /** default for new rows */
1455
1432
  default_row_height?: number;
@@ -1476,7 +1453,7 @@ export interface SerializedSheet {
1476
1453
  name?: string;
1477
1454
 
1478
1455
  /** current active selection */
1479
- selection: GridSelection;
1456
+ selection: SerializedGridSelection;
1480
1457
 
1481
1458
  /** */
1482
1459
  annotations?: Partial<AnnotationData>[];
@@ -1494,7 +1471,13 @@ export interface ScrollOffset {
1494
1471
  x: number;
1495
1472
  y: number;
1496
1473
  }
1497
- export type SerializedCellData = FlatCellData[] | NestedRowData[] | NestedColumnData[];
1474
+ export interface CellStyleRecord {
1475
+ row: number;
1476
+ column: number;
1477
+ ref: number;
1478
+ rows?: number;
1479
+ }
1480
+ export type SerializedCellData = CellDataWithAddress[] | NestedRowData[] | NestedColumnData[];
1498
1481
  export interface BaseCellData {
1499
1482
  value: CellValue;
1500
1483
  style_ref?: number;
@@ -1509,24 +1492,43 @@ export interface BaseCellData {
1509
1492
  type?: SerializedValueType;
1510
1493
  sheet_id?: number;
1511
1494
  }
1512
- export interface FlatCellData extends BaseCellData {
1495
+
1496
+ /**
1497
+ * this type is for serialized data that includes the row and column
1498
+ * in each cell. this was the original serialized data type, and is
1499
+ * still supported. current serialization will group data into rows or
1500
+ * columns, whichever results in a smaller overall serialized representation.
1501
+ */
1502
+ export interface CellDataWithAddress extends BaseCellData {
1513
1503
  row: number;
1514
1504
  column: number;
1515
1505
  }
1516
1506
  export interface NestedCellData {
1517
1507
  cells: BaseCellData[];
1518
1508
  }
1509
+
1510
+ /**
1511
+ * this type is for serialized data that is grouped by row, with each
1512
+ * cell referencing a column in the spreadsheet.
1513
+ */
1514
+ export interface CellDataWithColumn extends BaseCellData {
1515
+ column: number;
1516
+ }
1519
1517
  export interface NestedRowData extends NestedCellData {
1520
1518
  row: number;
1521
- cells: Array<{
1522
- column: number;
1523
- } & BaseCellData>;
1519
+ cells: CellDataWithColumn[];
1520
+ }
1521
+
1522
+ /**
1523
+ * this type is for serialized data that is grouped by column, with each
1524
+ * cell referencing a row in the spreadsheet.
1525
+ */
1526
+ export interface CellDataWithRow extends BaseCellData {
1527
+ row: number;
1524
1528
  }
1525
1529
  export interface NestedColumnData extends NestedCellData {
1526
1530
  column: number;
1527
- cells: Array<{
1528
- row: number;
1529
- } & BaseCellData>;
1531
+ cells: CellDataWithRow[];
1530
1532
  }
1531
1533
 
1532
1534
  /**
@@ -1571,11 +1573,7 @@ export interface Table {
1571
1573
  * (not meaning difficult). we may keep track of the last sort so we
1572
1574
  * can toggle asc/desc, for example. atm this will not survive serialization.
1573
1575
  */
1574
- sort?: {
1575
- column: number;
1576
- type: TableSortType;
1577
- asc: boolean;
1578
- };
1576
+ sort?: TableSortOptions;
1579
1577
  }
1580
1578
  export type DataValidation = DataValidationList | DataValidationRange | DataValidationNumber | DataValidationDate | DataValidationBoolean;
1581
1579
  export interface DataValidationBase {
@@ -1601,23 +1599,27 @@ export interface DataValidationBoolean extends DataValidationBase {
1601
1599
 
1602
1600
  /**
1603
1601
  * string types for import/export
1602
+ *
1603
+ * @internalRemarks
1604
+ *
1605
+ * temporarily switching to literal, see what happens to API
1606
+ *
1604
1607
  */
1605
- export type SerializedValueType = typeof ValueTypeList[number];
1608
+ export type SerializedValueType = // typeof ValueTypeList[number];
1609
+ 'undefined' | 'formula' | 'string' | 'number' | 'boolean' | 'object' | 'error' | 'complex' | 'array' | 'dimensioned_quantity';
1606
1610
 
1607
1611
  /**
1608
- * FIXME: this is broken. we treat this as a simple javascript object,
1609
- * cloning and creating via JSON, but area is a class instance.
1610
- *
1611
- * that means cloned objects won't work properly (if anyone is relying on
1612
- * that object).
1612
+ * temporarily splitting into a serialized version that uses IArea instead
1613
+ * of Area. we should do this for the actual selection type, but it breaks
1614
+ * too many things atm to do that immediately. TODO/FIXME.
1613
1615
  */
1614
- export interface GridSelection {
1616
+ export interface SerializedGridSelection {
1615
1617
 
1616
1618
  /** target or main cell in the selection */
1617
1619
  target: ICellAddress;
1618
1620
 
1619
1621
  /** selection area */
1620
- area: Area;
1622
+ area: IArea;
1621
1623
 
1622
1624
  /** there is nothing selected, even though this object exists */
1623
1625
  empty?: boolean;
@@ -1625,152 +1627,17 @@ export interface GridSelection {
1625
1627
  /** for cacheing addtional selections. optimally don't serialize */
1626
1628
  rendered?: boolean;
1627
1629
  }
1628
-
1629
- /**
1630
- * create an empty selection
1631
- */
1632
- export declare const CreateSelection: () => GridSelection;
1633
- export declare const CloneSelection: (rhs: GridSelection) => GridSelection;
1634
-
1635
- /**
1636
- * class represents a rectangular area on a sheet. can be a range,
1637
- * single cell, entire row/column, or entire sheet.
1638
- *
1639
- * "entire" row/column/sheet is represented with an infinity in the
1640
- * start/end value for row/column/both, so watch out on loops. the
1641
- * sheet class has a method for reducing infinite ranges to actual
1642
- * populated ranges.
1643
- */
1644
- export declare class Area implements IArea {
1645
-
1646
- /**
1647
- *
1648
- * @param start
1649
- * @param end
1650
- * @param normalize: calls the normalize function
1651
- */
1652
- constructor(start: ICellAddress, end?: ICellAddress, normalize?: boolean);
1653
- static FromColumn(column: number): Area;
1654
- static FromRow(row: number): Area;
1655
- static ColumnToLabel(c: number): string;
1656
- static CellAddressToLabel(address: ICellAddress, sheet_id?: boolean): string;
1657
-
1658
- /**
1659
- * merge two areas and return a new area.
1660
- * UPDATE to support arbitrary arguments
1661
- */
1662
- static Join(base: IArea, ...args: Array<IArea | undefined>): Area;
1663
-
1664
- /**
1665
- * creates an area that expands the original area in all directions
1666
- * (except at the top/left edges)
1667
- */
1668
- static Bleed(area: IArea, length?: number): Area;
1669
-
1670
- /** accessor returns a _copy_ of the start address */
1671
- get start(): ICellAddress;
1672
-
1673
- /** accessor */
1674
- set start(value: ICellAddress);
1675
-
1676
- /** accessor returns a _copy_ of the end address */
1677
- get end(): ICellAddress;
1678
-
1679
- /** accessor */
1680
- set end(value: ICellAddress);
1681
-
1682
- /** returns number of rows, possibly infinity */
1683
- get rows(): number;
1684
-
1685
- /** returns number of columns, possibly infinity */
1686
- get columns(): number;
1687
-
1688
- /** returns number of cells, possibly infinity */
1689
- get count(): number;
1690
-
1691
- /** returns flag indicating this is the entire sheet, usually after "select all" */
1692
- get entire_sheet(): boolean;
1693
-
1694
- /** returns flag indicating this range includes infinite rows */
1695
- get entire_column(): boolean;
1696
-
1697
- /** returns flag indicating this range includes infinite columns */
1698
- get entire_row(): boolean;
1699
- PatchNull(address: ICellAddress): ICellAddress;
1700
- SetSheetID(id: number): void;
1701
- Normalize(): void;
1702
-
1703
- /** returns the top-left cell in the area */
1704
- TopLeft(): ICellAddress;
1705
-
1706
- /** returns the bottom-right cell in the area */
1707
- BottomRight(): ICellAddress;
1708
- ContainsRow(row: number): boolean;
1709
- ContainsColumn(column: number): boolean;
1710
- Contains(address: ICellAddress): boolean;
1711
-
1712
- /**
1713
- * returns true if this area completely contains the argument area
1714
- * (also if areas are ===, as a side effect). note that this returns
1715
- * true if A contains B, but not vice-versa
1716
- */
1717
- ContainsArea(area: Area): boolean;
1718
-
1719
- /**
1720
- * returns true if there's an intersection. note that this won't work
1721
- * if there are infinities -- needs real area ?
1722
- */
1723
- Intersects(area: Area): boolean;
1724
- Equals(area: Area): boolean;
1725
- Clone(): Area;
1726
- Array(): ICellAddress[];
1727
- get left(): Area;
1728
- get right(): Area;
1729
- get top(): Area;
1730
- get bottom(): Area;
1731
-
1732
- /** shifts range in place */
1733
- Shift(rows: number, columns: number): Area;
1734
-
1735
- /** Resizes range in place so that it includes the given address */
1736
- ConsumeAddress(addr: ICellAddress): void;
1737
-
1738
- /** Resizes range in place so that it includes the given area (merge) */
1739
- ConsumeArea(area: IArea): void;
1740
-
1741
- /** resizes range in place (updates end) */
1742
- Resize(rows: number, columns: number): Area;
1743
- Iterate(f: (...args: any[]) => any): void;
1744
-
1745
- /**
1746
- * returns the range in A1-style spreadsheet addressing. if the
1747
- * entire sheet is selected, returns nothing (there's no way to
1748
- * express that in A1 notation). returns the row numbers for entire
1749
- * columns and vice-versa for rows.
1750
- */
1751
- get spreadsheet_label(): string;
1752
-
1753
- /**
1754
- * FIXME: is this different than what would be returned if
1755
- * we just used the default json serializer? (...)
1756
- *
1757
- * NOTE: we could return just the start if size === 1. if
1758
- * you pass an undefined to the Area class ctor it will reuse
1759
- * the start.
1760
- *
1761
- */
1762
- toJSON(): any;
1763
- }
1764
1630
  export type AnnotationData = AnnotationChartData | AnnotationImageData | AnnotationExternalData;
1631
+ export interface ImageSize {
1632
+ width: number;
1633
+ height: number;
1634
+ }
1765
1635
  export interface ImageAnnotationData {
1766
1636
  src: string;
1767
1637
 
1768
1638
  /**/
1769
1639
  scale: string;
1770
- original_size: {
1771
- width: number;
1772
- height: number;
1773
- };
1640
+ original_size: ImageSize;
1774
1641
  }
1775
1642
 
1776
1643
  /**
@@ -1797,7 +1664,7 @@ export interface AnnotationDataBase {
1797
1664
  * for serialization/deserialization. the actual rectangle is maintained
1798
1665
  * in the Annotation class.
1799
1666
  */
1800
- rect?: Partial<Rectangle>;
1667
+ rect?: Partial<IRectangle>;
1801
1668
 
1802
1669
  /** annotation can be resized. this is advisory, for UI */
1803
1670
  resizable: boolean;
@@ -1847,60 +1714,6 @@ export interface AnnotationExternalData extends AnnotationDataBase {
1847
1714
  type: 'external';
1848
1715
  data: Record<string, string>;
1849
1716
  }
1850
- export declare class Rectangle implements IRectangle {
1851
- left: number;
1852
- top: number;
1853
- width: number;
1854
- height: number;
1855
- get right(): number;
1856
- get bottom(): number;
1857
-
1858
- /**
1859
- * create a rectangle from an object that looks
1860
- * like a rectangle, probably a serialized object
1861
- */
1862
- static Create(obj: Partial<Rectangle>): Rectangle;
1863
- static IsRectangle(obj: unknown): obj is IRectangle;
1864
- constructor(left?: number, top?: number, width?: number, height?: number);
1865
-
1866
- /** returns a new rect shifted from this one by (x,y) */
1867
- Shift(x?: number, y?: number): Rectangle;
1868
- Scale(scale_x?: number, scale_y?: number): Rectangle;
1869
-
1870
- /** returns a new rect expanded from this one by (x,y) */
1871
- Expand(x?: number, y?: number): Rectangle;
1872
-
1873
- /** returns a new rectangle that combines this rectangle with the argument */
1874
- Combine(rect: Rectangle): Rectangle;
1875
- CheckEdges(x: number, y: number, border?: number): number;
1876
-
1877
- /**
1878
- * check if rectangle contains the given coordinates, optionally with
1879
- * some added padding
1880
- */
1881
- Contains(x: number, y: number, padding?: number): boolean;
1882
-
1883
- /** convenience method for canvas */
1884
- ContextFill(context: CanvasRenderingContext2D): void;
1885
-
1886
- /** convenience method for canvas */
1887
- ContextStroke(context: CanvasRenderingContext2D): void;
1888
-
1889
- /** clamp coordinate to rectangle */
1890
- Clamp(x: number, y: number): {
1891
- x: number;
1892
- y: number;
1893
- };
1894
-
1895
- /** convenience method for html element style */
1896
- ApplyStyle(element: HTMLElement): void;
1897
- toJSON(): {
1898
- top: number;
1899
- left: number;
1900
- width: number;
1901
- height: number;
1902
- };
1903
- }
1904
1717
 
1905
1718
  /**
1906
1719
  * represents the layout of an annotation, reference to the sheet