@trebco/treb 23.6.2 → 25.0.0-rc1
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/.eslintignore +8 -0
- package/.eslintrc.js +164 -0
- package/README-shadow-DOM.md +88 -0
- package/README.md +37 -130
- package/api-config.json +29 -0
- package/api-generator/api-generator-types.ts +82 -0
- package/api-generator/api-generator.ts +1172 -0
- package/api-generator/package.json +3 -0
- package/build/treb-spreadsheet.mjs +14 -0
- package/{treb.d.ts → build/treb.d.ts} +293 -299
- package/esbuild-custom-element.mjs +336 -0
- package/esbuild.js +305 -0
- package/package.json +43 -14
- package/treb-base-types/package.json +5 -0
- package/treb-base-types/src/api_types.ts +36 -0
- package/treb-base-types/src/area.ts +583 -0
- package/treb-base-types/src/basic_types.ts +45 -0
- package/treb-base-types/src/cell.ts +612 -0
- package/treb-base-types/src/cells.ts +1066 -0
- package/treb-base-types/src/color.ts +124 -0
- package/treb-base-types/src/import.ts +71 -0
- package/treb-base-types/src/index-standalone.ts +29 -0
- package/treb-base-types/src/index.ts +42 -0
- package/treb-base-types/src/layout.ts +47 -0
- package/treb-base-types/src/localization.ts +187 -0
- package/treb-base-types/src/rectangle.ts +145 -0
- package/treb-base-types/src/render_text.ts +72 -0
- package/treb-base-types/src/style.ts +545 -0
- package/treb-base-types/src/table.ts +109 -0
- package/treb-base-types/src/text_part.ts +54 -0
- package/treb-base-types/src/theme.ts +608 -0
- package/treb-base-types/src/union.ts +152 -0
- package/treb-base-types/src/value-type.ts +164 -0
- package/treb-base-types/style/resizable.css +59 -0
- package/treb-calculator/modern.tsconfig.json +11 -0
- package/treb-calculator/package.json +5 -0
- package/treb-calculator/src/calculator.ts +2546 -0
- package/treb-calculator/src/complex-math.ts +558 -0
- package/treb-calculator/src/dag/array-vertex.ts +198 -0
- package/treb-calculator/src/dag/graph.ts +951 -0
- package/treb-calculator/src/dag/leaf_vertex.ts +118 -0
- package/treb-calculator/src/dag/spreadsheet_vertex.ts +327 -0
- package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +44 -0
- package/treb-calculator/src/dag/vertex.ts +352 -0
- package/treb-calculator/src/descriptors.ts +162 -0
- package/treb-calculator/src/expression-calculator.ts +1069 -0
- package/treb-calculator/src/function-error.ts +103 -0
- package/treb-calculator/src/function-library.ts +103 -0
- package/treb-calculator/src/functions/base-functions.ts +1214 -0
- package/treb-calculator/src/functions/checkbox.ts +164 -0
- package/treb-calculator/src/functions/complex-functions.ts +253 -0
- package/treb-calculator/src/functions/finance-functions.ts +399 -0
- package/treb-calculator/src/functions/information-functions.ts +102 -0
- package/treb-calculator/src/functions/matrix-functions.ts +182 -0
- package/treb-calculator/src/functions/sparkline.ts +335 -0
- package/treb-calculator/src/functions/statistics-functions.ts +350 -0
- package/treb-calculator/src/functions/text-functions.ts +298 -0
- package/treb-calculator/src/index.ts +27 -0
- package/treb-calculator/src/notifier-types.ts +59 -0
- package/treb-calculator/src/primitives.ts +428 -0
- package/treb-calculator/src/utilities.ts +305 -0
- package/treb-charts/package.json +5 -0
- package/treb-charts/src/chart-functions.ts +156 -0
- package/treb-charts/src/chart-types.ts +230 -0
- package/treb-charts/src/chart.ts +1288 -0
- package/treb-charts/src/index.ts +24 -0
- package/treb-charts/src/main.ts +37 -0
- package/treb-charts/src/rectangle.ts +52 -0
- package/treb-charts/src/renderer.ts +1841 -0
- package/treb-charts/src/util.ts +122 -0
- package/treb-charts/style/charts.scss +221 -0
- package/treb-charts/style/old-charts.scss +250 -0
- package/treb-embed/markup/layout.html +137 -0
- package/treb-embed/markup/toolbar.html +175 -0
- package/treb-embed/modern.tsconfig.json +25 -0
- package/treb-embed/src/custom-element/content-types.d.ts +18 -0
- package/treb-embed/src/custom-element/global.d.ts +11 -0
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1227 -0
- package/treb-embed/src/custom-element/treb-global.ts +44 -0
- package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +52 -0
- package/treb-embed/src/embedded-spreadsheet.ts +5362 -0
- package/treb-embed/src/index.ts +16 -0
- package/treb-embed/src/language-model.ts +41 -0
- package/treb-embed/src/options.ts +320 -0
- package/treb-embed/src/progress-dialog.ts +228 -0
- package/treb-embed/src/selection-state.ts +16 -0
- package/treb-embed/src/spinner.ts +42 -0
- package/treb-embed/src/toolbar-message.ts +96 -0
- package/treb-embed/src/types.ts +167 -0
- package/treb-embed/style/autocomplete.scss +103 -0
- package/treb-embed/style/dark-theme.scss +114 -0
- package/treb-embed/style/defaults.scss +36 -0
- package/treb-embed/style/dialog.scss +181 -0
- package/treb-embed/style/dropdown-select.scss +101 -0
- package/treb-embed/style/formula-bar.scss +193 -0
- package/treb-embed/style/grid.scss +374 -0
- package/treb-embed/style/layout.scss +424 -0
- package/treb-embed/style/mouse-mask.scss +67 -0
- package/treb-embed/style/note.scss +92 -0
- package/treb-embed/style/overlay-editor.scss +102 -0
- package/treb-embed/style/spinner.scss +92 -0
- package/treb-embed/style/tab-bar.scss +228 -0
- package/treb-embed/style/table.scss +80 -0
- package/treb-embed/style/theme-defaults.scss +444 -0
- package/treb-embed/style/toolbar.scss +416 -0
- package/treb-embed/style/tooltip.scss +68 -0
- package/treb-embed/style/treb-icons.scss +130 -0
- package/treb-embed/style/treb-spreadsheet-element.scss +20 -0
- package/treb-embed/style/z-index.scss +43 -0
- package/treb-export/docs/charts.md +68 -0
- package/treb-export/modern.tsconfig.json +19 -0
- package/treb-export/package.json +4 -0
- package/treb-export/src/address-type.ts +77 -0
- package/treb-export/src/base-template.ts +22 -0
- package/treb-export/src/column-width.ts +85 -0
- package/treb-export/src/drawing2/chart-template-components2.ts +389 -0
- package/treb-export/src/drawing2/chart2.ts +282 -0
- package/treb-export/src/drawing2/column-chart-template2.ts +521 -0
- package/treb-export/src/drawing2/donut-chart-template2.ts +296 -0
- package/treb-export/src/drawing2/drawing2.ts +355 -0
- package/treb-export/src/drawing2/embedded-image.ts +71 -0
- package/treb-export/src/drawing2/scatter-chart-template2.ts +555 -0
- package/treb-export/src/export-worker/export-worker.ts +99 -0
- package/treb-export/src/export-worker/index-modern.ts +22 -0
- package/treb-export/src/export2.ts +2204 -0
- package/treb-export/src/import2.ts +882 -0
- package/treb-export/src/relationship.ts +36 -0
- package/treb-export/src/shared-strings2.ts +128 -0
- package/treb-export/src/template-2.ts +22 -0
- package/treb-export/src/unescape_xml.ts +47 -0
- package/treb-export/src/workbook-sheet2.ts +182 -0
- package/treb-export/src/workbook-style2.ts +1285 -0
- package/treb-export/src/workbook-theme2.ts +88 -0
- package/treb-export/src/workbook2.ts +491 -0
- package/treb-export/src/xml-utils.ts +201 -0
- package/treb-export/template/base/[Content_Types].xml +2 -0
- package/treb-export/template/base/_rels/.rels +2 -0
- package/treb-export/template/base/docProps/app.xml +2 -0
- package/treb-export/template/base/docProps/core.xml +12 -0
- package/treb-export/template/base/xl/_rels/workbook.xml.rels +2 -0
- package/treb-export/template/base/xl/sharedStrings.xml +2 -0
- package/treb-export/template/base/xl/styles.xml +2 -0
- package/treb-export/template/base/xl/theme/theme1.xml +2 -0
- package/treb-export/template/base/xl/workbook.xml +2 -0
- package/treb-export/template/base/xl/worksheets/sheet1.xml +2 -0
- package/treb-export/template/base.xlsx +0 -0
- package/treb-format/package.json +8 -0
- package/treb-format/src/format.test.ts +213 -0
- package/treb-format/src/format.ts +942 -0
- package/treb-format/src/format_cache.ts +199 -0
- package/treb-format/src/format_parser.ts +723 -0
- package/treb-format/src/index.ts +25 -0
- package/treb-format/src/number_format_section.ts +100 -0
- package/treb-format/src/value_parser.ts +337 -0
- package/treb-grid/package.json +5 -0
- package/treb-grid/src/editors/autocomplete.ts +394 -0
- package/treb-grid/src/editors/autocomplete_matcher.ts +260 -0
- package/treb-grid/src/editors/formula_bar.ts +473 -0
- package/treb-grid/src/editors/formula_editor_base.ts +910 -0
- package/treb-grid/src/editors/overlay_editor.ts +511 -0
- package/treb-grid/src/index.ts +37 -0
- package/treb-grid/src/layout/base_layout.ts +2618 -0
- package/treb-grid/src/layout/grid_layout.ts +299 -0
- package/treb-grid/src/layout/rectangle_cache.ts +86 -0
- package/treb-grid/src/render/selection-renderer.ts +414 -0
- package/treb-grid/src/render/svg_header_overlay.ts +93 -0
- package/treb-grid/src/render/svg_selection_block.ts +187 -0
- package/treb-grid/src/render/tile_renderer.ts +2122 -0
- package/treb-grid/src/types/annotation.ts +216 -0
- package/treb-grid/src/types/border_constants.ts +34 -0
- package/treb-grid/src/types/clipboard_data.ts +31 -0
- package/treb-grid/src/types/data_model.ts +334 -0
- package/treb-grid/src/types/drag_mask.ts +81 -0
- package/treb-grid/src/types/grid.ts +7743 -0
- package/treb-grid/src/types/grid_base.ts +3644 -0
- package/treb-grid/src/types/grid_command.ts +470 -0
- package/treb-grid/src/types/grid_events.ts +124 -0
- package/treb-grid/src/types/grid_options.ts +97 -0
- package/treb-grid/src/types/grid_selection.ts +60 -0
- package/treb-grid/src/types/named_range.ts +369 -0
- package/treb-grid/src/types/scale-control.ts +202 -0
- package/treb-grid/src/types/serialize_options.ts +72 -0
- package/treb-grid/src/types/set_range_options.ts +52 -0
- package/treb-grid/src/types/sheet.ts +3099 -0
- package/treb-grid/src/types/sheet_types.ts +95 -0
- package/treb-grid/src/types/tab_bar.ts +464 -0
- package/treb-grid/src/types/tile.ts +59 -0
- package/treb-grid/src/types/update_flags.ts +75 -0
- package/treb-grid/src/util/dom_utilities.ts +44 -0
- package/treb-grid/src/util/fontmetrics2.ts +179 -0
- package/treb-grid/src/util/ua.ts +104 -0
- package/treb-logo.svg +18 -0
- package/treb-parser/package.json +5 -0
- package/treb-parser/src/csv-parser.ts +122 -0
- package/treb-parser/src/index.ts +25 -0
- package/treb-parser/src/md-parser.ts +526 -0
- package/treb-parser/src/parser-types.ts +397 -0
- package/treb-parser/src/parser.test.ts +298 -0
- package/treb-parser/src/parser.ts +2673 -0
- package/treb-utils/package.json +5 -0
- package/treb-utils/src/dispatch.ts +57 -0
- package/treb-utils/src/event_source.ts +147 -0
- package/treb-utils/src/ievent_source.ts +33 -0
- package/treb-utils/src/index.ts +31 -0
- package/treb-utils/src/measurement.ts +174 -0
- package/treb-utils/src/resizable.ts +160 -0
- package/treb-utils/src/scale.ts +137 -0
- package/treb-utils/src/serialize_html.ts +124 -0
- package/treb-utils/src/template.ts +70 -0
- package/treb-utils/src/validate_uri.ts +61 -0
- package/tsconfig.json +10 -0
- package/tsproject.json +30 -0
- package/util/license-plugin-esbuild.js +86 -0
- package/util/list-css-vars.sh +46 -0
- package/README-esm.md +0 -37
- package/treb-bundle.css +0 -2
- package/treb-bundle.mjs +0 -15
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* this is our main file for building and generating API types.
|
|
3
|
+
*
|
|
4
|
+
* because we're using a custom element, we have a class that inherits from
|
|
5
|
+
* HTMLElement. that's fine, but it means the build output can't be used in
|
|
6
|
+
* a node environment (for testing, for example) without a shim.
|
|
7
|
+
*
|
|
8
|
+
* we may add some separate build targets that exclude the html
|
|
9
|
+
* element for that purpose in the future.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export { TREB, TREBGlobal } from './custom-element/treb-global';
|
|
13
|
+
|
|
14
|
+
// import for side effects
|
|
15
|
+
import './custom-element/treb-spreadsheet-element';
|
|
16
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { FunctionDescriptor } from 'treb-grid';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* this is similar to a function descriptor, but we need a lot less
|
|
26
|
+
* information. not sure if we should composite them.
|
|
27
|
+
*/
|
|
28
|
+
export interface TranslatedFunctionDescriptor extends FunctionDescriptor {
|
|
29
|
+
|
|
30
|
+
/** original name (name in english), so we know what to replace. */
|
|
31
|
+
base: string;
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface LanguageModel {
|
|
36
|
+
name: string;
|
|
37
|
+
version?: string;
|
|
38
|
+
locale?: string;
|
|
39
|
+
functions?: TranslatedFunctionDescriptor[];
|
|
40
|
+
}
|
|
41
|
+
|
|
@@ -0,0 +1,320 @@
|
|
|
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 { ICellAddress } from 'treb-base-types';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* options for exporting CSV/TSV
|
|
26
|
+
*/
|
|
27
|
+
export interface ExportOptions {
|
|
28
|
+
|
|
29
|
+
/** comma or tab */
|
|
30
|
+
delimiter?: ',' | '\t';
|
|
31
|
+
|
|
32
|
+
/** optionally choose a sheet to export (defaults to active sheet) */
|
|
33
|
+
sheet?: string|number;
|
|
34
|
+
|
|
35
|
+
/** export formulas not values */
|
|
36
|
+
formulas?: boolean;
|
|
37
|
+
|
|
38
|
+
/** use number formats when exporting numbers */
|
|
39
|
+
formatted?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* options for creating spreadsheet
|
|
44
|
+
*/
|
|
45
|
+
export interface EmbeddedSpreadsheetOptions {
|
|
46
|
+
|
|
47
|
+
/** containing HTML element */
|
|
48
|
+
container?: string|HTMLElement;
|
|
49
|
+
|
|
50
|
+
/** allow drag-and-drop files */
|
|
51
|
+
dnd?: boolean;
|
|
52
|
+
|
|
53
|
+
/** expandable grid */
|
|
54
|
+
expand?: boolean;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* key in localStorage for persisting document. it's possible
|
|
58
|
+
* to set this to boolean `true`, in which case we will generate
|
|
59
|
+
* a storage key based on the page URI.
|
|
60
|
+
*
|
|
61
|
+
* this can be convenient for quickly setting up a document, but don't
|
|
62
|
+
* use it if the page URI might change (the storage will get lost)
|
|
63
|
+
* or if there are multiple spreadsheets on the same page (they will
|
|
64
|
+
* overwrite each other).
|
|
65
|
+
*/
|
|
66
|
+
storage_key?: string|boolean;
|
|
67
|
+
|
|
68
|
+
/** don't load immediately (?) */
|
|
69
|
+
toll_initial_load?: boolean;
|
|
70
|
+
|
|
71
|
+
/** show formula bar. default true. */
|
|
72
|
+
formula_bar?: boolean;
|
|
73
|
+
|
|
74
|
+
/** expand formula bar */
|
|
75
|
+
expand_formula_button?: boolean;
|
|
76
|
+
|
|
77
|
+
/** scroll to cell on load */
|
|
78
|
+
scroll?: string | ICellAddress;
|
|
79
|
+
|
|
80
|
+
/** sheet to show on load, overrides anything in the model */
|
|
81
|
+
sheet?: string;
|
|
82
|
+
|
|
83
|
+
/** add resizable wrapper */
|
|
84
|
+
resizable?: boolean;
|
|
85
|
+
|
|
86
|
+
/** export to xlsx, now optional */
|
|
87
|
+
export?: boolean;
|
|
88
|
+
|
|
89
|
+
/** fill container */
|
|
90
|
+
auto_size?: boolean;
|
|
91
|
+
|
|
92
|
+
/* *
|
|
93
|
+
* popout icon
|
|
94
|
+
* removed as of version 25
|
|
95
|
+
*/
|
|
96
|
+
// popout?: boolean;
|
|
97
|
+
|
|
98
|
+
/* * the old "fork and edit" button */
|
|
99
|
+
// fork?: boolean;
|
|
100
|
+
|
|
101
|
+
/** fetch network document (URI) */
|
|
102
|
+
network_document?: string;
|
|
103
|
+
|
|
104
|
+
/* *
|
|
105
|
+
* load this document if the storage document isn't found (fallback)
|
|
106
|
+
*
|
|
107
|
+
* @deprecated - this is superfluous, using network_document with
|
|
108
|
+
* storage_key is sufficient for this pattern.
|
|
109
|
+
*
|
|
110
|
+
* removed as of version 25
|
|
111
|
+
*/
|
|
112
|
+
// alternate_document?: string;
|
|
113
|
+
|
|
114
|
+
/** freeze rows */
|
|
115
|
+
freeze_rows?: number;
|
|
116
|
+
|
|
117
|
+
/** freeze columns */
|
|
118
|
+
freeze_columns?: number;
|
|
119
|
+
|
|
120
|
+
/** row/column headers */
|
|
121
|
+
headers?: boolean;
|
|
122
|
+
|
|
123
|
+
/** recalculate on load */
|
|
124
|
+
recalculate?: boolean;
|
|
125
|
+
|
|
126
|
+
/** show scrollbars */
|
|
127
|
+
scrollbars?: boolean;
|
|
128
|
+
|
|
129
|
+
/** show tab bar (multi sheet) */
|
|
130
|
+
tab_bar?: boolean|'auto';
|
|
131
|
+
|
|
132
|
+
/** allow add tab */
|
|
133
|
+
add_tab?: boolean;
|
|
134
|
+
|
|
135
|
+
/** show delete tab */
|
|
136
|
+
delete_tab?: boolean;
|
|
137
|
+
|
|
138
|
+
/** set a reference in global (self) */
|
|
139
|
+
global_name?: string;
|
|
140
|
+
|
|
141
|
+
/** support undo */
|
|
142
|
+
undo?: boolean;
|
|
143
|
+
|
|
144
|
+
/** support in-cell editor */
|
|
145
|
+
in_cell_editor?: boolean;
|
|
146
|
+
|
|
147
|
+
/** prompt "you have unsaved changes" */
|
|
148
|
+
prompt_save?: boolean;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* toolbar display option
|
|
152
|
+
*/
|
|
153
|
+
toolbar?: boolean | 'show' | 'narrow' | 'show-narrow';
|
|
154
|
+
|
|
155
|
+
/** file options in the toolbar */
|
|
156
|
+
file_menu?: boolean;
|
|
157
|
+
|
|
158
|
+
/** font size in the toolbar */
|
|
159
|
+
font_scale?: boolean;
|
|
160
|
+
|
|
161
|
+
/** show insert/remove table button in toolbar */
|
|
162
|
+
table_button?: boolean;
|
|
163
|
+
|
|
164
|
+
/** show freeze button in toolbar */
|
|
165
|
+
freeze_button?: boolean;
|
|
166
|
+
|
|
167
|
+
/** chart menu in the toolbar */
|
|
168
|
+
chart_menu?: boolean;
|
|
169
|
+
|
|
170
|
+
/** recalculate button in the toolbar */
|
|
171
|
+
toolbar_recalculate_button?: boolean;
|
|
172
|
+
|
|
173
|
+
/** new option, better support for headless operations (default false) */
|
|
174
|
+
headless?: boolean;
|
|
175
|
+
|
|
176
|
+
/** max size for image, in bytes */
|
|
177
|
+
max_file_size?: number;
|
|
178
|
+
|
|
179
|
+
/** initial scale */
|
|
180
|
+
scale?: number;
|
|
181
|
+
|
|
182
|
+
/** show scale buttons */
|
|
183
|
+
scale_control?: boolean;
|
|
184
|
+
|
|
185
|
+
/** show stats panel */
|
|
186
|
+
stats?: boolean;
|
|
187
|
+
|
|
188
|
+
/** save/load scale. this can optionally have a string key to disambiguate */
|
|
189
|
+
persist_scale?: boolean|string;
|
|
190
|
+
|
|
191
|
+
/** target window for hyperlinks (default _blank); set false to disable hyperlinks altogether */
|
|
192
|
+
hyperlinks?: string|false;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* enable handling complex numbers in function calculation. turning this
|
|
196
|
+
* off doesn't actually disable complex numbers. it means that functions
|
|
197
|
+
* will not return complex numbers unless one of the arguments is complex.
|
|
198
|
+
*
|
|
199
|
+
* for example, if complex numbers are off, `=SQRT(-1)` will return `#VALUE`.
|
|
200
|
+
* if complex numbers are on, `=SQRT(-1)` will return `i`.
|
|
201
|
+
*
|
|
202
|
+
* even if complex numbers are off, however, `=SQRT(-1 + 0i)` will return
|
|
203
|
+
* `i` because the argument is complex.
|
|
204
|
+
*
|
|
205
|
+
* currently this behavior applies to `SQRT`, `POWER` and the exponentiation
|
|
206
|
+
* operator `^`.
|
|
207
|
+
*
|
|
208
|
+
* in version 22, this defaults to `off`.
|
|
209
|
+
*/
|
|
210
|
+
complex?: 'on'|'off';
|
|
211
|
+
|
|
212
|
+
/* *
|
|
213
|
+
* support complex numbers. the meaning of this flag is changing -- the
|
|
214
|
+
* parser is going to always support complex numbers, but we might load
|
|
215
|
+
* a different set of functions if they're not expected to be used.
|
|
216
|
+
* ...
|
|
217
|
+
* no, we're not doing that. atm complex support is always baked in.
|
|
218
|
+
* @deprecated
|
|
219
|
+
* @internal
|
|
220
|
+
*/
|
|
221
|
+
// complex?: boolean;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* for rendering the imaginary number. this is intended to support
|
|
225
|
+
* switching to a different character for rendering, or adding a leading
|
|
226
|
+
* space/half-space/hair-space.
|
|
227
|
+
*/
|
|
228
|
+
imaginary_value?: string;
|
|
229
|
+
|
|
230
|
+
/** support MD formatting for text */
|
|
231
|
+
markdown?: boolean;
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* show tinted colors in toolbar color dropdowns. as of version 25
|
|
235
|
+
* this defaults to true (used to be false).
|
|
236
|
+
*/
|
|
237
|
+
tint_theme_colors?: boolean;
|
|
238
|
+
|
|
239
|
+
/** show a spinner for long-running operations */
|
|
240
|
+
spinner?: boolean;
|
|
241
|
+
|
|
242
|
+
/** collapsed: start sidebar closed */
|
|
243
|
+
collapsed?: boolean;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* show the revert button. see the Revert method. this was renamed
|
|
247
|
+
* from `revert` to avoid any ambiguity.
|
|
248
|
+
*/
|
|
249
|
+
revert_button?: boolean;
|
|
250
|
+
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* default options. some of these are unecessary but we're being
|
|
255
|
+
* explicit here just to be clear that these are intentional.
|
|
256
|
+
*
|
|
257
|
+
* @internal
|
|
258
|
+
*/
|
|
259
|
+
export const DefaultOptions: EmbeddedSpreadsheetOptions = {
|
|
260
|
+
formula_bar: true,
|
|
261
|
+
in_cell_editor: true,
|
|
262
|
+
undo: true,
|
|
263
|
+
scrollbars: true,
|
|
264
|
+
headers: true,
|
|
265
|
+
export: true,
|
|
266
|
+
tab_bar: 'auto',
|
|
267
|
+
resizable: true,
|
|
268
|
+
hyperlinks: '_blank',
|
|
269
|
+
max_file_size: 1024 * 92,
|
|
270
|
+
|
|
271
|
+
// popout: false,
|
|
272
|
+
// imaginary_value: 'i',
|
|
273
|
+
|
|
274
|
+
tint_theme_colors: true,
|
|
275
|
+
|
|
276
|
+
// I don't think false options need to be in default?
|
|
277
|
+
// although it's nice to have a clear reference about defaults...
|
|
278
|
+
|
|
279
|
+
dnd: false,
|
|
280
|
+
add_tab: false,
|
|
281
|
+
expand_formula_button: false,
|
|
282
|
+
delete_tab: false,
|
|
283
|
+
|
|
284
|
+
// changing default value for expand -> false, it might be
|
|
285
|
+
// useful to disable it but the common expectation is that
|
|
286
|
+
// spreadsheets can grow.
|
|
287
|
+
|
|
288
|
+
expand: true,
|
|
289
|
+
markdown: false,
|
|
290
|
+
spinner: false,
|
|
291
|
+
complex: 'off',
|
|
292
|
+
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
/* *
|
|
296
|
+
* actual options requires the container node
|
|
297
|
+
* /
|
|
298
|
+
export interface EmbeddedSpreadsheetOptions extends BaseOptions {
|
|
299
|
+
container?: string|HTMLElement;
|
|
300
|
+
}
|
|
301
|
+
*/
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* embed creation adds option for icons
|
|
305
|
+
*/
|
|
306
|
+
export interface CreateSheetOptions extends EmbeddedSpreadsheetOptions {
|
|
307
|
+
|
|
308
|
+
/** icons */
|
|
309
|
+
decorated?: boolean;
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* optional callback function on create. we're not using this anymore, but
|
|
314
|
+
* leaving it in for backwards compatibility.
|
|
315
|
+
*
|
|
316
|
+
* @internal
|
|
317
|
+
*/
|
|
318
|
+
load?: string;
|
|
319
|
+
|
|
320
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
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 {tmpl, NodeModel} from 'treb-utils';
|
|
23
|
+
// import '../style/icon.scss';
|
|
24
|
+
|
|
25
|
+
export enum DialogType {
|
|
26
|
+
default = '',
|
|
27
|
+
info = 'info',
|
|
28
|
+
error = 'error',
|
|
29
|
+
warning = 'warning',
|
|
30
|
+
success = 'success',
|
|
31
|
+
about = 'about',
|
|
32
|
+
initial = 'initial',
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface MessageDialogOptions {
|
|
36
|
+
title?: string;
|
|
37
|
+
message?: string;
|
|
38
|
+
icon?: string|boolean;
|
|
39
|
+
close_box?: boolean;
|
|
40
|
+
timeout?: number;
|
|
41
|
+
type?: DialogType;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type ResolutionFunction = () => void;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* rebuilding the dialog, like this:
|
|
48
|
+
*
|
|
49
|
+
* +======================================================+
|
|
50
|
+
* | | TITLE | [X]|
|
|
51
|
+
* | [icon] | message | |
|
|
52
|
+
* | | (progress bar?) | |
|
|
53
|
+
* +------------------------------------------------------+
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* modal informational dialog that covers the embedded
|
|
59
|
+
* spreadsheet. not fancy.
|
|
60
|
+
*/
|
|
61
|
+
export class Dialog {
|
|
62
|
+
|
|
63
|
+
// private model: NodeModel;
|
|
64
|
+
private model: Record<string, HTMLElement> = {};
|
|
65
|
+
|
|
66
|
+
private layout_element: HTMLElement;
|
|
67
|
+
|
|
68
|
+
// tslint:disable-next-line:variable-name
|
|
69
|
+
private visible_ = false;
|
|
70
|
+
|
|
71
|
+
private timeout = 0;
|
|
72
|
+
|
|
73
|
+
private pending_dialog_resoltion: ResolutionFunction[] = [];
|
|
74
|
+
|
|
75
|
+
private options_: Partial<MessageDialogOptions> = {
|
|
76
|
+
type: DialogType.initial,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
private set options(options: Partial<MessageDialogOptions>) {
|
|
80
|
+
|
|
81
|
+
if (options.type === DialogType.about) {
|
|
82
|
+
options.close_box = true;
|
|
83
|
+
options.icon = true;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (this.options_.icon !== options.icon) {
|
|
87
|
+
this.model.left.style.display = options.icon ? 'block' : 'none';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (this.options_.close_box !== options.close_box) {
|
|
91
|
+
this.model.close.style.display = options.close_box ? 'block' : 'none';
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (this.options_.message !== options.message) {
|
|
95
|
+
this.model.message.textContent = options.message || '';
|
|
96
|
+
this.model.message.style.display = options.message ? 'block' : 'none';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (this.options_.title !== options.title) {
|
|
100
|
+
this.model.title.textContent = options.title || '';
|
|
101
|
+
this.model.title.style.display = options.title ? 'block' : 'none';
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.options_.type !== options.type) {
|
|
105
|
+
let classes = this.model.dialog.className.replace(/dialog-type-\S+/g, '').trim();
|
|
106
|
+
if (options.type) { classes += ` dialog-type-${options.type}`; }
|
|
107
|
+
this.model.dialog.className = classes;
|
|
108
|
+
|
|
109
|
+
if (options.type === 'about') {
|
|
110
|
+
this.model.about.style.display = 'block';
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
this.model.about.style.display = 'none';
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
this.options_ = options;
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private event_handler = (event: KeyboardEvent) => {
|
|
124
|
+
if (event.key === 'Escape' || event.key === 'Esc') {
|
|
125
|
+
event.stopPropagation();
|
|
126
|
+
event.preventDefault();
|
|
127
|
+
this.visible = false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private get visible(){
|
|
132
|
+
return this.visible_;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private set visible(value: boolean){
|
|
136
|
+
|
|
137
|
+
if (value === this.visible_) { return; }
|
|
138
|
+
this.visible_ = value;
|
|
139
|
+
|
|
140
|
+
// we want to mask not just the spreadsheet but also the toolbar and
|
|
141
|
+
// sidebar. unfortunately we built the node structure the other way.
|
|
142
|
+
// not a real problem though, just requires some reacharound
|
|
143
|
+
|
|
144
|
+
// actually check that we can do that with CSS -- siblings FTW
|
|
145
|
+
|
|
146
|
+
if (value) {
|
|
147
|
+
this.layout_element?.setAttribute('dialog', '');
|
|
148
|
+
window.addEventListener('keydown', this.event_handler);
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
this.layout_element?.removeAttribute('dialog');
|
|
152
|
+
window.removeEventListener('keydown', this.event_handler);
|
|
153
|
+
const tmp = this.pending_dialog_resoltion.slice(0);
|
|
154
|
+
this.pending_dialog_resoltion = [];
|
|
155
|
+
Promise.resolve().then(() => {
|
|
156
|
+
for (const func of tmp) {
|
|
157
|
+
func();
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
constructor(parent_node: HTMLElement) { // }, options: MaskDialogOptions = {}) {
|
|
165
|
+
|
|
166
|
+
this.layout_element = parent_node.parentElement as HTMLElement;
|
|
167
|
+
|
|
168
|
+
const root = this.layout_element?.querySelector('.treb-dialog-mask') as HTMLElement;
|
|
169
|
+
if (root) {
|
|
170
|
+
const elements = root.querySelectorAll('[data-bind]') as NodeListOf<HTMLElement>;
|
|
171
|
+
for (const element of Array.from(elements)) {
|
|
172
|
+
const bind = element.dataset.bind;
|
|
173
|
+
if (bind) {
|
|
174
|
+
this.model[bind] = element;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
// console.info({model: this.model});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (this.model.about) {
|
|
181
|
+
const html: string[] = [`<div>TREB version ${process.env.BUILD_VERSION}`];
|
|
182
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
183
|
+
html.push(`<small>(development build)</small>`);
|
|
184
|
+
}
|
|
185
|
+
html.push( `<small><a target=_blank href='https://treb.app'>http://treb.app</a></small>` )
|
|
186
|
+
this.model.about.innerHTML = html.join('\n');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
this.model.close?.addEventListener('click', (event) => {
|
|
190
|
+
event.stopPropagation();
|
|
191
|
+
event.preventDefault();
|
|
192
|
+
this.HideDialog();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
public Update(options: Partial<MessageDialogOptions>, delta = true): void {
|
|
199
|
+
if (delta) {
|
|
200
|
+
options = { ...this.options_, ... options};
|
|
201
|
+
}
|
|
202
|
+
this.options = options;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public HideDialog(): void {
|
|
206
|
+
this.visible = false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
public ShowDialog(options: Partial<MessageDialogOptions>): Promise<void> {
|
|
210
|
+
return new Promise((resolve) => {
|
|
211
|
+
|
|
212
|
+
this.pending_dialog_resoltion.push(resolve);
|
|
213
|
+
this.options = options;
|
|
214
|
+
this.visible = true;
|
|
215
|
+
|
|
216
|
+
if (this.timeout) {
|
|
217
|
+
window.clearTimeout(this.timeout);
|
|
218
|
+
this.timeout = 0;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
if (options.timeout) {
|
|
222
|
+
this.timeout = window.setTimeout(() => this.HideDialog(), options.timeout);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
|
|
2
|
+
import type { GridSelection } from 'treb-grid';
|
|
3
|
+
import type { Style } from 'treb-base-types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* state that should be reflected in toolbar buttons/selections
|
|
7
|
+
*/
|
|
8
|
+
export interface SelectionState {
|
|
9
|
+
style?: Style.Properties;
|
|
10
|
+
merge?: boolean;
|
|
11
|
+
table?: boolean;
|
|
12
|
+
frozen?: boolean;
|
|
13
|
+
comment?: string;
|
|
14
|
+
selection?: GridSelection;
|
|
15
|
+
relative_font_size?: number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
export class Spinner {
|
|
23
|
+
|
|
24
|
+
private node: HTMLDivElement;
|
|
25
|
+
private visible = false;
|
|
26
|
+
|
|
27
|
+
constructor(public container: HTMLElement) {
|
|
28
|
+
this.node = document.createElement('div');
|
|
29
|
+
this.node.classList.add('treb-spinner');
|
|
30
|
+
this.node.innerHTML = `<div><div></div><div></div><div></div><div></div></div>`;
|
|
31
|
+
container.appendChild(this.node);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public Show(): void {
|
|
35
|
+
this.node.classList.add('visible');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public Hide() {
|
|
39
|
+
this.node.classList.remove('visible');
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
}
|