@ricsam/react-spreadsheets 0.0.6 → 0.0.7
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/README.md +52 -0
- package/dist/cjs/lib.cjs +24 -26
- package/dist/cjs/lib.cjs.map +3 -3
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/lib.mjs +24 -26
- package/dist/mjs/lib.mjs.map +3 -3
- package/dist/mjs/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,6 +86,58 @@ export function Demo() {
|
|
|
86
86
|
`FormulaWorkbook` adds Excel-style sheet tabs, renaming, deletion and zoom on
|
|
87
87
|
top of `FormulaSheet`.
|
|
88
88
|
|
|
89
|
+
### Formula reference highlights
|
|
90
|
+
|
|
91
|
+
Keep editor-driven reference highlights separate from the user's spreadsheet
|
|
92
|
+
selection. `FormulaSheet` calls `customCellStyle` with both the cell and its
|
|
93
|
+
engine-provided style, so a host can add a transient range fill and perimeter
|
|
94
|
+
without replacing table or conditional formatting:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
type Highlight = {
|
|
98
|
+
start: { rowIndex: number; colIndex: number };
|
|
99
|
+
end: { rowIndex: number; colIndex: number };
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function ReferenceAwareSheet({ highlight }: { highlight?: Highlight }) {
|
|
103
|
+
return (
|
|
104
|
+
<FormulaSheet
|
|
105
|
+
engine={engine}
|
|
106
|
+
workbookName="Workbook1"
|
|
107
|
+
sheetName="Sheet1"
|
|
108
|
+
style={{ height: 480 }}
|
|
109
|
+
customCellStyle={(cell, internalStyle) => {
|
|
110
|
+
if (
|
|
111
|
+
!highlight ||
|
|
112
|
+
cell.rowIndex < highlight.start.rowIndex ||
|
|
113
|
+
cell.rowIndex > highlight.end.rowIndex ||
|
|
114
|
+
cell.colIndex < highlight.start.colIndex ||
|
|
115
|
+
cell.colIndex > highlight.end.colIndex
|
|
116
|
+
) {
|
|
117
|
+
return internalStyle;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const color = "#7c3aed";
|
|
121
|
+
return {
|
|
122
|
+
...internalStyle,
|
|
123
|
+
backgroundColor: "rgb(124 58 237 / 14%)",
|
|
124
|
+
...(cell.rowIndex === highlight.start.rowIndex && { borderTopColor: color }),
|
|
125
|
+
...(cell.rowIndex === highlight.end.rowIndex && { borderBottomColor: color }),
|
|
126
|
+
...(cell.colIndex === highlight.start.colIndex && { borderLeftColor: color }),
|
|
127
|
+
...(cell.colIndex === highlight.end.colIndex && { borderRightColor: color }),
|
|
128
|
+
};
|
|
129
|
+
}}
|
|
130
|
+
/>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Update `highlight` from the formula editor's caret/reference analysis. Clearing
|
|
136
|
+
it removes the decoration, while the selection manager continues to own mouse,
|
|
137
|
+
keyboard and edit selection state independently. For `FormulaWorkbook`, pass a
|
|
138
|
+
controlled `activeSheet` if the editor should reveal a reference on another
|
|
139
|
+
sheet; the same `customCellStyle` prop is forwarded to its active sheet.
|
|
140
|
+
|
|
89
141
|
## Theming
|
|
90
142
|
|
|
91
143
|
All colors, fonts and sizes are CSS custom properties. The package only ever
|
package/dist/cjs/lib.cjs
CHANGED
|
@@ -3642,31 +3642,29 @@ function FormulaSheet({
|
|
|
3642
3642
|
workbookName
|
|
3643
3643
|
});
|
|
3644
3644
|
if (!tableInfo) {
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
}
|
|
3669
|
-
return {};
|
|
3645
|
+
const style2 = conditionalStyle ? {
|
|
3646
|
+
...conditionalStyle.backgroundColor && {
|
|
3647
|
+
backgroundColor: conditionalStyle.backgroundColor
|
|
3648
|
+
},
|
|
3649
|
+
...conditionalStyle.color && {
|
|
3650
|
+
color: conditionalStyle.color
|
|
3651
|
+
},
|
|
3652
|
+
...conditionalStyle.fontSize && {
|
|
3653
|
+
fontSize: conditionalStyle.fontSize
|
|
3654
|
+
},
|
|
3655
|
+
...conditionalStyle.bold && {
|
|
3656
|
+
fontWeight: "bold"
|
|
3657
|
+
},
|
|
3658
|
+
...conditionalStyle.italic && {
|
|
3659
|
+
fontStyle: "italic"
|
|
3660
|
+
},
|
|
3661
|
+
...conditionalStyle.underline && {
|
|
3662
|
+
textDecoration: "underline"
|
|
3663
|
+
},
|
|
3664
|
+
...getBorderCellStyle(conditionalStyle),
|
|
3665
|
+
...getWrapCellStyle(conditionalStyle)
|
|
3666
|
+
} : {};
|
|
3667
|
+
return customCellStyle ? customCellStyle(cell, style2) : style2;
|
|
3670
3668
|
}
|
|
3671
3669
|
const isHeaderRow = cell.rowIndex === tableInfo.start.rowIndex;
|
|
3672
3670
|
const isFirstColumn = cell.colIndex === tableInfo.start.colIndex;
|
|
@@ -4163,4 +4161,4 @@ var useClickAway = (ref, callback) => {
|
|
|
4163
4161
|
}, [ref, callback]);
|
|
4164
4162
|
};
|
|
4165
4163
|
|
|
4166
|
-
//# debugId=
|
|
4164
|
+
//# debugId=4874F9DF8699906864756E2164756E21
|