@svgrid/enterprise 3.0.1 → 3.0.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/LICENSE +94 -24
- package/README.md +36 -4
- package/dist/SvAdvancedFilter.svelte +1 -1
- package/dist/SvAlertsManager.svelte +2 -1
- package/dist/SvBoard.svelte +2 -1
- package/dist/SvExportMenu.svelte +4 -1
- package/dist/SvExportMenu.svelte.d.ts +0 -13
- package/dist/SvExpressionEditor.svelte +3 -3
- package/dist/SvFormulaBar.svelte +680 -0
- package/dist/SvFormulaBar.svelte.d.ts +69 -0
- package/dist/SvGridAlerts.svelte +49 -9
- package/dist/SvGridBoard.svelte +13 -8
- package/dist/SvGridBulkEditDrawer.svelte +26 -2
- package/dist/SvGridEditPanel.svelte +3 -0
- package/dist/SvGridScheduler.svelte +69 -40
- package/dist/SvGridSelectionBar.svelte +10 -3
- package/dist/SvPivotDesigner.svelte +263 -54
- package/dist/SvPivotDesigner.svelte.d.ts +27 -20
- package/dist/SvRibbonIcon.svelte +46 -0
- package/dist/SvRibbonIcon.svelte.d.ts +17 -0
- package/dist/SvSchemaChart.svelte +4 -2
- package/dist/SvSheet.svelte +7914 -0
- package/dist/SvSheet.svelte.d.ts +215 -0
- package/dist/SvSheetChartSetup.svelte +151 -0
- package/dist/SvSheetChartSetup.svelte.d.ts +18 -0
- package/dist/SvSheetComment.svelte +283 -0
- package/dist/SvSheetComment.svelte.d.ts +22 -0
- package/dist/SvSheetConditionalFormat.svelte +159 -0
- package/dist/SvSheetConditionalFormat.svelte.d.ts +14 -0
- package/dist/SvSheetDataValidation.svelte +273 -0
- package/dist/SvSheetDataValidation.svelte.d.ts +14 -0
- package/dist/SvSheetEditRanges.svelte +217 -0
- package/dist/SvSheetEditRanges.svelte.d.ts +15 -0
- package/dist/SvSheetErrors.svelte +125 -0
- package/dist/SvSheetErrors.svelte.d.ts +20 -0
- package/dist/SvSheetEvaluate.svelte +133 -0
- package/dist/SvSheetEvaluate.svelte.d.ts +15 -0
- package/dist/SvSheetFilterMenu.svelte +320 -0
- package/dist/SvSheetFilterMenu.svelte.d.ts +22 -0
- package/dist/SvSheetFindReplace.svelte +132 -0
- package/dist/SvSheetFindReplace.svelte.d.ts +10 -0
- package/dist/SvSheetFormatCells.svelte +465 -0
- package/dist/SvSheetFormatCells.svelte.d.ts +17 -0
- package/dist/SvSheetGoalSeek.svelte +145 -0
- package/dist/SvSheetGoalSeek.svelte.d.ts +12 -0
- package/dist/SvSheetInsertFunction.svelte +149 -0
- package/dist/SvSheetInsertFunction.svelte.d.ts +8 -0
- package/dist/SvSheetIteration.svelte +81 -0
- package/dist/SvSheetIteration.svelte.d.ts +10 -0
- package/dist/SvSheetLink.svelte +99 -0
- package/dist/SvSheetLink.svelte.d.ts +17 -0
- package/dist/SvSheetListPicker.svelte +91 -0
- package/dist/SvSheetListPicker.svelte.d.ts +10 -0
- package/dist/SvSheetManageRules.svelte +187 -0
- package/dist/SvSheetManageRules.svelte.d.ts +16 -0
- package/dist/SvSheetNameManager.svelte +227 -0
- package/dist/SvSheetNameManager.svelte.d.ts +11 -0
- package/dist/SvSheetPageSetup.svelte +159 -0
- package/dist/SvSheetPageSetup.svelte.d.ts +13 -0
- package/dist/SvSheetPasteSpecial.svelte +107 -0
- package/dist/SvSheetPasteSpecial.svelte.d.ts +12 -0
- package/dist/SvSheetPivot.svelte +220 -0
- package/dist/SvSheetPivot.svelte.d.ts +21 -0
- package/dist/SvSheetProtectSheet.svelte +81 -0
- package/dist/SvSheetProtectSheet.svelte.d.ts +11 -0
- package/dist/SvSheetRemoveDuplicates.svelte +152 -0
- package/dist/SvSheetRemoveDuplicates.svelte.d.ts +12 -0
- package/dist/SvSheetRibbon.svelte +1254 -0
- package/dist/SvSheetRibbon.svelte.d.ts +34 -0
- package/dist/SvSheetSizeDialog.svelte +60 -0
- package/dist/SvSheetSizeDialog.svelte.d.ts +11 -0
- package/dist/SvSheetSort.svelte +218 -0
- package/dist/SvSheetSort.svelte.d.ts +28 -0
- package/dist/SvSheetSparklines.svelte +135 -0
- package/dist/SvSheetSparklines.svelte.d.ts +14 -0
- package/dist/SvSheetTable.svelte +160 -0
- package/dist/SvSheetTable.svelte.d.ts +24 -0
- package/dist/SvSheetTabs.svelte +571 -0
- package/dist/SvSheetTabs.svelte.d.ts +50 -0
- package/dist/SvSheetTabs.test-harness.svelte.d.ts +17 -0
- package/dist/SvSheetTabs.test-harness.svelte.js +22 -0
- package/dist/SvSheetTextToColumns.svelte +172 -0
- package/dist/SvSheetTextToColumns.svelte.d.ts +13 -0
- package/dist/SvSheetValidationAlert.svelte +85 -0
- package/dist/SvSheetValidationAlert.svelte.d.ts +15 -0
- package/dist/advanced-filter-enable.js +1 -1
- package/dist/alerts/alert-engine.d.ts +6 -0
- package/dist/alerts/alert-engine.js +21 -4
- package/dist/alerts/alert-formats.js +2 -0
- package/dist/alerts/alert-types.d.ts +1 -1
- package/dist/alerts.d.ts +1 -1
- package/dist/alerts.js +2 -2
- package/dist/board.js +2 -2
- package/dist/bulk-edit.d.ts +3 -1
- package/dist/bulk-edit.js +1 -1
- package/dist/cdn/svgrid-enterprise.svelte-external.js +43538 -6539
- package/dist/designer/assets/GridMenus-8gTNssgV.js +8 -0
- package/dist/designer/assets/SvChartMenu-BDoeqGz6.js +1 -0
- package/dist/designer/assets/SvChartMenu-BYO9cYdy.css +1 -0
- package/dist/designer/assets/SvDateRangeInput-BBRzrQeg.js +1 -0
- package/dist/designer/assets/SvDateTimePicker-DCPg7WGN.js +1 -0
- package/dist/designer/assets/SvGridCellEditor-DMoWJjEI.js +4 -0
- package/dist/designer/assets/SvGridChart-BgLuPO7I.css +1 -0
- package/dist/designer/assets/SvGridChart-Cy1ATrWh.js +3 -0
- package/dist/designer/assets/SvGridChartBuilder-08YWWeqY.css +1 -0
- package/dist/designer/assets/SvGridChartBuilder-eQ3mn0L9.js +1 -0
- package/dist/designer/assets/SvGridChartPanel-4Pc8y5yO.css +1 -0
- package/dist/designer/assets/SvGridChartPanel-CATdVc9X.js +4 -0
- package/dist/designer/assets/{SvGridChartView-DUc-1RUf.css → SvGridChartView-7msfnWZT.css} +1 -1
- package/dist/designer/assets/SvGridChartView-CmsZtCED.js +1 -0
- package/dist/designer/assets/SvGridDropdown-Cjz0H-fI.js +1 -0
- package/dist/designer/assets/SvListBox-BDS66lmZ.js +110 -0
- package/dist/designer/assets/SvMenuList-DJ47ba1h.css +1 -0
- package/dist/designer/assets/SvMenuList-Dgq2D5VN.js +1 -0
- package/dist/designer/assets/SvTabs-2mHC6oaz.js +1 -0
- package/dist/designer/assets/SvTabs-DKmwb5p1.css +1 -0
- package/dist/designer/assets/cell-formatting-BbubJTVz.js +1 -0
- package/dist/designer/assets/chart-Cn7MnNqA.js +1 -0
- package/dist/designer/assets/chart-export-B6bkQ3X8.js +11 -0
- package/dist/designer/assets/chart-export-pdf-BbA28-gt.js +11 -0
- package/dist/designer/assets/chart-panel-messages-Dz7PTIqT.js +1 -0
- package/dist/designer/assets/chart-summary-BD1qYB2R.js +1 -0
- package/dist/designer/assets/chart-trend-B8xr5LuD.js +1 -0
- package/dist/designer/assets/chart-validate-BMqM-qkF.js +1 -0
- package/dist/designer/assets/column-resize-BYDzR1Ve.js +1 -0
- package/dist/designer/assets/date-format-B8JbEtIG.js +1 -0
- package/dist/designer/assets/date-format-DKS-z0xS.css +1 -0
- package/dist/designer/assets/{dismissable-BO547MH9.js → dismissable-ChWRPkoa.js} +1 -1
- package/dist/designer/assets/editor-contract-Bpoa7A5g.js +1 -0
- package/dist/designer/assets/{export-format-D-eP4b2l.js → export-format-DGckmgKr.js} +1 -1
- package/dist/designer/assets/focus-trap-V2-6Fy9I.js +1 -0
- package/dist/designer/assets/{index-C_a9Cj8Y.js → index-D5bVbuzI.js} +318 -315
- package/dist/designer/assets/index-_JVFxt02.css +1 -0
- package/dist/designer/assets/list-option-BP_dWS66.js +1 -0
- package/dist/designer/assets/row-resize-BInFWCpr.js +1 -0
- package/dist/designer/assets/server-block-cache-CXJKkJpy.js +1 -0
- package/dist/designer/assets/src-CITpcm6b.js +1 -0
- package/dist/designer/assets/src-DUQ4xE3x.js +58 -0
- package/dist/designer/assets/validate-C3B8QKsM.js +1 -0
- package/dist/designer/index.html +29 -19
- package/dist/export-pdf.d.ts +164 -0
- package/dist/export-pdf.js +346 -15
- package/dist/export.js +25 -10
- package/dist/gantt/SvGridGantt.svelte +2890 -0
- package/dist/gantt/SvGridGantt.svelte.d.ts +30 -0
- package/dist/gantt/gantt-config.d.ts +73 -0
- package/dist/gantt/gantt-config.js +1 -0
- package/dist/gantt/gantt-critical-path.d.ts +67 -0
- package/dist/gantt/gantt-critical-path.js +207 -0
- package/dist/gantt/gantt-model.d.ts +257 -0
- package/dist/gantt/gantt-model.js +651 -0
- package/dist/gantt/gantt-resources.d.ts +59 -0
- package/dist/gantt/gantt-resources.js +71 -0
- package/dist/gantt/gantt.d.ts +7 -0
- package/dist/gantt/gantt.js +36 -0
- package/dist/gantt/index.d.ts +15 -0
- package/dist/gantt/index.js +22 -0
- package/dist/gantt/timeline-arrows.d.ts +102 -0
- package/dist/gantt/timeline-arrows.js +181 -0
- package/dist/import.d.ts +2 -2
- package/dist/import.js +1 -1
- package/dist/index.d.ts +93 -3
- package/dist/index.js +107 -3
- package/dist/install.js +13 -1
- package/dist/license-core.d.ts +17 -1
- package/dist/license-core.js +16 -5
- package/dist/license.d.ts +18 -2
- package/dist/license.js +71 -6
- package/dist/node/studio.js +203 -9
- package/dist/pivot-chart.d.ts +25 -1
- package/dist/pivot-chart.js +25 -69
- package/dist/pivot-enable.js +2 -2
- package/dist/scheduler-dependencies.d.ts +35 -0
- package/dist/scheduler-dependencies.js +36 -1
- package/dist/scheduler.js +2 -2
- package/dist/selection-bar.js +2 -2
- package/dist/server/SvGroupCell.svelte +213 -0
- package/dist/server/SvGroupCell.svelte.d.ts +62 -0
- package/dist/server/SvRowGroupPanel.svelte +322 -0
- package/dist/server/SvRowGroupPanel.svelte.d.ts +37 -0
- package/dist/server/enable.d.ts +17 -0
- package/dist/server/enable.js +49 -0
- package/dist/server/index.d.ts +22 -0
- package/dist/server/index.js +24 -0
- package/dist/server/messages.d.ts +45 -0
- package/dist/server/messages.js +35 -0
- package/dist/server/server-group-model.d.ts +104 -0
- package/dist/server/server-group-model.js +272 -0
- package/dist/server/server-pivot.d.ts +46 -0
- package/dist/server/server-pivot.js +57 -0
- package/dist/server/server-row-model.d.ts +547 -0
- package/dist/server/server-row-model.js +1551 -0
- package/dist/server/server-selection.d.ts +99 -0
- package/dist/server/server-selection.js +215 -0
- package/dist/server/svgrid-adapter.d.ts +155 -0
- package/dist/server/svgrid-adapter.js +202 -0
- package/dist/sheet/address.d.ts +43 -0
- package/dist/sheet/address.js +81 -0
- package/dist/sheet/ast.d.ts +138 -0
- package/dist/sheet/ast.js +70 -0
- package/dist/sheet/auto-filter.d.ts +120 -0
- package/dist/sheet/auto-filter.js +295 -0
- package/dist/sheet/autocomplete.d.ts +51 -0
- package/dist/sheet/autocomplete.js +248 -0
- package/dist/sheet/cell-images.d.ts +39 -0
- package/dist/sheet/cell-images.js +90 -0
- package/dist/sheet/cell-types.d.ts +58 -0
- package/dist/sheet/cell-types.js +96 -0
- package/dist/sheet/coerce.d.ts +71 -0
- package/dist/sheet/coerce.js +289 -0
- package/dist/sheet/commands.d.ts +89 -0
- package/dist/sheet/commands.js +230 -0
- package/dist/sheet/comments.d.ts +63 -0
- package/dist/sheet/comments.js +131 -0
- package/dist/sheet/conditional-formats.d.ts +167 -0
- package/dist/sheet/conditional-formats.js +341 -0
- package/dist/sheet/csv.d.ts +32 -0
- package/dist/sheet/csv.js +158 -0
- package/dist/sheet/culture.d.ts +87 -0
- package/dist/sheet/culture.js +247 -0
- package/dist/sheet/delta.d.ts +102 -0
- package/dist/sheet/delta.js +203 -0
- package/dist/sheet/deps.d.ts +104 -0
- package/dist/sheet/deps.js +274 -0
- package/dist/sheet/document.d.ts +252 -0
- package/dist/sheet/document.js +465 -0
- package/dist/sheet/edit-keys.d.ts +14 -0
- package/dist/sheet/edit-keys.js +40 -0
- package/dist/sheet/engine.d.ts +67 -0
- package/dist/sheet/engine.js +19 -0
- package/dist/sheet/entry.d.ts +35 -0
- package/dist/sheet/entry.js +226 -0
- package/dist/sheet/error-check.d.ts +49 -0
- package/dist/sheet/error-check.js +83 -0
- package/dist/sheet/evaluate-steps.d.ts +48 -0
- package/dist/sheet/evaluate-steps.js +196 -0
- package/dist/sheet/evaluate.d.ts +128 -0
- package/dist/sheet/evaluate.js +1049 -0
- package/dist/sheet/filter-files.d.ts +37 -0
- package/dist/sheet/filter-files.js +465 -0
- package/dist/sheet/find-replace.d.ts +62 -0
- package/dist/sheet/find-replace.js +152 -0
- package/dist/sheet/format-store.d.ts +114 -0
- package/dist/sheet/format-store.js +243 -0
- package/dist/sheet/freeze.d.ts +54 -0
- package/dist/sheet/freeze.js +58 -0
- package/dist/sheet/from-rows.d.ts +14 -0
- package/dist/sheet/from-rows.js +50 -0
- package/dist/sheet/function-catalog.d.ts +10 -0
- package/dist/sheet/function-catalog.js +385 -0
- package/dist/sheet/functions.d.ts +28 -0
- package/dist/sheet/functions.js +634 -0
- package/dist/sheet/goal-seek.d.ts +73 -0
- package/dist/sheet/goal-seek.js +153 -0
- package/dist/sheet/index.d.ts +80 -0
- package/dist/sheet/index.js +80 -0
- package/dist/sheet/links.d.ts +57 -0
- package/dist/sheet/links.js +174 -0
- package/dist/sheet/merges.d.ts +71 -0
- package/dist/sheet/merges.js +137 -0
- package/dist/sheet/messages.d.ts +778 -0
- package/dist/sheet/messages.js +806 -0
- package/dist/sheet/names.d.ts +31 -0
- package/dist/sheet/names.js +87 -0
- package/dist/sheet/navigate.d.ts +52 -0
- package/dist/sheet/navigate.js +135 -0
- package/dist/sheet/number-format.d.ts +110 -0
- package/dist/sheet/number-format.js +905 -0
- package/dist/sheet/objects.d.ts +106 -0
- package/dist/sheet/objects.js +149 -0
- package/dist/sheet/ods-document.d.ts +44 -0
- package/dist/sheet/ods-document.js +1275 -0
- package/dist/sheet/open-file.d.ts +26 -0
- package/dist/sheet/open-file.js +56 -0
- package/dist/sheet/outline.d.ts +82 -0
- package/dist/sheet/outline.js +228 -0
- package/dist/sheet/packs/array.d.ts +16 -0
- package/dist/sheet/packs/array.js +172 -0
- package/dist/sheet/packs/database.d.ts +42 -0
- package/dist/sheet/packs/database.js +142 -0
- package/dist/sheet/packs/engineering.d.ts +2 -0
- package/dist/sheet/packs/engineering.js +296 -0
- package/dist/sheet/packs/financial.d.ts +5 -0
- package/dist/sheet/packs/financial.js +220 -0
- package/dist/sheet/packs/math-stats.d.ts +2 -0
- package/dist/sheet/packs/math-stats.js +372 -0
- package/dist/sheet/packs/special.d.ts +44 -0
- package/dist/sheet/packs/special.js +187 -0
- package/dist/sheet/packs/stats-dist.d.ts +2 -0
- package/dist/sheet/packs/stats-dist.js +785 -0
- package/dist/sheet/packs/text-date.d.ts +2 -0
- package/dist/sheet/packs/text-date.js +332 -0
- package/dist/sheet/packs/trig.d.ts +2 -0
- package/dist/sheet/packs/trig.js +73 -0
- package/dist/sheet/page-setup.d.ts +73 -0
- package/dist/sheet/page-setup.js +73 -0
- package/dist/sheet/palette.d.ts +19 -0
- package/dist/sheet/palette.js +84 -0
- package/dist/sheet/parse.d.ts +13 -0
- package/dist/sheet/parse.js +140 -0
- package/dist/sheet/paste-special.d.ts +186 -0
- package/dist/sheet/paste-special.js +601 -0
- package/dist/sheet/pivot-range.d.ts +160 -0
- package/dist/sheet/pivot-range.js +333 -0
- package/dist/sheet/presence.d.ts +73 -0
- package/dist/sheet/presence.js +79 -0
- package/dist/sheet/print.d.ts +104 -0
- package/dist/sheet/print.js +169 -0
- package/dist/sheet/protection.d.ts +75 -0
- package/dist/sheet/protection.js +101 -0
- package/dist/sheet/rects.d.ts +45 -0
- package/dist/sheet/rects.js +112 -0
- package/dist/sheet/refs.d.ts +130 -0
- package/dist/sheet/refs.js +413 -0
- package/dist/sheet/ribbon-icons.d.ts +31 -0
- package/dist/sheet/ribbon-icons.js +536 -0
- package/dist/sheet/ribbon.d.ts +173 -0
- package/dist/sheet/ribbon.js +1054 -0
- package/dist/sheet/sheet-kinds.d.ts +74 -0
- package/dist/sheet/sheet-kinds.js +91 -0
- package/dist/sheet/shortcuts.d.ts +174 -0
- package/dist/sheet/shortcuts.js +674 -0
- package/dist/sheet/sort.d.ts +51 -0
- package/dist/sheet/sort.js +107 -0
- package/dist/sheet/sparklines.d.ts +111 -0
- package/dist/sheet/sparklines.js +204 -0
- package/dist/sheet/structure.d.ts +87 -0
- package/dist/sheet/structure.js +166 -0
- package/dist/sheet/table-styles.d.ts +74 -0
- package/dist/sheet/table-styles.js +152 -0
- package/dist/sheet/tables.d.ts +89 -0
- package/dist/sheet/tables.js +178 -0
- package/dist/sheet/tokenize.d.ts +71 -0
- package/dist/sheet/tokenize.js +355 -0
- package/dist/sheet/transforms.d.ts +76 -0
- package/dist/sheet/transforms.js +154 -0
- package/dist/sheet/validation.d.ts +108 -0
- package/dist/sheet/validation.js +278 -0
- package/dist/sheet/workbook.d.ts +217 -0
- package/dist/sheet/workbook.js +1120 -0
- package/dist/sheet/xls-cfb.d.ts +32 -0
- package/dist/sheet/xls-cfb.js +290 -0
- package/dist/sheet/xls-document.d.ts +10 -0
- package/dist/sheet/xls-document.js +1243 -0
- package/dist/sheet/xls-formula.d.ts +40 -0
- package/dist/sheet/xls-formula.js +569 -0
- package/dist/sheet/xlsx-document.d.ts +108 -0
- package/dist/sheet/xlsx-document.js +1849 -0
- package/dist/sheet/xlsx-drawing.d.ts +99 -0
- package/dist/sheet/xlsx-drawing.js +420 -0
- package/dist/sheet-enable.d.ts +6 -0
- package/dist/sheet-enable.js +45 -0
- package/dist/sheet-text.d.ts +7 -0
- package/dist/sheet-text.js +29 -0
- package/dist/sources/auth-supabase.js +2 -2
- package/dist/sources/realtime-supabase.js +2 -2
- package/dist/sources/rest.d.ts +6 -2
- package/dist/sources/rest.js +42 -7
- package/dist/sources/supabase.d.ts +10 -1
- package/dist/sources/supabase.js +73 -40
- package/dist/studio/emit-project.js +14 -1
- package/dist/studio/index.js +1 -1
- package/dist/studio/project.d.ts +11 -2
- package/dist/studio/project.js +5 -2
- package/dist/studio/ui-components.generated.js +170 -3
- package/dist/sveltekit/in-memory.d.ts +2 -2
- package/dist/sveltekit/in-memory.js +125 -4
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.js +1 -1
- package/dist/sveltekit/query-plan.d.ts +50 -4
- package/dist/sveltekit/query-plan.js +25 -3
- package/dist/sveltekit/sql-source.d.ts +6 -0
- package/dist/sveltekit/sql-source.js +34 -6
- package/dist/sveltekit/sql.d.ts +31 -0
- package/dist/sveltekit/sql.js +135 -25
- package/dist/sveltekit/transport.d.ts +10 -2
- package/dist/sveltekit/transport.js +30 -6
- package/dist/upgrade-prompt.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/watermark.js +35 -2
- package/dist/wc/GridMenus-By9vPuq0.js +1088 -0
- package/dist/wc/SvChartMenu-CQNrQGT2.js +308 -0
- package/dist/wc/SvDateRangeInput-DR6m7bSM.js +199 -0
- package/dist/wc/SvDateTimePicker-D-vRnaMo.js +771 -0
- package/dist/wc/SvField-B_kurx_P.js +149 -0
- package/dist/wc/SvGrid.helpers-BdVDtjUm.js +135 -0
- package/dist/wc/SvGridCellEditor-Bnf1Kr5C.js +560 -0
- package/dist/wc/SvGridChart-BqUJh2pG.js +3572 -0
- package/dist/wc/SvGridChartBuilder-CGycC5cn.js +988 -0
- package/dist/wc/SvGridChartPanel-CRnizsHD.js +1746 -0
- package/dist/wc/SvGridChartView-D1pa_xMy.js +47 -0
- package/dist/wc/SvGridDropdown-45WsObLL.js +259 -0
- package/dist/wc/SvModal-DrfOYYyX.js +189 -0
- package/dist/wc/cell-formatting-CBfgahv1.js +86 -0
- package/dist/wc/chart-6OXlybVT.js +4341 -0
- package/dist/wc/chart-export-CeSADGfi.js +135 -0
- package/dist/wc/chart-export-pdf-BGko7MER.js +104 -0
- package/dist/wc/chart-summary-2m3ia1-n.js +137 -0
- package/dist/wc/chart-trend-CQOQtTMl.js +50 -0
- package/dist/wc/chart-validate-CD6ptiwg.js +180 -0
- package/dist/wc/client-DQIzjDBG.js +3064 -0
- package/dist/wc/column-resize-DUPgynvc.js +101 -0
- package/dist/wc/date-format-DS-z_h9v.js +1130 -0
- package/dist/wc/dismissable-CQ6XFXsk.js +45 -0
- package/dist/wc/editor-contract-peBDxir_.js +22 -0
- package/dist/wc/editor-registry-DxGKqcvx.js +24 -0
- package/dist/wc/focus-trap-Dbb2tJxb.js +65 -0
- package/dist/wc/list-option-DrRyivWp.js +82 -0
- package/dist/wc/popover-WsGlvtQv.js +69 -0
- package/dist/wc/positioning-BiKLfu1E.js +112 -0
- package/dist/wc/react.d.ts +41 -0
- package/dist/wc/react.js +90 -0
- package/dist/wc/rolldown-runtime-Dy4uBu1J.js +11 -0
- package/dist/wc/row-drag-touch-CycRR65n.js +93 -0
- package/dist/wc/row-resize-limG_N1z.js +111 -0
- package/dist/wc/sv-sheet-element.d.ts +97 -0
- package/dist/wc/sv-sheet-element.js +44213 -0
- package/dist/wc/svelte-virtualizer.svelte-CXtQy2TQ.js +530 -0
- package/dist/wc/validate-BqDthkNr.js +88 -0
- package/dist/wc/vue.d.ts +31 -0
- package/dist/wc/vue.js +75 -0
- package/package.json +36 -6
- package/dist/designer/assets/GridMenus-B1JtIN21.js +0 -8
- package/dist/designer/assets/SvDateRangeInput-CjO7nn_x.js +0 -1
- package/dist/designer/assets/SvDateTimePicker-ByBD_ov6.js +0 -1
- package/dist/designer/assets/SvField-YDLipR6O.css +0 -1
- package/dist/designer/assets/SvField-cj1PFNgZ.js +0 -1
- package/dist/designer/assets/SvGridCellEditor-0W1L2hJ1.js +0 -2
- package/dist/designer/assets/SvGridChart-DBOR4xcz.js +0 -2
- package/dist/designer/assets/SvGridChart-fkMWeh1J.css +0 -1
- package/dist/designer/assets/SvGridChartPanel-symrhNnR.js +0 -11
- package/dist/designer/assets/SvGridChartView-BmRxq6mU.js +0 -1
- package/dist/designer/assets/SvGridDropdown-Bb3HH2Aj.js +0 -1
- package/dist/designer/assets/SvListBox-1oUF6Iav.js +0 -110
- package/dist/designer/assets/cell-formatting-wr5wm7US.js +0 -1
- package/dist/designer/assets/chart-DXFganU8.js +0 -1
- package/dist/designer/assets/column-resize-C_inr5zT.js +0 -1
- package/dist/designer/assets/date-format-DGagAqRc.css +0 -1
- package/dist/designer/assets/date-format-onlYDsrY.js +0 -1
- package/dist/designer/assets/easing-zaypKrr0.js +0 -3
- package/dist/designer/assets/index-k2stW6L8.css +0 -1
- package/dist/designer/assets/row-resize-B0FWHcNr.js +0 -1
- package/dist/designer/assets/src-D9p27OGC.js +0 -58
- package/dist/designer/assets/validate-h-aslRV9.js +0 -1
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* More of Excel's math, statistics and reference functions: rounding to a
|
|
3
|
+
* multiple, logs, integers, order statistics, variances, the *IFS
|
|
4
|
+
* aggregates, simple regression, CHOOSE and the range dimensions.
|
|
5
|
+
*
|
|
6
|
+
* Rounding to a multiple is where floating point bites: 1.5 / 0.1 is
|
|
7
|
+
* 15.000000000000002, which CEILING would happily read as 16. `snap` treats a
|
|
8
|
+
* quotient within a hair of an integer as that integer, and `tidy` trims
|
|
9
|
+
* the drift off the product, so `=CEILING(1.5, 0.1)` is 1.5 and not 1.6.
|
|
10
|
+
*/
|
|
11
|
+
import { err } from '../ast.js';
|
|
12
|
+
import { toNumber, numericOnly, multiCriteriaHits, criteriaPairs } from '../coerce.js';
|
|
13
|
+
const nth = (a, i) => a.args[i]?.[0] ?? '';
|
|
14
|
+
const num = (a, i) => toNumber(nth(a, i));
|
|
15
|
+
function opt(a, i, fallback) {
|
|
16
|
+
const v = a.args[i]?.[0];
|
|
17
|
+
return v === undefined || v === '' ? fallback : toNumber(v);
|
|
18
|
+
}
|
|
19
|
+
const snap = (q) => (Math.abs(q - Math.round(q)) < 1e-9 ? Math.round(q) : q);
|
|
20
|
+
const tidy = (x) => (Number.isFinite(x) ? Number(x.toPrecision(15)) : x);
|
|
21
|
+
/** Round half away from zero, which is what Excel does and Math.round does not
|
|
22
|
+
* for negatives. */
|
|
23
|
+
const roundHalfAway = (x) => Math.sign(x) * Math.round(Math.abs(x));
|
|
24
|
+
function sorted(values) {
|
|
25
|
+
return numericOnly(values).sort((x, y) => x - y);
|
|
26
|
+
}
|
|
27
|
+
/** PERCENTILE.INC: linear interpolation between the order statistics. */
|
|
28
|
+
function percentileInc(values, k) {
|
|
29
|
+
if (!values.length || k < 0 || k > 1)
|
|
30
|
+
return err('#NUM!');
|
|
31
|
+
const pos = k * (values.length - 1);
|
|
32
|
+
const lo = Math.floor(pos);
|
|
33
|
+
const hi = Math.ceil(pos);
|
|
34
|
+
return values[lo] + (values[hi] - values[lo]) * (pos - lo);
|
|
35
|
+
}
|
|
36
|
+
/** PERCENTILE.EXC: the same idea over n+1 slots, undefined at the ends. */
|
|
37
|
+
function percentileExc(values, k) {
|
|
38
|
+
const n = values.length;
|
|
39
|
+
if (!n || k <= 0 || k >= 1)
|
|
40
|
+
return err('#NUM!');
|
|
41
|
+
const pos = k * (n + 1) - 1;
|
|
42
|
+
if (pos < 0 || pos > n - 1)
|
|
43
|
+
return err('#NUM!');
|
|
44
|
+
const lo = Math.floor(pos);
|
|
45
|
+
const hi = Math.ceil(pos);
|
|
46
|
+
return values[lo] + (values[hi] - values[lo]) * (pos - lo);
|
|
47
|
+
}
|
|
48
|
+
function variance(values, sample) {
|
|
49
|
+
const n = values.length;
|
|
50
|
+
if (n < (sample ? 2 : 1))
|
|
51
|
+
return err('#DIV/0!');
|
|
52
|
+
const mean = values.reduce((x, y) => x + y, 0) / n;
|
|
53
|
+
const ss = values.reduce((acc, v) => acc + (v - mean) ** 2, 0);
|
|
54
|
+
return ss / (sample ? n - 1 : n);
|
|
55
|
+
}
|
|
56
|
+
const stdev = (values, sample) => {
|
|
57
|
+
const v = variance(values, sample);
|
|
58
|
+
return typeof v === 'number' ? Math.sqrt(v) : v;
|
|
59
|
+
};
|
|
60
|
+
/** The (x, y) pairs where both sides are numbers, as Excel pairs its
|
|
61
|
+
* known_y's and known_x's, dropping the rest. */
|
|
62
|
+
function pairs(ys, xs) {
|
|
63
|
+
if (ys.length !== xs.length)
|
|
64
|
+
return null;
|
|
65
|
+
const out = [];
|
|
66
|
+
for (let i = 0; i < ys.length; i += 1) {
|
|
67
|
+
const y = ys[i];
|
|
68
|
+
const x = xs[i];
|
|
69
|
+
if (typeof y === 'number' && typeof x === 'number')
|
|
70
|
+
out.push([x, y]);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
const isLine = (r) => typeof r === 'object' && r !== null && 'slope' in r;
|
|
75
|
+
function regression(ys, xs) {
|
|
76
|
+
const p = pairs(ys, xs);
|
|
77
|
+
if (!p)
|
|
78
|
+
return err('#N/A');
|
|
79
|
+
const n = p.length;
|
|
80
|
+
if (n < 2)
|
|
81
|
+
return err('#DIV/0!');
|
|
82
|
+
const mx = p.reduce((s, [x]) => s + x, 0) / n;
|
|
83
|
+
const my = p.reduce((s, [, y]) => s + y, 0) / n;
|
|
84
|
+
let sxx = 0;
|
|
85
|
+
let sxy = 0;
|
|
86
|
+
for (const [x, y] of p) {
|
|
87
|
+
sxx += (x - mx) ** 2;
|
|
88
|
+
sxy += (x - mx) * (y - my);
|
|
89
|
+
}
|
|
90
|
+
if (sxx === 0)
|
|
91
|
+
return err('#DIV/0!');
|
|
92
|
+
const slope = sxy / sxx;
|
|
93
|
+
return { slope, intercept: my - slope * mx };
|
|
94
|
+
}
|
|
95
|
+
function gcd(x, y) {
|
|
96
|
+
let a = Math.abs(x);
|
|
97
|
+
let b = Math.abs(y);
|
|
98
|
+
while (b) {
|
|
99
|
+
const t = a % b;
|
|
100
|
+
a = b;
|
|
101
|
+
b = t;
|
|
102
|
+
}
|
|
103
|
+
return a;
|
|
104
|
+
}
|
|
105
|
+
function ifsAggregate(a, pick) {
|
|
106
|
+
const target = a.args[0] ?? [];
|
|
107
|
+
const hits = multiCriteriaHits(criteriaPairs(a.args, 1)).map((i) => target[i] ?? '');
|
|
108
|
+
return pick(numericOnly(hits));
|
|
109
|
+
}
|
|
110
|
+
function ceilingLegacy(number, significance) {
|
|
111
|
+
if (significance === 0)
|
|
112
|
+
return 0;
|
|
113
|
+
if (number > 0 && significance < 0)
|
|
114
|
+
return err('#NUM!');
|
|
115
|
+
return tidy(Math.ceil(snap(number / significance)) * significance);
|
|
116
|
+
}
|
|
117
|
+
function floorLegacy(number, significance) {
|
|
118
|
+
if (significance === 0)
|
|
119
|
+
return err('#DIV/0!');
|
|
120
|
+
if (number > 0 && significance < 0)
|
|
121
|
+
return err('#NUM!');
|
|
122
|
+
return tidy(Math.floor(snap(number / significance)) * significance);
|
|
123
|
+
}
|
|
124
|
+
/** CEILING.MATH / FLOOR.MATH: the sign of `significance` is ignored, and
|
|
125
|
+
* `mode` says which way a negative number goes: toward zero by default for
|
|
126
|
+
* CEILING.MATH and away from it for FLOOR.MATH, the other way when set. */
|
|
127
|
+
function ceilingMath(number, significance, mode) {
|
|
128
|
+
const sig = Math.abs(significance);
|
|
129
|
+
if (sig === 0)
|
|
130
|
+
return 0;
|
|
131
|
+
const q = snap(number / sig);
|
|
132
|
+
const away = number < 0 && mode !== 0;
|
|
133
|
+
return tidy((away ? Math.floor(q) : Math.ceil(q)) * sig);
|
|
134
|
+
}
|
|
135
|
+
function floorMath(number, significance, mode) {
|
|
136
|
+
const sig = Math.abs(significance);
|
|
137
|
+
if (sig === 0)
|
|
138
|
+
return 0;
|
|
139
|
+
const q = snap(number / sig);
|
|
140
|
+
const towardZero = number < 0 && mode !== 0;
|
|
141
|
+
return tidy((towardZero ? Math.ceil(q) : Math.floor(q)) * sig);
|
|
142
|
+
}
|
|
143
|
+
function mode(values) {
|
|
144
|
+
const counts = new Map();
|
|
145
|
+
let best = null;
|
|
146
|
+
let bestCount = 1;
|
|
147
|
+
for (const v of values) {
|
|
148
|
+
const c = (counts.get(v) ?? 0) + 1;
|
|
149
|
+
counts.set(v, c);
|
|
150
|
+
if (c > bestCount) {
|
|
151
|
+
best = v;
|
|
152
|
+
bestCount = c;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return best === null ? err('#N/A') : best;
|
|
156
|
+
}
|
|
157
|
+
function forecast(a) {
|
|
158
|
+
const r = regression(a.args[1] ?? [], a.args[2] ?? []);
|
|
159
|
+
if (!isLine(r))
|
|
160
|
+
return r;
|
|
161
|
+
return r.intercept + r.slope * num(a, 0);
|
|
162
|
+
}
|
|
163
|
+
export const MATH_STATS_FUNCTIONS = {
|
|
164
|
+
// ---- Math ------------------------------------------------------------
|
|
165
|
+
PRODUCT: (a) => numericOnly(a.flat).reduce((x, y) => x * y, 1),
|
|
166
|
+
SUMSQ: (a) => numericOnly(a.flat).reduce((x, y) => x + y * y, 0),
|
|
167
|
+
// SUMPRODUCT: the ranges must be the same shape; a cell that is not a
|
|
168
|
+
// number counts as zero, as in Excel.
|
|
169
|
+
SUMPRODUCT: (a) => {
|
|
170
|
+
const lists = a.args;
|
|
171
|
+
if (!lists.length)
|
|
172
|
+
return 0;
|
|
173
|
+
const n = lists[0].length;
|
|
174
|
+
if (lists.some((l) => l.length !== n))
|
|
175
|
+
return err('#VALUE!');
|
|
176
|
+
let total = 0;
|
|
177
|
+
for (let i = 0; i < n; i += 1) {
|
|
178
|
+
let product = 1;
|
|
179
|
+
for (const l of lists) {
|
|
180
|
+
const v = l[i];
|
|
181
|
+
product *= typeof v === 'number' ? v : 0;
|
|
182
|
+
}
|
|
183
|
+
total += product;
|
|
184
|
+
}
|
|
185
|
+
return total;
|
|
186
|
+
},
|
|
187
|
+
CEILING: (a) => ceilingLegacy(num(a, 0), num(a, 1)),
|
|
188
|
+
'CEILING.MATH': (a) => ceilingMath(num(a, 0), opt(a, 1, 1), opt(a, 2, 0)),
|
|
189
|
+
FLOOR: (a) => floorLegacy(num(a, 0), num(a, 1)),
|
|
190
|
+
'FLOOR.MATH': (a) => floorMath(num(a, 0), opt(a, 1, 1), opt(a, 2, 0)),
|
|
191
|
+
MROUND: (a) => {
|
|
192
|
+
const n = num(a, 0);
|
|
193
|
+
const m = num(a, 1);
|
|
194
|
+
if (m === 0)
|
|
195
|
+
return 0;
|
|
196
|
+
if ((n > 0 && m < 0) || (n < 0 && m > 0))
|
|
197
|
+
return err('#NUM!');
|
|
198
|
+
return tidy(roundHalfAway(snap(n / m)) * m);
|
|
199
|
+
},
|
|
200
|
+
TRUNC: (a) => {
|
|
201
|
+
const digits = Math.trunc(opt(a, 1, 0));
|
|
202
|
+
const f = Math.pow(10, digits);
|
|
203
|
+
return tidy(Math.trunc(snap(num(a, 0) * f)) / f);
|
|
204
|
+
},
|
|
205
|
+
LOG: (a) => {
|
|
206
|
+
const n = num(a, 0);
|
|
207
|
+
const base = opt(a, 1, 10);
|
|
208
|
+
if (n <= 0 || base <= 0)
|
|
209
|
+
return err('#NUM!');
|
|
210
|
+
if (base === 1)
|
|
211
|
+
return err('#DIV/0!');
|
|
212
|
+
return tidy(Math.log(n) / Math.log(base));
|
|
213
|
+
},
|
|
214
|
+
LOG10: (a) => {
|
|
215
|
+
const n = num(a, 0);
|
|
216
|
+
return n <= 0 ? err('#NUM!') : Math.log10(n);
|
|
217
|
+
},
|
|
218
|
+
LN: (a) => {
|
|
219
|
+
const n = num(a, 0);
|
|
220
|
+
return n <= 0 ? err('#NUM!') : Math.log(n);
|
|
221
|
+
},
|
|
222
|
+
EXP: (a) => Math.exp(num(a, 0)),
|
|
223
|
+
PI: () => Math.PI,
|
|
224
|
+
RAND: () => Math.random(),
|
|
225
|
+
RANDBETWEEN: (a) => {
|
|
226
|
+
const lo = Math.ceil(num(a, 0));
|
|
227
|
+
const hi = Math.floor(num(a, 1));
|
|
228
|
+
if (lo > hi)
|
|
229
|
+
return err('#NUM!');
|
|
230
|
+
return lo + Math.floor(Math.random() * (hi - lo + 1));
|
|
231
|
+
},
|
|
232
|
+
SIGN: (a) => Math.sign(num(a, 0)),
|
|
233
|
+
// EVEN and ODD round away from zero to the next even or odd integer.
|
|
234
|
+
EVEN: (a) => {
|
|
235
|
+
const n = num(a, 0);
|
|
236
|
+
if (n === 0)
|
|
237
|
+
return 0;
|
|
238
|
+
const up = Math.ceil(Math.abs(n));
|
|
239
|
+
return Math.sign(n) * (up % 2 === 0 ? up : up + 1);
|
|
240
|
+
},
|
|
241
|
+
ODD: (a) => {
|
|
242
|
+
const n = num(a, 0);
|
|
243
|
+
if (n === 0)
|
|
244
|
+
return 1;
|
|
245
|
+
const up = Math.ceil(Math.abs(n));
|
|
246
|
+
return Math.sign(n) * (up % 2 === 1 ? up : up + 1);
|
|
247
|
+
},
|
|
248
|
+
QUOTIENT: (a) => {
|
|
249
|
+
const d = num(a, 1);
|
|
250
|
+
return d === 0 ? err('#DIV/0!') : Math.trunc(num(a, 0) / d);
|
|
251
|
+
},
|
|
252
|
+
GCD: (a) => {
|
|
253
|
+
const ns = numericOnly(a.flat).map(Math.trunc);
|
|
254
|
+
if (ns.some((n) => n < 0))
|
|
255
|
+
return err('#NUM!');
|
|
256
|
+
return ns.reduce((x, y) => gcd(x, y), 0);
|
|
257
|
+
},
|
|
258
|
+
LCM: (a) => {
|
|
259
|
+
const ns = numericOnly(a.flat).map(Math.trunc);
|
|
260
|
+
if (ns.some((n) => n < 0))
|
|
261
|
+
return err('#NUM!');
|
|
262
|
+
if (ns.some((n) => n === 0))
|
|
263
|
+
return 0;
|
|
264
|
+
return ns.reduce((x, y) => (x * y) / gcd(x, y), 1);
|
|
265
|
+
},
|
|
266
|
+
FACT: (a) => {
|
|
267
|
+
const n = Math.trunc(num(a, 0));
|
|
268
|
+
if (n < 0 || n > 170)
|
|
269
|
+
return err('#NUM!');
|
|
270
|
+
let out = 1;
|
|
271
|
+
for (let i = 2; i <= n; i += 1)
|
|
272
|
+
out *= i;
|
|
273
|
+
return out;
|
|
274
|
+
},
|
|
275
|
+
ISEVEN: (a) => Math.trunc(num(a, 0)) % 2 === 0,
|
|
276
|
+
ISODD: (a) => Math.trunc(num(a, 0)) % 2 !== 0,
|
|
277
|
+
// ---- Statistics ------------------------------------------------------
|
|
278
|
+
LARGE: (a) => {
|
|
279
|
+
const values = sorted(a.args[0] ?? []);
|
|
280
|
+
const k = Math.trunc(num(a, 1));
|
|
281
|
+
if (k < 1 || k > values.length)
|
|
282
|
+
return err('#NUM!');
|
|
283
|
+
return values[values.length - k];
|
|
284
|
+
},
|
|
285
|
+
SMALL: (a) => {
|
|
286
|
+
const values = sorted(a.args[0] ?? []);
|
|
287
|
+
const k = Math.trunc(num(a, 1));
|
|
288
|
+
if (k < 1 || k > values.length)
|
|
289
|
+
return err('#NUM!');
|
|
290
|
+
return values[k - 1];
|
|
291
|
+
},
|
|
292
|
+
PERCENTILE: (a) => percentileInc(sorted(a.args[0] ?? []), num(a, 1)),
|
|
293
|
+
'PERCENTILE.INC': (a) => percentileInc(sorted(a.args[0] ?? []), num(a, 1)),
|
|
294
|
+
'PERCENTILE.EXC': (a) => percentileExc(sorted(a.args[0] ?? []), num(a, 1)),
|
|
295
|
+
QUARTILE: (a) => {
|
|
296
|
+
const q = Math.trunc(num(a, 1));
|
|
297
|
+
return q < 0 || q > 4 ? err('#NUM!') : percentileInc(sorted(a.args[0] ?? []), q / 4);
|
|
298
|
+
},
|
|
299
|
+
'QUARTILE.INC': (a) => {
|
|
300
|
+
const q = Math.trunc(num(a, 1));
|
|
301
|
+
return q < 0 || q > 4 ? err('#NUM!') : percentileInc(sorted(a.args[0] ?? []), q / 4);
|
|
302
|
+
},
|
|
303
|
+
'QUARTILE.EXC': (a) => {
|
|
304
|
+
const q = Math.trunc(num(a, 1));
|
|
305
|
+
return q < 1 || q > 3 ? err('#NUM!') : percentileExc(sorted(a.args[0] ?? []), q / 4);
|
|
306
|
+
},
|
|
307
|
+
VAR: (a) => variance(numericOnly(a.flat), true),
|
|
308
|
+
'VAR.S': (a) => variance(numericOnly(a.flat), true),
|
|
309
|
+
'VAR.P': (a) => variance(numericOnly(a.flat), false),
|
|
310
|
+
VARP: (a) => variance(numericOnly(a.flat), false),
|
|
311
|
+
'STDEV.S': (a) => stdev(numericOnly(a.flat), true),
|
|
312
|
+
'STDEV.P': (a) => stdev(numericOnly(a.flat), false),
|
|
313
|
+
STDEVP: (a) => stdev(numericOnly(a.flat), false),
|
|
314
|
+
// MODE: the most frequent number, the first one at that count when tied;
|
|
315
|
+
// #N/A when nothing repeats, as Excel gives.
|
|
316
|
+
MODE: (a) => mode(numericOnly(a.flat)),
|
|
317
|
+
'MODE.SNGL': (a) => mode(numericOnly(a.flat)),
|
|
318
|
+
GEOMEAN: (a) => {
|
|
319
|
+
const values = numericOnly(a.flat);
|
|
320
|
+
if (!values.length || values.some((v) => v <= 0))
|
|
321
|
+
return err('#NUM!');
|
|
322
|
+
return Math.exp(values.reduce((s, v) => s + Math.log(v), 0) / values.length);
|
|
323
|
+
},
|
|
324
|
+
AVERAGEIFS: (a) => ifsAggregate(a, (ns) => (ns.length ? ns.reduce((x, y) => x + y, 0) / ns.length : err('#DIV/0!'))),
|
|
325
|
+
MAXIFS: (a) => ifsAggregate(a, (ns) => (ns.length ? Math.max(...ns) : 0)),
|
|
326
|
+
MINIFS: (a) => ifsAggregate(a, (ns) => (ns.length ? Math.min(...ns) : 0)),
|
|
327
|
+
CORREL: (a) => {
|
|
328
|
+
const p = pairs(a.args[0] ?? [], a.args[1] ?? []);
|
|
329
|
+
if (!p)
|
|
330
|
+
return err('#N/A');
|
|
331
|
+
const n = p.length;
|
|
332
|
+
if (n < 2)
|
|
333
|
+
return err('#DIV/0!');
|
|
334
|
+
const mx = p.reduce((s, [x]) => s + x, 0) / n;
|
|
335
|
+
const my = p.reduce((s, [, y]) => s + y, 0) / n;
|
|
336
|
+
let sxx = 0;
|
|
337
|
+
let syy = 0;
|
|
338
|
+
let sxy = 0;
|
|
339
|
+
for (const [x, y] of p) {
|
|
340
|
+
sxx += (x - mx) ** 2;
|
|
341
|
+
syy += (y - my) ** 2;
|
|
342
|
+
sxy += (x - mx) * (y - my);
|
|
343
|
+
}
|
|
344
|
+
if (sxx === 0 || syy === 0)
|
|
345
|
+
return err('#DIV/0!');
|
|
346
|
+
return sxy / Math.sqrt(sxx * syy);
|
|
347
|
+
},
|
|
348
|
+
SLOPE: (a) => {
|
|
349
|
+
const r = regression(a.args[0] ?? [], a.args[1] ?? []);
|
|
350
|
+
return isLine(r) ? r.slope : r;
|
|
351
|
+
},
|
|
352
|
+
INTERCEPT: (a) => {
|
|
353
|
+
const r = regression(a.args[0] ?? [], a.args[1] ?? []);
|
|
354
|
+
return isLine(r) ? r.intercept : r;
|
|
355
|
+
},
|
|
356
|
+
// FORECAST(x, known_y's, known_x's): the line through the pairs, read at x.
|
|
357
|
+
FORECAST: forecast,
|
|
358
|
+
'FORECAST.LINEAR': forecast,
|
|
359
|
+
// ---- Reference -------------------------------------------------------
|
|
360
|
+
CHOOSE: (a) => {
|
|
361
|
+
const index = Math.trunc(num(a, 0));
|
|
362
|
+
if (index < 1 || index >= a.args.length)
|
|
363
|
+
return err('#VALUE!');
|
|
364
|
+
return a.args[index][0] ?? '';
|
|
365
|
+
},
|
|
366
|
+
ROWS: (a) => a.grids[0]?.length ?? 1,
|
|
367
|
+
COLUMNS: (a) => a.grids[0]?.[0]?.length ?? 1,
|
|
368
|
+
ISNONTEXT: (a) => {
|
|
369
|
+
const v = a.flat[0] ?? '';
|
|
370
|
+
return typeof v !== 'string' || v === '';
|
|
371
|
+
},
|
|
372
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The special functions every statistical distribution is built out of:
|
|
3
|
+
* the log gamma, the two regularised incomplete integrals, and the error
|
|
4
|
+
* function that falls out of the first of them.
|
|
5
|
+
*
|
|
6
|
+
* Not exported from the package. Distributions call these; nothing else
|
|
7
|
+
* should need them.
|
|
8
|
+
*
|
|
9
|
+
* Accuracy is the point here rather than speed. A spreadsheet evaluates one
|
|
10
|
+
* of these per cell, not per frame, and a model that disagrees with Excel
|
|
11
|
+
* in the fourth decimal is a support ticket. Every routine below iterates
|
|
12
|
+
* to a relative tolerance well inside the fifteen digits a double carries,
|
|
13
|
+
* so the answers round to Excel's published examples.
|
|
14
|
+
*/
|
|
15
|
+
/** log(gamma(x)) for x > 0. Reflection carries the negative half. */
|
|
16
|
+
export declare function lgamma(x: number): number;
|
|
17
|
+
/** gamma(x) itself, sign included, for the places Excel exposes it. */
|
|
18
|
+
export declare function gammaFn(x: number): number;
|
|
19
|
+
/** The regularised lower incomplete gamma, P(a, x), in [0, 1]. */
|
|
20
|
+
export declare function gammaP(a: number, x: number): number;
|
|
21
|
+
/** The regularised upper incomplete gamma, Q(a, x) = 1 - P(a, x). */
|
|
22
|
+
export declare function gammaQ(a: number, x: number): number;
|
|
23
|
+
/** The regularised incomplete beta, I_x(a, b), in [0, 1]. */
|
|
24
|
+
export declare function betaI(a: number, b: number, x: number): number;
|
|
25
|
+
/** The error function, which is P(1/2, x^2) carrying x's sign. */
|
|
26
|
+
export declare function erf(x: number): number;
|
|
27
|
+
/** The complementary error function, taken from Q where that is the
|
|
28
|
+
* accurate half, so erfc(20) does not cancel to zero. */
|
|
29
|
+
export declare function erfc(x: number): number;
|
|
30
|
+
/** The standard normal's cumulative distribution. */
|
|
31
|
+
export declare function normalCdf(z: number): number;
|
|
32
|
+
/** The standard normal's density. */
|
|
33
|
+
export declare function normalPdf(z: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Invert a cumulative distribution by bisection over a bracket that is
|
|
36
|
+
* widened until it holds the answer.
|
|
37
|
+
*
|
|
38
|
+
* Bisection rather than Newton on purpose: every distribution here is
|
|
39
|
+
* monotone in x, so bisection cannot diverge, and fifty rounds already
|
|
40
|
+
* carries more digits than a spreadsheet shows. A Newton step would be
|
|
41
|
+
* quicker and would need a derivative per distribution and a fallback for
|
|
42
|
+
* the flat tails, which is three ways to be subtly wrong for no gain.
|
|
43
|
+
*/
|
|
44
|
+
export declare function invertCdf(cdf: (x: number) => number, p: number, lo: number, hi: number): number;
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The special functions every statistical distribution is built out of:
|
|
3
|
+
* the log gamma, the two regularised incomplete integrals, and the error
|
|
4
|
+
* function that falls out of the first of them.
|
|
5
|
+
*
|
|
6
|
+
* Not exported from the package. Distributions call these; nothing else
|
|
7
|
+
* should need them.
|
|
8
|
+
*
|
|
9
|
+
* Accuracy is the point here rather than speed. A spreadsheet evaluates one
|
|
10
|
+
* of these per cell, not per frame, and a model that disagrees with Excel
|
|
11
|
+
* in the fourth decimal is a support ticket. Every routine below iterates
|
|
12
|
+
* to a relative tolerance well inside the fifteen digits a double carries,
|
|
13
|
+
* so the answers round to Excel's published examples.
|
|
14
|
+
*/
|
|
15
|
+
/** Lanczos g = 7, n = 9. Good to about fifteen digits over the half plane. */
|
|
16
|
+
const LANCZOS = [
|
|
17
|
+
0.99999999999980993, 676.5203681218851, -1259.1392167224028,
|
|
18
|
+
771.32342877765313, -176.61502916214059, 12.507343278686905,
|
|
19
|
+
-0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7,
|
|
20
|
+
];
|
|
21
|
+
/** log(gamma(x)) for x > 0. Reflection carries the negative half. */
|
|
22
|
+
export function lgamma(x) {
|
|
23
|
+
if (x < 0.5) {
|
|
24
|
+
// Reflection: gamma(x) gamma(1-x) = pi / sin(pi x)
|
|
25
|
+
return Math.log(Math.PI / Math.abs(Math.sin(Math.PI * x))) - lgamma(1 - x);
|
|
26
|
+
}
|
|
27
|
+
const z = x - 1;
|
|
28
|
+
let a = LANCZOS[0];
|
|
29
|
+
const t = z + 7.5;
|
|
30
|
+
for (let i = 1; i < 9; i += 1)
|
|
31
|
+
a += LANCZOS[i] / (z + i);
|
|
32
|
+
return 0.5 * Math.log(2 * Math.PI) + (z + 0.5) * Math.log(t) - t + Math.log(a);
|
|
33
|
+
}
|
|
34
|
+
/** gamma(x) itself, sign included, for the places Excel exposes it. */
|
|
35
|
+
export function gammaFn(x) {
|
|
36
|
+
if (x < 0.5)
|
|
37
|
+
return Math.PI / (Math.sin(Math.PI * x) * gammaFn(1 - x));
|
|
38
|
+
return Math.exp(lgamma(x));
|
|
39
|
+
}
|
|
40
|
+
const ITMAX = 300;
|
|
41
|
+
const EPS = 1e-15;
|
|
42
|
+
const FPMIN = 1e-300;
|
|
43
|
+
/** P(a, x) by its series, which converges quickly while x < a + 1. */
|
|
44
|
+
function gammaSeries(a, x) {
|
|
45
|
+
let ap = a;
|
|
46
|
+
let sum = 1 / a;
|
|
47
|
+
let del = sum;
|
|
48
|
+
for (let n = 0; n < ITMAX; n += 1) {
|
|
49
|
+
ap += 1;
|
|
50
|
+
del *= x / ap;
|
|
51
|
+
sum += del;
|
|
52
|
+
if (Math.abs(del) < Math.abs(sum) * EPS)
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return sum * Math.exp(-x + a * Math.log(x) - lgamma(a));
|
|
56
|
+
}
|
|
57
|
+
/** Q(a, x) by its continued fraction, which takes over once x >= a + 1. */
|
|
58
|
+
function gammaContinued(a, x) {
|
|
59
|
+
let b = x + 1 - a;
|
|
60
|
+
let c = 1 / FPMIN;
|
|
61
|
+
let d = 1 / b;
|
|
62
|
+
let h = d;
|
|
63
|
+
for (let i = 1; i <= ITMAX; i += 1) {
|
|
64
|
+
const an = -i * (i - a);
|
|
65
|
+
b += 2;
|
|
66
|
+
d = an * d + b;
|
|
67
|
+
if (Math.abs(d) < FPMIN)
|
|
68
|
+
d = FPMIN;
|
|
69
|
+
c = b + an / c;
|
|
70
|
+
if (Math.abs(c) < FPMIN)
|
|
71
|
+
c = FPMIN;
|
|
72
|
+
d = 1 / d;
|
|
73
|
+
const del = d * c;
|
|
74
|
+
h *= del;
|
|
75
|
+
if (Math.abs(del - 1) < EPS)
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
return Math.exp(-x + a * Math.log(x) - lgamma(a)) * h;
|
|
79
|
+
}
|
|
80
|
+
/** The regularised lower incomplete gamma, P(a, x), in [0, 1]. */
|
|
81
|
+
export function gammaP(a, x) {
|
|
82
|
+
if (x <= 0 || a <= 0)
|
|
83
|
+
return 0;
|
|
84
|
+
return x < a + 1 ? gammaSeries(a, x) : 1 - gammaContinued(a, x);
|
|
85
|
+
}
|
|
86
|
+
/** The regularised upper incomplete gamma, Q(a, x) = 1 - P(a, x). */
|
|
87
|
+
export function gammaQ(a, x) {
|
|
88
|
+
if (x <= 0 || a <= 0)
|
|
89
|
+
return 1;
|
|
90
|
+
return x < a + 1 ? 1 - gammaSeries(a, x) : gammaContinued(a, x);
|
|
91
|
+
}
|
|
92
|
+
/** The continued fraction behind the incomplete beta, by Lentz's method. */
|
|
93
|
+
function betaContinued(a, b, x) {
|
|
94
|
+
const qab = a + b;
|
|
95
|
+
const qap = a + 1;
|
|
96
|
+
const qam = a - 1;
|
|
97
|
+
let c = 1;
|
|
98
|
+
let d = 1 - (qab * x) / qap;
|
|
99
|
+
if (Math.abs(d) < FPMIN)
|
|
100
|
+
d = FPMIN;
|
|
101
|
+
d = 1 / d;
|
|
102
|
+
let h = d;
|
|
103
|
+
for (let m = 1; m <= ITMAX; m += 1) {
|
|
104
|
+
const m2 = 2 * m;
|
|
105
|
+
let aa = (m * (b - m) * x) / ((qam + m2) * (a + m2));
|
|
106
|
+
d = 1 + aa * d;
|
|
107
|
+
if (Math.abs(d) < FPMIN)
|
|
108
|
+
d = FPMIN;
|
|
109
|
+
c = 1 + aa / c;
|
|
110
|
+
if (Math.abs(c) < FPMIN)
|
|
111
|
+
c = FPMIN;
|
|
112
|
+
d = 1 / d;
|
|
113
|
+
h *= d * c;
|
|
114
|
+
aa = (-(a + m) * (qab + m) * x) / ((a + m2) * (qap + m2));
|
|
115
|
+
d = 1 + aa * d;
|
|
116
|
+
if (Math.abs(d) < FPMIN)
|
|
117
|
+
d = FPMIN;
|
|
118
|
+
c = 1 + aa / c;
|
|
119
|
+
if (Math.abs(c) < FPMIN)
|
|
120
|
+
c = FPMIN;
|
|
121
|
+
d = 1 / d;
|
|
122
|
+
const del = d * c;
|
|
123
|
+
h *= del;
|
|
124
|
+
if (Math.abs(del - 1) < EPS)
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
return h;
|
|
128
|
+
}
|
|
129
|
+
/** The regularised incomplete beta, I_x(a, b), in [0, 1]. */
|
|
130
|
+
export function betaI(a, b, x) {
|
|
131
|
+
if (x <= 0)
|
|
132
|
+
return 0;
|
|
133
|
+
if (x >= 1)
|
|
134
|
+
return 1;
|
|
135
|
+
const front = Math.exp(lgamma(a + b) - lgamma(a) - lgamma(b) + a * Math.log(x) + b * Math.log(1 - x));
|
|
136
|
+
// The fraction converges fast on one side of the mode only; past it the
|
|
137
|
+
// symmetry I_x(a, b) = 1 - I_(1-x)(b, a) puts us back on the fast side.
|
|
138
|
+
return x < (a + 1) / (a + b + 2)
|
|
139
|
+
? (front * betaContinued(a, b, x)) / a
|
|
140
|
+
: 1 - (front * betaContinued(b, a, 1 - x)) / b;
|
|
141
|
+
}
|
|
142
|
+
/** The error function, which is P(1/2, x^2) carrying x's sign. */
|
|
143
|
+
export function erf(x) {
|
|
144
|
+
return x < 0 ? -gammaP(0.5, x * x) : gammaP(0.5, x * x);
|
|
145
|
+
}
|
|
146
|
+
/** The complementary error function, taken from Q where that is the
|
|
147
|
+
* accurate half, so erfc(20) does not cancel to zero. */
|
|
148
|
+
export function erfc(x) {
|
|
149
|
+
return x < 0 ? 1 + gammaP(0.5, x * x) : gammaQ(0.5, x * x);
|
|
150
|
+
}
|
|
151
|
+
/** The standard normal's cumulative distribution. */
|
|
152
|
+
export function normalCdf(z) {
|
|
153
|
+
return 0.5 * erfc(-z / Math.SQRT2);
|
|
154
|
+
}
|
|
155
|
+
/** The standard normal's density. */
|
|
156
|
+
export function normalPdf(z) {
|
|
157
|
+
return Math.exp((-z * z) / 2) / Math.sqrt(2 * Math.PI);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Invert a cumulative distribution by bisection over a bracket that is
|
|
161
|
+
* widened until it holds the answer.
|
|
162
|
+
*
|
|
163
|
+
* Bisection rather than Newton on purpose: every distribution here is
|
|
164
|
+
* monotone in x, so bisection cannot diverge, and fifty rounds already
|
|
165
|
+
* carries more digits than a spreadsheet shows. A Newton step would be
|
|
166
|
+
* quicker and would need a derivative per distribution and a fallback for
|
|
167
|
+
* the flat tails, which is three ways to be subtly wrong for no gain.
|
|
168
|
+
*/
|
|
169
|
+
export function invertCdf(cdf, p, lo, hi) {
|
|
170
|
+
let a = lo;
|
|
171
|
+
let b = hi;
|
|
172
|
+
// Widen, in case the caller's bracket was optimistic.
|
|
173
|
+
for (let i = 0; i < 200 && cdf(b) < p; i += 1)
|
|
174
|
+
b = b === 0 ? 1 : b * 2;
|
|
175
|
+
for (let i = 0; i < 200 && cdf(a) > p; i += 1)
|
|
176
|
+
a = a === 0 ? -1 : a * 2;
|
|
177
|
+
for (let i = 0; i < 200; i += 1) {
|
|
178
|
+
const mid = (a + b) / 2;
|
|
179
|
+
if (b - a < Math.abs(mid) * 1e-14 + 1e-300)
|
|
180
|
+
return mid;
|
|
181
|
+
if (cdf(mid) < p)
|
|
182
|
+
a = mid;
|
|
183
|
+
else
|
|
184
|
+
b = mid;
|
|
185
|
+
}
|
|
186
|
+
return (a + b) / 2;
|
|
187
|
+
}
|