@papernote/ui 1.10.21 → 1.10.23

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 CHANGED
@@ -15057,52 +15057,44 @@ function getAugmentedNamespace(n) {
15057
15057
  * (A1, A1:C5, ...)
15058
15058
  */
15059
15059
 
15060
- var collection;
15061
- var hasRequiredCollection;
15062
-
15063
- function requireCollection () {
15064
- if (hasRequiredCollection) return collection;
15065
- hasRequiredCollection = 1;
15066
- class Collection {
15067
-
15068
- constructor(data, refs) {
15069
- if (data == null && refs == null) {
15070
- this._data = [];
15071
- this._refs = [];
15072
- } else {
15073
- if (data.length !== refs.length)
15074
- throw Error('Collection: data length should match references length.');
15075
- this._data = data;
15076
- this._refs = refs;
15077
- }
15078
- }
15060
+ let Collection$3 = class Collection {
15079
15061
 
15080
- get data() {
15081
- return this._data;
15082
- }
15062
+ constructor(data, refs) {
15063
+ if (data == null && refs == null) {
15064
+ this._data = [];
15065
+ this._refs = [];
15066
+ } else {
15067
+ if (data.length !== refs.length)
15068
+ throw Error('Collection: data length should match references length.');
15069
+ this._data = data;
15070
+ this._refs = refs;
15071
+ }
15072
+ }
15083
15073
 
15084
- get refs() {
15085
- return this._refs;
15086
- }
15074
+ get data() {
15075
+ return this._data;
15076
+ }
15087
15077
 
15088
- get length() {
15089
- return this._data.length;
15090
- }
15078
+ get refs() {
15079
+ return this._refs;
15080
+ }
15091
15081
 
15092
- /**
15093
- * Add data and references to this collection.
15094
- * @param {{}} obj - data
15095
- * @param {{}} ref - reference
15096
- */
15097
- add(obj, ref) {
15098
- this._data.push(obj);
15099
- this._refs.push(ref);
15100
- }
15101
- }
15082
+ get length() {
15083
+ return this._data.length;
15084
+ }
15102
15085
 
15103
- collection = Collection;
15104
- return collection;
15105
- }
15086
+ /**
15087
+ * Add data and references to this collection.
15088
+ * @param {{}} obj - data
15089
+ * @param {{}} ref - reference
15090
+ */
15091
+ add(obj, ref) {
15092
+ this._data.push(obj);
15093
+ this._refs.push(ref);
15094
+ }
15095
+ };
15096
+
15097
+ var collection = Collection$3;
15106
15098
 
15107
15099
  var helpers;
15108
15100
  var hasRequiredHelpers;
@@ -15111,7 +15103,7 @@ function requireHelpers () {
15111
15103
  if (hasRequiredHelpers) return helpers;
15112
15104
  hasRequiredHelpers = 1;
15113
15105
  const FormulaError = requireError();
15114
- const Collection = requireCollection();
15106
+ const Collection = collection;
15115
15107
 
15116
15108
  const Types = {
15117
15109
  NUMBER: 0,
@@ -24765,7 +24757,7 @@ var engineering = EngineeringFunctions;
24765
24757
 
24766
24758
  const FormulaError$b = requireError();
24767
24759
  const {FormulaHelpers: FormulaHelpers$8, Types: Types$6, WildCard, Address: Address$3} = requireHelpers();
24768
- const Collection$2 = requireCollection();
24760
+ const Collection$2 = collection;
24769
24761
  const H$5 = FormulaHelpers$8;
24770
24762
 
24771
24763
  const ReferenceFunctions$1 = {
@@ -36393,7 +36385,7 @@ var parsing = {
36393
36385
  const FormulaError$4 = requireError();
36394
36386
  const {Address: Address$1} = requireHelpers();
36395
36387
  const {Prefix: Prefix$1, Postfix: Postfix$1, Infix: Infix$1, Operators: Operators$1} = operators;
36396
- const Collection$1 = requireCollection();
36388
+ const Collection$1 = collection;
36397
36389
  const MAX_ROW$1 = 1048576, MAX_COLUMN$1 = 16384;
36398
36390
  const {NotAllInputParsedException} = require$$4;
36399
36391
 
@@ -37155,7 +37147,7 @@ var hooks$1 = {
37155
37147
  const FormulaError$2 = requireError();
37156
37148
  const {FormulaHelpers: FormulaHelpers$1, Types, Address} = requireHelpers();
37157
37149
  const {Prefix, Postfix, Infix, Operators} = operators;
37158
- const Collection = requireCollection();
37150
+ const Collection = collection;
37159
37151
  const MAX_ROW = 1048576, MAX_COLUMN = 16384;
37160
37152
 
37161
37153
  let Utils$1 = class Utils {
@@ -39074,6 +39066,30 @@ const colIndexToLetter = (index) => {
39074
39066
  };
39075
39067
  // Note: parseRef is available for future formula reference parsing
39076
39068
  // const parseRef = (ref: string): { row: number; col: number } | null => { ... }
39069
+ /**
39070
+ * Color banding for column groups (e.g., comparison columns)
39071
+ * Alternates between color sets to visually distinguish groups
39072
+ */
39073
+ const COLUMN_GROUP_COLORS = [
39074
+ { header: 'bg-sky-100', cell: 'bg-sky-50', cellAlt: 'bg-sky-100/50' },
39075
+ { header: 'bg-amber-100', cell: 'bg-amber-50', cellAlt: 'bg-amber-100/50' },
39076
+ { header: 'bg-emerald-100', cell: 'bg-emerald-50', cellAlt: 'bg-emerald-100/50' },
39077
+ { header: 'bg-pink-100', cell: 'bg-pink-50', cellAlt: 'bg-pink-100/50' },
39078
+ ];
39079
+ /**
39080
+ * Build a map of group names to color indices for column banding
39081
+ */
39082
+ const buildGroupColorMap = (columns) => {
39083
+ const groupColorMap = new Map();
39084
+ let colorIndex = 0;
39085
+ for (const col of columns) {
39086
+ if (col.group && !groupColorMap.has(col.group)) {
39087
+ groupColorMap.set(col.group, colorIndex % COLUMN_GROUP_COLORS.length);
39088
+ colorIndex++;
39089
+ }
39090
+ }
39091
+ return groupColorMap;
39092
+ };
39077
39093
  /**
39078
39094
  * DataGrid - Excel-like data grid component with formulas
39079
39095
  *
@@ -39143,6 +39159,34 @@ const DataGrid = React.forwardRef(({ data: initialData, columns, onChange, rowHe
39143
39159
  return frozenRowsState;
39144
39160
  return 0;
39145
39161
  }, [frozenRowsState, selectedCell]);
39162
+ // Build group color map for column banding
39163
+ const groupColorMap = React.useMemo(() => buildGroupColorMap(columns), [columns]);
39164
+ // Get header background class for a column (considers group banding)
39165
+ const getHeaderBgClass = React.useCallback((column) => {
39166
+ if (column.group) {
39167
+ const colorIdx = groupColorMap.get(column.group);
39168
+ if (colorIdx !== undefined) {
39169
+ return COLUMN_GROUP_COLORS[colorIdx].header;
39170
+ }
39171
+ }
39172
+ return 'bg-stone-100';
39173
+ }, [groupColorMap]);
39174
+ // Get cell background class for a column (considers group banding and zebra)
39175
+ const getCellBgClass = React.useCallback((column, isZebra, isFrozenCol) => {
39176
+ if (column.group) {
39177
+ const colorIdx = groupColorMap.get(column.group);
39178
+ if (colorIdx !== undefined) {
39179
+ const colors = COLUMN_GROUP_COLORS[colorIdx];
39180
+ return isZebra ? colors.cellAlt : colors.cell;
39181
+ }
39182
+ }
39183
+ // Default behavior
39184
+ if (isZebra && isFrozenCol)
39185
+ return 'bg-paper-50';
39186
+ if (isFrozenCol)
39187
+ return 'bg-white';
39188
+ return '';
39189
+ }, [groupColorMap]);
39146
39190
  // Check if a specific row is frozen
39147
39191
  const isRowFrozen = React.useCallback((rowIndex) => {
39148
39192
  if (frozenRowsState === 'none')
@@ -39517,7 +39561,8 @@ const DataGrid = React.forwardRef(({ data: initialData, columns, onChange, rowHe
39517
39561
  }) })), jsxRuntime.jsx("div", { ref: tableRef, className: "relative overflow-auto border border-stone-200 rounded-lg bg-white", style: { height }, onKeyDown: handleKeyDown, tabIndex: 0, children: jsxRuntime.jsxs("table", { className: "border-collapse", style: { tableLayout: 'auto' }, children: [jsxRuntime.jsx("thead", { className: "sticky top-0 z-20 bg-stone-100", children: jsxRuntime.jsxs("tr", { children: [rowHeaders && (jsxRuntime.jsx("th", { className: `${cellPadding} border-b border-r border-stone-200 bg-stone-100 text-left font-semibold text-ink-600 sticky left-0 z-30`, style: { width: 50, minWidth: 50, maxWidth: 50 }, children: "#" })), columns.map((column, colIndex) => {
39518
39562
  const isFrozen = colIndex < frozenColumns;
39519
39563
  const leftOffset = rowHeaders ? 50 + columns.slice(0, colIndex).reduce((sum, c) => sum + (c.width || 100), 0) : columns.slice(0, colIndex).reduce((sum, c) => sum + (c.width || 100), 0);
39520
- return (jsxRuntime.jsx("th", { className: `${cellPadding} border-b border-r border-stone-200 bg-stone-100 font-semibold text-ink-600 text-${column.align || 'left'} ${isFrozen ? 'sticky z-30' : ''}`, style: {
39564
+ const headerBgClass = getHeaderBgClass(column);
39565
+ return (jsxRuntime.jsx("th", { className: `${cellPadding} border-b border-r border-stone-200 ${headerBgClass} font-semibold text-ink-600 text-${column.align || 'left'} ${isFrozen ? 'sticky z-30' : ''}`, style: {
39521
39566
  width: column.width,
39522
39567
  minWidth: column.minWidth || 80,
39523
39568
  left: isFrozen ? leftOffset : undefined,
@@ -39543,7 +39588,8 @@ const DataGrid = React.forwardRef(({ data: initialData, columns, onChange, rowHe
39543
39588
  const leftOffset = rowHeaders
39544
39589
  ? 50 + columns.slice(0, colIndex).reduce((sum, c) => sum + (c.width || 100), 0)
39545
39590
  : columns.slice(0, colIndex).reduce((sum, c) => sum + (c.width || 100), 0);
39546
- return (jsxRuntime.jsx("td", { className: `${cellPadding} border-b border-r border-stone-200 text-${column?.align || 'left'} ${isFrozenCol ? 'sticky z-10' : ''} ${isZebra && isFrozenCol ? 'bg-paper-50' : isFrozenCol ? 'bg-white' : ''} ${isSelected ? 'ring-2 ring-inset ring-primary-500' : ''} ${hasFormula ? 'bg-blue-50' : ''} ${cell?.className || ''}`, style: {
39591
+ const cellBgClass = getCellBgClass(column, isZebra, isFrozenCol);
39592
+ return (jsxRuntime.jsx("td", { className: `${cellPadding} border-b border-r border-stone-200 text-${column?.align || 'left'} ${isFrozenCol ? 'sticky z-10' : ''} ${cellBgClass} ${isSelected ? 'ring-2 ring-inset ring-primary-500' : ''} ${hasFormula ? 'bg-blue-50' : ''} ${cell?.className || ''}`, style: {
39547
39593
  left: isFrozenCol ? leftOffset : undefined,
39548
39594
  minWidth: column?.minWidth || 80,
39549
39595
  }, onClick: () => handleCellClick(rowIndex, colIndex), onDoubleClick: (e) => handleCellDoubleClick(rowIndex, colIndex, e.currentTarget), children: isEditing ? (formulas ? (jsxRuntime.jsx(FormulaAutocomplete, { value: editValue, onChange: setEditValue, onComplete: handleEditComplete, onCancel: handleEditCancel, anchorRect: editingCellRect, autoFocus: true })) : (jsxRuntime.jsx("input", { ref: inputRef, type: "text", value: editValue, onChange: (e) => setEditValue(e.target.value), onBlur: handleEditComplete, onKeyDown: handleEditKeyDown, className: "w-full h-full border-none outline-none bg-transparent", style: { margin: '-4px', padding: '4px' } }))) : (formatValue(cell?.value, column)) }, colIndex));