@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,75 +0,0 @@
|
|
|
1
|
-
import { uuidv4 } from "../../helpers/index";
|
|
2
|
-
import { _lt } from "../../translation";
|
|
3
|
-
import { SpreadsheetEnv } from "../../types";
|
|
4
|
-
import { MenuItemRegistry } from "../menu_items_registry";
|
|
5
|
-
|
|
6
|
-
export const sheetMenuRegistry = new MenuItemRegistry();
|
|
7
|
-
|
|
8
|
-
function getDuplicateSheetName(env: SpreadsheetEnv, sheet: string) {
|
|
9
|
-
let i = 1;
|
|
10
|
-
const names = env.getters.getSheets().map((s) => s.name);
|
|
11
|
-
const baseName = _lt("Copy of %s", sheet);
|
|
12
|
-
let name = baseName.toString();
|
|
13
|
-
while (names.includes(name)) {
|
|
14
|
-
name = `${baseName} (${i})`;
|
|
15
|
-
i++;
|
|
16
|
-
}
|
|
17
|
-
return name;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
sheetMenuRegistry
|
|
21
|
-
.add("delete", {
|
|
22
|
-
name: _lt("Delete"),
|
|
23
|
-
sequence: 10,
|
|
24
|
-
isVisible: (env) => {
|
|
25
|
-
return env.getters.getSheets().length > 1;
|
|
26
|
-
},
|
|
27
|
-
action: (env) =>
|
|
28
|
-
env.dispatch("DELETE_SHEET_CONFIRMATION", { sheet: env.getters.getActiveSheet() }),
|
|
29
|
-
})
|
|
30
|
-
.add("duplicate", {
|
|
31
|
-
name: _lt("Duplicate"),
|
|
32
|
-
sequence: 20,
|
|
33
|
-
action: (env) => {
|
|
34
|
-
const sheet = env.getters.getActiveSheet();
|
|
35
|
-
const name = getDuplicateSheetName(
|
|
36
|
-
env,
|
|
37
|
-
env.getters.getSheets().find((s) => s.id === sheet)!.name
|
|
38
|
-
);
|
|
39
|
-
env.dispatch("DUPLICATE_SHEET", {
|
|
40
|
-
sheet,
|
|
41
|
-
id: uuidv4(),
|
|
42
|
-
name,
|
|
43
|
-
});
|
|
44
|
-
},
|
|
45
|
-
})
|
|
46
|
-
.add("rename", {
|
|
47
|
-
name: _lt("Rename"),
|
|
48
|
-
sequence: 30,
|
|
49
|
-
action: (env) =>
|
|
50
|
-
env.dispatch("RENAME_SHEET", {
|
|
51
|
-
interactive: true,
|
|
52
|
-
sheet: env.getters.getActiveSheet(),
|
|
53
|
-
}),
|
|
54
|
-
})
|
|
55
|
-
.add("move_right", {
|
|
56
|
-
name: _lt("Move right"),
|
|
57
|
-
sequence: 40,
|
|
58
|
-
isVisible: (env) => {
|
|
59
|
-
const sheet = env.getters.getActiveSheet();
|
|
60
|
-
const sheets = env.getters.getSheets();
|
|
61
|
-
return sheets.findIndex((s) => s.id === sheet) !== sheets.length - 1;
|
|
62
|
-
},
|
|
63
|
-
action: (env) =>
|
|
64
|
-
env.dispatch("MOVE_SHEET", { sheet: env.getters.getActiveSheet(), direction: "right" }),
|
|
65
|
-
})
|
|
66
|
-
.add("move_left", {
|
|
67
|
-
name: _lt("Move left"),
|
|
68
|
-
sequence: 50,
|
|
69
|
-
isVisible: (env) => {
|
|
70
|
-
const sheet = env.getters.getActiveSheet();
|
|
71
|
-
return env.getters.getSheets().findIndex((s) => s.id === sheet) !== 0;
|
|
72
|
-
},
|
|
73
|
-
action: (env) =>
|
|
74
|
-
env.dispatch("MOVE_SHEET", { sheet: env.getters.getActiveSheet(), direction: "left" }),
|
|
75
|
-
});
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { fontSizes } from "../../fonts";
|
|
2
|
-
import { _lt } from "../../translation";
|
|
3
|
-
import { SpreadsheetEnv } from "../../types/env";
|
|
4
|
-
import { MenuItemRegistry } from "../menu_items_registry";
|
|
5
|
-
import * as ACTIONS from "./menu_items_actions";
|
|
6
|
-
|
|
7
|
-
export const topbarMenuRegistry = new MenuItemRegistry();
|
|
8
|
-
|
|
9
|
-
topbarMenuRegistry
|
|
10
|
-
.add("file", { name: _lt("File"), sequence: 10 })
|
|
11
|
-
.add("edit", { name: _lt("Edit"), sequence: 20 })
|
|
12
|
-
.add("view", { name: _lt("View"), sequence: 30 })
|
|
13
|
-
.add("insert", { name: _lt("Insert"), sequence: 40 })
|
|
14
|
-
.add("format", { name: _lt("Format"), sequence: 50 })
|
|
15
|
-
.add("data", { name: _lt("Data"), sequence: 60 })
|
|
16
|
-
.addChild("save", ["file"], {
|
|
17
|
-
name: _lt("Save"),
|
|
18
|
-
sequence: 10,
|
|
19
|
-
action: () => console.log("Not implemented"),
|
|
20
|
-
})
|
|
21
|
-
.addChild("undo", ["edit"], {
|
|
22
|
-
name: _lt("Undo"),
|
|
23
|
-
sequence: 10,
|
|
24
|
-
action: ACTIONS.UNDO_ACTION,
|
|
25
|
-
})
|
|
26
|
-
.addChild("redo", ["edit"], {
|
|
27
|
-
name: _lt("Redo"),
|
|
28
|
-
sequence: 20,
|
|
29
|
-
action: ACTIONS.REDO_ACTION,
|
|
30
|
-
separator: true,
|
|
31
|
-
})
|
|
32
|
-
.addChild("copy", ["edit"], {
|
|
33
|
-
name: _lt("Copy"),
|
|
34
|
-
sequence: 30,
|
|
35
|
-
action: ACTIONS.COPY_ACTION,
|
|
36
|
-
})
|
|
37
|
-
.addChild("cut", ["edit"], {
|
|
38
|
-
name: _lt("Cut"),
|
|
39
|
-
sequence: 40,
|
|
40
|
-
action: ACTIONS.CUT_ACTION,
|
|
41
|
-
})
|
|
42
|
-
.addChild("paste", ["edit"], {
|
|
43
|
-
name: _lt("Paste"),
|
|
44
|
-
sequence: 50,
|
|
45
|
-
action: ACTIONS.PASTE_ACTION,
|
|
46
|
-
})
|
|
47
|
-
.addChild("paste_special", ["edit"], {
|
|
48
|
-
name: _lt("Paste special"),
|
|
49
|
-
sequence: 60,
|
|
50
|
-
separator: true,
|
|
51
|
-
})
|
|
52
|
-
.addChild("paste_special_value", ["edit", "paste_special"], {
|
|
53
|
-
name: _lt("Paste value only"),
|
|
54
|
-
sequence: 10,
|
|
55
|
-
action: ACTIONS.PASTE_VALUE_ACTION,
|
|
56
|
-
})
|
|
57
|
-
.addChild("paste_special_format", ["edit", "paste_special"], {
|
|
58
|
-
name: _lt("Paste format only"),
|
|
59
|
-
sequence: 20,
|
|
60
|
-
action: ACTIONS.PASTE_FORMAT_ACTION,
|
|
61
|
-
})
|
|
62
|
-
.addChild("edit_delete_cell_values", ["edit"], {
|
|
63
|
-
name: _lt("Delete values"),
|
|
64
|
-
sequence: 70,
|
|
65
|
-
action: ACTIONS.DELETE_CONTENT_ACTION,
|
|
66
|
-
})
|
|
67
|
-
.addChild("edit_delete_row", ["edit"], {
|
|
68
|
-
name: ACTIONS.REMOVE_ROWS_NAME,
|
|
69
|
-
sequence: 80,
|
|
70
|
-
action: ACTIONS.REMOVE_ROWS_ACTION,
|
|
71
|
-
})
|
|
72
|
-
.addChild("edit_delete_column", ["edit"], {
|
|
73
|
-
name: ACTIONS.REMOVE_COLUMNS_NAME,
|
|
74
|
-
sequence: 90,
|
|
75
|
-
action: ACTIONS.REMOVE_COLUMNS_ACTION,
|
|
76
|
-
})
|
|
77
|
-
.addChild("insert_row_before", ["insert"], {
|
|
78
|
-
name: ACTIONS.MENU_INSERT_ROWS_BEFORE_NAME,
|
|
79
|
-
sequence: 10,
|
|
80
|
-
action: ACTIONS.INSERT_ROWS_BEFORE_ACTION,
|
|
81
|
-
isVisible: (env: SpreadsheetEnv) => env.getters.getActiveCols().size === 0,
|
|
82
|
-
})
|
|
83
|
-
.addChild("insert_row_after", ["insert"], {
|
|
84
|
-
name: ACTIONS.MENU_INSERT_ROWS_AFTER_NAME,
|
|
85
|
-
sequence: 20,
|
|
86
|
-
action: ACTIONS.INSERT_ROWS_AFTER_ACTION,
|
|
87
|
-
isVisible: (env: SpreadsheetEnv) => env.getters.getActiveCols().size === 0,
|
|
88
|
-
separator: true,
|
|
89
|
-
})
|
|
90
|
-
.addChild("insert_column_before", ["insert"], {
|
|
91
|
-
name: ACTIONS.MENU_INSERT_COLUMNS_BEFORE_NAME,
|
|
92
|
-
sequence: 30,
|
|
93
|
-
action: ACTIONS.INSERT_COLUMNS_BEFORE_ACTION,
|
|
94
|
-
isVisible: (env: SpreadsheetEnv) => env.getters.getActiveRows().size === 0,
|
|
95
|
-
})
|
|
96
|
-
.addChild("insert_column_after", ["insert"], {
|
|
97
|
-
name: ACTIONS.MENU_INSERT_COLUMNS_AFTER_NAME,
|
|
98
|
-
sequence: 40,
|
|
99
|
-
action: ACTIONS.INSERT_COLUMNS_AFTER_ACTION,
|
|
100
|
-
isVisible: (env: SpreadsheetEnv) => env.getters.getActiveRows().size === 0,
|
|
101
|
-
separator: true,
|
|
102
|
-
})
|
|
103
|
-
.addChild("insert_chart", ["insert"], {
|
|
104
|
-
name: _lt("Chart"),
|
|
105
|
-
sequence: 50,
|
|
106
|
-
action: ACTIONS.CREATE_CHART,
|
|
107
|
-
separator: true,
|
|
108
|
-
})
|
|
109
|
-
.addChild("insert_sheet", ["insert"], {
|
|
110
|
-
name: _lt("New sheet"),
|
|
111
|
-
sequence: 60,
|
|
112
|
-
action: ACTIONS.CREATE_SHEET_ACTION,
|
|
113
|
-
separator: true,
|
|
114
|
-
})
|
|
115
|
-
.addChild("view_formulas", ["view"], {
|
|
116
|
-
name: (env: SpreadsheetEnv) =>
|
|
117
|
-
env.getters.shouldShowFormulas() ? _lt("Hide formulas") : _lt("Show formulas"),
|
|
118
|
-
action: ACTIONS.SET_FORMULA_VISIBILITY_ACTION,
|
|
119
|
-
sequence: 10,
|
|
120
|
-
})
|
|
121
|
-
.addChild("format_number", ["format"], {
|
|
122
|
-
name: _lt("Numbers"),
|
|
123
|
-
sequence: 10,
|
|
124
|
-
separator: true,
|
|
125
|
-
})
|
|
126
|
-
.addChild("format_number_auto", ["format", "format_number"], {
|
|
127
|
-
name: _lt("Automatic"),
|
|
128
|
-
sequence: 10,
|
|
129
|
-
separator: true,
|
|
130
|
-
action: ACTIONS.FORMAT_AUTO_ACTION,
|
|
131
|
-
})
|
|
132
|
-
.addChild("format_number_number", ["format", "format_number"], {
|
|
133
|
-
name: _lt("Number (1,000.12)"),
|
|
134
|
-
sequence: 20,
|
|
135
|
-
action: ACTIONS.FORMAT_NUMBER_ACTION,
|
|
136
|
-
})
|
|
137
|
-
.addChild("format_number_percent", ["format", "format_number"], {
|
|
138
|
-
name: _lt("Percent (10.12%)"),
|
|
139
|
-
sequence: 30,
|
|
140
|
-
separator: true,
|
|
141
|
-
action: ACTIONS.FORMAT_PERCENT_ACTION,
|
|
142
|
-
})
|
|
143
|
-
.addChild("format_number_date", ["format", "format_number"], {
|
|
144
|
-
name: _lt("Date (9/26/2008)"),
|
|
145
|
-
sequence: 40,
|
|
146
|
-
action: ACTIONS.FORMAT_DATE_ACTION,
|
|
147
|
-
})
|
|
148
|
-
.addChild("format_number_time", ["format", "format_number"], {
|
|
149
|
-
name: _lt("Time (10:43:00 PM)"),
|
|
150
|
-
sequence: 50,
|
|
151
|
-
action: ACTIONS.FORMAT_TIME_ACTION,
|
|
152
|
-
})
|
|
153
|
-
.addChild("format_number_date_time", ["format", "format_number"], {
|
|
154
|
-
name: _lt("Date time (9/26/2008 22:43:00)"),
|
|
155
|
-
sequence: 60,
|
|
156
|
-
action: ACTIONS.FORMAT_DATE_TIME_ACTION,
|
|
157
|
-
})
|
|
158
|
-
.addChild("format_number_duration", ["format", "format_number"], {
|
|
159
|
-
name: _lt("Duration (27:51:38)"),
|
|
160
|
-
sequence: 70,
|
|
161
|
-
separator: true,
|
|
162
|
-
action: ACTIONS.FORMAT_DURATION_ACTION,
|
|
163
|
-
})
|
|
164
|
-
.addChild("format_bold", ["format"], {
|
|
165
|
-
name: _lt("Bold"),
|
|
166
|
-
sequence: 20,
|
|
167
|
-
action: ACTIONS.FORMAT_BOLD_ACTION,
|
|
168
|
-
})
|
|
169
|
-
.addChild("format_italic", ["format"], {
|
|
170
|
-
name: _lt("Italic"),
|
|
171
|
-
sequence: 30,
|
|
172
|
-
action: ACTIONS.FORMAT_ITALIC_ACTION,
|
|
173
|
-
})
|
|
174
|
-
// .addChild("format_underline", ["format"], {
|
|
175
|
-
// Underline is not yet implemented
|
|
176
|
-
// name: _lt("Underline"),
|
|
177
|
-
// sequence: 40,
|
|
178
|
-
// })
|
|
179
|
-
.addChild("format_strikethrough", ["format"], {
|
|
180
|
-
name: _lt("Strikethrough"),
|
|
181
|
-
sequence: 50,
|
|
182
|
-
action: ACTIONS.FORMAT_STRIKETHROUGH_ACTION,
|
|
183
|
-
separator: true,
|
|
184
|
-
})
|
|
185
|
-
.addChild("format_font_size", ["format"], {
|
|
186
|
-
name: _lt("Font size"),
|
|
187
|
-
sequence: 60,
|
|
188
|
-
separator: true,
|
|
189
|
-
})
|
|
190
|
-
.addChild("format_cf", ["format"], {
|
|
191
|
-
name: _lt("Conditional formatting"),
|
|
192
|
-
sequence: 70,
|
|
193
|
-
action: ACTIONS.OPEN_CF_SIDEPANEL_ACTION,
|
|
194
|
-
separator: true,
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Font-sizes
|
|
198
|
-
for (let fs of fontSizes) {
|
|
199
|
-
topbarMenuRegistry.addChild(`format_font_size_${fs.pt}`, ["format", "format_font_size"], {
|
|
200
|
-
name: fs.pt.toString(),
|
|
201
|
-
sequence: fs.pt,
|
|
202
|
-
action: (env: SpreadsheetEnv) => ACTIONS.setStyle(env, { fontSize: fs.pt }),
|
|
203
|
-
});
|
|
204
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ChartPanel } from "../components/side_panel/chart_panel";
|
|
2
|
-
import { ConditionalFormattingPanel } from "../components/side_panel/conditional_formatting";
|
|
3
|
-
import { Registry } from "../registry";
|
|
4
|
-
import { _lt } from "../translation";
|
|
5
|
-
import { SpreadsheetEnv } from "../types";
|
|
6
|
-
|
|
7
|
-
//------------------------------------------------------------------------------
|
|
8
|
-
// Side Panel Registry
|
|
9
|
-
//------------------------------------------------------------------------------
|
|
10
|
-
export interface SidePanelContent {
|
|
11
|
-
title: string | ((env: SpreadsheetEnv) => string);
|
|
12
|
-
Body: any;
|
|
13
|
-
Footer?: any;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const sidePanelRegistry = new Registry<SidePanelContent>();
|
|
17
|
-
|
|
18
|
-
sidePanelRegistry.add("ConditionalFormatting", {
|
|
19
|
-
title: _lt("Conditional formatting"),
|
|
20
|
-
Body: ConditionalFormattingPanel,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
sidePanelRegistry.add("ChartPanel", {
|
|
24
|
-
title: _lt("Chart"),
|
|
25
|
-
Body: ChartPanel,
|
|
26
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Registry } from "../registry";
|
|
2
|
-
import { SpreadsheetEnv } from "../types/env";
|
|
3
|
-
|
|
4
|
-
//------------------------------------------------------------------------------
|
|
5
|
-
// Topbar Component Registry
|
|
6
|
-
//------------------------------------------------------------------------------
|
|
7
|
-
interface TopbarComponent {
|
|
8
|
-
component: any;
|
|
9
|
-
isVisible?: (env: SpreadsheetEnv) => boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const topbarComponentRegistry = new Registry<TopbarComponent>();
|
package/src/registry.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registry
|
|
3
|
-
*
|
|
4
|
-
* The Registry class is basically just a mapping from a string key to an object.
|
|
5
|
-
* It is really not much more than an object. It is however useful for the
|
|
6
|
-
* following reasons:
|
|
7
|
-
*
|
|
8
|
-
* 1. it let us react and execute code when someone add something to the registry
|
|
9
|
-
* (for example, the FunctionRegistry subclass this for this purpose)
|
|
10
|
-
* 2. it throws an error when the get operation fails
|
|
11
|
-
* 3. it provides a chained API to add items to the registry.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export class Registry<T> {
|
|
15
|
-
content: { [key: string]: T } = {};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Add an item to the registry
|
|
19
|
-
*
|
|
20
|
-
* Note that this also returns the registry, so another add method call can
|
|
21
|
-
* be chained
|
|
22
|
-
*/
|
|
23
|
-
add(key: string, value: T): Registry<T> {
|
|
24
|
-
this.content[key] = value;
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get an item from the registry
|
|
30
|
-
*/
|
|
31
|
-
get(key: string): T {
|
|
32
|
-
if (!(key in this.content)) {
|
|
33
|
-
throw new Error(`Cannot find ${key} in this registry!`);
|
|
34
|
-
}
|
|
35
|
-
return this.content[key];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Get a list of all elements in the registry
|
|
40
|
-
*/
|
|
41
|
-
getAll(): T[] {
|
|
42
|
-
return Object.values(this.content);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Remove an item from the registry
|
|
47
|
-
*/
|
|
48
|
-
remove(key: string) {
|
|
49
|
-
delete this.content[key];
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/translation.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* usage: every string should be translated either with _lt if they are registered with a registry at
|
|
3
|
-
* the load of the app or with Spreadsheet._t in the templates. Spreadsheet._t is exposed in the
|
|
4
|
-
* sub-env of Spreadsheet components as _t
|
|
5
|
-
* */
|
|
6
|
-
|
|
7
|
-
export type TranslationFunction = (
|
|
8
|
-
string: string,
|
|
9
|
-
...values: string[] | [{ [key: string]: string }]
|
|
10
|
-
) => string;
|
|
11
|
-
|
|
12
|
-
// define a mock translation function, when o-spreadsheet runs in standalone it doesn't translate any string
|
|
13
|
-
let _t: TranslationFunction = (s) => s;
|
|
14
|
-
|
|
15
|
-
function sprintf(s: string, ...values: string[] | [{ [key: string]: string }]): string {
|
|
16
|
-
if (values.length === 1 && typeof values[0] === "object") {
|
|
17
|
-
const valuesDict = values[0] as { [key: string]: string };
|
|
18
|
-
s = s.replace(/%\(?([^\)]+)\)s/g, (match, value) => valuesDict[value]);
|
|
19
|
-
} else if (values.length > 0) {
|
|
20
|
-
s = s.replace(/\%s/g, () => values.shift() as string);
|
|
21
|
-
}
|
|
22
|
-
return s;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/***
|
|
26
|
-
* Allow to inject a translation function from outside o-spreadsheet.
|
|
27
|
-
* @param tfn the function that will do the translation
|
|
28
|
-
*/
|
|
29
|
-
export function setTranslationMethod(tfn: TranslationFunction) {
|
|
30
|
-
_t = tfn;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export const _lt: TranslationFunction = function (
|
|
34
|
-
s,
|
|
35
|
-
...values: string[] | [{ [key: string]: string }]
|
|
36
|
-
) {
|
|
37
|
-
return {
|
|
38
|
-
toString: function () {
|
|
39
|
-
return sprintf(_t(s), ...values);
|
|
40
|
-
},
|
|
41
|
-
// casts the object to unknown then to string to trick typescript into thinking that the object it receives is actually a string
|
|
42
|
-
// this way it will be typed correctly (behaves like a string) but tests like typeof _lt("whatever") will be object and not string !
|
|
43
|
-
} as unknown as string;
|
|
44
|
-
};
|
package/src/types/autofill.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An AutofillModifier describe the possible operations to apply to the
|
|
3
|
-
* content of a cell when we autofill this cell.
|
|
4
|
-
*
|
|
5
|
-
* It could be:
|
|
6
|
-
* - Increment: increment the content by a given step
|
|
7
|
-
* - Copy: simply copy the content
|
|
8
|
-
* - Formula: update the formula, with the same behaviour than paste
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import { CellData } from "./workbook_data";
|
|
12
|
-
|
|
13
|
-
export interface IncrementModifier {
|
|
14
|
-
type: "INCREMENT_MODIFIER";
|
|
15
|
-
increment: number;
|
|
16
|
-
current: number;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface CopyModifier {
|
|
20
|
-
type: "COPY_MODIFIER";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface FormulaModifier {
|
|
24
|
-
type: "FORMULA_MODIFIER";
|
|
25
|
-
increment: number;
|
|
26
|
-
current: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export type AutofillModifier = IncrementModifier | CopyModifier | FormulaModifier;
|
|
30
|
-
|
|
31
|
-
export interface Tooltip {
|
|
32
|
-
props: any;
|
|
33
|
-
component?: any;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export interface AutofillResult {
|
|
37
|
-
cellData: AutofillCellData;
|
|
38
|
-
tooltip?: Tooltip;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export interface AutofillCellData extends CellData {
|
|
42
|
-
col: number;
|
|
43
|
-
row: number;
|
|
44
|
-
}
|
|
45
|
-
export interface GeneratorCell {
|
|
46
|
-
data: AutofillCellData;
|
|
47
|
-
rule?: AutofillModifier;
|
|
48
|
-
}
|
package/src/types/chart.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Figure } from "./workbook_data";
|
|
2
|
-
|
|
3
|
-
export interface DataSet {
|
|
4
|
-
labelCell?: string;
|
|
5
|
-
dataRange: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export type ChartTypes = "line" | "bar" | "pie";
|
|
9
|
-
|
|
10
|
-
export interface ChartDefinition {
|
|
11
|
-
title?: string;
|
|
12
|
-
type: ChartTypes;
|
|
13
|
-
dataSets: DataSet[];
|
|
14
|
-
labelRange: string;
|
|
15
|
-
sheetId: string;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface CreateChartDefinition {
|
|
19
|
-
type: ChartTypes;
|
|
20
|
-
title: string;
|
|
21
|
-
labelRange: string;
|
|
22
|
-
dataSets: string[];
|
|
23
|
-
seriesHasTitle: boolean;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type ChartFigure = Figure<ChartDefinition>;
|