@xcelsior/ui-spreadsheets 1.1.8 → 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.d.mts CHANGED
@@ -23,6 +23,10 @@ interface SpreadsheetColumn<T = any> {
23
23
  editable?: boolean;
24
24
  /** Whether the column can be pinned */
25
25
  pinnable?: boolean;
26
+ /** Whether the column can be highlighted (defaults to true) */
27
+ highlightable?: boolean;
28
+ /** Whether the column can have comments (defaults to true) */
29
+ commentable?: boolean;
26
30
  /** Type of data in the column (for filtering/formatting) */
27
31
  type?: 'text' | 'number' | 'date' | 'select' | 'boolean' | 'checkbox';
28
32
  /** Options for select type columns */
package/dist/index.d.ts CHANGED
@@ -23,6 +23,10 @@ interface SpreadsheetColumn<T = any> {
23
23
  editable?: boolean;
24
24
  /** Whether the column can be pinned */
25
25
  pinnable?: boolean;
26
+ /** Whether the column can be highlighted (defaults to true) */
27
+ highlightable?: boolean;
28
+ /** Whether the column can have comments (defaults to true) */
29
+ commentable?: boolean;
26
30
  /** Type of data in the column (for filtering/formatting) */
27
31
  type?: 'text' | 'number' | 'date' | 'select' | 'boolean' | 'checkbox';
28
32
  /** Options for select type columns */
package/dist/index.js CHANGED
@@ -419,7 +419,7 @@ var SpreadsheetCell = ({
419
419
  }
420
420
  ),
421
421
  !isInSelection && !isFocused && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex items-center gap-0.5 shrink-0", children: [
422
- onHighlight && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
422
+ column.highlightable !== false && onHighlight && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
423
423
  "button",
424
424
  {
425
425
  type: "button",
@@ -440,7 +440,7 @@ var SpreadsheetCell = ({
440
440
  )
441
441
  }
442
442
  ),
443
- hasComments && onViewComments ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
443
+ column.commentable !== false && hasComments && onViewComments ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
444
444
  "button",
445
445
  {
446
446
  type: "button",
@@ -455,7 +455,7 @@ var SpreadsheetCell = ({
455
455
  unresolvedCommentCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-[9px] font-medium text-amber-600", children: unresolvedCommentCount > 99 ? "99+" : unresolvedCommentCount })
456
456
  ]
457
457
  }
458
- ) : onAddComment ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
458
+ ) : column.commentable !== false && onAddComment ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
459
459
  "button",
460
460
  {
461
461
  type: "button",
@@ -1258,7 +1258,7 @@ var SpreadsheetHeader = ({
1258
1258
  ColumnHeaderActions,
1259
1259
  {
1260
1260
  enableFiltering: column.filterable,
1261
- enableHighlighting: !!onHighlightClick,
1261
+ enableHighlighting: column.highlightable !== false && !!onHighlightClick,
1262
1262
  enablePinning: column.pinnable !== false,
1263
1263
  hasActiveFilter,
1264
1264
  hasActiveHighlight: !!highlightColor,
@@ -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
- transform: `scale(${zoom / 100})`,
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
- visibleColumns.map((column) => {
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: visibleColumns.length + 1,
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: visibleColumns.length + 1,
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
- visibleColumns.map((column) => {
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(column.id),
4266
+ rightOffset: getColumnRightOffset(
4267
+ column.id
4268
+ ),
4205
4269
  onClick: (e) => handleCellClick(rowId, column.id, e),
4206
4270
  onConfirm: handleConfirmEdit,
4207
4271
  onCancel: handleCancelEdit,