@trebco/treb 25.2.0 → 25.5.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.
- package/{.eslintrc.js → .eslintrc.cjs} +4 -0
- package/api-generator/api-generator.ts +25 -55
- package/dist/treb-spreadsheet.mjs +9 -9
- package/dist/treb.d.ts +2 -2
- package/esbuild-custom-element.mjs +5 -264
- package/esbuild-utils.mjs +273 -0
- package/package.json +2 -2
- package/treb-base-types/src/cell.ts +23 -22
- package/treb-base-types/src/cells.ts +55 -2
- package/treb-base-types/src/theme.ts +0 -11
- package/treb-base-types/src/union.ts +2 -1
- package/treb-calculator/src/calculator.ts +8 -5
- package/treb-calculator/src/dag/array-vertex.ts +22 -22
- package/treb-calculator/src/dag/graph.ts +25 -23
- package/treb-calculator/src/dag/leaf_vertex.ts +23 -22
- package/treb-calculator/src/dag/spreadsheet_vertex.ts +25 -23
- package/treb-calculator/src/expression-calculator.ts +23 -22
- package/treb-calculator/src/function-error.ts +23 -22
- package/treb-calculator/src/functions/base-functions.ts +3 -2
- package/treb-calculator/src/functions/checkbox.ts +23 -22
- package/treb-calculator/src/functions/complex-functions.ts +2 -1
- package/treb-calculator/src/functions/finance-functions.ts +22 -22
- package/treb-calculator/src/functions/information-functions.ts +22 -22
- package/treb-calculator/src/functions/matrix-functions.ts +2 -1
- package/treb-calculator/src/functions/statistics-functions.ts +22 -22
- package/treb-calculator/src/functions/text-functions.ts +23 -22
- package/treb-calculator/src/primitives.ts +23 -22
- package/treb-calculator/src/utilities.ts +23 -24
- package/treb-charts/src/chart-functions.ts +22 -22
- package/treb-charts/src/chart.ts +6 -3
- package/treb-charts/src/renderer.ts +25 -23
- package/treb-charts/src/util.ts +23 -22
- package/treb-embed/modern.tsconfig.json +3 -2
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +57 -14
- package/treb-embed/src/embedded-spreadsheet.ts +81 -47
- package/treb-embed/src/options.ts +11 -0
- package/treb-embed/src/progress-dialog.ts +0 -3
- package/treb-embed/src/types.ts +14 -3
- package/treb-embed/style/layout.scss +32 -29
- package/treb-embed/style/theme-defaults.scss +5 -0
- package/treb-export/src/drawing2/chart2.ts +2 -2
- package/treb-export/src/drawing2/drawing2.ts +6 -4
- package/treb-export/src/export-worker/export-worker.ts +22 -24
- package/treb-export/src/export-worker/index-modern.ts +2 -1
- package/treb-export/src/export2.ts +15 -8
- package/treb-export/src/import2.ts +10 -5
- package/treb-export/src/workbook-sheet2.ts +2 -1
- package/treb-format/src/format.ts +23 -22
- package/treb-format/src/format_parser.ts +23 -22
- package/treb-format/src/value_parser.ts +23 -22
- package/treb-grid/src/editors/formula_bar.ts +2 -1
- package/treb-grid/src/editors/formula_editor_base.ts +4 -2
- package/treb-grid/src/editors/overlay_editor.ts +2 -1
- package/treb-grid/src/index.ts +12 -9
- package/treb-grid/src/layout/base_layout.ts +4 -2
- package/treb-grid/src/render/selection-renderer.ts +25 -23
- package/treb-grid/src/render/tile_renderer.ts +6 -4
- package/treb-grid/src/types/annotation.ts +33 -37
- package/treb-grid/src/types/data_model.ts +30 -22
- package/treb-grid/src/types/grid.ts +55 -584
- package/treb-grid/src/types/grid_base.ts +401 -7
- package/treb-grid/src/types/grid_events.ts +3 -0
- package/treb-grid/src/types/grid_selection.ts +22 -22
- package/treb-grid/src/types/named_range.ts +22 -22
- package/treb-grid/src/types/sheet.ts +8 -7
- package/treb-grid/src/types/sheet_types.ts +11 -7
- package/treb-grid/src/types/tab_bar.ts +1 -1
- package/treb-parser/src/parser.ts +5 -4
- package/tsproject.json +3 -4
- package/tsconfig.json +0 -10
- /package/treb-embed/src/{custom-element/content-types.d.ts → content-types.d.ts} +0 -0
|
@@ -37,14 +37,17 @@
|
|
|
37
37
|
|
|
38
38
|
import { EventSource } from 'treb-utils';
|
|
39
39
|
import type { DataModel, MacroFunction, SerializedModel, SerializedNamedExpression, ViewModel } from './data_model';
|
|
40
|
-
import { Parser,
|
|
41
|
-
import {
|
|
42
|
-
import
|
|
40
|
+
import type { Parser, UnitAddress} from 'treb-parser';
|
|
41
|
+
import { type ExpressionUnit, IllegalSheetNameRegex, ParseCSV, ArgumentSeparatorType, DecimalMarkType } from 'treb-parser';
|
|
42
|
+
import { Area, IsCellAddress, ValidationType, ValueType, DefaultTableSortOptions } from 'treb-base-types';
|
|
43
|
+
import type { ICellAddress, IArea, Cell, CellValue , Style, Table, TableSortOptions, TableTheme, Complex } from 'treb-base-types';
|
|
43
44
|
import { Sheet } from './sheet';
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
45
|
+
import type { FunctionDescriptor} from '../editors/autocomplete_matcher';
|
|
46
|
+
import { AutocompleteMatcher, DescriptorType } from '../editors/autocomplete_matcher';
|
|
47
|
+
import { NumberFormat, ValueParser } from 'treb-format';
|
|
46
48
|
|
|
47
|
-
import {
|
|
49
|
+
import type { GridEvent } from './grid_events';
|
|
50
|
+
import { ErrorCode } from './grid_events';
|
|
48
51
|
import type { CommandRecord, DataValidationCommand, DuplicateSheetCommand, FreezeCommand, InsertColumnsCommand, InsertRowsCommand, ResizeColumnsCommand, ResizeRowsCommand, SelectCommand, SetRangeCommand, ShowSheetCommand, SortTableCommand } from './grid_command';
|
|
49
52
|
import { DefaultGridOptions, type GridOptions } from './grid_options';
|
|
50
53
|
import type { SerializeOptions } from './serialize_options';
|
|
@@ -55,7 +58,7 @@ import { CommandKey } from './grid_command';
|
|
|
55
58
|
import type { Command, ActivateSheetCommand,
|
|
56
59
|
DeleteSheetCommand, UpdateBordersCommand, SheetSelection } from './grid_command';
|
|
57
60
|
import type { UpdateFlags } from './update_flags';
|
|
58
|
-
import type { LegacySerializedSheet } from './sheet_types';
|
|
61
|
+
import type { FreezePane, LegacySerializedSheet } from './sheet_types';
|
|
59
62
|
import type { Annotation } from './annotation';
|
|
60
63
|
import type { ClipboardCellData } from './clipboard_data';
|
|
61
64
|
|
|
@@ -202,6 +205,176 @@ export class GridBase {
|
|
|
202
205
|
|
|
203
206
|
}
|
|
204
207
|
|
|
208
|
+
/**
|
|
209
|
+
* activate sheet, by name or index number
|
|
210
|
+
* @param sheet number (index into the array) or string (name)
|
|
211
|
+
*/
|
|
212
|
+
public ActivateSheet(sheet: number | string): void {
|
|
213
|
+
|
|
214
|
+
const index = (typeof sheet === 'number') ? sheet : undefined;
|
|
215
|
+
const name = (typeof sheet === 'string') ? sheet : undefined;
|
|
216
|
+
|
|
217
|
+
this.ExecCommand({
|
|
218
|
+
key: CommandKey.ActivateSheet,
|
|
219
|
+
index,
|
|
220
|
+
name,
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* activate sheet, by ID
|
|
227
|
+
*/
|
|
228
|
+
public ActivateSheetID(id: number): void {
|
|
229
|
+
this.ExecCommand({
|
|
230
|
+
key: CommandKey.ActivateSheet,
|
|
231
|
+
id,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* duplicate sheet by index or (omitting index) the current active sheet
|
|
237
|
+
*/
|
|
238
|
+
public DuplicateSheet(index?: number, name?: string, insert_before?: number|string): void {
|
|
239
|
+
|
|
240
|
+
const command: DuplicateSheetCommand = {
|
|
241
|
+
key: CommandKey.DuplicateSheet,
|
|
242
|
+
new_name: name,
|
|
243
|
+
insert_before,
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
if (typeof index === 'undefined') {
|
|
247
|
+
command.id = this.active_sheet.id;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
command.index = index;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
this.ExecCommand(command);
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public AddSheet(name?: string): void {
|
|
258
|
+
this.ExecCommand({
|
|
259
|
+
key: CommandKey.AddSheet,
|
|
260
|
+
name,
|
|
261
|
+
show: true,
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* delete sheet, by index or (omitting index) the current active sheet
|
|
267
|
+
*/
|
|
268
|
+
public DeleteSheet(index?: number): void {
|
|
269
|
+
|
|
270
|
+
if (typeof index === 'undefined') {
|
|
271
|
+
if (!this.model.sheets.list.some((sheet, i) => {
|
|
272
|
+
if (sheet === this.active_sheet) {
|
|
273
|
+
index = i;
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
return false;
|
|
277
|
+
})) {
|
|
278
|
+
throw new Error('invalid index');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
this.ExecCommand({
|
|
283
|
+
key: CommandKey.DeleteSheet,
|
|
284
|
+
index,
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** insert sheet at the given index (or current index) */
|
|
290
|
+
public InsertSheet(index?: number, name?: string): void {
|
|
291
|
+
|
|
292
|
+
if (typeof index === 'undefined') {
|
|
293
|
+
if (!this.model.sheets.list.some((sheet, i) => {
|
|
294
|
+
if (sheet === this.active_sheet) {
|
|
295
|
+
index = i + 1;
|
|
296
|
+
return true;
|
|
297
|
+
}
|
|
298
|
+
return false;
|
|
299
|
+
})) {
|
|
300
|
+
throw new Error('invalid index');
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
this.ExecCommand({
|
|
305
|
+
key: CommandKey.AddSheet,
|
|
306
|
+
insert_index: index,
|
|
307
|
+
name,
|
|
308
|
+
show: true,
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public DeleteSheetID(id: number): void {
|
|
314
|
+
this.ExecCommand({
|
|
315
|
+
key: CommandKey.DeleteSheet,
|
|
316
|
+
id,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* clear sheet, reset all data
|
|
322
|
+
*/
|
|
323
|
+
public Reset(): void {
|
|
324
|
+
this.ExecCommand({ key: CommandKey.Reset });
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* set hyperlink, like set note
|
|
329
|
+
*/
|
|
330
|
+
public SetLink(address: ICellAddress, reference?: string): void {
|
|
331
|
+
|
|
332
|
+
/*
|
|
333
|
+
if (!address) {
|
|
334
|
+
if (this.primary_selection.empty) return;
|
|
335
|
+
address = this.primary_selection.target;
|
|
336
|
+
}
|
|
337
|
+
*/
|
|
338
|
+
|
|
339
|
+
this.ExecCommand({
|
|
340
|
+
key: CommandKey.SetLink,
|
|
341
|
+
area: address,
|
|
342
|
+
reference,
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
public ShowAll(): void {
|
|
348
|
+
|
|
349
|
+
// obviously there are better ways to do this, but this
|
|
350
|
+
// will use the execcommand system and _should_ only fire
|
|
351
|
+
// a single event (FIXME: check)
|
|
352
|
+
|
|
353
|
+
const commands: ShowSheetCommand[] = [];
|
|
354
|
+
for (let index = 0; index < this.model.sheets.length; index++) {
|
|
355
|
+
commands.push({
|
|
356
|
+
key: CommandKey.ShowSheet,
|
|
357
|
+
index,
|
|
358
|
+
show: true,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
this.ExecCommand(commands);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
public ShowSheet(index: number|string = 0, show = true): void {
|
|
365
|
+
|
|
366
|
+
const command: ShowSheetCommand = {
|
|
367
|
+
key: CommandKey.ShowSheet,
|
|
368
|
+
show,
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
if (typeof index === 'string') { command.name = index; }
|
|
372
|
+
else { command.index = index; }
|
|
373
|
+
|
|
374
|
+
this.ExecCommand(command);
|
|
375
|
+
|
|
376
|
+
}
|
|
377
|
+
|
|
205
378
|
/**
|
|
206
379
|
* sort table. column is absolute.
|
|
207
380
|
*/
|
|
@@ -221,6 +394,170 @@ export class GridBase {
|
|
|
221
394
|
});
|
|
222
395
|
|
|
223
396
|
}
|
|
397
|
+
|
|
398
|
+
/** return freeze area */
|
|
399
|
+
public GetFreeze(): FreezePane {
|
|
400
|
+
return { ...this.active_sheet.freeze };
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
/**
|
|
404
|
+
* insert rows(s) at some specific point
|
|
405
|
+
*/
|
|
406
|
+
public InsertRows(before_row = 0, count = 1): void {
|
|
407
|
+
this.ExecCommand({
|
|
408
|
+
key: CommandKey.InsertRows,
|
|
409
|
+
before_row,
|
|
410
|
+
count,
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* return the table (if any) at the given address
|
|
416
|
+
*/
|
|
417
|
+
public GetTableReference(address: ICellAddress): Table|undefined {
|
|
418
|
+
const sheet = this.model.sheets.Find(address.sheet_id || this.active_sheet.id);
|
|
419
|
+
return sheet?.CellData(address).table || undefined;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
|
|
423
|
+
/**
|
|
424
|
+
* reset sheet, set data from CSV
|
|
425
|
+
*
|
|
426
|
+
* FIXME: this is problematic, because it runs around the exec command
|
|
427
|
+
* system. however it doesn't seem like a good candidate for a separate
|
|
428
|
+
* command. it should maybe move to the import class? (...)
|
|
429
|
+
*
|
|
430
|
+
* one problem with that is that import is really, really heavy (jszip).
|
|
431
|
+
* it seems wasteful to require all that just to import csv.
|
|
432
|
+
*/
|
|
433
|
+
public FromCSV(text: string): void {
|
|
434
|
+
|
|
435
|
+
// CSV assumes dot-decimal, correct? if we want to use the
|
|
436
|
+
// parser we will have to check (and set/reset) the separator
|
|
437
|
+
|
|
438
|
+
const toggle_separator = this.parser.decimal_mark === DecimalMarkType.Comma;
|
|
439
|
+
|
|
440
|
+
if (toggle_separator) {
|
|
441
|
+
// swap
|
|
442
|
+
this.parser.argument_separator = ArgumentSeparatorType.Comma;
|
|
443
|
+
this.parser.decimal_mark = DecimalMarkType.Period;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const records = ParseCSV(text);
|
|
447
|
+
const arr = records.map((record) =>
|
|
448
|
+
record.map((field) => {
|
|
449
|
+
if (field) {
|
|
450
|
+
const tmp = this.parser.Parse(field);
|
|
451
|
+
if (tmp.expression?.type === 'complex') {
|
|
452
|
+
return tmp.expression as Complex;
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
return ValueParser.TryParse(field).value;
|
|
456
|
+
}));
|
|
457
|
+
|
|
458
|
+
if (toggle_separator) {
|
|
459
|
+
// reset
|
|
460
|
+
this.parser.argument_separator = ArgumentSeparatorType.Semicolon;
|
|
461
|
+
this.parser.decimal_mark = DecimalMarkType.Comma;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const end = {
|
|
465
|
+
row: Math.max(0, arr.length - 1),
|
|
466
|
+
column: arr.reduce((max, row) => Math.max(max, Math.max(0, row.length - 1)), 0),
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
// NOTE: SetRange here does not need to be translated, because
|
|
470
|
+
// we're not expecting spreadsheet functions in the CSV. CSV should
|
|
471
|
+
// be data only. Famous last words.
|
|
472
|
+
|
|
473
|
+
this.ExecCommand([
|
|
474
|
+
{ key: CommandKey.Reset },
|
|
475
|
+
{
|
|
476
|
+
key: CommandKey.SetRange,
|
|
477
|
+
area: { start: { row: 0, column: 0 }, end },
|
|
478
|
+
value: arr,
|
|
479
|
+
},
|
|
480
|
+
|
|
481
|
+
// we took this out because the data may require a layout update
|
|
482
|
+
// (rebuilding tiles); in that case, this will be duplicative. maybe
|
|
483
|
+
// should use setTimeout or some sort of queue...
|
|
484
|
+
|
|
485
|
+
// { key: CommandKey.ResizeColumns }, // auto
|
|
486
|
+
]);
|
|
487
|
+
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* insert column(s) at some specific point
|
|
493
|
+
*/
|
|
494
|
+
public InsertColumns(before_column = 0, count = 1): void {
|
|
495
|
+
this.ExecCommand({
|
|
496
|
+
key: CommandKey.InsertColumns,
|
|
497
|
+
before_column,
|
|
498
|
+
count,
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** move sheet (X) before sheet (Y) */
|
|
503
|
+
public ReorderSheet(index: number, move_before: number): void {
|
|
504
|
+
this.ExecCommand({
|
|
505
|
+
key: CommandKey.ReorderSheet,
|
|
506
|
+
index,
|
|
507
|
+
move_before,
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* rename active sheet
|
|
513
|
+
*/
|
|
514
|
+
public RenameSheet(sheet: Sheet, name: string): void {
|
|
515
|
+
this.ExecCommand({
|
|
516
|
+
key: CommandKey.RenameSheet,
|
|
517
|
+
new_name: name,
|
|
518
|
+
id: sheet.id,
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* freeze rows or columns. set to 0 (or call with no arguments) to un-freeze.
|
|
524
|
+
*
|
|
525
|
+
* highglight is shown by default, but we can hide it(mostly for document load)
|
|
526
|
+
*/
|
|
527
|
+
public Freeze(rows = 0, columns = 0, highlight_transition = true): void {
|
|
528
|
+
this.ExecCommand({
|
|
529
|
+
key: CommandKey.Freeze,
|
|
530
|
+
rows,
|
|
531
|
+
columns,
|
|
532
|
+
highlight_transition,
|
|
533
|
+
});
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* API method
|
|
538
|
+
*/
|
|
539
|
+
public SetRowHeight(row?: number | number[], height?: number, shrink = true): void {
|
|
540
|
+
this.ExecCommand({
|
|
541
|
+
key: CommandKey.ResizeRows,
|
|
542
|
+
row,
|
|
543
|
+
height,
|
|
544
|
+
shrink,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* API method
|
|
550
|
+
*
|
|
551
|
+
* @param column column, columns, or undefined means all columns
|
|
552
|
+
* @param width target width, or undefined means auto-size
|
|
553
|
+
*/
|
|
554
|
+
public SetColumnWidth(column?: number | number[], width = 0): void {
|
|
555
|
+
this.ExecCommand({
|
|
556
|
+
key: CommandKey.ResizeColumns,
|
|
557
|
+
column,
|
|
558
|
+
width,
|
|
559
|
+
});
|
|
560
|
+
}
|
|
224
561
|
|
|
225
562
|
/**
|
|
226
563
|
* filter table. what this means is "show the rows that match the filter
|
|
@@ -552,6 +889,63 @@ export class GridBase {
|
|
|
552
889
|
|
|
553
890
|
}
|
|
554
891
|
|
|
892
|
+
/**
|
|
893
|
+
* check if we can paste into the target area(s). this will
|
|
894
|
+
* return false if the areas contain locked cells, or part of
|
|
895
|
+
* an array or merge but not the whole array or merge.
|
|
896
|
+
*
|
|
897
|
+
* @param areas
|
|
898
|
+
* @returns
|
|
899
|
+
*/
|
|
900
|
+
protected ValidatePasteAreas(areas: Area[]): boolean {
|
|
901
|
+
for (const area of areas) {
|
|
902
|
+
|
|
903
|
+
let sheet: Sheet|undefined = this.active_sheet;
|
|
904
|
+
if (area.start.sheet_id && area.start.sheet_id !== sheet.id) {
|
|
905
|
+
sheet = this.model.sheets.Find(area.start.sheet_id);
|
|
906
|
+
}
|
|
907
|
+
if (!sheet) {
|
|
908
|
+
return false;
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
let valid = true;
|
|
912
|
+
|
|
913
|
+
sheet.cells.Apply2(area, cell => {
|
|
914
|
+
if (cell.style?.locked) {
|
|
915
|
+
console.info('invalid: locked cells');
|
|
916
|
+
valid = false;
|
|
917
|
+
}
|
|
918
|
+
if (cell.merge_area) {
|
|
919
|
+
if (!area.Contains(cell.merge_area.start) || !area.Contains(cell.merge_area.end)) {
|
|
920
|
+
console.info('invalid: merge area');
|
|
921
|
+
valid = false;
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
if (cell.area) {
|
|
925
|
+
if (!area.Contains(cell.area.start) || !area.Contains(cell.area.end)) {
|
|
926
|
+
console.info('invalid: array');
|
|
927
|
+
valid = false;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
/* ok for paste
|
|
931
|
+
if (cell.table) {
|
|
932
|
+
if (!area.Contains(cell.table.area.start) || !area.Contains(cell.table.area.end)) {
|
|
933
|
+
console.info('invalid: table');
|
|
934
|
+
valid = false;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
*/
|
|
938
|
+
return valid;
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
if (!valid) {
|
|
942
|
+
return false;
|
|
943
|
+
}
|
|
944
|
+
|
|
945
|
+
}
|
|
946
|
+
return true;
|
|
947
|
+
}
|
|
948
|
+
|
|
555
949
|
protected SetValidationInternal(command: DataValidationCommand): void {
|
|
556
950
|
|
|
557
951
|
let cell: Cell|undefined;
|
|
@@ -41,6 +41,9 @@ export enum ErrorCode {
|
|
|
41
41
|
/** invalid area for insert table: there's a merge, array or existing table within the range */
|
|
42
42
|
invalid_area_for_table,
|
|
43
43
|
|
|
44
|
+
/** invalid area for paste, same as invalid area for table */
|
|
45
|
+
invalid_area_for_paste,
|
|
46
|
+
|
|
44
47
|
}
|
|
45
48
|
|
|
46
49
|
export interface SheetChangeEvent {
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { Area, ICellAddress } from 'treb-base-types';
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { Area, type ICellAddress } from 'treb-base-types';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* FIXME: this is broken. we treat this as a simple javascript object,
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* This file is part of TREB.
|
|
3
|
-
*
|
|
4
|
-
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
-
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
-
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
-
* later version.
|
|
8
|
-
*
|
|
9
|
-
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
-
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
-
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
-
* details.
|
|
13
|
-
*
|
|
14
|
-
* You should have received a copy of the GNU General Public License along
|
|
15
|
-
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
-
*
|
|
17
|
-
* Copyright 2022-2023 trebco, llc.
|
|
18
|
-
* info@treb.app
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
|
|
22
|
-
import { IArea, Area } from 'treb-base-types';
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of TREB.
|
|
3
|
+
*
|
|
4
|
+
* TREB is free software: you can redistribute it and/or modify it under the
|
|
5
|
+
* terms of the GNU General Public License as published by the Free Software
|
|
6
|
+
* Foundation, either version 3 of the License, or (at your option) any
|
|
7
|
+
* later version.
|
|
8
|
+
*
|
|
9
|
+
* TREB is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
10
|
+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
11
|
+
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
12
|
+
* details.
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of the GNU General Public License along
|
|
15
|
+
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2022-2023 trebco, llc.
|
|
18
|
+
* info@treb.app
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import { type IArea, Area } from 'treb-base-types';
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* I want to repurpose named ranges (a little) to allow either values or
|
|
@@ -21,22 +21,23 @@
|
|
|
21
21
|
|
|
22
22
|
// --- treb imports -----------------------------------------------------------
|
|
23
23
|
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
IsNestedRowArray, CellValue, ImportedSheetData, Complex,
|
|
28
|
-
DimensionedQuantity, IsCellAddress, IArea, Table, TableTheme,
|
|
24
|
+
import { ValueType, Cells, Style,
|
|
25
|
+
Area, IsFlatDataArray,
|
|
26
|
+
IsNestedRowArray, IsCellAddress
|
|
29
27
|
} from 'treb-base-types';
|
|
30
28
|
import { NumberFormatCache } from 'treb-format';
|
|
31
29
|
import { Measurement, ValidateURI } from 'treb-utils';
|
|
32
30
|
|
|
33
|
-
import type { TextPart
|
|
31
|
+
import type { TextPart ,
|
|
32
|
+
Cell, ICellAddress, CellSerializationOptions, CellValue, ImportedSheetData, Complex,
|
|
33
|
+
DimensionedQuantity, IArea, Table, TableTheme} from 'treb-base-types';
|
|
34
34
|
|
|
35
35
|
// --- local imports ----------------------------------------------------------
|
|
36
36
|
|
|
37
37
|
import type { FreezePane, SerializedSheet, ScrollOffset } from './sheet_types';
|
|
38
38
|
import type { SerializeOptions } from './serialize_options';
|
|
39
|
-
import {
|
|
39
|
+
import type { GridSelection } from './grid_selection';
|
|
40
|
+
import { CreateSelection } from './grid_selection';
|
|
40
41
|
import { Annotation } from './annotation';
|
|
41
42
|
|
|
42
43
|
// --- constants --------------------------------------------------------------
|
|
@@ -57,21 +57,25 @@ export interface SerializedSheet {
|
|
|
57
57
|
cell_style_refs?: Style.Properties[]; // old
|
|
58
58
|
styles?: Style.Properties[]; // new
|
|
59
59
|
|
|
60
|
-
// row_style: Style.Properties[];
|
|
61
|
-
// column_style: Style.Properties[];
|
|
62
|
-
// row_style: Array<Style.Properties|number>;
|
|
63
|
-
// column_style: Array<Style.Properties|number>;
|
|
64
60
|
row_style: Record<number, Style.Properties|number>;
|
|
65
61
|
column_style: Record<number, Style.Properties|number>;
|
|
66
62
|
|
|
63
|
+
/**
|
|
64
|
+
* @deprecated - no one uses this anymore and it's weird
|
|
65
|
+
*/
|
|
67
66
|
row_pattern?: Style.Properties[];
|
|
68
67
|
|
|
69
68
|
default_row_height?: number;
|
|
70
69
|
default_column_width?: number;
|
|
71
70
|
|
|
72
|
-
row_height?:
|
|
73
|
-
column_width?:
|
|
74
|
-
named_ranges?:
|
|
71
|
+
row_height?: Record<number, number>;
|
|
72
|
+
column_width?: Record<number, number>;
|
|
73
|
+
named_ranges?: Record<string, IArea>;
|
|
74
|
+
|
|
75
|
+
// row_height?: {[index: number]: number};
|
|
76
|
+
// column_width?: {[index: number]: number};
|
|
77
|
+
// named_ranges?: {[index: string]: IArea};
|
|
78
|
+
|
|
75
79
|
freeze?: FreezePane;
|
|
76
80
|
|
|
77
81
|
id?: number;
|
|
@@ -25,7 +25,7 @@ import type { Sheet } from './sheet';
|
|
|
25
25
|
import type { BaseLayout } from '../layout/base_layout';
|
|
26
26
|
import { MouseDrag } from './drag_mask';
|
|
27
27
|
import type { GridOptions } from './grid_options';
|
|
28
|
-
import { ScaleEvent, ScaleControl } from './scale-control';
|
|
28
|
+
import { type ScaleEvent, ScaleControl } from './scale-control';
|
|
29
29
|
|
|
30
30
|
export interface ActivateSheetEvent {
|
|
31
31
|
type: 'activate-sheet';
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import {
|
|
22
|
+
import type {
|
|
23
23
|
ExpressionUnit,
|
|
24
24
|
UnitAddress,
|
|
25
25
|
UnitIdentifier,
|
|
@@ -29,13 +29,14 @@ import {
|
|
|
29
29
|
UnitUnary,
|
|
30
30
|
DependencyList,
|
|
31
31
|
ParseResult,
|
|
32
|
-
ArgumentSeparatorType,
|
|
33
|
-
DecimalMarkType,
|
|
34
32
|
UnitLiteral,
|
|
35
33
|
UnitLiteralNumber,
|
|
36
34
|
ParserFlags,
|
|
37
35
|
UnitStructuredReference,
|
|
38
|
-
RenderOptions
|
|
36
|
+
RenderOptions} from './parser-types';
|
|
37
|
+
import {
|
|
38
|
+
ArgumentSeparatorType,
|
|
39
|
+
DecimalMarkType
|
|
39
40
|
} from './parser-types';
|
|
40
41
|
|
|
41
42
|
interface PrecedenceList {
|
package/tsproject.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"declaration": true,
|
|
4
4
|
"declarationDir": "declaration",
|
|
5
5
|
"target": "esnext",
|
|
6
|
-
"module": "
|
|
6
|
+
"module": "esnext",
|
|
7
7
|
"strict": true,
|
|
8
8
|
"composite": true,
|
|
9
9
|
"baseUrl": "./",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"rootDir": ".",
|
|
17
17
|
"importHelpers": true,
|
|
18
18
|
"noEmitHelpers": true,
|
|
19
|
-
"
|
|
19
|
+
"verbatimModuleSyntax": true,
|
|
20
20
|
"lib": [
|
|
21
21
|
"dom", "es2015"
|
|
22
22
|
],
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
"esModuleInterop": true
|
|
25
25
|
},
|
|
26
26
|
"exclude": [
|
|
27
|
-
"node_modules"
|
|
28
|
-
"external-declaration-files"
|
|
27
|
+
"node_modules"
|
|
29
28
|
]
|
|
30
29
|
}
|
package/tsconfig.json
DELETED
|
File without changes
|