@xcelsior/ui-spreadsheets 1.1.9 → 1.1.10
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.js +72 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +72 -8
- package/dist/index.mjs.map +1 -1
- package/dist/styles/globals.css +3 -0
- package/dist/styles/globals.css.map +1 -1
- package/package.json +1 -1
- package/src/components/Spreadsheet.stories.tsx +102 -17
- package/src/components/Spreadsheet.tsx +94 -9
package/dist/index.js
CHANGED
|
@@ -3874,6 +3874,42 @@ function Spreadsheet({
|
|
|
3874
3874
|
const handleRowIndexHighlightClick = (0, import_react17.useCallback)(() => {
|
|
3875
3875
|
setHighlightPickerColumn(ROW_INDEX_COLUMN_ID);
|
|
3876
3876
|
}, [setHighlightPickerColumn]);
|
|
3877
|
+
const columnRenderItems = (0, import_react17.useMemo)(() => {
|
|
3878
|
+
if (!columnGroups || columnGroups.length === 0) {
|
|
3879
|
+
return visibleColumns.map((col) => ({
|
|
3880
|
+
type: "column",
|
|
3881
|
+
column: col
|
|
3882
|
+
}));
|
|
3883
|
+
}
|
|
3884
|
+
const items = [];
|
|
3885
|
+
for (const group of columnGroups) {
|
|
3886
|
+
const isCollapsed = collapsedGroups.has(group.id);
|
|
3887
|
+
if (isCollapsed) {
|
|
3888
|
+
items.push({
|
|
3889
|
+
type: "collapsed-placeholder",
|
|
3890
|
+
groupId: group.id,
|
|
3891
|
+
headerColor: group.headerColor
|
|
3892
|
+
});
|
|
3893
|
+
}
|
|
3894
|
+
const groupVisibleCols = (columns || []).filter((c) => {
|
|
3895
|
+
if (!group.columns.includes(c.id)) return false;
|
|
3896
|
+
if (isCollapsed) return pinnedColumns.has(c.id);
|
|
3897
|
+
return true;
|
|
3898
|
+
});
|
|
3899
|
+
for (const col of groupVisibleCols) {
|
|
3900
|
+
items.push({ type: "column", column: col });
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
const allGroupedIds = new Set(
|
|
3904
|
+
columnGroups.flatMap((g) => g.columns)
|
|
3905
|
+
);
|
|
3906
|
+
for (const col of visibleColumns) {
|
|
3907
|
+
if (!allGroupedIds.has(col.id)) {
|
|
3908
|
+
items.push({ type: "column", column: col });
|
|
3909
|
+
}
|
|
3910
|
+
}
|
|
3911
|
+
return items;
|
|
3912
|
+
}, [columnGroups, collapsedGroups, columns, pinnedColumns, visibleColumns]);
|
|
3877
3913
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: cn("flex flex-col h-full bg-white", className), children: [
|
|
3878
3914
|
showToolbar && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3879
3915
|
SpreadsheetToolbar,
|
|
@@ -3909,9 +3945,7 @@ function Spreadsheet({
|
|
|
3909
3945
|
"div",
|
|
3910
3946
|
{
|
|
3911
3947
|
style: {
|
|
3912
|
-
|
|
3913
|
-
transformOrigin: "top left",
|
|
3914
|
-
width: `${100 / (zoom / 100)}%`
|
|
3948
|
+
zoom: zoom / 100
|
|
3915
3949
|
},
|
|
3916
3950
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { className: "w-full border-separate border-spacing-0 text-xs select-none", children: [
|
|
3917
3951
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("thead", { children: [
|
|
@@ -3972,7 +4006,22 @@ function Spreadsheet({
|
|
|
3972
4006
|
compactMode: effectiveCompactMode
|
|
3973
4007
|
}
|
|
3974
4008
|
),
|
|
3975
|
-
|
|
4009
|
+
columnRenderItems.map((item) => {
|
|
4010
|
+
if (item.type === "collapsed-placeholder") {
|
|
4011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4012
|
+
"th",
|
|
4013
|
+
{
|
|
4014
|
+
className: "border border-gray-200 px-2 py-1 text-center text-gray-400",
|
|
4015
|
+
style: {
|
|
4016
|
+
backgroundColor: item.headerColor || "rgb(243 244 246)",
|
|
4017
|
+
minWidth: "30px"
|
|
4018
|
+
},
|
|
4019
|
+
children: "..."
|
|
4020
|
+
},
|
|
4021
|
+
`${item.groupId}-placeholder`
|
|
4022
|
+
);
|
|
4023
|
+
}
|
|
4024
|
+
const column = item.column;
|
|
3976
4025
|
const isPinnedLeft = isColumnPinned(column.id) && getColumnPinSide(column.id) === "left";
|
|
3977
4026
|
const isPinnedRight = isColumnPinned(column.id) && getColumnPinSide(column.id) === "right";
|
|
3978
4027
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
@@ -4011,7 +4060,7 @@ function Spreadsheet({
|
|
|
4011
4060
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4012
4061
|
"td",
|
|
4013
4062
|
{
|
|
4014
|
-
colSpan:
|
|
4063
|
+
colSpan: columnRenderItems.length + 1,
|
|
4015
4064
|
className: "text-center py-8 text-gray-500",
|
|
4016
4065
|
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-center gap-2", children: [
|
|
4017
4066
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "w-4 h-4 border-2 border-blue-600 border-t-transparent rounded-full animate-spin" }),
|
|
@@ -4021,7 +4070,7 @@ function Spreadsheet({
|
|
|
4021
4070
|
) }) : paginatedData.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4022
4071
|
"td",
|
|
4023
4072
|
{
|
|
4024
|
-
colSpan:
|
|
4073
|
+
colSpan: columnRenderItems.length + 1,
|
|
4025
4074
|
className: "text-center py-8 text-gray-500",
|
|
4026
4075
|
children: emptyMessage
|
|
4027
4076
|
}
|
|
@@ -4166,7 +4215,20 @@ function Spreadsheet({
|
|
|
4166
4215
|
] })
|
|
4167
4216
|
}
|
|
4168
4217
|
),
|
|
4169
|
-
|
|
4218
|
+
columnRenderItems.map((item) => {
|
|
4219
|
+
if (item.type === "collapsed-placeholder") {
|
|
4220
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
4221
|
+
"td",
|
|
4222
|
+
{
|
|
4223
|
+
className: "border border-gray-200 px-2 py-1 text-center text-gray-300",
|
|
4224
|
+
style: {
|
|
4225
|
+
backgroundColor: item.headerColor || "rgb(243 244 246)"
|
|
4226
|
+
}
|
|
4227
|
+
},
|
|
4228
|
+
`${item.groupId}-placeholder`
|
|
4229
|
+
);
|
|
4230
|
+
}
|
|
4231
|
+
const column = item.column;
|
|
4170
4232
|
const value = column.getValue ? column.getValue(row) : row[column.id];
|
|
4171
4233
|
const isEditing = editingCell?.rowId === rowId && editingCell?.columnId === column.id;
|
|
4172
4234
|
const isFocused = focusedCell?.rowId === rowId && focusedCell?.columnId === column.id;
|
|
@@ -4201,7 +4263,9 @@ function Spreadsheet({
|
|
|
4201
4263
|
isPinned: isColPinned,
|
|
4202
4264
|
pinSide: colPinSide,
|
|
4203
4265
|
leftOffset: getColumnLeftOffset(column.id),
|
|
4204
|
-
rightOffset: getColumnRightOffset(
|
|
4266
|
+
rightOffset: getColumnRightOffset(
|
|
4267
|
+
column.id
|
|
4268
|
+
),
|
|
4205
4269
|
onClick: (e) => handleCellClick(rowId, column.id, e),
|
|
4206
4270
|
onConfirm: handleConfirmEdit,
|
|
4207
4271
|
onCancel: handleCancelEdit,
|