@betteroffice/xlsx-react 0.5.0 → 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,4 +1,6 @@
1
- import { XlsxEditRefusal, Selection, XlsxReadRequest, XlsxReadResult, XlsxFindRequest, XlsxFindResult, XlsxEditRequest, XlsxValidationResult, XlsxEditResult, CellRange, CellEdit, EditResult, ProposalEdit, Proposal, WorkbookHandle } 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';
2
4
  import { AsyncCollaborationReplica, CollaborationReplica, CollaborationAwareness } from '@betteroffice/xlsx/collaboration';
3
5
  import { TranslationKey, Translations, TFunction } from '@betteroffice/xlsx-i18n';
4
6
  import * as react from 'react';
@@ -91,6 +93,26 @@ type PluginCommandResult<Status extends string = string, Refusal extends {
91
93
  ok: false;
92
94
  failure: CommandReason;
93
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
+ }
94
116
 
95
117
  /**
96
118
  * How a toolbar gets its state: `'legacy'` from props and callbacks,
@@ -256,6 +278,7 @@ interface XlsxCommandArgs {
256
278
  value: TextWrapping;
257
279
  };
258
280
  searchMenus: null;
281
+ findReplace: null;
259
282
  save: null;
260
283
  exportPng: null;
261
284
  print: null;
@@ -277,6 +300,34 @@ interface XlsxCommandArgs {
277
300
  proposalReject: {
278
301
  proposalId: string;
279
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
+ };
280
331
  }
281
332
  /** @experimental */
282
333
  type XlsxCommandId = keyof XlsxCommandArgs;
@@ -325,6 +376,7 @@ interface XlsxCommandValues {
325
376
  verticalAlignment: VerticalAlignment | null;
326
377
  textWrapping: TextWrapping | null;
327
378
  searchMenus: null;
379
+ findReplace: null;
328
380
  save: null;
329
381
  exportPng: null;
330
382
  print: null;
@@ -335,17 +387,30 @@ interface XlsxCommandValues {
335
387
  proposalsPanel: number;
336
388
  proposalAccept: null;
337
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;
338
403
  }
339
404
  /**
340
405
  * Why a command is unavailable.
341
406
  * @experimental
342
407
  */
343
- 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';
344
409
  /**
345
410
  * Why an executed command did not complete.
346
411
  * @experimental
347
412
  */
348
- 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';
349
414
  /**
350
415
  * One choice of a selector command.
351
416
  * @experimental
@@ -444,17 +509,60 @@ interface XlsxCommandStore {
444
509
  execute(id: XlsxPluginCommandId, args: null): Promise<XlsxPluginCommandResult>;
445
510
  }
446
511
 
447
- /** Why work queued behind accepted input could not run. */
448
- type XlsxCommandAdmissionCode = Extract<XlsxCommandFailureCode, 'input-failed' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'editor-unavailable'>;
449
512
  /**
450
- * Raised when work queued behind accepted input cannot run: a command, or a version, read or
451
- * 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
452
516
  */
453
- declare class XlsxCommandAdmissionError extends Error {
454
- readonly code: XlsxCommandAdmissionCode;
455
- 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[];
456
546
  }
457
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
+
458
566
  /**
459
567
  * What the host lets one plugin do. Without a grant a plugin reads, validates and navigates only.
460
568
  * Built-in commands need their id listed and, when they mutate, `document: 'write'`; edit
@@ -534,21 +642,51 @@ interface XlsxPluginLayout {
534
642
  height: number;
535
643
  };
536
644
  }
537
- /** A cell under the pointer, with the layout it was resolved against. */
538
- 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 {
539
650
  sheetId: string;
540
651
  row: number;
541
652
  col: number;
542
653
  version: string;
543
654
  layoutId: string;
544
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
+ };
545
679
  /**
546
680
  * Geometry of the painted grid. Rectangles are in pixels of the overlay layer, already zoomed
547
- * and clipped to the visible grid; every method returns null once its layout is no longer
548
- * 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.
549
684
  */
550
685
  interface XlsxPluginGeometry {
551
686
  layout: XlsxPluginLayout;
687
+ getAnchorGeometry(target: XlsxGeometryTarget): XlsxAnchorGeometryResult;
688
+ /** @experimental Reads every target in order. */
689
+ readAnchorGeometries(targets: readonly XlsxGeometryTarget[]): Promise<XlsxAnchorGeometryResult[]>;
552
690
  /** One grid cell, without merge expansion; zero-based `row` and `col`. */
553
691
  getCellRect(target: {
554
692
  sheetId: string;
@@ -560,7 +698,12 @@ interface XlsxPluginGeometry {
560
698
  sheetId: string;
561
699
  range: CellRange;
562
700
  }): XlsxPluginRect | null;
563
- /** 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
+ */
564
707
  getPositionAtPoint: ((clientX: number, clientY: number) => XlsxPluginCellPosition | null) | null;
565
708
  }
566
709
  /** The active sheet and what is selected on it; ids are session-scoped. */
@@ -574,12 +717,18 @@ type XlsxPluginSelection = {
574
717
  chartId: string | null;
575
718
  } | null;
576
719
  interface XlsxPluginSnapshot {
720
+ /** @experimental Focus inside the document surface. */
721
+ focused: boolean;
722
+ /** @experimental The editor's resolved locale tag. */
723
+ locale: string;
577
724
  /** The open workbook; changes when a workbook replaces it. */
578
725
  generation: string;
579
726
  version: string;
580
727
  readOnly: boolean;
581
728
  grant: XlsxPluginGrant;
582
729
  selection: XlsxPluginSelection;
730
+ /** @experimental Whether the selection has finished changing. */
731
+ selectionSettled: boolean;
583
732
  /** Null while no painted frame shows `version`. */
584
733
  layout: XlsxPluginLayout | null;
585
734
  }
@@ -626,8 +775,14 @@ interface XlsxPluginNavigation {
626
775
  align?: 'nearest' | 'start' | 'center';
627
776
  }): Promise<XlsxPluginNavigationResult>;
628
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>;
629
784
  /** Lifecycle notifications describe current state; several changes may arrive as one. */
630
- type XlsxPluginEvent = {
785
+ type XlsxPluginEvent = XlsxPluginSelectionSettleEvent | XlsxPluginFocusChangeEvent | XlsxPluginLocaleChangeEvent | {
631
786
  type: 'load';
632
787
  generation: string;
633
788
  version: string;
@@ -636,6 +791,11 @@ type XlsxPluginEvent = {
636
791
  type: 'document-change';
637
792
  generation: string;
638
793
  version: string;
794
+ } | {
795
+ type: 'proposal-change';
796
+ generation: string;
797
+ version: string;
798
+ previewVersion: number;
639
799
  } | {
640
800
  type: 'selection-change';
641
801
  generation: string;
@@ -653,6 +813,18 @@ type XlsxPluginEvent = {
653
813
  type: 'grants-change';
654
814
  generation: string;
655
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;
656
828
  };
657
829
  /**
658
830
  * What a hook, renderer or action receives. Clients refuse once it is superseded or ended.
@@ -711,8 +883,45 @@ interface XlsxPluginCommand<S> {
711
883
  execute(context: XlsxPluginContext<S>): MaybePromise<XlsxPluginCommandResult>;
712
884
  }
713
885
  /**
714
- * A plugin. `createState`, renderers and command `getState` must be pure; `initialize`,
715
- * `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.
716
925
  *
717
926
  * @experimental The plugin API may change in minor releases.
718
927
  */
@@ -731,7 +940,54 @@ interface XlsxPluginDefinition<S> {
731
940
  commands?: readonly XlsxPluginCommand<S>[];
732
941
  /** Local command ids, in display order. */
733
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;
734
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
+ };
735
991
  declare const xlsxPluginBrand: unique symbol;
736
992
  /**
737
993
  * An installable plugin, created by `defineXlsxPlugin`.
@@ -743,7 +999,7 @@ interface XlsxPlugin {
743
999
  readonly revision?: string | number;
744
1000
  readonly [xlsxPluginBrand]: true;
745
1001
  }
746
- type XlsxPluginErrorPhase = PluginErrorPhase;
1002
+ type XlsxPluginErrorPhase = PluginErrorPhase | 'edit-gate' | 'row-decorations';
747
1003
  /**
748
1004
  * A plugin failure; the failing activation has already been stopped and cleaned up.
749
1005
  *
@@ -764,6 +1020,19 @@ interface XlsxEditorPluginProps {
764
1020
  onPluginError?(error: XlsxPluginError): void;
765
1021
  }
766
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
+
767
1036
  declare class WorkerInputNotReadyError extends Error {
768
1037
  constructor();
769
1038
  }
@@ -777,7 +1046,13 @@ declare class XlsxWorkerEditorCollaborationError extends Error {
777
1046
  readonly code = "collaboration-unavailable";
778
1047
  constructor();
779
1048
  }
780
- /** @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. */
781
1056
  interface XlsxWorkerEditorApi extends Omit<XlsxWorkerViewerApi, 'save' | 'selectCells'> {
782
1057
  readonly hydrated: boolean;
783
1058
  readonly failure: Error | null;
@@ -798,12 +1073,6 @@ interface XlsxWorkerEditorApi extends Omit<XlsxWorkerViewerApi, 'save' | 'select
798
1073
  editCellAsync(sheet: number, row: number, col: number, input: string): Promise<EditResult | null>;
799
1074
  }
800
1075
 
801
- declare class XlsxWorkerSessionFailedError extends Error {
802
- readonly cause: unknown;
803
- readonly code = "worker-session-failed";
804
- constructor(cause: unknown);
805
- }
806
-
807
1076
  declare class XlsxAsyncApiSyncAccessError extends Error {
808
1077
  readonly member: string;
809
1078
  readonly alternative: string;
@@ -850,27 +1119,16 @@ interface XlsxAsyncEditorApi {
850
1119
  save(): Promise<Uint8Array>;
851
1120
  readonly commands: XlsxCommandStore;
852
1121
  readonly collaboration: AsyncCollaborationReplica | null;
853
- /** Stages tracked cell edits after pending input drains; available on worker editors. */
1122
+ /** Stages tracked cell edits after pending input drains. */
854
1123
  proposeChanges?(request: XlsxProposalRequest): Promise<XlsxProposalResult>;
855
1124
  focus(): void;
856
- renderPng(...args: Parameters<WorkbookHandle['renderPng']>): Promise<ReturnType<WorkbookHandle['renderPng']>>;
857
- 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>;
858
1127
  exportStructured(...args: Parameters<WorkbookHandle['exportStructured']>): Promise<ReturnType<WorkbookHandle['exportStructured']>>;
859
1128
  exportMarkdown(...args: Parameters<WorkbookHandle['exportMarkdown']>): Promise<ReturnType<WorkbookHandle['exportMarkdown']>>;
860
1129
  printDisplayList(...args: Parameters<WorkbookHandle['printDisplayList']>): Promise<ReturnType<WorkbookHandle['printDisplayList']>>;
861
1130
  }
862
1131
 
863
- declare const LEGACY_SYNC_API: "legacySyncApi";
864
-
865
- /**
866
- * `<XlsxEditor />` — the editor shell. A dpr-aware canvas paints the grid; DOM
867
- * overlays (selection marquee, active-cell outline, in-cell editor) sit above it,
868
- * positioned from the same display-list geometry the painter uses. A top bar
869
- * holds the name box, formula bar, and save/undo/redo; an offscreen `role=grid`
870
- * mirror serves screen readers. All compute lives in `@betteroffice/xlsx`; this
871
- * layer is framework glue — keyboard/mouse wiring, focus flow, and DOM chrome.
872
- */
873
-
874
1132
  interface XlsxPointPosition {
875
1133
  sheet: number;
876
1134
  row: number;
@@ -887,7 +1145,7 @@ interface XlsxPointPosition {
887
1145
  * with {@link XlsxCommandAdmissionError}: `input-failed` while a refused entry
888
1146
  * waits for correction or earlier input failed, `gesture-active` during a chart
889
1147
  * drag, and `document-replaced` when the workbook is replaced meanwhile.
890
- * @deprecated Removed in 0.6.0. Use XlsxAsyncEditorApi.
1148
+ * @deprecated Removed in 0.7.0. Use XlsxAsyncEditorApi.
891
1149
  */
892
1150
  interface XlsxEditorApi {
893
1151
  flushPendingInput: () => Promise<void>;
@@ -909,6 +1167,7 @@ interface XlsxEditorApi {
909
1167
  focus: () => void;
910
1168
  handle: WorkbookHandle;
911
1169
  refreshProposals: () => void;
1170
+ proposeChanges?(request: XlsxProposalRequest): Promise<XlsxProposalResult>;
912
1171
  /**
913
1172
  * Writes the open cell entry and returns the workbook bytes at once. Throws
914
1173
  * {@link XlsxSaveRefusedError} rather than return bytes without accepted
@@ -938,7 +1197,7 @@ interface XlsxEditorApi {
938
1197
  */
939
1198
  applyEdits: (request: XlsxEditRequest) => Promise<XlsxEditResult>;
940
1199
  }
941
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorApi. */
1200
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorApi. */
942
1201
  interface XlsxWorkerViewerApi extends Omit<XlsxEditorApi, 'handle' | 'save' | 'selectCells' | 'version' | 'readCells' | 'findText' | 'validateEdits' | 'applyEdits'> {
943
1202
  handle: null;
944
1203
  save: () => null;
@@ -951,11 +1210,6 @@ interface XlsxWorkerViewerApi extends Omit<XlsxEditorApi, 'handle' | 'save' | 's
951
1210
  validateEdits: (request: XlsxEditRequest) => Promise<XlsxValidationResult | null>;
952
1211
  applyEdits: (request: XlsxEditRequest) => Promise<XlsxEditResult | null>;
953
1212
  }
954
- /** Why a synchronous {@link XlsxEditorApi.save} did not return bytes. */
955
- declare class XlsxSaveRefusedError extends Error {
956
- readonly code: 'input-pending' | 'input-failed';
957
- constructor(code: 'input-pending' | 'input-failed');
958
- }
959
1213
  interface XlsxEditorCollaborationOptions {
960
1214
  /** Peer-unique Yrs client ID. Generated securely when omitted. */
961
1215
  clientId?: number;
@@ -976,13 +1230,20 @@ interface XlsxHostProps {
976
1230
  downloadOnSave?: boolean;
977
1231
  /** Initial scale, clamped to the supported zoom range. Defaults to 1. */
978
1232
  initialZoom?: number;
979
- /** 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. */
980
1234
  loadingIndicator?: React.ReactNode;
981
1235
  /** Inline style overrides for the editor root. */
982
1236
  style?: React.CSSProperties;
983
1237
  }
984
1238
  /** Props for XlsxEditor. */
985
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;
986
1247
  /** @deprecated False selects the in-thread engine. */
987
1248
  experimentalWorkerOpen?: false;
988
1249
  onError?: (error: Error) => void;
@@ -1000,7 +1261,7 @@ interface XlsxInThreadEditorProps extends XlsxEditorPluginProps, XlsxHostProps {
1000
1261
  collaboration?: XlsxEditorCollaborationOptions;
1001
1262
  i18n?: Translations;
1002
1263
  /**
1003
- * 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
1004
1265
  * way to refresh the panel afterward. Enables demo/host agents without
1005
1266
  * exposing the wasm object through the render tree. A returned cleanup runs
1006
1267
  * before the workbook is replaced or disposed.
@@ -1009,6 +1270,11 @@ interface XlsxInThreadEditorProps extends XlsxEditorPluginProps, XlsxHostProps {
1009
1270
  className?: string;
1010
1271
  /** Blocks user edits; navigation and selection remain available. */
1011
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;
1012
1278
  /**
1013
1279
  * Replaces the default toolbar: omitted keeps it (hidden when read-only),
1014
1280
  * `null` removes it, and supplied chrome renders instead, also when
@@ -1018,10 +1284,21 @@ interface XlsxInThreadEditorProps extends XlsxEditorPluginProps, XlsxHostProps {
1018
1284
  toolbar?: React.ReactNode;
1019
1285
  /** `false` hides the toolbar region, whatever `toolbar` is. */
1020
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;
1021
1298
  }
1022
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorProps. */
1299
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorProps. */
1023
1300
  type XlsxWorkerViewerProps = Omit<XlsxInThreadEditorProps, 'onReady' | 'readOnly' | 'collaboration' | 'experimentalWorkerOpen' | keyof XlsxHostProps> & {
1024
- /** @deprecated Removed in 0.6.0. Omit for the async editor. */
1301
+ /** @deprecated Removed in 0.7.0. Omit for the async editor. */
1025
1302
  [LEGACY_SYNC_API]: true;
1026
1303
  readOnly: true;
1027
1304
  collaboration?: undefined;
@@ -1029,21 +1306,21 @@ type XlsxWorkerViewerProps = Omit<XlsxInThreadEditorProps, 'onReady' | 'readOnly
1029
1306
  experimentalWorkerOpen: true;
1030
1307
  onReady?: (api: XlsxWorkerViewerApi) => void | (() => void);
1031
1308
  };
1032
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorProps. */
1309
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorProps. */
1033
1310
  type XlsxWorkerEditorProps = Omit<XlsxWorkerViewerProps, 'onReady' | 'readOnly'> & {
1034
1311
  readOnly?: false;
1035
1312
  onReady?: (api: XlsxWorkerEditorApi) => void | (() => void);
1036
1313
  };
1037
1314
  type XlsxAsyncEditorProps = Omit<XlsxInThreadEditorProps, 'onReady' | 'experimentalWorkerOpen'> & {
1038
- /** @deprecated Removed in 0.6.0. Omit for the async editor. */
1315
+ /** @deprecated Removed in 0.7.0. Omit for the async editor. */
1039
1316
  [LEGACY_SYNC_API]?: false;
1040
1317
  /** @deprecated False selects the in-thread engine. */
1041
1318
  experimentalWorkerOpen?: boolean;
1042
1319
  onReady?: (api: XlsxAsyncEditorApi) => void | (() => void);
1043
1320
  };
1044
- /** @deprecated Removed in 0.6.0. Use XlsxAsyncEditorProps. */
1321
+ /** @deprecated Removed in 0.7.0. Use XlsxAsyncEditorProps. */
1045
1322
  type XlsxLegacyEditorProps = Omit<XlsxInThreadEditorProps, keyof XlsxHostProps> & {
1046
- /** @deprecated Removed in 0.6.0. Omit for the async editor. */
1323
+ /** @deprecated Removed in 0.7.0. Omit for the async editor. */
1047
1324
  [LEGACY_SYNC_API]: true;
1048
1325
  };
1049
1326
  type WorkerSessionProps = Omit<XlsxWorkerEditorProps, 'readOnly' | 'onReady'> & {
@@ -1055,6 +1332,21 @@ type GeneralEditorSessionProps = Omit<XlsxLegacyEditorProps, 'experimentalWorker
1055
1332
  onReady?: (api: XlsxEditorApi | XlsxWorkerEditorApi | XlsxWorkerViewerApi) => void | (() => void);
1056
1333
  };
1057
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
+ */
1058
1350
  declare function XlsxEditor(props: XlsxAsyncEditorProps): React.JSX.Element;
1059
1351
  declare function XlsxEditor(props: XlsxLegacyEditorProps): React.JSX.Element;
1060
1352
  declare function XlsxEditor(props: XlsxWorkerViewerProps): React.JSX.Element;
@@ -1162,6 +1454,7 @@ interface LocaleProviderProps {
1162
1454
  declare function LocaleProvider({ i18n, children }: LocaleProviderProps): react.JSX.Element;
1163
1455
  declare function useTranslation(): {
1164
1456
  t: TFunction;
1457
+ lang: string;
1165
1458
  };
1166
1459
 
1167
1460
  /** @experimental */
@@ -1199,6 +1492,8 @@ interface XlsxBoundCommand<K extends XlsxCommandId> {
1199
1492
  /** The label for the bound arguments, such as "Format as currency". */
1200
1493
  label: string;
1201
1494
  shortcut: string | null;
1495
+ /** The shortcut in `aria-keyshortcuts` form. */
1496
+ ariaShortcut: string | null;
1202
1497
  /** Executes with `args`, falling back to the arguments bound to the hook. */
1203
1498
  execute(args?: XlsxCommandArgs[K]): Promise<XlsxCommandResult>;
1204
1499
  }
@@ -1214,6 +1509,8 @@ interface XlsxBoundPluginCommand {
1214
1509
  /** The contributed label, or the id while no plugin contributes it. */
1215
1510
  label: string;
1216
1511
  shortcut: string | null;
1512
+ /** The shortcut in `aria-keyshortcuts` form. */
1513
+ ariaShortcut: string | null;
1217
1514
  execute(): Promise<XlsxPluginCommandResult>;
1218
1515
  }
1219
1516
  /**
@@ -1311,4 +1608,4 @@ declare function defineXlsxPlugin<S>(definition: XlsxPluginDefinition<S>): XlsxP
1311
1608
  */
1312
1609
  declare function XlsxPluginToolbar(): React.ReactElement | null;
1313
1610
 
1314
- 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 };