@odoo/o-spreadsheet 14.0.1 → 14.0.2
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/dist/o_spreadsheet.cjs.js +17836 -0
- package/dist/o_spreadsheet.d.ts +4102 -0
- package/dist/o_spreadsheet.esm.js +17801 -0
- package/dist/o_spreadsheet.iife.js +17838 -0
- package/dist/o_spreadsheet.iife.min.js +1440 -0
- package/package.json +27 -7
- package/readme.md +10 -0
- package/.eslintrc.json +0 -20
- package/.husky/post-checkout +0 -9
- package/.husky/pre-commit +0 -39
- package/.prettierignore +0 -1
- package/astToFormula.patch +0 -0
- package/demo/data.js +0 -255
- package/demo/index.html +0 -9
- package/demo/libs/Chart.bundle.js +0 -20755
- package/demo/main.js +0 -101
- package/doc/readme.md +0 -46
- package/rollup.config.js +0 -23
- package/src/base_plugin.ts +0 -102
- package/src/components/autofill.ts +0 -146
- package/src/components/bottom_bar.ts +0 -199
- package/src/components/color_picker.ts +0 -150
- package/src/components/composer/autocomplete_dropdown.ts +0 -135
- package/src/components/composer/composer.ts +0 -487
- package/src/components/composer/content_editable_helper.ts +0 -146
- package/src/components/figures/chart.ts +0 -70
- package/src/components/figures/container.ts +0 -268
- package/src/components/figures/text_figure.ts +0 -36
- package/src/components/grid.ts +0 -635
- package/src/components/helpers/dom_helpers.ts +0 -7
- package/src/components/helpers/drag_and_drop.ts +0 -17
- package/src/components/icons.ts +0 -36
- package/src/components/index.ts +0 -1
- package/src/components/menu.ts +0 -288
- package/src/components/overlay.ts +0 -457
- package/src/components/scrollbar.ts +0 -22
- package/src/components/selection_input.ts +0 -168
- package/src/components/side_panel/cell_is_rule_editor.ts +0 -169
- package/src/components/side_panel/chart_panel.ts +0 -104
- package/src/components/side_panel/color_scale_rule_editor.ts +0 -145
- package/src/components/side_panel/conditional_formatting.ts +0 -396
- package/src/components/side_panel/side_panel.ts +0 -127
- package/src/components/side_panel/translations_terms.ts +0 -45
- package/src/components/spreadsheet.ts +0 -198
- package/src/components/top_bar.ts +0 -535
- package/src/constants.ts +0 -26
- package/src/data.ts +0 -149
- package/src/fonts.ts +0 -41
- package/src/formulas/compiler.ts +0 -258
- package/src/formulas/composer_tokenizer.ts +0 -70
- package/src/formulas/index.ts +0 -15
- package/src/formulas/normalize.ts +0 -52
- package/src/formulas/parser.ts +0 -280
- package/src/formulas/range_tokenizer.ts +0 -97
- package/src/formulas/tokenizer.ts +0 -242
- package/src/functions/arguments.ts +0 -114
- package/src/functions/dates.ts +0 -302
- package/src/functions/helpers.ts +0 -592
- package/src/functions/index.ts +0 -52
- package/src/functions/module_database.ts +0 -282
- package/src/functions/module_date.ts +0 -743
- package/src/functions/module_info.ts +0 -69
- package/src/functions/module_logical.ts +0 -208
- package/src/functions/module_lookup.ts +0 -185
- package/src/functions/module_math.ts +0 -1252
- package/src/functions/module_operators.ts +0 -291
- package/src/functions/module_statistical.ts +0 -882
- package/src/functions/module_text.ts +0 -370
- package/src/helpers/color.ts +0 -30
- package/src/helpers/coordinates.ts +0 -71
- package/src/helpers/grid_manipulation.ts +0 -68
- package/src/helpers/index.ts +0 -7
- package/src/helpers/misc.ts +0 -76
- package/src/helpers/numbers.ts +0 -117
- package/src/helpers/uuid.ts +0 -19
- package/src/helpers/zones.ts +0 -263
- package/src/history.ts +0 -186
- package/src/index.ts +0 -84
- package/src/model.ts +0 -261
- package/src/plugins/autofill.ts +0 -412
- package/src/plugins/chart.ts +0 -404
- package/src/plugins/clipboard.ts +0 -461
- package/src/plugins/conditional_format.ts +0 -445
- package/src/plugins/core.ts +0 -1502
- package/src/plugins/edition.ts +0 -157
- package/src/plugins/evaluation.ts +0 -428
- package/src/plugins/figures.ts +0 -123
- package/src/plugins/formatting.ts +0 -630
- package/src/plugins/highlight.ts +0 -187
- package/src/plugins/index.ts +0 -32
- package/src/plugins/merge.ts +0 -524
- package/src/plugins/renderer.ts +0 -571
- package/src/plugins/selection.ts +0 -562
- package/src/plugins/selection_inputs.ts +0 -326
- package/src/registries/autofill_modifiers.ts +0 -76
- package/src/registries/autofill_rules.ts +0 -98
- package/src/registries/figure_registry.ts +0 -30
- package/src/registries/index.ts +0 -7
- package/src/registries/menu_items_registry.ts +0 -110
- package/src/registries/menus/cell_menu_registry.ts +0 -79
- package/src/registries/menus/col_menu_registry.ts +0 -63
- package/src/registries/menus/index.ts +0 -6
- package/src/registries/menus/menu_items_actions.ts +0 -425
- package/src/registries/menus/row_menu_registry.ts +0 -63
- package/src/registries/menus/sheet_menu_registry.ts +0 -75
- package/src/registries/menus/topbar_menu_registry.ts +0 -204
- package/src/registries/side_panel_registry.ts +0 -26
- package/src/registries/topbar_component_registry.ts +0 -12
- package/src/registry.ts +0 -51
- package/src/translation.ts +0 -44
- package/src/types/autofill.ts +0 -48
- package/src/types/chart.ts +0 -26
- package/src/types/commands.ts +0 -716
- package/src/types/conditional_formatting.ts +0 -124
- package/src/types/env.ts +0 -13
- package/src/types/functions.ts +0 -35
- package/src/types/getters.ts +0 -103
- package/src/types/index.ts +0 -20
- package/src/types/misc.ts +0 -143
- package/src/types/rendering.ts +0 -41
- package/src/types/workbook_data.ts +0 -62
- package/tests/__mocks__/uuid.ts +0 -7
- package/tests/canvas.mock.ts +0 -34
- package/tests/components/__mocks__/content_editable_helper.ts +0 -79
- package/tests/components/__mocks__/scrollbar.ts +0 -18
- package/tests/components/__snapshots__/autocomplete_dropdown_test.ts.snap +0 -29
- package/tests/components/__snapshots__/bottom_bar_test.ts.snap +0 -75
- package/tests/components/__snapshots__/context_menu_test.ts.snap +0 -88
- package/tests/components/__snapshots__/grid_test.ts.snap +0 -60
- package/tests/components/__snapshots__/spreadsheet_test.ts.snap +0 -455
- package/tests/components/__snapshots__/top_bar_test.ts.snap +0 -705
- package/tests/components/autocomplete_dropdown_test.ts +0 -315
- package/tests/components/autofill_test.ts +0 -167
- package/tests/components/bottom_bar_test.ts +0 -262
- package/tests/components/chart_side_panel_test.ts +0 -123
- package/tests/components/composer_test.ts +0 -400
- package/tests/components/context_menu_test.ts +0 -825
- package/tests/components/grid_manipulation_test.ts +0 -163
- package/tests/components/grid_test.ts +0 -581
- package/tests/components/overlay_test.ts +0 -541
- package/tests/components/selection_input_test.ts +0 -259
- package/tests/components/side_panel_test.ts +0 -148
- package/tests/components/spreadsheet_test.ts +0 -194
- package/tests/components/top_bar_test.ts +0 -427
- package/tests/data_test.ts +0 -175
- package/tests/dom_helper.ts +0 -42
- package/tests/formulas/__snapshots__/compiler_test.ts.snap +0 -302
- package/tests/formulas/compiler_test.ts +0 -266
- package/tests/formulas/composer_tokenizer_test.ts +0 -137
- package/tests/formulas/expressions_test.ts +0 -57
- package/tests/formulas/formulas_test.ts +0 -80
- package/tests/formulas/normalize_test.ts +0 -82
- package/tests/formulas/parser_test.ts +0 -224
- package/tests/formulas/range_tokenizer_test.ts +0 -187
- package/tests/formulas/tokenizer_test.ts +0 -164
- package/tests/functions/arguments_test.ts +0 -141
- package/tests/functions/dates_test.ts +0 -1081
- package/tests/functions/functions_test.ts +0 -53
- package/tests/functions/helper_test.ts +0 -98
- package/tests/functions/module_database_test.ts +0 -311
- package/tests/functions/module_date_test.ts +0 -941
- package/tests/functions/module_info_test.ts +0 -139
- package/tests/functions/module_logical_test.ts +0 -369
- package/tests/functions/module_lookup_test.ts +0 -541
- package/tests/functions/module_math_test.ts +0 -2482
- package/tests/functions/module_operators_test.ts +0 -955
- package/tests/functions/module_statistical_test.ts +0 -2014
- package/tests/functions/module_text_test.ts +0 -667
- package/tests/helpers/coordinates_test.ts +0 -25
- package/tests/helpers/misc_test.ts +0 -95
- package/tests/helpers/numbers_test.ts +0 -196
- package/tests/helpers/zones_test.ts +0 -97
- package/tests/helpers.ts +0 -384
- package/tests/menu_items_registry_test.ts +0 -540
- package/tests/model/plugins/__snapshots__/chart_test.ts.snap +0 -90
- package/tests/model/plugins/chart_test.ts +0 -562
- package/tests/model_test.ts +0 -82
- package/tests/plugins/__snapshots__/conditional_formatting_test.ts.snap +0 -131
- package/tests/plugins/__snapshots__/renderer_test.ts.snap +0 -371
- package/tests/plugins/autofill_test.ts +0 -457
- package/tests/plugins/borders_test.ts +0 -295
- package/tests/plugins/clipboard_test.ts +0 -1180
- package/tests/plugins/conditional_formatting_test.ts +0 -1253
- package/tests/plugins/core_test.ts +0 -614
- package/tests/plugins/edition_test.ts +0 -100
- package/tests/plugins/evaluation_async_test.ts +0 -332
- package/tests/plugins/evaluation_dates_test.ts +0 -79
- package/tests/plugins/evaluation_test.ts +0 -901
- package/tests/plugins/figures_test.ts +0 -327
- package/tests/plugins/formatting_test.ts +0 -391
- package/tests/plugins/grid_manipulation_test.ts +0 -1366
- package/tests/plugins/highlight_test.ts +0 -413
- package/tests/plugins/history_test.ts +0 -142
- package/tests/plugins/import_export_test.ts +0 -276
- package/tests/plugins/merges_test.ts +0 -490
- package/tests/plugins/navigation_test.ts +0 -181
- package/tests/plugins/plugins/evaluation_test.ts +0 -111
- package/tests/plugins/renderer_test.ts +0 -598
- package/tests/plugins/resizing_test.ts +0 -152
- package/tests/plugins/selection_input_test.ts +0 -409
- package/tests/plugins/selection_test.ts +0 -442
- package/tests/plugins/sheets_test.ts +0 -643
- package/tests/plugins/style_test.ts +0 -90
- package/tsconfig.json +0 -22
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { Style } from "./misc";
|
|
2
|
-
|
|
3
|
-
// -----------------------------------------------------------------------------
|
|
4
|
-
// Conditional Formatting
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* https://docs.microsoft.com/en-us/openspecs/office_standards/ms-xlsx/025ea6e4-ad42-43ea-a016-16f4e4688ac8
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export interface ConditionalFormat {
|
|
12
|
-
id: string;
|
|
13
|
-
rule: SingleColorRules | ColorScaleRule; //| DataBarRule | IconSetRule; // the rules to apply, in order;
|
|
14
|
-
stopIfTrue?: boolean; // the next rules must not be evaluated/applied if this rule is true
|
|
15
|
-
ranges: string[]; // the cells/ranges on which to apply this conditional formatting
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export type SingleColorRules =
|
|
19
|
-
| CellIsRule
|
|
20
|
-
| ExpressionRule
|
|
21
|
-
| ContainsTextRule
|
|
22
|
-
| NotContainsTextRule
|
|
23
|
-
| BeginsWithRule
|
|
24
|
-
| EndsWithRule
|
|
25
|
-
| containsBlanksRule
|
|
26
|
-
| notContainsBlanksRule
|
|
27
|
-
| containsErrorsRule
|
|
28
|
-
| notContainsErrorsRule
|
|
29
|
-
| TimePeriodRule
|
|
30
|
-
| AboveAverageRule
|
|
31
|
-
| Top10Rule;
|
|
32
|
-
|
|
33
|
-
export interface SingleColorRule {
|
|
34
|
-
style: Style;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface TextRule extends SingleColorRule {
|
|
38
|
-
text: string;
|
|
39
|
-
}
|
|
40
|
-
export interface CellIsRule extends SingleColorRule {
|
|
41
|
-
type: "CellIsRule";
|
|
42
|
-
operator: ConditionalFormattingOperatorValues;
|
|
43
|
-
// can be one value for all operator except between, then it is 2 values
|
|
44
|
-
values: string[];
|
|
45
|
-
}
|
|
46
|
-
export interface ExpressionRule extends SingleColorRule {
|
|
47
|
-
type: "ExpressionRule";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export type ThresholdTypes = "value" | "number" | "percent" | "percentile" | "formula";
|
|
51
|
-
export type ColorScaleThreshold = { color: number; type: ThresholdTypes; value?: number };
|
|
52
|
-
|
|
53
|
-
export interface ColorScaleRule {
|
|
54
|
-
type: "ColorScaleRule";
|
|
55
|
-
minimum: ColorScaleThreshold;
|
|
56
|
-
maximum: ColorScaleThreshold;
|
|
57
|
-
midpoint?: ColorScaleThreshold;
|
|
58
|
-
}
|
|
59
|
-
// for future use
|
|
60
|
-
// export interface DataBarRule {
|
|
61
|
-
// type: "ColorScaleRule";
|
|
62
|
-
// }
|
|
63
|
-
// export interface IconSetRule {
|
|
64
|
-
// type: "IconSetRule";
|
|
65
|
-
// }
|
|
66
|
-
export interface ContainsTextRule extends TextRule {
|
|
67
|
-
type: "ContainsTextRule";
|
|
68
|
-
}
|
|
69
|
-
export interface NotContainsTextRule extends TextRule {
|
|
70
|
-
type: "NotContainsTextRule";
|
|
71
|
-
}
|
|
72
|
-
export interface BeginsWithRule extends TextRule {
|
|
73
|
-
type: "BeginsWithRule";
|
|
74
|
-
}
|
|
75
|
-
export interface EndsWithRule extends TextRule {
|
|
76
|
-
type: "EndsWithRule";
|
|
77
|
-
}
|
|
78
|
-
export interface containsBlanksRule extends TextRule {
|
|
79
|
-
type: "containsBlanksRule";
|
|
80
|
-
}
|
|
81
|
-
export interface notContainsBlanksRule extends TextRule {
|
|
82
|
-
type: "notContainsBlanksRule";
|
|
83
|
-
}
|
|
84
|
-
export interface containsErrorsRule extends SingleColorRule {
|
|
85
|
-
type: "containsErrorsRule";
|
|
86
|
-
}
|
|
87
|
-
export interface notContainsErrorsRule extends SingleColorRule {
|
|
88
|
-
type: "notContainsErrorsRule";
|
|
89
|
-
}
|
|
90
|
-
export interface TimePeriodRule extends SingleColorRule {
|
|
91
|
-
type: "TimePeriodRule";
|
|
92
|
-
timePeriod: string;
|
|
93
|
-
}
|
|
94
|
-
export interface AboveAverageRule extends SingleColorRule {
|
|
95
|
-
type: "AboveAverageRule";
|
|
96
|
-
/*"true" The conditional formatting rule is applied to cells with values above the average value of all cells in the range.
|
|
97
|
-
"false" The conditional formatting rule is applied to cells with values below the average value of all cells in the range.*/
|
|
98
|
-
aboveAverage: boolean;
|
|
99
|
-
equalAverage: boolean;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface Top10Rule extends SingleColorRule {
|
|
103
|
-
type: "Top10Rule";
|
|
104
|
-
percent: boolean;
|
|
105
|
-
bottom: boolean;
|
|
106
|
-
/* specifies how many cells are formatted by this conditional formatting rule. The value of percent specifies whether
|
|
107
|
-
rank is a percentage or a quantity of cells. When percent is "true", rank MUST be greater than or equal to zero and
|
|
108
|
-
less than or equal to 100. Otherwise, rank MUST be greater than or equal to 1 and less than or equal to 1,000 */
|
|
109
|
-
rank: number;
|
|
110
|
-
}
|
|
111
|
-
//https://docs.microsoft.com/en-us/dotnet/api/documentformat.openxml.spreadsheet.conditionalformattingoperatorvalues?view=openxml-2.8.1
|
|
112
|
-
export type ConditionalFormattingOperatorValues =
|
|
113
|
-
| "BeginsWith"
|
|
114
|
-
| "Between"
|
|
115
|
-
| "ContainsText"
|
|
116
|
-
| "EndsWith"
|
|
117
|
-
| "Equal"
|
|
118
|
-
| "GreaterThan"
|
|
119
|
-
| "GreaterThanOrEqual"
|
|
120
|
-
| "LessThan"
|
|
121
|
-
| "LessThanOrEqual"
|
|
122
|
-
| "NotBetween"
|
|
123
|
-
| "NotContains"
|
|
124
|
-
| "NotEqual";
|
package/src/types/env.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Env } from "@odoo/owl/dist/types/component/component";
|
|
2
|
-
import { TranslationFunction } from "../translation";
|
|
3
|
-
import { CommandDispatcher } from "./commands";
|
|
4
|
-
import { Getters } from "./getters";
|
|
5
|
-
|
|
6
|
-
export interface SpreadsheetEnv extends Env {
|
|
7
|
-
openSidePanel: (panel: string, panelProps?: any) => void;
|
|
8
|
-
toggleSidePanel: (panel: string, panelProps?: any) => void;
|
|
9
|
-
dispatch: CommandDispatcher["dispatch"];
|
|
10
|
-
getters: Getters;
|
|
11
|
-
clipboard: Clipboard;
|
|
12
|
-
_t: TranslationFunction;
|
|
13
|
-
}
|
package/src/types/functions.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
export type ArgType =
|
|
2
|
-
| "ANY"
|
|
3
|
-
| "BOOLEAN"
|
|
4
|
-
| "NUMBER"
|
|
5
|
-
| "STRING"
|
|
6
|
-
| "DATE"
|
|
7
|
-
| "RANGE"
|
|
8
|
-
| "RANGE<BOOLEAN>"
|
|
9
|
-
| "RANGE<NUMBER>"
|
|
10
|
-
| "RANGE<STRING>"
|
|
11
|
-
| "RANGE<DATE>";
|
|
12
|
-
|
|
13
|
-
export interface Arg {
|
|
14
|
-
repeating?: boolean;
|
|
15
|
-
optional?: boolean;
|
|
16
|
-
lazy?: boolean;
|
|
17
|
-
description: string;
|
|
18
|
-
name: string;
|
|
19
|
-
type: ArgType[];
|
|
20
|
-
default?: any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface FunctionDescription {
|
|
24
|
-
description: string;
|
|
25
|
-
compute: (this: EvalContext, ...args: any[]) => any;
|
|
26
|
-
async?: boolean;
|
|
27
|
-
category?: string;
|
|
28
|
-
args: Arg[];
|
|
29
|
-
returns: [ArgType];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface EvalContext {
|
|
33
|
-
__lastFnCalled?: string;
|
|
34
|
-
[key: string]: any;
|
|
35
|
-
}
|
package/src/types/getters.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { WHistory } from "../history";
|
|
2
|
-
import { AutofillPlugin } from "../plugins/autofill";
|
|
3
|
-
import { ChartPlugin } from "../plugins/chart";
|
|
4
|
-
import { ClipboardPlugin } from "../plugins/clipboard";
|
|
5
|
-
import { ConditionalFormatPlugin } from "../plugins/conditional_format";
|
|
6
|
-
import { CorePlugin } from "../plugins/core";
|
|
7
|
-
import { EditionPlugin } from "../plugins/edition";
|
|
8
|
-
import { EvaluationPlugin } from "../plugins/evaluation";
|
|
9
|
-
import { FigurePlugin } from "../plugins/figures";
|
|
10
|
-
import { FormattingPlugin } from "../plugins/formatting";
|
|
11
|
-
import { HighlightPlugin } from "../plugins/highlight";
|
|
12
|
-
import { MergePlugin } from "../plugins/merge";
|
|
13
|
-
import { RendererPlugin } from "../plugins/renderer";
|
|
14
|
-
import { SelectionPlugin } from "../plugins/selection";
|
|
15
|
-
import { SelectionInputPlugin } from "../plugins/selection_inputs";
|
|
16
|
-
|
|
17
|
-
// -----------------------------------------------------------------------------
|
|
18
|
-
// Getters
|
|
19
|
-
// -----------------------------------------------------------------------------
|
|
20
|
-
export interface Getters {
|
|
21
|
-
applyOffset: CorePlugin["applyOffset"];
|
|
22
|
-
getCell: CorePlugin["getCell"];
|
|
23
|
-
getCellText: CorePlugin["getCellText"];
|
|
24
|
-
zoneToXC: CorePlugin["zoneToXC"];
|
|
25
|
-
|
|
26
|
-
getActiveSheet: CorePlugin["getActiveSheet"];
|
|
27
|
-
getSheetName: CorePlugin["getSheetName"];
|
|
28
|
-
getSheetIdByName: CorePlugin["getSheetIdByName"];
|
|
29
|
-
getSheets: CorePlugin["getSheets"];
|
|
30
|
-
getCol: CorePlugin["getCol"];
|
|
31
|
-
getRow: CorePlugin["getRow"];
|
|
32
|
-
getColCells: CorePlugin["getColCells"];
|
|
33
|
-
getNumberCols: CorePlugin["getNumberCols"];
|
|
34
|
-
getNumberRows: CorePlugin["getNumberRows"];
|
|
35
|
-
getColsZone: CorePlugin["getColsZone"];
|
|
36
|
-
getRowsZone: CorePlugin["getRowsZone"];
|
|
37
|
-
getGridSize: CorePlugin["getGridSize"];
|
|
38
|
-
getRangeValues: CorePlugin["getRangeValues"];
|
|
39
|
-
getRangeFormattedValues: CorePlugin["getRangeFormattedValues"];
|
|
40
|
-
shouldShowFormulas: CorePlugin["shouldShowFormulas"];
|
|
41
|
-
|
|
42
|
-
getClipboardContent: ClipboardPlugin["getClipboardContent"];
|
|
43
|
-
isPaintingFormat: ClipboardPlugin["isPaintingFormat"];
|
|
44
|
-
getPasteZones: ClipboardPlugin["getPasteZones"];
|
|
45
|
-
|
|
46
|
-
getCellWidth: FormattingPlugin["getCellWidth"];
|
|
47
|
-
getTextWidth: FormattingPlugin["getTextWidth"];
|
|
48
|
-
getCellHeight: FormattingPlugin["getCellHeight"];
|
|
49
|
-
|
|
50
|
-
expandZone: MergePlugin["expandZone"];
|
|
51
|
-
isMergeDestructive: MergePlugin["isMergeDestructive"];
|
|
52
|
-
isInMerge: MergePlugin["isInMerge"];
|
|
53
|
-
getMainCell: MergePlugin["getMainCell"];
|
|
54
|
-
doesIntersectMerge: MergePlugin["doesIntersectMerge"];
|
|
55
|
-
|
|
56
|
-
getActiveCell: SelectionPlugin["getActiveCell"];
|
|
57
|
-
getActiveCols: SelectionPlugin["getActiveCols"];
|
|
58
|
-
getActiveRows: SelectionPlugin["getActiveRows"];
|
|
59
|
-
getSelectedZones: SelectionPlugin["getSelectedZones"];
|
|
60
|
-
getSelectedZone: SelectionPlugin["getSelectedZone"];
|
|
61
|
-
getSelection: SelectionPlugin["getSelection"];
|
|
62
|
-
getPosition: SelectionPlugin["getPosition"];
|
|
63
|
-
getAggregate: SelectionPlugin["getAggregate"];
|
|
64
|
-
getSelectionMode: SelectionPlugin["getSelectionMode"];
|
|
65
|
-
isSelected: SelectionPlugin["isSelected"];
|
|
66
|
-
|
|
67
|
-
getHighlights: HighlightPlugin["getHighlights"];
|
|
68
|
-
|
|
69
|
-
getConditionalFormats: ConditionalFormatPlugin["getConditionalFormats"];
|
|
70
|
-
getConditionalStyle: ConditionalFormatPlugin["getConditionalStyle"];
|
|
71
|
-
getRulesSelection: ConditionalFormatPlugin["getRulesSelection"];
|
|
72
|
-
|
|
73
|
-
getColIndex: RendererPlugin["getColIndex"];
|
|
74
|
-
getRowIndex: RendererPlugin["getRowIndex"];
|
|
75
|
-
getRect: RendererPlugin["getRect"];
|
|
76
|
-
snapViewportToCell: RendererPlugin["snapViewportToCell"];
|
|
77
|
-
adjustViewportPosition: RendererPlugin["adjustViewportPosition"];
|
|
78
|
-
adjustViewportZone: RendererPlugin["adjustViewportZone"];
|
|
79
|
-
|
|
80
|
-
getCurrentStyle: FormattingPlugin["getCurrentStyle"];
|
|
81
|
-
getCellStyle: FormattingPlugin["getCellStyle"];
|
|
82
|
-
getCellBorder: FormattingPlugin["getCellBorder"];
|
|
83
|
-
|
|
84
|
-
canUndo: WHistory["canUndo"];
|
|
85
|
-
canRedo: WHistory["canRedo"];
|
|
86
|
-
|
|
87
|
-
evaluateFormula: EvaluationPlugin["evaluateFormula"];
|
|
88
|
-
isIdle: EvaluationPlugin["isIdle"];
|
|
89
|
-
|
|
90
|
-
getEditionMode: EditionPlugin["getEditionMode"];
|
|
91
|
-
getCurrentContent: EditionPlugin["getCurrentContent"];
|
|
92
|
-
getEditionSheet: EditionPlugin["getEditionSheet"];
|
|
93
|
-
|
|
94
|
-
getAutofillTooltip: AutofillPlugin["getAutofillTooltip"];
|
|
95
|
-
|
|
96
|
-
getSelectionInput: SelectionInputPlugin["getSelectionInput"];
|
|
97
|
-
getSelectionInputValue: SelectionInputPlugin["getSelectionInputValue"];
|
|
98
|
-
getFigures: FigurePlugin["getFigures"];
|
|
99
|
-
getSelectedFigureId: FigurePlugin["getSelectedFigureId"];
|
|
100
|
-
getFigure: FigurePlugin["getFigure"];
|
|
101
|
-
|
|
102
|
-
getChartRuntime: ChartPlugin["getChartRuntime"];
|
|
103
|
-
}
|
package/src/types/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* State
|
|
3
|
-
*
|
|
4
|
-
* This file defines the basic types involved in maintaining the running state
|
|
5
|
-
* of a o-spreadsheet.
|
|
6
|
-
*
|
|
7
|
-
* The most important exported values are:
|
|
8
|
-
* - interface GridState: the internal type of the state managed by the model
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export * from "./autofill";
|
|
12
|
-
export * from "./chart";
|
|
13
|
-
export * from "./commands";
|
|
14
|
-
export * from "./conditional_formatting";
|
|
15
|
-
export * from "./env";
|
|
16
|
-
export * from "./functions";
|
|
17
|
-
export * from "./getters";
|
|
18
|
-
export * from "./misc";
|
|
19
|
-
export * from "./rendering";
|
|
20
|
-
export * from "./workbook_data";
|
package/src/types/misc.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// -----------------------------------------------------------------------------
|
|
2
|
-
|
|
3
|
-
import { Dependencies } from ".";
|
|
4
|
-
|
|
5
|
-
// -----------------------------------------------------------------------------
|
|
6
|
-
export type UID = string;
|
|
7
|
-
export interface Zone {
|
|
8
|
-
left: number;
|
|
9
|
-
right: number;
|
|
10
|
-
top: number;
|
|
11
|
-
bottom: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type Align = "left" | "right" | "center" | undefined;
|
|
15
|
-
|
|
16
|
-
export interface Style {
|
|
17
|
-
bold?: boolean;
|
|
18
|
-
italic?: boolean;
|
|
19
|
-
strikethrough?: boolean;
|
|
20
|
-
align?: Align;
|
|
21
|
-
fillColor?: string;
|
|
22
|
-
textColor?: string;
|
|
23
|
-
fontSize?: number; // in pt, not in px!
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface Sheet {
|
|
27
|
-
id: string;
|
|
28
|
-
name: string;
|
|
29
|
-
cells: { [key: string]: Cell };
|
|
30
|
-
colNumber: number;
|
|
31
|
-
rowNumber: number;
|
|
32
|
-
merges: { [key: number]: Merge };
|
|
33
|
-
mergeCellMap: { [key: string]: number };
|
|
34
|
-
cols: Col[];
|
|
35
|
-
rows: Row[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// A border description is a pair [style, ]
|
|
39
|
-
export type BorderStyle = "thin" | "medium" | "thick" | "dashed" | "dotted" | "double";
|
|
40
|
-
export type BorderDescr = [BorderStyle, string];
|
|
41
|
-
|
|
42
|
-
export interface Border {
|
|
43
|
-
top?: BorderDescr;
|
|
44
|
-
left?: BorderDescr;
|
|
45
|
-
bottom?: BorderDescr;
|
|
46
|
-
right?: BorderDescr;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface NewCell {
|
|
50
|
-
content?: string;
|
|
51
|
-
style?: number;
|
|
52
|
-
border?: number;
|
|
53
|
-
format?: string;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export type ReferenceDenormalizer = (
|
|
57
|
-
position: number,
|
|
58
|
-
references: string[],
|
|
59
|
-
sheetId: UID,
|
|
60
|
-
functionName: string,
|
|
61
|
-
paramNumber: number
|
|
62
|
-
) => any | any[][];
|
|
63
|
-
|
|
64
|
-
export type EnsureRange = (position: number, references: string[], sheetId: UID) => any[][];
|
|
65
|
-
|
|
66
|
-
export type NumberParser = (str: string) => number;
|
|
67
|
-
|
|
68
|
-
export type _CompiledFormula = (
|
|
69
|
-
deps: Dependencies,
|
|
70
|
-
sheetId: UID,
|
|
71
|
-
refFn: ReferenceDenormalizer,
|
|
72
|
-
range: EnsureRange,
|
|
73
|
-
ctx: {}
|
|
74
|
-
) => any;
|
|
75
|
-
|
|
76
|
-
export interface CompiledFormula extends _CompiledFormula {
|
|
77
|
-
async: boolean;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export interface Cell extends NewCell {
|
|
81
|
-
col: number;
|
|
82
|
-
row: number;
|
|
83
|
-
xc: string;
|
|
84
|
-
error?: string;
|
|
85
|
-
pending?: boolean;
|
|
86
|
-
value: any;
|
|
87
|
-
formula?: {
|
|
88
|
-
text: string;
|
|
89
|
-
dependencies: Dependencies;
|
|
90
|
-
compiledFormula: CompiledFormula;
|
|
91
|
-
};
|
|
92
|
-
type: "formula" | "text" | "number" | "date";
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export interface Header {
|
|
96
|
-
start: number;
|
|
97
|
-
end: number;
|
|
98
|
-
name: string;
|
|
99
|
-
size: number;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface Row extends Header {
|
|
103
|
-
cells: { [col: number]: Cell };
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export type Col = Header;
|
|
107
|
-
|
|
108
|
-
export interface Merge extends Zone {
|
|
109
|
-
id: number;
|
|
110
|
-
topLeft: string;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
export interface Highlight {
|
|
114
|
-
zone: Zone;
|
|
115
|
-
sheet: string;
|
|
116
|
-
color: string | null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export type BorderCommand =
|
|
120
|
-
| "all"
|
|
121
|
-
| "hv"
|
|
122
|
-
| "h"
|
|
123
|
-
| "v"
|
|
124
|
-
| "external"
|
|
125
|
-
| "left"
|
|
126
|
-
| "top"
|
|
127
|
-
| "right"
|
|
128
|
-
| "bottom"
|
|
129
|
-
| "clear";
|
|
130
|
-
|
|
131
|
-
export interface Workbook {
|
|
132
|
-
// sheets
|
|
133
|
-
visibleSheets: string[]; // ids of visible sheets
|
|
134
|
-
sheets: { [id: string]: Sheet };
|
|
135
|
-
activeSheet: Sheet;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
export const enum DIRECTION {
|
|
139
|
-
UP,
|
|
140
|
-
DOWN,
|
|
141
|
-
LEFT,
|
|
142
|
-
RIGHT,
|
|
143
|
-
}
|
package/src/types/rendering.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Align, Border, Style, Zone } from "./misc";
|
|
2
|
-
|
|
3
|
-
export type Rect = [number, number, number, number];
|
|
4
|
-
|
|
5
|
-
export interface Box {
|
|
6
|
-
x: number;
|
|
7
|
-
y: number;
|
|
8
|
-
width: number;
|
|
9
|
-
height: number;
|
|
10
|
-
text: string;
|
|
11
|
-
textWidth: number;
|
|
12
|
-
style: Style | null;
|
|
13
|
-
border: Border | null;
|
|
14
|
-
align: Align;
|
|
15
|
-
clipRect: Rect | null;
|
|
16
|
-
error?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface Viewport extends Zone {
|
|
20
|
-
width: number;
|
|
21
|
-
height: number;
|
|
22
|
-
offsetX: number;
|
|
23
|
-
offsetY: number;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface GridRenderingContext {
|
|
27
|
-
ctx: CanvasRenderingContext2D;
|
|
28
|
-
viewport: Viewport;
|
|
29
|
-
dpr: number;
|
|
30
|
-
thinLineWidth: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const enum LAYERS {
|
|
34
|
-
Background,
|
|
35
|
-
Highlights,
|
|
36
|
-
Clipboard,
|
|
37
|
-
Chart,
|
|
38
|
-
Selection,
|
|
39
|
-
Autofill,
|
|
40
|
-
Headers, // Probably keep this at the end
|
|
41
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { ConditionalFormat } from "./conditional_formatting";
|
|
2
|
-
import { Border, Style } from "./misc";
|
|
3
|
-
|
|
4
|
-
export type Dependencies = (string | number)[];
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Represents a string in which all range references, strings and numbers are
|
|
8
|
-
* replaced by dependencies references.
|
|
9
|
-
*/
|
|
10
|
-
export type NormalizedFormulaString = string;
|
|
11
|
-
|
|
12
|
-
export type NormalizedFormula = {
|
|
13
|
-
// if the content is a formula (ex. =sum( a1:b3, 3) + a1, should be stored as
|
|
14
|
-
// {formula: "=sum( |ref1|, |ref2|) + |ref3|"), ["a1:b3","a1"]
|
|
15
|
-
// This normalization applies to range references, numbers and string values
|
|
16
|
-
text: NormalizedFormulaString;
|
|
17
|
-
dependencies: Dependencies;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export interface CellData {
|
|
21
|
-
content?: string;
|
|
22
|
-
formula?: NormalizedFormula;
|
|
23
|
-
style?: number;
|
|
24
|
-
border?: number;
|
|
25
|
-
format?: string;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface HeaderData {
|
|
29
|
-
size?: number;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface Figure<T> {
|
|
33
|
-
id: string;
|
|
34
|
-
x: number;
|
|
35
|
-
y: number;
|
|
36
|
-
width: number;
|
|
37
|
-
height: number;
|
|
38
|
-
tag: string;
|
|
39
|
-
data: T;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export interface SheetData {
|
|
43
|
-
id: string;
|
|
44
|
-
name: string;
|
|
45
|
-
colNumber: number;
|
|
46
|
-
rowNumber: number;
|
|
47
|
-
cells: { [key: string]: CellData };
|
|
48
|
-
merges: string[];
|
|
49
|
-
figures: Figure<any>[];
|
|
50
|
-
cols: { [key: number]: HeaderData };
|
|
51
|
-
rows: { [key: number]: HeaderData };
|
|
52
|
-
conditionalFormats: ConditionalFormat[];
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface WorkbookData {
|
|
56
|
-
version: number;
|
|
57
|
-
sheets: SheetData[];
|
|
58
|
-
activeSheet: string;
|
|
59
|
-
styles: { [key: number]: Style };
|
|
60
|
-
borders: { [key: number]: Border };
|
|
61
|
-
entities: { [key: string]: { [key: string]: any } };
|
|
62
|
-
}
|
package/tests/__mocks__/uuid.ts
DELETED
package/tests/canvas.mock.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
let size = 1000;
|
|
2
|
-
export function setMockSize(s) {
|
|
3
|
-
size = s;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export class MockCanvasRenderingContext2D {
|
|
7
|
-
translate() {}
|
|
8
|
-
scale() {}
|
|
9
|
-
clearRect() {}
|
|
10
|
-
beginPath() {}
|
|
11
|
-
moveTo() {}
|
|
12
|
-
lineTo() {}
|
|
13
|
-
stroke() {}
|
|
14
|
-
fillRect() {}
|
|
15
|
-
strokeRect() {}
|
|
16
|
-
fillText() {}
|
|
17
|
-
fill() {}
|
|
18
|
-
save() {}
|
|
19
|
-
rect() {}
|
|
20
|
-
clip() {}
|
|
21
|
-
restore() {}
|
|
22
|
-
setLineDash() {}
|
|
23
|
-
measureText(text: string) {
|
|
24
|
-
return { width: size };
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const patch = {
|
|
29
|
-
getContext: function () {
|
|
30
|
-
return new MockCanvasRenderingContext2D() as any as CanvasRenderingContext2D;
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
/* js-ignore */
|
|
34
|
-
Object.assign(HTMLCanvasElement.prototype, patch);
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
export class ContentEditableHelper {
|
|
2
|
-
currentState = {
|
|
3
|
-
cursorStart: 0,
|
|
4
|
-
cursorEnd: 0,
|
|
5
|
-
};
|
|
6
|
-
colors = {};
|
|
7
|
-
el: HTMLElement | null = null;
|
|
8
|
-
manualRange: boolean = false;
|
|
9
|
-
|
|
10
|
-
constructor() {}
|
|
11
|
-
|
|
12
|
-
updateEl(el: HTMLElement) {
|
|
13
|
-
this.el = el;
|
|
14
|
-
this.el.focus();
|
|
15
|
-
this.currentState = {
|
|
16
|
-
cursorStart: 0,
|
|
17
|
-
cursorEnd: 0,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
this.colors = {};
|
|
21
|
-
}
|
|
22
|
-
selectRange(start, end) {
|
|
23
|
-
this.manualRange = true;
|
|
24
|
-
this.currentState.cursorStart = start;
|
|
25
|
-
this.currentState.cursorEnd = end;
|
|
26
|
-
}
|
|
27
|
-
selectLast() {
|
|
28
|
-
const text = this.el!.textContent!;
|
|
29
|
-
this.currentState.cursorStart = text.length - 1;
|
|
30
|
-
this.currentState.cursorEnd = text.length - 1;
|
|
31
|
-
}
|
|
32
|
-
insertText(value, color) {
|
|
33
|
-
const text = this.el!.textContent!;
|
|
34
|
-
|
|
35
|
-
if (this.manualRange) {
|
|
36
|
-
let start = text.substring(0, this.currentState.cursorStart);
|
|
37
|
-
let end = text.substring(this.currentState.cursorEnd);
|
|
38
|
-
let newValue = start + value + end;
|
|
39
|
-
while (this.el!.firstChild) {
|
|
40
|
-
this.el!.removeChild(this.el!.firstChild);
|
|
41
|
-
}
|
|
42
|
-
this.el!.append(newValue);
|
|
43
|
-
} else {
|
|
44
|
-
this.el!.append(value);
|
|
45
|
-
}
|
|
46
|
-
if (this.currentState.cursorStart === this.currentState.cursorEnd) {
|
|
47
|
-
const position = this.currentState.cursorStart + value.length;
|
|
48
|
-
this.currentState.cursorEnd = position;
|
|
49
|
-
this.currentState.cursorStart = position;
|
|
50
|
-
} else {
|
|
51
|
-
this.currentState.cursorEnd = this.currentState.cursorStart + value.length;
|
|
52
|
-
this.manualRange = false;
|
|
53
|
-
}
|
|
54
|
-
this.colors[value] = color;
|
|
55
|
-
|
|
56
|
-
this.el!.dispatchEvent(new Event("input"));
|
|
57
|
-
}
|
|
58
|
-
removeSelection() {
|
|
59
|
-
this.currentState.cursorStart = 0;
|
|
60
|
-
this.currentState.cursorEnd = 0;
|
|
61
|
-
}
|
|
62
|
-
removeAll() {
|
|
63
|
-
this.currentState.cursorStart = 0;
|
|
64
|
-
this.currentState.cursorEnd = 0;
|
|
65
|
-
while (this.el!.firstChild) {
|
|
66
|
-
this.el!.removeChild(this.el!.firstChild);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
getCurrentSelection() {
|
|
70
|
-
if (this.manualRange) {
|
|
71
|
-
return { start: this.currentState.cursorStart, end: this.currentState.cursorEnd };
|
|
72
|
-
}
|
|
73
|
-
const v = this.el!.textContent || "";
|
|
74
|
-
return {
|
|
75
|
-
start: v.length,
|
|
76
|
-
end: v.length,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ScrollDirection } from "../../../src/components/scrollbar";
|
|
2
|
-
|
|
3
|
-
export class ScrollBar {
|
|
4
|
-
private scrollValue: number;
|
|
5
|
-
el: HTMLElement;
|
|
6
|
-
constructor(el: HTMLElement | null, direction: ScrollDirection) {
|
|
7
|
-
this.el = el!;
|
|
8
|
-
this.scrollValue = 0;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
get scroll(): number {
|
|
12
|
-
return this.scrollValue;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
set scroll(value: number) {
|
|
16
|
-
this.scrollValue = value;
|
|
17
|
-
}
|
|
18
|
-
}
|