@trebco/treb 32.14.0 → 36.1.3
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/api-generator/api-generator-types.ts +3 -0
- package/api-generator/api-generator.ts +15 -1
- package/bun.lock +145 -99
- package/dist/chunk-43DLP2OX.mjs +11 -0
- package/dist/chunk-4CKS56PE.mjs +11 -0
- package/dist/chunk-75PARUQE.mjs +11 -0
- package/dist/chunk-7QD63AZS.mjs +24601 -0
- package/dist/chunk-A55ARVRD.mjs +11 -0
- package/dist/chunk-DESAKYW4.mjs +11 -0
- package/dist/chunk-EQ2R5W6P.mjs +24565 -0
- package/dist/chunk-IYJU2J6D.mjs +24601 -0
- package/dist/chunk-KSJFPGXT.mjs +11 -0
- package/dist/chunk-ORQFKLXM.mjs +24601 -0
- package/dist/chunk-SFDNNDHY.mjs +11 -0
- package/dist/chunk-T47DX5MI.mjs +11 -0
- package/dist/chunk-T6ILBVEX.mjs +11 -0
- package/dist/chunk-TPRCDYYG.mjs +11 -0
- package/dist/chunk-YAHNOOHO.mjs +11 -0
- package/dist/chunk-YLCFKX2G.mjs +24601 -0
- package/dist/treb-export-worker.mjs +9 -2
- package/dist/treb-spreadsheet.mjs +7 -19
- package/dist/treb.d.ts +144 -117
- package/esbuild-composite.mjs +18 -6
- package/esbuild-utils.mjs +62 -3
- package/i18n/languages/treb-i18n-da.mjs +1 -1
- package/i18n/languages/treb-i18n-de.mjs +1 -1
- package/i18n/languages/treb-i18n-es.mjs +1 -1
- package/i18n/languages/treb-i18n-fr.mjs +1 -1
- package/i18n/languages/treb-i18n-it.mjs +1 -1
- package/i18n/languages/treb-i18n-nl.mjs +1 -1
- package/i18n/languages/treb-i18n-no.mjs +1 -1
- package/i18n/languages/treb-i18n-pl.mjs +1 -1
- package/i18n/languages/treb-i18n-pt.mjs +1 -1
- package/i18n/languages/treb-i18n-sv.mjs +1 -1
- package/ooxml-types/README.md +141 -0
- package/ooxml-types/package.json +5 -0
- package/ooxml-types/src/types/drawingml/chart.ts +327 -0
- package/ooxml-types/src/types/drawingml/index.ts +63 -0
- package/ooxml-types/src/types/drawingml/spreadsheetDrawing.ts +105 -0
- package/ooxml-types/src/types/drawingml/theme.ts +104 -0
- package/ooxml-types/src/types/index.ts +3 -0
- package/ooxml-types/src/types/package/contentTypes.ts +49 -0
- package/ooxml-types/src/types/package/docProps.ts +46 -0
- package/ooxml-types/src/types/package/index.ts +17 -0
- package/ooxml-types/src/types/package/relationships.ts +37 -0
- package/ooxml-types/src/types/spreadsheetml/columns.ts +20 -0
- package/ooxml-types/src/types/spreadsheetml/comments.ts +30 -0
- package/ooxml-types/src/types/spreadsheetml/dataFeatures.ts +261 -0
- package/ooxml-types/src/types/spreadsheetml/enums.ts +175 -0
- package/ooxml-types/src/types/spreadsheetml/index.ts +186 -0
- package/ooxml-types/src/types/spreadsheetml/metadata.ts +90 -0
- package/ooxml-types/src/types/spreadsheetml/misc.ts +35 -0
- package/ooxml-types/src/types/spreadsheetml/pageLayout.ts +83 -0
- package/ooxml-types/src/types/spreadsheetml/sharedStrings.ts +33 -0
- package/ooxml-types/src/types/spreadsheetml/sheetData.ts +70 -0
- package/ooxml-types/src/types/spreadsheetml/sheetProperties.ts +86 -0
- package/ooxml-types/src/types/spreadsheetml/sheetViews.ts +51 -0
- package/ooxml-types/src/types/spreadsheetml/sparkline.ts +46 -0
- package/ooxml-types/src/types/spreadsheetml/styles.ts +274 -0
- package/ooxml-types/src/types/spreadsheetml/table.ts +106 -0
- package/ooxml-types/src/types/spreadsheetml/util.ts +15 -0
- package/ooxml-types/src/types/spreadsheetml/workbook.ts +165 -0
- package/ooxml-types/src/types/spreadsheetml/worksheet.ts +60 -0
- package/package.json +13 -11
- package/treb-base-types/src/api_types.ts +1 -1
- package/treb-base-types/src/area-utils.ts +1 -1
- package/treb-base-types/src/area.ts +1 -1
- package/treb-base-types/src/basic_types.ts +1 -1
- package/treb-base-types/src/cell.ts +1 -1
- package/treb-base-types/src/cells.ts +1 -1
- package/treb-base-types/src/color.ts +1 -1
- package/treb-base-types/src/dom-utilities.ts +1 -1
- package/treb-base-types/src/evaluate-options.ts +1 -1
- package/treb-base-types/src/font-stack.ts +1 -1
- package/treb-base-types/src/gradient.ts +1 -1
- package/treb-base-types/src/import.ts +1 -1
- package/treb-base-types/src/index-standalone.ts +1 -1
- package/treb-base-types/src/index.ts +2 -1
- package/treb-base-types/src/layout.ts +1 -1
- package/treb-base-types/src/localization.ts +1 -1
- package/treb-base-types/src/rectangle.ts +1 -1
- package/treb-base-types/src/render_text.ts +7 -1
- package/treb-base-types/src/style.ts +1 -1
- package/treb-base-types/src/table.ts +1 -1
- package/treb-base-types/src/text_part.ts +1 -1
- package/treb-base-types/src/theme.ts +1 -1
- package/treb-base-types/src/union.ts +4 -1
- package/treb-base-types/src/value-type.ts +1 -1
- package/treb-base-types/src/worker-proxy.ts +294 -0
- package/treb-base-types/style/resizable.css +1 -1
- package/treb-calculator/src/calculator.ts +133 -14
- package/treb-calculator/src/complex-math.ts +1 -1
- package/treb-calculator/src/dag/array-vertex.ts +1 -1
- package/treb-calculator/src/dag/calculation_leaf_vertex.ts +1 -1
- package/treb-calculator/src/dag/graph.ts +1 -1
- package/treb-calculator/src/dag/spreadsheet_vertex.ts +1 -1
- package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +1 -1
- package/treb-calculator/src/dag/state_leaf_vertex.ts +1 -1
- package/treb-calculator/src/dag/vertex.ts +1 -1
- package/treb-calculator/src/descriptors.ts +9 -1
- package/treb-calculator/src/expression-calculator.ts +1 -1
- package/treb-calculator/src/function-error.ts +1 -1
- package/treb-calculator/src/function-library.ts +1 -1
- package/treb-calculator/src/functions/base-functions.ts +8 -4
- package/treb-calculator/src/functions/beta.ts +1 -1
- package/treb-calculator/src/functions/checkbox.ts +1 -1
- package/treb-calculator/src/functions/complex-functions.ts +1 -1
- package/treb-calculator/src/functions/date-utils.ts +1 -1
- package/treb-calculator/src/functions/finance-functions.ts +2 -4
- package/treb-calculator/src/functions/fp.ts +1 -1
- package/treb-calculator/src/functions/function-utilities.ts +1 -1
- package/treb-calculator/src/functions/gamma.ts +1 -1
- package/treb-calculator/src/functions/information-functions.ts +1 -1
- package/treb-calculator/src/functions/lambda-functions.ts +4 -1
- package/treb-calculator/src/functions/matrix-functions.ts +1 -1
- package/treb-calculator/src/functions/normal.ts +1 -1
- package/treb-calculator/src/functions/regex-functions.ts +13 -4
- package/treb-calculator/src/functions/sparkline.ts +1 -1
- package/treb-calculator/src/functions/statistics-functions.ts +1 -1
- package/treb-calculator/src/functions/students-t.ts +1 -1
- package/treb-calculator/src/functions/text-functions.ts +5 -1
- package/treb-calculator/src/index.ts +1 -1
- package/treb-calculator/src/notifier-types.ts +1 -1
- package/treb-calculator/src/primitives.ts +1 -1
- package/treb-calculator/src/utilities.ts +1 -1
- package/treb-charts/src/chart-functions.ts +1 -1
- package/treb-charts/src/chart-types.ts +1 -1
- package/treb-charts/src/chart-utils.ts +1 -1
- package/treb-charts/src/chart.ts +1 -1
- package/treb-charts/src/default-chart-renderer.ts +1 -1
- package/treb-charts/src/index.ts +1 -1
- package/treb-charts/src/main.ts +1 -1
- package/treb-charts/src/quicksort.ts +1 -1
- package/treb-charts/src/rectangle.ts +1 -1
- package/treb-charts/src/renderer-type.ts +1 -1
- package/treb-charts/src/renderer.ts +1 -1
- package/treb-charts/src/util.ts +1 -1
- package/treb-charts/style/charts.scss +1 -1
- package/treb-data-model/src/annotation.ts +1 -1
- package/treb-data-model/src/conditional_format.ts +1 -1
- package/treb-data-model/src/data-validation.ts +1 -1
- package/treb-data-model/src/data_model.ts +32 -5
- package/treb-data-model/src/index.ts +1 -1
- package/treb-data-model/src/language-model.ts +1 -1
- package/treb-data-model/src/named.ts +1 -1
- package/treb-data-model/src/serialize_options.ts +1 -1
- package/treb-data-model/src/sheet.ts +1 -1
- package/treb-data-model/src/sheet_collection.ts +1 -1
- package/treb-data-model/src/sheet_selection.ts +1 -1
- package/treb-data-model/src/sheet_types.ts +1 -1
- package/treb-data-model/src/types.ts +1 -1
- package/treb-embed/src/content-types.d.ts +1 -1
- package/treb-embed/src/custom-element/global.d.ts +1 -1
- package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1 -1
- package/treb-embed/src/custom-element/treb-global.ts +1 -1
- package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +1 -1
- package/treb-embed/src/embedded-spreadsheet.ts +357 -154
- package/treb-embed/src/index.ts +1 -1
- package/treb-embed/src/options.ts +4 -2
- package/treb-embed/src/plugin.ts +1 -1
- package/treb-embed/src/progress-dialog.ts +1 -1
- package/treb-embed/src/selection-state.ts +1 -1
- package/treb-embed/src/spinner.ts +1 -1
- package/treb-embed/src/toolbar-message.ts +6 -1
- package/treb-embed/src/types.ts +13 -1
- package/treb-embed/style/autocomplete.scss +1 -1
- package/treb-embed/style/dark-theme.scss +1 -1
- package/treb-embed/style/defaults.scss +1 -1
- package/treb-embed/style/dialog.scss +1 -1
- package/treb-embed/style/dropdown-select.scss +1 -1
- package/treb-embed/style/font-stacks.scss +1 -1
- package/treb-embed/style/formula-bar.scss +1 -1
- package/treb-embed/style/grid.scss +1 -1
- package/treb-embed/style/layout.scss +1 -1
- package/treb-embed/style/mouse-mask.scss +1 -1
- package/treb-embed/style/note.scss +1 -1
- package/treb-embed/style/overlay-editor.scss +1 -1
- package/treb-embed/style/spinner.scss +1 -1
- package/treb-embed/style/tab-bar.scss +1 -1
- package/treb-embed/style/table.scss +1 -1
- package/treb-embed/style/theme-defaults.scss +1 -1
- package/treb-embed/style/toolbar.scss +1 -1
- package/treb-embed/style/tooltip.scss +1 -1
- package/treb-embed/style/treb-icons.scss +1 -1
- package/treb-embed/style/treb-spreadsheet-element.scss +1 -1
- package/treb-embed/style/z-index.scss +1 -1
- package/treb-export/src/address-type.ts +1 -1
- package/treb-export/src/base-template.ts +1 -1
- package/treb-export/src/column-width.ts +1 -1
- package/treb-export/src/drawing/bubble-chart-template.ts +1 -1
- package/treb-export/src/drawing/chart-template-components2.ts +1 -1
- package/treb-export/src/drawing/chart.ts +1 -1
- package/treb-export/src/drawing/column-chart-template2.ts +1 -1
- package/treb-export/src/drawing/donut-chart-template2.ts +1 -1
- package/treb-export/src/drawing/drawing.ts +1 -1
- package/treb-export/src/drawing/embedded-image.ts +1 -1
- package/treb-export/src/drawing/scatter-chart-template2.ts +1 -1
- package/treb-export/src/export.ts +10 -6
- package/treb-export/src/import-export-messages.ts +61 -0
- package/treb-export/src/import.ts +318 -301
- package/treb-export/src/index.worker.ts +85 -53
- package/treb-export/src/metadata.ts +71 -3
- package/treb-export/src/ooxml.ts +47 -0
- package/treb-export/src/relationship.ts +1 -1
- package/treb-export/src/shared-strings.ts +19 -15
- package/treb-export/src/template-2.ts +1 -1
- package/treb-export/src/unescape_xml.ts +1 -1
- package/treb-export/src/workbook-sheet.ts +11 -6
- package/treb-export/src/workbook-style.ts +137 -25
- package/treb-export/src/workbook-theme.ts +20 -4
- package/treb-export/src/workbook.ts +85 -88
- package/treb-export/src/xml-test.ts +1 -1
- package/treb-export/src/xml-utils.ts +1 -1
- package/treb-export/src/zip-wrapper.ts +1 -1
- package/treb-export/tsconfig.json +2 -1
- package/treb-format/src/format.test.ts +1 -1
- package/treb-format/src/format.ts +12 -5
- package/treb-format/src/format_cache.ts +3 -3
- package/treb-format/src/format_parser.ts +1 -1
- package/treb-format/src/index.ts +1 -1
- package/treb-format/src/number_format_section.ts +1 -1
- package/treb-format/src/value_parser.ts +1 -1
- package/treb-grid/src/editors/autocomplete.ts +1 -1
- package/treb-grid/src/editors/autocomplete_matcher.ts +1 -1
- package/treb-grid/src/editors/editor.ts +15 -6
- package/treb-grid/src/editors/external_editor.ts +33 -8
- package/treb-grid/src/editors/formula_bar.ts +12 -1
- package/treb-grid/src/editors/overlay_editor.ts +4 -1
- package/treb-grid/src/index.ts +1 -1
- package/treb-grid/src/layout/base_layout.ts +1 -1
- package/treb-grid/src/layout/grid_layout.ts +1 -1
- package/treb-grid/src/layout/mock-layout.ts +1 -1
- package/treb-grid/src/render/selection-renderer.ts +1 -1
- package/treb-grid/src/render/svg_header_overlay.ts +1 -1
- package/treb-grid/src/render/svg_selection_block.ts +1 -1
- package/treb-grid/src/render/tile_renderer.ts +36 -7
- package/treb-grid/src/types/border_constants.ts +1 -1
- package/treb-grid/src/types/clipboard_data.ts +1 -1
- package/treb-grid/src/types/clipboard_data2.ts +1 -1
- package/treb-grid/src/types/drag_mask.ts +1 -1
- package/treb-grid/src/types/external_editor_config.ts +1 -1
- package/treb-grid/src/types/grid.ts +181 -40
- package/treb-grid/src/types/grid_base.ts +7 -4
- package/treb-grid/src/types/grid_command.ts +7 -1
- package/treb-grid/src/types/grid_events.ts +2 -1
- package/treb-grid/src/types/grid_options.ts +1 -1
- package/treb-grid/src/types/scale-control.ts +1 -1
- package/treb-grid/src/types/set_range_options.ts +1 -1
- package/treb-grid/src/types/tab_bar.ts +1 -1
- package/treb-grid/src/types/tile.ts +1 -1
- package/treb-grid/src/types/update_flags.ts +1 -1
- package/treb-grid/src/util/fontmetrics.ts +1 -1
- package/treb-grid/src/util/ua.ts +1 -1
- package/treb-parser/src/csv-parser.ts +1 -1
- package/treb-parser/src/index.ts +1 -1
- package/treb-parser/src/md-parser.ts +1 -1
- package/treb-parser/src/parser-types.ts +1 -1
- package/treb-parser/src/parser.ts +1 -1
- package/treb-utils/src/event_source.ts +1 -1
- package/treb-utils/src/ievent_source.ts +1 -1
- package/treb-utils/src/index.ts +1 -1
- package/treb-utils/src/measurement.ts +1 -1
- package/treb-utils/src/scale.ts +1 -1
- package/treb-utils/src/serialize_html.ts +1 -1
- package/treb-utils/src/validate_uri.ts +1 -1
- package/tsproject.json +2 -3
- package/treb-embed/src/export-worker.ts +0 -44
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -36,7 +36,7 @@ import * as Utilities from './utilities';
|
|
|
36
36
|
import { StringUnion } from './utilities';
|
|
37
37
|
|
|
38
38
|
import { FunctionLibrary } from './function-library';
|
|
39
|
-
import type { FunctionMap } from './descriptors';
|
|
39
|
+
import type { ExtendedFunctionDescriptor, FunctionMap } from './descriptors';
|
|
40
40
|
// import * as Utils from './utilities';
|
|
41
41
|
|
|
42
42
|
import { AltFunctionLibrary, BaseFunctionLibrary } from './functions/base-functions';
|
|
@@ -148,6 +148,9 @@ export interface CalculatorOptions {
|
|
|
148
148
|
/** enable spill arrays */
|
|
149
149
|
spill?: boolean;
|
|
150
150
|
|
|
151
|
+
/** helpful flag for resource initialization */
|
|
152
|
+
headless?: boolean;
|
|
153
|
+
|
|
151
154
|
}
|
|
152
155
|
|
|
153
156
|
const default_calculator_options: CalculatorOptions = {
|
|
@@ -192,6 +195,8 @@ export class Calculator extends Graph {
|
|
|
192
195
|
|
|
193
196
|
protected options: CalculatorOptions;
|
|
194
197
|
|
|
198
|
+
protected async_resource_init = false;
|
|
199
|
+
|
|
195
200
|
/**
|
|
196
201
|
* this is a flag we're using to communicate back to the embedded
|
|
197
202
|
* sheet, when the grid has expanded as a result of a calculation
|
|
@@ -1271,6 +1276,24 @@ export class Calculator extends Graph {
|
|
|
1271
1276
|
|
|
1272
1277
|
}
|
|
1273
1278
|
|
|
1279
|
+
/**
|
|
1280
|
+
* new async init method. we need this for subclasses, but
|
|
1281
|
+
* we should consider moving base methods in here as well.
|
|
1282
|
+
*
|
|
1283
|
+
* this function must be idempotent, so we can call it from
|
|
1284
|
+
* multiple paths
|
|
1285
|
+
*/
|
|
1286
|
+
public async InitResources() {
|
|
1287
|
+
if (this.async_resource_init) {
|
|
1288
|
+
// console.info("init resources noop");
|
|
1289
|
+
return;
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
// console.info("init resources (async)");
|
|
1293
|
+
|
|
1294
|
+
this.async_resource_init = true;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1274
1297
|
/**
|
|
1275
1298
|
* support for co-editing. we need to export calculated values from
|
|
1276
1299
|
* the leader instance, because things like RAND() and NOW() are
|
|
@@ -3158,30 +3181,126 @@ export class Calculator extends Graph {
|
|
|
3158
3181
|
|
|
3159
3182
|
if (parse_result.expression) {
|
|
3160
3183
|
|
|
3161
|
-
//
|
|
3162
|
-
//
|
|
3184
|
+
// some functions have UI - render and/or click. we want to attach
|
|
3185
|
+
// those to the cell. this is complicated in the case of lambdas.
|
|
3186
|
+
|
|
3187
|
+
// case 1: library function. check directly.
|
|
3188
|
+
// case 2: inline lambda. check the last parameter.
|
|
3189
|
+
// case 3: indirect lambda (implicit-call), also
|
|
3190
|
+
// case 4: named lambda: resolve, then handle like a lambda.
|
|
3191
|
+
|
|
3192
|
+
// AND NOTE, these could be nested... ?
|
|
3193
|
+
|
|
3194
|
+
// case 5: this is _not_ a pass through situation: an explicit call
|
|
3195
|
+
// to lambda, which just defines a function.
|
|
3196
|
+
|
|
3197
|
+
let descriptor: ExtendedFunctionDescriptor|undefined;
|
|
3198
|
+
let base: ExpressionUnit|undefined = parse_result.expression;
|
|
3199
|
+
|
|
3200
|
+
if (base?.type === 'implicit-call') {
|
|
3163
3201
|
|
|
3164
|
-
|
|
3165
|
-
// here, to look for macros. that might be OK, but the alternative is
|
|
3166
|
-
// just to calculate them on demand, which seems a lot more efficient
|
|
3202
|
+
// if this is a function, it's easy
|
|
3167
3203
|
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3204
|
+
if (base.call.type === 'call') {
|
|
3205
|
+
base = base.call;
|
|
3206
|
+
}
|
|
3207
|
+
else { // else if (base.call.type === 'address') {
|
|
3208
|
+
|
|
3209
|
+
// if this is an address, we'll have to resolve it...
|
|
3210
|
+
// I don't _think_ we need to handle any other types here
|
|
3211
|
+
// TODO/FIXME
|
|
3212
|
+
|
|
3213
|
+
}
|
|
3214
|
+
}
|
|
3215
|
+
else if (base?.type === 'call' ){
|
|
3216
|
+
|
|
3217
|
+
// handle case 5. top-level call, but indirect. this is the
|
|
3218
|
+
// case for lambdas defined in cell functions but not _called_
|
|
3219
|
+
|
|
3220
|
+
descriptor = this.library.Get(base.name);
|
|
3221
|
+
if (descriptor?.pass_through_ui === 'indirect') {
|
|
3222
|
+
base = undefined;
|
|
3223
|
+
}
|
|
3224
|
+
|
|
3225
|
+
}
|
|
3171
3226
|
|
|
3172
|
-
|
|
3227
|
+
while (base?.type === 'call') {
|
|
3173
3228
|
|
|
3229
|
+
descriptor = this.library.Get(base.name);
|
|
3230
|
+
if (descriptor) {
|
|
3231
|
+
if (descriptor.pass_through_ui && base.args.length) {
|
|
3232
|
+
base = base.args[base.args.length - 1];
|
|
3233
|
+
}
|
|
3234
|
+
else {
|
|
3235
|
+
break;
|
|
3236
|
+
}
|
|
3237
|
+
}
|
|
3238
|
+
else {
|
|
3239
|
+
const named = this.model.GetName(base.name, address.sheet_id);
|
|
3240
|
+
if (named?.type === 'expression') {
|
|
3241
|
+
base = named.expression;
|
|
3242
|
+
}
|
|
3243
|
+
else {
|
|
3244
|
+
break;
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
|
|
3249
|
+
if (descriptor) {
|
|
3250
|
+
cell.render_function = descriptor.render;
|
|
3251
|
+
cell.click_function = descriptor.click;
|
|
3252
|
+
}
|
|
3253
|
+
|
|
3254
|
+
/*
|
|
3174
3255
|
if (parse_result.expression.type === 'call') {
|
|
3175
|
-
const func = this.library.Get(parse_result.expression.name);
|
|
3176
3256
|
|
|
3177
|
-
|
|
3257
|
+
descriptor = this.library.Get(parse_result.expression.name);
|
|
3258
|
+
if (!descriptor) {
|
|
3259
|
+
const named = this.model.GetName(parse_result.expression.name, address.sheet_id);
|
|
3260
|
+
if (named?.type === 'expression' && named.expression.type === 'call') {
|
|
3261
|
+
descriptor = this.library.Get(named.expression.name);
|
|
3262
|
+
console.info("D", descriptor);
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
|
|
3266
|
+
if (descriptor) {
|
|
3267
|
+
cell.render_function = descriptor.render;
|
|
3268
|
+
cell.click_function = descriptor.click;
|
|
3269
|
+
}
|
|
3270
|
+
|
|
3271
|
+
}
|
|
3272
|
+
*/
|
|
3273
|
+
|
|
3274
|
+
/*
|
|
3275
|
+
if (parse_result.expression.type === 'call') {
|
|
3276
|
+
const func = this.library.Get(parse_result.expression.name);
|
|
3277
|
+
if (func) {
|
|
3178
3278
|
|
|
3179
|
-
if (func && (func.render || func.click)) {
|
|
3180
3279
|
cell.render_function = func.render;
|
|
3181
3280
|
cell.click_function = func.click;
|
|
3281
|
+
|
|
3282
|
+
if (func.pass_through_ui) {
|
|
3283
|
+
// ...
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3182
3286
|
}
|
|
3287
|
+
else {
|
|
3288
|
+
const named = this.model.GetName(parse_result.expression.name, address.sheet_id);
|
|
3289
|
+
if (named?.type === 'expression') {
|
|
3290
|
+
if (named.expression.type === 'call') {
|
|
3291
|
+
const func = this.library.Get(named.expression.name);
|
|
3292
|
+
if (func?.pass_through_ui && named.expression.args.length) {
|
|
3293
|
+
|
|
3294
|
+
// check the _last_ argument
|
|
3295
|
+
const last = named.expression.args[named.expression.args.length - 1];
|
|
3296
|
+
console.info({last});
|
|
3183
3297
|
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3184
3302
|
}
|
|
3303
|
+
*/
|
|
3185
3304
|
|
|
3186
3305
|
const dependencies = this.RebuildDependencies(parse_result.expression, address.sheet_id, '', undefined, address); // cell.sheet_id);
|
|
3187
3306
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -217,6 +217,14 @@ export interface CompositeFunctionDescriptor {
|
|
|
217
217
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
218
218
|
export?: (...args: any[]) => string;
|
|
219
219
|
|
|
220
|
+
/**
|
|
221
|
+
* pass through UI functions, if possible. this is for lambda and let; we
|
|
222
|
+
* want to pass through sparklines, if a sparkline is the first function call
|
|
223
|
+
*
|
|
224
|
+
* @internal
|
|
225
|
+
*/
|
|
226
|
+
pass_through_ui?: 'direct' | 'indirect';
|
|
227
|
+
|
|
220
228
|
/**
|
|
221
229
|
* flag indicating we've unrolled this function. it's possible functions
|
|
222
230
|
* will run through the registration process more than once and we don't
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -2295,7 +2295,11 @@ export const BaseFunctionLibrary: FunctionMap = {
|
|
|
2295
2295
|
},
|
|
2296
2296
|
|
|
2297
2297
|
Product: {
|
|
2298
|
-
arguments: [{
|
|
2298
|
+
arguments: [{
|
|
2299
|
+
boxed: true,
|
|
2300
|
+
name: 'values or ranges' ,
|
|
2301
|
+
repeat: true,
|
|
2302
|
+
}],
|
|
2299
2303
|
fn: (...args: UnionValue[]): UnionValue => {
|
|
2300
2304
|
|
|
2301
2305
|
let product: Complex = { real: 1, imaginary: 0 };
|
|
@@ -2703,7 +2707,7 @@ export const BaseFunctionLibrary: FunctionMap = {
|
|
|
2703
2707
|
return { handled: true }; // painted
|
|
2704
2708
|
},
|
|
2705
2709
|
fn: (...args: unknown[]): UnionValue => {
|
|
2706
|
-
return { type: ValueType.object, value: args, key: 'sparkline-data' };
|
|
2710
|
+
return { type: ValueType.object, value: args, key: 'sparkline-data', source: 'sparkline.column' };
|
|
2707
2711
|
},
|
|
2708
2712
|
},
|
|
2709
2713
|
|
|
@@ -2718,7 +2722,7 @@ export const BaseFunctionLibrary: FunctionMap = {
|
|
|
2718
2722
|
return { handled: true }; // painted
|
|
2719
2723
|
},
|
|
2720
2724
|
fn: (...args: unknown[]): UnionValue => {
|
|
2721
|
-
return { type: ValueType.object, value: args, key: 'sparkline-data' };
|
|
2725
|
+
return { type: ValueType.object, value: args, key: 'sparkline-data', source: 'sparkline.line' };
|
|
2722
2726
|
},
|
|
2723
2727
|
},
|
|
2724
2728
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -24,8 +24,6 @@ import { type CellValue, type UnionValue, ValueType } from 'treb-base-types';
|
|
|
24
24
|
import { FlattenCellValues } from '../utilities';
|
|
25
25
|
|
|
26
26
|
import { ArgumentError, ValueError } from '../function-error';
|
|
27
|
-
import { LotusDate, UnlotusDate } from 'treb-format';
|
|
28
|
-
import { ConstructDate, DaysInYear } from './date-utils';
|
|
29
27
|
|
|
30
28
|
// use a single, static object for base functions
|
|
31
29
|
|
|
@@ -158,7 +156,7 @@ export const FinanceFunctionLibrary: FunctionMap = {
|
|
|
158
156
|
description: 'Returns the present value of a series of future cashflows',
|
|
159
157
|
arguments: [
|
|
160
158
|
{ name: 'Rate' },
|
|
161
|
-
{ name: 'Cashflow' },
|
|
159
|
+
{ name: 'Cashflow', repeat: true },
|
|
162
160
|
],
|
|
163
161
|
fn: (rate = 0, ...args: CellValue[]): UnionValue => {
|
|
164
162
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -37,6 +37,9 @@ export const LambdaFunctionLibrary: FunctionMap = {
|
|
|
37
37
|
{ name: 'Function', boxed: true, passthrough: true },
|
|
38
38
|
],
|
|
39
39
|
|
|
40
|
+
// pass through render/click functions
|
|
41
|
+
pass_through_ui: 'indirect',
|
|
42
|
+
|
|
40
43
|
fn: (...args: ExpressionUnit[]) => {
|
|
41
44
|
return {
|
|
42
45
|
type: ValueType.function,
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -49,7 +49,7 @@ export const RegexFunctionLibrary: FunctionMap = {
|
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
],
|
|
52
|
-
fn: (
|
|
52
|
+
fn: (source_text, pattern = '', return_mode = 0, icase = false) => {
|
|
53
53
|
|
|
54
54
|
const args: string[] = [];
|
|
55
55
|
if (icase) {
|
|
@@ -59,7 +59,16 @@ export const RegexFunctionLibrary: FunctionMap = {
|
|
|
59
59
|
args.push('g');
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
const
|
|
62
|
+
const text = String(source_text ?? '');
|
|
63
|
+
|
|
64
|
+
let rex: RegExp|undefined;
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
rex = new RegExp(pattern, args.length ? args.join('') : undefined);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return ArgumentError();
|
|
71
|
+
}
|
|
63
72
|
|
|
64
73
|
switch (return_mode) {
|
|
65
74
|
case 0:
|
|
@@ -151,7 +160,7 @@ export const RegexFunctionLibrary: FunctionMap = {
|
|
|
151
160
|
if (occurrence === 0) {
|
|
152
161
|
return {
|
|
153
162
|
type: ValueType.string,
|
|
154
|
-
value:
|
|
163
|
+
value: text.replaceAll(rex, replacement), // huh?
|
|
155
164
|
};
|
|
156
165
|
}
|
|
157
166
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* You should have received a copy of the GNU General Public License along
|
|
15
15
|
* with TREB. If not, see <https://www.gnu.org/licenses/>.
|
|
16
16
|
*
|
|
17
|
-
* Copyright 2022-
|
|
17
|
+
* Copyright 2022-2026 trebco, llc.
|
|
18
18
|
* info@treb.app
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
@@ -333,6 +333,10 @@ export const TextFunctionLibrary: FunctionMap = {
|
|
|
333
333
|
/** canonical should be CONCAT; concatenate can be an alias */
|
|
334
334
|
Concat: {
|
|
335
335
|
description: 'Pastes strings together',
|
|
336
|
+
arguments: [{
|
|
337
|
+
name: 'text',
|
|
338
|
+
repeat: true,
|
|
339
|
+
}],
|
|
336
340
|
fn: (...args: CellValue[]): UnionValue => {
|
|
337
341
|
|
|
338
342
|
const values = Utils.FlattenCellValues(args);
|