@xcelsior/ui-spreadsheets 1.0.7 → 1.0.9
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/CHANGELOG.md +6 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +67 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/CommentModals.tsx +58 -0
- package/src/components/Spreadsheet.stories.tsx +15 -0
- package/src/components/Spreadsheet.tsx +25 -1
- package/src/components/SpreadsheetCell.tsx +6 -2
- package/src/types.ts +2 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -253,6 +253,8 @@ interface SpreadsheetProps<T = any> {
|
|
|
253
253
|
onRowDoubleClick?: (row: T, rowIndex: number) => void;
|
|
254
254
|
/** Callback when a row is cloned/duplicated */
|
|
255
255
|
onRowClone?: (row: T, rowId: string | number) => void;
|
|
256
|
+
/** Callback when a row is deleted */
|
|
257
|
+
onRowDelete?: (row: T, rowId: string | number) => void;
|
|
256
258
|
/** Callback when a cell comment is added */
|
|
257
259
|
onAddCellComment?: (rowId: string | number, columnId: string, comment: string) => void;
|
|
258
260
|
/** Callback when row highlight is toggled */
|
|
@@ -554,7 +556,7 @@ interface SpreadsheetColumnGroupHeaderProps {
|
|
|
554
556
|
* />
|
|
555
557
|
* ```
|
|
556
558
|
*/
|
|
557
|
-
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onAddCellComment, onRowHighlight, showToolbar, showPagination, showRowIndex, enableRowSelection, enableCellEditing, enableComments, enableHighlighting, enableUndoRedo, defaultPageSize, pageSizeOptions, defaultZoom, autoSave, compactMode, isLoading, className, emptyMessage, rowHighlights: externalRowHighlights, cellComments: externalCellComments, rowActions, serverSide, totalItems, currentPage: controlledCurrentPage, pageSize: controlledPageSize, onPageChange, sortConfig: controlledSortConfig, filters: controlledFilters, }: SpreadsheetProps<T>): react_jsx_runtime.JSX.Element;
|
|
559
|
+
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onRowDelete, onAddCellComment, onRowHighlight, showToolbar, showPagination, showRowIndex, enableRowSelection, enableCellEditing, enableComments, enableHighlighting, enableUndoRedo, defaultPageSize, pageSizeOptions, defaultZoom, autoSave, compactMode, isLoading, className, emptyMessage, rowHighlights: externalRowHighlights, cellComments: externalCellComments, rowActions, serverSide, totalItems, currentPage: controlledCurrentPage, pageSize: controlledPageSize, onPageChange, sortConfig: controlledSortConfig, filters: controlledFilters, }: SpreadsheetProps<T>): react_jsx_runtime.JSX.Element;
|
|
558
560
|
declare namespace Spreadsheet {
|
|
559
561
|
var displayName: string;
|
|
560
562
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -253,6 +253,8 @@ interface SpreadsheetProps<T = any> {
|
|
|
253
253
|
onRowDoubleClick?: (row: T, rowIndex: number) => void;
|
|
254
254
|
/** Callback when a row is cloned/duplicated */
|
|
255
255
|
onRowClone?: (row: T, rowId: string | number) => void;
|
|
256
|
+
/** Callback when a row is deleted */
|
|
257
|
+
onRowDelete?: (row: T, rowId: string | number) => void;
|
|
256
258
|
/** Callback when a cell comment is added */
|
|
257
259
|
onAddCellComment?: (rowId: string | number, columnId: string, comment: string) => void;
|
|
258
260
|
/** Callback when row highlight is toggled */
|
|
@@ -554,7 +556,7 @@ interface SpreadsheetColumnGroupHeaderProps {
|
|
|
554
556
|
* />
|
|
555
557
|
* ```
|
|
556
558
|
*/
|
|
557
|
-
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onAddCellComment, onRowHighlight, showToolbar, showPagination, showRowIndex, enableRowSelection, enableCellEditing, enableComments, enableHighlighting, enableUndoRedo, defaultPageSize, pageSizeOptions, defaultZoom, autoSave, compactMode, isLoading, className, emptyMessage, rowHighlights: externalRowHighlights, cellComments: externalCellComments, rowActions, serverSide, totalItems, currentPage: controlledCurrentPage, pageSize: controlledPageSize, onPageChange, sortConfig: controlledSortConfig, filters: controlledFilters, }: SpreadsheetProps<T>): react_jsx_runtime.JSX.Element;
|
|
559
|
+
declare function Spreadsheet<T extends Record<string, any>>({ data, columns, columnGroups, getRowId, onCellEdit, onSelectionChange, onSortChange, onFilterChange, onRowClick, onRowDoubleClick, onRowClone, onRowDelete, onAddCellComment, onRowHighlight, showToolbar, showPagination, showRowIndex, enableRowSelection, enableCellEditing, enableComments, enableHighlighting, enableUndoRedo, defaultPageSize, pageSizeOptions, defaultZoom, autoSave, compactMode, isLoading, className, emptyMessage, rowHighlights: externalRowHighlights, cellComments: externalCellComments, rowActions, serverSide, totalItems, currentPage: controlledCurrentPage, pageSize: controlledPageSize, onPageChange, sortConfig: controlledSortConfig, filters: controlledFilters, }: SpreadsheetProps<T>): react_jsx_runtime.JSX.Element;
|
|
558
560
|
declare namespace Spreadsheet {
|
|
559
561
|
var displayName: string;
|
|
560
562
|
}
|
package/dist/index.js
CHANGED
|
@@ -152,6 +152,9 @@ function HiReply(props) {
|
|
|
152
152
|
function HiSortAscending(props) {
|
|
153
153
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M3 3a1 1 0 000 2h11a1 1 0 100-2H3zM3 7a1 1 0 000 2h5a1 1 0 000-2H3zM3 11a1 1 0 100 2h4a1 1 0 100-2H3zM13 16a1 1 0 102 0v-5.586l1.293 1.293a1 1 0 001.414-1.414l-3-3a1 1 0 00-1.414 0l-3 3a1 1 0 101.414 1.414L13 10.414V16z" } }] })(props);
|
|
154
154
|
}
|
|
155
|
+
function HiTrash(props) {
|
|
156
|
+
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "fillRule": "evenodd", "d": "M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z", "clipRule": "evenodd" } }] })(props);
|
|
157
|
+
}
|
|
155
158
|
function HiViewBoards(props) {
|
|
156
159
|
return GenIcon({ "tag": "svg", "attr": { "viewBox": "0 0 20 20", "fill": "currentColor", "aria-hidden": "true" }, "child": [{ "tag": "path", "attr": { "d": "M2 4a1 1 0 011-1h2a1 1 0 011 1v12a1 1 0 01-1 1H3a1 1 0 01-1-1V4zM8 4a1 1 0 011-1h2a1 1 0 011 1v12a1 1 0 01-1 1H9a1 1 0 01-1-1V4zM15 3a1 1 0 00-1 1v12a1 1 0 001 1h2a1 1 0 001-1V4a1 1 0 00-1-1h-2z" } }] })(props);
|
|
157
160
|
}
|
|
@@ -317,8 +320,12 @@ var SpreadsheetCell = ({
|
|
|
317
320
|
},
|
|
318
321
|
onKeyDown: handleKeyDown,
|
|
319
322
|
onBlur: () => onConfirm?.(localValue),
|
|
323
|
+
autoComplete: "off",
|
|
324
|
+
autoCorrect: "off",
|
|
325
|
+
autoCapitalize: "off",
|
|
326
|
+
spellCheck: false,
|
|
320
327
|
className: cn(
|
|
321
|
-
"w-full border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500 bg-
|
|
328
|
+
"w-full border border-gray-300 rounded text-xs focus:outline-none focus:ring-1 focus:ring-blue-500 bg-[#edf7ff]",
|
|
322
329
|
compactMode ? "px-1 py-0.5" : "px-2 py-1"
|
|
323
330
|
)
|
|
324
331
|
}
|
|
@@ -368,7 +375,7 @@ var SpreadsheetCell = ({
|
|
|
368
375
|
{
|
|
369
376
|
className: cn(
|
|
370
377
|
"flex-1 truncate",
|
|
371
|
-
isEditable && "cursor-text hover:bg-gray-50 px-0.5 rounded min-h-[18px] flex items-center bg-
|
|
378
|
+
isEditable && "cursor-text hover:bg-gray-50 px-0.5 rounded min-h-[18px] flex items-center bg-[#edf7ff]/50"
|
|
372
379
|
),
|
|
373
380
|
title: String(value ?? ""),
|
|
374
381
|
children: renderContent()
|
|
@@ -2167,6 +2174,44 @@ function ViewCommentsModal({
|
|
|
2167
2174
|
] }) });
|
|
2168
2175
|
}
|
|
2169
2176
|
ViewCommentsModal.displayName = "ViewCommentsModal";
|
|
2177
|
+
function DeleteConfirmationModal({
|
|
2178
|
+
isOpen,
|
|
2179
|
+
title = "Delete Row",
|
|
2180
|
+
message = "Are you sure you want to delete this row? This action cannot be undone.",
|
|
2181
|
+
confirmLabel = "Delete",
|
|
2182
|
+
onConfirm,
|
|
2183
|
+
onClose
|
|
2184
|
+
}) {
|
|
2185
|
+
if (!isOpen) return null;
|
|
2186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "bg-white rounded-lg shadow-xl p-6 w-96 max-w-full mx-4", children: [
|
|
2187
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { className: "text-lg font-semibold mb-2", children: title }),
|
|
2188
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "text-gray-600 mb-6", children: message }),
|
|
2189
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex justify-end gap-2", children: [
|
|
2190
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2191
|
+
"button",
|
|
2192
|
+
{
|
|
2193
|
+
type: "button",
|
|
2194
|
+
onClick: onClose,
|
|
2195
|
+
className: "px-4 py-2 text-gray-600 hover:bg-gray-100 rounded-lg transition-colors",
|
|
2196
|
+
children: "Cancel"
|
|
2197
|
+
}
|
|
2198
|
+
),
|
|
2199
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
2200
|
+
"button",
|
|
2201
|
+
{
|
|
2202
|
+
type: "button",
|
|
2203
|
+
onClick: () => {
|
|
2204
|
+
onConfirm();
|
|
2205
|
+
onClose();
|
|
2206
|
+
},
|
|
2207
|
+
className: "px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 transition-colors",
|
|
2208
|
+
children: confirmLabel
|
|
2209
|
+
}
|
|
2210
|
+
)
|
|
2211
|
+
] })
|
|
2212
|
+
] }) });
|
|
2213
|
+
}
|
|
2214
|
+
DeleteConfirmationModal.displayName = "DeleteConfirmationModal";
|
|
2170
2215
|
|
|
2171
2216
|
// src/components/KeyboardShortcutsModal.tsx
|
|
2172
2217
|
var import_react10 = __toESM(require("react"));
|
|
@@ -2833,6 +2878,7 @@ function Spreadsheet({
|
|
|
2833
2878
|
onRowClick,
|
|
2834
2879
|
onRowDoubleClick,
|
|
2835
2880
|
onRowClone,
|
|
2881
|
+
onRowDelete,
|
|
2836
2882
|
onAddCellComment,
|
|
2837
2883
|
onRowHighlight,
|
|
2838
2884
|
showToolbar = true,
|
|
@@ -3221,6 +3267,12 @@ function Spreadsheet({
|
|
|
3221
3267
|
},
|
|
3222
3268
|
[onRowClone]
|
|
3223
3269
|
);
|
|
3270
|
+
const handleRowDelete = (0, import_react15.useCallback)(
|
|
3271
|
+
(row, rowId) => {
|
|
3272
|
+
onRowDelete?.(row, rowId);
|
|
3273
|
+
},
|
|
3274
|
+
[onRowDelete]
|
|
3275
|
+
);
|
|
3224
3276
|
const handleRowIndexHighlightClick = (0, import_react15.useCallback)(() => {
|
|
3225
3277
|
setHighlightPickerColumn(ROW_INDEX_COLUMN_ID);
|
|
3226
3278
|
}, [setHighlightPickerColumn]);
|
|
@@ -3424,6 +3476,19 @@ function Spreadsheet({
|
|
|
3424
3476
|
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HiDuplicate, { className: "h-2.5 w-2.5 text-gray-500" })
|
|
3425
3477
|
}
|
|
3426
3478
|
),
|
|
3479
|
+
onRowDelete && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3480
|
+
"button",
|
|
3481
|
+
{
|
|
3482
|
+
type: "button",
|
|
3483
|
+
onClick: (e) => {
|
|
3484
|
+
e.stopPropagation();
|
|
3485
|
+
handleRowDelete(row, rowId);
|
|
3486
|
+
},
|
|
3487
|
+
className: "opacity-0 group-hover:opacity-100 transition-opacity p-0.5 bg-gray-100 hover:bg-red-100 rounded",
|
|
3488
|
+
title: "Delete row",
|
|
3489
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(HiTrash, { className: "h-2.5 w-2.5 text-gray-500 hover:text-red-500" })
|
|
3490
|
+
}
|
|
3491
|
+
),
|
|
3427
3492
|
enableHighlighting && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
3428
3493
|
"button",
|
|
3429
3494
|
{
|