@betteroffice/xlsx-react 0.5.1 → 0.6.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/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { XlsxEditRefusal, Selection, XlsxReadRequest, XlsxReadResult, XlsxFindRequest, XlsxFindResult, XlsxEditRequest, XlsxValidationResult, XlsxEditResult, CellRange, CellEdit, EditResult, ProposalEdit, Proposal, WorkbookHandle } from '@betteroffice/xlsx';
2
- export { XlsxSheetVisibility } from '@betteroffice/xlsx';
1
+ import { XlsxEditRefusal, Selection, XlsxReadRequest, XlsxReadResult, XlsxFindRequest, XlsxFindResult, XlsxEditRequest, XlsxValidationResult, XlsxEditResult, CellRange, CellEdit, EditResult, ProposalEdit, Proposal, XlsxPngTarget, XlsxPngOptions, WorkbookHandle } from '@betteroffice/xlsx';
2
+ export { XlsxHeaderFooterPair, XlsxHeaderFooterText, XlsxSheetHeaderFooter, XlsxSheetVisibility } from '@betteroffice/xlsx';
3
+ import { RemoteFontProvider } from '@betteroffice/fonts/remote';
3
4
  import { AsyncCollaborationReplica, CollaborationReplica, CollaborationAwareness } from '@betteroffice/xlsx/collaboration';
4
5
  import { TranslationKey, Translations, TFunction } from '@betteroffice/xlsx-i18n';
5
6
  import * as react from 'react';
@@ -92,6 +93,26 @@ type PluginCommandResult<Status extends string = string, Refusal extends {
92
93
  ok: false;
93
94
  failure: CommandReason;
94
95
  } | Refusal;
96
+ /** @experimental The plugin API may change in minor releases. */
97
+ interface PluginFocusChangeEvent {
98
+ type: 'focus-change';
99
+ generation: string;
100
+ focused: boolean;
101
+ }
102
+ /** @experimental The plugin API may change in minor releases. */
103
+ interface PluginLocaleChangeEvent {
104
+ type: 'locale-change';
105
+ generation: string;
106
+ locale: string;
107
+ }
108
+ /** @experimental The plugin API may change in minor releases. */
109
+ interface PluginSelectionSettleEvent<Selection> {
110
+ type: 'selection-settle';
111
+ generation: string;
112
+ version: string;
113
+ selection: Selection;
114
+ source: 'pointer' | 'touch' | 'keyboard';
115
+ }
95
116
 
96
117
  /**
97
118
  * How a toolbar gets its state: `'legacy'` from props and callbacks,
@@ -257,6 +278,7 @@ interface XlsxCommandArgs {
257
278
  value: TextWrapping;
258
279
  };
259
280
  searchMenus: null;
281
+ findReplace: null;
260
282
  save: null;
261
283
  exportPng: null;
262
284
  print: null;
@@ -278,6 +300,34 @@ interface XlsxCommandArgs {
278
300
  proposalReject: {
279
301
  proposalId: string;
280
302
  };
303
+ cut: null;
304
+ copy: null;
305
+ /** Pastes values and formats from the clipboard. */
306
+ paste: null;
307
+ /** Pastes only the clipboard's text. */
308
+ pastePlainText: null;
309
+ /** Clears the values of the selected cells, keeping their formats. */
310
+ clearContents: null;
311
+ /** Inserts as many rows as the selection spans. */
312
+ insertRows: {
313
+ position: 'above' | 'below';
314
+ };
315
+ /** Inserts as many columns as the selection spans. */
316
+ insertColumns: {
317
+ position: 'left' | 'right';
318
+ };
319
+ deleteRows: null;
320
+ deleteColumns: null;
321
+ /** Inserts a sheet before the active one. */
322
+ insertSheet: null;
323
+ deleteSheet: null;
324
+ /** `null` opens the active sheet's name for editing. */
325
+ renameSheet: {
326
+ name: string;
327
+ } | null;
328
+ moveSheet: {
329
+ direction: 'left' | 'right';
330
+ };
281
331
  }
282
332
  /** @experimental */
283
333
  type XlsxCommandId = keyof XlsxCommandArgs;
@@ -326,6 +376,7 @@ interface XlsxCommandValues {
326
376
  verticalAlignment: VerticalAlignment | null;
327
377
  textWrapping: TextWrapping | null;
328
378
  searchMenus: null;
379
+ findReplace: null;
329
380
  save: null;
330
381
  exportPng: null;
331
382
  print: null;
@@ -336,17 +387,30 @@ interface XlsxCommandValues {
336
387
  proposalsPanel: number;
337
388
  proposalAccept: null;
338
389
  proposalReject: null;
390
+ cut: null;
391
+ copy: null;
392
+ paste: null;
393
+ pastePlainText: null;
394
+ clearContents: null;
395
+ insertRows: null;
396
+ insertColumns: null;
397
+ deleteRows: null;
398
+ deleteColumns: null;
399
+ insertSheet: null;
400
+ deleteSheet: null;
401
+ renameSheet: null;
402
+ moveSheet: null;
339
403
  }
340
404
  /**
341
405
  * Why a command is unavailable.
342
406
  * @experimental
343
407
  */
344
- type XlsxCommandDisabledCode = 'editor-unavailable' | 'document-loading' | 'no-document' | 'read-only' | 'cell-selection-required' | 'unsupported-selection' | 'multiple-cells-required' | 'multiple-columns-required' | 'multiple-rows-required' | 'no-merged-cells' | 'collaboration-unsupported' | 'nothing-to-undo' | 'nothing-to-redo' | 'png-unavailable' | 'no-proposals' | 'proposal-not-found' | 'host-disabled' | 'unsupported-command' | 'invalid-arguments' | 'permission-denied' | 'unsupported-policy' | 'plugin-unavailable';
408
+ type XlsxCommandDisabledCode = 'editor-unavailable' | 'document-loading' | 'no-document' | 'read-only' | 'cell-selection-required' | 'unsupported-selection' | 'multiple-cells-required' | 'multiple-columns-required' | 'multiple-rows-required' | 'no-merged-cells' | 'collaboration-unsupported' | 'nothing-to-undo' | 'nothing-to-redo' | 'png-unavailable' | 'no-proposals' | 'proposal-not-found' | 'host-disabled' | 'unsupported-command' | 'invalid-arguments' | 'permission-denied' | 'unsupported-policy' | 'plugin-unavailable' | 'clipboard-unavailable' | 'last-sheet' | 'sheet-at-edge' | 'sheet-name-invalid';
345
409
  /**
346
410
  * Why an executed command did not complete.
347
411
  * @experimental
348
412
  */
349
- type XlsxCommandFailureCode = XlsxCommandDisabledCode | 'input-failed' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'proposal-stale' | 'render-failed' | 'command-failed' | 'aborted';
413
+ type XlsxCommandFailureCode = XlsxCommandDisabledCode | 'input-failed' | 'edit-unsupported' | 'sheet-protected' | 'host-refused' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'proposal-stale' | 'render-failed' | 'clipboard-denied' | 'command-failed' | 'aborted';
350
414
  /**
351
415
  * One choice of a selector command.
352
416
  * @experimental
@@ -445,17 +509,60 @@ interface XlsxCommandStore {
445
509
  execute(id: XlsxPluginCommandId, args: null): Promise<XlsxPluginCommandResult>;
446
510
  }
447
511
 
448
- /** Why work queued behind accepted input could not run. */
449
- type XlsxCommandAdmissionCode = Extract<XlsxCommandFailureCode, 'input-failed' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'editor-unavailable'>;
450
512
  /**
451
- * Raised when work queued behind accepted input cannot run: a command, or a version, read or
452
- * edit-batch call of the editor API.
513
+ * A chord such as `Mod+Shift+V`. `Mod` is Cmd on macOS and Ctrl elsewhere; `Ctrl` is the physical
514
+ * Control key on macOS and the same as `Mod` elsewhere.
515
+ * @experimental
453
516
  */
454
- declare class XlsxCommandAdmissionError extends Error {
455
- readonly code: XlsxCommandAdmissionCode;
456
- constructor(code: XlsxCommandAdmissionCode);
517
+ type ShortcutChord = string;
518
+
519
+ /**
520
+ * What a host sets for one shortcut id: chords that replace the defaults, `null` to disable it,
521
+ * or a per-platform form where an absent platform keeps its default.
522
+ * @experimental
523
+ */
524
+ type ShortcutBinding = ShortcutChord | readonly ShortcutChord[] | null | {
525
+ mac?: ShortcutChord | readonly ShortcutChord[] | null;
526
+ other?: ShortcutChord | readonly ShortcutChord[] | null;
527
+ };
528
+ /**
529
+ * A host binding the editor changed or refused. `displaced-default` is informational: the host
530
+ * chord `chord` of `id` took over the default of `displaced`.
531
+ * @experimental
532
+ */
533
+ interface ShortcutIssue {
534
+ code: 'unknown-id' | 'invalid-chord' | 'reserved-chord' | 'duplicate-chord' | 'displaced-default';
535
+ id: string;
536
+ chord?: string;
537
+ /** The other shortcut id involved, for `duplicate-chord` and `displaced-default`. */
538
+ other?: string;
539
+ }
540
+ interface ResolvedShortcuts {
541
+ /** Effective canonical chords by id; an id without chords is absent or empty. */
542
+ chords: ReadonlyMap<string, readonly string[]>;
543
+ /** The id each effective canonical chord runs. */
544
+ owners: ReadonlyMap<string, string>;
545
+ issues: readonly ShortcutIssue[];
457
546
  }
458
547
 
548
+ type XlsxNullArgsCommandId = {
549
+ [K in XlsxCommandId]: null extends XlsxCommandArgs[K] ? K : never;
550
+ }[XlsxCommandId];
551
+ /**
552
+ * Every id a host can bind: commands that run without arguments and plugin commands.
553
+ * @experimental
554
+ */
555
+ type XlsxShortcutId = XlsxNullArgsCommandId | XlsxPluginCommandId;
556
+ /**
557
+ * Host changes to the editor's shortcuts. An omitted id keeps its default; chords replace all of
558
+ * its defaults; `null` disables it and leaves the keystroke to the host or browser. A chord taken
559
+ * from another command's default wins over it. `cut`, `copy`, `paste` and `pastePlainText` read
560
+ * and write the clipboard with the async Clipboard API, which browsers may gate behind a prompt.
561
+ * Navigation and editing keys of the grid, and select all, cannot be bound.
562
+ * @experimental
563
+ */
564
+ type XlsxShortcuts = Readonly<Partial<Record<XlsxShortcutId, ShortcutBinding>>>;
565
+
459
566
  /**
460
567
  * What the host lets one plugin do. Without a grant a plugin reads, validates and navigates only.
461
568
  * Built-in commands need their id listed and, when they mutate, `document: 'write'`; edit
@@ -535,21 +642,51 @@ interface XlsxPluginLayout {
535
642
  height: number;
536
643
  };
537
644
  }
538
- /** A cell under the pointer, with the layout it was resolved against. */
539
- interface XlsxPluginCellPosition {
645
+ /**
646
+ * A cell under the pointer, with the layout it was resolved against. `sheet`, `row` and `col`
647
+ * are what the editor's `getPositionAtPoint` answers for the same point; `sheetId` names that sheet.
648
+ */
649
+ interface XlsxPluginCellPosition extends XlsxPointPosition {
540
650
  sheetId: string;
541
651
  row: number;
542
652
  col: number;
543
653
  version: string;
544
654
  layoutId: string;
545
655
  }
656
+ type XlsxGeometryTarget = {
657
+ kind: 'proposal';
658
+ id: string;
659
+ }
660
+ /** @experimental Selection anchors are live-only; use getRangeRect to keep a cell range. */
661
+ | {
662
+ kind: 'selection';
663
+ };
664
+ type XlsxAnchorGeometryResult = {
665
+ ok: true;
666
+ version: string;
667
+ previewVersion: number;
668
+ layoutId: string;
669
+ rects: readonly XlsxPluginRect[];
670
+ anchor: XlsxPluginRect;
671
+ pageRect: XlsxPluginRect;
672
+ } | {
673
+ ok: false;
674
+ failure: {
675
+ code: XlsxPluginNavigationFailureCode | 'unknown-proposal' | 'pending' | 'read-failed';
676
+ message: string;
677
+ };
678
+ };
546
679
  /**
547
680
  * Geometry of the painted grid. Rectangles are in pixels of the overlay layer, already zoomed
548
- * and clipped to the visible grid; every method returns null once its layout is no longer
549
- * painted, and for cells scrolled out of view or on another sheet.
681
+ * and clipped to the visible grid. Cell and range queries return null for unpainted layouts
682
+ * and cells outside the visible sheet; anchor queries return a typed failure.
683
+ * A `selection` target answers `layout-unavailable` once the context's selection is superseded.
550
684
  */
551
685
  interface XlsxPluginGeometry {
552
686
  layout: XlsxPluginLayout;
687
+ getAnchorGeometry(target: XlsxGeometryTarget): XlsxAnchorGeometryResult;
688
+ /** @experimental Reads every target in order. */
689
+ readAnchorGeometries(targets: readonly XlsxGeometryTarget[]): Promise<XlsxAnchorGeometryResult[]>;
553
690
  /** One grid cell, without merge expansion; zero-based `row` and `col`. */
554
691
  getCellRect(target: {
555
692
  sheetId: string;
@@ -561,7 +698,12 @@ interface XlsxPluginGeometry {
561
698
  sheetId: string;
562
699
  range: CellRange;
563
700
  }): XlsxPluginRect | null;
564
- /** Client-coordinate hit testing; null until the editor exposes it. */
701
+ /**
702
+ * The cell under client coordinates, through the editor's own hit test; selection and focus
703
+ * stay where they are. It answers null outside the painted grid, over a chart, for non-finite
704
+ * coordinates, once this layout is no longer painted or its workbook was replaced, and wherever
705
+ * that hit test answers null. The member itself is null on hosts without a grid hit test.
706
+ */
565
707
  getPositionAtPoint: ((clientX: number, clientY: number) => XlsxPluginCellPosition | null) | null;
566
708
  }
567
709
  /** The active sheet and what is selected on it; ids are session-scoped. */
@@ -575,12 +717,18 @@ type XlsxPluginSelection = {
575
717
  chartId: string | null;
576
718
  } | null;
577
719
  interface XlsxPluginSnapshot {
720
+ /** @experimental Focus inside the document surface. */
721
+ focused: boolean;
722
+ /** @experimental The editor's resolved locale tag. */
723
+ locale: string;
578
724
  /** The open workbook; changes when a workbook replaces it. */
579
725
  generation: string;
580
726
  version: string;
581
727
  readOnly: boolean;
582
728
  grant: XlsxPluginGrant;
583
729
  selection: XlsxPluginSelection;
730
+ /** @experimental Whether the selection has finished changing. */
731
+ selectionSettled: boolean;
584
732
  /** Null while no painted frame shows `version`. */
585
733
  layout: XlsxPluginLayout | null;
586
734
  }
@@ -627,8 +775,14 @@ interface XlsxPluginNavigation {
627
775
  align?: 'nearest' | 'start' | 'center';
628
776
  }): Promise<XlsxPluginNavigationResult>;
629
777
  }
778
+ /** @experimental The plugin API may change in minor releases. */
779
+ type XlsxPluginFocusChangeEvent = PluginFocusChangeEvent;
780
+ /** @experimental The plugin API may change in minor releases. */
781
+ type XlsxPluginLocaleChangeEvent = PluginLocaleChangeEvent;
782
+ /** @experimental The plugin API may change in minor releases. */
783
+ type XlsxPluginSelectionSettleEvent = PluginSelectionSettleEvent<XlsxPluginSelection>;
630
784
  /** Lifecycle notifications describe current state; several changes may arrive as one. */
631
- type XlsxPluginEvent = {
785
+ type XlsxPluginEvent = XlsxPluginSelectionSettleEvent | XlsxPluginFocusChangeEvent | XlsxPluginLocaleChangeEvent | {
632
786
  type: 'load';
633
787
  generation: string;
634
788
  version: string;
@@ -637,6 +791,11 @@ type XlsxPluginEvent = {
637
791
  type: 'document-change';
638
792
  generation: string;
639
793
  version: string;
794
+ } | {
795
+ type: 'proposal-change';
796
+ generation: string;
797
+ version: string;
798
+ previewVersion: number;
640
799
  } | {
641
800
  type: 'selection-change';
642
801
  generation: string;
@@ -654,6 +813,18 @@ type XlsxPluginEvent = {
654
813
  type: 'grants-change';
655
814
  generation: string;
656
815
  grant: XlsxPluginGrant;
816
+ }
817
+ /**
818
+ * A row marker was clicked or pressed; sent only to the plugin that owns it.
819
+ *
820
+ * @experimental The plugin API may change in minor releases.
821
+ */
822
+ | {
823
+ type: 'row-decoration-activate';
824
+ generation: string;
825
+ id: string;
826
+ sheetId: string;
827
+ row: number;
657
828
  };
658
829
  /**
659
830
  * What a hook, renderer or action receives. Clients refuse once it is superseded or ended.
@@ -712,8 +883,45 @@ interface XlsxPluginCommand<S> {
712
883
  execute(context: XlsxPluginContext<S>): MaybePromise<XlsxPluginCommandResult>;
713
884
  }
714
885
  /**
715
- * A plugin. `createState`, renderers and command `getState` must be pure; `initialize`,
716
- * `onEvent`, command `execute` and `context.run` are managed effects.
886
+ * A cell as the edit gate sees it; zero-based `row` and `col`.
887
+ *
888
+ * @experimental The plugin API may change in minor releases.
889
+ */
890
+ type XlsxPluginCellRef = {
891
+ sheetId: string;
892
+ row: number;
893
+ col: number;
894
+ };
895
+ /**
896
+ * A cell write before it is made: `input` is the text the cell gets, empty for a clear. A pasted
897
+ * formula arrives moved to its cell; `cut` asks the cells a cut clears.
898
+ *
899
+ * @experimental The plugin API may change in minor releases.
900
+ */
901
+ type XlsxPluginCellCommit = XlsxPluginCellRef & {
902
+ input: string;
903
+ kind: 'value' | 'formula' | 'clear';
904
+ source: 'cell-editor' | 'formula-bar' | 'clear-key' | 'paste' | 'cut';
905
+ };
906
+ /** @experimental The plugin API may change in minor releases. */
907
+ type XlsxPluginCommitDecision = {
908
+ action: 'accept';
909
+ } | {
910
+ action: 'replace';
911
+ input: string;
912
+ } | {
913
+ action: 'refuse';
914
+ message?: string;
915
+ };
916
+ /**
917
+ * What the edit gate hooks receive: reads only, since they run synchronously and must not mutate.
918
+ *
919
+ * @experimental The plugin API may change in minor releases.
920
+ */
921
+ type XlsxPluginEditGateContext<S> = Pick<XlsxPluginContext<S>, 'pluginId' | 'snapshot' | 'state' | 'read'>;
922
+ /**
923
+ * A plugin. `createState`, renderers, command `getState`, `cellEditable` and `beforeCellCommit`
924
+ * must be pure; `initialize`, `onEvent`, command `execute` and `context.run` are managed effects.
717
925
  *
718
926
  * @experimental The plugin API may change in minor releases.
719
927
  */
@@ -732,7 +940,54 @@ interface XlsxPluginDefinition<S> {
732
940
  commands?: readonly XlsxPluginCommand<S>[];
733
941
  /** Local command ids, in display order. */
734
942
  toolbar?: readonly string[];
943
+ /**
944
+ * Sync. False makes the cell read-only for typing, clearing, pasting and cutting; any plugin
945
+ * returning false wins.
946
+ *
947
+ * @experimental The plugin API may change in minor releases.
948
+ */
949
+ cellEditable?(context: XlsxPluginEditGateContext<S>, cell: XlsxPluginCellRef): boolean;
950
+ /**
951
+ * Sync. Sees each cell a typed commit, clear, paste or cut changes before it is written; a
952
+ * refusal refuses the whole gesture. Return `{ action: 'accept' }`,
953
+ * `{ action: 'replace', input: string }` (the next plugin sees the replaced input) or
954
+ * `{ action: 'refuse', message?: string }`. Any refusal wins.
955
+ *
956
+ * @experimental The plugin API may change in minor releases.
957
+ */
958
+ beforeCellCommit?(context: XlsxPluginEditGateContext<S>, commit: XlsxPluginCellCommit): XlsxPluginCommitDecision;
959
+ /**
960
+ * Sync and pure. Row markers for the gutter, evaluated on load, after `setState` and after a
961
+ * document change. A throw or a malformed set ends the plugin with the `row-decorations` phase.
962
+ *
963
+ * @experimental The plugin API may change in minor releases.
964
+ */
965
+ rowDecorations?(context: XlsxPluginContext<S>): XlsxPluginRowDecorations | null;
735
966
  }
967
+ /**
968
+ * A marker in the row gutter. `row` is zero-based; `id` is unique within the plugin; `text`
969
+ * applies to badges only, at most 4 characters.
970
+ *
971
+ * @experimental The plugin API may change in minor releases.
972
+ */
973
+ type XlsxPluginRowDecoration = {
974
+ id: string;
975
+ sheetId: string;
976
+ row: number;
977
+ kind: 'badge' | 'dot';
978
+ text?: string;
979
+ tone?: 'neutral' | 'info' | 'success' | 'warning' | 'danger';
980
+ tooltip?: string;
981
+ };
982
+ /**
983
+ * Row markers computed at a document `version`; shown only while the workbook is at it.
984
+ *
985
+ * @experimental The plugin API may change in minor releases.
986
+ */
987
+ type XlsxPluginRowDecorations = {
988
+ version: string;
989
+ items: readonly XlsxPluginRowDecoration[];
990
+ };
736
991
  declare const xlsxPluginBrand: unique symbol;
737
992
  /**
738
993
  * An installable plugin, created by `defineXlsxPlugin`.
@@ -744,7 +999,7 @@ interface XlsxPlugin {
744
999
  readonly revision?: string | number;
745
1000
  readonly [xlsxPluginBrand]: true;
746
1001
  }
747
- type XlsxPluginErrorPhase = PluginErrorPhase;
1002
+ type XlsxPluginErrorPhase = PluginErrorPhase | 'edit-gate' | 'row-decorations';
748
1003
  /**
749
1004
  * A plugin failure; the failing activation has already been stopped and cleaned up.
750
1005
  *
@@ -765,6 +1020,19 @@ interface XlsxEditorPluginProps {
765
1020
  onPluginError?(error: XlsxPluginError): void;
766
1021
  }
767
1022
 
1023
+ declare const LEGACY_SYNC_API: "legacySyncApi";
1024
+
1025
+ /** Why work queued behind accepted input could not run. */
1026
+ type XlsxCommandAdmissionCode = Extract<XlsxCommandFailureCode, 'input-failed' | 'edit-unsupported' | 'sheet-protected' | 'host-refused' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'editor-unavailable'>;
1027
+ /**
1028
+ * Raised when work queued behind accepted input cannot run: a command, or a version, read or
1029
+ * edit-batch call of the editor API.
1030
+ */
1031
+ declare class XlsxCommandAdmissionError extends Error {
1032
+ readonly code: XlsxCommandAdmissionCode;
1033
+ constructor(code: XlsxCommandAdmissionCode);
1034
+ }
1035
+
768
1036
  declare class WorkerInputNotReadyError extends Error {
769
1037
  constructor();
770
1038
  }
@@ -778,7 +1046,13 @@ declare class XlsxWorkerEditorCollaborationError extends Error {
778
1046
  readonly code = "collaboration-unavailable";
779
1047
  constructor();
780
1048
  }
781
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorApi. */
1049
+ declare class XlsxWorkerSessionFailedError extends Error {
1050
+ readonly cause: unknown;
1051
+ readonly code = "worker-session-failed";
1052
+ constructor(cause: unknown);
1053
+ }
1054
+
1055
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorApi. */
782
1056
  interface XlsxWorkerEditorApi extends Omit<XlsxWorkerViewerApi, 'save' | 'selectCells'> {
783
1057
  readonly hydrated: boolean;
784
1058
  readonly failure: Error | null;
@@ -799,12 +1073,6 @@ interface XlsxWorkerEditorApi extends Omit<XlsxWorkerViewerApi, 'save' | 'select
799
1073
  editCellAsync(sheet: number, row: number, col: number, input: string): Promise<EditResult | null>;
800
1074
  }
801
1075
 
802
- declare class XlsxWorkerSessionFailedError extends Error {
803
- readonly cause: unknown;
804
- readonly code = "worker-session-failed";
805
- constructor(cause: unknown);
806
- }
807
-
808
1076
  declare class XlsxAsyncApiSyncAccessError extends Error {
809
1077
  readonly member: string;
810
1078
  readonly alternative: string;
@@ -851,27 +1119,16 @@ interface XlsxAsyncEditorApi {
851
1119
  save(): Promise<Uint8Array>;
852
1120
  readonly commands: XlsxCommandStore;
853
1121
  readonly collaboration: AsyncCollaborationReplica | null;
854
- /** Stages tracked cell edits after pending input drains; available on worker editors. */
1122
+ /** Stages tracked cell edits after pending input drains. */
855
1123
  proposeChanges?(request: XlsxProposalRequest): Promise<XlsxProposalResult>;
856
1124
  focus(): void;
857
- renderPng(...args: Parameters<WorkbookHandle['renderPng']>): Promise<ReturnType<WorkbookHandle['renderPng']>>;
858
- renderRangePng(...args: Parameters<WorkbookHandle['renderRangePng']>): Promise<ReturnType<WorkbookHandle['renderRangePng']>>;
1125
+ /** Draws a viewport or a cell range of a sheet as PNG bytes, after pending input. */
1126
+ renderPng(target: XlsxPngTarget, options?: XlsxPngOptions): Promise<Uint8Array>;
859
1127
  exportStructured(...args: Parameters<WorkbookHandle['exportStructured']>): Promise<ReturnType<WorkbookHandle['exportStructured']>>;
860
1128
  exportMarkdown(...args: Parameters<WorkbookHandle['exportMarkdown']>): Promise<ReturnType<WorkbookHandle['exportMarkdown']>>;
861
1129
  printDisplayList(...args: Parameters<WorkbookHandle['printDisplayList']>): Promise<ReturnType<WorkbookHandle['printDisplayList']>>;
862
1130
  }
863
1131
 
864
- declare const LEGACY_SYNC_API: "legacySyncApi";
865
-
866
- /**
867
- * `<XlsxEditor />` — the editor shell. A dpr-aware canvas paints the grid; DOM
868
- * overlays (selection marquee, active-cell outline, in-cell editor) sit above it,
869
- * positioned from the same display-list geometry the painter uses. A top bar
870
- * holds the name box, formula bar, and save/undo/redo; an offscreen `role=grid`
871
- * mirror serves screen readers. All compute lives in `@betteroffice/xlsx`; this
872
- * layer is framework glue — keyboard/mouse wiring, focus flow, and DOM chrome.
873
- */
874
-
875
1132
  interface XlsxPointPosition {
876
1133
  sheet: number;
877
1134
  row: number;
@@ -888,7 +1145,7 @@ interface XlsxPointPosition {
888
1145
  * with {@link XlsxCommandAdmissionError}: `input-failed` while a refused entry
889
1146
  * waits for correction or earlier input failed, `gesture-active` during a chart
890
1147
  * drag, and `document-replaced` when the workbook is replaced meanwhile.
891
- * @deprecated Removed in 0.6.0. Use XlsxAsyncEditorApi.
1148
+ * @deprecated Removed in 0.7.0. Use XlsxAsyncEditorApi.
892
1149
  */
893
1150
  interface XlsxEditorApi {
894
1151
  flushPendingInput: () => Promise<void>;
@@ -910,6 +1167,7 @@ interface XlsxEditorApi {
910
1167
  focus: () => void;
911
1168
  handle: WorkbookHandle;
912
1169
  refreshProposals: () => void;
1170
+ proposeChanges?(request: XlsxProposalRequest): Promise<XlsxProposalResult>;
913
1171
  /**
914
1172
  * Writes the open cell entry and returns the workbook bytes at once. Throws
915
1173
  * {@link XlsxSaveRefusedError} rather than return bytes without accepted
@@ -939,7 +1197,7 @@ interface XlsxEditorApi {
939
1197
  */
940
1198
  applyEdits: (request: XlsxEditRequest) => Promise<XlsxEditResult>;
941
1199
  }
942
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorApi. */
1200
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorApi. */
943
1201
  interface XlsxWorkerViewerApi extends Omit<XlsxEditorApi, 'handle' | 'save' | 'selectCells' | 'version' | 'readCells' | 'findText' | 'validateEdits' | 'applyEdits'> {
944
1202
  handle: null;
945
1203
  save: () => null;
@@ -952,11 +1210,6 @@ interface XlsxWorkerViewerApi extends Omit<XlsxEditorApi, 'handle' | 'save' | 's
952
1210
  validateEdits: (request: XlsxEditRequest) => Promise<XlsxValidationResult | null>;
953
1211
  applyEdits: (request: XlsxEditRequest) => Promise<XlsxEditResult | null>;
954
1212
  }
955
- /** Why a synchronous {@link XlsxEditorApi.save} did not return bytes. */
956
- declare class XlsxSaveRefusedError extends Error {
957
- readonly code: 'input-pending' | 'input-failed';
958
- constructor(code: 'input-pending' | 'input-failed');
959
- }
960
1213
  interface XlsxEditorCollaborationOptions {
961
1214
  /** Peer-unique Yrs client ID. Generated securely when omitted. */
962
1215
  clientId?: number;
@@ -977,13 +1230,20 @@ interface XlsxHostProps {
977
1230
  downloadOnSave?: boolean;
978
1231
  /** Initial scale, clamped to the supported zoom range. Defaults to 1. */
979
1232
  initialZoom?: number;
980
- /** Rendered while a supplied file is opening. */
1233
+ /** Shown while a supplied file opens. Until the editor's code has loaded it is shown in normal flow, as before. Once the editor has mounted it is shown over the grid area, in an overlay whose size does not affect the editor's layout; there it is not interactive by default: pointer input passes through it to the grid, and a control inside it that re-enables pointer input takes that input instead of the grid. */
981
1234
  loadingIndicator?: React.ReactNode;
982
1235
  /** Inline style overrides for the editor root. */
983
1236
  style?: React.CSSProperties;
984
1237
  }
985
1238
  /** Props for XlsxEditor. */
986
1239
  interface XlsxInThreadEditorProps extends XlsxEditorPluginProps, XlsxHostProps {
1240
+ /** Load bundled workbook fonts. Defaults to true. */
1241
+ defaultFonts?: boolean;
1242
+ /**
1243
+ * Where fonts with no bundled metric-compatible face are fetched from. Defaults to `'bunny'`
1244
+ * (fonts.bunny.net); `'off'` never fetches.
1245
+ */
1246
+ remoteFonts?: RemoteFontProvider;
987
1247
  /** @deprecated False selects the in-thread engine. */
988
1248
  experimentalWorkerOpen?: false;
989
1249
  onError?: (error: Error) => void;
@@ -1001,7 +1261,7 @@ interface XlsxInThreadEditorProps extends XlsxEditorPluginProps, XlsxHostProps {
1001
1261
  collaboration?: XlsxEditorCollaborationOptions;
1002
1262
  i18n?: Translations;
1003
1263
  /**
1004
- * Called when a workbook opens, with a handle to stage agent proposals and a
1264
+ * Called once an opened workbook's first frame is painted, with a handle to stage agent proposals and a
1005
1265
  * way to refresh the panel afterward. Enables demo/host agents without
1006
1266
  * exposing the wasm object through the render tree. A returned cleanup runs
1007
1267
  * before the workbook is replaced or disposed.
@@ -1010,6 +1270,11 @@ interface XlsxInThreadEditorProps extends XlsxEditorPluginProps, XlsxHostProps {
1010
1270
  className?: string;
1011
1271
  /** Blocks user edits; navigation and selection remain available. */
1012
1272
  readOnly?: boolean;
1273
+ /** Whether to show the column and row header bands. Defaults to false. */
1274
+ showSheetHeaders?: boolean;
1275
+ /** Shows the fill handle on the selection corner. */
1276
+ fillHandle?: boolean;
1277
+ allowHostProposals?: boolean;
1013
1278
  /**
1014
1279
  * Replaces the default toolbar: omitted keeps it (hidden when read-only),
1015
1280
  * `null` removes it, and supplied chrome renders instead, also when
@@ -1019,10 +1284,21 @@ interface XlsxInThreadEditorProps extends XlsxEditorPluginProps, XlsxHostProps {
1019
1284
  toolbar?: React.ReactNode;
1020
1285
  /** `false` hides the toolbar region, whatever `toolbar` is. */
1021
1286
  showToolbar?: boolean;
1287
+ /**
1288
+ * Remaps or disables keyboard shortcuts; menus and tooltips follow.
1289
+ * @experimental
1290
+ */
1291
+ shortcuts?: XlsxShortcuts;
1292
+ /**
1293
+ * Reports each entry of `shortcuts` that was refused, and each default a host chord displaced.
1294
+ * Without it, refusals are logged in development builds.
1295
+ * @experimental
1296
+ */
1297
+ onShortcutIssue?: (issue: ShortcutIssue) => void;
1022
1298
  }
1023
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorProps. */
1299
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorProps. */
1024
1300
  type XlsxWorkerViewerProps = Omit<XlsxInThreadEditorProps, 'onReady' | 'readOnly' | 'collaboration' | 'experimentalWorkerOpen' | keyof XlsxHostProps> & {
1025
- /** @deprecated Removed in 0.6.0. Omit for the async editor. */
1301
+ /** @deprecated Removed in 0.7.0. Omit for the async editor. */
1026
1302
  [LEGACY_SYNC_API]: true;
1027
1303
  readOnly: true;
1028
1304
  collaboration?: undefined;
@@ -1030,21 +1306,21 @@ type XlsxWorkerViewerProps = Omit<XlsxInThreadEditorProps, 'onReady' | 'readOnly
1030
1306
  experimentalWorkerOpen: true;
1031
1307
  onReady?: (api: XlsxWorkerViewerApi) => void | (() => void);
1032
1308
  };
1033
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorProps. */
1309
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorProps. */
1034
1310
  type XlsxWorkerEditorProps = Omit<XlsxWorkerViewerProps, 'onReady' | 'readOnly'> & {
1035
1311
  readOnly?: false;
1036
1312
  onReady?: (api: XlsxWorkerEditorApi) => void | (() => void);
1037
1313
  };
1038
1314
  type XlsxAsyncEditorProps = Omit<XlsxInThreadEditorProps, 'onReady' | 'experimentalWorkerOpen'> & {
1039
- /** @deprecated Removed in 0.6.0. Omit for the async editor. */
1315
+ /** @deprecated Removed in 0.7.0. Omit for the async editor. */
1040
1316
  [LEGACY_SYNC_API]?: false;
1041
1317
  /** @deprecated False selects the in-thread engine. */
1042
1318
  experimentalWorkerOpen?: boolean;
1043
1319
  onReady?: (api: XlsxAsyncEditorApi) => void | (() => void);
1044
1320
  };
1045
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorProps. */
1321
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorProps. */
1046
1322
  type XlsxLegacyEditorProps = Omit<XlsxInThreadEditorProps, keyof XlsxHostProps> & {
1047
- /** @deprecated Removed in 0.6.0. Omit for the async editor. */
1323
+ /** @deprecated Removed in 0.7.0. Omit for the async editor. */
1048
1324
  [LEGACY_SYNC_API]: true;
1049
1325
  };
1050
1326
  type WorkerSessionProps = Omit<XlsxWorkerEditorProps, 'readOnly' | 'onReady'> & {
@@ -1056,6 +1332,21 @@ type GeneralEditorSessionProps = Omit<XlsxLegacyEditorProps, 'experimentalWorker
1056
1332
  onReady?: (api: XlsxEditorApi | XlsxWorkerEditorApi | XlsxWorkerViewerApi) => void | (() => void);
1057
1333
  };
1058
1334
  type XlsxEditorProps = XlsxAsyncEditorProps | GeneralEditorSessionProps;
1335
+
1336
+ /** Why a synchronous {@link XlsxEditorApi.save} did not return bytes. */
1337
+ declare class XlsxSaveRefusedError extends Error {
1338
+ readonly code: 'input-pending' | 'input-failed';
1339
+ constructor(code: 'input-pending' | 'input-failed');
1340
+ }
1341
+
1342
+ /**
1343
+ * `<XlsxEditor />`: the editor shell. A dpr-aware canvas paints the grid; DOM
1344
+ * overlays (selection marquee, active-cell outline, in-cell editor) sit above it,
1345
+ * positioned from the same display-list geometry the painter uses. A top bar
1346
+ * holds the name box, formula bar, and save/undo/redo; an offscreen `role=grid`
1347
+ * mirror serves screen readers. All compute lives in `@betteroffice/xlsx`; this
1348
+ * layer is framework glue: keyboard/mouse wiring, focus flow, and DOM chrome.
1349
+ */
1059
1350
  declare function XlsxEditor(props: XlsxAsyncEditorProps): React.JSX.Element;
1060
1351
  declare function XlsxEditor(props: XlsxLegacyEditorProps): React.JSX.Element;
1061
1352
  declare function XlsxEditor(props: XlsxWorkerViewerProps): React.JSX.Element;
@@ -1163,6 +1454,7 @@ interface LocaleProviderProps {
1163
1454
  declare function LocaleProvider({ i18n, children }: LocaleProviderProps): react.JSX.Element;
1164
1455
  declare function useTranslation(): {
1165
1456
  t: TFunction;
1457
+ lang: string;
1166
1458
  };
1167
1459
 
1168
1460
  /** @experimental */
@@ -1200,6 +1492,8 @@ interface XlsxBoundCommand<K extends XlsxCommandId> {
1200
1492
  /** The label for the bound arguments, such as "Format as currency". */
1201
1493
  label: string;
1202
1494
  shortcut: string | null;
1495
+ /** The shortcut in `aria-keyshortcuts` form. */
1496
+ ariaShortcut: string | null;
1203
1497
  /** Executes with `args`, falling back to the arguments bound to the hook. */
1204
1498
  execute(args?: XlsxCommandArgs[K]): Promise<XlsxCommandResult>;
1205
1499
  }
@@ -1215,6 +1509,8 @@ interface XlsxBoundPluginCommand {
1215
1509
  /** The contributed label, or the id while no plugin contributes it. */
1216
1510
  label: string;
1217
1511
  shortcut: string | null;
1512
+ /** The shortcut in `aria-keyshortcuts` form. */
1513
+ ariaShortcut: string | null;
1218
1514
  execute(): Promise<XlsxPluginCommandResult>;
1219
1515
  }
1220
1516
  /**
@@ -1312,4 +1608,4 @@ declare function defineXlsxPlugin<S>(definition: XlsxPluginDefinition<S>): XlsxP
1312
1608
  */
1313
1609
  declare function XlsxPluginToolbar(): React.ReactElement | null;
1314
1610
 
1315
- export { type BorderPreset, type BorderStyle, type CommandReason, type CommandState, EditorToolbar, EditorToolbarContext, type EditorToolbarProps, type FormattingAction, type FormulaBarProps, type HorizontalAlignment, type JsonValue, LocaleProvider, type LocaleProviderProps, type MaybePromise, type MergeAction, type NumberFormat, type PluginCleanupReason, type PluginGrant, type PluginLoadReason, type SelectionFormatting, type SelectionShape, type TextWrapping, Toolbar, ToolbarButton, type ToolbarButtonProps, ToolbarCommand, type ToolbarCommandArgs, ToolbarCommandButton, type ToolbarCommandButtonProps, type ToolbarCommandProps, ToolbarCommandSelect, type ToolbarCommandSelectProps, ToolbarDropdown, type ToolbarDropdownProps, ToolbarGroup, ToolbarMenuItem, type ToolbarMenuItemProps, ToolbarMenuSeparator, type ToolbarMode, ToolbarOverflow, type ToolbarOverflowProps, type ToolbarProps, ToolbarSeparator, type VerticalAlignment, XlsxAsyncApiSyncAccessError, type XlsxAsyncEditorApi, type XlsxAsyncEditorProps, type XlsxBoundCommand, type XlsxBoundPluginCommand, type XlsxCommandAdmissionCode, XlsxCommandAdmissionError, type XlsxCommandArgs, type XlsxCommandDescriptor, type XlsxCommandDisabledCode, type XlsxCommandFailureCode, type XlsxCommandId, type XlsxCommandOption, XlsxCommandProvider, type XlsxCommandProviderProps, type XlsxCommandResult, type XlsxCommandShortcut, type XlsxCommandState, type XlsxCommandStatus, type XlsxCommandStore, type XlsxCommandValues, type XlsxDocumentChange, XlsxEditor, type XlsxEditorApi, type XlsxEditorCollaborationOptions, type XlsxEditorPluginProps, type XlsxEditorProps, type XlsxInThreadEditorProps, type XlsxLegacyEditorProps, type XlsxNumberFormatValue, XlsxPeerNotReadyError, type XlsxPlugin, type XlsxPluginCellPosition, type XlsxPluginCommand, type XlsxPluginCommandClient, type XlsxPluginCommandDescriptor, type XlsxPluginCommandId, type XlsxPluginCommandResult, type XlsxPluginCommandState, type XlsxPluginContext, type XlsxPluginDefinition, type XlsxPluginEditClient, type XlsxPluginError, type XlsxPluginErrorPhase, type XlsxPluginEvent, type XlsxPluginFailureCode, type XlsxPluginGeometry, type XlsxPluginGrant, type XlsxPluginLayout, type XlsxPluginNavigation, type XlsxPluginNavigationFailureCode, type XlsxPluginNavigationOptions, type XlsxPluginNavigationResult, type XlsxPluginPanel, type XlsxPluginReadClient, type XlsxPluginRect, type XlsxPluginRefusal, type XlsxPluginSelection, type XlsxPluginSnapshot, XlsxPluginToolbar, type XlsxPointPosition, type XlsxProposalRequest, type XlsxProposalResult, XlsxSaveRefusedError, type XlsxSelectCommandId, Toolbar as XlsxToolbar, type XlsxWorkerEditorApi, XlsxWorkerEditorChunkLoadError, XlsxWorkerEditorCollaborationError, type XlsxWorkerEditorProps, XlsxWorkerSessionFailedError, type XlsxWorkerViewerApi, type XlsxWorkerViewerProps, defineXlsxPlugin, useEditorToolbar, useTranslation, useXlsxCommand, useXlsxCommandState, useXlsxCommands };
1611
+ export { type BorderPreset, type BorderStyle, type CommandReason, type CommandState, EditorToolbar, EditorToolbarContext, type EditorToolbarProps, type FormattingAction, type FormulaBarProps, type HorizontalAlignment, type JsonValue, LocaleProvider, type LocaleProviderProps, type MaybePromise, type MergeAction, type NumberFormat, type PluginCleanupReason, type PluginGrant, type PluginLoadReason, type ResolvedShortcuts, type SelectionFormatting, type SelectionShape, type ShortcutBinding, type ShortcutChord, type ShortcutIssue, type TextWrapping, Toolbar, ToolbarButton, type ToolbarButtonProps, ToolbarCommand, type ToolbarCommandArgs, ToolbarCommandButton, type ToolbarCommandButtonProps, type ToolbarCommandProps, ToolbarCommandSelect, type ToolbarCommandSelectProps, ToolbarDropdown, type ToolbarDropdownProps, ToolbarGroup, ToolbarMenuItem, type ToolbarMenuItemProps, ToolbarMenuSeparator, type ToolbarMode, ToolbarOverflow, type ToolbarOverflowProps, type ToolbarProps, ToolbarSeparator, type VerticalAlignment, type XlsxAnchorGeometryResult, XlsxAsyncApiSyncAccessError, type XlsxAsyncEditorApi, type XlsxAsyncEditorProps, type XlsxBoundCommand, type XlsxBoundPluginCommand, type XlsxCommandAdmissionCode, XlsxCommandAdmissionError, type XlsxCommandArgs, type XlsxCommandDescriptor, type XlsxCommandDisabledCode, type XlsxCommandFailureCode, type XlsxCommandId, type XlsxCommandOption, XlsxCommandProvider, type XlsxCommandProviderProps, type XlsxCommandResult, type XlsxCommandShortcut, type XlsxCommandState, type XlsxCommandStatus, type XlsxCommandStore, type XlsxCommandValues, type XlsxDocumentChange, XlsxEditor, type XlsxEditorApi, type XlsxEditorCollaborationOptions, type XlsxEditorPluginProps, type XlsxEditorProps, type XlsxGeometryTarget, type XlsxInThreadEditorProps, type XlsxLegacyEditorProps, type XlsxNumberFormatValue, XlsxPeerNotReadyError, type XlsxPlugin, type XlsxPluginCellCommit, type XlsxPluginCellPosition, type XlsxPluginCellRef, type XlsxPluginCommand, type XlsxPluginCommandClient, type XlsxPluginCommandDescriptor, type XlsxPluginCommandId, type XlsxPluginCommandResult, type XlsxPluginCommandState, type XlsxPluginCommitDecision, type XlsxPluginContext, type XlsxPluginDefinition, type XlsxPluginEditClient, type XlsxPluginEditGateContext, type XlsxPluginError, type XlsxPluginErrorPhase, type XlsxPluginEvent, type XlsxPluginFailureCode, type XlsxPluginFocusChangeEvent, type XlsxPluginGeometry, type XlsxPluginGrant, type XlsxPluginLayout, type XlsxPluginLocaleChangeEvent, type XlsxPluginNavigation, type XlsxPluginNavigationFailureCode, type XlsxPluginNavigationOptions, type XlsxPluginNavigationResult, type XlsxPluginPanel, type XlsxPluginReadClient, type XlsxPluginRect, type XlsxPluginRefusal, type XlsxPluginRowDecoration, type XlsxPluginRowDecorations, type XlsxPluginSelection, type XlsxPluginSelectionSettleEvent, type XlsxPluginSnapshot, XlsxPluginToolbar, type XlsxPointPosition, type XlsxProposalRequest, type XlsxProposalResult, XlsxSaveRefusedError, type XlsxSelectCommandId, type XlsxShortcutId, type XlsxShortcuts, Toolbar as XlsxToolbar, type XlsxWorkerEditorApi, XlsxWorkerEditorChunkLoadError, XlsxWorkerEditorCollaborationError, type XlsxWorkerEditorProps, XlsxWorkerSessionFailedError, type XlsxWorkerViewerApi, type XlsxWorkerViewerProps, defineXlsxPlugin, useEditorToolbar, useTranslation, useXlsxCommand, useXlsxCommandState, useXlsxCommands };