@trebco/treb 25.9.1 → 26.0.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/api-config.json +0 -1
- package/dist/treb-spreadsheet.mjs +13 -13
- package/dist/treb.d.ts +620 -3
- package/package.json +1 -1
- package/treb-base-types/src/cell.ts +11 -11
- package/treb-base-types/src/cells.ts +73 -7
- package/treb-base-types/src/import.ts +3 -3
- package/treb-base-types/src/value-type.ts +37 -5
- package/treb-embed/src/types.ts +41 -3
- package/treb-export/src/import2.ts +21 -14
- package/treb-grid/src/types/data_model.ts +0 -1
- package/treb-grid/src/types/grid.ts +3 -1
- package/treb-grid/src/types/sheet_types.ts +45 -9
package/dist/treb.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! API
|
|
1
|
+
/*! API v26.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
|
|
@@ -647,7 +647,7 @@ export declare class EmbeddedSpreadsheet {
|
|
|
647
647
|
/**
|
|
648
648
|
* unserialize document from data.
|
|
649
649
|
*/
|
|
650
|
-
LoadDocument(data:
|
|
650
|
+
LoadDocument(data: TREBDocument, options?: LoadDocumentOptions): void;
|
|
651
651
|
|
|
652
652
|
/**
|
|
653
653
|
* Set note (comment) in cell.
|
|
@@ -690,7 +690,7 @@ export declare class EmbeddedSpreadsheet {
|
|
|
690
690
|
*
|
|
691
691
|
* @public
|
|
692
692
|
*/
|
|
693
|
-
SerializeDocument(options?: SerializeOptions):
|
|
693
|
+
SerializeDocument(options?: SerializeOptions): TREBDocument;
|
|
694
694
|
|
|
695
695
|
/**
|
|
696
696
|
* Recalculate sheet.
|
|
@@ -1171,6 +1171,27 @@ export interface DimensionedQuantity {
|
|
|
1171
1171
|
unit: string;
|
|
1172
1172
|
}
|
|
1173
1173
|
|
|
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
|
+
|
|
1174
1195
|
/**
|
|
1175
1196
|
* composite styling for tables.
|
|
1176
1197
|
*/
|
|
@@ -1228,6 +1249,69 @@ export interface TableSortOptions {
|
|
|
1228
1249
|
asc: boolean;
|
|
1229
1250
|
}
|
|
1230
1251
|
export type TableSortType = 'text' | 'numeric' | 'auto';
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
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.
|
|
1258
|
+
*/
|
|
1259
|
+
export interface TREBDocument {
|
|
1260
|
+
|
|
1261
|
+
/** app name, as identifier */
|
|
1262
|
+
app: string;
|
|
1263
|
+
|
|
1264
|
+
/** app version. we'll warn if you use a file from a newer version */
|
|
1265
|
+
version: string;
|
|
1266
|
+
|
|
1267
|
+
/**
|
|
1268
|
+
* revision number. this is a value that increments on any document change,
|
|
1269
|
+
* useful for checking if a document is "dirty".
|
|
1270
|
+
*/
|
|
1271
|
+
revision?: number;
|
|
1272
|
+
|
|
1273
|
+
/** document name */
|
|
1274
|
+
name?: string;
|
|
1275
|
+
|
|
1276
|
+
/**
|
|
1277
|
+
* opaque user data. we don't read or parse this, but applications can
|
|
1278
|
+
* use it to store arbitrary data.
|
|
1279
|
+
*/
|
|
1280
|
+
user_data?: any;
|
|
1281
|
+
|
|
1282
|
+
/**
|
|
1283
|
+
* per-sheet data. this should be an array, but for historical reasons
|
|
1284
|
+
* we still support a single sheet outside of an array.
|
|
1285
|
+
*/
|
|
1286
|
+
sheet_data?: SerializedSheet | SerializedSheet[];
|
|
1287
|
+
|
|
1288
|
+
/** document decimal mark */
|
|
1289
|
+
decimal_mark?: '.' | ',';
|
|
1290
|
+
|
|
1291
|
+
/** active sheet. if unset we'll show the first un-hidden sheet */
|
|
1292
|
+
active_sheet?: number;
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* this document includes rendered calculated values. using this lets the
|
|
1296
|
+
* app show a document faster, without requiring an initial calculation.
|
|
1297
|
+
*/
|
|
1298
|
+
rendered_values?: boolean;
|
|
1299
|
+
|
|
1300
|
+
/** document named ranges */
|
|
1301
|
+
named_ranges?: Record<string, IArea>;
|
|
1302
|
+
|
|
1303
|
+
/** document named expressions */
|
|
1304
|
+
named_expressions?: SerializedNamedExpression[];
|
|
1305
|
+
|
|
1306
|
+
/** document macro functions */
|
|
1307
|
+
macro_functions?: SerializedMacroFunction[];
|
|
1308
|
+
|
|
1309
|
+
/** document tables */
|
|
1310
|
+
tables?: Table[];
|
|
1311
|
+
|
|
1312
|
+
/** document shared resources (usually images) */
|
|
1313
|
+
shared_resources?: Record<string, string>;
|
|
1314
|
+
}
|
|
1231
1315
|
export declare type LoadSource = "drag-and-drop" | "local-file" | "network-file" | "local-storage" | "inline-document" | "undo";
|
|
1232
1316
|
|
|
1233
1317
|
/**
|
|
@@ -1314,6 +1398,539 @@ export interface SelectionEvent {
|
|
|
1314
1398
|
export interface FocusViewEvent {
|
|
1315
1399
|
type: 'focus-view';
|
|
1316
1400
|
}
|
|
1401
|
+
export interface SerializedNamedExpression {
|
|
1402
|
+
name: string;
|
|
1403
|
+
expression: string;
|
|
1404
|
+
}
|
|
1405
|
+
export interface SerializedSheet {
|
|
1406
|
+
|
|
1407
|
+
/** cell data */
|
|
1408
|
+
data: SerializedCellData;
|
|
1409
|
+
|
|
1410
|
+
/** top-level sheet style, if any */
|
|
1411
|
+
sheet_style: Style.Properties;
|
|
1412
|
+
|
|
1413
|
+
/** row count */
|
|
1414
|
+
rows: number;
|
|
1415
|
+
|
|
1416
|
+
/** column count */
|
|
1417
|
+
columns: number;
|
|
1418
|
+
|
|
1419
|
+
/**
|
|
1420
|
+
* cell styles is for empty cells that have styling
|
|
1421
|
+
*/
|
|
1422
|
+
cell_styles: Array<{
|
|
1423
|
+
row: number;
|
|
1424
|
+
column: number;
|
|
1425
|
+
ref: number;
|
|
1426
|
+
rows?: number;
|
|
1427
|
+
}>;
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* @deprecated use `styles` instead
|
|
1431
|
+
*/
|
|
1432
|
+
cell_style_refs?: Style.Properties[];
|
|
1433
|
+
|
|
1434
|
+
/**
|
|
1435
|
+
* new implementation
|
|
1436
|
+
*/
|
|
1437
|
+
styles?: Style.Properties[];
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* per-row styles
|
|
1441
|
+
*/
|
|
1442
|
+
row_style: Record<number, Style.Properties | number>;
|
|
1443
|
+
|
|
1444
|
+
/**
|
|
1445
|
+
* per-column styles
|
|
1446
|
+
*/
|
|
1447
|
+
column_style: Record<number, Style.Properties | number>;
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* @deprecated no one uses this anymore and it's weird
|
|
1451
|
+
*/
|
|
1452
|
+
row_pattern?: Style.Properties[];
|
|
1453
|
+
|
|
1454
|
+
/** default for new rows */
|
|
1455
|
+
default_row_height?: number;
|
|
1456
|
+
|
|
1457
|
+
/** default for new columns */
|
|
1458
|
+
default_column_width?: number;
|
|
1459
|
+
|
|
1460
|
+
/** list of row heights. we use a Record instead of an array because it's sparse */
|
|
1461
|
+
row_height?: Record<number, number>;
|
|
1462
|
+
|
|
1463
|
+
/** list of column widths. we use a Record instead of an array because it's sparse */
|
|
1464
|
+
column_width?: Record<number, number>;
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* @deprecated these were moved to the containing document
|
|
1468
|
+
*/
|
|
1469
|
+
named_ranges?: Record<string, IArea>;
|
|
1470
|
+
freeze?: FreezePane;
|
|
1471
|
+
|
|
1472
|
+
/** sheet ID, for serializing references */
|
|
1473
|
+
id?: number;
|
|
1474
|
+
|
|
1475
|
+
/** sheet name */
|
|
1476
|
+
name?: string;
|
|
1477
|
+
|
|
1478
|
+
/** current active selection */
|
|
1479
|
+
selection: GridSelection;
|
|
1480
|
+
|
|
1481
|
+
/** */
|
|
1482
|
+
annotations?: Partial<AnnotationData>[];
|
|
1483
|
+
|
|
1484
|
+
/** current scroll position */
|
|
1485
|
+
scroll?: ScrollOffset;
|
|
1486
|
+
|
|
1487
|
+
/** visible flag. we only support visible/hidden */
|
|
1488
|
+
visible?: boolean;
|
|
1489
|
+
|
|
1490
|
+
/** testing */
|
|
1491
|
+
background_image?: string;
|
|
1492
|
+
}
|
|
1493
|
+
export interface ScrollOffset {
|
|
1494
|
+
x: number;
|
|
1495
|
+
y: number;
|
|
1496
|
+
}
|
|
1497
|
+
export type SerializedCellData = FlatCellData[] | NestedRowData[] | NestedColumnData[];
|
|
1498
|
+
export interface BaseCellData {
|
|
1499
|
+
value: CellValue;
|
|
1500
|
+
style_ref?: number;
|
|
1501
|
+
calculated?: CellValue;
|
|
1502
|
+
table?: Table;
|
|
1503
|
+
area?: IArea;
|
|
1504
|
+
merge_area?: IArea;
|
|
1505
|
+
validation?: DataValidation;
|
|
1506
|
+
calculated_type?: SerializedValueType;
|
|
1507
|
+
note?: string;
|
|
1508
|
+
hyperlink?: string;
|
|
1509
|
+
type?: SerializedValueType;
|
|
1510
|
+
sheet_id?: number;
|
|
1511
|
+
}
|
|
1512
|
+
export interface FlatCellData extends BaseCellData {
|
|
1513
|
+
row: number;
|
|
1514
|
+
column: number;
|
|
1515
|
+
}
|
|
1516
|
+
export interface NestedCellData {
|
|
1517
|
+
cells: BaseCellData[];
|
|
1518
|
+
}
|
|
1519
|
+
export interface NestedRowData extends NestedCellData {
|
|
1520
|
+
row: number;
|
|
1521
|
+
cells: Array<{
|
|
1522
|
+
column: number;
|
|
1523
|
+
} & BaseCellData>;
|
|
1524
|
+
}
|
|
1525
|
+
export interface NestedColumnData extends NestedCellData {
|
|
1526
|
+
column: number;
|
|
1527
|
+
cells: Array<{
|
|
1528
|
+
row: number;
|
|
1529
|
+
} & BaseCellData>;
|
|
1530
|
+
}
|
|
1531
|
+
|
|
1532
|
+
/**
|
|
1533
|
+
* struct representing a table
|
|
1534
|
+
*/
|
|
1535
|
+
export interface Table {
|
|
1536
|
+
|
|
1537
|
+
/**
|
|
1538
|
+
* table must have a name
|
|
1539
|
+
*/
|
|
1540
|
+
name: string;
|
|
1541
|
+
|
|
1542
|
+
/** table area */
|
|
1543
|
+
area: IArea;
|
|
1544
|
+
|
|
1545
|
+
/**
|
|
1546
|
+
* table column headers. normalize case before inserting.
|
|
1547
|
+
*/
|
|
1548
|
+
columns?: string[];
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* table has a totals row. this impacts layout and what's included
|
|
1552
|
+
* in the range when you refer to a column. also on import/export, the
|
|
1553
|
+
* AutoFilter element should exclude the totals row.
|
|
1554
|
+
*
|
|
1555
|
+
* NOTE: xlsx actually uses an integer for this -- can it be > 1?
|
|
1556
|
+
*/
|
|
1557
|
+
totals_row?: boolean;
|
|
1558
|
+
|
|
1559
|
+
/**
|
|
1560
|
+
* table is sortable. defaults to true. if false, disables UI sorting.
|
|
1561
|
+
*/
|
|
1562
|
+
sortable?: boolean;
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* theme for table. we have a default, but you can set explicitly.
|
|
1566
|
+
*/
|
|
1567
|
+
theme?: TableTheme;
|
|
1568
|
+
|
|
1569
|
+
/**
|
|
1570
|
+
* sort data. sorts are hard, meaning we actually move data around.
|
|
1571
|
+
* (not meaning difficult). we may keep track of the last sort so we
|
|
1572
|
+
* can toggle asc/desc, for example. atm this will not survive serialization.
|
|
1573
|
+
*/
|
|
1574
|
+
sort?: {
|
|
1575
|
+
column: number;
|
|
1576
|
+
type: TableSortType;
|
|
1577
|
+
asc: boolean;
|
|
1578
|
+
};
|
|
1579
|
+
}
|
|
1580
|
+
export type DataValidation = DataValidationList | DataValidationRange | DataValidationNumber | DataValidationDate | DataValidationBoolean;
|
|
1581
|
+
export interface DataValidationBase {
|
|
1582
|
+
error?: boolean;
|
|
1583
|
+
}
|
|
1584
|
+
export interface DataValidationRange extends DataValidationBase {
|
|
1585
|
+
type: 'range';
|
|
1586
|
+
area: IArea;
|
|
1587
|
+
}
|
|
1588
|
+
export interface DataValidationList extends DataValidationBase {
|
|
1589
|
+
type: 'list';
|
|
1590
|
+
list: CellValue[];
|
|
1591
|
+
}
|
|
1592
|
+
export interface DataValidationDate extends DataValidationBase {
|
|
1593
|
+
type: 'date';
|
|
1594
|
+
}
|
|
1595
|
+
export interface DataValidationNumber extends DataValidationBase {
|
|
1596
|
+
type: 'number';
|
|
1597
|
+
}
|
|
1598
|
+
export interface DataValidationBoolean extends DataValidationBase {
|
|
1599
|
+
type: 'boolean';
|
|
1600
|
+
}
|
|
1601
|
+
|
|
1602
|
+
/**
|
|
1603
|
+
* string types for import/export
|
|
1604
|
+
*/
|
|
1605
|
+
export type SerializedValueType = typeof ValueTypeList[number];
|
|
1606
|
+
|
|
1607
|
+
/**
|
|
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).
|
|
1613
|
+
*/
|
|
1614
|
+
export interface GridSelection {
|
|
1615
|
+
|
|
1616
|
+
/** target or main cell in the selection */
|
|
1617
|
+
target: ICellAddress;
|
|
1618
|
+
|
|
1619
|
+
/** selection area */
|
|
1620
|
+
area: Area;
|
|
1621
|
+
|
|
1622
|
+
/** there is nothing selected, even though this object exists */
|
|
1623
|
+
empty?: boolean;
|
|
1624
|
+
|
|
1625
|
+
/** for cacheing addtional selections. optimally don't serialize */
|
|
1626
|
+
rendered?: boolean;
|
|
1627
|
+
}
|
|
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
|
+
export type AnnotationData = AnnotationChartData | AnnotationImageData | AnnotationExternalData;
|
|
1765
|
+
export interface ImageAnnotationData {
|
|
1766
|
+
src: string;
|
|
1767
|
+
|
|
1768
|
+
/**/
|
|
1769
|
+
scale: string;
|
|
1770
|
+
original_size: {
|
|
1771
|
+
width: number;
|
|
1772
|
+
height: number;
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1776
|
+
/**
|
|
1777
|
+
* splitting persisted data from the annotation class. that class might
|
|
1778
|
+
* disappear in the future in favor of just a type. this interface should
|
|
1779
|
+
* fully match the old Partial<Annotation> we used before. note that we
|
|
1780
|
+
* used to define values for all members, but they may now be undefined
|
|
1781
|
+
* because the Annotation class as a Partial instance of this data.
|
|
1782
|
+
*
|
|
1783
|
+
* conceptually annotation was originally intended to support types other
|
|
1784
|
+
* than our own charts and images, but no one ever used it. so we could
|
|
1785
|
+
* lock down the `type` field if we wanted to. or perhaps have an `external`
|
|
1786
|
+
* type with opaque data. TODO.
|
|
1787
|
+
*
|
|
1788
|
+
*/
|
|
1789
|
+
export interface AnnotationDataBase {
|
|
1790
|
+
|
|
1791
|
+
/** the new layout, persisted and takes preference over the old one */
|
|
1792
|
+
layout?: AnnotationLayout;
|
|
1793
|
+
|
|
1794
|
+
/**
|
|
1795
|
+
* the old layout used rectangles, and we need to keep support for
|
|
1796
|
+
* that. this is not the layout rectangle. this rectangle is just
|
|
1797
|
+
* for serialization/deserialization. the actual rectangle is maintained
|
|
1798
|
+
* in the Annotation class.
|
|
1799
|
+
*/
|
|
1800
|
+
rect?: Partial<Rectangle>;
|
|
1801
|
+
|
|
1802
|
+
/** annotation can be resized. this is advisory, for UI */
|
|
1803
|
+
resizable: boolean;
|
|
1804
|
+
|
|
1805
|
+
/** annotation can be moved. this is advisory, for UI */
|
|
1806
|
+
movable: boolean;
|
|
1807
|
+
|
|
1808
|
+
/** annotation can be removed/deleted. this is advisory, for UI */
|
|
1809
|
+
removable: boolean;
|
|
1810
|
+
|
|
1811
|
+
/** annotation can be selected. this is advisory, for UI */
|
|
1812
|
+
selectable: boolean;
|
|
1813
|
+
|
|
1814
|
+
/** move when resizing/inserting rows/columns */
|
|
1815
|
+
move_with_cells: boolean;
|
|
1816
|
+
|
|
1817
|
+
/** resize when resizing/inserting rows/columns */
|
|
1818
|
+
resize_with_cells: boolean;
|
|
1819
|
+
|
|
1820
|
+
/**
|
|
1821
|
+
* optional formula. the formula will be updated on structure events
|
|
1822
|
+
* (insert/delete row/column).
|
|
1823
|
+
*/
|
|
1824
|
+
formula: string;
|
|
1825
|
+
|
|
1826
|
+
/**
|
|
1827
|
+
* extent, useful for exporting. we could probably serialize this,
|
|
1828
|
+
* just be sure to clear it when layout changes so it will be
|
|
1829
|
+
* recalculated.
|
|
1830
|
+
*
|
|
1831
|
+
* the idea is to know the bottom/right row/column of the annotation,
|
|
1832
|
+
* so when we preserve/restore the sheet we don't trim those rows/columns.
|
|
1833
|
+
* they don't need any data, but it just looks bad. we can do this
|
|
1834
|
+
* dynamically but since it won't change all that often, we might
|
|
1835
|
+
* as well precalculate.
|
|
1836
|
+
*/
|
|
1837
|
+
extent: ICellAddress;
|
|
1838
|
+
}
|
|
1839
|
+
export interface AnnotationImageData extends AnnotationDataBase {
|
|
1840
|
+
type: 'image';
|
|
1841
|
+
data: ImageAnnotationData;
|
|
1842
|
+
}
|
|
1843
|
+
export interface AnnotationChartData extends AnnotationDataBase {
|
|
1844
|
+
type: 'treb-chart';
|
|
1845
|
+
}
|
|
1846
|
+
export interface AnnotationExternalData extends AnnotationDataBase {
|
|
1847
|
+
type: 'external';
|
|
1848
|
+
data: Record<string, string>;
|
|
1849
|
+
}
|
|
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
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* represents the layout of an annotation, reference to the sheet
|
|
1907
|
+
*/
|
|
1908
|
+
export interface AnnotationLayout {
|
|
1909
|
+
tl: Corner;
|
|
1910
|
+
br: Corner;
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
/**
|
|
1914
|
+
* offset from corner, as % of cell
|
|
1915
|
+
*/
|
|
1916
|
+
export interface AddressOffset {
|
|
1917
|
+
x: number;
|
|
1918
|
+
y: number;
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1921
|
+
/**
|
|
1922
|
+
* represents one corner of a layout rectangle
|
|
1923
|
+
*/
|
|
1924
|
+
export interface Corner {
|
|
1925
|
+
address: ICellAddress;
|
|
1926
|
+
offset: AddressOffset;
|
|
1927
|
+
}
|
|
1928
|
+
export interface SerializedMacroFunction {
|
|
1929
|
+
name: string;
|
|
1930
|
+
function_def: string;
|
|
1931
|
+
argument_names?: string[];
|
|
1932
|
+
description?: string;
|
|
1933
|
+
}
|
|
1317
1934
|
|
|
1318
1935
|
/**
|
|
1319
1936
|
* options for exporting CSV/TSV
|