@xcelsior/ui-spreadsheets 1.0.11 → 1.0.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xcelsior/ui-spreadsheets",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "dependencies": {
@@ -102,6 +102,7 @@ export function Spreadsheet<T extends Record<string, any>>({
102
102
  rowHighlights: externalRowHighlights,
103
103
  cellComments: externalCellComments,
104
104
  rowActions,
105
+ toolbarMenuItems,
105
106
  // Server-side mode props
106
107
  serverSide = false,
107
108
  totalItems,
@@ -595,7 +596,7 @@ export function Spreadsheet<T extends Record<string, any>>({
595
596
  onSave={handleSave}
596
597
  onSettings={() => setShowSettingsModal(true)}
597
598
  onShowShortcuts={() => setShowKeyboardShortcuts(true)}
598
- onExport={() => console.log('Export clicked')}
599
+ menuItems={toolbarMenuItems}
599
600
  />
600
601
  )}
601
602
 
@@ -230,7 +230,7 @@ const SpreadsheetCell: React.FC<SpreadsheetCellProps> = ({
230
230
  className={cn(
231
231
  'flex-1 truncate',
232
232
  isEditable &&
233
- 'cursor-text hover:bg-gray-50 px-0.5 rounded min-h-[18px] flex items-center bg-blue-50'
233
+ 'cursor-text hover:bg-gray-50 px-0.5 rounded min-h-[18px] flex items-center bg-yellow-50/50'
234
234
  )}
235
235
  title={String(value ?? '')}
236
236
  >
@@ -3,7 +3,6 @@ import {
3
3
  HiCheck,
4
4
  HiCog,
5
5
  HiDotsVertical,
6
- HiDownload,
7
6
  HiFilter,
8
7
  HiOutlineQuestionMarkCircle,
9
8
  HiReply,
@@ -56,7 +55,7 @@ export const SpreadsheetToolbar: React.FC<SpreadsheetToolbarProps> = ({
56
55
  onRedo,
57
56
  onClearSelection,
58
57
  onSave,
59
- onExport,
58
+ menuItems,
60
59
  onSettings,
61
60
  onShowShortcuts,
62
61
  hasActiveFilters,
@@ -318,23 +317,33 @@ export const SpreadsheetToolbar: React.FC<SpreadsheetToolbarProps> = ({
318
317
  </button>
319
318
  )}
320
319
 
321
- {(onSettings || onShowShortcuts) && onExport && (
320
+ {/* Custom menu items */}
321
+ {menuItems && menuItems.length > 0 && (onSettings || onShowShortcuts) && (
322
322
  <div className="border-t border-gray-100 my-1" />
323
323
  )}
324
324
 
325
- {onExport && (
325
+ {menuItems?.map((item) => (
326
326
  <button
327
+ key={item.id}
327
328
  type={'button'}
329
+ disabled={item.disabled}
328
330
  onClick={() => {
329
- onExport();
331
+ item.onClick();
330
332
  setShowMoreMenu(false);
331
333
  }}
332
- className="w-full px-3 py-2 text-left hover:bg-gray-50 flex items-center gap-2 text-xs transition-colors"
334
+ className={cn(
335
+ 'w-full px-3 py-2 text-left hover:bg-gray-50 flex items-center gap-2 text-xs transition-colors',
336
+ item.disabled && 'opacity-50 cursor-not-allowed'
337
+ )}
333
338
  >
334
- <HiDownload className="h-3.5 w-3.5 text-gray-500" />
335
- <span className="text-gray-700">Export</span>
339
+ {item.icon && (
340
+ <span className="h-3.5 w-3.5 text-gray-500 flex items-center justify-center">
341
+ {item.icon}
342
+ </span>
343
+ )}
344
+ <span className="text-gray-700">{item.label}</span>
336
345
  </button>
337
- )}
346
+ ))}
338
347
  </div>
339
348
  )}
340
349
  </div>
package/src/index.ts CHANGED
@@ -28,4 +28,5 @@ export type {
28
28
  SelectionState,
29
29
  PaginationState,
30
30
  RowAction,
31
+ ToolbarMenuItem,
31
32
  } from './types';
package/src/types.ts CHANGED
@@ -356,6 +356,8 @@ export interface SpreadsheetProps<T = any> {
356
356
  cellComments?: CellComment[];
357
357
  /** Custom row actions to display in the index column */
358
358
  rowActions?: RowAction<T>[];
359
+ /** Custom menu items to display in the toolbar's "More" dropdown menu */
360
+ toolbarMenuItems?: ToolbarMenuItem[];
359
361
 
360
362
  // ==================== SERVER-SIDE MODE ====================
361
363
  /**
@@ -541,6 +543,22 @@ export interface SpreadsheetPaginationProps {
541
543
  className?: string;
542
544
  }
543
545
 
546
+ /**
547
+ * A menu item that can be added to the toolbar's "More" dropdown menu
548
+ */
549
+ export interface ToolbarMenuItem {
550
+ /** Unique identifier for the menu item */
551
+ id: string;
552
+ /** Display label for the menu item */
553
+ label: string;
554
+ /** Icon component to display (e.g., from react-icons) */
555
+ icon?: React.ReactNode;
556
+ /** Callback when menu item is clicked */
557
+ onClick: () => void;
558
+ /** Whether the menu item is disabled */
559
+ disabled?: boolean;
560
+ }
561
+
544
562
  /**
545
563
  * Props for SpreadsheetToolbar component
546
564
  */
@@ -583,8 +601,8 @@ export interface SpreadsheetToolbarProps {
583
601
  onClearSelection: () => void;
584
602
  /** Callback for manual save */
585
603
  onSave?: () => void;
586
- /** Callback for export */
587
- onExport?: () => void;
604
+ /** Custom menu items to display in the "More" dropdown menu */
605
+ menuItems?: ToolbarMenuItem[];
588
606
  /** Callback for settings */
589
607
  onSettings?: () => void;
590
608
  /** Callback for keyboard shortcuts */