@extend-ai/react-xlsx 0.17.3 → 0.18.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/README.md +41 -0
- package/dist/index.cjs +1321 -891
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +1321 -891
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -396,6 +396,47 @@ Supported references include single cells (`A1`), rectangles (`B2:E8`), absolute
|
|
|
396
396
|
|
|
397
397
|
Each string must contain one rectangular A1 reference, not named ranges, structured table references, unions, R1C1 notation, external workbooks, or references spanning multiple worksheets. Whole-row/column highlights cover the displayed grid and extend as it grows.
|
|
398
398
|
|
|
399
|
+
## Context Menus
|
|
400
|
+
|
|
401
|
+
Right-click a worksheet cell, row header, column header, or the top-left corner to open the context menu. Right-clicking inside a selection preserves the range. Shift+F10 or the context-menu key opens it at the active cell; arrow keys navigate and Escape dismisses it.
|
|
402
|
+
|
|
403
|
+
Viewer mode (`readOnly`) offers Copy and selection actions. Editor mode also offers Cut, Paste, Edit cell, Clear contents, Undo/Redo, Merge/Unmerge, and sorting when the target belongs to a table. Actions use the existing controller and undo history. Row and column selections span the displayed grid, matching header selection. Worker-backed viewers copy tab-separated text; editable workbooks also preserve structured cell data when the browser supports custom clipboard formats. Clipboard commands require browser clipboard access; failed operations display an error and Cut only clears cells after copying succeeds.
|
|
404
|
+
|
|
405
|
+
Customize the existing menu with `contextMenuClassName`, `contextMenuStyle`, and CSS variables, or replace its contents with `renderContextMenu`:
|
|
406
|
+
|
|
407
|
+
```tsx
|
|
408
|
+
<XlsxViewer
|
|
409
|
+
file={file}
|
|
410
|
+
contextMenuClassName="spreadsheet-menu"
|
|
411
|
+
contextMenuStyle={{ borderRadius: 6 }}
|
|
412
|
+
renderContextMenu={({ context, actions, runAction, closeMenu, busy }) => (
|
|
413
|
+
<>
|
|
414
|
+
{actions.map((action) => (
|
|
415
|
+
<button
|
|
416
|
+
key={action.id}
|
|
417
|
+
type="button"
|
|
418
|
+
role="menuitem"
|
|
419
|
+
disabled={busy || action.disabled}
|
|
420
|
+
onClick={() => void runAction(action.id)}
|
|
421
|
+
>
|
|
422
|
+
{action.label}
|
|
423
|
+
</button>
|
|
424
|
+
))}
|
|
425
|
+
<button type="button" role="menuitem" onClick={() => {
|
|
426
|
+
inspectSelection(context.selection);
|
|
427
|
+
closeMenu();
|
|
428
|
+
}}>
|
|
429
|
+
Inspect selection
|
|
430
|
+
</button>
|
|
431
|
+
</>
|
|
432
|
+
)}
|
|
433
|
+
/>
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
The hook receives `context` (target kind, cell, selection, sheet index/name, and read-only state), `actions`, `runAction`, `closeMenu`, viewport `position`, `isDark`, `busy`, `error`, and `defaultNode`. Return `defaultNode` to keep built-in buttons while adding your own content. The viewer owns the portal, viewport-edge positioning, outside-click dismissal, and keyboard navigation for elements with `role="menuitem"`; return menu contents without another portal. `runAction` returns `Promise<boolean>` and rejects unavailable or disabled commands. Handle custom commands in your own callback and call `closeMenu` afterward.
|
|
437
|
+
|
|
438
|
+
Default styling follows the document theme. Override `.react-xlsx-context-menu`, `.react-xlsx-context-menu-item`, `.react-xlsx-context-menu-separator`, and `.react-xlsx-context-menu-shortcut`, or set `--xlsx-context-menu-background`, `--xlsx-context-menu-color`, `--xlsx-context-menu-border`, `--xlsx-context-menu-hover`, `--xlsx-context-menu-muted`, and `--xlsx-context-menu-danger` through `contextMenuStyle`. The menu is portaled to the document body, so use its class rather than a viewer-descendant selector. Set `enableContextMenu={false}` to retain the browser's native context menu.
|
|
439
|
+
|
|
399
440
|
## Custom Rendering
|
|
400
441
|
|
|
401
442
|
The viewer exposes render props for common UI integration points.
|