@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.
Files changed (204) hide show
  1. package/dist/o_spreadsheet.cjs.js +17836 -0
  2. package/dist/o_spreadsheet.d.ts +4102 -0
  3. package/dist/o_spreadsheet.esm.js +17801 -0
  4. package/dist/o_spreadsheet.iife.js +17838 -0
  5. package/dist/o_spreadsheet.iife.min.js +1440 -0
  6. package/package.json +27 -7
  7. package/readme.md +10 -0
  8. package/.eslintrc.json +0 -20
  9. package/.husky/post-checkout +0 -9
  10. package/.husky/pre-commit +0 -39
  11. package/.prettierignore +0 -1
  12. package/astToFormula.patch +0 -0
  13. package/demo/data.js +0 -255
  14. package/demo/index.html +0 -9
  15. package/demo/libs/Chart.bundle.js +0 -20755
  16. package/demo/main.js +0 -101
  17. package/doc/readme.md +0 -46
  18. package/rollup.config.js +0 -23
  19. package/src/base_plugin.ts +0 -102
  20. package/src/components/autofill.ts +0 -146
  21. package/src/components/bottom_bar.ts +0 -199
  22. package/src/components/color_picker.ts +0 -150
  23. package/src/components/composer/autocomplete_dropdown.ts +0 -135
  24. package/src/components/composer/composer.ts +0 -487
  25. package/src/components/composer/content_editable_helper.ts +0 -146
  26. package/src/components/figures/chart.ts +0 -70
  27. package/src/components/figures/container.ts +0 -268
  28. package/src/components/figures/text_figure.ts +0 -36
  29. package/src/components/grid.ts +0 -635
  30. package/src/components/helpers/dom_helpers.ts +0 -7
  31. package/src/components/helpers/drag_and_drop.ts +0 -17
  32. package/src/components/icons.ts +0 -36
  33. package/src/components/index.ts +0 -1
  34. package/src/components/menu.ts +0 -288
  35. package/src/components/overlay.ts +0 -457
  36. package/src/components/scrollbar.ts +0 -22
  37. package/src/components/selection_input.ts +0 -168
  38. package/src/components/side_panel/cell_is_rule_editor.ts +0 -169
  39. package/src/components/side_panel/chart_panel.ts +0 -104
  40. package/src/components/side_panel/color_scale_rule_editor.ts +0 -145
  41. package/src/components/side_panel/conditional_formatting.ts +0 -396
  42. package/src/components/side_panel/side_panel.ts +0 -127
  43. package/src/components/side_panel/translations_terms.ts +0 -45
  44. package/src/components/spreadsheet.ts +0 -198
  45. package/src/components/top_bar.ts +0 -535
  46. package/src/constants.ts +0 -26
  47. package/src/data.ts +0 -149
  48. package/src/fonts.ts +0 -41
  49. package/src/formulas/compiler.ts +0 -258
  50. package/src/formulas/composer_tokenizer.ts +0 -70
  51. package/src/formulas/index.ts +0 -15
  52. package/src/formulas/normalize.ts +0 -52
  53. package/src/formulas/parser.ts +0 -280
  54. package/src/formulas/range_tokenizer.ts +0 -97
  55. package/src/formulas/tokenizer.ts +0 -242
  56. package/src/functions/arguments.ts +0 -114
  57. package/src/functions/dates.ts +0 -302
  58. package/src/functions/helpers.ts +0 -592
  59. package/src/functions/index.ts +0 -52
  60. package/src/functions/module_database.ts +0 -282
  61. package/src/functions/module_date.ts +0 -743
  62. package/src/functions/module_info.ts +0 -69
  63. package/src/functions/module_logical.ts +0 -208
  64. package/src/functions/module_lookup.ts +0 -185
  65. package/src/functions/module_math.ts +0 -1252
  66. package/src/functions/module_operators.ts +0 -291
  67. package/src/functions/module_statistical.ts +0 -882
  68. package/src/functions/module_text.ts +0 -370
  69. package/src/helpers/color.ts +0 -30
  70. package/src/helpers/coordinates.ts +0 -71
  71. package/src/helpers/grid_manipulation.ts +0 -68
  72. package/src/helpers/index.ts +0 -7
  73. package/src/helpers/misc.ts +0 -76
  74. package/src/helpers/numbers.ts +0 -117
  75. package/src/helpers/uuid.ts +0 -19
  76. package/src/helpers/zones.ts +0 -263
  77. package/src/history.ts +0 -186
  78. package/src/index.ts +0 -84
  79. package/src/model.ts +0 -261
  80. package/src/plugins/autofill.ts +0 -412
  81. package/src/plugins/chart.ts +0 -404
  82. package/src/plugins/clipboard.ts +0 -461
  83. package/src/plugins/conditional_format.ts +0 -445
  84. package/src/plugins/core.ts +0 -1502
  85. package/src/plugins/edition.ts +0 -157
  86. package/src/plugins/evaluation.ts +0 -428
  87. package/src/plugins/figures.ts +0 -123
  88. package/src/plugins/formatting.ts +0 -630
  89. package/src/plugins/highlight.ts +0 -187
  90. package/src/plugins/index.ts +0 -32
  91. package/src/plugins/merge.ts +0 -524
  92. package/src/plugins/renderer.ts +0 -571
  93. package/src/plugins/selection.ts +0 -562
  94. package/src/plugins/selection_inputs.ts +0 -326
  95. package/src/registries/autofill_modifiers.ts +0 -76
  96. package/src/registries/autofill_rules.ts +0 -98
  97. package/src/registries/figure_registry.ts +0 -30
  98. package/src/registries/index.ts +0 -7
  99. package/src/registries/menu_items_registry.ts +0 -110
  100. package/src/registries/menus/cell_menu_registry.ts +0 -79
  101. package/src/registries/menus/col_menu_registry.ts +0 -63
  102. package/src/registries/menus/index.ts +0 -6
  103. package/src/registries/menus/menu_items_actions.ts +0 -425
  104. package/src/registries/menus/row_menu_registry.ts +0 -63
  105. package/src/registries/menus/sheet_menu_registry.ts +0 -75
  106. package/src/registries/menus/topbar_menu_registry.ts +0 -204
  107. package/src/registries/side_panel_registry.ts +0 -26
  108. package/src/registries/topbar_component_registry.ts +0 -12
  109. package/src/registry.ts +0 -51
  110. package/src/translation.ts +0 -44
  111. package/src/types/autofill.ts +0 -48
  112. package/src/types/chart.ts +0 -26
  113. package/src/types/commands.ts +0 -716
  114. package/src/types/conditional_formatting.ts +0 -124
  115. package/src/types/env.ts +0 -13
  116. package/src/types/functions.ts +0 -35
  117. package/src/types/getters.ts +0 -103
  118. package/src/types/index.ts +0 -20
  119. package/src/types/misc.ts +0 -143
  120. package/src/types/rendering.ts +0 -41
  121. package/src/types/workbook_data.ts +0 -62
  122. package/tests/__mocks__/uuid.ts +0 -7
  123. package/tests/canvas.mock.ts +0 -34
  124. package/tests/components/__mocks__/content_editable_helper.ts +0 -79
  125. package/tests/components/__mocks__/scrollbar.ts +0 -18
  126. package/tests/components/__snapshots__/autocomplete_dropdown_test.ts.snap +0 -29
  127. package/tests/components/__snapshots__/bottom_bar_test.ts.snap +0 -75
  128. package/tests/components/__snapshots__/context_menu_test.ts.snap +0 -88
  129. package/tests/components/__snapshots__/grid_test.ts.snap +0 -60
  130. package/tests/components/__snapshots__/spreadsheet_test.ts.snap +0 -455
  131. package/tests/components/__snapshots__/top_bar_test.ts.snap +0 -705
  132. package/tests/components/autocomplete_dropdown_test.ts +0 -315
  133. package/tests/components/autofill_test.ts +0 -167
  134. package/tests/components/bottom_bar_test.ts +0 -262
  135. package/tests/components/chart_side_panel_test.ts +0 -123
  136. package/tests/components/composer_test.ts +0 -400
  137. package/tests/components/context_menu_test.ts +0 -825
  138. package/tests/components/grid_manipulation_test.ts +0 -163
  139. package/tests/components/grid_test.ts +0 -581
  140. package/tests/components/overlay_test.ts +0 -541
  141. package/tests/components/selection_input_test.ts +0 -259
  142. package/tests/components/side_panel_test.ts +0 -148
  143. package/tests/components/spreadsheet_test.ts +0 -194
  144. package/tests/components/top_bar_test.ts +0 -427
  145. package/tests/data_test.ts +0 -175
  146. package/tests/dom_helper.ts +0 -42
  147. package/tests/formulas/__snapshots__/compiler_test.ts.snap +0 -302
  148. package/tests/formulas/compiler_test.ts +0 -266
  149. package/tests/formulas/composer_tokenizer_test.ts +0 -137
  150. package/tests/formulas/expressions_test.ts +0 -57
  151. package/tests/formulas/formulas_test.ts +0 -80
  152. package/tests/formulas/normalize_test.ts +0 -82
  153. package/tests/formulas/parser_test.ts +0 -224
  154. package/tests/formulas/range_tokenizer_test.ts +0 -187
  155. package/tests/formulas/tokenizer_test.ts +0 -164
  156. package/tests/functions/arguments_test.ts +0 -141
  157. package/tests/functions/dates_test.ts +0 -1081
  158. package/tests/functions/functions_test.ts +0 -53
  159. package/tests/functions/helper_test.ts +0 -98
  160. package/tests/functions/module_database_test.ts +0 -311
  161. package/tests/functions/module_date_test.ts +0 -941
  162. package/tests/functions/module_info_test.ts +0 -139
  163. package/tests/functions/module_logical_test.ts +0 -369
  164. package/tests/functions/module_lookup_test.ts +0 -541
  165. package/tests/functions/module_math_test.ts +0 -2482
  166. package/tests/functions/module_operators_test.ts +0 -955
  167. package/tests/functions/module_statistical_test.ts +0 -2014
  168. package/tests/functions/module_text_test.ts +0 -667
  169. package/tests/helpers/coordinates_test.ts +0 -25
  170. package/tests/helpers/misc_test.ts +0 -95
  171. package/tests/helpers/numbers_test.ts +0 -196
  172. package/tests/helpers/zones_test.ts +0 -97
  173. package/tests/helpers.ts +0 -384
  174. package/tests/menu_items_registry_test.ts +0 -540
  175. package/tests/model/plugins/__snapshots__/chart_test.ts.snap +0 -90
  176. package/tests/model/plugins/chart_test.ts +0 -562
  177. package/tests/model_test.ts +0 -82
  178. package/tests/plugins/__snapshots__/conditional_formatting_test.ts.snap +0 -131
  179. package/tests/plugins/__snapshots__/renderer_test.ts.snap +0 -371
  180. package/tests/plugins/autofill_test.ts +0 -457
  181. package/tests/plugins/borders_test.ts +0 -295
  182. package/tests/plugins/clipboard_test.ts +0 -1180
  183. package/tests/plugins/conditional_formatting_test.ts +0 -1253
  184. package/tests/plugins/core_test.ts +0 -614
  185. package/tests/plugins/edition_test.ts +0 -100
  186. package/tests/plugins/evaluation_async_test.ts +0 -332
  187. package/tests/plugins/evaluation_dates_test.ts +0 -79
  188. package/tests/plugins/evaluation_test.ts +0 -901
  189. package/tests/plugins/figures_test.ts +0 -327
  190. package/tests/plugins/formatting_test.ts +0 -391
  191. package/tests/plugins/grid_manipulation_test.ts +0 -1366
  192. package/tests/plugins/highlight_test.ts +0 -413
  193. package/tests/plugins/history_test.ts +0 -142
  194. package/tests/plugins/import_export_test.ts +0 -276
  195. package/tests/plugins/merges_test.ts +0 -490
  196. package/tests/plugins/navigation_test.ts +0 -181
  197. package/tests/plugins/plugins/evaluation_test.ts +0 -111
  198. package/tests/plugins/renderer_test.ts +0 -598
  199. package/tests/plugins/resizing_test.ts +0 -152
  200. package/tests/plugins/selection_input_test.ts +0 -409
  201. package/tests/plugins/selection_test.ts +0 -442
  202. package/tests/plugins/sheets_test.ts +0 -643
  203. package/tests/plugins/style_test.ts +0 -90
  204. 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
- }
@@ -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
- };
@@ -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
- }
@@ -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>;