@olympusoss/canvas 2.6.27 → 2.6.28

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": "@olympusoss/canvas",
3
- "version": "2.6.27",
3
+ "version": "2.6.28",
4
4
  "type": "module",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- import { GripVertical } from "lucide-react";
3
+ import { GripVertical, Trash2 } from "lucide-react";
4
4
  import * as React from "react";
5
5
  import type { Layout, Layouts } from "react-grid-layout";
6
6
  import GridLayout from "react-grid-layout";
@@ -332,24 +332,33 @@ export const DashboardGrid = React.forwardRef<HTMLDivElement, DashboardGridProps
332
332
  preventCollision={false}
333
333
  >
334
334
  {items.map((item) => (
335
- <div key={item.i} className="group/dashboard-grid-item flex flex-col overflow-hidden">
335
+ <div key={item.i} className="group/dashboard-grid-item relative h-full overflow-hidden">
336
+ {/* Inner wrapper forces the rendered widget to fill the cell —
337
+ consumers shouldn't have to add `h-full` to every card just to
338
+ make rows align. Kept separate from the drag handle so the
339
+ `*:h-full *:w-full` rule doesn't blow up the absolute handle. */}
340
+ <div className="h-full w-full *:h-full *:w-full">{renderItem(item)}</div>
336
341
  {editing && (
337
- <div
338
- role="button"
339
- tabIndex={0}
340
- className="dashboard-grid-handle flex h-7 shrink-0 cursor-grab items-center justify-center rounded-t-xl border-b border-border bg-muted/30 text-muted-foreground active:cursor-grabbing"
341
- aria-label={`Drag ${item.i}`}
342
- >
343
- <GripVertical className="h-3.5 w-3.5" />
344
- </div>
342
+ <>
343
+ <div
344
+ role="button"
345
+ tabIndex={0}
346
+ className="dashboard-grid-handle absolute right-2 top-2 z-10 flex h-6 w-6 cursor-grab items-center justify-center rounded-md border border-border bg-background/80 text-muted-foreground shadow-sm backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground active:cursor-grabbing"
347
+ aria-label={`Drag ${item.i}`}
348
+ >
349
+ <GripVertical className="h-3.5 w-3.5" />
350
+ </div>
351
+ <button
352
+ type="button"
353
+ onClick={() => onItemsChange?.(items.filter((it) => it.i !== item.i))}
354
+ className="absolute bottom-2 left-1/2 z-10 flex h-7 -translate-x-1/2 items-center gap-1.5 rounded-md border border-border bg-background/80 px-2.5 text-xs font-medium text-destructive shadow-sm backdrop-blur-sm transition-colors hover:bg-destructive hover:text-destructive-foreground"
355
+ aria-label={`Remove ${item.i}`}
356
+ >
357
+ <Trash2 className="h-3.5 w-3.5" />
358
+ Remove
359
+ </button>
360
+ </>
345
361
  )}
346
- {/* The inner wrapper forces ANY direct child of the rendered widget to
347
- fill the cell (`*:h-full *:w-full`). This is the grid's job, not the
348
- widget's — consumers shouldn't have to add `h-full` to every card just
349
- to make rows align. */}
350
- <div className="min-h-0 flex-1 overflow-hidden *:h-full *:w-full">
351
- {renderItem(item)}
352
- </div>
353
362
  </div>
354
363
  ))}
355
364
  </ResponsiveGridLayout>