@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.mjs
CHANGED
|
@@ -3832,6 +3832,42 @@ function Spreadsheet({
|
|
|
3832
3832
|
const handleRowIndexHighlightClick = useCallback7(() => {
|
|
3833
3833
|
setHighlightPickerColumn(ROW_INDEX_COLUMN_ID);
|
|
3834
3834
|
}, [setHighlightPickerColumn]);
|
|
3835
|
+
const columnRenderItems = useMemo5(() => {
|
|
3836
|
+
if (!columnGroups || columnGroups.length === 0) {
|
|
3837
|
+
return visibleColumns.map((col) => ({
|
|
3838
|
+
type: "column",
|
|
3839
|
+
column: col
|
|
3840
|
+
}));
|
|
3841
|
+
}
|
|
3842
|
+
const items = [];
|
|
3843
|
+
for (const group of columnGroups) {
|
|
3844
|
+
const isCollapsed = collapsedGroups.has(group.id);
|
|
3845
|
+
if (isCollapsed) {
|
|
3846
|
+
items.push({
|
|
3847
|
+
type: "collapsed-placeholder",
|
|
3848
|
+
groupId: group.id,
|
|
3849
|
+
headerColor: group.headerColor
|
|
3850
|
+
});
|
|
3851
|
+
}
|
|
3852
|
+
const groupVisibleCols = (columns || []).filter((c) => {
|
|
3853
|
+
if (!group.columns.includes(c.id)) return false;
|
|
3854
|
+
if (isCollapsed) return pinnedColumns.has(c.id);
|
|
3855
|
+
return true;
|
|
3856
|
+
});
|
|
3857
|
+
for (const col of groupVisibleCols) {
|
|
3858
|
+
items.push({ type: "column", column: col });
|
|
3859
|
+
}
|
|
3860
|
+
}
|
|
3861
|
+
const allGroupedIds = new Set(
|
|
3862
|
+
columnGroups.flatMap((g) => g.columns)
|
|
3863
|
+
);
|
|
3864
|
+
for (const col of visibleColumns) {
|
|
3865
|
+
if (!allGroupedIds.has(col.id)) {
|
|
3866
|
+
items.push({ type: "column", column: col });
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
return items;
|
|
3870
|
+
}, [columnGroups, collapsedGroups, columns, pinnedColumns, visibleColumns]);
|
|
3835
3871
|
return /* @__PURE__ */ jsxs12("div", { className: cn("flex flex-col h-full bg-white", className), children: [
|
|
3836
3872
|
showToolbar && /* @__PURE__ */ jsx12(
|
|
3837
3873
|
SpreadsheetToolbar,
|
|
@@ -3867,9 +3903,7 @@ function Spreadsheet({
|
|
|
3867
3903
|
"div",
|
|
3868
3904
|
{
|
|
3869
3905
|
style: {
|
|
3870
|
-
|
|
3871
|
-
transformOrigin: "top left",
|
|
3872
|
-
width: `${100 / (zoom / 100)}%`
|
|
3906
|
+
zoom: zoom / 100
|
|
3873
3907
|
},
|
|
3874
3908
|
children: /* @__PURE__ */ jsxs12("table", { className: "w-full border-separate border-spacing-0 text-xs select-none", children: [
|
|
3875
3909
|
/* @__PURE__ */ jsxs12("thead", { children: [
|
|
@@ -3930,7 +3964,22 @@ function Spreadsheet({
|
|
|
3930
3964
|
compactMode: effectiveCompactMode
|
|
3931
3965
|
}
|
|
3932
3966
|
),
|
|
3933
|
-
|
|
3967
|
+
columnRenderItems.map((item) => {
|
|
3968
|
+
if (item.type === "collapsed-placeholder") {
|
|
3969
|
+
return /* @__PURE__ */ jsx12(
|
|
3970
|
+
"th",
|
|
3971
|
+
{
|
|
3972
|
+
className: "border border-gray-200 px-2 py-1 text-center text-gray-400",
|
|
3973
|
+
style: {
|
|
3974
|
+
backgroundColor: item.headerColor || "rgb(243 244 246)",
|
|
3975
|
+
minWidth: "30px"
|
|
3976
|
+
},
|
|
3977
|
+
children: "..."
|
|
3978
|
+
},
|
|
3979
|
+
`${item.groupId}-placeholder`
|
|
3980
|
+
);
|
|
3981
|
+
}
|
|
3982
|
+
const column = item.column;
|
|
3934
3983
|
const isPinnedLeft = isColumnPinned(column.id) && getColumnPinSide(column.id) === "left";
|
|
3935
3984
|
const isPinnedRight = isColumnPinned(column.id) && getColumnPinSide(column.id) === "right";
|
|
3936
3985
|
return /* @__PURE__ */ jsx12(
|
|
@@ -3969,7 +4018,7 @@ function Spreadsheet({
|
|
|
3969
4018
|
/* @__PURE__ */ jsx12("tbody", { children: isLoading ? /* @__PURE__ */ jsx12("tr", { children: /* @__PURE__ */ jsx12(
|
|
3970
4019
|
"td",
|
|
3971
4020
|
{
|
|
3972
|
-
colSpan:
|
|
4021
|
+
colSpan: columnRenderItems.length + 1,
|
|
3973
4022
|
className: "text-center py-8 text-gray-500",
|
|
3974
4023
|
children: /* @__PURE__ */ jsxs12("div", { className: "flex items-center justify-center gap-2", children: [
|
|
3975
4024
|
/* @__PURE__ */ jsx12("div", { className: "w-4 h-4 border-2 border-blue-600 border-t-transparent rounded-full animate-spin" }),
|
|
@@ -3979,7 +4028,7 @@ function Spreadsheet({
|
|
|
3979
4028
|
) }) : paginatedData.length === 0 ? /* @__PURE__ */ jsx12("tr", { children: /* @__PURE__ */ jsx12(
|
|
3980
4029
|
"td",
|
|
3981
4030
|
{
|
|
3982
|
-
colSpan:
|
|
4031
|
+
colSpan: columnRenderItems.length + 1,
|
|
3983
4032
|
className: "text-center py-8 text-gray-500",
|
|
3984
4033
|
children: emptyMessage
|
|
3985
4034
|
}
|
|
@@ -4124,7 +4173,20 @@ function Spreadsheet({
|
|
|
4124
4173
|
] })
|
|
4125
4174
|
}
|
|
4126
4175
|
),
|
|
4127
|
-
|
|
4176
|
+
columnRenderItems.map((item) => {
|
|
4177
|
+
if (item.type === "collapsed-placeholder") {
|
|
4178
|
+
return /* @__PURE__ */ jsx12(
|
|
4179
|
+
"td",
|
|
4180
|
+
{
|
|
4181
|
+
className: "border border-gray-200 px-2 py-1 text-center text-gray-300",
|
|
4182
|
+
style: {
|
|
4183
|
+
backgroundColor: item.headerColor || "rgb(243 244 246)"
|
|
4184
|
+
}
|
|
4185
|
+
},
|
|
4186
|
+
`${item.groupId}-placeholder`
|
|
4187
|
+
);
|
|
4188
|
+
}
|
|
4189
|
+
const column = item.column;
|
|
4128
4190
|
const value = column.getValue ? column.getValue(row) : row[column.id];
|
|
4129
4191
|
const isEditing = editingCell?.rowId === rowId && editingCell?.columnId === column.id;
|
|
4130
4192
|
const isFocused = focusedCell?.rowId === rowId && focusedCell?.columnId === column.id;
|
|
@@ -4159,7 +4221,9 @@ function Spreadsheet({
|
|
|
4159
4221
|
isPinned: isColPinned,
|
|
4160
4222
|
pinSide: colPinSide,
|
|
4161
4223
|
leftOffset: getColumnLeftOffset(column.id),
|
|
4162
|
-
rightOffset: getColumnRightOffset(
|
|
4224
|
+
rightOffset: getColumnRightOffset(
|
|
4225
|
+
column.id
|
|
4226
|
+
),
|
|
4163
4227
|
onClick: (e) => handleCellClick(rowId, column.id, e),
|
|
4164
4228
|
onConfirm: handleConfirmEdit,
|
|
4165
4229
|
onCancel: handleCancelEdit,
|