@betteroffice/xlsx-react 0.2.1 → 0.3.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,56 +1,103 @@
1
1
  import * as react from 'react';
2
- import { CSSProperties, ReactNode } from 'react';
3
- import { WorkbookHandle } from '@betteroffice/xlsx';
2
+ import { CSSProperties, ReactNode, ComponentType } from 'react';
3
+ import { XlsxEditRefusal, Selection, XlsxReadRequest, XlsxReadResult, XlsxFindRequest, XlsxFindResult, XlsxEditRequest, XlsxValidationResult, XlsxEditResult, CellRange, WorkbookHandle } from '@betteroffice/xlsx';
4
4
  import { CollaborationReplica, CollaborationAwareness } from '@betteroffice/xlsx/collaboration';
5
- import { Translations, TFunction } from '@betteroffice/xlsx-i18n';
5
+ import { TranslationKey, Translations, TFunction } from '@betteroffice/xlsx-i18n';
6
6
 
7
7
  /**
8
- * The imperative surface handed to {@link XlsxEditorProps.onReady}: the open
9
- * workbook handle plus a `refreshProposals` to re-read the pending list after an
10
- * external caller (e.g. a demo agent) stages proposals on the same handle.
8
+ * A value that survives `JSON.stringify` / `JSON.parse` unchanged.
9
+ * @experimental
11
10
  */
12
- interface XlsxEditorApi {
13
- focus: () => void;
14
- handle: WorkbookHandle;
15
- refreshProposals: () => void;
16
- }
17
- interface XlsxEditorCollaborationOptions {
18
- /** Peer-unique Yrs client ID. Generated securely when omitted. */
19
- clientId?: number;
20
- /** Shared Yrs state applied before the replica is exposed. */
21
- initialUpdate?: Uint8Array;
22
- /** Receive the editor-owned collaboration replica. */
23
- onReplica?: (replica: CollaborationReplica | null) => void;
24
- /** Presence-capable provider connected to the editor-owned replica. */
25
- provider?: CollaborationAwareness | null;
11
+ type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
12
+ readonly [key: string]: JsonValue;
13
+ };
14
+ /**
15
+ * A machine-readable code with a localized explanation for people.
16
+ * @experimental
17
+ */
18
+ interface CommandReason<Code extends string = string> {
19
+ code: Code;
20
+ message: string;
26
21
  }
27
22
  /**
28
- * Props for {@link XlsxEditor}.
23
+ * Serializable availability of one editor command. A disabled command always
24
+ * says why; branch on `disabledReason.code`, show `disabledReason.message`.
25
+ * @experimental
29
26
  */
30
- interface XlsxEditorProps {
31
- /** Raw .xlsx bytes to open. When omitted the shell paints a demo frame. */
32
- file?: Uint8Array;
33
- /** Download name for the save button; falls back to `workbook.xlsx`. */
34
- fileName?: string;
35
- /** Receive saved bytes instead of triggering a browser download. */
36
- onSave?: (bytes: Uint8Array) => void;
37
- /** Open a network-ready Yrs replica and repaint when peer updates arrive. */
38
- collaboration?: XlsxEditorCollaborationOptions;
39
- i18n?: Translations;
40
- /**
41
- * Called when a workbook opens, with a handle to stage agent proposals and a
42
- * way to refresh the panel afterward. Enables demo/host agents without
43
- * exposing the wasm object through the render tree. A returned cleanup runs
44
- * before the workbook is replaced or disposed.
45
- */
46
- onReady?: (api: XlsxEditorApi) => void | (() => void);
47
- className?: string;
27
+ type CommandState<Value extends JsonValue = JsonValue, Code extends string = string> = {
28
+ /** Toggle state; `'mixed'` when the selection disagrees. */
29
+ active?: boolean | 'mixed';
30
+ /** The command's current value, such as the selected style or font size. */
31
+ value?: Value;
32
+ } & ({
33
+ enabled: true;
34
+ disabledReason?: never;
35
+ } | {
36
+ enabled: false;
37
+ disabledReason: CommandReason<Code>;
38
+ });
39
+
40
+ /**
41
+ * Plugin DTOs shared by the formats' editor plugin hosts. Clients, selections, anchors, layouts
42
+ * and command maps stay format-owned; these shapes fix grants, lifecycle metadata and refusals.
43
+ */
44
+
45
+ type MaybePromise<T> = T | Promise<T>;
46
+ /**
47
+ * What a host lets one plugin do. Without a grant a plugin reads, validates and navigates only.
48
+ * Built-in commands need their id listed; mutating ones also need `document: 'write'`.
49
+ */
50
+ type PluginGrant<CommandId extends string> = {
51
+ commands?: readonly CommandId[];
52
+ } & ({
53
+ document?: 'read';
54
+ editBatches?: never;
55
+ untrackedHistory?: never;
56
+ } | {
57
+ document: 'write';
58
+ /** Allows applying edit batches. */
59
+ editBatches?: true;
60
+ /** Allows batches with `history: 'none'`. */
61
+ untrackedHistory?: true;
62
+ });
63
+ /** Why a plugin's cleanups run. */
64
+ type PluginCleanupReason = 'removed' | 'document-replaced' | 'definition-replaced' | 'unmounted' | 'failed';
65
+ /** `attached`: the plugin was added while a document was open. */
66
+ type PluginLoadReason = 'loaded' | 'replaced' | 'attached';
67
+ type PluginFailureCode = 'plugin-unavailable' | 'document-replaced' | 'aborted' | 'permission-denied' | 'read-only' | 'input-failed' | 'unsupported-policy' | 'plugin-failed';
68
+ /** A plugin client call refused before it reached the document. */
69
+ interface PluginRefusal<Code extends string = PluginFailureCode> {
70
+ ok: false;
71
+ failure: CommandReason<Code>;
72
+ }
73
+ type PluginErrorPhase = 'definition' | 'initialize' | 'event' | 'render' | 'command-state' | 'command' | 'cleanup' | 'action';
74
+ /** A plugin failure reported to the host; `generation` is null outside a document. */
75
+ interface PluginError<Phase extends string = PluginErrorPhase> {
76
+ pluginId: string;
77
+ generation: string | null;
78
+ phase: Phase;
79
+ error: unknown;
48
80
  }
49
81
  /**
50
- * The xlsx editor React component.
82
+ * Outcome of a contributed command. Failure codes are the plugin's own, and a refused edit batch
83
+ * can be returned as-is, keeping its structured failure.
51
84
  */
52
- declare function XlsxEditor({ i18n, ...props }: XlsxEditorProps): react.JSX.Element;
85
+ type PluginCommandResult<Status extends string = string, Refusal extends {
86
+ ok: false;
87
+ } = never> = {
88
+ ok: true;
89
+ status: Status;
90
+ } | {
91
+ ok: false;
92
+ failure: CommandReason;
93
+ } | Refusal;
53
94
 
95
+ /**
96
+ * How a toolbar gets its state: `'legacy'` from props and callbacks,
97
+ * `'commands'` from the editor's command store.
98
+ * @experimental
99
+ */
100
+ type ToolbarMode = 'legacy' | 'commands';
54
101
  type NumberFormat = 'automatic' | 'plainText' | 'number' | 'percent' | 'scientific' | 'currency' | 'date' | 'time' | 'custom';
55
102
  type BorderPreset = 'all' | 'inner' | 'horizontal' | 'vertical' | 'outer' | 'left' | 'top' | 'right' | 'bottom' | 'none';
56
103
  type BorderStyle = 'solid' | 'dashed' | 'dotted' | 'double';
@@ -133,25 +180,733 @@ interface ToolbarProps {
133
180
  disabled?: boolean;
134
181
  className?: string;
135
182
  style?: CSSProperties;
183
+ /** Legacy mode appends these after the built-in controls; commands mode renders only these. */
136
184
  children?: ReactNode;
185
+ /**
186
+ * `'commands'` binds the built-in controls to the editor's commands, and
187
+ * rejects the state and callback props above. Defaults to the mode of the
188
+ * surrounding `EditorToolbar`, else `'legacy'`.
189
+ * @experimental
190
+ */
191
+ mode?: ToolbarMode;
192
+ }
193
+ /**
194
+ * The formatting rail. In legacy mode it renders the default controls from
195
+ * props and appends `children`; in commands mode, `children` replace the
196
+ * default arrangement. Narrow rails move trailing groups into a "More" menu.
197
+ */
198
+ declare function Toolbar(props: ToolbarProps): react.JSX.Element;
199
+
200
+ /**
201
+ * Arguments of every XLSX editor command, keyed by command id.
202
+ * @experimental
203
+ */
204
+ interface XlsxCommandArgs {
205
+ bold: null;
206
+ italic: null;
207
+ strikethrough: null;
208
+ /** Captures the selection's formatting; the next selection receives it. */
209
+ paintFormat: null;
210
+ fontFamily: {
211
+ family: string;
212
+ };
213
+ /** Size in points, 1 to 400. */
214
+ fontSize: {
215
+ points: number;
216
+ };
217
+ fontSizeStep: {
218
+ direction: 'increase' | 'decrease';
219
+ };
220
+ /** `#rrggbb`. */
221
+ textColor: {
222
+ color: string;
223
+ };
224
+ /** `#rrggbb`. */
225
+ fillColor: {
226
+ color: string;
227
+ };
228
+ /** `'custom'` applies the selection's custom pattern, or `0.00`. */
229
+ numberFormat: {
230
+ value: NumberFormat;
231
+ };
232
+ decimalPlaces: {
233
+ direction: 'increase' | 'decrease';
234
+ };
235
+ /** Applies the preset with the current border style and color. */
236
+ borderPreset: {
237
+ value: BorderPreset;
238
+ };
239
+ borderStyle: {
240
+ value: BorderStyle;
241
+ };
242
+ /** `#rrggbb`. */
243
+ borderColor: {
244
+ color: string;
245
+ };
246
+ merge: {
247
+ value: MergeAction;
248
+ };
249
+ horizontalAlignment: {
250
+ value: HorizontalAlignment;
251
+ };
252
+ verticalAlignment: {
253
+ value: VerticalAlignment;
254
+ };
255
+ textWrapping: {
256
+ value: TextWrapping;
257
+ };
258
+ searchMenus: null;
259
+ save: null;
260
+ exportPng: null;
261
+ print: null;
262
+ undo: null;
263
+ redo: null;
264
+ /** 1 is 100%; 0.25 to 4. */
265
+ zoom: {
266
+ scale: number;
267
+ };
268
+ /** `null` toggles the panel. */
269
+ proposalsPanel: {
270
+ open: boolean;
271
+ } | null;
272
+ /** `force` applies a proposal whose cells changed since it was staged. */
273
+ proposalAccept: {
274
+ proposalId: string;
275
+ force?: boolean;
276
+ };
277
+ proposalReject: {
278
+ proposalId: string;
279
+ };
280
+ }
281
+ /** @experimental */
282
+ type XlsxCommandId = keyof XlsxCommandArgs;
283
+ /**
284
+ * Commands presented as a choice between options.
285
+ * @experimental
286
+ */
287
+ type XlsxSelectCommandId = 'fontFamily' | 'fontSize' | 'numberFormat' | 'borderPreset' | 'borderStyle' | 'merge' | 'horizontalAlignment' | 'verticalAlignment' | 'textWrapping' | 'zoom';
288
+ /**
289
+ * Number format of the selection; `kind` is `null` when the cells disagree.
290
+ * @experimental
291
+ */
292
+ type XlsxNumberFormatValue = {
293
+ kind: NumberFormat | null;
294
+ pattern: string | null;
295
+ };
296
+ /**
297
+ * Current values reported in {@link XlsxCommandState.value}, keyed by command id.
298
+ * @experimental
299
+ */
300
+ interface XlsxCommandValues {
301
+ bold: null;
302
+ italic: null;
303
+ strikethrough: null;
304
+ paintFormat: null;
305
+ fontFamily: string | null;
306
+ /** Points; `null` when mixed or unknown. */
307
+ fontSize: number | null;
308
+ fontSizeStep: null;
309
+ /** `#rrggbb`; `null` when mixed or unknown. */
310
+ textColor: string | null;
311
+ fillColor: string | null;
312
+ numberFormat: XlsxNumberFormatValue | null;
313
+ decimalPlaces: null;
314
+ borderPreset: BorderPreset | null;
315
+ /** The style the next border preset applies. */
316
+ borderStyle: BorderStyle | null;
317
+ /** The color the next border preset applies. */
318
+ borderColor: string | null;
319
+ /** Size of the selected range. */
320
+ merge: {
321
+ rows: number;
322
+ columns: number;
323
+ } | null;
324
+ horizontalAlignment: HorizontalAlignment | null;
325
+ verticalAlignment: VerticalAlignment | null;
326
+ textWrapping: TextWrapping | null;
327
+ searchMenus: null;
328
+ save: null;
329
+ exportPng: null;
330
+ print: null;
331
+ undo: null;
332
+ redo: null;
333
+ zoom: number;
334
+ /** Number of pending proposals. */
335
+ proposalsPanel: number;
336
+ proposalAccept: null;
337
+ proposalReject: null;
338
+ }
339
+ /**
340
+ * Why a command is unavailable.
341
+ * @experimental
342
+ */
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';
344
+ /**
345
+ * Why an executed command did not complete.
346
+ * @experimental
347
+ */
348
+ type XlsxCommandFailureCode = XlsxCommandDisabledCode | 'input-failed' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'proposal-stale' | 'render-failed' | 'command-failed' | 'aborted';
349
+ /**
350
+ * One choice of a selector command.
351
+ * @experimental
352
+ */
353
+ interface XlsxCommandOption<K extends XlsxCommandId = XlsxCommandId> {
354
+ args: XlsxCommandArgs[K];
355
+ label: string;
356
+ /** The state of the command for these arguments, as `getState(id, args)` reports it. */
357
+ state: CommandState<XlsxCommandValues[K], XlsxCommandDisabledCode>;
358
+ }
359
+ /**
360
+ * Serializable state of one XLSX command, optionally for specific arguments.
361
+ * @experimental
362
+ */
363
+ type XlsxCommandState<K extends XlsxCommandId = XlsxCommandId> = CommandState<XlsxCommandValues[K], XlsxCommandDisabledCode> & {
364
+ /** Choices a selector presents, in display order. */
365
+ options?: readonly XlsxCommandOption<K>[];
366
+ };
367
+ /**
368
+ * A keyboard binding; `Mod` is Cmd on macOS and Ctrl elsewhere.
369
+ * @experimental
370
+ */
371
+ interface XlsxCommandShortcut<K extends XlsxCommandId = XlsxCommandId> {
372
+ chord: string;
373
+ args: XlsxCommandArgs[K];
374
+ }
375
+ /**
376
+ * Static, serializable description of a command.
377
+ * @experimental
378
+ */
379
+ interface XlsxCommandDescriptor<K extends XlsxCommandId = XlsxCommandId> {
380
+ id: K;
381
+ labelKey: TranslationKey;
382
+ mutatesDocument: boolean;
383
+ shortcuts: readonly XlsxCommandShortcut<K>[];
384
+ }
385
+ /** @experimental */
386
+ type XlsxCommandStatus = 'executed' | 'noop' | 'opened' | 'requested';
387
+ /**
388
+ * Outcome of {@link XlsxCommandStore.execute}: `executed` changed something,
389
+ * `noop` was valid but changed nothing, `opened` showed a picker, and
390
+ * `requested` handed the change to the host.
391
+ * @experimental
392
+ */
393
+ type XlsxCommandResult = {
394
+ ok: true;
395
+ status: XlsxCommandStatus;
396
+ } | {
397
+ ok: false;
398
+ failure: CommandReason<XlsxCommandFailureCode>;
399
+ };
400
+ /**
401
+ * A command a plugin contributes, registered as `plugin:<pluginId>/<localId>`.
402
+ * @experimental
403
+ */
404
+ type XlsxPluginCommandId = `plugin:${string}/${string}`;
405
+ /**
406
+ * Static description of a contributed command.
407
+ * @experimental
408
+ */
409
+ interface XlsxPluginCommandDescriptor {
410
+ id: XlsxPluginCommandId;
411
+ label: string;
412
+ mutatesDocument: boolean;
413
+ shortcuts: readonly {
414
+ chord: string;
415
+ args: null;
416
+ }[];
417
+ }
418
+ /**
419
+ * State of a contributed command; the plugin chooses its own disabled codes.
420
+ * @experimental
421
+ */
422
+ type XlsxPluginCommandState = CommandState;
423
+ /**
424
+ * Outcome of a contributed command: a plugin-defined failure, or a refused edit batch as-is.
425
+ *
426
+ * @experimental The plugin API may change in minor releases.
427
+ */
428
+ type XlsxPluginCommandResult = PluginCommandResult<XlsxCommandStatus, XlsxEditRefusal>;
429
+ /**
430
+ * The command authority of one editor, shared by built-in and host chrome.
431
+ * @experimental
432
+ */
433
+ interface XlsxCommandStore {
434
+ getDescriptor<K extends XlsxCommandId>(id: K): XlsxCommandDescriptor<K>;
435
+ /** Null while no active plugin contributes `id`. */
436
+ getDescriptor(id: XlsxPluginCommandId): XlsxPluginCommandDescriptor | null;
437
+ /** Snapshots are stable until the state changes; pass `args` to evaluate one option. */
438
+ getState<K extends XlsxCommandId>(id: K, args?: XlsxCommandArgs[K]): XlsxCommandState<K>;
439
+ getState(id: XlsxPluginCommandId, args?: null): XlsxPluginCommandState;
440
+ subscribe(listener: () => void): () => void;
441
+ /** Runs after input accepted before the call; availability is checked again first. */
442
+ execute<K extends XlsxCommandId>(id: K, args: XlsxCommandArgs[K]): Promise<XlsxCommandResult>;
443
+ /** Runs a contributed command with its plugin's own clients, outside the input queue. */
444
+ execute(id: XlsxPluginCommandId, args: null): Promise<XlsxPluginCommandResult>;
445
+ }
446
+
447
+ /**
448
+ * What the host lets one plugin do. Without a grant a plugin reads, validates and navigates only.
449
+ * Built-in commands need their id listed and, when they mutate, `document: 'write'`; edit
450
+ * batches need `document: 'write'` and `editBatches`, and `history: 'none'` also needs
451
+ * `untrackedHistory`. `readOnly` refuses every write regardless.
452
+ *
453
+ * @experimental The plugin API may change in minor releases.
454
+ */
455
+ type XlsxPluginGrant = PluginGrant<XlsxCommandId>;
456
+ type XlsxPluginFailureCode = PluginFailureCode;
457
+ /**
458
+ * A client call refused before it reached the workbook.
459
+ *
460
+ * @experimental The plugin API may change in minor releases.
461
+ */
462
+ type XlsxPluginRefusal = PluginRefusal<XlsxPluginFailureCode>;
463
+ /**
464
+ * Versioned workbook reads. Each runs after pending input.
465
+ *
466
+ * @experimental The plugin API may change in minor releases.
467
+ */
468
+ interface XlsxPluginReadClient {
469
+ version(): Promise<{
470
+ ok: true;
471
+ version: string;
472
+ } | XlsxPluginRefusal>;
473
+ readCells(request: XlsxReadRequest): Promise<XlsxReadResult | XlsxPluginRefusal>;
474
+ findText(request: XlsxFindRequest): Promise<XlsxFindResult | XlsxPluginRefusal>;
475
+ /** Checks a batch without granting anything; a later apply is checked again. */
476
+ validateEdits(request: XlsxEditRequest): Promise<XlsxValidationResult | XlsxPluginRefusal>;
477
+ }
478
+ /**
479
+ * Granted edit batches; the grant and `readOnly` are checked when the batch applies.
480
+ *
481
+ * @experimental The plugin API may change in minor releases.
482
+ */
483
+ interface XlsxPluginEditClient {
484
+ applyEdits(request: XlsxEditRequest): Promise<XlsxEditResult | XlsxPluginRefusal>;
485
+ }
486
+ /**
487
+ * The editor's commands as this plugin may use them.
488
+ *
489
+ * @experimental The plugin API may change in minor releases.
490
+ */
491
+ interface XlsxPluginCommandClient {
492
+ getDescriptor<K extends XlsxCommandId>(id: K): XlsxCommandDescriptor<K>;
493
+ getDescriptor(id: XlsxPluginCommandId): XlsxPluginCommandDescriptor | null;
494
+ getState<K extends XlsxCommandId>(id: K, args?: XlsxCommandArgs[K]): XlsxCommandState<K> | {
495
+ enabled: false;
496
+ disabledReason: XlsxPluginRefusal['failure'];
497
+ };
498
+ getState(id: XlsxPluginCommandId, args?: null): XlsxPluginCommandState;
499
+ subscribe(listener: () => void): () => void;
500
+ execute<K extends XlsxCommandId>(id: K, args: XlsxCommandArgs[K]): Promise<XlsxCommandResult | XlsxPluginRefusal>;
501
+ /** Only this plugin's own contributed commands. */
502
+ execute(id: XlsxPluginCommandId, args: null): Promise<XlsxPluginCommandResult | XlsxPluginRefusal>;
503
+ }
504
+ /** A rectangle in overlay pixels. */
505
+ interface XlsxPluginRect {
506
+ x: number;
507
+ y: number;
508
+ width: number;
509
+ height: number;
510
+ }
511
+ /** A painted grid frame and the workbook version its pixels show. */
512
+ interface XlsxPluginLayout {
513
+ /** Changes with every painted frame, sheet, zoom and scroll; unrelated to document versions. */
514
+ id: string;
515
+ version: string;
516
+ sheetId: string;
517
+ zoom: number;
518
+ /** The painted part of the sheet, in unzoomed sheet pixels; `x`/`y` scroll the body. */
519
+ viewport: {
520
+ x: number;
521
+ y: number;
522
+ width: number;
523
+ height: number;
524
+ };
525
+ }
526
+ /** A cell under the pointer, with the layout it was resolved against. */
527
+ interface XlsxPluginCellPosition {
528
+ sheetId: string;
529
+ row: number;
530
+ col: number;
531
+ version: string;
532
+ layoutId: string;
533
+ }
534
+ /**
535
+ * Geometry of the painted grid. Rectangles are in pixels of the overlay layer, already zoomed
536
+ * and clipped to the visible grid; every method returns null once its layout is no longer
537
+ * painted, and for cells scrolled out of view or on another sheet.
538
+ */
539
+ interface XlsxPluginGeometry {
540
+ layout: XlsxPluginLayout;
541
+ /** One grid cell, without merge expansion; zero-based `row` and `col`. */
542
+ getCellRect(target: {
543
+ sheetId: string;
544
+ row: number;
545
+ col: number;
546
+ }): XlsxPluginRect | null;
547
+ /** The visible part of an inclusive range, such as a merged area. */
548
+ getRangeRect(target: {
549
+ sheetId: string;
550
+ range: CellRange;
551
+ }): XlsxPluginRect | null;
552
+ /** Client-coordinate hit testing; null until the editor exposes it. */
553
+ getPositionAtPoint: ((clientX: number, clientY: number) => XlsxPluginCellPosition | null) | null;
554
+ }
555
+ /** The active sheet and what is selected on it; ids are session-scoped. */
556
+ type XlsxPluginSelection = {
557
+ sheetId: string;
558
+ /** Zero-based position in the workbook. */
559
+ sheetIndex: number;
560
+ /** Zero-based cells; `focus` may precede `anchor`. Null while nothing is selected. */
561
+ cells: Selection | null;
562
+ /** The selected chart, while one is selected instead of cells. */
563
+ chartId: string | null;
564
+ } | null;
565
+ interface XlsxPluginSnapshot {
566
+ /** The open workbook; changes when a workbook replaces it. */
567
+ generation: string;
568
+ version: string;
569
+ readOnly: boolean;
570
+ grant: XlsxPluginGrant;
571
+ selection: XlsxPluginSelection;
572
+ /** Null while no painted frame shows `version`. */
573
+ layout: XlsxPluginLayout | null;
574
+ }
575
+ type XlsxPluginNavigationFailureCode = 'stale-version' | 'missing-target' | 'ambiguous-target' | 'layout-unavailable' | 'unsupported';
576
+ /** @experimental The plugin API may change in minor releases. */
577
+ type XlsxPluginNavigationResult = {
578
+ ok: true;
579
+ } | XlsxPluginRefusal | {
580
+ ok: false;
581
+ failure: {
582
+ code: XlsxPluginNavigationFailureCode;
583
+ message: string;
584
+ };
585
+ };
586
+ interface XlsxPluginNavigationOptions {
587
+ /** The version the target was read at; a newer workbook refuses with `stale-version`. */
588
+ expectVersion: string;
589
+ }
590
+ /**
591
+ * Navigation after pending input, against the current workbook. It never writes.
592
+ *
593
+ * @experimental The plugin API may change in minor releases.
594
+ */
595
+ interface XlsxPluginNavigation {
596
+ /**
597
+ * Activates the sheet, selects `selection` in its direction and reveals the focus cell.
598
+ * Keyboard focus stays where it is unless `focus` is true.
599
+ */
600
+ selectCells(target: {
601
+ sheetId: string;
602
+ selection: Selection;
603
+ }, options: XlsxPluginNavigationOptions & {
604
+ focus?: boolean;
605
+ }): Promise<XlsxPluginNavigationResult>;
606
+ /**
607
+ * Reveals a cell, `nearest` by default. The selection stays on the current sheet; on another
608
+ * sheet, which becomes active, nothing is selected.
609
+ */
610
+ scrollToCell(target: {
611
+ sheetId: string;
612
+ row: number;
613
+ col: number;
614
+ }, options: XlsxPluginNavigationOptions & {
615
+ align?: 'nearest' | 'start' | 'center';
616
+ }): Promise<XlsxPluginNavigationResult>;
617
+ }
618
+ /** Lifecycle notifications describe current state; several changes may arrive as one. */
619
+ type XlsxPluginEvent = {
620
+ type: 'load';
621
+ generation: string;
622
+ version: string;
623
+ reason: PluginLoadReason;
624
+ } | {
625
+ type: 'document-change';
626
+ generation: string;
627
+ version: string;
628
+ } | {
629
+ type: 'selection-change';
630
+ generation: string;
631
+ version: string;
632
+ selection: XlsxPluginSelection;
633
+ } | {
634
+ type: 'mode-change';
635
+ generation: string;
636
+ readOnly: boolean;
637
+ } | {
638
+ type: 'layout-change';
639
+ generation: string;
640
+ layout: XlsxPluginLayout | null;
641
+ } | {
642
+ type: 'grants-change';
643
+ generation: string;
644
+ grant: XlsxPluginGrant;
645
+ };
646
+ /**
647
+ * What a hook, renderer or action receives. Clients refuse once it is superseded or ended.
648
+ *
649
+ * @experimental The plugin API may change in minor releases.
650
+ */
651
+ interface XlsxPluginContext<S> {
652
+ pluginId: string;
653
+ snapshot: XlsxPluginSnapshot;
654
+ readonly state: Readonly<S>;
655
+ /** Aborted when this hook is superseded or the plugin ends. */
656
+ signal: AbortSignal;
657
+ /** Aborted when this activation ends. */
658
+ lifetimeSignal: AbortSignal;
659
+ read: XlsxPluginReadClient;
660
+ commands: XlsxPluginCommandClient;
661
+ /** Null without an edit batch grant. */
662
+ edits: XlsxPluginEditClient | null;
663
+ /** Null while no painted frame shows the current version. */
664
+ geometry: XlsxPluginGeometry | null;
665
+ navigation: XlsxPluginNavigation;
666
+ /**
667
+ * Replaces the plugin's state. Returns false for a superseded context, an ended plugin, or when
668
+ * the workbook is no longer at `atVersion`, which defaults to `snapshot.version`.
669
+ */
670
+ setState(next: S | ((previous: S) => S), atVersion?: string): boolean;
671
+ /** Registers a disposer; after the plugin ended it runs at once. */
672
+ onCleanup(cleanup: (reason: PluginCleanupReason) => MaybePromise<void>): void;
673
+ /** Runs an event-handler action with a fresh context, isolating its failure. */
674
+ run(action: (context: XlsxPluginContext<S>) => MaybePromise<void>): Promise<void>;
675
+ }
676
+ interface XlsxPluginPanel<S> {
677
+ title: string;
678
+ placement: 'left' | 'right' | 'bottom';
679
+ /** Width for side panels, height for the bottom panel, in CSS pixels. */
680
+ preferredSize?: number;
681
+ defaultCollapsed?: boolean;
682
+ render: ComponentType<{
683
+ context: XlsxPluginContext<S>;
684
+ width: number;
685
+ height: number;
686
+ }>;
687
+ }
688
+ /** A command registered as `plugin:<pluginId>/<id>`. */
689
+ interface XlsxPluginCommand<S> {
690
+ id: string;
691
+ label: string;
692
+ /** Disables the command while read-only; grants nothing. */
693
+ mutatesDocument: boolean;
694
+ /**
695
+ * Chords such as `Mod+Shift+R` or `F7`: each uses Mod or Alt, or is F1 to F12. Built-in shortcuts
696
+ * and keys the grid handles take precedence; a clashing chord is reported and not bound.
697
+ */
698
+ shortcuts?: readonly string[];
699
+ getState?(context: XlsxPluginContext<S>): CommandState;
700
+ execute(context: XlsxPluginContext<S>): MaybePromise<XlsxPluginCommandResult>;
701
+ }
702
+ /**
703
+ * A plugin. `createState`, renderers and command `getState` must be pure; `initialize`,
704
+ * `onEvent`, command `execute` and `context.run` are managed effects.
705
+ *
706
+ * @experimental The plugin API may change in minor releases.
707
+ */
708
+ interface XlsxPluginDefinition<S> {
709
+ id: string;
710
+ /** Changing it restarts the plugin; other definition changes keep its state. */
711
+ revision?: string | number;
712
+ createState(): S;
713
+ initialize?(context: XlsxPluginContext<S>): MaybePromise<void>;
714
+ onEvent?(context: XlsxPluginContext<S>, event: XlsxPluginEvent): MaybePromise<void>;
715
+ panel?: XlsxPluginPanel<S>;
716
+ overlay?: ComponentType<{
717
+ context: XlsxPluginContext<S>;
718
+ geometry: XlsxPluginGeometry;
719
+ }>;
720
+ commands?: readonly XlsxPluginCommand<S>[];
721
+ /** Local command ids, in display order. */
722
+ toolbar?: readonly string[];
723
+ }
724
+ declare const xlsxPluginBrand: unique symbol;
725
+ /**
726
+ * An installable plugin, created by `defineXlsxPlugin`.
727
+ *
728
+ * @experimental The plugin API may change in minor releases.
729
+ */
730
+ interface XlsxPlugin {
731
+ readonly id: string;
732
+ readonly revision?: string | number;
733
+ readonly [xlsxPluginBrand]: true;
734
+ }
735
+ type XlsxPluginErrorPhase = PluginErrorPhase;
736
+ /**
737
+ * A plugin failure; the failing activation has already been stopped and cleaned up.
738
+ *
739
+ * @experimental The plugin API may change in minor releases.
740
+ */
741
+ type XlsxPluginError = PluginError<XlsxPluginErrorPhase>;
742
+ /** @experimental The plugin API may change in minor releases. */
743
+ interface XlsxEditorPluginProps {
744
+ /** @experimental The plugin API may change in minor releases. */
745
+ plugins?: readonly XlsxPlugin[];
746
+ /**
747
+ * Keyed by plugin id; omitted plugins read, validate and navigate only.
748
+ *
749
+ * @experimental The plugin API may change in minor releases.
750
+ */
751
+ pluginGrants?: Readonly<Record<string, XlsxPluginGrant>>;
752
+ /** @experimental The plugin API may change in minor releases. */
753
+ onPluginError?(error: XlsxPluginError): void;
137
754
  }
138
- declare function Toolbar(explicitProps: ToolbarProps): react.JSX.Element;
139
755
 
140
- type EditorToolbarProps = ToolbarProps;
756
+ /**
757
+ * The imperative surface handed to {@link XlsxEditorProps.onReady}: the open
758
+ * workbook handle plus a `refreshProposals` to re-read the pending list after an
759
+ * external caller (e.g. a demo agent) stages proposals on the same handle.
760
+ *
761
+ * The version, read and edit-batch methods run in order with the input accepted
762
+ * before them, as commands do: cell and formula entries, chart moves, pastes and
763
+ * cuts land first, and an IME composition ends with its text written. They reject
764
+ * with {@link XlsxCommandAdmissionError}: `input-failed` while a refused entry
765
+ * waits for correction or earlier input failed, `gesture-active` during a chart
766
+ * drag, and `document-replaced` when the workbook is replaced meanwhile.
767
+ */
768
+ interface XlsxEditorApi {
769
+ /**
770
+ * Closes the open cell entry and clears the selection. The entry is written
771
+ * at once, or queued behind input still waiting to be written. An entry the
772
+ * workbook refuses stays open, and nothing changes; one it refused earlier
773
+ * on this sheet reopens at its own cell.
774
+ */
775
+ clearSelection: () => void;
776
+ /**
777
+ * The editor's command store, shared by its toolbar and host chrome. It
778
+ * gates the editor's own UI; `handle` stays unrestricted host authority.
779
+ * @experimental
780
+ */
781
+ readonly commands: XlsxCommandStore;
782
+ focus: () => void;
783
+ handle: WorkbookHandle;
784
+ refreshProposals: () => void;
785
+ /**
786
+ * Writes the open cell entry and returns the workbook bytes at once. Throws
787
+ * {@link XlsxSaveRefusedError} rather than return bytes without accepted
788
+ * input: `input-pending` while earlier entries or a paste still wait to be
789
+ * written (await `commands.execute('save', null)` instead), `input-failed`
790
+ * while an entry the workbook refused waits for correction.
791
+ */
792
+ save: () => Uint8Array;
793
+ /**
794
+ * Scrolls the focus cell into view. Commands run after it, even in the same
795
+ * handler, act on this selection and sheet. The open cell entry is written
796
+ * first, or queued behind input still waiting to be written, so it may not
797
+ * have landed when this returns. False, changing nothing, for an invalid
798
+ * target or an open entry the workbook refuses; an entry it refused earlier
799
+ * on `sheet` reopens at its own cell.
800
+ */
801
+ selectCells: (sheet: number, selection: Selection) => boolean;
802
+ version: () => Promise<string>;
803
+ readCells: (request: XlsxReadRequest) => Promise<XlsxReadResult>;
804
+ findText: (request: XlsxFindRequest) => Promise<XlsxFindResult>;
805
+ /** Refuses with `read-only` while the editor is read-only. */
806
+ validateEdits: (request: XlsxEditRequest) => Promise<XlsxValidationResult>;
807
+ /**
808
+ * Applies the batch against the caller's `expectVersion` after committing pending input,
809
+ * so input that lands first refuses it with `stale-version`. Refuses with `read-only`
810
+ * while the editor is read-only; an applied batch calls `onChange` once.
811
+ */
812
+ applyEdits: (request: XlsxEditRequest) => Promise<XlsxEditResult>;
813
+ }
814
+ /** Why a synchronous {@link XlsxEditorApi.save} did not return bytes. */
815
+ declare class XlsxSaveRefusedError extends Error {
816
+ readonly code: 'input-pending' | 'input-failed';
817
+ constructor(code: 'input-pending' | 'input-failed');
818
+ }
819
+ interface XlsxEditorCollaborationOptions {
820
+ /** Peer-unique Yrs client ID. Generated securely when omitted. */
821
+ clientId?: number;
822
+ /** Shared Yrs state applied before the replica is exposed. */
823
+ initialUpdate?: Uint8Array;
824
+ /** Receive the editor-owned collaboration replica. */
825
+ onReplica?: (replica: CollaborationReplica | null) => void;
826
+ /** Presence-capable provider connected to the editor-owned replica. */
827
+ provider?: CollaborationAwareness | null;
828
+ }
829
+ /**
830
+ * Props for {@link XlsxEditor}.
831
+ */
832
+ interface XlsxEditorProps extends XlsxEditorPluginProps {
833
+ /** Raw .xlsx bytes to open. When omitted the shell paints a demo frame. */
834
+ file?: Uint8Array;
835
+ /** Download name for the save button; falls back to `workbook.xlsx`. */
836
+ fileName?: string;
837
+ /** Receive saved bytes instead of triggering a browser download. */
838
+ onSave?: (bytes: Uint8Array) => void;
839
+ /** Called after a user edit changes the workbook. */
840
+ onChange?: () => void;
841
+ /** Open a network-ready Yrs replica and repaint when peer updates arrive. */
842
+ collaboration?: XlsxEditorCollaborationOptions;
843
+ i18n?: Translations;
844
+ /**
845
+ * Called when a workbook opens, with a handle to stage agent proposals and a
846
+ * way to refresh the panel afterward. Enables demo/host agents without
847
+ * exposing the wasm object through the render tree. A returned cleanup runs
848
+ * before the workbook is replaced or disposed.
849
+ */
850
+ onReady?: (api: XlsxEditorApi) => void | (() => void);
851
+ className?: string;
852
+ /** Blocks user edits; navigation and selection remain available. */
853
+ readOnly?: boolean;
854
+ /**
855
+ * Replaces the default toolbar: omitted keeps it (hidden when read-only),
856
+ * `null` removes it, and supplied chrome renders instead, also when
857
+ * read-only. Compose it from `EditorToolbar mode="commands"` parts.
858
+ * @experimental
859
+ */
860
+ toolbar?: React.ReactNode;
861
+ /** `false` hides the toolbar region, whatever `toolbar` is. */
862
+ showToolbar?: boolean;
863
+ }
864
+ /**
865
+ * The xlsx editor React component.
866
+ */
867
+ declare function XlsxEditor(props: XlsxEditorProps): react.JSX.Element;
868
+
869
+ interface EditorToolbarProps extends ToolbarProps {
870
+ /**
871
+ * Locale of a command-mode toolbar rendered outside the editor; defaults to the editor's.
872
+ * @experimental
873
+ */
874
+ i18n?: Translations;
875
+ }
141
876
  declare const EditorToolbarContext: react.Context<ToolbarProps | null>;
142
877
  declare function useEditorToolbar(): ToolbarProps;
143
878
 
879
+ /** @experimental */
880
+ interface FormulaBarProps {
881
+ className?: string;
882
+ style?: CSSProperties;
883
+ }
884
+ /**
885
+ * The name box and formula input of the surrounding `XlsxEditor`. It edits
886
+ * the focused cell through the editor's input ordering, so commands issued
887
+ * while a formula is typed land after it. Renders nothing outside an editor.
888
+ * @experimental
889
+ */
890
+ declare function FormulaBar({ className, style }: FormulaBarProps): react.JSX.Element | null;
891
+
144
892
  interface EditorToolbarComponent {
145
- (props: EditorToolbarProps & {
146
- children: ReactNode;
147
- }): React.JSX.Element;
893
+ (props: EditorToolbarProps): React.JSX.Element;
148
894
  Toolbar: typeof Toolbar;
895
+ FormulaBar: typeof FormulaBar;
149
896
  }
897
+ /**
898
+ * The editor chrome as a compound component. `mode="commands"` binds its
899
+ * parts to the nearest editor's commands (inside `XlsxEditor` or an
900
+ * `XlsxCommandProvider`) and, without children, renders the formatting rail.
901
+ * The default legacy mode shares its props with the parts, as before.
902
+ */
150
903
  declare const EditorToolbar: EditorToolbarComponent;
151
904
 
152
905
  interface ToolbarButtonProps {
153
906
  active?: boolean;
154
907
  disabled?: boolean;
908
+ /** Why the button is disabled; announced and shown on hover, and it stays focusable. */
909
+ description?: string;
155
910
  title: string;
156
911
  onClick?: () => void;
157
912
  children: ReactNode;
@@ -159,7 +914,7 @@ interface ToolbarButtonProps {
159
914
  testId?: string;
160
915
  ariaExpanded?: boolean;
161
916
  }
162
- declare function ToolbarButton({ active, disabled, title, onClick, children, style, testId, ariaExpanded, }: ToolbarButtonProps): react.JSX.Element;
917
+ declare function ToolbarButton(props: ToolbarButtonProps): react.JSX.Element;
163
918
  declare function ToolbarGroup({ label, children, style, }: {
164
919
  label: string;
165
920
  children: ReactNode;
@@ -171,21 +926,31 @@ interface ToolbarDropdownProps {
171
926
  trigger: ReactNode;
172
927
  children: (close: () => void) => ReactNode;
173
928
  disabled?: boolean;
929
+ /** Why the dropdown is disabled; announced and shown on hover, and it stays focusable. */
930
+ description?: string;
174
931
  active?: boolean;
175
932
  menuWidth?: number;
176
933
  style?: CSSProperties;
177
934
  testId?: string;
178
935
  }
179
- declare function ToolbarDropdown({ title, trigger, children, disabled, active, menuWidth, style, testId, }: ToolbarDropdownProps): react.JSX.Element;
936
+ /**
937
+ * A button with a popup. Content made only of menu items is a menu with arrow
938
+ * keys, Home/End and typeahead; other content is a non-modal dialog. Escape
939
+ * returns focus to the button.
940
+ */
941
+ declare function ToolbarDropdown({ title, trigger, children, disabled, description, active, menuWidth, style, testId, }: ToolbarDropdownProps): react.JSX.Element;
180
942
  interface ToolbarMenuItemProps {
181
943
  label: string;
182
944
  icon?: ReactNode;
945
+ /** Makes the item a radio choice, checked when true. */
183
946
  selected?: boolean;
184
947
  disabled?: boolean;
948
+ /** Why the item is disabled; announced and shown on hover. */
949
+ description?: string;
185
950
  onClick?: () => void;
186
951
  close?: () => void;
187
952
  }
188
- declare function ToolbarMenuItem({ label, icon, selected, disabled, onClick, close, }: ToolbarMenuItemProps): react.JSX.Element;
953
+ declare function ToolbarMenuItem({ label, icon, selected, disabled, description, onClick, close, }: ToolbarMenuItemProps): react.JSX.Element;
189
954
  declare function ToolbarMenuSeparator(): react.JSX.Element;
190
955
 
191
956
  interface LocaleProviderProps {
@@ -197,4 +962,162 @@ declare function useTranslation(): {
197
962
  t: TFunction;
198
963
  };
199
964
 
200
- export { type BorderPreset, type BorderStyle, EditorToolbar, EditorToolbarContext, type EditorToolbarProps, type FormattingAction, type HorizontalAlignment, LocaleProvider, type LocaleProviderProps, type MergeAction, type NumberFormat, type SelectionFormatting, type SelectionShape, type TextWrapping, Toolbar, ToolbarButton, ToolbarDropdown, ToolbarGroup, ToolbarMenuItem, ToolbarMenuSeparator, type ToolbarProps, ToolbarSeparator, type VerticalAlignment, XlsxEditor, type XlsxEditorApi, type XlsxEditorCollaborationOptions, type XlsxEditorProps, Toolbar as XlsxToolbar, useEditorToolbar, useTranslation };
965
+ /** Why work queued behind accepted input could not run. */
966
+ type XlsxCommandAdmissionCode = Extract<XlsxCommandFailureCode, 'input-failed' | 'document-replaced' | 'target-changed' | 'gesture-active' | 'editor-unavailable'>;
967
+ /**
968
+ * Raised when work queued behind accepted input cannot run: a command, or a version, read or
969
+ * edit-batch call of the editor API.
970
+ */
971
+ declare class XlsxCommandAdmissionError extends Error {
972
+ readonly code: XlsxCommandAdmissionCode;
973
+ constructor(code: XlsxCommandAdmissionCode);
974
+ }
975
+
976
+ /** @experimental */
977
+ interface XlsxCommandProviderProps {
978
+ /** An editor's `api.commands`; `null` until the editor is ready. */
979
+ commands: XlsxCommandStore | null;
980
+ children?: ReactNode;
981
+ }
982
+ /**
983
+ * Provides one editor's commands to toolbar parts rendered anywhere in the tree.
984
+ * @experimental
985
+ */
986
+ declare function XlsxCommandProvider({ commands, children }: XlsxCommandProviderProps): react.JSX.Element;
987
+
988
+ /**
989
+ * The nearest editor's command store.
990
+ * @experimental
991
+ */
992
+ declare function useXlsxCommands(): XlsxCommandStore;
993
+ /**
994
+ * Subscribes to one command's state, optionally for specific arguments.
995
+ * @experimental
996
+ */
997
+ declare function useXlsxCommandState<K extends XlsxCommandId>(id: K, args?: XlsxCommandArgs[K]): XlsxCommandState<K>;
998
+ /** Subscribes to a contributed command's state. */
999
+ declare function useXlsxCommandState(id: XlsxPluginCommandId, args?: null): XlsxPluginCommandState;
1000
+ /**
1001
+ * A command bound to this component, with its localized label and shortcut.
1002
+ * @experimental
1003
+ */
1004
+ interface XlsxBoundCommand<K extends XlsxCommandId> {
1005
+ id: K;
1006
+ descriptor: XlsxCommandDescriptor<K>;
1007
+ state: XlsxCommandState<K>;
1008
+ /** The label for the bound arguments, such as "Format as currency". */
1009
+ label: string;
1010
+ shortcut: string | null;
1011
+ /** Executes with `args`, falling back to the arguments bound to the hook. */
1012
+ execute(args?: XlsxCommandArgs[K]): Promise<XlsxCommandResult>;
1013
+ }
1014
+ /**
1015
+ * A contributed command bound to this component.
1016
+ * @experimental
1017
+ */
1018
+ interface XlsxBoundPluginCommand {
1019
+ id: XlsxPluginCommandId;
1020
+ /** Null while no active plugin contributes the command. */
1021
+ descriptor: XlsxPluginCommandDescriptor | null;
1022
+ state: XlsxPluginCommandState;
1023
+ /** The contributed label, or the id while no plugin contributes it. */
1024
+ label: string;
1025
+ shortcut: string | null;
1026
+ execute(): Promise<XlsxPluginCommandResult>;
1027
+ }
1028
+ /**
1029
+ * Binds one command for a custom control.
1030
+ * @experimental
1031
+ */
1032
+ declare function useXlsxCommand<K extends XlsxCommandId>(id: K, args?: XlsxCommandArgs[K]): XlsxBoundCommand<K>;
1033
+ /** Binds a contributed command for a custom control. */
1034
+ declare function useXlsxCommand(id: XlsxPluginCommandId, args?: null): XlsxBoundPluginCommand;
1035
+
1036
+ /**
1037
+ * Arguments a control binds; required when the command takes arguments.
1038
+ * @experimental
1039
+ */
1040
+ type ToolbarCommandArgs<K extends XlsxCommandId | XlsxPluginCommandId> = K extends XlsxCommandId ? null extends XlsxCommandArgs[K] ? {
1041
+ args?: XlsxCommandArgs[K];
1042
+ } : {
1043
+ args: XlsxCommandArgs[K];
1044
+ } : {
1045
+ args?: null;
1046
+ };
1047
+ /**
1048
+ * A built-in or contributed command; a contributed one renders nothing while inactive.
1049
+ * @experimental
1050
+ */
1051
+ type ToolbarCommandButtonProps<K extends XlsxCommandId | XlsxPluginCommandId> = {
1052
+ id: K;
1053
+ /** Button content; defaults to the command's icon, or its label when it has none. */
1054
+ children?: ReactNode;
1055
+ /** Accessible name; defaults to the localized or contributed command label. */
1056
+ label?: string;
1057
+ className?: string;
1058
+ } & ToolbarCommandArgs<K>;
1059
+ /** @experimental */
1060
+ interface ToolbarCommandSelectProps<K extends XlsxSelectCommandId> {
1061
+ id: K;
1062
+ className?: string;
1063
+ }
1064
+ /** @experimental */
1065
+ interface ToolbarCommandProps<K extends XlsxCommandId | XlsxPluginCommandId> {
1066
+ id: K;
1067
+ /** Binds arguments; omit to render the command's full built-in control. */
1068
+ args?: K extends XlsxCommandId ? XlsxCommandArgs[K] : null;
1069
+ className?: string;
1070
+ }
1071
+ /**
1072
+ * A button bound to one command, showing its pressed and disabled state.
1073
+ * @experimental
1074
+ */
1075
+ declare function ToolbarCommandButton<K extends XlsxCommandId | XlsxPluginCommandId>(props: ToolbarCommandButtonProps<K>): react.JSX.Element;
1076
+ /**
1077
+ * The built-in picker of a selector command.
1078
+ * @experimental
1079
+ */
1080
+ declare function ToolbarCommandSelect<K extends XlsxSelectCommandId>({ id, className, }: ToolbarCommandSelectProps<K>): react.JSX.Element;
1081
+ /**
1082
+ * The built-in control of any command, as the default toolbar presents it.
1083
+ * @experimental
1084
+ */
1085
+ declare function ToolbarCommand<K extends XlsxCommandId | XlsxPluginCommandId>(props: ToolbarCommandProps<K>): react.JSX.Element;
1086
+
1087
+ /** @experimental */
1088
+ interface ToolbarOverflowProps {
1089
+ /** Label of the menu entry that replaces the content at narrow widths. */
1090
+ label: string;
1091
+ onSelect(): void;
1092
+ disabled?: boolean;
1093
+ /** Why the action is disabled. */
1094
+ description?: string;
1095
+ /** Toggle state for a checkbox entry. */
1096
+ checked?: boolean;
1097
+ children: ReactNode;
1098
+ }
1099
+ /**
1100
+ * Gives arbitrary host content a menu entry, so it can move into the overflow
1101
+ * menu instead of scrolling with the row in a narrow toolbar.
1102
+ * @experimental
1103
+ */
1104
+ declare function ToolbarOverflow({ label, onSelect, disabled, description, checked, children, }: ToolbarOverflowProps): react.JSX.Element;
1105
+
1106
+ /**
1107
+ * Wraps a plugin for `XlsxEditor`'s `plugins` prop. The definition is checked when the editor
1108
+ * installs it; a problem is reported through `onPluginError` and disables only this plugin. Its
1109
+ * panel, commands and toolbar are copied and frozen, so changing them takes a new definition.
1110
+ *
1111
+ * @experimental The plugin API may change in minor releases.
1112
+ */
1113
+ declare function defineXlsxPlugin<S>(definition: XlsxPluginDefinition<S>): XlsxPlugin;
1114
+
1115
+ /**
1116
+ * The toolbar commands installed plugins contribute, in plugin and declaration order. The
1117
+ * default toolbar includes it; place it in replacement chrome to keep those commands reachable.
1118
+ *
1119
+ * @experimental The plugin API may change in minor releases.
1120
+ */
1121
+ declare function XlsxPluginToolbar(): React.ReactElement | null;
1122
+
1123
+ 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, 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, XlsxEditor, type XlsxEditorApi, type XlsxEditorCollaborationOptions, type XlsxEditorPluginProps, type XlsxEditorProps, type XlsxNumberFormatValue, 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, XlsxSaveRefusedError, type XlsxSelectCommandId, Toolbar as XlsxToolbar, defineXlsxPlugin, useEditorToolbar, useTranslation, useXlsxCommand, useXlsxCommandState, useXlsxCommands };