@particle-academy/fancy-sheets 0.4.6 → 0.5.1

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.cts CHANGED
@@ -18,6 +18,20 @@ interface CellFormat {
18
18
  displayFormat?: CellDisplayFormat;
19
19
  /** Number of decimal places to display (for number/currency/percentage) */
20
20
  decimals?: number;
21
+ /** Background color (any CSS color value) */
22
+ backgroundColor?: string;
23
+ /** Font color (any CSS color value) */
24
+ color?: string;
25
+ /** Font size in pixels */
26
+ fontSize?: number;
27
+ /** Top border color (renders 1px solid) */
28
+ borderTop?: string;
29
+ /** Right border color */
30
+ borderRight?: string;
31
+ /** Bottom border color */
32
+ borderBottom?: string;
33
+ /** Left border color (renders 1px solid) */
34
+ borderLeft?: string;
21
35
  }
22
36
  /** A single cell's complete data */
23
37
  interface CellData {
@@ -76,6 +90,17 @@ interface SelectionState {
76
90
  ranges: CellRange[];
77
91
  }
78
92
 
93
+ /** Custom context menu item for right-click menus */
94
+ interface SpreadsheetContextMenuItem {
95
+ /** Display label */
96
+ label: string;
97
+ /** Called with the active cell address when the item is clicked */
98
+ onClick: (address: string) => void;
99
+ /** Whether the item is disabled — static or per-cell function */
100
+ disabled?: boolean | ((address: string) => boolean);
101
+ /** Render with danger styling */
102
+ danger?: boolean;
103
+ }
79
104
  interface SpreadsheetProps {
80
105
  children: ReactNode;
81
106
  className?: string;
@@ -95,6 +120,8 @@ interface SpreadsheetProps {
95
120
  rowHeight?: number;
96
121
  /** Read-only mode */
97
122
  readOnly?: boolean;
123
+ /** Custom context menu items appended after built-in items */
124
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
98
125
  }
99
126
  interface SpreadsheetContextValue {
100
127
  workbook: WorkbookData;
@@ -132,6 +159,8 @@ interface SpreadsheetContextValue {
132
159
  getColumnWidth: (col: number) => number;
133
160
  isCellSelected: (address: string) => boolean;
134
161
  isCellActive: (address: string) => boolean;
162
+ /** Custom context menu items from consumer */
163
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
135
164
  /** @internal drag-to-select state */
136
165
  _isDragging: React.RefObject<boolean>;
137
166
  }
@@ -147,8 +176,10 @@ declare namespace SpreadsheetGrid {
147
176
  interface SpreadsheetToolbarProps {
148
177
  children?: React.ReactNode;
149
178
  className?: string;
179
+ /** Additional toolbar content appended after default buttons */
180
+ extra?: React.ReactNode;
150
181
  }
151
- declare function SpreadsheetToolbar({ children, className }: SpreadsheetToolbarProps): react_jsx_runtime.JSX.Element;
182
+ declare function SpreadsheetToolbar({ children, className, extra }: SpreadsheetToolbarProps): react_jsx_runtime.JSX.Element;
152
183
  declare namespace SpreadsheetToolbar {
153
184
  var displayName: string;
154
185
  }
@@ -161,7 +192,7 @@ declare namespace SpreadsheetSheetTabs {
161
192
  var displayName: string;
162
193
  }
163
194
 
164
- declare function SpreadsheetRoot({ children, className, data, defaultData, onChange, columnCount, rowCount, defaultColumnWidth, rowHeight, readOnly, }: SpreadsheetProps): react_jsx_runtime.JSX.Element;
195
+ declare function SpreadsheetRoot({ children, className, data, defaultData, onChange, columnCount, rowCount, defaultColumnWidth, rowHeight, readOnly, contextMenuItems, }: SpreadsheetProps): react_jsx_runtime.JSX.Element;
165
196
  declare namespace SpreadsheetRoot {
166
197
  var displayName: string;
167
198
  }
@@ -173,6 +204,62 @@ declare const Spreadsheet: typeof SpreadsheetRoot & {
173
204
 
174
205
  declare function useSpreadsheet(): SpreadsheetContextValue;
175
206
 
207
+ interface SheetProps {
208
+ /** Single sheet data (controlled) */
209
+ data?: SheetData;
210
+ /** Called when sheet data changes */
211
+ onChange?: (data: SheetData) => void;
212
+ className?: string;
213
+ /** Number of columns (default: 26) */
214
+ columnCount?: number;
215
+ /** Number of rows (default: 100) */
216
+ rowCount?: number;
217
+ /** Default column width in px (default: 100) */
218
+ defaultColumnWidth?: number;
219
+ /** Row height in px (default: 28) */
220
+ rowHeight?: number;
221
+ /** Read-only mode */
222
+ readOnly?: boolean;
223
+ /** Custom context menu items */
224
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
225
+ }
226
+ declare function Sheet({ data, onChange, contextMenuItems, ...props }: SheetProps): react_jsx_runtime.JSX.Element;
227
+ declare namespace Sheet {
228
+ var displayName: string;
229
+ }
230
+
231
+ interface SheetWorkbookProps {
232
+ /** Controlled workbook data */
233
+ data?: WorkbookData;
234
+ /** Default data (uncontrolled) */
235
+ defaultData?: WorkbookData;
236
+ /** Called on any data change */
237
+ onChange?: (data: WorkbookData) => void;
238
+ className?: string;
239
+ /** Number of columns (default: 26) */
240
+ columnCount?: number;
241
+ /** Number of rows (default: 100) */
242
+ rowCount?: number;
243
+ /** Default column width in px (default: 100) */
244
+ defaultColumnWidth?: number;
245
+ /** Row height in px (default: 28) */
246
+ rowHeight?: number;
247
+ /** Read-only mode */
248
+ readOnly?: boolean;
249
+ /** Hide the toolbar (default: false) */
250
+ hideToolbar?: boolean;
251
+ /** Hide the sheet tabs (default: false) */
252
+ hideTabs?: boolean;
253
+ /** Extra content appended to the default toolbar */
254
+ toolbarExtra?: ReactNode;
255
+ /** Custom context menu items */
256
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
257
+ }
258
+ declare function SheetWorkbook({ hideToolbar, hideTabs, toolbarExtra, contextMenuItems, ...props }: SheetWorkbookProps): react_jsx_runtime.JSX.Element;
259
+ declare namespace SheetWorkbook {
260
+ var displayName: string;
261
+ }
262
+
176
263
  /** Convert 0-based column index to letter(s): 0="A", 25="Z", 26="AA" */
177
264
  declare function columnToLetter(col: number): string;
178
265
  /** Convert column letter(s) to 0-based index: "A"=0, "Z"=25, "AA"=26 */
@@ -197,4 +284,4 @@ declare function workbookToCSV(workbook: WorkbookData, sheetId?: string): string
197
284
  type FormulaRangeFunction = (args: CellValue[][]) => CellValue;
198
285
  declare function registerFunction(name: string, fn: FormulaRangeFunction): void;
199
286
 
200
- export { type CellAddress, type CellData, type CellFormat, type CellMap, type CellRange, type CellValue, type ColumnWidths, type MergedRegion, type SelectionState, type SheetData, Spreadsheet, type SpreadsheetContextValue, type SpreadsheetProps, type TextAlign, type WorkbookData, columnToLetter, createEmptySheet, createEmptyWorkbook, csvToWorkbook, letterToColumn, parseAddress, parseCSV, registerFunction, stringifyCSV, toAddress, useSpreadsheet, workbookToCSV };
287
+ export { type CellAddress, type CellData, type CellFormat, type CellMap, type CellRange, type CellValue, type ColumnWidths, type FormulaRangeFunction, type MergedRegion, type SelectionState, Sheet, type SheetData, type SheetProps, SheetWorkbook, type SheetWorkbookProps, Spreadsheet, type SpreadsheetContextMenuItem, type SpreadsheetContextValue, type SpreadsheetProps, type TextAlign, type WorkbookData, columnToLetter, createEmptySheet, createEmptyWorkbook, csvToWorkbook, letterToColumn, parseAddress, parseCSV, registerFunction, stringifyCSV, toAddress, useSpreadsheet, workbookToCSV };
package/dist/index.d.ts CHANGED
@@ -18,6 +18,20 @@ interface CellFormat {
18
18
  displayFormat?: CellDisplayFormat;
19
19
  /** Number of decimal places to display (for number/currency/percentage) */
20
20
  decimals?: number;
21
+ /** Background color (any CSS color value) */
22
+ backgroundColor?: string;
23
+ /** Font color (any CSS color value) */
24
+ color?: string;
25
+ /** Font size in pixels */
26
+ fontSize?: number;
27
+ /** Top border color (renders 1px solid) */
28
+ borderTop?: string;
29
+ /** Right border color */
30
+ borderRight?: string;
31
+ /** Bottom border color */
32
+ borderBottom?: string;
33
+ /** Left border color (renders 1px solid) */
34
+ borderLeft?: string;
21
35
  }
22
36
  /** A single cell's complete data */
23
37
  interface CellData {
@@ -76,6 +90,17 @@ interface SelectionState {
76
90
  ranges: CellRange[];
77
91
  }
78
92
 
93
+ /** Custom context menu item for right-click menus */
94
+ interface SpreadsheetContextMenuItem {
95
+ /** Display label */
96
+ label: string;
97
+ /** Called with the active cell address when the item is clicked */
98
+ onClick: (address: string) => void;
99
+ /** Whether the item is disabled — static or per-cell function */
100
+ disabled?: boolean | ((address: string) => boolean);
101
+ /** Render with danger styling */
102
+ danger?: boolean;
103
+ }
79
104
  interface SpreadsheetProps {
80
105
  children: ReactNode;
81
106
  className?: string;
@@ -95,6 +120,8 @@ interface SpreadsheetProps {
95
120
  rowHeight?: number;
96
121
  /** Read-only mode */
97
122
  readOnly?: boolean;
123
+ /** Custom context menu items appended after built-in items */
124
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
98
125
  }
99
126
  interface SpreadsheetContextValue {
100
127
  workbook: WorkbookData;
@@ -132,6 +159,8 @@ interface SpreadsheetContextValue {
132
159
  getColumnWidth: (col: number) => number;
133
160
  isCellSelected: (address: string) => boolean;
134
161
  isCellActive: (address: string) => boolean;
162
+ /** Custom context menu items from consumer */
163
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
135
164
  /** @internal drag-to-select state */
136
165
  _isDragging: React.RefObject<boolean>;
137
166
  }
@@ -147,8 +176,10 @@ declare namespace SpreadsheetGrid {
147
176
  interface SpreadsheetToolbarProps {
148
177
  children?: React.ReactNode;
149
178
  className?: string;
179
+ /** Additional toolbar content appended after default buttons */
180
+ extra?: React.ReactNode;
150
181
  }
151
- declare function SpreadsheetToolbar({ children, className }: SpreadsheetToolbarProps): react_jsx_runtime.JSX.Element;
182
+ declare function SpreadsheetToolbar({ children, className, extra }: SpreadsheetToolbarProps): react_jsx_runtime.JSX.Element;
152
183
  declare namespace SpreadsheetToolbar {
153
184
  var displayName: string;
154
185
  }
@@ -161,7 +192,7 @@ declare namespace SpreadsheetSheetTabs {
161
192
  var displayName: string;
162
193
  }
163
194
 
164
- declare function SpreadsheetRoot({ children, className, data, defaultData, onChange, columnCount, rowCount, defaultColumnWidth, rowHeight, readOnly, }: SpreadsheetProps): react_jsx_runtime.JSX.Element;
195
+ declare function SpreadsheetRoot({ children, className, data, defaultData, onChange, columnCount, rowCount, defaultColumnWidth, rowHeight, readOnly, contextMenuItems, }: SpreadsheetProps): react_jsx_runtime.JSX.Element;
165
196
  declare namespace SpreadsheetRoot {
166
197
  var displayName: string;
167
198
  }
@@ -173,6 +204,62 @@ declare const Spreadsheet: typeof SpreadsheetRoot & {
173
204
 
174
205
  declare function useSpreadsheet(): SpreadsheetContextValue;
175
206
 
207
+ interface SheetProps {
208
+ /** Single sheet data (controlled) */
209
+ data?: SheetData;
210
+ /** Called when sheet data changes */
211
+ onChange?: (data: SheetData) => void;
212
+ className?: string;
213
+ /** Number of columns (default: 26) */
214
+ columnCount?: number;
215
+ /** Number of rows (default: 100) */
216
+ rowCount?: number;
217
+ /** Default column width in px (default: 100) */
218
+ defaultColumnWidth?: number;
219
+ /** Row height in px (default: 28) */
220
+ rowHeight?: number;
221
+ /** Read-only mode */
222
+ readOnly?: boolean;
223
+ /** Custom context menu items */
224
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
225
+ }
226
+ declare function Sheet({ data, onChange, contextMenuItems, ...props }: SheetProps): react_jsx_runtime.JSX.Element;
227
+ declare namespace Sheet {
228
+ var displayName: string;
229
+ }
230
+
231
+ interface SheetWorkbookProps {
232
+ /** Controlled workbook data */
233
+ data?: WorkbookData;
234
+ /** Default data (uncontrolled) */
235
+ defaultData?: WorkbookData;
236
+ /** Called on any data change */
237
+ onChange?: (data: WorkbookData) => void;
238
+ className?: string;
239
+ /** Number of columns (default: 26) */
240
+ columnCount?: number;
241
+ /** Number of rows (default: 100) */
242
+ rowCount?: number;
243
+ /** Default column width in px (default: 100) */
244
+ defaultColumnWidth?: number;
245
+ /** Row height in px (default: 28) */
246
+ rowHeight?: number;
247
+ /** Read-only mode */
248
+ readOnly?: boolean;
249
+ /** Hide the toolbar (default: false) */
250
+ hideToolbar?: boolean;
251
+ /** Hide the sheet tabs (default: false) */
252
+ hideTabs?: boolean;
253
+ /** Extra content appended to the default toolbar */
254
+ toolbarExtra?: ReactNode;
255
+ /** Custom context menu items */
256
+ contextMenuItems?: SpreadsheetContextMenuItem[] | ((address: string) => SpreadsheetContextMenuItem[]);
257
+ }
258
+ declare function SheetWorkbook({ hideToolbar, hideTabs, toolbarExtra, contextMenuItems, ...props }: SheetWorkbookProps): react_jsx_runtime.JSX.Element;
259
+ declare namespace SheetWorkbook {
260
+ var displayName: string;
261
+ }
262
+
176
263
  /** Convert 0-based column index to letter(s): 0="A", 25="Z", 26="AA" */
177
264
  declare function columnToLetter(col: number): string;
178
265
  /** Convert column letter(s) to 0-based index: "A"=0, "Z"=25, "AA"=26 */
@@ -197,4 +284,4 @@ declare function workbookToCSV(workbook: WorkbookData, sheetId?: string): string
197
284
  type FormulaRangeFunction = (args: CellValue[][]) => CellValue;
198
285
  declare function registerFunction(name: string, fn: FormulaRangeFunction): void;
199
286
 
200
- export { type CellAddress, type CellData, type CellFormat, type CellMap, type CellRange, type CellValue, type ColumnWidths, type MergedRegion, type SelectionState, type SheetData, Spreadsheet, type SpreadsheetContextValue, type SpreadsheetProps, type TextAlign, type WorkbookData, columnToLetter, createEmptySheet, createEmptyWorkbook, csvToWorkbook, letterToColumn, parseAddress, parseCSV, registerFunction, stringifyCSV, toAddress, useSpreadsheet, workbookToCSV };
287
+ export { type CellAddress, type CellData, type CellFormat, type CellMap, type CellRange, type CellValue, type ColumnWidths, type FormulaRangeFunction, type MergedRegion, type SelectionState, Sheet, type SheetData, type SheetProps, SheetWorkbook, type SheetWorkbookProps, Spreadsheet, type SpreadsheetContextMenuItem, type SpreadsheetContextValue, type SpreadsheetProps, type TextAlign, type WorkbookData, columnToLetter, createEmptySheet, createEmptyWorkbook, csvToWorkbook, letterToColumn, parseAddress, parseCSV, registerFunction, stringifyCSV, toAddress, useSpreadsheet, workbookToCSV };
package/dist/index.js CHANGED
@@ -1836,6 +1836,24 @@ var Cell = memo(function Cell2({ address, row, col }) {
1836
1836
  if (cell?.format?.bold) formatStyle.fontWeight = "bold";
1837
1837
  if (cell?.format?.italic) formatStyle.fontStyle = "italic";
1838
1838
  if (cell?.format?.textAlign) formatStyle.textAlign = cell.format.textAlign;
1839
+ if (cell?.format?.backgroundColor) {
1840
+ formatStyle.backgroundColor = cell.format.backgroundColor;
1841
+ if (!cell.format.color) formatStyle.color = "#1f2937";
1842
+ }
1843
+ if (cell?.format?.color) formatStyle.color = cell.format.color;
1844
+ if (cell?.format?.fontSize) formatStyle.fontSize = cell.format.fontSize;
1845
+ if (cell?.format?.borderTop) {
1846
+ formatStyle.borderTopWidth = 1;
1847
+ formatStyle.borderTopStyle = "solid";
1848
+ formatStyle.borderTopColor = cell.format.borderTop;
1849
+ }
1850
+ if (cell?.format?.borderRight) formatStyle.borderRightColor = cell.format.borderRight;
1851
+ if (cell?.format?.borderBottom) formatStyle.borderBottomColor = cell.format.borderBottom;
1852
+ if (cell?.format?.borderLeft) {
1853
+ formatStyle.borderLeftWidth = 1;
1854
+ formatStyle.borderLeftStyle = "solid";
1855
+ formatStyle.borderLeftColor = cell.format.borderLeft;
1856
+ }
1839
1857
  return /* @__PURE__ */ jsx(
1840
1858
  "div",
1841
1859
  {
@@ -1995,7 +2013,8 @@ function SpreadsheetGrid({ className }) {
1995
2013
  setFrozenCols,
1996
2014
  extendSelection,
1997
2015
  undo,
1998
- redo
2016
+ redo,
2017
+ contextMenuItems
1999
2018
  } = useSpreadsheet();
2000
2019
  const containerRef = useRef(null);
2001
2020
  const handleKeyDown = useCallback(
@@ -2188,14 +2207,31 @@ function SpreadsheetGrid({ className }) {
2188
2207
  /* @__PURE__ */ jsx(ContextMenu.Item, { onClick: () => {
2189
2208
  const col = parseAddress(selection.activeCell).col;
2190
2209
  setFrozenCols(activeSheet.frozenCols > 0 ? 0 : col);
2191
- }, disabled: readOnly, children: activeSheet.frozenCols > 0 ? "Unfreeze columns" : "Freeze columns left" })
2210
+ }, disabled: readOnly, children: activeSheet.frozenCols > 0 ? "Unfreeze columns" : "Freeze columns left" }),
2211
+ (() => {
2212
+ const items = typeof contextMenuItems === "function" ? contextMenuItems(selection.activeCell) : contextMenuItems;
2213
+ if (!items || items.length === 0) return null;
2214
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
2215
+ /* @__PURE__ */ jsx(ContextMenu.Separator, {}),
2216
+ items.map((item, i) => /* @__PURE__ */ jsx(
2217
+ ContextMenu.Item,
2218
+ {
2219
+ onClick: () => item.onClick(selection.activeCell),
2220
+ disabled: typeof item.disabled === "function" ? item.disabled(selection.activeCell) : item.disabled,
2221
+ danger: item.danger,
2222
+ children: item.label
2223
+ },
2224
+ i
2225
+ ))
2226
+ ] });
2227
+ })()
2192
2228
  ] })
2193
2229
  ] });
2194
2230
  }
2195
2231
  SpreadsheetGrid.displayName = "SpreadsheetGrid";
2196
2232
  var btnClass = "inline-flex items-center justify-center rounded px-2 py-1 text-[12px] font-medium text-zinc-600 transition-colors hover:bg-zinc-100 disabled:opacity-40 dark:text-zinc-300 dark:hover:bg-zinc-800";
2197
2233
  var activeBtnClass = "bg-zinc-200 dark:bg-zinc-700";
2198
- function DefaultToolbar() {
2234
+ function DefaultToolbar({ extra }) {
2199
2235
  const {
2200
2236
  selection,
2201
2237
  activeSheet,
@@ -2387,7 +2423,11 @@ function DefaultToolbar() {
2387
2423
  /* @__PURE__ */ jsx("span", { className: "text-[8px]", children: "\u2192" })
2388
2424
  ]
2389
2425
  }
2390
- )
2426
+ ),
2427
+ extra && /* @__PURE__ */ jsxs(Fragment, { children: [
2428
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-4 w-px bg-zinc-200 dark:bg-zinc-700" }),
2429
+ extra
2430
+ ] })
2391
2431
  ] }),
2392
2432
  /* @__PURE__ */ jsxs("div", { "data-fancy-sheets-formula-bar": "", className: "flex items-center gap-2 border-b border-zinc-200 px-2 py-1 dark:border-zinc-700", children: [
2393
2433
  /* @__PURE__ */ jsx("span", { className: "w-12 shrink-0 text-center text-[11px] font-medium text-zinc-500 dark:text-zinc-400", children: selection.activeCell }),
@@ -2406,8 +2446,8 @@ function DefaultToolbar() {
2406
2446
  ] })
2407
2447
  ] });
2408
2448
  }
2409
- function SpreadsheetToolbar({ children, className }) {
2410
- return /* @__PURE__ */ jsx("div", { "data-fancy-sheets-toolbar": "", className: cn("", className), children: children ?? /* @__PURE__ */ jsx(DefaultToolbar, {}) });
2449
+ function SpreadsheetToolbar({ children, className, extra }) {
2450
+ return /* @__PURE__ */ jsx("div", { "data-fancy-sheets-toolbar": "", className: cn("", className), children: children ?? /* @__PURE__ */ jsx(DefaultToolbar, { extra }) });
2411
2451
  }
2412
2452
  SpreadsheetToolbar.displayName = "SpreadsheetToolbar";
2413
2453
  function SpreadsheetSheetTabs({ className }) {
@@ -2504,7 +2544,8 @@ function SpreadsheetRoot({
2504
2544
  rowCount = 100,
2505
2545
  defaultColumnWidth = 100,
2506
2546
  rowHeight = 28,
2507
- readOnly = false
2547
+ readOnly = false,
2548
+ contextMenuItems
2508
2549
  }) {
2509
2550
  const { state, actions } = useSpreadsheetStore(data ?? defaultData);
2510
2551
  const onChangeRef = useRef(onChange);
@@ -2569,9 +2610,10 @@ function SpreadsheetRoot({
2569
2610
  getColumnWidth,
2570
2611
  isCellSelected,
2571
2612
  isCellActive,
2613
+ contextMenuItems,
2572
2614
  _isDragging: isDraggingRef
2573
2615
  }),
2574
- [state, activeSheet, columnCount, rowCount, defaultColumnWidth, rowHeight, readOnly, actions, getColumnWidth, isCellSelected, isCellActive]
2616
+ [state, activeSheet, columnCount, rowCount, defaultColumnWidth, rowHeight, readOnly, actions, getColumnWidth, isCellSelected, isCellActive, contextMenuItems]
2575
2617
  );
2576
2618
  return /* @__PURE__ */ jsx(SpreadsheetContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
2577
2619
  "div",
@@ -2588,6 +2630,32 @@ var Spreadsheet = Object.assign(SpreadsheetRoot, {
2588
2630
  Grid: SpreadsheetGrid,
2589
2631
  SheetTabs: SpreadsheetSheetTabs
2590
2632
  });
2633
+ function Sheet({ data, onChange, contextMenuItems, ...props }) {
2634
+ const workbook = useMemo(
2635
+ () => data ? { sheets: [data], activeSheetId: data.id } : void 0,
2636
+ [data]
2637
+ );
2638
+ const handleChange = useMemo(() => {
2639
+ if (!onChange) return void 0;
2640
+ return (wb) => onChange(wb.sheets[0]);
2641
+ }, [onChange]);
2642
+ return /* @__PURE__ */ jsx(Spreadsheet, { data: workbook, onChange: handleChange, contextMenuItems, ...props, children: /* @__PURE__ */ jsx(Spreadsheet.Grid, {}) });
2643
+ }
2644
+ Sheet.displayName = "Sheet";
2645
+ function SheetWorkbook({
2646
+ hideToolbar = false,
2647
+ hideTabs = false,
2648
+ toolbarExtra,
2649
+ contextMenuItems,
2650
+ ...props
2651
+ }) {
2652
+ return /* @__PURE__ */ jsxs(Spreadsheet, { ...props, contextMenuItems, children: [
2653
+ !hideToolbar && /* @__PURE__ */ jsx(Spreadsheet.Toolbar, { extra: toolbarExtra }),
2654
+ /* @__PURE__ */ jsx(Spreadsheet.Grid, {}),
2655
+ !hideTabs && /* @__PURE__ */ jsx(Spreadsheet.SheetTabs, {})
2656
+ ] });
2657
+ }
2658
+ SheetWorkbook.displayName = "SheetWorkbook";
2591
2659
 
2592
2660
  // src/engine/csv.ts
2593
2661
  function parseCSV(text) {
@@ -2685,6 +2753,6 @@ function workbookToCSV(workbook, sheetId) {
2685
2753
  return stringifyCSV(data);
2686
2754
  }
2687
2755
 
2688
- export { Spreadsheet, columnToLetter, createEmptySheet, createEmptyWorkbook, csvToWorkbook, letterToColumn, parseAddress, parseCSV, registerFunction, stringifyCSV, toAddress, useSpreadsheet, workbookToCSV };
2756
+ export { Sheet, SheetWorkbook, Spreadsheet, columnToLetter, createEmptySheet, createEmptyWorkbook, csvToWorkbook, letterToColumn, parseAddress, parseCSV, registerFunction, stringifyCSV, toAddress, useSpreadsheet, workbookToCSV };
2689
2757
  //# sourceMappingURL=index.js.map
2690
2758
  //# sourceMappingURL=index.js.map