@trebco/treb 23.6.5 → 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} +285 -269
- 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,152 @@
|
|
|
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 { ValueType, Complex, GetValueType, DimensionedQuantity } from './value-type';
|
|
23
|
+
|
|
24
|
+
export type CellValue = undefined | string | number | boolean | Complex | DimensionedQuantity;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* utility method
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export const Is2DArray = <T>(obj: undefined|T|T[]|T[][]): obj is T[][] => {
|
|
32
|
+
return !!obj && Array.isArray(obj) && Array.isArray(obj[0]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface NumberUnion {
|
|
36
|
+
type: ValueType.number;
|
|
37
|
+
value: number;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface StringUnion {
|
|
41
|
+
type: ValueType.string;
|
|
42
|
+
value: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ErrorUnion {
|
|
46
|
+
type: ValueType.error;
|
|
47
|
+
value: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface FormulaUnion {
|
|
51
|
+
type: ValueType.formula;
|
|
52
|
+
value: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface BooleanUnion {
|
|
56
|
+
type: ValueType.boolean;
|
|
57
|
+
value: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** we should have these for other types as well */
|
|
61
|
+
export interface ComplexUnion {
|
|
62
|
+
type: ValueType.complex;
|
|
63
|
+
value: Complex;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface DimensionedQuantityUnion {
|
|
67
|
+
type: ValueType.dimensioned_quantity;
|
|
68
|
+
value: DimensionedQuantity;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface UndefinedUnion {
|
|
72
|
+
type: ValueType.undefined;
|
|
73
|
+
value?: undefined;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ExtendedUnion {
|
|
77
|
+
type: ValueType.object;
|
|
78
|
+
value: any;
|
|
79
|
+
key?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** potentially recursive structure */
|
|
83
|
+
export interface ArrayUnion {
|
|
84
|
+
type: ValueType.array;
|
|
85
|
+
value: UnionValue[][]; // 2d
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** switch to a discriminated union. implicit type guards! */
|
|
89
|
+
export type UnionValue
|
|
90
|
+
= NumberUnion
|
|
91
|
+
| ArrayUnion
|
|
92
|
+
| ComplexUnion
|
|
93
|
+
| DimensionedQuantityUnion
|
|
94
|
+
| ExtendedUnion
|
|
95
|
+
| StringUnion
|
|
96
|
+
| FormulaUnion
|
|
97
|
+
| UndefinedUnion
|
|
98
|
+
| BooleanUnion
|
|
99
|
+
| ErrorUnion
|
|
100
|
+
;
|
|
101
|
+
|
|
102
|
+
// common types
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* this is a factory instead of a constant value to prevent any accidental pollution
|
|
106
|
+
*/
|
|
107
|
+
// export const CreateUndefinedUnion = (): UnionValue => {
|
|
108
|
+
// return { type: ValueType.undefined, value: undefined };
|
|
109
|
+
//};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* shortcut, although this is wasteful
|
|
113
|
+
*
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
export const Box = (value: unknown, type?: ValueType): UnionValue => {
|
|
117
|
+
|
|
118
|
+
// FIXME: type properly... instead of the GetValueType call
|
|
119
|
+
|
|
120
|
+
if (typeof type === 'undefined') {
|
|
121
|
+
type = GetValueType(value);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// assert?
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
value,
|
|
128
|
+
type,
|
|
129
|
+
} as UnionValue;
|
|
130
|
+
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// export type UnionOrArray = UnionValue|UnionValue[][];
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* box a complex value in a union, potentially switching to a real if
|
|
137
|
+
* there's no imaginary component.
|
|
138
|
+
*
|
|
139
|
+
* @internal
|
|
140
|
+
*/
|
|
141
|
+
export const ComplexOrReal = (value: Complex): ComplexUnion|NumberUnion => {
|
|
142
|
+
if (value.imaginary) {
|
|
143
|
+
return {
|
|
144
|
+
type: ValueType.complex,
|
|
145
|
+
value,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return { type: ValueType.number, value: value.real };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
@@ -0,0 +1,164 @@
|
|
|
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
|
+
// split from cell for separate import,
|
|
23
|
+
// @see format-index.ts
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Complex number type
|
|
27
|
+
*/
|
|
28
|
+
export interface Complex {
|
|
29
|
+
real: number,
|
|
30
|
+
imaginary: number,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* typeguard
|
|
35
|
+
*
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export const IsComplex = (value: unknown): value is Complex => {
|
|
39
|
+
return (typeof value === 'object')
|
|
40
|
+
&& (!!value)
|
|
41
|
+
&& (typeof (value as Complex).real === 'number')
|
|
42
|
+
&& (typeof (value as Complex).imaginary === 'number');
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export const ComplexToString = (value: Complex): string => {
|
|
49
|
+
if (value.real) {
|
|
50
|
+
if (value.imaginary) {
|
|
51
|
+
if (value.imaginary > 0) {
|
|
52
|
+
return `${value.real} + ${value.imaginary}i`;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
return `${value.real} - ${Math.abs(value.imaginary)}i`;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
return value.real.toString();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (value.imaginary) {
|
|
63
|
+
return value.imaginary + 'i';
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
return '0';
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export interface DimensionedQuantity {
|
|
71
|
+
value: number;
|
|
72
|
+
unit: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* typeguard
|
|
77
|
+
*
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
export const IsDimensionedQuantity = (value: unknown): value is DimensionedQuantity => {
|
|
81
|
+
return (typeof value === 'object')
|
|
82
|
+
&& (!!value)
|
|
83
|
+
&& (typeof (value as DimensionedQuantity).value === 'number')
|
|
84
|
+
&& (typeof (value as DimensionedQuantity).unit === 'string');
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* I _think_ using enums is faster. I'm not actually sure about that, though.
|
|
89
|
+
* it stands to reason that a single int compare is faster than a string
|
|
90
|
+
* compare, but you never know with javascript. undefined preferred over null.
|
|
91
|
+
* formula implies a string.
|
|
92
|
+
*
|
|
93
|
+
* undefined is 0 so we can test it as falsy.
|
|
94
|
+
*
|
|
95
|
+
* we're passing this type information out to calculators, so it needs
|
|
96
|
+
* to have known values. DO NOT MODIFY EXISTING INDEXES, or at least be
|
|
97
|
+
* aware of the implications. definitely do not change undefined => 0.
|
|
98
|
+
*/
|
|
99
|
+
export enum ValueType {
|
|
100
|
+
undefined = 0,
|
|
101
|
+
|
|
102
|
+
// formula is a string; we usually test the first character === '='
|
|
103
|
+
formula = 1,
|
|
104
|
+
string = 2,
|
|
105
|
+
number = 3,
|
|
106
|
+
boolean = 4,
|
|
107
|
+
|
|
108
|
+
// we don't actually use this type, it's here for matching only
|
|
109
|
+
object = 5,
|
|
110
|
+
|
|
111
|
+
// error is a STRING VALUE... object errors are layered on top? is that
|
|
112
|
+
// correct? (...) it sort of makes sense... since we have separate typing
|
|
113
|
+
error = 6,
|
|
114
|
+
|
|
115
|
+
// complex is pretty stable by now
|
|
116
|
+
complex = 7,
|
|
117
|
+
|
|
118
|
+
// this is new though. this is not a cell value, it's
|
|
119
|
+
// only for union types. perhaps we should move or rename
|
|
120
|
+
// this array, and then cells could have a subset?
|
|
121
|
+
array = 8,
|
|
122
|
+
|
|
123
|
+
// adding DQ to union
|
|
124
|
+
dimensioned_quantity = 9,
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** @internal */
|
|
129
|
+
export const GetValueType = (value: unknown): ValueType => {
|
|
130
|
+
|
|
131
|
+
switch (typeof value){
|
|
132
|
+
|
|
133
|
+
case 'undefined':
|
|
134
|
+
return ValueType.undefined;
|
|
135
|
+
|
|
136
|
+
case 'number':
|
|
137
|
+
return ValueType.number;
|
|
138
|
+
|
|
139
|
+
case 'boolean':
|
|
140
|
+
return ValueType.boolean;
|
|
141
|
+
|
|
142
|
+
case 'object':
|
|
143
|
+
if (value === null) {
|
|
144
|
+
return ValueType.undefined;
|
|
145
|
+
}
|
|
146
|
+
else if (IsComplex(value)) {
|
|
147
|
+
return ValueType.complex;
|
|
148
|
+
}
|
|
149
|
+
else if (IsDimensionedQuantity(value)) {
|
|
150
|
+
return ValueType.dimensioned_quantity;
|
|
151
|
+
}
|
|
152
|
+
return ValueType.object;
|
|
153
|
+
|
|
154
|
+
case 'string':
|
|
155
|
+
if (value[0] === '=') {
|
|
156
|
+
return ValueType.formula;
|
|
157
|
+
}
|
|
158
|
+
return ValueType.string;
|
|
159
|
+
|
|
160
|
+
default: // function or symbol
|
|
161
|
+
return ValueType.error;
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
.treb-embed-mouse-mask {
|
|
23
|
+
position: fixed;
|
|
24
|
+
top: 0px;
|
|
25
|
+
left: 0px;
|
|
26
|
+
right: 0px;
|
|
27
|
+
bottom: 0px;
|
|
28
|
+
background: transparent;
|
|
29
|
+
z-index: 1000;
|
|
30
|
+
display: none;
|
|
31
|
+
cursor: nwse-resize;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.treb-embed-resize-rect {
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
position: absolute;
|
|
37
|
+
/* border: 1px dotted #339966; */
|
|
38
|
+
border: 1px dotted #2e8dd6;
|
|
39
|
+
border-radius: 2px;
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.treb-embed-resize-handle {
|
|
44
|
+
box-sizing: border-box;
|
|
45
|
+
position: absolute;
|
|
46
|
+
height: 16px;
|
|
47
|
+
width: 16px;
|
|
48
|
+
min-height: 16px;
|
|
49
|
+
min-width: 16px;
|
|
50
|
+
/* border: 8px solid #339966; */
|
|
51
|
+
border: 8px solid #2e8dd6;
|
|
52
|
+
|
|
53
|
+
border-top-color: transparent;
|
|
54
|
+
border-left-color: transparent;
|
|
55
|
+
cursor: nwse-resize;
|
|
56
|
+
bottom: 1px;
|
|
57
|
+
right: 1px;
|
|
58
|
+
z-index: 999;
|
|
59
|
+
}
|