@rowsncolumns/spreadsheet-state 28.0.66
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.md +100 -0
- package/Readme.md +65 -0
- package/dist/cjs/api/border.d.ts +9 -0
- package/dist/cjs/api/border.d.ts.map +1 -0
- package/dist/cjs/api/border.js +25 -0
- package/dist/cjs/api/conditional-format.d.ts +2 -0
- package/dist/cjs/api/conditional-format.d.ts.map +1 -0
- package/dist/cjs/api/conditional-format.js +5 -0
- package/dist/cjs/api/copy-paste.d.ts +20 -0
- package/dist/cjs/api/copy-paste.d.ts.map +1 -0
- package/dist/cjs/api/copy-paste.js +384 -0
- package/dist/cjs/api/data-validation.d.ts +2 -0
- package/dist/cjs/api/data-validation.d.ts.map +1 -0
- package/dist/cjs/api/data-validation.js +5 -0
- package/dist/cjs/api/datatype.d.ts +89 -0
- package/dist/cjs/api/datatype.d.ts.map +1 -0
- package/dist/cjs/api/datatype.js +671 -0
- package/dist/cjs/api/date.d.ts +27 -0
- package/dist/cjs/api/date.d.ts.map +1 -0
- package/dist/cjs/api/date.js +222 -0
- package/dist/cjs/api/decimals.d.ts +10 -0
- package/dist/cjs/api/decimals.d.ts.map +1 -0
- package/dist/cjs/api/decimals.js +192 -0
- package/dist/cjs/api/dependency.d.ts +64 -0
- package/dist/cjs/api/dependency.d.ts.map +1 -0
- package/dist/cjs/api/dependency.js +279 -0
- package/dist/cjs/api/fill.d.ts +88 -0
- package/dist/cjs/api/fill.d.ts.map +1 -0
- package/dist/cjs/api/fill.js +959 -0
- package/dist/cjs/api/filter-range.d.ts +4 -0
- package/dist/cjs/api/filter-range.d.ts.map +1 -0
- package/dist/cjs/api/filter-range.js +101 -0
- package/dist/cjs/api/filter.d.ts +24 -0
- package/dist/cjs/api/filter.d.ts.map +1 -0
- package/dist/cjs/api/filter.js +66 -0
- package/dist/cjs/api/format-caches.d.ts +43 -0
- package/dist/cjs/api/format-caches.d.ts.map +1 -0
- package/dist/cjs/api/format-caches.js +107 -0
- package/dist/cjs/api/formula.d.ts +69 -0
- package/dist/cjs/api/formula.d.ts.map +1 -0
- package/dist/cjs/api/formula.js +458 -0
- package/dist/cjs/api/immer-utils.d.ts +66 -0
- package/dist/cjs/api/immer-utils.d.ts.map +1 -0
- package/dist/cjs/api/immer-utils.js +1633 -0
- package/dist/cjs/api/intl.d.ts +51 -0
- package/dist/cjs/api/intl.d.ts.map +1 -0
- package/dist/cjs/api/intl.js +261 -0
- package/dist/cjs/api/merges.d.ts +7 -0
- package/dist/cjs/api/merges.d.ts.map +1 -0
- package/dist/cjs/api/merges.js +134 -0
- package/dist/cjs/api/outline.d.ts +33 -0
- package/dist/cjs/api/outline.d.ts.map +1 -0
- package/dist/cjs/api/outline.js +70 -0
- package/dist/cjs/api/parse-html.d.ts +15 -0
- package/dist/cjs/api/parse-html.d.ts.map +1 -0
- package/dist/cjs/api/parse-html.js +1066 -0
- package/dist/cjs/api/patches.d.ts +11 -0
- package/dist/cjs/api/patches.d.ts.map +1 -0
- package/dist/cjs/api/patches.js +218 -0
- package/dist/cjs/api/pivot-range.d.ts +8 -0
- package/dist/cjs/api/pivot-range.d.ts.map +1 -0
- package/dist/cjs/api/pivot-range.js +130 -0
- package/dist/cjs/api/range-rule-helpers.d.ts +65 -0
- package/dist/cjs/api/range-rule-helpers.d.ts.map +1 -0
- package/dist/cjs/api/range-rule-helpers.js +142 -0
- package/dist/cjs/api/range.d.ts +19 -0
- package/dist/cjs/api/range.d.ts.map +1 -0
- package/dist/cjs/api/range.js +183 -0
- package/dist/cjs/api/rename-sheet.d.ts +22 -0
- package/dist/cjs/api/rename-sheet.d.ts.map +1 -0
- package/dist/cjs/api/rename-sheet.js +54 -0
- package/dist/cjs/api/selection.d.ts +36 -0
- package/dist/cjs/api/selection.d.ts.map +1 -0
- package/dist/cjs/api/selection.js +133 -0
- package/dist/cjs/api/sort.d.ts +3 -0
- package/dist/cjs/api/sort.d.ts.map +1 -0
- package/dist/cjs/api/sort.js +33 -0
- package/dist/cjs/api/split-text.d.ts +2 -0
- package/dist/cjs/api/split-text.d.ts.map +1 -0
- package/dist/cjs/api/split-text.js +25 -0
- package/dist/cjs/api/structural-formula-update.d.ts +75 -0
- package/dist/cjs/api/structural-formula-update.d.ts.map +1 -0
- package/dist/cjs/api/structural-formula-update.js +508 -0
- package/dist/cjs/api/table.d.ts +39 -0
- package/dist/cjs/api/table.d.ts.map +1 -0
- package/dist/cjs/api/table.js +337 -0
- package/dist/cjs/api/validation.d.ts +12 -0
- package/dist/cjs/api/validation.d.ts.map +1 -0
- package/dist/cjs/api/validation.js +306 -0
- package/dist/cjs/api/xlsx-source.d.ts +22 -0
- package/dist/cjs/api/xlsx-source.d.ts.map +1 -0
- package/dist/cjs/api/xlsx-source.js +31 -0
- package/dist/cjs/atoms/delete-sheet-atom.d.ts +6 -0
- package/dist/cjs/atoms/delete-sheet-atom.d.ts.map +1 -0
- package/dist/cjs/atoms/delete-sheet-atom.js +4 -0
- package/dist/cjs/atoms/dialog-state.atom.d.ts +23 -0
- package/dist/cjs/atoms/dialog-state.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/dialog-state.atom.js +72 -0
- package/dist/cjs/atoms/editing-data-validation-id.atom.d.ts +7 -0
- package/dist/cjs/atoms/editing-data-validation-id.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/editing-data-validation-id.atom.js +12 -0
- package/dist/cjs/atoms/editing-embed.atom.d.ts +8 -0
- package/dist/cjs/atoms/editing-embed.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/editing-embed.atom.js +5 -0
- package/dist/cjs/atoms/editing-table.atom.d.ts +8 -0
- package/dist/cjs/atoms/editing-table.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/editing-table.atom.js +6 -0
- package/dist/cjs/atoms/error-state.atom.d.ts +10 -0
- package/dist/cjs/atoms/error-state.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/error-state.atom.js +5 -0
- package/dist/cjs/atoms/index.d.ts +5 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -0
- package/dist/cjs/atoms/index.js +4 -0
- package/dist/cjs/atoms/insert-image-state.atom.d.ts +6 -0
- package/dist/cjs/atoms/insert-image-state.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/insert-image-state.atom.js +9 -0
- package/dist/cjs/atoms/named-range.atom.d.ts +8 -0
- package/dist/cjs/atoms/named-range.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/named-range.atom.js +6 -0
- package/dist/cjs/atoms/resize-dimension.atom.d.ts +12 -0
- package/dist/cjs/atoms/resize-dimension.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/resize-dimension.atom.js +5 -0
- package/dist/cjs/atoms/sheet-observer.atom.d.ts +16 -0
- package/dist/cjs/atoms/sheet-observer.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/sheet-observer.atom.js +19 -0
- package/dist/cjs/cellxfs-registry.d.ts +37 -0
- package/dist/cjs/cellxfs-registry.d.ts.map +1 -0
- package/dist/cjs/cellxfs-registry.js +175 -0
- package/dist/cjs/commands.d.ts +691 -0
- package/dist/cjs/commands.d.ts.map +1 -0
- package/dist/cjs/commands.js +1 -0
- package/dist/cjs/components/dialogs/delete-sheet-confirmation.d.ts +7 -0
- package/dist/cjs/components/dialogs/delete-sheet-confirmation.d.ts.map +1 -0
- package/dist/cjs/components/dialogs/delete-sheet-confirmation.js +31 -0
- package/dist/cjs/components/dialogs/error-state.d.ts +3 -0
- package/dist/cjs/components/dialogs/error-state.d.ts.map +1 -0
- package/dist/cjs/components/dialogs/error-state.js +24 -0
- package/dist/cjs/components/editors/cell-format-editor.d.ts +26 -0
- package/dist/cjs/components/editors/cell-format-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/cell-format-editor.js +671 -0
- package/dist/cjs/components/editors/conditional-format-editor.d.ts +43 -0
- package/dist/cjs/components/editors/conditional-format-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/conditional-format-editor.js +176 -0
- package/dist/cjs/components/editors/conditional-format-rule-editor.d.ts +27 -0
- package/dist/cjs/components/editors/conditional-format-rule-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/conditional-format-rule-editor.js +640 -0
- package/dist/cjs/components/editors/data-validation-editor.d.ts +27 -0
- package/dist/cjs/components/editors/data-validation-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/data-validation-editor.js +163 -0
- package/dist/cjs/components/editors/data-validation-rule-editor.d.ts +17 -0
- package/dist/cjs/components/editors/data-validation-rule-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/data-validation-rule-editor.js +217 -0
- package/dist/cjs/components/editors/embed-editor.d.ts +19 -0
- package/dist/cjs/components/editors/embed-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/embed-editor.js +80 -0
- package/dist/cjs/components/editors/insert-image-editor.d.ts +20 -0
- package/dist/cjs/components/editors/insert-image-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/insert-image-editor.js +78 -0
- package/dist/cjs/components/editors/insert-link-editor.d.ts +20 -0
- package/dist/cjs/components/editors/insert-link-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/insert-link-editor.js +64 -0
- package/dist/cjs/components/editors/named-range-editor.d.ts +13 -0
- package/dist/cjs/components/editors/named-range-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/named-range-editor.js +106 -0
- package/dist/cjs/components/editors/resize-dimension-editor.d.ts +9 -0
- package/dist/cjs/components/editors/resize-dimension-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/resize-dimension-editor.js +62 -0
- package/dist/cjs/components/editors/sheet-filter.d.ts +59 -0
- package/dist/cjs/components/editors/sheet-filter.d.ts.map +1 -0
- package/dist/cjs/components/editors/sheet-filter.js +119 -0
- package/dist/cjs/components/editors/table-editor.d.ts +12 -0
- package/dist/cjs/components/editors/table-editor.d.ts.map +1 -0
- package/dist/cjs/components/editors/table-editor.js +105 -0
- package/dist/cjs/components/index.d.ts +13 -0
- package/dist/cjs/components/index.d.ts.map +1 -0
- package/dist/cjs/components/index.js +12 -0
- package/dist/cjs/generated-names.d.ts +51 -0
- package/dist/cjs/generated-names.d.ts.map +1 -0
- package/dist/cjs/generated-names.js +5 -0
- package/dist/cjs/helpers/iterative-calculation.d.ts +4 -0
- package/dist/cjs/helpers/iterative-calculation.d.ts.map +1 -0
- package/dist/cjs/helpers/iterative-calculation.js +44 -0
- package/dist/cjs/helpers/sheet-title.d.ts +5 -0
- package/dist/cjs/helpers/sheet-title.d.ts.map +1 -0
- package/dist/cjs/helpers/sheet-title.js +11 -0
- package/dist/cjs/helpers.d.ts +45 -0
- package/dist/cjs/helpers.d.ts.map +1 -0
- package/dist/cjs/helpers.js +154 -0
- package/dist/cjs/hooks/use-async-datasource.d.ts +57 -0
- package/dist/cjs/hooks/use-async-datasource.d.ts.map +1 -0
- package/dist/cjs/hooks/use-async-datasource.js +329 -0
- package/dist/cjs/hooks/use-calculation-initialize.d.ts +61 -0
- package/dist/cjs/hooks/use-calculation-initialize.d.ts.map +1 -0
- package/dist/cjs/hooks/use-calculation-initialize.js +800 -0
- package/dist/cjs/hooks/use-calculation-process-array.d.ts +20 -0
- package/dist/cjs/hooks/use-calculation-process-array.d.ts.map +1 -0
- package/dist/cjs/hooks/use-calculation-process-array.js +331 -0
- package/dist/cjs/hooks/use-calculation-queue.d.ts +10 -0
- package/dist/cjs/hooks/use-calculation-queue.d.ts.map +1 -0
- package/dist/cjs/hooks/use-calculation-queue.js +15 -0
- package/dist/cjs/hooks/use-calculation-worker.d.ts +37 -0
- package/dist/cjs/hooks/use-calculation-worker.d.ts.map +1 -0
- package/dist/cjs/hooks/use-calculation-worker.js +1868 -0
- package/dist/cjs/hooks/use-calculation.d.ts +173 -0
- package/dist/cjs/hooks/use-calculation.d.ts.map +1 -0
- package/dist/cjs/hooks/use-calculation.js +2735 -0
- package/dist/cjs/hooks/use-can-edit-cellrange.d.ts +31 -0
- package/dist/cjs/hooks/use-can-edit-cellrange.d.ts.map +1 -0
- package/dist/cjs/hooks/use-can-edit-cellrange.js +86 -0
- package/dist/cjs/hooks/use-cellxfs-registry.d.ts +6 -0
- package/dist/cjs/hooks/use-cellxfs-registry.d.ts.map +1 -0
- package/dist/cjs/hooks/use-cellxfs-registry.js +22 -0
- package/dist/cjs/hooks/use-citations.d.ts +19 -0
- package/dist/cjs/hooks/use-citations.d.ts.map +1 -0
- package/dist/cjs/hooks/use-citations.js +62 -0
- package/dist/cjs/hooks/use-comments.d.ts +14 -0
- package/dist/cjs/hooks/use-comments.d.ts.map +1 -0
- package/dist/cjs/hooks/use-comments.js +49 -0
- package/dist/cjs/hooks/use-conditional-formatting-rules.d.ts +22 -0
- package/dist/cjs/hooks/use-conditional-formatting-rules.d.ts.map +1 -0
- package/dist/cjs/hooks/use-conditional-formatting-rules.js +95 -0
- package/dist/cjs/hooks/use-data-validation-rules.d.ts +54 -0
- package/dist/cjs/hooks/use-data-validation-rules.d.ts.map +1 -0
- package/dist/cjs/hooks/use-data-validation-rules.js +151 -0
- package/dist/cjs/hooks/use-deferred-calculation-flush.d.ts +14 -0
- package/dist/cjs/hooks/use-deferred-calculation-flush.d.ts.map +1 -0
- package/dist/cjs/hooks/use-deferred-calculation-flush.js +81 -0
- package/dist/cjs/hooks/use-idle-scheduler.d.ts +5 -0
- package/dist/cjs/hooks/use-idle-scheduler.d.ts.map +1 -0
- package/dist/cjs/hooks/use-idle-scheduler.js +46 -0
- package/dist/cjs/hooks/use-indent.d.ts +23 -0
- package/dist/cjs/hooks/use-indent.d.ts.map +1 -0
- package/dist/cjs/hooks/use-indent.js +98 -0
- package/dist/cjs/hooks/use-named-range.d.ts +7 -0
- package/dist/cjs/hooks/use-named-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-named-range.js +70 -0
- package/dist/cjs/hooks/use-on-adjust-row-height.d.ts +11 -0
- package/dist/cjs/hooks/use-on-adjust-row-height.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-adjust-row-height.js +66 -0
- package/dist/cjs/hooks/use-on-autoresize.d.ts +17 -0
- package/dist/cjs/hooks/use-on-autoresize.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-autoresize.js +39 -0
- package/dist/cjs/hooks/use-on-banded-ranges.d.ts +15 -0
- package/dist/cjs/hooks/use-on-banded-ranges.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-banded-ranges.js +38 -0
- package/dist/cjs/hooks/use-on-calculation-begin.d.ts +14 -0
- package/dist/cjs/hooks/use-on-calculation-begin.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-calculation-begin.js +36 -0
- package/dist/cjs/hooks/use-on-calculation-success.d.ts +22 -0
- package/dist/cjs/hooks/use-on-calculation-success.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-calculation-success.js +182 -0
- package/dist/cjs/hooks/use-on-change-batch-stream.d.ts +7 -0
- package/dist/cjs/hooks/use-on-change-batch-stream.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-batch-stream.js +59 -0
- package/dist/cjs/hooks/use-on-change-batch.d.ts +54 -0
- package/dist/cjs/hooks/use-on-change-batch.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-batch.js +124 -0
- package/dist/cjs/hooks/use-on-change-calculated-column.d.ts +23 -0
- package/dist/cjs/hooks/use-on-change-calculated-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-calculated-column.js +30 -0
- package/dist/cjs/hooks/use-on-change-decimals.d.ts +22 -0
- package/dist/cjs/hooks/use-on-change-decimals.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-decimals.js +47 -0
- package/dist/cjs/hooks/use-on-change-formatting.d.ts +44 -0
- package/dist/cjs/hooks/use-on-change-formatting.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-formatting.js +165 -0
- package/dist/cjs/hooks/use-on-change-sheet-tabcolor.d.ts +11 -0
- package/dist/cjs/hooks/use-on-change-sheet-tabcolor.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-sheet-tabcolor.js +27 -0
- package/dist/cjs/hooks/use-on-change-table-column.d.ts +25 -0
- package/dist/cjs/hooks/use-on-change-table-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-table-column.js +53 -0
- package/dist/cjs/hooks/use-on-change-theme.d.ts +11 -0
- package/dist/cjs/hooks/use-on-change-theme.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change-theme.js +20 -0
- package/dist/cjs/hooks/use-on-change.d.ts +61 -0
- package/dist/cjs/hooks/use-on-change.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-change.js +298 -0
- package/dist/cjs/hooks/use-on-clear-formatting.d.ts +17 -0
- package/dist/cjs/hooks/use-on-clear-formatting.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-clear-formatting.js +46 -0
- package/dist/cjs/hooks/use-on-collapse-column-group.d.ts +11 -0
- package/dist/cjs/hooks/use-on-collapse-column-group.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-collapse-column-group.js +47 -0
- package/dist/cjs/hooks/use-on-collapse-row-group.d.ts +18 -0
- package/dist/cjs/hooks/use-on-collapse-row-group.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-collapse-row-group.js +57 -0
- package/dist/cjs/hooks/use-on-copy.d.ts +49 -0
- package/dist/cjs/hooks/use-on-copy.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-copy.js +325 -0
- package/dist/cjs/hooks/use-on-create-named-range.d.ts +13 -0
- package/dist/cjs/hooks/use-on-create-named-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-create-named-range.js +33 -0
- package/dist/cjs/hooks/use-on-create-sheet.d.ts +23 -0
- package/dist/cjs/hooks/use-on-create-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-create-sheet.js +66 -0
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts +28 -0
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-cells-shift-left.js +66 -0
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts +28 -0
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-cells-shift-up.js +66 -0
- package/dist/cjs/hooks/use-on-delete-column.d.ts +38 -0
- package/dist/cjs/hooks/use-on-delete-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-column.js +87 -0
- package/dist/cjs/hooks/use-on-delete-named-range.d.ts +14 -0
- package/dist/cjs/hooks/use-on-delete-named-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-named-range.js +23 -0
- package/dist/cjs/hooks/use-on-delete-row.d.ts +38 -0
- package/dist/cjs/hooks/use-on-delete-row.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-row.js +87 -0
- package/dist/cjs/hooks/use-on-delete-sheet.d.ts +16 -0
- package/dist/cjs/hooks/use-on-delete-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-sheet.js +37 -0
- package/dist/cjs/hooks/use-on-delete-table-row.d.ts +29 -0
- package/dist/cjs/hooks/use-on-delete-table-row.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete-table-row.js +56 -0
- package/dist/cjs/hooks/use-on-delete.d.ts +33 -0
- package/dist/cjs/hooks/use-on-delete.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-delete.js +60 -0
- package/dist/cjs/hooks/use-on-drag-n-drop.d.ts +55 -0
- package/dist/cjs/hooks/use-on-drag-n-drop.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-drag-n-drop.js +191 -0
- package/dist/cjs/hooks/use-on-duplicate-sheet.d.ts +29 -0
- package/dist/cjs/hooks/use-on-duplicate-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-duplicate-sheet.js +65 -0
- package/dist/cjs/hooks/use-on-embeds.d.ts +19 -0
- package/dist/cjs/hooks/use-on-embeds.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-embeds.js +87 -0
- package/dist/cjs/hooks/use-on-expand-column-group.d.ts +11 -0
- package/dist/cjs/hooks/use-on-expand-column-group.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-expand-column-group.js +45 -0
- package/dist/cjs/hooks/use-on-expand-row-group.d.ts +18 -0
- package/dist/cjs/hooks/use-on-expand-row-group.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-expand-row-group.js +52 -0
- package/dist/cjs/hooks/use-on-fill-range.d.ts +9 -0
- package/dist/cjs/hooks/use-on-fill-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-fill-range.js +55 -0
- package/dist/cjs/hooks/use-on-fill.d.ts +29 -0
- package/dist/cjs/hooks/use-on-fill.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-fill.js +78 -0
- package/dist/cjs/hooks/use-on-filter-table.d.ts +76 -0
- package/dist/cjs/hooks/use-on-filter-table.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-filter-table.js +429 -0
- package/dist/cjs/hooks/use-on-find-replace.d.ts +19 -0
- package/dist/cjs/hooks/use-on-find-replace.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-find-replace.js +150 -0
- package/dist/cjs/hooks/use-on-freeze.d.ts +13 -0
- package/dist/cjs/hooks/use-on-freeze.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-freeze.js +56 -0
- package/dist/cjs/hooks/use-on-group-columns.d.ts +11 -0
- package/dist/cjs/hooks/use-on-group-columns.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-group-columns.js +49 -0
- package/dist/cjs/hooks/use-on-group-rows.d.ts +17 -0
- package/dist/cjs/hooks/use-on-group-rows.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-group-rows.js +55 -0
- package/dist/cjs/hooks/use-on-hide-column.d.ts +23 -0
- package/dist/cjs/hooks/use-on-hide-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-hide-column.js +55 -0
- package/dist/cjs/hooks/use-on-hide-row.d.ts +32 -0
- package/dist/cjs/hooks/use-on-hide-row.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-hide-row.js +58 -0
- package/dist/cjs/hooks/use-on-hide-show-sheet.d.ts +18 -0
- package/dist/cjs/hooks/use-on-hide-show-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-hide-show-sheet.js +90 -0
- package/dist/cjs/hooks/use-on-import-csv-legacy.d.ts +8 -0
- package/dist/cjs/hooks/use-on-import-csv-legacy.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-import-csv-legacy.js +165 -0
- package/dist/cjs/hooks/use-on-import-csv.d.ts +28 -0
- package/dist/cjs/hooks/use-on-import-csv.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-import-csv.js +332 -0
- package/dist/cjs/hooks/use-on-import-excel.d.ts +67 -0
- package/dist/cjs/hooks/use-on-import-excel.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-import-excel.js +689 -0
- package/dist/cjs/hooks/use-on-insert-autosum.d.ts +9 -0
- package/dist/cjs/hooks/use-on-insert-autosum.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-autosum.js +105 -0
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts +28 -0
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-cells-shift-down.js +66 -0
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts +28 -0
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-cells-shift-right.js +66 -0
- package/dist/cjs/hooks/use-on-insert-checkbox.d.ts +17 -0
- package/dist/cjs/hooks/use-on-insert-checkbox.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-checkbox.js +87 -0
- package/dist/cjs/hooks/use-on-insert-column.d.ts +40 -0
- package/dist/cjs/hooks/use-on-insert-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-column.js +93 -0
- package/dist/cjs/hooks/use-on-insert-date-time.d.ts +4 -0
- package/dist/cjs/hooks/use-on-insert-date-time.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-date-time.js +12 -0
- package/dist/cjs/hooks/use-on-insert-date.d.ts +4 -0
- package/dist/cjs/hooks/use-on-insert-date.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-date.js +13 -0
- package/dist/cjs/hooks/use-on-insert-image.d.ts +24 -0
- package/dist/cjs/hooks/use-on-insert-image.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-image.js +145 -0
- package/dist/cjs/hooks/use-on-insert-link.d.ts +25 -0
- package/dist/cjs/hooks/use-on-insert-link.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-link.js +220 -0
- package/dist/cjs/hooks/use-on-insert-note.d.ts +4 -0
- package/dist/cjs/hooks/use-on-insert-note.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-note.js +14 -0
- package/dist/cjs/hooks/use-on-insert-row.d.ts +38 -0
- package/dist/cjs/hooks/use-on-insert-row.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-row.js +106 -0
- package/dist/cjs/hooks/use-on-insert-table-row.d.ts +31 -0
- package/dist/cjs/hooks/use-on-insert-table-row.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-table-row.js +60 -0
- package/dist/cjs/hooks/use-on-insert-time.d.ts +4 -0
- package/dist/cjs/hooks/use-on-insert-time.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-insert-time.js +12 -0
- package/dist/cjs/hooks/use-on-locale-change.d.ts +35 -0
- package/dist/cjs/hooks/use-on-locale-change.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-locale-change.js +314 -0
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.d.ts +28 -0
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.js +366 -0
- package/dist/cjs/hooks/use-on-move-columns.d.ts +28 -0
- package/dist/cjs/hooks/use-on-move-columns.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-move-columns.js +378 -0
- package/dist/cjs/hooks/use-on-move-rows.d.ts +30 -0
- package/dist/cjs/hooks/use-on-move-rows.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-move-rows.js +293 -0
- package/dist/cjs/hooks/use-on-move-selection.d.ts +35 -0
- package/dist/cjs/hooks/use-on-move-selection.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-move-selection.js +477 -0
- package/dist/cjs/hooks/use-on-move-sheet.d.ts +12 -0
- package/dist/cjs/hooks/use-on-move-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-move-sheet.js +68 -0
- package/dist/cjs/hooks/use-on-move-table-columns.d.ts +21 -0
- package/dist/cjs/hooks/use-on-move-table-columns.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-move-table-columns.js +249 -0
- package/dist/cjs/hooks/use-on-paste.d.ts +79 -0
- package/dist/cjs/hooks/use-on-paste.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-paste.js +985 -0
- package/dist/cjs/hooks/use-on-protect-range.d.ts +20 -0
- package/dist/cjs/hooks/use-on-protect-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-protect-range.js +67 -0
- package/dist/cjs/hooks/use-on-protect-sheet.d.ts +19 -0
- package/dist/cjs/hooks/use-on-protect-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-protect-sheet.js +65 -0
- package/dist/cjs/hooks/use-on-remove-duplicates.d.ts +21 -0
- package/dist/cjs/hooks/use-on-remove-duplicates.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-remove-duplicates.js +40 -0
- package/dist/cjs/hooks/use-on-rename-sheet.d.ts +21 -0
- package/dist/cjs/hooks/use-on-rename-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-rename-sheet.js +80 -0
- package/dist/cjs/hooks/use-on-request-calculate-wrapper.d.ts +30 -0
- package/dist/cjs/hooks/use-on-request-calculate-wrapper.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-calculate-wrapper.js +90 -0
- package/dist/cjs/hooks/use-on-request-conditional-format.d.ts +2 -0
- package/dist/cjs/hooks/use-on-request-conditional-format.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-conditional-format.js +8 -0
- package/dist/cjs/hooks/use-on-request-data-validation.d.ts +7 -0
- package/dist/cjs/hooks/use-on-request-data-validation.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-data-validation.js +23 -0
- package/dist/cjs/hooks/use-on-request-define-named-range.d.ts +8 -0
- package/dist/cjs/hooks/use-on-request-define-named-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-define-named-range.js +19 -0
- package/dist/cjs/hooks/use-on-request-delete-sheet.d.ts +2 -0
- package/dist/cjs/hooks/use-on-request-delete-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-delete-sheet.js +12 -0
- package/dist/cjs/hooks/use-on-request-edit-table.d.ts +3 -0
- package/dist/cjs/hooks/use-on-request-edit-table.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-edit-table.js +11 -0
- package/dist/cjs/hooks/use-on-request-format-cells.d.ts +2 -0
- package/dist/cjs/hooks/use-on-request-format-cells.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-format-cells.js +8 -0
- package/dist/cjs/hooks/use-on-request-insert-image.d.ts +3 -0
- package/dist/cjs/hooks/use-on-request-insert-image.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-insert-image.js +12 -0
- package/dist/cjs/hooks/use-on-request-insert-link.d.ts +5 -0
- package/dist/cjs/hooks/use-on-request-insert-link.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-insert-link.js +9 -0
- package/dist/cjs/hooks/use-on-request-resize.d.ts +3 -0
- package/dist/cjs/hooks/use-on-request-resize.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-resize.js +13 -0
- package/dist/cjs/hooks/use-on-request-update-named-range.d.ts +3 -0
- package/dist/cjs/hooks/use-on-request-update-named-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-request-update-named-range.js +11 -0
- package/dist/cjs/hooks/use-on-resize-table.d.ts +33 -0
- package/dist/cjs/hooks/use-on-resize-table.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-resize-table.js +218 -0
- package/dist/cjs/hooks/use-on-resize.d.ts +19 -0
- package/dist/cjs/hooks/use-on-resize.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-resize.js +55 -0
- package/dist/cjs/hooks/use-on-set-outline-depth.d.ts +17 -0
- package/dist/cjs/hooks/use-on-set-outline-depth.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-set-outline-depth.js +96 -0
- package/dist/cjs/hooks/use-on-show-column.d.ts +16 -0
- package/dist/cjs/hooks/use-on-show-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-show-column.js +96 -0
- package/dist/cjs/hooks/use-on-show-row.d.ts +22 -0
- package/dist/cjs/hooks/use-on-show-row.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-show-row.js +99 -0
- package/dist/cjs/hooks/use-on-sort-column.d.ts +53 -0
- package/dist/cjs/hooks/use-on-sort-column.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-sort-column.js +300 -0
- package/dist/cjs/hooks/use-on-sort-range.d.ts +42 -0
- package/dist/cjs/hooks/use-on-sort-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-sort-range.js +252 -0
- package/dist/cjs/hooks/use-on-sort-table.d.ts +59 -0
- package/dist/cjs/hooks/use-on-sort-table.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-sort-table.js +345 -0
- package/dist/cjs/hooks/use-on-table.d.ts +49 -0
- package/dist/cjs/hooks/use-on-table.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-table.js +386 -0
- package/dist/cjs/hooks/use-on-trace-dependents-precedents.d.ts +14 -0
- package/dist/cjs/hooks/use-on-trace-dependents-precedents.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-trace-dependents-precedents.js +146 -0
- package/dist/cjs/hooks/use-on-ungroup-columns.d.ts +11 -0
- package/dist/cjs/hooks/use-on-ungroup-columns.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-ungroup-columns.js +57 -0
- package/dist/cjs/hooks/use-on-ungroup-rows.d.ts +17 -0
- package/dist/cjs/hooks/use-on-ungroup-rows.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-ungroup-rows.js +63 -0
- package/dist/cjs/hooks/use-on-update-named-range.d.ts +19 -0
- package/dist/cjs/hooks/use-on-update-named-range.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-update-named-range.js +133 -0
- package/dist/cjs/hooks/use-on-update-note.d.ts +13 -0
- package/dist/cjs/hooks/use-on-update-note.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-update-note.js +21 -0
- package/dist/cjs/hooks/use-on-update-sheet.d.ts +10 -0
- package/dist/cjs/hooks/use-on-update-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-update-sheet.js +12 -0
- package/dist/cjs/hooks/use-paint-format.d.ts +17 -0
- package/dist/cjs/hooks/use-paint-format.d.ts.map +1 -0
- package/dist/cjs/hooks/use-paint-format.js +118 -0
- package/dist/cjs/hooks/use-search.d.ts +81 -0
- package/dist/cjs/hooks/use-search.d.ts.map +1 -0
- package/dist/cjs/hooks/use-search.js +261 -0
- package/dist/cjs/hooks/use-select-next-prev-sheet.d.ts +11 -0
- package/dist/cjs/hooks/use-select-next-prev-sheet.d.ts.map +1 -0
- package/dist/cjs/hooks/use-select-next-prev-sheet.js +22 -0
- package/dist/cjs/hooks/use-sheet-observer.d.ts +20 -0
- package/dist/cjs/hooks/use-sheet-observer.d.ts.map +1 -0
- package/dist/cjs/hooks/use-sheet-observer.js +127 -0
- package/dist/cjs/hooks/use-sheet-properties.d.ts +105 -0
- package/dist/cjs/hooks/use-sheet-properties.d.ts.map +1 -0
- package/dist/cjs/hooks/use-sheet-properties.js +1019 -0
- package/dist/cjs/hooks/use-sheet-state.d.ts +17 -0
- package/dist/cjs/hooks/use-sheet-state.d.ts.map +1 -0
- package/dist/cjs/hooks/use-sheet-state.js +84 -0
- package/dist/cjs/hooks/use-sheetdata-subscriber.d.ts +10 -0
- package/dist/cjs/hooks/use-sheetdata-subscriber.d.ts.map +1 -0
- package/dist/cjs/hooks/use-sheetdata-subscriber.js +15 -0
- package/dist/cjs/hooks/use-slicers.d.ts +19 -0
- package/dist/cjs/hooks/use-slicers.d.ts.map +1 -0
- package/dist/cjs/hooks/use-slicers.js +84 -0
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts +19 -0
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts.map +1 -0
- package/dist/cjs/hooks/use-split-text-to-columns.js +32 -0
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +627 -0
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -0
- package/dist/cjs/hooks/use-spreadsheet-state.js +2038 -0
- package/dist/cjs/hooks/use-ss-registry.d.ts +6 -0
- package/dist/cjs/hooks/use-ss-registry.d.ts.map +1 -0
- package/dist/cjs/hooks/use-ss-registry.js +17 -0
- package/dist/cjs/hooks/use-structured-reference.d.ts +8 -0
- package/dist/cjs/hooks/use-structured-reference.d.ts.map +1 -0
- package/dist/cjs/hooks/use-structured-reference.js +132 -0
- package/dist/cjs/hooks/use-undo-redo-actions.d.ts +40 -0
- package/dist/cjs/hooks/use-undo-redo-actions.d.ts.map +1 -0
- package/dist/cjs/hooks/use-undo-redo-actions.js +209 -0
- package/dist/cjs/hooks/use-undo-redo.d.ts +69 -0
- package/dist/cjs/hooks/use-undo-redo.d.ts.map +1 -0
- package/dist/cjs/hooks/use-undo-redo.js +124 -0
- package/dist/cjs/hooks/utils/frozen-sort.d.ts +9 -0
- package/dist/cjs/hooks/utils/frozen-sort.d.ts.map +1 -0
- package/dist/cjs/hooks/utils/frozen-sort.js +28 -0
- package/dist/cjs/hooks/utils/sort-rows.d.ts +32 -0
- package/dist/cjs/hooks/utils/sort-rows.d.ts.map +1 -0
- package/dist/cjs/hooks/utils/sort-rows.js +113 -0
- package/dist/cjs/index.d.ts +38 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +39 -0
- package/dist/cjs/interface/apply-fill.d.ts +6 -0
- package/dist/cjs/interface/apply-fill.d.ts.map +1 -0
- package/dist/cjs/interface/apply-fill.js +203 -0
- package/dist/cjs/interface/auto-resize.d.ts +4 -0
- package/dist/cjs/interface/auto-resize.d.ts.map +1 -0
- package/dist/cjs/interface/auto-resize.js +63 -0
- package/dist/cjs/interface/calculation-interface.d.ts +67 -0
- package/dist/cjs/interface/calculation-interface.d.ts.map +1 -0
- package/dist/cjs/interface/calculation-interface.js +409 -0
- package/dist/cjs/interface/change-batch-stream.d.ts +25 -0
- package/dist/cjs/interface/change-batch-stream.d.ts.map +1 -0
- package/dist/cjs/interface/change-batch-stream.js +428 -0
- package/dist/cjs/interface/change-batch.d.ts +39 -0
- package/dist/cjs/interface/change-batch.d.ts.map +1 -0
- package/dist/cjs/interface/change-batch.js +329 -0
- package/dist/cjs/interface/change-border.d.ts +5 -0
- package/dist/cjs/interface/change-border.d.ts.map +1 -0
- package/dist/cjs/interface/change-border.js +141 -0
- package/dist/cjs/interface/change-calculated-column.d.ts +5 -0
- package/dist/cjs/interface/change-calculated-column.d.ts.map +1 -0
- package/dist/cjs/interface/change-calculated-column.js +131 -0
- package/dist/cjs/interface/change-decimals.d.ts +7 -0
- package/dist/cjs/interface/change-decimals.d.ts.map +1 -0
- package/dist/cjs/interface/change-decimals.js +82 -0
- package/dist/cjs/interface/change-formatting.d.ts +4 -0
- package/dist/cjs/interface/change-formatting.d.ts.map +1 -0
- package/dist/cjs/interface/change-formatting.js +240 -0
- package/dist/cjs/interface/change-sheet-tabcolor.d.ts +4 -0
- package/dist/cjs/interface/change-sheet-tabcolor.d.ts.map +1 -0
- package/dist/cjs/interface/change-sheet-tabcolor.js +21 -0
- package/dist/cjs/interface/change-table-column.d.ts +49 -0
- package/dist/cjs/interface/change-table-column.d.ts.map +1 -0
- package/dist/cjs/interface/change-table-column.js +267 -0
- package/dist/cjs/interface/change-theme.d.ts +4 -0
- package/dist/cjs/interface/change-theme.d.ts.map +1 -0
- package/dist/cjs/interface/change-theme.js +23 -0
- package/dist/cjs/interface/chart-extensions.d.ts +32 -0
- package/dist/cjs/interface/chart-extensions.d.ts.map +1 -0
- package/dist/cjs/interface/chart-extensions.js +71 -0
- package/dist/cjs/interface/citations.d.ts +33 -0
- package/dist/cjs/interface/citations.d.ts.map +1 -0
- package/dist/cjs/interface/citations.js +142 -0
- package/dist/cjs/interface/clear-formatting.d.ts +5 -0
- package/dist/cjs/interface/clear-formatting.d.ts.map +1 -0
- package/dist/cjs/interface/clear-formatting.js +72 -0
- package/dist/cjs/interface/conditional-formatting-rules.d.ts +7 -0
- package/dist/cjs/interface/conditional-formatting-rules.d.ts.map +1 -0
- package/dist/cjs/interface/conditional-formatting-rules.js +191 -0
- package/dist/cjs/interface/create-table.d.ts +5 -0
- package/dist/cjs/interface/create-table.d.ts.map +1 -0
- package/dist/cjs/interface/create-table.js +96 -0
- package/dist/cjs/interface/data-validation-rules.d.ts +25 -0
- package/dist/cjs/interface/data-validation-rules.d.ts.map +1 -0
- package/dist/cjs/interface/data-validation-rules.js +366 -0
- package/dist/cjs/interface/data-validation-utils.d.ts +12 -0
- package/dist/cjs/interface/data-validation-utils.d.ts.map +1 -0
- package/dist/cjs/interface/data-validation-utils.js +118 -0
- package/dist/cjs/interface/delete-cells-shift-left.d.ts +5 -0
- package/dist/cjs/interface/delete-cells-shift-left.d.ts.map +1 -0
- package/dist/cjs/interface/delete-cells-shift-left.js +160 -0
- package/dist/cjs/interface/delete-cells-shift-up.d.ts +5 -0
- package/dist/cjs/interface/delete-cells-shift-up.d.ts.map +1 -0
- package/dist/cjs/interface/delete-cells-shift-up.js +152 -0
- package/dist/cjs/interface/delete-cells.d.ts +6 -0
- package/dist/cjs/interface/delete-cells.d.ts.map +1 -0
- package/dist/cjs/interface/delete-cells.js +231 -0
- package/dist/cjs/interface/delete-column.d.ts +4 -0
- package/dist/cjs/interface/delete-column.d.ts.map +1 -0
- package/dist/cjs/interface/delete-column.js +306 -0
- package/dist/cjs/interface/delete-row.d.ts +4 -0
- package/dist/cjs/interface/delete-row.d.ts.map +1 -0
- package/dist/cjs/interface/delete-row.js +227 -0
- package/dist/cjs/interface/delete-sheet.d.ts +4 -0
- package/dist/cjs/interface/delete-sheet.d.ts.map +1 -0
- package/dist/cjs/interface/delete-sheet.js +81 -0
- package/dist/cjs/interface/delete-table-column.d.ts +4 -0
- package/dist/cjs/interface/delete-table-column.d.ts.map +1 -0
- package/dist/cjs/interface/delete-table-column.js +349 -0
- package/dist/cjs/interface/delete-table-row.d.ts +4 -0
- package/dist/cjs/interface/delete-table-row.d.ts.map +1 -0
- package/dist/cjs/interface/delete-table-row.js +313 -0
- package/dist/cjs/interface/duplicate-sheet.d.ts +4 -0
- package/dist/cjs/interface/duplicate-sheet.d.ts.map +1 -0
- package/dist/cjs/interface/duplicate-sheet.js +232 -0
- package/dist/cjs/interface/embeds.d.ts +9 -0
- package/dist/cjs/interface/embeds.d.ts.map +1 -0
- package/dist/cjs/interface/embeds.js +121 -0
- package/dist/cjs/interface/freeze.d.ts +5 -0
- package/dist/cjs/interface/freeze.d.ts.map +1 -0
- package/dist/cjs/interface/freeze.js +160 -0
- package/dist/cjs/interface/helpers.d.ts +6 -0
- package/dist/cjs/interface/helpers.d.ts.map +1 -0
- package/dist/cjs/interface/helpers.js +44 -0
- package/dist/cjs/interface/hide-column.d.ts +4 -0
- package/dist/cjs/interface/hide-column.d.ts.map +1 -0
- package/dist/cjs/interface/hide-column.js +68 -0
- package/dist/cjs/interface/hide-row.d.ts +4 -0
- package/dist/cjs/interface/hide-row.d.ts.map +1 -0
- package/dist/cjs/interface/hide-row.js +65 -0
- package/dist/cjs/interface/indent.d.ts +7 -0
- package/dist/cjs/interface/indent.d.ts.map +1 -0
- package/dist/cjs/interface/indent.js +97 -0
- package/dist/cjs/interface/insert-cells-shift-down.d.ts +5 -0
- package/dist/cjs/interface/insert-cells-shift-down.d.ts.map +1 -0
- package/dist/cjs/interface/insert-cells-shift-down.js +154 -0
- package/dist/cjs/interface/insert-cells-shift-right.d.ts +5 -0
- package/dist/cjs/interface/insert-cells-shift-right.d.ts.map +1 -0
- package/dist/cjs/interface/insert-cells-shift-right.js +150 -0
- package/dist/cjs/interface/insert-column.d.ts +7 -0
- package/dist/cjs/interface/insert-column.d.ts.map +1 -0
- package/dist/cjs/interface/insert-column.js +645 -0
- package/dist/cjs/interface/insert-note.d.ts +5 -0
- package/dist/cjs/interface/insert-note.d.ts.map +1 -0
- package/dist/cjs/interface/insert-note.js +27 -0
- package/dist/cjs/interface/insert-row.d.ts +4 -0
- package/dist/cjs/interface/insert-row.d.ts.map +1 -0
- package/dist/cjs/interface/insert-row.js +188 -0
- package/dist/cjs/interface/insert-table-row.d.ts +4 -0
- package/dist/cjs/interface/insert-table-row.d.ts.map +1 -0
- package/dist/cjs/interface/insert-table-row.js +348 -0
- package/dist/cjs/interface/interface-cli.d.ts +3 -0
- package/dist/cjs/interface/interface-cli.d.ts.map +1 -0
- package/dist/cjs/interface/interface-cli.js +76 -0
- package/dist/cjs/interface/named-range-operations.d.ts +19 -0
- package/dist/cjs/interface/named-range-operations.d.ts.map +1 -0
- package/dist/cjs/interface/named-range-operations.js +96 -0
- package/dist/cjs/interface/new-sheet.d.ts +4 -0
- package/dist/cjs/interface/new-sheet.d.ts.map +1 -0
- package/dist/cjs/interface/new-sheet.js +109 -0
- package/dist/cjs/interface/pivot-extensions.d.ts +27 -0
- package/dist/cjs/interface/pivot-extensions.d.ts.map +1 -0
- package/dist/cjs/interface/pivot-extensions.js +62 -0
- package/dist/cjs/interface/remove-duplicates.d.ts +11 -0
- package/dist/cjs/interface/remove-duplicates.d.ts.map +1 -0
- package/dist/cjs/interface/remove-duplicates.js +132 -0
- package/dist/cjs/interface/remove-table.d.ts +4 -0
- package/dist/cjs/interface/remove-table.d.ts.map +1 -0
- package/dist/cjs/interface/remove-table.js +53 -0
- package/dist/cjs/interface/resize-utils.d.ts +18 -0
- package/dist/cjs/interface/resize-utils.d.ts.map +1 -0
- package/dist/cjs/interface/resize-utils.js +60 -0
- package/dist/cjs/interface/resize.d.ts +5 -0
- package/dist/cjs/interface/resize.d.ts.map +1 -0
- package/dist/cjs/interface/resize.js +56 -0
- package/dist/cjs/interface/slicers.d.ts +9 -0
- package/dist/cjs/interface/slicers.d.ts.map +1 -0
- package/dist/cjs/interface/slicers.js +113 -0
- package/dist/cjs/interface/split-text.d.ts +5 -0
- package/dist/cjs/interface/split-text.d.ts.map +1 -0
- package/dist/cjs/interface/split-text.js +120 -0
- package/dist/cjs/interface/spreadsheet-interface.d.ts +642 -0
- package/dist/cjs/interface/spreadsheet-interface.d.ts.map +1 -0
- package/dist/cjs/interface/spreadsheet-interface.js +2787 -0
- package/dist/cjs/interface/table-totalrow.d.ts +20 -0
- package/dist/cjs/interface/table-totalrow.d.ts.map +1 -0
- package/dist/cjs/interface/table-totalrow.js +170 -0
- package/dist/cjs/interface/table-utils.d.ts +21 -0
- package/dist/cjs/interface/table-utils.d.ts.map +1 -0
- package/dist/cjs/interface/table-utils.js +44 -0
- package/dist/cjs/interface/update-sheet.d.ts +16 -0
- package/dist/cjs/interface/update-sheet.d.ts.map +1 -0
- package/dist/cjs/interface/update-sheet.js +63 -0
- package/dist/cjs/interface/update-table.d.ts +4 -0
- package/dist/cjs/interface/update-table.d.ts.map +1 -0
- package/dist/cjs/interface/update-table.js +109 -0
- package/dist/cjs/server-utils.d.ts +8 -0
- package/dist/cjs/server-utils.d.ts.map +1 -0
- package/dist/cjs/server-utils.js +3 -0
- package/dist/cjs/server.browser.d.ts +9 -0
- package/dist/cjs/server.browser.d.ts.map +1 -0
- package/dist/cjs/server.browser.js +5 -0
- package/dist/cjs/server.d.ts +9 -0
- package/dist/cjs/server.d.ts.map +1 -0
- package/dist/cjs/server.js +5 -0
- package/dist/cjs/shared-string-registry.d.ts +35 -0
- package/dist/cjs/shared-string-registry.d.ts.map +1 -0
- package/dist/cjs/shared-string-registry.js +314 -0
- package/dist/cjs/sheet-cell.d.ts +310 -0
- package/dist/cjs/sheet-cell.d.ts.map +1 -0
- package/dist/cjs/sheet-cell.js +1809 -0
- package/dist/cjs/test-setup.d.ts +2 -0
- package/dist/cjs/test-setup.d.ts.map +1 -0
- package/dist/cjs/test-setup.js +3 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/cjs/types.d.ts +44 -0
- package/dist/cjs/types.d.ts.map +1 -0
- package/dist/cjs/types.js +33 -0
- package/dist/cjs/validation-schema/table.schema.d.ts +6 -0
- package/dist/cjs/validation-schema/table.schema.d.ts.map +1 -0
- package/dist/cjs/validation-schema/table.schema.js +4 -0
- package/dist/cjs/vitest.config.d.ts +3 -0
- package/dist/cjs/vitest.config.d.ts.map +1 -0
- package/dist/cjs/vitest.config.js +22 -0
- package/dist/esm/api/border.d.ts +9 -0
- package/dist/esm/api/border.d.ts.map +1 -0
- package/dist/esm/api/border.js +25 -0
- package/dist/esm/api/conditional-format.d.ts +2 -0
- package/dist/esm/api/conditional-format.d.ts.map +1 -0
- package/dist/esm/api/conditional-format.js +5 -0
- package/dist/esm/api/copy-paste.d.ts +20 -0
- package/dist/esm/api/copy-paste.d.ts.map +1 -0
- package/dist/esm/api/copy-paste.js +302 -0
- package/dist/esm/api/data-validation.d.ts +2 -0
- package/dist/esm/api/data-validation.d.ts.map +1 -0
- package/dist/esm/api/data-validation.js +5 -0
- package/dist/esm/api/datatype.d.ts +89 -0
- package/dist/esm/api/datatype.d.ts.map +1 -0
- package/dist/esm/api/datatype.js +639 -0
- package/dist/esm/api/date.d.ts +27 -0
- package/dist/esm/api/date.d.ts.map +1 -0
- package/dist/esm/api/date.js +220 -0
- package/dist/esm/api/decimals.d.ts +10 -0
- package/dist/esm/api/decimals.d.ts.map +1 -0
- package/dist/esm/api/decimals.js +181 -0
- package/dist/esm/api/dependency.d.ts +64 -0
- package/dist/esm/api/dependency.d.ts.map +1 -0
- package/dist/esm/api/dependency.js +251 -0
- package/dist/esm/api/fill.d.ts +88 -0
- package/dist/esm/api/fill.d.ts.map +1 -0
- package/dist/esm/api/fill.js +919 -0
- package/dist/esm/api/filter-range.d.ts +4 -0
- package/dist/esm/api/filter-range.d.ts.map +1 -0
- package/dist/esm/api/filter-range.js +100 -0
- package/dist/esm/api/filter.d.ts +24 -0
- package/dist/esm/api/filter.d.ts.map +1 -0
- package/dist/esm/api/filter.js +62 -0
- package/dist/esm/api/format-caches.d.ts +43 -0
- package/dist/esm/api/format-caches.d.ts.map +1 -0
- package/dist/esm/api/format-caches.js +95 -0
- package/dist/esm/api/formula.d.ts +69 -0
- package/dist/esm/api/formula.d.ts.map +1 -0
- package/dist/esm/api/formula.js +422 -0
- package/dist/esm/api/immer-utils.d.ts +66 -0
- package/dist/esm/api/immer-utils.d.ts.map +1 -0
- package/dist/esm/api/immer-utils.js +1552 -0
- package/dist/esm/api/intl.d.ts +51 -0
- package/dist/esm/api/intl.d.ts.map +1 -0
- package/dist/esm/api/intl.js +257 -0
- package/dist/esm/api/merges.d.ts +7 -0
- package/dist/esm/api/merges.d.ts.map +1 -0
- package/dist/esm/api/merges.js +174 -0
- package/dist/esm/api/outline.d.ts +33 -0
- package/dist/esm/api/outline.d.ts.map +1 -0
- package/dist/esm/api/outline.js +56 -0
- package/dist/esm/api/parse-html.d.ts +15 -0
- package/dist/esm/api/parse-html.d.ts.map +1 -0
- package/dist/esm/api/parse-html.js +865 -0
- package/dist/esm/api/patches.d.ts +11 -0
- package/dist/esm/api/patches.d.ts.map +1 -0
- package/dist/esm/api/patches.js +206 -0
- package/dist/esm/api/pivot-range.d.ts +8 -0
- package/dist/esm/api/pivot-range.d.ts.map +1 -0
- package/dist/esm/api/pivot-range.js +93 -0
- package/dist/esm/api/range-rule-helpers.d.ts +65 -0
- package/dist/esm/api/range-rule-helpers.d.ts.map +1 -0
- package/dist/esm/api/range-rule-helpers.js +138 -0
- package/dist/esm/api/range.d.ts +19 -0
- package/dist/esm/api/range.d.ts.map +1 -0
- package/dist/esm/api/range.js +136 -0
- package/dist/esm/api/rename-sheet.d.ts +22 -0
- package/dist/esm/api/rename-sheet.d.ts.map +1 -0
- package/dist/esm/api/rename-sheet.js +41 -0
- package/dist/esm/api/selection.d.ts +36 -0
- package/dist/esm/api/selection.d.ts.map +1 -0
- package/dist/esm/api/selection.js +138 -0
- package/dist/esm/api/sort.d.ts +3 -0
- package/dist/esm/api/sort.d.ts.map +1 -0
- package/dist/esm/api/sort.js +33 -0
- package/dist/esm/api/split-text.d.ts +2 -0
- package/dist/esm/api/split-text.d.ts.map +1 -0
- package/dist/esm/api/split-text.js +24 -0
- package/dist/esm/api/structural-formula-update.d.ts +75 -0
- package/dist/esm/api/structural-formula-update.d.ts.map +1 -0
- package/dist/esm/api/structural-formula-update.js +431 -0
- package/dist/esm/api/table.d.ts +39 -0
- package/dist/esm/api/table.d.ts.map +1 -0
- package/dist/esm/api/table.js +333 -0
- package/dist/esm/api/validation.d.ts +12 -0
- package/dist/esm/api/validation.d.ts.map +1 -0
- package/dist/esm/api/validation.js +297 -0
- package/dist/esm/api/xlsx-source.d.ts +22 -0
- package/dist/esm/api/xlsx-source.d.ts.map +1 -0
- package/dist/esm/api/xlsx-source.js +30 -0
- package/dist/esm/atoms/delete-sheet-atom.d.ts +6 -0
- package/dist/esm/atoms/delete-sheet-atom.d.ts.map +1 -0
- package/dist/esm/atoms/delete-sheet-atom.js +4 -0
- package/dist/esm/atoms/dialog-state.atom.d.ts +23 -0
- package/dist/esm/atoms/dialog-state.atom.d.ts.map +1 -0
- package/dist/esm/atoms/dialog-state.atom.js +34 -0
- package/dist/esm/atoms/editing-data-validation-id.atom.d.ts +7 -0
- package/dist/esm/atoms/editing-data-validation-id.atom.d.ts.map +1 -0
- package/dist/esm/atoms/editing-data-validation-id.atom.js +6 -0
- package/dist/esm/atoms/editing-embed.atom.d.ts +8 -0
- package/dist/esm/atoms/editing-embed.atom.d.ts.map +1 -0
- package/dist/esm/atoms/editing-embed.atom.js +5 -0
- package/dist/esm/atoms/editing-table.atom.d.ts +8 -0
- package/dist/esm/atoms/editing-table.atom.d.ts.map +1 -0
- package/dist/esm/atoms/editing-table.atom.js +6 -0
- package/dist/esm/atoms/error-state.atom.d.ts +10 -0
- package/dist/esm/atoms/error-state.atom.d.ts.map +1 -0
- package/dist/esm/atoms/error-state.atom.js +5 -0
- package/dist/esm/atoms/index.d.ts +5 -0
- package/dist/esm/atoms/index.d.ts.map +1 -0
- package/dist/esm/atoms/index.js +4 -0
- package/dist/esm/atoms/insert-image-state.atom.d.ts +6 -0
- package/dist/esm/atoms/insert-image-state.atom.d.ts.map +1 -0
- package/dist/esm/atoms/insert-image-state.atom.js +5 -0
- package/dist/esm/atoms/named-range.atom.d.ts +8 -0
- package/dist/esm/atoms/named-range.atom.d.ts.map +1 -0
- package/dist/esm/atoms/named-range.atom.js +6 -0
- package/dist/esm/atoms/resize-dimension.atom.d.ts +12 -0
- package/dist/esm/atoms/resize-dimension.atom.d.ts.map +1 -0
- package/dist/esm/atoms/resize-dimension.atom.js +5 -0
- package/dist/esm/atoms/sheet-observer.atom.d.ts +16 -0
- package/dist/esm/atoms/sheet-observer.atom.d.ts.map +1 -0
- package/dist/esm/atoms/sheet-observer.atom.js +16 -0
- package/dist/esm/cellxfs-registry.d.ts +37 -0
- package/dist/esm/cellxfs-registry.d.ts.map +1 -0
- package/dist/esm/cellxfs-registry.js +147 -0
- package/dist/esm/commands.d.ts +691 -0
- package/dist/esm/commands.d.ts.map +1 -0
- package/dist/esm/commands.js +1 -0
- package/dist/esm/components/dialogs/delete-sheet-confirmation.d.ts +7 -0
- package/dist/esm/components/dialogs/delete-sheet-confirmation.d.ts.map +1 -0
- package/dist/esm/components/dialogs/delete-sheet-confirmation.js +29 -0
- package/dist/esm/components/dialogs/error-state.d.ts +3 -0
- package/dist/esm/components/dialogs/error-state.d.ts.map +1 -0
- package/dist/esm/components/dialogs/error-state.js +22 -0
- package/dist/esm/components/editors/cell-format-editor.d.ts +26 -0
- package/dist/esm/components/editors/cell-format-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/cell-format-editor.js +648 -0
- package/dist/esm/components/editors/conditional-format-editor.d.ts +43 -0
- package/dist/esm/components/editors/conditional-format-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/conditional-format-editor.js +172 -0
- package/dist/esm/components/editors/conditional-format-rule-editor.d.ts +27 -0
- package/dist/esm/components/editors/conditional-format-rule-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/conditional-format-rule-editor.js +608 -0
- package/dist/esm/components/editors/data-validation-editor.d.ts +27 -0
- package/dist/esm/components/editors/data-validation-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/data-validation-editor.js +160 -0
- package/dist/esm/components/editors/data-validation-rule-editor.d.ts +17 -0
- package/dist/esm/components/editors/data-validation-rule-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/data-validation-rule-editor.js +194 -0
- package/dist/esm/components/editors/embed-editor.d.ts +19 -0
- package/dist/esm/components/editors/embed-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/embed-editor.js +75 -0
- package/dist/esm/components/editors/insert-image-editor.d.ts +20 -0
- package/dist/esm/components/editors/insert-image-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/insert-image-editor.js +73 -0
- package/dist/esm/components/editors/insert-link-editor.d.ts +20 -0
- package/dist/esm/components/editors/insert-link-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/insert-link-editor.js +60 -0
- package/dist/esm/components/editors/named-range-editor.d.ts +13 -0
- package/dist/esm/components/editors/named-range-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/named-range-editor.js +103 -0
- package/dist/esm/components/editors/resize-dimension-editor.d.ts +9 -0
- package/dist/esm/components/editors/resize-dimension-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/resize-dimension-editor.js +60 -0
- package/dist/esm/components/editors/sheet-filter.d.ts +59 -0
- package/dist/esm/components/editors/sheet-filter.d.ts.map +1 -0
- package/dist/esm/components/editors/sheet-filter.js +88 -0
- package/dist/esm/components/editors/table-editor.d.ts +12 -0
- package/dist/esm/components/editors/table-editor.d.ts.map +1 -0
- package/dist/esm/components/editors/table-editor.js +106 -0
- package/dist/esm/components/index.d.ts +13 -0
- package/dist/esm/components/index.d.ts.map +1 -0
- package/dist/esm/components/index.js +12 -0
- package/dist/esm/generated-names.d.ts +51 -0
- package/dist/esm/generated-names.d.ts.map +1 -0
- package/dist/esm/generated-names.js +5 -0
- package/dist/esm/helpers/iterative-calculation.d.ts +4 -0
- package/dist/esm/helpers/iterative-calculation.d.ts.map +1 -0
- package/dist/esm/helpers/iterative-calculation.js +44 -0
- package/dist/esm/helpers/sheet-title.d.ts +5 -0
- package/dist/esm/helpers/sheet-title.d.ts.map +1 -0
- package/dist/esm/helpers/sheet-title.js +13 -0
- package/dist/esm/helpers.d.ts +45 -0
- package/dist/esm/helpers.d.ts.map +1 -0
- package/dist/esm/helpers.js +143 -0
- package/dist/esm/hooks/use-async-datasource.d.ts +57 -0
- package/dist/esm/hooks/use-async-datasource.d.ts.map +1 -0
- package/dist/esm/hooks/use-async-datasource.js +276 -0
- package/dist/esm/hooks/use-calculation-initialize.d.ts +61 -0
- package/dist/esm/hooks/use-calculation-initialize.d.ts.map +1 -0
- package/dist/esm/hooks/use-calculation-initialize.js +603 -0
- package/dist/esm/hooks/use-calculation-process-array.d.ts +20 -0
- package/dist/esm/hooks/use-calculation-process-array.d.ts.map +1 -0
- package/dist/esm/hooks/use-calculation-process-array.js +279 -0
- package/dist/esm/hooks/use-calculation-queue.d.ts +10 -0
- package/dist/esm/hooks/use-calculation-queue.d.ts.map +1 -0
- package/dist/esm/hooks/use-calculation-queue.js +13 -0
- package/dist/esm/hooks/use-calculation-worker.d.ts +37 -0
- package/dist/esm/hooks/use-calculation-worker.d.ts.map +1 -0
- package/dist/esm/hooks/use-calculation-worker.js +1688 -0
- package/dist/esm/hooks/use-calculation.d.ts +173 -0
- package/dist/esm/hooks/use-calculation.d.ts.map +1 -0
- package/dist/esm/hooks/use-calculation.js +2069 -0
- package/dist/esm/hooks/use-can-edit-cellrange.d.ts +31 -0
- package/dist/esm/hooks/use-can-edit-cellrange.d.ts.map +1 -0
- package/dist/esm/hooks/use-can-edit-cellrange.js +72 -0
- package/dist/esm/hooks/use-cellxfs-registry.d.ts +6 -0
- package/dist/esm/hooks/use-cellxfs-registry.d.ts.map +1 -0
- package/dist/esm/hooks/use-cellxfs-registry.js +22 -0
- package/dist/esm/hooks/use-citations.d.ts +19 -0
- package/dist/esm/hooks/use-citations.d.ts.map +1 -0
- package/dist/esm/hooks/use-citations.js +61 -0
- package/dist/esm/hooks/use-comments.d.ts +14 -0
- package/dist/esm/hooks/use-comments.d.ts.map +1 -0
- package/dist/esm/hooks/use-comments.js +45 -0
- package/dist/esm/hooks/use-conditional-formatting-rules.d.ts +22 -0
- package/dist/esm/hooks/use-conditional-formatting-rules.d.ts.map +1 -0
- package/dist/esm/hooks/use-conditional-formatting-rules.js +81 -0
- package/dist/esm/hooks/use-data-validation-rules.d.ts +54 -0
- package/dist/esm/hooks/use-data-validation-rules.d.ts.map +1 -0
- package/dist/esm/hooks/use-data-validation-rules.js +135 -0
- package/dist/esm/hooks/use-deferred-calculation-flush.d.ts +14 -0
- package/dist/esm/hooks/use-deferred-calculation-flush.d.ts.map +1 -0
- package/dist/esm/hooks/use-deferred-calculation-flush.js +78 -0
- package/dist/esm/hooks/use-idle-scheduler.d.ts +5 -0
- package/dist/esm/hooks/use-idle-scheduler.d.ts.map +1 -0
- package/dist/esm/hooks/use-idle-scheduler.js +46 -0
- package/dist/esm/hooks/use-indent.d.ts +23 -0
- package/dist/esm/hooks/use-indent.d.ts.map +1 -0
- package/dist/esm/hooks/use-indent.js +97 -0
- package/dist/esm/hooks/use-named-range.d.ts +7 -0
- package/dist/esm/hooks/use-named-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-named-range.js +69 -0
- package/dist/esm/hooks/use-on-adjust-row-height.d.ts +11 -0
- package/dist/esm/hooks/use-on-adjust-row-height.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-adjust-row-height.js +63 -0
- package/dist/esm/hooks/use-on-autoresize.d.ts +17 -0
- package/dist/esm/hooks/use-on-autoresize.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-autoresize.js +38 -0
- package/dist/esm/hooks/use-on-banded-ranges.d.ts +15 -0
- package/dist/esm/hooks/use-on-banded-ranges.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-banded-ranges.js +36 -0
- package/dist/esm/hooks/use-on-calculation-begin.d.ts +14 -0
- package/dist/esm/hooks/use-on-calculation-begin.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-calculation-begin.js +22 -0
- package/dist/esm/hooks/use-on-calculation-success.d.ts +22 -0
- package/dist/esm/hooks/use-on-calculation-success.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-calculation-success.js +167 -0
- package/dist/esm/hooks/use-on-change-batch-stream.d.ts +7 -0
- package/dist/esm/hooks/use-on-change-batch-stream.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-batch-stream.js +58 -0
- package/dist/esm/hooks/use-on-change-batch.d.ts +54 -0
- package/dist/esm/hooks/use-on-change-batch.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-batch.js +111 -0
- package/dist/esm/hooks/use-on-change-calculated-column.d.ts +23 -0
- package/dist/esm/hooks/use-on-change-calculated-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-calculated-column.js +29 -0
- package/dist/esm/hooks/use-on-change-decimals.d.ts +22 -0
- package/dist/esm/hooks/use-on-change-decimals.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-decimals.js +45 -0
- package/dist/esm/hooks/use-on-change-formatting.d.ts +44 -0
- package/dist/esm/hooks/use-on-change-formatting.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-formatting.js +158 -0
- package/dist/esm/hooks/use-on-change-sheet-tabcolor.d.ts +11 -0
- package/dist/esm/hooks/use-on-change-sheet-tabcolor.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-sheet-tabcolor.js +26 -0
- package/dist/esm/hooks/use-on-change-table-column.d.ts +25 -0
- package/dist/esm/hooks/use-on-change-table-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-table-column.js +52 -0
- package/dist/esm/hooks/use-on-change-theme.d.ts +11 -0
- package/dist/esm/hooks/use-on-change-theme.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change-theme.js +11 -0
- package/dist/esm/hooks/use-on-change.d.ts +61 -0
- package/dist/esm/hooks/use-on-change.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-change.js +281 -0
- package/dist/esm/hooks/use-on-clear-formatting.d.ts +17 -0
- package/dist/esm/hooks/use-on-clear-formatting.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-clear-formatting.js +45 -0
- package/dist/esm/hooks/use-on-collapse-column-group.d.ts +11 -0
- package/dist/esm/hooks/use-on-collapse-column-group.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-collapse-column-group.js +44 -0
- package/dist/esm/hooks/use-on-collapse-row-group.d.ts +18 -0
- package/dist/esm/hooks/use-on-collapse-row-group.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-collapse-row-group.js +54 -0
- package/dist/esm/hooks/use-on-copy.d.ts +49 -0
- package/dist/esm/hooks/use-on-copy.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-copy.js +302 -0
- package/dist/esm/hooks/use-on-create-named-range.d.ts +13 -0
- package/dist/esm/hooks/use-on-create-named-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-create-named-range.js +32 -0
- package/dist/esm/hooks/use-on-create-sheet.d.ts +23 -0
- package/dist/esm/hooks/use-on-create-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-create-sheet.js +64 -0
- package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts +28 -0
- package/dist/esm/hooks/use-on-delete-cells-shift-left.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-cells-shift-left.js +65 -0
- package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts +28 -0
- package/dist/esm/hooks/use-on-delete-cells-shift-up.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-cells-shift-up.js +65 -0
- package/dist/esm/hooks/use-on-delete-column.d.ts +38 -0
- package/dist/esm/hooks/use-on-delete-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-column.js +86 -0
- package/dist/esm/hooks/use-on-delete-named-range.d.ts +14 -0
- package/dist/esm/hooks/use-on-delete-named-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-named-range.js +22 -0
- package/dist/esm/hooks/use-on-delete-row.d.ts +38 -0
- package/dist/esm/hooks/use-on-delete-row.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-row.js +86 -0
- package/dist/esm/hooks/use-on-delete-sheet.d.ts +16 -0
- package/dist/esm/hooks/use-on-delete-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-sheet.js +36 -0
- package/dist/esm/hooks/use-on-delete-table-row.d.ts +29 -0
- package/dist/esm/hooks/use-on-delete-table-row.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete-table-row.js +55 -0
- package/dist/esm/hooks/use-on-delete.d.ts +33 -0
- package/dist/esm/hooks/use-on-delete.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-delete.js +58 -0
- package/dist/esm/hooks/use-on-drag-n-drop.d.ts +55 -0
- package/dist/esm/hooks/use-on-drag-n-drop.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-drag-n-drop.js +160 -0
- package/dist/esm/hooks/use-on-duplicate-sheet.d.ts +29 -0
- package/dist/esm/hooks/use-on-duplicate-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-duplicate-sheet.js +63 -0
- package/dist/esm/hooks/use-on-embeds.d.ts +19 -0
- package/dist/esm/hooks/use-on-embeds.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-embeds.js +86 -0
- package/dist/esm/hooks/use-on-expand-column-group.d.ts +11 -0
- package/dist/esm/hooks/use-on-expand-column-group.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-expand-column-group.js +42 -0
- package/dist/esm/hooks/use-on-expand-row-group.d.ts +18 -0
- package/dist/esm/hooks/use-on-expand-row-group.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-expand-row-group.js +49 -0
- package/dist/esm/hooks/use-on-fill-range.d.ts +9 -0
- package/dist/esm/hooks/use-on-fill-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-fill-range.js +79 -0
- package/dist/esm/hooks/use-on-fill.d.ts +29 -0
- package/dist/esm/hooks/use-on-fill.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-fill.js +66 -0
- package/dist/esm/hooks/use-on-filter-table.d.ts +76 -0
- package/dist/esm/hooks/use-on-filter-table.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-filter-table.js +341 -0
- package/dist/esm/hooks/use-on-find-replace.d.ts +19 -0
- package/dist/esm/hooks/use-on-find-replace.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-find-replace.js +115 -0
- package/dist/esm/hooks/use-on-freeze.d.ts +13 -0
- package/dist/esm/hooks/use-on-freeze.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-freeze.js +55 -0
- package/dist/esm/hooks/use-on-group-columns.d.ts +11 -0
- package/dist/esm/hooks/use-on-group-columns.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-group-columns.js +35 -0
- package/dist/esm/hooks/use-on-group-rows.d.ts +17 -0
- package/dist/esm/hooks/use-on-group-rows.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-group-rows.js +41 -0
- package/dist/esm/hooks/use-on-hide-column.d.ts +23 -0
- package/dist/esm/hooks/use-on-hide-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-hide-column.js +54 -0
- package/dist/esm/hooks/use-on-hide-row.d.ts +32 -0
- package/dist/esm/hooks/use-on-hide-row.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-hide-row.js +57 -0
- package/dist/esm/hooks/use-on-hide-show-sheet.d.ts +18 -0
- package/dist/esm/hooks/use-on-hide-show-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-hide-show-sheet.js +88 -0
- package/dist/esm/hooks/use-on-import-csv-legacy.d.ts +8 -0
- package/dist/esm/hooks/use-on-import-csv-legacy.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-import-csv-legacy.js +148 -0
- package/dist/esm/hooks/use-on-import-csv.d.ts +28 -0
- package/dist/esm/hooks/use-on-import-csv.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-import-csv.js +267 -0
- package/dist/esm/hooks/use-on-import-excel.d.ts +67 -0
- package/dist/esm/hooks/use-on-import-excel.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-import-excel.js +595 -0
- package/dist/esm/hooks/use-on-insert-autosum.d.ts +9 -0
- package/dist/esm/hooks/use-on-insert-autosum.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-autosum.js +91 -0
- package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts +28 -0
- package/dist/esm/hooks/use-on-insert-cells-shift-down.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-cells-shift-down.js +65 -0
- package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts +28 -0
- package/dist/esm/hooks/use-on-insert-cells-shift-right.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-cells-shift-right.js +65 -0
- package/dist/esm/hooks/use-on-insert-checkbox.d.ts +17 -0
- package/dist/esm/hooks/use-on-insert-checkbox.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-checkbox.js +73 -0
- package/dist/esm/hooks/use-on-insert-column.d.ts +40 -0
- package/dist/esm/hooks/use-on-insert-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-column.js +91 -0
- package/dist/esm/hooks/use-on-insert-date-time.d.ts +4 -0
- package/dist/esm/hooks/use-on-insert-date-time.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-date-time.js +11 -0
- package/dist/esm/hooks/use-on-insert-date.d.ts +4 -0
- package/dist/esm/hooks/use-on-insert-date.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-date.js +12 -0
- package/dist/esm/hooks/use-on-insert-image.d.ts +24 -0
- package/dist/esm/hooks/use-on-insert-image.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-image.js +131 -0
- package/dist/esm/hooks/use-on-insert-link.d.ts +25 -0
- package/dist/esm/hooks/use-on-insert-link.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-link.js +193 -0
- package/dist/esm/hooks/use-on-insert-note.d.ts +4 -0
- package/dist/esm/hooks/use-on-insert-note.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-note.js +14 -0
- package/dist/esm/hooks/use-on-insert-row.d.ts +38 -0
- package/dist/esm/hooks/use-on-insert-row.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-row.js +104 -0
- package/dist/esm/hooks/use-on-insert-table-row.d.ts +31 -0
- package/dist/esm/hooks/use-on-insert-table-row.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-table-row.js +59 -0
- package/dist/esm/hooks/use-on-insert-time.d.ts +4 -0
- package/dist/esm/hooks/use-on-insert-time.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-insert-time.js +11 -0
- package/dist/esm/hooks/use-on-locale-change.d.ts +35 -0
- package/dist/esm/hooks/use-on-locale-change.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-locale-change.js +314 -0
- package/dist/esm/hooks/use-on-merge-unmerge-cells.d.ts +28 -0
- package/dist/esm/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-merge-unmerge-cells.js +310 -0
- package/dist/esm/hooks/use-on-move-columns.d.ts +28 -0
- package/dist/esm/hooks/use-on-move-columns.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-move-columns.js +295 -0
- package/dist/esm/hooks/use-on-move-rows.d.ts +30 -0
- package/dist/esm/hooks/use-on-move-rows.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-move-rows.js +264 -0
- package/dist/esm/hooks/use-on-move-selection.d.ts +35 -0
- package/dist/esm/hooks/use-on-move-selection.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-move-selection.js +383 -0
- package/dist/esm/hooks/use-on-move-sheet.d.ts +12 -0
- package/dist/esm/hooks/use-on-move-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-move-sheet.js +65 -0
- package/dist/esm/hooks/use-on-move-table-columns.d.ts +21 -0
- package/dist/esm/hooks/use-on-move-table-columns.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-move-table-columns.js +235 -0
- package/dist/esm/hooks/use-on-paste.d.ts +79 -0
- package/dist/esm/hooks/use-on-paste.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-paste.js +868 -0
- package/dist/esm/hooks/use-on-protect-range.d.ts +20 -0
- package/dist/esm/hooks/use-on-protect-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-protect-range.js +67 -0
- package/dist/esm/hooks/use-on-protect-sheet.d.ts +19 -0
- package/dist/esm/hooks/use-on-protect-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-protect-sheet.js +61 -0
- package/dist/esm/hooks/use-on-remove-duplicates.d.ts +21 -0
- package/dist/esm/hooks/use-on-remove-duplicates.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-remove-duplicates.js +39 -0
- package/dist/esm/hooks/use-on-rename-sheet.d.ts +21 -0
- package/dist/esm/hooks/use-on-rename-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-rename-sheet.js +78 -0
- package/dist/esm/hooks/use-on-request-calculate-wrapper.d.ts +30 -0
- package/dist/esm/hooks/use-on-request-calculate-wrapper.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-calculate-wrapper.js +88 -0
- package/dist/esm/hooks/use-on-request-conditional-format.d.ts +2 -0
- package/dist/esm/hooks/use-on-request-conditional-format.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-conditional-format.js +8 -0
- package/dist/esm/hooks/use-on-request-data-validation.d.ts +7 -0
- package/dist/esm/hooks/use-on-request-data-validation.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-data-validation.js +21 -0
- package/dist/esm/hooks/use-on-request-define-named-range.d.ts +8 -0
- package/dist/esm/hooks/use-on-request-define-named-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-define-named-range.js +25 -0
- package/dist/esm/hooks/use-on-request-delete-sheet.d.ts +2 -0
- package/dist/esm/hooks/use-on-request-delete-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-delete-sheet.js +11 -0
- package/dist/esm/hooks/use-on-request-edit-table.d.ts +3 -0
- package/dist/esm/hooks/use-on-request-edit-table.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-edit-table.js +11 -0
- package/dist/esm/hooks/use-on-request-format-cells.d.ts +2 -0
- package/dist/esm/hooks/use-on-request-format-cells.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-format-cells.js +8 -0
- package/dist/esm/hooks/use-on-request-insert-image.d.ts +3 -0
- package/dist/esm/hooks/use-on-request-insert-image.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-insert-image.js +12 -0
- package/dist/esm/hooks/use-on-request-insert-link.d.ts +5 -0
- package/dist/esm/hooks/use-on-request-insert-link.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-insert-link.js +9 -0
- package/dist/esm/hooks/use-on-request-resize.d.ts +3 -0
- package/dist/esm/hooks/use-on-request-resize.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-resize.js +13 -0
- package/dist/esm/hooks/use-on-request-update-named-range.d.ts +3 -0
- package/dist/esm/hooks/use-on-request-update-named-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-request-update-named-range.js +11 -0
- package/dist/esm/hooks/use-on-resize-table.d.ts +33 -0
- package/dist/esm/hooks/use-on-resize-table.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-resize-table.js +212 -0
- package/dist/esm/hooks/use-on-resize.d.ts +19 -0
- package/dist/esm/hooks/use-on-resize.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-resize.js +54 -0
- package/dist/esm/hooks/use-on-set-outline-depth.d.ts +17 -0
- package/dist/esm/hooks/use-on-set-outline-depth.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-set-outline-depth.js +93 -0
- package/dist/esm/hooks/use-on-show-column.d.ts +16 -0
- package/dist/esm/hooks/use-on-show-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-show-column.js +82 -0
- package/dist/esm/hooks/use-on-show-row.d.ts +22 -0
- package/dist/esm/hooks/use-on-show-row.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-show-row.js +85 -0
- package/dist/esm/hooks/use-on-sort-column.d.ts +53 -0
- package/dist/esm/hooks/use-on-sort-column.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-sort-column.js +268 -0
- package/dist/esm/hooks/use-on-sort-range.d.ts +42 -0
- package/dist/esm/hooks/use-on-sort-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-sort-range.js +247 -0
- package/dist/esm/hooks/use-on-sort-table.d.ts +59 -0
- package/dist/esm/hooks/use-on-sort-table.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-sort-table.js +332 -0
- package/dist/esm/hooks/use-on-table.d.ts +49 -0
- package/dist/esm/hooks/use-on-table.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-table.js +384 -0
- package/dist/esm/hooks/use-on-trace-dependents-precedents.d.ts +14 -0
- package/dist/esm/hooks/use-on-trace-dependents-precedents.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-trace-dependents-precedents.js +144 -0
- package/dist/esm/hooks/use-on-ungroup-columns.d.ts +11 -0
- package/dist/esm/hooks/use-on-ungroup-columns.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-ungroup-columns.js +43 -0
- package/dist/esm/hooks/use-on-ungroup-rows.d.ts +17 -0
- package/dist/esm/hooks/use-on-ungroup-rows.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-ungroup-rows.js +49 -0
- package/dist/esm/hooks/use-on-update-named-range.d.ts +19 -0
- package/dist/esm/hooks/use-on-update-named-range.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-update-named-range.js +108 -0
- package/dist/esm/hooks/use-on-update-note.d.ts +13 -0
- package/dist/esm/hooks/use-on-update-note.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-update-note.js +20 -0
- package/dist/esm/hooks/use-on-update-sheet.d.ts +10 -0
- package/dist/esm/hooks/use-on-update-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-update-sheet.js +11 -0
- package/dist/esm/hooks/use-paint-format.d.ts +17 -0
- package/dist/esm/hooks/use-paint-format.d.ts.map +1 -0
- package/dist/esm/hooks/use-paint-format.js +110 -0
- package/dist/esm/hooks/use-search.d.ts +81 -0
- package/dist/esm/hooks/use-search.d.ts.map +1 -0
- package/dist/esm/hooks/use-search.js +251 -0
- package/dist/esm/hooks/use-select-next-prev-sheet.d.ts +11 -0
- package/dist/esm/hooks/use-select-next-prev-sheet.d.ts.map +1 -0
- package/dist/esm/hooks/use-select-next-prev-sheet.js +21 -0
- package/dist/esm/hooks/use-sheet-observer.d.ts +20 -0
- package/dist/esm/hooks/use-sheet-observer.d.ts.map +1 -0
- package/dist/esm/hooks/use-sheet-observer.js +120 -0
- package/dist/esm/hooks/use-sheet-properties.d.ts +105 -0
- package/dist/esm/hooks/use-sheet-properties.d.ts.map +1 -0
- package/dist/esm/hooks/use-sheet-properties.js +895 -0
- package/dist/esm/hooks/use-sheet-state.d.ts +17 -0
- package/dist/esm/hooks/use-sheet-state.d.ts.map +1 -0
- package/dist/esm/hooks/use-sheet-state.js +102 -0
- package/dist/esm/hooks/use-sheetdata-subscriber.d.ts +10 -0
- package/dist/esm/hooks/use-sheetdata-subscriber.d.ts.map +1 -0
- package/dist/esm/hooks/use-sheetdata-subscriber.js +14 -0
- package/dist/esm/hooks/use-slicers.d.ts +19 -0
- package/dist/esm/hooks/use-slicers.d.ts.map +1 -0
- package/dist/esm/hooks/use-slicers.js +83 -0
- package/dist/esm/hooks/use-split-text-to-columns.d.ts +19 -0
- package/dist/esm/hooks/use-split-text-to-columns.d.ts.map +1 -0
- package/dist/esm/hooks/use-split-text-to-columns.js +30 -0
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +627 -0
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -0
- package/dist/esm/hooks/use-spreadsheet-state.js +2010 -0
- package/dist/esm/hooks/use-ss-registry.d.ts +6 -0
- package/dist/esm/hooks/use-ss-registry.d.ts.map +1 -0
- package/dist/esm/hooks/use-ss-registry.js +17 -0
- package/dist/esm/hooks/use-structured-reference.d.ts +8 -0
- package/dist/esm/hooks/use-structured-reference.d.ts.map +1 -0
- package/dist/esm/hooks/use-structured-reference.js +129 -0
- package/dist/esm/hooks/use-undo-redo-actions.d.ts +40 -0
- package/dist/esm/hooks/use-undo-redo-actions.d.ts.map +1 -0
- package/dist/esm/hooks/use-undo-redo-actions.js +166 -0
- package/dist/esm/hooks/use-undo-redo.d.ts +69 -0
- package/dist/esm/hooks/use-undo-redo.d.ts.map +1 -0
- package/dist/esm/hooks/use-undo-redo.js +113 -0
- package/dist/esm/hooks/utils/frozen-sort.d.ts +9 -0
- package/dist/esm/hooks/utils/frozen-sort.d.ts.map +1 -0
- package/dist/esm/hooks/utils/frozen-sort.js +25 -0
- package/dist/esm/hooks/utils/sort-rows.d.ts +32 -0
- package/dist/esm/hooks/utils/sort-rows.d.ts.map +1 -0
- package/dist/esm/hooks/utils/sort-rows.js +102 -0
- package/dist/esm/index.d.ts +38 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +39 -0
- package/dist/esm/interface/apply-fill.d.ts +6 -0
- package/dist/esm/interface/apply-fill.d.ts.map +1 -0
- package/dist/esm/interface/apply-fill.js +195 -0
- package/dist/esm/interface/auto-resize.d.ts +4 -0
- package/dist/esm/interface/auto-resize.d.ts.map +1 -0
- package/dist/esm/interface/auto-resize.js +50 -0
- package/dist/esm/interface/calculation-interface.d.ts +67 -0
- package/dist/esm/interface/calculation-interface.d.ts.map +1 -0
- package/dist/esm/interface/calculation-interface.js +339 -0
- package/dist/esm/interface/change-batch-stream.d.ts +25 -0
- package/dist/esm/interface/change-batch-stream.d.ts.map +1 -0
- package/dist/esm/interface/change-batch-stream.js +294 -0
- package/dist/esm/interface/change-batch.d.ts +39 -0
- package/dist/esm/interface/change-batch.d.ts.map +1 -0
- package/dist/esm/interface/change-batch.js +282 -0
- package/dist/esm/interface/change-border.d.ts +5 -0
- package/dist/esm/interface/change-border.d.ts.map +1 -0
- package/dist/esm/interface/change-border.js +116 -0
- package/dist/esm/interface/change-calculated-column.d.ts +5 -0
- package/dist/esm/interface/change-calculated-column.d.ts.map +1 -0
- package/dist/esm/interface/change-calculated-column.js +120 -0
- package/dist/esm/interface/change-decimals.d.ts +7 -0
- package/dist/esm/interface/change-decimals.d.ts.map +1 -0
- package/dist/esm/interface/change-decimals.js +58 -0
- package/dist/esm/interface/change-formatting.d.ts +4 -0
- package/dist/esm/interface/change-formatting.d.ts.map +1 -0
- package/dist/esm/interface/change-formatting.js +209 -0
- package/dist/esm/interface/change-sheet-tabcolor.d.ts +4 -0
- package/dist/esm/interface/change-sheet-tabcolor.d.ts.map +1 -0
- package/dist/esm/interface/change-sheet-tabcolor.js +19 -0
- package/dist/esm/interface/change-table-column.d.ts +49 -0
- package/dist/esm/interface/change-table-column.d.ts.map +1 -0
- package/dist/esm/interface/change-table-column.js +247 -0
- package/dist/esm/interface/change-theme.d.ts +4 -0
- package/dist/esm/interface/change-theme.d.ts.map +1 -0
- package/dist/esm/interface/change-theme.js +21 -0
- package/dist/esm/interface/chart-extensions.d.ts +32 -0
- package/dist/esm/interface/chart-extensions.d.ts.map +1 -0
- package/dist/esm/interface/chart-extensions.js +71 -0
- package/dist/esm/interface/citations.d.ts +33 -0
- package/dist/esm/interface/citations.d.ts.map +1 -0
- package/dist/esm/interface/citations.js +123 -0
- package/dist/esm/interface/clear-formatting.d.ts +5 -0
- package/dist/esm/interface/clear-formatting.d.ts.map +1 -0
- package/dist/esm/interface/clear-formatting.js +48 -0
- package/dist/esm/interface/conditional-formatting-rules.d.ts +7 -0
- package/dist/esm/interface/conditional-formatting-rules.d.ts.map +1 -0
- package/dist/esm/interface/conditional-formatting-rules.js +123 -0
- package/dist/esm/interface/create-table.d.ts +5 -0
- package/dist/esm/interface/create-table.d.ts.map +1 -0
- package/dist/esm/interface/create-table.js +105 -0
- package/dist/esm/interface/data-validation-rules.d.ts +25 -0
- package/dist/esm/interface/data-validation-rules.d.ts.map +1 -0
- package/dist/esm/interface/data-validation-rules.js +310 -0
- package/dist/esm/interface/data-validation-utils.d.ts +12 -0
- package/dist/esm/interface/data-validation-utils.d.ts.map +1 -0
- package/dist/esm/interface/data-validation-utils.js +79 -0
- package/dist/esm/interface/delete-cells-shift-left.d.ts +5 -0
- package/dist/esm/interface/delete-cells-shift-left.d.ts.map +1 -0
- package/dist/esm/interface/delete-cells-shift-left.js +146 -0
- package/dist/esm/interface/delete-cells-shift-up.d.ts +5 -0
- package/dist/esm/interface/delete-cells-shift-up.d.ts.map +1 -0
- package/dist/esm/interface/delete-cells-shift-up.js +138 -0
- package/dist/esm/interface/delete-cells.d.ts +6 -0
- package/dist/esm/interface/delete-cells.d.ts.map +1 -0
- package/dist/esm/interface/delete-cells.js +184 -0
- package/dist/esm/interface/delete-column.d.ts +4 -0
- package/dist/esm/interface/delete-column.d.ts.map +1 -0
- package/dist/esm/interface/delete-column.js +254 -0
- package/dist/esm/interface/delete-row.d.ts +4 -0
- package/dist/esm/interface/delete-row.d.ts.map +1 -0
- package/dist/esm/interface/delete-row.js +226 -0
- package/dist/esm/interface/delete-sheet.d.ts +4 -0
- package/dist/esm/interface/delete-sheet.d.ts.map +1 -0
- package/dist/esm/interface/delete-sheet.js +78 -0
- package/dist/esm/interface/delete-table-column.d.ts +4 -0
- package/dist/esm/interface/delete-table-column.d.ts.map +1 -0
- package/dist/esm/interface/delete-table-column.js +274 -0
- package/dist/esm/interface/delete-table-row.d.ts +4 -0
- package/dist/esm/interface/delete-table-row.d.ts.map +1 -0
- package/dist/esm/interface/delete-table-row.js +278 -0
- package/dist/esm/interface/duplicate-sheet.d.ts +4 -0
- package/dist/esm/interface/duplicate-sheet.d.ts.map +1 -0
- package/dist/esm/interface/duplicate-sheet.js +206 -0
- package/dist/esm/interface/embeds.d.ts +9 -0
- package/dist/esm/interface/embeds.d.ts.map +1 -0
- package/dist/esm/interface/embeds.js +115 -0
- package/dist/esm/interface/freeze.d.ts +5 -0
- package/dist/esm/interface/freeze.d.ts.map +1 -0
- package/dist/esm/interface/freeze.js +109 -0
- package/dist/esm/interface/helpers.d.ts +6 -0
- package/dist/esm/interface/helpers.d.ts.map +1 -0
- package/dist/esm/interface/helpers.js +32 -0
- package/dist/esm/interface/hide-column.d.ts +4 -0
- package/dist/esm/interface/hide-column.d.ts.map +1 -0
- package/dist/esm/interface/hide-column.js +59 -0
- package/dist/esm/interface/hide-row.d.ts +4 -0
- package/dist/esm/interface/hide-row.d.ts.map +1 -0
- package/dist/esm/interface/hide-row.js +54 -0
- package/dist/esm/interface/indent.d.ts +7 -0
- package/dist/esm/interface/indent.d.ts.map +1 -0
- package/dist/esm/interface/indent.js +73 -0
- package/dist/esm/interface/insert-cells-shift-down.d.ts +5 -0
- package/dist/esm/interface/insert-cells-shift-down.d.ts.map +1 -0
- package/dist/esm/interface/insert-cells-shift-down.js +143 -0
- package/dist/esm/interface/insert-cells-shift-right.d.ts +5 -0
- package/dist/esm/interface/insert-cells-shift-right.d.ts.map +1 -0
- package/dist/esm/interface/insert-cells-shift-right.js +134 -0
- package/dist/esm/interface/insert-column.d.ts +7 -0
- package/dist/esm/interface/insert-column.d.ts.map +1 -0
- package/dist/esm/interface/insert-column.js +481 -0
- package/dist/esm/interface/insert-note.d.ts +5 -0
- package/dist/esm/interface/insert-note.d.ts.map +1 -0
- package/dist/esm/interface/insert-note.js +23 -0
- package/dist/esm/interface/insert-row.d.ts +4 -0
- package/dist/esm/interface/insert-row.d.ts.map +1 -0
- package/dist/esm/interface/insert-row.js +158 -0
- package/dist/esm/interface/insert-table-row.d.ts +4 -0
- package/dist/esm/interface/insert-table-row.d.ts.map +1 -0
- package/dist/esm/interface/insert-table-row.js +314 -0
- package/dist/esm/interface/interface-cli.d.ts +3 -0
- package/dist/esm/interface/interface-cli.d.ts.map +1 -0
- package/dist/esm/interface/interface-cli.js +62 -0
- package/dist/esm/interface/named-range-operations.d.ts +19 -0
- package/dist/esm/interface/named-range-operations.d.ts.map +1 -0
- package/dist/esm/interface/named-range-operations.js +71 -0
- package/dist/esm/interface/new-sheet.d.ts +4 -0
- package/dist/esm/interface/new-sheet.d.ts.map +1 -0
- package/dist/esm/interface/new-sheet.js +102 -0
- package/dist/esm/interface/pivot-extensions.d.ts +27 -0
- package/dist/esm/interface/pivot-extensions.d.ts.map +1 -0
- package/dist/esm/interface/pivot-extensions.js +60 -0
- package/dist/esm/interface/remove-duplicates.d.ts +11 -0
- package/dist/esm/interface/remove-duplicates.d.ts.map +1 -0
- package/dist/esm/interface/remove-duplicates.js +107 -0
- package/dist/esm/interface/remove-table.d.ts +4 -0
- package/dist/esm/interface/remove-table.d.ts.map +1 -0
- package/dist/esm/interface/remove-table.js +50 -0
- package/dist/esm/interface/resize-utils.d.ts +18 -0
- package/dist/esm/interface/resize-utils.d.ts.map +1 -0
- package/dist/esm/interface/resize-utils.js +34 -0
- package/dist/esm/interface/resize.d.ts +5 -0
- package/dist/esm/interface/resize.d.ts.map +1 -0
- package/dist/esm/interface/resize.js +43 -0
- package/dist/esm/interface/slicers.d.ts +9 -0
- package/dist/esm/interface/slicers.d.ts.map +1 -0
- package/dist/esm/interface/slicers.js +107 -0
- package/dist/esm/interface/split-text.d.ts +5 -0
- package/dist/esm/interface/split-text.d.ts.map +1 -0
- package/dist/esm/interface/split-text.js +94 -0
- package/dist/esm/interface/spreadsheet-interface.d.ts +642 -0
- package/dist/esm/interface/spreadsheet-interface.d.ts.map +1 -0
- package/dist/esm/interface/spreadsheet-interface.js +2442 -0
- package/dist/esm/interface/table-totalrow.d.ts +20 -0
- package/dist/esm/interface/table-totalrow.d.ts.map +1 -0
- package/dist/esm/interface/table-totalrow.js +155 -0
- package/dist/esm/interface/table-utils.d.ts +21 -0
- package/dist/esm/interface/table-utils.d.ts.map +1 -0
- package/dist/esm/interface/table-utils.js +38 -0
- package/dist/esm/interface/update-sheet.d.ts +16 -0
- package/dist/esm/interface/update-sheet.d.ts.map +1 -0
- package/dist/esm/interface/update-sheet.js +64 -0
- package/dist/esm/interface/update-table.d.ts +4 -0
- package/dist/esm/interface/update-table.d.ts.map +1 -0
- package/dist/esm/interface/update-table.js +111 -0
- package/dist/esm/server-utils.d.ts +8 -0
- package/dist/esm/server-utils.d.ts.map +1 -0
- package/dist/esm/server-utils.js +3 -0
- package/dist/esm/server.browser.d.ts +9 -0
- package/dist/esm/server.browser.d.ts.map +1 -0
- package/dist/esm/server.browser.js +5 -0
- package/dist/esm/server.d.ts +9 -0
- package/dist/esm/server.d.ts.map +1 -0
- package/dist/esm/server.js +5 -0
- package/dist/esm/shared-string-registry.d.ts +35 -0
- package/dist/esm/shared-string-registry.d.ts.map +1 -0
- package/dist/esm/shared-string-registry.js +248 -0
- package/dist/esm/sheet-cell.d.ts +310 -0
- package/dist/esm/sheet-cell.d.ts.map +1 -0
- package/dist/esm/sheet-cell.js +1829 -0
- package/dist/esm/test-setup.d.ts +2 -0
- package/dist/esm/test-setup.d.ts.map +1 -0
- package/dist/esm/test-setup.js +3 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
- package/dist/esm/types.d.ts +44 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +33 -0
- package/dist/esm/validation-schema/table.schema.d.ts +6 -0
- package/dist/esm/validation-schema/table.schema.d.ts.map +1 -0
- package/dist/esm/validation-schema/table.schema.js +4 -0
- package/dist/esm/vitest.config.d.ts +3 -0
- package/dist/esm/vitest.config.d.ts.map +1 -0
- package/dist/esm/vitest.config.js +22 -0
- package/package.json +89 -0
|
@@ -0,0 +1,2069 @@
|
|
|
1
|
+
import { Calculator, cellCoordsToCellCoordinate, DataSource, } from "@rowsncolumns/calculator";
|
|
2
|
+
import { isCellCoordinateWithinCellRange, StaticNode } from "@rowsncolumns/dag";
|
|
3
|
+
import { CellRangeNode, isCellCoordinate, isCellNode, isCellRangeNode, isStaticNode, isStaticReference, makeKey, } from "@rowsncolumns/dag";
|
|
4
|
+
import { CellNode } from "@rowsncolumns/dag";
|
|
5
|
+
import { FormulaError } from "@rowsncolumns/fast-formula-parser";
|
|
6
|
+
import { isAreasEqual } from "@rowsncolumns/grid";
|
|
7
|
+
import { ERROR_COLOR, useCallbackRef } from "@rowsncolumns/spreadsheet";
|
|
8
|
+
import { useIsomorphicLayoutEffect } from "@rowsncolumns/ui";
|
|
9
|
+
import { alpha2number, debug, error, isAFormula, isBareFormulaExpression, isNil, scheduleAfterPaint, } from "@rowsncolumns/utils";
|
|
10
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
11
|
+
import { getFunctionNamesFromFormula } from "../api/immer-utils";
|
|
12
|
+
import { isEqualPosition } from "../api/range";
|
|
13
|
+
import { AWAITING_CALCULATION, isCellRange } from "../helpers";
|
|
14
|
+
import { computeDelta } from "../helpers/iterative-calculation";
|
|
15
|
+
import { useCalculationProcessArray } from "./use-calculation-process-array";
|
|
16
|
+
import { useDeferredCalculationFlush } from "./use-deferred-calculation-flush";
|
|
17
|
+
import { useIdleScheduler } from "./use-idle-scheduler";
|
|
18
|
+
const rangesOverlap = (left, right) => {
|
|
19
|
+
if (left.sheet !== right.sheet) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return (left.from.row <= right.to.row &&
|
|
23
|
+
left.to.row >= right.from.row &&
|
|
24
|
+
left.from.col <= right.to.col &&
|
|
25
|
+
left.to.col >= right.from.col);
|
|
26
|
+
};
|
|
27
|
+
const isErrorResult = (value) => {
|
|
28
|
+
if (value instanceof FormulaError) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return (!!value &&
|
|
32
|
+
typeof value === "object" &&
|
|
33
|
+
(value.type === "Error" ||
|
|
34
|
+
value.type === "Invalid"));
|
|
35
|
+
};
|
|
36
|
+
const isDerivedCellPosition = (position) => position.conditionalFormatId !== undefined ||
|
|
37
|
+
position.dataValidationId !== undefined;
|
|
38
|
+
const findCircularKeys = (nodes) => {
|
|
39
|
+
if (!nodes.length) {
|
|
40
|
+
return new Set();
|
|
41
|
+
}
|
|
42
|
+
const nodeMap = new Map();
|
|
43
|
+
const nodesBySheet = new Map();
|
|
44
|
+
for (const node of nodes) {
|
|
45
|
+
nodeMap.set(node.key, node);
|
|
46
|
+
const bucket = nodesBySheet.get(node.position.sheetId);
|
|
47
|
+
if (bucket) {
|
|
48
|
+
bucket.push(node);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
nodesBySheet.set(node.position.sheetId, [node]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const adjacency = new Map();
|
|
55
|
+
for (const node of nodes) {
|
|
56
|
+
const edges = new Set();
|
|
57
|
+
for (const input of node.inputKeys) {
|
|
58
|
+
if (isCellNode(input)) {
|
|
59
|
+
const cellInput = input;
|
|
60
|
+
if (nodeMap.has(cellInput.key)) {
|
|
61
|
+
edges.add(cellInput.key);
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
if (isCellRangeNode(input)) {
|
|
66
|
+
const rangeInput = input;
|
|
67
|
+
const candidates = nodesBySheet.get(rangeInput.position.sheetId);
|
|
68
|
+
if (!candidates) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
for (const candidate of candidates) {
|
|
72
|
+
if (isCellNode(candidate) &&
|
|
73
|
+
!isDerivedCellPosition(candidate.position) &&
|
|
74
|
+
isCellCoordinateWithinCellRange(candidate.position, rangeInput)) {
|
|
75
|
+
edges.add(candidate.key);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
adjacency.set(node.key, edges);
|
|
81
|
+
}
|
|
82
|
+
const indexMap = new Map();
|
|
83
|
+
const lowLink = new Map();
|
|
84
|
+
const stack = [];
|
|
85
|
+
const onStack = new Set();
|
|
86
|
+
let index = 0;
|
|
87
|
+
const components = [];
|
|
88
|
+
const strongConnect = (key) => {
|
|
89
|
+
indexMap.set(key, index);
|
|
90
|
+
lowLink.set(key, index);
|
|
91
|
+
index++;
|
|
92
|
+
stack.push(key);
|
|
93
|
+
onStack.add(key);
|
|
94
|
+
for (const neighbor of adjacency.get(key) ?? []) {
|
|
95
|
+
if (!indexMap.has(neighbor)) {
|
|
96
|
+
strongConnect(neighbor);
|
|
97
|
+
lowLink.set(key, Math.min(lowLink.get(key), lowLink.get(neighbor)));
|
|
98
|
+
}
|
|
99
|
+
else if (onStack.has(neighbor)) {
|
|
100
|
+
lowLink.set(key, Math.min(lowLink.get(key), indexMap.get(neighbor)));
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (lowLink.get(key) === indexMap.get(key)) {
|
|
104
|
+
const component = [];
|
|
105
|
+
let candidate;
|
|
106
|
+
do {
|
|
107
|
+
candidate = stack.pop();
|
|
108
|
+
onStack.delete(candidate);
|
|
109
|
+
component.push(candidate);
|
|
110
|
+
} while (candidate !== key);
|
|
111
|
+
components.push(component);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
for (const key of nodeMap.keys()) {
|
|
115
|
+
if (!indexMap.has(key)) {
|
|
116
|
+
strongConnect(key);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const circular = new Set();
|
|
120
|
+
for (const component of components) {
|
|
121
|
+
if (!component.length)
|
|
122
|
+
continue;
|
|
123
|
+
if (component.length === 1 &&
|
|
124
|
+
!adjacency.get(component[0])?.has(component[0])) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
component.forEach((key) => circular.add(key));
|
|
128
|
+
}
|
|
129
|
+
return circular;
|
|
130
|
+
};
|
|
131
|
+
// List of ephemeral functions
|
|
132
|
+
// Ephemeral functions are always recalculated when
|
|
133
|
+
// a cell changes
|
|
134
|
+
export const EPHEMERAL_FUNCTIONS = new Set([
|
|
135
|
+
"NOW",
|
|
136
|
+
"TODAY",
|
|
137
|
+
"RAND",
|
|
138
|
+
"RANDARRAY",
|
|
139
|
+
"RANDBETWEEN",
|
|
140
|
+
"SHEET",
|
|
141
|
+
"SHEETS",
|
|
142
|
+
"OFFSET",
|
|
143
|
+
"INDIRECT",
|
|
144
|
+
]);
|
|
145
|
+
const DEFAULT_BATCH_WEIGHT = 600;
|
|
146
|
+
const ARRAY_FORMULA_WEIGHT = 300;
|
|
147
|
+
const LARGE_RANGE_MIN_CELLS = 100;
|
|
148
|
+
const MAX_CHUNK_DURATION_MS = 16;
|
|
149
|
+
const getTimestamp = () => typeof performance !== "undefined" && typeof performance.now === "function"
|
|
150
|
+
? performance.now()
|
|
151
|
+
: Date.now();
|
|
152
|
+
const yieldToBrowser = () => new Promise((resolve) => {
|
|
153
|
+
scheduleAfterPaint(resolve);
|
|
154
|
+
});
|
|
155
|
+
const parseCellReference = (reference) => {
|
|
156
|
+
const match = /^\$?([A-Z]{1,3})\$?(\d+)$/i.exec(reference.trim());
|
|
157
|
+
if (!match) {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const column = alpha2number(match[1].toUpperCase());
|
|
161
|
+
if (column == null) {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
164
|
+
const row = Number.parseInt(match[2], 10);
|
|
165
|
+
if (Number.isNaN(row)) {
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
return { column, row };
|
|
169
|
+
};
|
|
170
|
+
const toValidRange = (range) => {
|
|
171
|
+
const startRowIndex = Math.max(1, range.startRowIndex);
|
|
172
|
+
const endRowIndex = Math.max(startRowIndex, range.endRowIndex);
|
|
173
|
+
const startColumnIndex = Math.max(1, range.startColumnIndex);
|
|
174
|
+
const endColumnIndex = Math.max(startColumnIndex, range.endColumnIndex);
|
|
175
|
+
if (endRowIndex < startRowIndex || endColumnIndex < startColumnIndex) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
sheetId: range.sheetId,
|
|
180
|
+
startRowIndex,
|
|
181
|
+
endRowIndex,
|
|
182
|
+
startColumnIndex,
|
|
183
|
+
endColumnIndex,
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
const getInvalidationRangeFromStructureChange = (change) => {
|
|
187
|
+
switch (change.kind) {
|
|
188
|
+
case "delete-row":
|
|
189
|
+
case "insert-row":
|
|
190
|
+
return toValidRange({
|
|
191
|
+
sheetId: change.sheetId,
|
|
192
|
+
startRowIndex: change.index,
|
|
193
|
+
endRowIndex: change.rowCount,
|
|
194
|
+
startColumnIndex: 1,
|
|
195
|
+
endColumnIndex: change.columnCount,
|
|
196
|
+
});
|
|
197
|
+
case "delete-column":
|
|
198
|
+
case "insert-column":
|
|
199
|
+
return toValidRange({
|
|
200
|
+
sheetId: change.sheetId,
|
|
201
|
+
startRowIndex: 1,
|
|
202
|
+
endRowIndex: change.rowCount,
|
|
203
|
+
startColumnIndex: change.index,
|
|
204
|
+
endColumnIndex: change.columnCount,
|
|
205
|
+
});
|
|
206
|
+
case "delete-cells-shift-up":
|
|
207
|
+
case "insert-cells-shift-down":
|
|
208
|
+
return toValidRange({
|
|
209
|
+
sheetId: change.sheetId,
|
|
210
|
+
startRowIndex: change.startRowIndex,
|
|
211
|
+
endRowIndex: change.rowCount,
|
|
212
|
+
startColumnIndex: change.startColumnIndex,
|
|
213
|
+
endColumnIndex: change.endColumnIndex,
|
|
214
|
+
});
|
|
215
|
+
case "delete-cells-shift-left":
|
|
216
|
+
case "insert-cells-shift-right":
|
|
217
|
+
return toValidRange({
|
|
218
|
+
sheetId: change.sheetId,
|
|
219
|
+
startRowIndex: change.startRowIndex,
|
|
220
|
+
endRowIndex: change.endRowIndex,
|
|
221
|
+
startColumnIndex: change.startColumnIndex,
|
|
222
|
+
endColumnIndex: change.columnCount,
|
|
223
|
+
});
|
|
224
|
+
case "delete-table-row":
|
|
225
|
+
case "insert-table-row":
|
|
226
|
+
return toValidRange({
|
|
227
|
+
sheetId: change.sheetId,
|
|
228
|
+
startRowIndex: change.index,
|
|
229
|
+
endRowIndex: change.rowCount,
|
|
230
|
+
startColumnIndex: change.startColumnIndex,
|
|
231
|
+
endColumnIndex: change.endColumnIndex,
|
|
232
|
+
});
|
|
233
|
+
case "delete-table-column":
|
|
234
|
+
case "insert-table-column":
|
|
235
|
+
return toValidRange({
|
|
236
|
+
sheetId: change.sheetId,
|
|
237
|
+
startRowIndex: change.startRowIndex,
|
|
238
|
+
endRowIndex: change.endRowIndex,
|
|
239
|
+
startColumnIndex: change.index,
|
|
240
|
+
endColumnIndex: change.columnCount,
|
|
241
|
+
});
|
|
242
|
+
case "invalidate-range":
|
|
243
|
+
return toValidRange({
|
|
244
|
+
sheetId: change.sheetId,
|
|
245
|
+
startRowIndex: change.startRowIndex,
|
|
246
|
+
endRowIndex: change.endRowIndex,
|
|
247
|
+
startColumnIndex: change.startColumnIndex,
|
|
248
|
+
endColumnIndex: change.endColumnIndex,
|
|
249
|
+
});
|
|
250
|
+
default:
|
|
251
|
+
return null;
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
const hasFullColumnReference = (formula) => {
|
|
255
|
+
const pattern = /(^|[^A-Z0-9_])(\$?[A-Z]{1,3})(?!\d)\s*:\s*(\$?[A-Z]{1,3})(?!\d)/gi;
|
|
256
|
+
return pattern.test(formula);
|
|
257
|
+
};
|
|
258
|
+
const hasFullRowReference = (formula) => {
|
|
259
|
+
const pattern = /(^|[^A-Z0-9_])(\$?\d+)\s*:\s*(\$?\d+)(?!\d)/gi;
|
|
260
|
+
return pattern.test(formula);
|
|
261
|
+
};
|
|
262
|
+
const hasLargeExplicitRange = (formula) => {
|
|
263
|
+
const pattern = /(\$?[A-Z]{1,3}\$?\d+)\s*:\s*(\$?[A-Z]{1,3}\$?\d+)/gi;
|
|
264
|
+
let match;
|
|
265
|
+
while ((match = pattern.exec(formula))) {
|
|
266
|
+
const start = parseCellReference(match[1]);
|
|
267
|
+
const end = parseCellReference(match[2]);
|
|
268
|
+
if (!start || !end) {
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
const rowCount = Math.abs(end.row - start.row) + 1;
|
|
272
|
+
const columnCount = Math.abs(end.column - start.column) + 1;
|
|
273
|
+
if (rowCount * columnCount >= LARGE_RANGE_MIN_CELLS) {
|
|
274
|
+
return true;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return false;
|
|
278
|
+
};
|
|
279
|
+
const isHeavyArrayFormula = (formula) => {
|
|
280
|
+
if (!formula)
|
|
281
|
+
return false;
|
|
282
|
+
return (hasFullColumnReference(formula) ||
|
|
283
|
+
hasFullRowReference(formula) ||
|
|
284
|
+
hasLargeExplicitRange(formula));
|
|
285
|
+
};
|
|
286
|
+
const cellPromises = new Map();
|
|
287
|
+
export const useCalculation = ({ locale, functions, iterativeCalculation, onDemandFormulaPattern, activeSheetId, onSuccess, onChangeDependencyGraph, getSheetId, getSheetName, getSheetIndex, getSheetCount, getActiveSheetId, getEffectiveValue, getUserEnteredValue, getConditionalFormatFormula, getDataValidationFormula, getSheetProperties, getCellData, onStructuredReference, onNamedRange, namedRanges, onChangeStaticReference, onBeginCalculation, getEffectiveStructuredValue, isRowHidden, isRowHiddenByFilter, enableLazyCalculation = true, enabled = true, }) => {
|
|
288
|
+
// Convert string pattern to RegExp if provided
|
|
289
|
+
const onDemandPattern = useMemo(() => {
|
|
290
|
+
if (!onDemandFormulaPattern)
|
|
291
|
+
return undefined;
|
|
292
|
+
return new RegExp(onDemandFormulaPattern, "gi");
|
|
293
|
+
}, [onDemandFormulaPattern]);
|
|
294
|
+
const calculator = useRef(undefined);
|
|
295
|
+
const computationCache = useRef(undefined);
|
|
296
|
+
const iterativeCalculationRef = useRef(iterativeCalculation);
|
|
297
|
+
iterativeCalculationRef.current = iterativeCalculation;
|
|
298
|
+
const operationQueue = useRef([]);
|
|
299
|
+
const graphOperationQueue = useRef([]);
|
|
300
|
+
// Results queue
|
|
301
|
+
const resultsQueueRef = useRef(new Map());
|
|
302
|
+
const resultsFlushPendingRef = useRef(false);
|
|
303
|
+
const isFullRecalcRef = useRef(false);
|
|
304
|
+
const staticNodeArrayRef = useRef([]);
|
|
305
|
+
const initialCalculationArrayRef = useRef([]);
|
|
306
|
+
const getSheetNameStable = useCallbackRef(getSheetName);
|
|
307
|
+
const getSheetIdStable = useCallbackRef(getSheetId);
|
|
308
|
+
const getSheetIndexStable = useCallbackRef(getSheetIndex);
|
|
309
|
+
const getSheetCountStable = useCallbackRef(getSheetCount);
|
|
310
|
+
const getCellDataStable = useCallbackRef(getCellData);
|
|
311
|
+
const onStructuredReferenceStable = useCallbackRef(onStructuredReference);
|
|
312
|
+
const getUserEnteredValueStable = useCallbackRef(getUserEnteredValue);
|
|
313
|
+
const isRowHiddenStable = useCallbackRef(isRowHidden);
|
|
314
|
+
const isRowHiddenByFilterStable = useCallbackRef(isRowHiddenByFilter);
|
|
315
|
+
const initialArrayResults = useRef(new Map());
|
|
316
|
+
const ephemeralCellsRef = useRef(new Map());
|
|
317
|
+
const forceRecalcKeys = useRef(new Set());
|
|
318
|
+
// Keys actually consumed (evaluated with fresh state) during the current
|
|
319
|
+
// calculation cycle. Only these are cleared in `onAfterCalculation`; keys
|
|
320
|
+
// added concurrently (e.g. by a paste RAF while a calc was mid-flight, with
|
|
321
|
+
// stale closures) survive into the next cycle so they aren't dropped.
|
|
322
|
+
const consumedForceRecalcKeys = useRef(new Set());
|
|
323
|
+
// Position for each force key, so unconsumed keys can be re-dirtied + rescheduled.
|
|
324
|
+
const forceRecalcPositions = useRef(new Map());
|
|
325
|
+
// Guards the reschedule loop against an unconsumable key spinning forever.
|
|
326
|
+
const rescheduleCount = useRef(0);
|
|
327
|
+
const rafTimerMapRef = useRef(new Map());
|
|
328
|
+
const deferredOperationsBySheetRef = useRef(new Map());
|
|
329
|
+
const pendingStartResultsRef = useRef(new Map());
|
|
330
|
+
const pendingRecalculatedPositionRef = useRef(undefined);
|
|
331
|
+
const startCalculationRef = useRef(null);
|
|
332
|
+
const { schedule: scheduleStartCalculationIdle } = useIdleScheduler();
|
|
333
|
+
// Add to ephemeral function if required
|
|
334
|
+
const addToEphemeralFunction = useCallback((formulaValue, position) => {
|
|
335
|
+
const fns = getFunctionNamesFromFormula(formulaValue);
|
|
336
|
+
if (fns.some((fn) => EPHEMERAL_FUNCTIONS.has(fn.toUpperCase()))) {
|
|
337
|
+
ephemeralCellsRef.current.set(makeKey(position), position);
|
|
338
|
+
}
|
|
339
|
+
}, []);
|
|
340
|
+
// Remove from ephemeral function if required
|
|
341
|
+
const removeFromEphemeralFunction = useCallback((position) => {
|
|
342
|
+
ephemeralCellsRef.current.delete(makeKey(position));
|
|
343
|
+
}, []);
|
|
344
|
+
// Get all ephemeral functions
|
|
345
|
+
const getEphemeralCells = useCallback(() => {
|
|
346
|
+
const ephemeralCellsToRecalc = [
|
|
347
|
+
...ephemeralCellsRef.current.values(),
|
|
348
|
+
].map((position) => {
|
|
349
|
+
return {
|
|
350
|
+
type: "add",
|
|
351
|
+
position,
|
|
352
|
+
};
|
|
353
|
+
});
|
|
354
|
+
debug("Recalculation ephemeral cells", ephemeralCellsToRecalc);
|
|
355
|
+
return ephemeralCellsToRecalc;
|
|
356
|
+
}, []);
|
|
357
|
+
// Get computation cache
|
|
358
|
+
// Used for the current calculation frame
|
|
359
|
+
const getComputationCache = useCallback(() => {
|
|
360
|
+
if (computationCache.current === undefined) {
|
|
361
|
+
computationCache.current = new Map();
|
|
362
|
+
}
|
|
363
|
+
return computationCache.current;
|
|
364
|
+
}, []);
|
|
365
|
+
// Clear cache
|
|
366
|
+
const onAfterCalculation = useCallback(() => {
|
|
367
|
+
// Remove cached values
|
|
368
|
+
getComputationCache().clear();
|
|
369
|
+
// Cleanup the graph, so we dont have
|
|
370
|
+
// any stale nodes
|
|
371
|
+
getCalculator().cleanupGraph();
|
|
372
|
+
// Only clear keys that were actually consumed during this calculation cycle.
|
|
373
|
+
// Keys added concurrently (e.g. by a paste RAF while this calculation was
|
|
374
|
+
// running) must survive so the next cycle can evaluate them.
|
|
375
|
+
consumedForceRecalcKeys.current.forEach((key) => {
|
|
376
|
+
forceRecalcKeys.current.delete(key);
|
|
377
|
+
forceRecalcPositions.current.delete(key);
|
|
378
|
+
});
|
|
379
|
+
consumedForceRecalcKeys.current.clear();
|
|
380
|
+
}, []);
|
|
381
|
+
const getFunctions = useCallback(() => {
|
|
382
|
+
return functions;
|
|
383
|
+
}, [functions]);
|
|
384
|
+
const overridesRef = useRef(null);
|
|
385
|
+
// Get user entered value
|
|
386
|
+
const getFinalUserEnteredValue = (position) => {
|
|
387
|
+
const { conditionalFormatId, dataValidationId } = position;
|
|
388
|
+
if (!isNil(conditionalFormatId)) {
|
|
389
|
+
return getConditionalFormatFormula(position.sheetId, position.rowIndex, position.columnIndex, conditionalFormatId);
|
|
390
|
+
}
|
|
391
|
+
if (!isNil(dataValidationId)) {
|
|
392
|
+
return getDataValidationFormula(position.sheetId, position.rowIndex, position.columnIndex, dataValidationId);
|
|
393
|
+
}
|
|
394
|
+
// Read through the stable ref so a calc-captured closure (e.g. a paste RAF
|
|
395
|
+
// that ran with a pre-paste render's `getUserEnteredValue`) still resolves
|
|
396
|
+
// the latest user-entered value rather than a stale snapshot.
|
|
397
|
+
return getUserEnteredValueStable(position.sheetId, position.rowIndex, position.columnIndex);
|
|
398
|
+
};
|
|
399
|
+
const deferCalculationNodes = (positions) => {
|
|
400
|
+
if (!positions.length) {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
for (const position of positions) {
|
|
404
|
+
const key = makeKey(position);
|
|
405
|
+
const sheetId = position.sheetId;
|
|
406
|
+
const existing = deferredOperationsBySheetRef.current.get(sheetId) ??
|
|
407
|
+
new Map();
|
|
408
|
+
existing.set(key, {
|
|
409
|
+
type: "dirty",
|
|
410
|
+
position,
|
|
411
|
+
force: forceRecalcKeys.current.has(key),
|
|
412
|
+
});
|
|
413
|
+
deferredOperationsBySheetRef.current.set(sheetId, existing);
|
|
414
|
+
getCalculator().unMarkAsDirty(position);
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
const filterDirtyCellsForActiveSheet = (cells, rootSheetId) => {
|
|
418
|
+
if (!cells.length) {
|
|
419
|
+
return { included: cells, deferred: [] };
|
|
420
|
+
}
|
|
421
|
+
const cellNodeByKey = new Map();
|
|
422
|
+
const dirtyNodesBySheet = new Map();
|
|
423
|
+
for (const node of cells) {
|
|
424
|
+
cellNodeByKey.set(node.key, node);
|
|
425
|
+
const list = dirtyNodesBySheet.get(node.position.sheetId);
|
|
426
|
+
if (list) {
|
|
427
|
+
list.push(node);
|
|
428
|
+
}
|
|
429
|
+
else {
|
|
430
|
+
dirtyNodesBySheet.set(node.position.sheetId, [node]);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
// Find cells that are inputs to static references (charts, etc.)
|
|
434
|
+
// These cells should not be deferred even if they're on other sheets
|
|
435
|
+
const staticInputKeys = new Set();
|
|
436
|
+
const staticInputs = getCalculator().getStaticReferenceInputs();
|
|
437
|
+
for (const inputNode of staticInputs) {
|
|
438
|
+
if (isCellNode(inputNode)) {
|
|
439
|
+
staticInputKeys.add(inputNode.key);
|
|
440
|
+
}
|
|
441
|
+
else if (isCellRangeNode(inputNode)) {
|
|
442
|
+
// For range inputs, check which dirty cells fall within the range
|
|
443
|
+
const rangeInput = inputNode;
|
|
444
|
+
for (const cell of cells) {
|
|
445
|
+
if (!isDerivedCellPosition(cell.position) &&
|
|
446
|
+
isCellCoordinateWithinCellRange(cell.position, rangeInput)) {
|
|
447
|
+
staticInputKeys.add(cell.key);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
const includedKeys = new Set();
|
|
453
|
+
const forcedKeys = forceRecalcKeys.current;
|
|
454
|
+
const stack = [];
|
|
455
|
+
for (const node of cells) {
|
|
456
|
+
if (forcedKeys.has(node.key) ||
|
|
457
|
+
node.position.sheetId === rootSheetId ||
|
|
458
|
+
staticInputKeys.has(node.key)) {
|
|
459
|
+
includedKeys.add(node.key);
|
|
460
|
+
stack.push(node);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
while (stack.length) {
|
|
464
|
+
const current = stack.pop();
|
|
465
|
+
if (!current) {
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
468
|
+
const userEnteredValue = getFinalUserEnteredValue(current.position);
|
|
469
|
+
if (!isAFormula(userEnteredValue) || !userEnteredValue) {
|
|
470
|
+
continue;
|
|
471
|
+
}
|
|
472
|
+
const formulaValue = String(userEnteredValue).slice(1);
|
|
473
|
+
const dependencies = getCalculator().dependencies(formulaValue, current.position);
|
|
474
|
+
for (const dependency of dependencies) {
|
|
475
|
+
// Named-range refs (StaticReference) come back as deps too
|
|
476
|
+
// now that the DAG is unified, but this code path is
|
|
477
|
+
// chasing grid-level cell/range dependencies for the
|
|
478
|
+
// active-sheet filter. Skip them.
|
|
479
|
+
if (isStaticReference(dependency))
|
|
480
|
+
continue;
|
|
481
|
+
if (isCellCoordinate(dependency)) {
|
|
482
|
+
const depKey = makeKey(dependency);
|
|
483
|
+
const depNode = cellNodeByKey.get(depKey);
|
|
484
|
+
if (depNode && !includedKeys.has(depKey)) {
|
|
485
|
+
includedKeys.add(depKey);
|
|
486
|
+
stack.push(depNode);
|
|
487
|
+
}
|
|
488
|
+
continue;
|
|
489
|
+
}
|
|
490
|
+
const candidates = dirtyNodesBySheet.get(dependency.sheetId);
|
|
491
|
+
if (!candidates) {
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
for (const candidate of candidates) {
|
|
495
|
+
if (includedKeys.has(candidate.key)) {
|
|
496
|
+
continue;
|
|
497
|
+
}
|
|
498
|
+
if (isCellRangeNode(dependency) &&
|
|
499
|
+
!isDerivedCellPosition(candidate.position) &&
|
|
500
|
+
isCellCoordinateWithinCellRange(candidate.position, dependency)) {
|
|
501
|
+
includedKeys.add(candidate.key);
|
|
502
|
+
stack.push(candidate);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
const included = [];
|
|
508
|
+
const deferred = [];
|
|
509
|
+
for (const node of cells) {
|
|
510
|
+
if (includedKeys.has(node.key)) {
|
|
511
|
+
included.push(node);
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
deferred.push(node);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return { included, deferred };
|
|
518
|
+
};
|
|
519
|
+
const scheduleStartCalculation = useCallback((results, recalculatedPosition) => {
|
|
520
|
+
if (results && results.size) {
|
|
521
|
+
for (const entry of results) {
|
|
522
|
+
pendingStartResultsRef.current.set(entry[0], entry[1]);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
if (recalculatedPosition) {
|
|
526
|
+
pendingRecalculatedPositionRef.current = recalculatedPosition;
|
|
527
|
+
}
|
|
528
|
+
scheduleStartCalculationIdle(() => {
|
|
529
|
+
const pendingResults = pendingStartResultsRef.current;
|
|
530
|
+
pendingStartResultsRef.current = new Map();
|
|
531
|
+
const position = pendingRecalculatedPositionRef.current;
|
|
532
|
+
pendingRecalculatedPositionRef.current = undefined;
|
|
533
|
+
startCalculationRef.current?.(pendingResults, position);
|
|
534
|
+
});
|
|
535
|
+
}, [scheduleStartCalculationIdle]);
|
|
536
|
+
// Calculator instance
|
|
537
|
+
const getCalculator = () => {
|
|
538
|
+
if (!calculator.current) {
|
|
539
|
+
const overrideValuesRef = overridesRef;
|
|
540
|
+
calculator.current = new Calculator({
|
|
541
|
+
locale,
|
|
542
|
+
getSheetId: getSheetIdStable,
|
|
543
|
+
getSheetIndex: getSheetIndexStable,
|
|
544
|
+
getSheetCount: getSheetCountStable,
|
|
545
|
+
getSheetProperties: (sheetId = getActiveSheetId()) => getSheetProperties(sheetId),
|
|
546
|
+
getSheetName: getSheetNameStable,
|
|
547
|
+
isRowHidden: isRowHidden ? isRowHiddenStable : undefined,
|
|
548
|
+
isRowHiddenByFilter: isRowHiddenByFilter
|
|
549
|
+
? isRowHiddenByFilterStable
|
|
550
|
+
: undefined,
|
|
551
|
+
getCellValue(sheetId, rowIndex, columnIndex, property) {
|
|
552
|
+
const key = makeKey({
|
|
553
|
+
sheetId,
|
|
554
|
+
rowIndex,
|
|
555
|
+
columnIndex,
|
|
556
|
+
});
|
|
557
|
+
if (overrideValuesRef.current?.has(key)) {
|
|
558
|
+
const result = overrideValuesRef.current.get(key);
|
|
559
|
+
if (property) {
|
|
560
|
+
return getEffectiveStructuredValue?.(result, property);
|
|
561
|
+
}
|
|
562
|
+
return result;
|
|
563
|
+
}
|
|
564
|
+
const cachedValue = getComputationCache().has(key)
|
|
565
|
+
? getComputationCache().get(key)
|
|
566
|
+
: null;
|
|
567
|
+
if (cachedValue !== null) {
|
|
568
|
+
// Cached structured value
|
|
569
|
+
if (cachedValue &&
|
|
570
|
+
typeof cachedValue === "object" &&
|
|
571
|
+
cachedValue.kind &&
|
|
572
|
+
getEffectiveStructuredValue) {
|
|
573
|
+
return getEffectiveStructuredValue?.(cachedValue, property);
|
|
574
|
+
}
|
|
575
|
+
return cachedValue;
|
|
576
|
+
}
|
|
577
|
+
return getEffectiveValue(sheetId, rowIndex, columnIndex, property);
|
|
578
|
+
},
|
|
579
|
+
functions: getFunctions(),
|
|
580
|
+
onStructuredReference: onStructuredReferenceStable,
|
|
581
|
+
onVariable: onNamedRange,
|
|
582
|
+
onRecalculation: onRecalculation,
|
|
583
|
+
markAsQueued,
|
|
584
|
+
markAsLoading,
|
|
585
|
+
markAsError,
|
|
586
|
+
getCellData: (coords) => {
|
|
587
|
+
if (isCellRange(coords)) {
|
|
588
|
+
const arr = [];
|
|
589
|
+
const sheetId = coords.sheet
|
|
590
|
+
? getSheetIdStable(coords.sheet)
|
|
591
|
+
: getActiveSheetId();
|
|
592
|
+
for (let rowIndex = coords.from.row; rowIndex <= coords.to.row; rowIndex++) {
|
|
593
|
+
for (let columnIndex = coords.from.col; columnIndex <= coords.to.col; columnIndex++) {
|
|
594
|
+
arr.push(getCellDataStable(sheetId, rowIndex, columnIndex));
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return arr;
|
|
598
|
+
}
|
|
599
|
+
else {
|
|
600
|
+
const position = cellCoordsToCellCoordinate(coords, coords.sheet
|
|
601
|
+
? getSheetIdStable(coords.sheet)
|
|
602
|
+
: getActiveSheetId());
|
|
603
|
+
return getCellDataStable(position.sheetId, position.rowIndex, position.columnIndex);
|
|
604
|
+
}
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
return calculator.current;
|
|
609
|
+
};
|
|
610
|
+
// Cleanup
|
|
611
|
+
useIsomorphicLayoutEffect(() => {
|
|
612
|
+
return () => {
|
|
613
|
+
calculator.current?.cleanup();
|
|
614
|
+
};
|
|
615
|
+
}, []);
|
|
616
|
+
// Phase 9 — virtual-cell named ranges. Sync the host's named-range
|
|
617
|
+
// list with the calculator's registered set. Each formula-typed
|
|
618
|
+
// named range becomes a DAG node; range-typed ones go straight
|
|
619
|
+
// through `onNamedRange` and are skipped here.
|
|
620
|
+
//
|
|
621
|
+
// Excel-correctness requires named ranges to be registered BEFORE
|
|
622
|
+
// any cell formula is parsed — otherwise the dep parser sees the
|
|
623
|
+
// name as `#NAME?` and no DAG edge to the static node is created.
|
|
624
|
+
// We do this via a callable `applyNamedRanges` that's invoked
|
|
625
|
+
// synchronously by the init hook at the top of its calculate
|
|
626
|
+
// pass (before walking sheetData), AND from a useEffect so
|
|
627
|
+
// ongoing changes (Name Manager edits) propagate too. Both paths
|
|
628
|
+
// are idempotent: the diff against `registeredNamedRangeFormulasRef`
|
|
629
|
+
// means re-calling with the same list is a no-op.
|
|
630
|
+
// Track both formula AND scope so we re-register when scope flips
|
|
631
|
+
// (workbook ↔ sheet) even if the formula text is unchanged. Scope
|
|
632
|
+
// is the numeric sheetId — names can be renamed, ids are stable.
|
|
633
|
+
const registeredNamedRangeFormulasRef = useRef(new Map());
|
|
634
|
+
// Diff the provided list against what's already registered and
|
|
635
|
+
// apply only the delta. Pure function over its arg — no implicit
|
|
636
|
+
// ref reads — so the init hook can call it with the same
|
|
637
|
+
// namedRanges prop it has, and tests can call it directly with
|
|
638
|
+
// any list.
|
|
639
|
+
const applyNamedRanges = useCallbackRef((list) => {
|
|
640
|
+
if (!enabled)
|
|
641
|
+
return;
|
|
642
|
+
const calc = getCalculator();
|
|
643
|
+
// Map key combines lowercase name + scope so workbook-scoped
|
|
644
|
+
// and sheet-scoped names with the same display name don't
|
|
645
|
+
// collide (Excel treats them as separate defined names).
|
|
646
|
+
const scopeKey = (name, sheetId) => `${sheetId == null ? "wb" : String(sheetId)}:${name.toLowerCase()}`;
|
|
647
|
+
const next = new Map();
|
|
648
|
+
for (const nr of list ?? []) {
|
|
649
|
+
const value = nr?.value;
|
|
650
|
+
if (typeof value !== "string")
|
|
651
|
+
continue;
|
|
652
|
+
// Accept both shapes: "=OFFSET(...)" (spreadsheet convention)
|
|
653
|
+
// and bare "OFFSET(...)" (OOXML definedName convention).
|
|
654
|
+
// Static literals and plain references are not registered —
|
|
655
|
+
// they resolve through the host's onNamedRange fallback.
|
|
656
|
+
const trimmedValue = value.trim();
|
|
657
|
+
let formula;
|
|
658
|
+
if (trimmedValue.startsWith("=")) {
|
|
659
|
+
formula = trimmedValue.slice(1).trim();
|
|
660
|
+
}
|
|
661
|
+
else if (isBareFormulaExpression(trimmedValue)) {
|
|
662
|
+
formula = trimmedValue;
|
|
663
|
+
}
|
|
664
|
+
else {
|
|
665
|
+
continue;
|
|
666
|
+
}
|
|
667
|
+
if (!formula)
|
|
668
|
+
continue;
|
|
669
|
+
// Sheet-scoped if NamedRange.range.sheetId is present; else
|
|
670
|
+
// workbook-scoped. sheetId is stable across sheet renames.
|
|
671
|
+
const sheetId = nr.range?.sheetId ?? undefined;
|
|
672
|
+
next.set(scopeKey(nr.name, sheetId), {
|
|
673
|
+
name: nr.name,
|
|
674
|
+
formula,
|
|
675
|
+
sheetId,
|
|
676
|
+
});
|
|
677
|
+
}
|
|
678
|
+
const prev = registeredNamedRangeFormulasRef.current;
|
|
679
|
+
// Removals: in prev, not in next.
|
|
680
|
+
for (const [key, prevEntry] of prev) {
|
|
681
|
+
if (!next.has(key)) {
|
|
682
|
+
// The map key is `<scope>:<name>`; recover the name by
|
|
683
|
+
// slicing past the first colon and pass the tracked
|
|
684
|
+
// sheetId so we hit the right scoped registration.
|
|
685
|
+
calc.unregisterNamedRange(key.slice(key.indexOf(":") + 1), prevEntry.sheetId);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
// Collect adds + updates. Compare formula AND scope so a
|
|
689
|
+
// scope-only change still re-registers (scope changes also
|
|
690
|
+
// flip the map key, so they hit removal+add — defensive
|
|
691
|
+
// equality check kept for robustness).
|
|
692
|
+
const toApply = [];
|
|
693
|
+
const nextPrev = new Map();
|
|
694
|
+
for (const [key, { name, formula, sheetId }] of next) {
|
|
695
|
+
const prevEntry = prev.get(key);
|
|
696
|
+
nextPrev.set(key, { formula, sheetId });
|
|
697
|
+
if (prevEntry?.formula === formula && prevEntry.sheetId === sheetId) {
|
|
698
|
+
continue;
|
|
699
|
+
}
|
|
700
|
+
toApply.push({ name, formula, sheetId });
|
|
701
|
+
}
|
|
702
|
+
// Order-independent batch: cross-name edges
|
|
703
|
+
// (`fullPrice = price * 1.08`) get wired correctly regardless
|
|
704
|
+
// of the order the names appear in the host's array.
|
|
705
|
+
if (toApply.length)
|
|
706
|
+
calc.registerNamedRanges(toApply);
|
|
707
|
+
registeredNamedRangeFormulasRef.current = nextPrev;
|
|
708
|
+
});
|
|
709
|
+
// Re-apply whenever the host's namedRanges list changes.
|
|
710
|
+
useEffect(() => {
|
|
711
|
+
applyNamedRanges(namedRanges);
|
|
712
|
+
}, [namedRanges, enabled, applyNamedRanges]);
|
|
713
|
+
// Hook for processing arrays
|
|
714
|
+
const [processArrayResults, createArraySideEffectsAndGetResults, getErrorResultsFromArrayPosition,] = useCalculationProcessArray({
|
|
715
|
+
locale,
|
|
716
|
+
getCalculator,
|
|
717
|
+
getSheetId: getSheetIdStable,
|
|
718
|
+
getComputationCache,
|
|
719
|
+
getUserEnteredValue,
|
|
720
|
+
getCellData: getCellDataStable,
|
|
721
|
+
});
|
|
722
|
+
/**
|
|
723
|
+
* Mark a cell
|
|
724
|
+
*/
|
|
725
|
+
const markCell = useCallback((coords, value, formatting) => {
|
|
726
|
+
const results = new Map();
|
|
727
|
+
const position = cellCoordsToCellCoordinate(coords, coords.sheet ? getSheetIdStable(coords.sheet) : getActiveSheetId());
|
|
728
|
+
const key = makeKey(position);
|
|
729
|
+
if (rafTimerMapRef.current.has(key)) {
|
|
730
|
+
const rafTimerId = rafTimerMapRef.current.get(key);
|
|
731
|
+
if (!isNil(rafTimerId)) {
|
|
732
|
+
cancelAnimationFrame(rafTimerId);
|
|
733
|
+
rafTimerMapRef.current.delete(key);
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
results.set(key, [position, value, formatting]);
|
|
737
|
+
publishResults(results.values());
|
|
738
|
+
}, []);
|
|
739
|
+
/**
|
|
740
|
+
* Mark a position as queue
|
|
741
|
+
*/
|
|
742
|
+
const markAsQueued = useCallback((coords) => {
|
|
743
|
+
markCell(coords, "Queued", {
|
|
744
|
+
horizontalAlignment: "center",
|
|
745
|
+
});
|
|
746
|
+
}, [markCell]);
|
|
747
|
+
/**
|
|
748
|
+
* Mark a position as loading
|
|
749
|
+
*/
|
|
750
|
+
const markAsLoading = useCallback((coords) => {
|
|
751
|
+
markCell(coords, "Loading...", {
|
|
752
|
+
horizontalAlignment: "center",
|
|
753
|
+
});
|
|
754
|
+
}, [markCell]);
|
|
755
|
+
/**
|
|
756
|
+
* Mark a position as error
|
|
757
|
+
*/
|
|
758
|
+
const markAsError = useCallback((coords, value) => {
|
|
759
|
+
markCell(coords, value, {
|
|
760
|
+
horizontalAlignment: "center",
|
|
761
|
+
textFormat: {
|
|
762
|
+
color: ERROR_COLOR,
|
|
763
|
+
},
|
|
764
|
+
});
|
|
765
|
+
}, [markCell]);
|
|
766
|
+
// On Recalculation: For dynamically updating calculated values
|
|
767
|
+
const onRecalculation = (coords, calculationResults) => {
|
|
768
|
+
const results = new Map();
|
|
769
|
+
const position = cellCoordsToCellCoordinate(coords, coords.sheet ? getSheetIdStable(coords.sheet) : getActiveSheetId());
|
|
770
|
+
const key = makeKey(position);
|
|
771
|
+
/**
|
|
772
|
+
* Multitenant returns null for
|
|
773
|
+
* unsubscribe callback
|
|
774
|
+
*/
|
|
775
|
+
if (calculationResults === null) {
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
// Set this cell as dirty
|
|
779
|
+
getCalculator().markAsDirty(position);
|
|
780
|
+
if (Array.isArray(calculationResults)) {
|
|
781
|
+
const [collides, recomputeOperations] = processArrayResults(calculationResults, position, results, getDependents);
|
|
782
|
+
if (collides) {
|
|
783
|
+
getCalculator().cleanupPipelineFunction(position);
|
|
784
|
+
}
|
|
785
|
+
// New compuete
|
|
786
|
+
enqueueCalculations(recomputeOperations);
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
// Add it to computation cache
|
|
790
|
+
getComputationCache().set(key, calculationResults);
|
|
791
|
+
// Push result to array
|
|
792
|
+
results.set(key, [position, calculationResults]);
|
|
793
|
+
}
|
|
794
|
+
scheduleStartCalculation(results, position);
|
|
795
|
+
};
|
|
796
|
+
// Begin calculation
|
|
797
|
+
const startCalculation = async (initialResults = new Map(), recalculatedPosition) => {
|
|
798
|
+
// `startCalculation` is invoked fire-and-forget (the RAF idle scheduler
|
|
799
|
+
// discards its promise, and `useDeferredCalculationFlush` types
|
|
800
|
+
// `onFlushComplete` as `() => void`), so a rejection here surfaces as a
|
|
801
|
+
// window `unhandledrejection` — seen in production as raw
|
|
802
|
+
// FormulaError("#NAME?", "Unknown range name") exceptions reaching users.
|
|
803
|
+
// Every per-cell path already converts FormulaError into a cell error
|
|
804
|
+
// value; this guard is the backstop for anything thrown outside those
|
|
805
|
+
// catches, so a recalc failure degrades to an aborted pass (dirty cells
|
|
806
|
+
// stay dirty for the next trigger) instead of an uncaught exception. The
|
|
807
|
+
// tail below still runs so calculation state is always released.
|
|
808
|
+
try {
|
|
809
|
+
// Publish initial results
|
|
810
|
+
if (initialResults.size) {
|
|
811
|
+
publishResults(initialResults.values());
|
|
812
|
+
}
|
|
813
|
+
// Per-batch processing of a run of dirty cells (lazy-calc
|
|
814
|
+
// filtering, circular detection, parallel evaluation). Extracted
|
|
815
|
+
// so the interleaved topo loop can call it per cell segment.
|
|
816
|
+
const runCellBatch = async (input) => {
|
|
817
|
+
let cellNodes = input;
|
|
818
|
+
const rootSheetId = enableLazyCalculation
|
|
819
|
+
? getActiveSheetId()
|
|
820
|
+
: undefined;
|
|
821
|
+
if (typeof rootSheetId === "number") {
|
|
822
|
+
const { included, deferred } = filterDirtyCellsForActiveSheet(cellNodes, rootSheetId);
|
|
823
|
+
if (deferred.length) {
|
|
824
|
+
deferCalculationNodes(deferred.map((cell) => cell.position));
|
|
825
|
+
}
|
|
826
|
+
cellNodes = included;
|
|
827
|
+
}
|
|
828
|
+
if (!cellNodes.length)
|
|
829
|
+
return;
|
|
830
|
+
if (!iterativeCalculationRef.current?.enabled) {
|
|
831
|
+
const circularKeys = findCircularKeys(cellNodes);
|
|
832
|
+
if (circularKeys.size) {
|
|
833
|
+
const results = new Map();
|
|
834
|
+
for (const node of cellNodes) {
|
|
835
|
+
if (!circularKeys.has(node.key)) {
|
|
836
|
+
continue;
|
|
837
|
+
}
|
|
838
|
+
const error = new FormulaError("#REF!", "Circular dependency detected.");
|
|
839
|
+
getComputationCache().set(node.key, error);
|
|
840
|
+
results.set(node.key, [node.position, error]);
|
|
841
|
+
}
|
|
842
|
+
publishResults(results.values());
|
|
843
|
+
cellNodes = cellNodes.filter((node) => !circularKeys.has(node.key));
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
await processCells(cellNodes, recalculatedPosition);
|
|
847
|
+
};
|
|
848
|
+
let dirtyCells = [];
|
|
849
|
+
while ((dirtyCells = getCalculator().getDirtyCells()) &&
|
|
850
|
+
dirtyCells.length !== 0) {
|
|
851
|
+
// Walk the dirty list in topological order, interleaving:
|
|
852
|
+
// - CellNode → batched and run by `runCellBatch` (parallel
|
|
853
|
+
// within the batch).
|
|
854
|
+
// - StaticNode that's a named-range virtual cell → evaluate
|
|
855
|
+
// inline; this populates the value cache so
|
|
856
|
+
// downstream cells in this same batch read
|
|
857
|
+
// the fresh value via `onVariable`.
|
|
858
|
+
// - StaticNode other (array spill etc) → `publishStaticCells`.
|
|
859
|
+
//
|
|
860
|
+
// Named-range nodes can appear anywhere in the topo order —
|
|
861
|
+
// they may depend on dirty cells that need to recompute first,
|
|
862
|
+
// and other cells may depend on them. We flush the pending
|
|
863
|
+
// cell batch before each static, so writes land in host state
|
|
864
|
+
// (via onSuccess) before the next static reads them. This is
|
|
865
|
+
// the Excel unified-sort semantics.
|
|
866
|
+
const calc = getCalculator();
|
|
867
|
+
const pendingCells = [];
|
|
868
|
+
const flushPending = async () => {
|
|
869
|
+
if (!pendingCells.length)
|
|
870
|
+
return;
|
|
871
|
+
const batch = pendingCells.slice();
|
|
872
|
+
pendingCells.length = 0;
|
|
873
|
+
await runCellBatch(batch);
|
|
874
|
+
};
|
|
875
|
+
for (const node of dirtyCells) {
|
|
876
|
+
// Duck-type instead of `instanceof` to survive bundler
|
|
877
|
+
// class-duplication: when @rowsncolumns/dag is inlined into separate
|
|
878
|
+
// chunks (the published rnc-engine path), its classes get distinct
|
|
879
|
+
// constructor identities and `instanceof` fails even for shape-identical
|
|
880
|
+
// nodes. StaticNode has no `position` (created via `new StaticNode(id)`);
|
|
881
|
+
// CellNode's `position` is a cell coordinate.
|
|
882
|
+
if (!node.position) {
|
|
883
|
+
await flushPending();
|
|
884
|
+
if (calc.isNamedRangeNodeKey(node.key)) {
|
|
885
|
+
await calc.evaluateNamedRangeNodeKey(node.key);
|
|
886
|
+
}
|
|
887
|
+
else {
|
|
888
|
+
publishStaticCells(node);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
else if (isCellCoordinate(node.position)) {
|
|
892
|
+
// `isCellCoordinate` narrows `node.position`, not `node`; the cast
|
|
893
|
+
// reflects the shape the guard just confirmed (a cell-coordinate node).
|
|
894
|
+
pendingCells.push(node);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
await flushPending();
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
catch (err) {
|
|
901
|
+
console.error("[spreadsheet-state] recalculation pass aborted:", err);
|
|
902
|
+
}
|
|
903
|
+
// Clear current calculation array results
|
|
904
|
+
initialArrayResults.current = new Map();
|
|
905
|
+
onAfterCalculation();
|
|
906
|
+
// If there are unconsumed forceRecalcKeys (added concurrently by a paste
|
|
907
|
+
// RAF while this calculation was running with stale closures), re-dirty
|
|
908
|
+
// those cells so the next calculation cycle (with fresh state) can evaluate
|
|
909
|
+
// them. Cap reschedules to prevent an infinite loop if a key can never be
|
|
910
|
+
// consumed.
|
|
911
|
+
if (forceRecalcKeys.current.size > 0) {
|
|
912
|
+
const MAX_RESCHEDULE = 50;
|
|
913
|
+
rescheduleCount.current = (rescheduleCount.current || 0) + 1;
|
|
914
|
+
if (rescheduleCount.current <= MAX_RESCHEDULE) {
|
|
915
|
+
forceRecalcPositions.current.forEach((pos) => {
|
|
916
|
+
getCalculator().markAsDirty(pos);
|
|
917
|
+
});
|
|
918
|
+
scheduleStartCalculation();
|
|
919
|
+
}
|
|
920
|
+
else {
|
|
921
|
+
// Give up — clear to avoid infinite spin.
|
|
922
|
+
forceRecalcKeys.current.clear();
|
|
923
|
+
forceRecalcPositions.current.clear();
|
|
924
|
+
rescheduleCount.current = 0;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
else {
|
|
928
|
+
rescheduleCount.current = 0;
|
|
929
|
+
}
|
|
930
|
+
// Trigger onChange
|
|
931
|
+
onChangeDependencyGraph?.(getCalculator().graph.toJSON());
|
|
932
|
+
};
|
|
933
|
+
startCalculationRef.current = startCalculation;
|
|
934
|
+
// Process async
|
|
935
|
+
async function processCells(cells, recalculatedPosition) {
|
|
936
|
+
if (!iterativeCalculationRef.current?.enabled) {
|
|
937
|
+
return processCellsInParallel(cells, recalculatedPosition);
|
|
938
|
+
}
|
|
939
|
+
const cellMap = new Map();
|
|
940
|
+
for (const cell of cells) {
|
|
941
|
+
cellMap.set(makeKey(cell.position), cell);
|
|
942
|
+
}
|
|
943
|
+
const adjacency = new Map();
|
|
944
|
+
const getDependencies = (cell) => {
|
|
945
|
+
const deps = getCalculator().getPrecedents(cell.position);
|
|
946
|
+
const depKeys = new Set();
|
|
947
|
+
for (const dep of deps) {
|
|
948
|
+
if (isCellNode(dep)) {
|
|
949
|
+
const depKey = makeKey(dep.position);
|
|
950
|
+
if (cellMap.has(depKey)) {
|
|
951
|
+
depKeys.add(depKey);
|
|
952
|
+
}
|
|
953
|
+
continue;
|
|
954
|
+
}
|
|
955
|
+
if (isCellRangeNode(dep)) {
|
|
956
|
+
const rangeDep = dep;
|
|
957
|
+
for (const candidate of cells) {
|
|
958
|
+
if (!isDerivedCellPosition(candidate.position) &&
|
|
959
|
+
isCellCoordinateWithinCellRange(candidate.position, rangeDep)) {
|
|
960
|
+
depKeys.add(makeKey(candidate.position));
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
return depKeys;
|
|
966
|
+
};
|
|
967
|
+
const hasSelfReference = (cell) => {
|
|
968
|
+
const userEnteredValue = getFinalUserEnteredValue(cell.position);
|
|
969
|
+
if (!isAFormula(userEnteredValue) || !userEnteredValue) {
|
|
970
|
+
return false;
|
|
971
|
+
}
|
|
972
|
+
const formulaValue = String(userEnteredValue).slice(1);
|
|
973
|
+
try {
|
|
974
|
+
const deps = getCalculator().dependencies(formulaValue, cell.position);
|
|
975
|
+
return deps.some((dep) => {
|
|
976
|
+
// Named-range static refs can't self-reference a cell.
|
|
977
|
+
if (isStaticReference(dep))
|
|
978
|
+
return false;
|
|
979
|
+
if (isCellCoordinate(dep)) {
|
|
980
|
+
return isEqualPosition(dep, cell.position);
|
|
981
|
+
}
|
|
982
|
+
return (dep.sheetId === cell.position.sheetId &&
|
|
983
|
+
cell.position.rowIndex >= dep.startRowIndex &&
|
|
984
|
+
cell.position.rowIndex <= dep.endRowIndex &&
|
|
985
|
+
cell.position.columnIndex >= dep.startColumnIndex &&
|
|
986
|
+
cell.position.columnIndex <= dep.endColumnIndex);
|
|
987
|
+
});
|
|
988
|
+
}
|
|
989
|
+
catch {
|
|
990
|
+
return false;
|
|
991
|
+
}
|
|
992
|
+
};
|
|
993
|
+
const indices = new Map();
|
|
994
|
+
const lowlinks = new Map();
|
|
995
|
+
const stack = [];
|
|
996
|
+
const onStack = new Set();
|
|
997
|
+
const iterativeGroups = [];
|
|
998
|
+
let index = 0;
|
|
999
|
+
const strongConnect = (key) => {
|
|
1000
|
+
indices.set(key, index);
|
|
1001
|
+
lowlinks.set(key, index);
|
|
1002
|
+
index++;
|
|
1003
|
+
stack.push(key);
|
|
1004
|
+
onStack.add(key);
|
|
1005
|
+
const deps = adjacency.get(key) ?? new Set();
|
|
1006
|
+
for (const depKey of deps) {
|
|
1007
|
+
if (!indices.has(depKey)) {
|
|
1008
|
+
strongConnect(depKey);
|
|
1009
|
+
lowlinks.set(key, Math.min(lowlinks.get(key), lowlinks.get(depKey)));
|
|
1010
|
+
}
|
|
1011
|
+
else if (onStack.has(depKey)) {
|
|
1012
|
+
lowlinks.set(key, Math.min(lowlinks.get(key), indices.get(depKey)));
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
if (lowlinks.get(key) === indices.get(key)) {
|
|
1016
|
+
const componentKeys = [];
|
|
1017
|
+
let current;
|
|
1018
|
+
do {
|
|
1019
|
+
current = stack.pop();
|
|
1020
|
+
if (!current) {
|
|
1021
|
+
break;
|
|
1022
|
+
}
|
|
1023
|
+
onStack.delete(current);
|
|
1024
|
+
componentKeys.push(current);
|
|
1025
|
+
} while (current !== key);
|
|
1026
|
+
if (componentKeys.length > 1) {
|
|
1027
|
+
iterativeGroups.push(componentKeys
|
|
1028
|
+
.map((componentKey) => cellMap.get(componentKey))
|
|
1029
|
+
.filter((cell) => !!cell));
|
|
1030
|
+
return;
|
|
1031
|
+
}
|
|
1032
|
+
const singleKey = componentKeys[0];
|
|
1033
|
+
const cell = singleKey ? cellMap.get(singleKey) : undefined;
|
|
1034
|
+
if (cell && hasSelfReference(cell)) {
|
|
1035
|
+
iterativeGroups.push([cell]);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
for (const cell of cells) {
|
|
1040
|
+
const key = makeKey(cell.position);
|
|
1041
|
+
if (!adjacency.has(key)) {
|
|
1042
|
+
adjacency.set(key, getDependencies(cell));
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
for (const cell of cells) {
|
|
1046
|
+
const key = makeKey(cell.position);
|
|
1047
|
+
if (!indices.has(key)) {
|
|
1048
|
+
strongConnect(key);
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
if (!iterativeGroups.length) {
|
|
1052
|
+
return processCellsInParallel(cells, recalculatedPosition);
|
|
1053
|
+
}
|
|
1054
|
+
const iterativeKeys = new Set();
|
|
1055
|
+
for (const group of iterativeGroups) {
|
|
1056
|
+
for (const cell of group) {
|
|
1057
|
+
iterativeKeys.add(makeKey(cell.position));
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
const nonIterativeCells = cells.filter((cell) => !iterativeKeys.has(makeKey(cell.position)));
|
|
1061
|
+
if (nonIterativeCells.length) {
|
|
1062
|
+
await processCellsInParallel(nonIterativeCells, recalculatedPosition);
|
|
1063
|
+
}
|
|
1064
|
+
const maxIterations = Math.max(1, iterativeCalculationRef.current?.maxIterations ?? 100);
|
|
1065
|
+
const maxChange = Math.max(0, iterativeCalculationRef.current?.maxChange ?? 0.001);
|
|
1066
|
+
for (const group of iterativeGroups) {
|
|
1067
|
+
for (const cell of group) {
|
|
1068
|
+
const effectiveValue = getEffectiveValue?.(cell.position.sheetId, cell.position.rowIndex, cell.position.columnIndex);
|
|
1069
|
+
if (isErrorResult(effectiveValue)) {
|
|
1070
|
+
getComputationCache().set(makeKey(cell.position), 0);
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
let previousValues = null;
|
|
1074
|
+
let converged = false;
|
|
1075
|
+
for (let iteration = 0; iteration < maxIterations; iteration++) {
|
|
1076
|
+
const currentValues = new Map();
|
|
1077
|
+
for (const cell of group) {
|
|
1078
|
+
if (recalculatedPosition &&
|
|
1079
|
+
isEqualPosition(cell.position, recalculatedPosition)) {
|
|
1080
|
+
continue;
|
|
1081
|
+
}
|
|
1082
|
+
const userEnteredValue = getFinalUserEnteredValue(cell.position);
|
|
1083
|
+
if (!isAFormula(userEnteredValue) || !userEnteredValue) {
|
|
1084
|
+
continue;
|
|
1085
|
+
}
|
|
1086
|
+
try {
|
|
1087
|
+
let result = await getCalculator().calculate(String(userEnteredValue).slice(1), cell.position);
|
|
1088
|
+
if (result instanceof DataSource) {
|
|
1089
|
+
result = await result.get();
|
|
1090
|
+
}
|
|
1091
|
+
const key = makeKey(cell.position);
|
|
1092
|
+
currentValues.set(key, result);
|
|
1093
|
+
if (!Array.isArray(result)) {
|
|
1094
|
+
getComputationCache().set(key, result);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
catch (err) {
|
|
1098
|
+
const error = err instanceof FormulaError
|
|
1099
|
+
? err
|
|
1100
|
+
: new FormulaError(err?.name ?? "#ERROR!", err?.message ?? String(err), err?.stack);
|
|
1101
|
+
currentValues.set(makeKey(cell.position), error);
|
|
1102
|
+
getComputationCache().set(makeKey(cell.position), error);
|
|
1103
|
+
}
|
|
1104
|
+
}
|
|
1105
|
+
if (previousValues) {
|
|
1106
|
+
let maxDelta = 0;
|
|
1107
|
+
for (const [key, value] of currentValues) {
|
|
1108
|
+
const delta = computeDelta(previousValues.get(key), value);
|
|
1109
|
+
if (delta > maxDelta) {
|
|
1110
|
+
maxDelta = delta;
|
|
1111
|
+
}
|
|
1112
|
+
}
|
|
1113
|
+
previousValues = currentValues;
|
|
1114
|
+
if (maxDelta <= maxChange) {
|
|
1115
|
+
converged = true;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
previousValues = currentValues;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
const finalValues = previousValues ?? new Map();
|
|
1124
|
+
const results = new Map();
|
|
1125
|
+
for (const cell of group) {
|
|
1126
|
+
const key = makeKey(cell.position);
|
|
1127
|
+
let value = finalValues.get(key);
|
|
1128
|
+
if (!converged) {
|
|
1129
|
+
value = new FormulaError("#NUM!", "Iterative calculation did not converge");
|
|
1130
|
+
}
|
|
1131
|
+
if (value instanceof FormulaError) {
|
|
1132
|
+
const [arrayErrors, recomputeOperations] = getErrorResultsFromArrayPosition(cell.position);
|
|
1133
|
+
getComputationCache().set(key, value);
|
|
1134
|
+
enqueueCalculations(recomputeOperations);
|
|
1135
|
+
results.set(key, [cell.position, value]);
|
|
1136
|
+
for (const [errorKey, errorValue] of arrayErrors) {
|
|
1137
|
+
results.set(errorKey, errorValue);
|
|
1138
|
+
}
|
|
1139
|
+
continue;
|
|
1140
|
+
}
|
|
1141
|
+
if (Array.isArray(value)) {
|
|
1142
|
+
const [collides, recomputeOperations] = processArrayResults(value, cell.position, results, getDependents);
|
|
1143
|
+
if (collides) {
|
|
1144
|
+
getCalculator().cleanupPipelineFunction(cell.position);
|
|
1145
|
+
}
|
|
1146
|
+
enqueueCalculations(recomputeOperations);
|
|
1147
|
+
}
|
|
1148
|
+
else {
|
|
1149
|
+
getComputationCache().set(key, value);
|
|
1150
|
+
results.set(key, [cell.position, value]);
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
publishResults(results.values());
|
|
1154
|
+
}
|
|
1155
|
+
const followUpCells = new Map();
|
|
1156
|
+
for (const group of iterativeGroups) {
|
|
1157
|
+
for (const cell of group) {
|
|
1158
|
+
const dependents = getDependents(cell.position);
|
|
1159
|
+
for (const dependent of dependents) {
|
|
1160
|
+
if (isCellNode(dependent)) {
|
|
1161
|
+
const cellDep = dependent;
|
|
1162
|
+
const depKey = makeKey(cellDep.position);
|
|
1163
|
+
if (!iterativeKeys.has(depKey)) {
|
|
1164
|
+
followUpCells.set(depKey, cellDep);
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
if (followUpCells.size) {
|
|
1171
|
+
await processCellsInParallel(Array.from(followUpCells.values()), recalculatedPosition);
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
async function processCellsInParallel(cells, recalculatedPosition) {
|
|
1175
|
+
const processingCells = new Set();
|
|
1176
|
+
async function processCellWithDependencies(cell) {
|
|
1177
|
+
const cellKey = makeKey(cell.position);
|
|
1178
|
+
// If the cell is already being processed, wait for it to complete
|
|
1179
|
+
while (processingCells.has(cellKey)) {
|
|
1180
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
1181
|
+
}
|
|
1182
|
+
if (cellPromises.has(cellKey)) {
|
|
1183
|
+
return cellPromises.get(cellKey).promise;
|
|
1184
|
+
}
|
|
1185
|
+
processingCells.add(cellKey);
|
|
1186
|
+
try {
|
|
1187
|
+
// Create a new AbortController for this cell
|
|
1188
|
+
const controller = new AbortController();
|
|
1189
|
+
const dependencies = getPrecedents(cell.position);
|
|
1190
|
+
// Use `isCellNode` / `isCellRangeNode` instead of `instanceof`.
|
|
1191
|
+
// When `@rowsncolumns/dag` is loaded through more than one
|
|
1192
|
+
// module-resolution path in a consumer bundle (CJS/ESM
|
|
1193
|
+
// dual-package hazard hits webpack/Next builds even with a
|
|
1194
|
+
// single installed copy), each path produces its own
|
|
1195
|
+
// constructor identity and `instanceof` returns `false` for
|
|
1196
|
+
// shape-identical nodes. The `___type`-tag check in these
|
|
1197
|
+
// helpers is identity-independent and survives across module
|
|
1198
|
+
// instances.
|
|
1199
|
+
const cellDependencies = dependencies.filter((dep) => isCellNode(dep) && cells.includes(dep));
|
|
1200
|
+
const rangeDependencies = dependencies.filter((dep) => isCellRangeNode(dep));
|
|
1201
|
+
for (const dep of rangeDependencies) {
|
|
1202
|
+
for (const cell of cells) {
|
|
1203
|
+
if (!isDerivedCellPosition(cell.position) &&
|
|
1204
|
+
isCellCoordinateWithinCellRange(cell.position, dep)) {
|
|
1205
|
+
cellDependencies.push(cell);
|
|
1206
|
+
}
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
const dependencyPromises = cellDependencies.map((dep) => processCellWithDependencies(dep));
|
|
1210
|
+
const cellPromise = (async () => {
|
|
1211
|
+
await Promise.allSettled(dependencyPromises);
|
|
1212
|
+
// Set signal
|
|
1213
|
+
cell.position.signal = controller.signal;
|
|
1214
|
+
// Process cell
|
|
1215
|
+
await processCell(cell, recalculatedPosition);
|
|
1216
|
+
// Remove signal after processing this cell
|
|
1217
|
+
delete cell.position.signal;
|
|
1218
|
+
})();
|
|
1219
|
+
cellPromises.set(cellKey, { promise: cellPromise, controller });
|
|
1220
|
+
return cellPromise;
|
|
1221
|
+
}
|
|
1222
|
+
finally {
|
|
1223
|
+
processingCells.delete(cellKey);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
// Remove old promises
|
|
1227
|
+
cells.forEach((cell) => {
|
|
1228
|
+
const key = makeKey(cell.position);
|
|
1229
|
+
if (key) {
|
|
1230
|
+
cellPromises.get(key)?.controller.abort();
|
|
1231
|
+
cellPromises.delete(key);
|
|
1232
|
+
}
|
|
1233
|
+
});
|
|
1234
|
+
const getCellWeight = (cell) => {
|
|
1235
|
+
const value = getFinalUserEnteredValue(cell.position);
|
|
1236
|
+
if (typeof value === "string" && value.startsWith("=")) {
|
|
1237
|
+
const formula = value.slice(1);
|
|
1238
|
+
if (isHeavyArrayFormula(formula)) {
|
|
1239
|
+
return ARRAY_FORMULA_WEIGHT;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
return 1;
|
|
1243
|
+
};
|
|
1244
|
+
const chunkCells = () => {
|
|
1245
|
+
if (!cells.length) {
|
|
1246
|
+
return [];
|
|
1247
|
+
}
|
|
1248
|
+
const chunks = [];
|
|
1249
|
+
let current = [];
|
|
1250
|
+
let weight = 0;
|
|
1251
|
+
const flush = () => {
|
|
1252
|
+
if (!current.length) {
|
|
1253
|
+
return;
|
|
1254
|
+
}
|
|
1255
|
+
chunks.push(current);
|
|
1256
|
+
current = [];
|
|
1257
|
+
weight = 0;
|
|
1258
|
+
};
|
|
1259
|
+
for (const cell of cells) {
|
|
1260
|
+
const nextWeight = getCellWeight(cell);
|
|
1261
|
+
if (current.length && weight + nextWeight > DEFAULT_BATCH_WEIGHT) {
|
|
1262
|
+
flush();
|
|
1263
|
+
}
|
|
1264
|
+
current.push(cell);
|
|
1265
|
+
weight += nextWeight;
|
|
1266
|
+
if (weight >= DEFAULT_BATCH_WEIGHT) {
|
|
1267
|
+
flush();
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
flush();
|
|
1271
|
+
return chunks.length ? chunks : [cells];
|
|
1272
|
+
};
|
|
1273
|
+
const chunks = chunkCells();
|
|
1274
|
+
for (let index = 0; index < chunks.length; index++) {
|
|
1275
|
+
const chunk = chunks[index];
|
|
1276
|
+
if (!chunk.length) {
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
const start = getTimestamp();
|
|
1280
|
+
await Promise.allSettled(chunk.map(processCellWithDependencies));
|
|
1281
|
+
const elapsed = getTimestamp() - start;
|
|
1282
|
+
if (elapsed >= MAX_CHUNK_DURATION_MS && index < chunks.length - 1) {
|
|
1283
|
+
await yieldToBrowser();
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
cellPromises.clear();
|
|
1287
|
+
}
|
|
1288
|
+
// Process a single dirty cell
|
|
1289
|
+
const processCell = async (dirtyCell, recalculatedPosition) => {
|
|
1290
|
+
const results = new Map();
|
|
1291
|
+
const { position, key } = dirtyCell;
|
|
1292
|
+
const userEnteredValue = getFinalUserEnteredValue(position);
|
|
1293
|
+
const isFormula = isAFormula(userEnteredValue);
|
|
1294
|
+
if (recalculatedPosition &&
|
|
1295
|
+
isEqualPosition(position, recalculatedPosition)) {
|
|
1296
|
+
debug("Prevent recalculation of pipeline function", key);
|
|
1297
|
+
return;
|
|
1298
|
+
}
|
|
1299
|
+
// Check for force
|
|
1300
|
+
if (onDemandPattern) {
|
|
1301
|
+
onDemandPattern.lastIndex = 0;
|
|
1302
|
+
}
|
|
1303
|
+
if (isFormula &&
|
|
1304
|
+
userEnteredValue &&
|
|
1305
|
+
onDemandPattern?.test(userEnteredValue)) {
|
|
1306
|
+
if (!forceRecalcKeys.current.has(key)) {
|
|
1307
|
+
// Prevent calculation
|
|
1308
|
+
const onDemandMap = new Map();
|
|
1309
|
+
onDemandMap.set(key, [position, AWAITING_CALCULATION]);
|
|
1310
|
+
onSuccess(onDemandMap.values());
|
|
1311
|
+
return;
|
|
1312
|
+
}
|
|
1313
|
+
// Mark this on-demand key as consumed inside the gate's PASSED branch.
|
|
1314
|
+
// A stale closure that reads userEnteredValue as undefined (pre-paste
|
|
1315
|
+
// state) has isFormula === false, so it never enters this gate and thus
|
|
1316
|
+
// never consumes the key. The key survives until the next calculation
|
|
1317
|
+
// cycle runs with fresh React state, where getFinalUserEnteredValue
|
|
1318
|
+
// returns the actual formula.
|
|
1319
|
+
consumedForceRecalcKeys.current.add(key);
|
|
1320
|
+
}
|
|
1321
|
+
// For non-on-demand cells in forceRecalcKeys, only consume when we can
|
|
1322
|
+
// confirm the cell actually holds a formula (guards against stale closures
|
|
1323
|
+
// where userEnteredValue is undefined).
|
|
1324
|
+
if (forceRecalcKeys.current.has(key) && isFormula && userEnteredValue) {
|
|
1325
|
+
consumedForceRecalcKeys.current.add(key);
|
|
1326
|
+
}
|
|
1327
|
+
// Log
|
|
1328
|
+
debug("Processing", position, key, userEnteredValue);
|
|
1329
|
+
if (isFormula && userEnteredValue) {
|
|
1330
|
+
let rafTimer;
|
|
1331
|
+
try {
|
|
1332
|
+
// Validate this formuala. Duck-type instead of `instanceof CellNode`
|
|
1333
|
+
// to survive bundler class-duplication (see the dirtyCells loop).
|
|
1334
|
+
const isCellNode = !!dirtyCell.position && isCellCoordinate(dirtyCell.position);
|
|
1335
|
+
rafTimer = isCellNode
|
|
1336
|
+
? requestAnimationFrame(() => publishBeginCalculation?.(dirtyCell))
|
|
1337
|
+
: undefined;
|
|
1338
|
+
if (!isNil(rafTimer)) {
|
|
1339
|
+
rafTimerMapRef.current.set(key, rafTimer);
|
|
1340
|
+
}
|
|
1341
|
+
let result = await getCalculator().calculate(userEnteredValue.slice(1), position);
|
|
1342
|
+
// Cancel
|
|
1343
|
+
if (rafTimer) {
|
|
1344
|
+
cancelAnimationFrame(rafTimer);
|
|
1345
|
+
rafTimerMapRef.current.delete(key);
|
|
1346
|
+
}
|
|
1347
|
+
// Datasource
|
|
1348
|
+
if (result instanceof DataSource) {
|
|
1349
|
+
result = await result.get();
|
|
1350
|
+
}
|
|
1351
|
+
// Array results
|
|
1352
|
+
if (Array.isArray(result)) {
|
|
1353
|
+
// Get all array cells (excludes parent cell) for recomputing in the same RAF
|
|
1354
|
+
const [collides, recomputeOperations] = processArrayResults(result, position, results, getDependents);
|
|
1355
|
+
// If it does collide
|
|
1356
|
+
if (collides) {
|
|
1357
|
+
getCalculator().cleanupPipelineFunction(position);
|
|
1358
|
+
}
|
|
1359
|
+
// New compuete
|
|
1360
|
+
enqueueCalculations(recomputeOperations);
|
|
1361
|
+
}
|
|
1362
|
+
else {
|
|
1363
|
+
// Add it to computation cache
|
|
1364
|
+
getComputationCache().set(key, result);
|
|
1365
|
+
// Invalidate any cached ranges containing this cell
|
|
1366
|
+
getCalculator().invalidateCacheForCell(position.sheetId, position.rowIndex, position.columnIndex);
|
|
1367
|
+
// Push result to array
|
|
1368
|
+
results.set(key, [position, result]);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
catch (err) {
|
|
1372
|
+
if (rafTimer) {
|
|
1373
|
+
cancelAnimationFrame(rafTimer);
|
|
1374
|
+
}
|
|
1375
|
+
// Calculation error
|
|
1376
|
+
if (err instanceof FormulaError || err instanceof Error) {
|
|
1377
|
+
// Cast error messages
|
|
1378
|
+
const error = err instanceof FormulaError
|
|
1379
|
+
? err
|
|
1380
|
+
: new FormulaError(err.name, err.message, err.stack);
|
|
1381
|
+
// We have to check if this error is caused in a cell
|
|
1382
|
+
// containing array formula
|
|
1383
|
+
// If so we have to reset all values references by this
|
|
1384
|
+
// array
|
|
1385
|
+
debug("Computation Error", error, position, key, userEnteredValue);
|
|
1386
|
+
const [arrayErrors, recomputeOperations] = getErrorResultsFromArrayPosition(position);
|
|
1387
|
+
// Add it to computation cache
|
|
1388
|
+
getComputationCache().set(key, error);
|
|
1389
|
+
// Invalidate any cached ranges containing this cell
|
|
1390
|
+
getCalculator().invalidateCacheForCell(position.sheetId, position.rowIndex, position.columnIndex);
|
|
1391
|
+
// New compuete
|
|
1392
|
+
enqueueCalculations(recomputeOperations);
|
|
1393
|
+
// Add to results
|
|
1394
|
+
results.set(key, [position, error]);
|
|
1395
|
+
for (const [key, value] of arrayErrors) {
|
|
1396
|
+
results.set(key, value);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
publishResults(results.values());
|
|
1401
|
+
}
|
|
1402
|
+
else {
|
|
1403
|
+
// Cleanup functions
|
|
1404
|
+
// Scenario -
|
|
1405
|
+
// 1. Delete a pipeline function
|
|
1406
|
+
// 2. Undo
|
|
1407
|
+
// 3. And then Redo - Cleanup should be called when formula is deleted
|
|
1408
|
+
getCalculator().cleanupPipelineFunction(position);
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1411
|
+
/**
|
|
1412
|
+
* Publish static cells back
|
|
1413
|
+
*/
|
|
1414
|
+
const publishStaticCells = useCallback((node) => {
|
|
1415
|
+
if (staticNodeArrayRef.current.push(node) === 1) {
|
|
1416
|
+
requestAnimationFrame(() => {
|
|
1417
|
+
try {
|
|
1418
|
+
onChangeStaticReference?.(staticNodeArrayRef.current);
|
|
1419
|
+
}
|
|
1420
|
+
catch (err) {
|
|
1421
|
+
console.error("[spreadsheet-state] recalculation pass aborted:", err);
|
|
1422
|
+
}
|
|
1423
|
+
finally {
|
|
1424
|
+
staticNodeArrayRef.current.length = 0;
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
}
|
|
1428
|
+
}, [onChangeStaticReference]);
|
|
1429
|
+
/**
|
|
1430
|
+
* Publish loading cells
|
|
1431
|
+
*/
|
|
1432
|
+
const publishBeginCalculation = useCallback((node) => {
|
|
1433
|
+
if (initialCalculationArrayRef.current.push(node.position) === 1) {
|
|
1434
|
+
requestAnimationFrame(() => {
|
|
1435
|
+
try {
|
|
1436
|
+
onBeginCalculation?.(initialCalculationArrayRef.current);
|
|
1437
|
+
}
|
|
1438
|
+
catch (err) {
|
|
1439
|
+
console.error("[spreadsheet-state] recalculation pass aborted:", err);
|
|
1440
|
+
}
|
|
1441
|
+
finally {
|
|
1442
|
+
initialCalculationArrayRef.current.length = 0;
|
|
1443
|
+
}
|
|
1444
|
+
});
|
|
1445
|
+
}
|
|
1446
|
+
}, [onBeginCalculation]);
|
|
1447
|
+
/**
|
|
1448
|
+
* Publish results back to the
|
|
1449
|
+
*/
|
|
1450
|
+
const publishResults = useCallback((item) => {
|
|
1451
|
+
for (const entry of item) {
|
|
1452
|
+
const [key] = entry;
|
|
1453
|
+
resultsQueueRef.current.set(makeKey(key), entry);
|
|
1454
|
+
}
|
|
1455
|
+
if (resultsQueueRef.current.size === 0) {
|
|
1456
|
+
return;
|
|
1457
|
+
}
|
|
1458
|
+
if (resultsFlushPendingRef.current) {
|
|
1459
|
+
return;
|
|
1460
|
+
}
|
|
1461
|
+
resultsFlushPendingRef.current = true;
|
|
1462
|
+
const isFullRecalc = isFullRecalcRef.current;
|
|
1463
|
+
// The flush RAF is fire-and-forget: a throw from the host's `onSuccess`
|
|
1464
|
+
// used to escape to `window.onerror` as a raw uncaught exception.
|
|
1465
|
+
// Contain it, and clear the queue in `finally` so a throwing host
|
|
1466
|
+
// callback can't replay the same results on every subsequent flush.
|
|
1467
|
+
requestAnimationFrame(() => {
|
|
1468
|
+
resultsFlushPendingRef.current = false;
|
|
1469
|
+
if (!resultsQueueRef.current.size) {
|
|
1470
|
+
return;
|
|
1471
|
+
}
|
|
1472
|
+
try {
|
|
1473
|
+
onSuccess?.(resultsQueueRef.current.values(), isFullRecalc, {});
|
|
1474
|
+
}
|
|
1475
|
+
catch (err) {
|
|
1476
|
+
console.error("[spreadsheet-state] recalculation pass aborted:", err);
|
|
1477
|
+
}
|
|
1478
|
+
finally {
|
|
1479
|
+
resultsQueueRef.current.clear();
|
|
1480
|
+
isFullRecalcRef.current = false;
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
}, [onSuccess]);
|
|
1484
|
+
// Immediately enqueue a calculation
|
|
1485
|
+
const enqueueCalculations = (operations) => {
|
|
1486
|
+
operations.forEach(processSingleOperation);
|
|
1487
|
+
};
|
|
1488
|
+
// Seed the calculator's array range map with a persisted spill range.
|
|
1489
|
+
// No-op when no spillRange is supplied or the sheet name can't be resolved.
|
|
1490
|
+
const seedArraySpillRange = (position, spillRange) => {
|
|
1491
|
+
if (!spillRange) {
|
|
1492
|
+
return;
|
|
1493
|
+
}
|
|
1494
|
+
const calculator = getCalculator();
|
|
1495
|
+
const sheetName = calculator.getSheetName(position.sheetId);
|
|
1496
|
+
if (!sheetName) {
|
|
1497
|
+
return;
|
|
1498
|
+
}
|
|
1499
|
+
calculator.setArrayRangeReference(position, {
|
|
1500
|
+
sheet: sheetName,
|
|
1501
|
+
from: {
|
|
1502
|
+
row: spillRange.startRowIndex,
|
|
1503
|
+
col: spillRange.startColumnIndex,
|
|
1504
|
+
},
|
|
1505
|
+
to: {
|
|
1506
|
+
row: spillRange.endRowIndex,
|
|
1507
|
+
col: spillRange.endColumnIndex,
|
|
1508
|
+
},
|
|
1509
|
+
});
|
|
1510
|
+
};
|
|
1511
|
+
// Process a single
|
|
1512
|
+
const processSingleOperation = (operation) => {
|
|
1513
|
+
const { position, type, force, spillRange } = operation;
|
|
1514
|
+
const userEnteredValue = getFinalUserEnteredValue(position);
|
|
1515
|
+
const isFormula = isAFormula(userEnteredValue);
|
|
1516
|
+
const formulaValue = isFormula
|
|
1517
|
+
? String(userEnteredValue)?.slice(1)
|
|
1518
|
+
: undefined;
|
|
1519
|
+
if (force) {
|
|
1520
|
+
const forceKey = makeKey(position);
|
|
1521
|
+
forceRecalcKeys.current.add(forceKey);
|
|
1522
|
+
forceRecalcPositions.current.set(forceKey, position);
|
|
1523
|
+
}
|
|
1524
|
+
try {
|
|
1525
|
+
// Add/remove to DAG
|
|
1526
|
+
if (isFormula && formulaValue) {
|
|
1527
|
+
// Does both add and update formula. Updates DAG references
|
|
1528
|
+
getCalculator().addFormula(formulaValue, position);
|
|
1529
|
+
// Seed array spill range from persisted ref so dependents pointing
|
|
1530
|
+
// into the spill region resolve on first load without re-eval.
|
|
1531
|
+
seedArraySpillRange(position, spillRange);
|
|
1532
|
+
// Add to ephemeral
|
|
1533
|
+
addToEphemeralFunction(formulaValue, position);
|
|
1534
|
+
}
|
|
1535
|
+
else if (type === "add") {
|
|
1536
|
+
// If user replaces a formula with static text
|
|
1537
|
+
// Remove old references
|
|
1538
|
+
getCalculator().removePrecedents(position);
|
|
1539
|
+
// Mark this cell as dirty
|
|
1540
|
+
getCalculator().markAsDirty(position);
|
|
1541
|
+
// Cleanup ephemeral
|
|
1542
|
+
removeFromEphemeralFunction(position);
|
|
1543
|
+
}
|
|
1544
|
+
else if (type === "dirty") {
|
|
1545
|
+
getCalculator().markAsDirty(position);
|
|
1546
|
+
}
|
|
1547
|
+
else if (type === "remove") {
|
|
1548
|
+
// Remove cell and mark its dependents dirty (not the cell itself)
|
|
1549
|
+
getCalculator().removeCellAndMarkDependentsDirty(position);
|
|
1550
|
+
// Remove ephemeral cells
|
|
1551
|
+
removeFromEphemeralFunction(position);
|
|
1552
|
+
}
|
|
1553
|
+
}
|
|
1554
|
+
catch (err) {
|
|
1555
|
+
if (isFormula) {
|
|
1556
|
+
// Delete formula references
|
|
1557
|
+
getCalculator().removeFormula(position);
|
|
1558
|
+
}
|
|
1559
|
+
// Remove all cell dependencies
|
|
1560
|
+
getCalculator().deleteCell(position);
|
|
1561
|
+
// Remove it from being executed again
|
|
1562
|
+
getCalculator().unMarkAsDirty(position);
|
|
1563
|
+
// For circular dependencies
|
|
1564
|
+
const errorMap = new Map([
|
|
1565
|
+
[makeKey(position), [position, new FormulaError("#REF!", String(err))]],
|
|
1566
|
+
]);
|
|
1567
|
+
publishResults(errorMap.values());
|
|
1568
|
+
}
|
|
1569
|
+
};
|
|
1570
|
+
// Update dependency graph
|
|
1571
|
+
// without making cells dirty
|
|
1572
|
+
const processUpdateDependencyGraphOperation = useCallback((operation) => {
|
|
1573
|
+
const { position, type, previousPosition, spillRange } = operation;
|
|
1574
|
+
const userEnteredValue = getFinalUserEnteredValue(position);
|
|
1575
|
+
const isFormula = isAFormula(userEnteredValue);
|
|
1576
|
+
const formulaValue = isFormula
|
|
1577
|
+
? String(userEnteredValue)?.slice(1)
|
|
1578
|
+
: undefined;
|
|
1579
|
+
// We need to move array formulas
|
|
1580
|
+
if (previousPosition) {
|
|
1581
|
+
const shouldRemoveArrayReference = false;
|
|
1582
|
+
const arraySideEffects = createArraySideEffectsAndGetResults({
|
|
1583
|
+
position: previousPosition,
|
|
1584
|
+
shouldRemoveArrayReference,
|
|
1585
|
+
getDependents,
|
|
1586
|
+
});
|
|
1587
|
+
if (arraySideEffects.size) {
|
|
1588
|
+
// Immediately publish array side effects
|
|
1589
|
+
publishResults(arraySideEffects.values());
|
|
1590
|
+
}
|
|
1591
|
+
if (getCalculator().isArray(previousPosition)) {
|
|
1592
|
+
getCalculator().shiftArrayFormula(previousPosition, position);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
try {
|
|
1596
|
+
// Add/remove to DAG
|
|
1597
|
+
if (isFormula && formulaValue) {
|
|
1598
|
+
// Does both add and update formula. Updates DAG references
|
|
1599
|
+
getCalculator().addFormulaToGraph(formulaValue, position);
|
|
1600
|
+
// Seed array spill range so dependents in the spill region resolve
|
|
1601
|
+
// through the DAG even though we skipped evaluation.
|
|
1602
|
+
seedArraySpillRange(position, spillRange);
|
|
1603
|
+
}
|
|
1604
|
+
else if (type === "remove") {
|
|
1605
|
+
getCalculator().removeCellFromGraph(position);
|
|
1606
|
+
}
|
|
1607
|
+
else if (type === "add") {
|
|
1608
|
+
// If user replaces a formula with static text
|
|
1609
|
+
// Remove old references
|
|
1610
|
+
getCalculator().removePrecendentsFromGraph(position);
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
catch (err) {
|
|
1614
|
+
error("Error when updateDependencyGraphFromOperation", err);
|
|
1615
|
+
}
|
|
1616
|
+
}, [getFinalUserEnteredValue]);
|
|
1617
|
+
/**
|
|
1618
|
+
* Goes through the queue of update operations and processes them.
|
|
1619
|
+
*
|
|
1620
|
+
* Optimization: Instead of using shift() which is O(n) per call (making the
|
|
1621
|
+
* entire loop O(n²)), we swap the queue with an empty array and iterate
|
|
1622
|
+
* with a for loop. This makes the entire operation O(n).
|
|
1623
|
+
*
|
|
1624
|
+
* If new operations are enqueued during processing, they go into the new
|
|
1625
|
+
* empty array and will be processed in the next animation frame.
|
|
1626
|
+
*/
|
|
1627
|
+
const processUpdateDependencyGraphQueue = useCallback(() => {
|
|
1628
|
+
// Swap queue with empty array - O(1) operation
|
|
1629
|
+
const operations = graphOperationQueue.current;
|
|
1630
|
+
if (operations.length === 0)
|
|
1631
|
+
return;
|
|
1632
|
+
graphOperationQueue.current = [];
|
|
1633
|
+
// Process all operations - O(n) total
|
|
1634
|
+
for (let i = 0; i < operations.length; i++) {
|
|
1635
|
+
const operation = operations[i];
|
|
1636
|
+
if (operation) {
|
|
1637
|
+
processUpdateDependencyGraphOperation(operation);
|
|
1638
|
+
}
|
|
1639
|
+
}
|
|
1640
|
+
}, [processUpdateDependencyGraphOperation]);
|
|
1641
|
+
// Add to calculation queue
|
|
1642
|
+
// Stable reference prevents re-render of grid
|
|
1643
|
+
const enqueueGraphOperation = useCallbackRef(useCallback((operation) => {
|
|
1644
|
+
if (graphOperationQueue.current.push(operation) === 1) {
|
|
1645
|
+
requestAnimationFrame(() => {
|
|
1646
|
+
try {
|
|
1647
|
+
// Process operation queuu
|
|
1648
|
+
processUpdateDependencyGraphQueue();
|
|
1649
|
+
}
|
|
1650
|
+
catch (err) {
|
|
1651
|
+
console.error("[spreadsheet-state] recalculation pass aborted:", err);
|
|
1652
|
+
}
|
|
1653
|
+
});
|
|
1654
|
+
}
|
|
1655
|
+
}, [processUpdateDependencyGraphQueue]));
|
|
1656
|
+
useDeferredCalculationFlush({
|
|
1657
|
+
activeSheetId: enableLazyCalculation && !isNil(activeSheetId)
|
|
1658
|
+
? activeSheetId
|
|
1659
|
+
: undefined,
|
|
1660
|
+
deferredOperationsBySheetRef,
|
|
1661
|
+
enqueueOperation: processSingleOperation,
|
|
1662
|
+
onChunkComplete: yieldToBrowser,
|
|
1663
|
+
onFlushComplete: startCalculation,
|
|
1664
|
+
});
|
|
1665
|
+
// Get all precendets of a cell
|
|
1666
|
+
const getPrecedents = useCallback((source, includeSource) => {
|
|
1667
|
+
return getCalculator()
|
|
1668
|
+
.getPrecedents(source)
|
|
1669
|
+
.filter(
|
|
1670
|
+
// Ignore source
|
|
1671
|
+
(node) => {
|
|
1672
|
+
if (isStaticNode(node)) {
|
|
1673
|
+
return true;
|
|
1674
|
+
}
|
|
1675
|
+
// After isStaticNode early-return, node is CellNode or
|
|
1676
|
+
// CellRangeNode — both have a defined position. The cast
|
|
1677
|
+
// bridges a TS narrowing limitation across the union.
|
|
1678
|
+
const pos = node.position;
|
|
1679
|
+
if (!includeSource &&
|
|
1680
|
+
isCellCoordinate(pos) &&
|
|
1681
|
+
isCellCoordinate(source)) {
|
|
1682
|
+
return !isEqualPosition(pos, source);
|
|
1683
|
+
}
|
|
1684
|
+
if (includeSource &&
|
|
1685
|
+
!isCellCoordinate(pos) &&
|
|
1686
|
+
!isCellCoordinate(source)) {
|
|
1687
|
+
return !isAreasEqual(pos, source);
|
|
1688
|
+
}
|
|
1689
|
+
return true;
|
|
1690
|
+
});
|
|
1691
|
+
}, []);
|
|
1692
|
+
// Get precedents from formula string
|
|
1693
|
+
// Does not check with DAG
|
|
1694
|
+
const getPrecedentsFromFormulaString = useCallback((value, source) => {
|
|
1695
|
+
const dependencies = getCalculator().dependencies(value, source);
|
|
1696
|
+
const nodes = [];
|
|
1697
|
+
for (const pos of dependencies) {
|
|
1698
|
+
if (isStaticReference(pos)) {
|
|
1699
|
+
// Named-range static reference. Build a StaticNode shape
|
|
1700
|
+
// — caller treats it as a non-cell precedent.
|
|
1701
|
+
nodes.push(new StaticNode(makeKey(pos)));
|
|
1702
|
+
}
|
|
1703
|
+
else if (isCellCoordinate(pos)) {
|
|
1704
|
+
nodes.push(new CellNode(makeKey(pos), pos));
|
|
1705
|
+
}
|
|
1706
|
+
else {
|
|
1707
|
+
nodes.push(new CellRangeNode(makeKey(pos), pos));
|
|
1708
|
+
}
|
|
1709
|
+
}
|
|
1710
|
+
return nodes;
|
|
1711
|
+
}, []);
|
|
1712
|
+
// Is array formula
|
|
1713
|
+
const isArrayFormula = useCallbackRef(useCallback((position) => {
|
|
1714
|
+
return (getCalculator().isArray(position) ||
|
|
1715
|
+
getCalculator().isInArrayRange(position));
|
|
1716
|
+
}, []));
|
|
1717
|
+
// Get all dependents of a cell. Returns a mixed list — narrow with
|
|
1718
|
+
// the `isCellNode`/`isStaticNode` helpers at call sites (NOT
|
|
1719
|
+
// `instanceof`, which breaks across bundler module instances).
|
|
1720
|
+
const getDependents = useCallback((source, includeSource) => {
|
|
1721
|
+
return getCalculator()
|
|
1722
|
+
.getDependents(source)
|
|
1723
|
+
.filter(
|
|
1724
|
+
// Ignore source
|
|
1725
|
+
(node) => {
|
|
1726
|
+
if (isStaticNode(node)) {
|
|
1727
|
+
return true;
|
|
1728
|
+
}
|
|
1729
|
+
// Array formulas
|
|
1730
|
+
if (isArrayFormula(node.position)) {
|
|
1731
|
+
return true;
|
|
1732
|
+
}
|
|
1733
|
+
// For cell range
|
|
1734
|
+
if (!includeSource && isCellRangeNode(node)) {
|
|
1735
|
+
return !isAreasEqual(node.position, source);
|
|
1736
|
+
}
|
|
1737
|
+
if (!includeSource &&
|
|
1738
|
+
isCellCoordinate(source) &&
|
|
1739
|
+
isCellNode(node)) {
|
|
1740
|
+
return (node.position.rowIndex !== source.rowIndex ||
|
|
1741
|
+
node.position.columnIndex !== source.columnIndex);
|
|
1742
|
+
}
|
|
1743
|
+
return true;
|
|
1744
|
+
});
|
|
1745
|
+
}, [isArrayFormula]);
|
|
1746
|
+
/**
|
|
1747
|
+
* Process the calculation operation queue.
|
|
1748
|
+
*
|
|
1749
|
+
* Optimization: Instead of using shift() which is O(n) per call (making the
|
|
1750
|
+
* entire loop O(n²)), we swap the queue with an empty array and iterate
|
|
1751
|
+
* with a for loop. This makes the entire operation O(n).
|
|
1752
|
+
*
|
|
1753
|
+
* If new operations are enqueued during processing (via processSingleOperation),
|
|
1754
|
+
* they go into the new empty array and will trigger a new requestAnimationFrame
|
|
1755
|
+
* via the enqueue logic.
|
|
1756
|
+
*/
|
|
1757
|
+
const processOperationQueue = useCallback(() => {
|
|
1758
|
+
// Swap queue with empty array - O(1) operation
|
|
1759
|
+
const operations = operationQueue.current;
|
|
1760
|
+
if (operations.length === 0)
|
|
1761
|
+
return;
|
|
1762
|
+
operationQueue.current = [];
|
|
1763
|
+
// Process all operations - O(n) total
|
|
1764
|
+
for (let i = 0; i < operations.length; i++) {
|
|
1765
|
+
const operation = operations[i];
|
|
1766
|
+
if (operation) {
|
|
1767
|
+
const clearedArrayRange = operation.type !== "dirty" && isArrayFormula(operation.position)
|
|
1768
|
+
? getCalculator().getArrayRange(operation.position)
|
|
1769
|
+
: undefined;
|
|
1770
|
+
if (operation.type === "remove") {
|
|
1771
|
+
// Only publish undefined result for formulas or array formulas
|
|
1772
|
+
// Static cells don't need calculation results
|
|
1773
|
+
const userEnteredValue = getFinalUserEnteredValue(operation.position);
|
|
1774
|
+
if (isAFormula(userEnteredValue) ||
|
|
1775
|
+
isArrayFormula(operation.position)) {
|
|
1776
|
+
initialArrayResults.current.set(makeKey(operation.position), [
|
|
1777
|
+
operation.position,
|
|
1778
|
+
undefined,
|
|
1779
|
+
]);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
if (operation.type !== "dirty" && isArrayFormula(operation.position)) {
|
|
1783
|
+
const parentCandidates = new Map();
|
|
1784
|
+
for (const [key, value] of createArraySideEffectsAndGetResults({
|
|
1785
|
+
position: operation.position,
|
|
1786
|
+
getDependents,
|
|
1787
|
+
})) {
|
|
1788
|
+
initialArrayResults.current.set(key, value);
|
|
1789
|
+
const [cellPosition] = value;
|
|
1790
|
+
const parent = getCalculator().getClosestArrayParentCell(cellPosition);
|
|
1791
|
+
if (parent &&
|
|
1792
|
+
!isEqualPosition(parent, cellPosition) &&
|
|
1793
|
+
!isEqualPosition(parent, operation.position)) {
|
|
1794
|
+
parentCandidates.set(makeKey(parent), parent);
|
|
1795
|
+
}
|
|
1796
|
+
}
|
|
1797
|
+
for (const parent of parentCandidates.values()) {
|
|
1798
|
+
getCalculator().markAsDirty(parent);
|
|
1799
|
+
}
|
|
1800
|
+
if (clearedArrayRange) {
|
|
1801
|
+
for (const [key, range] of getCalculator().arrayRangeMap) {
|
|
1802
|
+
if (!rangesOverlap(range, clearedArrayRange)) {
|
|
1803
|
+
continue;
|
|
1804
|
+
}
|
|
1805
|
+
const anchor = getCalculator().arrayReferenceMap.get(key);
|
|
1806
|
+
if (anchor && !isEqualPosition(anchor, operation.position)) {
|
|
1807
|
+
getCalculator().markAsDirty(anchor);
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
const arrayParent = getCalculator().getClosestArrayParentCell(operation.position);
|
|
1813
|
+
if (arrayParent && !isEqualPosition(arrayParent, operation.position)) {
|
|
1814
|
+
for (const [key, value] of createArraySideEffectsAndGetResults({
|
|
1815
|
+
position: arrayParent,
|
|
1816
|
+
shouldRemoveArrayReference: false,
|
|
1817
|
+
getDependents,
|
|
1818
|
+
})) {
|
|
1819
|
+
initialArrayResults.current.set(key, value);
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
// Backend driven
|
|
1823
|
+
// When a backend sets a effective value of a formula
|
|
1824
|
+
// Only update the dependent cells.
|
|
1825
|
+
// This can be removed if the agent can do cell dependency computation
|
|
1826
|
+
// And update the changed cells in the back-end
|
|
1827
|
+
if (operation.source === "backend") {
|
|
1828
|
+
const graph = getCalculator().graph;
|
|
1829
|
+
const hasRanges = graph.ranges.size > 0;
|
|
1830
|
+
let shouldResolveDependents = hasRanges;
|
|
1831
|
+
if (!hasRanges) {
|
|
1832
|
+
if (graph.hasNode(operation.position)) {
|
|
1833
|
+
const node = graph.getNode(operation.position);
|
|
1834
|
+
shouldResolveDependents = node.dependentKeys.size > 0;
|
|
1835
|
+
}
|
|
1836
|
+
else {
|
|
1837
|
+
shouldResolveDependents = false;
|
|
1838
|
+
}
|
|
1839
|
+
}
|
|
1840
|
+
if (!shouldResolveDependents) {
|
|
1841
|
+
continue;
|
|
1842
|
+
}
|
|
1843
|
+
const dependents = getDependents(operation.position);
|
|
1844
|
+
dependents.forEach((dependent) => {
|
|
1845
|
+
if (isCellNode(dependent)) {
|
|
1846
|
+
// CellNode.position is always defined — assertion to
|
|
1847
|
+
// bridge a TS narrowing limitation across the union.
|
|
1848
|
+
processSingleOperation({
|
|
1849
|
+
type: "dirty",
|
|
1850
|
+
position: dependent.position,
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
else {
|
|
1856
|
+
// Process operation
|
|
1857
|
+
processSingleOperation(operation);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
}
|
|
1861
|
+
}, [
|
|
1862
|
+
createArraySideEffectsAndGetResults,
|
|
1863
|
+
getDependents,
|
|
1864
|
+
processSingleOperation,
|
|
1865
|
+
]);
|
|
1866
|
+
// Add to calculation queue
|
|
1867
|
+
// Stable reference prevents re-render of grid
|
|
1868
|
+
const enqueueCalculation = useCallbackRef(useCallback((operation) => {
|
|
1869
|
+
if (operationQueue.current.push(operation) === 1) {
|
|
1870
|
+
// The RAF callback runs the queue processing + initial publish
|
|
1871
|
+
// synchronously, so a throw here escapes straight to
|
|
1872
|
+
// `window.onerror` (the `$exception` twin of the fire-and-forget
|
|
1873
|
+
// rejection guarded in `startCalculation`). Contain it the same
|
|
1874
|
+
// way: abort this pass, leave the queue for the next trigger.
|
|
1875
|
+
requestAnimationFrame(() => {
|
|
1876
|
+
try {
|
|
1877
|
+
const hasValueAffectingNonEphemeralOp = operationQueue.current.some((queued) => !ephemeralCellsRef.current.has(makeKey(queued.position)));
|
|
1878
|
+
if (hasValueAffectingNonEphemeralOp) {
|
|
1879
|
+
// Add ephemeral functions
|
|
1880
|
+
operationQueue.current.push(...getEphemeralCells());
|
|
1881
|
+
}
|
|
1882
|
+
// Process operation queuu
|
|
1883
|
+
processOperationQueue();
|
|
1884
|
+
const initialResults = initialArrayResults.current;
|
|
1885
|
+
const shouldPublishInitialResults = initialResults.size > 0;
|
|
1886
|
+
if (shouldPublishInitialResults) {
|
|
1887
|
+
initialArrayResults.current = new Map();
|
|
1888
|
+
publishResults(initialResults.values());
|
|
1889
|
+
requestAnimationFrame(() => {
|
|
1890
|
+
scheduleStartCalculation();
|
|
1891
|
+
});
|
|
1892
|
+
return;
|
|
1893
|
+
}
|
|
1894
|
+
// Start calculation
|
|
1895
|
+
scheduleStartCalculation(initialResults);
|
|
1896
|
+
}
|
|
1897
|
+
catch (err) {
|
|
1898
|
+
console.error("[spreadsheet-state] recalculation pass aborted:", err);
|
|
1899
|
+
}
|
|
1900
|
+
});
|
|
1901
|
+
}
|
|
1902
|
+
}, [processOperationQueue, processSingleOperation, scheduleStartCalculation]));
|
|
1903
|
+
// Delete all sheet references
|
|
1904
|
+
const deleteSheetReferences = useCallback((sheetId) => {
|
|
1905
|
+
return getCalculator().deleteSheet(sheetId);
|
|
1906
|
+
}, []);
|
|
1907
|
+
const enqueueStructureChange = useCallbackRef(useCallback((change) => {
|
|
1908
|
+
const range = getInvalidationRangeFromStructureChange(change);
|
|
1909
|
+
if (!range) {
|
|
1910
|
+
return;
|
|
1911
|
+
}
|
|
1912
|
+
getCalculator().invalidateCacheForRange(range.sheetId, range.startRowIndex, range.startColumnIndex, range.endRowIndex, range.endColumnIndex);
|
|
1913
|
+
}, []));
|
|
1914
|
+
const clearRangeCache = useCallbackRef(useCallback(() => {
|
|
1915
|
+
getCalculator().clearRangeCache();
|
|
1916
|
+
}, []));
|
|
1917
|
+
// Used for formula preview
|
|
1918
|
+
const onRequestCalculate = useCallback(async (value, sheetId, rowIndex, columnIndex, options) => {
|
|
1919
|
+
const isArray = options?.isArray ?? false;
|
|
1920
|
+
const disablePreview = options?.disablePreview ?? false;
|
|
1921
|
+
const skipOnDemand = options?.skipOnDemand ?? true;
|
|
1922
|
+
if (skipOnDemand && onDemandPattern) {
|
|
1923
|
+
onDemandPattern.lastIndex = 0;
|
|
1924
|
+
}
|
|
1925
|
+
if (skipOnDemand && isAFormula(value) && onDemandPattern?.test(value)) {
|
|
1926
|
+
return undefined;
|
|
1927
|
+
}
|
|
1928
|
+
const previousOverrides = overridesRef.current;
|
|
1929
|
+
overridesRef.current = options?.overrides ?? null;
|
|
1930
|
+
const position = { sheetId, rowIndex, columnIndex };
|
|
1931
|
+
try {
|
|
1932
|
+
if (iterativeCalculationRef.current?.enabled &&
|
|
1933
|
+
isAFormula(value) &&
|
|
1934
|
+
!disablePreview) {
|
|
1935
|
+
const precedents = getPrecedentsFromFormulaString(value.slice(1), position);
|
|
1936
|
+
const isCircular = precedents.some((node) => {
|
|
1937
|
+
const range = node.position;
|
|
1938
|
+
// Named-range static nodes have no grid position — they
|
|
1939
|
+
// can't be a circular self-reference.
|
|
1940
|
+
if (!range)
|
|
1941
|
+
return false;
|
|
1942
|
+
if ("rowIndex" in range) {
|
|
1943
|
+
return (range.sheetId === sheetId &&
|
|
1944
|
+
range.rowIndex === rowIndex &&
|
|
1945
|
+
range.columnIndex === columnIndex);
|
|
1946
|
+
}
|
|
1947
|
+
return (range.sheetId === sheetId &&
|
|
1948
|
+
rowIndex >= range.startRowIndex &&
|
|
1949
|
+
rowIndex <= range.endRowIndex &&
|
|
1950
|
+
columnIndex >= range.startColumnIndex &&
|
|
1951
|
+
columnIndex <= range.endColumnIndex);
|
|
1952
|
+
});
|
|
1953
|
+
if (isCircular) {
|
|
1954
|
+
return undefined;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
const isPreview = true;
|
|
1958
|
+
return await getCalculator().calculate(value.slice(1), position, isArray, isPreview, disablePreview);
|
|
1959
|
+
}
|
|
1960
|
+
catch (err) {
|
|
1961
|
+
// Formula errors (#NAME?, #REF!, …) are values, not
|
|
1962
|
+
// exceptions — the recalc loop stores them as cell values,
|
|
1963
|
+
// and fire-and-forget preview callers (charts, status bar,
|
|
1964
|
+
// filter-by-condition) have no rejection handler, so a throw
|
|
1965
|
+
// here escapes as an unhandled promise rejection.
|
|
1966
|
+
if (err instanceof FormulaError) {
|
|
1967
|
+
return err;
|
|
1968
|
+
}
|
|
1969
|
+
throw err;
|
|
1970
|
+
}
|
|
1971
|
+
finally {
|
|
1972
|
+
overridesRef.current = previousOverrides ?? null;
|
|
1973
|
+
}
|
|
1974
|
+
}, []);
|
|
1975
|
+
// Get all nodes from calculator
|
|
1976
|
+
const getGraphNodes = useCallback(() => {
|
|
1977
|
+
return getCalculator().graph.nodes;
|
|
1978
|
+
}, []);
|
|
1979
|
+
// Get sheet-bound nodes from the per-sheet bucket. Cheaper than
|
|
1980
|
+
// `getGraphNodes()` for callers that only care about a single sheet —
|
|
1981
|
+
// structural ops use this for the formula-cell sweep so cost scales with
|
|
1982
|
+
// `nodes_in_sheet` rather than `nodes_in_workbook`.
|
|
1983
|
+
const getGraphNodesInSheet = useCallback((sheetId) => {
|
|
1984
|
+
return getCalculator().graph.getNodesInSheet(sheetId);
|
|
1985
|
+
}, []);
|
|
1986
|
+
// Add a static reference
|
|
1987
|
+
const addStaticReference = useCallback((source, sourcePosition) => {
|
|
1988
|
+
return getCalculator().addStaticReference(source, sourcePosition);
|
|
1989
|
+
}, []);
|
|
1990
|
+
const addFormulaToGraph = useCallbackRef(useCallback((formulaValue, position) => {
|
|
1991
|
+
if (!formulaValue) {
|
|
1992
|
+
return;
|
|
1993
|
+
}
|
|
1994
|
+
getCalculator().addFormulaToGraph(formulaValue, position);
|
|
1995
|
+
}, []));
|
|
1996
|
+
// Remove static reference
|
|
1997
|
+
const removeStaticReference = useCallback((source) => {
|
|
1998
|
+
return getCalculator().removeStaticReference(source);
|
|
1999
|
+
}, []);
|
|
2000
|
+
// Reset calculator
|
|
2001
|
+
const onResetCalculator = useCallbackRef(useCallback(() => {
|
|
2002
|
+
isFullRecalcRef.current = true;
|
|
2003
|
+
// Reset graph
|
|
2004
|
+
getCalculator().graph.reset();
|
|
2005
|
+
getCalculator().arrayRangeMap.clear();
|
|
2006
|
+
getCalculator().arrayRangeMap.clear();
|
|
2007
|
+
}, []));
|
|
2008
|
+
/**
|
|
2009
|
+
* Get dependency graph
|
|
2010
|
+
*/
|
|
2011
|
+
const getDependencyGraph = useCallbackRef(useCallback(() => {
|
|
2012
|
+
return getCalculator().graph.toJSON();
|
|
2013
|
+
}, []));
|
|
2014
|
+
// Update dependency graph
|
|
2015
|
+
const updateDependencyGraph = useCallbackRef(useCallback((nodes) => {
|
|
2016
|
+
// Reset graph
|
|
2017
|
+
getCalculator().graph.reset();
|
|
2018
|
+
// Update graph
|
|
2019
|
+
getCalculator().graph.fromJSON(JSON.parse(nodes));
|
|
2020
|
+
}, []));
|
|
2021
|
+
const noopCalculationApi = useMemo(() => ({
|
|
2022
|
+
enqueueCalculation: () => { },
|
|
2023
|
+
enqueueGraphOperation: () => { },
|
|
2024
|
+
getPrecedents: () => [],
|
|
2025
|
+
getPrecedentsFromFormulaString: () => [],
|
|
2026
|
+
getDependents: () => [],
|
|
2027
|
+
enqueueStructureChange: () => { },
|
|
2028
|
+
clearRangeCache: () => { },
|
|
2029
|
+
deleteSheetReferences: () => { },
|
|
2030
|
+
onRequestCalculate: async () => undefined,
|
|
2031
|
+
getGraphNodes: () => new Map(),
|
|
2032
|
+
getGraphNodesInSheet: () => undefined,
|
|
2033
|
+
addStaticReference: () => { },
|
|
2034
|
+
addFormulaToGraph: () => { },
|
|
2035
|
+
removeStaticReference: () => { },
|
|
2036
|
+
onResetCalculator: () => { },
|
|
2037
|
+
getDependencyGraph: () => "[]",
|
|
2038
|
+
updateDependencyGraph: () => { },
|
|
2039
|
+
isArrayFormula: () => false,
|
|
2040
|
+
applyNamedRanges: (_list) => { },
|
|
2041
|
+
}), []);
|
|
2042
|
+
const api = {
|
|
2043
|
+
enqueueCalculation,
|
|
2044
|
+
enqueueGraphOperation,
|
|
2045
|
+
getPrecedents,
|
|
2046
|
+
getPrecedentsFromFormulaString,
|
|
2047
|
+
getDependents,
|
|
2048
|
+
enqueueStructureChange,
|
|
2049
|
+
clearRangeCache,
|
|
2050
|
+
deleteSheetReferences,
|
|
2051
|
+
onRequestCalculate,
|
|
2052
|
+
getGraphNodes,
|
|
2053
|
+
getGraphNodesInSheet,
|
|
2054
|
+
addStaticReference,
|
|
2055
|
+
addFormulaToGraph,
|
|
2056
|
+
removeStaticReference,
|
|
2057
|
+
onResetCalculator,
|
|
2058
|
+
getDependencyGraph,
|
|
2059
|
+
updateDependencyGraph,
|
|
2060
|
+
isArrayFormula,
|
|
2061
|
+
// Phase 9 — exposed so `useCalculationInitialize` can guarantee
|
|
2062
|
+
// named ranges are registered BEFORE cell formulas are parsed
|
|
2063
|
+
// (otherwise cells using a named range would form no DAG edge
|
|
2064
|
+
// to its static node — Excel registers names workbook-wide
|
|
2065
|
+
// before any cell evaluates).
|
|
2066
|
+
applyNamedRanges,
|
|
2067
|
+
};
|
|
2068
|
+
return enabled ? api : noopCalculationApi;
|
|
2069
|
+
};
|