@abraca/nuxt 1.8.2 → 2.0.0
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/README.md +27 -2
- package/dist/module.d.mts +4 -3
- package/dist/module.json +1 -1
- package/dist/module.mjs +50 -4
- package/dist/runtime/components/ADocumentTree.vue +1 -1
- package/dist/runtime/components/AEditor.d.vue.ts +26 -1
- package/dist/runtime/components/AEditor.vue +153 -4
- package/dist/runtime/components/AEditor.vue.d.ts +26 -1
- package/dist/runtime/components/AIdentityModal.d.vue.ts +46 -0
- package/dist/runtime/components/AIdentityModal.vue +157 -0
- package/dist/runtime/components/AIdentityModal.vue.d.ts +46 -0
- package/dist/runtime/components/AMnemonicLoginModal.d.vue.ts +35 -0
- package/dist/runtime/components/AMnemonicLoginModal.vue +173 -0
- package/dist/runtime/components/AMnemonicLoginModal.vue.d.ts +35 -0
- package/dist/runtime/components/ANodePanel.d.vue.ts +29 -2
- package/dist/runtime/components/ANodePanel.vue +148 -27
- package/dist/runtime/components/ANodePanel.vue.d.ts +29 -2
- package/dist/runtime/components/ANodePanelHeader.d.vue.ts +64 -0
- package/dist/runtime/components/ANodePanelHeader.vue +105 -0
- package/dist/runtime/components/ANodePanelHeader.vue.d.ts +64 -0
- package/dist/runtime/components/ANodeSettingsPanel.d.vue.ts +49 -0
- package/dist/runtime/components/ANodeSettingsPanel.vue +59 -0
- package/dist/runtime/components/ANodeSettingsPanel.vue.d.ts +49 -0
- package/dist/runtime/components/ANotificationBell.d.vue.ts +26 -0
- package/dist/runtime/components/ANotificationBell.vue +55 -0
- package/dist/runtime/components/ANotificationBell.vue.d.ts +26 -0
- package/dist/runtime/components/AOfflineSync.d.vue.ts +11 -0
- package/dist/runtime/components/AOfflineSync.vue +217 -0
- package/dist/runtime/components/AOfflineSync.vue.d.ts +11 -0
- package/dist/runtime/components/ARecoveryPhraseDisplay.d.vue.ts +26 -0
- package/dist/runtime/components/ARecoveryPhraseDisplay.vue +94 -0
- package/dist/runtime/components/ARecoveryPhraseDisplay.vue.d.ts +26 -0
- package/dist/runtime/components/AServerInfoModal.d.vue.ts +43 -0
- package/dist/runtime/components/AServerInfoModal.vue +150 -0
- package/dist/runtime/components/AServerInfoModal.vue.d.ts +43 -0
- package/dist/runtime/components/ASpaceFormModal.vue +1 -1
- package/dist/runtime/components/aware/AAccordion.d.vue.ts +25 -0
- package/dist/runtime/components/aware/AAccordion.vue +107 -0
- package/dist/runtime/components/aware/AAccordion.vue.d.ts +25 -0
- package/dist/runtime/components/aware/AArea.vue +24 -11
- package/dist/runtime/components/aware/AAvatar.d.vue.ts +6 -0
- package/dist/runtime/components/aware/AAvatar.vue +33 -3
- package/dist/runtime/components/aware/AAvatar.vue.d.ts +6 -0
- package/dist/runtime/components/aware/AAvatarGroup.d.vue.ts +10 -0
- package/dist/runtime/components/aware/AAvatarGroup.vue +30 -0
- package/dist/runtime/components/aware/AAvatarGroup.vue.d.ts +10 -0
- package/dist/runtime/components/aware/AButton.d.vue.ts +4 -2
- package/dist/runtime/components/aware/AButton.vue +46 -14
- package/dist/runtime/components/aware/AButton.vue.d.ts +4 -2
- package/dist/runtime/components/aware/ACalendar.d.vue.ts +17 -0
- package/dist/runtime/components/aware/ACalendar.vue +145 -0
- package/dist/runtime/components/aware/ACalendar.vue.d.ts +17 -0
- package/dist/runtime/components/aware/ACarousel.d.vue.ts +25 -0
- package/dist/runtime/components/aware/ACarousel.vue +39 -0
- package/dist/runtime/components/aware/ACarousel.vue.d.ts +25 -0
- package/dist/runtime/components/aware/ACheckbox.d.vue.ts +11 -0
- package/dist/runtime/components/aware/ACheckbox.vue +74 -0
- package/dist/runtime/components/aware/ACheckbox.vue.d.ts +11 -0
- package/dist/runtime/components/aware/ACheckboxGroup.d.vue.ts +27 -0
- package/dist/runtime/components/aware/ACheckboxGroup.vue +79 -0
- package/dist/runtime/components/aware/ACheckboxGroup.vue.d.ts +27 -0
- package/dist/runtime/components/aware/ACollapsible.d.vue.ts +25 -0
- package/dist/runtime/components/aware/ACollapsible.vue +45 -0
- package/dist/runtime/components/aware/ACollapsible.vue.d.ts +25 -0
- package/dist/runtime/components/aware/AColorPicker.d.vue.ts +15 -0
- package/dist/runtime/components/aware/AColorPicker.vue +48 -0
- package/dist/runtime/components/aware/AColorPicker.vue.d.ts +15 -0
- package/dist/runtime/components/aware/ACommandPalette.d.vue.ts +33 -0
- package/dist/runtime/components/aware/ACommandPalette.vue +123 -0
- package/dist/runtime/components/aware/ACommandPalette.vue.d.ts +33 -0
- package/dist/runtime/components/aware/AContextMenu.d.vue.ts +25 -0
- package/dist/runtime/components/aware/AContextMenu.vue +63 -0
- package/dist/runtime/components/aware/AContextMenu.vue.d.ts +25 -0
- package/dist/runtime/components/aware/ADrawer.d.vue.ts +25 -0
- package/dist/runtime/components/aware/ADrawer.vue +57 -0
- package/dist/runtime/components/aware/ADrawer.vue.d.ts +25 -0
- package/dist/runtime/components/aware/ADropdownMenu.d.vue.ts +25 -0
- package/dist/runtime/components/aware/ADropdownMenu.vue +63 -0
- package/dist/runtime/components/aware/ADropdownMenu.vue.d.ts +25 -0
- package/dist/runtime/components/aware/AFileUpload.d.vue.ts +27 -0
- package/dist/runtime/components/aware/AFileUpload.vue +67 -0
- package/dist/runtime/components/aware/AFileUpload.vue.d.ts +27 -0
- package/dist/runtime/components/aware/AFollowBar.d.vue.ts +21 -0
- package/dist/runtime/components/aware/AFollowBar.vue +62 -0
- package/dist/runtime/components/aware/AFollowBar.vue.d.ts +21 -0
- package/dist/runtime/components/aware/AFollowScroll.d.vue.ts +7 -0
- package/dist/runtime/components/aware/AFollowScroll.vue +17 -0
- package/dist/runtime/components/aware/AFollowScroll.vue.d.ts +7 -0
- package/dist/runtime/components/aware/AFormSync.d.vue.ts +21 -0
- package/dist/runtime/components/aware/AFormSync.vue +52 -0
- package/dist/runtime/components/aware/AFormSync.vue.d.ts +21 -0
- package/dist/runtime/components/aware/AGlobalFocusLayer.d.vue.ts +3 -0
- package/dist/runtime/components/aware/AGlobalFocusLayer.vue +90 -0
- package/dist/runtime/components/aware/AGlobalFocusLayer.vue.d.ts +3 -0
- package/dist/runtime/components/aware/AHoverItem.d.vue.ts +27 -0
- package/dist/runtime/components/aware/AHoverItem.vue +124 -0
- package/dist/runtime/components/aware/AHoverItem.vue.d.ts +27 -0
- package/dist/runtime/components/aware/AInput.d.vue.ts +12 -2
- package/dist/runtime/components/aware/AInput.vue +72 -19
- package/dist/runtime/components/aware/AInput.vue.d.ts +12 -2
- package/dist/runtime/components/aware/AInputMenu.d.vue.ts +17 -0
- package/dist/runtime/components/aware/AInputMenu.vue +138 -0
- package/dist/runtime/components/aware/AInputMenu.vue.d.ts +17 -0
- package/dist/runtime/components/aware/AInputNumber.d.vue.ts +15 -0
- package/dist/runtime/components/aware/AInputNumber.vue +67 -0
- package/dist/runtime/components/aware/AInputNumber.vue.d.ts +15 -0
- package/dist/runtime/components/aware/AInputTags.d.vue.ts +15 -0
- package/dist/runtime/components/aware/AInputTags.vue +67 -0
- package/dist/runtime/components/aware/AInputTags.vue.d.ts +15 -0
- package/dist/runtime/components/aware/AKeyHint.d.vue.ts +3 -0
- package/dist/runtime/components/aware/AKeyHint.vue +23 -0
- package/dist/runtime/components/aware/AKeyHint.vue.d.ts +3 -0
- package/dist/runtime/components/aware/AMedia.d.vue.ts +19 -0
- package/dist/runtime/components/aware/AMedia.vue +85 -0
- package/dist/runtime/components/aware/AMedia.vue.d.ts +19 -0
- package/dist/runtime/components/aware/AModal.d.vue.ts +33 -0
- package/dist/runtime/components/aware/AModal.vue +110 -0
- package/dist/runtime/components/aware/AModal.vue.d.ts +33 -0
- package/dist/runtime/components/aware/ANavigationMenu.d.vue.ts +25 -0
- package/dist/runtime/components/aware/ANavigationMenu.vue +82 -0
- package/dist/runtime/components/aware/ANavigationMenu.vue.d.ts +25 -0
- package/dist/runtime/components/aware/APagination.d.vue.ts +13 -0
- package/dist/runtime/components/aware/APagination.vue +53 -0
- package/dist/runtime/components/aware/APagination.vue.d.ts +13 -0
- package/dist/runtime/components/aware/APeerCaretLayer.d.vue.ts +10 -0
- package/dist/runtime/components/aware/APeerCaretLayer.vue +133 -0
- package/dist/runtime/components/aware/APeerCaretLayer.vue.d.ts +10 -0
- package/dist/runtime/components/aware/APinInput.d.vue.ts +15 -0
- package/dist/runtime/components/aware/APinInput.vue +48 -0
- package/dist/runtime/components/aware/APinInput.vue.d.ts +15 -0
- package/dist/runtime/components/aware/APopover.d.vue.ts +25 -0
- package/dist/runtime/components/aware/APopover.vue +57 -0
- package/dist/runtime/components/aware/APopover.vue.d.ts +25 -0
- package/dist/runtime/components/aware/APresenceBlobs.d.vue.ts +3 -0
- package/dist/runtime/components/aware/APresenceBlobs.vue +69 -0
- package/dist/runtime/components/aware/APresenceBlobs.vue.d.ts +3 -0
- package/dist/runtime/components/aware/APresenceCursors.d.vue.ts +20 -0
- package/dist/runtime/components/aware/APresenceCursors.vue +47 -0
- package/dist/runtime/components/aware/APresenceCursors.vue.d.ts +20 -0
- package/dist/runtime/components/aware/ARadioGroup.d.vue.ts +27 -0
- package/dist/runtime/components/aware/ARadioGroup.vue +86 -0
- package/dist/runtime/components/aware/ARadioGroup.vue.d.ts +27 -0
- package/dist/runtime/components/aware/AScroll.d.vue.ts +25 -0
- package/dist/runtime/components/aware/AScroll.vue +87 -0
- package/dist/runtime/components/aware/AScroll.vue.d.ts +25 -0
- package/dist/runtime/components/aware/ASelect.d.vue.ts +12 -2
- package/dist/runtime/components/aware/ASelect.vue +146 -22
- package/dist/runtime/components/aware/ASelect.vue.d.ts +12 -2
- package/dist/runtime/components/aware/ASelectMenu.d.vue.ts +17 -0
- package/dist/runtime/components/aware/ASelectMenu.vue +139 -0
- package/dist/runtime/components/aware/ASelectMenu.vue.d.ts +17 -0
- package/dist/runtime/components/aware/ASlideover.d.vue.ts +33 -0
- package/dist/runtime/components/aware/ASlideover.vue +110 -0
- package/dist/runtime/components/aware/ASlideover.vue.d.ts +33 -0
- package/dist/runtime/components/aware/ASlider.d.vue.ts +19 -0
- package/dist/runtime/components/aware/ASlider.vue +77 -0
- package/dist/runtime/components/aware/ASlider.vue.d.ts +19 -0
- package/dist/runtime/components/aware/AStepper.d.vue.ts +25 -0
- package/dist/runtime/components/aware/AStepper.vue +82 -0
- package/dist/runtime/components/aware/AStepper.vue.d.ts +25 -0
- package/dist/runtime/components/aware/ASwitch.d.vue.ts +11 -0
- package/dist/runtime/components/aware/ASwitch.vue +75 -0
- package/dist/runtime/components/aware/ASwitch.vue.d.ts +11 -0
- package/dist/runtime/components/aware/ATable.d.vue.ts +23 -0
- package/dist/runtime/components/aware/ATable.vue +97 -0
- package/dist/runtime/components/aware/ATable.vue.d.ts +23 -0
- package/dist/runtime/components/aware/ATabs.d.vue.ts +27 -0
- package/dist/runtime/components/aware/ATabs.vue +128 -0
- package/dist/runtime/components/aware/ATabs.vue.d.ts +27 -0
- package/dist/runtime/components/aware/ATextarea.d.vue.ts +12 -2
- package/dist/runtime/components/aware/ATextarea.vue +72 -19
- package/dist/runtime/components/aware/ATextarea.vue.d.ts +12 -2
- package/dist/runtime/components/aware/AToggleGroup.d.vue.ts +27 -0
- package/dist/runtime/components/aware/AToggleGroup.vue +79 -0
- package/dist/runtime/components/aware/AToggleGroup.vue.d.ts +27 -0
- package/dist/runtime/components/aware/ATree.d.vue.ts +27 -0
- package/dist/runtime/components/aware/ATree.vue +111 -0
- package/dist/runtime/components/aware/ATree.vue.d.ts +27 -0
- package/dist/runtime/components/chat/AChatPanel.d.vue.ts +6 -6
- package/dist/runtime/components/chat/AChatPanel.vue.d.ts +6 -6
- package/dist/runtime/components/chat/ANodeChatPanel.d.vue.ts +42 -0
- package/dist/runtime/components/chat/ANodeChatPanel.vue +53 -0
- package/dist/runtime/components/chat/ANodeChatPanel.vue.d.ts +42 -0
- package/dist/runtime/components/docs/ADocsNavigation.d.vue.ts +155 -0
- package/dist/runtime/components/docs/ADocsNavigation.vue +154 -0
- package/dist/runtime/components/docs/ADocsNavigation.vue.d.ts +155 -0
- package/dist/runtime/components/docs/ADocsSearch.d.vue.ts +249 -0
- package/dist/runtime/components/docs/ADocsSearch.vue +187 -0
- package/dist/runtime/components/docs/ADocsSearch.vue.d.ts +249 -0
- package/dist/runtime/components/docs/ADocsSearchButton.d.vue.ts +253 -0
- package/dist/runtime/components/docs/ADocsSearchButton.vue +99 -0
- package/dist/runtime/components/docs/ADocsSearchButton.vue.d.ts +253 -0
- package/dist/runtime/components/docs/ADocsSurround.d.vue.ts +56 -0
- package/dist/runtime/components/docs/ADocsSurround.vue +68 -0
- package/dist/runtime/components/docs/ADocsSurround.vue.d.ts +56 -0
- package/dist/runtime/components/docs/ADocsToc.d.vue.ts +117 -0
- package/dist/runtime/components/docs/ADocsToc.vue +194 -0
- package/dist/runtime/components/docs/ADocsToc.vue.d.ts +117 -0
- package/dist/runtime/components/editor/ADocLinkPopover.vue +1 -5
- package/dist/runtime/components/editor/AEditorRedoButton.d.vue.ts +26 -0
- package/dist/runtime/components/editor/AEditorRedoButton.vue +38 -0
- package/dist/runtime/components/editor/AEditorRedoButton.vue.d.ts +26 -0
- package/dist/runtime/components/editor/AEditorUndoButton.d.vue.ts +26 -0
- package/dist/runtime/components/editor/AEditorUndoButton.vue +38 -0
- package/dist/runtime/components/editor/AEditorUndoButton.vue.d.ts +26 -0
- package/dist/runtime/components/editor/AIconPickerPopover.d.vue.ts +24 -0
- package/dist/runtime/components/editor/AIconPickerPopover.vue +113 -0
- package/dist/runtime/components/editor/AIconPickerPopover.vue.d.ts +24 -0
- package/dist/runtime/components/editor/ANodeInlineLabel.d.vue.ts +24 -0
- package/dist/runtime/components/editor/ANodeInlineLabel.vue +101 -0
- package/dist/runtime/components/editor/ANodeInlineLabel.vue.d.ts +24 -0
- package/dist/runtime/components/renderers/ADocLoadError.d.vue.ts +3 -0
- package/dist/runtime/components/renderers/ADocLoadError.vue +11 -0
- package/dist/runtime/components/renderers/ADocLoadError.vue.d.ts +3 -0
- package/dist/runtime/components/renderers/ADocLoadingSkeleton.d.vue.ts +3 -0
- package/dist/runtime/components/renderers/ADocLoadingSkeleton.vue +5 -0
- package/dist/runtime/components/renderers/ADocLoadingSkeleton.vue.d.ts +3 -0
- package/dist/runtime/components/renderers/AMediaRenderer.vue +1 -1
- package/dist/runtime/components/renderers/AOverviewRenderer.d.vue.ts +22 -0
- package/dist/runtime/components/renderers/AOverviewRenderer.vue +1041 -0
- package/dist/runtime/components/renderers/AOverviewRenderer.vue.d.ts +22 -0
- package/dist/runtime/components/renderers/AProseRenderer.d.vue.ts +23 -0
- package/dist/runtime/components/renderers/AProseRenderer.vue +31 -0
- package/dist/runtime/components/renderers/AProseRenderer.vue.d.ts +23 -0
- package/dist/runtime/components/renderers/ASheetsRenderer.client.d.vue.ts +19 -0
- package/dist/runtime/components/renderers/ASheetsRenderer.client.vue +865 -0
- package/dist/runtime/components/renderers/ASheetsRenderer.client.vue.d.ts +19 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.d.vue.ts +14 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue +45 -15
- package/dist/runtime/components/renderers/calendar/ACalendarDayCell.vue.d.ts +14 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayView.d.vue.ts +15 -0
- package/dist/runtime/components/renderers/calendar/ACalendarDayView.vue +93 -20
- package/dist/runtime/components/renderers/calendar/ACalendarDayView.vue.d.ts +15 -0
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.d.vue.ts +9 -0
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue +31 -2
- package/dist/runtime/components/renderers/calendar/ACalendarEventChip.vue.d.ts +9 -0
- package/dist/runtime/components/renderers/calendar/ACalendarToolbar.d.vue.ts +4 -4
- package/dist/runtime/components/renderers/calendar/ACalendarToolbar.vue.d.ts +4 -4
- package/dist/runtime/components/renderers/calendar/ACalendarWeekView.d.vue.ts +15 -0
- package/dist/runtime/components/renderers/calendar/ACalendarWeekView.vue +94 -21
- package/dist/runtime/components/renderers/calendar/ACalendarWeekView.vue.d.ts +15 -0
- package/dist/runtime/components/renderers/media/MediaTransportBar.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/media/MediaTransportBar.vue.d.ts +2 -2
- package/dist/runtime/components/renderers/sheets/ASheetsCell.d.vue.ts +45 -0
- package/dist/runtime/components/renderers/sheets/ASheetsCell.vue +123 -0
- package/dist/runtime/components/renderers/sheets/ASheetsCell.vue.d.ts +45 -0
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.d.vue.ts +111 -0
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue +737 -0
- package/dist/runtime/components/renderers/sheets/ASheetsGrid.vue.d.ts +111 -0
- package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.d.vue.ts +26 -0
- package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.vue +100 -0
- package/dist/runtime/components/renderers/sheets/ASheetsMobileActionBar.vue.d.ts +26 -0
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.d.vue.ts +48 -0
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue +243 -0
- package/dist/runtime/components/renderers/sheets/ASheetsToolbar.vue.d.ts +48 -0
- package/dist/runtime/components/renderers/table/cells/ATableCellColor.d.vue.ts +1 -0
- package/dist/runtime/components/renderers/table/cells/ATableCellColor.vue +13 -32
- package/dist/runtime/components/renderers/table/cells/ATableCellColor.vue.d.ts +1 -0
- package/dist/runtime/components/renderers/timeline/ATimelineBar.d.vue.ts +6 -0
- package/dist/runtime/components/renderers/timeline/ATimelineBar.vue +34 -4
- package/dist/runtime/components/renderers/timeline/ATimelineBar.vue.d.ts +6 -0
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.d.vue.ts +16 -0
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue +14 -3
- package/dist/runtime/components/renderers/timeline/ATimelineBarArea.vue.d.ts +16 -0
- package/dist/runtime/components/renderers/timeline/ATimelineLabelPanel.d.vue.ts +13 -1
- package/dist/runtime/components/renderers/timeline/ATimelineLabelPanel.vue +114 -47
- package/dist/runtime/components/renderers/timeline/ATimelineLabelPanel.vue.d.ts +13 -1
- package/dist/runtime/components/renderers/timeline/ATimelineMilestone.d.vue.ts +4 -0
- package/dist/runtime/components/renderers/timeline/ATimelineMilestone.vue +21 -4
- package/dist/runtime/components/renderers/timeline/ATimelineMilestone.vue.d.ts +4 -0
- package/dist/runtime/components/renderers/timeline/ATimelineToolbar.d.vue.ts +2 -2
- package/dist/runtime/components/renderers/timeline/ATimelineToolbar.vue.d.ts +2 -2
- package/dist/runtime/components/settings/ASettingsSpacesPanel.vue +7 -25
- package/dist/runtime/components/shell/ADocPanelSettings.d.vue.ts +34 -4
- package/dist/runtime/components/shell/ADocPanelSettings.vue +289 -2
- package/dist/runtime/components/shell/ADocPanelSettings.vue.d.ts +34 -4
- package/dist/runtime/components/shell/ASyncStatus.d.vue.ts +1 -1
- package/dist/runtime/components/shell/ASyncStatus.vue.d.ts +1 -1
- package/dist/runtime/components/shell/AUserMenu.d.vue.ts +2 -2
- package/dist/runtime/components/shell/AUserMenu.vue.d.ts +2 -2
- package/dist/runtime/components/shell/AWelcomeScreen.d.vue.ts +1 -1
- package/dist/runtime/components/shell/AWelcomeScreen.vue.d.ts +1 -1
- package/dist/runtime/composables/useAACaret.d.ts +29 -0
- package/dist/runtime/composables/useAACaret.js +64 -0
- package/dist/runtime/composables/useAAEphemeral.d.ts +32 -0
- package/dist/runtime/composables/useAAEphemeral.js +33 -0
- package/dist/runtime/composables/useAAField.d.ts +10 -2
- package/dist/runtime/composables/useAAField.js +31 -2
- package/dist/runtime/composables/useAAFieldValue.d.ts +26 -0
- package/dist/runtime/composables/useAAFieldValue.js +32 -0
- package/dist/runtime/composables/useAAFocus.d.ts +68 -0
- package/dist/runtime/composables/useAAFocus.js +174 -0
- package/dist/runtime/composables/useAAFollowAnchor.d.ts +25 -0
- package/dist/runtime/composables/useAAFollowAnchor.js +69 -0
- package/dist/runtime/composables/useAAFollowPeer.d.ts +29 -0
- package/dist/runtime/composables/useAAFollowPeer.js +75 -0
- package/dist/runtime/composables/useAAKey.d.ts +22 -0
- package/dist/runtime/composables/useAAKey.js +24 -0
- package/dist/runtime/composables/useAAPointer.d.ts +30 -0
- package/dist/runtime/composables/useAAPointer.js +53 -0
- package/dist/runtime/composables/useAAUIState.d.ts +29 -0
- package/dist/runtime/composables/useAAUIState.js +28 -0
- package/dist/runtime/composables/useAAViewport.d.ts +22 -0
- package/dist/runtime/composables/useAAViewport.js +50 -0
- package/dist/runtime/composables/useAbraAdmin.d.ts +54 -0
- package/dist/runtime/composables/useAbraAdmin.js +115 -0
- package/dist/runtime/composables/useAbracadabraAuth.d.ts +8 -0
- package/dist/runtime/composables/useAbracadabraAuth.js +8 -0
- package/dist/runtime/composables/useAggregatedPresence.d.ts +23 -0
- package/dist/runtime/composables/useAggregatedPresence.js +140 -0
- package/dist/runtime/composables/useChat.d.ts +16 -2
- package/dist/runtime/composables/useChat.js +257 -66
- package/dist/runtime/composables/useChatUsers.d.ts +2 -0
- package/dist/runtime/composables/useChatUsers.js +2 -1
- package/dist/runtime/composables/useDocLookup.d.ts +4 -0
- package/dist/runtime/composables/useDocLookup.js +25 -0
- package/dist/runtime/composables/useDocSnapshots.d.ts +79 -0
- package/dist/runtime/composables/useDocSnapshots.js +234 -0
- package/dist/runtime/composables/useDocsSearch.d.ts +24 -0
- package/dist/runtime/composables/useDocsSearch.js +34 -0
- package/dist/runtime/composables/useEditorDragHandle.d.ts +7 -0
- package/dist/runtime/composables/useEditorDragHandle.js +19 -1
- package/dist/runtime/composables/useEditorSuggestions.js +26 -1
- package/dist/runtime/composables/useEditorToolbar.js +9 -1
- package/dist/runtime/composables/useEmailVerification.d.ts +33 -0
- package/dist/runtime/composables/useEmailVerification.js +58 -0
- package/dist/runtime/composables/useIdentityDoc.js +0 -3
- package/dist/runtime/composables/useItemPresence.d.ts +47 -0
- package/dist/runtime/composables/useItemPresence.js +73 -0
- package/dist/runtime/composables/useResizableWidth.d.ts +24 -0
- package/dist/runtime/composables/useResizableWidth.js +87 -0
- package/dist/runtime/composables/useServerInfo.d.ts +17 -2
- package/dist/runtime/composables/useServerInfo.js +30 -6
- package/dist/runtime/composables/useServerSearch.d.ts +36 -0
- package/dist/runtime/composables/useServerSearch.js +91 -0
- package/dist/runtime/composables/useServerTrash.d.ts +67 -0
- package/dist/runtime/composables/useServerTrash.js +128 -0
- package/dist/runtime/composables/useSheetsClipboard.d.ts +42 -0
- package/dist/runtime/composables/useSheetsClipboard.js +109 -0
- package/dist/runtime/composables/useSheetsFormulas.d.ts +38 -0
- package/dist/runtime/composables/useSheetsFormulas.js +725 -0
- package/dist/runtime/composables/useSheetsSelection.d.ts +68 -0
- package/dist/runtime/composables/useSheetsSelection.js +390 -0
- package/dist/runtime/composables/useSheetsView.d.ts +31 -0
- package/dist/runtime/composables/useSheetsView.js +77 -0
- package/dist/runtime/composables/useSpaceConnections.d.ts +43 -0
- package/dist/runtime/composables/useSpaceConnections.js +72 -0
- package/dist/runtime/composables/useSpaces.d.ts +1 -3
- package/dist/runtime/composables/useSpaces.js +2 -5
- package/dist/runtime/composables/useTiptapHistory.d.ts +22 -0
- package/dist/runtime/composables/useTiptapHistory.js +12 -0
- package/dist/runtime/composables/useTreeExpansion.d.ts +28 -0
- package/dist/runtime/composables/useTreeExpansion.js +94 -0
- package/dist/runtime/composables/useYDoc.js +12 -1
- package/dist/runtime/extensions/button.d.ts +3 -0
- package/dist/runtime/extensions/button.js +62 -0
- package/dist/runtime/extensions/color-swatch.d.ts +2 -0
- package/dist/runtime/extensions/color-swatch.js +34 -0
- package/dist/runtime/extensions/diff.d.ts +2 -0
- package/dist/runtime/extensions/diff.js +40 -0
- package/dist/runtime/extensions/divider.d.ts +2 -0
- package/dist/runtime/extensions/divider.js +33 -0
- package/dist/runtime/extensions/doc-embed.js +2 -1
- package/dist/runtime/extensions/doc-link-drop.js +4 -4
- package/dist/runtime/extensions/doc-link.d.ts +12 -0
- package/dist/runtime/extensions/doc-link.js +60 -0
- package/dist/runtime/extensions/embed.d.ts +2 -0
- package/dist/runtime/extensions/embed.js +40 -0
- package/dist/runtime/extensions/figure.d.ts +2 -0
- package/dist/runtime/extensions/figure.js +49 -0
- package/dist/runtime/extensions/math.d.ts +15 -0
- package/dist/runtime/extensions/math.js +66 -0
- package/dist/runtime/extensions/progress.d.ts +2 -0
- package/dist/runtime/extensions/progress.js +43 -0
- package/dist/runtime/extensions/quote.d.ts +2 -0
- package/dist/runtime/extensions/quote.js +39 -0
- package/dist/runtime/extensions/spoiler.d.ts +2 -0
- package/dist/runtime/extensions/spoiler.js +36 -0
- package/dist/runtime/extensions/stat.d.ts +3 -0
- package/dist/runtime/extensions/stat.js +58 -0
- package/dist/runtime/extensions/video.d.ts +2 -0
- package/dist/runtime/extensions/video.js +40 -0
- package/dist/runtime/extensions/views/ButtonGroupView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/ButtonGroupView.vue +25 -0
- package/dist/runtime/extensions/views/ButtonGroupView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/ButtonView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/ButtonView.vue +171 -0
- package/dist/runtime/extensions/views/ButtonView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/ColorSwatchView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/ColorSwatchView.vue +134 -0
- package/dist/runtime/extensions/views/ColorSwatchView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/DiffView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/DiffView.vue +163 -0
- package/dist/runtime/extensions/views/DiffView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/DividerView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/DividerView.vue +40 -0
- package/dist/runtime/extensions/views/DividerView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/DocEmbedView.vue +18 -3
- package/dist/runtime/extensions/views/DocLinkView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/DocLinkView.vue +71 -0
- package/dist/runtime/extensions/views/DocLinkView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/EmbedView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/EmbedView.vue +166 -0
- package/dist/runtime/extensions/views/EmbedView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/FigureView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/FigureView.vue +122 -0
- package/dist/runtime/extensions/views/FigureView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/FileNodeView.vue +21 -24
- package/dist/runtime/extensions/views/MathBlockView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/MathBlockView.vue +151 -0
- package/dist/runtime/extensions/views/MathBlockView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/MathInlineView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/MathInlineView.vue +149 -0
- package/dist/runtime/extensions/views/MathInlineView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/MetaFieldView.vue +1129 -550
- package/dist/runtime/extensions/views/ProgressView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/ProgressView.vue +156 -0
- package/dist/runtime/extensions/views/ProgressView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/QuoteView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/QuoteView.vue +128 -0
- package/dist/runtime/extensions/views/QuoteView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/SpoilerView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/SpoilerView.vue +62 -0
- package/dist/runtime/extensions/views/SpoilerView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/StatGroupView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/StatGroupView.vue +25 -0
- package/dist/runtime/extensions/views/StatGroupView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/StatView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/StatView.vue +89 -0
- package/dist/runtime/extensions/views/StatView.vue.d.ts +4 -0
- package/dist/runtime/extensions/views/VideoView.d.vue.ts +4 -0
- package/dist/runtime/extensions/views/VideoView.vue +190 -0
- package/dist/runtime/extensions/views/VideoView.vue.d.ts +4 -0
- package/dist/runtime/locale.d.ts +133 -0
- package/dist/runtime/locale.js +121 -2
- package/dist/runtime/plugin-abracadabra.client.js +251 -38
- package/dist/runtime/plugin-abracadabra.server.js +0 -1
- package/dist/runtime/plugins/core.plugin.js +76 -4
- package/dist/runtime/server/plugins/abracadabra-service.js +4 -2
- package/dist/runtime/server/utils/rpcHandler.d.ts +74 -0
- package/dist/runtime/server/utils/rpcHandler.js +74 -0
- package/dist/runtime/server/utils/spaceManager.js +10 -9
- package/dist/runtime/theme/content/_shared.d.ts +6 -0
- package/dist/runtime/theme/content/_shared.js +6 -0
- package/dist/runtime/theme/content/content-navigation.d.ts +120 -0
- package/dist/runtime/theme/content/content-navigation.js +155 -0
- package/dist/runtime/theme/content/content-search-button.d.ts +16 -0
- package/dist/runtime/theme/content/content-search-button.js +15 -0
- package/dist/runtime/theme/content/content-search.d.ts +24 -0
- package/dist/runtime/theme/content/content-search.js +23 -0
- package/dist/runtime/theme/content/content-surround.d.ts +22 -0
- package/dist/runtime/theme/content/content-surround.js +23 -0
- package/dist/runtime/theme/content/content-toc.d.ts +84 -0
- package/dist/runtime/theme/content/content-toc.js +94 -0
- package/dist/runtime/theme/content/index.d.ts +5 -0
- package/dist/runtime/theme/content/index.js +5 -0
- package/dist/runtime/types.d.ts +63 -10
- package/dist/runtime/utils/awareRingStyle.d.ts +22 -0
- package/dist/runtime/utils/awareRingStyle.js +16 -0
- package/dist/runtime/utils/caretCoordinates.d.ts +41 -0
- package/dist/runtime/utils/caretCoordinates.js +126 -0
- package/dist/runtime/utils/content.d.ts +19 -0
- package/dist/runtime/utils/content.js +23 -0
- package/dist/runtime/utils/docReferenceEdges.js +1 -1
- package/dist/runtime/utils/docTypes.js +44 -13
- package/dist/runtime/utils/domPath.d.ts +42 -0
- package/dist/runtime/utils/domPath.js +89 -0
- package/dist/runtime/utils/loadKatex.d.ts +1 -0
- package/dist/runtime/utils/loadKatex.js +29 -0
- package/dist/runtime/utils/lucideIcons.d.ts +16 -0
- package/dist/runtime/utils/lucideIcons.js +451 -0
- package/dist/runtime/utils/time.d.ts +15 -0
- package/dist/runtime/utils/time.js +5 -0
- package/dist/types.d.mts +4 -0
- package/package.json +38 -20
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
export class FormulaError {
|
|
2
|
+
constructor(type) {
|
|
3
|
+
this.type = type;
|
|
4
|
+
}
|
|
5
|
+
toString() {
|
|
6
|
+
return this.type;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
const CELL_REF_RE = /^\$?([A-Z]{1,3})\$?(\d{1,5})/;
|
|
10
|
+
const OPERATORS = /* @__PURE__ */ new Set(["+", "-", "*", "/", "^", ">", "<", "="]);
|
|
11
|
+
const TWO_CHAR_OPS = /* @__PURE__ */ new Set([">=", "<=", "<>"]);
|
|
12
|
+
function tokenize(formula) {
|
|
13
|
+
const tokens = [];
|
|
14
|
+
let i = 0;
|
|
15
|
+
const s = formula.trim();
|
|
16
|
+
while (i < s.length) {
|
|
17
|
+
const ch = s[i];
|
|
18
|
+
if (ch === " " || ch === " ") {
|
|
19
|
+
i++;
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
if (i + 1 < s.length && TWO_CHAR_OPS.has(s[i] + s[i + 1])) {
|
|
23
|
+
tokens.push({ type: "OPERATOR", value: s[i] + s[i + 1] });
|
|
24
|
+
i += 2;
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (OPERATORS.has(ch)) {
|
|
28
|
+
tokens.push({ type: "OPERATOR", value: ch });
|
|
29
|
+
i++;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (ch === "(") {
|
|
33
|
+
tokens.push({ type: "LPAREN", value: "(" });
|
|
34
|
+
i++;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (ch === ")") {
|
|
38
|
+
tokens.push({ type: "RPAREN", value: ")" });
|
|
39
|
+
i++;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (ch === ",") {
|
|
43
|
+
tokens.push({ type: "COMMA", value: "," });
|
|
44
|
+
i++;
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (ch === ":") {
|
|
48
|
+
tokens.push({ type: "COLON", value: ":" });
|
|
49
|
+
i++;
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (ch === '"') {
|
|
53
|
+
let str = "";
|
|
54
|
+
i++;
|
|
55
|
+
while (i < s.length && s[i] !== '"') {
|
|
56
|
+
str += s[i];
|
|
57
|
+
i++;
|
|
58
|
+
}
|
|
59
|
+
i++;
|
|
60
|
+
tokens.push({ type: "STRING", value: str });
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (ch >= "0" && ch <= "9" || ch === ".") {
|
|
64
|
+
let num = "";
|
|
65
|
+
while (i < s.length && (s[i] >= "0" && s[i] <= "9" || s[i] === ".")) {
|
|
66
|
+
num += s[i];
|
|
67
|
+
i++;
|
|
68
|
+
}
|
|
69
|
+
tokens.push({ type: "NUMBER", value: num });
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch === "$") {
|
|
73
|
+
const rest = s.slice(i).toUpperCase();
|
|
74
|
+
if (rest.startsWith("TRUE") && (i + 4 >= s.length || !isAlphaNum(s[i + 4]))) {
|
|
75
|
+
tokens.push({ type: "NUMBER", value: "TRUE" });
|
|
76
|
+
i += 4;
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (rest.startsWith("FALSE") && (i + 5 >= s.length || !isAlphaNum(s[i + 5]))) {
|
|
80
|
+
tokens.push({ type: "NUMBER", value: "FALSE" });
|
|
81
|
+
i += 5;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const cellMatch = rest.match(CELL_REF_RE);
|
|
85
|
+
let afterRef = i + (cellMatch ? cellMatch[0].length : 0);
|
|
86
|
+
while (afterRef < s.length && s[afterRef] === " ") afterRef++;
|
|
87
|
+
let word = "";
|
|
88
|
+
let j = i;
|
|
89
|
+
while (j < s.length && (s[j] >= "A" && s[j] <= "Z" || s[j] >= "a" && s[j] <= "z" || s[j] === "_" || s[j] === "$")) {
|
|
90
|
+
word += s[j].toUpperCase();
|
|
91
|
+
j++;
|
|
92
|
+
}
|
|
93
|
+
let wordWithDigits = word;
|
|
94
|
+
let k = j;
|
|
95
|
+
while (k < s.length && s[k] >= "0" && s[k] <= "9") {
|
|
96
|
+
wordWithDigits += s[k];
|
|
97
|
+
k++;
|
|
98
|
+
}
|
|
99
|
+
let afterWord = j;
|
|
100
|
+
while (afterWord < s.length && s[afterWord] === " ") afterWord++;
|
|
101
|
+
if (afterWord < s.length && s[afterWord] === "(" && word.length > 0 && !word.includes("$")) {
|
|
102
|
+
tokens.push({ type: "FUNCTION", value: word });
|
|
103
|
+
i = j;
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (cellMatch) {
|
|
107
|
+
tokens.push({ type: "CELL_REF", value: cellMatch[1] + cellMatch[2] });
|
|
108
|
+
i += cellMatch[0].length;
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
tokens.push({ type: "FUNCTION", value: word });
|
|
112
|
+
i = j;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
i++;
|
|
116
|
+
}
|
|
117
|
+
return tokens;
|
|
118
|
+
}
|
|
119
|
+
function isAlphaNum(ch) {
|
|
120
|
+
return ch >= "A" && ch <= "Z" || ch >= "a" && ch <= "z" || ch >= "0" && ch <= "9";
|
|
121
|
+
}
|
|
122
|
+
class Parser {
|
|
123
|
+
constructor(tokens) {
|
|
124
|
+
this.tokens = tokens;
|
|
125
|
+
}
|
|
126
|
+
pos = 0;
|
|
127
|
+
parse() {
|
|
128
|
+
const node = this.parseExpression();
|
|
129
|
+
return node;
|
|
130
|
+
}
|
|
131
|
+
peek() {
|
|
132
|
+
return this.tokens[this.pos] ?? null;
|
|
133
|
+
}
|
|
134
|
+
consume(type) {
|
|
135
|
+
const t = this.tokens[this.pos];
|
|
136
|
+
if (!t) throw new FormulaError("#ERROR!");
|
|
137
|
+
if (type && t.type !== type) throw new FormulaError("#ERROR!");
|
|
138
|
+
this.pos++;
|
|
139
|
+
return t;
|
|
140
|
+
}
|
|
141
|
+
parseExpression() {
|
|
142
|
+
return this.parseComparison();
|
|
143
|
+
}
|
|
144
|
+
parseComparison() {
|
|
145
|
+
let left = this.parseAddSub();
|
|
146
|
+
while (this.peek()?.type === "OPERATOR" && [">", "<", ">=", "<=", "=", "<>"].includes(this.peek().value)) {
|
|
147
|
+
const op = this.consume().value;
|
|
148
|
+
const right = this.parseAddSub();
|
|
149
|
+
left = { type: "binaryOp", op, left, right };
|
|
150
|
+
}
|
|
151
|
+
return left;
|
|
152
|
+
}
|
|
153
|
+
parseAddSub() {
|
|
154
|
+
let left = this.parseMulDiv();
|
|
155
|
+
while (this.peek()?.type === "OPERATOR" && (this.peek().value === "+" || this.peek().value === "-")) {
|
|
156
|
+
const op = this.consume().value;
|
|
157
|
+
const right = this.parseMulDiv();
|
|
158
|
+
left = { type: "binaryOp", op, left, right };
|
|
159
|
+
}
|
|
160
|
+
return left;
|
|
161
|
+
}
|
|
162
|
+
parseMulDiv() {
|
|
163
|
+
let left = this.parsePower();
|
|
164
|
+
while (this.peek()?.type === "OPERATOR" && (this.peek().value === "*" || this.peek().value === "/")) {
|
|
165
|
+
const op = this.consume().value;
|
|
166
|
+
const right = this.parsePower();
|
|
167
|
+
left = { type: "binaryOp", op, left, right };
|
|
168
|
+
}
|
|
169
|
+
return left;
|
|
170
|
+
}
|
|
171
|
+
parsePower() {
|
|
172
|
+
let left = this.parseUnary();
|
|
173
|
+
while (this.peek()?.type === "OPERATOR" && this.peek().value === "^") {
|
|
174
|
+
this.consume();
|
|
175
|
+
const right = this.parseUnary();
|
|
176
|
+
left = { type: "binaryOp", op: "^", left, right };
|
|
177
|
+
}
|
|
178
|
+
return left;
|
|
179
|
+
}
|
|
180
|
+
parseUnary() {
|
|
181
|
+
if (this.peek()?.type === "OPERATOR" && this.peek().value === "-") {
|
|
182
|
+
this.consume();
|
|
183
|
+
const operand = this.parseUnary();
|
|
184
|
+
return { type: "unaryOp", op: "-", operand };
|
|
185
|
+
}
|
|
186
|
+
if (this.peek()?.type === "OPERATOR" && this.peek().value === "+") {
|
|
187
|
+
this.consume();
|
|
188
|
+
return this.parseUnary();
|
|
189
|
+
}
|
|
190
|
+
return this.parsePrimary();
|
|
191
|
+
}
|
|
192
|
+
parsePrimary() {
|
|
193
|
+
const t = this.peek();
|
|
194
|
+
if (!t) throw new FormulaError("#ERROR!");
|
|
195
|
+
if (t.type === "NUMBER") {
|
|
196
|
+
this.consume();
|
|
197
|
+
if (t.value === "TRUE") return { type: "boolean", value: true };
|
|
198
|
+
if (t.value === "FALSE") return { type: "boolean", value: false };
|
|
199
|
+
return { type: "number", value: parseFloat(t.value) };
|
|
200
|
+
}
|
|
201
|
+
if (t.type === "STRING") {
|
|
202
|
+
this.consume();
|
|
203
|
+
return { type: "string", value: t.value };
|
|
204
|
+
}
|
|
205
|
+
if (t.type === "FUNCTION") {
|
|
206
|
+
const name = this.consume().value;
|
|
207
|
+
this.consume("LPAREN");
|
|
208
|
+
const args = [];
|
|
209
|
+
if (this.peek()?.type !== "RPAREN") {
|
|
210
|
+
args.push(this.parseExpression());
|
|
211
|
+
while (this.peek()?.type === "COMMA") {
|
|
212
|
+
this.consume();
|
|
213
|
+
args.push(this.parseExpression());
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
this.consume("RPAREN");
|
|
217
|
+
return { type: "functionCall", name, args };
|
|
218
|
+
}
|
|
219
|
+
if (t.type === "CELL_REF") {
|
|
220
|
+
const ref1 = this.consume();
|
|
221
|
+
const { col: col1, row: row1 } = parseCellRefStr(ref1.value);
|
|
222
|
+
if (this.peek()?.type === "COLON") {
|
|
223
|
+
this.consume();
|
|
224
|
+
const ref2 = this.consume("CELL_REF");
|
|
225
|
+
const { col: col2, row: row2 } = parseCellRefStr(ref2.value);
|
|
226
|
+
return { type: "rangeRef", startCol: col1, startRow: row1, endCol: col2, endRow: row2 };
|
|
227
|
+
}
|
|
228
|
+
return { type: "cellRef", col: col1, row: row1 };
|
|
229
|
+
}
|
|
230
|
+
if (t.type === "LPAREN") {
|
|
231
|
+
this.consume();
|
|
232
|
+
const expr = this.parseExpression();
|
|
233
|
+
this.consume("RPAREN");
|
|
234
|
+
return expr;
|
|
235
|
+
}
|
|
236
|
+
throw new FormulaError("#ERROR!");
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function parseCellRefStr(ref) {
|
|
240
|
+
const match = ref.match(/^([A-Z]+)(\d+)$/);
|
|
241
|
+
if (!match) throw new FormulaError("#REF!");
|
|
242
|
+
return { col: match[1], row: parseInt(match[2], 10) };
|
|
243
|
+
}
|
|
244
|
+
function evaluate(node, ctx) {
|
|
245
|
+
switch (node.type) {
|
|
246
|
+
case "number":
|
|
247
|
+
return node.value;
|
|
248
|
+
case "string":
|
|
249
|
+
return node.value;
|
|
250
|
+
case "boolean":
|
|
251
|
+
return node.value;
|
|
252
|
+
case "cellRef": {
|
|
253
|
+
const colIdx = ctx.colLetterToIndex(node.col);
|
|
254
|
+
const rowIdx = node.row - 1;
|
|
255
|
+
const key = `${colIdx}:${rowIdx}`;
|
|
256
|
+
if (ctx.evaluating.has(key)) return new FormulaError("#REF!");
|
|
257
|
+
ctx.evaluating.add(key);
|
|
258
|
+
const result = ctx.getCellValue(colIdx, rowIdx);
|
|
259
|
+
ctx.evaluating.delete(key);
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
case "rangeRef":
|
|
263
|
+
return new FormulaError("#VALUE!");
|
|
264
|
+
case "unaryOp": {
|
|
265
|
+
const val = evaluate(node.operand, ctx);
|
|
266
|
+
if (val instanceof FormulaError) return val;
|
|
267
|
+
if (node.op === "-") return -toNumber(val);
|
|
268
|
+
return val;
|
|
269
|
+
}
|
|
270
|
+
case "binaryOp": {
|
|
271
|
+
const left = evaluate(node.left, ctx);
|
|
272
|
+
const right = evaluate(node.right, ctx);
|
|
273
|
+
if (left instanceof FormulaError) return left;
|
|
274
|
+
if (right instanceof FormulaError) return right;
|
|
275
|
+
return evalBinaryOp(node.op, left, right);
|
|
276
|
+
}
|
|
277
|
+
case "functionCall":
|
|
278
|
+
return evalFunction(node.name, node.args, ctx);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
function evalBinaryOp(op, left, right) {
|
|
282
|
+
if (left instanceof FormulaError) return left;
|
|
283
|
+
if (right instanceof FormulaError) return right;
|
|
284
|
+
const ln = toNumber(left);
|
|
285
|
+
const rn = toNumber(right);
|
|
286
|
+
switch (op) {
|
|
287
|
+
case "+":
|
|
288
|
+
return ln + rn;
|
|
289
|
+
case "-":
|
|
290
|
+
return ln - rn;
|
|
291
|
+
case "*":
|
|
292
|
+
return ln * rn;
|
|
293
|
+
case "/":
|
|
294
|
+
return rn === 0 ? new FormulaError("#DIV/0!") : ln / rn;
|
|
295
|
+
case "^":
|
|
296
|
+
return Math.pow(ln, rn);
|
|
297
|
+
case ">":
|
|
298
|
+
return ln > rn;
|
|
299
|
+
case "<":
|
|
300
|
+
return ln < rn;
|
|
301
|
+
case ">=":
|
|
302
|
+
return ln >= rn;
|
|
303
|
+
case "<=":
|
|
304
|
+
return ln <= rn;
|
|
305
|
+
case "=":
|
|
306
|
+
return left === right || ln === rn;
|
|
307
|
+
case "<>":
|
|
308
|
+
return left !== right && ln !== rn;
|
|
309
|
+
default:
|
|
310
|
+
return new FormulaError("#ERROR!");
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function evalFunction(name, args, ctx) {
|
|
314
|
+
switch (name) {
|
|
315
|
+
case "SUM": {
|
|
316
|
+
const values = collectValues(args, ctx);
|
|
317
|
+
if (values instanceof FormulaError) return values;
|
|
318
|
+
return values.reduce((s, v) => s + toNumber(v), 0);
|
|
319
|
+
}
|
|
320
|
+
case "AVERAGE": {
|
|
321
|
+
const values = collectValues(args, ctx);
|
|
322
|
+
if (values instanceof FormulaError) return values;
|
|
323
|
+
if (values.length === 0) return new FormulaError("#DIV/0!");
|
|
324
|
+
return values.reduce((s, v) => s + toNumber(v), 0) / values.length;
|
|
325
|
+
}
|
|
326
|
+
case "COUNT": {
|
|
327
|
+
const values = collectValues(args, ctx);
|
|
328
|
+
if (values instanceof FormulaError) return values;
|
|
329
|
+
return values.filter((v) => typeof v === "number" || typeof v === "string" && v !== "" && !isNaN(Number(v))).length;
|
|
330
|
+
}
|
|
331
|
+
case "MIN": {
|
|
332
|
+
const values = collectValues(args, ctx);
|
|
333
|
+
if (values instanceof FormulaError) return values;
|
|
334
|
+
const nums = values.map(toNumber).filter((n) => !isNaN(n));
|
|
335
|
+
return nums.length ? Math.min(...nums) : 0;
|
|
336
|
+
}
|
|
337
|
+
case "MAX": {
|
|
338
|
+
const values = collectValues(args, ctx);
|
|
339
|
+
if (values instanceof FormulaError) return values;
|
|
340
|
+
const nums = values.map(toNumber).filter((n) => !isNaN(n));
|
|
341
|
+
return nums.length ? Math.max(...nums) : 0;
|
|
342
|
+
}
|
|
343
|
+
case "IF": {
|
|
344
|
+
if (args.length < 2) return new FormulaError("#VALUE!");
|
|
345
|
+
const cond = evaluate(args[0], ctx);
|
|
346
|
+
if (cond instanceof FormulaError) return cond;
|
|
347
|
+
const truthy = !!cond && cond !== 0 && cond !== "";
|
|
348
|
+
if (truthy) return evaluate(args[1], ctx);
|
|
349
|
+
return args[2] ? evaluate(args[2], ctx) : false;
|
|
350
|
+
}
|
|
351
|
+
case "ROUND": {
|
|
352
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
353
|
+
const val = evaluate(args[0], ctx);
|
|
354
|
+
if (val instanceof FormulaError) return val;
|
|
355
|
+
const decimals = args[1] ? evaluate(args[1], ctx) : 0;
|
|
356
|
+
if (decimals instanceof FormulaError) return decimals;
|
|
357
|
+
const d = toNumber(decimals);
|
|
358
|
+
const factor = Math.pow(10, d);
|
|
359
|
+
return Math.round(toNumber(val) * factor) / factor;
|
|
360
|
+
}
|
|
361
|
+
case "ABS": {
|
|
362
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
363
|
+
const val = evaluate(args[0], ctx);
|
|
364
|
+
if (val instanceof FormulaError) return val;
|
|
365
|
+
return Math.abs(toNumber(val));
|
|
366
|
+
}
|
|
367
|
+
case "CONCAT": {
|
|
368
|
+
const parts = [];
|
|
369
|
+
for (const arg of args) {
|
|
370
|
+
const val = evaluate(arg, ctx);
|
|
371
|
+
if (val instanceof FormulaError) return val;
|
|
372
|
+
parts.push(String(val));
|
|
373
|
+
}
|
|
374
|
+
return parts.join("");
|
|
375
|
+
}
|
|
376
|
+
// ── Math functions ──────────────────────────────────────────────────────
|
|
377
|
+
case "SQRT": {
|
|
378
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
379
|
+
const val = evaluate(args[0], ctx);
|
|
380
|
+
if (val instanceof FormulaError) return val;
|
|
381
|
+
const n = toNumber(val);
|
|
382
|
+
return n < 0 ? new FormulaError("#VALUE!") : Math.sqrt(n);
|
|
383
|
+
}
|
|
384
|
+
case "POWER": {
|
|
385
|
+
if (args.length < 2) return new FormulaError("#VALUE!");
|
|
386
|
+
const base = evaluate(args[0], ctx);
|
|
387
|
+
const exp = evaluate(args[1], ctx);
|
|
388
|
+
if (base instanceof FormulaError) return base;
|
|
389
|
+
if (exp instanceof FormulaError) return exp;
|
|
390
|
+
return Math.pow(toNumber(base), toNumber(exp));
|
|
391
|
+
}
|
|
392
|
+
case "LOG": {
|
|
393
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
394
|
+
const val = evaluate(args[0], ctx);
|
|
395
|
+
if (val instanceof FormulaError) return val;
|
|
396
|
+
const n = toNumber(val);
|
|
397
|
+
if (n <= 0) return new FormulaError("#VALUE!");
|
|
398
|
+
const base = args[1] ? evaluate(args[1], ctx) : 10;
|
|
399
|
+
if (base instanceof FormulaError) return base;
|
|
400
|
+
const b = toNumber(base);
|
|
401
|
+
return b === 1 ? new FormulaError("#DIV/0!") : Math.log(n) / Math.log(b);
|
|
402
|
+
}
|
|
403
|
+
case "FLOOR": {
|
|
404
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
405
|
+
const val = evaluate(args[0], ctx);
|
|
406
|
+
if (val instanceof FormulaError) return val;
|
|
407
|
+
return Math.floor(toNumber(val));
|
|
408
|
+
}
|
|
409
|
+
case "CEIL":
|
|
410
|
+
case "CEILING": {
|
|
411
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
412
|
+
const val = evaluate(args[0], ctx);
|
|
413
|
+
if (val instanceof FormulaError) return val;
|
|
414
|
+
return Math.ceil(toNumber(val));
|
|
415
|
+
}
|
|
416
|
+
case "MOD": {
|
|
417
|
+
if (args.length < 2) return new FormulaError("#VALUE!");
|
|
418
|
+
const val = evaluate(args[0], ctx);
|
|
419
|
+
const div = evaluate(args[1], ctx);
|
|
420
|
+
if (val instanceof FormulaError) return val;
|
|
421
|
+
if (div instanceof FormulaError) return div;
|
|
422
|
+
const d = toNumber(div);
|
|
423
|
+
return d === 0 ? new FormulaError("#DIV/0!") : toNumber(val) % d;
|
|
424
|
+
}
|
|
425
|
+
case "RAND": {
|
|
426
|
+
return Math.random();
|
|
427
|
+
}
|
|
428
|
+
// ── Text functions ──────────────────────────────────────────────────────
|
|
429
|
+
case "LEN": {
|
|
430
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
431
|
+
const val = evaluate(args[0], ctx);
|
|
432
|
+
if (val instanceof FormulaError) return val;
|
|
433
|
+
return String(val).length;
|
|
434
|
+
}
|
|
435
|
+
case "LEFT": {
|
|
436
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
437
|
+
const val = evaluate(args[0], ctx);
|
|
438
|
+
if (val instanceof FormulaError) return val;
|
|
439
|
+
const n = args[1] ? evaluate(args[1], ctx) : 1;
|
|
440
|
+
if (n instanceof FormulaError) return n;
|
|
441
|
+
return String(val).slice(0, toNumber(n));
|
|
442
|
+
}
|
|
443
|
+
case "RIGHT": {
|
|
444
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
445
|
+
const val = evaluate(args[0], ctx);
|
|
446
|
+
if (val instanceof FormulaError) return val;
|
|
447
|
+
const n = args[1] ? evaluate(args[1], ctx) : 1;
|
|
448
|
+
if (n instanceof FormulaError) return n;
|
|
449
|
+
const s = String(val);
|
|
450
|
+
return s.slice(Math.max(0, s.length - toNumber(n)));
|
|
451
|
+
}
|
|
452
|
+
case "MID": {
|
|
453
|
+
if (args.length < 3) return new FormulaError("#VALUE!");
|
|
454
|
+
const val = evaluate(args[0], ctx);
|
|
455
|
+
const start = evaluate(args[1], ctx);
|
|
456
|
+
const len = evaluate(args[2], ctx);
|
|
457
|
+
if (val instanceof FormulaError) return val;
|
|
458
|
+
if (start instanceof FormulaError) return start;
|
|
459
|
+
if (len instanceof FormulaError) return len;
|
|
460
|
+
return String(val).substr(toNumber(start) - 1, toNumber(len));
|
|
461
|
+
}
|
|
462
|
+
case "UPPER": {
|
|
463
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
464
|
+
const val = evaluate(args[0], ctx);
|
|
465
|
+
if (val instanceof FormulaError) return val;
|
|
466
|
+
return String(val).toUpperCase();
|
|
467
|
+
}
|
|
468
|
+
case "LOWER": {
|
|
469
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
470
|
+
const val = evaluate(args[0], ctx);
|
|
471
|
+
if (val instanceof FormulaError) return val;
|
|
472
|
+
return String(val).toLowerCase();
|
|
473
|
+
}
|
|
474
|
+
case "TRIM": {
|
|
475
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
476
|
+
const val = evaluate(args[0], ctx);
|
|
477
|
+
if (val instanceof FormulaError) return val;
|
|
478
|
+
return String(val).trim();
|
|
479
|
+
}
|
|
480
|
+
case "SUBSTITUTE": {
|
|
481
|
+
if (args.length < 3) return new FormulaError("#VALUE!");
|
|
482
|
+
const text = evaluate(args[0], ctx);
|
|
483
|
+
const old = evaluate(args[1], ctx);
|
|
484
|
+
const rep = evaluate(args[2], ctx);
|
|
485
|
+
if (text instanceof FormulaError) return text;
|
|
486
|
+
if (old instanceof FormulaError) return old;
|
|
487
|
+
if (rep instanceof FormulaError) return rep;
|
|
488
|
+
return String(text).split(String(old)).join(String(rep));
|
|
489
|
+
}
|
|
490
|
+
// ── Logic functions ─────────────────────────────────────────────────────
|
|
491
|
+
case "AND": {
|
|
492
|
+
for (const arg of args) {
|
|
493
|
+
const val = evaluate(arg, ctx);
|
|
494
|
+
if (val instanceof FormulaError) return val;
|
|
495
|
+
if (!val || val === 0 || val === "") return false;
|
|
496
|
+
}
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
case "OR": {
|
|
500
|
+
for (const arg of args) {
|
|
501
|
+
const val = evaluate(arg, ctx);
|
|
502
|
+
if (val instanceof FormulaError) return val;
|
|
503
|
+
if (val && val !== 0 && val !== "") return true;
|
|
504
|
+
}
|
|
505
|
+
return false;
|
|
506
|
+
}
|
|
507
|
+
case "NOT": {
|
|
508
|
+
if (args.length < 1) return new FormulaError("#VALUE!");
|
|
509
|
+
const val = evaluate(args[0], ctx);
|
|
510
|
+
if (val instanceof FormulaError) return val;
|
|
511
|
+
return !val || val === 0 || val === "";
|
|
512
|
+
}
|
|
513
|
+
case "IFERROR": {
|
|
514
|
+
if (args.length < 2) return new FormulaError("#VALUE!");
|
|
515
|
+
const val = evaluate(args[0], ctx);
|
|
516
|
+
if (val instanceof FormulaError) return evaluate(args[1], ctx);
|
|
517
|
+
return val;
|
|
518
|
+
}
|
|
519
|
+
// ── Conditional aggregation ─────────────────────────────────────────────
|
|
520
|
+
case "SUMIF": {
|
|
521
|
+
if (args.length < 2) return new FormulaError("#VALUE!");
|
|
522
|
+
const rangeVals = collectValues([args[0]], ctx);
|
|
523
|
+
if (rangeVals instanceof FormulaError) return rangeVals;
|
|
524
|
+
const criteria = evaluate(args[1], ctx);
|
|
525
|
+
if (criteria instanceof FormulaError) return criteria;
|
|
526
|
+
const sumVals = args[2] ? collectValues([args[2]], ctx) : rangeVals;
|
|
527
|
+
if (sumVals instanceof FormulaError) return sumVals;
|
|
528
|
+
let sum = 0;
|
|
529
|
+
for (let i = 0; i < rangeVals.length; i++) {
|
|
530
|
+
if (matchesCriteria(rangeVals[i], criteria)) {
|
|
531
|
+
sum += toNumber(sumVals[i] ?? 0);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return sum;
|
|
535
|
+
}
|
|
536
|
+
case "COUNTIF": {
|
|
537
|
+
if (args.length < 2) return new FormulaError("#VALUE!");
|
|
538
|
+
const rangeVals = collectValues([args[0]], ctx);
|
|
539
|
+
if (rangeVals instanceof FormulaError) return rangeVals;
|
|
540
|
+
const criteria = evaluate(args[1], ctx);
|
|
541
|
+
if (criteria instanceof FormulaError) return criteria;
|
|
542
|
+
let count = 0;
|
|
543
|
+
for (const v of rangeVals) {
|
|
544
|
+
if (matchesCriteria(v, criteria)) count++;
|
|
545
|
+
}
|
|
546
|
+
return count;
|
|
547
|
+
}
|
|
548
|
+
// ── Lookup ──────────────────────────────────────────────────────────────
|
|
549
|
+
case "VLOOKUP": {
|
|
550
|
+
if (args.length < 3) return new FormulaError("#VALUE!");
|
|
551
|
+
const lookupVal = evaluate(args[0], ctx);
|
|
552
|
+
if (lookupVal instanceof FormulaError) return lookupVal;
|
|
553
|
+
const rangeArg = args[1];
|
|
554
|
+
if (rangeArg.type !== "rangeRef") return new FormulaError("#VALUE!");
|
|
555
|
+
const colIndex = evaluate(args[2], ctx);
|
|
556
|
+
if (colIndex instanceof FormulaError) return colIndex;
|
|
557
|
+
const ci = toNumber(colIndex);
|
|
558
|
+
if (ci < 1) return new FormulaError("#VALUE!");
|
|
559
|
+
const startColIdx = ctx.colLetterToIndex(rangeArg.startCol);
|
|
560
|
+
const endColIdx = ctx.colLetterToIndex(rangeArg.endCol);
|
|
561
|
+
const startRow = rangeArg.startRow - 1;
|
|
562
|
+
const endRow = rangeArg.endRow - 1;
|
|
563
|
+
if (ci > endColIdx - startColIdx + 1) return new FormulaError("#REF!");
|
|
564
|
+
for (let r = startRow; r <= endRow; r++) {
|
|
565
|
+
const cellVal = ctx.getCellValue(startColIdx, r);
|
|
566
|
+
if (cellVal instanceof FormulaError) continue;
|
|
567
|
+
if (cellVal === lookupVal || toNumber(cellVal) === toNumber(lookupVal)) {
|
|
568
|
+
return ctx.getCellValue(startColIdx + ci - 1, r);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
return new FormulaError("#VALUE!");
|
|
572
|
+
}
|
|
573
|
+
default:
|
|
574
|
+
return new FormulaError("#NAME?");
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
function collectValues(args, ctx) {
|
|
578
|
+
const values = [];
|
|
579
|
+
for (const arg of args) {
|
|
580
|
+
if (arg.type === "rangeRef") {
|
|
581
|
+
const startColIdx = ctx.colLetterToIndex(arg.startCol);
|
|
582
|
+
const endColIdx = ctx.colLetterToIndex(arg.endCol);
|
|
583
|
+
const startRow = arg.startRow - 1;
|
|
584
|
+
const endRow = arg.endRow - 1;
|
|
585
|
+
const minCol = Math.min(startColIdx, endColIdx);
|
|
586
|
+
const maxCol = Math.max(startColIdx, endColIdx);
|
|
587
|
+
const minRow = Math.min(startRow, endRow);
|
|
588
|
+
const maxRow = Math.max(startRow, endRow);
|
|
589
|
+
for (let c = minCol; c <= maxCol; c++) {
|
|
590
|
+
for (let r = minRow; r <= maxRow; r++) {
|
|
591
|
+
const key = `${c}:${r}`;
|
|
592
|
+
if (ctx.evaluating.has(key)) return new FormulaError("#REF!");
|
|
593
|
+
ctx.evaluating.add(key);
|
|
594
|
+
const v = ctx.getCellValue(c, r);
|
|
595
|
+
ctx.evaluating.delete(key);
|
|
596
|
+
if (v instanceof FormulaError) return v;
|
|
597
|
+
values.push(v);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
} else {
|
|
601
|
+
const v = evaluate(arg, ctx);
|
|
602
|
+
if (v instanceof FormulaError) return v;
|
|
603
|
+
values.push(v);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return values;
|
|
607
|
+
}
|
|
608
|
+
function matchesCriteria(cellVal, criteria) {
|
|
609
|
+
if (cellVal instanceof FormulaError) return false;
|
|
610
|
+
if (criteria instanceof FormulaError) return false;
|
|
611
|
+
if (typeof criteria === "string") {
|
|
612
|
+
const opMatch = criteria.match(/^(<>|>=|<=|>|<|=)(.+)$/);
|
|
613
|
+
if (opMatch) {
|
|
614
|
+
const op = opMatch[1];
|
|
615
|
+
const cmpVal = opMatch[2];
|
|
616
|
+
const cn = Number(cmpVal);
|
|
617
|
+
const cv = typeof cellVal === "number" ? cellVal : cellVal !== "" && !isNaN(Number(cellVal)) ? Number(cellVal) : NaN;
|
|
618
|
+
if (!isNaN(cn) && !isNaN(cv)) {
|
|
619
|
+
switch (op) {
|
|
620
|
+
case ">":
|
|
621
|
+
return cv > cn;
|
|
622
|
+
case "<":
|
|
623
|
+
return cv < cn;
|
|
624
|
+
case ">=":
|
|
625
|
+
return cv >= cn;
|
|
626
|
+
case "<=":
|
|
627
|
+
return cv <= cn;
|
|
628
|
+
case "<>":
|
|
629
|
+
return cv !== cn;
|
|
630
|
+
case "=":
|
|
631
|
+
return cv === cn;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
switch (op) {
|
|
635
|
+
case "<>":
|
|
636
|
+
return String(cellVal) !== cmpVal;
|
|
637
|
+
case "=":
|
|
638
|
+
return String(cellVal) === cmpVal;
|
|
639
|
+
default:
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
if (typeof criteria === "number") return toNumber(cellVal) === criteria;
|
|
645
|
+
return String(cellVal) === String(criteria);
|
|
646
|
+
}
|
|
647
|
+
function toNumber(val) {
|
|
648
|
+
if (typeof val === "number") return val;
|
|
649
|
+
if (typeof val === "boolean") return val ? 1 : 0;
|
|
650
|
+
if (typeof val === "string") {
|
|
651
|
+
if (val === "") return 0;
|
|
652
|
+
const n = Number(val);
|
|
653
|
+
return isNaN(n) ? 0 : n;
|
|
654
|
+
}
|
|
655
|
+
return 0;
|
|
656
|
+
}
|
|
657
|
+
export function evaluateFormula(formula, ctx) {
|
|
658
|
+
try {
|
|
659
|
+
const tokens = tokenize(formula);
|
|
660
|
+
const parser = new Parser(tokens);
|
|
661
|
+
const ast = parser.parse();
|
|
662
|
+
return evaluate(ast, ctx);
|
|
663
|
+
} catch (e) {
|
|
664
|
+
if (e instanceof FormulaError) return e;
|
|
665
|
+
return new FormulaError("#ERROR!");
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
export function formatFormulaResult(result) {
|
|
669
|
+
if (result instanceof FormulaError) return result.type;
|
|
670
|
+
if (typeof result === "boolean") return result ? "TRUE" : "FALSE";
|
|
671
|
+
if (typeof result === "number") {
|
|
672
|
+
return String(Math.round(result * 1e10) / 1e10);
|
|
673
|
+
}
|
|
674
|
+
return String(result);
|
|
675
|
+
}
|
|
676
|
+
export function extractCellRefs(formula) {
|
|
677
|
+
const results = [];
|
|
678
|
+
const refRe = /\$?([A-Z]{1,3})\$?(\d{1,5})(?::(\$?[A-Z]{1,3})\$?(\d{1,5}))?/g;
|
|
679
|
+
let match;
|
|
680
|
+
while ((match = refRe.exec(formula)) !== null) {
|
|
681
|
+
const col1 = match[1];
|
|
682
|
+
const row1 = parseInt(match[2], 10);
|
|
683
|
+
if (match[3] && match[4]) {
|
|
684
|
+
const col2 = match[3].replace(/\$/g, "");
|
|
685
|
+
const row2 = parseInt(match[4], 10);
|
|
686
|
+
results.push({
|
|
687
|
+
range: match[0],
|
|
688
|
+
startCol: colLetterToIndexStatic(col1),
|
|
689
|
+
startRow: row1 - 1,
|
|
690
|
+
endCol: colLetterToIndexStatic(col2),
|
|
691
|
+
endRow: row2 - 1
|
|
692
|
+
});
|
|
693
|
+
} else {
|
|
694
|
+
results.push({
|
|
695
|
+
ref: match[0],
|
|
696
|
+
colIdx: colLetterToIndexStatic(col1),
|
|
697
|
+
rowIdx: row1 - 1
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return results;
|
|
702
|
+
}
|
|
703
|
+
function colLetterToIndexStatic(s) {
|
|
704
|
+
let result = 0;
|
|
705
|
+
for (let i = 0; i < s.length; i++) {
|
|
706
|
+
result = result * 26 + (s.charCodeAt(i) - 64);
|
|
707
|
+
}
|
|
708
|
+
return result - 1;
|
|
709
|
+
}
|
|
710
|
+
function indexToColLetterStatic(n) {
|
|
711
|
+
let result = "";
|
|
712
|
+
let idx = n;
|
|
713
|
+
while (idx >= 0) {
|
|
714
|
+
result = String.fromCharCode(65 + idx % 26) + result;
|
|
715
|
+
idx = Math.floor(idx / 26) - 1;
|
|
716
|
+
}
|
|
717
|
+
return result;
|
|
718
|
+
}
|
|
719
|
+
export function adjustFormulaRefs(formula, dCol, dRow) {
|
|
720
|
+
return formula.replace(/(\$?)([A-Z]{1,3})(\$?)(\d{1,5})/g, (_match, absDollarCol, col, absDollarRow, row) => {
|
|
721
|
+
const newCol = absDollarCol ? col : indexToColLetterStatic(colLetterToIndexStatic(col) + dCol);
|
|
722
|
+
const newRow = absDollarRow ? row : String(parseInt(row, 10) + dRow);
|
|
723
|
+
return `${absDollarCol}${newCol}${absDollarRow}${newRow}`;
|
|
724
|
+
});
|
|
725
|
+
}
|