@rowsncolumns/spreadsheet-state 28.0.73 → 28.0.74
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/dist/cjs/api/advanced-filter.d.ts +72 -0
- package/dist/cjs/api/advanced-filter.d.ts.map +1 -0
- package/dist/cjs/api/advanced-filter.js +0 -0
- package/dist/cjs/api/goal-seek.d.ts +29 -0
- package/dist/cjs/api/goal-seek.d.ts.map +1 -0
- package/dist/cjs/api/goal-seek.js +131 -0
- package/dist/cjs/api/immer-utils.d.ts.map +1 -1
- package/dist/cjs/api/immer-utils.js +1 -0
- package/dist/cjs/api/paint-format.d.ts +41 -0
- package/dist/cjs/api/paint-format.d.ts.map +1 -0
- package/dist/cjs/api/paint-format.js +115 -0
- package/dist/cjs/api/split-text.d.ts +12 -0
- package/dist/cjs/api/split-text.d.ts.map +1 -1
- package/dist/cjs/api/split-text.js +41 -0
- package/dist/cjs/api/subtotal.d.ts +85 -0
- package/dist/cjs/api/subtotal.d.ts.map +1 -0
- package/dist/cjs/api/subtotal.js +250 -0
- package/dist/cjs/commands.d.ts +8 -0
- package/dist/cjs/commands.d.ts.map +1 -1
- package/dist/cjs/components/editors/data-validation-rule-editor.d.ts.map +1 -1
- package/dist/cjs/components/editors/data-validation-rule-editor.js +83 -16
- package/dist/cjs/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/cjs/hooks/use-calculation-worker.js +1 -0
- package/dist/cjs/hooks/use-on-advanced-filter.d.ts +21 -0
- package/dist/cjs/hooks/use-on-advanced-filter.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-advanced-filter.js +42 -0
- package/dist/cjs/hooks/use-on-goal-seek.d.ts +30 -0
- package/dist/cjs/hooks/use-on-goal-seek.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-goal-seek.js +140 -0
- package/dist/cjs/hooks/use-on-import-excel.d.ts +10 -1
- package/dist/cjs/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-import-excel.js +8 -4
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/cjs/hooks/use-on-merge-unmerge-cells.js +53 -34
- package/dist/cjs/hooks/use-on-subtotal.d.ts +26 -0
- package/dist/cjs/hooks/use-on-subtotal.d.ts.map +1 -0
- package/dist/cjs/hooks/use-on-subtotal.js +53 -0
- package/dist/cjs/hooks/use-paint-format.d.ts +19 -3
- package/dist/cjs/hooks/use-paint-format.d.ts.map +1 -1
- package/dist/cjs/hooks/use-paint-format.js +85 -31
- package/dist/cjs/hooks/use-sheet-properties.d.ts +2 -0
- package/dist/cjs/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/cjs/hooks/use-sheet-properties.js +4 -0
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts +2 -1
- package/dist/cjs/hooks/use-split-text-to-columns.d.ts.map +1 -1
- package/dist/cjs/hooks/use-split-text-to-columns.js +3 -2
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts +50 -36
- package/dist/cjs/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/cjs/hooks/use-spreadsheet-state.js +97 -18
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/interface/change-batch-stream.d.ts.map +1 -1
- package/dist/cjs/interface/change-batch-stream.js +12 -6
- package/dist/cjs/interface/change-batch.d.ts.map +1 -1
- package/dist/cjs/interface/change-batch.js +17 -9
- package/dist/cjs/interface/change-formatting.d.ts.map +1 -1
- package/dist/cjs/interface/change-formatting.js +30 -11
- package/dist/cjs/interface/split-text.d.ts +2 -1
- package/dist/cjs/interface/split-text.d.ts.map +1 -1
- package/dist/cjs/interface/split-text.js +7 -3
- package/dist/cjs/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/cjs/interface/spreadsheet-interface.js +2 -2
- package/dist/cjs/sheet-cell.d.ts.map +1 -1
- package/dist/cjs/sheet-cell.js +7 -0
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/esm/api/advanced-filter.d.ts +72 -0
- package/dist/esm/api/advanced-filter.d.ts.map +1 -0
- package/dist/esm/api/advanced-filter.js +0 -0
- package/dist/esm/api/goal-seek.d.ts +29 -0
- package/dist/esm/api/goal-seek.d.ts.map +1 -0
- package/dist/esm/api/goal-seek.js +108 -0
- package/dist/esm/api/immer-utils.d.ts.map +1 -1
- package/dist/esm/api/immer-utils.js +1 -0
- package/dist/esm/api/paint-format.d.ts +41 -0
- package/dist/esm/api/paint-format.d.ts.map +1 -0
- package/dist/esm/api/paint-format.js +77 -0
- package/dist/esm/api/split-text.d.ts +12 -0
- package/dist/esm/api/split-text.d.ts.map +1 -1
- package/dist/esm/api/split-text.js +28 -0
- package/dist/esm/api/subtotal.d.ts +85 -0
- package/dist/esm/api/subtotal.d.ts.map +1 -0
- package/dist/esm/api/subtotal.js +181 -0
- package/dist/esm/commands.d.ts +8 -0
- package/dist/esm/commands.d.ts.map +1 -1
- package/dist/esm/components/editors/data-validation-rule-editor.d.ts.map +1 -1
- package/dist/esm/components/editors/data-validation-rule-editor.js +52 -4
- package/dist/esm/hooks/use-calculation-worker.d.ts.map +1 -1
- package/dist/esm/hooks/use-calculation-worker.js +1 -0
- package/dist/esm/hooks/use-on-advanced-filter.d.ts +21 -0
- package/dist/esm/hooks/use-on-advanced-filter.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-advanced-filter.js +41 -0
- package/dist/esm/hooks/use-on-goal-seek.d.ts +30 -0
- package/dist/esm/hooks/use-on-goal-seek.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-goal-seek.js +82 -0
- package/dist/esm/hooks/use-on-import-excel.d.ts +10 -1
- package/dist/esm/hooks/use-on-import-excel.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-import-excel.js +8 -4
- package/dist/esm/hooks/use-on-merge-unmerge-cells.d.ts.map +1 -1
- package/dist/esm/hooks/use-on-merge-unmerge-cells.js +13 -13
- package/dist/esm/hooks/use-on-subtotal.d.ts +26 -0
- package/dist/esm/hooks/use-on-subtotal.d.ts.map +1 -0
- package/dist/esm/hooks/use-on-subtotal.js +48 -0
- package/dist/esm/hooks/use-paint-format.d.ts +19 -3
- package/dist/esm/hooks/use-paint-format.d.ts.map +1 -1
- package/dist/esm/hooks/use-paint-format.js +71 -29
- package/dist/esm/hooks/use-sheet-properties.d.ts +2 -0
- package/dist/esm/hooks/use-sheet-properties.d.ts.map +1 -1
- package/dist/esm/hooks/use-sheet-properties.js +4 -0
- package/dist/esm/hooks/use-split-text-to-columns.d.ts +2 -1
- package/dist/esm/hooks/use-split-text-to-columns.d.ts.map +1 -1
- package/dist/esm/hooks/use-split-text-to-columns.js +3 -2
- package/dist/esm/hooks/use-spreadsheet-state.d.ts +50 -36
- package/dist/esm/hooks/use-spreadsheet-state.d.ts.map +1 -1
- package/dist/esm/hooks/use-spreadsheet-state.js +88 -16
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -0
- package/dist/esm/interface/change-batch-stream.d.ts.map +1 -1
- package/dist/esm/interface/change-batch-stream.js +12 -6
- package/dist/esm/interface/change-batch.d.ts.map +1 -1
- package/dist/esm/interface/change-batch.js +15 -9
- package/dist/esm/interface/change-formatting.d.ts.map +1 -1
- package/dist/esm/interface/change-formatting.js +28 -11
- package/dist/esm/interface/split-text.d.ts +2 -1
- package/dist/esm/interface/split-text.d.ts.map +1 -1
- package/dist/esm/interface/split-text.js +6 -3
- package/dist/esm/interface/spreadsheet-interface.d.ts.map +1 -1
- package/dist/esm/interface/spreadsheet-interface.js +2 -2
- package/dist/esm/sheet-cell.d.ts.map +1 -1
- package/dist/esm/sheet-cell.js +7 -0
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +18 -18
package/dist/cjs/sheet-cell.js
CHANGED
|
@@ -919,6 +919,13 @@ var SheetCell = /** @class */ (function () {
|
|
|
919
919
|
this.setStringValue(formulaValue);
|
|
920
920
|
return;
|
|
921
921
|
}
|
|
922
|
+
// A lone "=" has no expression to evaluate: Excel and Sheets keep it as
|
|
923
|
+
// the text "=" rather than a formula that can only show a parse error.
|
|
924
|
+
// The Rust store (`rnc-store` set-value / paste) applies the same rule.
|
|
925
|
+
if (formulaValue.trim() === "=") {
|
|
926
|
+
this.setStringValue(formulaValue);
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
922
929
|
this.clearSharedStringIndex();
|
|
923
930
|
// Balance parenthesis
|
|
924
931
|
formulaValue = balanceFormula(formulaValue);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../../cellxfs-registry.ts","../../commands.ts","../../generated-names.ts","../../helpers.ts","../../index.ts","../../server-utils.ts","../../server.browser.ts","../../server.ts","../../shared-string-registry.ts","../../sheet-cell.ts","../../test-setup.ts","../../types.ts","../../vitest.config.ts","../../api/border.ts","../../api/conditional-format.ts","../../api/copy-paste.ts","../../api/data-validation.ts","../../api/datatype.ts","../../api/date.ts","../../api/decimals.ts","../../api/dependency.ts","../../api/fill.ts","../../api/filter-range.ts","../../api/filter.ts","../../api/format-caches.ts","../../api/formula.ts","../../api/immer-utils.ts","../../api/intl.ts","../../api/merges.ts","../../api/outline.ts","../../api/parse-html.ts","../../api/paste-special.ts","../../api/patches.ts","../../api/pivot-range.ts","../../api/range-rule-helpers.ts","../../api/range.ts","../../api/rename-sheet.ts","../../api/selection.ts","../../api/sort.ts","../../api/split-text.ts","../../api/structural-formula-update.ts","../../api/table.ts","../../api/validation.ts","../../api/xlsx-source.ts","../../atoms/delete-sheet-atom.ts","../../atoms/dialog-state.atom.ts","../../atoms/editing-data-validation-id.atom.ts","../../atoms/editing-embed.atom.ts","../../atoms/editing-table.atom.ts","../../atoms/error-state.atom.ts","../../atoms/index.ts","../../atoms/insert-image-state.atom.ts","../../atoms/named-range.atom.ts","../../atoms/resize-dimension.atom.ts","../../atoms/sheet-observer.atom.ts","../../components/index.tsx","../../components/dialogs/delete-sheet-confirmation.tsx","../../components/dialogs/error-state.tsx","../../components/editors/cell-format-editor.tsx","../../components/editors/conditional-format-editor.tsx","../../components/editors/conditional-format-rule-editor.tsx","../../components/editors/data-validation-editor.tsx","../../components/editors/data-validation-rule-editor.tsx","../../components/editors/embed-editor.tsx","../../components/editors/insert-image-editor.tsx","../../components/editors/insert-link-editor.tsx","../../components/editors/named-range-editor.tsx","../../components/editors/resize-dimension-editor.tsx","../../components/editors/sheet-filter.tsx","../../components/editors/table-editor.tsx","../../helpers/iterative-calculation.ts","../../helpers/sheet-title.ts","../../hooks/use-async-datasource.ts","../../hooks/use-calculation-initialize.ts","../../hooks/use-calculation-process-array.ts","../../hooks/use-calculation-queue.ts","../../hooks/use-calculation-worker.ts","../../hooks/use-calculation.ts","../../hooks/use-can-edit-cellrange.ts","../../hooks/use-cellxfs-registry.ts","../../hooks/use-citations.ts","../../hooks/use-comments.ts","../../hooks/use-conditional-formatting-rules.ts","../../hooks/use-data-validation-rules.ts","../../hooks/use-deferred-calculation-flush.ts","../../hooks/use-idle-scheduler.ts","../../hooks/use-indent.ts","../../hooks/use-named-range.ts","../../hooks/use-on-adjust-row-height.ts","../../hooks/use-on-autoresize.ts","../../hooks/use-on-banded-ranges.ts","../../hooks/use-on-calculation-begin.ts","../../hooks/use-on-calculation-success.ts","../../hooks/use-on-change-batch-stream.ts","../../hooks/use-on-change-batch.ts","../../hooks/use-on-change-calculated-column.ts","../../hooks/use-on-change-decimals.ts","../../hooks/use-on-change-formatting.ts","../../hooks/use-on-change-sheet-tabcolor.ts","../../hooks/use-on-change-table-column.ts","../../hooks/use-on-change-theme.ts","../../hooks/use-on-change.ts","../../hooks/use-on-clear-formatting.ts","../../hooks/use-on-collapse-column-group.ts","../../hooks/use-on-collapse-row-group.ts","../../hooks/use-on-copy.ts","../../hooks/use-on-create-named-range.ts","../../hooks/use-on-create-sheet.ts","../../hooks/use-on-delete-cells-shift-left.ts","../../hooks/use-on-delete-cells-shift-up.ts","../../hooks/use-on-delete-column.ts","../../hooks/use-on-delete-named-range.ts","../../hooks/use-on-delete-row.ts","../../hooks/use-on-delete-sheet.ts","../../hooks/use-on-delete-table-row.ts","../../hooks/use-on-delete.ts","../../hooks/use-on-drag-n-drop.ts","../../hooks/use-on-duplicate-sheet.ts","../../hooks/use-on-embeds.ts","../../hooks/use-on-expand-column-group.ts","../../hooks/use-on-expand-row-group.ts","../../hooks/use-on-fill-range.ts","../../hooks/use-on-fill.ts","../../hooks/use-on-filter-table.ts","../../hooks/use-on-find-replace.ts","../../hooks/use-on-freeze.ts","../../hooks/use-on-group-columns.ts","../../hooks/use-on-group-rows.ts","../../hooks/use-on-hide-column.ts","../../hooks/use-on-hide-row.ts","../../hooks/use-on-hide-show-sheet.ts","../../hooks/use-on-import-csv-legacy.ts","../../hooks/use-on-import-csv.ts","../../hooks/use-on-import-excel.ts","../../hooks/use-on-insert-autosum.ts","../../hooks/use-on-insert-cells-shift-down.ts","../../hooks/use-on-insert-cells-shift-right.ts","../../hooks/use-on-insert-checkbox.ts","../../hooks/use-on-insert-column.ts","../../hooks/use-on-insert-date-time.ts","../../hooks/use-on-insert-date.ts","../../hooks/use-on-insert-image.ts","../../hooks/use-on-insert-link.ts","../../hooks/use-on-insert-note.ts","../../hooks/use-on-insert-row.ts","../../hooks/use-on-insert-table-row.ts","../../hooks/use-on-insert-time.ts","../../hooks/use-on-locale-change.ts","../../hooks/use-on-merge-unmerge-cells.ts","../../hooks/use-on-move-columns.ts","../../hooks/use-on-move-rows.ts","../../hooks/use-on-move-selection.ts","../../hooks/use-on-move-sheet.ts","../../hooks/use-on-move-table-columns.ts","../../hooks/use-on-paste.ts","../../hooks/use-on-protect-range.ts","../../hooks/use-on-protect-sheet.ts","../../hooks/use-on-remove-duplicates.ts","../../hooks/use-on-rename-sheet.ts","../../hooks/use-on-request-calculate-wrapper.ts","../../hooks/use-on-request-conditional-format.ts","../../hooks/use-on-request-data-validation.ts","../../hooks/use-on-request-define-named-range.ts","../../hooks/use-on-request-delete-sheet.ts","../../hooks/use-on-request-edit-table.ts","../../hooks/use-on-request-format-cells.ts","../../hooks/use-on-request-insert-image.ts","../../hooks/use-on-request-insert-link.ts","../../hooks/use-on-request-resize.ts","../../hooks/use-on-request-update-named-range.ts","../../hooks/use-on-resize-table.ts","../../hooks/use-on-resize.ts","../../hooks/use-on-set-outline-depth.ts","../../hooks/use-on-show-column.ts","../../hooks/use-on-show-row.ts","../../hooks/use-on-sort-column.ts","../../hooks/use-on-sort-range.ts","../../hooks/use-on-sort-table.ts","../../hooks/use-on-table.ts","../../hooks/use-on-trace-dependents-precedents.tsx","../../hooks/use-on-ungroup-columns.ts","../../hooks/use-on-ungroup-rows.ts","../../hooks/use-on-update-named-range.ts","../../hooks/use-on-update-note.ts","../../hooks/use-on-update-sheet.ts","../../hooks/use-paint-format.ts","../../hooks/use-search.ts","../../hooks/use-select-next-prev-sheet.ts","../../hooks/use-sheet-observer.ts","../../hooks/use-sheet-properties.ts","../../hooks/use-sheet-state.ts","../../hooks/use-sheetdata-subscriber.ts","../../hooks/use-slicers.ts","../../hooks/use-split-text-to-columns.ts","../../hooks/use-spreadsheet-state.ts","../../hooks/use-ss-registry.ts","../../hooks/use-structured-reference.ts","../../hooks/use-undo-redo-actions.ts","../../hooks/use-undo-redo.ts","../../hooks/utils/frozen-sort.ts","../../hooks/utils/sort-rows.ts","../../interface/apply-fill.ts","../../interface/auto-resize.ts","../../interface/calculation-interface.ts","../../interface/change-batch-stream.ts","../../interface/change-batch.ts","../../interface/change-border.ts","../../interface/change-calculated-column.ts","../../interface/change-decimals.ts","../../interface/change-formatting.ts","../../interface/change-sheet-tabcolor.ts","../../interface/change-table-column.ts","../../interface/change-theme.ts","../../interface/chart-extensions.ts","../../interface/citations.ts","../../interface/clear-formatting.ts","../../interface/conditional-formatting-rules.ts","../../interface/create-table.ts","../../interface/data-validation-rules.ts","../../interface/data-validation-utils.ts","../../interface/delete-cells-shift-left.ts","../../interface/delete-cells-shift-up.ts","../../interface/delete-cells.ts","../../interface/delete-column.ts","../../interface/delete-row.ts","../../interface/delete-sheet.ts","../../interface/delete-table-column.ts","../../interface/delete-table-row.ts","../../interface/duplicate-sheet.ts","../../interface/embeds.ts","../../interface/freeze.ts","../../interface/helpers.ts","../../interface/hide-column.ts","../../interface/hide-row.ts","../../interface/indent.ts","../../interface/insert-cells-shift-down.ts","../../interface/insert-cells-shift-right.ts","../../interface/insert-column.ts","../../interface/insert-note.ts","../../interface/insert-row.ts","../../interface/insert-table-row.ts","../../interface/interface-cli.ts","../../interface/named-range-operations.ts","../../interface/new-sheet.ts","../../interface/pivot-extensions.ts","../../interface/remove-duplicates.ts","../../interface/remove-table.ts","../../interface/resize-utils.ts","../../interface/resize.ts","../../interface/slicers.ts","../../interface/split-text.ts","../../interface/spreadsheet-interface.ts","../../interface/table-totalrow.ts","../../interface/table-utils.ts","../../interface/update-sheet.ts","../../interface/update-table.ts","../../validation-schema/table.schema.ts"],"version":"5.8.3"}
|
|
1
|
+
{"root":["../../cellxfs-registry.ts","../../commands.ts","../../generated-names.ts","../../helpers.ts","../../index.ts","../../server-utils.ts","../../server.browser.ts","../../server.ts","../../shared-string-registry.ts","../../sheet-cell.ts","../../test-setup.ts","../../types.ts","../../vitest.config.ts","../../api/advanced-filter.ts","../../api/border.ts","../../api/conditional-format.ts","../../api/copy-paste.ts","../../api/data-validation.ts","../../api/datatype.ts","../../api/date.ts","../../api/decimals.ts","../../api/dependency.ts","../../api/fill.ts","../../api/filter-range.ts","../../api/filter.ts","../../api/format-caches.ts","../../api/formula.ts","../../api/goal-seek.ts","../../api/immer-utils.ts","../../api/intl.ts","../../api/merges.ts","../../api/outline.ts","../../api/paint-format.ts","../../api/parse-html.ts","../../api/paste-special.ts","../../api/patches.ts","../../api/pivot-range.ts","../../api/range-rule-helpers.ts","../../api/range.ts","../../api/rename-sheet.ts","../../api/selection.ts","../../api/sort.ts","../../api/split-text.ts","../../api/structural-formula-update.ts","../../api/subtotal.ts","../../api/table.ts","../../api/validation.ts","../../api/xlsx-source.ts","../../atoms/delete-sheet-atom.ts","../../atoms/dialog-state.atom.ts","../../atoms/editing-data-validation-id.atom.ts","../../atoms/editing-embed.atom.ts","../../atoms/editing-table.atom.ts","../../atoms/error-state.atom.ts","../../atoms/index.ts","../../atoms/insert-image-state.atom.ts","../../atoms/named-range.atom.ts","../../atoms/resize-dimension.atom.ts","../../atoms/sheet-observer.atom.ts","../../components/index.tsx","../../components/dialogs/delete-sheet-confirmation.tsx","../../components/dialogs/error-state.tsx","../../components/editors/cell-format-editor.tsx","../../components/editors/conditional-format-editor.tsx","../../components/editors/conditional-format-rule-editor.tsx","../../components/editors/data-validation-editor.tsx","../../components/editors/data-validation-rule-editor.tsx","../../components/editors/embed-editor.tsx","../../components/editors/insert-image-editor.tsx","../../components/editors/insert-link-editor.tsx","../../components/editors/named-range-editor.tsx","../../components/editors/resize-dimension-editor.tsx","../../components/editors/sheet-filter.tsx","../../components/editors/table-editor.tsx","../../helpers/iterative-calculation.ts","../../helpers/sheet-title.ts","../../hooks/use-async-datasource.ts","../../hooks/use-calculation-initialize.ts","../../hooks/use-calculation-process-array.ts","../../hooks/use-calculation-queue.ts","../../hooks/use-calculation-worker.ts","../../hooks/use-calculation.ts","../../hooks/use-can-edit-cellrange.ts","../../hooks/use-cellxfs-registry.ts","../../hooks/use-citations.ts","../../hooks/use-comments.ts","../../hooks/use-conditional-formatting-rules.ts","../../hooks/use-data-validation-rules.ts","../../hooks/use-deferred-calculation-flush.ts","../../hooks/use-idle-scheduler.ts","../../hooks/use-indent.ts","../../hooks/use-named-range.ts","../../hooks/use-on-adjust-row-height.ts","../../hooks/use-on-advanced-filter.ts","../../hooks/use-on-autoresize.ts","../../hooks/use-on-banded-ranges.ts","../../hooks/use-on-calculation-begin.ts","../../hooks/use-on-calculation-success.ts","../../hooks/use-on-change-batch-stream.ts","../../hooks/use-on-change-batch.ts","../../hooks/use-on-change-calculated-column.ts","../../hooks/use-on-change-decimals.ts","../../hooks/use-on-change-formatting.ts","../../hooks/use-on-change-sheet-tabcolor.ts","../../hooks/use-on-change-table-column.ts","../../hooks/use-on-change-theme.ts","../../hooks/use-on-change.ts","../../hooks/use-on-clear-formatting.ts","../../hooks/use-on-collapse-column-group.ts","../../hooks/use-on-collapse-row-group.ts","../../hooks/use-on-copy.ts","../../hooks/use-on-create-named-range.ts","../../hooks/use-on-create-sheet.ts","../../hooks/use-on-delete-cells-shift-left.ts","../../hooks/use-on-delete-cells-shift-up.ts","../../hooks/use-on-delete-column.ts","../../hooks/use-on-delete-named-range.ts","../../hooks/use-on-delete-row.ts","../../hooks/use-on-delete-sheet.ts","../../hooks/use-on-delete-table-row.ts","../../hooks/use-on-delete.ts","../../hooks/use-on-drag-n-drop.ts","../../hooks/use-on-duplicate-sheet.ts","../../hooks/use-on-embeds.ts","../../hooks/use-on-expand-column-group.ts","../../hooks/use-on-expand-row-group.ts","../../hooks/use-on-fill-range.ts","../../hooks/use-on-fill.ts","../../hooks/use-on-filter-table.ts","../../hooks/use-on-find-replace.ts","../../hooks/use-on-freeze.ts","../../hooks/use-on-goal-seek.ts","../../hooks/use-on-group-columns.ts","../../hooks/use-on-group-rows.ts","../../hooks/use-on-hide-column.ts","../../hooks/use-on-hide-row.ts","../../hooks/use-on-hide-show-sheet.ts","../../hooks/use-on-import-csv-legacy.ts","../../hooks/use-on-import-csv.ts","../../hooks/use-on-import-excel.ts","../../hooks/use-on-insert-autosum.ts","../../hooks/use-on-insert-cells-shift-down.ts","../../hooks/use-on-insert-cells-shift-right.ts","../../hooks/use-on-insert-checkbox.ts","../../hooks/use-on-insert-column.ts","../../hooks/use-on-insert-date-time.ts","../../hooks/use-on-insert-date.ts","../../hooks/use-on-insert-image.ts","../../hooks/use-on-insert-link.ts","../../hooks/use-on-insert-note.ts","../../hooks/use-on-insert-row.ts","../../hooks/use-on-insert-table-row.ts","../../hooks/use-on-insert-time.ts","../../hooks/use-on-locale-change.ts","../../hooks/use-on-merge-unmerge-cells.ts","../../hooks/use-on-move-columns.ts","../../hooks/use-on-move-rows.ts","../../hooks/use-on-move-selection.ts","../../hooks/use-on-move-sheet.ts","../../hooks/use-on-move-table-columns.ts","../../hooks/use-on-paste.ts","../../hooks/use-on-protect-range.ts","../../hooks/use-on-protect-sheet.ts","../../hooks/use-on-remove-duplicates.ts","../../hooks/use-on-rename-sheet.ts","../../hooks/use-on-request-calculate-wrapper.ts","../../hooks/use-on-request-conditional-format.ts","../../hooks/use-on-request-data-validation.ts","../../hooks/use-on-request-define-named-range.ts","../../hooks/use-on-request-delete-sheet.ts","../../hooks/use-on-request-edit-table.ts","../../hooks/use-on-request-format-cells.ts","../../hooks/use-on-request-insert-image.ts","../../hooks/use-on-request-insert-link.ts","../../hooks/use-on-request-resize.ts","../../hooks/use-on-request-update-named-range.ts","../../hooks/use-on-resize-table.ts","../../hooks/use-on-resize.ts","../../hooks/use-on-set-outline-depth.ts","../../hooks/use-on-show-column.ts","../../hooks/use-on-show-row.ts","../../hooks/use-on-sort-column.ts","../../hooks/use-on-sort-range.ts","../../hooks/use-on-sort-table.ts","../../hooks/use-on-subtotal.ts","../../hooks/use-on-table.ts","../../hooks/use-on-trace-dependents-precedents.tsx","../../hooks/use-on-ungroup-columns.ts","../../hooks/use-on-ungroup-rows.ts","../../hooks/use-on-update-named-range.ts","../../hooks/use-on-update-note.ts","../../hooks/use-on-update-sheet.ts","../../hooks/use-paint-format.ts","../../hooks/use-search.ts","../../hooks/use-select-next-prev-sheet.ts","../../hooks/use-sheet-observer.ts","../../hooks/use-sheet-properties.ts","../../hooks/use-sheet-state.ts","../../hooks/use-sheetdata-subscriber.ts","../../hooks/use-slicers.ts","../../hooks/use-split-text-to-columns.ts","../../hooks/use-spreadsheet-state.ts","../../hooks/use-ss-registry.ts","../../hooks/use-structured-reference.ts","../../hooks/use-undo-redo-actions.ts","../../hooks/use-undo-redo.ts","../../hooks/utils/frozen-sort.ts","../../hooks/utils/sort-rows.ts","../../interface/apply-fill.ts","../../interface/auto-resize.ts","../../interface/calculation-interface.ts","../../interface/change-batch-stream.ts","../../interface/change-batch.ts","../../interface/change-border.ts","../../interface/change-calculated-column.ts","../../interface/change-decimals.ts","../../interface/change-formatting.ts","../../interface/change-sheet-tabcolor.ts","../../interface/change-table-column.ts","../../interface/change-theme.ts","../../interface/chart-extensions.ts","../../interface/citations.ts","../../interface/clear-formatting.ts","../../interface/conditional-formatting-rules.ts","../../interface/create-table.ts","../../interface/data-validation-rules.ts","../../interface/data-validation-utils.ts","../../interface/delete-cells-shift-left.ts","../../interface/delete-cells-shift-up.ts","../../interface/delete-cells.ts","../../interface/delete-column.ts","../../interface/delete-row.ts","../../interface/delete-sheet.ts","../../interface/delete-table-column.ts","../../interface/delete-table-row.ts","../../interface/duplicate-sheet.ts","../../interface/embeds.ts","../../interface/freeze.ts","../../interface/helpers.ts","../../interface/hide-column.ts","../../interface/hide-row.ts","../../interface/indent.ts","../../interface/insert-cells-shift-down.ts","../../interface/insert-cells-shift-right.ts","../../interface/insert-column.ts","../../interface/insert-note.ts","../../interface/insert-row.ts","../../interface/insert-table-row.ts","../../interface/interface-cli.ts","../../interface/named-range-operations.ts","../../interface/new-sheet.ts","../../interface/pivot-extensions.ts","../../interface/remove-duplicates.ts","../../interface/remove-table.ts","../../interface/resize-utils.ts","../../interface/resize.ts","../../interface/slicers.ts","../../interface/split-text.ts","../../interface/spreadsheet-interface.ts","../../interface/table-totalrow.ts","../../interface/table-utils.ts","../../interface/update-sheet.ts","../../interface/update-table.ts","../../validation-schema/table.schema.ts"],"version":"5.8.3"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/common-types";
|
|
2
|
+
import type { AdvancedFilterAction, AdvancedFilterOptions } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
/**
|
|
4
|
+
* Excel's Data → Sort & Filter → Advanced: a list range (header row + records)
|
|
5
|
+
* filtered by a CRITERIA RANGE — a header row naming list columns, then one
|
|
6
|
+
* or more criteria rows. Conditions on one criteria row AND together; the
|
|
7
|
+
* rows OR together. A criterion cell is an Excel comparison string:
|
|
8
|
+
*
|
|
9
|
+
* `>100` `<=5` `<>done` `=apple` operator + value
|
|
10
|
+
* `app` text begins with "app" (case-insensitive)
|
|
11
|
+
* `="=apple"` → `=apple` exact text match
|
|
12
|
+
* `a*e` `?at` `~*` `*` any run, `?` one char, `~` escapes
|
|
13
|
+
* blank no condition (a fully blank criteria row
|
|
14
|
+
* matches every record, as in Excel)
|
|
15
|
+
*
|
|
16
|
+
* Numbers compare numerically when both sides are numeric; text compares
|
|
17
|
+
* case-insensitively. A criteria header that matches no list header is a
|
|
18
|
+
* computed criterion in Excel — those need a formula per record and are not
|
|
19
|
+
* evaluated here (the condition is ignored; see the compatibility doc).
|
|
20
|
+
*/
|
|
21
|
+
export type { AdvancedFilterAction, AdvancedFilterOptions };
|
|
22
|
+
export type CellValueReader = (rowIndex: number, columnIndex: number) => string | number | boolean | null | undefined;
|
|
23
|
+
type Operator = "=" | "<>" | "<" | "<=" | ">" | ">=" | "begins";
|
|
24
|
+
export type Criterion = {
|
|
25
|
+
columnIndex: number;
|
|
26
|
+
operator: Operator;
|
|
27
|
+
value: string;
|
|
28
|
+
};
|
|
29
|
+
/** Excel wildcard pattern → anchored RegExp (`~` escapes `*`, `?`, `~`). */
|
|
30
|
+
export declare const wildcardToRegExp: (pattern: string, anchorEnd?: boolean) => RegExp;
|
|
31
|
+
/** Whether one record cell satisfies one criterion. */
|
|
32
|
+
export declare const matchesCriterion: (cellValue: string | number | boolean | null | undefined, criterion: Criterion) => boolean;
|
|
33
|
+
/**
|
|
34
|
+
* One OR-branch of the criteria range: the AND-ed criteria of one criteria
|
|
35
|
+
* row. An empty array is a blank criteria row — it matches every record.
|
|
36
|
+
*/
|
|
37
|
+
export type CriteriaRow = Criterion[];
|
|
38
|
+
/**
|
|
39
|
+
* Reads the criteria range against the list's header row. Criteria headers
|
|
40
|
+
* resolve to list columns case-insensitively; a header without a list match
|
|
41
|
+
* (a computed criterion) is skipped.
|
|
42
|
+
*/
|
|
43
|
+
export declare const parseCriteriaRange: (listRange: GridRange, criteriaRange: GridRange, getValue: CellValueReader) => CriteriaRow[];
|
|
44
|
+
/** A record matches when any criteria row's conditions all hold. */
|
|
45
|
+
export declare const matchesCriteria: (rowIndex: number, criteriaRows: CriteriaRow[], getValue: CellValueReader) => boolean;
|
|
46
|
+
export type AdvancedFilterPlan = {
|
|
47
|
+
/** Record rows that satisfy the criteria (absolute indexes, ascending). */
|
|
48
|
+
matchingRows: number[];
|
|
49
|
+
/** `filter`: record rows to hide (non-matching). */
|
|
50
|
+
hideRows: number[];
|
|
51
|
+
/** `filter`: record rows to show (matching — undoes an earlier in-place filter). */
|
|
52
|
+
showRows: number[];
|
|
53
|
+
/** `copy`: the header row + matching records to write at `copyTo`. */
|
|
54
|
+
copy?: {
|
|
55
|
+
range: GridRange;
|
|
56
|
+
values: (string | number | boolean | null)[][];
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Plans an Advanced Filter over the list range. Returns `undefined` when the
|
|
61
|
+
* list has no records, or `copy` was asked for without a destination.
|
|
62
|
+
*/
|
|
63
|
+
export declare const planAdvancedFilter: (options: AdvancedFilterOptions, getValue: CellValueReader) => AdvancedFilterPlan | undefined;
|
|
64
|
+
/** The state callbacks a plan is applied through — the same in both engines. */
|
|
65
|
+
export type AdvancedFilterPlanExecutor = {
|
|
66
|
+
onHideRow: (sheetId: number, rowIndexes: number[]) => void;
|
|
67
|
+
onShowRow: (sheetId: number, rowIndexes: number[]) => void;
|
|
68
|
+
onChangeBatch: (sheetId: number, range: GridRange, values: (string | number | boolean | null)[][]) => void;
|
|
69
|
+
};
|
|
70
|
+
/** Applies an {@link AdvancedFilterPlan}: show the matches, hide the rest, or write the copy. */
|
|
71
|
+
export declare const applyAdvancedFilterPlan: (sheetId: number, plan: AdvancedFilterPlan, executor: AdvancedFilterPlanExecutor) => void;
|
|
72
|
+
//# sourceMappingUR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
+
* Calculation options → "Maximum Iterations" / "Maximum Change"). The
|
|
6
|
+
* search is a secant method — Excel's own is a secant/Newton hybrid — with
|
|
7
|
+
* bisection whenever a sign change has been bracketed and the secant step
|
|
8
|
+
* would leave the bracket, so a monotone target converges in a handful of
|
|
9
|
+
* evaluations while a badly scaled one still narrows a bracket.
|
|
10
|
+
*
|
|
11
|
+
* `evaluate(trial)` returns the set cell's value with the changing cell at
|
|
12
|
+
* `trial`; `undefined` means the trial produced an error (`#DIV/0!`, text…),
|
|
13
|
+
* which the solver treats as "step somewhere else".
|
|
14
|
+
*/
|
|
15
|
+
import type { GoalSeekResult, GoalSeekStatus } from "@rowsncolumns/spreadsheet";
|
|
16
|
+
export declare const GOAL_SEEK_MAX_ITERATIONS = 100;
|
|
17
|
+
export declare const GOAL_SEEK_TOLERANCE = 0.001;
|
|
18
|
+
export type GoalSeekEvaluate = (trial: number) => Promise<number | undefined>;
|
|
19
|
+
export type { GoalSeekResult, GoalSeekStatus };
|
|
20
|
+
export type GoalSeekOptions = {
|
|
21
|
+
evaluate: GoalSeekEvaluate;
|
|
22
|
+
targetValue: number;
|
|
23
|
+
/** Starting trial — the changing cell's current value (0 when blank). */
|
|
24
|
+
initialValue?: number;
|
|
25
|
+
maxIterations?: number;
|
|
26
|
+
tolerance?: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const goalSeek: ({ evaluate, targetValue, initialValue, maxIterations, tolerance, }: GoalSeekOptions) => Promise<GoalSeekResult>;
|
|
29
|
+
//# sourceMappingURL=goal-seek.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"goal-seek.d.ts","sourceRoot":"","sources":["../../../api/goal-seek.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAEhF,eAAO,MAAM,wBAAwB,MAAM,CAAC;AAC5C,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9E,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAKF,eAAO,MAAM,QAAQ,GAAU,oEAM5B,eAAe,KAAG,OAAO,CAAC,cAAc,CAqG1C,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export const GOAL_SEEK_MAX_ITERATIONS = 100;
|
|
2
|
+
export const GOAL_SEEK_TOLERANCE = 0.001;
|
|
3
|
+
const isUsable = (value) => typeof value === "number" && Number.isFinite(value);
|
|
4
|
+
export const goalSeek = async ({ evaluate, targetValue, initialValue = 0, maxIterations = GOAL_SEEK_MAX_ITERATIONS, tolerance = GOAL_SEEK_TOLERANCE, }) => {
|
|
5
|
+
let iterations = 0;
|
|
6
|
+
let best = {
|
|
7
|
+
value: initialValue,
|
|
8
|
+
currentValue: undefined,
|
|
9
|
+
residual: Number.POSITIVE_INFINITY,
|
|
10
|
+
};
|
|
11
|
+
// Residual f(x) = set(x) − target; records the best trial as a side effect.
|
|
12
|
+
const residualAt = async (trial) => {
|
|
13
|
+
iterations++;
|
|
14
|
+
const current = await evaluate(trial);
|
|
15
|
+
if (!isUsable(current))
|
|
16
|
+
return undefined;
|
|
17
|
+
const residual = current - targetValue;
|
|
18
|
+
if (Math.abs(residual) < best.residual) {
|
|
19
|
+
best = { value: trial, currentValue: current, residual: Math.abs(residual) };
|
|
20
|
+
}
|
|
21
|
+
return residual;
|
|
22
|
+
};
|
|
23
|
+
const finish = (status) => ({
|
|
24
|
+
status,
|
|
25
|
+
value: best.value,
|
|
26
|
+
currentValue: best.currentValue,
|
|
27
|
+
targetValue,
|
|
28
|
+
iterations,
|
|
29
|
+
});
|
|
30
|
+
// Bracket of a sign change, once seen: bisection fallback + secant clamp.
|
|
31
|
+
let negative;
|
|
32
|
+
let positive;
|
|
33
|
+
const bracket = (x, f) => {
|
|
34
|
+
if (f < 0)
|
|
35
|
+
negative = x;
|
|
36
|
+
else
|
|
37
|
+
positive = x;
|
|
38
|
+
};
|
|
39
|
+
let x0 = initialValue;
|
|
40
|
+
let f0 = await residualAt(x0);
|
|
41
|
+
// The current value may itself be an error (=1/A1 with A1 blank): nudge off it.
|
|
42
|
+
let nudges = 0;
|
|
43
|
+
while (f0 === undefined && iterations < maxIterations && nudges < 8) {
|
|
44
|
+
x0 = x0 === 0 ? 1 : x0 * 2;
|
|
45
|
+
f0 = await residualAt(x0);
|
|
46
|
+
nudges++;
|
|
47
|
+
}
|
|
48
|
+
if (f0 === undefined)
|
|
49
|
+
return finish("not-found");
|
|
50
|
+
if (Math.abs(f0) <= tolerance)
|
|
51
|
+
return finish("found");
|
|
52
|
+
bracket(x0, f0);
|
|
53
|
+
// Excel perturbs the starting value by ~1% to get a first slope.
|
|
54
|
+
let x1 = x0 === 0 ? 0.01 : x0 * 1.01;
|
|
55
|
+
let shrinks = 0;
|
|
56
|
+
let backoffs = 0;
|
|
57
|
+
while (iterations < maxIterations) {
|
|
58
|
+
const f1 = await residualAt(x1);
|
|
59
|
+
if (f1 === undefined) {
|
|
60
|
+
// Errored trial: pull it halfway back toward the last good point.
|
|
61
|
+
if (++shrinks > 16)
|
|
62
|
+
return finish("not-found");
|
|
63
|
+
x1 = x0 + (x1 - x0) / 2;
|
|
64
|
+
continue;
|
|
65
|
+
}
|
|
66
|
+
shrinks = 0;
|
|
67
|
+
if (Math.abs(f1) <= tolerance)
|
|
68
|
+
return finish("found");
|
|
69
|
+
bracket(x1, f1);
|
|
70
|
+
// A secant step that made things worse with no sign change in sight is
|
|
71
|
+
// heading away from the root (a flat or curving function such as =1/A1):
|
|
72
|
+
// back off — half the step, in the opposite direction — instead of
|
|
73
|
+
// following it to infinity. The bracketed case below never needs this.
|
|
74
|
+
if ((negative === undefined || positive === undefined) &&
|
|
75
|
+
Math.abs(f1) > Math.abs(f0)) {
|
|
76
|
+
if (++backoffs > 24)
|
|
77
|
+
return finish("not-found");
|
|
78
|
+
x1 = x0 - (x1 - x0) / 2;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
backoffs = 0;
|
|
82
|
+
let x2;
|
|
83
|
+
const slope = f1 - f0;
|
|
84
|
+
if (slope === 0 || !Number.isFinite(slope)) {
|
|
85
|
+
// Flat: widen the step in the same direction to find any change.
|
|
86
|
+
x2 = x1 + (x1 - x0 || 0.01) * 2;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
x2 = x1 - (f1 * (x1 - x0)) / slope;
|
|
90
|
+
}
|
|
91
|
+
if (negative !== undefined && positive !== undefined) {
|
|
92
|
+
const lo = Math.min(negative, positive);
|
|
93
|
+
const hi = Math.max(negative, positive);
|
|
94
|
+
if (!Number.isFinite(x2) || x2 <= lo || x2 >= hi) {
|
|
95
|
+
x2 = (lo + hi) / 2;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
else if (!Number.isFinite(x2)) {
|
|
99
|
+
return finish("not-found");
|
|
100
|
+
}
|
|
101
|
+
if (x2 === x1)
|
|
102
|
+
return finish(Math.abs(f1) <= tolerance ? "found" : "not-found");
|
|
103
|
+
x0 = x1;
|
|
104
|
+
f0 = f1;
|
|
105
|
+
x1 = x2;
|
|
106
|
+
}
|
|
107
|
+
return finish("not-found");
|
|
108
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"immer-utils.d.ts","sourceRoot":"","sources":["../../../api/immer-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,gBAAgB,IAAI,2BAA2B,EA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ChC,OAAO,kBAAkB,CAC1B,CAAC,uBAAuB,CAAC,YAc3B,CAAC;AAGF,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,QAAQ,EAC3C,OAAO,WAAW,GAAG,SAAS,EAC9B,SAAS,MAAM,EACf,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACzC,kBAAkB,eAAe,EACjC,wBAAwB,UAAU,CAChC,OAAO,kBAAkB,CAC1B,CAAC,uBAAuB,CAAC,YAc3B,CAAC;AAkFF;;;;GAIG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,UAAU,gBAAgB,CAAC,CAAC,CAAC;;;;;;;;;CAY5D,CAAC;AAEF,eAAO,MAAM,wBAAwB,GAAI,CAAC,SAAS,QAAQ,EACzD,SAAS,MAAM,GAAG,SAAc,EAChC,YAAY,CAAC,QAAQ,GAAG,aAAa,GAAG,UAAU,CAAC,EAAE,EACrD,OAAO,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,EACzC,SAAS,MAAM,EACf,QAAQ,MAAM,GAAG,SAAS,EAC1B,kBAAkB,eAAe,gCA2ClC,CAAC"}
|
|
@@ -67,6 +67,7 @@ const formatDerivationRules = {
|
|
|
67
67
|
UNIQUE: { type: "fixed_index", index: 0 },
|
|
68
68
|
TAKE: { type: "fixed_index", index: 0 },
|
|
69
69
|
DROP: { type: "fixed_index", index: 0 },
|
|
70
|
+
TRIMRANGE: { type: "fixed_index", index: 0 },
|
|
70
71
|
EXPAND: { type: "fixed_index", index: 0 },
|
|
71
72
|
TOCOL: { type: "fixed_index", index: 0 },
|
|
72
73
|
TOROW: { type: "fixed_index", index: 0 },
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CellFormat, GridRange } from "@rowsncolumns/common-types";
|
|
2
|
+
/**
|
|
3
|
+
* Format-painter pattern shared by both engines: the captured 2-D format grid plus the
|
|
4
|
+
* source block's merge configuration, re-based to the block's top-left so it can be tiled
|
|
5
|
+
* onto any target (Google Sheets copies merges with the format; Excel's painter does too).
|
|
6
|
+
*/
|
|
7
|
+
export type PaintPattern = {
|
|
8
|
+
formats: (CellFormat | null | undefined)[][];
|
|
9
|
+
/** Merges fully inside the source block, as 0-based offsets from its top-left. */
|
|
10
|
+
merges: GridRange[];
|
|
11
|
+
/** Source block size — the tiling period. */
|
|
12
|
+
rows: number;
|
|
13
|
+
cols: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* The merges the painter carries from a source block: every merge that lies FULLY inside
|
|
17
|
+
* `source`, re-based to 0-based offsets from the block's top-left. A merge reaching outside the
|
|
18
|
+
* block is not part of its pattern (Sheets/Excel behave the same — the painter copies the look of
|
|
19
|
+
* the selected cells, not of the cells around them).
|
|
20
|
+
*/
|
|
21
|
+
export declare const collectPaintMerges: (merges: GridRange[] | null | undefined, source: GridRange) => GridRange[];
|
|
22
|
+
/**
|
|
23
|
+
* Tile a pattern's relative merges across `target` with the pattern's period (`rows` × `cols`),
|
|
24
|
+
* the same way the format grid itself is tiled by the formatting applier. A merge that a partial
|
|
25
|
+
* trailing tile would push past the target's edge is dropped — the painter never creates a merge
|
|
26
|
+
* that the user did not drag over.
|
|
27
|
+
*/
|
|
28
|
+
export declare const tilePaintMerges: (relativeMerges: GridRange[], rows: number, cols: number, target: GridRange) => GridRange[];
|
|
29
|
+
/**
|
|
30
|
+
* The banded (table stripe / alternating-colour) format the grid paints under a cell, looked up
|
|
31
|
+
* in the map `getBandedCells` builds for a sheet.
|
|
32
|
+
*/
|
|
33
|
+
export declare const getBandedCellFormat: (bandedCells: Map<string, CellFormat> | undefined | null, rowIndex: number, columnIndex: number) => CellFormat | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Layer a cell's explicit format over the banded format the grid would paint beneath it, so the
|
|
36
|
+
* captured pattern carries the VISIBLE look (Sheets copies the alternating colours as static cell
|
|
37
|
+
* fills — it does not create a table or banding at the target). Explicit keys win; an explicit
|
|
38
|
+
* `undefined` never clobbers a banded value.
|
|
39
|
+
*/
|
|
40
|
+
export declare const layerBandedFormat: (explicit: CellFormat | null | undefined, banded: CellFormat | undefined) => CellFormat | null | undefined;
|
|
41
|
+
//# sourceMappingURL=paint-format.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paint-format.d.ts","sourceRoot":"","sources":["../../../api/paint-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGxE;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,CAAC,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EAAE,CAAC;IAC7C,kFAAkF;IAClF,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAQF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,SAAS,EAAE,GAAG,IAAI,GAAG,SAAS,EACtC,QAAQ,SAAS,KAChB,SAAS,EAaX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAC1B,gBAAgB,SAAS,EAAE,EAC3B,MAAM,MAAM,EACZ,MAAM,MAAM,EACZ,QAAQ,SAAS,KAChB,SAAS,EAqBX,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAC9B,aAAa,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,SAAS,GAAG,IAAI,EACvD,UAAU,MAAM,EAChB,aAAa,MAAM,KAClB,UAAU,GAAG,SACyC,CAAC;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAC5B,UAAU,UAAU,GAAG,IAAI,GAAG,SAAS,EACvC,QAAQ,UAAU,GAAG,SAAS,KAC7B,UAAU,GAAG,IAAI,GAAG,SAWtB,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { cellIdentifier } from "@rowsncolumns/grid";
|
|
2
|
+
const rangeContains = (outer, inner) => inner.startRowIndex >= outer.startRowIndex &&
|
|
3
|
+
inner.endRowIndex <= outer.endRowIndex &&
|
|
4
|
+
inner.startColumnIndex >= outer.startColumnIndex &&
|
|
5
|
+
inner.endColumnIndex <= outer.endColumnIndex;
|
|
6
|
+
/**
|
|
7
|
+
* The merges the painter carries from a source block: every merge that lies FULLY inside
|
|
8
|
+
* `source`, re-based to 0-based offsets from the block's top-left. A merge reaching outside the
|
|
9
|
+
* block is not part of its pattern (Sheets/Excel behave the same — the painter copies the look of
|
|
10
|
+
* the selected cells, not of the cells around them).
|
|
11
|
+
*/
|
|
12
|
+
export const collectPaintMerges = (merges, source) => {
|
|
13
|
+
if (!merges?.length)
|
|
14
|
+
return [];
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const merge of merges) {
|
|
17
|
+
if (!rangeContains(source, merge))
|
|
18
|
+
continue;
|
|
19
|
+
out.push({
|
|
20
|
+
startRowIndex: merge.startRowIndex - source.startRowIndex,
|
|
21
|
+
endRowIndex: merge.endRowIndex - source.startRowIndex,
|
|
22
|
+
startColumnIndex: merge.startColumnIndex - source.startColumnIndex,
|
|
23
|
+
endColumnIndex: merge.endColumnIndex - source.startColumnIndex,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Tile a pattern's relative merges across `target` with the pattern's period (`rows` × `cols`),
|
|
30
|
+
* the same way the format grid itself is tiled by the formatting applier. A merge that a partial
|
|
31
|
+
* trailing tile would push past the target's edge is dropped — the painter never creates a merge
|
|
32
|
+
* that the user did not drag over.
|
|
33
|
+
*/
|
|
34
|
+
export const tilePaintMerges = (relativeMerges, rows, cols, target) => {
|
|
35
|
+
if (!relativeMerges.length || rows <= 0 || cols <= 0)
|
|
36
|
+
return [];
|
|
37
|
+
const out = [];
|
|
38
|
+
for (let top = target.startRowIndex; top <= target.endRowIndex; top += rows) {
|
|
39
|
+
for (let left = target.startColumnIndex; left <= target.endColumnIndex; left += cols) {
|
|
40
|
+
for (const merge of relativeMerges) {
|
|
41
|
+
const placed = {
|
|
42
|
+
startRowIndex: top + merge.startRowIndex,
|
|
43
|
+
endRowIndex: top + merge.endRowIndex,
|
|
44
|
+
startColumnIndex: left + merge.startColumnIndex,
|
|
45
|
+
endColumnIndex: left + merge.endColumnIndex,
|
|
46
|
+
};
|
|
47
|
+
if (rangeContains(target, placed))
|
|
48
|
+
out.push(placed);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return out;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The banded (table stripe / alternating-colour) format the grid paints under a cell, looked up
|
|
56
|
+
* in the map `getBandedCells` builds for a sheet.
|
|
57
|
+
*/
|
|
58
|
+
export const getBandedCellFormat = (bandedCells, rowIndex, columnIndex) => bandedCells?.get(cellIdentifier(rowIndex, columnIndex));
|
|
59
|
+
/**
|
|
60
|
+
* Layer a cell's explicit format over the banded format the grid would paint beneath it, so the
|
|
61
|
+
* captured pattern carries the VISIBLE look (Sheets copies the alternating colours as static cell
|
|
62
|
+
* fills — it does not create a table or banding at the target). Explicit keys win; an explicit
|
|
63
|
+
* `undefined` never clobbers a banded value.
|
|
64
|
+
*/
|
|
65
|
+
export const layerBandedFormat = (explicit, banded) => {
|
|
66
|
+
if (!banded)
|
|
67
|
+
return explicit;
|
|
68
|
+
const merged = { ...banded };
|
|
69
|
+
if (explicit) {
|
|
70
|
+
for (const [key, value] of Object.entries(explicit)) {
|
|
71
|
+
if (value !== undefined) {
|
|
72
|
+
merged[key] = value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return merged;
|
|
77
|
+
};
|
|
@@ -1,2 +1,14 @@
|
|
|
1
|
+
import type { SplitTextOptions } from "@rowsncolumns/spreadsheet";
|
|
1
2
|
export declare const splitTextToColumns: (values: (string | null | undefined)[], delimiter?: string) => string[][];
|
|
3
|
+
export type { SplitTextOptions };
|
|
4
|
+
/** Normalized, ascending, de-duplicated positive break positions. */
|
|
5
|
+
export declare const normalizeColumnBreaks: (columnBreaks: number[]) => number[];
|
|
6
|
+
/**
|
|
7
|
+
* Excel's Text to Columns → Fixed width: cut each cell at the given
|
|
8
|
+
* character positions. Fields are trimmed like the delimited path (Excel's
|
|
9
|
+
* General column data format drops the padding spaces fixed-width data is
|
|
10
|
+
* aligned with). Cells without breaks inside their text still split — the
|
|
11
|
+
* trailing fields are empty — so the resulting block is rectangular.
|
|
12
|
+
*/
|
|
13
|
+
export declare const splitTextFixedWidth: (values: (string | null | undefined)[], columnBreaks: number[]) => string[][];
|
|
2
14
|
//# sourceMappingURL=split-text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"split-text.d.ts","sourceRoot":"","sources":["../../../api/split-text.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"split-text.d.ts","sourceRoot":"","sources":["../../../api/split-text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAIlE,eAAO,MAAM,kBAAkB,GAC7B,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACrC,YAAW,MAAY,KACtB,MAAM,EAAE,EAwBV,CAAC;AAEF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,qEAAqE;AACrE,eAAO,MAAM,qBAAqB,GAAI,cAAc,MAAM,EAAE,KAAG,MAAM,EAG3C,CAAC;AAE3B;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,EACrC,cAAc,MAAM,EAAE,KACrB,MAAM,EAAE,EAgBV,CAAC"}
|
|
@@ -22,3 +22,31 @@ export const splitTextToColumns = (values, delimiter = ",") => {
|
|
|
22
22
|
return trimmedParts;
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
|
+
/** Normalized, ascending, de-duplicated positive break positions. */
|
|
26
|
+
export const normalizeColumnBreaks = (columnBreaks) => [...new Set(columnBreaks)]
|
|
27
|
+
.filter((position) => Number.isInteger(position) && position > 0)
|
|
28
|
+
.sort((a, b) => a - b);
|
|
29
|
+
/**
|
|
30
|
+
* Excel's Text to Columns → Fixed width: cut each cell at the given
|
|
31
|
+
* character positions. Fields are trimmed like the delimited path (Excel's
|
|
32
|
+
* General column data format drops the padding spaces fixed-width data is
|
|
33
|
+
* aligned with). Cells without breaks inside their text still split — the
|
|
34
|
+
* trailing fields are empty — so the resulting block is rectangular.
|
|
35
|
+
*/
|
|
36
|
+
export const splitTextFixedWidth = (values, columnBreaks) => {
|
|
37
|
+
const breaks = normalizeColumnBreaks(columnBreaks);
|
|
38
|
+
return values.map((cell) => {
|
|
39
|
+
if (isNil(cell)) {
|
|
40
|
+
return [""];
|
|
41
|
+
}
|
|
42
|
+
const text = String(cell);
|
|
43
|
+
const parts = [];
|
|
44
|
+
let start = 0;
|
|
45
|
+
for (const position of breaks) {
|
|
46
|
+
parts.push(text.slice(start, position).trim());
|
|
47
|
+
start = position;
|
|
48
|
+
}
|
|
49
|
+
parts.push(text.slice(start).trim());
|
|
50
|
+
return parts;
|
|
51
|
+
});
|
|
52
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/common-types";
|
|
2
|
+
import { SUBTOTAL_FUNCTIONS, type SubtotalFunction, type SubtotalOptions } from "@rowsncolumns/spreadsheet";
|
|
3
|
+
export { SUBTOTAL_FUNCTIONS };
|
|
4
|
+
export type { SubtotalFunction, SubtotalOptions };
|
|
5
|
+
/**
|
|
6
|
+
* The `SUBTOTAL(function_num, …)` code each "Use function" entry writes.
|
|
7
|
+
* Codes 1–11 (not 101–111): the subtotal rows Excel inserts count manually
|
|
8
|
+
* hidden rows.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SUBTOTAL_FUNCTION_NUMBERS: Record<SubtotalFunction, number>;
|
|
11
|
+
/** Excel's total-row labels: "<group> Total" per group, "Grand Total" at the bottom. */
|
|
12
|
+
export declare const SUBTOTAL_GRAND_TOTAL_LABEL = "Grand Total";
|
|
13
|
+
export declare const subtotalGroupLabel: (groupValue: string) => string;
|
|
14
|
+
/**
|
|
15
|
+
* Reads a cell of the data range. `getValue` should return the DISPLAYED text
|
|
16
|
+
* when the host has one (Excel groups and labels on what the cells show —
|
|
17
|
+
* `1/1/2024 Total`, not `45292 Total`). `getFormula` returns the `=…` text for
|
|
18
|
+
* a formula cell. `getOutlineLevel` returns a row's current outline level so
|
|
19
|
+
* "Replace current subtotals" can rebuild the outline from level 0.
|
|
20
|
+
*/
|
|
21
|
+
export type SubtotalReader = {
|
|
22
|
+
getValue: (rowIndex: number, columnIndex: number) => string | number | boolean | null | undefined;
|
|
23
|
+
getFormula: (rowIndex: number, columnIndex: number) => string | undefined;
|
|
24
|
+
getOutlineLevel?: (rowIndex: number) => number | undefined;
|
|
25
|
+
};
|
|
26
|
+
/** One `change-batch` write: a single row segment at final coordinates. */
|
|
27
|
+
export type SubtotalWrite = {
|
|
28
|
+
rowIndex: number;
|
|
29
|
+
startColumnIndex: number;
|
|
30
|
+
values: (string | null)[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* The plan applies in this order, every index already in FINAL coordinates
|
|
34
|
+
* (the sheet after all removals and insertions):
|
|
35
|
+
* 1. `deleteRows` (descending original indexes — existing subtotal rows),
|
|
36
|
+
* 2. `insertRows` ascending: inserting at final row `r` shifts the not-yet
|
|
37
|
+
* final rows below it, so ascending order lands each new row exactly
|
|
38
|
+
* where the plan expects it,
|
|
39
|
+
* 3. `writes` (labels + SUBTOTAL formulas),
|
|
40
|
+
* 4. `ungroupRows`: one `ungroup-rows` call per entry — the outline reset of
|
|
41
|
+
* "Replace current subtotals". Group / ungroup are ±1 steps in both
|
|
42
|
+
* engines, so pass `k` lists the surviving data rows that were deeper
|
|
43
|
+
* than level `k`; after the passes every row of the range is back at
|
|
44
|
+
* level 0 (empty when nothing was outlined or when not replacing), then
|
|
45
|
+
* 5. `outlineGroups`: one `group-rows` call per entry (Excel's levels — the
|
|
46
|
+
* first spans every row above the grand total, the second the detail
|
|
47
|
+
* rows of each group, so detail rows end at level 2 and subtotal rows
|
|
48
|
+
* at level 1 — the same three-level outline on every re-apply).
|
|
49
|
+
*/
|
|
50
|
+
export type SubtotalPlan = {
|
|
51
|
+
deleteRows: number[];
|
|
52
|
+
insertRows: number[];
|
|
53
|
+
writes: SubtotalWrite[];
|
|
54
|
+
ungroupRows: number[][];
|
|
55
|
+
outlineGroups: number[][];
|
|
56
|
+
/** Number of groups found. */
|
|
57
|
+
groupCount: number;
|
|
58
|
+
/** The range after the plan is applied (header row included when present). */
|
|
59
|
+
resultRange: GridRange;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Plans Excel's Subtotal command over `options.range`. Consecutive rows with
|
|
63
|
+
* the same group-column value form a group (Excel does not sort — it expects
|
|
64
|
+
* the data sorted and totals each run of equal values). Each group gets a
|
|
65
|
+
* total row right below it holding "<value> Total" in the group column and
|
|
66
|
+
* `=SUBTOTAL(n, first:last)` over the group's data rows in every aggregate
|
|
67
|
+
* column; a grand-total row closes the range with `SUBTOTAL` over the whole
|
|
68
|
+
* data block (SUBTOTAL ignores the nested subtotal rows, like Excel). With
|
|
69
|
+
* `replaceCurrent` the range's existing outline is cleared too, so a re-apply
|
|
70
|
+
* yields Excel's fresh detail 2 / subtotal 1 / grand total 0 levels instead
|
|
71
|
+
* of nesting deeper; without it the new levels stack on the old ones (Excel's
|
|
72
|
+
* nested subtotals). Returns `undefined` when the range has no data rows.
|
|
73
|
+
*/
|
|
74
|
+
export declare const planSubtotals: (options: SubtotalOptions, reader: SubtotalReader) => SubtotalPlan | undefined;
|
|
75
|
+
/** The state callbacks a plan is applied through — the same in both engines. */
|
|
76
|
+
export type SubtotalPlanExecutor = {
|
|
77
|
+
onDeleteRow: (sheetId: number, rowIndexes: number[]) => void;
|
|
78
|
+
onInsertRow: (sheetId: number, referenceRowIndex: number, numRows?: number) => void;
|
|
79
|
+
onChangeBatch: (sheetId: number, range: GridRange, values: (string | null)[][]) => void;
|
|
80
|
+
onGroupRows: (sheetId: number, rowIndexes: number[]) => void;
|
|
81
|
+
onUngroupRows: (sheetId: number, rowIndexes: number[]) => void;
|
|
82
|
+
};
|
|
83
|
+
/** Applies a {@link SubtotalPlan} in its documented order. */
|
|
84
|
+
export declare const applySubtotalPlan: (sheetId: number, plan: SubtotalPlan, executor: SubtotalPlanExecutor) => void;
|
|
85
|
+
//# sourceMappingURL=subtotal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subtotal.d.ts","sourceRoot":"","sources":["../../../api/subtotal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EACL,kBAAkB,EAClB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,2BAA2B,CAAC;AAGnC,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAYtE,CAAC;AAEF,wFAAwF;AACxF,eAAO,MAAM,0BAA0B,gBAAgB,CAAC;AACxD,eAAO,MAAM,kBAAkB,GAAI,YAAY,MAAM,WACP,CAAC;AAE/C;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS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