@rowsncolumns/spreadsheet 10.6.4 → 10.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/api/autocomplete.d.ts +42 -0
- package/dist/cjs/api/autocomplete.d.ts.map +1 -0
- package/dist/cjs/api/autocomplete.js +114 -0
- package/dist/cjs/api/banded-ranges.d.ts.map +1 -1
- package/dist/cjs/api/banded-ranges.js +51 -1
- package/dist/cjs/api/error-checking.d.ts +82 -0
- package/dist/cjs/api/error-checking.d.ts.map +1 -0
- package/dist/cjs/api/error-checking.js +207 -0
- package/dist/cjs/api/move-overwrite.d.ts +8 -2
- package/dist/cjs/api/move-overwrite.d.ts.map +1 -1
- package/dist/cjs/api/move-overwrite.js +19 -3
- package/dist/cjs/api/selections.d.ts +2 -2
- package/dist/cjs/api/validation.d.ts +39 -1
- package/dist/cjs/api/validation.d.ts.map +1 -1
- package/dist/cjs/api/validation.js +87 -1
- package/dist/cjs/atoms/cell-input-context.atom.d.ts +4 -1
- package/dist/cjs/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/enter-key-direction.atom.d.ts +11 -0
- package/dist/cjs/atoms/enter-key-direction.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/enter-key-direction.atom.js +13 -0
- package/dist/cjs/atoms/index.d.ts +1 -0
- package/dist/cjs/atoms/index.d.ts.map +1 -1
- package/dist/cjs/atoms/index.js +1 -0
- package/dist/cjs/atoms/paste-menu.atom.d.ts +22 -0
- package/dist/cjs/atoms/paste-menu.atom.d.ts.map +1 -1
- package/dist/cjs/atoms/paste-menu.atom.js +13 -1
- package/dist/cjs/atoms/pick-list.atom.d.ts +15 -0
- package/dist/cjs/atoms/pick-list.atom.d.ts.map +1 -0
- package/dist/cjs/atoms/pick-list.atom.js +7 -0
- package/dist/cjs/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/cjs/components/canvas-grid/index.js +305 -70
- package/dist/cjs/components/canvas-grid/typings.d.ts +96 -11
- package/dist/cjs/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/cjs/components/cell/alignment.d.ts +25 -0
- package/dist/cjs/components/cell/alignment.d.ts.map +1 -1
- package/dist/cjs/components/cell/alignment.js +39 -1
- package/dist/cjs/components/cell/cell-background.d.ts +16 -0
- package/dist/cjs/components/cell/cell-background.d.ts.map +1 -1
- package/dist/cjs/components/cell/cell-background.js +141 -54
- package/dist/cjs/components/cell/cell-text-runs.d.ts +12 -5
- package/dist/cjs/components/cell/cell-text-runs.d.ts.map +1 -1
- package/dist/cjs/components/cell/cell-text-runs.js +18 -20
- package/dist/cjs/components/cell/index.d.ts.map +1 -1
- package/dist/cjs/components/cell/index.js +26 -21
- package/dist/cjs/components/cell/typings.d.ts +9 -0
- package/dist/cjs/components/cell/typings.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/helpers.d.ts +22 -2
- package/dist/cjs/components/cell-editor/helpers.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/helpers.js +32 -8
- package/dist/cjs/components/cell-editor/index.d.ts +7 -1
- package/dist/cjs/components/cell-editor/index.d.ts.map +1 -1
- package/dist/cjs/components/cell-editor/index.js +85 -13
- package/dist/cjs/components/cell-indicator/index.d.ts +41 -0
- package/dist/cjs/components/cell-indicator/index.d.ts.map +1 -0
- package/dist/cjs/components/cell-indicator/index.js +90 -0
- package/dist/cjs/components/cell-input/cell-input.d.ts +10 -2
- package/dist/cjs/components/cell-input/cell-input.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/cell-input.js +5 -3
- package/dist/cjs/components/cell-input/formula-bar-cell-input.d.ts.map +1 -1
- package/dist/cjs/components/cell-input/formula-bar-cell-input.js +9 -2
- package/dist/cjs/components/cell-structured/sparkline-math.d.ts +27 -1
- package/dist/cjs/components/cell-structured/sparkline-math.d.ts.map +1 -1
- package/dist/cjs/components/cell-structured/sparkline-math.js +48 -1
- package/dist/cjs/components/cell-structured/sparkline.d.ts +1 -1
- package/dist/cjs/components/cell-structured/sparkline.d.ts.map +1 -1
- package/dist/cjs/components/cell-structured/sparkline.js +36 -92
- package/dist/cjs/components/cell-structured/types.d.ts +6 -0
- package/dist/cjs/components/cell-structured/types.d.ts.map +1 -1
- package/dist/cjs/components/data-table-dialog/index.d.ts +22 -0
- package/dist/cjs/components/data-table-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/data-table-dialog/index.js +93 -0
- package/dist/cjs/components/error-check-smart-tag/index.d.ts +27 -0
- package/dist/cjs/components/error-check-smart-tag/index.d.ts.map +1 -0
- package/dist/cjs/components/error-check-smart-tag/index.js +39 -0
- package/dist/cjs/components/forecast-sheet-dialog/index.d.ts +26 -0
- package/dist/cjs/components/forecast-sheet-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/forecast-sheet-dialog/index.js +92 -0
- package/dist/cjs/components/paste-special-dialog/index.d.ts +3 -3
- package/dist/cjs/components/paste-special-dialog/index.d.ts.map +1 -1
- package/dist/cjs/components/paste-special-dialog/index.js +61 -23
- package/dist/cjs/components/protect-sheet-dialog/allow-edit-ranges-dialog.d.ts +57 -0
- package/dist/cjs/components/protect-sheet-dialog/allow-edit-ranges-dialog.d.ts.map +1 -0
- package/dist/cjs/components/protect-sheet-dialog/allow-edit-ranges-dialog.js +196 -0
- package/dist/cjs/components/protect-sheet-dialog/constants.d.ts +3 -0
- package/dist/cjs/components/protect-sheet-dialog/constants.d.ts.map +1 -0
- package/dist/cjs/components/protect-sheet-dialog/constants.js +5 -0
- package/dist/cjs/components/protect-sheet-dialog/index.d.ts +2 -2
- package/dist/cjs/components/protect-sheet-dialog/index.d.ts.map +1 -1
- package/dist/cjs/components/protect-sheet-dialog/index.js +5 -3
- package/dist/cjs/components/scenario-manager-dialog/index.d.ts +51 -0
- package/dist/cjs/components/scenario-manager-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/scenario-manager-dialog/index.js +257 -0
- package/dist/cjs/components/selection/index.d.ts +1 -1
- package/dist/cjs/components/selection/index.d.ts.map +1 -1
- package/dist/cjs/components/selection/index.js +9 -4
- package/dist/cjs/components/selection/paste-menu.d.ts +14 -1
- package/dist/cjs/components/selection/paste-menu.d.ts.map +1 -1
- package/dist/cjs/components/selection/paste-menu.js +78 -6
- package/dist/cjs/components/selection/paste-options.d.ts +28 -0
- package/dist/cjs/components/selection/paste-options.d.ts.map +1 -0
- package/dist/cjs/components/selection/paste-options.js +70 -0
- package/dist/cjs/components/selection/types.d.ts +12 -1
- package/dist/cjs/components/selection/types.d.ts.map +1 -1
- package/dist/cjs/components/selection-drop-menu/index.d.ts +18 -0
- package/dist/cjs/components/selection-drop-menu/index.d.ts.map +1 -0
- package/dist/cjs/components/selection-drop-menu/index.js +62 -0
- package/dist/cjs/components/solver-dialog/index.d.ts +57 -0
- package/dist/cjs/components/solver-dialog/index.d.ts.map +1 -0
- package/dist/cjs/components/solver-dialog/index.js +204 -0
- package/dist/cjs/components/toolbar/sparkline-actions.d.ts +3 -2
- package/dist/cjs/components/toolbar/sparkline-actions.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/sparkline-actions.js +6 -2
- package/dist/cjs/components/toolbar/table-style-selector.d.ts.map +1 -1
- package/dist/cjs/components/toolbar/table-style-selector.js +33 -2
- package/dist/cjs/config.d.ts +5 -4
- package/dist/cjs/config.d.ts.map +1 -1
- package/dist/cjs/config.js +13 -9
- package/dist/cjs/helpers.d.ts +5 -0
- package/dist/cjs/helpers.d.ts.map +1 -1
- package/dist/cjs/helpers.js +8 -4
- package/dist/cjs/hooks/use-cell-renderer.d.ts +12 -1
- package/dist/cjs/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-cell-renderer.js +6 -3
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts +36 -2
- package/dist/cjs/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/cjs/hooks/use-copy-paste-cut.js +131 -5
- package/dist/cjs/hooks/use-editable.d.ts +6 -0
- package/dist/cjs/hooks/use-editable.d.ts.map +1 -1
- package/dist/cjs/hooks/use-editor-submit.d.ts +45 -3
- package/dist/cjs/hooks/use-editor-submit.d.ts.map +1 -1
- package/dist/cjs/hooks/use-editor-submit.js +91 -7
- package/dist/cjs/hooks/use-keyboard-handler.d.ts +5 -1
- package/dist/cjs/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/cjs/hooks/use-keyboard-handler.js +10 -1
- package/dist/cjs/hooks/use-selection-drag-copy.d.ts +55 -0
- package/dist/cjs/hooks/use-selection-drag-copy.d.ts.map +1 -0
- package/dist/cjs/hooks/use-selection-drag-copy.js +274 -0
- package/dist/cjs/hooks/use-selection-renderer.d.ts +8 -1
- package/dist/cjs/hooks/use-selection-renderer.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection-renderer.js +7 -2
- package/dist/cjs/hooks/use-selection.d.ts +59 -1
- package/dist/cjs/hooks/use-selection.d.ts.map +1 -1
- package/dist/cjs/hooks/use-selection.js +270 -61
- package/dist/cjs/index.d.ts +6 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/release-date.js +1 -1
- package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/cjs/types.d.ts +50 -1
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/api/autocomplete.d.ts +42 -0
- package/dist/esm/api/autocomplete.d.ts.map +1 -0
- package/dist/esm/api/autocomplete.js +91 -0
- package/dist/esm/api/banded-ranges.d.ts.map +1 -1
- package/dist/esm/api/banded-ranges.js +52 -2
- package/dist/esm/api/error-checking.d.ts +82 -0
- package/dist/esm/api/error-checking.d.ts.map +1 -0
- package/dist/esm/api/error-checking.js +156 -0
- package/dist/esm/api/move-overwrite.d.ts +8 -2
- package/dist/esm/api/move-overwrite.d.ts.map +1 -1
- package/dist/esm/api/move-overwrite.js +17 -2
- package/dist/esm/api/selections.d.ts +2 -2
- package/dist/esm/api/validation.d.ts +39 -1
- package/dist/esm/api/validation.d.ts.map +1 -1
- package/dist/esm/api/validation.js +70 -0
- package/dist/esm/atoms/cell-input-context.atom.d.ts +4 -1
- package/dist/esm/atoms/cell-input-context.atom.d.ts.map +1 -1
- package/dist/esm/atoms/enter-key-direction.atom.d.ts +11 -0
- package/dist/esm/atoms/enter-key-direction.atom.d.ts.map +1 -0
- package/dist/esm/atoms/enter-key-direction.atom.js +8 -0
- package/dist/esm/atoms/index.d.ts +1 -0
- package/dist/esm/atoms/index.d.ts.map +1 -1
- package/dist/esm/atoms/index.js +1 -0
- package/dist/esm/atoms/paste-menu.atom.d.ts +22 -0
- package/dist/esm/atoms/paste-menu.atom.d.ts.map +1 -1
- package/dist/esm/atoms/paste-menu.atom.js +10 -1
- package/dist/esm/atoms/pick-list.atom.d.ts +15 -0
- package/dist/esm/atoms/pick-list.atom.d.ts.map +1 -0
- package/dist/esm/atoms/pick-list.atom.js +3 -0
- package/dist/esm/components/canvas-grid/index.d.ts.map +1 -1
- package/dist/esm/components/canvas-grid/index.js +239 -13
- package/dist/esm/components/canvas-grid/typings.d.ts +96 -11
- package/dist/esm/components/canvas-grid/typings.d.ts.map +1 -1
- package/dist/esm/components/cell/alignment.d.ts +25 -0
- package/dist/esm/components/cell/alignment.d.ts.map +1 -1
- package/dist/esm/components/cell/alignment.js +33 -0
- package/dist/esm/components/cell/cell-background.d.ts +16 -0
- package/dist/esm/components/cell/cell-background.d.ts.map +1 -1
- package/dist/esm/components/cell/cell-background.js +106 -36
- package/dist/esm/components/cell/cell-text-runs.d.ts +12 -5
- package/dist/esm/components/cell/cell-text-runs.d.ts.map +1 -1
- package/dist/esm/components/cell/cell-text-runs.js +17 -22
- package/dist/esm/components/cell/index.d.ts.map +1 -1
- package/dist/esm/components/cell/index.js +25 -20
- package/dist/esm/components/cell/typings.d.ts +9 -0
- package/dist/esm/components/cell/typings.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/helpers.d.ts +22 -2
- package/dist/esm/components/cell-editor/helpers.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/helpers.js +25 -7
- package/dist/esm/components/cell-editor/index.d.ts +7 -1
- package/dist/esm/components/cell-editor/index.d.ts.map +1 -1
- package/dist/esm/components/cell-editor/index.js +80 -9
- package/dist/esm/components/cell-indicator/index.d.ts +41 -0
- package/dist/esm/components/cell-indicator/index.d.ts.map +1 -0
- package/dist/esm/components/cell-indicator/index.js +76 -0
- package/dist/esm/components/cell-input/cell-input.d.ts +10 -2
- package/dist/esm/components/cell-input/cell-input.d.ts.map +1 -1
- package/dist/esm/components/cell-input/cell-input.js +5 -3
- package/dist/esm/components/cell-input/formula-bar-cell-input.d.ts.map +1 -1
- package/dist/esm/components/cell-input/formula-bar-cell-input.js +9 -2
- package/dist/esm/components/cell-structured/sparkline-math.d.ts +27 -1
- package/dist/esm/components/cell-structured/sparkline-math.d.ts.map +1 -1
- package/dist/esm/components/cell-structured/sparkline-math.js +35 -0
- package/dist/esm/components/cell-structured/sparkline.d.ts +1 -1
- package/dist/esm/components/cell-structured/sparkline.d.ts.map +1 -1
- package/dist/esm/components/cell-structured/sparkline.js +34 -88
- package/dist/esm/components/cell-structured/types.d.ts +6 -0
- package/dist/esm/components/cell-structured/types.d.ts.map +1 -1
- package/dist/esm/components/data-table-dialog/index.d.ts +22 -0
- package/dist/esm/components/data-table-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/data-table-dialog/index.js +75 -0
- package/dist/esm/components/error-check-smart-tag/index.d.ts +27 -0
- package/dist/esm/components/error-check-smart-tag/index.d.ts.map +1 -0
- package/dist/esm/components/error-check-smart-tag/index.js +33 -0
- package/dist/esm/components/forecast-sheet-dialog/index.d.ts +26 -0
- package/dist/esm/components/forecast-sheet-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/forecast-sheet-dialog/index.js +83 -0
- package/dist/esm/components/paste-special-dialog/index.d.ts +3 -3
- package/dist/esm/components/paste-special-dialog/index.d.ts.map +1 -1
- package/dist/esm/components/paste-special-dialog/index.js +58 -23
- package/dist/esm/components/protect-sheet-dialog/allow-edit-ranges-dialog.d.ts +57 -0
- package/dist/esm/components/protect-sheet-dialog/allow-edit-ranges-dialog.d.ts.map +1 -0
- package/dist/esm/components/protect-sheet-dialog/allow-edit-ranges-dialog.js +177 -0
- package/dist/esm/components/protect-sheet-dialog/constants.d.ts +3 -0
- package/dist/esm/components/protect-sheet-dialog/constants.d.ts.map +1 -0
- package/dist/esm/components/protect-sheet-dialog/constants.js +2 -0
- package/dist/esm/components/protect-sheet-dialog/index.d.ts +2 -2
- package/dist/esm/components/protect-sheet-dialog/index.d.ts.map +1 -1
- package/dist/esm/components/protect-sheet-dialog/index.js +3 -2
- package/dist/esm/components/scenario-manager-dialog/index.d.ts +51 -0
- package/dist/esm/components/scenario-manager-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/scenario-manager-dialog/index.js +213 -0
- package/dist/esm/components/selection/index.d.ts +1 -1
- package/dist/esm/components/selection/index.d.ts.map +1 -1
- package/dist/esm/components/selection/index.js +9 -4
- package/dist/esm/components/selection/paste-menu.d.ts +14 -1
- package/dist/esm/components/selection/paste-menu.d.ts.map +1 -1
- package/dist/esm/components/selection/paste-menu.js +76 -8
- package/dist/esm/components/selection/paste-options.d.ts +28 -0
- package/dist/esm/components/selection/paste-options.d.ts.map +1 -0
- package/dist/esm/components/selection/paste-options.js +62 -0
- package/dist/esm/components/selection/types.d.ts +12 -1
- package/dist/esm/components/selection/types.d.ts.map +1 -1
- package/dist/esm/components/selection-drop-menu/index.d.ts +18 -0
- package/dist/esm/components/selection-drop-menu/index.d.ts.map +1 -0
- package/dist/esm/components/selection-drop-menu/index.js +56 -0
- package/dist/esm/components/solver-dialog/index.d.ts +57 -0
- package/dist/esm/components/solver-dialog/index.d.ts.map +1 -0
- package/dist/esm/components/solver-dialog/index.js +176 -0
- package/dist/esm/components/toolbar/sparkline-actions.d.ts +3 -2
- package/dist/esm/components/toolbar/sparkline-actions.d.ts.map +1 -1
- package/dist/esm/components/toolbar/sparkline-actions.js +6 -2
- package/dist/esm/components/toolbar/table-style-selector.d.ts.map +1 -1
- package/dist/esm/components/toolbar/table-style-selector.js +29 -3
- package/dist/esm/config.d.ts +5 -4
- package/dist/esm/config.d.ts.map +1 -1
- package/dist/esm/config.js +12 -8
- package/dist/esm/helpers.d.ts +5 -0
- package/dist/esm/helpers.d.ts.map +1 -1
- package/dist/esm/helpers.js +8 -4
- package/dist/esm/hooks/use-cell-renderer.d.ts +12 -1
- package/dist/esm/hooks/use-cell-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-cell-renderer.js +5 -2
- package/dist/esm/hooks/use-copy-paste-cut.d.ts +36 -2
- package/dist/esm/hooks/use-copy-paste-cut.d.ts.map +1 -1
- package/dist/esm/hooks/use-copy-paste-cut.js +117 -6
- package/dist/esm/hooks/use-editable.d.ts +6 -0
- package/dist/esm/hooks/use-editable.d.ts.map +1 -1
- package/dist/esm/hooks/use-editor-submit.d.ts +45 -3
- package/dist/esm/hooks/use-editor-submit.d.ts.map +1 -1
- package/dist/esm/hooks/use-editor-submit.js +81 -6
- package/dist/esm/hooks/use-keyboard-handler.d.ts +5 -1
- package/dist/esm/hooks/use-keyboard-handler.d.ts.map +1 -1
- package/dist/esm/hooks/use-keyboard-handler.js +10 -1
- package/dist/esm/hooks/use-selection-drag-copy.d.ts +55 -0
- package/dist/esm/hooks/use-selection-drag-copy.d.ts.map +1 -0
- package/dist/esm/hooks/use-selection-drag-copy.js +245 -0
- package/dist/esm/hooks/use-selection-renderer.d.ts +8 -1
- package/dist/esm/hooks/use-selection-renderer.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection-renderer.js +7 -2
- package/dist/esm/hooks/use-selection.d.ts +59 -1
- package/dist/esm/hooks/use-selection.d.ts.map +1 -1
- package/dist/esm/hooks/use-selection.js +245 -52
- package/dist/esm/index.d.ts +6 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -0
- package/dist/esm/release-date.js +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/types.d.ts +50 -1
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/spreadsheet.min.css +1 -1
- package/package.json +6 -5
- package/dist/cjs/components/cell-error/index.d.ts +0 -14
- package/dist/cjs/components/cell-error/index.d.ts.map +0 -1
- package/dist/cjs/components/cell-error/index.js +0 -24
- package/dist/esm/components/cell-error/index.d.ts +0 -14
- package/dist/esm/components/cell-error/index.d.ts.map +0 -1
- package/dist/esm/components/cell-error/index.js +0 -18
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { GridRange } from "@rowsncolumns/common-types";
|
|
2
|
+
import type { ErrorValue, ExtendedValue, IgnoredError } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* The Excel background error-checking rules the grid flags with the green ◤ indicator. The names
|
|
5
|
+
* are the OOXML `<ignoredError>` attribute names, so an ignored error round-trips through xlsx.
|
|
6
|
+
*
|
|
7
|
+
* - `evalError` — "Cells containing formulas that result in an error".
|
|
8
|
+
* - `numberStoredAsText` — "Numbers formatted as text or preceded by an apostrophe".
|
|
9
|
+
*/
|
|
10
|
+
export type ErrorCheckKind = "evalError" | "numberStoredAsText";
|
|
11
|
+
/**
|
|
12
|
+
* The number a "number stored as text" holds, or `undefined` when the text is not one. This is
|
|
13
|
+
* the value Excel's Convert to Number writes back.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parseNumberStoredAsText: (text: string | null | undefined) => number | undefined;
|
|
16
|
+
export type ErrorCheckInput = {
|
|
17
|
+
/** What the user typed (`uev`): a formula, a number, a string, … */
|
|
18
|
+
userEnteredValue: ExtendedValue | null | undefined;
|
|
19
|
+
/** The cell's error, if its effective value is one. */
|
|
20
|
+
errorValue: ErrorValue | null | undefined;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Which error-checking rule (if any) flags this cell, before ignored errors are applied.
|
|
24
|
+
* A typed error constant (`#N/A` entered as a value) is not flagged — only a formula's result.
|
|
25
|
+
* A data-validation failure is not an error-checking rule (Excel only circles it on request).
|
|
26
|
+
*/
|
|
27
|
+
export declare const getErrorCheckKind: ({ userEnteredValue, errorValue, }: ErrorCheckInput) => ErrorCheckKind | undefined;
|
|
28
|
+
/** What the error-checking smart tag's menu can do. */
|
|
29
|
+
export type ErrorCheckOption = "convertToNumber" | "help" | "ignore" | "editInFormulaBar" | "options";
|
|
30
|
+
/** The menu's heading, as Excel words it. */
|
|
31
|
+
export declare const getErrorCheckTitle: (kind: ErrorCheckKind, errorName?: string) => string;
|
|
32
|
+
/** Excel's own help pages: hiding error values and error indicators, and the rule options. */
|
|
33
|
+
export declare const ERROR_CHECKING_HELP_URL = "https://support.microsoft.com/en-us/office/hide-error-values-and-error-indicators-in-cells-d171b96e-8fb4-4863-a1ba-b64557474439";
|
|
34
|
+
/** "Help on this Error": Excel's article for the error, else the error-indicators article. */
|
|
35
|
+
export declare const getErrorHelpUrl: (kind: ErrorCheckKind, errorName?: string) => string;
|
|
36
|
+
/** Has the user ignored this rule for this cell ("Ignore Error", or the file's `<ignoredErrors>`)? */
|
|
37
|
+
export declare const isErrorIgnored: (ignoredErrors: ReadonlyArray<IgnoredError> | null | undefined, rowIndex: number, columnIndex: number, kind: ErrorCheckKind) => boolean;
|
|
38
|
+
/** The sheet's ignored-errors list after "Ignore Error" on `ranges` (one new entry, as Excel writes). */
|
|
39
|
+
export declare const appendIgnoredError: (ignoredErrors: ReadonlyArray<IgnoredError> | null | undefined, ranges: GridRange[], kind: ErrorCheckKind) => IgnoredError[];
|
|
40
|
+
/** One row's run of adjacent cells Convert to Number rewrites, with their numbers. */
|
|
41
|
+
export type NumberRun = {
|
|
42
|
+
rowIndex: number;
|
|
43
|
+
startColumnIndex: number;
|
|
44
|
+
values: number[];
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The numbers stored as text inside `ranges`, as runs of adjacent cells per row — so Convert to
|
|
48
|
+
* Number writes each run in one call and never touches the cells between them. Rows / columns are
|
|
49
|
+
* clipped to `maxRow` / `maxColumn` (the sheet's data extent) so a whole-column selection scans
|
|
50
|
+
* only the used rows.
|
|
51
|
+
*/
|
|
52
|
+
export declare const collectNumberStoredAsTextRuns: (ranges: GridRange[], getUserEnteredValue: (rowIndex: number, columnIndex: number) => ExtendedValue | null | undefined, maxRow: number, maxColumn: number) => NumberRun[];
|
|
53
|
+
export type ErrorCheckActionContext = {
|
|
54
|
+
sheetId: number;
|
|
55
|
+
kind: ErrorCheckKind;
|
|
56
|
+
errorName?: string;
|
|
57
|
+
/** The selection's ranges (the active cell's when nothing else is selected). */
|
|
58
|
+
ranges: GridRange[];
|
|
59
|
+
getUserEnteredValue(rowIndex: number, columnIndex: number): ExtendedValue | null | undefined;
|
|
60
|
+
/** The sheet's data extent: Convert to Number scans no further. */
|
|
61
|
+
maxRow: number;
|
|
62
|
+
maxColumn: number;
|
|
63
|
+
getIgnoredErrors?(sheetId: number): IgnoredError[] | null | undefined;
|
|
64
|
+
onChangeBatch?(sheetId: number, range: GridRange, values: number[][]): void;
|
|
65
|
+
/** Records every write `action` makes as one undo step. */
|
|
66
|
+
batchHistory?<R>(action: () => R): R;
|
|
67
|
+
onUpdateSheet?(sheetId: number, sheet: {
|
|
68
|
+
ignoredErrors: IgnoredError[];
|
|
69
|
+
}): void;
|
|
70
|
+
/** Start editing the active cell in the formula bar (or in the cell when there is no bar). */
|
|
71
|
+
editInFormulaBar(): void;
|
|
72
|
+
openUrl(url: string): void;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Run one of the error-checking smart tag's menu items. Convert to Number and Ignore Error act on
|
|
76
|
+
* every selected cell, as Excel does: Convert to Number rewrites each number stored as text as its
|
|
77
|
+
* number — one `onChangeBatch` per run of adjacent cells, all inside one `batchHistory`, so it is a
|
|
78
|
+
* single undo step and syncs as ordinary value writes; Ignore Error appends the selection to the
|
|
79
|
+
* sheet's `ignoredErrors` (persisted, xlsx `<ignoredErrors>`).
|
|
80
|
+
*/
|
|
81
|
+
export declare const runErrorCheckOption: (option: ErrorCheckOption, context: ErrorCheckActionContext) => void;
|
|
82
|
+
//# sourceMappingURL=error-checking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-checking.d.ts","sourceRoot":"","sources":["../../../api/error-checking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,oBAAoB,CAAC;AAShE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,GAClC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,KAC9B,MAAM,GAAG,SAQX,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,gBAAgB,EAAE,aAAa,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,uDAAuD;IACvD,UAAU,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,mCAG/B,eAAe,KAAG,cAAc,GAAG,SAQrC,CAAC;AAEF,uDAAuD;AACvD,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,MAAM,GACN,QAAQ,GACR,kBAAkB,GAClB,SAAS,CAAC;AAcd,6CAA6C;AAC7C,eAAO,MAAM,kBAAkB,GAAI,MAAM,cAAc,EAAE,YAAY,MAAM,WAGT,CAAC;AAEnE,8FAA8F;AAC9F,eAAO,MAAM,uBAAuB,oIAC+F,CAAC;AAapI,8FAA8F;AAC9F,eAAO,MAAM,eAAe,GAAI,MAAM,cAAc,EAAE,YAAY,MAAM,WAE/C,CAAC;AAQ1B,sGAAsG;AACtG,eAAO,MAAM,cAAc,GACzB,eAAe,aAAa,CAAC,YAAY,CAAC,GAAG,IAAI,GAAG,SAAS,EAC7D,UAAU,MAAM,EAChB,aAAa,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AAM,CAAC,GAAG,CAAC,CAAC;IACrC,aAAa,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;QAAE,aAAa,EAAE,YAAY,EAAE,CAAA;KAAE,GAAG,IAAI,CAAC;IAChF,8FAA8F;IAC9F,gBAAgB,IAAI,IAAI,CAAC;IACzB,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,QAAQ,gBAAgB,EACxB,SAAS,uBAAuB,SAiDjC,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text that Excel's "Number Stored as Text" rule flags: an optionally signed number, with optional
|
|
3
|
+
* thousands separators, decimals, exponent or a trailing percent sign — and nothing else.
|
|
4
|
+
*/
|
|
5
|
+
const NUMBER_STORED_AS_TEXT = /^[+-]?(?:\d{1,3}(?:,\d{3})+|\d+)?(?:\.\d+)?(?:[eE][+-]?\d+)?%?$/;
|
|
6
|
+
/**
|
|
7
|
+
* The number a "number stored as text" holds, or `undefined` when the text is not one. This is
|
|
8
|
+
* the value Excel's Convert to Number writes back.
|
|
9
|
+
*/
|
|
10
|
+
export const parseNumberStoredAsText = (text) => {
|
|
11
|
+
if (typeof text !== "string" || !/\d/.test(text))
|
|
12
|
+
return undefined;
|
|
13
|
+
if (!NUMBER_STORED_AS_TEXT.test(text))
|
|
14
|
+
return undefined;
|
|
15
|
+
const isPercent = text.endsWith("%");
|
|
16
|
+
const body = (isPercent ? text.slice(0, -1) : text).replace(/,/g, "");
|
|
17
|
+
const value = Number(body);
|
|
18
|
+
if (!Number.isFinite(value))
|
|
19
|
+
return undefined;
|
|
20
|
+
return isPercent ? value / 100 : value;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Which error-checking rule (if any) flags this cell, before ignored errors are applied.
|
|
24
|
+
* A typed error constant (`#N/A` entered as a value) is not flagged — only a formula's result.
|
|
25
|
+
* A data-validation failure is not an error-checking rule (Excel only circles it on request).
|
|
26
|
+
*/
|
|
27
|
+
export const getErrorCheckKind = ({ userEnteredValue, errorValue, }) => {
|
|
28
|
+
const formula = userEnteredValue?.fv ?? userEnteredValue?.formulaValue;
|
|
29
|
+
if (formula) {
|
|
30
|
+
return errorValue?.type === "Error" ? "evalError" : undefined;
|
|
31
|
+
}
|
|
32
|
+
const text = userEnteredValue?.sv ?? userEnteredValue?.stringValue;
|
|
33
|
+
if (parseNumberStoredAsText(text) !== undefined)
|
|
34
|
+
return "numberStoredAsText";
|
|
35
|
+
return undefined;
|
|
36
|
+
};
|
|
37
|
+
const ERROR_TITLES = {
|
|
38
|
+
"#VALUE!": "Error in Value",
|
|
39
|
+
"#DIV/0!": "Divide by Zero Error",
|
|
40
|
+
"#N/A": "Value Not Available Error",
|
|
41
|
+
"#NAME?": "Invalid Name Error",
|
|
42
|
+
"#NULL!": "Null Error",
|
|
43
|
+
"#NUM!": "Invalid Number Error",
|
|
44
|
+
"#REF!": "Invalid Cell Reference Error",
|
|
45
|
+
"#SPILL!": "Spill Range Isn't Blank",
|
|
46
|
+
"#CALC!": "Calculation Error",
|
|
47
|
+
};
|
|
48
|
+
/** The menu's heading, as Excel words it. */
|
|
49
|
+
export const getErrorCheckTitle = (kind, errorName) => kind === "numberStoredAsText"
|
|
50
|
+
? "Number Stored as Text"
|
|
51
|
+
: (errorName && ERROR_TITLES[errorName]) || "Error in Formula";
|
|
52
|
+
/** Excel's own help pages: hiding error values and error indicators, and the rule options. */
|
|
53
|
+
export const ERROR_CHECKING_HELP_URL = "https://support.microsoft.com/en-us/office/hide-error-values-and-error-indicators-in-cells-d171b96e-8fb4-4863-a1ba-b64557474439";
|
|
54
|
+
const ERROR_HELP_URLS = {
|
|
55
|
+
"#VALUE!": "https://support.microsoft.com/en-us/office/how-to-correct-a-value-error-15e1b616-fbf2-4147-9c0b-0a11a20e409e",
|
|
56
|
+
"#NAME?": "https://support.microsoft.com/en-us/office/how-to-correct-a-name-error-b6d54e31-a743-4d7d-9b61-40002a7b4286",
|
|
57
|
+
"#NUM!": "https://support.microsoft.com/en-us/office/how-to-correct-a-num-error-f5193bfc-4400-43f4-88c4-8e1dcca0428b",
|
|
58
|
+
"#SPILL!": "https://support.microsoft.com/en-us/office/how-to-correct-a-spill-error-ffe0f555-b479-4a17-a6e2-ef9cc9ad4023",
|
|
59
|
+
};
|
|
60
|
+
/** "Help on this Error": Excel's article for the error, else the error-indicators article. */
|
|
61
|
+
export const getErrorHelpUrl = (kind, errorName) => (kind === "evalError" && errorName && ERROR_HELP_URLS[errorName]) ||
|
|
62
|
+
ERROR_CHECKING_HELP_URL;
|
|
63
|
+
const inRange = (range, rowIndex, columnIndex) => rowIndex >= range.startRowIndex &&
|
|
64
|
+
rowIndex <= range.endRowIndex &&
|
|
65
|
+
columnIndex >= range.startColumnIndex &&
|
|
66
|
+
columnIndex <= range.endColumnIndex;
|
|
67
|
+
/** Has the user ignored this rule for this cell ("Ignore Error", or the file's `<ignoredErrors>`)? */
|
|
68
|
+
export const isErrorIgnored = (ignoredErrors, rowIndex, columnIndex, kind) => !!ignoredErrors?.some((entry) => entry[kind] === true &&
|
|
69
|
+
entry.ranges.some((range) => inRange(range, rowIndex, columnIndex)));
|
|
70
|
+
/** The sheet's ignored-errors list after "Ignore Error" on `ranges` (one new entry, as Excel writes). */
|
|
71
|
+
export const appendIgnoredError = (ignoredErrors, ranges, kind) => [
|
|
72
|
+
...(ignoredErrors ?? []),
|
|
73
|
+
{ ranges: ranges.map((range) => ({ ...range })), [kind]: true },
|
|
74
|
+
];
|
|
75
|
+
/**
|
|
76
|
+
* The numbers stored as text inside `ranges`, as runs of adjacent cells per row — so Convert to
|
|
77
|
+
* Number writes each run in one call and never touches the cells between them. Rows / columns are
|
|
78
|
+
* clipped to `maxRow` / `maxColumn` (the sheet's data extent) so a whole-column selection scans
|
|
79
|
+
* only the used rows.
|
|
80
|
+
*/
|
|
81
|
+
export const collectNumberStoredAsTextRuns = (ranges, getUserEnteredValue, maxRow, maxColumn) => {
|
|
82
|
+
const runs = [];
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
for (const range of ranges) {
|
|
85
|
+
const endRow = Math.min(range.endRowIndex, maxRow);
|
|
86
|
+
const endColumn = Math.min(range.endColumnIndex, maxColumn);
|
|
87
|
+
for (let row = range.startRowIndex; row <= endRow; row++) {
|
|
88
|
+
let run = null;
|
|
89
|
+
for (let col = range.startColumnIndex; col <= endColumn; col++) {
|
|
90
|
+
const key = `${row}:${col}`;
|
|
91
|
+
const uev = seen.has(key) ? null : getUserEnteredValue(row, col);
|
|
92
|
+
seen.add(key);
|
|
93
|
+
const kind = getErrorCheckKind({ userEnteredValue: uev, errorValue: null });
|
|
94
|
+
const value = kind === "numberStoredAsText"
|
|
95
|
+
? parseNumberStoredAsText(uev?.sv ?? uev?.stringValue)
|
|
96
|
+
: undefined;
|
|
97
|
+
if (value === undefined) {
|
|
98
|
+
run = null;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (!run) {
|
|
102
|
+
run = { rowIndex: row, startColumnIndex: col, values: [] };
|
|
103
|
+
runs.push(run);
|
|
104
|
+
}
|
|
105
|
+
run.values.push(value);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return runs;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Run one of the error-checking smart tag's menu items. Convert to Number and Ignore Error act on
|
|
113
|
+
* every selected cell, as Excel does: Convert to Number rewrites each number stored as text as its
|
|
114
|
+
* number — one `onChangeBatch` per run of adjacent cells, all inside one `batchHistory`, so it is a
|
|
115
|
+
* single undo step and syncs as ordinary value writes; Ignore Error appends the selection to the
|
|
116
|
+
* sheet's `ignoredErrors` (persisted, xlsx `<ignoredErrors>`).
|
|
117
|
+
*/
|
|
118
|
+
export const runErrorCheckOption = (option, context) => {
|
|
119
|
+
const { sheetId, kind, ranges } = context;
|
|
120
|
+
switch (option) {
|
|
121
|
+
case "convertToNumber": {
|
|
122
|
+
const runs = collectNumberStoredAsTextRuns(ranges, context.getUserEnteredValue, context.maxRow, context.maxColumn);
|
|
123
|
+
if (!runs.length)
|
|
124
|
+
return;
|
|
125
|
+
const write = () => {
|
|
126
|
+
for (const run of runs) {
|
|
127
|
+
context.onChangeBatch?.(sheetId, {
|
|
128
|
+
startRowIndex: run.rowIndex,
|
|
129
|
+
endRowIndex: run.rowIndex,
|
|
130
|
+
startColumnIndex: run.startColumnIndex,
|
|
131
|
+
endColumnIndex: run.startColumnIndex + run.values.length - 1,
|
|
132
|
+
}, [run.values]);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
if (context.batchHistory)
|
|
136
|
+
context.batchHistory(write);
|
|
137
|
+
else
|
|
138
|
+
write();
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
case "ignore":
|
|
142
|
+
context.onUpdateSheet?.(sheetId, {
|
|
143
|
+
ignoredErrors: appendIgnoredError(context.getIgnoredErrors?.(sheetId), ranges, kind),
|
|
144
|
+
});
|
|
145
|
+
return;
|
|
146
|
+
case "editInFormulaBar":
|
|
147
|
+
context.editInFormulaBar();
|
|
148
|
+
return;
|
|
149
|
+
case "help":
|
|
150
|
+
context.openUrl(getErrorHelpUrl(kind, context.errorName));
|
|
151
|
+
return;
|
|
152
|
+
case "options":
|
|
153
|
+
context.openUrl(ERROR_CHECKING_HELP_URL);
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
@@ -7,8 +7,14 @@ export declare const MOVE_OVERWRITE_PROMPT = "There's already data here. Do you
|
|
|
7
7
|
* destination cell OUTSIDE the source block holds a value. Cells the block itself
|
|
8
8
|
* currently occupies are never "data here" — they leave with the move — so an
|
|
9
9
|
* overlapping drag one cell over prompts only for the newly covered strip. An
|
|
10
|
-
* empty destination never prompts; Shift+drag (insert)
|
|
11
|
-
*
|
|
10
|
+
* empty destination never prompts; Shift+drag (insert) never reaches this check and
|
|
11
|
+
* Ctrl+drag (copy) uses {@link needsCopyOverwritePrompt}.
|
|
12
12
|
*/
|
|
13
13
|
export declare const needsOverwritePrompt: (from: GridRange, to: GridRange, hasValue: (rowIndex: number, columnIndex: number) => boolean) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Whether a Ctrl+drag (⌥+drag on macOS) COPY onto `to` needs the same prompt: any
|
|
16
|
+
* destination cell holding a value counts — a copy leaves the source in place, so
|
|
17
|
+
* source cells the copy lands on are replaced too.
|
|
18
|
+
*/
|
|
19
|
+
export declare const needsCopyOverwritePrompt: (to: GridRange, hasValue: (rowIndex: number, columnIndex: number) => boolean) => boolean;
|
|
14
20
|
//# sourceMappingURL=move-overwrite.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move-overwrite.d.ts","sourceRoot":"","sources":["../../../api/move-overwrite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,0DACuB,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,SAAS,EACf,IAAI,SAAS,EACb,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,KAC3D,OAkBF,CAAC"}
|
|
1
|
+
{"version":3,"file":"move-overwrite.d.ts","sourceRoot":"","sources":["../../../api/move-overwrite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,sFAAsF;AACtF,eAAO,MAAM,qBAAqB,0DACuB,CAAC;AAE1D;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAC/B,MAAM,SAAS,EACf,IAAI,SAAS,EACb,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,KAC3D,OAkBF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,GACnC,IAAI,SAAS,EACb,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,OAAO,KAC3D,OAaF,CAAC"}
|
|
@@ -6,8 +6,8 @@ export const MOVE_OVERWRITE_PROMPT = "There's already data here. Do you want to
|
|
|
6
6
|
* destination cell OUTSIDE the source block holds a value. Cells the block itself
|
|
7
7
|
* currently occupies are never "data here" — they leave with the move — so an
|
|
8
8
|
* overlapping drag one cell over prompts only for the newly covered strip. An
|
|
9
|
-
* empty destination never prompts; Shift+drag (insert)
|
|
10
|
-
*
|
|
9
|
+
* empty destination never prompts; Shift+drag (insert) never reaches this check and
|
|
10
|
+
* Ctrl+drag (copy) uses {@link needsCopyOverwritePrompt}.
|
|
11
11
|
*/
|
|
12
12
|
export const needsOverwritePrompt = (from, to, hasValue) => {
|
|
13
13
|
for (let rowIndex = to.startRowIndex; rowIndex <= to.endRowIndex; rowIndex++) {
|
|
@@ -23,3 +23,18 @@ export const needsOverwritePrompt = (from, to, hasValue) => {
|
|
|
23
23
|
}
|
|
24
24
|
return false;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Whether a Ctrl+drag (⌥+drag on macOS) COPY onto `to` needs the same prompt: any
|
|
28
|
+
* destination cell holding a value counts — a copy leaves the source in place, so
|
|
29
|
+
* source cells the copy lands on are replaced too.
|
|
30
|
+
*/
|
|
31
|
+
export const needsCopyOverwritePrompt = (to, hasValue) => {
|
|
32
|
+
for (let rowIndex = to.startRowIndex; rowIndex <= to.endRowIndex; rowIndex++) {
|
|
33
|
+
for (let columnIndex = to.startColumnIndex; columnIndex <= to.endColumnIndex; columnIndex++) {
|
|
34
|
+
if (hasValue(rowIndex, columnIndex)) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return false;
|
|
40
|
+
};
|
|
@@ -8,7 +8,7 @@ import type { SheetRange, TableView } from "../types";
|
|
|
8
8
|
* @param isActiveCell
|
|
9
9
|
* @param isSelection
|
|
10
10
|
*/
|
|
11
|
-
export declare const getSelectionStrokeStyle: (formulaMode: boolean, isFill: boolean, isActiveCell: boolean, emptySelections: boolean) => "
|
|
11
|
+
export declare const getSelectionStrokeStyle: (formulaMode: boolean, isFill: boolean, isActiveCell: boolean, emptySelections: boolean) => "solid" | "dashed";
|
|
12
12
|
export type SelectionStrokeOptions = {
|
|
13
13
|
/** Border width of a range selection outside formula mode. Default `1`. */
|
|
14
14
|
selectionStrokeWidth?: number;
|
|
@@ -37,7 +37,7 @@ export declare const getSelectionStrokeWidth: (formulaMode: boolean, isFill: boo
|
|
|
37
37
|
* @param isFill
|
|
38
38
|
* @returns
|
|
39
39
|
*/
|
|
40
|
-
export declare const getSelectionFillOpacity: (formulaMode: boolean, isFill: boolean) =>
|
|
40
|
+
export declare const getSelectionFillOpacity: (formulaMode: boolean, isFill: boolean) => 0 | 1 | 0.2;
|
|
41
41
|
/**
|
|
42
42
|
* Get background color of selection
|
|
43
43
|
* @param formulaMode
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CellInterface, GridRange } from "@rowsncolumns/grid";
|
|
2
|
-
import type { BooleanCondition, CellData, ConditionType, ConditionValue, CustomFormulaResult, DataValidationRule, DataValidationRuleAlert, FilterCriteria, Maybe, ProtectedRange, SheetProtection, TimePeriodTypes } from "../types";
|
|
2
|
+
import type { AllowEditRange, BooleanCondition, CellData, ConditionType, ConditionValue, CustomFormulaResult, DataValidationRule, DataValidationRuleAlert, FilterCriteria, Maybe, ProtectedRange, SheetProtection, TimePeriodTypes } from "../types";
|
|
3
3
|
export type CheckBooleanRuleOptions = {
|
|
4
4
|
locale?: string;
|
|
5
5
|
};
|
|
@@ -50,6 +50,28 @@ export declare const showValidationDropdownArrow: (rule?: DataValidationRule | n
|
|
|
50
50
|
* @returns
|
|
51
51
|
*/
|
|
52
52
|
export declare const isProtectedCell: (sheetId: number, cell: CellInterface, protectedRanges: ProtectedRange[]) => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The Excel Allow Edit Range covering `cell` on `sheetId`, preferring one this
|
|
55
|
+
* session may already edit (no password, or unlocked). `undefined` when no
|
|
56
|
+
* range covers the cell.
|
|
57
|
+
*/
|
|
58
|
+
export declare const getAllowEditRangeAt: (sheetId: number, cell: CellInterface, allowEditRanges: Maybe<AllowEditRange[]> | undefined) => AllowEditRange | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* What worksheet protection lets a typed edit of `cell` do (Excel's rules):
|
|
61
|
+
* `"edit"` for an unprotected sheet, an unlocked cell or a cell of an open
|
|
62
|
+
* Allow Edit Range; `"locked"` for any other locked cell; `{ unlock }` for a
|
|
63
|
+
* cell of a password-protected range this session has not unlocked (Excel's
|
|
64
|
+
* Unlock Range prompt).
|
|
65
|
+
*/
|
|
66
|
+
export declare const resolveProtectedCellEdit: ({ sheetId, cell, sheetProtection, cellProtection, allowEditRanges, }: {
|
|
67
|
+
sheetId: number;
|
|
68
|
+
cell: CellInterface;
|
|
69
|
+
sheetProtection: Maybe<SheetProtection> | undefined;
|
|
70
|
+
cellProtection: Maybe<Pick<NonNullable<CellData["protection"]>, "locked">>;
|
|
71
|
+
allowEditRanges?: Maybe<AllowEditRange[]>;
|
|
72
|
+
}) => "edit" | "locked" | {
|
|
73
|
+
unlock: AllowEditRange;
|
|
74
|
+
};
|
|
53
75
|
/**
|
|
54
76
|
* Check if the entire sheet is protected
|
|
55
77
|
* @param sheetId
|
|
@@ -86,6 +108,22 @@ export declare const isActionBlockedBySheetProtection: (sheetProtection: Maybe<S
|
|
|
86
108
|
* protection is inactive.
|
|
87
109
|
*/
|
|
88
110
|
export declare const isCellLockedUnderProtection: (sheetProtection: Maybe<SheetProtection> | undefined, cellProtection: Maybe<Pick<NonNullable<CellData["protection"]>, "locked">>) => boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Past this many cells a selection on a sheet that refuses locked cells is
|
|
113
|
+
* refused without a per-cell scan (it would cover a locked default cell in
|
|
114
|
+
* practice — the engine's protection gate uses the same reasoning).
|
|
115
|
+
*/
|
|
116
|
+
export declare const SELECTABLE_SCAN_CELL_CAP = 100000;
|
|
117
|
+
/**
|
|
118
|
+
* Excel's "Select locked cells" / "Select unlocked cells" (support.microsoft.com
|
|
119
|
+
* "Protect a worksheet"): whether the selection may cover `range` on a sheet.
|
|
120
|
+
* Only an ACTIVE protection restricts anything. `selectUnlockedCells` set
|
|
121
|
+
* (`true` prohibits) means no cell can be selected — Excel clears both boxes
|
|
122
|
+
* together. `selectLockedCells` set means the range must hold only unlocked
|
|
123
|
+
* cells (`protection.locked === false`; a cell is locked by default). Absent
|
|
124
|
+
* flags take the OOXML schema default: allowed.
|
|
125
|
+
*/
|
|
126
|
+
export declare const isRangeSelectableUnderProtection: (sheetProtection: Maybe<SheetProtection> | undefined, range: GridRange, getCellProtection: (rowIndex: number, columnIndex: number) => Maybe<Pick<NonNullable<CellData["protection"]>, "locked">> | undefined) => boolean;
|
|
89
127
|
/**
|
|
90
128
|
* Whether a cell's contents are hidden from the formula bar: Excel's Format
|
|
91
129
|
* Cells ▸ Protection ▸ Hidden takes effect only while the sheet is protected.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../api/validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAanE,OAAO,KAAK,EACV,gBAAgB,EAChB,QAAQ,EACR,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,uBAAuB,EAEvB,cAAc,EACd,KAAK,EACL,cAAc,EACd,eAAe,EACf,eAAe,EAChB,MAAM,UAAU,CAAC;AAElB,MAAM,MAAM,uBAAuB,GAAG;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AA6CF;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,QAAQ,EACj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B,KAAK,CAAC,eAAe,CAAC,GAAG,SAAS,EACnD,gBAAgB,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,KACzE,OAC0E,CAAC;AAE9E;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,MAAM,EACf,OAAO,SAAS,EAChB,iBAAiB,cAAc,EAAE,GAAG,SAAS,GAAG,IAAI,wBAWrD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,SAAS,MAAM,EACf,OAAO,SAAS,EAChB,iBAAiB,cAAc,EAAE,GAAG,SAAS,+BAW9C,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,OAAO,KAAK,CAAC,aAAa,CAAC,YAGjE,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,wBAAwB,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;AAEvE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GACjC,OAAO,KAAK,CAAC,uBAAuB,CAAC,EACrC,SAAS,OAAO,KACf,wBAKF,CAAC"}
|
|
@@ -482,6 +482,40 @@ export const isProtectedCell = (sheetId, cell, protectedRanges) => {
|
|
|
482
482
|
}
|
|
483
483
|
});
|
|
484
484
|
};
|
|
485
|
+
/**
|
|
486
|
+
* The Excel Allow Edit Range covering `cell` on `sheetId`, preferring one this
|
|
487
|
+
* session may already edit (no password, or unlocked). `undefined` when no
|
|
488
|
+
* range covers the cell.
|
|
489
|
+
*/
|
|
490
|
+
export const getAllowEditRangeAt = (sheetId, cell, allowEditRanges) => {
|
|
491
|
+
let found;
|
|
492
|
+
for (const range of allowEditRanges ?? []) {
|
|
493
|
+
if (range.sheetId !== sheetId)
|
|
494
|
+
continue;
|
|
495
|
+
if (!range.ranges.some((r) => isCellWithinBounds(cell, r)))
|
|
496
|
+
continue;
|
|
497
|
+
if (range.unlocked)
|
|
498
|
+
return range;
|
|
499
|
+
found ??= range;
|
|
500
|
+
}
|
|
501
|
+
return found;
|
|
502
|
+
};
|
|
503
|
+
/**
|
|
504
|
+
* What worksheet protection lets a typed edit of `cell` do (Excel's rules):
|
|
505
|
+
* `"edit"` for an unprotected sheet, an unlocked cell or a cell of an open
|
|
506
|
+
* Allow Edit Range; `"locked"` for any other locked cell; `{ unlock }` for a
|
|
507
|
+
* cell of a password-protected range this session has not unlocked (Excel's
|
|
508
|
+
* Unlock Range prompt).
|
|
509
|
+
*/
|
|
510
|
+
export const resolveProtectedCellEdit = ({ sheetId, cell, sheetProtection, cellProtection, allowEditRanges, }) => {
|
|
511
|
+
if (!isCellLockedUnderProtection(sheetProtection, cellProtection)) {
|
|
512
|
+
return "edit";
|
|
513
|
+
}
|
|
514
|
+
const range = getAllowEditRangeAt(sheetId, cell, allowEditRanges);
|
|
515
|
+
if (!range)
|
|
516
|
+
return "locked";
|
|
517
|
+
return range.unlocked ? "edit" : { unlock: range };
|
|
518
|
+
};
|
|
485
519
|
/**
|
|
486
520
|
* Check if the entire sheet is protected
|
|
487
521
|
* @param sheetId
|
|
@@ -530,6 +564,42 @@ export const isActionBlockedBySheetProtection = (sheetProtection, action) => {
|
|
|
530
564
|
* protection is inactive.
|
|
531
565
|
*/
|
|
532
566
|
export const isCellLockedUnderProtection = (sheetProtection, cellProtection) => isSheetProtectionActive(sheetProtection) && cellProtection?.locked !== false;
|
|
567
|
+
/**
|
|
568
|
+
* Past this many cells a selection on a sheet that refuses locked cells is
|
|
569
|
+
* refused without a per-cell scan (it would cover a locked default cell in
|
|
570
|
+
* practice — the engine's protection gate uses the same reasoning).
|
|
571
|
+
*/
|
|
572
|
+
export const SELECTABLE_SCAN_CELL_CAP = 100_000;
|
|
573
|
+
/**
|
|
574
|
+
* Excel's "Select locked cells" / "Select unlocked cells" (support.microsoft.com
|
|
575
|
+
* "Protect a worksheet"): whether the selection may cover `range` on a sheet.
|
|
576
|
+
* Only an ACTIVE protection restricts anything. `selectUnlockedCells` set
|
|
577
|
+
* (`true` prohibits) means no cell can be selected — Excel clears both boxes
|
|
578
|
+
* together. `selectLockedCells` set means the range must hold only unlocked
|
|
579
|
+
* cells (`protection.locked === false`; a cell is locked by default). Absent
|
|
580
|
+
* flags take the OOXML schema default: allowed.
|
|
581
|
+
*/
|
|
582
|
+
export const isRangeSelectableUnderProtection = (sheetProtection, range, getCellProtection) => {
|
|
583
|
+
if (!isSheetProtectionActive(sheetProtection))
|
|
584
|
+
return true;
|
|
585
|
+
if (sheetProtection?.selectUnlockedCells === true)
|
|
586
|
+
return false;
|
|
587
|
+
if (sheetProtection?.selectLockedCells !== true)
|
|
588
|
+
return true;
|
|
589
|
+
const rows = range.endRowIndex - range.startRowIndex + 1;
|
|
590
|
+
const columns = range.endColumnIndex - range.startColumnIndex + 1;
|
|
591
|
+
if (rows <= 0 || columns <= 0)
|
|
592
|
+
return true;
|
|
593
|
+
if (rows * columns > SELECTABLE_SCAN_CELL_CAP)
|
|
594
|
+
return false;
|
|
595
|
+
for (let row = range.startRowIndex; row <= range.endRowIndex; row++) {
|
|
596
|
+
for (let column = range.startColumnIndex; column <= range.endColumnIndex; column++) {
|
|
597
|
+
if (getCellProtection(row, column)?.locked !== false)
|
|
598
|
+
return false;
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
return true;
|
|
602
|
+
};
|
|
533
603
|
/**
|
|
534
604
|
* Whether a cell's contents are hidden from the formula bar: Excel's Format
|
|
535
605
|
* Cells ▸ Protection ▸ Hidden takes effect only while the sheet is protected.
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export declare const useCellInputContext: () => {
|
|
2
2
|
makeEditable: ((sheetId: number, cell: import("@rowsncolumns/grid").CellInterface, initialValue?: string, options?: import("../hooks/use-editable").MakeEditableOptions) => void) | undefined;
|
|
3
3
|
getNextFocusableCell: ((sheetId: number, currentCell: import("@rowsncolumns/grid").CellInterface, direction?: import("@rowsncolumns/grid").Direction, restrictWithinSelection?: boolean) => import("@rowsncolumns/grid").CellInterface | null) | undefined;
|
|
4
|
-
submitEditor: ((value: string, textFormatRuns: import("@rowsncolumns/common-types").TextFormatRun[] | undefined, sheetId: number, activeCell: import("@rowsncolumns/grid").CellInterface, nextActiveCell?: import("@rowsncolumns/grid").CellInterface | null | undefined
|
|
4
|
+
submitEditor: ((value: string, textFormatRuns: import("@rowsncolumns/common-types").TextFormatRun[] | undefined, sheetId: number, activeCell: import("@rowsncolumns/grid").CellInterface, nextActiveCell?: import("@rowsncolumns/grid").CellInterface | null | undefined, shouldFocusGrid?: boolean, options?: {
|
|
5
|
+
arrayFormula?: boolean;
|
|
6
|
+
fillSelection?: boolean;
|
|
7
|
+
}) => void) | undefined;
|
|
5
8
|
cancelEditor: ((e?: React.KeyboardEvent<HTMLDivElement>) => void) | undefined;
|
|
6
9
|
onEditorKeyDown: ((e: React.KeyboardEvent<HTMLDivElement>) => void) | undefined;
|
|
7
10
|
canEditCell: ((sheetId: number, cell: import("@rowsncolumns/grid").CellInterface) => boolean) | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell-input-context.atom.d.ts","sourceRoot":"","sources":["../../../atoms/cell-input-context.atom.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"cell-input-context.atom.d.ts","sourceRoot":"","sources":["../../../atoms/cell-input-context.atom.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,mBAAmB;;;;oBACohiF,CAAC;qBAAwB,CAAC;;;;;;;;;;;CAD//hF,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EnterKeyDirection } from "../components/cell-editor/helpers";
|
|
2
|
+
/**
|
|
3
|
+
* The grid's `enterKeyDirection`, for the editors that commit on Enter outside its props (the
|
|
4
|
+
* in-cell editor a host supplies, the formula bar).
|
|
5
|
+
*/
|
|
6
|
+
export declare const enterKeyDirectionAtom: import("jotai").PrimitiveAtom<EnterKeyDirection> & {
|
|
7
|
+
init: EnterKeyDirection;
|
|
8
|
+
};
|
|
9
|
+
export declare const useEnterKeyDirection: () => EnterKeyDirection;
|
|
10
|
+
export declare const useSetEnterKeyDirection: () => (args_0: EnterKeyDirection | ((prev: EnterKeyDirection) => EnterKeyDirection)) => void;
|
|
11
|
+
//# sourceMappingURL=enter-key-direction.atom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enter-key-direction.atom.d.ts","sourceRoot":"","sources":["../../../atoms/enter-key-direction.atom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;CAAkC,CAAC;AAErE,eAAO,MAAM,oBAAoB,yBAA4C,CAAC;AAC9E,eAAO,MAAM,uBAAuB,8FAA0C,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { atom, useAtomValue, useSetAtom } from "jotai";
|
|
2
|
+
/**
|
|
3
|
+
* The grid's `enterKeyDirection`, for the editors that commit on Enter outside its props (the
|
|
4
|
+
* in-cell editor a host supplies, the formula bar).
|
|
5
|
+
*/
|
|
6
|
+
export const enterKeyDirectionAtom = atom("down");
|
|
7
|
+
export const useEnterKeyDirection = () => useAtomValue(enterKeyDirectionAtom);
|
|
8
|
+
export const useSetEnterKeyDirection = () => useSetAtom(enterKeyDirectionAtom);
|
|
@@ -13,6 +13,7 @@ export * from "./selected-chart-embed.atom";
|
|
|
13
13
|
export * from "./selected-chart-series.atom";
|
|
14
14
|
export * from "./popover.atom";
|
|
15
15
|
export * from "./paste-menu.atom";
|
|
16
|
+
export * from "./pick-list.atom";
|
|
16
17
|
export * from "./fill-options.atom";
|
|
17
18
|
export * from "./fill-series-dialog.atom";
|
|
18
19
|
export * from "./magic-fill-state.atom";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../atoms/index.ts"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,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC"}
|
package/dist/esm/atoms/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./selected-chart-embed.atom";
|
|
|
13
13
|
export * from "./selected-chart-series.atom";
|
|
14
14
|
export * from "./popover.atom";
|
|
15
15
|
export * from "./paste-menu.atom";
|
|
16
|
+
export * from "./pick-list.atom";
|
|
16
17
|
export * from "./fill-options.atom";
|
|
17
18
|
export * from "./fill-series-dialog.atom";
|
|
18
19
|
export * from "./magic-fill-state.atom";
|
|
@@ -1,6 +1,28 @@
|
|
|
1
|
+
import type { PasteOptionId } from "../components/selection/paste-options";
|
|
1
2
|
export declare const showPasteMenuAtom: import("jotai").PrimitiveAtom<boolean> & {
|
|
2
3
|
init: boolean;
|
|
3
4
|
};
|
|
4
5
|
export declare const useShowPasteMenu: () => [boolean, (args_0: boolean | ((prev: boolean) => boolean)) => void];
|
|
5
6
|
export declare const useSetShowPasteMenu: () => (args_0: boolean | ((prev: boolean) => boolean)) => void;
|
|
7
|
+
/**
|
|
8
|
+
* The Paste Options button's state for the last paste: whether its gallery
|
|
9
|
+
* is open (a click, or Ctrl pressed alone after the paste), which gallery
|
|
10
|
+
* entry the paste currently stands as, and what the gallery may offer.
|
|
11
|
+
*/
|
|
12
|
+
export type PasteMenuState = {
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** The gallery entry the last paste was applied as. */
|
|
15
|
+
active?: PasteOptionId;
|
|
16
|
+
/** The last paste can be re-applied in another mode (a copy, not a cut). */
|
|
17
|
+
canReapply: boolean;
|
|
18
|
+
/** Paste Link needs copied grid cells (not after a cut or a foreign clipboard). */
|
|
19
|
+
canLink: boolean;
|
|
20
|
+
};
|
|
21
|
+
export declare const DEFAULT_PASTE_MENU_STATE: PasteMenuState;
|
|
22
|
+
export declare const pasteMenuStateAtom: import("jotai").PrimitiveAtom<PasteMenuState> & {
|
|
23
|
+
init: PasteMenuState;
|
|
24
|
+
};
|
|
25
|
+
export declare const usePasteMenuState: () => [PasteMenuState, (args_0: PasteMenuState | ((prev: PasteMenuState) => PasteMenuState)) => void];
|
|
26
|
+
export declare const usePasteMenuStateValue: () => PasteMenuState;
|
|
27
|
+
export declare const useSetPasteMenuState: () => (args_0: PasteMenuState | ((prev: PasteMenuState) => PasteMenuState)) => void;
|
|
6
28
|
//# sourceMappingURL=paste-menu.atom.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paste-menu.atom.d.ts","sourceRoot":"","sources":["../../../atoms/paste-menu.atom.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB;;CAAc,CAAC;AAE7C,eAAO,MAAM,gBAAgB,2EAAmC,CAAC;AACjE,eAAO,MAAM,mBAAmB,gEAAsC,CAAC"}
|
|
1
|
+
{"version":3,"file":"paste-menu.atom.d.ts","sourceRoot":"","sources":["../../../atoms/paste-menu.atom.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAE3E,eAAO,MAAM,iBAAiB;;CAAc,CAAC;AAE7C,eAAO,MAAM,gBAAgB,2EAAmC,CAAC;AACjE,eAAO,MAAM,mBAAmB,gEAAsC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,EAAE,OAAO,CAAC;IACd,uDAAuD;IACvD,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,4EAA4E;IAC5E,UAAU,EAAE,OAAO,CAAC;IACpB,mFAAmF;IACnF,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,cAItC,CAAC;AAEF,eAAO,MAAM,kBAAkB;;CAAiD,CAAC;AAEjF,eAAO,MAAM,iBAAiB,uGAAoC,CAAC;AACnE,eAAO,MAAM,sBAAsB,sBAAyC,CAAC;AAC7E,eAAO,MAAM,oBAAoB,qFAAuC,CAAC"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import { atom, useAtom, useSetAtom } from "jotai";
|
|
1
|
+
import { atom, useAtom, useAtomValue, useSetAtom } from "jotai";
|
|
2
2
|
export const showPasteMenuAtom = atom(false);
|
|
3
3
|
export const useShowPasteMenu = () => useAtom(showPasteMenuAtom);
|
|
4
4
|
export const useSetShowPasteMenu = () => useSetAtom(showPasteMenuAtom);
|
|
5
|
+
export const DEFAULT_PASTE_MENU_STATE = {
|
|
6
|
+
open: false,
|
|
7
|
+
canReapply: false,
|
|
8
|
+
canLink: false,
|
|
9
|
+
};
|
|
10
|
+
export const pasteMenuStateAtom = atom(DEFAULT_PASTE_MENU_STATE);
|
|
11
|
+
export const usePasteMenuState = () => useAtom(pasteMenuStateAtom);
|
|
12
|
+
export const usePasteMenuStateValue = () => useAtomValue(pasteMenuStateAtom);
|
|
13
|
+
export const useSetPasteMenuState = () => useSetAtom(pasteMenuStateAtom);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CellInterface } from "@rowsncolumns/grid";
|
|
2
|
+
/**
|
|
3
|
+
* Excel's Pick From Drop-down List (Alt+↓ on a cell with no list of its
|
|
4
|
+
* own): the column's entries the cell editor offers for `cell`.
|
|
5
|
+
*/
|
|
6
|
+
export type PickListRequest = {
|
|
7
|
+
sheetId: number;
|
|
8
|
+
cell: CellInterface;
|
|
9
|
+
entries: string[];
|
|
10
|
+
};
|
|
11
|
+
export declare const pickListAtom: import("jotai").PrimitiveAtom<PickListRequest | null> & {
|
|
12
|
+
init: PickListRequest | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const usePickList: () => [PickListRequest | null, (args_0: PickListRequest | ((prev: PickListRequest | null) => PickListRequest | null) | null) => void];
|
|
15
|
+
//# sourceMappingURL=pick-list.atom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pick-list.atom.d.ts","sourceRoot":"","sources":["../../../atoms/pick-list.atom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,aAAa,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,YAAY;;CAAqC,CAAC;AAE/D,eAAO,MAAM,WAAW,uIAA8B,CAAC"}
|