@xlsx-editor.dev/react 0.0.0-stage → 0.1.0-beta.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.
@@ -0,0 +1,576 @@
1
+ /**
2
+ * `@xlsx-editor.dev/react`: the React adapter for XLSX Editor.
3
+ *
4
+ * Provider-first, after PPTX Editor's adapter: `XlsxEditor.Root` owns the editor instance,
5
+ * `.Viewport` scopes the styles, and `.Content` attaches the grid surface. Every piece of chrome
6
+ * is a hook consumer; `.Toolbar` renders the chrome registry. `XlsxEditor` composes them all.
7
+ *
8
+ * @packageDocumentation
9
+ * @public
10
+ */
11
+ import * as react from 'react';
12
+ import { ReactNode, CSSProperties, ReactElement, ForwardRefExoticComponent, RefAttributes } from 'react';
13
+ import { FontSource, NumberLocale, EditorMode, ColorMode, XlsxEditorInstance, EditorSnapshot, EditorFailure, SavedWorkbook, ChromeSlotId, ChromeGroupId, ResolvedColorMode, EditorEvents } from '@xlsx-editor.dev/core/editor';
14
+ export { ActiveCellFormat, CLIPBOARD_TYPE, CUSTOM_NUMBER_FORMAT_PREFIX, CellEditMode, ChromeDisabledReason, ChromeGroup, ChromeGroupId, ChromeHint, ChromeSlotId, ClipboardContent, ColorMode, CopyResult, DecimalSteps, DocumentChange, EditMove, EditRefusal, EditRefusalCode, EditResult, EditTextOptions, EditorEvents, EditorFailure, EditorMode, EditorSheet, EditorSnapshot, FieldKeys, FontSource, GridPoint, GridRange, GridSelection, MAX_COLUMN_WIDTH, MAX_CONTENT_FIELD_CHARS, MAX_GO_TO_LENGTH, MAX_LISTED_NUMBER_FORMATS, MAX_RESIZE_NEW_ROWS, MAX_ROW_HEIGHT, MergeCommand, MergeCommandState, MergeOptions, NUMBER_FORMAT_CODE_PROBLEM_KEYS, NUMBER_FORMAT_SAMPLE, NumberFormatChoice, NumberFormatChoiceValue, NumberFormatCodeProblem, NumberFormatDialogApplyStep, NumberFormatDialogStart, NumberFormatListEntry, NumberFormatListView, NumberFormatPreview, NumberLocale, PartPastLimit, PasteData, ResolvedColorMode, SavedWorkbook, SheetCommand, SheetCommandInput, SheetCommandState, SheetProtection, ToolbarCommandState, ToolbarHintKey, WorkbookKind, WorkbookProtection, XlsxEditorInstance, composesKey, contentFieldText, editMoveOf, fieldHistoryKey, mergeCommandState, numberFormatChoiceCode, numberFormatChoices, numberFormatCodeProblem, numberFormatDialogApplyStep, numberFormatDialogCurrent, numberFormatDialogStart, numberFormatListView, numberFormatValue, previewNumberFormat, refusalText, refusesEditText, refusesReference, sheetCommandState, trapTabWithin, workbookNumberFormatCodes } from '@xlsx-editor.dev/core/editor';
15
+ import { Translations, TFunction } from '@xlsx-editor.dev/i18n';
16
+ export { Translations } from '@xlsx-editor.dev/i18n';
17
+
18
+ /** The faces that measure and paint text: bytes, or a function that loads them once. @public */
19
+ type XlsxEditorFonts = readonly FontSource[] | (() => Promise<readonly FontSource[]>);
20
+ /** Props for `XlsxEditor.Root`. Only `document` identity reloads the workbook. @public */
21
+ interface XlsxEditorRootProps {
22
+ /**
23
+ * The bytes of a workbook or a template package, as a `Uint8Array` or an `ArrayBuffer`. A new
24
+ * array or buffer opens the new workbook. A change
25
+ * to `undefined` closes the open workbook (`close`), so the editor shows no workbook, as DOCX
26
+ * Editor mounts no document without one.
27
+ */
28
+ readonly document?: Uint8Array | ArrayBuffer | undefined;
29
+ /**
30
+ * The faces that measure and paint text. Omitted, the packaged substitute faces load
31
+ * (`loadSubstituteFonts`); nothing else is fetched. As DOCX Editor's `fonts` prop, a new
32
+ * value replaces the faces in place (`setFonts`): the workbook, the selection, and the undo
33
+ * history stay. A list is compared by its faces (`sameFontSource`), so an inline list does
34
+ * not load the faces again; a function is compared by identity, so keep it stable. When new
35
+ * faces do not load, the old faces stay and `onFontError` fires with the cause.
36
+ */
37
+ readonly fonts?: XlsxEditorFonts;
38
+ /**
39
+ * The number locale of the shown values: separators and built-in format codes. A value that
40
+ * differs (`sameNumberLocale`) applies in place (`setNumberLocale`); an inline object with
41
+ * the same value changes nothing. An open cell edit keeps the number locale it opened with;
42
+ * the next edit reads the new one. A separate prop from `locale` (the UI
43
+ * strings): the engine formats numbers from explicit separators, not a BCP-47 tag, and ships
44
+ * no regional data.
45
+ */
46
+ readonly numberLocale?: NumberLocale;
47
+ /**
48
+ * `'edit'` (default) or `'view'`. In `'view'`, every edit command is refused and the
49
+ * toolbar's edit controls are disabled; selection, sheet tabs, zoom, and save stay
50
+ * available. A change applies without a reload. For when a change applies and waits, see
51
+ * "View mode" in the README.
52
+ */
53
+ readonly mode?: EditorMode;
54
+ /** UI strings; English when omitted. A `null` entry falls back to English. */
55
+ readonly locale?: Translations;
56
+ /**
57
+ * Color theme of the chrome, as on DOCX Editor's root. `'dark'` puts `.dark` beside
58
+ * `.xlsx-editor` on the viewport, and `'system'` follows the OS setting as it changes.
59
+ * Defaults to `'light'`. The workbook canvas keeps the workbook's own colors. Changes apply
60
+ * without a remount.
61
+ */
62
+ readonly colorMode?: ColorMode;
63
+ /**
64
+ * Fired once per editor, as DOCX Editor's `onReady` is: after the editor is published and any
65
+ * `XlsxEditor.Content` in the same commit has attached it, and after the first open of
66
+ * `document` settles (`snapshot().status` is `'ready'` or `'failed'`). Without `document`, it
67
+ * fires right after the attach. A `select` or a zoom from it applies to the opened workbook.
68
+ */
69
+ readonly onReady?: (editor: XlsxEditorInstance) => void;
70
+ /**
71
+ * Fired after every change of the editor state, with the new snapshot: a content change and
72
+ * a view change (selection, zoom, sheet) alike. To act on content changes only, as DOCX
73
+ * Editor's `onChange` does, compare `snapshot.revision` with the last one. DOCX Editor
74
+ * passes a document change and PPTX Editor the instance; this editor passes the snapshot,
75
+ * because it is the one immutable state object that chrome renders, and it carries the
76
+ * revision. The `change` event of `useEditorEvent` fires for content changes only.
77
+ */
78
+ readonly onChange?: (snapshot: EditorSnapshot) => void;
79
+ /**
80
+ * Fired when the fonts that measure and paint text do not load, as DOCX Editor's
81
+ * `onFontError` is. When an open fails for its fonts, the snapshot also turns `failed` with
82
+ * the failure code `fonts`; fires once for each failed open. When a new `fonts` value does
83
+ * not load, the old faces stay and it fires too. The argument differs from DOCX Editor's
84
+ * `EditorFontError`: it is the snapshot's `EditorFailure` with the code `fonts` and the cause
85
+ * in `detail`, the same object that `snapshot().failure` holds, so a host reads one shape.
86
+ * When some packaged substitute faces do not load and the others do (`fonts` omitted), the
87
+ * workbook opens, and it fires with `substituteFailures`, as PPTX Editor reports them
88
+ * (`fontReport()`). Without a handler, each failure prints one console warning.
89
+ */
90
+ readonly onFontError?: (failure: EditorFailure) => void;
91
+ readonly children?: ReactNode;
92
+ }
93
+ /**
94
+ * The imperative handle of `XlsxEditor` and `XlsxEditor.Root`. It stays small: it never
95
+ * mirrors the commands of the editor instance, such as the sheet, clipboard, and resize commands.
96
+ * Call them on `getEditor()`.
97
+ *
98
+ * It differs from DOCX Editor's `DocxEditorRef` in four ways, for these reasons:
99
+ *
100
+ * - No `exec`. Each command is a typed method of `XlsxEditorInstance`, and the engine has no
101
+ * command union to dispatch on. A toolbar slot runs through `useEditorCommand`.
102
+ * - No `getDocumentHandle`. The workbook has no document handle API; read the state with
103
+ * `snapshot()` and edit through `getEditor()`.
104
+ * - `save()` is synchronous, as PPTX Editor's is, because the package writer is synchronous.
105
+ * - `load()` returns a promise of the snapshot after the open, where DOCX Editor's returns
106
+ * nothing: opening loads fonts and parses the package asynchronously, so the caller can wait.
107
+ *
108
+ * @public
109
+ */
110
+ interface XlsxEditorRef {
111
+ /**
112
+ * Open the bytes of a workbook or a template package. Resolves with the snapshot after the
113
+ * open, or `null` before mount. An open cell edit is dropped without a commit, as
114
+ * `XlsxEditorInstance.load` does.
115
+ */
116
+ load(bytes: Uint8Array | ArrayBuffer): Promise<EditorSnapshot | null>;
117
+ /**
118
+ * The workbook as bytes of the opened package's kind (`snapshot().workbookKind`: a workbook or a
119
+ * template), with every edit, or `null` when none is open. An open cell edit is committed first;
120
+ * when the editor cannot store it, `save` returns `null` and shows the reason.
121
+ */
122
+ save(): Uint8Array<ArrayBuffer> | null;
123
+ /**
124
+ * `save` in short tasks, so the page stays responsive while a large workbook saves. An edit
125
+ * made while the save runs belongs to the next save. Resolves to `null` when it is refused.
126
+ */
127
+ saveInTasks(): Promise<SavedWorkbook | null>;
128
+ /** The editor instance, with every editing command, or `null` before it mounts. */
129
+ getEditor(): XlsxEditorInstance | null;
130
+ /** Give the keyboard to the grid. */
131
+ focus(): void;
132
+ /** The editor's state now. Before it mounts, an empty snapshot with the `mode` prop. */
133
+ snapshot(): EditorSnapshot;
134
+ }
135
+ /** Owns the editor instance. Takes a `ref` to an `XlsxEditorRef`. @public */
136
+ declare const XlsxEditorRoot: react.ForwardRefExoticComponent<XlsxEditorRootProps & react.RefAttributes<XlsxEditorRef>>;
137
+ /** The props of `XlsxEditor.Viewport`. @public */
138
+ interface XlsxEditorViewportProps {
139
+ /** Appended after the `xlsx-editor` and `xlsx-editor-viewport` classes. */
140
+ readonly className?: string;
141
+ /**
142
+ * The name of the editor's landmark region. Default: "Workbook editor". `false` renders no
143
+ * region, for a host whose own landmarks are inside.
144
+ */
145
+ readonly label?: string | false;
146
+ /** Inline style, for example the editor's height. */
147
+ readonly style?: CSSProperties;
148
+ readonly children?: ReactNode;
149
+ }
150
+ /**
151
+ * The editor's styling scope and landmark region: carries the `.xlsx-editor` class, and
152
+ * `xlsx-editor-viewport`, which keeps its width from following its content. F6 and
153
+ * Shift+F6 inside it move the keyboard among the toolbar, the formula bar, the grid, and the
154
+ * footer.
155
+ *
156
+ * @public
157
+ */
158
+ declare function XlsxEditorViewport({ className, label, style, children }: XlsxEditorViewportProps): react.JSX.Element;
159
+ /** The props of `XlsxEditor.Content`. @public */
160
+ interface XlsxEditorContentProps {
161
+ /** Appended after the `xlsx-canvas` class. */
162
+ readonly className?: string;
163
+ }
164
+ /** The grid: attaches the editor's surface in a layout effect. @public */
165
+ declare function XlsxEditorContent({ className }: XlsxEditorContentProps): react.JSX.Element;
166
+
167
+ /** Props for `XlsxEditor`: the root's props and the viewport's class. @public */
168
+ interface XlsxEditorProps extends Omit<XlsxEditorRootProps, 'children'> {
169
+ /** Appended after the `xlsx-editor` and `xlsx-editor-viewport` classes. */
170
+ readonly className?: string;
171
+ /** Inline style of the viewport, for example its height. */
172
+ readonly style?: CSSProperties;
173
+ /**
174
+ * Receives the workbook as bytes of the opened package's kind (`snapshot().workbookKind`: a
175
+ * workbook or a template) when the toolbar's save control is pressed, or when the user presses
176
+ * Control or Command and S in the editor, also with the save control hidden. Without it, the
177
+ * save control is disabled with the engine's reason, and the browser keeps the shortcut. A
178
+ * refused save calls nothing: the snapshot holds the refusal with `command: 'save'`. The bytes
179
+ * arrive after the press, because a save runs in short tasks. `saved.stillOpen` is false when
180
+ * another open, `close()`, or `destroy()` ended the workbook during the save, and
181
+ * `saved.revision` is the revision of the bytes.
182
+ */
183
+ readonly onSave?: (bytes: Uint8Array<ArrayBuffer>, saved: SavedWorkbook) => void;
184
+ /**
185
+ * Called once when a press of the save control, or of Control or Command and S in the editor,
186
+ * starts a delivery to `onSave`. It gets the promise of the result, so you can show that the
187
+ * save runs. A press that joins the running save of an earlier press and a refused save do
188
+ * not call it. A press that joins a save from `saveInTasks` calls it, because that save has no
189
+ * delivery yet. The promise resolves to `null` when the save is refused later.
190
+ */
191
+ readonly onSaveStart?: (saving: Promise<SavedWorkbook | null>) => void;
192
+ /**
193
+ * Whether your page opens another workbook now, while the editor still shows the old one. While
194
+ * it is true, the save control is disabled and Control or Command and S starts no save. See the
195
+ * `opening` prop of `XlsxEditor.Toolbar`.
196
+ */
197
+ readonly opening?: boolean;
198
+ }
199
+
200
+ /** @jsxImportSource react */
201
+ /** Zoom out, the zoom level (press to reset to 100%), and zoom in. @public */
202
+ declare function ZoomControl(): react.JSX.Element | null;
203
+ /**
204
+ * The state of the editor when it shows no grid, the reason the last edit was refused, the
205
+ * stale-results notice, and the notice for conditional formatting that the grid can leave out
206
+ * (`conditionalHidden`). The engine's live region announces the refusal, so the refusal here
207
+ * has no live role: it is shown, not announced twice. @public
208
+ */
209
+ declare function StatusMessage(): react.JSX.Element;
210
+
211
+ /** @jsxImportSource react */
212
+ /**
213
+ * The active cell's reference and content, both editable. The content is formula text, or the
214
+ * value in a form that reads back, such as `2026-11-12` for a date. @public
215
+ */
216
+ declare function FormulaBar(): react.JSX.Element | null;
217
+
218
+ /** @jsxImportSource react */
219
+ /** One tab for each visible worksheet, in workbook order, with the sheet actions. @public */
220
+ declare function SheetTabs(): react.JSX.Element | null;
221
+
222
+ /** Props for `XlsxEditor.Toolbar.Slot`. @public */
223
+ interface XlsxEditorToolbarSlotProps {
224
+ /** The built-in slot that the part names, such as `'font.bold'`. */
225
+ readonly slotId: ChromeSlotId;
226
+ /**
227
+ * Removes the slot where it stands, as the toolbar's `hidden` list does. A group whose slots
228
+ * are all hidden is left out.
229
+ */
230
+ readonly hidden?: boolean;
231
+ /**
232
+ * Content that takes the slot's place: in the bar, and in the group's section of the "More"
233
+ * panel. Without children, the part renders the built-in control of the slot.
234
+ */
235
+ readonly children?: ReactNode;
236
+ }
237
+ /** Props for `XlsxEditor.Toolbar.Group`. @public */
238
+ interface XlsxEditorToolbarGroupProps {
239
+ /**
240
+ * The group id. A built-in id, such as `'font'` or `'file'`, adds the children to that group,
241
+ * after its own controls. Any other id makes a host group, which the bar measures and moves
242
+ * into the "More" panel as it moves its own groups.
243
+ */
244
+ readonly id: ChromeGroupId | (string & {});
245
+ /**
246
+ * The heading of a host group in the "More" panel, and its accessible name. It wins over
247
+ * `labelKey`. Without either, the heading is the `id`. A built-in group keeps its own label.
248
+ */
249
+ readonly label?: string;
250
+ /** A catalog key for the heading of a host group, translated with the toolbar's locale. */
251
+ readonly labelKey?: string;
252
+ /**
253
+ * The group that a host group follows in the bar. Without it, a host group follows every
254
+ * built-in group, in order of appearance. A built-in group keeps its place.
255
+ */
256
+ readonly after?: ChromeGroupId | (string & {});
257
+ /** Removes the group, built-in or host, from the bar and from the "More" panel. */
258
+ readonly hidden?: boolean;
259
+ /** Appended after the `xlsx-toolbar-group` class. */
260
+ readonly className?: string;
261
+ /**
262
+ * The controls of a host group, or the controls that a built-in group shows after its own.
263
+ * A host group with no children is left out.
264
+ */
265
+ readonly children?: ReactNode;
266
+ }
267
+ /**
268
+ * One slot of the toolbar. Under the preset toolbar, the part replaces its slot where it
269
+ * stands, or removes it with `hidden`. Anywhere else, such as in a host group or under
270
+ * `preset={false}`, it renders its children, or the built-in control of its slot. The toolbar
271
+ * reads a part only as its direct child or in a Fragment, not in a component of your own.
272
+ *
273
+ * @example
274
+ * ```tsx
275
+ * <XlsxEditor.Toolbar>
276
+ * <XlsxEditor.Toolbar.Slot slotId="file.save">
277
+ * <MySaveButton />
278
+ * </XlsxEditor.Toolbar.Slot>
279
+ * <XlsxEditor.Toolbar.Slot slotId="font.underline" hidden />
280
+ * </XlsxEditor.Toolbar>
281
+ * ```
282
+ *
283
+ * @public
284
+ */
285
+ declare function XlsxEditorToolbarSlot({ slotId, hidden, children }: XlsxEditorToolbarSlotProps): react.JSX.Element | null;
286
+ /**
287
+ * A group of the toolbar. Under the preset toolbar, a host group is measured with the built-in
288
+ * groups, moves into the "More" panel when it does not fit, and shows there as a section with
289
+ * its heading. A built-in id adds the children to that group, or removes the group with
290
+ * `hidden`. Under `preset={false}`, the part renders its children as one group. The toolbar
291
+ * reads a part only as its direct child or in a Fragment, not in a component of your own.
292
+ *
293
+ * @example
294
+ * ```tsx
295
+ * <XlsxEditor.Toolbar>
296
+ * <XlsxEditor.Toolbar.Group id="share" label="Share" after="file">
297
+ * <ShareButton />
298
+ * </XlsxEditor.Toolbar.Group>
299
+ * <XlsxEditor.Toolbar.Group id="borders" hidden />
300
+ * </XlsxEditor.Toolbar>
301
+ * ```
302
+ *
303
+ * @public
304
+ */
305
+ declare function XlsxEditorToolbarGroup(props: XlsxEditorToolbarGroupProps): react.JSX.Element | null;
306
+
307
+ /** @jsxImportSource react */
308
+
309
+ /** Props for `XlsxEditor.Toolbar`. @public */
310
+ interface XlsxEditorToolbarProps {
311
+ /**
312
+ * Receives the workbook as bytes of the opened package's kind (`snapshot().workbookKind`: a
313
+ * workbook or a template) when the save control is pressed, or when the user presses Control
314
+ * or Command and S in the editor, also with the save control hidden. Without it, the save
315
+ * control is disabled with the engine's reason, and the browser keeps the shortcut. A refused
316
+ * save calls nothing: the snapshot holds the refusal with `command: 'save'`. The bytes arrive
317
+ * after the press, because a save runs in short tasks. `saved.stillOpen` is false when
318
+ * another open, `close()`, or `destroy()` ended the workbook during the save, and
319
+ * `saved.revision` is the revision of the bytes.
320
+ */
321
+ readonly onSave?: (bytes: Uint8Array<ArrayBuffer>, saved: SavedWorkbook) => void;
322
+ /**
323
+ * Called once when a press of the save control, or of Control or Command and S in the editor,
324
+ * starts a delivery to `onSave`. It gets the promise of the result, so you can show that the
325
+ * save runs. A press that joins the running save of an earlier press and a refused save do
326
+ * not call it. A press that joins a save from `saveInTasks` calls it, because that save has no
327
+ * delivery yet. The promise resolves to `null` when the save is refused later.
328
+ */
329
+ readonly onSaveStart?: (saving: Promise<SavedWorkbook | null>) => void;
330
+ /**
331
+ * Whether your page opens another workbook now, while the editor still shows the old one: for
332
+ * example during a download or a file read before `load`. While it is true, the save control
333
+ * is disabled with the reason that a workbook is loading, and Control or Command and S in the
334
+ * editor starts no save work. After such a press, and only then, the snapshot holds the
335
+ * refusal `loading`, with `command: 'save'`. A press reads the value of the latest render. When
336
+ * it changes to false, the toolbar forgets that refusal and keeps any other refusal. The default
337
+ * is `false`. Pass a boolean from your state, as the other props of the toolbar.
338
+ */
339
+ readonly opening?: boolean;
340
+ /**
341
+ * `false` wraps the controls onto more rows instead of moving the groups that do not fit
342
+ * into the "More" panel. It has no effect with `preset={false}`, which always wraps.
343
+ */
344
+ readonly overflow?: boolean;
345
+ /**
346
+ * `false` renders only the children, in their order, with no measure and no "More" panel. An
347
+ * `XlsxEditor.Toolbar.Slot` there renders the built-in control of its slot, or its children.
348
+ * The default is `true`: the groups of `CHROME_GROUPS`, changed by the children.
349
+ */
350
+ readonly preset?: boolean;
351
+ /**
352
+ * Parts that change the preset bar. `XlsxEditor.Toolbar.Slot` replaces or hides one slot
353
+ * where it stands, and `XlsxEditor.Toolbar.Group` adds a host group or changes a built-in
354
+ * group. The last part for a slot or a group wins. Other children show in one block after
355
+ * the groups, which never moves into the "More" panel.
356
+ */
357
+ readonly children?: ReactNode;
358
+ /** Appended after the `xlsx-toolbar` class. */
359
+ readonly className?: string;
360
+ /**
361
+ * Slot ids to leave out, such as `['file.save']`. A group whose slots are all hidden is left
362
+ * out with its separator. The order of the list does not matter.
363
+ */
364
+ readonly hidden?: readonly ChromeSlotId[];
365
+ }
366
+ /** The toolbar with its parts as statics. @public */
367
+ interface XlsxEditorToolbarNamespace {
368
+ /** The toolbar. */
369
+ (props: XlsxEditorToolbarProps): ReactElement;
370
+ /** Replaces or hides one slot where it stands, or renders its built-in control. */
371
+ readonly Slot: typeof XlsxEditorToolbarSlot;
372
+ /** A host group that the bar measures and collapses, or a change of a built-in group. */
373
+ readonly Group: typeof XlsxEditorToolbarGroup;
374
+ }
375
+ /**
376
+ * The editing toolbar: every group of the chrome registry in bar order. Place it inside
377
+ * `XlsxEditor.Viewport`, which carries the styling scope. Its parts change the bar:
378
+ * `XlsxEditor.Toolbar.Slot` and `XlsxEditor.Toolbar.Group`.
379
+ *
380
+ * @example
381
+ * ```tsx
382
+ * <XlsxEditor.Toolbar onSave={upload}>
383
+ * <XlsxEditor.Toolbar.Slot slotId="font.underline" hidden />
384
+ * <XlsxEditor.Toolbar.Group id="share" label="Share">
385
+ * <ShareButton />
386
+ * </XlsxEditor.Toolbar.Group>
387
+ * </XlsxEditor.Toolbar>
388
+ * ```
389
+ *
390
+ * @public
391
+ */
392
+ declare const XlsxEditorToolbar: XlsxEditorToolbarNamespace;
393
+
394
+ /**
395
+ * What {@link useEditorColorMode} returns.
396
+ *
397
+ * @public
398
+ */
399
+ interface UseEditorColorModeReturn {
400
+ /**
401
+ * The resolved theme: `'dark'` or `'light'`. Re-renders when `colorMode` or the OS setting
402
+ * changes.
403
+ */
404
+ readonly colorMode: ResolvedColorMode;
405
+ }
406
+ /**
407
+ * The theme the enclosing `XlsxEditor.Root` resolved from its `colorMode`, so parts you build
408
+ * yourself can match the editor chrome, as DOCX Editor's hook of this name does. `'system'`
409
+ * resolves to the operating system's current setting and re-renders when it changes. Outside a
410
+ * `Root`, or without `colorMode`, the answer is `'light'`.
411
+ *
412
+ * @example
413
+ * ```tsx
414
+ * function MyPanel() {
415
+ * const { colorMode } = useEditorColorMode();
416
+ * return <aside className={colorMode === 'dark' ? 'panel panel--dark' : 'panel'} />;
417
+ * }
418
+ * ```
419
+ *
420
+ * @public
421
+ */
422
+ declare function useEditorColorMode(): UseEditorColorModeReturn;
423
+ /**
424
+ * The scope classes that a part you build yourself adds to its own root element, so the editor's
425
+ * `--doc-*` tokens and chrome styles apply to it, as DOCX Editor's `useScopeClassName`. Inside
426
+ * `XlsxEditor.Viewport` it is `''`: the viewport already carries the scope. Outside it, it is
427
+ * `'xlsx-editor '`, or `'xlsx-editor dark '` when the root's `colorMode` resolved dark, and it
428
+ * re-renders when that changes. Outside a root, it is `'xlsx-editor '`. A part inside the
429
+ * viewport that portals out of it (to `document.body`) adds `xlsx-editor` itself, with
430
+ * `useEditorColorMode` for the theme.
431
+ *
432
+ * The value ends with a space, so it concatenates cleanly, and `''` collapses away.
433
+ *
434
+ * @example
435
+ * ```tsx
436
+ * const scope = useScopeClassName();
437
+ * <aside className={`${scope}my-panel`} />
438
+ * ```
439
+ *
440
+ * @public
441
+ */
442
+ declare function useScopeClassName(): '' | 'xlsx-editor ' | 'xlsx-editor dark ';
443
+
444
+ /** The editor published by `XlsxEditor.Root`. @public */
445
+ declare const XlsxEditorContext: react.Context<XlsxEditorInstance | null>;
446
+ /** A translator over a locale catalog: missing or `null` entries fall back to English. @public */
447
+ declare function translatorFor(locale: Translations | undefined): TFunction;
448
+ /** The translator published by `XlsxEditor.Root` (English by default). @public */
449
+ declare const TranslationContext: react.Context<TFunction>;
450
+ /** The editor, or null before it mounts. @public */
451
+ declare function useXlsxEditor(): XlsxEditorInstance | null;
452
+ /** The translator of the enclosing root. @public */
453
+ declare function useTranslation(): {
454
+ readonly t: TFunction;
455
+ };
456
+ /**
457
+ * Whether a change of the root's `mode` prop to view mode waits for the open cell edit, as
458
+ * `XlsxEditor.StatusMessage` shows it. For a layout that shows the wait in its own chrome.
459
+ *
460
+ * @public
461
+ */
462
+ declare function useViewModeWaits(): boolean;
463
+ /**
464
+ * A slice of the editor's state, after DOCX Editor's `useEditorState`. The component re-renders
465
+ * only when `selector`'s result changes by `isEqual` (default `Object.is`). Before the editor
466
+ * mounts, the selector reads an empty snapshot with the root's `mode`, never `null`.
467
+ *
468
+ * @public
469
+ */
470
+ declare function useEditorState<T>(selector: (snapshot: EditorSnapshot) => T, isEqual?: (a: T, b: T) => boolean): T;
471
+ /**
472
+ * The editor's whole state, re-read after each change. Before it mounts, an empty snapshot
473
+ * with the root's `mode`.
474
+ *
475
+ * @public
476
+ */
477
+ declare function useEditorSnapshot(): EditorSnapshot;
478
+
479
+ /**
480
+ * The live state of one chrome slot, and its action.
481
+ *
482
+ * @public
483
+ */
484
+ interface EditorCommandState {
485
+ /**
486
+ * Run the slot's command. Pass the picked value of a value slot, such as `'Arial'` for
487
+ * `font.family` or `'FF0000'` for `font.color`.
488
+ *
489
+ * @returns `true` when the editor ran the command; `false` when it refused it, or before
490
+ * the editor mounts.
491
+ */
492
+ readonly execute: (value?: string) => boolean;
493
+ /** Whether the command is applied at the active cell, such as bold on a bold cell. */
494
+ readonly isActive: boolean;
495
+ /** Whether the editor runs the command now. */
496
+ readonly isEnabled: boolean;
497
+ /** The engine's reason when the command is disabled, translated. Null when it is enabled. */
498
+ readonly disabledReason: string | null;
499
+ /**
500
+ * The engine's hint for an enabled command, translated, or null. The text of
501
+ * `hint.conditionalFormat` means that a true conditional formatting rule shows another state
502
+ * of this control at the active cell; the command still reads and sets the cell format.
503
+ */
504
+ readonly hint: string | null;
505
+ /**
506
+ * What a value slot shows: the font name, the size in points, the color as `RRGGBB` (or
507
+ * `none` for no fill), the number format choice, or the format code of the active cell for
508
+ * `number.custom`. Null for a slot that has no value.
509
+ */
510
+ readonly value: string | null;
511
+ }
512
+ /**
513
+ * Bind a chrome slot, such as `font.bold` or `history.undo`, to the editor. The component
514
+ * re-renders only when the slot's own state changes, and the result keeps its identity while
515
+ * its fields are equal.
516
+ *
517
+ * `file.save` hands the bytes to the `onSave` of the enclosing toolbar. Outside a toolbar it is
518
+ * disabled: call `save()` on the editor ref instead.
519
+ *
520
+ * @public
521
+ */
522
+ declare function useEditorCommand(slot: ChromeSlotId): EditorCommandState;
523
+
524
+ /**
525
+ * Subscribe to an editor event (`'change'`, `'selectionChange'`, `'rejection'`,
526
+ * `'openFailure'`) for the lifetime of the component. It does nothing until the nearest
527
+ * `XlsxEditor.Root` creates the editor, and subscribes again when the instance changes. A new
528
+ * handler on each render does not subscribe again; the latest one is called.
529
+ *
530
+ * `'change'` fires only when the workbook content changes. The root's `onChange` prop fires
531
+ * after every state change, also a selection or a zoom change.
532
+ *
533
+ * @example
534
+ * ```tsx
535
+ * const { t } = useTranslation();
536
+ * useEditorEvent('rejection', (refusal, snapshot) =>
537
+ * toast(refusalText(refusal, t, snapshot.numberLocale))
538
+ * );
539
+ * ```
540
+ *
541
+ * @public
542
+ */
543
+ declare function useEditorEvent<E extends keyof EditorEvents>(event: E, handler: EditorEvents[E]): void;
544
+
545
+ /**
546
+ * `@xlsx-editor.dev/react`: the React adapter for XLSX Editor.
547
+ *
548
+ * Provider-first, after PPTX Editor's adapter: `XlsxEditor.Root` owns the editor instance,
549
+ * `.Viewport` scopes the styles, and `.Content` attaches the grid surface. Every piece of chrome
550
+ * is a hook consumer; `.Toolbar` renders the chrome registry. `XlsxEditor` composes them all.
551
+ *
552
+ * @packageDocumentation
553
+ * @public
554
+ */
555
+
556
+ /**
557
+ * The type of `XlsxEditor`: the composed editor, and its parts as statics for a custom layout.
558
+ * Each part is also exported by its own name.
559
+ *
560
+ * @public
561
+ */
562
+ interface XlsxEditorNamespace extends ForwardRefExoticComponent<XlsxEditorProps & RefAttributes<XlsxEditorRef>> {
563
+ readonly Root: typeof XlsxEditorRoot;
564
+ readonly Viewport: typeof XlsxEditorViewport;
565
+ readonly Content: typeof XlsxEditorContent;
566
+ readonly Toolbar: typeof XlsxEditorToolbar;
567
+ readonly FormulaBar: typeof FormulaBar;
568
+ readonly SheetTabs: typeof SheetTabs;
569
+ readonly ZoomControl: typeof ZoomControl;
570
+ readonly StatusMessage: typeof StatusMessage;
571
+ }
572
+ /** The composed editor, with its parts for a custom layout. @public */
573
+ declare const XlsxEditor: XlsxEditorNamespace;
574
+
575
+ export { FormulaBar, SheetTabs, StatusMessage, TranslationContext, XlsxEditor, XlsxEditorContent, XlsxEditorContext, XlsxEditorRoot, XlsxEditorToolbar, XlsxEditorToolbarGroup, XlsxEditorToolbarSlot, XlsxEditorViewport, ZoomControl, translatorFor, useEditorColorMode, useEditorCommand, useEditorEvent, useEditorSnapshot, useEditorState, useScopeClassName, useTranslation, useViewModeWaits, useXlsxEditor };
576
+ export type { EditorCommandState, UseEditorColorModeReturn, XlsxEditorContentProps, XlsxEditorFonts, XlsxEditorNamespace, XlsxEditorProps, XlsxEditorRef, XlsxEditorRootProps, XlsxEditorToolbarGroupProps, XlsxEditorToolbarNamespace, XlsxEditorToolbarProps, XlsxEditorToolbarSlotProps, XlsxEditorViewportProps };